@micjanic/recursive-grid 1.0.2 → 1.0.4

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.
@@ -1,7 +1,7 @@
1
- import { E as w, U as wt, T as ve, a as Tt, a2 as U, a3 as O, D as H, t as R, $ as V, M as k, ac as vt, ad as St, w as ne, _ as j, Q as Z, ae as Ct, af as q, ag as G, l as Y, d as Le, I as A, a5 as me, R as xe, H as Ie, c as N, B as z, n as Se, S as ee, y as te, ah as Pt, ai as _e, L as pe, aj as K, s as be, v as Ft, G as Bt, m as Oe, q as Ee, a7 as He, aa as Ve, o as Mt, p as Rt, a8 as Ut, a9 as kt, ab as Gt, ak as At, al as zt, e as P, am as Dt } from "./PixiApp-D4xu0PT4.js";
2
- import { c as se, a as Wt, b as Lt, B as Ye } from "./colorToUniform-C2jGzNe1.js";
3
- import { C as X } from "./CanvasPool-BvJplAOp.js";
4
- class Xe {
1
+ import { E as y, U as Pt, T as we, a as Ft, a4 as z, a5 as L, D as H, t as M, a0 as V, M as U, ae as Bt, af as Rt, w as K, $ as j, V as ee, ag as Mt, ah as q, ai as G, F as Ut, v as Le, x as Ee, l as Y, d as He, J as A, a7 as me, R as xe, I as Ve, c as N, B as D, n as Se, S as te, z as re, aj as zt, ak as _e, N as pe, al as Q, s as ve, m as Ye, q as Xe, a9 as $e, ac as Ne, o as kt, p as Gt, aa as At, ab as Dt, ad as Ot, am as It, an as Wt, e as P, ao as Lt } from "./PixiApp-BHmY2ZMg.js";
2
+ import { c as se, a as Et, b as Ht, B as Ke } from "./colorToUniform-C2jGzNe1.js";
3
+ import { C as X } from "./CanvasPool-D2Uot4VE.js";
4
+ class je {
5
5
  /**
6
6
  * Initialize the plugin with scope of application instance
7
7
  * @private
@@ -45,8 +45,8 @@ class Xe {
45
45
  globalThis.removeEventListener("resize", this.queueResize), this._cancelResize(), this._cancelResize = null, this.queueResize = null, this.resizeTo = null, this.resize = null;
46
46
  }
47
47
  }
48
- Xe.extension = w.Application;
49
- class $e {
48
+ je.extension = y.Application;
49
+ class qe {
50
50
  /**
51
51
  * Initialize the plugin with scope of application instance
52
52
  * @private
@@ -61,7 +61,7 @@ class $e {
61
61
  "ticker",
62
62
  {
63
63
  set(t) {
64
- this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this, wt.LOW);
64
+ this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this, Pt.LOW);
65
65
  },
66
66
  get() {
67
67
  return this._ticker;
@@ -71,7 +71,7 @@ class $e {
71
71
  this._ticker.stop();
72
72
  }, this.start = () => {
73
73
  this._ticker.start();
74
- }, this._ticker = null, this.ticker = e.sharedTicker ? ve.shared : new ve(), e.autoStart && this.start();
74
+ }, this._ticker = null, this.ticker = e.sharedTicker ? we.shared : new we(), e.autoStart && this.start();
75
75
  }
76
76
  /**
77
77
  * Clean up the ticker, scoped to application.
@@ -84,8 +84,8 @@ class $e {
84
84
  }
85
85
  }
86
86
  }
87
- $e.extension = w.Application;
88
- class It extends Tt {
87
+ qe.extension = y.Application;
88
+ class Vt extends Ft {
89
89
  constructor() {
90
90
  super(...arguments), this.chars = /* @__PURE__ */ Object.create(null), this.lineHeight = 0, this.fontFamily = "", this.fontMetrics = { fontSize: 0, ascent: 0, descent: 0 }, this.baseLineOffset = 0, this.distanceField = { type: "none", range: 0 }, this.pages = [], this.applyFillAsTint = !0, this.baseMeasurementFontSize = 100, this.baseRenderedFontSize = 100;
91
91
  }
@@ -94,35 +94,35 @@ class It extends Tt {
94
94
  * @deprecated since 8.0.0 Use `fontFamily` instead.
95
95
  */
96
96
  get font() {
97
- return U(O, "BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."), this.fontFamily;
97
+ return z(L, "BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."), this.fontFamily;
98
98
  }
99
99
  /**
100
100
  * The map of base page textures (i.e., sheets of glyphs).
101
101
  * @deprecated since 8.0.0 Use `pages` instead.
102
102
  */
103
103
  get pageTextures() {
104
- return U(O, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
104
+ return z(L, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
105
105
  }
106
106
  /**
107
107
  * The size of the font face in pixels.
108
108
  * @deprecated since 8.0.0 Use `fontMetrics.fontSize` instead.
109
109
  */
110
110
  get size() {
111
- return U(O, "BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."), this.fontMetrics.fontSize;
111
+ return z(L, "BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."), this.fontMetrics.fontSize;
112
112
  }
113
113
  /**
114
114
  * The kind of distance field for this font or "none".
115
115
  * @deprecated since 8.0.0 Use `distanceField.type` instead.
116
116
  */
117
117
  get distanceFieldRange() {
118
- return U(O, "BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."), this.distanceField.range;
118
+ return z(L, "BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."), this.distanceField.range;
119
119
  }
120
120
  /**
121
121
  * The range of the distance field in pixels.
122
122
  * @deprecated since 8.0.0 Use `distanceField.range` instead.
123
123
  */
124
124
  get distanceFieldType() {
125
- return U(O, "BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."), this.distanceField.type;
125
+ return z(L, "BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."), this.distanceField.type;
126
126
  }
127
127
  destroy(e = !1) {
128
128
  var t;
@@ -132,7 +132,294 @@ class It extends Tt {
132
132
  this.chars = null, e && (this.pages.forEach((r) => r.texture.destroy(!0)), this.pages = null);
133
133
  }
134
134
  }
135
- const Ot = [
135
+ /**
136
+ * tiny-lru
137
+ *
138
+ * @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
139
+ * @license BSD-3-Clause
140
+ * @version 11.4.5
141
+ */
142
+ class Yt {
143
+ /**
144
+ * Creates a new LRU cache instance.
145
+ * Note: Constructor does not validate parameters. Use lru() factory function for parameter validation.
146
+ *
147
+ * @constructor
148
+ * @param {number} [max=0] - Maximum number of items to store. 0 means unlimited.
149
+ * @param {number} [ttl=0] - Time to live in milliseconds. 0 means no expiration.
150
+ * @param {boolean} [resetTtl=false] - Whether to reset TTL when accessing existing items via get().
151
+ * @example
152
+ * const cache = new LRU(1000, 60000, true); // 1000 items, 1 minute TTL, reset on access
153
+ * @see {@link lru} For parameter validation
154
+ * @since 1.0.0
155
+ */
156
+ constructor(e = 0, t = 0, r = !1) {
157
+ this.first = null, this.items = /* @__PURE__ */ Object.create(null), this.last = null, this.max = e, this.resetTtl = r, this.size = 0, this.ttl = t;
158
+ }
159
+ /**
160
+ * Removes all items from the cache.
161
+ *
162
+ * @method clear
163
+ * @memberof LRU
164
+ * @returns {LRU} The LRU instance for method chaining.
165
+ * @example
166
+ * cache.clear();
167
+ * console.log(cache.size); // 0
168
+ * @since 1.0.0
169
+ */
170
+ clear() {
171
+ return this.first = null, this.items = /* @__PURE__ */ Object.create(null), this.last = null, this.size = 0, this;
172
+ }
173
+ /**
174
+ * Removes an item from the cache by key.
175
+ *
176
+ * @method delete
177
+ * @memberof LRU
178
+ * @param {string} key - The key of the item to delete.
179
+ * @returns {LRU} The LRU instance for method chaining.
180
+ * @example
181
+ * cache.set('key1', 'value1');
182
+ * cache.delete('key1');
183
+ * console.log(cache.has('key1')); // false
184
+ * @see {@link LRU#has}
185
+ * @see {@link LRU#clear}
186
+ * @since 1.0.0
187
+ */
188
+ delete(e) {
189
+ if (this.has(e)) {
190
+ const t = this.items[e];
191
+ delete this.items[e], this.size--, t.prev !== null && (t.prev.next = t.next), t.next !== null && (t.next.prev = t.prev), this.first === t && (this.first = t.next), this.last === t && (this.last = t.prev);
192
+ }
193
+ return this;
194
+ }
195
+ /**
196
+ * Returns an array of [key, value] pairs for the specified keys.
197
+ * Order follows LRU order (least to most recently used).
198
+ *
199
+ * @method entries
200
+ * @memberof LRU
201
+ * @param {string[]} [keys=this.keys()] - Array of keys to get entries for. Defaults to all keys.
202
+ * @returns {Array<Array<*>>} Array of [key, value] pairs in LRU order.
203
+ * @example
204
+ * cache.set('a', 1).set('b', 2);
205
+ * console.log(cache.entries()); // [['a', 1], ['b', 2]]
206
+ * console.log(cache.entries(['a'])); // [['a', 1]]
207
+ * @see {@link LRU#keys}
208
+ * @see {@link LRU#values}
209
+ * @since 11.1.0
210
+ */
211
+ entries(e = this.keys()) {
212
+ return e.map((t) => [t, this.get(t)]);
213
+ }
214
+ /**
215
+ * Removes the least recently used item from the cache.
216
+ *
217
+ * @method evict
218
+ * @memberof LRU
219
+ * @param {boolean} [bypass=false] - Whether to force eviction even when cache is empty.
220
+ * @returns {LRU} The LRU instance for method chaining.
221
+ * @example
222
+ * cache.set('old', 'value').set('new', 'value');
223
+ * cache.evict(); // Removes 'old' item
224
+ * @see {@link LRU#setWithEvicted}
225
+ * @since 1.0.0
226
+ */
227
+ evict(e = !1) {
228
+ if (e || this.size > 0) {
229
+ const t = this.first;
230
+ delete this.items[t.key], --this.size === 0 ? (this.first = null, this.last = null) : (this.first = t.next, this.first.prev = null);
231
+ }
232
+ return this;
233
+ }
234
+ /**
235
+ * Returns the expiration timestamp for a given key.
236
+ *
237
+ * @method expiresAt
238
+ * @memberof LRU
239
+ * @param {string} key - The key to check expiration for.
240
+ * @returns {number|undefined} The expiration timestamp in milliseconds, or undefined if key doesn't exist.
241
+ * @example
242
+ * const cache = new LRU(100, 5000); // 5 second TTL
243
+ * cache.set('key1', 'value1');
244
+ * console.log(cache.expiresAt('key1')); // timestamp 5 seconds from now
245
+ * @see {@link LRU#get}
246
+ * @see {@link LRU#has}
247
+ * @since 1.0.0
248
+ */
249
+ expiresAt(e) {
250
+ let t;
251
+ return this.has(e) && (t = this.items[e].expiry), t;
252
+ }
253
+ /**
254
+ * Retrieves a value from the cache by key. Updates the item's position to most recently used.
255
+ *
256
+ * @method get
257
+ * @memberof LRU
258
+ * @param {string} key - The key to retrieve.
259
+ * @returns {*} The value associated with the key, or undefined if not found or expired.
260
+ * @example
261
+ * cache.set('key1', 'value1');
262
+ * console.log(cache.get('key1')); // 'value1'
263
+ * console.log(cache.get('nonexistent')); // undefined
264
+ * @see {@link LRU#set}
265
+ * @see {@link LRU#has}
266
+ * @since 1.0.0
267
+ */
268
+ get(e) {
269
+ const t = this.items[e];
270
+ if (t !== void 0) {
271
+ if (this.ttl > 0 && t.expiry <= Date.now()) {
272
+ this.delete(e);
273
+ return;
274
+ }
275
+ return this.moveToEnd(t), t.value;
276
+ }
277
+ }
278
+ /**
279
+ * Checks if a key exists in the cache.
280
+ *
281
+ * @method has
282
+ * @memberof LRU
283
+ * @param {string} key - The key to check for.
284
+ * @returns {boolean} True if the key exists, false otherwise.
285
+ * @example
286
+ * cache.set('key1', 'value1');
287
+ * console.log(cache.has('key1')); // true
288
+ * console.log(cache.has('nonexistent')); // false
289
+ * @see {@link LRU#get}
290
+ * @see {@link LRU#delete}
291
+ * @since 9.0.0
292
+ */
293
+ has(e) {
294
+ return e in this.items;
295
+ }
296
+ /**
297
+ * Efficiently moves an item to the end of the LRU list (most recently used position).
298
+ * This is an internal optimization method that avoids the overhead of the full set() operation
299
+ * when only LRU position needs to be updated.
300
+ *
301
+ * @method moveToEnd
302
+ * @memberof LRU
303
+ * @param {Object} item - The cache item with prev/next pointers to reposition.
304
+ * @private
305
+ * @since 11.3.5
306
+ */
307
+ moveToEnd(e) {
308
+ this.last !== e && (e.prev !== null && (e.prev.next = e.next), e.next !== null && (e.next.prev = e.prev), this.first === e && (this.first = e.next), e.prev = this.last, e.next = null, this.last !== null && (this.last.next = e), this.last = e, this.first === null && (this.first = e));
309
+ }
310
+ /**
311
+ * Returns an array of all keys in the cache, ordered from least to most recently used.
312
+ *
313
+ * @method keys
314
+ * @memberof LRU
315
+ * @returns {string[]} Array of keys in LRU order.
316
+ * @example
317
+ * cache.set('a', 1).set('b', 2);
318
+ * cache.get('a'); // Move 'a' to most recent
319
+ * console.log(cache.keys()); // ['b', 'a']
320
+ * @see {@link LRU#values}
321
+ * @see {@link LRU#entries}
322
+ * @since 9.0.0
323
+ */
324
+ keys() {
325
+ const e = [];
326
+ let t = this.first;
327
+ for (; t !== null; )
328
+ e.push(t.key), t = t.next;
329
+ return e;
330
+ }
331
+ /**
332
+ * Sets a value in the cache and returns any evicted item.
333
+ *
334
+ * @method setWithEvicted
335
+ * @memberof LRU
336
+ * @param {string} key - The key to set.
337
+ * @param {*} value - The value to store.
338
+ * @param {boolean} [resetTtl=this.resetTtl] - Whether to reset the TTL for this operation.
339
+ * @returns {Object|null} The evicted item (if any) with shape {key, value, expiry, prev, next}, or null.
340
+ * @example
341
+ * const cache = new LRU(2);
342
+ * cache.set('a', 1).set('b', 2);
343
+ * const evicted = cache.setWithEvicted('c', 3); // evicted = {key: 'a', value: 1, ...}
344
+ * @see {@link LRU#set}
345
+ * @see {@link LRU#evict}
346
+ * @since 11.3.0
347
+ */
348
+ setWithEvicted(e, t, r = this.resetTtl) {
349
+ let i = null;
350
+ if (this.has(e))
351
+ this.set(e, t, !0, r);
352
+ else {
353
+ this.max > 0 && this.size === this.max && (i = { ...this.first }, this.evict(!0));
354
+ let n = this.items[e] = {
355
+ expiry: this.ttl > 0 ? Date.now() + this.ttl : this.ttl,
356
+ key: e,
357
+ prev: this.last,
358
+ next: null,
359
+ value: t
360
+ };
361
+ ++this.size === 1 ? this.first = n : this.last.next = n, this.last = n;
362
+ }
363
+ return i;
364
+ }
365
+ /**
366
+ * Sets a value in the cache. Updates the item's position to most recently used.
367
+ *
368
+ * @method set
369
+ * @memberof LRU
370
+ * @param {string} key - The key to set.
371
+ * @param {*} value - The value to store.
372
+ * @param {boolean} [bypass=false] - Internal parameter for setWithEvicted method.
373
+ * @param {boolean} [resetTtl=this.resetTtl] - Whether to reset the TTL for this operation.
374
+ * @returns {LRU} The LRU instance for method chaining.
375
+ * @example
376
+ * cache.set('key1', 'value1')
377
+ * .set('key2', 'value2')
378
+ * .set('key3', 'value3');
379
+ * @see {@link LRU#get}
380
+ * @see {@link LRU#setWithEvicted}
381
+ * @since 1.0.0
382
+ */
383
+ set(e, t, r = !1, i = this.resetTtl) {
384
+ let n = this.items[e];
385
+ return r || n !== void 0 ? (n.value = t, r === !1 && i && (n.expiry = this.ttl > 0 ? Date.now() + this.ttl : this.ttl), this.moveToEnd(n)) : (this.max > 0 && this.size === this.max && this.evict(!0), n = this.items[e] = {
386
+ expiry: this.ttl > 0 ? Date.now() + this.ttl : this.ttl,
387
+ key: e,
388
+ prev: this.last,
389
+ next: null,
390
+ value: t
391
+ }, ++this.size === 1 ? this.first = n : this.last.next = n, this.last = n), this;
392
+ }
393
+ /**
394
+ * Returns an array of all values in the cache for the specified keys.
395
+ * Order follows LRU order (least to most recently used).
396
+ *
397
+ * @method values
398
+ * @memberof LRU
399
+ * @param {string[]} [keys=this.keys()] - Array of keys to get values for. Defaults to all keys.
400
+ * @returns {Array<*>} Array of values corresponding to the keys in LRU order.
401
+ * @example
402
+ * cache.set('a', 1).set('b', 2);
403
+ * console.log(cache.values()); // [1, 2]
404
+ * console.log(cache.values(['a'])); // [1]
405
+ * @see {@link LRU#keys}
406
+ * @see {@link LRU#entries}
407
+ * @since 11.1.0
408
+ */
409
+ values(e = this.keys()) {
410
+ return e.map((t) => this.get(t));
411
+ }
412
+ }
413
+ function Qe(o = 1e3, e = 0, t = !1) {
414
+ if (isNaN(o) || o < 0)
415
+ throw new TypeError("Invalid max value");
416
+ if (isNaN(e) || e < 0)
417
+ throw new TypeError("Invalid ttl value");
418
+ if (typeof t != "boolean")
419
+ throw new TypeError("Invalid resetTtl value");
420
+ return new Yt(o, e, t);
421
+ }
422
+ const Xt = [
136
423
  "serif",
137
424
  "sans-serif",
138
425
  "monospace",
@@ -140,20 +427,20 @@ const Ot = [
140
427
  "fantasy",
141
428
  "system-ui"
142
429
  ];
143
- function re(o) {
430
+ function ie(o) {
144
431
  const e = typeof o.fontSize == "number" ? `${o.fontSize}px` : o.fontSize;
145
432
  let t = o.fontFamily;
146
433
  Array.isArray(o.fontFamily) || (t = o.fontFamily.split(","));
147
434
  for (let r = t.length - 1; r >= 0; r--) {
148
435
  let i = t[r].trim();
149
- !/([\"\'])[^\'\"]+\1/.test(i) && !Ot.includes(i) && (i = `"${i}"`), t[r] = i;
436
+ !/([\"\'])[^\'\"]+\1/.test(i) && !Xt.includes(i) && (i = `"${i}"`), t[r] = i;
150
437
  }
151
438
  return `${o.fontStyle} ${o.fontVariant} ${o.fontWeight} ${e} ${t.join(",")}`;
152
439
  }
153
440
  const oe = {
154
441
  // TextMetrics requires getImageData readback for measuring fonts.
155
442
  willReadFrequently: !0
156
- }, W = class g {
443
+ }, k = class p {
157
444
  /**
158
445
  * Checking that we can use modern canvas 2D API.
159
446
  *
@@ -163,10 +450,10 @@ const oe = {
163
450
  * @see https://developer.chrome.com/origintrials/#/view_trial/3585991203293757441
164
451
  */
165
452
  static get experimentalLetterSpacingSupported() {
166
- let e = g._experimentalLetterSpacingSupported;
453
+ let e = p._experimentalLetterSpacingSupported;
167
454
  if (e === void 0) {
168
455
  const t = H.get().getCanvasRenderingContext2D().prototype;
169
- e = g._experimentalLetterSpacingSupported = "letterSpacing" in t || "textLetterSpacing" in t;
456
+ e = p._experimentalLetterSpacingSupported = "letterSpacing" in t || "textLetterSpacing" in t;
170
457
  }
171
458
  return e;
172
459
  }
@@ -181,8 +468,8 @@ const oe = {
181
468
  * @param maxLineWidth - the maximum line width for all measured lines
182
469
  * @param {FontMetrics} fontProperties - the font properties object from TextMetrics.measureFont
183
470
  */
184
- constructor(e, t, r, i, n, s, a, l, c) {
185
- this.text = e, this.style = t, this.width = r, this.height = i, this.lines = n, this.lineWidths = s, this.lineHeight = a, this.maxLineWidth = l, this.fontProperties = c;
471
+ constructor(e, t, r, i, n, s, a, u, l) {
472
+ this.text = e, this.style = t, this.width = r, this.height = i, this.lines = n, this.lineWidths = s, this.lineHeight = a, this.maxLineWidth = u, this.fontProperties = l;
186
473
  }
187
474
  /**
188
475
  * Measures the supplied string of text and returns a Rectangle.
@@ -192,50 +479,55 @@ const oe = {
192
479
  * @param wordWrap
193
480
  * @returns Measured width and height of the text.
194
481
  */
195
- static measureText(e = " ", t, r = g._canvas, i = t.wordWrap) {
196
- var p;
197
- const n = re(t), s = g.measureFont(n);
198
- s.fontSize === 0 && (s.fontSize = t.fontSize, s.ascent = t.fontSize);
199
- const a = g.__context;
200
- a.font = n;
201
- const c = (i ? g._wordWrap(e, t, r) : e).split(/(?:\r\n|\r|\n)/), d = new Array(c.length);
202
- let u = 0;
203
- for (let b = 0; b < c.length; b++) {
204
- const y = g._measureText(c[b], t.letterSpacing, a);
205
- d[b] = y, u = Math.max(u, y);
482
+ static measureText(e = " ", t, r = p._canvas, i = t.wordWrap) {
483
+ var b;
484
+ const n = `${e}-${t.styleKey}-wordWrap-${i}`;
485
+ if (p._measurementCache.has(n))
486
+ return p._measurementCache.get(n);
487
+ const s = ie(t), a = p.measureFont(s);
488
+ a.fontSize === 0 && (a.fontSize = t.fontSize, a.ascent = t.fontSize);
489
+ const u = p.__context;
490
+ u.font = s;
491
+ const h = (i ? p._wordWrap(e, t, r) : e).split(/(?:\r\n|\r|\n)/), c = new Array(h.length);
492
+ let d = 0;
493
+ for (let m = 0; m < h.length; m++) {
494
+ const T = p._measureText(h[m], t.letterSpacing, u);
495
+ c[m] = T, d = Math.max(d, T);
206
496
  }
207
- const h = ((p = t._stroke) == null ? void 0 : p.width) || 0;
208
- let f = u + h;
209
- t.dropShadow && (f += t.dropShadow.distance);
210
- const m = t.lineHeight || s.fontSize;
211
- let x = Math.max(m, s.fontSize + h) + (c.length - 1) * (m + t.leading);
212
- return t.dropShadow && (x += t.dropShadow.distance), new g(
497
+ const f = ((b = t._stroke) == null ? void 0 : b.width) || 0;
498
+ let x = d + f;
499
+ t.dropShadow && (x += t.dropShadow.distance);
500
+ const _ = t.lineHeight || a.fontSize;
501
+ let v = Math.max(_, a.fontSize + f) + (h.length - 1) * (_ + t.leading);
502
+ t.dropShadow && (v += t.dropShadow.distance);
503
+ const g = new p(
213
504
  e,
214
505
  t,
215
- f,
216
506
  x,
507
+ v,
508
+ h,
217
509
  c,
510
+ _ + t.leading,
218
511
  d,
219
- m + t.leading,
220
- u,
221
- s
512
+ a
222
513
  );
514
+ return p._measurementCache.set(n, g), g;
223
515
  }
224
516
  static _measureText(e, t, r) {
225
517
  let i = !1;
226
- g.experimentalLetterSpacingSupported && (g.experimentalLetterSpacing ? (r.letterSpacing = `${t}px`, r.textLetterSpacing = `${t}px`, i = !0) : (r.letterSpacing = "0px", r.textLetterSpacing = "0px"));
518
+ p.experimentalLetterSpacingSupported && (p.experimentalLetterSpacing ? (r.letterSpacing = `${t}px`, r.textLetterSpacing = `${t}px`, i = !0) : (r.letterSpacing = "0px", r.textLetterSpacing = "0px"));
227
519
  const n = r.measureText(e);
228
520
  let s = n.width;
229
521
  const a = -n.actualBoundingBoxLeft;
230
- let c = n.actualBoundingBoxRight - a;
522
+ let l = n.actualBoundingBoxRight - a;
231
523
  if (s > 0)
232
524
  if (i)
233
- s -= t, c -= t;
525
+ s -= t, l -= t;
234
526
  else {
235
- const d = (g.graphemeSegmenter(e).length - 1) * t;
236
- s += d, c += d;
527
+ const h = (p.graphemeSegmenter(e).length - 1) * t;
528
+ s += h, l += h;
237
529
  }
238
- return Math.max(s, c);
530
+ return Math.max(s, l);
239
531
  }
240
532
  /**
241
533
  * Applies newlines to a string to have it optimally fit into the horizontal
@@ -245,53 +537,53 @@ const oe = {
245
537
  * @param canvas - optional specification of the canvas to use for measuring.
246
538
  * @returns New string with new lines applied where required
247
539
  */
248
- static _wordWrap(e, t, r = g._canvas) {
540
+ static _wordWrap(e, t, r = p._canvas) {
249
541
  const i = r.getContext("2d", oe);
250
542
  let n = 0, s = "", a = "";
251
- const l = /* @__PURE__ */ Object.create(null), { letterSpacing: c, whiteSpace: d } = t, u = g._collapseSpaces(d), h = g._collapseNewlines(d);
252
- let f = !u;
253
- const m = t.wordWrapWidth + c, x = g._tokenize(e);
254
- for (let _ = 0; _ < x.length; _++) {
255
- let p = x[_];
256
- if (g._isNewline(p)) {
257
- if (!h) {
258
- a += g._addLine(s), f = !u, s = "", n = 0;
543
+ const u = /* @__PURE__ */ Object.create(null), { letterSpacing: l, whiteSpace: h } = t, c = p._collapseSpaces(h), d = p._collapseNewlines(h);
544
+ let f = !c;
545
+ const x = t.wordWrapWidth + l, _ = p._tokenize(e);
546
+ for (let v = 0; v < _.length; v++) {
547
+ let g = _[v];
548
+ if (p._isNewline(g)) {
549
+ if (!d) {
550
+ a += p._addLine(s), f = !c, s = "", n = 0;
259
551
  continue;
260
552
  }
261
- p = " ";
553
+ g = " ";
262
554
  }
263
- if (u) {
264
- const y = g.isBreakingSpace(p), T = g.isBreakingSpace(s[s.length - 1]);
265
- if (y && T)
555
+ if (c) {
556
+ const m = p.isBreakingSpace(g), T = p.isBreakingSpace(s[s.length - 1]);
557
+ if (m && T)
266
558
  continue;
267
559
  }
268
- const b = g._getFromCache(p, c, l, i);
269
- if (b > m)
270
- if (s !== "" && (a += g._addLine(s), s = "", n = 0), g.canBreakWords(p, t.breakWords)) {
271
- const y = g.wordWrapSplit(p);
272
- for (let T = 0; T < y.length; T++) {
273
- let S = y[T], B = S, v = 1;
274
- for (; y[T + v]; ) {
275
- const M = y[T + v];
276
- if (!g.canBreakChars(B, M, p, T, t.breakWords))
277
- S += M;
560
+ const b = p._getFromCache(g, l, u, i);
561
+ if (b > x)
562
+ if (s !== "" && (a += p._addLine(s), s = "", n = 0), p.canBreakWords(g, t.breakWords)) {
563
+ const m = p.wordWrapSplit(g);
564
+ for (let T = 0; T < m.length; T++) {
565
+ let S = m[T], B = S, w = 1;
566
+ for (; m[T + w]; ) {
567
+ const R = m[T + w];
568
+ if (!p.canBreakChars(B, R, g, T, t.breakWords))
569
+ S += R;
278
570
  else
279
571
  break;
280
- B = M, v++;
572
+ B = R, w++;
281
573
  }
282
- T += v - 1;
283
- const F = g._getFromCache(S, c, l, i);
284
- F + n > m && (a += g._addLine(s), f = !1, s = "", n = 0), s += S, n += F;
574
+ T += w - 1;
575
+ const F = p._getFromCache(S, l, u, i);
576
+ F + n > x && (a += p._addLine(s), f = !1, s = "", n = 0), s += S, n += F;
285
577
  }
286
578
  } else {
287
- s.length > 0 && (a += g._addLine(s), s = "", n = 0);
288
- const y = _ === x.length - 1;
289
- a += g._addLine(p, !y), f = !1, s = "", n = 0;
579
+ s.length > 0 && (a += p._addLine(s), s = "", n = 0);
580
+ const m = v === _.length - 1;
581
+ a += p._addLine(g, !m), f = !1, s = "", n = 0;
290
582
  }
291
583
  else
292
- b + n > m && (f = !1, a += g._addLine(s), s = "", n = 0), (s.length > 0 || !g.isBreakingSpace(p) || f) && (s += p, n += b);
584
+ b + n > x && (f = !1, a += p._addLine(s), s = "", n = 0), (s.length > 0 || !p.isBreakingSpace(g) || f) && (s += g, n += b);
293
585
  }
294
- return a += g._addLine(s, !1), a;
586
+ return a += p._addLine(s, !1), a;
295
587
  }
296
588
  /**
297
589
  * Convenience function for logging each line added during the wordWrap method.
@@ -300,7 +592,7 @@ const oe = {
300
592
  * @returns A formatted line
301
593
  */
302
594
  static _addLine(e, t = !0) {
303
- return e = g._trimRight(e), e = t ? `${e}
595
+ return e = p._trimRight(e), e = t ? `${e}
304
596
  ` : e, e;
305
597
  }
306
598
  /**
@@ -313,7 +605,7 @@ const oe = {
313
605
  */
314
606
  static _getFromCache(e, t, r, i) {
315
607
  let n = r[e];
316
- return typeof n != "number" && (n = g._measureText(e, t, i) + t, r[e] = n), n;
608
+ return typeof n != "number" && (n = p._measureText(e, t, i) + t, r[e] = n), n;
317
609
  }
318
610
  /**
319
611
  * Determines whether we should collapse breaking spaces.
@@ -341,7 +633,7 @@ const oe = {
341
633
  return "";
342
634
  for (let t = e.length - 1; t >= 0; t--) {
343
635
  const r = e[t];
344
- if (!g.isBreakingSpace(r))
636
+ if (!p.isBreakingSpace(r))
345
637
  break;
346
638
  e = e.slice(0, -1);
347
639
  }
@@ -353,7 +645,7 @@ const oe = {
353
645
  * @returns True if newline, False otherwise.
354
646
  */
355
647
  static _isNewline(e) {
356
- return typeof e != "string" ? !1 : g._newlines.includes(e.charCodeAt(0));
648
+ return typeof e != "string" ? !1 : p._newlines.includes(e.charCodeAt(0));
357
649
  }
358
650
  /**
359
651
  * Determines if char is a breaking whitespace.
@@ -366,7 +658,7 @@ const oe = {
366
658
  * @returns True if whitespace, False otherwise.
367
659
  */
368
660
  static isBreakingSpace(e, t) {
369
- return typeof e != "string" ? !1 : g._breakingSpaces.includes(e.charCodeAt(0));
661
+ return typeof e != "string" ? !1 : p._breakingSpaces.includes(e.charCodeAt(0));
370
662
  }
371
663
  /**
372
664
  * Splits a string into words, breaking-spaces and newLine characters
@@ -380,7 +672,7 @@ const oe = {
380
672
  return t;
381
673
  for (let i = 0; i < e.length; i++) {
382
674
  const n = e[i], s = e[i + 1];
383
- if (g.isBreakingSpace(n, s) || g._isNewline(n)) {
675
+ if (p.isBreakingSpace(n, s) || p._isNewline(n)) {
384
676
  r !== "" && (t.push(r), r = ""), n === "\r" && s === `
385
677
  ` ? (t.push(`\r
386
678
  `), i++) : t.push(n);
@@ -431,7 +723,7 @@ const oe = {
431
723
  * @see CanvasTextMetrics.graphemeSegmenter
432
724
  */
433
725
  static wordWrapSplit(e) {
434
- return g.graphemeSegmenter(e);
726
+ return p.graphemeSegmenter(e);
435
727
  }
436
728
  /**
437
729
  * Calculates the ascent, descent and fontSize of a given font-style
@@ -439,23 +731,23 @@ const oe = {
439
731
  * @returns Font properties object
440
732
  */
441
733
  static measureFont(e) {
442
- if (g._fonts[e])
443
- return g._fonts[e];
444
- const t = g._context;
734
+ if (p._fonts[e])
735
+ return p._fonts[e];
736
+ const t = p._context;
445
737
  t.font = e;
446
- const r = t.measureText(g.METRICS_STRING + g.BASELINE_SYMBOL), i = {
738
+ const r = t.measureText(p.METRICS_STRING + p.BASELINE_SYMBOL), i = {
447
739
  ascent: r.actualBoundingBoxAscent,
448
740
  descent: r.actualBoundingBoxDescent,
449
741
  fontSize: r.actualBoundingBoxAscent + r.actualBoundingBoxDescent
450
742
  };
451
- return g._fonts[e] = i, i;
743
+ return p._fonts[e] = i, i;
452
744
  }
453
745
  /**
454
746
  * Clear font metrics in metrics cache.
455
747
  * @param {string} [font] - font name. If font name not set then clear cache for all fonts.
456
748
  */
457
749
  static clearMetrics(e = "") {
458
- e ? delete g._fonts[e] : g._fonts = {};
750
+ e ? delete p._fonts[e] : p._fonts = {};
459
751
  }
460
752
  /**
461
753
  * Cached canvas element for measuring text
@@ -463,33 +755,33 @@ const oe = {
463
755
  * @ignore
464
756
  */
465
757
  static get _canvas() {
466
- if (!g.__canvas) {
758
+ if (!p.__canvas) {
467
759
  let e;
468
760
  try {
469
761
  const t = new OffscreenCanvas(0, 0), r = t.getContext("2d", oe);
470
762
  if (r != null && r.measureText)
471
- return g.__canvas = t, t;
763
+ return p.__canvas = t, t;
472
764
  e = H.get().createCanvas();
473
765
  } catch {
474
766
  e = H.get().createCanvas();
475
767
  }
476
- e.width = e.height = 10, g.__canvas = e;
768
+ e.width = e.height = 10, p.__canvas = e;
477
769
  }
478
- return g.__canvas;
770
+ return p.__canvas;
479
771
  }
480
772
  /**
481
773
  * TODO: this should be private, but isn't because of backward compat, will fix later.
482
774
  * @ignore
483
775
  */
484
776
  static get _context() {
485
- return g.__context || (g.__context = g._canvas.getContext("2d", oe)), g.__context;
777
+ return p.__context || (p.__context = p._canvas.getContext("2d", oe)), p.__context;
486
778
  }
487
779
  };
488
- W.METRICS_STRING = "|ÉqÅ";
489
- W.BASELINE_SYMBOL = "M";
490
- W.BASELINE_MULTIPLIER = 1.4;
491
- W.HEIGHT_MULTIPLIER = 2;
492
- W.graphemeSegmenter = (() => {
780
+ k.METRICS_STRING = "|ÉqÅ";
781
+ k.BASELINE_SYMBOL = "M";
782
+ k.BASELINE_MULTIPLIER = 1.4;
783
+ k.HEIGHT_MULTIPLIER = 2;
784
+ k.graphemeSegmenter = (() => {
493
785
  if (typeof (Intl == null ? void 0 : Intl.Segmenter) == "function") {
494
786
  const o = new Intl.Segmenter();
495
787
  return (e) => {
@@ -502,15 +794,15 @@ W.graphemeSegmenter = (() => {
502
794
  }
503
795
  return (o) => [...o];
504
796
  })();
505
- W.experimentalLetterSpacing = !1;
506
- W._fonts = {};
507
- W._newlines = [
797
+ k.experimentalLetterSpacing = !1;
798
+ k._fonts = {};
799
+ k._newlines = [
508
800
  10,
509
801
  // line feed
510
802
  13
511
803
  // carriage return
512
804
  ];
513
- W._breakingSpaces = [
805
+ k._breakingSpaces = [
514
806
  9,
515
807
  // character tabulation
516
808
  32,
@@ -540,85 +832,86 @@ W._breakingSpaces = [
540
832
  12288
541
833
  // ideographic space
542
834
  ];
543
- let D = W;
835
+ k._measurementCache = Qe(1e3);
836
+ let O = k;
544
837
  const Ce = 1e5;
545
- function ie(o, e, t, r = 0) {
546
- if (o.texture === R.WHITE && !o.fill)
838
+ function ne(o, e, t, r = 0) {
839
+ if (o.texture === M.WHITE && !o.fill)
547
840
  return V.shared.setValue(o.color).setAlpha(o.alpha ?? 1).toHexa();
548
841
  if (o.fill) {
549
- if (o.fill instanceof vt) {
550
- const i = o.fill, n = e.createPattern(i.texture.source.resource, "repeat"), s = i.transform.copyTo(k.shared);
842
+ if (o.fill instanceof Bt) {
843
+ const i = o.fill, n = e.createPattern(i.texture.source.resource, "repeat"), s = i.transform.copyTo(U.shared);
551
844
  return s.scale(
552
845
  i.texture.frame.width,
553
846
  i.texture.frame.height
554
847
  ), n.setTransform(s), n;
555
- } else if (o.fill instanceof St) {
848
+ } else if (o.fill instanceof Rt) {
556
849
  const i = o.fill, n = i.type === "linear", s = i.textureSpace === "local";
557
- let a = 1, l = 1;
558
- s && t && (a = t.width + r, l = t.height + r);
559
- let c, d = !1;
850
+ let a = 1, u = 1;
851
+ s && t && (a = t.width + r, u = t.height + r);
852
+ let l, h = !1;
560
853
  if (n) {
561
- const { start: u, end: h } = i;
562
- c = e.createLinearGradient(
563
- u.x * a,
564
- u.y * l,
565
- h.x * a,
566
- h.y * l
567
- ), d = Math.abs(h.x - u.x) < Math.abs((h.y - u.y) * 0.1);
854
+ const { start: c, end: d } = i;
855
+ l = e.createLinearGradient(
856
+ c.x * a,
857
+ c.y * u,
858
+ d.x * a,
859
+ d.y * u
860
+ ), h = Math.abs(d.x - c.x) < Math.abs((d.y - c.y) * 0.1);
568
861
  } else {
569
- const { center: u, innerRadius: h, outerCenter: f, outerRadius: m } = i;
570
- c = e.createRadialGradient(
571
- u.x * a,
572
- u.y * l,
573
- h * a,
862
+ const { center: c, innerRadius: d, outerCenter: f, outerRadius: x } = i;
863
+ l = e.createRadialGradient(
864
+ c.x * a,
865
+ c.y * u,
866
+ d * a,
574
867
  f.x * a,
575
- f.y * l,
576
- m * a
868
+ f.y * u,
869
+ x * a
577
870
  );
578
871
  }
579
- if (d && s && t) {
580
- const u = t.lineHeight / l;
581
- for (let h = 0; h < t.lines.length; h++) {
582
- const f = (h * t.lineHeight + r / 2) / l;
583
- i.colorStops.forEach((m) => {
584
- const x = f + m.offset * u;
585
- c.addColorStop(
872
+ if (h && s && t) {
873
+ const c = t.lineHeight / u;
874
+ for (let d = 0; d < t.lines.length; d++) {
875
+ const f = (d * t.lineHeight + r / 2) / u;
876
+ i.colorStops.forEach((x) => {
877
+ const _ = f + x.offset * c;
878
+ l.addColorStop(
586
879
  // fix to 5 decimal places to avoid floating point precision issues
587
- Math.floor(x * Ce) / Ce,
588
- V.shared.setValue(m.color).toHex()
880
+ Math.floor(_ * Ce) / Ce,
881
+ V.shared.setValue(x.color).toHex()
589
882
  );
590
883
  });
591
884
  }
592
885
  } else
593
- i.colorStops.forEach((u) => {
594
- c.addColorStop(u.offset, V.shared.setValue(u.color).toHex());
886
+ i.colorStops.forEach((c) => {
887
+ l.addColorStop(c.offset, V.shared.setValue(c.color).toHex());
595
888
  });
596
- return c;
889
+ return l;
597
890
  }
598
891
  } else {
599
- const i = e.createPattern(o.texture.source.resource, "repeat"), n = o.matrix.copyTo(k.shared);
892
+ const i = e.createPattern(o.texture.source.resource, "repeat"), n = o.matrix.copyTo(U.shared);
600
893
  return n.scale(o.texture.frame.width, o.texture.frame.height), i.setTransform(n), i;
601
894
  }
602
- return ne("FillStyle not recognised", o), "red";
895
+ return K("FillStyle not recognised", o), "red";
603
896
  }
604
- const Ne = class je extends It {
897
+ const Je = class Ze extends Vt {
605
898
  /**
606
899
  * @param options - The options for the dynamic bitmap font.
607
900
  */
608
901
  constructor(e) {
609
902
  super(), this.resolution = 1, this.pages = [], this._padding = 0, this._measureCache = /* @__PURE__ */ Object.create(null), this._currentChars = [], this._currentX = 0, this._currentY = 0, this._currentMaxCharHeight = 0, this._currentPageIndex = -1, this._skipKerning = !1;
610
- const t = { ...je.defaultOptions, ...e };
903
+ const t = { ...Ze.defaultOptions, ...e };
611
904
  this._textureSize = t.textureSize, this._mipmap = t.mipmap;
612
905
  const r = t.style.clone();
613
- t.overrideFill && (r._fill.color = 16777215, r._fill.alpha = 1, r._fill.texture = R.WHITE, r._fill.fill = null), this.applyFillAsTint = t.overrideFill;
906
+ t.overrideFill && (r._fill.color = 16777215, r._fill.alpha = 1, r._fill.texture = M.WHITE, r._fill.fill = null), this.applyFillAsTint = t.overrideFill;
614
907
  const i = r.fontSize;
615
908
  r.fontSize = this.baseMeasurementFontSize;
616
- const n = re(r);
617
- t.overrideSize ? r._stroke && (r._stroke.width *= this.baseRenderedFontSize / i) : r.fontSize = this.baseRenderedFontSize = i, this._style = r, this._skipKerning = t.skipKerning ?? !1, this.resolution = t.resolution ?? 1, this._padding = t.padding ?? 4, t.textureStyle && (this._textureStyle = t.textureStyle instanceof j ? t.textureStyle : new j(t.textureStyle)), this.fontMetrics = D.measureFont(n), this.lineHeight = r.lineHeight || this.fontMetrics.fontSize || r.fontSize;
909
+ const n = ie(r);
910
+ t.overrideSize ? r._stroke && (r._stroke.width *= this.baseRenderedFontSize / i) : r.fontSize = this.baseRenderedFontSize = i, this._style = r, this._skipKerning = t.skipKerning ?? !1, this.resolution = t.resolution ?? 1, this._padding = t.padding ?? 4, t.textureStyle && (this._textureStyle = t.textureStyle instanceof j ? t.textureStyle : new j(t.textureStyle)), this.fontMetrics = O.measureFont(n), this.lineHeight = r.lineHeight || this.fontMetrics.fontSize || r.fontSize;
618
911
  }
619
912
  ensureCharacters(e) {
620
- var _, p;
621
- const t = D.graphemeSegmenter(e).filter((b) => !this._currentChars.includes(b)).filter((b, y, T) => T.indexOf(b) === y);
913
+ var v, g;
914
+ const t = O.graphemeSegmenter(e).filter((b) => !this._currentChars.includes(b)).filter((b, m, T) => T.indexOf(b) === m);
622
915
  if (!t.length)
623
916
  return;
624
917
  this._currentChars = [...this._currentChars, ...t];
@@ -626,23 +919,23 @@ const Ne = class je extends It {
626
919
  this._currentPageIndex === -1 ? r = this._nextPage() : r = this.pages[this._currentPageIndex];
627
920
  let { canvas: i, context: n } = r.canvasAndContext, s = r.texture.source;
628
921
  const a = this._style;
629
- let l = this._currentX, c = this._currentY, d = this._currentMaxCharHeight;
630
- const u = this.baseRenderedFontSize / this.baseMeasurementFontSize, h = this._padding * u;
922
+ let u = this._currentX, l = this._currentY, h = this._currentMaxCharHeight;
923
+ const c = this.baseRenderedFontSize / this.baseMeasurementFontSize, d = this._padding * c;
631
924
  let f = !1;
632
- const m = i.width / this.resolution, x = i.height / this.resolution;
925
+ const x = i.width / this.resolution, _ = i.height / this.resolution;
633
926
  for (let b = 0; b < t.length; b++) {
634
- const y = t[b], T = D.measureText(y, a, i, !1);
927
+ const m = t[b], T = O.measureText(m, a, i, !1);
635
928
  T.lineHeight = T.height;
636
- const S = T.width * u, B = Math.ceil((a.fontStyle === "italic" ? 2 : 1) * S), v = T.height * u, F = B + h * 2, M = v + h * 2;
637
- if (f = !1, y !== `
638
- ` && y !== "\r" && y !== " " && y !== " " && (f = !0, d = Math.ceil(Math.max(M, d))), l + F > m && (c += d, d = M, l = 0, c + d > x)) {
929
+ const S = T.width * c, B = Math.ceil((a.fontStyle === "italic" ? 2 : 1) * S), w = T.height * c, F = B + d * 2, R = w + d * 2;
930
+ if (f = !1, m !== `
931
+ ` && m !== "\r" && m !== " " && m !== " " && (f = !0, h = Math.ceil(Math.max(R, h))), u + F > x && (l += h, h = R, u = 0, l + h > _)) {
639
932
  s.update();
640
- const L = this._nextPage();
641
- i = L.canvasAndContext.canvas, n = L.canvasAndContext.context, s = L.texture.source, l = 0, c = 0, d = 0;
933
+ const I = this._nextPage();
934
+ i = I.canvasAndContext.canvas, n = I.canvasAndContext.context, s = I.texture.source, u = 0, l = 0, h = 0;
642
935
  }
643
- const ae = S / u - (((_ = a.dropShadow) == null ? void 0 : _.distance) ?? 0) - (((p = a._stroke) == null ? void 0 : p.width) ?? 0);
644
- if (this.chars[y] = {
645
- id: y.codePointAt(0),
936
+ const ae = S / c - (((v = a.dropShadow) == null ? void 0 : v.distance) ?? 0) - (((g = a._stroke) == null ? void 0 : g.width) ?? 0);
937
+ if (this.chars[m] = {
938
+ id: m.codePointAt(0),
646
939
  xOffset: -this._padding,
647
940
  yOffset: -this._padding,
648
941
  xAdvance: ae,
@@ -651,31 +944,31 @@ const Ne = class je extends It {
651
944
  this._drawGlyph(
652
945
  n,
653
946
  T,
654
- l + h,
655
- c + h,
656
- u,
947
+ u + d,
948
+ l + d,
949
+ c,
657
950
  a
658
951
  );
659
- const L = s.width * u, $ = s.height * u, C = new Z(
660
- l / L * s.width,
661
- c / $ * s.height,
662
- F / L * s.width,
663
- M / $ * s.height
952
+ const I = s.width * c, $ = s.height * c, C = new ee(
953
+ u / I * s.width,
954
+ l / $ * s.height,
955
+ F / I * s.width,
956
+ R / $ * s.height
664
957
  );
665
- this.chars[y].texture = new R({
958
+ this.chars[m].texture = new M({
666
959
  source: s,
667
960
  frame: C
668
- }), l += Math.ceil(F);
961
+ }), u += Math.ceil(F);
669
962
  }
670
963
  }
671
- s.update(), this._currentX = l, this._currentY = c, this._currentMaxCharHeight = d, this._skipKerning && this._applyKerning(t, n);
964
+ s.update(), this._currentX = u, this._currentY = l, this._currentMaxCharHeight = h, this._skipKerning && this._applyKerning(t, n);
672
965
  }
673
966
  /**
674
967
  * @deprecated since 8.0.0
675
968
  * The map of base page textures (i.e., sheets of glyphs).
676
969
  */
677
970
  get pageTextures() {
678
- return U(O, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
971
+ return z(L, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
679
972
  }
680
973
  _applyKerning(e, t) {
681
974
  const r = this._measureCache;
@@ -683,12 +976,12 @@ const Ne = class je extends It {
683
976
  const n = e[i];
684
977
  for (let s = 0; s < this._currentChars.length; s++) {
685
978
  const a = this._currentChars[s];
686
- let l = r[n];
687
- l || (l = r[n] = t.measureText(n).width);
688
- let c = r[a];
689
- c || (c = r[a] = t.measureText(a).width);
690
- let d = t.measureText(n + a).width, u = d - (l + c);
691
- u && (this.chars[n].kerning[a] = u), d = t.measureText(n + a).width, u = d - (l + c), u && (this.chars[a].kerning[n] = u);
979
+ let u = r[n];
980
+ u || (u = r[n] = t.measureText(n).width);
981
+ let l = r[a];
982
+ l || (l = r[a] = t.measureText(a).width);
983
+ let h = t.measureText(n + a).width, c = h - (u + l);
984
+ c && (this.chars[n].kerning[a] = c), h = t.measureText(n + a).width, c = h - (u + l), c && (this.chars[a].kerning[n] = c);
692
985
  }
693
986
  }
694
987
  }
@@ -700,8 +993,8 @@ const Ne = class je extends It {
700
993
  e
701
994
  );
702
995
  this._setupContext(t.context, this._style, e);
703
- const r = e * (this.baseRenderedFontSize / this.baseMeasurementFontSize), i = new R({
704
- source: new Ct({
996
+ const r = e * (this.baseRenderedFontSize / this.baseMeasurementFontSize), i = new M({
997
+ source: new Mt({
705
998
  resource: t.canvas,
706
999
  resolution: r,
707
1000
  alphaMode: "premultiply-alpha-on-upload",
@@ -717,20 +1010,20 @@ const Ne = class je extends It {
717
1010
  }
718
1011
  // canvas style!
719
1012
  _setupContext(e, t, r) {
720
- t.fontSize = this.baseRenderedFontSize, e.scale(r, r), e.font = re(t), t.fontSize = this.baseMeasurementFontSize, e.textBaseline = t.textBaseline;
1013
+ t.fontSize = this.baseRenderedFontSize, e.scale(r, r), e.font = ie(t), t.fontSize = this.baseMeasurementFontSize, e.textBaseline = t.textBaseline;
721
1014
  const i = t._stroke, n = (i == null ? void 0 : i.width) ?? 0;
722
- if (i && (e.lineWidth = n, e.lineJoin = i.join, e.miterLimit = i.miterLimit, e.strokeStyle = ie(i, e)), t._fill && (e.fillStyle = ie(t._fill, e)), t.dropShadow) {
723
- const s = t.dropShadow, a = V.shared.setValue(s.color).toArray(), l = s.blur * r, c = s.distance * r;
724
- e.shadowColor = `rgba(${a[0] * 255},${a[1] * 255},${a[2] * 255},${s.alpha})`, e.shadowBlur = l, e.shadowOffsetX = Math.cos(s.angle) * c, e.shadowOffsetY = Math.sin(s.angle) * c;
1015
+ if (i && (e.lineWidth = n, e.lineJoin = i.join, e.miterLimit = i.miterLimit, e.strokeStyle = ne(i, e)), t._fill && (e.fillStyle = ne(t._fill, e)), t.dropShadow) {
1016
+ const s = t.dropShadow, a = V.shared.setValue(s.color).toArray(), u = s.blur * r, l = s.distance * r;
1017
+ e.shadowColor = `rgba(${a[0] * 255},${a[1] * 255},${a[2] * 255},${s.alpha})`, e.shadowBlur = u, e.shadowOffsetX = Math.cos(s.angle) * l, e.shadowOffsetY = Math.sin(s.angle) * l;
725
1018
  } else
726
1019
  e.shadowColor = "black", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0;
727
1020
  }
728
1021
  _drawGlyph(e, t, r, i, n, s) {
729
- const a = t.text, l = t.fontProperties, c = s._stroke, d = ((c == null ? void 0 : c.width) ?? 0) * n, u = r + d / 2, h = i - d / 2, f = l.descent * n, m = t.lineHeight * n;
730
- let x = !1;
731
- s.stroke && d && (x = !0, e.strokeText(a, u, h + m - f));
732
- const { shadowBlur: _, shadowOffsetX: p, shadowOffsetY: b } = e;
733
- s._fill && (x && (e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0), e.fillText(a, u, h + m - f)), x && (e.shadowBlur = _, e.shadowOffsetX = p, e.shadowOffsetY = b);
1022
+ const a = t.text, u = t.fontProperties, l = s._stroke, h = ((l == null ? void 0 : l.width) ?? 0) * n, c = r + h / 2, d = i - h / 2, f = u.descent * n, x = t.lineHeight * n;
1023
+ let _ = !1;
1024
+ s.stroke && h && (_ = !0, e.strokeText(a, c, d + x - f));
1025
+ const { shadowBlur: v, shadowOffsetX: g, shadowOffsetY: b } = e;
1026
+ s._fill && (_ && (e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0), e.fillText(a, c, d + x - f)), _ && (e.shadowBlur = v, e.shadowOffsetX = g, e.shadowOffsetY = b);
734
1027
  }
735
1028
  destroy() {
736
1029
  super.destroy();
@@ -741,13 +1034,13 @@ const Ne = class je extends It {
741
1034
  this.pages = null;
742
1035
  }
743
1036
  };
744
- Ne.defaultOptions = {
1037
+ Je.defaultOptions = {
745
1038
  textureSize: 512,
746
1039
  style: new q(),
747
1040
  mipmap: !0
748
1041
  };
749
- let Pe = Ne;
750
- function qe(o, e, t, r) {
1042
+ let Pe = Je;
1043
+ function et(o, e, t, r) {
751
1044
  const i = {
752
1045
  width: 0,
753
1046
  height: 0,
@@ -763,26 +1056,26 @@ function qe(o, e, t, r) {
763
1056
  };
764
1057
  i.offsetY = t.baseLineOffset;
765
1058
  let n = i.lines[0], s = null, a = !0;
766
- const l = {
1059
+ const u = {
767
1060
  width: 0,
768
1061
  start: 0,
769
1062
  index: 0,
770
1063
  // use index to not modify the array as we use it a lot!
771
1064
  positions: [],
772
1065
  chars: []
773
- }, c = t.baseMeasurementFontSize / e.fontSize, d = e.letterSpacing * c, u = e.wordWrapWidth * c, h = e.lineHeight ? e.lineHeight * c : t.lineHeight, f = e.wordWrap && e.breakWords, m = (p) => {
1066
+ }, l = t.baseMeasurementFontSize / e.fontSize, h = e.letterSpacing * l, c = e.wordWrapWidth * l, d = e.lineHeight ? e.lineHeight * l : t.lineHeight, f = e.wordWrap && e.breakWords, x = (g) => {
774
1067
  const b = n.width;
775
- for (let y = 0; y < l.index; y++) {
776
- const T = p.positions[y];
777
- n.chars.push(p.chars[y]), n.charPositions.push(T + b);
1068
+ for (let m = 0; m < u.index; m++) {
1069
+ const T = g.positions[m];
1070
+ n.chars.push(g.chars[m]), n.charPositions.push(T + b);
778
1071
  }
779
- n.width += p.width, a = !1, l.width = 0, l.index = 0, l.chars.length = 0;
780
- }, x = () => {
781
- let p = n.chars.length - 1;
1072
+ n.width += g.width, a = !1, u.width = 0, u.index = 0, u.chars.length = 0;
1073
+ }, _ = () => {
1074
+ let g = n.chars.length - 1;
782
1075
  if (r) {
783
- let b = n.chars[p];
1076
+ let b = n.chars[g];
784
1077
  for (; b === " "; )
785
- n.width -= t.chars[b].xAdvance, b = n.chars[--p];
1078
+ n.width -= t.chars[b].xAdvance, b = n.chars[--g];
786
1079
  }
787
1080
  i.width = Math.max(i.width, n.width), n = {
788
1081
  width: 0,
@@ -790,55 +1083,55 @@ function qe(o, e, t, r) {
790
1083
  chars: [],
791
1084
  spaceWidth: 0,
792
1085
  spacesIndex: []
793
- }, a = !0, i.lines.push(n), i.height += h;
794
- }, _ = (p) => p - d > u;
795
- for (let p = 0; p < o.length + 1; p++) {
1086
+ }, a = !0, i.lines.push(n), i.height += d;
1087
+ }, v = (g) => g - h > c;
1088
+ for (let g = 0; g < o.length + 1; g++) {
796
1089
  let b;
797
- const y = p === o.length;
798
- y || (b = o[p]);
1090
+ const m = g === o.length;
1091
+ m || (b = o[g]);
799
1092
  const T = t.chars[b] || t.chars[" "];
800
1093
  if (/(?:\s)/.test(b) || b === "\r" || b === `
801
- ` || y) {
802
- if (!a && e.wordWrap && _(n.width + l.width) ? (x(), m(l), y || n.charPositions.push(0)) : (l.start = n.width, m(l), y || n.charPositions.push(0)), b === "\r" || b === `
1094
+ ` || m) {
1095
+ if (!a && e.wordWrap && v(n.width + u.width) ? (_(), x(u), m || n.charPositions.push(0)) : (u.start = n.width, x(u), m || n.charPositions.push(0)), b === "\r" || b === `
803
1096
  `)
804
- n.width !== 0 && x();
805
- else if (!y) {
806
- const F = T.xAdvance + (T.kerning[s] || 0) + d;
1097
+ _();
1098
+ else if (!m) {
1099
+ const F = T.xAdvance + (T.kerning[s] || 0) + h;
807
1100
  n.width += F, n.spaceWidth = F, n.spacesIndex.push(n.charPositions.length), n.chars.push(b);
808
1101
  }
809
1102
  } else {
810
- const v = T.kerning[s] || 0, F = T.xAdvance + v + d;
811
- f && _(n.width + l.width + F) && (m(l), x()), l.positions[l.index++] = l.width + v, l.chars.push(b), l.width += F;
1103
+ const w = T.kerning[s] || 0, F = T.xAdvance + w + h;
1104
+ f && v(n.width + u.width + F) && (x(u), _()), u.positions[u.index++] = u.width + w, u.chars.push(b), u.width += F;
812
1105
  }
813
1106
  s = b;
814
1107
  }
815
- return x(), e.align === "center" ? Et(i) : e.align === "right" ? Ht(i) : e.align === "justify" && Vt(i), i;
1108
+ return _(), e.align === "center" ? $t(i) : e.align === "right" ? Nt(i) : e.align === "justify" && Kt(i), i;
816
1109
  }
817
- function Et(o) {
1110
+ function $t(o) {
818
1111
  for (let e = 0; e < o.lines.length; e++) {
819
1112
  const t = o.lines[e], r = o.width / 2 - t.width / 2;
820
1113
  for (let i = 0; i < t.charPositions.length; i++)
821
1114
  t.charPositions[i] += r;
822
1115
  }
823
1116
  }
824
- function Ht(o) {
1117
+ function Nt(o) {
825
1118
  for (let e = 0; e < o.lines.length; e++) {
826
1119
  const t = o.lines[e], r = o.width - t.width;
827
1120
  for (let i = 0; i < t.charPositions.length; i++)
828
1121
  t.charPositions[i] += r;
829
1122
  }
830
1123
  }
831
- function Vt(o) {
1124
+ function Kt(o) {
832
1125
  const e = o.width;
833
1126
  for (let t = 0; t < o.lines.length; t++) {
834
1127
  const r = o.lines[t];
835
1128
  let i = 0, n = r.spacesIndex[i++], s = 0;
836
- const a = r.spacesIndex.length, c = (e - r.width) / a;
837
- for (let d = 0; d < r.charPositions.length; d++)
838
- d === n && (n = r.spacesIndex[i++], s += c), r.charPositions[d] += s;
1129
+ const a = r.spacesIndex.length, l = (e - r.width) / a;
1130
+ for (let h = 0; h < r.charPositions.length; h++)
1131
+ h === n && (n = r.spacesIndex[i++], s += l), r.charPositions[h] += s;
839
1132
  }
840
1133
  }
841
- function Yt(o) {
1134
+ function jt(o) {
842
1135
  if (o === "")
843
1136
  return [];
844
1137
  typeof o == "string" && (o = [o]);
@@ -853,7 +1146,7 @@ function Yt(o) {
853
1146
  const n = i[0].charCodeAt(0), s = i[1].charCodeAt(0);
854
1147
  if (s < n)
855
1148
  throw new Error("[BitmapFont]: Invalid character range.");
856
- for (let a = n, l = s; a <= l; a++)
1149
+ for (let a = n, u = s; a <= u; a++)
857
1150
  e.push(String.fromCharCode(a));
858
1151
  } else
859
1152
  e.push(...Array.from(i));
@@ -862,8 +1155,8 @@ function Yt(o) {
862
1155
  throw new Error("[BitmapFont]: Empty set when resolving characters.");
863
1156
  return e;
864
1157
  }
865
- let Q = 0;
866
- class Xt {
1158
+ let J = 0;
1159
+ class qt {
867
1160
  constructor() {
868
1161
  this.ALPHA = [["a", "z"], ["A", "Z"], " "], this.NUMERIC = [["0", "9"]], this.ALPHANUMERIC = [["a", "z"], ["A", "Z"], ["0", "9"], " "], this.ASCII = [[" ", "~"]], this.defaultOptions = {
869
1162
  chars: this.ALPHANUMERIC,
@@ -871,7 +1164,7 @@ class Xt {
871
1164
  padding: 4,
872
1165
  skipKerning: !1,
873
1166
  textureStyle: null
874
- };
1167
+ }, this.measureCache = Qe(1e3);
875
1168
  }
876
1169
  /**
877
1170
  * Get a font for the specified text and style.
@@ -881,26 +1174,20 @@ class Xt {
881
1174
  getFont(e, t) {
882
1175
  var s;
883
1176
  let r = `${t.fontFamily}-bitmap`, i = !0;
884
- if (t._fill.fill && !t._stroke)
885
- r += t._fill.fill.styleKey, i = !1;
886
- else if (t._stroke || t.dropShadow) {
887
- let a = t.styleKey;
888
- a = a.substring(0, a.lastIndexOf("-")), r = `${a}-bitmap`, i = !1;
889
- }
890
- if (!G.has(r)) {
1177
+ if (t._fill.fill && !t._stroke ? (r += t._fill.fill.styleKey, i = !1) : (t._stroke || t.dropShadow) && (r = `${t.styleKey}-bitmap`, i = !1), !G.has(r)) {
891
1178
  const a = Object.create(t);
892
1179
  a.lineHeight = 0;
893
- const l = new Pe({
1180
+ const u = new Pe({
894
1181
  style: a,
895
1182
  overrideFill: i,
896
1183
  overrideSize: !0,
897
1184
  ...this.defaultOptions
898
1185
  });
899
- Q++, Q > 50 && ne("BitmapText", `You have dynamically created ${Q} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``), l.once("destroy", () => {
900
- Q--, G.remove(r);
1186
+ J++, J > 50 && K("BitmapText", `You have dynamically created ${J} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``), u.once("destroy", () => {
1187
+ J--, G.remove(r);
901
1188
  }), G.set(
902
1189
  r,
903
- l
1190
+ u
904
1191
  );
905
1192
  }
906
1193
  const n = G.get(r);
@@ -913,8 +1200,11 @@ class Xt {
913
1200
  * @param trimEnd - Whether to ignore whitespaces at the end of each line
914
1201
  */
915
1202
  getLayout(e, t, r = !0) {
916
- const i = this.getFont(e, t), n = D.graphemeSegmenter(e);
917
- return qe(n, t, i, r);
1203
+ const i = this.getFont(e, t), n = `${e}-${t.styleKey}-${r}`;
1204
+ if (this.measureCache.has(n))
1205
+ return this.measureCache.get(n);
1206
+ const s = O.graphemeSegmenter(e), a = et(s, t, i, r);
1207
+ return this.measureCache.set(n, a), a;
918
1208
  }
919
1209
  /**
920
1210
  * Measure the text using the specified style.
@@ -927,16 +1217,16 @@ class Xt {
927
1217
  }
928
1218
  // eslint-disable-next-line max-len
929
1219
  install(...e) {
930
- var c, d, u, h;
1220
+ var l, h, c, d;
931
1221
  let t = e[0];
932
1222
  typeof t == "string" && (t = {
933
1223
  name: t,
934
1224
  style: e[1],
935
- chars: (c = e[2]) == null ? void 0 : c.chars,
936
- resolution: (d = e[2]) == null ? void 0 : d.resolution,
937
- padding: (u = e[2]) == null ? void 0 : u.padding,
938
- skipKerning: (h = e[2]) == null ? void 0 : h.skipKerning
939
- }, U(O, "BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));
1225
+ chars: (l = e[2]) == null ? void 0 : l.chars,
1226
+ resolution: (h = e[2]) == null ? void 0 : h.resolution,
1227
+ padding: (c = e[2]) == null ? void 0 : c.padding,
1228
+ skipKerning: (d = e[2]) == null ? void 0 : d.skipKerning
1229
+ }, z(L, "BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));
940
1230
  const r = t == null ? void 0 : t.name;
941
1231
  if (!r)
942
1232
  throw new Error("[BitmapFontManager] Property `name` is required.");
@@ -949,8 +1239,8 @@ class Xt {
949
1239
  resolution: t.resolution,
950
1240
  overrideSize: !1,
951
1241
  textureStyle: t.textureStyle
952
- }), l = Yt(t.chars);
953
- return a.ensureCharacters(l.join("")), G.set(`${r}-bitmap`, a), a.once("destroy", () => G.remove(`${r}-bitmap`)), a;
1242
+ }), u = jt(t.chars);
1243
+ return a.ensureCharacters(u.join("")), G.set(`${r}-bitmap`, a), a.once("destroy", () => G.remove(`${r}-bitmap`)), a;
954
1244
  }
955
1245
  /**
956
1246
  * Uninstalls a bitmap font from the cache.
@@ -971,8 +1261,108 @@ class Xt {
971
1261
  return !e._stroke && (!e.dropShadow || e.dropShadow.color === 0) && !e._fill.fill && e._fill.color === 16777215;
972
1262
  }
973
1263
  }
974
- const $t = new Xt();
975
- class Ke {
1264
+ const Qt = new qt();
1265
+ var Jt = `in vec2 aPosition;
1266
+ out vec2 vTextureCoord;
1267
+
1268
+ uniform vec4 uInputSize;
1269
+ uniform vec4 uOutputFrame;
1270
+ uniform vec4 uOutputTexture;
1271
+
1272
+ vec4 filterVertexPosition( void )
1273
+ {
1274
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
1275
+
1276
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
1277
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
1278
+
1279
+ return vec4(position, 0.0, 1.0);
1280
+ }
1281
+
1282
+ vec2 filterTextureCoord( void )
1283
+ {
1284
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
1285
+ }
1286
+
1287
+ void main(void)
1288
+ {
1289
+ gl_Position = filterVertexPosition();
1290
+ vTextureCoord = filterTextureCoord();
1291
+ }
1292
+ `, Zt = `in vec2 vTextureCoord;
1293
+ out vec4 finalColor;
1294
+ uniform sampler2D uTexture;
1295
+ void main() {
1296
+ finalColor = texture(uTexture, vTextureCoord);
1297
+ }
1298
+ `, Fe = `struct GlobalFilterUniforms {
1299
+ uInputSize: vec4<f32>,
1300
+ uInputPixel: vec4<f32>,
1301
+ uInputClamp: vec4<f32>,
1302
+ uOutputFrame: vec4<f32>,
1303
+ uGlobalFrame: vec4<f32>,
1304
+ uOutputTexture: vec4<f32>,
1305
+ };
1306
+
1307
+ @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
1308
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
1309
+ @group(0) @binding(2) var uSampler: sampler;
1310
+
1311
+ struct VSOutput {
1312
+ @builtin(position) position: vec4<f32>,
1313
+ @location(0) uv: vec2<f32>
1314
+ };
1315
+
1316
+ fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
1317
+ {
1318
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
1319
+
1320
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
1321
+ position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
1322
+
1323
+ return vec4(position, 0.0, 1.0);
1324
+ }
1325
+
1326
+ fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
1327
+ {
1328
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
1329
+ }
1330
+
1331
+ @vertex
1332
+ fn mainVertex(
1333
+ @location(0) aPosition: vec2<f32>,
1334
+ ) -> VSOutput {
1335
+ return VSOutput(
1336
+ filterVertexPosition(aPosition),
1337
+ filterTextureCoord(aPosition)
1338
+ );
1339
+ }
1340
+
1341
+ @fragment
1342
+ fn mainFragment(
1343
+ @location(0) uv: vec2<f32>,
1344
+ ) -> @location(0) vec4<f32> {
1345
+ return textureSample(uTexture, uSampler, uv);
1346
+ }
1347
+ `;
1348
+ class er extends Ut {
1349
+ constructor() {
1350
+ const e = Le.from({
1351
+ vertex: { source: Fe, entryPoint: "mainVertex" },
1352
+ fragment: { source: Fe, entryPoint: "mainFragment" },
1353
+ name: "passthrough-filter"
1354
+ }), t = Ee.from({
1355
+ vertex: Jt,
1356
+ fragment: Zt,
1357
+ name: "passthrough-filter"
1358
+ });
1359
+ super({
1360
+ gpuProgram: e,
1361
+ glProgram: t
1362
+ });
1363
+ }
1364
+ }
1365
+ class tt {
976
1366
  constructor(e) {
977
1367
  this._renderer = e;
978
1368
  }
@@ -999,24 +1389,28 @@ class Ke {
999
1389
  this._renderer = null;
1000
1390
  }
1001
1391
  }
1002
- Ke.extension = {
1392
+ tt.extension = {
1003
1393
  type: [
1004
- w.WebGLPipes,
1005
- w.WebGPUPipes,
1006
- w.CanvasPipes
1394
+ y.WebGLPipes,
1395
+ y.WebGPUPipes,
1396
+ y.CanvasPipes
1007
1397
  ],
1008
1398
  name: "filter"
1009
1399
  };
1010
- function Nt(o, e) {
1400
+ const Be = new U();
1401
+ function tr(o, e) {
1011
1402
  e.clear();
1012
1403
  const t = e.matrix;
1013
1404
  for (let r = 0; r < o.length; r++) {
1014
1405
  const i = o[r];
1015
- i.globalDisplayStatus < 7 || (e.matrix = i.worldTransform, e.addBounds(i.bounds));
1406
+ if (i.globalDisplayStatus < 7)
1407
+ continue;
1408
+ const n = i.renderGroup ?? i.parentRenderGroup;
1409
+ n != null && n.isCachedAsTexture ? e.matrix = Be.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform) : n != null && n._parentCacheAsTextureRenderGroup ? e.matrix = Be.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform) : e.matrix = i.worldTransform, e.addBounds(i.bounds);
1016
1410
  }
1017
1411
  return e.matrix = t, e;
1018
1412
  }
1019
- const jt = new me({
1413
+ const rr = new me({
1020
1414
  attributes: {
1021
1415
  aPosition: {
1022
1416
  buffer: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
@@ -1027,12 +1421,12 @@ const jt = new me({
1027
1421
  },
1028
1422
  indexBuffer: new Uint32Array([0, 1, 2, 0, 2, 3])
1029
1423
  });
1030
- class qt {
1424
+ class ir {
1031
1425
  constructor() {
1032
- this.skip = !1, this.inputTexture = null, this.backTexture = null, this.filters = null, this.bounds = new Ie(), this.container = null, this.blendRequired = !1, this.outputRenderSurface = null, this.globalFrame = { x: 0, y: 0, width: 0, height: 0 };
1426
+ this.skip = !1, this.inputTexture = null, this.backTexture = null, this.filters = null, this.bounds = new Ve(), this.container = null, this.blendRequired = !1, this.outputRenderSurface = null, this.globalFrame = { x: 0, y: 0, width: 0, height: 0 }, this.firstEnabledIndex = -1, this.lastEnabledIndex = -1;
1033
1427
  }
1034
1428
  }
1035
- class Qe {
1429
+ class rt {
1036
1430
  constructor(e) {
1037
1431
  this._filterStackIndex = 0, this._filterStack = [], this._filterGlobalUniforms = new Y({
1038
1432
  uInputSize: { value: new Float32Array(4), type: "vec4<f32>" },
@@ -1041,7 +1435,7 @@ class Qe {
1041
1435
  uOutputFrame: { value: new Float32Array(4), type: "vec4<f32>" },
1042
1436
  uGlobalFrame: { value: new Float32Array(4), type: "vec4<f32>" },
1043
1437
  uOutputTexture: { value: new Float32Array(4), type: "vec4<f32>" }
1044
- }), this._globalFilterBindGroup = new Le({}), this.renderer = e;
1438
+ }), this._globalFilterBindGroup = new He({}), this.renderer = e;
1045
1439
  }
1046
1440
  /**
1047
1441
  * The back texture of the currently active filter. Requires the filter to have `blendRequired` set to true.
@@ -1060,23 +1454,23 @@ class Qe {
1060
1454
  const t = this.renderer, r = e.filterEffect.filters, i = this._pushFilterData();
1061
1455
  i.skip = !1, i.filters = r, i.container = e.container, i.outputRenderSurface = t.renderTarget.renderSurface;
1062
1456
  const n = t.renderTarget.renderTarget.colorTexture.source, s = n.resolution, a = n.antialias;
1063
- if (r.length === 0) {
1457
+ if (r.every((f) => !f.enabled)) {
1064
1458
  i.skip = !0;
1065
1459
  return;
1066
1460
  }
1067
- const l = i.bounds;
1068
- if (this._calculateFilterArea(e, l), this._calculateFilterBounds(i, t.renderTarget.rootViewPort, a, s, 1), i.skip)
1461
+ const u = i.bounds;
1462
+ if (this._calculateFilterArea(e, u), this._calculateFilterBounds(i, t.renderTarget.rootViewPort, a, s, 1), i.skip)
1069
1463
  return;
1070
- const c = this._getPreviousFilterData(), d = this._findFilterResolution(s);
1071
- let u = 0, h = 0;
1072
- c && (u = c.bounds.minX, h = c.bounds.minY), this._calculateGlobalFrame(
1464
+ const l = this._getPreviousFilterData(), h = this._findFilterResolution(s);
1465
+ let c = 0, d = 0;
1466
+ l && (c = l.bounds.minX, d = l.bounds.minY), this._calculateGlobalFrame(
1073
1467
  i,
1074
- u,
1075
- h,
1468
+ c,
1076
1469
  d,
1470
+ h,
1077
1471
  n.width,
1078
1472
  n.height
1079
- ), this._setupFilterTextures(i, l, t, c);
1473
+ ), this._setupFilterTextures(i, u, t, l);
1080
1474
  }
1081
1475
  /**
1082
1476
  * Applies filters to a texture.
@@ -1109,17 +1503,17 @@ class Qe {
1109
1503
  const r = this._pushFilterData();
1110
1504
  this._activeFilterData = r, r.skip = !1, r.filters = t;
1111
1505
  const i = e.source, n = i.resolution, s = i.antialias;
1112
- if (t.length === 0)
1506
+ if (t.every((f) => !f.enabled))
1113
1507
  return r.skip = !0, e;
1114
1508
  const a = r.bounds;
1115
1509
  if (a.addRect(e.frame), this._calculateFilterBounds(r, a.rectangle, s, n, 0), r.skip)
1116
1510
  return e;
1117
- const l = n;
1511
+ const u = n;
1118
1512
  this._calculateGlobalFrame(
1119
1513
  r,
1120
1514
  0,
1121
1515
  0,
1122
- l,
1516
+ u,
1123
1517
  i.width,
1124
1518
  i.height
1125
1519
  ), r.outputRenderSurface = A.getOptimalTexture(
@@ -1127,9 +1521,9 @@ class Qe {
1127
1521
  a.height,
1128
1522
  r.resolution,
1129
1523
  r.antialias
1130
- ), r.backTexture = R.EMPTY, r.inputTexture = e, this.renderer.renderTarget.finishRenderPass(), this._applyFiltersToTexture(r, !0);
1131
- const h = r.outputRenderSurface;
1132
- return h.source.alphaMode = "premultiplied-alpha", h;
1524
+ ), r.backTexture = M.EMPTY, r.inputTexture = e, this.renderer.renderTarget.finishRenderPass(), this._applyFiltersToTexture(r, !0);
1525
+ const d = r.outputRenderSurface;
1526
+ return d.source.alphaMode = "premultiplied-alpha", d;
1133
1527
  }
1134
1528
  /** @internal */
1135
1529
  pop() {
@@ -1151,12 +1545,12 @@ class Qe {
1151
1545
  );
1152
1546
  let s = t.minX, a = t.minY;
1153
1547
  r && (s -= r.minX, a -= r.minY), s = Math.floor(s * i), a = Math.floor(a * i);
1154
- const l = Math.ceil(t.width * i), c = Math.ceil(t.height * i);
1548
+ const u = Math.ceil(t.width * i), l = Math.ceil(t.height * i);
1155
1549
  return this.renderer.renderTarget.copyToTexture(
1156
1550
  e,
1157
1551
  n,
1158
1552
  { x: s, y: a },
1159
- { width: l, height: c },
1553
+ { width: u, height: l },
1160
1554
  { x: 0, y: 0 }
1161
1555
  ), n;
1162
1556
  }
@@ -1168,13 +1562,15 @@ class Qe {
1168
1562
  * @param clear - Whether to clear the output surface before applying the filter.
1169
1563
  */
1170
1564
  applyFilter(e, t, r, i) {
1171
- const n = this.renderer, s = this._activeFilterData, l = s.outputRenderSurface === r, c = n.renderTarget.rootRenderTarget.colorTexture.source._resolution, d = this._findFilterResolution(c);
1172
- let u = 0, h = 0;
1173
- if (l) {
1174
- const f = this._findPreviousFilterOffset();
1175
- u = f.x, h = f.y;
1565
+ const n = this.renderer, s = this._activeFilterData, u = s.outputRenderSurface === r, l = n.renderTarget.rootRenderTarget.colorTexture.source._resolution, h = this._findFilterResolution(l);
1566
+ let c = 0, d = 0;
1567
+ if (u) {
1568
+ const x = this._findPreviousFilterOffset();
1569
+ c = x.x, d = x.y;
1176
1570
  }
1177
- this._updateFilterUniforms(t, r, s, u, h, d, l, i), this._setupBindGroupsAndRender(e, t, n);
1571
+ this._updateFilterUniforms(t, r, s, c, d, h, u, i);
1572
+ const f = e.enabled ? e : this._getPassthroughFilter();
1573
+ this._setupBindGroupsAndRender(f, t, n);
1178
1574
  }
1179
1575
  /**
1180
1576
  * Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.
@@ -1192,13 +1588,18 @@ class Qe {
1192
1588
  r.inputTexture._source.height,
1193
1589
  r.bounds.minX,
1194
1590
  r.bounds.minY
1195
- ), n = t.worldTransform.copyTo(k.shared), s = t.renderGroup || t.parentRenderGroup;
1591
+ ), n = t.worldTransform.copyTo(U.shared), s = t.renderGroup || t.parentRenderGroup;
1196
1592
  return s && s.cacheToLocalTransform && n.prepend(s.cacheToLocalTransform), n.invert(), i.prepend(n), i.scale(
1197
1593
  1 / t.texture.orig.width,
1198
1594
  1 / t.texture.orig.height
1199
1595
  ), i.translate(t.anchor.x, t.anchor.y), i;
1200
1596
  }
1201
1597
  destroy() {
1598
+ var e;
1599
+ (e = this._passthroughFilter) == null || e.destroy(!0), this._passthroughFilter = null;
1600
+ }
1601
+ _getPassthroughFilter() {
1602
+ return this._passthroughFilter ?? (this._passthroughFilter = new er()), this._passthroughFilter;
1202
1603
  }
1203
1604
  /**
1204
1605
  * Sets up the bind groups and renders the filter.
@@ -1213,7 +1614,7 @@ class Qe {
1213
1614
  } else
1214
1615
  this._globalFilterBindGroup.setResource(this._filterGlobalUniforms, 0);
1215
1616
  this._globalFilterBindGroup.setResource(t.source, 1), this._globalFilterBindGroup.setResource(t.source.style, 2), e.groups[0] = this._globalFilterBindGroup, r.encoder.draw({
1216
- geometry: jt,
1617
+ geometry: rr,
1217
1618
  shader: e,
1218
1619
  state: e._state,
1219
1620
  topology: "triangle-list"
@@ -1227,17 +1628,17 @@ class Qe {
1227
1628
  * @param previousFilterData - The previous filter data for back texture calculation
1228
1629
  */
1229
1630
  _setupFilterTextures(e, t, r, i) {
1230
- if (e.backTexture = R.EMPTY, e.blendRequired) {
1231
- r.renderTarget.finishRenderPass();
1232
- const n = r.renderTarget.getRenderTarget(e.outputRenderSurface);
1233
- e.backTexture = this.getBackTexture(n, t, i == null ? void 0 : i.bounds);
1234
- }
1235
- e.inputTexture = A.getOptimalTexture(
1631
+ if (e.backTexture = M.EMPTY, e.inputTexture = A.getOptimalTexture(
1236
1632
  t.width,
1237
1633
  t.height,
1238
1634
  e.resolution,
1239
1635
  e.antialias
1240
- ), r.renderTarget.bind(e.inputTexture, !0), r.globalUniforms.push({
1636
+ ), e.blendRequired) {
1637
+ r.renderTarget.finishRenderPass();
1638
+ const n = r.renderTarget.getRenderTarget(e.outputRenderSurface);
1639
+ e.backTexture = this.getBackTexture(n, t, i == null ? void 0 : i.bounds);
1640
+ }
1641
+ r.renderTarget.bind(e.inputTexture, !0), r.globalUniforms.push({
1241
1642
  offset: t
1242
1643
  });
1243
1644
  }
@@ -1265,13 +1666,13 @@ class Qe {
1265
1666
  * @param isFinalTarget - Whether this is the final render target
1266
1667
  * @param clear - Whether to clear the output surface
1267
1668
  */
1268
- _updateFilterUniforms(e, t, r, i, n, s, a, l) {
1269
- const c = this._filterGlobalUniforms.uniforms, d = c.uOutputFrame, u = c.uInputSize, h = c.uInputPixel, f = c.uInputClamp, m = c.uGlobalFrame, x = c.uOutputTexture;
1270
- a ? (d[0] = r.bounds.minX - i, d[1] = r.bounds.minY - n) : (d[0] = 0, d[1] = 0), d[2] = e.frame.width, d[3] = e.frame.height, u[0] = e.source.width, u[1] = e.source.height, u[2] = 1 / u[0], u[3] = 1 / u[1], h[0] = e.source.pixelWidth, h[1] = e.source.pixelHeight, h[2] = 1 / h[0], h[3] = 1 / h[1], f[0] = 0.5 * h[2], f[1] = 0.5 * h[3], f[2] = e.frame.width * u[2] - 0.5 * h[2], f[3] = e.frame.height * u[3] - 0.5 * h[3];
1271
- const _ = this.renderer.renderTarget.rootRenderTarget.colorTexture;
1272
- m[0] = i * s, m[1] = n * s, m[2] = _.source.width * s, m[3] = _.source.height * s, t instanceof R && (t.source.resource = null);
1273
- const p = this.renderer.renderTarget.getRenderTarget(t);
1274
- this.renderer.renderTarget.bind(t, !!l), t instanceof R ? (x[0] = t.frame.width, x[1] = t.frame.height) : (x[0] = p.width, x[1] = p.height), x[2] = p.isRoot ? -1 : 1, this._filterGlobalUniforms.update();
1669
+ _updateFilterUniforms(e, t, r, i, n, s, a, u) {
1670
+ const l = this._filterGlobalUniforms.uniforms, h = l.uOutputFrame, c = l.uInputSize, d = l.uInputPixel, f = l.uInputClamp, x = l.uGlobalFrame, _ = l.uOutputTexture;
1671
+ a ? (h[0] = r.bounds.minX - i, h[1] = r.bounds.minY - n) : (h[0] = 0, h[1] = 0), h[2] = e.frame.width, h[3] = e.frame.height, c[0] = e.source.width, c[1] = e.source.height, c[2] = 1 / c[0], c[3] = 1 / c[1], d[0] = e.source.pixelWidth, d[1] = e.source.pixelHeight, d[2] = 1 / d[0], d[3] = 1 / d[1], f[0] = 0.5 * d[2], f[1] = 0.5 * d[3], f[2] = e.frame.width * c[2] - 0.5 * d[2], f[3] = e.frame.height * c[3] - 0.5 * d[3];
1672
+ const v = this.renderer.renderTarget.rootRenderTarget.colorTexture;
1673
+ x[0] = i * s, x[1] = n * s, x[2] = v.source.width * s, x[3] = v.source.height * s, t instanceof M && (t.source.resource = null);
1674
+ const g = this.renderer.renderTarget.getRenderTarget(t);
1675
+ this.renderer.renderTarget.bind(t, !!u), t instanceof M ? (_[0] = t.frame.width, _[1] = t.frame.height) : (_[0] = g.width, _[1] = g.height), _[2] = g.isRoot ? -1 : 1, this._filterGlobalUniforms.update();
1275
1676
  }
1276
1677
  /**
1277
1678
  * Finds the correct resolution by looking back through the filter stack.
@@ -1306,87 +1707,92 @@ class Qe {
1306
1707
  * @param bounds - The bounds object to populate
1307
1708
  */
1308
1709
  _calculateFilterArea(e, t) {
1309
- if (e.renderables ? Nt(e.renderables, t) : e.filterEffect.filterArea ? (t.clear(), t.addRect(e.filterEffect.filterArea), t.applyMatrix(e.container.worldTransform)) : e.container.getFastGlobalBounds(!0, t), e.container) {
1710
+ if (e.renderables ? tr(e.renderables, t) : e.filterEffect.filterArea ? (t.clear(), t.addRect(e.filterEffect.filterArea), t.applyMatrix(e.container.worldTransform)) : e.container.getFastGlobalBounds(!0, t), e.container) {
1310
1711
  const i = (e.container.renderGroup || e.container.parentRenderGroup).cacheToLocalTransform;
1311
1712
  i && t.applyMatrix(i);
1312
1713
  }
1313
1714
  }
1314
1715
  _applyFiltersToTexture(e, t) {
1315
- const r = e.inputTexture, i = e.bounds, n = e.filters;
1316
- if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3), n.length === 1)
1317
- n[0].apply(this, r, e.outputRenderSurface, t);
1716
+ const r = e.inputTexture, i = e.bounds, n = e.filters, s = e.firstEnabledIndex, a = e.lastEnabledIndex;
1717
+ if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3), s === a)
1718
+ n[s].apply(this, r, e.outputRenderSurface, t);
1318
1719
  else {
1319
- let s = e.inputTexture;
1320
- const a = A.getOptimalTexture(
1720
+ let u = e.inputTexture;
1721
+ const l = A.getOptimalTexture(
1321
1722
  i.width,
1322
1723
  i.height,
1323
- s.source._resolution,
1724
+ u.source._resolution,
1324
1725
  !1
1325
1726
  );
1326
- let l = a, c = 0;
1327
- for (c = 0; c < n.length - 1; ++c) {
1328
- n[c].apply(this, s, l, !0);
1329
- const u = s;
1330
- s = l, l = u;
1727
+ let h = l;
1728
+ for (let c = s; c < a; c++) {
1729
+ const d = n[c];
1730
+ if (!d.enabled)
1731
+ continue;
1732
+ d.apply(this, u, h, !0);
1733
+ const f = u;
1734
+ u = h, h = f;
1331
1735
  }
1332
- n[c].apply(this, s, e.outputRenderSurface, t), A.returnTexture(a);
1736
+ n[a].apply(this, u, e.outputRenderSurface, t), A.returnTexture(l);
1333
1737
  }
1334
1738
  }
1335
1739
  _calculateFilterBounds(e, t, r, i, n) {
1336
- var x;
1337
- const s = this.renderer, a = e.bounds, l = e.filters;
1338
- let c = 1 / 0, d = 0, u = !0, h = !1, f = !1, m = !0;
1339
- for (let _ = 0; _ < l.length; _++) {
1340
- const p = l[_];
1341
- if (c = Math.min(c, p.resolution === "inherit" ? i : p.resolution), d += p.padding, p.antialias === "off" ? u = !1 : p.antialias === "inherit" && u && (u = r), p.clipToViewport || (m = !1), !!!(p.compatibleRenderers & s.type)) {
1740
+ var g;
1741
+ const s = this.renderer, a = e.bounds, u = e.filters;
1742
+ let l = 1 / 0, h = 0, c = !0, d = !1, f = !1, x = !0, _ = -1, v = -1;
1743
+ for (let b = 0; b < u.length; b++) {
1744
+ const m = u[b];
1745
+ if (!m.enabled)
1746
+ continue;
1747
+ if (_ === -1 && (_ = b), v = b, l = Math.min(l, m.resolution === "inherit" ? i : m.resolution), h += m.padding, m.antialias === "off" ? c = !1 : m.antialias === "inherit" && c && (c = r), m.clipToViewport || (x = !1), !!!(m.compatibleRenderers & s.type)) {
1342
1748
  f = !1;
1343
1749
  break;
1344
1750
  }
1345
- if (p.blendRequired && !(((x = s.backBuffer) == null ? void 0 : x.useBackBuffer) ?? !0)) {
1346
- ne("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), f = !1;
1751
+ if (m.blendRequired && !(((g = s.backBuffer) == null ? void 0 : g.useBackBuffer) ?? !0)) {
1752
+ K("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), f = !1;
1347
1753
  break;
1348
1754
  }
1349
- f = p.enabled || f, h || (h = p.blendRequired);
1755
+ f = !0, d || (d = m.blendRequired);
1350
1756
  }
1351
1757
  if (!f) {
1352
1758
  e.skip = !0;
1353
1759
  return;
1354
1760
  }
1355
- if (m && a.fitBounds(0, t.width / i, 0, t.height / i), a.scale(c).ceil().scale(1 / c).pad((d | 0) * n), !a.isPositive) {
1761
+ if (x && a.fitBounds(0, t.width / i, 0, t.height / i), a.scale(l).ceil().scale(1 / l).pad((h | 0) * n), !a.isPositive) {
1356
1762
  e.skip = !0;
1357
1763
  return;
1358
1764
  }
1359
- e.antialias = u, e.resolution = c, e.blendRequired = h;
1765
+ e.antialias = c, e.resolution = l, e.blendRequired = d, e.firstEnabledIndex = _, e.lastEnabledIndex = v;
1360
1766
  }
1361
1767
  _popFilterData() {
1362
1768
  return this._filterStackIndex--, this._filterStack[this._filterStackIndex];
1363
1769
  }
1364
1770
  _getPreviousFilterData() {
1365
1771
  let e, t = this._filterStackIndex - 1;
1366
- for (; t > 1 && (t--, e = this._filterStack[t], !!e.skip); )
1772
+ for (; t > 0 && (t--, e = this._filterStack[t], !!e.skip); )
1367
1773
  ;
1368
1774
  return e;
1369
1775
  }
1370
1776
  _pushFilterData() {
1371
1777
  let e = this._filterStack[this._filterStackIndex];
1372
- return e || (e = this._filterStack[this._filterStackIndex] = new qt()), this._filterStackIndex++, e;
1778
+ return e || (e = this._filterStack[this._filterStackIndex] = new ir()), this._filterStackIndex++, e;
1373
1779
  }
1374
1780
  }
1375
- Qe.extension = {
1781
+ rt.extension = {
1376
1782
  type: [
1377
- w.WebGLSystem,
1378
- w.WebGPUSystem
1783
+ y.WebGLSystem,
1784
+ y.WebGPUSystem
1379
1785
  ],
1380
1786
  name: "filter"
1381
1787
  };
1382
- const Je = class Ze extends me {
1788
+ const it = class nt extends me {
1383
1789
  constructor(...e) {
1384
1790
  let t = e[0] ?? {};
1385
- t instanceof Float32Array && (U(O, "use new MeshGeometry({ positions, uvs, indices }) instead"), t = {
1791
+ t instanceof Float32Array && (z(L, "use new MeshGeometry({ positions, uvs, indices }) instead"), t = {
1386
1792
  positions: t,
1387
1793
  uvs: e[1],
1388
1794
  indices: e[2]
1389
- }), t = { ...Ze.defaultOptions, ...t };
1795
+ }), t = { ...nt.defaultOptions, ...t };
1390
1796
  const r = t.positions || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
1391
1797
  let i = t.uvs;
1392
1798
  i || (t.positions ? i = new Float32Array(r.length) : i = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]));
@@ -1394,17 +1800,17 @@ const Je = class Ze extends me {
1394
1800
  data: r,
1395
1801
  label: "attribute-mesh-positions",
1396
1802
  shrinkToFit: s,
1397
- usage: z.VERTEX | z.COPY_DST
1398
- }), l = new N({
1803
+ usage: D.VERTEX | D.COPY_DST
1804
+ }), u = new N({
1399
1805
  data: i,
1400
1806
  label: "attribute-mesh-uvs",
1401
1807
  shrinkToFit: s,
1402
- usage: z.VERTEX | z.COPY_DST
1403
- }), c = new N({
1808
+ usage: D.VERTEX | D.COPY_DST
1809
+ }), l = new N({
1404
1810
  data: n,
1405
1811
  label: "index-mesh-buffer",
1406
1812
  shrinkToFit: s,
1407
- usage: z.INDEX | z.COPY_DST
1813
+ usage: D.INDEX | D.COPY_DST
1408
1814
  });
1409
1815
  super({
1410
1816
  attributes: {
@@ -1415,13 +1821,13 @@ const Je = class Ze extends me {
1415
1821
  offset: 0
1416
1822
  },
1417
1823
  aUV: {
1418
- buffer: l,
1824
+ buffer: u,
1419
1825
  format: "float32x2",
1420
1826
  stride: 8,
1421
1827
  offset: 0
1422
1828
  }
1423
1829
  },
1424
- indexBuffer: c,
1830
+ indexBuffer: l,
1425
1831
  topology: t.topology
1426
1832
  }), this.batchMode = "auto";
1427
1833
  }
@@ -1459,35 +1865,35 @@ const Je = class Ze extends me {
1459
1865
  this.indexBuffer.data = e;
1460
1866
  }
1461
1867
  };
1462
- Je.defaultOptions = {
1868
+ it.defaultOptions = {
1463
1869
  topology: "triangle-list",
1464
1870
  shrinkBuffersToFit: !1
1465
1871
  };
1466
- let ye = Je, E = null, I = null;
1467
- function Kt(o, e) {
1468
- E || (E = H.get().createCanvas(256, 128), I = E.getContext("2d", { willReadFrequently: !0 }), I.globalCompositeOperation = "copy", I.globalAlpha = 1), (E.width < o || E.height < e) && (E.width = Se(o), E.height = Se(e));
1872
+ let be = it, E = null, W = null;
1873
+ function nr(o, e) {
1874
+ E || (E = H.get().createCanvas(256, 128), W = E.getContext("2d", { willReadFrequently: !0 }), W.globalCompositeOperation = "copy", W.globalAlpha = 1), (E.width < o || E.height < e) && (E.width = Se(o), E.height = Se(e));
1469
1875
  }
1470
- function Fe(o, e, t) {
1876
+ function Re(o, e, t) {
1471
1877
  for (let r = 0, i = 4 * t * e; r < e; ++r, i += 4)
1472
1878
  if (o[i + 3] !== 0)
1473
1879
  return !1;
1474
1880
  return !0;
1475
1881
  }
1476
- function Be(o, e, t, r, i) {
1882
+ function Me(o, e, t, r, i) {
1477
1883
  const n = 4 * e;
1478
1884
  for (let s = r, a = r * n + 4 * t; s <= i; ++s, a += n)
1479
1885
  if (o[a + 3] !== 0)
1480
1886
  return !1;
1481
1887
  return !0;
1482
1888
  }
1483
- function Qt(...o) {
1889
+ function sr(...o) {
1484
1890
  let e = o[0];
1485
1891
  e.canvas || (e = { canvas: o[0], resolution: o[1] });
1486
1892
  const { canvas: t } = e, r = Math.min(e.resolution ?? 1, 1), i = e.width ?? t.width, n = e.height ?? t.height;
1487
1893
  let s = e.output;
1488
- if (Kt(i, n), !I)
1894
+ if (nr(i, n), !W)
1489
1895
  throw new TypeError("Failed to get canvas 2D context");
1490
- I.drawImage(
1896
+ W.drawImage(
1491
1897
  t,
1492
1898
  0,
1493
1899
  0,
@@ -1498,22 +1904,22 @@ function Qt(...o) {
1498
1904
  i * r,
1499
1905
  n * r
1500
1906
  );
1501
- const l = I.getImageData(0, 0, i, n).data;
1502
- let c = 0, d = 0, u = i - 1, h = n - 1;
1503
- for (; d < n && Fe(l, i, d); )
1504
- ++d;
1505
- if (d === n)
1506
- return Z.EMPTY;
1507
- for (; Fe(l, i, h); )
1508
- --h;
1509
- for (; Be(l, i, c, d, h); )
1510
- ++c;
1511
- for (; Be(l, i, u, d, h); )
1512
- --u;
1513
- return ++u, ++h, I.globalCompositeOperation = "source-over", I.strokeRect(c, d, u - c, h - d), I.globalCompositeOperation = "copy", s ?? (s = new Z()), s.set(c / r, d / r, (u - c) / r, (h - d) / r), s;
1514
- }
1515
- const Me = new Z();
1516
- class Jt {
1907
+ const u = W.getImageData(0, 0, i, n).data;
1908
+ let l = 0, h = 0, c = i - 1, d = n - 1;
1909
+ for (; h < n && Re(u, i, h); )
1910
+ ++h;
1911
+ if (h === n)
1912
+ return ee.EMPTY;
1913
+ for (; Re(u, i, d); )
1914
+ --d;
1915
+ for (; Me(u, i, l, h, d); )
1916
+ ++l;
1917
+ for (; Me(u, i, c, h, d); )
1918
+ --c;
1919
+ return ++c, ++d, W.globalCompositeOperation = "source-over", W.strokeRect(l, h, c - l, d - h), W.globalCompositeOperation = "copy", s ?? (s = new ee()), s.set(l / r, h / r, (c - l) / r, (d - h) / r), s;
1920
+ }
1921
+ const Ue = new ee();
1922
+ class ar {
1517
1923
  /**
1518
1924
  * Creates a canvas with the specified text rendered to it.
1519
1925
  *
@@ -1530,12 +1936,12 @@ class Jt {
1530
1936
  * @returns An object containing the canvas/context and the frame (bounds) of the text
1531
1937
  */
1532
1938
  getCanvasAndContext(e) {
1533
- const { text: t, style: r, resolution: i = 1 } = e, n = r._getFinalPadding(), s = D.measureText(t || " ", r), a = Math.ceil(Math.ceil(Math.max(1, s.width) + n * 2) * i), l = Math.ceil(Math.ceil(Math.max(1, s.height) + n * 2) * i), c = X.getOptimalCanvasAndContext(a, l);
1534
- this._renderTextToCanvas(t, r, n, i, c);
1535
- const d = r.trim ? Qt({ canvas: c.canvas, width: a, height: l, resolution: 1, output: Me }) : Me.set(0, 0, a, l);
1939
+ const { text: t, style: r, resolution: i = 1 } = e, n = r._getFinalPadding(), s = O.measureText(t || " ", r), a = Math.ceil(Math.ceil(Math.max(1, s.width) + n * 2) * i), u = Math.ceil(Math.ceil(Math.max(1, s.height) + n * 2) * i), l = X.getOptimalCanvasAndContext(a, u);
1940
+ this._renderTextToCanvas(t, r, n, i, l);
1941
+ const h = r.trim ? sr({ canvas: l.canvas, width: a, height: u, resolution: 1, output: Ue }) : Ue.set(0, 0, a, u);
1536
1942
  return {
1537
- canvasAndContext: c,
1538
- frame: d
1943
+ canvasAndContext: l,
1944
+ frame: h
1539
1945
  };
1540
1946
  }
1541
1947
  /**
@@ -1557,47 +1963,47 @@ class Jt {
1557
1963
  * @param canvasAndContext - The canvas and context to render the text to
1558
1964
  */
1559
1965
  _renderTextToCanvas(e, t, r, i, n) {
1560
- var y, T, S, B;
1561
- const { canvas: s, context: a } = n, l = re(t), c = D.measureText(e || " ", t), d = c.lines, u = c.lineHeight, h = c.lineWidths, f = c.maxLineWidth, m = c.fontProperties, x = s.height;
1562
- if (a.resetTransform(), a.scale(i, i), a.textBaseline = t.textBaseline, (y = t._stroke) != null && y.width) {
1563
- const v = t._stroke;
1564
- a.lineWidth = v.width, a.miterLimit = v.miterLimit, a.lineJoin = v.join, a.lineCap = v.cap;
1966
+ var m, T, S, B;
1967
+ const { canvas: s, context: a } = n, u = ie(t), l = O.measureText(e || " ", t), h = l.lines, c = l.lineHeight, d = l.lineWidths, f = l.maxLineWidth, x = l.fontProperties, _ = s.height;
1968
+ if (a.resetTransform(), a.scale(i, i), a.textBaseline = t.textBaseline, (m = t._stroke) != null && m.width) {
1969
+ const w = t._stroke;
1970
+ a.lineWidth = w.width, a.miterLimit = w.miterLimit, a.lineJoin = w.join, a.lineCap = w.cap;
1565
1971
  }
1566
- a.font = l;
1567
- let _, p;
1972
+ a.font = u;
1973
+ let v, g;
1568
1974
  const b = t.dropShadow ? 2 : 1;
1569
- for (let v = 0; v < b; ++v) {
1570
- const F = t.dropShadow && v === 0, M = F ? Math.ceil(Math.max(1, x) + r * 2) : 0, ae = M * i;
1975
+ for (let w = 0; w < b; ++w) {
1976
+ const F = t.dropShadow && w === 0, R = F ? Math.ceil(Math.max(1, _) + r * 2) : 0, ae = R * i;
1571
1977
  if (F) {
1572
1978
  a.fillStyle = "black", a.strokeStyle = "black";
1573
- const C = t.dropShadow, _t = C.color, bt = C.alpha;
1574
- a.shadowColor = V.shared.setValue(_t).setAlpha(bt).toRgbaString();
1575
- const yt = C.blur * i, Te = C.distance * i;
1576
- a.shadowBlur = yt, a.shadowOffsetX = Math.cos(C.angle) * Te, a.shadowOffsetY = Math.sin(C.angle) * Te + ae;
1979
+ const C = t.dropShadow, wt = C.color, St = C.alpha;
1980
+ a.shadowColor = V.shared.setValue(wt).setAlpha(St).toRgbaString();
1981
+ const Ct = C.blur * i, Te = C.distance * i;
1982
+ a.shadowBlur = Ct, a.shadowOffsetX = Math.cos(C.angle) * Te, a.shadowOffsetY = Math.sin(C.angle) * Te + ae;
1577
1983
  } else {
1578
- if (a.fillStyle = t._fill ? ie(t._fill, a, c, r * 2) : null, (T = t._stroke) != null && T.width) {
1984
+ if (a.fillStyle = t._fill ? ne(t._fill, a, l, r * 2) : null, (T = t._stroke) != null && T.width) {
1579
1985
  const C = t._stroke.width * 0.5 + r * 2;
1580
- a.strokeStyle = ie(t._stroke, a, c, C);
1986
+ a.strokeStyle = ne(t._stroke, a, l, C);
1581
1987
  }
1582
1988
  a.shadowColor = "black";
1583
1989
  }
1584
- let L = (u - m.fontSize) / 2;
1585
- u - m.fontSize < 0 && (L = 0);
1990
+ let I = (c - x.fontSize) / 2;
1991
+ c - x.fontSize < 0 && (I = 0);
1586
1992
  const $ = ((S = t._stroke) == null ? void 0 : S.width) ?? 0;
1587
- for (let C = 0; C < d.length; C++)
1588
- _ = $ / 2, p = $ / 2 + C * u + m.ascent + L, t.align === "right" ? _ += f - h[C] : t.align === "center" && (_ += (f - h[C]) / 2), (B = t._stroke) != null && B.width && this._drawLetterSpacing(
1589
- d[C],
1993
+ for (let C = 0; C < h.length; C++)
1994
+ v = $ / 2, g = $ / 2 + C * c + x.ascent + I, t.align === "right" ? v += f - d[C] : t.align === "center" && (v += (f - d[C]) / 2), (B = t._stroke) != null && B.width && this._drawLetterSpacing(
1995
+ h[C],
1590
1996
  t,
1591
1997
  n,
1592
- _ + r,
1593
- p + r - M,
1998
+ v + r,
1999
+ g + r - R,
1594
2000
  !0
1595
2001
  ), t._fill !== void 0 && this._drawLetterSpacing(
1596
- d[C],
2002
+ h[C],
1597
2003
  t,
1598
2004
  n,
1599
- _ + r,
1600
- p + r - M
2005
+ v + r,
2006
+ g + r - R
1601
2007
  );
1602
2008
  }
1603
2009
  }
@@ -1619,59 +2025,62 @@ class Jt {
1619
2025
  * @private
1620
2026
  */
1621
2027
  _drawLetterSpacing(e, t, r, i, n, s = !1) {
1622
- const { context: a } = r, l = t.letterSpacing;
1623
- let c = !1;
1624
- if (D.experimentalLetterSpacingSupported && (D.experimentalLetterSpacing ? (a.letterSpacing = `${l}px`, a.textLetterSpacing = `${l}px`, c = !0) : (a.letterSpacing = "0px", a.textLetterSpacing = "0px")), l === 0 || c) {
2028
+ const { context: a } = r, u = t.letterSpacing;
2029
+ let l = !1;
2030
+ if (O.experimentalLetterSpacingSupported && (O.experimentalLetterSpacing ? (a.letterSpacing = `${u}px`, a.textLetterSpacing = `${u}px`, l = !0) : (a.letterSpacing = "0px", a.textLetterSpacing = "0px")), u === 0 || l) {
1625
2031
  s ? a.strokeText(e, i, n) : a.fillText(e, i, n);
1626
2032
  return;
1627
2033
  }
1628
- let d = i;
1629
- const u = D.graphemeSegmenter(e);
1630
- let h = a.measureText(e).width, f = 0;
1631
- for (let m = 0; m < u.length; ++m) {
1632
- const x = u[m];
1633
- s ? a.strokeText(x, d, n) : a.fillText(x, d, n);
1634
- let _ = "";
1635
- for (let p = m + 1; p < u.length; ++p)
1636
- _ += u[p];
1637
- f = a.measureText(_).width, d += h - f + l, h = f;
2034
+ let h = i;
2035
+ const c = O.graphemeSegmenter(e);
2036
+ let d = a.measureText(e).width, f = 0;
2037
+ for (let x = 0; x < c.length; ++x) {
2038
+ const _ = c[x];
2039
+ s ? a.strokeText(_, h, n) : a.fillText(_, h, n);
2040
+ let v = "";
2041
+ for (let g = x + 1; g < c.length; ++g)
2042
+ v += c[g];
2043
+ f = a.measureText(v).width, h += d - f + u, d = f;
1638
2044
  }
1639
2045
  }
1640
2046
  }
1641
- const le = new Jt(), Re = "http://www.w3.org/2000/svg", Ue = "http://www.w3.org/1999/xhtml";
1642
- class et {
2047
+ const ue = new ar(), ze = "http://www.w3.org/2000/svg", ke = "http://www.w3.org/1999/xhtml";
2048
+ class st {
1643
2049
  constructor() {
1644
- this.svgRoot = document.createElementNS(Re, "svg"), this.foreignObject = document.createElementNS(Re, "foreignObject"), this.domElement = document.createElementNS(Ue, "div"), this.styleElement = document.createElementNS(Ue, "style");
2050
+ this.svgRoot = document.createElementNS(ze, "svg"), this.foreignObject = document.createElementNS(ze, "foreignObject"), this.domElement = document.createElementNS(ke, "div"), this.styleElement = document.createElementNS(ke, "style");
1645
2051
  const { foreignObject: e, svgRoot: t, styleElement: r, domElement: i } = this;
1646
2052
  e.setAttribute("width", "10000"), e.setAttribute("height", "10000"), e.style.overflow = "hidden", t.appendChild(e), e.appendChild(r), e.appendChild(i), this.image = H.get().createImage();
1647
2053
  }
2054
+ destroy() {
2055
+ this.svgRoot.remove(), this.foreignObject.remove(), this.styleElement.remove(), this.domElement.remove(), this.image.src = "", this.image.remove(), this.svgRoot = null, this.foreignObject = null, this.styleElement = null, this.domElement = null, this.image = null, this.canvasAndContext = null;
2056
+ }
1648
2057
  }
1649
- let ke;
1650
- function Zt(o, e, t, r) {
1651
- r || (r = ke || (ke = new et()));
2058
+ let Ge;
2059
+ function or(o, e, t, r) {
2060
+ r || (r = Ge || (Ge = new st()));
1652
2061
  const { domElement: i, styleElement: n, svgRoot: s } = r;
1653
2062
  i.innerHTML = `<style>${e.cssStyle};</style><div style='padding:0'>${o}</div>`, i.setAttribute("style", "transform-origin: top left; display: inline-block"), t && (n.textContent = t), document.body.appendChild(s);
1654
2063
  const a = i.getBoundingClientRect();
1655
2064
  s.remove();
1656
- const l = e.padding * 2;
2065
+ const u = e.padding * 2;
1657
2066
  return {
1658
- width: a.width - l,
1659
- height: a.height - l
2067
+ width: a.width - u,
2068
+ height: a.height - u
1660
2069
  };
1661
2070
  }
1662
- class er {
2071
+ class ur {
1663
2072
  constructor() {
1664
2073
  this.batches = [], this.batched = !1;
1665
2074
  }
1666
2075
  destroy() {
1667
2076
  this.batches.forEach((e) => {
1668
- te.return(e);
2077
+ re.return(e);
1669
2078
  }), this.batches.length = 0;
1670
2079
  }
1671
2080
  }
1672
- class tt {
2081
+ class at {
1673
2082
  constructor(e, t) {
1674
- this.state = ee.for2d(), this.renderer = e, this._adaptor = t, this.renderer.runners.contextChange.add(this);
2083
+ this.state = te.for2d(), this.renderer = e, this._adaptor = t, this.renderer.runners.contextChange.add(this);
1675
2084
  }
1676
2085
  contextChange() {
1677
2086
  this._adaptor.contextChange(this.renderer);
@@ -1721,13 +2130,13 @@ class tt {
1721
2130
  return e._gpuData[this.renderer.uid] || this._initGpuDataForRenderable(e);
1722
2131
  }
1723
2132
  _initGpuDataForRenderable(e) {
1724
- const t = new er();
2133
+ const t = new ur();
1725
2134
  return e._gpuData[this.renderer.uid] = t, t;
1726
2135
  }
1727
2136
  _updateBatchesForRenderable(e, t) {
1728
2137
  const r = e.context, i = this.renderer.graphicsContext.getGpuContext(r), n = this.renderer._roundPixels | e._roundPixels;
1729
2138
  t.batches = i.batches.map((s) => {
1730
- const a = te.get(Pt);
2139
+ const a = re.get(zt);
1731
2140
  return s.copyTo(a), a.renderable = e, a.roundPixels = n, a;
1732
2141
  });
1733
2142
  }
@@ -1735,19 +2144,19 @@ class tt {
1735
2144
  this.renderer = null, this._adaptor.destroy(), this._adaptor = null, this.state = null;
1736
2145
  }
1737
2146
  }
1738
- tt.extension = {
2147
+ at.extension = {
1739
2148
  type: [
1740
- w.WebGLPipes,
1741
- w.WebGPUPipes,
1742
- w.CanvasPipes
2149
+ y.WebGLPipes,
2150
+ y.WebGPUPipes,
2151
+ y.CanvasPipes
1743
2152
  ],
1744
2153
  name: "graphics"
1745
2154
  };
1746
- const rt = class it extends ye {
2155
+ const ot = class ut extends be {
1747
2156
  constructor(...e) {
1748
2157
  super({});
1749
2158
  let t = e[0] ?? {};
1750
- typeof t == "number" && (U(O, "PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"), t = {
2159
+ typeof t == "number" && (z(L, "PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"), t = {
1751
2160
  width: t,
1752
2161
  height: e[1],
1753
2162
  verticesX: e[2],
@@ -1759,35 +2168,35 @@ const rt = class it extends ye {
1759
2168
  * @param options - Options to be applied to plane geometry
1760
2169
  */
1761
2170
  build(e) {
1762
- e = { ...it.defaultOptions, ...e }, this.verticesX = this.verticesX ?? e.verticesX, this.verticesY = this.verticesY ?? e.verticesY, this.width = this.width ?? e.width, this.height = this.height ?? e.height;
1763
- const t = this.verticesX * this.verticesY, r = [], i = [], n = [], s = this.verticesX - 1, a = this.verticesY - 1, l = this.width / s, c = this.height / a;
1764
- for (let u = 0; u < t; u++) {
1765
- const h = u % this.verticesX, f = u / this.verticesX | 0;
1766
- r.push(h * l, f * c), i.push(h / s, f / a);
2171
+ e = { ...ut.defaultOptions, ...e }, this.verticesX = this.verticesX ?? e.verticesX, this.verticesY = this.verticesY ?? e.verticesY, this.width = this.width ?? e.width, this.height = this.height ?? e.height;
2172
+ const t = this.verticesX * this.verticesY, r = [], i = [], n = [], s = this.verticesX - 1, a = this.verticesY - 1, u = this.width / s, l = this.height / a;
2173
+ for (let c = 0; c < t; c++) {
2174
+ const d = c % this.verticesX, f = c / this.verticesX | 0;
2175
+ r.push(d * u, f * l), i.push(d / s, f / a);
1767
2176
  }
1768
- const d = s * a;
1769
- for (let u = 0; u < d; u++) {
1770
- const h = u % s, f = u / s | 0, m = f * this.verticesX + h, x = f * this.verticesX + h + 1, _ = (f + 1) * this.verticesX + h, p = (f + 1) * this.verticesX + h + 1;
2177
+ const h = s * a;
2178
+ for (let c = 0; c < h; c++) {
2179
+ const d = c % s, f = c / s | 0, x = f * this.verticesX + d, _ = f * this.verticesX + d + 1, v = (f + 1) * this.verticesX + d, g = (f + 1) * this.verticesX + d + 1;
1771
2180
  n.push(
1772
- m,
1773
2181
  x,
1774
2182
  _,
1775
- x,
1776
- p,
1777
- _
2183
+ v,
2184
+ _,
2185
+ g,
2186
+ v
1778
2187
  );
1779
2188
  }
1780
2189
  this.buffers[0].data = new Float32Array(r), this.buffers[1].data = new Float32Array(i), this.indexBuffer.data = new Uint32Array(n), this.buffers[0].update(), this.buffers[1].update(), this.indexBuffer.update();
1781
2190
  }
1782
2191
  };
1783
- rt.defaultOptions = {
2192
+ ot.defaultOptions = {
1784
2193
  width: 100,
1785
2194
  height: 100,
1786
2195
  verticesX: 10,
1787
2196
  verticesY: 10
1788
2197
  };
1789
- let tr = rt;
1790
- class we {
2198
+ let lr = ot;
2199
+ class ye {
1791
2200
  constructor() {
1792
2201
  this.batcherName = "default", this.packAsQuad = !1, this.indexOffset = 0, this.attributeOffset = 0, this.roundPixels = 0, this._batcher = null, this._batch = null, this._textureMatrixUpdateId = -1, this._uvUpdateId = -1;
1793
2202
  }
@@ -1837,17 +2246,17 @@ class we {
1837
2246
  return this.geometry.indices.length;
1838
2247
  }
1839
2248
  }
1840
- class Ge {
2249
+ class Ae {
1841
2250
  destroy() {
1842
2251
  }
1843
2252
  }
1844
- class nt {
2253
+ class lt {
1845
2254
  constructor(e, t) {
1846
2255
  this.localUniforms = new Y({
1847
- uTransformMatrix: { value: new k(), type: "mat3x3<f32>" },
2256
+ uTransformMatrix: { value: new U(), type: "mat3x3<f32>" },
1848
2257
  uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
1849
2258
  uRound: { value: 0, type: "f32" }
1850
- }), this.localUniformsBindGroup = new Le({
2259
+ }), this.localUniformsBindGroup = new He({
1851
2260
  0: this.localUniforms
1852
2261
  }), this.renderer = e, this._adaptor = t, this._adaptor.init();
1853
2262
  }
@@ -1895,7 +2304,7 @@ class nt {
1895
2304
  }
1896
2305
  _getMeshData(e) {
1897
2306
  var t, r;
1898
- return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new Ge()), e._gpuData[this.renderer.uid].meshData || this._initMeshData(e);
2307
+ return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new Ae()), e._gpuData[this.renderer.uid].meshData || this._initMeshData(e);
1899
2308
  }
1900
2309
  _initMeshData(e) {
1901
2310
  return e._gpuData[this.renderer.uid].meshData = {
@@ -1906,35 +2315,35 @@ class nt {
1906
2315
  }
1907
2316
  _getBatchableMesh(e) {
1908
2317
  var t, r;
1909
- return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new Ge()), e._gpuData[this.renderer.uid].batchableMesh || this._initBatchableMesh(e);
2318
+ return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new Ae()), e._gpuData[this.renderer.uid].batchableMesh || this._initBatchableMesh(e);
1910
2319
  }
1911
2320
  _initBatchableMesh(e) {
1912
- const t = new we();
2321
+ const t = new ye();
1913
2322
  return t.renderable = e, t.setTexture(e._texture), t.transform = e.groupTransform, t.roundPixels = this.renderer._roundPixels | e._roundPixels, e._gpuData[this.renderer.uid].batchableMesh = t, t;
1914
2323
  }
1915
2324
  destroy() {
1916
2325
  this.localUniforms = null, this.localUniformsBindGroup = null, this._adaptor.destroy(), this._adaptor = null, this.renderer = null;
1917
2326
  }
1918
2327
  }
1919
- nt.extension = {
2328
+ lt.extension = {
1920
2329
  type: [
1921
- w.WebGLPipes,
1922
- w.WebGPUPipes,
1923
- w.CanvasPipes
2330
+ y.WebGLPipes,
2331
+ y.WebGPUPipes,
2332
+ y.CanvasPipes
1924
2333
  ],
1925
2334
  name: "mesh"
1926
2335
  };
1927
- class rr {
2336
+ class cr {
1928
2337
  execute(e, t) {
1929
2338
  const r = e.state, i = e.renderer, n = t.shader || e.defaultShader;
1930
2339
  n.resources.uTexture = t.texture._source, n.resources.uniforms = e.localUniforms;
1931
2340
  const s = i.gl, a = e.getBuffers(t);
1932
2341
  i.shader.bind(n), i.state.set(r), i.geometry.bind(a.geometry, n.glProgram);
1933
- const c = a.geometry.indexBuffer.data.BYTES_PER_ELEMENT === 2 ? s.UNSIGNED_SHORT : s.UNSIGNED_INT;
1934
- s.drawElements(s.TRIANGLES, t.particleChildren.length * 6, c, 0);
2342
+ const l = a.geometry.indexBuffer.data.BYTES_PER_ELEMENT === 2 ? s.UNSIGNED_SHORT : s.UNSIGNED_INT;
2343
+ s.drawElements(s.TRIANGLES, t.particleChildren.length * 6, l, 0);
1935
2344
  }
1936
2345
  }
1937
- class ir {
2346
+ class hr {
1938
2347
  execute(e, t) {
1939
2348
  const r = e.renderer, i = t.shader || e.defaultShader;
1940
2349
  i.groups[0] = r.renderPipes.uniformBatch.getUniformBindGroup(e.localUniforms, !0), i.groups[1] = r.texture.getTextureBindGroup(t.texture);
@@ -1947,7 +2356,7 @@ class ir {
1947
2356
  });
1948
2357
  }
1949
2358
  }
1950
- function Ae(o, e = null) {
2359
+ function De(o, e = null) {
1951
2360
  const t = o * 6;
1952
2361
  if (t > 65535 ? e || (e = new Uint32Array(t)) : e || (e = new Uint16Array(t)), e.length !== t)
1953
2362
  throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);
@@ -1955,13 +2364,13 @@ function Ae(o, e = null) {
1955
2364
  e[r + 0] = i + 0, e[r + 1] = i + 1, e[r + 2] = i + 2, e[r + 3] = i + 0, e[r + 4] = i + 2, e[r + 5] = i + 3;
1956
2365
  return e;
1957
2366
  }
1958
- function nr(o) {
2367
+ function dr(o) {
1959
2368
  return {
1960
- dynamicUpdate: ze(o, !0),
1961
- staticUpdate: ze(o, !1)
2369
+ dynamicUpdate: Oe(o, !0),
2370
+ staticUpdate: Oe(o, !1)
1962
2371
  };
1963
2372
  }
1964
- function ze(o, e) {
2373
+ function Oe(o, e) {
1965
2374
  const t = [];
1966
2375
  t.push(`
1967
2376
 
@@ -1991,56 +2400,56 @@ function ze(o, e) {
1991
2400
  `);
1992
2401
  return new Function("ps", "f32v", "u32v", i);
1993
2402
  }
1994
- class sr {
2403
+ class fr {
1995
2404
  constructor(e) {
1996
2405
  this._size = 0, this._generateParticleUpdateCache = {};
1997
2406
  const t = this._size = e.size ?? 1e3, r = e.properties;
1998
2407
  let i = 0, n = 0;
1999
- for (const d in r) {
2000
- const u = r[d], h = pe(u.format);
2001
- u.dynamic ? n += h.stride : i += h.stride;
2408
+ for (const h in r) {
2409
+ const c = r[h], d = pe(c.format);
2410
+ c.dynamic ? n += d.stride : i += d.stride;
2002
2411
  }
2003
- this._dynamicStride = n / 4, this._staticStride = i / 4, this.staticAttributeBuffer = new K(t * 4 * i), this.dynamicAttributeBuffer = new K(t * 4 * n), this.indexBuffer = Ae(t);
2412
+ this._dynamicStride = n / 4, this._staticStride = i / 4, this.staticAttributeBuffer = new Q(t * 4 * i), this.dynamicAttributeBuffer = new Q(t * 4 * n), this.indexBuffer = De(t);
2004
2413
  const s = new me();
2005
- let a = 0, l = 0;
2414
+ let a = 0, u = 0;
2006
2415
  this._staticBuffer = new N({
2007
2416
  data: new Float32Array(1),
2008
2417
  label: "static-particle-buffer",
2009
2418
  shrinkToFit: !1,
2010
- usage: z.VERTEX | z.COPY_DST
2419
+ usage: D.VERTEX | D.COPY_DST
2011
2420
  }), this._dynamicBuffer = new N({
2012
2421
  data: new Float32Array(1),
2013
2422
  label: "dynamic-particle-buffer",
2014
2423
  shrinkToFit: !1,
2015
- usage: z.VERTEX | z.COPY_DST
2424
+ usage: D.VERTEX | D.COPY_DST
2016
2425
  });
2017
- for (const d in r) {
2018
- const u = r[d], h = pe(u.format);
2019
- u.dynamic ? (s.addAttribute(u.attributeName, {
2426
+ for (const h in r) {
2427
+ const c = r[h], d = pe(c.format);
2428
+ c.dynamic ? (s.addAttribute(c.attributeName, {
2020
2429
  buffer: this._dynamicBuffer,
2021
2430
  stride: this._dynamicStride * 4,
2022
2431
  offset: a * 4,
2023
- format: u.format
2024
- }), a += h.size) : (s.addAttribute(u.attributeName, {
2432
+ format: c.format
2433
+ }), a += d.size) : (s.addAttribute(c.attributeName, {
2025
2434
  buffer: this._staticBuffer,
2026
2435
  stride: this._staticStride * 4,
2027
- offset: l * 4,
2028
- format: u.format
2029
- }), l += h.size);
2436
+ offset: u * 4,
2437
+ format: c.format
2438
+ }), u += d.size);
2030
2439
  }
2031
2440
  s.addIndex(this.indexBuffer);
2032
- const c = this.getParticleUpdate(r);
2033
- this._dynamicUpload = c.dynamicUpdate, this._staticUpload = c.staticUpdate, this.geometry = s;
2441
+ const l = this.getParticleUpdate(r);
2442
+ this._dynamicUpload = l.dynamicUpdate, this._staticUpload = l.staticUpdate, this.geometry = s;
2034
2443
  }
2035
2444
  getParticleUpdate(e) {
2036
- const t = ar(e);
2445
+ const t = pr(e);
2037
2446
  return this._generateParticleUpdateCache[t] ? this._generateParticleUpdateCache[t] : (this._generateParticleUpdateCache[t] = this.generateParticleUpdate(e), this._generateParticleUpdateCache[t]);
2038
2447
  }
2039
2448
  generateParticleUpdate(e) {
2040
- return nr(e);
2449
+ return dr(e);
2041
2450
  }
2042
2451
  update(e, t) {
2043
- e.length > this._size && (t = !0, this._size = Math.max(e.length, this._size * 1.5 | 0), this.staticAttributeBuffer = new K(this._size * this._staticStride * 4 * 4), this.dynamicAttributeBuffer = new K(this._size * this._dynamicStride * 4 * 4), this.indexBuffer = Ae(this._size), this.geometry.indexBuffer.setDataWithSize(
2452
+ e.length > this._size && (t = !0, this._size = Math.max(e.length, this._size * 1.5 | 0), this.staticAttributeBuffer = new Q(this._size * this._staticStride * 4 * 4), this.dynamicAttributeBuffer = new Q(this._size * this._dynamicStride * 4 * 4), this.indexBuffer = De(this._size), this.geometry.indexBuffer.setDataWithSize(
2044
2453
  this.indexBuffer,
2045
2454
  this.indexBuffer.byteLength,
2046
2455
  !0
@@ -2063,7 +2472,7 @@ class sr {
2063
2472
  this._staticBuffer.destroy(), this._dynamicBuffer.destroy(), this.geometry.destroy();
2064
2473
  }
2065
2474
  }
2066
- function ar(o) {
2475
+ function pr(o) {
2067
2476
  const e = [];
2068
2477
  for (const t in o) {
2069
2478
  const r = o[t];
@@ -2071,7 +2480,7 @@ function ar(o) {
2071
2480
  }
2072
2481
  return e.join("_");
2073
2482
  }
2074
- var or = `varying vec2 vUV;
2483
+ var gr = `varying vec2 vUV;
2075
2484
  varying vec4 vColor;
2076
2485
 
2077
2486
  uniform sampler2D uTexture;
@@ -2079,7 +2488,7 @@ uniform sampler2D uTexture;
2079
2488
  void main(void){
2080
2489
  vec4 color = texture2D(uTexture, vUV) * vColor;
2081
2490
  gl_FragColor = color;
2082
- }`, lr = `attribute vec2 aVertex;
2491
+ }`, mr = `attribute vec2 aVertex;
2083
2492
  attribute vec2 aUV;
2084
2493
  attribute vec4 aColor;
2085
2494
 
@@ -2118,14 +2527,19 @@ void main(void){
2118
2527
  vUV = aUV;
2119
2528
  vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
2120
2529
  }
2121
- `, De = `
2530
+ `, Ie = `
2122
2531
  struct ParticleUniforms {
2123
- uProjectionMatrix:mat3x3<f32>,
2532
+ uTranslationMatrix:mat3x3<f32>,
2124
2533
  uColor:vec4<f32>,
2534
+ uRound:f32,
2125
2535
  uResolution:vec2<f32>,
2126
- uRoundPixels:f32,
2127
2536
  };
2128
2537
 
2538
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
2539
+ {
2540
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
2541
+ }
2542
+
2129
2543
  @group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
2130
2544
 
2131
2545
  @group(1) @binding(0) var uTexture: texture_2d<f32>;
@@ -2150,7 +2564,11 @@ fn mainVertex(
2150
2564
  aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
2151
2565
  ) + aPosition;
2152
2566
 
2153
- let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
2567
+ var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
2568
+
2569
+ if(uniforms.uRound == 1.0) {
2570
+ position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);
2571
+ }
2154
2572
 
2155
2573
  let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;
2156
2574
 
@@ -2172,18 +2590,18 @@ fn mainFragment(
2172
2590
 
2173
2591
  return sample;
2174
2592
  }`;
2175
- class cr extends be {
2593
+ class xr extends ve {
2176
2594
  constructor() {
2177
- const e = Ft.from({
2178
- vertex: lr,
2179
- fragment: or
2180
- }), t = Bt.from({
2595
+ const e = Ee.from({
2596
+ vertex: mr,
2597
+ fragment: gr
2598
+ }), t = Le.from({
2181
2599
  fragment: {
2182
- source: De,
2600
+ source: Ie,
2183
2601
  entryPoint: "mainFragment"
2184
2602
  },
2185
2603
  vertex: {
2186
- source: De,
2604
+ source: Ie,
2187
2605
  entryPoint: "mainVertex"
2188
2606
  }
2189
2607
  });
@@ -2192,12 +2610,12 @@ class cr extends be {
2192
2610
  gpuProgram: t,
2193
2611
  resources: {
2194
2612
  // this will be replaced with the texture from the particle container
2195
- uTexture: R.WHITE.source,
2613
+ uTexture: M.WHITE.source,
2196
2614
  // this will be replaced with the texture style from the particle container
2197
2615
  uSampler: new j({}),
2198
2616
  // this will be replaced with the local uniforms from the particle container
2199
2617
  uniforms: {
2200
- uTranslationMatrix: { value: new k(), type: "mat3x3<f32>" },
2618
+ uTranslationMatrix: { value: new U(), type: "mat3x3<f32>" },
2201
2619
  uColor: { value: new V(16777215), type: "vec4<f32>" },
2202
2620
  uRound: { value: 1, type: "f32" },
2203
2621
  uResolution: { value: [0, 0], type: "vec2<f32>" }
@@ -2206,18 +2624,18 @@ class cr extends be {
2206
2624
  });
2207
2625
  }
2208
2626
  }
2209
- class st {
2627
+ class ct {
2210
2628
  /**
2211
2629
  * @param renderer - The renderer this sprite batch works for.
2212
2630
  * @param adaptor
2213
2631
  */
2214
2632
  constructor(e, t) {
2215
- this.state = ee.for2d(), this.localUniforms = new Y({
2216
- uTranslationMatrix: { value: new k(), type: "mat3x3<f32>" },
2633
+ this.state = te.for2d(), this.localUniforms = new Y({
2634
+ uTranslationMatrix: { value: new U(), type: "mat3x3<f32>" },
2217
2635
  uColor: { value: new Float32Array(4), type: "vec4<f32>" },
2218
2636
  uRound: { value: 1, type: "f32" },
2219
2637
  uResolution: { value: [0, 0], type: "vec2<f32>" }
2220
- }), this.renderer = e, this.adaptor = t, this.defaultShader = new cr(), this.state = ee.for2d();
2638
+ }), this.renderer = e, this.adaptor = t, this.defaultShader = new xr(), this.state = te.for2d();
2221
2639
  }
2222
2640
  validateRenderable(e) {
2223
2641
  return !1;
@@ -2229,7 +2647,7 @@ class st {
2229
2647
  return e._gpuData[this.renderer.uid] || this._initBuffer(e);
2230
2648
  }
2231
2649
  _initBuffer(e) {
2232
- return e._gpuData[this.renderer.uid] = new sr({
2650
+ return e._gpuData[this.renderer.uid] = new fr({
2233
2651
  size: e.particleChildren.length,
2234
2652
  properties: e._properties
2235
2653
  }), e._gpuData[this.renderer.uid];
@@ -2253,34 +2671,34 @@ class st {
2253
2671
  }
2254
2672
  /** Destroys the ParticleRenderer. */
2255
2673
  destroy() {
2256
- this.defaultShader && (this.defaultShader.destroy(), this.defaultShader = null);
2674
+ this.renderer = null, this.defaultShader && (this.defaultShader.destroy(), this.defaultShader = null);
2257
2675
  }
2258
2676
  }
2259
- class at extends st {
2677
+ class ht extends ct {
2260
2678
  constructor(e) {
2261
- super(e, new rr());
2679
+ super(e, new cr());
2262
2680
  }
2263
2681
  }
2264
- at.extension = {
2682
+ ht.extension = {
2265
2683
  type: [
2266
- w.WebGLPipes
2684
+ y.WebGLPipes
2267
2685
  ],
2268
2686
  name: "particle"
2269
2687
  };
2270
- class ot extends st {
2688
+ class dt extends ct {
2271
2689
  constructor(e) {
2272
- super(e, new ir());
2690
+ super(e, new hr());
2273
2691
  }
2274
2692
  }
2275
- ot.extension = {
2693
+ dt.extension = {
2276
2694
  type: [
2277
- w.WebGPUPipes
2695
+ y.WebGPUPipes
2278
2696
  ],
2279
2697
  name: "particle"
2280
2698
  };
2281
- const lt = class ct extends tr {
2699
+ const ft = class pt extends lr {
2282
2700
  constructor(e = {}) {
2283
- e = { ...ct.defaultOptions, ...e }, super({
2701
+ e = { ...pt.defaultOptions, ...e }, super({
2284
2702
  width: e.width,
2285
2703
  height: e.height,
2286
2704
  verticesX: 4,
@@ -2304,10 +2722,10 @@ const lt = class ct extends tr {
2304
2722
  _rightWidth: n,
2305
2723
  _topHeight: s,
2306
2724
  _bottomHeight: a,
2307
- _anchorX: l,
2308
- _anchorY: c
2309
- } = this, d = i + n, u = t > d ? 1 : t / d, h = s + a, f = r > h ? 1 : r / h, m = Math.min(u, f), x = l * t, _ = c * r;
2310
- e[0] = e[8] = e[16] = e[24] = -x, e[2] = e[10] = e[18] = e[26] = i * m - x, e[4] = e[12] = e[20] = e[28] = t - n * m - x, e[6] = e[14] = e[22] = e[30] = t - x, e[1] = e[3] = e[5] = e[7] = -_, e[9] = e[11] = e[13] = e[15] = s * m - _, e[17] = e[19] = e[21] = e[23] = r - a * m - _, e[25] = e[27] = e[29] = e[31] = r - _, this.getBuffer("aPosition").update();
2725
+ _anchorX: u,
2726
+ _anchorY: l
2727
+ } = this, h = i + n, c = t > h ? 1 : t / h, d = s + a, f = r > d ? 1 : r / d, x = Math.min(c, f), _ = u * t, v = l * r;
2728
+ e[0] = e[8] = e[16] = e[24] = -_, e[2] = e[10] = e[18] = e[26] = i * x - _, e[4] = e[12] = e[20] = e[28] = t - n * x - _, e[6] = e[14] = e[22] = e[30] = t - _, e[1] = e[3] = e[5] = e[7] = -v, e[9] = e[11] = e[13] = e[15] = s * x - v, e[17] = e[19] = e[21] = e[23] = r - a * x - v, e[25] = e[27] = e[29] = e[31] = r - v, this.getBuffer("aPosition").update();
2311
2729
  }
2312
2730
  /** Updates the UVs of the vertices. */
2313
2731
  updateUvs() {
@@ -2317,7 +2735,7 @@ const lt = class ct extends tr {
2317
2735
  e[2] = e[10] = e[18] = e[26] = t * this._leftWidth, e[9] = e[11] = e[13] = e[15] = r * this._topHeight, e[4] = e[12] = e[20] = e[28] = 1 - t * this._rightWidth, e[17] = e[19] = e[21] = e[23] = 1 - r * this._bottomHeight, this.getBuffer("aUV").update();
2318
2736
  }
2319
2737
  };
2320
- lt.defaultOptions = {
2738
+ ft.defaultOptions = {
2321
2739
  /** The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */
2322
2740
  width: 100,
2323
2741
  /** The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */
@@ -2335,16 +2753,16 @@ lt.defaultOptions = {
2335
2753
  /** The original height of the texture */
2336
2754
  originalHeight: 100
2337
2755
  };
2338
- let ur = lt;
2339
- class dr extends we {
2756
+ let _r = ft;
2757
+ class vr extends ye {
2340
2758
  constructor() {
2341
- super(), this.geometry = new ur();
2759
+ super(), this.geometry = new _r();
2342
2760
  }
2343
2761
  destroy() {
2344
2762
  this.geometry.destroy();
2345
2763
  }
2346
2764
  }
2347
- class ut {
2765
+ class gt {
2348
2766
  constructor(e) {
2349
2767
  this._renderer = e;
2350
2768
  }
@@ -2370,22 +2788,22 @@ class ut {
2370
2788
  return e._gpuData[this._renderer.uid] || this._initGPUSprite(e);
2371
2789
  }
2372
2790
  _initGPUSprite(e) {
2373
- const t = e._gpuData[this._renderer.uid] = new dr(), r = t;
2791
+ const t = e._gpuData[this._renderer.uid] = new vr(), r = t;
2374
2792
  return r.renderable = e, r.transform = e.groupTransform, r.texture = e._texture, r.roundPixels = this._renderer._roundPixels | e._roundPixels, e.didViewUpdate || this._updateBatchableSprite(e, r), t;
2375
2793
  }
2376
2794
  destroy() {
2377
2795
  this._renderer = null;
2378
2796
  }
2379
2797
  }
2380
- ut.extension = {
2798
+ gt.extension = {
2381
2799
  type: [
2382
- w.WebGLPipes,
2383
- w.WebGPUPipes,
2384
- w.CanvasPipes
2800
+ y.WebGLPipes,
2801
+ y.WebGPUPipes,
2802
+ y.CanvasPipes
2385
2803
  ],
2386
2804
  name: "nineSliceSprite"
2387
2805
  };
2388
- const hr = {
2806
+ const br = {
2389
2807
  name: "tiling-bit",
2390
2808
  vertex: {
2391
2809
  header: (
@@ -2450,7 +2868,7 @@ const hr = {
2450
2868
  `
2451
2869
  )
2452
2870
  }
2453
- }, fr = {
2871
+ }, yr = {
2454
2872
  name: "tiling-bit",
2455
2873
  vertex: {
2456
2874
  header: (
@@ -2495,59 +2913,59 @@ const hr = {
2495
2913
  )
2496
2914
  }
2497
2915
  };
2498
- let ce, ue;
2499
- class pr extends be {
2916
+ let le, ce;
2917
+ class Tr extends ve {
2500
2918
  constructor() {
2501
- ce ?? (ce = Oe({
2919
+ le ?? (le = Ye({
2502
2920
  name: "tiling-sprite-shader",
2503
2921
  bits: [
2504
- Wt,
2505
- hr,
2506
- Ee
2922
+ Et,
2923
+ br,
2924
+ Xe
2507
2925
  ]
2508
- })), ue ?? (ue = He({
2926
+ })), ce ?? (ce = $e({
2509
2927
  name: "tiling-sprite-shader",
2510
2928
  bits: [
2511
- Lt,
2512
- fr,
2513
- Ve
2929
+ Ht,
2930
+ yr,
2931
+ Ne
2514
2932
  ]
2515
2933
  }));
2516
2934
  const e = new Y({
2517
- uMapCoord: { value: new k(), type: "mat3x3<f32>" },
2935
+ uMapCoord: { value: new U(), type: "mat3x3<f32>" },
2518
2936
  uClampFrame: { value: new Float32Array([0, 0, 1, 1]), type: "vec4<f32>" },
2519
2937
  uClampOffset: { value: new Float32Array([0, 0]), type: "vec2<f32>" },
2520
- uTextureTransform: { value: new k(), type: "mat3x3<f32>" },
2938
+ uTextureTransform: { value: new U(), type: "mat3x3<f32>" },
2521
2939
  uSizeAnchor: { value: new Float32Array([100, 100, 0.5, 0.5]), type: "vec4<f32>" }
2522
2940
  });
2523
2941
  super({
2524
- glProgram: ue,
2525
- gpuProgram: ce,
2942
+ glProgram: ce,
2943
+ gpuProgram: le,
2526
2944
  resources: {
2527
2945
  localUniforms: new Y({
2528
- uTransformMatrix: { value: new k(), type: "mat3x3<f32>" },
2946
+ uTransformMatrix: { value: new U(), type: "mat3x3<f32>" },
2529
2947
  uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
2530
2948
  uRound: { value: 0, type: "f32" }
2531
2949
  }),
2532
2950
  tilingUniforms: e,
2533
- uTexture: R.EMPTY.source,
2534
- uSampler: R.EMPTY.source.style
2951
+ uTexture: M.EMPTY.source,
2952
+ uSampler: M.EMPTY.source.style
2535
2953
  }
2536
2954
  });
2537
2955
  }
2538
2956
  updateUniforms(e, t, r, i, n, s) {
2539
- const a = this.resources.tilingUniforms, l = s.width, c = s.height, d = s.textureMatrix, u = a.uniforms.uTextureTransform;
2540
- u.set(
2541
- r.a * l / e,
2542
- r.b * l / t,
2543
- r.c * c / e,
2544
- r.d * c / t,
2957
+ const a = this.resources.tilingUniforms, u = s.width, l = s.height, h = s.textureMatrix, c = a.uniforms.uTextureTransform;
2958
+ c.set(
2959
+ r.a * u / e,
2960
+ r.b * u / t,
2961
+ r.c * l / e,
2962
+ r.d * l / t,
2545
2963
  r.tx / e,
2546
2964
  r.ty / t
2547
- ), u.invert(), a.uniforms.uMapCoord = d.mapCoord, a.uniforms.uClampFrame = d.uClampFrame, a.uniforms.uClampOffset = d.uClampOffset, a.uniforms.uTextureTransform = u, a.uniforms.uSizeAnchor[0] = e, a.uniforms.uSizeAnchor[1] = t, a.uniforms.uSizeAnchor[2] = i, a.uniforms.uSizeAnchor[3] = n, s && (this.resources.uTexture = s.source, this.resources.uSampler = s.source.style);
2965
+ ), c.invert(), a.uniforms.uMapCoord = h.mapCoord, a.uniforms.uClampFrame = h.uClampFrame, a.uniforms.uClampOffset = h.uClampOffset, a.uniforms.uTextureTransform = c, a.uniforms.uSizeAnchor[0] = e, a.uniforms.uSizeAnchor[1] = t, a.uniforms.uSizeAnchor[2] = i, a.uniforms.uSizeAnchor[3] = n, s && (this.resources.uTexture = s.source, this.resources.uSampler = s.source.style);
2548
2966
  }
2549
2967
  }
2550
- class gr extends ye {
2968
+ class wr extends be {
2551
2969
  constructor() {
2552
2970
  super({
2553
2971
  positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
@@ -2556,32 +2974,32 @@ class gr extends ye {
2556
2974
  });
2557
2975
  }
2558
2976
  }
2559
- function mr(o, e) {
2977
+ function Sr(o, e) {
2560
2978
  const t = o.anchor.x, r = o.anchor.y;
2561
2979
  e[0] = -t * o.width, e[1] = -r * o.height, e[2] = (1 - t) * o.width, e[3] = -r * o.height, e[4] = (1 - t) * o.width, e[5] = (1 - r) * o.height, e[6] = -t * o.width, e[7] = (1 - r) * o.height;
2562
2980
  }
2563
- function xr(o, e, t, r) {
2981
+ function Cr(o, e, t, r) {
2564
2982
  let i = 0;
2565
- const n = o.length / e, s = r.a, a = r.b, l = r.c, c = r.d, d = r.tx, u = r.ty;
2983
+ const n = o.length / e, s = r.a, a = r.b, u = r.c, l = r.d, h = r.tx, c = r.ty;
2566
2984
  for (t *= e; i < n; ) {
2567
- const h = o[t], f = o[t + 1];
2568
- o[t] = s * h + l * f + d, o[t + 1] = a * h + c * f + u, t += e, i++;
2985
+ const d = o[t], f = o[t + 1];
2986
+ o[t] = s * d + u * f + h, o[t + 1] = a * d + l * f + c, t += e, i++;
2569
2987
  }
2570
2988
  }
2571
- function _r(o, e) {
2989
+ function Pr(o, e) {
2572
2990
  const t = o.texture, r = t.frame.width, i = t.frame.height;
2573
2991
  let n = 0, s = 0;
2574
2992
  o.applyAnchorToTexture && (n = o.anchor.x, s = o.anchor.y), e[0] = e[6] = -n, e[2] = e[4] = 1 - n, e[1] = e[3] = -s, e[5] = e[7] = 1 - s;
2575
- const a = k.shared;
2576
- a.copyFrom(o._tileTransform.matrix), a.tx /= o.width, a.ty /= o.height, a.invert(), a.scale(o.width / r, o.height / i), xr(e, 2, 0, a);
2993
+ const a = U.shared;
2994
+ a.copyFrom(o._tileTransform.matrix), a.tx /= o.width, a.ty /= o.height, a.invert(), a.scale(o.width / r, o.height / i), Cr(e, 2, 0, a);
2577
2995
  }
2578
- const J = new gr();
2579
- class br {
2996
+ const Z = new wr();
2997
+ class Fr {
2580
2998
  constructor() {
2581
- this.canBatch = !0, this.geometry = new ye({
2582
- indices: J.indices.slice(),
2583
- positions: J.positions.slice(),
2584
- uvs: J.uvs.slice()
2999
+ this.canBatch = !0, this.geometry = new be({
3000
+ indices: Z.indices.slice(),
3001
+ positions: Z.positions.slice(),
3002
+ uvs: Z.uvs.slice()
2585
3003
  });
2586
3004
  }
2587
3005
  destroy() {
@@ -2589,9 +3007,9 @@ class br {
2589
3007
  this.geometry.destroy(), (e = this.shader) == null || e.destroy();
2590
3008
  }
2591
3009
  }
2592
- class dt {
3010
+ class mt {
2593
3011
  constructor(e) {
2594
- this._state = ee.default2d, this._renderer = e;
3012
+ this._state = te.default2d, this._renderer = e;
2595
3013
  }
2596
3014
  validateRenderable(e) {
2597
3015
  const t = this._getTilingSpriteData(e), r = t.canBatch;
@@ -2611,11 +3029,11 @@ class dt {
2611
3029
  this._updateCanBatch(e);
2612
3030
  const i = this._getTilingSpriteData(e), { geometry: n, canBatch: s } = i;
2613
3031
  if (s) {
2614
- i.batchableMesh || (i.batchableMesh = new we());
3032
+ i.batchableMesh || (i.batchableMesh = new ye());
2615
3033
  const a = i.batchableMesh;
2616
3034
  e.didViewUpdate && (this._updateBatchableMesh(e), a.geometry = n, a.renderable = e, a.transform = e.groupTransform, a.setTexture(e._texture)), a.roundPixels = this._renderer._roundPixels | e._roundPixels, r.addToBatch(a, t);
2617
3035
  } else
2618
- r.break(t), i.shader || (i.shader = new pr()), this.updateRenderable(e), t.add(e);
3036
+ r.break(t), i.shader || (i.shader = new Tr()), this.updateRenderable(e), t.add(e);
2619
3037
  }
2620
3038
  execute(e) {
2621
3039
  const { shader: t } = this._getTilingSpriteData(e);
@@ -2626,7 +3044,7 @@ class dt {
2626
3044
  r.uColor,
2627
3045
  0
2628
3046
  ), this._state.blendMode = _e(e.groupBlendMode, e.texture._source), this._renderer.encoder.draw({
2629
- geometry: J,
3047
+ geometry: Z,
2630
3048
  shader: t,
2631
3049
  state: this._state
2632
3050
  });
@@ -2652,12 +3070,12 @@ class dt {
2652
3070
  return e._gpuData[this._renderer.uid] || this._initTilingSpriteData(e);
2653
3071
  }
2654
3072
  _initTilingSpriteData(e) {
2655
- const t = new br();
3073
+ const t = new Fr();
2656
3074
  return t.renderable = e, e._gpuData[this._renderer.uid] = t, t;
2657
3075
  }
2658
3076
  _updateBatchableMesh(e) {
2659
3077
  const t = this._getTilingSpriteData(e), { geometry: r } = t, i = e.texture.source.style;
2660
- i.addressMode !== "repeat" && (i.addressMode = "repeat", i.update()), _r(e, r.uvs), mr(e, r.positions);
3078
+ i.addressMode !== "repeat" && (i.addressMode = "repeat", i.update()), Pr(e, r.uvs), Sr(e, r.positions);
2661
3079
  }
2662
3080
  destroy() {
2663
3081
  this._renderer = null;
@@ -2668,15 +3086,15 @@ class dt {
2668
3086
  return this._renderer.type === xe.WEBGL && (i = this._renderer.context.supports.nonPowOf2wrapping), t.canBatch = r.textureMatrix.isSimple && (i || r.source.isPowerOfTwo), t.canBatch;
2669
3087
  }
2670
3088
  }
2671
- dt.extension = {
3089
+ mt.extension = {
2672
3090
  type: [
2673
- w.WebGLPipes,
2674
- w.WebGPUPipes,
2675
- w.CanvasPipes
3091
+ y.WebGLPipes,
3092
+ y.WebGPUPipes,
3093
+ y.CanvasPipes
2676
3094
  ],
2677
3095
  name: "tilingSprite"
2678
3096
  };
2679
- const yr = {
3097
+ const Br = {
2680
3098
  name: "local-uniform-msdf-bit",
2681
3099
  vertex: {
2682
3100
  header: (
@@ -2729,7 +3147,7 @@ const yr = {
2729
3147
  `
2730
3148
  )
2731
3149
  }
2732
- }, wr = {
3150
+ }, Rr = {
2733
3151
  name: "local-uniform-msdf-bit",
2734
3152
  vertex: {
2735
3153
  header: (
@@ -2771,7 +3189,7 @@ const yr = {
2771
3189
  `
2772
3190
  )
2773
3191
  }
2774
- }, Tr = {
3192
+ }, Mr = {
2775
3193
  name: "msdf-bit",
2776
3194
  fragment: {
2777
3195
  header: (
@@ -2806,7 +3224,7 @@ const yr = {
2806
3224
  `
2807
3225
  )
2808
3226
  }
2809
- }, vr = {
3227
+ }, Ur = {
2810
3228
  name: "msdf-bit",
2811
3229
  fragment: {
2812
3230
  header: (
@@ -2842,51 +3260,51 @@ const yr = {
2842
3260
  )
2843
3261
  }
2844
3262
  };
2845
- let de, he;
2846
- class Sr extends be {
3263
+ let he, de;
3264
+ class zr extends ve {
2847
3265
  constructor(e) {
2848
3266
  const t = new Y({
2849
3267
  uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
2850
- uTransformMatrix: { value: new k(), type: "mat3x3<f32>" },
3268
+ uTransformMatrix: { value: new U(), type: "mat3x3<f32>" },
2851
3269
  uDistance: { value: 4, type: "f32" },
2852
3270
  uRound: { value: 0, type: "f32" }
2853
3271
  });
2854
- de ?? (de = Oe({
3272
+ he ?? (he = Ye({
2855
3273
  name: "sdf-shader",
2856
3274
  bits: [
2857
- Mt,
2858
- Rt(e),
2859
- yr,
2860
- Tr,
2861
- Ee
3275
+ kt,
3276
+ Gt(e),
3277
+ Br,
3278
+ Mr,
3279
+ Xe
2862
3280
  ]
2863
- })), he ?? (he = He({
3281
+ })), de ?? (de = $e({
2864
3282
  name: "sdf-shader",
2865
3283
  bits: [
2866
- Ut,
2867
- kt(e),
2868
- wr,
2869
- vr,
2870
- Ve
3284
+ At,
3285
+ Dt(e),
3286
+ Rr,
3287
+ Ur,
3288
+ Ne
2871
3289
  ]
2872
3290
  })), super({
2873
- glProgram: he,
2874
- gpuProgram: de,
3291
+ glProgram: de,
3292
+ gpuProgram: he,
2875
3293
  resources: {
2876
3294
  localUniforms: t,
2877
- batchSamplers: Gt(e)
3295
+ batchSamplers: Ot(e)
2878
3296
  }
2879
3297
  });
2880
3298
  }
2881
3299
  }
2882
- class Cr extends At {
3300
+ class kr extends It {
2883
3301
  destroy() {
2884
3302
  this.context.customShader && this.context.customShader.destroy(), super.destroy();
2885
3303
  }
2886
3304
  }
2887
- class ht {
3305
+ class xt {
2888
3306
  constructor(e) {
2889
- this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_gpuBitmapText");
3307
+ this._renderer = e;
2890
3308
  }
2891
3309
  validateRenderable(e) {
2892
3310
  const t = this._getGpuBitmapText(e);
@@ -2901,70 +3319,70 @@ class ht {
2901
3319
  We(e, t), this._renderer.renderPipes.graphics.updateRenderable(t), t.context.customShader && this._updateDistanceField(e);
2902
3320
  }
2903
3321
  _updateContext(e, t) {
2904
- const { context: r } = t, i = $t.getFont(e.text, e._style);
2905
- r.clear(), i.distanceField.type !== "none" && (r.customShader || (r.customShader = new Sr(this._renderer.limits.maxBatchableTextures)));
2906
- const n = D.graphemeSegmenter(e.text), s = e._style;
3322
+ const { context: r } = t, i = Qt.getFont(e.text, e._style);
3323
+ r.clear(), i.distanceField.type !== "none" && (r.customShader || (r.customShader = new zr(this._renderer.limits.maxBatchableTextures)));
3324
+ const n = O.graphemeSegmenter(e.text), s = e._style;
2907
3325
  let a = i.baseLineOffset;
2908
- const l = qe(n, s, i, !0), c = s.padding, d = l.scale;
2909
- let u = l.width, h = l.height + l.offsetY;
2910
- s._stroke && (u += s._stroke.width / d, h += s._stroke.width / d), r.translate(-e._anchor._x * u - c, -e._anchor._y * h - c).scale(d, d);
3326
+ const u = et(n, s, i, !0), l = s.padding, h = u.scale;
3327
+ let c = u.width, d = u.height + u.offsetY;
3328
+ s._stroke && (c += s._stroke.width / h, d += s._stroke.width / h), r.translate(-e._anchor._x * c - l, -e._anchor._y * d - l).scale(h, h);
2911
3329
  const f = i.applyFillAsTint ? s._fill.color : 16777215;
2912
- let m = i.fontMetrics.fontSize, x = i.lineHeight;
2913
- s.lineHeight && (m = s.fontSize / d, x = s.lineHeight / d);
2914
- let _ = (x - m) / 2;
2915
- _ - i.baseLineOffset < 0 && (_ = 0);
2916
- for (let p = 0; p < l.lines.length; p++) {
2917
- const b = l.lines[p];
2918
- for (let y = 0; y < b.charPositions.length; y++) {
2919
- const T = b.chars[y], S = i.chars[T];
3330
+ let x = i.fontMetrics.fontSize, _ = i.lineHeight;
3331
+ s.lineHeight && (x = s.fontSize / h, _ = s.lineHeight / h);
3332
+ let v = (_ - x) / 2;
3333
+ v - i.baseLineOffset < 0 && (v = 0);
3334
+ for (let g = 0; g < u.lines.length; g++) {
3335
+ const b = u.lines[g];
3336
+ for (let m = 0; m < b.charPositions.length; m++) {
3337
+ const T = b.chars[m], S = i.chars[T];
2920
3338
  if (S != null && S.texture) {
2921
3339
  const B = S.texture;
2922
3340
  r.texture(
2923
3341
  B,
2924
3342
  f || "black",
2925
- Math.round(b.charPositions[y] + S.xOffset),
2926
- Math.round(a + S.yOffset + _),
3343
+ Math.round(b.charPositions[m] + S.xOffset),
3344
+ Math.round(a + S.yOffset + v),
2927
3345
  B.orig.width,
2928
3346
  B.orig.height
2929
3347
  );
2930
3348
  }
2931
3349
  }
2932
- a += x;
3350
+ a += _;
2933
3351
  }
2934
3352
  }
2935
3353
  _getGpuBitmapText(e) {
2936
3354
  return e._gpuData[this._renderer.uid] || this.initGpuText(e);
2937
3355
  }
2938
3356
  initGpuText(e) {
2939
- const t = new Cr();
3357
+ const t = new kr();
2940
3358
  return e._gpuData[this._renderer.uid] = t, this._updateContext(e, t), t;
2941
3359
  }
2942
3360
  _updateDistanceField(e) {
2943
- const t = this._getGpuBitmapText(e).context, r = e._style.fontFamily, i = G.get(`${r}-bitmap`), { a: n, b: s, c: a, d: l } = e.groupTransform, c = Math.sqrt(n * n + s * s), d = Math.sqrt(a * a + l * l), u = (Math.abs(c) + Math.abs(d)) / 2, h = i.baseRenderedFontSize / e._style.fontSize, f = u * i.distanceField.range * (1 / h);
3361
+ const t = this._getGpuBitmapText(e).context, r = e._style.fontFamily, i = G.get(`${r}-bitmap`), { a: n, b: s, c: a, d: u } = e.groupTransform, l = Math.sqrt(n * n + s * s), h = Math.sqrt(a * a + u * u), c = (Math.abs(l) + Math.abs(h)) / 2, d = i.baseRenderedFontSize / e._style.fontSize, f = c * i.distanceField.range * (1 / d);
2944
3362
  t.customShader.resources.localUniforms.uniforms.uDistance = f;
2945
3363
  }
2946
3364
  destroy() {
2947
3365
  this._renderer = null;
2948
3366
  }
2949
3367
  }
2950
- ht.extension = {
3368
+ xt.extension = {
2951
3369
  type: [
2952
- w.WebGLPipes,
2953
- w.WebGPUPipes,
2954
- w.CanvasPipes
3370
+ y.WebGLPipes,
3371
+ y.WebGPUPipes,
3372
+ y.CanvasPipes
2955
3373
  ],
2956
3374
  name: "bitmapText"
2957
3375
  };
2958
3376
  function We(o, e) {
2959
3377
  e.groupTransform = o.groupTransform, e.groupColorAlpha = o.groupColorAlpha, e.groupColor = o.groupColor, e.groupBlendMode = o.groupBlendMode, e.globalDisplayStatus = o.globalDisplayStatus, e.groupTransform = o.groupTransform, e.localDisplayStatus = o.localDisplayStatus, e.groupAlpha = o.groupAlpha, e._roundPixels = o._roundPixels;
2960
3378
  }
2961
- class Pr extends Ye {
3379
+ class Gr extends Ke {
2962
3380
  /**
2963
3381
  * Creates an instance of BatchableHTMLText.
2964
3382
  * @param renderer - The renderer instance to be used.
2965
3383
  */
2966
3384
  constructor(e) {
2967
- super(), this.generatingTexture = !1, this._renderer = e, e.runners.resolutionChange.add(this);
3385
+ super(), this.generatingTexture = !1, this.currentKey = "--", this._renderer = e, e.runners.resolutionChange.add(this);
2968
3386
  }
2969
3387
  /** Handles resolution changes for the HTML text. If the text has auto resolution enabled, it triggers a view update. */
2970
3388
  resolutionChange() {
@@ -2973,27 +3391,33 @@ class Pr extends Ye {
2973
3391
  }
2974
3392
  /** Destroys the BatchableHTMLText instance. Returns the texture promise to the renderer and cleans up references. */
2975
3393
  destroy() {
2976
- this._renderer.htmlText.returnTexturePromise(this.texturePromise), this.texturePromise = null, this._renderer = null;
3394
+ const { htmlText: e } = this._renderer;
3395
+ e.getReferenceCount(this.currentKey) === null ? e.returnTexturePromise(this.texturePromise) : e.decreaseReferenceCount(this.currentKey), this._renderer.runners.resolutionChange.remove(this), this.texturePromise = null, this._renderer = null;
2977
3396
  }
2978
3397
  }
2979
3398
  function ge(o, e) {
2980
3399
  const { texture: t, bounds: r } = o, i = e._style._getFinalPadding();
2981
- zt(r, e._anchor, t);
3400
+ Wt(r, e._anchor, t);
2982
3401
  const n = e._anchor._x * i * 2, s = e._anchor._y * i * 2;
2983
3402
  r.minX -= i - n, r.minY -= i - s, r.maxX -= i - n, r.maxY -= i - s;
2984
3403
  }
2985
- class ft {
3404
+ class _t {
2986
3405
  constructor(e) {
2987
3406
  this._renderer = e;
2988
3407
  }
2989
3408
  validateRenderable(e) {
2990
- return e._didTextUpdate;
3409
+ const t = this._getGpuText(e), r = e.styleKey;
3410
+ return t.currentKey !== r;
2991
3411
  }
2992
3412
  addRenderable(e, t) {
2993
3413
  const r = this._getGpuText(e);
2994
- e._didTextUpdate && (this._updateGpuText(e).catch((i) => {
2995
- console.error(i);
2996
- }), e._didTextUpdate = !1, ge(r, e)), this._renderer.renderPipes.batch.addToBatch(r, t);
3414
+ if (e._didTextUpdate) {
3415
+ const i = e._autoResolution ? this._renderer.resolution : e.resolution;
3416
+ (r.currentKey !== e.styleKey || e.resolution !== i) && this._updateGpuText(e).catch((n) => {
3417
+ console.error(n);
3418
+ }), e._didTextUpdate = !1, ge(r, e);
3419
+ }
3420
+ this._renderer.renderPipes.batch.addToBatch(r, t);
2997
3421
  }
2998
3422
  updateRenderable(e) {
2999
3423
  const t = this._getGpuText(e);
@@ -3004,38 +3428,41 @@ class ft {
3004
3428
  const t = this._getGpuText(e);
3005
3429
  if (t.generatingTexture)
3006
3430
  return;
3007
- t.texturePromise && (this._renderer.htmlText.returnTexturePromise(t.texturePromise), t.texturePromise = null), t.generatingTexture = !0, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution;
3008
- const r = this._renderer.htmlText.getTexturePromise(e);
3009
- t.texturePromise = r, t.texture = await r;
3010
- const i = e.renderGroup || e.parentRenderGroup;
3011
- i && (i.structureDidChange = !0), t.generatingTexture = !1, ge(t, e);
3431
+ const r = t.texturePromise;
3432
+ t.texturePromise = null, t.generatingTexture = !0, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution;
3433
+ let i = this._renderer.htmlText.getTexturePromise(e);
3434
+ r && (i = i.finally(() => {
3435
+ this._renderer.htmlText.decreaseReferenceCount(t.currentKey), this._renderer.htmlText.returnTexturePromise(r);
3436
+ })), t.texturePromise = i, t.currentKey = e.styleKey, t.texture = await i;
3437
+ const n = e.renderGroup || e.parentRenderGroup;
3438
+ n && (n.structureDidChange = !0), t.generatingTexture = !1, ge(t, e);
3012
3439
  }
3013
3440
  _getGpuText(e) {
3014
3441
  return e._gpuData[this._renderer.uid] || this.initGpuText(e);
3015
3442
  }
3016
3443
  initGpuText(e) {
3017
- const t = new Pr(this._renderer);
3018
- return t.renderable = e, t.transform = e.groupTransform, t.texture = R.EMPTY, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, e._gpuData[this._renderer.uid] = t, t;
3444
+ const t = new Gr(this._renderer);
3445
+ return t.renderable = e, t.transform = e.groupTransform, t.texture = M.EMPTY, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, e._gpuData[this._renderer.uid] = t, t;
3019
3446
  }
3020
3447
  destroy() {
3021
3448
  this._renderer = null;
3022
3449
  }
3023
3450
  }
3024
- ft.extension = {
3451
+ _t.extension = {
3025
3452
  type: [
3026
- w.WebGLPipes,
3027
- w.WebGPUPipes,
3028
- w.CanvasPipes
3453
+ y.WebGLPipes,
3454
+ y.WebGPUPipes,
3455
+ y.CanvasPipes
3029
3456
  ],
3030
3457
  name: "htmlText"
3031
3458
  };
3032
- function Fr() {
3459
+ function Ar() {
3033
3460
  const { userAgent: o } = H.get().getNavigator();
3034
3461
  return /^((?!chrome|android).)*safari/i.test(o);
3035
3462
  }
3036
- const Br = new Ie();
3037
- function pt(o, e, t, r) {
3038
- const i = Br;
3463
+ const Dr = new Ve();
3464
+ function vt(o, e, t, r) {
3465
+ const i = Dr;
3039
3466
  i.minX = 0, i.minY = 0, i.maxX = o.width / r | 0, i.maxY = o.height / r | 0;
3040
3467
  const n = A.getOptimalTexture(
3041
3468
  i.width,
@@ -3045,34 +3472,34 @@ function pt(o, e, t, r) {
3045
3472
  );
3046
3473
  return n.source.uploadMethodId = "image", n.source.resource = o, n.source.alphaMode = "premultiply-alpha-on-upload", n.frame.width = e / r, n.frame.height = t / r, n.source.emit("update", n.source), n.updateUvs(), n;
3047
3474
  }
3048
- function Mr(o, e) {
3475
+ function Or(o, e) {
3049
3476
  const t = e.fontFamily, r = [], i = {}, n = /font-family:([^;"\s]+)/g, s = o.match(n);
3050
- function a(l) {
3051
- i[l] || (r.push(l), i[l] = !0);
3477
+ function a(u) {
3478
+ i[u] || (r.push(u), i[u] = !0);
3052
3479
  }
3053
3480
  if (Array.isArray(t))
3054
- for (let l = 0; l < t.length; l++)
3055
- a(t[l]);
3481
+ for (let u = 0; u < t.length; u++)
3482
+ a(t[u]);
3056
3483
  else
3057
3484
  a(t);
3058
- s && s.forEach((l) => {
3059
- const c = l.split(":")[1].trim();
3060
- a(c);
3485
+ s && s.forEach((u) => {
3486
+ const l = u.split(":")[1].trim();
3487
+ a(l);
3061
3488
  });
3062
- for (const l in e.tagStyles) {
3063
- const c = e.tagStyles[l].fontFamily;
3064
- a(c);
3489
+ for (const u in e.tagStyles) {
3490
+ const l = e.tagStyles[u].fontFamily;
3491
+ a(l);
3065
3492
  }
3066
3493
  return r;
3067
3494
  }
3068
- async function Rr(o) {
3495
+ async function Ir(o) {
3069
3496
  const t = await (await H.get().fetch(o)).blob(), r = new FileReader();
3070
3497
  return await new Promise((n, s) => {
3071
3498
  r.onloadend = () => n(r.result), r.onerror = s, r.readAsDataURL(t);
3072
3499
  });
3073
3500
  }
3074
- async function Ur(o, e) {
3075
- const t = await Rr(e);
3501
+ async function Wr(o, e) {
3502
+ const t = await Ir(e);
3076
3503
  return `@font-face {
3077
3504
  font-family: "${o.fontFamily}";
3078
3505
  font-weight: ${o.fontWeight};
@@ -3081,18 +3508,18 @@ async function Ur(o, e) {
3081
3508
  }`;
3082
3509
  }
3083
3510
  const fe = /* @__PURE__ */ new Map();
3084
- async function kr(o) {
3511
+ async function Lr(o) {
3085
3512
  const e = o.filter((t) => G.has(`${t}-and-url`)).map((t) => {
3086
3513
  if (!fe.has(t)) {
3087
3514
  const { entries: r } = G.get(`${t}-and-url`), i = [];
3088
3515
  r.forEach((n) => {
3089
- const s = n.url, l = n.faces.map((c) => ({ weight: c.weight, style: c.style }));
3516
+ const s = n.url, u = n.faces.map((l) => ({ weight: l.weight, style: l.style }));
3090
3517
  i.push(
3091
- ...l.map(
3092
- (c) => Ur(
3518
+ ...u.map(
3519
+ (l) => Wr(
3093
3520
  {
3094
- fontWeight: c.weight,
3095
- fontStyle: c.style,
3521
+ fontWeight: l.weight,
3522
+ fontStyle: l.style,
3096
3523
  fontFamily: t
3097
3524
  },
3098
3525
  s
@@ -3110,13 +3537,13 @@ async function kr(o) {
3110
3537
  return (await Promise.all(e)).join(`
3111
3538
  `);
3112
3539
  }
3113
- function Gr(o, e, t, r, i) {
3540
+ function Er(o, e, t, r, i) {
3114
3541
  const { domElement: n, styleElement: s, svgRoot: a } = i;
3115
3542
  n.innerHTML = `<style>${e.cssStyle}</style><div style='padding:0;'>${o}</div>`, n.setAttribute("style", `transform: scale(${t});transform-origin: top left; display: inline-block`), s.textContent = r;
3116
- const { width: l, height: c } = i.image;
3117
- return a.setAttribute("width", l.toString()), a.setAttribute("height", c.toString()), new XMLSerializer().serializeToString(a);
3543
+ const { width: u, height: l } = i.image;
3544
+ return a.setAttribute("width", u.toString()), a.setAttribute("height", l.toString()), new XMLSerializer().serializeToString(a);
3118
3545
  }
3119
- function Ar(o, e) {
3546
+ function Hr(o, e) {
3120
3547
  const t = X.getOptimalCanvasAndContext(
3121
3548
  o.width,
3122
3549
  o.height,
@@ -3124,16 +3551,16 @@ function Ar(o, e) {
3124
3551
  ), { context: r } = t;
3125
3552
  return r.clearRect(0, 0, o.width, o.height), r.drawImage(o, 0, 0), t;
3126
3553
  }
3127
- function zr(o, e, t) {
3554
+ function Vr(o, e, t) {
3128
3555
  return new Promise(async (r) => {
3129
3556
  t && await new Promise((i) => setTimeout(i, 100)), o.onload = () => {
3130
3557
  r();
3131
3558
  }, o.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`, o.crossOrigin = "anonymous";
3132
3559
  });
3133
3560
  }
3134
- class gt {
3561
+ class bt {
3135
3562
  constructor(e) {
3136
- this._renderer = e, this._createCanvas = e.type === xe.WEBGPU;
3563
+ this._activeTextures = {}, this._renderer = e, this._createCanvas = e.type === xe.WEBGPU;
3137
3564
  }
3138
3565
  /**
3139
3566
  * @param options
@@ -3142,30 +3569,75 @@ class gt {
3142
3569
  getTexture(e) {
3143
3570
  return this.getTexturePromise(e);
3144
3571
  }
3572
+ /**
3573
+ * Increases the reference count for a texture.
3574
+ * @param text - The HTMLText instance associated with the texture.
3575
+ */
3576
+ getManagedTexture(e) {
3577
+ const t = e.styleKey;
3578
+ if (this._activeTextures[t])
3579
+ return this._increaseReferenceCount(t), this._activeTextures[t].promise;
3580
+ const r = this._buildTexturePromise(e).then((i) => (this._activeTextures[t].texture = i, i));
3581
+ return this._activeTextures[t] = {
3582
+ texture: null,
3583
+ promise: r,
3584
+ usageCount: 1
3585
+ }, r;
3586
+ }
3587
+ /**
3588
+ * Gets the current reference count for a texture associated with a text key.
3589
+ * @param textKey - The unique key identifying the text style configuration
3590
+ * @returns The number of Text instances currently using this texture
3591
+ */
3592
+ getReferenceCount(e) {
3593
+ var t;
3594
+ return ((t = this._activeTextures[e]) == null ? void 0 : t.usageCount) ?? null;
3595
+ }
3596
+ _increaseReferenceCount(e) {
3597
+ this._activeTextures[e].usageCount++;
3598
+ }
3599
+ /**
3600
+ * Decreases the reference count for a texture.
3601
+ * If the count reaches zero, the texture is cleaned up.
3602
+ * @param textKey - The key associated with the HTMLText instance.
3603
+ */
3604
+ decreaseReferenceCount(e) {
3605
+ const t = this._activeTextures[e];
3606
+ t && (t.usageCount--, t.usageCount === 0 && (t.texture ? this._cleanUp(t.texture) : t.promise.then((r) => {
3607
+ t.texture = r, this._cleanUp(t.texture);
3608
+ }).catch(() => {
3609
+ K("HTMLTextSystem: Failed to clean texture");
3610
+ }), this._activeTextures[e] = null));
3611
+ }
3612
+ /**
3613
+ * Returns a promise that resolves to a texture for the given HTMLText options.
3614
+ * @param options - The options for the HTMLText.
3615
+ * @returns A promise that resolves to a Texture.
3616
+ */
3145
3617
  getTexturePromise(e) {
3146
3618
  return this._buildTexturePromise(e);
3147
3619
  }
3148
3620
  async _buildTexturePromise(e) {
3149
- const { text: t, style: r, resolution: i, textureStyle: n } = e, s = te.get(et), a = Mr(t, r), l = await kr(a), c = Zt(t, r, l, s), d = Math.ceil(Math.ceil(Math.max(1, c.width) + r.padding * 2) * i), u = Math.ceil(Math.ceil(Math.max(1, c.height) + r.padding * 2) * i), h = s.image, f = 2;
3150
- h.width = (d | 0) + f, h.height = (u | 0) + f;
3151
- const m = Gr(t, r, i, l, s);
3152
- await zr(h, m, Fr() && a.length > 0);
3153
- const x = h;
3154
- let _;
3155
- this._createCanvas && (_ = Ar(h, i));
3156
- const p = pt(
3157
- _ ? _.canvas : x,
3158
- h.width - f,
3159
- h.height - f,
3621
+ const { text: t, style: r, resolution: i, textureStyle: n } = e, s = re.get(st), a = Or(t, r), u = await Lr(a), l = or(t, r, u, s), h = Math.ceil(Math.ceil(Math.max(1, l.width) + r.padding * 2) * i), c = Math.ceil(Math.ceil(Math.max(1, l.height) + r.padding * 2) * i), d = s.image, f = 2;
3622
+ d.width = (h | 0) + f, d.height = (c | 0) + f;
3623
+ const x = Er(t, r, i, u, s);
3624
+ await Vr(d, x, Ar() && a.length > 0);
3625
+ const _ = d;
3626
+ let v;
3627
+ this._createCanvas && (v = Hr(d, i));
3628
+ const g = vt(
3629
+ v ? v.canvas : _,
3630
+ d.width - f,
3631
+ d.height - f,
3160
3632
  i
3161
3633
  );
3162
- return n && (p.source.style = n), this._createCanvas && (this._renderer.texture.initSource(p.source), X.returnCanvasAndContext(_)), te.return(s), p;
3634
+ return n && (g.source.style = n), this._createCanvas && (this._renderer.texture.initSource(g.source), X.returnCanvasAndContext(v)), re.return(s), g;
3163
3635
  }
3164
3636
  returnTexturePromise(e) {
3165
3637
  e.then((t) => {
3166
3638
  this._cleanUp(t);
3167
3639
  }).catch(() => {
3168
- ne("HTMLTextSystem: Failed to clean texture");
3640
+ K("HTMLTextSystem: Failed to clean texture");
3169
3641
  });
3170
3642
  }
3171
3643
  _cleanUp(e) {
@@ -3173,17 +3645,20 @@ class gt {
3173
3645
  }
3174
3646
  destroy() {
3175
3647
  this._renderer = null;
3648
+ for (const e in this._activeTextures)
3649
+ this._activeTextures[e] && this.returnTexturePromise(this._activeTextures[e].promise);
3650
+ this._activeTextures = null;
3176
3651
  }
3177
3652
  }
3178
- gt.extension = {
3653
+ bt.extension = {
3179
3654
  type: [
3180
- w.WebGLSystem,
3181
- w.WebGPUSystem,
3182
- w.CanvasSystem
3655
+ y.WebGLSystem,
3656
+ y.WebGPUSystem,
3657
+ y.CanvasSystem
3183
3658
  ],
3184
3659
  name: "htmlText"
3185
3660
  };
3186
- class Dr extends Ye {
3661
+ class Yr extends Ke {
3187
3662
  constructor(e) {
3188
3663
  super(), this._renderer = e, e.runners.resolutionChange.add(this);
3189
3664
  }
@@ -3192,19 +3667,25 @@ class Dr extends Ye {
3192
3667
  e._autoResolution && e.onViewUpdate();
3193
3668
  }
3194
3669
  destroy() {
3195
- this._renderer.canvasText.returnTexture(this.texture), this._renderer = null;
3670
+ const { canvasText: e } = this._renderer;
3671
+ e.getReferenceCount(this.currentKey) > 0 ? e.decreaseReferenceCount(this.currentKey) : this.texture && e.returnTexture(this.texture), this._renderer.runners.resolutionChange.remove(this), this._renderer = null;
3196
3672
  }
3197
3673
  }
3198
- class mt {
3674
+ class yt {
3199
3675
  constructor(e) {
3200
3676
  this._renderer = e;
3201
3677
  }
3202
3678
  validateRenderable(e) {
3203
- return e._didTextUpdate;
3679
+ const t = this._getGpuText(e), r = e.styleKey;
3680
+ return t.currentKey !== r ? !0 : e._didTextUpdate;
3204
3681
  }
3205
3682
  addRenderable(e, t) {
3206
3683
  const r = this._getGpuText(e);
3207
- e._didTextUpdate && (this._updateGpuText(e), e._didTextUpdate = !1), this._renderer.renderPipes.batch.addToBatch(r, t);
3684
+ if (e._didTextUpdate) {
3685
+ const i = e._autoResolution ? this._renderer.resolution : e.resolution;
3686
+ (r.currentKey !== e.styleKey || e.resolution !== i) && this._updateGpuText(e), e._didTextUpdate = !1, ge(r, e);
3687
+ }
3688
+ this._renderer.renderPipes.batch.addToBatch(r, t);
3208
3689
  }
3209
3690
  updateRenderable(e) {
3210
3691
  const t = this._getGpuText(e);
@@ -3212,47 +3693,47 @@ class mt {
3212
3693
  }
3213
3694
  _updateGpuText(e) {
3214
3695
  const t = this._getGpuText(e);
3215
- t.texture && this._renderer.canvasText.returnTexture(t.texture), e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, t.texture = this._renderer.canvasText.getTexture(e), ge(t, e);
3696
+ t.texture && this._renderer.canvasText.decreaseReferenceCount(t.currentKey), e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, t.texture = this._renderer.canvasText.getManagedTexture(e), t.currentKey = e.styleKey;
3216
3697
  }
3217
3698
  _getGpuText(e) {
3218
3699
  return e._gpuData[this._renderer.uid] || this.initGpuText(e);
3219
3700
  }
3220
3701
  initGpuText(e) {
3221
- const t = new Dr(this._renderer);
3222
- return t.renderable = e, t.transform = e.groupTransform, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._gpuData[this._renderer.uid] = t, t;
3702
+ const t = new Yr(this._renderer);
3703
+ return t.currentKey = "--", t.renderable = e, t.transform = e.groupTransform, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._gpuData[this._renderer.uid] = t, t;
3223
3704
  }
3224
3705
  destroy() {
3225
3706
  this._renderer = null;
3226
3707
  }
3227
3708
  }
3228
- mt.extension = {
3709
+ yt.extension = {
3229
3710
  type: [
3230
- w.WebGLPipes,
3231
- w.WebGPUPipes,
3232
- w.CanvasPipes
3711
+ y.WebGLPipes,
3712
+ y.WebGPUPipes,
3713
+ y.CanvasPipes
3233
3714
  ],
3234
3715
  name: "text"
3235
3716
  };
3236
- class xt {
3717
+ class Tt {
3237
3718
  constructor(e) {
3238
- this._renderer = e;
3719
+ this._activeTextures = {}, this._renderer = e;
3239
3720
  }
3240
3721
  getTexture(e, t, r, i) {
3241
- typeof e == "string" && (U("8.0.0", "CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"), e = {
3722
+ typeof e == "string" && (z("8.0.0", "CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"), e = {
3242
3723
  text: e,
3243
3724
  style: r,
3244
3725
  resolution: t
3245
3726
  }), e.style instanceof q || (e.style = new q(e.style)), e.textureStyle instanceof j || (e.textureStyle = new j(e.textureStyle)), typeof e.text != "string" && (e.text = e.text.toString());
3246
- const { text: n, style: s, textureStyle: a } = e, l = e.resolution ?? this._renderer.resolution, { frame: c, canvasAndContext: d } = le.getCanvasAndContext({
3727
+ const { text: n, style: s, textureStyle: a } = e, u = e.resolution ?? this._renderer.resolution, { frame: l, canvasAndContext: h } = ue.getCanvasAndContext({
3247
3728
  text: n,
3248
3729
  style: s,
3249
- resolution: l
3250
- }), u = pt(d.canvas, c.width, c.height, l);
3251
- if (a && (u.source.style = a), s.trim && (c.pad(s.padding), u.frame.copyFrom(c), u.frame.scale(1 / l), u.updateUvs()), s.filters) {
3252
- const h = this._applyFilters(u, s.filters);
3253
- return this.returnTexture(u), le.returnCanvasAndContext(d), h;
3730
+ resolution: u
3731
+ }), c = vt(h.canvas, l.width, l.height, u);
3732
+ if (a && (c.source.style = a), s.trim && (l.pad(s.padding), c.frame.copyFrom(l), c.frame.scale(1 / u), c.updateUvs()), s.filters) {
3733
+ const d = this._applyFilters(c, s.filters);
3734
+ return this.returnTexture(c), ue.returnCanvasAndContext(h), d;
3254
3735
  }
3255
- return this._renderer.texture.initSource(u._source), le.returnCanvasAndContext(d), u;
3736
+ return this._renderer.texture.initSource(c._source), ue.returnCanvasAndContext(h), c;
3256
3737
  }
3257
3738
  /**
3258
3739
  * Returns a texture that was created wit the above `getTexture` function.
@@ -3268,11 +3749,62 @@ class xt {
3268
3749
  * @deprecated since 8.10.0
3269
3750
  */
3270
3751
  renderTextToCanvas() {
3271
- U(
3752
+ z(
3272
3753
  "8.10.0",
3273
3754
  "CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead"
3274
3755
  );
3275
3756
  }
3757
+ /**
3758
+ * Gets or creates a managed texture for a Text object. This method handles texture reuse and reference counting.
3759
+ * @param text - The Text object that needs a texture
3760
+ * @returns A Texture instance that represents the rendered text
3761
+ * @remarks
3762
+ * This method performs the following:
3763
+ * 1. Sets the appropriate resolution based on auto-resolution settings
3764
+ * 2. Checks if a texture already exists for the text's style
3765
+ * 3. Creates a new texture if needed or returns an existing one
3766
+ * 4. Manages reference counting for texture reuse
3767
+ */
3768
+ getManagedTexture(e) {
3769
+ e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution;
3770
+ const t = e.styleKey;
3771
+ if (this._activeTextures[t])
3772
+ return this._increaseReferenceCount(t), this._activeTextures[t].texture;
3773
+ const r = this.getTexture({
3774
+ text: e.text,
3775
+ style: e.style,
3776
+ resolution: e._resolution,
3777
+ textureStyle: e.textureStyle
3778
+ });
3779
+ return this._activeTextures[t] = {
3780
+ texture: r,
3781
+ usageCount: 1
3782
+ }, r;
3783
+ }
3784
+ /**
3785
+ * Decreases the reference count for a texture associated with a text key.
3786
+ * When the reference count reaches zero, the texture is returned to the pool.
3787
+ * @param textKey - The unique key identifying the text style configuration
3788
+ * @remarks
3789
+ * This method is crucial for memory management, ensuring textures are properly
3790
+ * cleaned up when they are no longer needed by any Text instances.
3791
+ */
3792
+ decreaseReferenceCount(e) {
3793
+ const t = this._activeTextures[e];
3794
+ t.usageCount--, t.usageCount === 0 && (this.returnTexture(t.texture), this._activeTextures[e] = null);
3795
+ }
3796
+ /**
3797
+ * Gets the current reference count for a texture associated with a text key.
3798
+ * @param textKey - The unique key identifying the text style configuration
3799
+ * @returns The number of Text instances currently using this texture
3800
+ */
3801
+ getReferenceCount(e) {
3802
+ var t;
3803
+ return ((t = this._activeTextures[e]) == null ? void 0 : t.usageCount) ?? 0;
3804
+ }
3805
+ _increaseReferenceCount(e) {
3806
+ this._activeTextures[e].usageCount++;
3807
+ }
3276
3808
  /**
3277
3809
  * Applies the specified filters to the given texture.
3278
3810
  *
@@ -3292,30 +3824,33 @@ class xt {
3292
3824
  }
3293
3825
  destroy() {
3294
3826
  this._renderer = null;
3827
+ for (const e in this._activeTextures)
3828
+ this._activeTextures[e] && this.returnTexture(this._activeTextures[e].texture);
3829
+ this._activeTextures = null;
3295
3830
  }
3296
3831
  }
3297
- xt.extension = {
3832
+ Tt.extension = {
3298
3833
  type: [
3299
- w.WebGLSystem,
3300
- w.WebGPUSystem,
3301
- w.CanvasSystem
3834
+ y.WebGLSystem,
3835
+ y.WebGPUSystem,
3836
+ y.CanvasSystem
3302
3837
  ],
3303
3838
  name: "canvasText"
3304
3839
  };
3305
- P.add(Xe);
3306
- P.add($e);
3307
- P.add(tt);
3308
- P.add(Dt);
3309
- P.add(nt);
3840
+ P.add(je);
3841
+ P.add(qe);
3310
3842
  P.add(at);
3311
- P.add(ot);
3843
+ P.add(Lt);
3844
+ P.add(lt);
3845
+ P.add(ht);
3846
+ P.add(dt);
3847
+ P.add(Tt);
3848
+ P.add(yt);
3312
3849
  P.add(xt);
3850
+ P.add(bt);
3851
+ P.add(_t);
3313
3852
  P.add(mt);
3314
- P.add(ht);
3315
3853
  P.add(gt);
3316
- P.add(ft);
3317
- P.add(dt);
3318
- P.add(ut);
3319
- P.add(Qe);
3320
- P.add(Ke);
3321
- //# sourceMappingURL=webworkerAll-CI8_Z7rX.js.map
3854
+ P.add(rt);
3855
+ P.add(tt);
3856
+ //# sourceMappingURL=webworkerAll-pikqGfAy.js.map