expxagents 0.15.11 → 0.15.13

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.
@@ -19,15 +19,16 @@ You are the Solution Architect of ExpxAgents. You design AI agent squads that ex
19
19
  - **Role:** Design squads by understanding user needs, researching context, and generating complete configurations
20
20
  - **Communication:** Clear, structured, asks precise questions
21
21
 
22
- ## Discovery Phase (max 5 questions)
22
+ ## Discovery Phase (max 6 questions)
23
23
 
24
24
  Before designing, gather requirements through focused questions:
25
25
 
26
- 1. **Objective:** What specific outcome do you want this squad to produce?
27
- 2. **Context:** Who is the target audience and what platform/format?
28
- 3. **Process:** Are there specific steps or stages you want in the workflow?
29
- 4. **Quality:** What are the quality criteria for the final output?
30
- 5. **References:** Any reference profiles, competitors, or examples to investigate?
26
+ 1. **Group:** Which group does this squad belong to? (e.g., marketing, commercial, development, support, finance, hr, operations). The group name will be used as a prefix for the squad code: `<group>-<squad-name>`.
27
+ 2. **Objective:** What specific outcome do you want this squad to produce?
28
+ 3. **Context:** Who is the target audience and what platform/format?
29
+ 4. **Process:** Are there specific steps or stages you want in the workflow?
30
+ 5. **Quality:** What are the quality criteria for the final output?
31
+ 6. **References:** Any reference profiles, competitors, or examples to investigate?
31
32
 
32
33
  If the user provides reference URLs, delegate to the **Insight Hunter** to investigate before designing.
33
34
 
@@ -47,7 +48,8 @@ After discovery, generate the complete squad structure:
47
48
 
48
49
  ```yaml
49
50
  squad:
50
- code: <kebab-case>
51
+ code: <group>-<squad-name> # e.g., marketing-landing-page, commercial-outbound
52
+ group: <group> # e.g., marketing, commercial, development
51
53
  name: <Human Readable Name>
52
54
  description: <What this squad produces>
53
55
  icon: <emoji-name>
@@ -22,6 +22,7 @@ export interface ScheduleConfig {
22
22
  export interface SquadConfig {
23
23
  squad: {
24
24
  code: string;
25
+ group?: string;
25
26
  name: string;
26
27
  description: string;
27
28
  icon: string;
@@ -72,9 +72,11 @@ export function loadSquad(squadDir) {
72
72
  else if (rawSchedule) {
73
73
  schedule = { ...rawSchedule, enabled: false };
74
74
  }
75
+ const group = squad.group;
75
76
  return {
76
77
  squad: {
77
78
  code: squad.code,
79
+ group,
78
80
  name: squad.name,
79
81
  description: squad.description,
80
82
  icon: squad.icon,
@@ -1,4 +1,4 @@
1
- import{w as U,g,S as c,d as S,B as _,e as m,E as I,f as p}from"./index-DGn2ljNa.js";const x={name:"local-uniform-bit",vertex:{header:`
1
+ import{w as U,g,S as c,e as S,B as _,f as m,E as I,h as p}from"./index-CnMelTt1.js";const x={name:"local-uniform-bit",vertex:{header:`
2
2
 
3
3
  struct LocalUniforms {
4
4
  uTransformMatrix:mat3x3<f32>,
@@ -54,7 +54,7 @@ import{w as U,g,S as c,d as S,B as _,e as m,E as I,f as p}from"./index-DGn2ljNa.
54
54
 
55
55
  `,main:`
56
56
  outColor = texture(uTexture, vUV);
57
- `}};function A(e,t){for(const a in e.attributes){const s=e.attributes[a],r=t[a];r?(s.format??(s.format=r.format),s.offset??(s.offset=r.offset),s.instance??(s.instance=r.instance)):U(`Attribute ${a} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}M(e)}function M(e){const{buffers:t,attributes:a}=e,s={},r={};for(const n in t){const o=t[n];s[o.uid]=0,r[o.uid]=0}for(const n in a){const o=a[n];s[o.buffer.uid]+=g(o.format).stride}for(const n in a){const o=a[n];o.stride??(o.stride=s[o.buffer.uid]),o.start??(o.start=r[o.buffer.uid]),r[o.buffer.uid]+=g(o.format).stride}}const d=[];d[c.NONE]=void 0;d[c.DISABLED]={stencilWriteMask:0,stencilReadMask:0};d[c.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};d[c.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};d[c.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};d[c.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class B{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!S())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const a=this.getUniformGroupData(t);t.buffer||(t.buffer=new _({data:new Float32Array(a.layout.size/4),usage:m.UNIFORM|m.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const a=t._signature;let s=this._syncFunctionHash[a];if(!s){const r=Object.keys(t.uniformStructures).map(l=>t.uniformStructures[l]),n=this._adaptor.createUboElements(r),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[a]={layout:n,syncFunction:o}}return this._syncFunctionHash[a]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,a,s){const r=this.getUniformGroupData(t);t.buffer||(t.buffer=new _({data:new Float32Array(r.layout.size/4),usage:m.UNIFORM|m.COPY_DST}));let n=null;return a||(a=t.buffer.data,n=t.buffer.dataInt32),s||(s=0),r.syncFunction(t.uniforms,a,n,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const a=this.syncUniformGroup(t);return t.buffer.update(),a}destroy(){this._syncFunctionHash=null}}const h=[{type:"mat3x3<f32>",test:e=>e.value.a!==void 0,ubo:`
57
+ `}};function A(e,t){for(const a in e.attributes){const s=e.attributes[a],r=t[a];r?(s.format??(s.format=r.format),s.offset??(s.offset=r.offset),s.instance??(s.instance=r.instance)):U(`Attribute ${a} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}M(e)}function M(e){const{buffers:t,attributes:a}=e,s={},r={};for(const n in t){const o=t[n];s[o.uid]=0,r[o.uid]=0}for(const n in a){const o=a[n];s[o.buffer.uid]+=g(o.format).stride}for(const n in a){const o=a[n];o.stride??(o.stride=s[o.buffer.uid]),o.start??(o.start=r[o.buffer.uid]),r[o.buffer.uid]+=g(o.format).stride}}const l=[];l[c.NONE]=void 0;l[c.DISABLED]={stencilWriteMask:0,stencilReadMask:0};l[c.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};l[c.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};l[c.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};l[c.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class B{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!S())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const a=this.getUniformGroupData(t);t.buffer||(t.buffer=new _({data:new Float32Array(a.layout.size/4),usage:m.UNIFORM|m.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const a=t._signature;let s=this._syncFunctionHash[a];if(!s){const r=Object.keys(t.uniformStructures).map(d=>t.uniformStructures[d]),n=this._adaptor.createUboElements(r),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[a]={layout:n,syncFunction:o}}return this._syncFunctionHash[a]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,a,s){const r=this.getUniformGroupData(t);t.buffer||(t.buffer=new _({data:new Float32Array(r.layout.size/4),usage:m.UNIFORM|m.COPY_DST}));let n=null;return a||(a=t.buffer.data,n=t.buffer.dataInt32),s||(s=0),r.syncFunction(t.uniforms,a,n,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const a=this.syncUniformGroup(t);return t.buffer.update(),a}destroy(){this._syncFunctionHash=null}}const h=[{type:"mat3x3<f32>",test:e=>e.value.a!==void 0,ubo:`
58
58
  var matrix = uv[name].toArray(true);
59
59
  data[offset] = matrix[0];
60
60
  data[offset + 1] = matrix[1];
@@ -132,7 +132,7 @@ import{w as U,g,S as c,d as S,B as _,e as m,E as I,f as p}from"./index-DGn2ljNa.
132
132
  var index = 0;
133
133
  var name = null;
134
134
  var arrayOffset = null;
135
- `];let n=0;for(let l=0;l<e.length;l++){const f=e[l],b=f.data.name;let y=!1,i=0;for(let u=0;u<h.length;u++)if(h[u].test(f.data)){i=f.offset/4,r.push(`name = "${b}";`,`offset += ${i-n};`,h[u][t]||h[u].ubo),y=!0;break}if(!y)if(f.data.size>1)i=f.offset/4,r.push(a(f,i-n));else{const u=s[f.data.type];i=f.offset/4,r.push(`
135
+ `];let n=0;for(let d=0;d<e.length;d++){const f=e[d],b=f.data.name;let y=!1,i=0;for(let u=0;u<h.length;u++)if(h[u].test(f.data)){i=f.offset/4,r.push(`name = "${b}";`,`offset += ${i-n};`,h[u][t]||h[u].ubo),y=!0;break}if(!y)if(f.data.size>1)i=f.offset/4,r.push(a(f,i-n));else{const u=s[f.data.type];i=f.offset/4,r.push(`
136
136
  v = uv.${b};
137
137
  offset += ${i-n};
138
138
  ${u};
@@ -182,4 +182,4 @@ import{w as U,g,S as c,d as S,B as _,e as m,E as I,f as p}from"./index-DGn2ljNa.
182
182
  data[offset + 1] = v[1];
183
183
  data[offset + 2] = v[2];
184
184
  data[offset + 3] = v[3];
185
- `};class P extends I{constructor({buffer:t,offset:a,size:s}){super(),this.uid=p("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=p("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=a|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=p("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}export{P as B,d as G,B as U,x as a,F as b,k as c,h as d,A as e,D as f,R as g,C as l,O as t,w as u};
185
+ `};class P extends I{constructor({buffer:t,offset:a,size:s}){super(),this.uid=p("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=p("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=a|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=p("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}export{P as B,l as G,B as U,x as a,F as b,k as c,h as d,A as e,D as f,R as g,C as l,O as t,w as u};
@@ -1 +1 @@
1
- import{D as E,C as ee,h as D,i as Re,m as ce,M as F,k as R,G as Xe,w as $e,T as He,l as ze,n as Je,o as Ke,F as Qe,p as Ze,q as et,A as tt,R as nt,t as he}from"./index-DGn2ljNa.js";import{R as at,S as st,B as ot,a as rt,b as it,c as ct,A as lt,C as ht}from"./RenderTargetSystem-C1V_CUBl.js";let Z;function Ae(o){const e=E.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=o,t.fillRect(0,0,6,1),e}function Be(){if(Z!==void 0)return Z;try{const o=Ae("#ff00ff"),e=Ae("#ffff00"),a=E.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(o,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)Z=!1;else{const s=n.data;Z=s[0]===255&&s[1]===0&&s[2]===0}}catch{Z=!1}return Z}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Be(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:o=>{const e=o.source,t=e==null?void 0:e.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,s=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||s!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),f=l.data,x=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let p=0;p<f.length&&p+3<x.length;p+=4)f[p]=x[p+2],f[p+1]=x[p+1],f[p+2]=x[p],f[p+3]=x[p+3];else f.set(x.subarray(0,f.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=E.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let f=0;f<l.length;f+=4){const x=l[f+3];if(x>0){const p=255/x;l[f]=Math.min(255,l[f]*p+.5),l[f+1]=Math.min(255,l[f+1]*p+.5),l[f+2]=Math.min(255,l[f+2]*p+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(o,e)=>{const t=o.texture,a=ee.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),s=n[a],r=t.source._resourceId;if((s==null?void 0:s.tintId)===r)return s;const i=s&&"getContext"in s?s:E.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(o,e)=>{const t=ee.shared.setValue(e).toHex(),a=o.patternCache||(o.patternCache={}),n=o.source._resourceId;let s=a[t];return(s==null?void 0:s.tintId)===n||(d.canvas||(d.canvas=E.get().createCanvas()),d.tintMethod(o,e,d.canvas),s=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),s.tintId=n,a[t]=s),s},applyPatternTransform:(o,e,t=!0)=>{if(!e)return;const a=o;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const s=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?s.inverse():s)},tintWithMultiply:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const f=e>>16&255,x=e>>8&255,p=e&255,y=a.getImageData(0,0,c,h),T=y.data;for(let v=0;v<T.length;v+=4)T[v]=T[v]*f/255,T[v+1]=T[v+1]*x/255,T[v+2]=T[v+2]*p/255;a.putImageData(y,0,0)},_applyInverseRotation:(o,e,t,a)=>{const n=D.inv(e),s=D.uX(n),r=D.uY(n),i=D.vX(n),c=D.vY(n),h=-Math.min(0,s*t,i*a,s*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);o.transform(s,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const xe=class z{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){var i,c,h,l;const a=t.elements;if(!a||!a.length)return;const n=e.renderer,s=n.canvasContext,r=s.activeContext;for(let f=0;f<a.length;f++){const x=a[f];if(!x.packAsQuad)continue;const p=x,y=p.texture,T=y?d.getCanvasSource(y):null;if(!T)continue;const v=y.source.style,H=s.smoothProperty,V=v.scaleMode!=="nearest";r[H]!==V&&(r[H]=V),s.setBlendMode(t.blendMode);const G=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,b=p.color,P=(G>>>24&255)/255,X=(b>>>24&255)/255,se=((c=n.filter)==null?void 0:c.alphaMultiplier)??1,te=P*X*se;if(te<=0)continue;r.globalAlpha=te;const ne=G&16777215,J=b&16777215,w=Re(ce(J,ne)),S=y.frame,I=v.addressModeU??v.addressMode,de=v.addressModeV??v.addressMode,ae=z._getPatternRepeat(I,de),q=y.source._resolution??y.source.resolution??1,$=(l=(h=p.renderable)==null?void 0:h.renderGroup)==null?void 0:l.isCachedAsTexture,m=S.x*q,C=S.y*q,_=S.width*q,L=S.height*q,A=p.bounds,k=n.renderTarget.renderTarget.isRoot,U=A.minX,O=A.minY,B=A.maxX-A.minX,W=A.maxY-A.minY,N=y.rotate,u=y.uvs,Y=Math.min(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),j=Math.max(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),M=ae!=="no-repeat"&&(Y<0||j>1),pe=N&&!(!M&&(w!==16777215||N));pe?(z._tempPatternMatrix.copyFrom(p.transform),D.matrixAppendRotationInv(z._tempPatternMatrix,N,U,O,B,W),s.setContextTransform(z._tempPatternMatrix,p.roundPixels===1,void 0,$&&k)):s.setContextTransform(p.transform,p.roundPixels===1,void 0,$&&k);const oe=pe?0:U,re=pe?0:O,ue=B,fe=W;if(M){let ge=T;const K=w!==16777215&&!N,Q=S.width<=y.source.width&&S.height<=y.source.height;K&&Q&&(ge=d.getTintedCanvas({texture:y},w));const me=r.createPattern(ge,ae);if(!me)continue;const _e=ue,Pe=fe;if(_e===0||Pe===0)continue;const Me=1/_e,be=1/Pe,we=(u.x1-u.x0)*Me,ke=(u.y1-u.y0)*Me,Se=(u.x3-u.x0)*be,Ie=(u.y3-u.y0)*be,Ye=u.x0-we*oe-Se*re,je=u.y0-ke*oe-Ie*re,ve=y.source.pixelWidth,ye=y.source.pixelHeight;z._tempPatternMatrix.set(we*ve,ke*ye,Se*ve,Ie*ye,Ye*ve,je*ye),d.applyPatternTransform(me,z._tempPatternMatrix),r.fillStyle=me,r.fillRect(oe,re,ue,fe)}else{const K=w!==16777215||N?d.getTintedCanvas({texture:y},w):T,Q=K!==T;r.drawImage(K,Q?0:m,Q?0:C,Q?K.width:_,Q?K.height:L,oe,re,ue,fe)}}}};xe._tempPatternMatrix=new F;xe.extension={type:[R.CanvasPipesAdaptor],name:"batch"};let dt=xe;class We{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,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}We.extension={type:[R.CanvasPipes],name:"colorMask"};function pt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function De(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;pt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.moveTo(t.x+t.radius,t.y),o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?(o.moveTo(t.x+t.halfWidth,t.y),o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.moveTo(1,0),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function ut(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),De(o,a.shape),s&&o.restore()}return!0}class Ge{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var l,f,x;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a==null?void 0:a.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const s=e.mask.mask;if(!(s instanceof Xe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=s,i=(l=r.context)==null?void 0:l.instructions;if(!(i!=null&&i.length)){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let p=0;p<i.length;p++){const y=i[p],T=y.action;if(T!=="fill"&&T!=="stroke")continue;const v=y.data,H=(f=v==null?void 0:v.path)==null?void 0:f.shapePath;if(!((x=H==null?void 0:H.shapePrimitives)!=null&&x.length))continue;const V=H.shapePrimitives;for(let G=0;G<V.length;G++){const b=V[G];if(!(b!=null&&b.shape))continue;const P=b.transform,X=P&&!P.isIdentity();X&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),De(n,b.shape),h=ut(n,b.holes)||h,c=!0,X&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),$e(t))}}Ge.extension={type:[R.CanvasPipes],name:"stencilMask"};const g="source-over";function ft(){const o=Be(),e=Object.create(null);return e.inherit=g,e.none=g,e.normal="source-over",e.add="lighter",e.multiply=o?"multiply":g,e.screen=o?"screen":g,e.overlay=o?"overlay":g,e.darken=o?"darken":g,e.lighten=o?"lighten":g,e["color-dodge"]=o?"color-dodge":g,e["color-burn"]=o?"color-burn":g,e["hard-light"]=o?"hard-light":g,e["soft-light"]=o?"soft-light":g,e.difference=o?"difference":g,e.exclusion=o?"exclusion":g,e.saturation=o?"saturation":g,e.color=o?"color":g,e.luminosity=o?"luminosity":g,e["linear-burn"]=o?"color-burn":g,e["linear-dodge"]=o?"color-dodge":g,e["linear-light"]=o?"hard-light":g,e["pin-light"]=o?"hard-light":g,e["vivid-light"]=o?"hard-light":g,e["hard-mix"]=g,e.negation=o?"difference":g,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=g,e.divide=g,e.min=g,e.max=g,e}const gt=new F;class Ue{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=ft(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){var h;const s=n?F.IDENTITY:((h=this._renderer.globalUniforms.globalUniformData)==null?void 0:h.worldTransformMatrix)||F.IDENTITY;let r=gt;r.copyFrom(s),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const l=F.shared;l.copyFrom(r),l.prepend(i),r=l}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const s=ee.shared.setValue(e);a.globalAlpha=t??s.alpha,a.fillStyle=s.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!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";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ue.extension={type:[R.CanvasSystem],name:"canvasContext"};class Oe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Oe.extension={type:[R.CanvasSystem],name:"limits"};const mt="#808080",ie=new F,vt=new F,yt=new F,Ce=new F;function Ct(o,e,t){o.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,s=t[a+1]*2,r=t[a+2]*2;o.moveTo(e[n],e[n+1]),o.lineTo(e[s],e[s+1]),o.lineTo(e[r],e[r+1]),o.closePath()}o.fill()}function xt(o){return`#${(o&16777215).toString(16).padStart(6,"0")}`}function Tt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function le(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Tt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function _t(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),le(o,a.shape),s&&o.restore()}return!0}function Pt(o,e,t,a){const n=o.fill;if(n instanceof Qe){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?Ce.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):Ce.copyFrom(n.transform);return a&&!o.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof Ze){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const s=o.texture;if(s&&s!==He.WHITE){if(!s.source.resource)return mt;const r=d.getTintedPattern(s,e),i=t?Ce.copyFrom(t).scale(s.source.pixelWidth,s.source.pixelHeight):o.matrix;return d.applyPatternTransform(r,i),r}return xt(e)}class Ee{constructor(){this.shader=null}contextChange(e){}execute(e,t){var V,G,b,P,X,se,te;const a=e.renderer,n=a.canvasContext,s=n.activeContext,r=t.groupTransform,i=((V=a.globalUniforms.globalUniformData)==null?void 0:V.worldColor)??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,f=((G=a.filter)==null?void 0:G.alphaMultiplier)??1,x=h*l*f;if(x<=0)return;const p=i&16777215,y=c&16777215,T=Re(ce(y,p)),v=a._roundPixels|t._roundPixels;s.save(),n.setContextTransform(r,v===1),n.setBlendMode(t.groupBlendMode);const H=t.context.instructions;for(let ne=0;ne<H.length;ne++){const J=H[ne];if(J.action==="texture"){const m=J.data,C=m.image,_=C?d.getCanvasSource(C):null;if(!_)continue;const L=m.alpha*x;if(L<=0)continue;const A=ce(m.style,T);s.globalAlpha=L;let k=_;A!==16777215&&(k=d.getTintedCanvas({texture:C},A));const U=C.frame,O=C.source._resolution??C.source.resolution??1;let B=U.x*O,W=U.y*O;const N=U.width*O,u=U.height*O;k!==_&&(B=0,W=0);const Y=m.transform,j=Y&&!Y.isIdentity(),M=C.rotate;j||M?(ie.copyFrom(r),j&&ie.append(Y),M&&D.matrixAppendRotationInv(ie,M,m.dx,m.dy,m.dw,m.dh),n.setContextTransform(ie,v===1)):n.setContextTransform(r,v===1),s.drawImage(k,B,W,k===_?N:k.width,k===_?u:k.height,M?0:m.dx,M?0:m.dy,m.dw,m.dh),(j||M)&&n.setContextTransform(r,v===1);continue}const w=J.data,S=(b=w==null?void 0:w.path)==null?void 0:b.shapePath;if(!((P=S==null?void 0:S.shapePrimitives)!=null&&P.length))continue;const I=w.style,de=ce(I.color,T),ae=I.alpha*x;if(ae<=0)continue;const q=J.action==="stroke";if(s.globalAlpha=ae,q){const m=I;s.lineWidth=m.width,s.lineCap=m.cap,s.lineJoin=m.join,s.miterLimit=m.miterLimit}const $=S.shapePrimitives;if(!q&&((te=(se=(X=w.hole)==null?void 0:X.shapePath)==null?void 0:se.shapePrimitives)!=null&&te.length)){const m=$[$.length-1];m.holes=w.hole.shapePath.shapePrimitives}for(let m=0;m<$.length;m++){const C=$[m];if(!(C!=null&&C.shape))continue;const _=C.transform,L=_&&!_.isIdentity(),A=I.texture&&I.texture!==He.WHITE,k=I.textureSpace==="global"?_:null,U=A?ze(vt,I,C.shape,k):null,O=L?yt.copyFrom(r).append(_):r,B=Pt(I,de,U,O);if(L&&(s.save(),s.transform(_.a,_.b,_.c,_.d,_.tx,_.ty)),q){const W=I;if(W.alignment!==.5&&!W.pixelLine){const u=[],Y=[],j=[],M=Je[C.shape.type];if(M!=null&&M.build(C.shape,u)){const Te=C.shape.closePath??!0;Ke(u,W,!1,Te,Y,j),s.fillStyle=B,Ct(s,Y,j)}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.fillStyle=B,s.beginPath(),le(s,C.shape),_t(s,C.holes)?s.fill("evenodd"):s.fill();L&&s.restore()}}s.restore()}destroy(){this.shader=null}}Ee.extension={type:[R.CanvasPipesAdaptor],name:"graphics"};class Mt{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const s=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=s.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=ee.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,s){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=(s==null?void 0:s.x)??0,f=(s==null?void 0:s.y)??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,f,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!et.test(t))&&(t=E.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class Fe extends at{constructor(e){super(e),this.adaptor=new Mt,this.adaptor.init(e,this)}}Fe.extension={type:[R.CanvasSystem],name:"renderTarget"};class Ve{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=E.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const s=e.frame,r=e.source._resolution??e.source.resolution??1,i=s.x*r,c=s.y*r,h=s.width*r,l=s.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}Ve.extension={type:[R.CanvasSystem],name:"texture"};const bt=[...st,Ue,Oe,Ve,Fe],wt=[ot,rt,it,ct,lt,Ge,We,ht],kt=[dt,Ee],qe=[],Le=[],Ne=[];he.handleByNamedList(R.CanvasSystem,qe);he.handleByNamedList(R.CanvasPipes,Le);he.handleByNamedList(R.CanvasPipesAdaptor,Ne);he.add(...bt,...wt,...kt);class At extends tt{constructor(){const e={name:"canvas",type:nt.CANVAS,systems:qe,renderPipes:Le,renderPipeAdaptors:Ne};super(e)}}export{At as CanvasRenderer};
1
+ import{D as E,C as ee,i as D,k as Re,m as ce,M as F,l as R,G as Xe,w as $e,T as He,n as ze,o as Je,p as Ke,F as Qe,q as Ze,t as et,A as tt,R as nt,v as he}from"./index-CnMelTt1.js";import{R as at,S as st,B as ot,a as rt,b as it,c as ct,A as lt,C as ht}from"./RenderTargetSystem-DK3MhP8K.js";let Z;function Ae(o){const e=E.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=o,t.fillRect(0,0,6,1),e}function Be(){if(Z!==void 0)return Z;try{const o=Ae("#ff00ff"),e=Ae("#ffff00"),a=E.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(o,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)Z=!1;else{const s=n.data;Z=s[0]===255&&s[1]===0&&s[2]===0}}catch{Z=!1}return Z}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Be(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:o=>{const e=o.source,t=e==null?void 0:e.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,s=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||s!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),f=l.data,x=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let p=0;p<f.length&&p+3<x.length;p+=4)f[p]=x[p+2],f[p+1]=x[p+1],f[p+2]=x[p],f[p+3]=x[p+3];else f.set(x.subarray(0,f.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=E.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let f=0;f<l.length;f+=4){const x=l[f+3];if(x>0){const p=255/x;l[f]=Math.min(255,l[f]*p+.5),l[f+1]=Math.min(255,l[f+1]*p+.5),l[f+2]=Math.min(255,l[f+2]*p+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(o,e)=>{const t=o.texture,a=ee.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),s=n[a],r=t.source._resourceId;if((s==null?void 0:s.tintId)===r)return s;const i=s&&"getContext"in s?s:E.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(o,e)=>{const t=ee.shared.setValue(e).toHex(),a=o.patternCache||(o.patternCache={}),n=o.source._resourceId;let s=a[t];return(s==null?void 0:s.tintId)===n||(d.canvas||(d.canvas=E.get().createCanvas()),d.tintMethod(o,e,d.canvas),s=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),s.tintId=n,a[t]=s),s},applyPatternTransform:(o,e,t=!0)=>{if(!e)return;const a=o;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const s=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?s.inverse():s)},tintWithMultiply:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const f=e>>16&255,x=e>>8&255,p=e&255,y=a.getImageData(0,0,c,h),T=y.data;for(let v=0;v<T.length;v+=4)T[v]=T[v]*f/255,T[v+1]=T[v+1]*x/255,T[v+2]=T[v+2]*p/255;a.putImageData(y,0,0)},_applyInverseRotation:(o,e,t,a)=>{const n=D.inv(e),s=D.uX(n),r=D.uY(n),i=D.vX(n),c=D.vY(n),h=-Math.min(0,s*t,i*a,s*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);o.transform(s,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const xe=class z{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){var i,c,h,l;const a=t.elements;if(!a||!a.length)return;const n=e.renderer,s=n.canvasContext,r=s.activeContext;for(let f=0;f<a.length;f++){const x=a[f];if(!x.packAsQuad)continue;const p=x,y=p.texture,T=y?d.getCanvasSource(y):null;if(!T)continue;const v=y.source.style,H=s.smoothProperty,V=v.scaleMode!=="nearest";r[H]!==V&&(r[H]=V),s.setBlendMode(t.blendMode);const G=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,b=p.color,P=(G>>>24&255)/255,X=(b>>>24&255)/255,se=((c=n.filter)==null?void 0:c.alphaMultiplier)??1,te=P*X*se;if(te<=0)continue;r.globalAlpha=te;const ne=G&16777215,J=b&16777215,w=Re(ce(J,ne)),S=y.frame,I=v.addressModeU??v.addressMode,de=v.addressModeV??v.addressMode,ae=z._getPatternRepeat(I,de),q=y.source._resolution??y.source.resolution??1,$=(l=(h=p.renderable)==null?void 0:h.renderGroup)==null?void 0:l.isCachedAsTexture,m=S.x*q,C=S.y*q,_=S.width*q,L=S.height*q,A=p.bounds,k=n.renderTarget.renderTarget.isRoot,U=A.minX,O=A.minY,B=A.maxX-A.minX,W=A.maxY-A.minY,N=y.rotate,u=y.uvs,Y=Math.min(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),j=Math.max(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),M=ae!=="no-repeat"&&(Y<0||j>1),pe=N&&!(!M&&(w!==16777215||N));pe?(z._tempPatternMatrix.copyFrom(p.transform),D.matrixAppendRotationInv(z._tempPatternMatrix,N,U,O,B,W),s.setContextTransform(z._tempPatternMatrix,p.roundPixels===1,void 0,$&&k)):s.setContextTransform(p.transform,p.roundPixels===1,void 0,$&&k);const oe=pe?0:U,re=pe?0:O,ue=B,fe=W;if(M){let ge=T;const K=w!==16777215&&!N,Q=S.width<=y.source.width&&S.height<=y.source.height;K&&Q&&(ge=d.getTintedCanvas({texture:y},w));const me=r.createPattern(ge,ae);if(!me)continue;const _e=ue,Pe=fe;if(_e===0||Pe===0)continue;const Me=1/_e,be=1/Pe,we=(u.x1-u.x0)*Me,ke=(u.y1-u.y0)*Me,Se=(u.x3-u.x0)*be,Ie=(u.y3-u.y0)*be,Ye=u.x0-we*oe-Se*re,je=u.y0-ke*oe-Ie*re,ve=y.source.pixelWidth,ye=y.source.pixelHeight;z._tempPatternMatrix.set(we*ve,ke*ye,Se*ve,Ie*ye,Ye*ve,je*ye),d.applyPatternTransform(me,z._tempPatternMatrix),r.fillStyle=me,r.fillRect(oe,re,ue,fe)}else{const K=w!==16777215||N?d.getTintedCanvas({texture:y},w):T,Q=K!==T;r.drawImage(K,Q?0:m,Q?0:C,Q?K.width:_,Q?K.height:L,oe,re,ue,fe)}}}};xe._tempPatternMatrix=new F;xe.extension={type:[R.CanvasPipesAdaptor],name:"batch"};let dt=xe;class We{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,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}We.extension={type:[R.CanvasPipes],name:"colorMask"};function pt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function De(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;pt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.moveTo(t.x+t.radius,t.y),o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?(o.moveTo(t.x+t.halfWidth,t.y),o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.moveTo(1,0),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function ut(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),De(o,a.shape),s&&o.restore()}return!0}class Ge{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var l,f,x;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a==null?void 0:a.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const s=e.mask.mask;if(!(s instanceof Xe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=s,i=(l=r.context)==null?void 0:l.instructions;if(!(i!=null&&i.length)){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let p=0;p<i.length;p++){const y=i[p],T=y.action;if(T!=="fill"&&T!=="stroke")continue;const v=y.data,H=(f=v==null?void 0:v.path)==null?void 0:f.shapePath;if(!((x=H==null?void 0:H.shapePrimitives)!=null&&x.length))continue;const V=H.shapePrimitives;for(let G=0;G<V.length;G++){const b=V[G];if(!(b!=null&&b.shape))continue;const P=b.transform,X=P&&!P.isIdentity();X&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),De(n,b.shape),h=ut(n,b.holes)||h,c=!0,X&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),$e(t))}}Ge.extension={type:[R.CanvasPipes],name:"stencilMask"};const g="source-over";function ft(){const o=Be(),e=Object.create(null);return e.inherit=g,e.none=g,e.normal="source-over",e.add="lighter",e.multiply=o?"multiply":g,e.screen=o?"screen":g,e.overlay=o?"overlay":g,e.darken=o?"darken":g,e.lighten=o?"lighten":g,e["color-dodge"]=o?"color-dodge":g,e["color-burn"]=o?"color-burn":g,e["hard-light"]=o?"hard-light":g,e["soft-light"]=o?"soft-light":g,e.difference=o?"difference":g,e.exclusion=o?"exclusion":g,e.saturation=o?"saturation":g,e.color=o?"color":g,e.luminosity=o?"luminosity":g,e["linear-burn"]=o?"color-burn":g,e["linear-dodge"]=o?"color-dodge":g,e["linear-light"]=o?"hard-light":g,e["pin-light"]=o?"hard-light":g,e["vivid-light"]=o?"hard-light":g,e["hard-mix"]=g,e.negation=o?"difference":g,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=g,e.divide=g,e.min=g,e.max=g,e}const gt=new F;class Ue{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=ft(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){var h;const s=n?F.IDENTITY:((h=this._renderer.globalUniforms.globalUniformData)==null?void 0:h.worldTransformMatrix)||F.IDENTITY;let r=gt;r.copyFrom(s),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const l=F.shared;l.copyFrom(r),l.prepend(i),r=l}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const s=ee.shared.setValue(e);a.globalAlpha=t??s.alpha,a.fillStyle=s.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!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";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ue.extension={type:[R.CanvasSystem],name:"canvasContext"};class Oe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Oe.extension={type:[R.CanvasSystem],name:"limits"};const mt="#808080",ie=new F,vt=new F,yt=new F,Ce=new F;function Ct(o,e,t){o.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,s=t[a+1]*2,r=t[a+2]*2;o.moveTo(e[n],e[n+1]),o.lineTo(e[s],e[s+1]),o.lineTo(e[r],e[r+1]),o.closePath()}o.fill()}function xt(o){return`#${(o&16777215).toString(16).padStart(6,"0")}`}function Tt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function le(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Tt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function _t(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),le(o,a.shape),s&&o.restore()}return!0}function Pt(o,e,t,a){const n=o.fill;if(n instanceof Qe){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?Ce.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):Ce.copyFrom(n.transform);return a&&!o.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof Ze){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const s=o.texture;if(s&&s!==He.WHITE){if(!s.source.resource)return mt;const r=d.getTintedPattern(s,e),i=t?Ce.copyFrom(t).scale(s.source.pixelWidth,s.source.pixelHeight):o.matrix;return d.applyPatternTransform(r,i),r}return xt(e)}class Ee{constructor(){this.shader=null}contextChange(e){}execute(e,t){var V,G,b,P,X,se,te;const a=e.renderer,n=a.canvasContext,s=n.activeContext,r=t.groupTransform,i=((V=a.globalUniforms.globalUniformData)==null?void 0:V.worldColor)??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,f=((G=a.filter)==null?void 0:G.alphaMultiplier)??1,x=h*l*f;if(x<=0)return;const p=i&16777215,y=c&16777215,T=Re(ce(y,p)),v=a._roundPixels|t._roundPixels;s.save(),n.setContextTransform(r,v===1),n.setBlendMode(t.groupBlendMode);const H=t.context.instructions;for(let ne=0;ne<H.length;ne++){const J=H[ne];if(J.action==="texture"){const m=J.data,C=m.image,_=C?d.getCanvasSource(C):null;if(!_)continue;const L=m.alpha*x;if(L<=0)continue;const A=ce(m.style,T);s.globalAlpha=L;let k=_;A!==16777215&&(k=d.getTintedCanvas({texture:C},A));const U=C.frame,O=C.source._resolution??C.source.resolution??1;let B=U.x*O,W=U.y*O;const N=U.width*O,u=U.height*O;k!==_&&(B=0,W=0);const Y=m.transform,j=Y&&!Y.isIdentity(),M=C.rotate;j||M?(ie.copyFrom(r),j&&ie.append(Y),M&&D.matrixAppendRotationInv(ie,M,m.dx,m.dy,m.dw,m.dh),n.setContextTransform(ie,v===1)):n.setContextTransform(r,v===1),s.drawImage(k,B,W,k===_?N:k.width,k===_?u:k.height,M?0:m.dx,M?0:m.dy,m.dw,m.dh),(j||M)&&n.setContextTransform(r,v===1);continue}const w=J.data,S=(b=w==null?void 0:w.path)==null?void 0:b.shapePath;if(!((P=S==null?void 0:S.shapePrimitives)!=null&&P.length))continue;const I=w.style,de=ce(I.color,T),ae=I.alpha*x;if(ae<=0)continue;const q=J.action==="stroke";if(s.globalAlpha=ae,q){const m=I;s.lineWidth=m.width,s.lineCap=m.cap,s.lineJoin=m.join,s.miterLimit=m.miterLimit}const $=S.shapePrimitives;if(!q&&((te=(se=(X=w.hole)==null?void 0:X.shapePath)==null?void 0:se.shapePrimitives)!=null&&te.length)){const m=$[$.length-1];m.holes=w.hole.shapePath.shapePrimitives}for(let m=0;m<$.length;m++){const C=$[m];if(!(C!=null&&C.shape))continue;const _=C.transform,L=_&&!_.isIdentity(),A=I.texture&&I.texture!==He.WHITE,k=I.textureSpace==="global"?_:null,U=A?ze(vt,I,C.shape,k):null,O=L?yt.copyFrom(r).append(_):r,B=Pt(I,de,U,O);if(L&&(s.save(),s.transform(_.a,_.b,_.c,_.d,_.tx,_.ty)),q){const W=I;if(W.alignment!==.5&&!W.pixelLine){const u=[],Y=[],j=[],M=Je[C.shape.type];if(M!=null&&M.build(C.shape,u)){const Te=C.shape.closePath??!0;Ke(u,W,!1,Te,Y,j),s.fillStyle=B,Ct(s,Y,j)}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.fillStyle=B,s.beginPath(),le(s,C.shape),_t(s,C.holes)?s.fill("evenodd"):s.fill();L&&s.restore()}}s.restore()}destroy(){this.shader=null}}Ee.extension={type:[R.CanvasPipesAdaptor],name:"graphics"};class Mt{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const s=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=s.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=ee.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,s){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=(s==null?void 0:s.x)??0,f=(s==null?void 0:s.y)??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,f,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!et.test(t))&&(t=E.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class Fe extends at{constructor(e){super(e),this.adaptor=new Mt,this.adaptor.init(e,this)}}Fe.extension={type:[R.CanvasSystem],name:"renderTarget"};class Ve{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=E.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const s=e.frame,r=e.source._resolution??e.source.resolution??1,i=s.x*r,c=s.y*r,h=s.width*r,l=s.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}Ve.extension={type:[R.CanvasSystem],name:"texture"};const bt=[...st,Ue,Oe,Ve,Fe],wt=[ot,rt,it,ct,lt,Ge,We,ht],kt=[dt,Ee],qe=[],Le=[],Ne=[];he.handleByNamedList(R.CanvasSystem,qe);he.handleByNamedList(R.CanvasPipes,Le);he.handleByNamedList(R.CanvasPipesAdaptor,Ne);he.add(...bt,...wt,...kt);class At extends tt{constructor(){const e={name:"canvas",type:nt.CANVAS,systems:qe,renderPipes:Le,renderPipeAdaptors:Ne};super(e)}}export{At as CanvasRenderer};
@@ -1 +1 @@
1
- var W=Object.defineProperty;var G=(c,a,o)=>a in c?W(c,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):c[a]=o;var k=(c,a,o)=>G(c,typeof a!="symbol"?a+"":a,o);import{r as S,J as b,a as u,u as m,b as B,c as I,j as w,s as O}from"./index-DGn2ljNa.js";const N=/\bjarvis\b/i;function U(c){return N.test(c)}function j(c){if(!c)return[];if(c.length<=b.ttsSplitLength)return[c];const a=c.match(/[^.!?]+[.!?]+\s*/g)||[c],o=[];let n="";for(const e of a)n.length+e.length>b.ttsSplitLength&&n?(o.push(n.trim()),n=e):n+=e;return n.trim()&&o.push(n.trim()),o}function q(c){const a=globalThis.SpeechRecognition||globalThis.webkitSpeechRecognition,o=!!a;let n=null,e=null,s=null,t=null,i=!1,d=!1;function l(){if(a&&!(n!=null&&n._started)){d=!1,n=new a,n.continuous=!0,n.interimResults=!0,n.lang="pt-BR",n.onresult=p=>{var P;const r=p.results[p.resultIndex];if(!r)return;const f=((P=r[0])==null?void 0:P.transcript)??"",h=r.isFinal;if(i&&h){const R=f.replace(N,"").trim();R&&(i=!1,c.onUtterance(R));return}if(U(f)&&!d){const R=f.replace(/^.*?\bjarvis\b\s*/i,"").trim();R&&h?(d=!0,c.onWakeWord(R)):R?h&&(d=!0,c.onWakeWord(R)):(d=!0,c.onWakeWord(""),i=!0)}},n.onend=()=>{if(n)try{n.start()}catch{}},n.onerror=()=>{};try{n.start()}catch{}}}function x(){if(n){const p=n;n=null;try{p.stop()}catch{}}}async function g(){try{t=await navigator.mediaDevices.getUserMedia({audio:!0}),s=new AudioContext;const p=s.createMediaStreamSource(t);e=s.createAnalyser(),e.fftSize=256,p.connect(e)}catch{e=null}}function A(p){x(),speechSynthesis.cancel();const y=j(p);if(y.length===0){c.onTTSEnd(),l();return}y.forEach((r,f)=>{const h=new SpeechSynthesisUtterance(r);h.lang="pt-BR",h.rate=1,h.pitch=.8;const R=speechSynthesis.getVoices().filter(v=>v.lang.startsWith("pt")),M=R.find(v=>/male|masculin|felipe|daniel|luciano|ricardo|google.*br/i.test(v.name)&&!/female|femin|luciana|joana|francisca|fernanda|raquel/i.test(v.name));h.voice=M??R[0]??null,f===y.length-1&&(h.onend=()=>{c.onTTSEnd(),l()},h.onerror=()=>{c.onTTSEnd(),l()}),speechSynthesis.speak(h)})}function T(){speechSynthesis.cancel()}return{start:()=>{l(),typeof navigator<"u"&&navigator.mediaDevices&&g()},stop:()=>{x(),T(),t&&(t.getTracks().forEach(p=>p.stop()),t=null),s&&(s.close(),s=null),e=null},speak:A,cancelSpeech:T,isSupported:o,getAnalyser:()=>e}}function D(c){const a=S.useRef(null),o=S.useRef(c);o.current=c,S.useEffect(()=>{const t=q({onWakeWord:i=>o.current.onWakeWord(i),onUtterance:i=>o.current.onUtterance(i),onTTSEnd:()=>o.current.onTTSEnd()});return a.current=t,t.start(),()=>t.stop()},[]);const n=S.useCallback(t=>{var i;(i=a.current)==null||i.speak(t)},[]),e=S.useCallback(()=>{var t;(t=a.current)==null||t.cancelSpeech()},[]),s=S.useCallback(()=>{var t;return((t=a.current)==null?void 0:t.getAnalyser())??null},[]);return{speak:n,cancelSpeech:e,getAnalyser:s,isSupported:!!(globalThis.SpeechRecognition||globalThis.webkitSpeechRecognition)}}const L={STANDBY:u.orbStandby,GREETING:u.orbListening,LISTENING:u.orbListening,PROCESSING:u.orbProcessing,SPEAKING:u.orbSpeaking};class F{constructor(a){k(this,"canvas");k(this,"ctx");k(this,"particles");k(this,"destroyed",!1);this.canvas=a,this.ctx=a.getContext("2d"),this.particles=this.initParticles()}getParticleCount(){return this.particles.length}initParticles(){const a=b.particleCount,o=[];for(let n=0;n<a;n++)o.push({x:Math.random()*this.canvas.width,y:Math.random()*this.canvas.height,vx:(Math.random()-.5)*.5,vy:(Math.random()-.5)*.5,radius:b.particleMinRadius+Math.random()*(b.particleMaxRadius-b.particleMinRadius),alpha:.2+Math.random()*.6});return o}render(a){if(this.destroyed)return;const{ctx:o,canvas:n}=this,e=n.width,s=n.height,t=e/2,i=s/2;o.clearRect(0,0,e,s),o.fillStyle=u.background,o.fillRect(0,0,e,s),this.drawGrid(e,s,a.time),this.updateAndDrawParticles(a.mode,e,s),this.drawOrb(t,i,a),a.mode==="LISTENING"&&a.amplitudes&&this.drawWaveform(t,i,a.amplitudes),this.drawSquadsPanel(a.squads,s),this.drawStatusPanel(a,e,s),this.drawTranscript(a.transcript,t,s),o.fillStyle=u.textAccent,o.font="11px monospace",o.textAlign="center",o.textBaseline="bottom",o.globalAlpha=.5,o.fillText("── EXPXAGENTS JARVIS v1 ──",t,s-8),o.globalAlpha=1}drawGrid(a,o,n){const e=this.ctx,s=b.gridSpacing;e.strokeStyle=u.grid,e.lineWidth=.5,e.beginPath();for(let t=0;t<a;t+=s)e.moveTo(t,0),e.lineTo(t,o);e.stroke(),e.beginPath();for(let t=0;t<o;t+=s)e.moveTo(0,t),e.lineTo(a,t);e.stroke()}updateAndDrawParticles(a,o,n){const e=this.ctx,s=a==="LISTENING"||a==="PROCESSING"?2:1;for(const t of this.particles)t.x+=t.vx*s,t.y+=t.vy*s,t.x<0&&(t.x=o),t.x>o&&(t.x=0),t.y<0&&(t.y=n),t.y>n&&(t.y=0),e.beginPath(),e.arc(t.x,t.y,t.radius,0,Math.PI*2),e.fillStyle=u.particleStart,e.globalAlpha=t.alpha,e.fill();e.globalAlpha=1}drawOrb(a,o,n){const e=this.ctx,s=b.orbRadius,t=L[n.mode];e.save(),e.shadowBlur=n.mode==="STANDBY"?20:40,e.shadowColor=t;const i=e.createRadialGradient(a,o,0,a,o,s);if(i.addColorStop(0,t),i.addColorStop(1,"transparent"),e.fillStyle=i,e.beginPath(),e.arc(a,o,s,0,Math.PI*2),e.fill(),e.strokeStyle=t,e.lineWidth=b.orbRingWidth,e.beginPath(),n.mode==="PROCESSING"){const l=n.time/500%(Math.PI*2);e.arc(a,o,s+8,l,l+Math.PI*1.5)}else e.arc(a,o,s+8,0,Math.PI*2);if(e.stroke(),n.mode==="STANDBY"){const l=.5+.3*Math.sin(n.time/1500);e.globalAlpha=l,e.beginPath(),e.arc(a,o,s+4,0,Math.PI*2),e.fillStyle=t,e.fill(),e.globalAlpha=1}if(n.mode==="SPEAKING"){const l=.6+.4*Math.sin(n.time/200);e.globalAlpha=l,e.beginPath(),e.arc(a,o,s*(.9+.1*Math.sin(n.time/300)),0,Math.PI*2),e.fillStyle=t,e.fill(),e.globalAlpha=1}e.restore(),e.fillStyle=t,e.font="bold 12px monospace",e.textAlign="center",e.textBaseline="top";const d=n.mode==="PROCESSING"?"Processando...":n.mode;e.fillText(d,a,o+s+20),e.fillStyle=u.textPrimary,e.font="bold 16px monospace",e.fillText("JARVIS",a,o-s-30)}drawWaveform(a,o,n){const e=this.ctx,s=b.waveformBars,t=b.waveformMaxHeight,i=b.orbRadius+16;e.strokeStyle=u.orbListening,e.lineWidth=2;for(let d=0;d<s;d++){const l=d/s*Math.PI*2-Math.PI/2,x=Math.floor(d/s*n.length),g=(n[x]??0)/255,A=g*t,T=a+Math.cos(l)*i,p=o+Math.sin(l)*i,y=a+Math.cos(l)*(i+A),r=o+Math.sin(l)*(i+A);e.beginPath(),e.moveTo(T,p),e.lineTo(y,r),e.globalAlpha=.6+g*.4,e.stroke()}e.globalAlpha=1}drawSquadsPanel(a,o){const n=this.ctx,e=b.panelWidth,s=b.panelPadding,t=Math.max(200,a.length*28+60),i=(o-t)/2;n.fillStyle=u.panelBg,n.fillRect(s,i,e,t),n.strokeStyle=u.panelBorder,n.lineWidth=1,n.strokeRect(s,i,e,t),n.fillStyle=u.textAccent,n.font="bold 13px monospace",n.textAlign="left",n.textBaseline="top",n.fillText("SQUADS",s+10,i+10),n.font="12px monospace",a.forEach((d,l)=>{const x=i+40+l*28,g=d.active?"●":"○";n.fillStyle=d.active?u.orbSpeaking:u.textPrimary,n.fillText(`${g} ${d.name}`,s+10,x)})}drawStatusPanel(a,o,n){var p;const e=this.ctx,s=b.panelWidth,t=b.panelPadding,i=200,d=(n-i)/2,l=o-s-t;e.fillStyle=u.panelBg,e.fillRect(l,d,s,i),e.strokeStyle=u.panelBorder,e.lineWidth=1,e.strokeRect(l,d,s,i),e.fillStyle=u.textAccent,e.font="bold 13px monospace",e.textAlign="left",e.textBaseline="top",e.fillText("STATUS",l+10,d+10),e.font="12px monospace";const x=Math.floor(a.time/1e3),g=String(Math.floor(x/60)).padStart(2,"0"),A=String(x%60).padStart(2,"0"),T=[`Mode: ${a.mode}`,"Mic: ON",`Squad: ${((p=a.squads.find(y=>y.active))==null?void 0:p.name)??"---"}`,`Time: ${g}:${A}`];a.userName&&T.push(`User: ${a.userName}`),T.forEach((y,r)=>{e.fillStyle=u.textPrimary,e.fillText(y,l+10,d+40+r*24)})}drawTranscript(a,o,n){const e=this.ctx,s=a.slice(-10);if(s.length===0)return;const t=b.transcriptLineHeight,i=Math.min(700,this.canvas.width-100),d=s.length*t+24,l=o-i/2,x=n-d-40;e.fillStyle=u.panelBg,e.fillRect(l,x,i,d),e.strokeStyle=u.panelBorder,e.lineWidth=1,e.strokeRect(l,x,i,d),e.font="12px monospace",e.textAlign="left",e.textBaseline="top",s.forEach((g,A)=>{const T=x+12+A*t,p=g.role==="user"?"User: ":"Jarvis: ";e.fillStyle=g.role==="user"?u.textAccent:u.textJarvis;const y=Math.floor((i-20)/7),r=p+(g.text.length>y?g.text.slice(0,y-3)+"...":g.text);e.fillText(r,l+10,T)})}destroy(){this.destroyed=!0}}function H(){const c=S.useRef(null),a=S.useRef(null),o=S.useRef(0),n=S.useRef(Date.now()),[e,s]=S.useState(""),t=m(r=>r.messages);m(r=>r.userName);const i=B(r=>r.user);I(r=>r.squads),S.useEffect(()=>{i!=null&&i.username&&m.getState().setUserName(i.username)},[i==null?void 0:i.username]);const d=S.useRef(0);S.useEffect(()=>{if(t.length>d.current){const r=t[t.length-1];r.role==="assistant"&&m.getState().mode==="PROCESSING"&&(m.getState().setMode("SPEAKING"),g.current.speak(r.content))}d.current=t.length},[t]);const l=S.useCallback(r=>{const f=["Certo, vou verificar isso agora.","Entendido, deixa comigo.","Um momento, já estou processando.","Certo, já estou buscando a informação."],h=f[Math.floor(Math.random()*f.length)];g.current.speak(h)},[]),x=S.useCallback(r=>{const f=m.getState().selectedSquad??"_jarvis";m.getState().addMessage("user",r),l(r),m.getState().setMode("PROCESSING"),m.getState().clearStandbyTimer(),O(f,r)},[l]),g=S.useRef({speak:r=>{}}),{speak:A,getAnalyser:T,isSupported:p}=D({onWakeWord:r=>{const f=m.getState().mode;if(!(f==="PROCESSING"||f==="SPEAKING"))if(r)x(r);else{m.getState().setMode("GREETING");const h=m.getState().userName||"senhor";A(`Olá ${h}, como posso ajudar?`)}},onUtterance:r=>{const f=m.getState().mode;f==="PROCESSING"||f==="SPEAKING"||x(r)},onTTSEnd:()=>{const r=m.getState().mode;(r==="GREETING"||r==="SPEAKING")&&(m.getState().setMode("LISTENING"),m.getState().startStandbyTimer())}});g.current.speak=A,S.useEffect(()=>{const r=c.current;if(!r)return;const f=()=>{r.width=window.innerWidth,r.height=window.innerHeight};f(),window.addEventListener("resize",f);const h=new F(r);a.current=h;const P=()=>{const R=T();let M=null;if(R){const E=new ArrayBuffer(R.frequencyBinCount);M=new Uint8Array(E),R.getByteFrequencyData(M)}const v=m.getState(),C=I.getState().squads;h.render({mode:v.mode,time:Date.now()-n.current,amplitudes:M,squads:C.map(E=>({name:E.code,active:E.code===v.selectedSquad})),transcript:v.messages.map(E=>({role:E.role,text:E.content})),userName:v.userName}),o.current=requestAnimationFrame(P)};return o.current=requestAnimationFrame(P),()=>{cancelAnimationFrame(o.current),h.destroy(),window.removeEventListener("resize",f)}},[T]),S.useEffect(()=>()=>{m.getState().clearStandbyTimer()},[]);const y=r=>{r.preventDefault(),e.trim()&&(x(e.trim()),s(""))};return w.jsxs("div",{style:{position:"fixed",inset:0,background:u.background,zIndex:1e3},children:[w.jsx("canvas",{ref:c,style:{display:"block",width:"100%",height:"100%"}}),!p&&w.jsx("div",{style:{position:"absolute",top:20,left:"50%",transform:"translateX(-50%)",color:u.orbProcessing,fontFamily:"monospace",fontSize:13,background:"rgba(255, 140, 0, 0.1)",border:"1px solid rgba(255, 140, 0, 0.3)",borderRadius:4,padding:"8px 16px",zIndex:1001},children:"Speech recognition not available. Use text input below."}),w.jsxs("form",{onSubmit:y,style:{position:"absolute",bottom:30,left:"50%",transform:"translateX(-50%)",display:"flex",gap:8,zIndex:1001},children:[w.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),placeholder:p?"Or type a message...":"Type a message...",style:{width:400,padding:"8px 12px",background:"rgba(0, 200, 255, 0.08)",border:"1px solid rgba(0, 200, 255, 0.25)",borderRadius:4,color:u.textPrimary,fontFamily:"monospace",fontSize:13,outline:"none"}}),w.jsx("button",{type:"submit",style:{padding:"8px 16px",background:"rgba(0, 200, 255, 0.15)",border:"1px solid rgba(0, 200, 255, 0.25)",borderRadius:4,color:u.textAccent,fontFamily:"monospace",fontSize:13,cursor:"pointer"},children:"Send"})]})]})}export{H as JarvisView};
1
+ var W=Object.defineProperty;var G=(c,a,o)=>a in c?W(c,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):c[a]=o;var k=(c,a,o)=>G(c,typeof a!="symbol"?a+"":a,o);import{r as S,J as b,a as u,b as m,c as B,d as I,j as w,s as O}from"./index-CnMelTt1.js";const N=/\bjarvis\b/i;function U(c){return N.test(c)}function j(c){if(!c)return[];if(c.length<=b.ttsSplitLength)return[c];const a=c.match(/[^.!?]+[.!?]+\s*/g)||[c],o=[];let n="";for(const e of a)n.length+e.length>b.ttsSplitLength&&n?(o.push(n.trim()),n=e):n+=e;return n.trim()&&o.push(n.trim()),o}function q(c){const a=globalThis.SpeechRecognition||globalThis.webkitSpeechRecognition,o=!!a;let n=null,e=null,s=null,t=null,i=!1,d=!1;function l(){if(a&&!(n!=null&&n._started)){d=!1,n=new a,n.continuous=!0,n.interimResults=!0,n.lang="pt-BR",n.onresult=p=>{var P;const r=p.results[p.resultIndex];if(!r)return;const f=((P=r[0])==null?void 0:P.transcript)??"",h=r.isFinal;if(i&&h){const R=f.replace(N,"").trim();R&&(i=!1,c.onUtterance(R));return}if(U(f)&&!d){const R=f.replace(/^.*?\bjarvis\b\s*/i,"").trim();R&&h?(d=!0,c.onWakeWord(R)):R?h&&(d=!0,c.onWakeWord(R)):(d=!0,c.onWakeWord(""),i=!0)}},n.onend=()=>{if(n)try{n.start()}catch{}},n.onerror=()=>{};try{n.start()}catch{}}}function x(){if(n){const p=n;n=null;try{p.stop()}catch{}}}async function g(){try{t=await navigator.mediaDevices.getUserMedia({audio:!0}),s=new AudioContext;const p=s.createMediaStreamSource(t);e=s.createAnalyser(),e.fftSize=256,p.connect(e)}catch{e=null}}function A(p){x(),speechSynthesis.cancel();const y=j(p);if(y.length===0){c.onTTSEnd(),l();return}y.forEach((r,f)=>{const h=new SpeechSynthesisUtterance(r);h.lang="pt-BR",h.rate=1,h.pitch=.8;const R=speechSynthesis.getVoices().filter(v=>v.lang.startsWith("pt")),M=R.find(v=>/male|masculin|felipe|daniel|luciano|ricardo|google.*br/i.test(v.name)&&!/female|femin|luciana|joana|francisca|fernanda|raquel/i.test(v.name));h.voice=M??R[0]??null,f===y.length-1&&(h.onend=()=>{c.onTTSEnd(),l()},h.onerror=()=>{c.onTTSEnd(),l()}),speechSynthesis.speak(h)})}function T(){speechSynthesis.cancel()}return{start:()=>{l(),typeof navigator<"u"&&navigator.mediaDevices&&g()},stop:()=>{x(),T(),t&&(t.getTracks().forEach(p=>p.stop()),t=null),s&&(s.close(),s=null),e=null},speak:A,cancelSpeech:T,isSupported:o,getAnalyser:()=>e}}function D(c){const a=S.useRef(null),o=S.useRef(c);o.current=c,S.useEffect(()=>{const t=q({onWakeWord:i=>o.current.onWakeWord(i),onUtterance:i=>o.current.onUtterance(i),onTTSEnd:()=>o.current.onTTSEnd()});return a.current=t,t.start(),()=>t.stop()},[]);const n=S.useCallback(t=>{var i;(i=a.current)==null||i.speak(t)},[]),e=S.useCallback(()=>{var t;(t=a.current)==null||t.cancelSpeech()},[]),s=S.useCallback(()=>{var t;return((t=a.current)==null?void 0:t.getAnalyser())??null},[]);return{speak:n,cancelSpeech:e,getAnalyser:s,isSupported:!!(globalThis.SpeechRecognition||globalThis.webkitSpeechRecognition)}}const L={STANDBY:u.orbStandby,GREETING:u.orbListening,LISTENING:u.orbListening,PROCESSING:u.orbProcessing,SPEAKING:u.orbSpeaking};class F{constructor(a){k(this,"canvas");k(this,"ctx");k(this,"particles");k(this,"destroyed",!1);this.canvas=a,this.ctx=a.getContext("2d"),this.particles=this.initParticles()}getParticleCount(){return this.particles.length}initParticles(){const a=b.particleCount,o=[];for(let n=0;n<a;n++)o.push({x:Math.random()*this.canvas.width,y:Math.random()*this.canvas.height,vx:(Math.random()-.5)*.5,vy:(Math.random()-.5)*.5,radius:b.particleMinRadius+Math.random()*(b.particleMaxRadius-b.particleMinRadius),alpha:.2+Math.random()*.6});return o}render(a){if(this.destroyed)return;const{ctx:o,canvas:n}=this,e=n.width,s=n.height,t=e/2,i=s/2;o.clearRect(0,0,e,s),o.fillStyle=u.background,o.fillRect(0,0,e,s),this.drawGrid(e,s,a.time),this.updateAndDrawParticles(a.mode,e,s),this.drawOrb(t,i,a),a.mode==="LISTENING"&&a.amplitudes&&this.drawWaveform(t,i,a.amplitudes),this.drawSquadsPanel(a.squads,s),this.drawStatusPanel(a,e,s),this.drawTranscript(a.transcript,t,s),o.fillStyle=u.textAccent,o.font="11px monospace",o.textAlign="center",o.textBaseline="bottom",o.globalAlpha=.5,o.fillText("── EXPXAGENTS JARVIS v1 ──",t,s-8),o.globalAlpha=1}drawGrid(a,o,n){const e=this.ctx,s=b.gridSpacing;e.strokeStyle=u.grid,e.lineWidth=.5,e.beginPath();for(let t=0;t<a;t+=s)e.moveTo(t,0),e.lineTo(t,o);e.stroke(),e.beginPath();for(let t=0;t<o;t+=s)e.moveTo(0,t),e.lineTo(a,t);e.stroke()}updateAndDrawParticles(a,o,n){const e=this.ctx,s=a==="LISTENING"||a==="PROCESSING"?2:1;for(const t of this.particles)t.x+=t.vx*s,t.y+=t.vy*s,t.x<0&&(t.x=o),t.x>o&&(t.x=0),t.y<0&&(t.y=n),t.y>n&&(t.y=0),e.beginPath(),e.arc(t.x,t.y,t.radius,0,Math.PI*2),e.fillStyle=u.particleStart,e.globalAlpha=t.alpha,e.fill();e.globalAlpha=1}drawOrb(a,o,n){const e=this.ctx,s=b.orbRadius,t=L[n.mode];e.save(),e.shadowBlur=n.mode==="STANDBY"?20:40,e.shadowColor=t;const i=e.createRadialGradient(a,o,0,a,o,s);if(i.addColorStop(0,t),i.addColorStop(1,"transparent"),e.fillStyle=i,e.beginPath(),e.arc(a,o,s,0,Math.PI*2),e.fill(),e.strokeStyle=t,e.lineWidth=b.orbRingWidth,e.beginPath(),n.mode==="PROCESSING"){const l=n.time/500%(Math.PI*2);e.arc(a,o,s+8,l,l+Math.PI*1.5)}else e.arc(a,o,s+8,0,Math.PI*2);if(e.stroke(),n.mode==="STANDBY"){const l=.5+.3*Math.sin(n.time/1500);e.globalAlpha=l,e.beginPath(),e.arc(a,o,s+4,0,Math.PI*2),e.fillStyle=t,e.fill(),e.globalAlpha=1}if(n.mode==="SPEAKING"){const l=.6+.4*Math.sin(n.time/200);e.globalAlpha=l,e.beginPath(),e.arc(a,o,s*(.9+.1*Math.sin(n.time/300)),0,Math.PI*2),e.fillStyle=t,e.fill(),e.globalAlpha=1}e.restore(),e.fillStyle=t,e.font="bold 12px monospace",e.textAlign="center",e.textBaseline="top";const d=n.mode==="PROCESSING"?"Processando...":n.mode;e.fillText(d,a,o+s+20),e.fillStyle=u.textPrimary,e.font="bold 16px monospace",e.fillText("JARVIS",a,o-s-30)}drawWaveform(a,o,n){const e=this.ctx,s=b.waveformBars,t=b.waveformMaxHeight,i=b.orbRadius+16;e.strokeStyle=u.orbListening,e.lineWidth=2;for(let d=0;d<s;d++){const l=d/s*Math.PI*2-Math.PI/2,x=Math.floor(d/s*n.length),g=(n[x]??0)/255,A=g*t,T=a+Math.cos(l)*i,p=o+Math.sin(l)*i,y=a+Math.cos(l)*(i+A),r=o+Math.sin(l)*(i+A);e.beginPath(),e.moveTo(T,p),e.lineTo(y,r),e.globalAlpha=.6+g*.4,e.stroke()}e.globalAlpha=1}drawSquadsPanel(a,o){const n=this.ctx,e=b.panelWidth,s=b.panelPadding,t=Math.max(200,a.length*28+60),i=(o-t)/2;n.fillStyle=u.panelBg,n.fillRect(s,i,e,t),n.strokeStyle=u.panelBorder,n.lineWidth=1,n.strokeRect(s,i,e,t),n.fillStyle=u.textAccent,n.font="bold 13px monospace",n.textAlign="left",n.textBaseline="top",n.fillText("SQUADS",s+10,i+10),n.font="12px monospace",a.forEach((d,l)=>{const x=i+40+l*28,g=d.active?"●":"○";n.fillStyle=d.active?u.orbSpeaking:u.textPrimary,n.fillText(`${g} ${d.name}`,s+10,x)})}drawStatusPanel(a,o,n){var p;const e=this.ctx,s=b.panelWidth,t=b.panelPadding,i=200,d=(n-i)/2,l=o-s-t;e.fillStyle=u.panelBg,e.fillRect(l,d,s,i),e.strokeStyle=u.panelBorder,e.lineWidth=1,e.strokeRect(l,d,s,i),e.fillStyle=u.textAccent,e.font="bold 13px monospace",e.textAlign="left",e.textBaseline="top",e.fillText("STATUS",l+10,d+10),e.font="12px monospace";const x=Math.floor(a.time/1e3),g=String(Math.floor(x/60)).padStart(2,"0"),A=String(x%60).padStart(2,"0"),T=[`Mode: ${a.mode}`,"Mic: ON",`Squad: ${((p=a.squads.find(y=>y.active))==null?void 0:p.name)??"---"}`,`Time: ${g}:${A}`];a.userName&&T.push(`User: ${a.userName}`),T.forEach((y,r)=>{e.fillStyle=u.textPrimary,e.fillText(y,l+10,d+40+r*24)})}drawTranscript(a,o,n){const e=this.ctx,s=a.slice(-10);if(s.length===0)return;const t=b.transcriptLineHeight,i=Math.min(700,this.canvas.width-100),d=s.length*t+24,l=o-i/2,x=n-d-40;e.fillStyle=u.panelBg,e.fillRect(l,x,i,d),e.strokeStyle=u.panelBorder,e.lineWidth=1,e.strokeRect(l,x,i,d),e.font="12px monospace",e.textAlign="left",e.textBaseline="top",s.forEach((g,A)=>{const T=x+12+A*t,p=g.role==="user"?"User: ":"Jarvis: ";e.fillStyle=g.role==="user"?u.textAccent:u.textJarvis;const y=Math.floor((i-20)/7),r=p+(g.text.length>y?g.text.slice(0,y-3)+"...":g.text);e.fillText(r,l+10,T)})}destroy(){this.destroyed=!0}}function H(){const c=S.useRef(null),a=S.useRef(null),o=S.useRef(0),n=S.useRef(Date.now()),[e,s]=S.useState(""),t=m(r=>r.messages);m(r=>r.userName);const i=B(r=>r.user);I(r=>r.squads),S.useEffect(()=>{i!=null&&i.username&&m.getState().setUserName(i.username)},[i==null?void 0:i.username]);const d=S.useRef(0);S.useEffect(()=>{if(t.length>d.current){const r=t[t.length-1];r.role==="assistant"&&m.getState().mode==="PROCESSING"&&(m.getState().setMode("SPEAKING"),g.current.speak(r.content))}d.current=t.length},[t]);const l=S.useCallback(r=>{const f=["Certo, vou verificar isso agora.","Entendido, deixa comigo.","Um momento, já estou processando.","Certo, já estou buscando a informação."],h=f[Math.floor(Math.random()*f.length)];g.current.speak(h)},[]),x=S.useCallback(r=>{const f=m.getState().selectedSquad??"_jarvis";m.getState().addMessage("user",r),l(r),m.getState().setMode("PROCESSING"),m.getState().clearStandbyTimer(),O(f,r)},[l]),g=S.useRef({speak:r=>{}}),{speak:A,getAnalyser:T,isSupported:p}=D({onWakeWord:r=>{const f=m.getState().mode;if(!(f==="PROCESSING"||f==="SPEAKING"))if(r)x(r);else{m.getState().setMode("GREETING");const h=m.getState().userName||"senhor";A(`Olá ${h}, como posso ajudar?`)}},onUtterance:r=>{const f=m.getState().mode;f==="PROCESSING"||f==="SPEAKING"||x(r)},onTTSEnd:()=>{const r=m.getState().mode;(r==="GREETING"||r==="SPEAKING")&&(m.getState().setMode("LISTENING"),m.getState().startStandbyTimer())}});g.current.speak=A,S.useEffect(()=>{const r=c.current;if(!r)return;const f=()=>{r.width=window.innerWidth,r.height=window.innerHeight};f(),window.addEventListener("resize",f);const h=new F(r);a.current=h;const P=()=>{const R=T();let M=null;if(R){const E=new ArrayBuffer(R.frequencyBinCount);M=new Uint8Array(E),R.getByteFrequencyData(M)}const v=m.getState(),C=I.getState().squads;h.render({mode:v.mode,time:Date.now()-n.current,amplitudes:M,squads:C.map(E=>({name:E.code,active:E.code===v.selectedSquad})),transcript:v.messages.map(E=>({role:E.role,text:E.content})),userName:v.userName}),o.current=requestAnimationFrame(P)};return o.current=requestAnimationFrame(P),()=>{cancelAnimationFrame(o.current),h.destroy(),window.removeEventListener("resize",f)}},[T]),S.useEffect(()=>()=>{m.getState().clearStandbyTimer()},[]);const y=r=>{r.preventDefault(),e.trim()&&(x(e.trim()),s(""))};return w.jsxs("div",{style:{position:"fixed",inset:0,background:u.background,zIndex:1e3},children:[w.jsx("canvas",{ref:c,style:{display:"block",width:"100%",height:"100%"}}),!p&&w.jsx("div",{style:{position:"absolute",top:20,left:"50%",transform:"translateX(-50%)",color:u.orbProcessing,fontFamily:"monospace",fontSize:13,background:"rgba(255, 140, 0, 0.1)",border:"1px solid rgba(255, 140, 0, 0.3)",borderRadius:4,padding:"8px 16px",zIndex:1001},children:"Speech recognition not available. Use text input below."}),w.jsxs("form",{onSubmit:y,style:{position:"absolute",bottom:30,left:"50%",transform:"translateX(-50%)",display:"flex",gap:8,zIndex:1001},children:[w.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),placeholder:p?"Or type a message...":"Type a message...",style:{width:400,padding:"8px 12px",background:"rgba(0, 200, 255, 0.08)",border:"1px solid rgba(0, 200, 255, 0.25)",borderRadius:4,color:u.textPrimary,fontFamily:"monospace",fontSize:13,outline:"none"}}),w.jsx("button",{type:"submit",style:{padding:"8px 16px",background:"rgba(0, 200, 255, 0.15)",border:"1px solid rgba(0, 200, 255, 0.25)",borderRadius:4,color:u.textAccent,fontFamily:"monospace",fontSize:13,cursor:"pointer"},children:"Send"})]})]})}export{H as JarvisView};
@@ -1,4 +1,4 @@
1
- import{a0 as Ve,a1 as Ne,V as oe,M as m,a2 as je,a3 as $e,H as qe,a4 as le,k as l,t as W,a5 as w,a6 as Ke,a7 as z,a8 as T,R as V,a9 as de,aa as Ye,T as f,S as g,O as D,ab as ue,w as ce,ac as ee,ad as he,ae as pe,af as fe,ag as me,y as P,ah as Je,C as E,D as N,Q as y,ai as B,aj as Xe,P as Qe,ak as Ze,L as et,v as te,al as re,am as p,f as tt,q as O,an as rt,ao as st,ap as nt,aq as at}from"./index-DGn2ljNa.js";var it=`in vec2 vMaskCoord;
1
+ import{a1 as Ve,a2 as Ne,W as oe,M as m,a3 as je,a4 as $e,I as qe,a5 as le,l,v as W,a6 as w,a7 as Ke,a8 as z,a9 as T,R as V,aa as de,ab as Ye,T as f,S as g,Q as D,ac as ue,w as ce,ad as ee,ae as he,af as pe,ag as fe,ah as me,z as P,ai as Je,C as E,D as N,V as v,aj as B,ak as Xe,P as Qe,al as Ze,N as et,x as te,am as re,an as p,h as tt,t as O,ao as rt,ap as st,aq as nt,ar as at}from"./index-CnMelTt1.js";var it=`in vec2 vMaskCoord;
2
2
  in vec2 vTextureCoord;
3
3
 
4
4
  uniform sampler2D uTexture;
@@ -167,6 +167,6 @@ fn mainFragment(
167
167
 
168
168
  return source * a;
169
169
  }
170
- `;class lt extends Ve{constructor(e){const{sprite:t,...r}=e,s=new Ne(t.texture),n=new oe({uFilterMatrix:{value:new m,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"}}),i=je.from({vertex:{source:se,entryPoint:"mainVertex"},fragment:{source:se,entryPoint:"mainFragment"}}),o=$e.from({vertex:ot,fragment:it,name:"mask-filter"});super({...r,gpuProgram:i,glProgram:o,clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=s}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(e,t,r,s){this._textureMatrix.texture=this.sprite.texture,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,e.applyFilter(this,t,r,s)}}const j=class ge{constructor(e,t){var r,s;this.state=qe.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,(s=(r=this._adaptor).init)==null||s.call(r,this)}static getBatcher(e){return new this._availableBatchers[e]}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new le({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const r in this._activeBatches)this._activeBatches[r].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let r=this._activeBatches[e.batcherName];r||(r=this._activeBatches[e.batcherName]=ge.getBatcher(e.batcherName),r.begin()),this._activeBatch=r}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const r in t){const s=t[r],n=s.geometry;n.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),n.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!1)}}upload(e){const t=this._batchersByInstructionSet[e.uid];for(const r in t){const s=t[r],n=s.geometry;s.dirty&&(s.dirty=!1,n.buffers[0].update(s.attributeSize*4))}}execute(e){if(e.action==="startBatch"){const t=e.batcher,r=t.geometry,s=t.shader;this._adaptor.start(this,r,s)}this._adaptor.execute(this,e)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};j.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"batch"};j._availableBatchers=Object.create(null);let _e=j;W.handleByMap(l.Batcher,_e._availableBatchers);W.add(le);const dt=new z;class ut extends de{constructor(){super(),this.filters=[new lt({sprite:new Ye(f.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}}class xe{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,r){const s=this._renderer;if(s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.renderMaskToTexture){const n=e.mask;n.includeInBuild=!0,n.collectRenderables(r,s,null),n.includeInBuild=!1}s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,r=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){const s=w.get(ut);if(s.inverse=e.inverse,r){e.mask.mask.measurable=!0;const n=Ke(e.mask.mask,!0,dt);e.mask.mask.measurable=!1,n.ceil();const i=t.renderTarget.renderTarget.colorTexture.source,o=T.getOptimalTexture(n.width,n.height,i._resolution,i.antialias);t.renderTarget.push(o,!0),t.globalUniforms.push({offset:n,worldColor:4294967295});const d=s.sprite;d.texture=o,d.worldTransform.tx=n.minX,d.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer,filterTexture:o})}else s.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){const s=this._activeMaskStage[this._activeMaskStage.length-1];r&&(t.type===V.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();const s=this._activeMaskStage.pop();r&&T.returnTexture(s.filterTexture),w.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}xe.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"alphaMask"};class be{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,r){this._renderer.renderPipes.batch.break(r);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);const n=this._colorStack;this._colorStackIndex--;const i=n[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}be.extension={type:[l.WebGLPipes,l.WebGPUPipes],name:"colorMask"};class Te{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,r){var s;const n=e,i=this._renderer;i.renderPipes.batch.break(r),i.renderPipes.blendMode.setBlendMode(n.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const o=n.mask;o.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const d=this._maskHash.get(n);d.instructionsStart=r.instructionSize,o.collectRenderables(r,i,null),o.includeInBuild=!1,i.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const c=r.instructionSize-d.instructionsStart-1;d.instructionsLength=c;const h=i.renderTarget.renderTarget.uid;(s=this._maskStackHash)[h]??(s[h]=0)}pop(e,t,r){const s=e,n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(s.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});const i=this._maskHash.get(e);for(let o=0;o<i.instructionsLength;o++)r.instructions[r.instructionSize++]=r.instructions[i.instructionsStart++];r.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){var t;const r=this._renderer,s=r,n=r.renderTarget.renderTarget.uid;let i=(t=this._maskStackHash)[n]??(t[n]=0);e.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(g.RENDERING_MASK_ADD,i),i++,s.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?s.stencil.setStencilMode(g.INVERSE_MASK_ACTIVE,i):s.stencil.setStencilMode(g.MASK_ACTIVE,i),s.colorMask.setMask(15)):e.action==="popMaskBegin"?(s.colorMask.setMask(0),i!==0?s.stencil.setStencilMode(g.RENDERING_MASK_REMOVE,i):(s.renderTarget.clear(null,D.STENCIL),s.stencil.setStencilMode(g.DISABLED,i)),i--):e.action==="popMaskEnd"&&(e.inverse?s.stencil.setStencilMode(g.INVERSE_MASK_ACTIVE,i):s.stencil.setStencilMode(g.MASK_ACTIVE,i),s.colorMask.setMask(15)),this._maskStackHash[n]=i}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Te.extension={type:[l.WebGLPipes,l.WebGPUPipes],name:"stencilMask"};class ye{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}ye.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"customRender"};function L(a,e){const t=a.instructionSet,r=t.instructions;for(let s=0;s<t.instructionSize;s++){const n=r[s];e[n.renderPipeId].execute(n)}}class ve{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(w.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const r=e._batchableRenderGroup??(e._batchableRenderGroup=w.get(ue));r.renderable=e.root,r.transform=e.root.relativeGroupTransform,r.texture=e.texture,r.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(r,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=new m().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push(e.texture,!0,null,e.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),L(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),L(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}ve.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"renderGroup"};class Ce{constructor(e){this._renderer=e}addRenderable(e,t){const r=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r,t)}updateRenderable(e){const t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new ue;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}Ce.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"sprite"};const v={};W.handle(l.BlendMode,a=>{if(!a.name)throw new Error("BlendMode extension must have a name property");v[a.name]=a.ref},a=>{delete v[a.name]});class ke{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,r){this._blendModeStack.push(t),this.setBlendMode(e,t,r)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,r){var n;const s=e instanceof ee;if(this._activeBlendMode===t){this._isAdvanced&&e&&!s&&((n=this._renderableList)==null||n.push(e));return}this._isAdvanced&&this._endAdvancedBlendMode(r),this._activeBlendMode=t,e&&(this._isAdvanced=!!v[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,r))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const r=this._activeBlendMode;if(!v[r]){ce(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const s=this._ensureFilterEffect(r),n=e instanceof ee,i={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:n?null:[e],container:n?e.root:null,canBundle:!1};this._renderableList=i.renderables,t.add(i)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new de,t.filters=[new v[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(const e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}ke.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"blendMode"};function H(a,e){e||(e=0);for(let t=e;t<a.length&&a[t];t++)a[t]=null}const ct=new P,ne=pe|fe|me;function Me(a,e=!1){ht(a);const t=a.childrenToUpdate,r=a.updateTick++;for(const s in t){const n=Number(s),i=t[s],o=i.list,d=i.index;for(let c=0;c<d;c++){const h=o[c];h.parentRenderGroup===a&&h.relativeRenderGroupDepth===n&&Re(h,r,0)}H(o,d),i.index=0}if(e)for(let s=0;s<a.renderGroupChildren.length;s++)Me(a.renderGroupChildren[s],e)}function ht(a){const e=a.root;let t;if(a.renderGroupParent){const r=a.renderGroupParent;a.worldTransform.appendFrom(e.relativeGroupTransform,r.worldTransform),a.worldColor=he(e.groupColor,r.worldColor),t=e.groupAlpha*r.worldAlpha}else a.worldTransform.copyFrom(e.localTransform),a.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,a.worldAlpha=t,a.worldColorAlpha=a.worldColor+((t*255|0)<<24)}function Re(a,e,t){if(e===a.updateTick)return;a.updateTick=e,a.didChange=!1;const r=a.localTransform;a.updateLocalTransform();const s=a.parent;if(s&&!s.renderGroup?(t|=a._updateFlags,a.relativeGroupTransform.appendFrom(r,s.relativeGroupTransform),t&ne&&ae(a,s,t)):(t=a._updateFlags,a.relativeGroupTransform.copyFrom(r),t&ne&&ae(a,ct,t)),!a.renderGroup){const n=a.children,i=n.length;for(let c=0;c<i;c++)Re(n[c],e,t);const o=a.parentRenderGroup,d=a;d.renderPipeId&&!o.structureDidChange&&o.updateRenderable(d)}}function ae(a,e,t){if(t&fe){a.groupColor=he(a.localColor,e.groupColor);let r=a.localAlpha*e.groupAlpha;r=r<0?0:r>1?1:r,a.groupAlpha=r,a.groupColorAlpha=a.groupColor+((r*255|0)<<24)}t&me&&(a.groupBlendMode=a.localBlendMode==="inherit"?e.groupBlendMode:a.localBlendMode),t&pe&&(a.globalDisplayStatus=a.localDisplayStatus&e.globalDisplayStatus),a._updateFlags=0}function pt(a,e){const{list:t}=a.childrenRenderablesToUpdate;let r=!1;for(let s=0;s<a.childrenRenderablesToUpdate.index;s++){const n=t[s];if(r=e[n.renderPipeId].validateRenderable(n),r)break}return a.structureDidChange=r,r}const ft=new m;class Se{constructor(e){this._renderer=e}render({container:e,transform:t}){const r=e.parent,s=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const n=this._renderer,i=ft;t&&(i.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));const o=n.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),n.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),L(e.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(i),e.parent=r,e.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let r=e.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(e.renderGroupChildren[r],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const r=e.root.getLocalBounds(),s=this._renderer,n=e.textureOptions.resolution||s.view.resolution,i=e.textureOptions.antialias??s.view.antialias,o=e.textureOptions.scaleMode??"linear",d=e.texture;r.ceil(),e.texture&&T.returnTexture(e.texture,!0);const c=T.getOptimalTexture(r.width,r.height,n,i);c._source.style=new Je({scaleMode:o}),e.texture=c,e._textureBounds||(e._textureBounds=new z),e._textureBounds.copyFrom(r),d!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(T.returnTexture(e.texture,!0),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,r=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=r,e.structureDidChange?H(e.childrenRenderablesToUpdate.list,0):pt(e,r),Me(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!(e.isCachedAsTexture&&!e.textureNeedsUpdate))for(let s=0;s<e.renderGroupChildren.length;s++)this._updateRenderGroups(e.renderGroupChildren[s])}_updateRenderables(e){const{list:t,index:r}=e.childrenRenderablesToUpdate;for(let s=0;s<r;s++){const n=t[s];n.didViewUpdate&&e.updateRenderable(n)}H(t,r)}_buildInstructions(e,t){const r=e.root,s=e.instructionSet;s.reset();const n=t.renderPipes?t:t.batch.renderer,i=n.renderPipes;i.batch.buildStart(s),i.blendMode.buildStart(),i.colorMask.buildStart(),r.sortableChildren&&r.sortChildren(),r.collectRenderablesWithEffects(s,n,null),i.batch.buildEnd(s),i.blendMode.buildEnd(s)}}Se.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"renderGroup"};const $=class we{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new E(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...we.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){E.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&ce("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};$.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"background",priority:0};$.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let mt=$;const I={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},q=class Pe{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof P||e instanceof f?{target:e,...t}:{...t,...e}}async image(e){const t=N.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,Pe.defaultImageOptions);const{format:t,quality:r}=e,s=this.canvas(e);if(s.toBlob!==void 0)return new Promise((n,i)=>{s.toBlob(o=>{if(!o){i(new Error("ICanvas.toBlob failed!"));return}const d=new FileReader;d.onload=()=>n(d.result),d.onerror=i,d.readAsDataURL(o)},I[t],r)});if(s.toDataURL!==void 0)return s.toDataURL(I[t],r);if(s.convertToBlob!==void 0){const n=await s.convertToBlob({type:I[t],quality:r});return new Promise((i,o)=>{const d=new FileReader;d.onload=()=>i(d.result),d.onerror=o,d.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){e=this._normalizeOptions(e);const t=e.target,r=this._renderer;if(t instanceof f)return r.texture.generateCanvas(t);const s=r.textureGenerator.generateTexture(e),n=r.texture.generateCanvas(s);return s.destroy(!0),n}pixels(e){e=this._normalizeOptions(e);const t=e.target,r=this._renderer,s=t instanceof f?t:r.textureGenerator.generateTexture(e),n=r.texture.getPixels(s);return t instanceof P&&s.destroy(!0),n}texture(e){return e=this._normalizeOptions(e),e.target instanceof f?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const t=this.canvas(e),r=document.createElement("a");r.download=e.filename??"image.png",r.href=t.toDataURL("image/png"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}log(e){const t=e.width??200;e=this._normalizeOptions(e);const r=this.canvas(e),s=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);const n=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};q.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"extract"};q.defaultImageOptions={format:"png",quality:1};let gt=q;class K extends f{static create(e){const{dynamic:t,...r}=e;return new K({source:new y(r),dynamic:t??!1})}resize(e,t,r){return this.source.resize(e,t,r),this}}const _t=new B,xt=new z,bt=[0,0,0,0];class Be{constructor(e){this._renderer=e}generateTexture(e){var c;e instanceof P&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,r=e.antialias||this._renderer.view.antialias,s=e.target;let n=e.clearColor;n?n=Array.isArray(n)&&n.length===4?n:E.shared.setValue(n).toArray():n=bt;const i=((c=e.frame)==null?void 0:c.copyTo(_t))||Xe(s,xt).rectangle;i.width=Math.max(i.width,1/t)|0,i.height=Math.max(i.height,1/t)|0;const o=K.create({...e.textureSourceOptions,width:i.width,height:i.height,resolution:t,antialias:r}),d=m.shared.translate(-i.x,-i.y);return this._renderer.render({container:s,transform:d,target:o,clearColor:n}),o.source.updateMipmaps(),o}destroy(){this._renderer=null}}Be.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"textureGenerator"};function Tt(a){let e=!1;for(const r in a)if(a[r]==null){e=!0;break}if(!e)return a;const t=Object.create(null);for(const r in a){const s=a[r];s&&(t[r]=s)}return t}function yt(a){let e=0;for(let t=0;t<a.length;t++)a[t]==null?e++:a[t-e]=a[t];return a.length-=e,a}const Y=class Ge{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(e){e={...Ge.defaultOptions,...e},this.maxUnusedTime=e.gcMaxUnusedTime,this._frequency=e.gcFrequency,this.enabled=e.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedCollections){const{context:r,collection:s,type:n}=t;n==="hash"?r[s]=Tt(r[s]):r[s]=yt(r[s])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(const r of e.renderGroupChildren)this._updateInstructionGCTick(r,t)}addCollection(e,t,r){this._managedCollections.push({context:e,collection:t,type:r})}addResource(e,t){var s,n;if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,(s=e._onTouch)==null||s.call(e,this.now);return}const r=this._managedResources.length;e._gcData={index:r,type:t},e._gcLastUsed=this.now,(n=e._onTouch)==null||n.call(e,this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){const t=e._gcData;if(!t)return;const r=t.index,s=this._managedResources.length-1;if(r!==s){const n=this._managedResources[s];this._managedResources[r]=n,n._gcData.index=r}this._managedResources.length--,e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,r,s=0){this._managedResourceHashes.push({context:e,hash:t,type:r,priority:s}),this._managedResourceHashes.sort((n,i)=>n.priority-i.priority)}run(){const e=performance.now(),t=this._managedResourceHashes;for(const s of t)this.runOnHash(s,e);let r=0;for(let s=0;s<this._managedResources.length;s++){const n=this._managedResources[s];r=this.runOnResource(n,e,r)}this._managedResources.length=r}updateRenderableGCTick(e,t){var n,i;const r=e.renderGroup??e.parentRenderGroup,s=((n=r==null?void 0:r.instructionSet)==null?void 0:n.gcTick)??-1;((r==null?void 0:r.gcTick)??0)===s&&(e._gcLastUsed=t,(i=e._onTouch)==null||i.call(e,t))}runOnResource(e,t,r){const s=e._gcData;return s.type==="renderable"&&this.updateRenderableGCTick(e,t),t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect?(this._managedResources[r]=e,s.index=r,r++):(e.unload(),e._gcData=null,e._gcLastUsed=-1,e.off("unload",this.removeResource,this)),r}_createHashClone(e,t){const r=Object.create(null);for(const s in e){if(s===t)break;e[s]!==null&&(r[s]=e[s])}return r}runOnHash(e,t){var c;const{context:r,hash:s,type:n}=e,i=r[s];let o=null,d=0;for(const h in i){const u=i[h];if(u===null){d++,d===1e4&&!o&&(o=this._createHashClone(i,h));continue}if(u._gcLastUsed===-1){u._gcLastUsed=t,(c=u._onTouch)==null||c.call(u,t),o&&(o[h]=u);continue}if(n==="renderable"&&this.updateRenderableGCTick(u,t),!(t-u._gcLastUsed<this.maxUnusedTime)&&u.autoGarbageCollect){if(o||(d+1!==1e4?(i[h]=null,d++):o=this._createHashClone(i,h)),n==="renderable"){const _=u,x=_.renderGroup??_.parentRenderGroup;x&&(x.structureDidChange=!0)}u.unload(),u._gcData=null,u._gcLastUsed=-1}else o&&(o[h]=u)}o&&(r[s]=o)}destroy(){this.enabled=!1,this._managedResources.forEach(e=>{e.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Y.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"gc",priority:0};Y.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let vt=Y;class Ue{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:r,worldColor:s,offset:n}){const i=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new m,worldColor:4294967295,offset:new Qe},d={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||i.size,worldTransformMatrix:r||o.worldTransformMatrix,worldColor:s||o.worldColor,offset:n||o.offset,bindGroup:null},c=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(c);const h=c.uniforms;h.uProjectionMatrix=d.projectionMatrix,h.uResolution=d.resolution,h.uWorldTransformMatrix.copyFrom(d.worldTransformMatrix),h.uWorldTransformMatrix.tx-=d.offset.x,h.uWorldTransformMatrix.ty-=d.offset.y,Ze(d.worldColor,h.uWorldColorAlpha,0),c.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c,!1):(u=this._bindGroupPool.pop()||new et,this._activeBindGroups.push(u),u.setResource(c,0)),d.bindGroup=u,this._currentGlobalUniformData=d}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===V.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new oe({uProjectionMatrix:{value:new m,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new m,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}Ue.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"globalUniforms"};let Ct=1;class Ae{constructor(){this._tasks=[],this._offset=0}init(){te.system.add(this._update,this)}repeat(e,t,r=!0){const s=Ct++;let n=0;return r&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){const e=performance.now();for(let t=0;t<this._tasks.length;t++){const r=this._tasks[t];if(e-r.offset-r.last>=r.duration){const s=e-r.start;r.func(s),r.last=e}}}destroy(){te.system.remove(this._update,this),this._tasks.length=0}}Ae.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"scheduler",priority:0};let ie=!1;function kt(a){if(!ie){if(N.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${re} (${a}) http://www.pixijs.com/
170
+ `;class lt extends Ve{constructor(e){const{sprite:t,...r}=e,s=new Ne(t.texture),n=new oe({uFilterMatrix:{value:new m,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"}}),i=je.from({vertex:{source:se,entryPoint:"mainVertex"},fragment:{source:se,entryPoint:"mainFragment"}}),o=$e.from({vertex:ot,fragment:it,name:"mask-filter"});super({...r,gpuProgram:i,glProgram:o,clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=s}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(e,t,r,s){this._textureMatrix.texture=this.sprite.texture,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,e.applyFilter(this,t,r,s)}}const j=class ge{constructor(e,t){var r,s;this.state=qe.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,(s=(r=this._adaptor).init)==null||s.call(r,this)}static getBatcher(e){return new this._availableBatchers[e]}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new le({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const r in this._activeBatches)this._activeBatches[r].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let r=this._activeBatches[e.batcherName];r||(r=this._activeBatches[e.batcherName]=ge.getBatcher(e.batcherName),r.begin()),this._activeBatch=r}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const r in t){const s=t[r],n=s.geometry;n.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),n.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!1)}}upload(e){const t=this._batchersByInstructionSet[e.uid];for(const r in t){const s=t[r],n=s.geometry;s.dirty&&(s.dirty=!1,n.buffers[0].update(s.attributeSize*4))}}execute(e){if(e.action==="startBatch"){const t=e.batcher,r=t.geometry,s=t.shader;this._adaptor.start(this,r,s)}this._adaptor.execute(this,e)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};j.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"batch"};j._availableBatchers=Object.create(null);let _e=j;W.handleByMap(l.Batcher,_e._availableBatchers);W.add(le);const dt=new z;class ut extends de{constructor(){super(),this.filters=[new lt({sprite:new Ye(f.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}}class xe{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,r){const s=this._renderer;if(s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.renderMaskToTexture){const n=e.mask;n.includeInBuild=!0,n.collectRenderables(r,s,null),n.includeInBuild=!1}s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,r=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){const s=w.get(ut);if(s.inverse=e.inverse,r){e.mask.mask.measurable=!0;const n=Ke(e.mask.mask,!0,dt);e.mask.mask.measurable=!1,n.ceil();const i=t.renderTarget.renderTarget.colorTexture.source,o=T.getOptimalTexture(n.width,n.height,i._resolution,i.antialias);t.renderTarget.push(o,!0),t.globalUniforms.push({offset:n,worldColor:4294967295});const d=s.sprite;d.texture=o,d.worldTransform.tx=n.minX,d.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer,filterTexture:o})}else s.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){const s=this._activeMaskStage[this._activeMaskStage.length-1];r&&(t.type===V.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();const s=this._activeMaskStage.pop();r&&T.returnTexture(s.filterTexture),w.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}xe.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"alphaMask"};class be{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,r){this._renderer.renderPipes.batch.break(r);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);const n=this._colorStack;this._colorStackIndex--;const i=n[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}be.extension={type:[l.WebGLPipes,l.WebGPUPipes],name:"colorMask"};class Te{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,r){var s;const n=e,i=this._renderer;i.renderPipes.batch.break(r),i.renderPipes.blendMode.setBlendMode(n.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const o=n.mask;o.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const d=this._maskHash.get(n);d.instructionsStart=r.instructionSize,o.collectRenderables(r,i,null),o.includeInBuild=!1,i.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const c=r.instructionSize-d.instructionsStart-1;d.instructionsLength=c;const h=i.renderTarget.renderTarget.uid;(s=this._maskStackHash)[h]??(s[h]=0)}pop(e,t,r){const s=e,n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(s.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});const i=this._maskHash.get(e);for(let o=0;o<i.instructionsLength;o++)r.instructions[r.instructionSize++]=r.instructions[i.instructionsStart++];r.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){var t;const r=this._renderer,s=r,n=r.renderTarget.renderTarget.uid;let i=(t=this._maskStackHash)[n]??(t[n]=0);e.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(g.RENDERING_MASK_ADD,i),i++,s.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?s.stencil.setStencilMode(g.INVERSE_MASK_ACTIVE,i):s.stencil.setStencilMode(g.MASK_ACTIVE,i),s.colorMask.setMask(15)):e.action==="popMaskBegin"?(s.colorMask.setMask(0),i!==0?s.stencil.setStencilMode(g.RENDERING_MASK_REMOVE,i):(s.renderTarget.clear(null,D.STENCIL),s.stencil.setStencilMode(g.DISABLED,i)),i--):e.action==="popMaskEnd"&&(e.inverse?s.stencil.setStencilMode(g.INVERSE_MASK_ACTIVE,i):s.stencil.setStencilMode(g.MASK_ACTIVE,i),s.colorMask.setMask(15)),this._maskStackHash[n]=i}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Te.extension={type:[l.WebGLPipes,l.WebGPUPipes],name:"stencilMask"};class ve{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}ve.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"customRender"};function L(a,e){const t=a.instructionSet,r=t.instructions;for(let s=0;s<t.instructionSize;s++){const n=r[s];e[n.renderPipeId].execute(n)}}class ye{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(w.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const r=e._batchableRenderGroup??(e._batchableRenderGroup=w.get(ue));r.renderable=e.root,r.transform=e.root.relativeGroupTransform,r.texture=e.texture,r.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(r,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=new m().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push(e.texture,!0,null,e.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),L(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),L(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}ye.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"renderGroup"};class Ce{constructor(e){this._renderer=e}addRenderable(e,t){const r=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r,t)}updateRenderable(e){const t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new ue;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}Ce.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"sprite"};const y={};W.handle(l.BlendMode,a=>{if(!a.name)throw new Error("BlendMode extension must have a name property");y[a.name]=a.ref},a=>{delete y[a.name]});class ke{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,r){this._blendModeStack.push(t),this.setBlendMode(e,t,r)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,r){var n;const s=e instanceof ee;if(this._activeBlendMode===t){this._isAdvanced&&e&&!s&&((n=this._renderableList)==null||n.push(e));return}this._isAdvanced&&this._endAdvancedBlendMode(r),this._activeBlendMode=t,e&&(this._isAdvanced=!!y[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,r))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const r=this._activeBlendMode;if(!y[r]){ce(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const s=this._ensureFilterEffect(r),n=e instanceof ee,i={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:n?null:[e],container:n?e.root:null,canBundle:!1};this._renderableList=i.renderables,t.add(i)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new de,t.filters=[new y[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(const e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}ke.extension={type:[l.WebGLPipes,l.WebGPUPipes,l.CanvasPipes],name:"blendMode"};function H(a,e){e||(e=0);for(let t=e;t<a.length&&a[t];t++)a[t]=null}const ct=new P,ne=pe|fe|me;function Me(a,e=!1){ht(a);const t=a.childrenToUpdate,r=a.updateTick++;for(const s in t){const n=Number(s),i=t[s],o=i.list,d=i.index;for(let c=0;c<d;c++){const h=o[c];h.parentRenderGroup===a&&h.relativeRenderGroupDepth===n&&Re(h,r,0)}H(o,d),i.index=0}if(e)for(let s=0;s<a.renderGroupChildren.length;s++)Me(a.renderGroupChildren[s],e)}function ht(a){const e=a.root;let t;if(a.renderGroupParent){const r=a.renderGroupParent;a.worldTransform.appendFrom(e.relativeGroupTransform,r.worldTransform),a.worldColor=he(e.groupColor,r.worldColor),t=e.groupAlpha*r.worldAlpha}else a.worldTransform.copyFrom(e.localTransform),a.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,a.worldAlpha=t,a.worldColorAlpha=a.worldColor+((t*255|0)<<24)}function Re(a,e,t){if(e===a.updateTick)return;a.updateTick=e,a.didChange=!1;const r=a.localTransform;a.updateLocalTransform();const s=a.parent;if(s&&!s.renderGroup?(t|=a._updateFlags,a.relativeGroupTransform.appendFrom(r,s.relativeGroupTransform),t&ne&&ae(a,s,t)):(t=a._updateFlags,a.relativeGroupTransform.copyFrom(r),t&ne&&ae(a,ct,t)),!a.renderGroup){const n=a.children,i=n.length;for(let c=0;c<i;c++)Re(n[c],e,t);const o=a.parentRenderGroup,d=a;d.renderPipeId&&!o.structureDidChange&&o.updateRenderable(d)}}function ae(a,e,t){if(t&fe){a.groupColor=he(a.localColor,e.groupColor);let r=a.localAlpha*e.groupAlpha;r=r<0?0:r>1?1:r,a.groupAlpha=r,a.groupColorAlpha=a.groupColor+((r*255|0)<<24)}t&me&&(a.groupBlendMode=a.localBlendMode==="inherit"?e.groupBlendMode:a.localBlendMode),t&pe&&(a.globalDisplayStatus=a.localDisplayStatus&e.globalDisplayStatus),a._updateFlags=0}function pt(a,e){const{list:t}=a.childrenRenderablesToUpdate;let r=!1;for(let s=0;s<a.childrenRenderablesToUpdate.index;s++){const n=t[s];if(r=e[n.renderPipeId].validateRenderable(n),r)break}return a.structureDidChange=r,r}const ft=new m;class Se{constructor(e){this._renderer=e}render({container:e,transform:t}){const r=e.parent,s=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const n=this._renderer,i=ft;t&&(i.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));const o=n.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),n.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),L(e.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(i),e.parent=r,e.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let r=e.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(e.renderGroupChildren[r],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const r=e.root.getLocalBounds(),s=this._renderer,n=e.textureOptions.resolution||s.view.resolution,i=e.textureOptions.antialias??s.view.antialias,o=e.textureOptions.scaleMode??"linear",d=e.texture;r.ceil(),e.texture&&T.returnTexture(e.texture,!0);const c=T.getOptimalTexture(r.width,r.height,n,i);c._source.style=new Je({scaleMode:o}),e.texture=c,e._textureBounds||(e._textureBounds=new z),e._textureBounds.copyFrom(r),d!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(T.returnTexture(e.texture,!0),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,r=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=r,e.structureDidChange?H(e.childrenRenderablesToUpdate.list,0):pt(e,r),Me(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!(e.isCachedAsTexture&&!e.textureNeedsUpdate))for(let s=0;s<e.renderGroupChildren.length;s++)this._updateRenderGroups(e.renderGroupChildren[s])}_updateRenderables(e){const{list:t,index:r}=e.childrenRenderablesToUpdate;for(let s=0;s<r;s++){const n=t[s];n.didViewUpdate&&e.updateRenderable(n)}H(t,r)}_buildInstructions(e,t){const r=e.root,s=e.instructionSet;s.reset();const n=t.renderPipes?t:t.batch.renderer,i=n.renderPipes;i.batch.buildStart(s),i.blendMode.buildStart(),i.colorMask.buildStart(),r.sortableChildren&&r.sortChildren(),r.collectRenderablesWithEffects(s,n,null),i.batch.buildEnd(s),i.blendMode.buildEnd(s)}}Se.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"renderGroup"};const $=class we{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new E(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...we.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){E.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&ce("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};$.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"background",priority:0};$.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let mt=$;const I={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},q=class Pe{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof P||e instanceof f?{target:e,...t}:{...t,...e}}async image(e){const t=N.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,Pe.defaultImageOptions);const{format:t,quality:r}=e,s=this.canvas(e);if(s.toBlob!==void 0)return new Promise((n,i)=>{s.toBlob(o=>{if(!o){i(new Error("ICanvas.toBlob failed!"));return}const d=new FileReader;d.onload=()=>n(d.result),d.onerror=i,d.readAsDataURL(o)},I[t],r)});if(s.toDataURL!==void 0)return s.toDataURL(I[t],r);if(s.convertToBlob!==void 0){const n=await s.convertToBlob({type:I[t],quality:r});return new Promise((i,o)=>{const d=new FileReader;d.onload=()=>i(d.result),d.onerror=o,d.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){e=this._normalizeOptions(e);const t=e.target,r=this._renderer;if(t instanceof f)return r.texture.generateCanvas(t);const s=r.textureGenerator.generateTexture(e),n=r.texture.generateCanvas(s);return s.destroy(!0),n}pixels(e){e=this._normalizeOptions(e);const t=e.target,r=this._renderer,s=t instanceof f?t:r.textureGenerator.generateTexture(e),n=r.texture.getPixels(s);return t instanceof P&&s.destroy(!0),n}texture(e){return e=this._normalizeOptions(e),e.target instanceof f?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const t=this.canvas(e),r=document.createElement("a");r.download=e.filename??"image.png",r.href=t.toDataURL("image/png"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}log(e){const t=e.width??200;e=this._normalizeOptions(e);const r=this.canvas(e),s=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);const n=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};q.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"extract"};q.defaultImageOptions={format:"png",quality:1};let gt=q;class K extends f{static create(e){const{dynamic:t,...r}=e;return new K({source:new v(r),dynamic:t??!1})}resize(e,t,r){return this.source.resize(e,t,r),this}}const _t=new B,xt=new z,bt=[0,0,0,0];class Be{constructor(e){this._renderer=e}generateTexture(e){var c;e instanceof P&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,r=e.antialias||this._renderer.view.antialias,s=e.target;let n=e.clearColor;n?n=Array.isArray(n)&&n.length===4?n:E.shared.setValue(n).toArray():n=bt;const i=((c=e.frame)==null?void 0:c.copyTo(_t))||Xe(s,xt).rectangle;i.width=Math.max(i.width,1/t)|0,i.height=Math.max(i.height,1/t)|0;const o=K.create({...e.textureSourceOptions,width:i.width,height:i.height,resolution:t,antialias:r}),d=m.shared.translate(-i.x,-i.y);return this._renderer.render({container:s,transform:d,target:o,clearColor:n}),o.source.updateMipmaps(),o}destroy(){this._renderer=null}}Be.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"textureGenerator"};function Tt(a){let e=!1;for(const r in a)if(a[r]==null){e=!0;break}if(!e)return a;const t=Object.create(null);for(const r in a){const s=a[r];s&&(t[r]=s)}return t}function vt(a){let e=0;for(let t=0;t<a.length;t++)a[t]==null?e++:a[t-e]=a[t];return a.length-=e,a}const Y=class Ge{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(e){e={...Ge.defaultOptions,...e},this.maxUnusedTime=e.gcMaxUnusedTime,this._frequency=e.gcFrequency,this.enabled=e.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedCollections){const{context:r,collection:s,type:n}=t;n==="hash"?r[s]=Tt(r[s]):r[s]=vt(r[s])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(const r of e.renderGroupChildren)this._updateInstructionGCTick(r,t)}addCollection(e,t,r){this._managedCollections.push({context:e,collection:t,type:r})}addResource(e,t){var s,n;if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,(s=e._onTouch)==null||s.call(e,this.now);return}const r=this._managedResources.length;e._gcData={index:r,type:t},e._gcLastUsed=this.now,(n=e._onTouch)==null||n.call(e,this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){const t=e._gcData;if(!t)return;const r=t.index,s=this._managedResources.length-1;if(r!==s){const n=this._managedResources[s];this._managedResources[r]=n,n._gcData.index=r}this._managedResources.length--,e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,r,s=0){this._managedResourceHashes.push({context:e,hash:t,type:r,priority:s}),this._managedResourceHashes.sort((n,i)=>n.priority-i.priority)}run(){const e=performance.now(),t=this._managedResourceHashes;for(const s of t)this.runOnHash(s,e);let r=0;for(let s=0;s<this._managedResources.length;s++){const n=this._managedResources[s];r=this.runOnResource(n,e,r)}this._managedResources.length=r}updateRenderableGCTick(e,t){var n,i;const r=e.renderGroup??e.parentRenderGroup,s=((n=r==null?void 0:r.instructionSet)==null?void 0:n.gcTick)??-1;((r==null?void 0:r.gcTick)??0)===s&&(e._gcLastUsed=t,(i=e._onTouch)==null||i.call(e,t))}runOnResource(e,t,r){const s=e._gcData;return s.type==="renderable"&&this.updateRenderableGCTick(e,t),t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect?(this._managedResources[r]=e,s.index=r,r++):(e.unload(),e._gcData=null,e._gcLastUsed=-1,e.off("unload",this.removeResource,this)),r}_createHashClone(e,t){const r=Object.create(null);for(const s in e){if(s===t)break;e[s]!==null&&(r[s]=e[s])}return r}runOnHash(e,t){var c;const{context:r,hash:s,type:n}=e,i=r[s];let o=null,d=0;for(const h in i){const u=i[h];if(u===null){d++,d===1e4&&!o&&(o=this._createHashClone(i,h));continue}if(u._gcLastUsed===-1){u._gcLastUsed=t,(c=u._onTouch)==null||c.call(u,t),o&&(o[h]=u);continue}if(n==="renderable"&&this.updateRenderableGCTick(u,t),!(t-u._gcLastUsed<this.maxUnusedTime)&&u.autoGarbageCollect){if(o||(d+1!==1e4?(i[h]=null,d++):o=this._createHashClone(i,h)),n==="renderable"){const _=u,x=_.renderGroup??_.parentRenderGroup;x&&(x.structureDidChange=!0)}u.unload(),u._gcData=null,u._gcLastUsed=-1}else o&&(o[h]=u)}o&&(r[s]=o)}destroy(){this.enabled=!1,this._managedResources.forEach(e=>{e.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Y.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"gc",priority:0};Y.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let yt=Y;class Ue{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:r,worldColor:s,offset:n}){const i=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new m,worldColor:4294967295,offset:new Qe},d={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||i.size,worldTransformMatrix:r||o.worldTransformMatrix,worldColor:s||o.worldColor,offset:n||o.offset,bindGroup:null},c=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(c);const h=c.uniforms;h.uProjectionMatrix=d.projectionMatrix,h.uResolution=d.resolution,h.uWorldTransformMatrix.copyFrom(d.worldTransformMatrix),h.uWorldTransformMatrix.tx-=d.offset.x,h.uWorldTransformMatrix.ty-=d.offset.y,Ze(d.worldColor,h.uWorldColorAlpha,0),c.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c,!1):(u=this._bindGroupPool.pop()||new et,this._activeBindGroups.push(u),u.setResource(c,0)),d.bindGroup=u,this._currentGlobalUniformData=d}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===V.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new oe({uProjectionMatrix:{value:new m,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new m,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}Ue.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"globalUniforms"};let Ct=1;class Ae{constructor(){this._tasks=[],this._offset=0}init(){te.system.add(this._update,this)}repeat(e,t,r=!0){const s=Ct++;let n=0;return r&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){const e=performance.now();for(let t=0;t<this._tasks.length;t++){const r=this._tasks[t];if(e-r.offset-r.last>=r.duration){const s=e-r.start;r.func(s),r.last=e}}}destroy(){te.system.remove(this._update,this),this._tasks.length=0}}Ae.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"scheduler",priority:0};let ie=!1;function kt(a){if(!ie){if(N.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${re} (${a}) http://www.pixijs.com/
171
171
 
172
- `,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${re} - ${a} - http://www.pixijs.com/`);ie=!0}}class J{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===V.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),kt(t)}}}J.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"hello",priority:-2};J.defaultOptions={hello:!1};const X=class Ie{constructor(e){this._renderer=e}init(e){e={...Ie.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return p("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){p("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){p("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){p("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){p("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){p("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};X.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"renderableGC",priority:0};X.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Mt=X;const Q=class S{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(e){e.textureGCActive!==S.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==S.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==S.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Q.extension={type:[l.WebGLSystem,l.WebGPUSystem],name:"textureGC"};Q.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Rt=Q;const De=class Ee{constructor(e={}){if(this.uid=tt("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e={...Ee.defaultOptions,...e},this.stencil=e.stencil,this.depth=e.depth,this.isRoot=e.isRoot,typeof e.colorTextures=="number"){this._managedColorTextures=!0;for(let t=0;t<e.colorTextures;t++)this.colorTextures.push(new y({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(r=>r.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(e.depthStencilTexture||this.stencil)&&(e.depthStencilTexture instanceof f||e.depthStencilTexture instanceof y?this.depthStencilTexture=e.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new y({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(e,t,r=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,i)=>{s&&i===0||n.source.resize(e,t,r)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(e,t,r)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(e=>{e.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};De.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let F=De;const b=new Map;rt.register(b);function Oe(a,e){if(!b.has(a)){const t=new f({source:new O({resource:a,...e})}),r=()=>{b.get(a)===t&&b.delete(a)};t.once("destroy",r),t.source.once("destroy",r),b.set(a,t)}return b.get(a)}const Z=class Le{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(e){e={...Le.defaultOptions,...e},e.view&&(p(st,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new B(0,0,e.width,e.height),this.canvas=e.canvas||N.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Oe(this.canvas,e),this.renderTarget=new F({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(e,t,r){this.texture.source.resize(e,t,r),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e=="boolean"?e:!!(e!=null&&e.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};Z.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"view",priority:0};Z.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let St=Z;const Gt=[mt,Ue,J,St,Se,vt,Rt,Be,gt,nt,Mt,Ae],Ut=[ke,_e,Ce,ve,xe,Te,be,ye];function wt(a,e,t,r,s,n){const i=n?1:-1;return a.identity(),a.a=1/r*2,a.d=i*(1/s*2),a.tx=-1-e*a.a,a.ty=-i-t*a.d,a}function Pt(a){const e=a.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}class At{constructor(e){this.rootViewPort=new B,this.viewport=new B,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new at("onRenderTargetChange"),this.projectionMatrix=new m,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:r,frame:s,mipLevel:n,layer:i}){var o,d;this._renderTargetStack.length=0,this.push(e,t,r,s,n??0,i??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Pt(this.rootRenderTarget),(d=(o=this.adaptor).prerender)==null||d.call(o,this.rootRenderTarget)}postrender(){var e,t;(t=(e=this.adaptor).postrender)==null||t.call(e,this.rootRenderTarget)}bind(e,t=!0,r,s,n=0,i=0){const o=this.getRenderTarget(e),d=this.renderTarget!==o;this.renderTarget=o,this.renderSurface=e;const c=this.getGpuRenderTarget(o);(o.pixelWidth!==c.width||o.pixelHeight!==c.height)&&(this.adaptor.resizeGpuRenderTarget(o),c.width=o.pixelWidth,c.height=o.pixelHeight);const h=o.colorTexture,u=this.viewport,G=h.arrayLayerCount||1;if((i|0)!==i&&(i|=0),i<0||i>=G)throw new Error(`[RenderTargetSystem] layer ${i} is out of bounds (arrayLayerCount=${G}).`);this.mipLevel=n|0,this.layer=i|0;const _=Math.max(h.pixelWidth>>n,1),x=Math.max(h.pixelHeight>>n,1);if(!s&&e instanceof f&&(s=e.frame),s){const C=h._resolution,k=1<<Math.max(n|0,0),He=s.x*C+.5|0,Fe=s.y*C+.5|0,We=s.width*C+.5|0,ze=s.height*C+.5|0;let M=Math.floor(He/k),R=Math.floor(Fe/k),U=Math.ceil(We/k),A=Math.ceil(ze/k);M=Math.min(Math.max(M,0),_-1),R=Math.min(Math.max(R,0),x-1),U=Math.min(Math.max(U,1),_-M),A=Math.min(Math.max(A,1),x-R),u.x=M,u.y=R,u.width=U,u.height=A}else u.x=0,u.y=0,u.width=_,u.height=x;return wt(this.projectionMatrix,0,0,u.width/h.resolution,u.height/h.resolution,!o.isRoot),this.adaptor.startRenderPass(o,t,r,u,n,i),d&&this.onRenderTargetChange.emit(o),o}clear(e,t=D.ALL,r,s=this.mipLevel,n=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,r,this.viewport,s,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=D.ALL,r,s,n=0,i=0){const o=this.bind(e,t,r,s,n,i);return this._renderTargetStack.push({renderTarget:o,frame:s,mipLevel:n,layer:i}),o}pop(){this._renderTargetStack.pop();const e=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(e.renderTarget,!1,null,e.frame,e.mipLevel,e.layer)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,r,s,n){r.x<0&&(s.width+=r.x,n.x-=r.x,r.x=0),r.y<0&&(s.height+=r.y,n.y-=r.y,r.y=0);const{pixelWidth:i,pixelHeight:o}=e;return s.width=Math.min(s.width,i-r.x),s.height=Math.min(s.height,o-r.y),this.adaptor.copyToTexture(e,t,r,s,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e!==t&&e.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;return O.test(e)&&(e=Oe(e).source),e instanceof F?t=e:e instanceof y&&(t=new F({colorTextures:[e]}),e.source instanceof O&&(t.isRoot=!0),e.once("destroy",()=>{t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);const r=this._gpuRenderTargetHash[t.uid];r&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(r))})),this._renderSurfaceToRenderTargetHash.set(e,t),t}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this.renderSurface=null}}export{xe as A,ke as B,ye as C,At as R,Gt as S,_e as a,Ce as b,ve as c,Ut as d};
172
+ `,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${re} - ${a} - http://www.pixijs.com/`);ie=!0}}class J{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===V.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),kt(t)}}}J.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"hello",priority:-2};J.defaultOptions={hello:!1};const X=class Ie{constructor(e){this._renderer=e}init(e){e={...Ie.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return p("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){p("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){p("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){p("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){p("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){p("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};X.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"renderableGC",priority:0};X.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Mt=X;const Q=class S{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(e){e.textureGCActive!==S.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==S.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==S.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){p("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Q.extension={type:[l.WebGLSystem,l.WebGPUSystem],name:"textureGC"};Q.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Rt=Q;const De=class Ee{constructor(e={}){if(this.uid=tt("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e={...Ee.defaultOptions,...e},this.stencil=e.stencil,this.depth=e.depth,this.isRoot=e.isRoot,typeof e.colorTextures=="number"){this._managedColorTextures=!0;for(let t=0;t<e.colorTextures;t++)this.colorTextures.push(new v({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(r=>r.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(e.depthStencilTexture||this.stencil)&&(e.depthStencilTexture instanceof f||e.depthStencilTexture instanceof v?this.depthStencilTexture=e.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new v({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(e,t,r=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,i)=>{s&&i===0||n.source.resize(e,t,r)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(e,t,r)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(e=>{e.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};De.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let F=De;const b=new Map;rt.register(b);function Oe(a,e){if(!b.has(a)){const t=new f({source:new O({resource:a,...e})}),r=()=>{b.get(a)===t&&b.delete(a)};t.once("destroy",r),t.source.once("destroy",r),b.set(a,t)}return b.get(a)}const Z=class Le{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(e){e={...Le.defaultOptions,...e},e.view&&(p(st,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new B(0,0,e.width,e.height),this.canvas=e.canvas||N.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Oe(this.canvas,e),this.renderTarget=new F({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(e,t,r){this.texture.source.resize(e,t,r),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e=="boolean"?e:!!(e!=null&&e.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};Z.extension={type:[l.WebGLSystem,l.WebGPUSystem,l.CanvasSystem],name:"view",priority:0};Z.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let St=Z;const Gt=[mt,Ue,J,St,Se,yt,Rt,Be,gt,nt,Mt,Ae],Ut=[ke,_e,Ce,ye,xe,Te,be,ve];function wt(a,e,t,r,s,n){const i=n?1:-1;return a.identity(),a.a=1/r*2,a.d=i*(1/s*2),a.tx=-1-e*a.a,a.ty=-i-t*a.d,a}function Pt(a){const e=a.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}class At{constructor(e){this.rootViewPort=new B,this.viewport=new B,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new at("onRenderTargetChange"),this.projectionMatrix=new m,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:r,frame:s,mipLevel:n,layer:i}){var o,d;this._renderTargetStack.length=0,this.push(e,t,r,s,n??0,i??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Pt(this.rootRenderTarget),(d=(o=this.adaptor).prerender)==null||d.call(o,this.rootRenderTarget)}postrender(){var e,t;(t=(e=this.adaptor).postrender)==null||t.call(e,this.rootRenderTarget)}bind(e,t=!0,r,s,n=0,i=0){const o=this.getRenderTarget(e),d=this.renderTarget!==o;this.renderTarget=o,this.renderSurface=e;const c=this.getGpuRenderTarget(o);(o.pixelWidth!==c.width||o.pixelHeight!==c.height)&&(this.adaptor.resizeGpuRenderTarget(o),c.width=o.pixelWidth,c.height=o.pixelHeight);const h=o.colorTexture,u=this.viewport,G=h.arrayLayerCount||1;if((i|0)!==i&&(i|=0),i<0||i>=G)throw new Error(`[RenderTargetSystem] layer ${i} is out of bounds (arrayLayerCount=${G}).`);this.mipLevel=n|0,this.layer=i|0;const _=Math.max(h.pixelWidth>>n,1),x=Math.max(h.pixelHeight>>n,1);if(!s&&e instanceof f&&(s=e.frame),s){const C=h._resolution,k=1<<Math.max(n|0,0),He=s.x*C+.5|0,Fe=s.y*C+.5|0,We=s.width*C+.5|0,ze=s.height*C+.5|0;let M=Math.floor(He/k),R=Math.floor(Fe/k),U=Math.ceil(We/k),A=Math.ceil(ze/k);M=Math.min(Math.max(M,0),_-1),R=Math.min(Math.max(R,0),x-1),U=Math.min(Math.max(U,1),_-M),A=Math.min(Math.max(A,1),x-R),u.x=M,u.y=R,u.width=U,u.height=A}else u.x=0,u.y=0,u.width=_,u.height=x;return wt(this.projectionMatrix,0,0,u.width/h.resolution,u.height/h.resolution,!o.isRoot),this.adaptor.startRenderPass(o,t,r,u,n,i),d&&this.onRenderTargetChange.emit(o),o}clear(e,t=D.ALL,r,s=this.mipLevel,n=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,r,this.viewport,s,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=D.ALL,r,s,n=0,i=0){const o=this.bind(e,t,r,s,n,i);return this._renderTargetStack.push({renderTarget:o,frame:s,mipLevel:n,layer:i}),o}pop(){this._renderTargetStack.pop();const e=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(e.renderTarget,!1,null,e.frame,e.mipLevel,e.layer)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,r,s,n){r.x<0&&(s.width+=r.x,n.x-=r.x,r.x=0),r.y<0&&(s.height+=r.y,n.y-=r.y,r.y=0);const{pixelWidth:i,pixelHeight:o}=e;return s.width=Math.min(s.width,i-r.x),s.height=Math.min(s.height,o-r.y),this.adaptor.copyToTexture(e,t,r,s,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e!==t&&e.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;return O.test(e)&&(e=Oe(e).source),e instanceof F?t=e:e instanceof v&&(t=new F({colorTextures:[e]}),e.source instanceof O&&(t.isRoot=!0),e.once("destroy",()=>{t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);const r=this._gpuRenderTargetHash[t.uid];r&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(r))})),this._renderSurfaceToRenderTargetHash.set(e,t),t}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this.renderSurface=null}}export{xe as A,ke as B,ve as C,At as R,Gt as S,_e as a,Ce as b,ye as c,Ut as d};
@@ -0,0 +1 @@
1
+ import{r as d,u as k,j as Z}from"./index-CnMelTt1.js";import{S as $,O as tt,W as et,B as q,a as G,P as ot,C as nt,b as st,L as it,c as rt,V as D}from"./three-BZk_I9Ly.js";const m=60,_=120,H=40;function at(){try{const R=document.createElement("canvas");return!!(R.getContext("webgl2")||R.getContext("webgl"))}catch{return!1}}function ut({opacity:R=1}){const N=d.useRef(null),T=d.useRef(0),C=d.useRef({x:0,y:0}),F=d.useRef(k.getState().theme),[S]=d.useState(()=>at());return d.useEffect(()=>k.subscribe(p=>{F.current=p.theme}),[]),d.useEffect(()=>{if(!S)return;const n=N.current;if(!n)return;const p=n.clientWidth,b=n.clientHeight,P=new $,M=new tt(0,p,0,b,-100,100),c=new et({alpha:!0,antialias:!0});c.setSize(p,b),c.setPixelRatio(Math.min(window.devicePixelRatio,2)),n.appendChild(c.domElement);const r=[],v=new q,g=new Float32Array(m*3);for(let e=0;e<m;e++){const s=Math.random()*p,u=Math.random()*b,E=(Math.random()-.5)*.3,L=(Math.random()-.5)*.3;r.push({position:new D(s,u,0),velocity:new D(E,L,0),baseY:u}),g[e*3]=s,g[e*3+1]=u,g[e*3+2]=0}v.setAttribute("position",new G(g,3));const A=new ot({size:2,color:new nt("#007acc"),transparent:!0,opacity:.6,sizeAttenuation:!1}),V=new st(v,A);P.add(V);const a=new q,I=m*m,Y=new Float32Array(I*6),X=new Float32Array(I*6);a.setAttribute("position",new G(Y,3)),a.setAttribute("color",new G(X,3));const z=new it({vertexColors:!0,transparent:!0,opacity:.12,depthTest:!1}),J=new rt(a,z);P.add(J);const O=e=>{const s=n.getBoundingClientRect();C.current.x=e.clientX-s.left,C.current.y=e.clientY-s.top};n.addEventListener("mousemove",O);let U=0;const j=()=>{T.current=requestAnimationFrame(j),U+=.005;const e=F.current==="dark",s=0,u=.478,E=.8;A.color.setRGB(s,u,E),A.opacity=e?.5:.35,z.opacity=e?.08:.05;const L=v.attributes.position.array,K=C.current.x,Q=C.current.y;for(let o=0;o<m;o++){const t=r[o];t.position.x+=t.velocity.x,t.position.y+=t.velocity.y+Math.sin(U+o*.1)*.08;const x=K-t.position.x,h=Q-t.position.y,l=Math.sqrt(x*x+h*h);l<200&&l>1&&(t.position.x+=x/l*H*.005,t.position.y+=h/l*H*.005),t.position.x<-10&&(t.position.x=p+10),t.position.x>p+10&&(t.position.x=-10),t.position.y<-10&&(t.position.y=b+10),t.position.y>b+10&&(t.position.y=-10),L[o*3]=t.position.x,L[o*3+1]=t.position.y}v.attributes.position.needsUpdate=!0;let B=0;const f=a.attributes.position.array,y=a.attributes.color.array;for(let o=0;o<m;o++)for(let t=o+1;t<m;t++){const x=r[o].position.x-r[t].position.x,h=r[o].position.y-r[t].position.y,l=Math.sqrt(x*x+h*h);if(l<_){const w=1-l/_,i=B*6;f[i]=r[o].position.x,f[i+1]=r[o].position.y,f[i+2]=0,f[i+3]=r[t].position.x,f[i+4]=r[t].position.y,f[i+5]=0,y[i]=s*w,y[i+1]=u*w,y[i+2]=E*w,y[i+3]=s*w,y[i+4]=u*w,y[i+5]=E*w,B++}}a.setDrawRange(0,B*2),a.attributes.position.needsUpdate=!0,a.attributes.color.needsUpdate=!0,c.render(P,M)};j();const W=()=>{const e=n.clientWidth,s=n.clientHeight;M.right=e,M.bottom=s,M.updateProjectionMatrix(),c.setSize(e,s)};return window.addEventListener("resize",W),()=>{cancelAnimationFrame(T.current),n.removeEventListener("mousemove",O),window.removeEventListener("resize",W),c.dispose(),v.dispose(),A.dispose(),a.dispose(),z.dispose(),n.contains(c.domElement)&&n.removeChild(c.domElement)}},[S]),S?Z.jsx("div",{ref:N,style:{position:"absolute",inset:0,zIndex:0,pointerEvents:"auto",opacity:R}}):null}export{ut as ThreeBackground};