@foothill/agent-move 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +46 -9
  2. package/package.json +2 -1
  3. package/packages/client/dist/assets/{BufferResource-Ddjob236.js → BufferResource-Dfd5uHKt.js} +1 -1
  4. package/packages/client/dist/assets/{CanvasRenderer-B0w6SYyW.js → CanvasRenderer-7Cv6xZVP.js} +1 -1
  5. package/packages/client/dist/assets/{Filter-NcMGuiK-.js → Filter-CBX7EB7j.js} +1 -1
  6. package/packages/client/dist/assets/{RenderTargetSystem-DgAzY5_U.js → RenderTargetSystem-ko-v73NG.js} +1 -1
  7. package/packages/client/dist/assets/{WebGLRenderer-DUWXDPIX.js → WebGLRenderer-vhPQEPUG.js} +1 -1
  8. package/packages/client/dist/assets/{WebGPURenderer-C1HbrllR.js → WebGPURenderer-Dwywvwqe.js} +1 -1
  9. package/packages/client/dist/assets/{browserAll-CaF1Fl0O.js → browserAll-QyCAT8_K.js} +1 -1
  10. package/packages/client/dist/assets/index-BPJtz4FL.js +722 -0
  11. package/packages/client/dist/assets/{webworkerAll-BJ6UhC7r.js → webworkerAll-hM-gNP7L.js} +1 -1
  12. package/packages/client/dist/index.html +1 -1
  13. package/packages/server/dist/config.d.ts +4 -0
  14. package/packages/server/dist/config.d.ts.map +1 -1
  15. package/packages/server/dist/config.js +5 -5
  16. package/packages/server/dist/config.js.map +1 -1
  17. package/packages/server/dist/hooks/hook-event-manager.js +0 -4
  18. package/packages/server/dist/hooks/hook-installer.js +0 -4
  19. package/packages/server/dist/index.d.ts.map +1 -1
  20. package/packages/server/dist/index.js +792 -856
  21. package/packages/server/dist/index.js.map +1 -1
  22. package/packages/server/dist/routes/api.js +0 -4
  23. package/packages/server/dist/state/activity-processor.d.ts +1 -1
  24. package/packages/server/dist/state/activity-processor.d.ts.map +1 -1
  25. package/packages/server/dist/state/activity-processor.js +1 -5
  26. package/packages/server/dist/state/activity-processor.js.map +1 -1
  27. package/packages/server/dist/state/agent-state-manager.d.ts +1 -2
  28. package/packages/server/dist/state/agent-state-manager.d.ts.map +1 -1
  29. package/packages/server/dist/state/agent-state-manager.js +87 -6
  30. package/packages/server/dist/state/agent-state-manager.js.map +1 -1
  31. package/packages/server/dist/state/anomaly-detector.js +0 -4
  32. package/packages/server/dist/state/identity-manager.js +0 -4
  33. package/packages/server/dist/state/role-resolver.d.ts +1 -2
  34. package/packages/server/dist/state/role-resolver.d.ts.map +1 -1
  35. package/packages/server/dist/state/role-resolver.js +0 -4
  36. package/packages/server/dist/state/role-resolver.js.map +1 -1
  37. package/packages/server/dist/state/task-graph-manager.d.ts +12 -0
  38. package/packages/server/dist/state/task-graph-manager.d.ts.map +1 -1
  39. package/packages/server/dist/state/task-graph-manager.js +80 -4
  40. package/packages/server/dist/state/task-graph-manager.js.map +1 -1
  41. package/packages/server/dist/state/tool-chain-tracker.js +0 -4
  42. package/packages/server/dist/watcher/agent-watcher.js +0 -5
  43. package/packages/server/dist/watcher/claude/claude-paths.d.ts +18 -0
  44. package/packages/server/dist/watcher/claude/claude-paths.d.ts.map +1 -0
  45. package/packages/server/dist/watcher/{claude-paths.js → claude/claude-paths.js} +47 -59
  46. package/packages/server/dist/watcher/claude/claude-paths.js.map +1 -0
  47. package/packages/server/dist/watcher/{file-watcher.d.ts → claude/claude-watcher.d.ts} +3 -3
  48. package/packages/server/dist/watcher/claude/claude-watcher.d.ts.map +1 -0
  49. package/packages/server/dist/watcher/{file-watcher.js → claude/claude-watcher.js} +59 -69
  50. package/packages/server/dist/watcher/claude/claude-watcher.js.map +1 -0
  51. package/packages/server/dist/watcher/claude/jsonl-parser.d.ts +6 -0
  52. package/packages/server/dist/watcher/claude/jsonl-parser.d.ts.map +1 -0
  53. package/packages/server/dist/watcher/{jsonl-parser.js → claude/jsonl-parser.js} +1 -5
  54. package/packages/server/dist/watcher/claude/jsonl-parser.js.map +1 -0
  55. package/packages/server/dist/watcher/codex/codex-parser.d.ts +30 -0
  56. package/packages/server/dist/watcher/codex/codex-parser.d.ts.map +1 -0
  57. package/packages/server/dist/watcher/codex/codex-parser.js +326 -0
  58. package/packages/server/dist/watcher/codex/codex-parser.js.map +1 -0
  59. package/packages/server/dist/watcher/codex/codex-paths.d.ts +35 -0
  60. package/packages/server/dist/watcher/codex/codex-paths.d.ts.map +1 -0
  61. package/packages/server/dist/watcher/codex/codex-paths.js +46 -0
  62. package/packages/server/dist/watcher/codex/codex-paths.js.map +1 -0
  63. package/packages/server/dist/watcher/codex/codex-watcher.d.ts +42 -0
  64. package/packages/server/dist/watcher/codex/codex-watcher.d.ts.map +1 -0
  65. package/packages/server/dist/watcher/codex/codex-watcher.js +577 -0
  66. package/packages/server/dist/watcher/codex/codex-watcher.js.map +1 -0
  67. package/packages/server/dist/watcher/git-info.js +0 -4
  68. package/packages/server/dist/watcher/opencode/opencode-parser.d.ts +1 -1
  69. package/packages/server/dist/watcher/opencode/opencode-parser.d.ts.map +1 -1
  70. package/packages/server/dist/watcher/opencode/opencode-parser.js +31 -6
  71. package/packages/server/dist/watcher/opencode/opencode-paths.d.ts +1 -1
  72. package/packages/server/dist/watcher/opencode/opencode-paths.d.ts.map +1 -1
  73. package/packages/server/dist/watcher/opencode/opencode-paths.js +1 -4
  74. package/packages/server/dist/watcher/opencode/opencode-paths.js.map +1 -1
  75. package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts.map +1 -1
  76. package/packages/server/dist/watcher/opencode/opencode-watcher.js +50 -789
  77. package/packages/server/dist/watcher/opencode/opencode-watcher.js.map +1 -1
  78. package/packages/server/dist/watcher/path-utils.d.ts +10 -0
  79. package/packages/server/dist/watcher/path-utils.d.ts.map +1 -0
  80. package/packages/server/dist/watcher/path-utils.js +38 -0
  81. package/packages/server/dist/watcher/path-utils.js.map +1 -0
  82. package/packages/server/dist/watcher/pi/pi-parser.d.ts +19 -0
  83. package/packages/server/dist/watcher/pi/pi-parser.d.ts.map +1 -0
  84. package/packages/server/dist/watcher/pi/pi-parser.js +307 -0
  85. package/packages/server/dist/watcher/pi/pi-parser.js.map +1 -0
  86. package/packages/server/dist/watcher/pi/pi-paths.d.ts +28 -0
  87. package/packages/server/dist/watcher/pi/pi-paths.d.ts.map +1 -0
  88. package/packages/server/dist/watcher/pi/pi-paths.js +86 -0
  89. package/packages/server/dist/watcher/pi/pi-paths.js.map +1 -0
  90. package/packages/server/dist/watcher/pi/pi-watcher.d.ts +36 -0
  91. package/packages/server/dist/watcher/pi/pi-watcher.d.ts.map +1 -0
  92. package/packages/server/dist/watcher/pi/pi-watcher.js +593 -0
  93. package/packages/server/dist/watcher/pi/pi-watcher.js.map +1 -0
  94. package/packages/server/dist/watcher/session-scanner.d.ts +9 -3
  95. package/packages/server/dist/watcher/session-scanner.d.ts.map +1 -1
  96. package/packages/server/dist/watcher/session-scanner.js +11 -13
  97. package/packages/server/dist/watcher/session-scanner.js.map +1 -1
  98. package/packages/server/dist/watcher/types.d.ts +30 -0
  99. package/packages/server/dist/watcher/types.d.ts.map +1 -0
  100. package/packages/server/dist/watcher/types.js +14 -0
  101. package/packages/server/dist/watcher/types.js.map +1 -0
  102. package/packages/server/dist/ws/broadcaster.js +0 -4
  103. package/packages/server/dist/ws/ws-handler.js +0 -4
  104. package/packages/shared/dist/constants/colors.d.ts +1 -1
  105. package/packages/shared/dist/constants/colors.js +1 -1
  106. package/packages/shared/dist/constants/colors.js.map +1 -1
  107. package/packages/shared/dist/constants/tools.d.ts.map +1 -1
  108. package/packages/shared/dist/constants/tools.js +30 -1
  109. package/packages/shared/dist/constants/tools.js.map +1 -1
  110. package/packages/shared/dist/index.d.ts +1 -1
  111. package/packages/shared/dist/index.d.ts.map +1 -1
  112. package/packages/shared/dist/types/agent.d.ts +3 -0
  113. package/packages/shared/dist/types/agent.d.ts.map +1 -1
  114. package/packages/client/dist/assets/index-Dh8yWoLP.js +0 -711
  115. package/packages/server/dist/watcher/claude-paths.d.ts +0 -32
  116. package/packages/server/dist/watcher/claude-paths.d.ts.map +0 -1
  117. package/packages/server/dist/watcher/claude-paths.js.map +0 -1
  118. package/packages/server/dist/watcher/file-watcher.d.ts.map +0 -1
  119. package/packages/server/dist/watcher/file-watcher.js.map +0 -1
  120. package/packages/server/dist/watcher/jsonl-parser.d.ts +0 -21
  121. package/packages/server/dist/watcher/jsonl-parser.d.ts.map +0 -1
  122. package/packages/server/dist/watcher/jsonl-parser.js.map +0 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **Watch your AI coding agents come alive.**
6
6
 
7
- A real-time pixel-art visualizer that turns AI coding sessions into a living 2D world. Agents walk between rooms, use tools, chat, and rest — all rendered at 60fps in your browser.
7
+ A real-time pixel-art visualizer that turns AI coding sessions into a living 2D world. Supports **Claude Code**, **OpenCode**, **Codex CLI**, and **pi** — agents walk between rooms, use tools, chat, and rest — all rendered at 60fps in your browser.
8
8
 
9
9
  ```
10
10
  npx @foothill/agent-move@latest
@@ -28,7 +28,18 @@ npx @foothill/agent-move@latest
28
28
 
29
29
  AgentMove reads AI coding agent session files and maps every tool call to one of **9 activity zones**. Each agent gets a unique pixel-art character that physically walks between zones as it works.
30
30
 
31
- It uses a **hybrid data pipeline** — JSONL file watching for rich data (tokens, costs, full text) combined with Claude Code hooks for precise lifecycle events (session start/end, tool success/failure, permissions).
31
+ ### Supported CLIs
32
+
33
+ | CLI | Badge | Session Format | Auto-detected |
34
+ |-----|-------|---------------|---------------|
35
+ | **Claude Code** | `CC` | JSONL + Hooks | `~/.claude/projects/` |
36
+ | **OpenCode** | `OC` | SQLite WAL | `~/.opencode/` |
37
+ | **Codex CLI** | `CX` | JSONL | `~/.codex/sessions/` |
38
+ | **pi** | `PI` | JSONL | `~/.pi-agent/sessions/` |
39
+
40
+ All CLIs are watched simultaneously — you can run agents from different tools and see them all in the same world.
41
+
42
+ It uses a **hybrid data pipeline** — JSONL/SQLite file watching for rich data (tokens, costs, full text) combined with Claude Code hooks for precise lifecycle events (session start/end, tool success/failure, permissions).
32
43
 
33
44
  | Zone | What Happens There | Tools |
34
45
  |------|--------------------|-------|
@@ -47,7 +58,7 @@ It uses a **hybrid data pipeline** — JSONL file watching for rich data (tokens
47
58
  ### Prerequisites
48
59
 
49
60
  - **Node.js 18+**
50
- - **Claude Code** installed and used at least once (so `~/.claude/` exists)
61
+ - At least one supported CLI installed: **Claude Code**, **OpenCode**, **Codex CLI**, or **pi**
51
62
  - Works on **Windows**, **macOS**, and **Linux**
52
63
 
53
64
  ### One Command
@@ -71,6 +82,16 @@ npx @foothill/agent-move@latest --no-open # don't auto-open the browser
71
82
  npx @foothill/agent-move@latest --help # show all options
72
83
  ```
73
84
 
85
+ ### Environment Variables
86
+
87
+ | Variable | Default | Description |
88
+ |----------|---------|-------------|
89
+ | `AGENT_MOVE_OPENCODE` | `true` | Enable/disable OpenCode watching |
90
+ | `AGENT_MOVE_PI` | `true` | Enable/disable pi watching |
91
+ | `AGENT_MOVE_CODEX` | `true` | Enable/disable Codex CLI watching |
92
+
93
+ Set to `false` to disable a specific watcher (e.g., `AGENT_MOVE_CODEX=false`).
94
+
74
95
  ### Hooks Management
75
96
 
76
97
  Hooks are auto-installed on first run. You can also manage them manually:
@@ -112,6 +133,7 @@ This starts the server on `:3333` and the Vite dev server on `:5173` with hot re
112
133
  - **12 color palettes** — each agent gets a distinct look
113
134
  - **6 sprite variants** — Human, Robot, Wizard, Ninja, Skeleton, Slime
114
135
  - **Animations** — idle breathing, walking between zones, working effects
136
+ - **CLI type badges** — CC, OC, CX, PI identify which tool spawned the agent
115
137
  - **Role badges** — MAIN, SUB, LEAD, MEMBER based on session type
116
138
  - **Speech bubbles** — show the current tool or text output above each agent
117
139
  - **Relationship lines** — dashed connections between parent/child and team agents
@@ -145,6 +167,13 @@ This starts the server on `:3333` and the Vite dev server on `:5173` with hot re
145
167
  - **Session duration** — per-agent uptime with active/idle status
146
168
  - **Cost threshold alerts** — configurable budget alert with visual notification
147
169
 
170
+ ### Task Graph
171
+
172
+ - **Multi-format support** — tracks tasks from Claude Code (`TaskCreate`/`TaskUpdate`), OpenCode (`TodoWrite`), and Codex (`update_plan`)
173
+ - **Live status** — pending, in-progress, completed, deleted with real-time updates
174
+ - **Dependency tracking** — blocks/blockedBy relationships between tasks
175
+ - **Per-team scoping** — task IDs scoped per root session to prevent cross-team collisions
176
+
148
177
  ### Leaderboard
149
178
 
150
179
  - **Agent rankings** — sortable by tokens, cost, duration, or tool count
@@ -172,12 +201,16 @@ Hook events ──────→ │ │
172
201
  push-based) │ Manager │──→ Broadcaster ──→ WebSocket ──→ Client
173
202
  │ │
174
203
  JSONL watching ───→ │ (merged state) │
175
- (byte-offset, └─────────────────┘
176
- pull-based)
204
+ (Claude, Codex, │ │
205
+ pi) └─────────────────┘
206
+
207
+ SQLite polling ────────────┘
208
+ (OpenCode)
177
209
  ```
178
210
 
179
211
  Hook events provide **lifecycle accuracy** (exact session start/end, tool success/failure).
180
- JSONL parsing provides **rich data** (token counts, costs, full response text).
212
+ File watching provides **rich data** (token counts, costs, full response text).
213
+ Tool names are normalized across CLIs to a canonical set (e.g., `shell_command` → `Bash`, `read_file` → `Read`).
181
214
 
182
215
  ## Architecture
183
216
 
@@ -194,8 +227,12 @@ agent-move/
194
227
  │ ├── server/ # Fastify backend
195
228
  │ │ └── src/
196
229
  │ │ ├── hooks/ hook event manager, hook installer
197
- │ │ ├── watcher/ chokidar file watcher, JSONL parser
198
- │ │ ├── state/ agent state machine, anomaly detector, tool chains
230
+ │ │ ├── watcher/
231
+ │ │ ├── claude/ JSONL file watcher (byte-offset delta reads)
232
+ │ │ │ ├── opencode/ SQLite WAL polling watcher
233
+ │ │ │ ├── codex/ Codex JSONL watcher (recursive YYYY/MM/DD scan)
234
+ │ │ │ └── pi/ pi agent JSONL watcher
235
+ │ │ ├── state/ agent state machine, anomaly detector, tool chains, task graph
199
236
  │ │ ├── ws/ WebSocket broadcaster
200
237
  │ │ └── routes/ REST API
201
238
  │ └── client/ # Pixi.js frontend
@@ -244,7 +281,7 @@ The WebSocket sends a `full_state` snapshot on connect, then incremental events:
244
281
  |---------|----------|
245
282
  | Port already in use | `npx @foothill/agent-move@latest --port 4444` |
246
283
  | Hooks not working | `npx @foothill/agent-move@latest hooks status` to check, then `hooks install` to fix |
247
- | No agents showing up | Make sure Claude Code is running — agents appear when sessions are active |
284
+ | No agents showing up | Make sure a supported CLI is running — agents appear when sessions are active |
248
285
  | Build artifacts missing (from source) | Run `npm run build` |
249
286
  | Permission denied on port | Use a port above 1024: `--port 3333` |
250
287
  | Browser didn't open | Visit `http://localhost:3333` manually, or check `--no-open` flag |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foothill/agent-move",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Watch your AI coding agents come alive as pixel-art characters in a 2D world",
5
5
  "type": "module",
6
6
  "engines": {
@@ -39,6 +39,7 @@
39
39
  "@fastify/cors": "^10.0.2",
40
40
  "@fastify/static": "^8.1.0",
41
41
  "@fastify/websocket": "^11.0.2",
42
+ "better-sqlite3": "^12.6.2",
42
43
  "chokidar": "^3.6.0",
43
44
  "fastify": "^5.2.1"
44
45
  },
@@ -1,4 +1,4 @@
1
- import{w as U,g,c,u as S,B as _,d as m,E as I,e as p}from"./index-Dh8yWoLP.js";const x={name:"local-uniform-bit",vertex:{header:`
1
+ import{w as U,g,c,u as S,B as _,d as m,E as I,e as p}from"./index-BPJtz4FL.js";const x={name:"local-uniform-bit",vertex:{header:`
2
2
 
3
3
  struct LocalUniforms {
4
4
  uTransformMatrix:mat3x3<f32>,
@@ -1 +1 @@
1
- import{D as E,C as ee,f as D,h as Re,m as ce,M as F,i as R,j as Xe,w as $e,T as He,k as ze,s as Je,l as Ke,F as Qe,n as Ze,o as et,A as tt,R as nt,p as he}from"./index-Dh8yWoLP.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-DgAzY5_U.js";import"./Filter-NcMGuiK-.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 U=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,b=p.color,P=(U>>>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=U&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,G=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,G,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:G,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 Ue{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 U=0;U<V.length;U++){const b=V[U];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))}}Ue.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 Ge{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()}}Ge.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,U,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=((U=a.filter)==null?void 0:U.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 G=C.frame,O=C.source._resolution??C.source.resolution??1;let B=G.x*O,W=G.y*O;const N=G.width*O,u=G.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,G=A?ze(vt,I,C.shape,k):null,O=L?yt.copyFrom(r).append(_):r,B=Pt(I,de,G,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,Ge,Oe,Ve,Fe],wt=[ot,rt,it,ct,lt,Ue,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 Rt extends tt{constructor(){const e={name:"canvas",type:nt.CANVAS,systems:qe,renderPipes:Le,renderPipeAdaptors:Ne};super(e)}}export{Rt as CanvasRenderer};
1
+ import{D as E,C as ee,f as D,h as Re,m as ce,M as F,i as R,j as Xe,w as $e,T as He,k as ze,s as Je,l as Ke,F as Qe,n as Ze,o as et,A as tt,R as nt,p as he}from"./index-BPJtz4FL.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-ko-v73NG.js";import"./Filter-CBX7EB7j.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 U=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,b=p.color,P=(U>>>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=U&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,G=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,G,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:G,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 Ue{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 U=0;U<V.length;U++){const b=V[U];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))}}Ue.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 Ge{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()}}Ge.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,U,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=((U=a.filter)==null?void 0:U.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 G=C.frame,O=C.source._resolution??C.source.resolution??1;let B=G.x*O,W=G.y*O;const N=G.width*O,u=G.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,G=A?ze(vt,I,C.shape,k):null,O=L?yt.copyFrom(r).append(_):r,B=Pt(I,de,G,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,Ge,Oe,Ve,Fe],wt=[ot,rt,it,ct,lt,Ue,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 Rt extends tt{constructor(){const e={name:"canvas",type:nt.CANVAS,systems:qe,renderPipes:Le,renderPipeAdaptors:Ne};super(e)}}export{Rt as CanvasRenderer};
@@ -1 +1 @@
1
- import{S as n,a as u,G as o,b as f}from"./index-Dh8yWoLP.js";const s=class i extends n{constructor(e){e={...i.defaultOptions,...e},super(e),this.enabled=!0,this._state=u.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,a,r){e.applyFilter(this,t,a,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:a,...r}=e;let l,d;return t&&(l=o.from(t)),a&&(d=f.from(a)),new i({gpuProgram:l,glProgram:d,...r})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let b=s;export{b as F};
1
+ import{S as n,a as u,G as o,b as f}from"./index-BPJtz4FL.js";const s=class i extends n{constructor(e){e={...i.defaultOptions,...e},super(e),this.enabled=!0,this._state=u.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,a,r){e.applyFilter(this,t,a,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:a,...r}=e;let l,d;return t&&(l=o.from(t)),a&&(d=f.from(a)),new i({gpuProgram:l,glProgram:d,...r})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let b=s;export{b as F};
@@ -1,4 +1,4 @@
1
- import{W as Ve,K as oe,M as m,G as Ne,b as je,a as $e,X as le,i as l,p as W,Y as w,Z as qe,_ as z,$ as T,R as V,a0 as de,a1 as Ke,T as f,c as g,I as D,a2 as ue,w as ce,a3 as ee,a4 as he,a5 as pe,a6 as fe,a7 as me,t as P,a8 as Ye,C as E,D as N,J as y,a9 as B,aa as Je,P as Xe,ab as Ze,z as Qe,q as te,ac as re,ad as p,e as et,o as O,ae as tt,af as rt,ag as st,ah as nt}from"./index-Dh8yWoLP.js";import{F as at}from"./Filter-NcMGuiK-.js";var it=`in vec2 vMaskCoord;
1
+ import{W as Ve,K as oe,M as m,G as Ne,b as je,a as $e,X as le,i as l,p as W,Y as w,Z as qe,_ as z,$ as T,R as V,a0 as de,a1 as Ke,T as f,c as g,I as D,a2 as ue,w as ce,a3 as ee,a4 as he,a5 as pe,a6 as fe,a7 as me,t as P,a8 as Ye,C as E,D as N,J as y,a9 as B,aa as Je,P as Xe,ab as Ze,z as Qe,q as te,ac as re,ad as p,e as et,o as O,ae as tt,af as rt,ag as st,ah as nt}from"./index-BPJtz4FL.js";import{F as at}from"./Filter-CBX7EB7j.js";var it=`in vec2 vMaskCoord;
2
2
  in vec2 vTextureCoord;
3
3
 
4
4
  uniform sampler2D uTexture;
@@ -1,4 +1,4 @@
1
- import{D as R,a as F,i as d,x as P,d as B,w as p,g as z,b as ye,S as O,T as S,ai as Ce,J as q,aj as Ne,c as g,a9 as V,o as y,I as C,K as M,M as Z,ak as J,al as De,am as Q,an as Ie,ao as Ge,A as Ue,R as Fe,p as A}from"./index-Dh8yWoLP.js";import{e as Pe,G as Oe,c as Me,b as Le,U as we,B as ee,d as N,f as te,g as He}from"./BufferResource-Ddjob236.js";import{R as Ve,S as Xe,d as ke}from"./RenderTargetSystem-DgAzY5_U.js";import"./Filter-NcMGuiK-.js";function We(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,i=this._didUploadHash[n.uid];s.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let i=0;i<r.textures.count;i++)n.texture.bind(s[i],i);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class je{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const i=this._boundBufferBases[s];if(i&&i._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:i}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,i.bindBufferRange(i.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new je(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(p("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&p("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var r;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(r=this.extensions.loseContext)==null||r.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&p("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,i=this.extensions;n.uint32Indices=s||!!i.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!i.vertexArrayObject,n.srgbTextures=s||!!i.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||p("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Ke=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const X={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function $e(t){return X[t]??X.float32}const Ye={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ze{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ie{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,i,a,o)=>{n.drawArraysInstancedANGLE(s,i,a,o)},e.drawElementsInstanced=(s,i,a,o,u)=>{n.drawElementsInstancedANGLE(s,i,a,o,u)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,i=["g",e.uid];for(const a in n)s[a]&&i.push(a,s[a].location);return i.join("-")}getVao(e,r){var n;return((n=e._gpuData[this._renderer.uid])==null?void 0:n.vaoCache[r._key])||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const a=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new ze,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const u=o.vaoCache;let c=u[a];if(c)return u[r._key]=c,c;Pe(e,r._attributeData);const _=e.buffers;c=s.createVertexArray(),s.bindVertexArray(c);for(let f=0;f<_.length;f++){const h=_[f];i.bind(h)}return this.activateVao(e,r),u[r._key]=c,u[a]=c,s.bindVertexArray(null),c}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const i in s)this._activeVao!==s[i]&&this.resetState(),this.gl.deleteVertexArray(s[i])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){var o;const n=this._renderer.gl,s=this._renderer.buffer,i=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let a=null;for(const u in i){const c=i[u],_=c.buffer,f=s.getGlBuffer(_),h=r._attributeData[u];if(h){a!==f&&(s.bind(_),a=f);const m=h.location;n.enableVertexAttribArray(m);const b=z(c.format),E=$e(c.format);if(((o=h.format)==null?void 0:o.substring(1,4))==="int"?n.vertexAttribIPointer(m,b.size,E,c.stride,c.offset):n.vertexAttribPointer(m,b.size,E,b.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const Be=c.divisor??1;n.vertexAttribDivisor(m,Be)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:i}=this._renderer,a=this._activeGeometry,o=Ye[e||a.topology];if(s??(s=a.instanceCount),a.indexBuffer){const u=a.indexBuffer.data.BYTES_PER_ELEMENT,c=u===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;s!==1?i.drawElementsInstanced(o,r||a.indexBuffer.data.length,c,(n||0)*u,s):i.drawElements(o,r||a.indexBuffer.data.length,c,(n||0)*u)}else s!==1?i.drawArraysInstanced(o,n||0,r||a.getSize(),s):i.drawArrays(o,n||0,r||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ie.extension={type:[d.WebGLSystem],name:"geometry"};const qe=new Ce({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ae{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ae.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(p("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new ye({vertex:`
1
+ import{D as R,a as F,i as d,x as P,d as B,w as p,g as z,b as ye,S as O,T as S,ai as Ce,J as q,aj as Ne,c as g,a9 as V,o as y,I as C,K as M,M as Z,ak as J,al as De,am as Q,an as Ie,ao as Ge,A as Ue,R as Fe,p as A}from"./index-BPJtz4FL.js";import{e as Pe,G as Oe,c as Me,b as Le,U as we,B as ee,d as N,f as te,g as He}from"./BufferResource-Dfd5uHKt.js";import{R as Ve,S as Xe,d as ke}from"./RenderTargetSystem-ko-v73NG.js";import"./Filter-CBX7EB7j.js";function We(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,i=this._didUploadHash[n.uid];s.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let i=0;i<r.textures.count;i++)n.texture.bind(s[i],i);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class je{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const i=this._boundBufferBases[s];if(i&&i._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:i}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,i.bindBufferRange(i.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new je(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(p("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&p("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var r;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(r=this.extensions.loseContext)==null||r.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&p("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,i=this.extensions;n.uint32Indices=s||!!i.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!i.vertexArrayObject,n.srgbTextures=s||!!i.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||p("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Ke=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const X={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function $e(t){return X[t]??X.float32}const Ye={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ze{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ie{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,i,a,o)=>{n.drawArraysInstancedANGLE(s,i,a,o)},e.drawElementsInstanced=(s,i,a,o,u)=>{n.drawElementsInstancedANGLE(s,i,a,o,u)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,i=["g",e.uid];for(const a in n)s[a]&&i.push(a,s[a].location);return i.join("-")}getVao(e,r){var n;return((n=e._gpuData[this._renderer.uid])==null?void 0:n.vaoCache[r._key])||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const a=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new ze,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const u=o.vaoCache;let c=u[a];if(c)return u[r._key]=c,c;Pe(e,r._attributeData);const _=e.buffers;c=s.createVertexArray(),s.bindVertexArray(c);for(let f=0;f<_.length;f++){const h=_[f];i.bind(h)}return this.activateVao(e,r),u[r._key]=c,u[a]=c,s.bindVertexArray(null),c}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const i in s)this._activeVao!==s[i]&&this.resetState(),this.gl.deleteVertexArray(s[i])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){var o;const n=this._renderer.gl,s=this._renderer.buffer,i=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let a=null;for(const u in i){const c=i[u],_=c.buffer,f=s.getGlBuffer(_),h=r._attributeData[u];if(h){a!==f&&(s.bind(_),a=f);const m=h.location;n.enableVertexAttribArray(m);const b=z(c.format),E=$e(c.format);if(((o=h.format)==null?void 0:o.substring(1,4))==="int"?n.vertexAttribIPointer(m,b.size,E,c.stride,c.offset):n.vertexAttribPointer(m,b.size,E,b.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const Be=c.divisor??1;n.vertexAttribDivisor(m,Be)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:i}=this._renderer,a=this._activeGeometry,o=Ye[e||a.topology];if(s??(s=a.instanceCount),a.indexBuffer){const u=a.indexBuffer.data.BYTES_PER_ELEMENT,c=u===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;s!==1?i.drawElementsInstanced(o,r||a.indexBuffer.data.length,c,(n||0)*u,s):i.drawElements(o,r||a.indexBuffer.data.length,c,(n||0)*u)}else s!==1?i.drawArraysInstanced(o,n||0,r||a.getSize(),s):i.drawArrays(o,n||0,r||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ie.extension={type:[d.WebGLSystem],name:"geometry"};const qe=new Ce({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ae{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ae.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(p("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new ye({vertex:`
2
2
  attribute vec2 aPosition;
3
3
  out vec2 vUv;
4
4
 
@@ -1,4 +1,4 @@
1
- import{v as L,a as A,i as l,x as D,e as ce,y as de,D as B,c as C,d as T,B as he,z as k,H as w,w as v,I as y,o as pe,J as le,K as z,L as M,M as F,N as O,O as fe,Q as I,V as ge,S as W,T as R,A as me,R as _e,p as S}from"./index-Dh8yWoLP.js";import{c as be,u as ye,U as xe,B as Ge,G as Pe,e as Be,l as Se,a as Te,t as Ce}from"./BufferResource-Ddjob236.js";import{R as ve,S as Ue,d as we}from"./RenderTargetSystem-DgAzY5_U.js";import"./Filter-NcMGuiK-.js";const G=A.for2d();class H{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),G.blendMode="normal",s.pipeline.getPipeline(t,n,G);const o=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=L(u.textures,u.count,s.limits.maxBatchableTextures)}G.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),o=s.pipeline.getPipeline(this._geometry,r,G,t.topology);t.bindGroup._touch(s.gc.now,s.tick),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}H.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class V{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],o=this._renderer;for(const f in i){const h=e.resources[f]??e.resources[i[f]];let p;if(h._resourceType==="uniformGroup"){const d=h;o.ubo.updateUniformGroup(d);const g=d.buffer;p={buffer:o.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:o.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:o.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=o.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=o.texture.getTextureView(d)}n.push({binding:i[f],resource:p})}const u=o.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){this._hash=null,this._renderer=null}}V.extension={type:[l.WebGPUSystem],name:"bindGroup"};class Me{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class N{constructor(e){this._renderer=e,this._managedBuffers=new D({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuBuffer)||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=ce("resource"),e.data&&(de(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Me(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}N.extension={type:[l.WebGPUSystem],name:"buffer"};class Re{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}class j{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}j.extension={type:[l.WebGPUSystem],name:"colorMask"};class U{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await B.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}U.extension={type:[l.WebGPUSystem],name:"device"};U.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class K{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(parseInt(s,10),e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:o,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u??t.instanceCount,o||0):this.renderPassEncoder.draw(n||t.getSize(),u??t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const o in r)this._setVertexBuffer(o,r[o]);for(const o in i)this.setBindGroup(o,i[o],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}K.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class q{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}q.extension={type:[l.WebGPUSystem],name:"limits"};class Y{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:C.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Y.extension={type:[l.WebGPUSystem],name:"stencil"};const P={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Ee(a){const e=a.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r<e.length;r++){const s=e[r];let i=P[s.data.type].size;const n=P[s.data.type].align;if(!P[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Le(a,e){const{size:t,align:r}=P[a.data.type],s=(r-t)/4,i=a.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
1
+ import{v as L,a as A,i as l,x as D,e as ce,y as de,D as B,c as C,d as T,B as he,z as k,H as w,w as v,I as y,o as pe,J as le,K as z,L as M,M as F,N as O,O as fe,Q as I,V as ge,S as W,T as R,A as me,R as _e,p as S}from"./index-BPJtz4FL.js";import{c as be,u as ye,U as xe,B as Ge,G as Pe,e as Be,l as Se,a as Te,t as Ce}from"./BufferResource-Dfd5uHKt.js";import{R as ve,S as Ue,d as we}from"./RenderTargetSystem-ko-v73NG.js";import"./Filter-CBX7EB7j.js";const G=A.for2d();class H{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),G.blendMode="normal",s.pipeline.getPipeline(t,n,G);const o=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=L(u.textures,u.count,s.limits.maxBatchableTextures)}G.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),o=s.pipeline.getPipeline(this._geometry,r,G,t.topology);t.bindGroup._touch(s.gc.now,s.tick),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}H.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class V{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],o=this._renderer;for(const f in i){const h=e.resources[f]??e.resources[i[f]];let p;if(h._resourceType==="uniformGroup"){const d=h;o.ubo.updateUniformGroup(d);const g=d.buffer;p={buffer:o.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:o.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:o.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=o.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=o.texture.getTextureView(d)}n.push({binding:i[f],resource:p})}const u=o.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){this._hash=null,this._renderer=null}}V.extension={type:[l.WebGPUSystem],name:"bindGroup"};class Me{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class N{constructor(e){this._renderer=e,this._managedBuffers=new D({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuBuffer)||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=ce("resource"),e.data&&(de(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Me(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}N.extension={type:[l.WebGPUSystem],name:"buffer"};class Re{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}class j{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}j.extension={type:[l.WebGPUSystem],name:"colorMask"};class U{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await B.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}U.extension={type:[l.WebGPUSystem],name:"device"};U.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class K{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(parseInt(s,10),e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:o,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u??t.instanceCount,o||0):this.renderPassEncoder.draw(n||t.getSize(),u??t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const o in r)this._setVertexBuffer(o,r[o]);for(const o in i)this.setBindGroup(o,i[o],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}K.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class q{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}q.extension={type:[l.WebGPUSystem],name:"limits"};class Y{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:C.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Y.extension={type:[l.WebGPUSystem],name:"stencil"};const P={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Ee(a){const e=a.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r<e.length;r++){const s=e[r];let i=P[s.data.type].size;const n=P[s.data.type].align;if(!P[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Le(a,e){const{size:t,align:r}=P[a.data.type],s=(r-t)/4,i=a.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
2
2
  v = uv.${a.data.name};
3
3
  ${e!==0?`offset += ${e};`:""}
4
4
 
@@ -1,4 +1,4 @@
1
- import{q as A,U as Z,P as g,r as te,i as b,E as ie,w as y,p as w,t as V}from"./index-Dh8yWoLP.js";import"./webworkerAll-BJ6UhC7r.js";import"./Filter-NcMGuiK-.js";class q{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=t.width/i*this._renderer.resolution,o=t.height/s*this._renderer.resolution,r=t.left,h=t.top,d=`translate(${r}px, ${h}px) scale(${n}, ${o})`;d!==this._lastTransform&&(this._domElement.style.transform=d,this._lastTransform=d)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||A.shared.add(this.updateTranslation,this,Z.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&A.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class O{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=O.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new g,this.page=new g,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var I=/iPhone/i,B=/iPod/i,C=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,E=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,M=/Silk/i,m=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,K=/BlackBerry/i,Y=/BB10/i,H=/Opera Mini/i,F=/\b(CriOS|Chrome)(?:.+)Mobile/i,N=/Mobile(?:.+)Firefox\b/i,$=function(a){return typeof a<"u"&&a.platform==="MacIntel"&&typeof a.maxTouchPoints=="number"&&a.maxTouchPoints>1&&typeof MSStream>"u"};function se(a){return function(e){return e.test(a)}}function G(a){var e={userAgent:"",platform:"",maxTouchPoints:0};!a&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof a=="string"?e.userAgent=a:a&&a.userAgent&&(e={userAgent:a.userAgent,platform:a.platform,maxTouchPoints:a.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=se(t),n={apple:{phone:s(I)&&!s(m),ipod:s(B),tablet:!s(I)&&(s(C)||$(e))&&!s(m),universal:s(U),device:(s(I)||s(B)||s(C)||s(U)||$(e))&&!s(m)},amazon:{phone:s(E),tablet:!s(E)&&s(M),device:s(E)||s(M)},android:{phone:!s(m)&&s(E)||!s(m)&&s(k),tablet:!s(m)&&!s(E)&&!s(k)&&(s(M)||s(R)),device:!s(m)&&(s(E)||s(M)||s(k)||s(R))||s(/\bokhttp\b/i)},windows:{phone:s(m),tablet:s(X),device:s(m)||s(X)},other:{blackberry:s(K),blackberry10:s(Y),opera:s(H),firefox:s(N),chrome:s(F),device:s(K)||s(Y)||s(H)||s(N)||s(F)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ne=G.default??G,oe=ne(globalThis.navigator),re=9,W=100,ae=0,le=0,j=2,z=1,he=-1e3,ce=-1e3,de=2,L=class J{constructor(e,t=oe){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${z}px`,e.style.height=`${z}px`,e.style.position="absolute",e.style.top=`${he}px`,e.style.left=`${ce}px`,e.style.zIndex=de.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${ae}px`,this._div.style.left=`${le}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=j.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var e,t;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const i of this._children)(e=i._accessibleDiv)!=null&&e.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[i];(t=this._div)!=null&&t.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this._updateAccessibleObjects(t[i])}init(e){const i={accessibilityOptions:{...J.defaultOptions,...(e==null?void 0:e.accessibilityOptions)||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&t.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const s=this._children[i];t.has(i)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const s=this._children[i];if(!s._accessibleActive||!s._accessibleDiv)continue;const n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const r=s.worldTransform;n.style.left=`${r.tx+o.x*r.a}px`,n.style.top=`${r.ty+o.y*r.d}px`,n.style.width=`${o.width*r.a}px`,n.style.height=`${o.height*r.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let i=this._getPool(e.accessibleType).pop();i?(i.innerHTML="",i.removeAttribute("title"),i.removeAttribute("aria-label"),i.tabIndex=0):(e.accessibleType==="button"?i=document.createElement("button"):(i=document.createElement(e.accessibleType),i.style.cssText=`
1
+ import{q as A,U as Z,P as g,r as te,i as b,E as ie,w as y,p as w,t as V}from"./index-BPJtz4FL.js";import"./webworkerAll-hM-gNP7L.js";import"./Filter-CBX7EB7j.js";class q{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=t.width/i*this._renderer.resolution,o=t.height/s*this._renderer.resolution,r=t.left,h=t.top,d=`translate(${r}px, ${h}px) scale(${n}, ${o})`;d!==this._lastTransform&&(this._domElement.style.transform=d,this._lastTransform=d)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||A.shared.add(this.updateTranslation,this,Z.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&A.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class O{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=O.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new g,this.page=new g,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var I=/iPhone/i,B=/iPod/i,C=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,E=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,M=/Silk/i,m=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,K=/BlackBerry/i,Y=/BB10/i,H=/Opera Mini/i,F=/\b(CriOS|Chrome)(?:.+)Mobile/i,N=/Mobile(?:.+)Firefox\b/i,$=function(a){return typeof a<"u"&&a.platform==="MacIntel"&&typeof a.maxTouchPoints=="number"&&a.maxTouchPoints>1&&typeof MSStream>"u"};function se(a){return function(e){return e.test(a)}}function G(a){var e={userAgent:"",platform:"",maxTouchPoints:0};!a&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof a=="string"?e.userAgent=a:a&&a.userAgent&&(e={userAgent:a.userAgent,platform:a.platform,maxTouchPoints:a.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=se(t),n={apple:{phone:s(I)&&!s(m),ipod:s(B),tablet:!s(I)&&(s(C)||$(e))&&!s(m),universal:s(U),device:(s(I)||s(B)||s(C)||s(U)||$(e))&&!s(m)},amazon:{phone:s(E),tablet:!s(E)&&s(M),device:s(E)||s(M)},android:{phone:!s(m)&&s(E)||!s(m)&&s(k),tablet:!s(m)&&!s(E)&&!s(k)&&(s(M)||s(R)),device:!s(m)&&(s(E)||s(M)||s(k)||s(R))||s(/\bokhttp\b/i)},windows:{phone:s(m),tablet:s(X),device:s(m)||s(X)},other:{blackberry:s(K),blackberry10:s(Y),opera:s(H),firefox:s(N),chrome:s(F),device:s(K)||s(Y)||s(H)||s(N)||s(F)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ne=G.default??G,oe=ne(globalThis.navigator),re=9,W=100,ae=0,le=0,j=2,z=1,he=-1e3,ce=-1e3,de=2,L=class J{constructor(e,t=oe){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${z}px`,e.style.height=`${z}px`,e.style.position="absolute",e.style.top=`${he}px`,e.style.left=`${ce}px`,e.style.zIndex=de.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${ae}px`,this._div.style.left=`${le}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=j.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var e,t;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const i of this._children)(e=i._accessibleDiv)!=null&&e.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[i];(t=this._div)!=null&&t.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this._updateAccessibleObjects(t[i])}init(e){const i={accessibilityOptions:{...J.defaultOptions,...(e==null?void 0:e.accessibilityOptions)||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&t.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const s=this._children[i];t.has(i)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const s=this._children[i];if(!s._accessibleActive||!s._accessibleDiv)continue;const n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const r=s.worldTransform;n.style.left=`${r.tx+o.x*r.a}px`,n.style.top=`${r.ty+o.y*r.d}px`,n.style.width=`${o.width*r.a}px`,n.style.height=`${o.height*r.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let i=this._getPool(e.accessibleType).pop();i?(i.innerHTML="",i.removeAttribute("title"),i.removeAttribute("aria-label"),i.tabIndex=0):(e.accessibleType==="button"?i=document.createElement("button"):(i=document.createElement(e.accessibleType),i.style.cssText=`
2
2
  color: transparent;
3
3
  pointer-events: none;
4
4
  padding: 0;