@phil65/demoreel 0.6.0 → 0.7.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.
Files changed (37) hide show
  1. package/README.md +8 -5
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/args.js +1 -1
  4. package/dist/cli.js +3 -3
  5. package/dist/compose.d.ts +9 -1
  6. package/dist/compose.js +38 -3
  7. package/dist/idle.js +1 -1
  8. package/dist/index.d.ts +3 -3
  9. package/dist/index.js +2 -2
  10. package/dist/layout.d.ts +10 -1
  11. package/dist/layout.js +41 -0
  12. package/dist/marks.d.ts +7 -12
  13. package/dist/marks.js +73 -43
  14. package/dist/mcp.js +2 -2
  15. package/dist/project.d.ts +261 -11
  16. package/dist/project.js +255 -8
  17. package/dist/record.js +8 -0
  18. package/dist/renderer/assets/{CanvasPool-PBu3bHFZ.js → CanvasPool-SkgMbnEH.js} +1 -1
  19. package/dist/renderer/assets/{CanvasRenderer-HmF-4gyW.js → CanvasRenderer-CEGuSdsG.js} +1 -1
  20. package/dist/renderer/assets/{RenderTargetSystem-Dk1U4wDJ.js → RenderTargetSystem-um8Nv1HQ.js} +1 -1
  21. package/dist/renderer/assets/{WebGLRenderer-C0v9HBel.js → WebGLRenderer-BnY2xfDL.js} +1 -1
  22. package/dist/renderer/assets/{WebGPURenderer-Ce0-U9Q1.js → WebGPURenderer-D9KI_sD9.js} +1 -1
  23. package/dist/renderer/assets/{browserAll-DhvWQ7nM.js → browserAll-vQt6iTAv.js} +1 -1
  24. package/dist/renderer/assets/{canvasUtils-KRroregW.js → canvasUtils-CZLntkW8.js} +1 -1
  25. package/dist/renderer/assets/{getTexelRangeRects-D3pwCyRt.js → getTexelRangeRects-CRAnqulP.js} +1 -1
  26. package/dist/renderer/assets/{index-CE-lli1m.js → index-41-d13J1.js} +4 -4
  27. package/dist/renderer/assets/{init-DfmWKarH.js → init-D6nA7FlC.js} +1 -1
  28. package/dist/renderer/assets/webworkerAll-BEIrFubI.js +1 -0
  29. package/dist/renderer/index.html +1 -1
  30. package/dist/scene.d.ts +93 -1
  31. package/dist/scene.js +177 -3
  32. package/dist/types.d.ts +73 -1
  33. package/dist/voice.d.ts +18 -6
  34. package/dist/voice.js +74 -6
  35. package/package.json +2 -2
  36. package/skills/demoreel/SKILL.md +6 -2
  37. package/dist/renderer/assets/webworkerAll-B41hok0-.js +0 -1
@@ -1 +1 @@
1
- import{Ct as e,Dt as t,Et as n,K as r,L as i,O as a,St as o,a as s,ct as c,dt as l,et as u,i as d,lt as f,nt as p,o as m,q as h,r as g,s as _,t as v}from"./index-CE-lli1m.js";import{a as y,c as b,i as x,l as S,o as C,r as w,s as T,t as E}from"./RenderTargetSystem-Dk1U4wDJ.js";import{n as D,t as O}from"./canvasUtils-KRroregW.js";var k=class e{static _getPatternRepeat(e,t){let n=e&&e!==`clamp-to-edge`,r=t&&t!==`clamp-to-edge`;return n&&r?`repeat`:n?`repeat-x`:r?`repeat-y`:`no-repeat`}start(e,t,n){}execute(t,n){let r=n.elements;if(!r||!r.length)return;let i=t.renderer,a=i.canvasContext,s=a.activeContext;for(let t=0;t<r.length;t++){let c=r[t];if(!c.packAsQuad)continue;let l=c,d=l.texture,f=d?O.getCanvasSource(d):null;if(!f)continue;let m=d.source.style,h=a.smoothProperty,g=m.scaleMode!==`nearest`;s[h]!==g&&(s[h]=g),a.setBlendMode(n.blendMode);let _=i.globalUniforms.globalUniformData?.worldColor??0xffffffff,v=l.color,y=(_>>>24&255)/255,b=(v>>>24&255)/255,x=i.filter?.alphaMultiplier??1,S=y*b*x;if(S<=0)continue;s.globalAlpha=S;let C=_&0xffffff,w=v&0xffffff,T=u(p(w,C)),E=d.frame,D=m.addressModeU??m.addressMode,k=m.addressModeV??m.addressMode,A=e._getPatternRepeat(D,k),j=d.source._resolution??d.source.resolution??1,M=l.renderable?.renderGroup?.isCachedAsTexture,N=E.x*j,P=E.y*j,F=E.width*j,I=E.height*j,L=l.bounds,R=i.renderTarget.renderTarget.isRoot,z=L.minX,B=L.minY,V=L.maxX-L.minX,H=L.maxY-L.minY,U=d.rotate,W=d.uvs,G=Math.min(W.x0,W.x1,W.x2,W.x3,W.y0,W.y1,W.y2,W.y3),K=Math.max(W.x0,W.x1,W.x2,W.x3,W.y0,W.y1,W.y2,W.y3),q=A!==`no-repeat`&&(G<0||K>1),J=U&&(!!q||T===0xffffff&&!U);J?(e._tempPatternMatrix.copyFrom(l.transform),o.matrixAppendRotationInv(e._tempPatternMatrix,U,z,B,V,H),a.setContextTransform(e._tempPatternMatrix,l.roundPixels===1,void 0,M&&R)):a.setContextTransform(l.transform,l.roundPixels===1,void 0,M&&R);let Y=V,X=H,Z=J?0:z,Q=J?0:B;if(!J&&l.roundPixels===1&&(Z|=0,Q|=0),q){let t=f,n=T!==0xffffff&&!U,r=E.width<=d.source.width&&E.height<=d.source.height;n&&r&&(t=O.getTintedCanvas({texture:d},T));let i=s.createPattern(t,A);if(!i)continue;let a=Y,o=X;if(a===0||o===0)continue;let c=1/a,l=1/o,u=(W.x1-W.x0)*c,p=(W.y1-W.y0)*c,m=(W.x3-W.x0)*l,h=(W.y3-W.y0)*l,g=W.x0-u*Z-m*Q,_=W.y0-p*Z-h*Q,v=d.source.pixelWidth,y=d.source.pixelHeight;e._tempPatternMatrix.set(u*v,p*y,m*v,h*y,g*v,_*y),O.applyPatternTransform(i,e._tempPatternMatrix),s.fillStyle=i,s.fillRect(Z,Q,Y,X)}else{let e=T!==0xffffff||U?O.getTintedCanvas({texture:d},T):f,t=e!==f;s.drawImage(e,t?0:N,t?0:P,t?e.width:F,t?e.height:I,Z,Q,Y,X)}}}};k._tempPatternMatrix=new e,k.extension={type:[n.CanvasPipesAdaptor],name:`batch`};var A=k,j=class{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);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}};j.extension={type:[n.CanvasPipes],name:`colorMask`};function M(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function N(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;M(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.moveTo(n.x+n.radius,n.y),e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?(e.moveTo(n.x+n.halfWidth,n.y),e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2)):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.moveTo(1,0),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function P(e,t,n){let r=[],i=[],a=[];if(!d[t.type]?.build(t,r))return!1;let o=t.closePath??!0;_(r,n,!1,o,i,a);for(let t=0;t<a.length;t+=3){let n=a[t]*2,r=a[t+1]*2,o=a[t+2]*2;e.moveTo(i[n],i[n+1]),e.lineTo(i[r],i[r+1]),e.lineTo(i[o],i[o+1]),e.closePath()}return!0}function F(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),N(e,r.shape),a&&e.restore()}return!0}var I=class{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(e.action!==`pushMaskBegin`&&e.action!==`popMaskEnd`)return;let t=this._renderer,n=t.canvasContext,r=n?.activeContext;if(!r)return;if(e.action===`popMaskEnd`){this._canvasMaskStack.pop()&&r.restore();return}e.inverse&&this._warnOnce(`inverse`,`CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.`);let i=e.mask.mask;if(!(i instanceof v)){this._warnOnce(`nonGraphics`,`CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask.`),this._canvasMaskStack.push(!1);return}let a=i,o=a.context?.instructions;if(!o?.length){this._canvasMaskStack.push(!1);return}r.save(),n.setContextTransform(a.groupTransform,(t._roundPixels|a._roundPixels)===1),r.beginPath();let s=!1,c=!1;for(let e=0;e<o.length;e++){let t=o[e],n=t.action;if(n!==`fill`&&n!==`stroke`)continue;let i=t.data,a=i?.path?.shapePath;if(!a?.shapePrimitives?.length)continue;let l=n===`stroke`,u=a.shapePrimitives;for(let e=0;e<u.length;e++){let t=u[e];if(!t?.shape)continue;let n=t.transform,a=n&&!n.isIdentity();a&&(r.save(),r.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),l&&i.style?s=P(r,t.shape,i.style)||s:(N(r,t.shape),c=F(r,t.holes)||c,s=!0),a&&r.restore()}}s?(c?r.clip(`evenodd`):r.clip(),this._canvasMaskStack.push(!0)):(r.restore(),this._canvasMaskStack.push(!1))}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),c(t))}};I.extension={type:[n.CanvasPipes],name:`stencilMask`};var L=`source-over`;function R(){let e=D(),t=Object.create(null);return t.inherit=L,t.none=L,t.normal=`source-over`,t.add=`lighter`,t.multiply=e?`multiply`:L,t.screen=e?`screen`:L,t.overlay=e?`overlay`:L,t.darken=e?`darken`:L,t.lighten=e?`lighten`:L,t[`color-dodge`]=e?`color-dodge`:L,t[`color-burn`]=e?`color-burn`:L,t[`hard-light`]=e?`hard-light`:L,t[`soft-light`]=e?`soft-light`:L,t.difference=e?`difference`:L,t.exclusion=e?`exclusion`:L,t.saturation=e?`saturation`:L,t.color=e?`color`:L,t.luminosity=e?`luminosity`:L,t[`linear-burn`]=e?`color-burn`:L,t[`linear-dodge`]=e?`color-dodge`:L,t[`linear-light`]=e?`hard-light`:L,t[`pin-light`]=e?`hard-light`:L,t[`vivid-light`]=e?`hard-light`:L,t[`hard-mix`]=L,t.negation=e?`difference`:L,t[`normal-npm`]=t.normal,t[`add-npm`]=t.add,t[`screen-npm`]=t.screen,t.erase=`destination-out`,t.subtract=L,t.divide=L,t.min=L,t.max=L,t}var z=new e,B=class{constructor(e){this.activeResolution=1,this.smoothProperty=`imageSmoothingEnabled`,this.blendModes=R(),this._activeBlendMode=`normal`,this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){let 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){let e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty=`webkitImageSmoothingEnabled`:e.mozImageSmoothingEnabled?this.smoothProperty=`mozImageSmoothingEnabled`:e.oImageSmoothingEnabled?this.smoothProperty=`oImageSmoothingEnabled`:e.msImageSmoothingEnabled&&(this.smoothProperty=`msImageSmoothingEnabled`)}}setContextTransform(t,n,r,i){let a=i?e.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||e.IDENTITY,o=z;o.copyFrom(a),o.append(t);let s=this._projTransform,c=this.activeResolution;if(r||=c,s){let t=e.shared;t.copyFrom(o),t.prepend(s),o=t}n?this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*c|0,o.ty*c|0):this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*c,o.ty*c)}clear(e,t){let n=this.activeContext,r=this._renderer;if(n.clearRect(0,0,r.width,r.height),e){let i=f.shared.setValue(e);n.globalAlpha=t??i.alpha,n.fillStyle=i.toHex(),n.fillRect(0,0,r.width,r.height),n.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;let t=this.blendModes[e];t?this.activeContext.globalCompositeOperation=t:(this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation=`source-over`)}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}};B.extension={type:[n.CanvasSystem],name:`canvasContext`};var V=class{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0,this.minUniformBufferOffsetAlignment=0}init(){}};V.extension={type:[n.CanvasSystem],name:`limits`};var H=`#808080`,U=new e,W=new e,G=new e,K=new e,q=new e;function J(e,t,n){e.beginPath();for(let r=0;r<n.length;r+=3){let i=n[r]*2,a=n[r+1]*2,o=n[r+2]*2;e.moveTo(t[i],t[i+1]),e.lineTo(t[a],t[a+1]),e.lineTo(t[o],t[o+1]),e.closePath()}e.fill()}function Y(e){return`#${(e&0xffffff).toString(16).padStart(6,`0`)}`}function X(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function Z(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;X(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function Q(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),Z(e,r.shape),a&&e.restore()}return!0}function ee(e,t,n,r){let i=e.fill;if(i instanceof m){i.buildGradient();let a=i.texture;if(a){let o=O.getTintedPattern(a,t),s=n?K.copyFrom(n).scale(a.source.pixelWidth,a.source.pixelHeight):K.copyFrom(i.transform);return r&&!e.textureSpace&&s.append(r),O.applyPatternTransform(o,s),o}}if(i instanceof g){let e=O.getTintedPattern(i.texture,t);return O.applyPatternTransform(e,i.transform,!1),e}let a=e.texture;if(a&&a!==l.WHITE){if(!a.source.resource)return H;let r=O.getTintedPattern(a,t),i=e.matrix;if(n){let{resolution:e}=a.source;if(i=K.copyFrom(n),a.rotate){let{uvs:t,orig:n}=a;i.prepend(q.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0).invert()).scale(n.width*e,n.height*e)}else i.scale(a.source.pixelWidth,a.source.pixelHeight).translate(-a.frame.x*e,-a.frame.y*e)}return O.applyPatternTransform(r,i),r}return Y(t)}var $=class{constructor(){this.shader=null}contextChange(e){}execute(e,t){let n=e.renderer,r=n.canvasContext,i=r.activeContext,a=t.groupTransform,c=n.globalUniforms.globalUniformData?.worldColor??0xffffffff,f=t.groupColorAlpha,m=(c>>>24&255)/255,h=(f>>>24&255)/255,g=n.filter?.alphaMultiplier??1,v=m*h*g;if(v<=0)return;let y=c&0xffffff,b=f&0xffffff,x=u(p(b,y)),S=n._roundPixels|t._roundPixels;i.save(),r.setContextTransform(a,S===1),r.setBlendMode(t.groupBlendMode);let C=t.context.instructions;for(let e=0;e<C.length;e++){let t=C[e];if(t.action===`texture`){let e=t.data,n=e.image,s=n?O.getCanvasSource(n):null;if(!s)continue;let c=e.alpha*v;if(c<=0)continue;let l=p(e.style,x);i.globalAlpha=c;let u=s;l!==0xffffff&&(u=O.getTintedCanvas({texture:n},l));let d=n.frame,f=n.source._resolution??n.source.resolution??1,m=d.x*f,h=d.y*f,g=d.width*f,_=d.height*f;u!==s&&(m=0,h=0);let y=e.transform,b=y&&!y.isIdentity(),C=n.rotate;b||C?(U.copyFrom(a),b&&U.append(y),C&&o.matrixAppendRotationInv(U,C,e.dx,e.dy,e.dw,e.dh),r.setContextTransform(U,S===1)):r.setContextTransform(a,S===1),i.drawImage(u,m,h,u===s?g:u.width,u===s?_:u.height,C?0:e.dx,C?0:e.dy,e.dw,e.dh),(b||C)&&r.setContextTransform(a,S===1);continue}let n=t.data,c=n?.path?.shapePath;if(!c?.shapePrimitives?.length)continue;let u=n.style,f=p(u.color,x),m=u.alpha*v;if(m<=0)continue;let h=t.action===`stroke`;if(i.globalAlpha=m,h){let e=u;i.lineWidth=e.width,i.lineCap=e.cap,i.lineJoin=e.join,i.miterLimit=e.miterLimit}let g=c.shapePrimitives;if(!h&&n.hole?.shapePath?.shapePrimitives?.length){let e=g[g.length-1];e.holes=n.hole.shapePath.shapePrimitives}for(let e=0;e<g.length;e++){let t=g[e];if(!t?.shape)continue;let n=t.transform,r=n&&!n.isIdentity(),o=u.texture&&u.texture!==l.WHITE,c=u.textureSpace===`global`?n:null,p=ee(u,f,o?s(W,u,t.shape,c):null,r?G.copyFrom(a).append(n):a);if(r&&(i.save(),i.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),h){let e=u;if(e.alignment!==.5&&!e.pixelLine){let n=[],r=[],a=[];if(d[t.shape.type]?.build(t.shape,n)){let o=t.shape.closePath??!0;_(n,e,!1,o,r,a),i.fillStyle=p,J(i,r,a)}else i.strokeStyle=p,i.beginPath(),Z(i,t.shape),i.stroke()}else i.strokeStyle=p,i.beginPath(),Z(i,t.shape),i.stroke()}else i.fillStyle=p,i.beginPath(),Z(i,t.shape),Q(i,t.holes)?i.fill(`evenodd`):i.fill();r&&i.restore()}}i.restore()}destroy(){this.shader=null}};$.extension={type:[n.CanvasPipesAdaptor],name:`graphics`};var te=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){let t=e.colorTexture,{canvas:n,context:r}=this._ensureCanvas(t);return{canvas:n,context:r,width:n.width,height:n.height}}resizeGpuRenderTarget(e){let t=e.colorTexture,{canvas:n}=this._ensureCanvas(t);n.width=e.pixelWidth,n.height=e.pixelHeight}startRenderPass(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=i.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,n,r)}clear(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e).context,a=r||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(i.setTransform(1,0,0,1,0,0),i.clearRect(a.x,a.y,a.width,a.height),n){let e=f.shared.setValue(n);e.alpha>0&&(i.globalAlpha=e.alpha,i.fillStyle=e.toHex(),i.fillRect(a.x,a.y,a.width,a.height),i.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,n,r,i){let a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,o=t.source,{context:s}=this._ensureCanvas(o),c=i?.x??0,l=i?.y??0;return s.drawImage(a,n.x,n.y,r.width,r.height,c,l,r.width,r.height),o.update(),t}copyDepthTexture(e,t,n,r,i){c(`[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer`)}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;t&&r.test(t)||(t=h.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);let n=t.getContext(`2d`);return{canvas:t,context:n}}},ne=class extends E{constructor(e){super(e),this.adaptor=new te,this.adaptor.init(e,this)}};ne.extension={type:[n.CanvasSystem],name:`renderTarget`};var re=class{constructor(e){}init(){}initSource(e){}generateCanvas(e){let t=h.get().createCanvas(),n=t.getContext(`2d`),r=O.getCanvasSource(e);if(!r)return t;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.x*a,s=i.y*a,c=i.width*a,l=i.height*a;return t.width=Math.ceil(c),t.height=Math.ceil(l),n.drawImage(r,o,s,c,l,0,0,c,l),t}getPixels(e){let 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(){}};re.extension={type:[n.CanvasSystem],name:`texture`};var ie=[...w,B,V,re,ne],ae=[x,S,y,C,b,I,j,T],oe=[A,$],se=[],ce=[],le=[],ue=[];t.handleByNamedList(n.CanvasSystem,se),t.handleByNamedList(n.CanvasPipes,ce),t.handleByNamedList(n.CanvasPipesAdaptor,le),t.handleByNamedList(n.CanvasLoader,ue),t.add(...ie,...ae,...oe);var de=class extends a{constructor(){let e={name:`canvas`,type:i.CANVAS,systems:se,renderPipes:ce,renderPipeAdaptors:le,loaders:ue};super(e)}};export{de as CanvasRenderer};
1
+ import{Ct as e,Dt as t,Et as n,K as r,L as i,O as a,St as o,a as s,ct as c,dt as l,et as u,i as d,lt as f,nt as p,o as m,q as h,r as g,s as _,t as v}from"./index-41-d13J1.js";import{a as y,c as b,i as x,l as S,o as C,r as w,s as T,t as E}from"./RenderTargetSystem-um8Nv1HQ.js";import{n as D,t as O}from"./canvasUtils-CZLntkW8.js";var k=class e{static _getPatternRepeat(e,t){let n=e&&e!==`clamp-to-edge`,r=t&&t!==`clamp-to-edge`;return n&&r?`repeat`:n?`repeat-x`:r?`repeat-y`:`no-repeat`}start(e,t,n){}execute(t,n){let r=n.elements;if(!r||!r.length)return;let i=t.renderer,a=i.canvasContext,s=a.activeContext;for(let t=0;t<r.length;t++){let c=r[t];if(!c.packAsQuad)continue;let l=c,d=l.texture,f=d?O.getCanvasSource(d):null;if(!f)continue;let m=d.source.style,h=a.smoothProperty,g=m.scaleMode!==`nearest`;s[h]!==g&&(s[h]=g),a.setBlendMode(n.blendMode);let _=i.globalUniforms.globalUniformData?.worldColor??0xffffffff,v=l.color,y=(_>>>24&255)/255,b=(v>>>24&255)/255,x=i.filter?.alphaMultiplier??1,S=y*b*x;if(S<=0)continue;s.globalAlpha=S;let C=_&0xffffff,w=v&0xffffff,T=u(p(w,C)),E=d.frame,D=m.addressModeU??m.addressMode,k=m.addressModeV??m.addressMode,A=e._getPatternRepeat(D,k),j=d.source._resolution??d.source.resolution??1,M=l.renderable?.renderGroup?.isCachedAsTexture,N=E.x*j,P=E.y*j,F=E.width*j,I=E.height*j,L=l.bounds,R=i.renderTarget.renderTarget.isRoot,z=L.minX,B=L.minY,V=L.maxX-L.minX,H=L.maxY-L.minY,U=d.rotate,W=d.uvs,G=Math.min(W.x0,W.x1,W.x2,W.x3,W.y0,W.y1,W.y2,W.y3),K=Math.max(W.x0,W.x1,W.x2,W.x3,W.y0,W.y1,W.y2,W.y3),q=A!==`no-repeat`&&(G<0||K>1),J=U&&(!!q||T===0xffffff&&!U);J?(e._tempPatternMatrix.copyFrom(l.transform),o.matrixAppendRotationInv(e._tempPatternMatrix,U,z,B,V,H),a.setContextTransform(e._tempPatternMatrix,l.roundPixels===1,void 0,M&&R)):a.setContextTransform(l.transform,l.roundPixels===1,void 0,M&&R);let Y=V,X=H,Z=J?0:z,Q=J?0:B;if(!J&&l.roundPixels===1&&(Z|=0,Q|=0),q){let t=f,n=T!==0xffffff&&!U,r=E.width<=d.source.width&&E.height<=d.source.height;n&&r&&(t=O.getTintedCanvas({texture:d},T));let i=s.createPattern(t,A);if(!i)continue;let a=Y,o=X;if(a===0||o===0)continue;let c=1/a,l=1/o,u=(W.x1-W.x0)*c,p=(W.y1-W.y0)*c,m=(W.x3-W.x0)*l,h=(W.y3-W.y0)*l,g=W.x0-u*Z-m*Q,_=W.y0-p*Z-h*Q,v=d.source.pixelWidth,y=d.source.pixelHeight;e._tempPatternMatrix.set(u*v,p*y,m*v,h*y,g*v,_*y),O.applyPatternTransform(i,e._tempPatternMatrix),s.fillStyle=i,s.fillRect(Z,Q,Y,X)}else{let e=T!==0xffffff||U?O.getTintedCanvas({texture:d},T):f,t=e!==f;s.drawImage(e,t?0:N,t?0:P,t?e.width:F,t?e.height:I,Z,Q,Y,X)}}}};k._tempPatternMatrix=new e,k.extension={type:[n.CanvasPipesAdaptor],name:`batch`};var A=k,j=class{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);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}};j.extension={type:[n.CanvasPipes],name:`colorMask`};function M(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function N(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;M(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.moveTo(n.x+n.radius,n.y),e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?(e.moveTo(n.x+n.halfWidth,n.y),e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2)):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.moveTo(1,0),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function P(e,t,n){let r=[],i=[],a=[];if(!d[t.type]?.build(t,r))return!1;let o=t.closePath??!0;_(r,n,!1,o,i,a);for(let t=0;t<a.length;t+=3){let n=a[t]*2,r=a[t+1]*2,o=a[t+2]*2;e.moveTo(i[n],i[n+1]),e.lineTo(i[r],i[r+1]),e.lineTo(i[o],i[o+1]),e.closePath()}return!0}function F(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),N(e,r.shape),a&&e.restore()}return!0}var I=class{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(e.action!==`pushMaskBegin`&&e.action!==`popMaskEnd`)return;let t=this._renderer,n=t.canvasContext,r=n?.activeContext;if(!r)return;if(e.action===`popMaskEnd`){this._canvasMaskStack.pop()&&r.restore();return}e.inverse&&this._warnOnce(`inverse`,`CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.`);let i=e.mask.mask;if(!(i instanceof v)){this._warnOnce(`nonGraphics`,`CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask.`),this._canvasMaskStack.push(!1);return}let a=i,o=a.context?.instructions;if(!o?.length){this._canvasMaskStack.push(!1);return}r.save(),n.setContextTransform(a.groupTransform,(t._roundPixels|a._roundPixels)===1),r.beginPath();let s=!1,c=!1;for(let e=0;e<o.length;e++){let t=o[e],n=t.action;if(n!==`fill`&&n!==`stroke`)continue;let i=t.data,a=i?.path?.shapePath;if(!a?.shapePrimitives?.length)continue;let l=n===`stroke`,u=a.shapePrimitives;for(let e=0;e<u.length;e++){let t=u[e];if(!t?.shape)continue;let n=t.transform,a=n&&!n.isIdentity();a&&(r.save(),r.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),l&&i.style?s=P(r,t.shape,i.style)||s:(N(r,t.shape),c=F(r,t.holes)||c,s=!0),a&&r.restore()}}s?(c?r.clip(`evenodd`):r.clip(),this._canvasMaskStack.push(!0)):(r.restore(),this._canvasMaskStack.push(!1))}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),c(t))}};I.extension={type:[n.CanvasPipes],name:`stencilMask`};var L=`source-over`;function R(){let e=D(),t=Object.create(null);return t.inherit=L,t.none=L,t.normal=`source-over`,t.add=`lighter`,t.multiply=e?`multiply`:L,t.screen=e?`screen`:L,t.overlay=e?`overlay`:L,t.darken=e?`darken`:L,t.lighten=e?`lighten`:L,t[`color-dodge`]=e?`color-dodge`:L,t[`color-burn`]=e?`color-burn`:L,t[`hard-light`]=e?`hard-light`:L,t[`soft-light`]=e?`soft-light`:L,t.difference=e?`difference`:L,t.exclusion=e?`exclusion`:L,t.saturation=e?`saturation`:L,t.color=e?`color`:L,t.luminosity=e?`luminosity`:L,t[`linear-burn`]=e?`color-burn`:L,t[`linear-dodge`]=e?`color-dodge`:L,t[`linear-light`]=e?`hard-light`:L,t[`pin-light`]=e?`hard-light`:L,t[`vivid-light`]=e?`hard-light`:L,t[`hard-mix`]=L,t.negation=e?`difference`:L,t[`normal-npm`]=t.normal,t[`add-npm`]=t.add,t[`screen-npm`]=t.screen,t.erase=`destination-out`,t.subtract=L,t.divide=L,t.min=L,t.max=L,t}var z=new e,B=class{constructor(e){this.activeResolution=1,this.smoothProperty=`imageSmoothingEnabled`,this.blendModes=R(),this._activeBlendMode=`normal`,this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){let 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){let e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty=`webkitImageSmoothingEnabled`:e.mozImageSmoothingEnabled?this.smoothProperty=`mozImageSmoothingEnabled`:e.oImageSmoothingEnabled?this.smoothProperty=`oImageSmoothingEnabled`:e.msImageSmoothingEnabled&&(this.smoothProperty=`msImageSmoothingEnabled`)}}setContextTransform(t,n,r,i){let a=i?e.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||e.IDENTITY,o=z;o.copyFrom(a),o.append(t);let s=this._projTransform,c=this.activeResolution;if(r||=c,s){let t=e.shared;t.copyFrom(o),t.prepend(s),o=t}n?this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*c|0,o.ty*c|0):this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*c,o.ty*c)}clear(e,t){let n=this.activeContext,r=this._renderer;if(n.clearRect(0,0,r.width,r.height),e){let i=f.shared.setValue(e);n.globalAlpha=t??i.alpha,n.fillStyle=i.toHex(),n.fillRect(0,0,r.width,r.height),n.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;let t=this.blendModes[e];t?this.activeContext.globalCompositeOperation=t:(this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation=`source-over`)}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}};B.extension={type:[n.CanvasSystem],name:`canvasContext`};var V=class{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0,this.minUniformBufferOffsetAlignment=0}init(){}};V.extension={type:[n.CanvasSystem],name:`limits`};var H=`#808080`,U=new e,W=new e,G=new e,K=new e,q=new e;function J(e,t,n){e.beginPath();for(let r=0;r<n.length;r+=3){let i=n[r]*2,a=n[r+1]*2,o=n[r+2]*2;e.moveTo(t[i],t[i+1]),e.lineTo(t[a],t[a+1]),e.lineTo(t[o],t[o+1]),e.closePath()}e.fill()}function Y(e){return`#${(e&0xffffff).toString(16).padStart(6,`0`)}`}function X(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function Z(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;X(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function Q(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),Z(e,r.shape),a&&e.restore()}return!0}function ee(e,t,n,r){let i=e.fill;if(i instanceof m){i.buildGradient();let a=i.texture;if(a){let o=O.getTintedPattern(a,t),s=n?K.copyFrom(n).scale(a.source.pixelWidth,a.source.pixelHeight):K.copyFrom(i.transform);return r&&!e.textureSpace&&s.append(r),O.applyPatternTransform(o,s),o}}if(i instanceof g){let e=O.getTintedPattern(i.texture,t);return O.applyPatternTransform(e,i.transform,!1),e}let a=e.texture;if(a&&a!==l.WHITE){if(!a.source.resource)return H;let r=O.getTintedPattern(a,t),i=e.matrix;if(n){let{resolution:e}=a.source;if(i=K.copyFrom(n),a.rotate){let{uvs:t,orig:n}=a;i.prepend(q.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0).invert()).scale(n.width*e,n.height*e)}else i.scale(a.source.pixelWidth,a.source.pixelHeight).translate(-a.frame.x*e,-a.frame.y*e)}return O.applyPatternTransform(r,i),r}return Y(t)}var $=class{constructor(){this.shader=null}contextChange(e){}execute(e,t){let n=e.renderer,r=n.canvasContext,i=r.activeContext,a=t.groupTransform,c=n.globalUniforms.globalUniformData?.worldColor??0xffffffff,f=t.groupColorAlpha,m=(c>>>24&255)/255,h=(f>>>24&255)/255,g=n.filter?.alphaMultiplier??1,v=m*h*g;if(v<=0)return;let y=c&0xffffff,b=f&0xffffff,x=u(p(b,y)),S=n._roundPixels|t._roundPixels;i.save(),r.setContextTransform(a,S===1),r.setBlendMode(t.groupBlendMode);let C=t.context.instructions;for(let e=0;e<C.length;e++){let t=C[e];if(t.action===`texture`){let e=t.data,n=e.image,s=n?O.getCanvasSource(n):null;if(!s)continue;let c=e.alpha*v;if(c<=0)continue;let l=p(e.style,x);i.globalAlpha=c;let u=s;l!==0xffffff&&(u=O.getTintedCanvas({texture:n},l));let d=n.frame,f=n.source._resolution??n.source.resolution??1,m=d.x*f,h=d.y*f,g=d.width*f,_=d.height*f;u!==s&&(m=0,h=0);let y=e.transform,b=y&&!y.isIdentity(),C=n.rotate;b||C?(U.copyFrom(a),b&&U.append(y),C&&o.matrixAppendRotationInv(U,C,e.dx,e.dy,e.dw,e.dh),r.setContextTransform(U,S===1)):r.setContextTransform(a,S===1),i.drawImage(u,m,h,u===s?g:u.width,u===s?_:u.height,C?0:e.dx,C?0:e.dy,e.dw,e.dh),(b||C)&&r.setContextTransform(a,S===1);continue}let n=t.data,c=n?.path?.shapePath;if(!c?.shapePrimitives?.length)continue;let u=n.style,f=p(u.color,x),m=u.alpha*v;if(m<=0)continue;let h=t.action===`stroke`;if(i.globalAlpha=m,h){let e=u;i.lineWidth=e.width,i.lineCap=e.cap,i.lineJoin=e.join,i.miterLimit=e.miterLimit}let g=c.shapePrimitives;if(!h&&n.hole?.shapePath?.shapePrimitives?.length){let e=g[g.length-1];e.holes=n.hole.shapePath.shapePrimitives}for(let e=0;e<g.length;e++){let t=g[e];if(!t?.shape)continue;let n=t.transform,r=n&&!n.isIdentity(),o=u.texture&&u.texture!==l.WHITE,c=u.textureSpace===`global`?n:null,p=ee(u,f,o?s(W,u,t.shape,c):null,r?G.copyFrom(a).append(n):a);if(r&&(i.save(),i.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),h){let e=u;if(e.alignment!==.5&&!e.pixelLine){let n=[],r=[],a=[];if(d[t.shape.type]?.build(t.shape,n)){let o=t.shape.closePath??!0;_(n,e,!1,o,r,a),i.fillStyle=p,J(i,r,a)}else i.strokeStyle=p,i.beginPath(),Z(i,t.shape),i.stroke()}else i.strokeStyle=p,i.beginPath(),Z(i,t.shape),i.stroke()}else i.fillStyle=p,i.beginPath(),Z(i,t.shape),Q(i,t.holes)?i.fill(`evenodd`):i.fill();r&&i.restore()}}i.restore()}destroy(){this.shader=null}};$.extension={type:[n.CanvasPipesAdaptor],name:`graphics`};var te=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){let t=e.colorTexture,{canvas:n,context:r}=this._ensureCanvas(t);return{canvas:n,context:r,width:n.width,height:n.height}}resizeGpuRenderTarget(e){let t=e.colorTexture,{canvas:n}=this._ensureCanvas(t);n.width=e.pixelWidth,n.height=e.pixelHeight}startRenderPass(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=i.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,n,r)}clear(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e).context,a=r||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(i.setTransform(1,0,0,1,0,0),i.clearRect(a.x,a.y,a.width,a.height),n){let e=f.shared.setValue(n);e.alpha>0&&(i.globalAlpha=e.alpha,i.fillStyle=e.toHex(),i.fillRect(a.x,a.y,a.width,a.height),i.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,n,r,i){let a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,o=t.source,{context:s}=this._ensureCanvas(o),c=i?.x??0,l=i?.y??0;return s.drawImage(a,n.x,n.y,r.width,r.height,c,l,r.width,r.height),o.update(),t}copyDepthTexture(e,t,n,r,i){c(`[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer`)}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;t&&r.test(t)||(t=h.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);let n=t.getContext(`2d`);return{canvas:t,context:n}}},ne=class extends E{constructor(e){super(e),this.adaptor=new te,this.adaptor.init(e,this)}};ne.extension={type:[n.CanvasSystem],name:`renderTarget`};var re=class{constructor(e){}init(){}initSource(e){}generateCanvas(e){let t=h.get().createCanvas(),n=t.getContext(`2d`),r=O.getCanvasSource(e);if(!r)return t;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.x*a,s=i.y*a,c=i.width*a,l=i.height*a;return t.width=Math.ceil(c),t.height=Math.ceil(l),n.drawImage(r,o,s,c,l,0,0,c,l),t}getPixels(e){let 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(){}};re.extension={type:[n.CanvasSystem],name:`texture`};var ie=[...w,B,V,re,ne],ae=[x,S,y,C,b,I,j,T],oe=[A,$],se=[],ce=[],le=[],ue=[];t.handleByNamedList(n.CanvasSystem,se),t.handleByNamedList(n.CanvasPipes,ce),t.handleByNamedList(n.CanvasPipesAdaptor,le),t.handleByNamedList(n.CanvasLoader,ue),t.add(...ie,...ae,...oe);var de=class extends a{constructor(){let e={name:`canvas`,type:i.CANVAS,systems:se,renderPipes:ce,renderPipeAdaptors:le,loaders:ue};super(e)}};export{de as CanvasRenderer};
@@ -1,4 +1,4 @@
1
- import{$ as e,A as t,B as n,Ct as r,D as i,Dt as a,E as o,Et as s,H as c,J as l,K as u,L as d,M as f,P as p,R as m,Tt as h,W as g,X as _,Y as v,Z as y,_t as b,bt as ee,ct as x,dt as S,ft as te,gt as C,it as w,k as ne,lt as T,n as re,ot as E,pt as D,q as O,rt as ie,st as ae,tt as oe,u as se,ut as k,vt as ce,w as A,wt as le,xt as j,yt as ue,z as de}from"./index-CE-lli1m.js";import{t as fe}from"./CanvasPool-PBu3bHFZ.js";var pe=`in vec2 vMaskCoord;
1
+ import{$ as e,A as t,B as n,Ct as r,D as i,Dt as a,E as o,Et as s,H as c,J as l,K as u,L as d,M as f,P as p,R as m,Tt as h,W as g,X as _,Y as v,Z as y,_t as b,bt as ee,ct as x,dt as S,ft as te,gt as C,it as w,k as ne,lt as T,n as re,ot as E,pt as D,q as O,rt as ie,st as ae,tt as oe,u as se,ut as k,vt as ce,w as A,wt as le,xt as j,yt as ue,z as de}from"./index-41-d13J1.js";import{t as fe}from"./CanvasPool-SkgMbnEH.js";var pe=`in vec2 vMaskCoord;
2
2
  in vec2 vTextureCoord;
3
3
 
4
4
  uniform sampler2D uTexture;
@@ -1,4 +1,4 @@
1
- import{A as e,C as t,Ct as n,Dt as r,Et as i,F as a,H as o,K as s,L as c,N as l,O as u,P as d,S as f,Tt as p,V as m,_ as ee,b as te,bt as ne,c as h,ct as g,d as re,dt as _,gt as v,h as ie,p as y,pt as b,q as x,v as S,w as C,xt as w,z as T}from"./index-CE-lli1m.js";import{a as ae,c as oe,d as se,l as ce,n as le,o as E,p as D,r as ue,s as de,t as fe}from"./getTexelRangeRects-D3pwCyRt.js";import{n as pe,r as me,t as he}from"./RenderTargetSystem-Dk1U4wDJ.js";function ge(){let{userAgent:e}=x.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}var O=class{constructor(){this._tempState=d.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,n){let r=e.renderer,i=this._didUploadHash[n.uid];r.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),r.shader.updateUniformGroup(r.globalUniforms.uniformGroup),r.geometry.bind(t,n.glProgram)}execute(e,t){let n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);let r=t.textures.textures;for(let e=0;e<t.textures.count;e++)n.texture.bind(r[e],e);n.texture.unbindIntegerTextures(t.textures.count),n.geometry.draw(t.topology,t.size,t.start)}};O.extension={type:[i.WebGLPipesAdaptor],name:`batch`};var k=(e=>(e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e))(k||{}),_e=class{constructor(e,t){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1}},A=class{constructor(e){this._boundBuffers=[],this._boundOffsets=[],this._boundSizes=[],this._renderer=e,this._managedBuffers=new h({renderer:e,type:`resource`,onUnload:this.onBufferUnload.bind(this),name:`glBuffer`})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBuffers.length=0}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._boundBuffers.length=0}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){let{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){(this._boundBuffers[t]!==e||this._boundSizes[t]!==-1)&&(this._boundBuffers[t]=e,this._boundOffsets[t]=0,this._boundSizes[t]=-1,this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e.buffer))}bindBufferRange(e,t=0,n=0,r){r??=e.byteLength-n,(this._boundBuffers[t]!==e||this._boundOffsets[t]!==n||this._boundSizes[t]!==r)&&(this._boundBuffers[t]=e,this._boundOffsets[t]=n,this._boundSizes[t]=r,this._gl.bindBufferRange(this._gl.UNIFORM_BUFFER,t,e.buffer,n,r))}updateBuffer(e){let t=this.getGlBuffer(e);return this._upload(e,t,t.type),t}_upload(e,t,n){let{_gl:r}=this;if(e._updateID===t.updateID)return;t.updateID=e._updateID,r.bindBuffer(n,t.buffer);let i=e.data,a=e.descriptor.usage&f.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;if(i){if(t.byteLength>=i.byteLength){let t=e._updateOffset/i.BYTES_PER_ELEMENT,a=(e._updateSize||i.byteLength)/i.BYTES_PER_ELEMENT;this._renderer.context.webGLVersion===2?r.bufferSubData(n,e._updateOffset,i,t,a):r.bufferSubData(n,e._updateOffset,a===i.length?i:i.subarray(t,t+a))}else t.byteLength=i.byteLength,r.bufferData(n,i,a)}else t.byteLength=e.descriptor.size,r.bufferData(n,t.byteLength,a)}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){e.off(`update`,this.updateBuffer,this),e.off(`update`,this._updateIndexBuffer,this);let n=e._gpuData[this._renderer.uid];n&&(t||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){let{_gl:t}=this,n=k.ARRAY_BUFFER;e.descriptor.usage&f.INDEX?n=k.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&f.UNIFORM&&(n=k.UNIFORM_BUFFER);let r=new _e(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=r,this._managedBuffers.add(e)&&(n===k.ELEMENT_ARRAY_BUFFER?e.on(`update`,this._updateIndexBuffer,this):e.on(`update`,this.updateBuffer,this)),r}_updateIndexBuffer(e){let t=this.getGlBuffer(e);t.byteLength<0||(this._renderer.context.webGLVersion===2?this._upload(e,t,this._gl.COPY_WRITE_BUFFER):(this._renderer.geometry._activeVao&&this._renderer.geometry.resetState(),this._upload(e,t,t.type)))}resetState(){this._boundBuffers.length=0}};A.extension={type:[i.WebGLSystem],name:`buffer`};var j=class e{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(t){t={...e.defaultOptions,...t};let n=this.multiView=t.multiView;if(t.context&&n&&(g(`Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together.`),n=!1),this.canvas=n?x.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{let e=this._renderer.background.alpha<1,n=t.premultipliedAlpha??!0,r=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:n,antialias:r,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??`default`})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&g(`multiView is disabled, but targetCanvas is not the main canvas`);return}let{canvas:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof x.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);let t=this._renderer.view.canvas;t.addEventListener(`webglcontextlost`,this.handleContextLost,!1),t.addEventListener(`webglcontextrestored`,this.handleContextRestored,!1)}createContext(e,t){let n,r=this.canvas;if(e===2&&(n=r.getContext(`webgl2`,t)),!n&&(n=r.getContext(`webgl`,t),!n))throw Error(`This browser does not support WebGL. Try using the canvas renderer`);this.gl=n,this.initFromContext(this.gl)}getExtensions(){let{gl:e}=this,t={anisotropicFiltering:e.getExtension(`EXT_texture_filter_anisotropic`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),s3tc:e.getExtension(`WEBGL_compressed_texture_s3tc`),s3tc_sRGB:e.getExtension(`WEBGL_compressed_texture_s3tc_srgb`),etc:e.getExtension(`WEBGL_compressed_texture_etc`),etc1:e.getExtension(`WEBGL_compressed_texture_etc1`),pvrtc:e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`),atc:e.getExtension(`WEBGL_compressed_texture_atc`),astc:e.getExtension(`WEBGL_compressed_texture_astc`),bptc:e.getExtension(`EXT_texture_compression_bptc`),rgtc:e.getExtension(`EXT_texture_compression_rgtc`),loseContext:e.getExtension(`WEBGL_lose_context`)};if(this.webGLVersion===1)this.extensions={...t,drawBuffers:e.getExtension(`WEBGL_draw_buffers`),depthTexture:e.getExtension(`WEBGL_depth_texture`),vertexArrayObject:e.getExtension(`OES_vertex_array_object`)||e.getExtension(`MOZ_OES_vertex_array_object`)||e.getExtension(`WEBKIT_OES_vertex_array_object`),uint32ElementIndex:e.getExtension(`OES_element_index_uint`),floatTexture:e.getExtension(`OES_texture_float`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),textureHalfFloat:e.getExtension(`OES_texture_half_float`),textureHalfFloatLinear:e.getExtension(`OES_texture_half_float_linear`),vertexAttribDivisorANGLE:e.getExtension(`ANGLE_instanced_arrays`),srgb:e.getExtension(`EXT_sRGB`)};else{this.extensions={...t,colorBufferFloat:e.getExtension(`EXT_color_buffer_float`)};let n=e.getExtension(`WEBGL_provoking_vertex`);n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){let e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener(`webglcontextlost`,this.handleContextLost),e.removeEventListener(`webglcontextrestored`,this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){let t=e.getContextAttributes();t&&!t.stencil&&g(`Provided WebGL context does not have a stencil buffer, masks may not render correctly`);let n=this.supports,r=this.webGLVersion===2,i=this.extensions;n.uint32Indices=r||!!i.uint32ElementIndex,n.uniformBufferObject=r,n.vertexArrayObject=r||!!i.vertexArrayObject,n.srgbTextures=r||!!i.srgb,n.nonPowOf2wrapping=r,n.nonPowOf2mipmaps=r,n.msaa=r,n.uint32Indices||g(`Provided WebGL context does not support 32 index buffer, large scenes may not render correctly`)}};j.extension={type:[i.WebGLSystem],name:`context`},j.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};var ve=j,M=(e=>(e[e.RGBA=6408]=`RGBA`,e[e.RGB=6407]=`RGB`,e[e.RG=33319]=`RG`,e[e.RED=6403]=`RED`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.ALPHA=6406]=`ALPHA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e))(M||{}),N=(e=>(e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_3D=32879]=`TEXTURE_3D`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e))(N||{}),P=(e=>(e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.BYTE=5120]=`BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.INT=5124]=`INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.HALF_FLOAT=36193]=`HALF_FLOAT`,e))(P||{}),F={uint8x2:P.UNSIGNED_BYTE,uint8x4:P.UNSIGNED_BYTE,sint8x2:P.BYTE,sint8x4:P.BYTE,unorm8x2:P.UNSIGNED_BYTE,unorm8x4:P.UNSIGNED_BYTE,snorm8x2:P.BYTE,snorm8x4:P.BYTE,uint16x2:P.UNSIGNED_SHORT,uint16x4:P.UNSIGNED_SHORT,sint16x2:P.SHORT,sint16x4:P.SHORT,unorm16x2:P.UNSIGNED_SHORT,unorm16x4:P.UNSIGNED_SHORT,snorm16x2:P.SHORT,snorm16x4:P.SHORT,float16x2:P.HALF_FLOAT,float16x4:P.HALF_FLOAT,float32:P.FLOAT,float32x2:P.FLOAT,float32x3:P.FLOAT,float32x4:P.FLOAT,uint32:P.UNSIGNED_INT,uint32x2:P.UNSIGNED_INT,uint32x3:P.UNSIGNED_INT,uint32x4:P.UNSIGNED_INT,sint32:P.INT,sint32x2:P.INT,sint32x3:P.INT,sint32x4:P.INT};function ye(e){return F[e]??F.float32}var be={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5},xe=class{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}},I=class{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new h({renderer:e,type:`resource`,onUnload:this.onGeometryUnload.bind(this),name:`glGeometry`})}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw Error(`[PixiJS] Vertex Array Objects are not supported on this device`);this.destroyAll(!0);let t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=e=>t.bindVertexArrayOES(e),e.deleteVertexArray=e=>t.deleteVertexArrayOES(e));let n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(e,t,r,i)=>{n.drawArraysInstancedANGLE(e,t,r,i)},e.drawElementsInstanced=(e,t,r,i,a)=>{n.drawElementsInstancedANGLE(e,t,r,i,a)},e.vertexAttribDivisor=(e,t)=>n.vertexAttribDivisorANGLE(e,t)),this._activeGeometry=null,this._activeVao=null}bind(e,t){let n=this.gl;this._activeGeometry=e;let r=this.getVao(e,t);this._activeVao!==r&&(this._activeVao=r,n.bindVertexArray(r)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n];t.updateBuffer(r)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){let n=e.attributes,r=t._attributeData;for(let e in r)if(!n[e])throw Error(`shader and geometry incompatible, geometry missing the "${e}" attribute`)}getSignature(e,t){let n=e.attributes,r=t._attributeData,i=[`g`,e.uid];for(let e in n)r[e]&&i.push(e,r[e].location);return i.join(`-`)}getVao(e,t){return e._gpuData[this._renderer.uid]?.vaoCache[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){let r=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);let a=this.getSignature(e,t),o=e._gpuData[this._renderer.uid];o||(o=new xe,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));let s=o.vaoCache,c=s[a];if(c)return s[t._key]=c,c;ce(e,t._attributeData);let l=e.buffers;c=r.createVertexArray(),r.bindVertexArray(c);for(let e=0;e<l.length;e++){let t=l[e];i.bind(t)}return this.activateVao(e,t),s[t._key]=c,s[a]=c,r.bindVertexArray(null),c}onGeometryUnload(e,t=!1){let n=e._gpuData[this._renderer.uid];if(!n)return;let r=n.vaoCache;if(!t)for(let e in r)this._activeVao===r[e]&&this.resetState(),this.gl.deleteVertexArray(r[e])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){let n=this._renderer.gl,r=this._renderer.buffer,i=e.attributes;e.indexBuffer&&r.bind(e.indexBuffer);let a=null;for(let e in i){let o=i[e],s=o.buffer,c=r.getGlBuffer(s),l=t._attributeData[e];if(l){a!==c&&(r.bind(s),a=c);let e=l.location;n.enableVertexAttribArray(e);let t=m(o.format),i=ye(o.format);if(l.format?.substring(1,4)===`int`?n.vertexAttribIPointer(e,t.size,i,o.stride,o.offset):n.vertexAttribPointer(e,t.size,i,t.normalised,o.stride,o.offset),o.instance){if(this.hasInstance){let t=o.divisor??1;n.vertexAttribDivisor(e,t)}else throw Error(`geometry error, GPU Instancing is not supported on this device`)}}}}draw(e,t,n,r){let{gl:i}=this._renderer,a=this._activeGeometry,o=be[e||a.topology];if(r??=a.instanceCount,a.indexBuffer){let e=a.indexBuffer.data.BYTES_PER_ELEMENT,s=e===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT,c=t||a.indexCount||a.indexBuffer.data.length,l=(n||0)*e;r===1?i.drawElements(o,c,s,l):i.drawElementsInstanced(o,c,s,l,r)}else r===1?i.drawArrays(o,n||0,t||a.vertexCount):i.drawArraysInstanced(o,n||0,t||a.vertexCount,r);return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}};I.extension={type:[i.WebGLSystem],name:`geometry`};var Se=new te({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),L=class e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(t={}){let{useBackBuffer:n,antialias:r}={...e.defaultOptions,...t};this.useBackBuffer=n,this._antialias=r,this._renderer.context.supports.msaa||(g(`antialiasing, is not supported on when using the back buffer`),this._antialias=!1),this._state=d.for2d();let i=new o({vertex:`
1
+ import{A as e,C as t,Ct as n,Dt as r,Et as i,F as a,H as o,K as s,L as c,N as l,O as u,P as d,S as f,Tt as p,V as m,_ as ee,b as te,bt as ne,c as h,ct as g,d as re,dt as _,gt as v,h as ie,p as y,pt as b,q as x,v as S,w as C,xt as w,z as T}from"./index-41-d13J1.js";import{a as ae,c as oe,d as se,l as ce,n as le,o as E,p as D,r as ue,s as de,t as fe}from"./getTexelRangeRects-CRAnqulP.js";import{n as pe,r as me,t as he}from"./RenderTargetSystem-um8Nv1HQ.js";function ge(){let{userAgent:e}=x.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}var O=class{constructor(){this._tempState=d.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,n){let r=e.renderer,i=this._didUploadHash[n.uid];r.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),r.shader.updateUniformGroup(r.globalUniforms.uniformGroup),r.geometry.bind(t,n.glProgram)}execute(e,t){let n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);let r=t.textures.textures;for(let e=0;e<t.textures.count;e++)n.texture.bind(r[e],e);n.texture.unbindIntegerTextures(t.textures.count),n.geometry.draw(t.topology,t.size,t.start)}};O.extension={type:[i.WebGLPipesAdaptor],name:`batch`};var k=(e=>(e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e))(k||{}),_e=class{constructor(e,t){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1}},A=class{constructor(e){this._boundBuffers=[],this._boundOffsets=[],this._boundSizes=[],this._renderer=e,this._managedBuffers=new h({renderer:e,type:`resource`,onUnload:this.onBufferUnload.bind(this),name:`glBuffer`})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBuffers.length=0}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._boundBuffers.length=0}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){let{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){(this._boundBuffers[t]!==e||this._boundSizes[t]!==-1)&&(this._boundBuffers[t]=e,this._boundOffsets[t]=0,this._boundSizes[t]=-1,this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e.buffer))}bindBufferRange(e,t=0,n=0,r){r??=e.byteLength-n,(this._boundBuffers[t]!==e||this._boundOffsets[t]!==n||this._boundSizes[t]!==r)&&(this._boundBuffers[t]=e,this._boundOffsets[t]=n,this._boundSizes[t]=r,this._gl.bindBufferRange(this._gl.UNIFORM_BUFFER,t,e.buffer,n,r))}updateBuffer(e){let t=this.getGlBuffer(e);return this._upload(e,t,t.type),t}_upload(e,t,n){let{_gl:r}=this;if(e._updateID===t.updateID)return;t.updateID=e._updateID,r.bindBuffer(n,t.buffer);let i=e.data,a=e.descriptor.usage&f.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;if(i){if(t.byteLength>=i.byteLength){let t=e._updateOffset/i.BYTES_PER_ELEMENT,a=(e._updateSize||i.byteLength)/i.BYTES_PER_ELEMENT;this._renderer.context.webGLVersion===2?r.bufferSubData(n,e._updateOffset,i,t,a):r.bufferSubData(n,e._updateOffset,a===i.length?i:i.subarray(t,t+a))}else t.byteLength=i.byteLength,r.bufferData(n,i,a)}else t.byteLength=e.descriptor.size,r.bufferData(n,t.byteLength,a)}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){e.off(`update`,this.updateBuffer,this),e.off(`update`,this._updateIndexBuffer,this);let n=e._gpuData[this._renderer.uid];n&&(t||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){let{_gl:t}=this,n=k.ARRAY_BUFFER;e.descriptor.usage&f.INDEX?n=k.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&f.UNIFORM&&(n=k.UNIFORM_BUFFER);let r=new _e(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=r,this._managedBuffers.add(e)&&(n===k.ELEMENT_ARRAY_BUFFER?e.on(`update`,this._updateIndexBuffer,this):e.on(`update`,this.updateBuffer,this)),r}_updateIndexBuffer(e){let t=this.getGlBuffer(e);t.byteLength<0||(this._renderer.context.webGLVersion===2?this._upload(e,t,this._gl.COPY_WRITE_BUFFER):(this._renderer.geometry._activeVao&&this._renderer.geometry.resetState(),this._upload(e,t,t.type)))}resetState(){this._boundBuffers.length=0}};A.extension={type:[i.WebGLSystem],name:`buffer`};var j=class e{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(t){t={...e.defaultOptions,...t};let n=this.multiView=t.multiView;if(t.context&&n&&(g(`Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together.`),n=!1),this.canvas=n?x.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{let e=this._renderer.background.alpha<1,n=t.premultipliedAlpha??!0,r=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:n,antialias:r,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??`default`})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&g(`multiView is disabled, but targetCanvas is not the main canvas`);return}let{canvas:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof x.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);let t=this._renderer.view.canvas;t.addEventListener(`webglcontextlost`,this.handleContextLost,!1),t.addEventListener(`webglcontextrestored`,this.handleContextRestored,!1)}createContext(e,t){let n,r=this.canvas;if(e===2&&(n=r.getContext(`webgl2`,t)),!n&&(n=r.getContext(`webgl`,t),!n))throw Error(`This browser does not support WebGL. Try using the canvas renderer`);this.gl=n,this.initFromContext(this.gl)}getExtensions(){let{gl:e}=this,t={anisotropicFiltering:e.getExtension(`EXT_texture_filter_anisotropic`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),s3tc:e.getExtension(`WEBGL_compressed_texture_s3tc`),s3tc_sRGB:e.getExtension(`WEBGL_compressed_texture_s3tc_srgb`),etc:e.getExtension(`WEBGL_compressed_texture_etc`),etc1:e.getExtension(`WEBGL_compressed_texture_etc1`),pvrtc:e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`),atc:e.getExtension(`WEBGL_compressed_texture_atc`),astc:e.getExtension(`WEBGL_compressed_texture_astc`),bptc:e.getExtension(`EXT_texture_compression_bptc`),rgtc:e.getExtension(`EXT_texture_compression_rgtc`),loseContext:e.getExtension(`WEBGL_lose_context`)};if(this.webGLVersion===1)this.extensions={...t,drawBuffers:e.getExtension(`WEBGL_draw_buffers`),depthTexture:e.getExtension(`WEBGL_depth_texture`),vertexArrayObject:e.getExtension(`OES_vertex_array_object`)||e.getExtension(`MOZ_OES_vertex_array_object`)||e.getExtension(`WEBKIT_OES_vertex_array_object`),uint32ElementIndex:e.getExtension(`OES_element_index_uint`),floatTexture:e.getExtension(`OES_texture_float`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),textureHalfFloat:e.getExtension(`OES_texture_half_float`),textureHalfFloatLinear:e.getExtension(`OES_texture_half_float_linear`),vertexAttribDivisorANGLE:e.getExtension(`ANGLE_instanced_arrays`),srgb:e.getExtension(`EXT_sRGB`)};else{this.extensions={...t,colorBufferFloat:e.getExtension(`EXT_color_buffer_float`)};let n=e.getExtension(`WEBGL_provoking_vertex`);n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){let e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener(`webglcontextlost`,this.handleContextLost),e.removeEventListener(`webglcontextrestored`,this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){let t=e.getContextAttributes();t&&!t.stencil&&g(`Provided WebGL context does not have a stencil buffer, masks may not render correctly`);let n=this.supports,r=this.webGLVersion===2,i=this.extensions;n.uint32Indices=r||!!i.uint32ElementIndex,n.uniformBufferObject=r,n.vertexArrayObject=r||!!i.vertexArrayObject,n.srgbTextures=r||!!i.srgb,n.nonPowOf2wrapping=r,n.nonPowOf2mipmaps=r,n.msaa=r,n.uint32Indices||g(`Provided WebGL context does not support 32 index buffer, large scenes may not render correctly`)}};j.extension={type:[i.WebGLSystem],name:`context`},j.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};var ve=j,M=(e=>(e[e.RGBA=6408]=`RGBA`,e[e.RGB=6407]=`RGB`,e[e.RG=33319]=`RG`,e[e.RED=6403]=`RED`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.ALPHA=6406]=`ALPHA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e))(M||{}),N=(e=>(e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_3D=32879]=`TEXTURE_3D`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e))(N||{}),P=(e=>(e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.BYTE=5120]=`BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.INT=5124]=`INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.HALF_FLOAT=36193]=`HALF_FLOAT`,e))(P||{}),F={uint8x2:P.UNSIGNED_BYTE,uint8x4:P.UNSIGNED_BYTE,sint8x2:P.BYTE,sint8x4:P.BYTE,unorm8x2:P.UNSIGNED_BYTE,unorm8x4:P.UNSIGNED_BYTE,snorm8x2:P.BYTE,snorm8x4:P.BYTE,uint16x2:P.UNSIGNED_SHORT,uint16x4:P.UNSIGNED_SHORT,sint16x2:P.SHORT,sint16x4:P.SHORT,unorm16x2:P.UNSIGNED_SHORT,unorm16x4:P.UNSIGNED_SHORT,snorm16x2:P.SHORT,snorm16x4:P.SHORT,float16x2:P.HALF_FLOAT,float16x4:P.HALF_FLOAT,float32:P.FLOAT,float32x2:P.FLOAT,float32x3:P.FLOAT,float32x4:P.FLOAT,uint32:P.UNSIGNED_INT,uint32x2:P.UNSIGNED_INT,uint32x3:P.UNSIGNED_INT,uint32x4:P.UNSIGNED_INT,sint32:P.INT,sint32x2:P.INT,sint32x3:P.INT,sint32x4:P.INT};function ye(e){return F[e]??F.float32}var be={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5},xe=class{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}},I=class{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new h({renderer:e,type:`resource`,onUnload:this.onGeometryUnload.bind(this),name:`glGeometry`})}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw Error(`[PixiJS] Vertex Array Objects are not supported on this device`);this.destroyAll(!0);let t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=e=>t.bindVertexArrayOES(e),e.deleteVertexArray=e=>t.deleteVertexArrayOES(e));let n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(e,t,r,i)=>{n.drawArraysInstancedANGLE(e,t,r,i)},e.drawElementsInstanced=(e,t,r,i,a)=>{n.drawElementsInstancedANGLE(e,t,r,i,a)},e.vertexAttribDivisor=(e,t)=>n.vertexAttribDivisorANGLE(e,t)),this._activeGeometry=null,this._activeVao=null}bind(e,t){let n=this.gl;this._activeGeometry=e;let r=this.getVao(e,t);this._activeVao!==r&&(this._activeVao=r,n.bindVertexArray(r)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n];t.updateBuffer(r)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){let n=e.attributes,r=t._attributeData;for(let e in r)if(!n[e])throw Error(`shader and geometry incompatible, geometry missing the "${e}" attribute`)}getSignature(e,t){let n=e.attributes,r=t._attributeData,i=[`g`,e.uid];for(let e in n)r[e]&&i.push(e,r[e].location);return i.join(`-`)}getVao(e,t){return e._gpuData[this._renderer.uid]?.vaoCache[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){let r=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);let a=this.getSignature(e,t),o=e._gpuData[this._renderer.uid];o||(o=new xe,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));let s=o.vaoCache,c=s[a];if(c)return s[t._key]=c,c;ce(e,t._attributeData);let l=e.buffers;c=r.createVertexArray(),r.bindVertexArray(c);for(let e=0;e<l.length;e++){let t=l[e];i.bind(t)}return this.activateVao(e,t),s[t._key]=c,s[a]=c,r.bindVertexArray(null),c}onGeometryUnload(e,t=!1){let n=e._gpuData[this._renderer.uid];if(!n)return;let r=n.vaoCache;if(!t)for(let e in r)this._activeVao===r[e]&&this.resetState(),this.gl.deleteVertexArray(r[e])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){let n=this._renderer.gl,r=this._renderer.buffer,i=e.attributes;e.indexBuffer&&r.bind(e.indexBuffer);let a=null;for(let e in i){let o=i[e],s=o.buffer,c=r.getGlBuffer(s),l=t._attributeData[e];if(l){a!==c&&(r.bind(s),a=c);let e=l.location;n.enableVertexAttribArray(e);let t=m(o.format),i=ye(o.format);if(l.format?.substring(1,4)===`int`?n.vertexAttribIPointer(e,t.size,i,o.stride,o.offset):n.vertexAttribPointer(e,t.size,i,t.normalised,o.stride,o.offset),o.instance){if(this.hasInstance){let t=o.divisor??1;n.vertexAttribDivisor(e,t)}else throw Error(`geometry error, GPU Instancing is not supported on this device`)}}}}draw(e,t,n,r){let{gl:i}=this._renderer,a=this._activeGeometry,o=be[e||a.topology];if(r??=a.instanceCount,a.indexBuffer){let e=a.indexBuffer.data.BYTES_PER_ELEMENT,s=e===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT,c=t||a.indexCount||a.indexBuffer.data.length,l=(n||0)*e;r===1?i.drawElements(o,c,s,l):i.drawElementsInstanced(o,c,s,l,r)}else r===1?i.drawArrays(o,n||0,t||a.vertexCount):i.drawArraysInstanced(o,n||0,t||a.vertexCount,r);return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}};I.extension={type:[i.WebGLSystem],name:`geometry`};var Se=new te({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),L=class e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(t={}){let{useBackBuffer:n,antialias:r}={...e.defaultOptions,...t};this.useBackBuffer=n,this._antialias=r,this._renderer.context.supports.msaa||(g(`antialiasing, is not supported on when using the back buffer`),this._antialias=!1),this._state=d.for2d();let i=new o({vertex:`
2
2
  attribute vec2 aPosition;
3
3
  out vec2 vUv;
4
4
 
@@ -1,4 +1,4 @@
1
- import{A as e,Ct as t,Dt as n,Et as r,F as i,I as a,K as o,L as s,O as c,P as l,R as u,S as d,T as f,U as p,c as m,ct as h,dt as g,f as _,g as v,gt as y,l as b,m as x,pt as S,q as C,w,x as ee,xt as T,y as E,z as D}from"./index-CE-lli1m.js";import{a as te,c as ne,f as re,i as ie,l as O,m as ae,n as oe,s as se,t as ce,u as le}from"./getTexelRangeRects-D3pwCyRt.js";import{n as ue,r as de,t as fe}from"./RenderTargetSystem-Dk1U4wDJ.js";import{t as k}from"./CanvasPool-PBu3bHFZ.js";var A=l.for2d(),j=class{start(e,t,n){let r=e.renderer,i=r.encoder,a=n.gpuProgram;this._shader=n,this._geometry=t,i.setGeometry(t,a),A.blendMode=`normal`,r.pipeline.getPipeline(t,a,A,void 0,n._overrides);let o=r.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,a)}execute(e,t){let n=this._shader.gpuProgram,r=e.renderer,i=r.encoder;if(!t.bindGroup){let e=t.textures;t.bindGroup=b(e.textures,e.count,r.limits.maxBatchableTextures)}A.blendMode=t.blendMode;let a=r.bindGroup.getBindGroup(t.bindGroup,n,1),o=r.pipeline.getPipeline(this._geometry,n,A,t.topology,this._shader._overrides);t.bindGroup._touch(r.gc.now),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,a),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}};j.extension={type:[r.WebGPUPipesAdaptor],name:`batch`};var pe=0,me=class{constructor(e,t,n,r,i,a){this.autoGarbageCollect=!0,this._gpuData=null,this.gpuBindGroup=e,this._gcLastUsed=t,this.keyLow=n,this.keyHigh=r,this.layoutKey=i,this.cacheId=a}unload(){this.gpuBindGroup=null}},M=class{constructor(e){this._hash=Object.create(null),this._cacheId=0,this._renderer=e,e.gc.addResourceHash(this,`_hash`,`resource`),e.gc.addCollection(this,`_hash`,`hash`)}contextChange(e){this._gpu=e,this._cacheId=++pe,this._hash=Object.create(null)}getBindGroup(e,t,n){let r=t._layoutKey<<4|n,i=e._gpuEntry;if(i!==null&&e._gpuEntryLayoutKey===r&&i.gpuBindGroup!==null&&i.cacheId===this._cacheId)return i._gcLastUsed=this._renderer.gc.now,i.gpuBindGroup;let a=e._keyLow,o=e._keyHigh,s=(a^Math.imul(r+1,0x9e3779b1))&0x3fffffff;return i=this._hash[s],i&&i.keyLow===a&&i.keyHigh===o&&i.layoutKey===r?i._gcLastUsed=this._renderer.gc.now:(i=new me(this._createBindGroup(e,t,n),this._renderer.gc.now,a,o,r,this._cacheId),this._hash[s]=i),e._gpuEntry=i,e._gpuEntryLayoutKey=r,i.gpuBindGroup}_createBindGroup(e,t,n){let r=this._gpu.device,i=t.layout[n],a=e.layout,o=[],s=this._renderer;for(let t in i){let n=e.resources[a?a[t]:i[t]];if(!n||n.destroyed)throw Error(`[BindGroup] no usable resource for the shader's '${t}' binding: it was never set, was destroyed while a shader still uses it, or is missing from the bind group's layout.`);let r;if(n._resourceType===`uniformGroup`){let e=n;s.ubo.updateUniformGroup(e);let t=e.buffer;r={buffer:s.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if(n._resourceType===`buffer`){let e=n;r={buffer:s.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if(n._resourceType===`bufferResource`){let e=n;r={buffer:s.buffer.getGPUBuffer(e.buffer),offset:e.offset,size:e.size}}else if(n._resourceType===`textureSampler`){let e=n;r=s.texture.getGpuSampler(e)}else if(n._resourceType===`textureSource`){let e=n;r=s.texture.getTextureView(e)}else if(n._resourceType===`textureView`){let e=n;r=s.texture.getTextureView(e.source,e.viewDescriptor)}o.push({binding:i[t],resource:r})}let c=s.shader.getProgramData(t).bindGroups[n];return r.createBindGroup({layout:c,entries:o})}destroy(){this._hash=null,this._renderer=null}};M.extension={type:[r.WebGPUSystem],name:`bindGroup`};var he=class{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}},N=class{constructor(e){this._renderer=e,this._managedBuffers=new m({renderer:e,type:`resource`,onUnload:this.onBufferUnload.bind(this),name:`gpuBuffer`})}contextChange(e){this._gpu=e,this.destroyAll()}getGPUBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(e)}updateBuffer(e){let t=this.getGPUBuffer(e),n=e.data;return e._updateID&&n&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,e._updateOffset,n.buffer,n.byteOffset+e._updateOffset,(e._updateSize||n.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off(`update`,this.updateBuffer,this),e.off(`change`,this.onBufferChange,this)}createGPUBuffer(e){let t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&(f(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new he(t),this._managedBuffers.add(e)&&(e.on(`update`,this.updateBuffer,this),e.on(`change`,this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}};N.extension={type:[r.WebGPUSystem],name:`buffer`};var ge=class{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw Error(`UniformBufferBatch: array is too large: ${e*4}`);let t=this.byteIndex,n=t+e*4;if(n=Math.ceil(n/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,n>this.data.length*4)throw Error(`UniformBufferBatch: ubo batch got too big`);return this.byteIndex=n,t}addGroup(e){let t=this.addEmptyGroup(e.length);for(let n=0;n<e.length;n++)this.data[t/4+n]=e[n];return t}destroy(){this.data=null}},P=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}};P.extension={type:[r.WebGPUSystem],name:`colorMask`};function _e(e){let{userAgent:t}=C.get().getNavigator();if(!/AppleWebKit\//.test(t)||/Chrome\/|Chromium\//.test(t))return!1;if(!e)return!0;let n=/Version\/([\d.]+)/.exec(t)?.[1];return!n||!(e.from&&F(n,e.from)<0||e.before&&F(n,e.before)>=0)}function F(e,t){let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<Math.max(n.length,r.length);e++){let t=(parseInt(n[e],10)||0)-(parseInt(r[e],10)||0);if(t)return t}return 0}var ve=new Set([`apple`,`arm`,`qualcomm`,`img-tec`]),I=class{constructor(e){this._renderer=e}async init(e){return this._initPromise||=(this._options=e,(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(e=>this._setGpu(e))),this._initPromise}_setGpu(e){this.gpu=e,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT==`number`&&!_e({from:`27.1`,before:`28`}),tileBased:ve.has(e.adapter?.info?.vendor)},this._options.gpu||e.device.lost.then(()=>this._restoreDevice()).catch(e=>h(`WebGPU device was lost and could not be restored`,e)),this._renderer.runners.contextChange.emit(this.gpu)}async _restoreDevice(){if(!this._renderer)return;let e=await this._createDeviceAndAdaptor(this._options);this._renderer?this._setGpu(e):e.device.destroy()}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){let t=await C.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter});if(!t)throw Error(`WebGPU not supported. No GPU adapter was returned by navigator.gpu.requestAdapter().`);let n=[`texture-compression-bc`,`texture-compression-astc`,`texture-compression-etc2`,`indirect-first-instance`,`bgra8unorm-storage`,`texture-formats-tier1`].filter(e=>t.features.has(e));return{adapter:t,device:await t.requestDevice({requiredFeatures:n,requiredLimits:{maxSampledTexturesPerShaderStage:t.limits.maxSampledTexturesPerShaderStage,maxSamplersPerShaderStage:t.limits.maxSamplersPerShaderStage,minUniformBufferOffsetAlignment:t.limits.minUniformBufferOffsetAlignment}})}}destroy(){this._options?.gpu||this.gpu?.device.destroy(),this.gpu=null,this.extensions=null,this._renderer=null}};I.extension={type:[r.WebGPUSystem],name:`device`},I.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var ye=class{constructor(e,t,n,r){this.gpuBundle=e,this.stateKey=t,this.device=n,this.label=r}},L=class{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e;for(let e=0;e<16;e++)this._boundBindGroup[e]={bindGroup:null,program:null,entry:null}}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){return this.endRenderPass(),this._clearCache(),this._passEncoder=this.commandEncoder.beginRenderPass(e.descriptor),this.renderPassEncoder=this._passEncoder,this._passEncoder}endRenderPass(){this._passEncoder&&this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null}beginBundle(e){if(this._passEncoder!==this.renderPassEncoder)throw Error(`Cannot begin a new render bundle while one is already being recorded.`);this._clearCache();let t=this._renderer.pipeline,n=t.getBundleDescriptor();n.label=e,this._bundleStateKey=t.bundleStateKey,this._bundleLabel=e,this.renderPassEncoder=this._gpu.device.createRenderBundleEncoder(n)}endBundle(){let e=this.renderPassEncoder;if(!e||!(`finish`in e))throw Error(`endBundle called without an active render bundle.`);let t=e.finish({label:this._bundleLabel});return this.renderPassEncoder=this._passEncoder,this._clearCache(),new ye(t,this._bundleStateKey,this._gpu.device,this._bundleLabel)}isBundleValid(e){return e?.stateKey===this._renderer.pipeline.bundleStateKey&&e.device===this._gpu.device}executeBundle(e){let t=[];if(Array.isArray(e))for(let n=0;n<e.length;n++)t[n]=this._getGpuBundle(e[n]);else t[0]=this._getGpuBundle(e);this._clearCache(),this._passEncoder.executeBundles(t)}_getGpuBundle(e){return this.isBundleValid(e)||h(`Render bundle ${e?.label??`(unlabeled)`} was recorded against a different render target state or on a lost device. Re-record it \u2014 replaying it will either be rejected by WebGPU or draw with the wrong winding. Check encoder.isBundleValid(bundle) before executing.`),e.gpuBundle}setViewport(e){this._passEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setStencilReference(e){this._passEncoder.setStencilReference(e)}setPipelineFromGeometryProgramAndState(e,t,n,r,i){let a=this._renderer.pipeline.getPipeline(e,t,n,r,i);this.setPipeline(a)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;let t=e.data.BYTES_PER_ELEMENT===2?`uint16`:`uint32`;this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){let t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.entry=null}setBindGroup(e,t,n){let r=this._boundBindGroup[e];if(r.bindGroup===t&&r.program===n&&r.entry===t._gpuEntry)return;r.bindGroup=t,r.program=n,t._touch(this._renderer.gc.now);let i=this._renderer.bindGroup.getBindGroup(t,n,e);r.entry=t._gpuEntry,this.renderPassEncoder.setBindGroup(e,i)}setGeometry(e,t){let n=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let t=0;t<n.length;t++)this._setVertexBuffer(t,e.attributes[n[t]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){let n=e.gpuProgram,r=n.layout;for(let i=0;i<r.length;i++){let a=e.groups[i];r[i]&&a&&(t||this._syncBindGroup(a),this.setBindGroup(i,a,n))}}_syncBindGroup(e){let t=e.resources,n=e._resourceKeys;for(let e=0;e<n.length;e++){let r=t[n[e]];r&&r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){let{geometry:t,shader:n,state:r,topology:i,size:a,start:o,baseVertex:s,instanceCount:c,skipSync:l,firstInstance:u}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,r,i,n._overrides),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,l),t.indexBuffer?this.renderPassEncoder.drawIndexed(a||t.indexCount||t.indexBuffer.data.length,c??t.instanceCount,o||0,s||0,u||0):this.renderPassEncoder.draw(a||t.vertexCount,c??t.instanceCount,o||0,u||0)}drawIndirect(e){let{geometry:t,shader:n,state:r,topology:i,skipSync:a,indirectBuffer:o,indirectOffset:s}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,r,i,n._overrides),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,a),t.indexBuffer?this.renderPassEncoder.drawIndexedIndirect(o,s):this.renderPassEncoder.drawIndirect(o,s)}finishRenderPass(){this._passEncoder&&=(this._passEncoder.end(),this.renderPassEncoder=null,null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}_clearCache(){for(let e=0;e<16;e++){let t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.entry=null,this._boundVertexBuffer[e]=null}this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null,this.renderPassEncoder=null,this._passEncoder=null}contextChange(e){this._gpu=e}};L.extension={type:[r.WebGPUSystem],name:`encoder`,priority:1};var R=class{constructor(e){this.supportsOverrideConstants=!1,this._renderer=e}contextChange(){let e=this._renderer.device.gpu.device;this.maxTextures=Math.min(e.limits.maxSampledTexturesPerShaderStage,e.limits.maxSamplersPerShaderStage),this.maxBatchableTextures=this.maxTextures,this.minUniformBufferOffsetAlignment=e.limits.minUniformBufferOffsetAlignment,this._detectOverrideConstantsSupport(e)}_detectOverrideConstantsSupport(e){e.pushErrorScope(`validation`);let t=e.createShaderModule({code:`override TEST_VALUE: f32 = 0.0;
1
+ import{A as e,Ct as t,Dt as n,Et as r,F as i,I as a,K as o,L as s,O as c,P as l,R as u,S as d,T as f,U as p,c as m,ct as h,dt as g,f as _,g as v,gt as y,l as b,m as x,pt as S,q as C,w,x as ee,xt as T,y as E,z as D}from"./index-41-d13J1.js";import{a as te,c as ne,f as re,i as ie,l as O,m as ae,n as oe,s as se,t as ce,u as le}from"./getTexelRangeRects-CRAnqulP.js";import{n as ue,r as de,t as fe}from"./RenderTargetSystem-um8Nv1HQ.js";import{t as k}from"./CanvasPool-SkgMbnEH.js";var A=l.for2d(),j=class{start(e,t,n){let r=e.renderer,i=r.encoder,a=n.gpuProgram;this._shader=n,this._geometry=t,i.setGeometry(t,a),A.blendMode=`normal`,r.pipeline.getPipeline(t,a,A,void 0,n._overrides);let o=r.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,a)}execute(e,t){let n=this._shader.gpuProgram,r=e.renderer,i=r.encoder;if(!t.bindGroup){let e=t.textures;t.bindGroup=b(e.textures,e.count,r.limits.maxBatchableTextures)}A.blendMode=t.blendMode;let a=r.bindGroup.getBindGroup(t.bindGroup,n,1),o=r.pipeline.getPipeline(this._geometry,n,A,t.topology,this._shader._overrides);t.bindGroup._touch(r.gc.now),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,a),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}};j.extension={type:[r.WebGPUPipesAdaptor],name:`batch`};var pe=0,me=class{constructor(e,t,n,r,i,a){this.autoGarbageCollect=!0,this._gpuData=null,this.gpuBindGroup=e,this._gcLastUsed=t,this.keyLow=n,this.keyHigh=r,this.layoutKey=i,this.cacheId=a}unload(){this.gpuBindGroup=null}},M=class{constructor(e){this._hash=Object.create(null),this._cacheId=0,this._renderer=e,e.gc.addResourceHash(this,`_hash`,`resource`),e.gc.addCollection(this,`_hash`,`hash`)}contextChange(e){this._gpu=e,this._cacheId=++pe,this._hash=Object.create(null)}getBindGroup(e,t,n){let r=t._layoutKey<<4|n,i=e._gpuEntry;if(i!==null&&e._gpuEntryLayoutKey===r&&i.gpuBindGroup!==null&&i.cacheId===this._cacheId)return i._gcLastUsed=this._renderer.gc.now,i.gpuBindGroup;let a=e._keyLow,o=e._keyHigh,s=(a^Math.imul(r+1,0x9e3779b1))&0x3fffffff;return i=this._hash[s],i&&i.keyLow===a&&i.keyHigh===o&&i.layoutKey===r?i._gcLastUsed=this._renderer.gc.now:(i=new me(this._createBindGroup(e,t,n),this._renderer.gc.now,a,o,r,this._cacheId),this._hash[s]=i),e._gpuEntry=i,e._gpuEntryLayoutKey=r,i.gpuBindGroup}_createBindGroup(e,t,n){let r=this._gpu.device,i=t.layout[n],a=e.layout,o=[],s=this._renderer;for(let t in i){let n=e.resources[a?a[t]:i[t]];if(!n||n.destroyed)throw Error(`[BindGroup] no usable resource for the shader's '${t}' binding: it was never set, was destroyed while a shader still uses it, or is missing from the bind group's layout.`);let r;if(n._resourceType===`uniformGroup`){let e=n;s.ubo.updateUniformGroup(e);let t=e.buffer;r={buffer:s.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if(n._resourceType===`buffer`){let e=n;r={buffer:s.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if(n._resourceType===`bufferResource`){let e=n;r={buffer:s.buffer.getGPUBuffer(e.buffer),offset:e.offset,size:e.size}}else if(n._resourceType===`textureSampler`){let e=n;r=s.texture.getGpuSampler(e)}else if(n._resourceType===`textureSource`){let e=n;r=s.texture.getTextureView(e)}else if(n._resourceType===`textureView`){let e=n;r=s.texture.getTextureView(e.source,e.viewDescriptor)}o.push({binding:i[t],resource:r})}let c=s.shader.getProgramData(t).bindGroups[n];return r.createBindGroup({layout:c,entries:o})}destroy(){this._hash=null,this._renderer=null}};M.extension={type:[r.WebGPUSystem],name:`bindGroup`};var he=class{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}},N=class{constructor(e){this._renderer=e,this._managedBuffers=new m({renderer:e,type:`resource`,onUnload:this.onBufferUnload.bind(this),name:`gpuBuffer`})}contextChange(e){this._gpu=e,this.destroyAll()}getGPUBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(e)}updateBuffer(e){let t=this.getGPUBuffer(e),n=e.data;return e._updateID&&n&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,e._updateOffset,n.buffer,n.byteOffset+e._updateOffset,(e._updateSize||n.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off(`update`,this.updateBuffer,this),e.off(`change`,this.onBufferChange,this)}createGPUBuffer(e){let t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&(f(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new he(t),this._managedBuffers.add(e)&&(e.on(`update`,this.updateBuffer,this),e.on(`change`,this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}};N.extension={type:[r.WebGPUSystem],name:`buffer`};var ge=class{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw Error(`UniformBufferBatch: array is too large: ${e*4}`);let t=this.byteIndex,n=t+e*4;if(n=Math.ceil(n/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,n>this.data.length*4)throw Error(`UniformBufferBatch: ubo batch got too big`);return this.byteIndex=n,t}addGroup(e){let t=this.addEmptyGroup(e.length);for(let n=0;n<e.length;n++)this.data[t/4+n]=e[n];return t}destroy(){this.data=null}},P=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}};P.extension={type:[r.WebGPUSystem],name:`colorMask`};function _e(e){let{userAgent:t}=C.get().getNavigator();if(!/AppleWebKit\//.test(t)||/Chrome\/|Chromium\//.test(t))return!1;if(!e)return!0;let n=/Version\/([\d.]+)/.exec(t)?.[1];return!n||!(e.from&&F(n,e.from)<0||e.before&&F(n,e.before)>=0)}function F(e,t){let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<Math.max(n.length,r.length);e++){let t=(parseInt(n[e],10)||0)-(parseInt(r[e],10)||0);if(t)return t}return 0}var ve=new Set([`apple`,`arm`,`qualcomm`,`img-tec`]),I=class{constructor(e){this._renderer=e}async init(e){return this._initPromise||=(this._options=e,(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(e=>this._setGpu(e))),this._initPromise}_setGpu(e){this.gpu=e,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT==`number`&&!_e({from:`27.1`,before:`28`}),tileBased:ve.has(e.adapter?.info?.vendor)},this._options.gpu||e.device.lost.then(()=>this._restoreDevice()).catch(e=>h(`WebGPU device was lost and could not be restored`,e)),this._renderer.runners.contextChange.emit(this.gpu)}async _restoreDevice(){if(!this._renderer)return;let e=await this._createDeviceAndAdaptor(this._options);this._renderer?this._setGpu(e):e.device.destroy()}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){let t=await C.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter});if(!t)throw Error(`WebGPU not supported. No GPU adapter was returned by navigator.gpu.requestAdapter().`);let n=[`texture-compression-bc`,`texture-compression-astc`,`texture-compression-etc2`,`indirect-first-instance`,`bgra8unorm-storage`,`texture-formats-tier1`].filter(e=>t.features.has(e));return{adapter:t,device:await t.requestDevice({requiredFeatures:n,requiredLimits:{maxSampledTexturesPerShaderStage:t.limits.maxSampledTexturesPerShaderStage,maxSamplersPerShaderStage:t.limits.maxSamplersPerShaderStage,minUniformBufferOffsetAlignment:t.limits.minUniformBufferOffsetAlignment}})}}destroy(){this._options?.gpu||this.gpu?.device.destroy(),this.gpu=null,this.extensions=null,this._renderer=null}};I.extension={type:[r.WebGPUSystem],name:`device`},I.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var ye=class{constructor(e,t,n,r){this.gpuBundle=e,this.stateKey=t,this.device=n,this.label=r}},L=class{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e;for(let e=0;e<16;e++)this._boundBindGroup[e]={bindGroup:null,program:null,entry:null}}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){return this.endRenderPass(),this._clearCache(),this._passEncoder=this.commandEncoder.beginRenderPass(e.descriptor),this.renderPassEncoder=this._passEncoder,this._passEncoder}endRenderPass(){this._passEncoder&&this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null}beginBundle(e){if(this._passEncoder!==this.renderPassEncoder)throw Error(`Cannot begin a new render bundle while one is already being recorded.`);this._clearCache();let t=this._renderer.pipeline,n=t.getBundleDescriptor();n.label=e,this._bundleStateKey=t.bundleStateKey,this._bundleLabel=e,this.renderPassEncoder=this._gpu.device.createRenderBundleEncoder(n)}endBundle(){let e=this.renderPassEncoder;if(!e||!(`finish`in e))throw Error(`endBundle called without an active render bundle.`);let t=e.finish({label:this._bundleLabel});return this.renderPassEncoder=this._passEncoder,this._clearCache(),new ye(t,this._bundleStateKey,this._gpu.device,this._bundleLabel)}isBundleValid(e){return e?.stateKey===this._renderer.pipeline.bundleStateKey&&e.device===this._gpu.device}executeBundle(e){let t=[];if(Array.isArray(e))for(let n=0;n<e.length;n++)t[n]=this._getGpuBundle(e[n]);else t[0]=this._getGpuBundle(e);this._clearCache(),this._passEncoder.executeBundles(t)}_getGpuBundle(e){return this.isBundleValid(e)||h(`Render bundle ${e?.label??`(unlabeled)`} was recorded against a different render target state or on a lost device. Re-record it \u2014 replaying it will either be rejected by WebGPU or draw with the wrong winding. Check encoder.isBundleValid(bundle) before executing.`),e.gpuBundle}setViewport(e){this._passEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setStencilReference(e){this._passEncoder.setStencilReference(e)}setPipelineFromGeometryProgramAndState(e,t,n,r,i){let a=this._renderer.pipeline.getPipeline(e,t,n,r,i);this.setPipeline(a)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;let t=e.data.BYTES_PER_ELEMENT===2?`uint16`:`uint32`;this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){let t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.entry=null}setBindGroup(e,t,n){let r=this._boundBindGroup[e];if(r.bindGroup===t&&r.program===n&&r.entry===t._gpuEntry)return;r.bindGroup=t,r.program=n,t._touch(this._renderer.gc.now);let i=this._renderer.bindGroup.getBindGroup(t,n,e);r.entry=t._gpuEntry,this.renderPassEncoder.setBindGroup(e,i)}setGeometry(e,t){let n=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let t=0;t<n.length;t++)this._setVertexBuffer(t,e.attributes[n[t]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){let n=e.gpuProgram,r=n.layout;for(let i=0;i<r.length;i++){let a=e.groups[i];r[i]&&a&&(t||this._syncBindGroup(a),this.setBindGroup(i,a,n))}}_syncBindGroup(e){let t=e.resources,n=e._resourceKeys;for(let e=0;e<n.length;e++){let r=t[n[e]];r&&r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){let{geometry:t,shader:n,state:r,topology:i,size:a,start:o,baseVertex:s,instanceCount:c,skipSync:l,firstInstance:u}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,r,i,n._overrides),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,l),t.indexBuffer?this.renderPassEncoder.drawIndexed(a||t.indexCount||t.indexBuffer.data.length,c??t.instanceCount,o||0,s||0,u||0):this.renderPassEncoder.draw(a||t.vertexCount,c??t.instanceCount,o||0,u||0)}drawIndirect(e){let{geometry:t,shader:n,state:r,topology:i,skipSync:a,indirectBuffer:o,indirectOffset:s}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,r,i,n._overrides),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,a),t.indexBuffer?this.renderPassEncoder.drawIndexedIndirect(o,s):this.renderPassEncoder.drawIndirect(o,s)}finishRenderPass(){this._passEncoder&&=(this._passEncoder.end(),this.renderPassEncoder=null,null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}_clearCache(){for(let e=0;e<16;e++){let t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.entry=null,this._boundVertexBuffer[e]=null}this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null,this.renderPassEncoder=null,this._passEncoder=null}contextChange(e){this._gpu=e}};L.extension={type:[r.WebGPUSystem],name:`encoder`,priority:1};var R=class{constructor(e){this.supportsOverrideConstants=!1,this._renderer=e}contextChange(){let e=this._renderer.device.gpu.device;this.maxTextures=Math.min(e.limits.maxSampledTexturesPerShaderStage,e.limits.maxSamplersPerShaderStage),this.maxBatchableTextures=this.maxTextures,this.minUniformBufferOffsetAlignment=e.limits.minUniformBufferOffsetAlignment,this._detectOverrideConstantsSupport(e)}_detectOverrideConstantsSupport(e){e.pushErrorScope(`validation`);let t=e.createShaderModule({code:`override TEST_VALUE: f32 = 0.0;
2
2
  @compute @workgroup_size(1) fn main() {}`});e.createComputePipeline({layout:`auto`,compute:{module:t,entryPoint:`main`,constants:{TEST_VALUE:1}}}),e.popErrorScope().then(e=>{this.supportsOverrideConstants=!e})}destroy(){}};R.extension={type:[r.WebGPUSystem],name:`limits`};var z=class{constructor(e){this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}contextChange(){this._activeGpuRenderTarget=null}onRenderTargetChange(e){let t=this._renderer.renderTarget.getGpuRenderTarget(e);this._activeRenderTarget=e,this._activeGpuRenderTarget=t,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let n=this._activeGpuRenderTarget??=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget);n.stencilMode=e,n.stencilReference=t;let r=this._renderer;r.pipeline.setStencilMode(e),r.encoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}};z.extension={type:[r.WebGPUSystem],name:`stencil`};var B={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function be(e){let t=e.map(e=>({data:e,offset:0,size:0})),n=0;for(let e=0;e<t.length;e++){let r=t[e],i=B[r.data.type].size,a=B[r.data.type].align;if(!B[r.data.type])throw Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${r.data.type}`);r.data.size>1&&(i=Math.max(i,a)*r.data.size),n=Math.ceil(n/a)*a,r.size=i,r.offset=n,n+=i}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function xe(e,t){let{size:n,align:r}=B[e.data.type],i=(Math.max(n,r)-n)/4,a=e.data.type.indexOf(`i32`)>=0?`dataInt32`:`data`;return`
3
3
  v = uv.${e.data.name};
4
4
  ${t===0?``:`offset += ${t};`}
@@ -1,4 +1,4 @@
1
- import{Dt as e,Et as t,G as n,Tt as r,W as i,Y as a,at as o,ct as s,wt as c}from"./index-CE-lli1m.js";import"./init-DfmWKarH.js";var l=class{constructor(e){this._lastTransform=``,this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let e=this._canvas.getBoundingClientRect(),t=this._canvas.width,n=this._canvas.height,r=e.width/t*this._renderer.resolution,i=e.height/n*this._renderer.resolution,a=`translate(${e.left}px, ${e.top}px) scale(${r}, ${i})`;a!==this._lastTransform&&(this._domElement.style.transform=a,this._lastTransform=a)},this._domElement=e.domElement,this._renderer=e.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas||(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){`ResizeObserver`in globalThis?(this._observer&&=(this._observer.disconnect(),null),this._observer=new ResizeObserver(e=>{for(let t of e){if(t.target!==this._canvas)continue;let e=this.canvas.width,n=this.canvas.height,r=t.contentRect.width/e*this._renderer.resolution,i=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==r||this._lastScaleY!==i)&&(this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=i)}}),this._observer.observe(this._canvas)):this._tickerAttached||=(i.shared.add(this.updateTranslation,this,n.HIGH),!0)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&i.shared.remove(this.updateTranslation,this),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform=``,this._lastScaleX=null,this._lastScaleY=null}},u=class e{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=e.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new c,this.page=new c,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,n){throw Error(`initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}initUIEvent(e,t,n,r,i){throw Error(`initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}},d=/iPhone/i,f=/iPod/i,p=/iPad/i,m=/\biOS-universal(?:.+)Mac\b/i,h=/\bAndroid(?:.+)Mobile\b/i,g=/Android/i,_=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,v=/Silk/i,y=/Windows Phone/i,b=/\bWindows(?:.+)ARM\b/i,x=/BlackBerry/i,S=/BB10/i,C=/Opera Mini/i,w=/\b(CriOS|Chrome)(?:.+)Mobile/i,T=/Mobile(?:.+)Firefox\b/i,E=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`};function D(e){return function(t){return t.test(e)}}function O(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=D(n),a={apple:{phone:i(d)&&!i(y),ipod:i(f),tablet:!i(d)&&(i(p)||E(t))&&!i(y),universal:i(m),device:(i(d)||i(f)||i(p)||i(m)||E(t))&&!i(y)},amazon:{phone:i(_),tablet:!i(_)&&i(v),device:i(_)||i(v)},android:{phone:!i(y)&&i(_)||!i(y)&&i(h),tablet:!i(y)&&!i(_)&&!i(h)&&(i(v)||i(g)),device:!i(y)&&(i(_)||i(v)||i(h)||i(g))||i(/\bokhttp\b/i)},windows:{phone:i(y),tablet:i(b),device:i(y)||i(b)},other:{blackberry:i(x),blackberry10:i(S),opera:i(C),firefox:i(T),chrome:i(w),device:i(x)||i(S)||i(C)||i(T)||i(w)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var k=(O.default??O)(globalThis.navigator),A=9,j=100,ee=0,M=0,N=2,P=1,F=-1e3,I=-1e3,L=2,R=class e{constructor(e,t=k){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let e=document.createElement(`button`);e.style.width=`${P}px`,e.style.height=`${P}px`,e.style.position=`absolute`,e.style.top=`${F}px`,e.style.left=`${I}px`,e.style.zIndex=L.toString(),e.style.backgroundColor=`#FF0000`,e.title=`select to enable accessibility for this content`,e.addEventListener(`focus`,()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&=(document.body.removeChild(this._hookDiv),null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement(`div`),this._div.style.position=`absolute`,this._div.style.top=`${ee}px`,this._div.style.left=`${M}px`,this._div.style.pointerEvents=`none`,this._div.style.zIndex=N.toString(),this._canvasObserver=new l({domElement:this._div,renderer:this._renderer})),this._deactivateOnMouseMove&&globalThis.document.addEventListener(`mousemove`,this._boundOnMouseMove,!0);let e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{let t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener(`mousemove`,this._boundOnMouseMove,!0),this._renderer.runners.postrender.remove(this);for(let e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(let e in this._pools)this._pools[e].forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);let t=e.children;if(t)for(let e=0;e<t.length;e++)this._updateAccessibleObjects(t[e])}init(t){let n={accessibilityOptions:{...e.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=n.accessibilityOptions.debug,this._activateOnTab=n.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=n.accessibilityOptions.deactivateOnMouseMove,this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),n.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){let e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;let t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(let e of this._children)e._renderId===this._renderId&&t.add(this._children.indexOf(e))}for(let e=this._children.length-1;e>=0;e--){let n=this._children[e];t.has(e)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,o(this._children,e,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let e=0;e<this._children.length;e++){let t=this._children[e];if(!t._accessibleActive||!t._accessibleDiv)continue;let n=t._accessibleDiv,r=t.hitArea||t.getBounds().rectangle;if(t.hitArea){let e=t.worldTransform;n.style.left=`${e.tx+r.x*e.a}px`,n.style.top=`${e.ty+r.y*e.d}px`,n.style.width=`${r.width*e.a}px`,n.style.height=`${r.height*e.d}px`}else this._capHitArea(r),n.style.left=`${r.x}px`,n.style.top=`${r.y}px`,n.style.width=`${r.width}px`,n.style.height=`${r.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);let{width:t,height:n}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>n&&(e.height=n-e.y)}_addChild(e){let t=this._getPool(e.accessibleType).pop();t?(t.innerHTML=``,t.removeAttribute(`title`),t.removeAttribute(`aria-label`),t.tabIndex=0):(e.accessibleType===`button`?(t=document.createElement(`button`),this.debug||(t.style.color=`transparent`)):(t=document.createElement(e.accessibleType),t.style.cssText=`
1
+ import{Dt as e,Et as t,G as n,Tt as r,W as i,Y as a,at as o,ct as s,wt as c}from"./index-41-d13J1.js";import"./init-D6nA7FlC.js";var l=class{constructor(e){this._lastTransform=``,this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let e=this._canvas.getBoundingClientRect(),t=this._canvas.width,n=this._canvas.height,r=e.width/t*this._renderer.resolution,i=e.height/n*this._renderer.resolution,a=`translate(${e.left}px, ${e.top}px) scale(${r}, ${i})`;a!==this._lastTransform&&(this._domElement.style.transform=a,this._lastTransform=a)},this._domElement=e.domElement,this._renderer=e.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas||(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){`ResizeObserver`in globalThis?(this._observer&&=(this._observer.disconnect(),null),this._observer=new ResizeObserver(e=>{for(let t of e){if(t.target!==this._canvas)continue;let e=this.canvas.width,n=this.canvas.height,r=t.contentRect.width/e*this._renderer.resolution,i=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==r||this._lastScaleY!==i)&&(this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=i)}}),this._observer.observe(this._canvas)):this._tickerAttached||=(i.shared.add(this.updateTranslation,this,n.HIGH),!0)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&i.shared.remove(this.updateTranslation,this),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform=``,this._lastScaleX=null,this._lastScaleY=null}},u=class e{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=e.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new c,this.page=new c,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,n){throw Error(`initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}initUIEvent(e,t,n,r,i){throw Error(`initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}},d=/iPhone/i,f=/iPod/i,p=/iPad/i,m=/\biOS-universal(?:.+)Mac\b/i,h=/\bAndroid(?:.+)Mobile\b/i,g=/Android/i,_=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,v=/Silk/i,y=/Windows Phone/i,b=/\bWindows(?:.+)ARM\b/i,x=/BlackBerry/i,S=/BB10/i,C=/Opera Mini/i,w=/\b(CriOS|Chrome)(?:.+)Mobile/i,T=/Mobile(?:.+)Firefox\b/i,E=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`};function D(e){return function(t){return t.test(e)}}function O(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=D(n),a={apple:{phone:i(d)&&!i(y),ipod:i(f),tablet:!i(d)&&(i(p)||E(t))&&!i(y),universal:i(m),device:(i(d)||i(f)||i(p)||i(m)||E(t))&&!i(y)},amazon:{phone:i(_),tablet:!i(_)&&i(v),device:i(_)||i(v)},android:{phone:!i(y)&&i(_)||!i(y)&&i(h),tablet:!i(y)&&!i(_)&&!i(h)&&(i(v)||i(g)),device:!i(y)&&(i(_)||i(v)||i(h)||i(g))||i(/\bokhttp\b/i)},windows:{phone:i(y),tablet:i(b),device:i(y)||i(b)},other:{blackberry:i(x),blackberry10:i(S),opera:i(C),firefox:i(T),chrome:i(w),device:i(x)||i(S)||i(C)||i(T)||i(w)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var k=(O.default??O)(globalThis.navigator),A=9,j=100,ee=0,M=0,N=2,P=1,F=-1e3,I=-1e3,L=2,R=class e{constructor(e,t=k){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let e=document.createElement(`button`);e.style.width=`${P}px`,e.style.height=`${P}px`,e.style.position=`absolute`,e.style.top=`${F}px`,e.style.left=`${I}px`,e.style.zIndex=L.toString(),e.style.backgroundColor=`#FF0000`,e.title=`select to enable accessibility for this content`,e.addEventListener(`focus`,()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&=(document.body.removeChild(this._hookDiv),null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement(`div`),this._div.style.position=`absolute`,this._div.style.top=`${ee}px`,this._div.style.left=`${M}px`,this._div.style.pointerEvents=`none`,this._div.style.zIndex=N.toString(),this._canvasObserver=new l({domElement:this._div,renderer:this._renderer})),this._deactivateOnMouseMove&&globalThis.document.addEventListener(`mousemove`,this._boundOnMouseMove,!0);let e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{let t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener(`mousemove`,this._boundOnMouseMove,!0),this._renderer.runners.postrender.remove(this);for(let e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(let e in this._pools)this._pools[e].forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);let t=e.children;if(t)for(let e=0;e<t.length;e++)this._updateAccessibleObjects(t[e])}init(t){let n={accessibilityOptions:{...e.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=n.accessibilityOptions.debug,this._activateOnTab=n.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=n.accessibilityOptions.deactivateOnMouseMove,this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),n.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){let e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;let t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(let e of this._children)e._renderId===this._renderId&&t.add(this._children.indexOf(e))}for(let e=this._children.length-1;e>=0;e--){let n=this._children[e];t.has(e)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,o(this._children,e,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let e=0;e<this._children.length;e++){let t=this._children[e];if(!t._accessibleActive||!t._accessibleDiv)continue;let n=t._accessibleDiv,r=t.hitArea||t.getBounds().rectangle;if(t.hitArea){let e=t.worldTransform;n.style.left=`${e.tx+r.x*e.a}px`,n.style.top=`${e.ty+r.y*e.d}px`,n.style.width=`${r.width*e.a}px`,n.style.height=`${r.height*e.d}px`}else this._capHitArea(r),n.style.left=`${r.x}px`,n.style.top=`${r.y}px`,n.style.width=`${r.width}px`,n.style.height=`${r.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);let{width:t,height:n}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>n&&(e.height=n-e.y)}_addChild(e){let t=this._getPool(e.accessibleType).pop();t?(t.innerHTML=``,t.removeAttribute(`title`),t.removeAttribute(`aria-label`),t.tabIndex=0):(e.accessibleType===`button`?(t=document.createElement(`button`),this.debug||(t.style.color=`transparent`)):(t=document.createElement(e.accessibleType),t.style.cssText=`
2
2
  color: transparent;
3
3
  pointer-events: none;
4
4
  padding: 0;
@@ -1 +1 @@
1
- import{St as e,lt as t,q as n}from"./index-CE-lli1m.js";var r;function i(e){let t=n.get().createCanvas(6,1),r=t.getContext(`2d`);return r.fillStyle=e,r.fillRect(0,0,6,1),t}function a(){if(r!==void 0)return r;try{let e=i(`#ff00ff`),t=i(`#ffff00`),a=n.get().createCanvas(6,1).getContext(`2d`);a.globalCompositeOperation=`multiply`,a.drawImage(e,0,0),a.drawImage(t,2,0);let o=a.getImageData(2,0,1,1);if(!o)r=!1;else{let e=o.data;r=e[0]===255&&e[1]===0&&e[2]===0}}catch{r=!1}return r}var o={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,_canUseMultiply:void 0,get canUseMultiply(){return this._canUseMultiply??=a()},set canUseMultiply(e){this._canUseMultiply=e},_tintMethod:null,get tintMethod(){return this._tintMethod??=this.canUseMultiply?this.tintWithMultiply:this.tintWithPerPixel},set tintMethod(e){this._tintMethod=e},_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:e=>{let t=e.source,r=t?.resource;if(!r)return null;let i=t.alphaMode===`premultiplied-alpha`,a=t.resourceWidth??t.pixelWidth,s=t.resourceHeight??t.pixelHeight,c=a!==t.pixelWidth||s!==t.pixelHeight;if(i){if((r instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&r instanceof OffscreenCanvas)&&!c)return r;let e=o._unpremultipliedCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas}if(r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int8Array||r instanceof Uint16Array||r instanceof Int16Array||r instanceof Uint32Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof ArrayBuffer){let e=o._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let i=n.get().createCanvas(t.pixelWidth,t.pixelHeight),a=i.getContext(`2d`),s=a.createImageData(t.pixelWidth,t.pixelHeight),c=s.data,l=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength);if(t.format===`bgra8unorm`)for(let e=0;e<c.length&&e+3<l.length;e+=4)c[e]=l[e+2],c[e+1]=l[e+1],c[e+2]=l[e],c[e+3]=l[e+3];else c.set(l.subarray(0,c.length));return a.putImageData(s,0,0),o._canvasSourceCache.set(t,{canvas:i,resourceId:t._resourceId}),i}if(i){let e=n.get().createCanvas(t.pixelWidth,t.pixelHeight),i=e.getContext(`2d`,{willReadFrequently:!0});e.width=t.pixelWidth,e.height=t.pixelHeight,i.drawImage(r,0,0);let a=i.getImageData(0,0,e.width,e.height),s=a.data;for(let e=0;e<s.length;e+=4){let t=s[e+3];if(t>0){let n=255/t;s[e]=Math.min(255,s[e]*n+.5),s[e+1]=Math.min(255,s[e+1]*n+.5),s[e+2]=Math.min(255,s[e+2]*n+.5)}}return i.putImageData(a,0,0),o._unpremultipliedCache.set(t,{canvas:e,resourceId:t._resourceId}),e}if(c){let e=o._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let i=n.get().createCanvas(t.pixelWidth,t.pixelHeight),a=i.getContext(`2d`);return i.width=t.pixelWidth,i.height=t.pixelHeight,a.drawImage(r,0,0),o._canvasSourceCache.set(t,{canvas:i,resourceId:t._resourceId}),i}return r},getTintedCanvas:(e,r)=>{let i=e.texture,a=t.shared.setValue(r).toHex(),s=i.tintCache||={},c=s[a],l=i.source._resourceId;if(c?.tintId===l)return c;let u=c&&`getContext`in c?c:n.get().createCanvas();if(o.tintMethod(i,r,u),u.tintId=l,o.convertTintToImage&&u.toDataURL!==void 0){let e=n.get().createImage();e.src=u.toDataURL(),e.tintId=l,s[a]=e}else s[a]=u;return s[a]},getTintedPattern:(e,r)=>{let i=t.shared.setValue(r).toHex(),a=e.patternCache||={},s=e.source._resourceId,c=a[i];return c?.tintId===s||(o.canvas||=n.get().createCanvas(),o.tintMethod(e,r,o.canvas),c=o.canvas.getContext(`2d`).createPattern(o.canvas,`repeat`),c.tintId=s,a[i]=c),c},applyPatternTransform:(e,t,n=!0)=>{if(!t)return;let r=e;if(!r.setTransform)return;let i=globalThis.DOMMatrix;if(!i)return;let a=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);r.setTransform(n?a.inverse():a)},tintWithMultiply:(n,r,i)=>{let a=i.getContext(`2d`),s=n.frame.clone(),c=n.source._resolution??n.source.resolution??1,l=n.rotate;s.x*=c,s.y*=c,s.width*=c,s.height*=c;let u=e.isVertical(l),d=u?s.height:s.width,f=u?s.width:s.height;i.width=Math.ceil(d),i.height=Math.ceil(f),a.save(),r!==0xffffff&&(a.fillStyle=t.shared.setValue(r).toHex(),a.fillRect(0,0,d,f),a.globalCompositeOperation=`multiply`);let p=o.getCanvasSource(n);p&&(l&&o._applyInverseRotation(a,l,s.width,s.height),a.drawImage(p,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r!==0xffffff&&(a.globalCompositeOperation=`destination-atop`,a.drawImage(p,s.x,s.y,s.width,s.height,0,0,s.width,s.height))),a.restore()},tintWithOverlay:(n,r,i)=>{let a=i.getContext(`2d`),s=n.frame.clone(),c=n.source._resolution??n.source.resolution??1,l=n.rotate;s.x*=c,s.y*=c,s.width*=c,s.height*=c;let u=e.isVertical(l),d=u?s.height:s.width,f=u?s.width:s.height;i.width=Math.ceil(d),i.height=Math.ceil(f),a.save(),a.globalCompositeOperation=`copy`,a.fillStyle=t.shared.setValue(r).toHex(),a.fillRect(0,0,d,f),a.globalCompositeOperation=`destination-atop`;let p=o.getCanvasSource(n);p&&(l&&o._applyInverseRotation(a,l,s.width,s.height),a.drawImage(p,s.x,s.y,s.width,s.height,0,0,s.width,s.height)),a.restore()},tintWithPerPixel:(t,n,r)=>{let i=r.getContext(`2d`),a=t.frame.clone(),s=t.source._resolution??t.source.resolution??1,c=t.rotate;a.x*=s,a.y*=s,a.width*=s,a.height*=s;let l=e.isVertical(c),u=l?a.height:a.width,d=l?a.width:a.height;r.width=Math.ceil(u),r.height=Math.ceil(d),i.save(),i.globalCompositeOperation=`copy`;let f=o.getCanvasSource(t);if(!f){i.restore();return}c&&o._applyInverseRotation(i,c,a.width,a.height),i.drawImage(f,a.x,a.y,a.width,a.height,0,0,a.width,a.height),i.restore();let p=n>>16&255,m=n>>8&255,h=n&255,g=i.getImageData(0,0,u,d),_=g.data;for(let e=0;e<_.length;e+=4)_[e]=_[e]*p/255,_[e+1]=_[e+1]*m/255,_[e+2]=_[e+2]*h/255;i.putImageData(g,0,0)},_applyInverseRotation:(t,n,r,i)=>{let a=e.inv(n),o=e.uX(a),s=e.uY(a),c=e.vX(a),l=e.vY(a),u=-Math.min(0,o*r,c*i,o*r+c*i),d=-Math.min(0,s*r,l*i,s*r+l*i);t.transform(o,s,c,l,u,d)}};export{a as n,o as t};
1
+ import{St as e,lt as t,q as n}from"./index-41-d13J1.js";var r;function i(e){let t=n.get().createCanvas(6,1),r=t.getContext(`2d`);return r.fillStyle=e,r.fillRect(0,0,6,1),t}function a(){if(r!==void 0)return r;try{let e=i(`#ff00ff`),t=i(`#ffff00`),a=n.get().createCanvas(6,1).getContext(`2d`);a.globalCompositeOperation=`multiply`,a.drawImage(e,0,0),a.drawImage(t,2,0);let o=a.getImageData(2,0,1,1);if(!o)r=!1;else{let e=o.data;r=e[0]===255&&e[1]===0&&e[2]===0}}catch{r=!1}return r}var o={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,_canUseMultiply:void 0,get canUseMultiply(){return this._canUseMultiply??=a()},set canUseMultiply(e){this._canUseMultiply=e},_tintMethod:null,get tintMethod(){return this._tintMethod??=this.canUseMultiply?this.tintWithMultiply:this.tintWithPerPixel},set tintMethod(e){this._tintMethod=e},_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:e=>{let t=e.source,r=t?.resource;if(!r)return null;let i=t.alphaMode===`premultiplied-alpha`,a=t.resourceWidth??t.pixelWidth,s=t.resourceHeight??t.pixelHeight,c=a!==t.pixelWidth||s!==t.pixelHeight;if(i){if((r instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&r instanceof OffscreenCanvas)&&!c)return r;let e=o._unpremultipliedCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas}if(r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int8Array||r instanceof Uint16Array||r instanceof Int16Array||r instanceof Uint32Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof ArrayBuffer){let e=o._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let i=n.get().createCanvas(t.pixelWidth,t.pixelHeight),a=i.getContext(`2d`),s=a.createImageData(t.pixelWidth,t.pixelHeight),c=s.data,l=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength);if(t.format===`bgra8unorm`)for(let e=0;e<c.length&&e+3<l.length;e+=4)c[e]=l[e+2],c[e+1]=l[e+1],c[e+2]=l[e],c[e+3]=l[e+3];else c.set(l.subarray(0,c.length));return a.putImageData(s,0,0),o._canvasSourceCache.set(t,{canvas:i,resourceId:t._resourceId}),i}if(i){let e=n.get().createCanvas(t.pixelWidth,t.pixelHeight),i=e.getContext(`2d`,{willReadFrequently:!0});e.width=t.pixelWidth,e.height=t.pixelHeight,i.drawImage(r,0,0);let a=i.getImageData(0,0,e.width,e.height),s=a.data;for(let e=0;e<s.length;e+=4){let t=s[e+3];if(t>0){let n=255/t;s[e]=Math.min(255,s[e]*n+.5),s[e+1]=Math.min(255,s[e+1]*n+.5),s[e+2]=Math.min(255,s[e+2]*n+.5)}}return i.putImageData(a,0,0),o._unpremultipliedCache.set(t,{canvas:e,resourceId:t._resourceId}),e}if(c){let e=o._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let i=n.get().createCanvas(t.pixelWidth,t.pixelHeight),a=i.getContext(`2d`);return i.width=t.pixelWidth,i.height=t.pixelHeight,a.drawImage(r,0,0),o._canvasSourceCache.set(t,{canvas:i,resourceId:t._resourceId}),i}return r},getTintedCanvas:(e,r)=>{let i=e.texture,a=t.shared.setValue(r).toHex(),s=i.tintCache||={},c=s[a],l=i.source._resourceId;if(c?.tintId===l)return c;let u=c&&`getContext`in c?c:n.get().createCanvas();if(o.tintMethod(i,r,u),u.tintId=l,o.convertTintToImage&&u.toDataURL!==void 0){let e=n.get().createImage();e.src=u.toDataURL(),e.tintId=l,s[a]=e}else s[a]=u;return s[a]},getTintedPattern:(e,r)=>{let i=t.shared.setValue(r).toHex(),a=e.patternCache||={},s=e.source._resourceId,c=a[i];return c?.tintId===s||(o.canvas||=n.get().createCanvas(),o.tintMethod(e,r,o.canvas),c=o.canvas.getContext(`2d`).createPattern(o.canvas,`repeat`),c.tintId=s,a[i]=c),c},applyPatternTransform:(e,t,n=!0)=>{if(!t)return;let r=e;if(!r.setTransform)return;let i=globalThis.DOMMatrix;if(!i)return;let a=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);r.setTransform(n?a.inverse():a)},tintWithMultiply:(n,r,i)=>{let a=i.getContext(`2d`),s=n.frame.clone(),c=n.source._resolution??n.source.resolution??1,l=n.rotate;s.x*=c,s.y*=c,s.width*=c,s.height*=c;let u=e.isVertical(l),d=u?s.height:s.width,f=u?s.width:s.height;i.width=Math.ceil(d),i.height=Math.ceil(f),a.save(),r!==0xffffff&&(a.fillStyle=t.shared.setValue(r).toHex(),a.fillRect(0,0,d,f),a.globalCompositeOperation=`multiply`);let p=o.getCanvasSource(n);p&&(l&&o._applyInverseRotation(a,l,s.width,s.height),a.drawImage(p,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r!==0xffffff&&(a.globalCompositeOperation=`destination-atop`,a.drawImage(p,s.x,s.y,s.width,s.height,0,0,s.width,s.height))),a.restore()},tintWithOverlay:(n,r,i)=>{let a=i.getContext(`2d`),s=n.frame.clone(),c=n.source._resolution??n.source.resolution??1,l=n.rotate;s.x*=c,s.y*=c,s.width*=c,s.height*=c;let u=e.isVertical(l),d=u?s.height:s.width,f=u?s.width:s.height;i.width=Math.ceil(d),i.height=Math.ceil(f),a.save(),a.globalCompositeOperation=`copy`,a.fillStyle=t.shared.setValue(r).toHex(),a.fillRect(0,0,d,f),a.globalCompositeOperation=`destination-atop`;let p=o.getCanvasSource(n);p&&(l&&o._applyInverseRotation(a,l,s.width,s.height),a.drawImage(p,s.x,s.y,s.width,s.height,0,0,s.width,s.height)),a.restore()},tintWithPerPixel:(t,n,r)=>{let i=r.getContext(`2d`),a=t.frame.clone(),s=t.source._resolution??t.source.resolution??1,c=t.rotate;a.x*=s,a.y*=s,a.width*=s,a.height*=s;let l=e.isVertical(c),u=l?a.height:a.width,d=l?a.width:a.height;r.width=Math.ceil(u),r.height=Math.ceil(d),i.save(),i.globalCompositeOperation=`copy`;let f=o.getCanvasSource(t);if(!f){i.restore();return}c&&o._applyInverseRotation(i,c,a.width,a.height),i.drawImage(f,a.x,a.y,a.width,a.height,0,0,a.width,a.height),i.restore();let p=n>>16&255,m=n>>8&255,h=n&255,g=i.getImageData(0,0,u,d),_=g.data;for(let e=0;e<_.length;e+=4)_[e]=_[e]*p/255,_[e+1]=_[e+1]*m/255,_[e+2]=_[e+2]*h/255;i.putImageData(g,0,0)},_applyInverseRotation:(t,n,r,i)=>{let a=e.inv(n),o=e.uX(a),s=e.uY(a),c=e.vX(a),l=e.vY(a),u=-Math.min(0,o*r,c*i,o*r+c*i),d=-Math.min(0,s*r,l*i,s*r+l*i);t.transform(o,s,c,l,u,d)}};export{a as n,o as t};
@@ -1,4 +1,4 @@
1
- import{S as e,Tt as t,V as n,bt as r,ct as i,j as a,w as o,x as s}from"./index-CE-lli1m.js";var c={name:`local-uniform-bit`,vertex:{header:`
1
+ import{S as e,Tt as t,V as n,bt as r,ct as i,j as a,w as o,x as s}from"./index-41-d13J1.js";var c={name:`local-uniform-bit`,vertex:{header:`
2
2
 
3
3
  struct LocalUniforms {
4
4
  uTransformMatrix:mat3x3<f32>,