@sepveneto/dao 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/app/Application.d.ts +2 -2
  2. package/dist/assets/Assets.d.ts +4 -4
  3. package/dist/assets/loader/Loader.d.ts +2 -2
  4. package/dist/dao.cjs +1 -1
  5. package/dist/dao.cjs.map +1 -1
  6. package/dist/dao.js +1945 -1670
  7. package/dist/dao.js.map +1 -1
  8. package/dist/events/FederatedEvent.d.ts +2 -2
  9. package/dist/events/FederatedEventMap.d.ts +2 -2
  10. package/dist/main.d.ts +5 -5
  11. package/dist/maths/Bounds.d.ts +6 -3
  12. package/dist/maths/Matrix.d.ts +6 -10
  13. package/dist/maths/Point.d.ts +1 -1
  14. package/dist/maths/getLocalBounds.d.ts +4 -0
  15. package/dist/maths/index.d.ts +2 -2
  16. package/dist/maths/shapes/Polygon.d.ts +5 -2
  17. package/dist/maths/shapes/Rectangle.d.ts +3 -1
  18. package/dist/maths/utils.d.ts +17 -0
  19. package/dist/renderer/CanvasPool.d.ts +2 -2
  20. package/dist/renderer/RenderPipe.d.ts +6 -0
  21. package/dist/renderer/index.d.ts +15 -15
  22. package/dist/renderer/texture/RenderTexture.d.ts +1 -1
  23. package/dist/renderer/texture/Texture.d.ts +1 -1
  24. package/dist/renderer/texture/TextureSource.d.ts +4 -3
  25. package/dist/scene/ViewContainer.d.ts +3 -3
  26. package/dist/scene/batcher/Batcher.d.ts +1 -1
  27. package/dist/scene/batcher/BatcherPipe.d.ts +6 -6
  28. package/dist/scene/container/Container.d.ts +20 -20
  29. package/dist/scene/container/RenderGroup.d.ts +3 -3
  30. package/dist/scene/container/__tests__/DummyEffect.d.ts +1 -1
  31. package/dist/scene/container/__tests__/DummyView.d.ts +1 -1
  32. package/dist/scene/container/mixins/childrenHelperMixin.d.ts +1 -1
  33. package/dist/scene/container/mixins/effectMixin.d.ts +3 -3
  34. package/dist/scene/container/mixins/measureMixin.d.ts +1 -1
  35. package/dist/scene/graphics/Graphics.d.ts +7 -2
  36. package/dist/scene/graphics/GraphicsContext.d.ts +18 -32
  37. package/dist/scene/graphics/GraphicsPipe.d.ts +5 -3
  38. package/dist/scene/graphics/__tests__/Graphics.Bounds.test.d.ts +1 -0
  39. package/dist/scene/graphics/__tests__/Graphics.test.d.ts +1 -0
  40. package/dist/scene/graphics/__tests__/bounds.test.d.ts +1 -0
  41. package/dist/scene/graphics/path/GraphicsPath.d.ts +2 -2
  42. package/dist/scene/graphics/path/ShapePath.d.ts +5 -3
  43. package/dist/scene/graphics/utils/FillTypes.d.ts +28 -0
  44. package/dist/scene/graphics/utils/convertInputToStyle.d.ts +15 -0
  45. package/dist/scene/graphics/utils/getMaxMiterRatio.d.ts +11 -0
  46. package/dist/scene/index.d.ts +1 -1
  47. package/dist/scene/mask/StencilMask.d.ts +2 -2
  48. package/dist/scene/mask/StencilMaskPipe.d.ts +1 -1
  49. package/dist/scene/sprite/Sprite.d.ts +2 -2
  50. package/dist/scene/sprite/SpritePipe.d.ts +7 -2
  51. package/dist/scene/text/Text.d.ts +4 -4
  52. package/dist/scene/text/TextPipe.d.ts +5 -4
  53. package/dist/scene/text/TextStyle.d.ts +3 -3
  54. package/dist/scene/text/TextSystem.d.ts +1 -1
  55. package/dist/scene/text/utils.d.ts +18 -18
  56. package/dist/system/CanvasContextSystem.d.ts +1 -1
  57. package/dist/system/EventSystem.d.ts +10 -5
  58. package/dist/system/ExtractSystem.d.ts +2 -2
  59. package/dist/system/ViewSystem.d.ts +2 -2
  60. package/dist/ticker/Ticker.d.ts +243 -243
  61. package/dist/ticker/TickerListener.d.ts +5 -5
  62. package/dist/utils/color.d.ts +8 -0
  63. package/dist/utils/index.d.ts +0 -1
  64. package/dist/utils/pool/Pool.d.ts +17 -0
  65. package/dist/utils/pool/PoolGroup.d.ts +6 -0
  66. package/package.json +20 -26
package/dist/dao.js CHANGED
@@ -1,513 +1,384 @@
1
- var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJSMin = (n, j) => () => (j || n((j = { exports: {} }).exports, j), j.exports), __copyProps = (n, P, I, L) => {
2
- if (P && typeof P == "object" || typeof P == "function") for (var R = __getOwnPropNames(P), z = 0, B = R.length, V; z < B; z++) V = R[z], !__hasOwnProp.call(n, V) && V !== I && __defProp(n, V, {
3
- get: ((n) => P[n]).bind(null, V),
4
- enumerable: !(L = __getOwnPropDesc(P, V)) || L.enumerable
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
5
6
  });
6
- return n;
7
- }, __toESM = (M, N, F) => (F = M == null ? {} : __create(__getProtoOf(M)), __copyProps(N || !M || !M.__esModule ? __defProp(F, "default", {
8
- value: M,
7
+ return e;
8
+ }, c = (/* @__PURE__ */ ((n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
9
+ value: n,
9
10
  enumerable: !0
10
- }) : F, M));
11
- const PI_2 = Math.PI * 2;
12
- var Matrix = class n {
13
- constructor(n = 1, j = 0, M = 0, N = 1, P = 0, F = 0) {
14
- this.a = n, this.b = j, this.c = M, this.d = N, this.tx = P, this.ty = F;
15
- }
16
- static append(j, M) {
17
- return new n(M.a * j.a + M.b * j.c, M.a * j.b + M.b * j.d, M.c * j.a + M.d * j.c, M.c * j.b + M.d * j.d, M.tx * j.a + M.ty * j.c + j.tx, M.tx * j.b + M.ty * j.d + j.ty);
18
- }
19
- apply(n) {
20
- let { x: j, y: M } = n;
21
- return new Vector2(j * this.a + M * this.c + this.tx, j * this.b + M * this.d + this.ty);
11
+ }) : a, n)))((/* @__PURE__ */ o(((e, t) => {
12
+ var n = Object.prototype.hasOwnProperty, r = "~";
13
+ function i() {}
14
+ Object.create && (i.prototype = Object.create(null), new i().__proto__ || (r = !1));
15
+ function a(e, t, n) {
16
+ this.fn = e, this.context = t, this.once = n || !1;
17
+ }
18
+ function o(e, t, n, i, o) {
19
+ if (typeof n != "function") throw TypeError("The listener must be a function");
20
+ var s = new a(n, i || e, o), c = r ? r + t : t;
21
+ return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], s] : e._events[c].push(s) : (e._events[c] = s, e._eventsCount++), e;
22
+ }
23
+ function s(e, t) {
24
+ --e._eventsCount === 0 ? e._events = new i() : delete e._events[t];
25
+ }
26
+ function c() {
27
+ this._events = new i(), this._eventsCount = 0;
28
+ }
29
+ c.prototype.eventNames = function() {
30
+ var e = [], t, i;
31
+ if (this._eventsCount === 0) return e;
32
+ for (i in t = this._events) n.call(t, i) && e.push(r ? i.slice(1) : i);
33
+ return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(t)) : e;
34
+ }, c.prototype.listeners = function(e) {
35
+ var t = r ? r + e : e, n = this._events[t];
36
+ if (!n) return [];
37
+ if (n.fn) return [n.fn];
38
+ for (var i = 0, a = n.length, o = Array(a); i < a; i++) o[i] = n[i].fn;
39
+ return o;
40
+ }, c.prototype.listenerCount = function(e) {
41
+ var t = r ? r + e : e, n = this._events[t];
42
+ return n ? n.fn ? 1 : n.length : 0;
43
+ }, c.prototype.emit = function(e, t, n, i, a, o) {
44
+ var s = r ? r + e : e;
45
+ if (!this._events[s]) return !1;
46
+ var c = this._events[s], l = arguments.length, u, d;
47
+ if (c.fn) {
48
+ switch (c.once && this.removeListener(e, c.fn, void 0, !0), l) {
49
+ case 1: return c.fn.call(c.context), !0;
50
+ case 2: return c.fn.call(c.context, t), !0;
51
+ case 3: return c.fn.call(c.context, t, n), !0;
52
+ case 4: return c.fn.call(c.context, t, n, i), !0;
53
+ case 5: return c.fn.call(c.context, t, n, i, a), !0;
54
+ case 6: return c.fn.call(c.context, t, n, i, a, o), !0;
55
+ }
56
+ for (d = 1, u = Array(l - 1); d < l; d++) u[d - 1] = arguments[d];
57
+ c.fn.apply(c.context, u);
58
+ } else {
59
+ var f = c.length, p;
60
+ for (d = 0; d < f; d++) switch (c[d].once && this.removeListener(e, c[d].fn, void 0, !0), l) {
61
+ case 1:
62
+ c[d].fn.call(c[d].context);
63
+ break;
64
+ case 2:
65
+ c[d].fn.call(c[d].context, t);
66
+ break;
67
+ case 3:
68
+ c[d].fn.call(c[d].context, t, n);
69
+ break;
70
+ case 4:
71
+ c[d].fn.call(c[d].context, t, n, i);
72
+ break;
73
+ default:
74
+ if (!u) for (p = 1, u = Array(l - 1); p < l; p++) u[p - 1] = arguments[p];
75
+ c[d].fn.apply(c[d].context, u);
76
+ }
77
+ }
78
+ return !0;
79
+ }, c.prototype.on = function(e, t, n) {
80
+ return o(this, e, t, n, !1);
81
+ }, c.prototype.once = function(e, t, n) {
82
+ return o(this, e, t, n, !0);
83
+ }, c.prototype.removeListener = function(e, t, n, i) {
84
+ var a = r ? r + e : e;
85
+ if (!this._events[a]) return this;
86
+ if (!t) return s(this, a), this;
87
+ var o = this._events[a];
88
+ if (o.fn) o.fn === t && (!i || o.once) && (!n || o.context === n) && s(this, a);
89
+ else {
90
+ for (var c = 0, l = [], u = o.length; c < u; c++) (o[c].fn !== t || i && !o[c].once || n && o[c].context !== n) && l.push(o[c]);
91
+ l.length ? this._events[a] = l.length === 1 ? l[0] : l : s(this, a);
92
+ }
93
+ return this;
94
+ }, c.prototype.removeAllListeners = function(e) {
95
+ var t;
96
+ return e ? (t = r ? r + e : e, this._events[t] && s(this, t)) : (this._events = new i(), this._eventsCount = 0), this;
97
+ }, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = r, c.EventEmitter = c, t !== void 0 && (t.exports = c);
98
+ })))(), 1)).default;
99
+ //#endregion
100
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
101
+ function l(e) {
102
+ "@babel/helpers - typeof";
103
+ return l = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
104
+ return typeof e;
105
+ } : function(e) {
106
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
107
+ }, l(e);
108
+ }
109
+ //#endregion
110
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
111
+ function u(e, t) {
112
+ if (l(e) != "object" || !e) return e;
113
+ var n = e[Symbol.toPrimitive];
114
+ if (n !== void 0) {
115
+ var r = n.call(e, t || "default");
116
+ if (l(r) != "object") return r;
117
+ throw TypeError("@@toPrimitive must return a primitive value.");
118
+ }
119
+ return (t === "string" ? String : Number)(e);
120
+ }
121
+ //#endregion
122
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
123
+ function d(e) {
124
+ var t = u(e, "string");
125
+ return l(t) == "symbol" ? t : t + "";
126
+ }
127
+ //#endregion
128
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
129
+ function f(e, t, n) {
130
+ return (t = d(t)) in e ? Object.defineProperty(e, t, {
131
+ value: n,
132
+ enumerable: !0,
133
+ configurable: !0,
134
+ writable: !0
135
+ }) : e[t] = n, e;
136
+ }
137
+ //#endregion
138
+ //#region lib/scene/batcher/BatcherPipe.ts
139
+ var p = class {
140
+ constructor() {
141
+ f(this, "renderPipeId", "batch"), f(this, "elements", []);
22
142
  }
23
- translate(n, j) {
24
- return this.tx += n, this.ty += j, this;
143
+ }, m = class {
144
+ constructor(e) {
145
+ f(this, "_renderer", void 0), f(this, "_activeBatch", void 0), this._renderer = e;
25
146
  }
26
- rotate(n) {
27
- let j = Math.cos(n), M = Math.sin(n), N = this.a, P = this.c, F = this.tx;
28
- return this.a = N * j - this.b * M, this.b = N * M + this.b * j, this.c = P * j - this.d * M, this.d = P * M + this.d * j, this.tx = F * j - this.ty * M, this.ty = F * M + this.ty * j, this;
147
+ get batch() {
148
+ return this._activeBatch;
29
149
  }
30
- scale(n, j) {
31
- return this.a *= n, this.d *= j, this.c *= n, this.b *= j, this.tx *= n, this.ty *= j, this;
150
+ buildStart() {
151
+ this._activeBatch = new h();
32
152
  }
33
- appendFrom(n, j) {
34
- let M = n.a, N = n.b, P = n.c, F = n.d, I = n.tx, L = n.ty, R = j.a, z = j.b, B = j.c, V = j.d, H = j.tx, U = j.ty;
35
- this.a = M * R + N * B, this.b = M * z + N * V, this.c = P * R + F * B, this.d = P * z + F * V, this.tx = I * R + L * B + H, this.ty = I * z + L * V + U;
153
+ buildEnd(e) {
154
+ this.break(e);
36
155
  }
37
- set(n, j, M, N, P, F) {
38
- this.a = n, this.b = j, this.c = M, this.d = N, this.tx = P, this.ty = F;
156
+ break(e) {
157
+ this._activeBatch.build(e);
39
158
  }
40
- applyInverse(n, j) {
41
- j = j || new Vector2();
42
- let M = this.a, N = this.b, P = this.c, F = this.d, I = this.tx, L = this.ty, R = 1 / (M * F + P * -N), z = n.x, B = n.y;
43
- return j.x = F * R * z + -P * R * B + (L * P - I * F) * R, j.y = M * R * B + -N * R * z + (-L * M + I * N) * R, j;
159
+ addToBatch(e, t) {
160
+ this._activeBatch.add({
161
+ ...e,
162
+ getColor: () => e.renderable.groupColorAlpha
163
+ });
44
164
  }
45
- copyFrom(n) {
46
- return this.a = n.a, this.b = n.b, this.c = n.c, this.d = n.d, this.tx = n.tx, this.ty = n.ty, this;
165
+ execute(e) {
166
+ let t = e.elements;
167
+ if (!t || !t.length) return;
168
+ let n = this._renderer.canvasContext, r = n.activeConext;
169
+ for (let e = 0; e < t.length; e++) {
170
+ let i = t[e], a = i.roundPixels, o = (i.getColor() >>> 24 & 255) / 255;
171
+ if (o <= 0) continue;
172
+ r.globalAlpha = o, n.setContextTransform(i.transform, a === 1);
173
+ let s = i.bounds, c = i.texture, l = c.frame, u = c.source._resolution || 1, d = l.x * u, f = l.y * u, p = l.width * u, m = l.height * u, h = s.minX, g = s.minY, _ = s.maxX - s.minX, v = s.maxY - s.minY, y = h, b = g, x = _, S = v;
174
+ r.drawImage(c.source.resource, d, f, p, m, y, b, x, S);
175
+ }
47
176
  }
48
- decompose(n) {
49
- let j = this.a, M = this.b, N = this.c, P = this.d, F = n.pivot, I = -Math.atan2(-N, P), L = Math.atan2(M, j), R = Math.abs(I + L);
50
- return R < 1e-5 || Math.abs(PI_2 - R) < 1e-5 ? (n.rotation = L, n.skew.x = n.skew.y = 0) : (n.rotation = 0, n.skew.x = I, n.skew.y = L), n.scale.x = Math.sqrt(j * j + M * M), n.scale.y = Math.sqrt(N * N + P * P), n.position.x = this.tx + F.x * j + F.y * N, n.position.y = this.ty + F.x * M + F.y * P, n;
177
+ destroy() {
178
+ var e;
179
+ this._renderer = null, (e = this._activeBatch) == null || e.destroy(), this._activeBatch = null;
51
180
  }
52
- clone() {
53
- let j = new n();
54
- return j.a = this.a, j.b = this.b, j.c = this.c, j.d = this.d, j.tx = this.tx, j.ty = this.ty, j;
181
+ };
182
+ f(m, "desc", { name: "batch" });
183
+ //#endregion
184
+ //#region lib/scene/batcher/Batcher.ts
185
+ var h = class {
186
+ constructor() {
187
+ f(this, "renderPipeId", "batch"), f(this, "elements", []), f(this, "elementSize", 0);
55
188
  }
56
- }, Rectangle = class n {
57
- constructor(n = 0, j = 0, M = 0, N = 0) {
58
- this.type = "rectangle", this.x = n, this.y = j, this.width = M, this.height = N;
189
+ add(e) {
190
+ this.elements[this.elementSize++] = e;
59
191
  }
60
- getBounds() {
61
- let j = new n();
62
- return j.copyFrom(this), j;
192
+ build(e) {
193
+ let t = new p(), n = this.elements;
194
+ if (n[0]) {
195
+ for (let e = 0; e < n.length; e++) {
196
+ let r = n[e];
197
+ this.elements[e] = null, t.elements.push(r);
198
+ }
199
+ e.add(t);
200
+ }
63
201
  }
64
- copyFrom(n) {
65
- return this.x = n.x, this.y = n.y, this.width = n.width, this.height = n.height, this;
202
+ destroy() {
203
+ this.elements = null;
66
204
  }
67
- contains(n, j) {
68
- return this.width <= 0 || this.height <= 0 ? !1 : n >= this.x && n < this.x + this.width && j >= this.y && j < this.y + this.height;
205
+ }, g = Math.PI * 2, _ = class e {
206
+ constructor(e = 1, t = 0, n = 0, r = 1, i = 0, a = 0) {
207
+ f(this, "a", void 0), f(this, "b", void 0), f(this, "c", void 0), f(this, "d", void 0), f(this, "tx", void 0), f(this, "ty", void 0), this.a = e, this.b = t, this.c = n, this.d = r, this.tx = i, this.ty = a;
69
208
  }
70
- }, Vector2 = class {
71
- constructor(n = 0, j = 0) {
72
- this.x = n, this.y = j;
209
+ static get IDENTITY() {
210
+ return v.identity();
73
211
  }
74
- set(n, j) {
75
- j == null ? this.x = this.y = n : (this.x = n, this.y = j);
212
+ static append(t, n) {
213
+ return new e(n.a * t.a + n.b * t.c, n.a * t.b + n.b * t.d, n.c * t.a + n.d * t.c, n.c * t.b + n.d * t.d, n.tx * t.a + n.ty * t.c + t.tx, n.tx * t.b + n.ty * t.d + t.ty);
76
214
  }
77
- copyFrom(n) {
78
- return this.set(n.x, n.y), this;
215
+ identity() {
216
+ return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this;
79
217
  }
80
- };
81
- function nextPow2(n) {
82
- return n += n === 0 ? 1 : 0, --n, n |= n >>> 1, n |= n >>> 2, n |= n >>> 4, n |= n >>> 8, n |= n >>> 16, n + 1;
83
- }
84
- var FederatedEvent = class {
85
- constructor(n) {
86
- this.global = new Vector2(), this.screen = new Vector2(), this.system = n;
218
+ apply(e, t) {
219
+ t || (t = new b());
220
+ let { x: n, y: r } = e;
221
+ return t.x = n * this.a + r * this.c + this.tx, t.y = n * this.b + r * this.d + this.ty, t;
87
222
  }
88
- getLocalPosition(n, j) {
89
- return n.worldTransform.applyInverse(j || this.global);
223
+ translate(e, t) {
224
+ return this.tx += e, this.ty += t, this;
90
225
  }
91
- composedPath() {
92
- return (!this.path || this.path[this.path.length - 1] !== this.target) && (this.path = this.target ? this.system.propagationPath(this.target) : []), this.path;
226
+ rotate(e) {
227
+ let t = Math.cos(e), n = Math.sin(e), r = this.a, i = this.c, a = this.tx;
228
+ return this.a = r * t - this.b * n, this.b = r * n + this.b * t, this.c = i * t - this.d * n, this.d = i * n + this.d * t, this.tx = a * t - this.ty * n, this.ty = a * n + this.ty * t, this;
93
229
  }
94
- }, _EventSystem, PROPAGATION_LIMIT = 2048, EventSystem = class {
95
- constructor(n) {
96
- this.domElement = null, this.rootTarget = null, this.resolution = 1, this._allInteractiveElements = [], this._hitElements = [], this._isPointerMoveEvent = !1, this.mappingState = { trackingData: {} }, this.renderer = n, this.resolution = n.resolution, this._rootPointerEvent = new FederatedEvent(null), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
230
+ scale(e, t) {
231
+ return this.a *= e, this.d *= t, this.c *= e, this.b *= t, this.tx *= e, this.ty *= t, this;
97
232
  }
98
- get pointer() {
99
- return this._rootPointerEvent;
233
+ appendFrom(e, t) {
234
+ let n = e.a, r = e.b, i = e.c, a = e.d, o = e.tx, s = e.ty, c = t.a, l = t.b, u = t.c, d = t.d, f = t.tx, p = t.ty;
235
+ return this.a = n * c + r * u, this.b = n * l + r * d, this.c = i * c + a * u, this.d = i * l + a * d, this.tx = o * c + s * u + f, this.ty = o * l + s * d + p, this;
100
236
  }
101
- trackingData(n) {
102
- return this.mappingState.trackingData[n] || (this.mappingState.trackingData[n] = {
103
- pressTargetsByButton: {},
104
- clicksByButton: {},
105
- overTargets: null
106
- }), this.mappingState.trackingData[n];
237
+ set(e, t, n, r, i, a) {
238
+ this.a = e, this.b = t, this.c = n, this.d = r, this.tx = i, this.ty = a;
107
239
  }
108
- init() {
109
- let n = this.renderer.canvas;
110
- this.setTargetElement(n);
111
- }
112
- setTargetElement(n) {
113
- this._removeEvents(), this.domElement = n, this._addEvents();
114
- }
115
- dispatchEvent(n, j) {
116
- if (!n.target) return;
117
- let M = n.composedPath();
118
- for (let N = 0; N < M.length - 1; ++N) n.currentTarget = M[N], this._notifyTarget(n, j);
119
- n.currentTarget = n.target, this._notifyTarget(n, j);
120
- }
121
- _notifyTarget(n, j) {
122
- j != null || (j = n.type);
123
- let M = n.currentTarget._events[j];
124
- if (M) if ("fn" in M) M.once && n.target.removeListener(j, M.fn, void 0, !0), M.fn.call(M.context, n);
125
- else for (let N = 0; N < M.length; ++N) {
126
- let P = M[N];
127
- P.once && n.target.removeListener(j, P.fn, void 0, !0), P.fn.call(P.context, n);
128
- }
240
+ applyInverse(e, t) {
241
+ t = t || new b();
242
+ let n = this.a, r = this.b, i = this.c, a = this.d, o = this.tx, s = this.ty, c = 1 / (n * a + i * -r), l = e.x, u = e.y;
243
+ return t.x = a * c * l + -i * c * u + (s * i - o * a) * c, t.y = n * c * u + -r * c * l + (-s * n + o * r) * c, t;
129
244
  }
130
- propagationPath(n) {
131
- let j = [n];
132
- for (let M = 0; M < PROPAGATION_LIMIT && (n !== this.rootTarget || n.parent); ++M) {
133
- if (!n.parent) throw Error("Cannot find propagation path to disconnected target");
134
- j.push(n.parent), n = n.parent;
135
- }
136
- return j.reverse(), j;
245
+ copyFrom(e) {
246
+ return this.a = e.a, this.b = e.b, this.c = e.c, this.d = e.d, this.tx = e.tx, this.ty = e.ty, this;
137
247
  }
138
- _removeEvents() {
139
- let n = this.domElement;
140
- n && (globalThis.document.removeEventListener("pointermove", this._onPointerMove, !0), n.removeEventListener("pointerdown", this._onPointerDown, !0), n.removeEventListener("pointerleave", this._onPointerOverOut, !0), n.removeEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.removeEventListener("pointerup", this._onPointerUp, !0));
248
+ decompose(e) {
249
+ let t = this.a, n = this.b, r = this.c, i = this.d, a = e.pivot, o = -Math.atan2(-r, i), s = Math.atan2(n, t), c = Math.abs(o + s);
250
+ return c < 1e-5 || Math.abs(g - c) < 1e-5 ? (e.rotation = s, e.skew.x = e.skew.y = 0) : (e.rotation = 0, e.skew.x = o, e.skew.y = s), e.scale.x = Math.sqrt(t * t + n * n), e.scale.y = Math.sqrt(r * r + i * i), e.position.x = this.tx + a.x * t + a.y * r, e.position.y = this.ty + a.x * n + a.y * i, e;
141
251
  }
142
- _addEvents() {
143
- let n = this.domElement;
144
- if (!n) return;
145
- let j = n.style;
146
- j && (j.touchAction = "none"), globalThis.document.addEventListener("pointermove", this._onPointerMove, !0), n.addEventListener("pointerdown", this._onPointerDown, !0), n.addEventListener("pointerleave", this._onPointerOverOut, !0), n.addEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.addEventListener("pointerup", this._onPointerUp, !0);
147
- }
148
- _onPointerMove(n) {
149
- var j;
150
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
151
- this._isPointerMoveEvent = !0, this._allInteractiveElements.length = 0, this._hitElements.length = 0;
152
- let M = this._bootstrapEvent(this._rootPointerEvent, n), N = this.createPointEvent(M);
153
- this._isPointerMoveEvent = !1;
154
- let P = this.trackingData(n.pointerId), F = findMountedTarget(P.overTargets);
155
- if (((j = P.overTargets) == null ? void 0 : j.length) > 0 && F !== N.target) {
156
- let n = this.createPointEvent(M, "pointerout", F);
157
- this.dispatchEvent(n, "pointerout");
158
- let j = N.composedPath();
159
- if (!j.includes(F)) {
160
- let n = this.createPointEvent(M, "pointerleave", F);
161
- for (; n.target && !j.includes(n.target);) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
162
- }
163
- }
164
- if (F !== N.target) {
165
- let n = "pointerover", j = this.clonePointEvent(N, n);
166
- this.dispatchEvent(j, n);
167
- let M = F == null ? void 0 : F.parent;
168
- for (; M && M !== this.rootTarget.parent && M !== N.target;) M = M.parent;
169
- if (!M || M === this.rootTarget.parent) {
170
- let n = this.clonePointEvent(N, "pointerenter");
171
- for (; n.target && n.target !== F && n.target !== this.rootTarget.parent;) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
172
- }
173
- }
174
- this.dispatchEvent(N, "pointermove");
175
- let I = this._allInteractiveElements;
176
- for (let n = I.length - 1; n >= 0; --n) N.currentTarget = I[n], this._notifyTarget(N, "globalpointermove");
177
- this._allInteractiveElements.length = 0, this._hitElements.length = 0, P.overTargets = N.composedPath();
178
- }
179
- _onPointerDown(n) {
180
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
181
- let j = this._bootstrapEvent(this._rootPointerEvent, n), M = this.createPointEvent(j);
182
- this.dispatchEvent(M, "pointerdown");
183
- let N = this.trackingData(n.pointerId);
184
- N.pressTargetsByButton[n.button] = M.composedPath();
252
+ clone() {
253
+ let t = new e();
254
+ return t.a = this.a, t.b = this.b, t.c = this.c, t.d = this.d, t.tx = this.tx, t.ty = this.ty, t;
185
255
  }
186
- _onPointerOverOut(n) {
187
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
188
- let j = this._bootstrapEvent(this._rootPointerEvent, n), M = this.createPointEvent(j);
189
- this.dispatchEvent(M, "pointerout");
256
+ }, v = new _(), y = class e {
257
+ constructor(e = 0, t = 0, n = 0, r = 0) {
258
+ f(this, "x", void 0), f(this, "y", void 0), f(this, "width", void 0), f(this, "height", void 0), f(this, "type", "rectangle"), this.x = e, this.y = t, this.width = n, this.height = r;
190
259
  }
191
- _onPointerUp(n) {
192
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
193
- let j = n.target;
194
- n.composedPath && n.composedPath().length > 1 && (j = n.composedPath()[0]);
195
- let M = this._bootstrapEvent(this._rootPointerEvent, n), N = j === this.domElement ? "" : "outside", P = this.createPointEvent(M);
196
- this.dispatchEvent(P, `pointerup${N}`);
260
+ getBounds() {
261
+ let t = new e();
262
+ return t.copyFrom(this), t;
197
263
  }
198
- _isInteractive(n) {
199
- return n === "static";
264
+ copyFrom(e) {
265
+ return this.x = e.x, this.y = e.y, this.width = e.width, this.height = e.height, this;
200
266
  }
201
- _bootstrapEvent(n, j) {
202
- return n.nativeEvent = j, this.mapPositionToPoint(n.screen, j.clientX, j.clientY), n.global.copyFrom(n.screen), j.type === "pointerleave" ? n.type = "pointerout" : n.type = j.type, n;
267
+ strokeContains(e, t, n, r = .5) {
268
+ let { width: i, height: a } = this;
269
+ if (i <= 0 || a <= 0) return !1;
270
+ let o = this.x, s = this.y, c = n * (1 - r), l = n - c, u = o - c, d = o + i + c, f = s - c, p = s + a + c, m = o + l, h = o + i - l, g = s + l, _ = s + a - l;
271
+ return e >= u && e <= d && t >= f && t <= p && !(e > m && e < h && t > g && t < _);
203
272
  }
204
- createPointEvent(n, j, M) {
205
- var N;
206
- let P = new FederatedEvent(this);
207
- return P.global.copyFrom(n.global), P.screen.copyFrom(n.screen), P.nativeEvent = n.nativeEvent, P.target = (N = M == null ? this.hitTest(P.global.x, P.global.y) : M) == null ? this._hitElements[0] : N, j && (P.type = j), P;
273
+ contains(e, t) {
274
+ return this.width <= 0 || this.height <= 0 ? !1 : e >= this.x && e < this.x + this.width && t >= this.y && t < this.y + this.height;
208
275
  }
209
- clonePointEvent(n, j) {
210
- let M = new FederatedEvent(this);
211
- return M.nativeEvent = n.nativeEvent, M.global = n.global, M.type = j == null ? n.type : j, M.path = n.composedPath().slice(), M.target = n.target, M;
276
+ }, b = class {
277
+ constructor(e = 0, t = 0) {
278
+ f(this, "x", void 0), f(this, "y", void 0), this.x = e, this.y = t;
212
279
  }
213
- mapPositionToPoint(n, j, M) {
214
- let N = this.domElement, P = N.isConnected ? N.getBoundingClientRect() : {
215
- x: 0,
216
- y: 0,
217
- width: N.width,
218
- height: N.height,
219
- left: 0,
220
- top: 0
221
- }, F = 1 / this.resolution;
222
- return n.x = (j - P.left) * (N.width / P.width) * F, n.y = (M - P.top) * (N.height / P.height) * F, n;
223
- }
224
- hitTest(n, j) {
225
- let M = this._isPointerMoveEvent, N = this[M ? "hitTestMoveRecursive" : "hitTestRecursive"](this.rootTarget, this.rootTarget.eventMode, new Vector2(n, j));
226
- return N && N[0];
227
- }
228
- _interactivePrune(n) {
229
- return !n || !n.visible || !n.renderable || !n.measurable || n.eventMode === "none";
230
- }
231
- hitTestMoveRecursive(n, j, M) {
232
- let N = !1;
233
- if (this._interactivePrune(n)) return;
234
- let P = n.children;
235
- if (P && P.length > 0) for (let F = P.length - 1; F >= 0; --F) {
236
- let I = P[F], L = this.hitTestMoveRecursive(I, this._isInteractive(j) ? j : I.eventMode, M);
237
- if (L) {
238
- if (L.length > 0 && !L[L.length - 1].parent) continue;
239
- let j = this._isInteractive(n.eventMode);
240
- (L.length > 0 || j) && (j && this._allInteractiveElements.push(n), L.push(n)), this._hitElements.length === 0 && (this._hitElements = L), N = !0;
241
- }
242
- }
243
- let F = this._isInteractive(j), I = this._isInteractive(n.eventMode);
244
- if (I && this._allInteractiveElements.push(n), !(this._hitElements.length > 0)) {
245
- if (N) return this._hitElements;
246
- if (F && this.hitTestFn(n, M)) return I ? [n] : [];
247
- }
280
+ set(e, t) {
281
+ t == null ? this.x = this.y = e : (this.x = e, this.y = t);
248
282
  }
249
- hitTestRecursive(n, j, M) {
250
- if (this._interactivePrune(n)) return;
251
- let N = n.children;
252
- for (let P = N.length - 1; P >= 0; P--) {
253
- let F = N[P], I = this.hitTestRecursive(F, this._isInteractive(j) ? j : F.eventMode, M);
254
- if (I) {
255
- let j = this._isInteractive(n.eventMode);
256
- return (I.length > 0 || j) && I.push(n), I;
257
- }
258
- }
259
- let P = this._isInteractive(j), F = this._isInteractive(n.eventMode);
260
- return P && this.hitTestFn(n, M) ? F ? [n] : [] : null;
261
- }
262
- hitTestFn(n, j) {
263
- if (n.hitArea) return !0;
264
- if (n.containsPoint) {
265
- let M = n.worldTransform.applyInverse(j);
266
- return n.containsPoint(M);
267
- }
268
- return !1;
283
+ copyFrom(e) {
284
+ return this.set(e.x, e.y), this;
269
285
  }
270
286
  };
271
- _EventSystem = EventSystem, _EventSystem.desc = { name: "events" };
272
- function findMountedTarget(n) {
273
- if (!n) return;
274
- let j = n[0];
275
- for (let M = 1; M < n.length && n[M].parent === j; ++M) j = n[M];
276
- return j;
287
+ function x(e) {
288
+ return e += +(e === 0), --e, e |= e >>> 1, e |= e >>> 2, e |= e >>> 4, e |= e >>> 8, e |= e >>> 16, e + 1;
277
289
  }
278
- function clearList(n, j) {
279
- j || (j = 0);
280
- for (let M = j; M < n.length && n[M]; ++M) n[M] = null;
281
- }
282
- function assignWithIgnore(n, j, M = {}) {
283
- for (let N in j) !M[N] && j[N] !== void 0 && (n[N] = j[N]);
284
- }
285
- var InstructionSet = class {
286
- constructor() {
287
- this.instructions = [], this.instructionSize = 0;
288
- }
289
- reset() {
290
- this.instructionSize = 0;
291
- }
292
- add(n) {
293
- this.instructions[this.instructionSize++] = n;
290
+ //#endregion
291
+ //#region lib/maths/const.ts
292
+ var S = 180 / Math.PI, ee = Math.PI / 180, C = class {
293
+ constructor(e, t, n) {
294
+ f(this, "_x", void 0), f(this, "_y", void 0), f(this, "_observer", void 0), this._x = t || 0, this._y = n || 0, this._observer = e;
294
295
  }
295
- }, RenderGroup = class {
296
- constructor(n) {
297
- this.worldTransform = new Matrix(), this.localTransform = new Matrix(), this.root = null, this.instructionSet = new InstructionSet(), this.structureDidChange = !0, this.renderGroupParent = null, this.renderGroupChildren = [], this.childrenToUpdate = Object.create(null), this.childrenRenderablesToUpdate = {
298
- list: [],
299
- index: 0
300
- }, this._onRenderContainers = [], this.init(n);
301
- }
302
- init(n) {
303
- this.root = n;
304
- let j = n.children;
305
- for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
306
- }
307
- addChild(n) {
308
- if (this.structureDidChange = !0, n.parentRenderGroup = this, n.parent === this.root ? n.relativeRenderGroupDepth = 1 : n.relativeRenderGroupDepth = n.parent.relativeRenderGroupDepth + 1, n.didChange = !0, this.onChildUpdate(n), n.renderGroup) {
309
- this.addRenderGroupChild(n.renderGroup);
310
- return;
311
- }
312
- n._onRender && this.addOnRender(n);
313
- let j = n.children;
314
- for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
296
+ set(e = 0, t = e) {
297
+ return (this._x !== e || this._y !== t) && (this._x = e, this._y = t, this._observer._onUpdate(this)), this;
315
298
  }
316
- removeChild(n) {
317
- if (this.structureDidChange = !0, n.parentRenderGroup = null, n.renderGroup) {
318
- this._removeRenderGroupChild(n.renderGroup);
319
- return;
320
- }
321
- let j = n.children;
322
- for (let n = 0; n < j.length; ++n) this.removeChild(j[n]);
299
+ get x() {
300
+ return this._x;
323
301
  }
324
- removeChildren(n) {
325
- for (let j = 0; j < n.length; ++j) this.removeChild(n[j]);
302
+ set x(e) {
303
+ this._x !== e && (this._x = e, this._observer._onUpdate(this));
326
304
  }
327
- addRenderGroupChild(n) {
328
- n.renderGroupParent && n.renderGroupParent._removeRenderGroupChild(n), n.renderGroupParent = this, this.renderGroupChildren.push(n);
305
+ get y() {
306
+ return this._y;
329
307
  }
330
- _removeRenderGroupChild(n) {
331
- let j = this.renderGroupChildren.indexOf(n);
332
- j > -1 && this.renderGroupChildren.splice(j, 1), n.renderGroupParent = null;
308
+ set y(e) {
309
+ this._y !== e && (this._y = e, this._observer._onUpdate(this));
333
310
  }
334
- addOnRender(n) {
335
- this._onRenderContainers.push(n);
311
+ copyFrom(e) {
312
+ return (this.x !== e.x || this.y !== e.y) && (this._x = e.x, this._y = e.y, this._observer._onUpdate(this)), this;
336
313
  }
337
- removeOnRender(n) {
338
- this._onRenderContainers.splice(this._onRenderContainers.indexOf(n), 1);
314
+ toVector2() {
315
+ return new b(this.x, this.y);
339
316
  }
340
- runOnRender(n) {
341
- for (let j = 0; j < this._onRenderContainers.length; ++j) this._onRenderContainers[j]._onRender(n);
317
+ }, te = class {
318
+ constructor(e) {
319
+ f(this, "_classType", void 0), f(this, "_pool", []), f(this, "_index", 0), f(this, "_count", 0), this._classType = e;
342
320
  }
343
- onChildViewUpdate(n) {
344
- this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++] = n;
321
+ get(e) {
322
+ var t;
323
+ let n;
324
+ return this._index > 0 ? n = this._pool[--this._index] : (n = new this._classType(), this._count++), (t = n.init) == null || t.call(n, e), n;
345
325
  }
346
- onChildUpdate(n) {
347
- let j = this.childrenToUpdate[n.relativeRenderGroupDepth];
348
- j || (j = this.childrenToUpdate[n.relativeRenderGroupDepth] = {
349
- index: 0,
350
- list: []
351
- }), j.list[j.index++] = n;
326
+ return(e) {
327
+ var t;
328
+ (t = e.reset) == null || t.call(e), this._pool[this._index++] = e;
352
329
  }
353
- updateRenderable(n) {
354
- n.globalDisplayStatus < 7 || (this.instructionSet.renderPipes[n.renderPipeId].updateRenderable(n), n.didViewUpdate = !1);
330
+ clear() {
331
+ if (this._pool.length > 0 && this._pool[0].destroy) for (let e = 0; e < this._index; ++e) this._pool[e].destroy();
332
+ this._pool.length = 0, this._count = 0, this._index = 0;
355
333
  }
356
- destroy() {
357
- this.root = null, this.childrenRenderablesToUpdate = null, this.childrenToUpdate = null, this._onRenderContainers = null, this.renderGroupChildren = null, this.instructionSet = null;
334
+ }, ne = new class {
335
+ constructor() {
336
+ f(this, "_poolsByClass", /* @__PURE__ */ new Map());
358
337
  }
359
- }, uidCache = { default: -1 };
360
- function uid(n = "default") {
361
- return uidCache[n] === void 0 && (uidCache[n] = -1), ++uidCache[n];
362
- }
363
- function updateBounds(n, j, M) {
364
- let { width: N, height: P } = M.orig;
365
- n.minX = -j.x * N, n.minY = -j.y * P, n.maxX = n.minX + N, n.maxY = n.minY + P;
366
- }
367
- function applyMixins(n, ...j) {
368
- for (let M of j) Object.defineProperties(n.prototype, Object.getOwnPropertyDescriptors(M));
369
- }
370
- var ObservablePoint = class {
371
- constructor(n, j, M) {
372
- this._x = j || 0, this._y = M || 0, this._observer = n;
338
+ getPool(e) {
339
+ return this._poolsByClass.has(e) || this._poolsByClass.set(e, new te(e)), this._poolsByClass.get(e);
373
340
  }
374
- set(n = 0, j = n) {
375
- return (this._x !== n || this._y !== j) && (this._x = n, this._y = j, this._observer._onUpdate(this)), this;
341
+ }(), w = class e {
342
+ constructor(e = Infinity, t = Infinity, n = -Infinity, r = -Infinity) {
343
+ f(this, "minX", Infinity), f(this, "minY", Infinity), f(this, "maxX", -Infinity), f(this, "maxY", -Infinity), f(this, "matrix", new _()), f(this, "_rectangle", void 0), this.minX = e, this.minY = t, this.maxX = n, this.maxY = r;
376
344
  }
377
345
  get x() {
378
- return this._x;
346
+ return this.minX;
379
347
  }
380
- set x(n) {
381
- this._x !== n && (this._x = n, this._observer._onUpdate(this));
348
+ set x(e) {
349
+ let t = this.maxX - this.minX;
350
+ this.minX = e, this.maxX = e + t;
382
351
  }
383
352
  get y() {
384
- return this._y;
385
- }
386
- set y(n) {
387
- this._y !== n && (this._y = n, this._observer._onUpdate(this));
388
- }
389
- copyFrom(n) {
390
- return (this.x !== n.x || this.y !== n.y) && (this._x = n.x, this._y = n.y, this._observer._onUpdate(this)), this;
353
+ return this.minY;
391
354
  }
392
- toVector2() {
393
- return new Vector2(this.x, this.y);
394
- }
395
- };
396
- const RAD_TO_DEG = 180 / Math.PI, DEG_TO_RAD = Math.PI / 180;
397
- var eventemitter3_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((n, j) => {
398
- var M = Object.prototype.hasOwnProperty, N = "~";
399
- function P() {}
400
- Object.create && (P.prototype = Object.create(null), new P().__proto__ || (N = !1));
401
- function F(n, j, M) {
402
- this.fn = n, this.context = j, this.once = M || !1;
403
- }
404
- function I(n, j, M, P, I) {
405
- if (typeof M != "function") throw TypeError("The listener must be a function");
406
- var L = new F(M, P || n, I), R = N ? N + j : j;
407
- return n._events[R] ? n._events[R].fn ? n._events[R] = [n._events[R], L] : n._events[R].push(L) : (n._events[R] = L, n._eventsCount++), n;
408
- }
409
- function L(n, j) {
410
- --n._eventsCount === 0 ? n._events = new P() : delete n._events[j];
411
- }
412
- function R() {
413
- this._events = new P(), this._eventsCount = 0;
414
- }
415
- R.prototype.eventNames = function() {
416
- var n = [], j, P;
417
- if (this._eventsCount === 0) return n;
418
- for (P in j = this._events) M.call(j, P) && n.push(N ? P.slice(1) : P);
419
- return Object.getOwnPropertySymbols ? n.concat(Object.getOwnPropertySymbols(j)) : n;
420
- }, R.prototype.listeners = function(n) {
421
- var j = N ? N + n : n, M = this._events[j];
422
- if (!M) return [];
423
- if (M.fn) return [M.fn];
424
- for (var P = 0, F = M.length, I = Array(F); P < F; P++) I[P] = M[P].fn;
425
- return I;
426
- }, R.prototype.listenerCount = function(n) {
427
- var j = N ? N + n : n, M = this._events[j];
428
- return M ? M.fn ? 1 : M.length : 0;
429
- }, R.prototype.emit = function(n, j, M, P, F, I) {
430
- var L = N ? N + n : n;
431
- if (!this._events[L]) return !1;
432
- var R = this._events[L], z = arguments.length, B, V;
433
- if (R.fn) {
434
- switch (R.once && this.removeListener(n, R.fn, void 0, !0), z) {
435
- case 1: return R.fn.call(R.context), !0;
436
- case 2: return R.fn.call(R.context, j), !0;
437
- case 3: return R.fn.call(R.context, j, M), !0;
438
- case 4: return R.fn.call(R.context, j, M, P), !0;
439
- case 5: return R.fn.call(R.context, j, M, P, F), !0;
440
- case 6: return R.fn.call(R.context, j, M, P, F, I), !0;
441
- }
442
- for (V = 1, B = Array(z - 1); V < z; V++) B[V - 1] = arguments[V];
443
- R.fn.apply(R.context, B);
444
- } else {
445
- var H = R.length, U;
446
- for (V = 0; V < H; V++) switch (R[V].once && this.removeListener(n, R[V].fn, void 0, !0), z) {
447
- case 1:
448
- R[V].fn.call(R[V].context);
449
- break;
450
- case 2:
451
- R[V].fn.call(R[V].context, j);
452
- break;
453
- case 3:
454
- R[V].fn.call(R[V].context, j, M);
455
- break;
456
- case 4:
457
- R[V].fn.call(R[V].context, j, M, P);
458
- break;
459
- default:
460
- if (!B) for (U = 1, B = Array(z - 1); U < z; U++) B[U - 1] = arguments[U];
461
- R[V].fn.apply(R[V].context, B);
462
- }
463
- }
464
- return !0;
465
- }, R.prototype.on = function(n, j, M) {
466
- return I(this, n, j, M, !1);
467
- }, R.prototype.once = function(n, j, M) {
468
- return I(this, n, j, M, !0);
469
- }, R.prototype.removeListener = function(n, j, M, P) {
470
- var F = N ? N + n : n;
471
- if (!this._events[F]) return this;
472
- if (!j) return L(this, F), this;
473
- var I = this._events[F];
474
- if (I.fn) I.fn === j && (!P || I.once) && (!M || I.context === M) && L(this, F);
475
- else {
476
- for (var R = 0, z = [], B = I.length; R < B; R++) (I[R].fn !== j || P && !I[R].once || M && I[R].context !== M) && z.push(I[R]);
477
- z.length ? this._events[F] = z.length === 1 ? z[0] : z : L(this, F);
478
- }
479
- return this;
480
- }, R.prototype.removeAllListeners = function(n) {
481
- var j;
482
- return n ? (j = N ? N + n : n, this._events[j] && L(this, j)) : (this._events = new P(), this._eventsCount = 0), this;
483
- }, R.prototype.off = R.prototype.removeListener, R.prototype.addListener = R.prototype.on, R.prefixed = N, R.EventEmitter = R, j !== void 0 && (j.exports = R);
484
- })))(), 1)).default, Bounds = class n {
485
- constructor(n = Infinity, j = Infinity, M = -Infinity, N = -Infinity) {
486
- this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity, this.matrix = new Matrix(), this.minX = n, this.minY = j, this.maxX = M, this.maxY = N;
355
+ set y(e) {
356
+ let t = this.maxY - this.minY;
357
+ this.minY = e, this.maxY = e + t;
487
358
  }
488
359
  clone() {
489
- return new n(this.minX, this.minY, this.maxX, this.maxY);
360
+ return new e(this.minX, this.minY, this.maxX, this.maxY);
490
361
  }
491
362
  isEmpty() {
492
363
  return this.minX >= this.maxX || this.minY >= this.maxY;
493
364
  }
494
365
  clear() {
495
- this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity;
366
+ return this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity, this;
496
367
  }
497
- pad(n, j = n) {
498
- return this.minX -= n, this.maxX += n, this.minY -= j, this.maxY += j, this;
368
+ pad(e, t = e) {
369
+ return this.minX -= e, this.maxX += e, this.minY -= t, this.maxY += t, this;
499
370
  }
500
371
  get width() {
501
372
  return this.maxX - this.minX;
502
373
  }
503
- set width(n) {
504
- this.maxX = this.minX + n;
374
+ set width(e) {
375
+ this.maxX = this.minX + e;
505
376
  }
506
377
  get height() {
507
378
  return this.maxY - this.minY;
508
379
  }
509
- set height(n) {
510
- this.maxY = this.minY + n;
380
+ set height(e) {
381
+ this.maxY = this.minY + e;
511
382
  }
512
383
  get left() {
513
384
  return this.minX;
@@ -524,492 +395,491 @@ var eventemitter3_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJS
524
395
  get isValid() {
525
396
  return this.minX + this.minY !== Infinity;
526
397
  }
527
- set(n, j, M, N) {
528
- this.minX = n, this.minY = j, this.maxX = M, this.maxY = N;
398
+ set(e, t, n, r) {
399
+ this.minX = e, this.minY = t, this.maxX = n, this.maxY = r;
529
400
  }
530
- addBounds(n, j) {
531
- this.addFrame(n.minX, n.minY, n.maxX, n.maxY, j);
401
+ addBounds(e, t) {
402
+ this.addFrame(e.minX, e.minY, e.maxX, e.maxY, t);
532
403
  }
533
- addRect(n, j) {
534
- this.addFrame(n.x, n.y, n.width + n.x, n.height + n.y, j);
404
+ addRect(e, t) {
405
+ this.addFrame(e.x, e.y, e.width + e.x, e.height + e.y, t);
535
406
  }
536
- addFrame(n, j, M, N, P) {
537
- P || (P = this.matrix);
538
- let F = P.a, I = P.b, L = P.c, R = P.d, z = P.tx, B = P.ty;
539
- updateMinMax(F * n + L * j + z, I * n + R * j + B, this), updateMinMax(F * M + L * j + z, I * M + R * j + B, this), updateMinMax(F * n + L * N + z, I * n + R * N + B, this), updateMinMax(F * M + L * N + z, I * M + R * N + B, this);
407
+ addFrame(e, t, n, r, i) {
408
+ i || (i = this.matrix);
409
+ let a = i.a, o = i.b, s = i.c, c = i.d, l = i.tx, u = i.ty, d = this.minX, f = this.minY, p = this.maxX, m = this.maxY, h = a * e + s * t + l, g = o * e + c * t + u;
410
+ h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), h = a * n + s * t + l, g = o * n + c * t + u, h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), h = a * e + s * r + l, g = o * e + c * r + u, h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), h = a * n + s * r + l, g = o * n + c * r + u, h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), this.minX = d, this.minY = f, this.maxX = p, this.maxY = m;
540
411
  }
541
412
  get rectangle() {
542
- this._rectangle || (this._rectangle = new Rectangle());
543
- let n = this._rectangle;
544
- return this.minX > this.maxX || this.minY > this.maxY ? (n.x = 0, n.y = 0, n.width = 0, n.height = 0) : (n.x = this.minX, n.y = this.minY, n.width = this.maxX - this.minX, n.height = this.maxY - this.minY), n;
545
- }
546
- addBoundsMask(n) {
547
- this.minX = this.minX > n.minX ? this.minX : n.minX, this.minY = this.minY > n.minY ? this.minY : n.minY, this.maxX = this.maxX < n.maxX ? this.maxX : n.maxX, this.maxY = this.maxY < n.maxY ? this.maxY : n.maxY;
548
- }
549
- };
550
- function updateMinMax(n, j, M) {
551
- n < M.minX && (M.minX = n), n > M.maxX && (M.maxX = n), j < M.minY && (M.minY = j), j > M.maxY && (M.maxY = j);
413
+ this._rectangle || (this._rectangle = new y());
414
+ let e = this._rectangle;
415
+ return this.minX > this.maxX || this.minY > this.maxY ? (e.x = 0, e.y = 0, e.width = 0, e.height = 0) : (e.x = this.minX, e.y = this.minY, e.width = this.maxX - this.minX, e.height = this.maxY - this.minY), e;
416
+ }
417
+ addBoundsMask(e) {
418
+ this.minX = this.minX > e.minX ? this.minX : e.minX, this.minY = this.minY > e.minY ? this.minY : e.minY, this.maxX = this.maxX < e.maxX ? this.maxX : e.maxX, this.maxY = this.maxY < e.maxY ? this.maxY : e.maxY;
419
+ }
420
+ containsPoint(e, t) {
421
+ return this.minX <= e && e <= this.maxX && this.minY <= t && t <= this.maxY;
422
+ }
423
+ }, T = ne.getPool(_), re = ne.getPool(w);
424
+ function ie(e, t, n, r, i, a) {
425
+ let o = e - n, s = t - r, c = i - n, l = a - r, u = o * c + s * l, d = c * c + l * l, f = -1;
426
+ d !== 0 && (f = u / d);
427
+ let p, m;
428
+ f < 0 ? (p = n, m = r) : f > 1 ? (p = i, m = a) : (p = n + f * c, m = r + f * l);
429
+ let h = e - p, g = t - m;
430
+ return h * h + g * g;
431
+ }
432
+ //#endregion
433
+ //#region lib/utils/uid.ts
434
+ var E = { default: -1 };
435
+ function D(e = "default") {
436
+ return E[e] === void 0 && (E[e] = -1), ++E[e];
437
+ }
438
+ //#endregion
439
+ //#region lib/utils/index.ts
440
+ function ae(e, t, n) {
441
+ let { width: r, height: i } = n.orig;
442
+ e.minX = -t.x * r, e.minY = -t.y * i, e.maxX = e.minX + r, e.maxY = e.minY + i;
552
443
  }
553
- function getLocalBounds(n, j, M) {
554
- return j.clear(), M || (M = new Matrix()), _getLocalBounds(n, j, M, n, !0), j.isValid || j.set(0, 0, 0, 0), j;
444
+ function oe(e, ...t) {
445
+ for (let n of t) Object.defineProperties(e.prototype, Object.getOwnPropertyDescriptors(n));
555
446
  }
556
- function _getLocalBounds(n, j, M, N, P) {
557
- let F = new Matrix();
558
- if (P) F.copyFrom(M);
447
+ //#endregion
448
+ //#region lib/scene/container/mixins/childrenHelperMixin.ts
449
+ var se = { removeChildren(e = 0, t) {
450
+ let n = t == null ? this.children.length : t, r = n - e, i = [];
451
+ if (r > 0 && r <= n) {
452
+ for (let t = n - 1; t >= e; --t) {
453
+ let e = this.children[t];
454
+ e && (i.push(e), e.parent = null);
455
+ }
456
+ ce(this.children, e, n);
457
+ let t = this.renderGroup || this.parentRenderGroup;
458
+ return t && t.removeChildren(i), i.length > 0 && this._didViewChangeTick++, i;
459
+ } else if (r === 0 && this.children.length === 0) return i;
460
+ throw Error("removeChildren: numeric values are outside the acceptable range.");
461
+ } };
462
+ function ce(e, t, n) {
463
+ let r = e.length, i;
464
+ if (t >= r || n === 0) return;
465
+ n = t + n > r ? r - t : n;
466
+ let a = r - n;
467
+ for (i = t; i < a; ++i) e[i] = e[i + n];
468
+ e.length = a;
469
+ }
470
+ //#endregion
471
+ //#region lib/maths/getLocalBounds.ts
472
+ function O(e, t, n) {
473
+ return t.clear(), n || (n = new _()), le(e, t, n, e, !0), t.isValid || t.set(0, 0, 0, 0), t;
474
+ }
475
+ function le(e, t, n, r, i) {
476
+ let a;
477
+ if (i) a = T.get(), a.copyFrom(n);
559
478
  else {
560
- if (!n.visible || !n.measurable) return;
561
- n.updateLocalTransform(), F.appendFrom(n.localTransform, M);
479
+ if (!e.visible || !e.measurable) return;
480
+ e.updateLocalTransform(), a = T.get(), a.appendFrom(e.localTransform, n);
562
481
  }
563
- let I = j, L = !!n.effects.length;
564
- if (L && (j = new Bounds()), n.boundsArea) j.addRect(n.boundsArea, F);
482
+ let o = t, s = !!e.effects.length;
483
+ if (s && (t = re.get().clear()), e.boundsArea) t.addRect(e.boundsArea, a);
565
484
  else {
566
- n.renderPipeId && (j.matrix = F, j.addBounds(n.bounds));
567
- let M = n.children;
568
- for (let n = 0; n < M.length; n++) _getLocalBounds(M[n], j, F, N, !1);
569
- if (L) {
570
- for (let M = 0; M < n.effects.length; ++M) {
571
- var R, z;
572
- (R = (z = n.effects[M]).addLocalBounds) == null || R.call(z, j, N);
485
+ e.renderPipeId && (t.matrix = a, t.addBounds(e.bounds));
486
+ let n = e.children;
487
+ for (let e = 0; e < n.length; e++) le(n[e], t, a, r, !1);
488
+ if (s) {
489
+ for (let n = 0; n < e.effects.length; ++n) {
490
+ var c, l;
491
+ (c = (l = e.effects[n]).addLocalBounds) == null || c.call(l, t, r);
573
492
  }
574
- I.addBounds(j, new Matrix());
493
+ o.addBounds(t, _.IDENTITY), re.return(t);
575
494
  }
576
495
  }
577
- return j;
496
+ T.return(a);
578
497
  }
579
- var StencilMask = class {
580
- constructor(n) {
581
- this.pipe = "stencilMask", this.mask = n, n.includeInBuild = !1, n.measurable = !1;
582
- }
583
- addLocalBounds(n, j) {
584
- let M = new Bounds();
498
+ //#endregion
499
+ //#region lib/scene/mask/StencilMask.ts
500
+ var ue = class {
501
+ constructor(e) {
502
+ f(this, "pipe", "stencilMask"), f(this, "mask", void 0), this.mask = e, e.includeInBuild = !1, e.measurable = !1;
503
+ }
504
+ addLocalBounds(e, t) {
505
+ let n = new w();
585
506
  this.mask.measurable = !0;
586
- let N = getMatrixRelativeToParent(this.mask, j);
587
- getLocalBounds(this.mask, M, N), this.mask.measurable = !1, n.addBoundsMask(M);
507
+ let r = de(this.mask, t);
508
+ O(this.mask, n, r), this.mask.measurable = !1, e.addBoundsMask(n);
588
509
  }
589
510
  };
590
- function getMatrixRelativeToParent(n, j, M) {
591
- return M || (M = new Matrix()), n === j ? M : (M = getMatrixRelativeToParent(n.parent, j, M), n.updateLocalTransform(), Matrix.append(M, n.localTransform));
511
+ function de(e, t, n) {
512
+ return n || (n = new _()), e === t ? n : (n = de(e.parent, t, n), e.updateLocalTransform(), _.append(n, e.localTransform));
592
513
  }
593
- const effectMixin = {
514
+ //#endregion
515
+ //#region lib/scene/container/mixins/effectMixin.ts
516
+ var fe = {
594
517
  effects: [],
595
518
  _maskEffect: null,
596
- addEffect(n) {
597
- this.effects.push(n), this._updateIsSimple();
519
+ addEffect(e) {
520
+ this.effects.push(e), this._updateIsSimple();
598
521
  },
599
- removeEffect(n) {
600
- let j = this.effects.indexOf(n);
601
- j === -1 && this.effects.splice(j, 1), this._updateIsSimple();
522
+ removeEffect(e) {
523
+ let t = this.effects.indexOf(e);
524
+ t === -1 && this.effects.splice(t, 1), this._updateIsSimple();
602
525
  },
603
- set mask(n) {
604
- let j = this._maskEffect;
605
- n !== (j == null ? void 0 : j.mask) && (j && (this.removeEffect(j), this._maskEffect = null), n != null && (this._maskEffect = new StencilMask(n), this.addEffect(this._maskEffect)));
526
+ set mask(e) {
527
+ let t = this._maskEffect;
528
+ e !== (t == null ? void 0 : t.mask) && (t && (this.removeEffect(t), this._maskEffect = null), e != null && (this._maskEffect = new ue(e), this.addEffect(this._maskEffect)));
606
529
  },
607
530
  get mask() {
608
- var n;
609
- return (n = this._maskEffect) == null ? void 0 : n.mask;
531
+ var e;
532
+ return (e = this._maskEffect) == null ? void 0 : e.mask;
610
533
  }
611
- }, sortMixin = {
612
- _zIndex: 0,
613
- sortableChildren: !1,
614
- sortDirty: !1
615
- }, measureMixin = {
534
+ }, pe = {
616
535
  _localBoundsCacheData: null,
617
- _setWidth(n, j) {
618
- let M = Math.sign(this.scale.x) || 1;
619
- j === 0 ? this.scale.x = M : this.scale.x = n / j * M;
536
+ _setWidth(e, t) {
537
+ let n = Math.sign(this.scale.x) || 1;
538
+ t === 0 ? this.scale.x = n : this.scale.x = e / t * n;
620
539
  },
621
- _setHeight(n, j) {
622
- let M = Math.sign(this.scale.y) || 1;
623
- j === 0 ? this.scale.y = M : this.scale.y = n / j * M;
540
+ _setHeight(e, t) {
541
+ let n = Math.sign(this.scale.y) || 1;
542
+ t === 0 ? this.scale.y = n : this.scale.y = e / t * n;
624
543
  },
625
544
  getLocalBounds() {
626
545
  this._localBoundsCacheData || (this._localBoundsCacheData = {
627
546
  data: [],
628
547
  index: 1,
629
548
  didChange: !1,
630
- localBounds: new Bounds()
549
+ localBounds: new w()
631
550
  });
632
- let n = this._localBoundsCacheData;
633
- return n.index = 1, n.didChange = !1, n.data[0] !== this._didViewChangeTick && (n.didChange = !0, n.data[0] = this._didViewChangeTick), checkChildrenDidChange(this, n), n.didChange && getLocalBounds(this, n.localBounds), n.localBounds;
551
+ let e = this._localBoundsCacheData;
552
+ return e.index = 1, e.didChange = !1, e.data[0] !== this._didViewChangeTick && (e.didChange = !0, e.data[0] = this._didViewChangeTick), me(this, e), e.didChange && O(this, e.localBounds), e.localBounds;
634
553
  }
635
554
  };
636
- function checkChildrenDidChange(n, j) {
637
- let M = n.children;
638
- for (let n = 0; n < M.length; ++n) {
639
- let N = M[n], P = N.uid, F = (N._didViewChangeTick & 65535) << 16 | N._didContainerChangeTick & 65535, I = j.index;
640
- (j.data[I] !== P || j.data[I + 1] !== F) && (j.data[I] = P, j.data[I + 1] = F, j.didChange = !0), j.index += 2, N.children.length && checkChildrenDidChange(N, j);
555
+ function me(e, t) {
556
+ let n = e.children;
557
+ for (let e = 0; e < n.length; ++e) {
558
+ let r = n[e], i = r.uid, a = (r._didViewChangeTick & 65535) << 16 | r._didContainerChangeTick & 65535, o = t.index;
559
+ (t.data[o] !== i || t.data[o + 1] !== a) && (t.data[o] = i, t.data[o + 1] = a, t.didChange = !0), t.index += 2, r.children.length && me(r, t);
641
560
  }
642
- return j.didChange;
561
+ return t.didChange;
643
562
  }
644
- const childrenHelperMixin = { removeChildren(n = 0, j) {
645
- let M = j == null ? this.children.length : j, N = M - n, P = [];
646
- if (N > 0 && N <= M) {
647
- for (let j = M - 1; j >= n; --j) {
648
- let n = this.children[j];
649
- n && (P.push(n), n.parent = null);
563
+ //#endregion
564
+ //#region lib/scene/container/mixins/sortMixin.ts
565
+ var he = {
566
+ _zIndex: 0,
567
+ sortableChildren: !1,
568
+ sortDirty: !1
569
+ }, ge = class {
570
+ constructor() {
571
+ f(this, "instructions", []), f(this, "instructionSize", 0), f(this, "renderPipes", void 0);
572
+ }
573
+ reset() {
574
+ this.instructionSize = 0;
575
+ }
576
+ add(e) {
577
+ this.instructions[this.instructionSize++] = e;
578
+ }
579
+ }, _e = class {
580
+ constructor(e) {
581
+ f(this, "worldTransform", new _()), f(this, "localTransform", new _()), f(this, "root", null), f(this, "instructionSet", new ge()), f(this, "structureDidChange", !0), f(this, "renderGroupParent", null), f(this, "renderGroupChildren", []), f(this, "childrenToUpdate", Object.create(null)), f(this, "childrenRenderablesToUpdate", {
582
+ list: [],
583
+ index: 0
584
+ }), f(this, "_onRenderContainers", []), this.init(e);
585
+ }
586
+ init(e) {
587
+ this.root = e;
588
+ let t = e.children;
589
+ for (let e = 0; e < t.length; ++e) this.addChild(t[e]);
590
+ }
591
+ addChild(e) {
592
+ if (this.structureDidChange = !0, e.parentRenderGroup = this, e.parent === this.root ? e.relativeRenderGroupDepth = 1 : e.relativeRenderGroupDepth = e.parent.relativeRenderGroupDepth + 1, e.didChange = !0, this.onChildUpdate(e), e.renderGroup) {
593
+ this.addRenderGroupChild(e.renderGroup);
594
+ return;
650
595
  }
651
- removeItems(this.children, n, M);
652
- let j = this.renderGroup || this.parentRenderGroup;
653
- return j && j.removeChildren(P), P.length > 0 && this._didViewChangeTick++, P;
654
- } else if (N === 0 && this.children.length === 0) return P;
655
- throw Error("removeChildren: numeric values are outside the acceptable range.");
656
- } };
657
- function removeItems(n, j, M) {
658
- let N = n.length, P;
659
- if (j >= N || M === 0) return;
660
- M = j + M > N ? N - j : M;
661
- let F = N - M;
662
- for (P = j; P < F; ++P) n[P] = n[P + M];
663
- n.length = F;
596
+ e._onRender && this.addOnRender(e);
597
+ let t = e.children;
598
+ for (let e = 0; e < t.length; ++e) this.addChild(t[e]);
599
+ }
600
+ removeChild(e) {
601
+ if (this.structureDidChange = !0, e.parentRenderGroup = null, e.renderGroup) {
602
+ this._removeRenderGroupChild(e.renderGroup);
603
+ return;
604
+ }
605
+ let t = e.children;
606
+ for (let e = 0; e < t.length; ++e) this.removeChild(t[e]);
607
+ }
608
+ removeChildren(e) {
609
+ for (let t = 0; t < e.length; ++t) this.removeChild(e[t]);
610
+ }
611
+ addRenderGroupChild(e) {
612
+ e.renderGroupParent && e.renderGroupParent._removeRenderGroupChild(e), e.renderGroupParent = this, this.renderGroupChildren.push(e);
613
+ }
614
+ _removeRenderGroupChild(e) {
615
+ let t = this.renderGroupChildren.indexOf(e);
616
+ t > -1 && this.renderGroupChildren.splice(t, 1), e.renderGroupParent = null;
617
+ }
618
+ addOnRender(e) {
619
+ this._onRenderContainers.push(e);
620
+ }
621
+ removeOnRender(e) {
622
+ this._onRenderContainers.splice(this._onRenderContainers.indexOf(e), 1);
623
+ }
624
+ runOnRender(e) {
625
+ for (let t = 0; t < this._onRenderContainers.length; ++t) this._onRenderContainers[t]._onRender(e);
626
+ }
627
+ onChildViewUpdate(e) {
628
+ this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++] = e;
629
+ }
630
+ onChildUpdate(e) {
631
+ let t = this.childrenToUpdate[e.relativeRenderGroupDepth];
632
+ t || (t = this.childrenToUpdate[e.relativeRenderGroupDepth] = {
633
+ index: 0,
634
+ list: []
635
+ }), t.list[t.index++] = e;
636
+ }
637
+ updateRenderable(e) {
638
+ e.globalDisplayStatus < 7 || (this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e), e.didViewUpdate = !1);
639
+ }
640
+ destroy() {
641
+ this.root = null, this.childrenRenderablesToUpdate = null, this.childrenToUpdate = null, this._onRenderContainers = null, this.renderGroupChildren = null, this.instructionSet = null;
642
+ }
643
+ };
644
+ //#endregion
645
+ //#region lib/scene/container/utils.ts
646
+ function ve(e, t) {
647
+ t || (t = 0);
648
+ for (let n = t; n < e.length && e[n]; ++n) e[n] = null;
649
+ }
650
+ function ye(e, t, n = {}) {
651
+ for (let r in t) !n[r] && t[r] !== void 0 && (e[r] = t[r]);
664
652
  }
665
- const UPDATE_COLOR = 1, UPDATE_BLEND = 2, UPDATE_VISIBLE = 4, UPDATE_TRANSFORM = 8;
666
- var defaultSkew = new ObservablePoint(null), defaultOrigin = new ObservablePoint(null), defaultScale = new ObservablePoint(null, 1, 1), defaultPivot = new ObservablePoint(null), Container = class extends eventemitter3_default {
667
- constructor(n = {}) {
668
- var j, M;
669
- super(), this.uid = uid("renderable"), this.destroyed = !1, this.renderGroup = null, this.parentRenderGroup = null, this.parent = null, this.eventMode = "passive", this.hitArea = null, this._position = new ObservablePoint(this, 0, 0), this.includeInBuild = !0, this.didChange = !1, this.didViewUpdate = !1, this.isSimple = !0, this.measurable = !0, this.relativeRenderGroupDepth = 0, this._didViewChangeTick = 0, this._didContainerChangeTick = 0, this._localTransformUpdateTick = 0, this._updateFlags = 15, this.localDisplayStatus = 7, this.globalDisplayStatus = 7, this.children = [], this.localTransform = new Matrix(), this.relativeGroupTransform = new Matrix(), this.groupTransform = this.relativeGroupTransform, this._rotation = 0, this._cx = 1, this._sx = 0, this._cy = 0, this._sy = 1, this._skew = defaultSkew, this._scale = defaultScale, this._origin = defaultOrigin, this._pivot = defaultPivot, this.localAlpha = 1, this.groupColor = 16777215, this.localColor = 16777215, this.groupAlpha = 1, this.groupColorAlpha = 4294967295, assignWithIgnore(this, n, {
653
+ //#endregion
654
+ //#region lib/scene/container/Container.ts
655
+ var be = 1, xe = 2, Se = 4, Ce = 8, k = new C(null), A = new C(null), j = new C(null, 1, 1), M = new C(null), N = class extends c {
656
+ constructor(e = {}) {
657
+ var t, n;
658
+ super(), f(this, "uid", D("renderable")), f(this, "label", void 0), f(this, "destroyed", !1), f(this, "renderGroup", null), f(this, "parentRenderGroup", null), f(this, "parent", null), f(this, "eventMode", "passive"), f(this, "hitArea", null), f(this, "boundsArea", void 0), f(this, "_position", new C(this, 0, 0)), f(this, "includeInBuild", !0), f(this, "renderPipeId", void 0), f(this, "didChange", !1), f(this, "didViewUpdate", !1), f(this, "isSimple", !0), f(this, "measurable", !0), f(this, "relativeRenderGroupDepth", 0), f(this, "_didViewChangeTick", 0), f(this, "_didContainerChangeTick", 0), f(this, "_localTransformUpdateTick", 0), f(this, "_updateFlags", 15), f(this, "localDisplayStatus", 7), f(this, "globalDisplayStatus", 7), f(this, "children", []), f(this, "localTransform", new _()), f(this, "relativeGroupTransform", new _()), f(this, "groupTransform", this.relativeGroupTransform), f(this, "_rotation", 0), f(this, "_worldTransform", void 0), f(this, "_cx", 1), f(this, "_sx", 0), f(this, "_cy", 0), f(this, "_sy", 1), f(this, "_skew", k), f(this, "_scale", j), f(this, "_origin", A), f(this, "_pivot", M), f(this, "localAlpha", 1), f(this, "groupColor", 16777215), f(this, "localColor", 16777215), f(this, "groupAlpha", 1), f(this, "groupColorAlpha", 4294967295), ye(this, e, {
670
659
  children: !0,
671
660
  parent: !0,
672
661
  effects: !0
673
- }), (j = n.children) == null || j.forEach((n) => this.addChild(n)), (M = n.parent) == null || M.addChild(this), this.effects = [];
662
+ }), (t = e.children) == null || t.forEach((e) => this.addChild(e)), (n = e.parent) == null || n.addChild(this), this.effects = [];
674
663
  }
675
664
  get renderable() {
676
665
  return !!(this.localDisplayStatus & 1);
677
666
  }
678
- set renderable(n) {
679
- let j = n ? 1 : 0;
680
- (this.localDisplayStatus & 1) !== j && (this._updateFlags |= 4, this.localDisplayStatus ^= 1, this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._onUpdate());
667
+ set renderable(e) {
668
+ let t = +!!e;
669
+ (this.localDisplayStatus & 1) !== t && (this._updateFlags |= 4, this.localDisplayStatus ^= 1, this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._onUpdate());
681
670
  }
682
671
  get visible() {
683
672
  return !!(this.localDisplayStatus & 2);
684
673
  }
685
- set visible(n) {
686
- let j = n ? 2 : 0;
687
- (this.localDisplayStatus & 2) !== j && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 2, this._onUpdate(), this.emit("visibleChanged", n));
674
+ set visible(e) {
675
+ let t = e ? 2 : 0;
676
+ (this.localDisplayStatus & 2) !== t && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 2, this._onUpdate(), this.emit("visibleChanged", e));
688
677
  }
689
678
  get isRenderGroup() {
690
679
  return !!this.renderGroup;
691
680
  }
692
- set isRenderGroup(n) {
693
- !!this.renderGroup !== n && (n ? this.enableRenderGroup() : this.disableRenderGroup());
681
+ set isRenderGroup(e) {
682
+ !!this.renderGroup !== e && (e ? this.enableRenderGroup() : this.disableRenderGroup());
694
683
  }
695
684
  get zIndex() {
696
685
  return this._zIndex;
697
686
  }
698
- set zIndex(n) {
699
- n !== this._zIndex && (this._zIndex = n, this.depthOfChildModified());
687
+ set zIndex(e) {
688
+ e !== this._zIndex && (this._zIndex = e, this.depthOfChildModified());
700
689
  }
701
690
  _updateIsSimple() {
702
- this.isSimple = !this.renderGroup && this.effects.length == 0;
691
+ this.isSimple = !this.renderGroup && this.effects.length === 0;
703
692
  }
704
693
  sortChildren() {
705
- this.sortDirty && (this.sortDirty = !1, this.children.sort(sortChildren));
694
+ this.sortDirty && (this.sortDirty = !1, this.children.sort(Te));
706
695
  }
707
696
  depthOfChildModified() {
708
697
  this.parent && (this.parent.sortableChildren = !0, this.parent.sortDirty = !0), this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0);
709
698
  }
710
699
  enableRenderGroup() {
711
700
  if (this.renderGroup) return;
712
- let n = this.parentRenderGroup;
713
- n == null || n.removeChild(this), this.renderGroup = new RenderGroup(this), this.groupTransform = new Matrix(), n == null || n.addChild(this), this._updateIsSimple();
701
+ let e = this.parentRenderGroup;
702
+ e == null || e.removeChild(this), this.renderGroup = new _e(this), this.groupTransform = _.IDENTITY, e == null || e.addChild(this), this._updateIsSimple();
714
703
  }
715
704
  disableRenderGroup() {
716
705
  if (!this.renderGroup) return;
717
- let n = this.parentRenderGroup;
718
- n == null || n.removeChild(this), this.renderGroup = null, this.groupTransform = this.relativeGroupTransform, n == null || n.addChild(this), this._updateIsSimple();
706
+ let e = this.parentRenderGroup;
707
+ e == null || e.removeChild(this), this.renderGroup = null, this.groupTransform = this.relativeGroupTransform, e == null || e.addChild(this), this._updateIsSimple();
719
708
  }
720
- collectRenderables(n, j) {
721
- this.globalDisplayStatus < 7 || !this.includeInBuild || (this.sortableChildren && this.sortChildren(), this.isSimple ? this.collectRenderableSimple(n, j) : this.renderGroup || this.collectRenderablesWithEffects(n, j));
709
+ collectRenderables(e, t) {
710
+ this.globalDisplayStatus < 7 || !this.includeInBuild || (this.sortableChildren && this.sortChildren(), this.isSimple ? this.collectRenderableSimple(e, t) : this.renderGroup || this.collectRenderablesWithEffects(e, t));
722
711
  }
723
- collectRenderablesWithEffects(n, j) {
724
- for (let M = 0; M < this.effects.length; ++M) {
725
- let N = this.effects[M];
726
- n[N.pipe].push(N, j);
712
+ collectRenderablesWithEffects(e, t) {
713
+ for (let n = 0; n < this.effects.length; ++n) {
714
+ let r = this.effects[n];
715
+ e[r.pipe].push(r, t);
727
716
  }
728
- this.collectRenderableSimple(n, j);
729
- for (let M = 0; M < this.effects.length; ++M) {
730
- let N = this.effects[M];
731
- n[N.pipe].pop(N, j);
717
+ this.collectRenderableSimple(e, t);
718
+ for (let n = 0; n < this.effects.length; ++n) {
719
+ let r = this.effects[n];
720
+ e[r.pipe].pop(r, t);
732
721
  }
733
722
  }
734
- collectRenderableSimple(n, j) {
735
- let M = this.children;
736
- for (let N = 0; N < M.length; ++N) M[N].collectRenderables(n, j);
723
+ collectRenderableSimple(e, t) {
724
+ let n = this.children;
725
+ for (let r = 0; r < n.length; ++r) n[r].collectRenderables(e, t);
737
726
  }
738
- setFromMatrix(n) {
739
- n.decompose(this);
727
+ setFromMatrix(e) {
728
+ e.decompose(this);
740
729
  }
741
730
  _updateSkew() {
742
- let n = this.rotation, j = this.skew;
743
- this._cx = Math.cos(n + j.y), this._sx = Math.sin(n + j.y), this._cy = -Math.sin(n - j.x), this._sy = Math.cos(n - j.x);
731
+ let e = this.rotation, t = this.skew;
732
+ this._cx = Math.cos(e + t.y), this._sx = Math.sin(e + t.y), this._cy = -Math.sin(e - t.x), this._sy = Math.cos(e - t.x);
744
733
  }
745
734
  updateLocalTransform() {
746
- let n = this._didContainerChangeTick;
747
- if (this._localTransformUpdateTick === n) return;
748
- this._localTransformUpdateTick = n, this._updateSkew();
749
- let j = this.position, M = this.localTransform, N = this._scale.x, P = this._scale.y, F = -this._origin.x, I = -this._origin.y, L = this._pivot.x, R = this._pivot.y;
750
- M.a = this._cx * N, M.b = this._sx * N, M.c = this._cy * P, M.d = this._sy * P, M.tx = j.x - (L * M.a + R * M.c) + (F * M.a + I * M.c) - F, M.ty = j.y - (L * M.b + R * M.d) + (F * M.b + I * M.d) - I;
735
+ let e = this._didContainerChangeTick;
736
+ if (this._localTransformUpdateTick === e) return;
737
+ this._localTransformUpdateTick = e, this._updateSkew();
738
+ let t = this.position, n = this.localTransform, r = this._scale.x, i = this._scale.y, a = -this._origin.x, o = -this._origin.y, s = this._pivot.x, c = this._pivot.y;
739
+ n.a = this._cx * r, n.b = this._sx * r, n.c = this._cy * i, n.d = this._sy * i, n.tx = t.x - (s * n.a + c * n.c) + (a * n.a + o * n.c) - a, n.ty = t.y - (s * n.b + c * n.d) + (a * n.b + o * n.d) - o;
751
740
  }
752
741
  get alpha() {
753
742
  return this.localAlpha;
754
743
  }
755
- set alpha(n) {
756
- n !== this.localAlpha && (this.localAlpha = n, this._updateFlags |= 1, this._onUpdate());
744
+ set alpha(e) {
745
+ e !== this.localAlpha && (this.localAlpha = e, this._updateFlags |= 1, this._onUpdate());
757
746
  }
758
747
  get root() {
759
- let n = this.parent, j = this.parent;
760
- for (; n;) n.parent || (j = n), n = n.parent;
761
- return j;
748
+ let e = this.parent, t = this.parent;
749
+ for (; e;) e.parent || (t = e), e = e.parent;
750
+ return t;
762
751
  }
763
752
  get worldTransform() {
764
- return this._worldTransform || (this._worldTransform = new Matrix()), this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform), this._worldTransform;
753
+ return this._worldTransform || (this._worldTransform = new _()), this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform), this._worldTransform;
765
754
  }
766
755
  get x() {
767
756
  return this._position.x;
768
757
  }
769
- set x(n) {
770
- this._position.x = n;
758
+ set x(e) {
759
+ this._position.x = e;
771
760
  }
772
761
  get position() {
773
762
  return this._position;
774
763
  }
775
- set position(n) {
776
- this._position.copyFrom(n);
764
+ set position(e) {
765
+ this._position.copyFrom(e);
777
766
  }
778
767
  get y() {
779
768
  return this._position.y;
780
769
  }
781
- set y(n) {
782
- this._position.y = n;
770
+ set y(e) {
771
+ this._position.y = e;
783
772
  }
784
773
  get rotation() {
785
774
  return this._rotation;
786
775
  }
787
- set rotation(n) {
788
- this._rotation !== n && (this._rotation = n, this._onUpdate(this._skew));
776
+ set rotation(e) {
777
+ this._rotation !== e && (this._rotation = e, this._onUpdate(this._skew));
789
778
  }
790
779
  get angle() {
791
- return this.rotation * RAD_TO_DEG;
780
+ return this.rotation * S;
792
781
  }
793
- set angle(n) {
794
- this.rotation = n * DEG_TO_RAD;
782
+ set angle(e) {
783
+ this.rotation = e * ee;
795
784
  }
796
785
  get skew() {
797
- return this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew;
786
+ return this._skew === k && (this._skew = new C(this, 0, 0)), this._skew;
798
787
  }
799
- set skew(n) {
800
- this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew.copyFrom(n);
788
+ set skew(e) {
789
+ this._skew === k && (this._skew = new C(this, 0, 0)), this._skew.copyFrom(e);
801
790
  }
802
791
  get scale() {
803
- return this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale;
792
+ return this._scale === j && (this._scale = new C(this, 1, 1)), this._scale;
804
793
  }
805
- set scale(n) {
806
- this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale.copyFrom(n);
794
+ set scale(e) {
795
+ this._scale === j && (this._scale = new C(this, 1, 1)), this._scale.copyFrom(e);
807
796
  }
808
797
  get pivot() {
809
- return this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot;
798
+ return this._pivot === M && (this._pivot = new C(this, 0, 0)), this._pivot;
810
799
  }
811
- set pivot(n) {
812
- this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot.copyFrom(n);
800
+ set pivot(e) {
801
+ this._pivot === M && (this._pivot = new C(this, 0, 0)), this._pivot.copyFrom(e);
813
802
  }
814
803
  get origin() {
815
- return this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), this._origin;
804
+ return this._origin === A && (this._origin = new C(this, 0, 0)), this._origin;
816
805
  }
817
- set origin(n) {
818
- this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), typeof n == "number" ? this._origin.set(n) : this._origin.copyFrom(n);
806
+ set origin(e) {
807
+ this._origin === A && (this._origin = new C(this, 0, 0)), typeof e == "number" ? this._origin.set(e) : this._origin.copyFrom(e);
819
808
  }
820
809
  get width() {
821
810
  return Math.abs(this.scale.x * this.getLocalBounds().width);
822
811
  }
823
- set width(n) {}
812
+ set width(e) {}
824
813
  get height() {
825
814
  return Math.abs(this.scale.y * this.getLocalBounds().height);
826
815
  }
827
- set height(n) {}
828
- addChild(...n) {
829
- if (n.length > 1) {
830
- for (let j = 0; j < n.length; ++j) this.addChild(n[j]);
831
- return n[0];
816
+ set height(e) {}
817
+ addChild(...e) {
818
+ if (e.length > 1) {
819
+ for (let t = 0; t < e.length; ++t) this.addChild(e[t]);
820
+ return e[0];
832
821
  }
833
- let j = n[0], M = this.renderGroup || this.parentRenderGroup;
834
- return j.parent === this ? (this.children.splice(this.children.indexOf(j), 1), this.children.push(j), M && (M.structureDidChange = !0), j) : (this.sortableChildren && (this.sortDirty = !0), j.parent && j.parent.removeChild(j), this.children.push(j), this.sortableChildren && (this.sortDirty = !0), j.parent = this, j.didChange = !0, j._updateFlags = 7, M && M.addChild(j), this._didViewChangeTick++, j._zIndex != 0 && j.depthOfChildModified(), j);
822
+ let t = e[0], n = this.renderGroup || this.parentRenderGroup;
823
+ return t.parent === this ? (this.children.splice(this.children.indexOf(t), 1), this.children.push(t), n && (n.structureDidChange = !0), t) : (this.sortableChildren && (this.sortDirty = !0), t.parent && t.parent.removeChild(t), this.children.push(t), this.sortableChildren && (this.sortDirty = !0), t.parent = this, t.didChange = !0, t._updateFlags = 7, n && n.addChild(t), this._didViewChangeTick++, t._zIndex !== 0 && t.depthOfChildModified(), t);
835
824
  }
836
- removeChild(...n) {
837
- if (n.length > 1) {
838
- for (let j = 0; j < n.length; ++j) this.removeChild(n[j]);
839
- return n[0];
825
+ removeChild(...e) {
826
+ if (e.length > 1) {
827
+ for (let t = 0; t < e.length; ++t) this.removeChild(e[t]);
828
+ return e[0];
840
829
  }
841
- let j = n[0];
842
- if (!j) return j;
843
- let M = this.children.indexOf(j);
844
- return M > -1 && (this._didViewChangeTick++, this.children.splice(M, 1), this.renderGroup ? this.renderGroup.removeChild(j) : this.parentRenderGroup && this.parentRenderGroup.removeChild(j), j.parent = null), j;
830
+ let t = e[0];
831
+ if (!t) return t;
832
+ let n = this.children.indexOf(t);
833
+ return n > -1 && (this._didViewChangeTick++, this.children.splice(n, 1), this.renderGroup ? this.renderGroup.removeChild(t) : this.parentRenderGroup && this.parentRenderGroup.removeChild(t), t.parent = null), t;
845
834
  }
846
- _onUpdate(n) {
847
- n && n === this._skew && this._updateSkew(), this._didContainerChangeTick++, !this.didChange && (this.didChange = !0, this.parentRenderGroup && this.parentRenderGroup.onChildUpdate(this));
835
+ _onUpdate(e) {
836
+ e && e === this._skew && this._updateSkew(), this._didContainerChangeTick++, !this.didChange && (this.didChange = !0, this.parentRenderGroup && this.parentRenderGroup.onChildUpdate(this));
848
837
  }
849
- toGlobal(n, j) {
850
- return this.getGlobalTransform(j).apply(n);
838
+ toGlobal(e, t, n) {
839
+ let r = this.getGlobalTransform(T.get(), n);
840
+ return t = r.apply(e, t), T.return(r), t;
851
841
  }
852
- toLocal(n, j, M) {
853
- let N;
854
- return j && (N = j.toGlobal(n)), N = this.getGlobalTransform(M).applyInverse(n), N;
842
+ toLocal(e, t, n, r) {
843
+ t && (e = t.toGlobal(e, n, r));
844
+ let i = this.getGlobalTransform(T.get(), r);
845
+ return n = i.applyInverse(e, n), T.return(i), n;
855
846
  }
856
- getGlobalTransform(n = !1) {
857
- if (n) return this.worldTransform.clone();
847
+ getGlobalTransform(e = new _(), t = !1) {
848
+ if (t) return this.worldTransform.clone();
858
849
  this.updateLocalTransform();
859
- let j = new Matrix(), M = updateTransformBackwards(this, j);
860
- return j.appendFrom(this.localTransform, M), j;
850
+ let n = we(this, T.get().identity());
851
+ return e.appendFrom(this.localTransform, n), T.return(n), e;
861
852
  }
862
- getGlobalPosition(n = !1) {
863
- return this.parent ? this.parent.toGlobal(this._position, n) : this._position.toVector2();
853
+ getGlobalPosition(e = new b(), t = !1) {
854
+ return this.parent ? this.parent.toGlobal(this._position, e, t) : (e.x = this._position.x, e.y = this._position.y), e;
864
855
  }
865
- destroy(n = !1) {
866
- var j, M;
856
+ destroy(e = !1) {
857
+ var t, n;
867
858
  if (this.destroyed) return;
868
859
  this.destroyed = !0;
869
- let N;
870
- if (this.children.length && (N = this.removeChildren(0, this.children.length)), (j = this.parent) == null || j.removeChild(this), this.parent = null, this._maskEffect = null, this.effects = null, this._position = null, this._scale = null, this._pivot = null, this._origin = null, this._skew = null, (typeof n == "boolean" ? n : n != null && n.children) && N) for (let j = 0; j < N.length; ++j) N[j].destroy(n);
871
- (M = this.renderGroup) == null || M.destroy(), this.renderGroup = null;
860
+ let r;
861
+ if (this.children.length && (r = this.removeChildren(0, this.children.length)), (t = this.parent) == null || t.removeChild(this), this.parent = null, this._maskEffect = null, this.effects = null, this._position = null, this._scale = null, this._pivot = null, this._origin = null, this._skew = null, (typeof e == "boolean" ? e : e != null && e.children) && r) for (let t = 0; t < r.length; ++t) r[t].destroy(e);
862
+ (n = this.renderGroup) == null || n.destroy(), this.renderGroup = null;
872
863
  }
873
864
  };
874
- function updateTransformBackwards(n, j) {
875
- let M = n.parent;
876
- if (M) {
877
- updateTransformBackwards(M, j), M.updateLocalTransform();
878
- let n = Matrix.append(j, M.localTransform);
879
- j.copyFrom(n);
880
- }
881
- return j;
865
+ function we(e, t) {
866
+ let n = e.parent;
867
+ if (n) {
868
+ we(n, t), n.updateLocalTransform();
869
+ let e = _.append(t, n.localTransform);
870
+ t.copyFrom(e);
871
+ }
872
+ return t;
882
873
  }
883
- function sortChildren(n, j) {
884
- return n._zIndex - j._zIndex;
874
+ function Te(e, t) {
875
+ return e._zIndex - t._zIndex;
885
876
  }
886
- applyMixins(Container, sortMixin, effectMixin, measureMixin, childrenHelperMixin);
887
- var UPDATE_BLEND_COLOR_VISIBLE = 7;
888
- function updateRenderGroupTransform(n, j = !1) {
889
- let M = n.root;
890
- n.worldTransform.copyFrom(M.localTransform);
891
- let N = n.childrenToUpdate;
892
- for (let j in N) {
893
- let M = Number(j), P = N[M], F = P.list, I = P.index;
894
- for (let j = 0; j < I; ++j) {
895
- let N = F[j];
896
- N.parentRenderGroup === n && N.relativeRenderGroupDepth === M && updateTransform(N, 0);
897
- }
898
- clearList(F, I), P.index = 0;
899
- }
900
- if (j) for (let M = 0; M < n.renderGroupChildren.length; ++M) updateRenderGroupTransform(n.renderGroupChildren[M], j);
901
- }
902
- function updateTransform(n, j) {
903
- n.didChange = !1;
904
- let M = n.parent, N = n.localTransform;
905
- n.updateLocalTransform(), M && (j |= n._updateFlags, n.relativeGroupTransform.appendFrom(N, M.relativeGroupTransform), j & UPDATE_BLEND_COLOR_VISIBLE && updateBlendColorVisible(n, M, j));
906
- let P = n.children;
907
- for (let n = 0; n < P.length; n++) updateTransform(P[n], j);
908
- }
909
- function updateBlendColorVisible(n, j, M) {
910
- if (M & 1) {
911
- n.groupColor = j.groupColor;
912
- let M = n.localAlpha * j.groupAlpha;
913
- M = M < 0 ? 0 : M > 1 ? 1 : M, n.groupAlpha = M, n.groupColorAlpha = n.groupColor + ((M * 255 | 0) << 24);
914
- }
915
- M & 4 && (n.globalDisplayStatus = n.localDisplayStatus & j.globalDisplayStatus), n._updateFlags = 0;
916
- }
917
- function validateRenderables(n, j) {
918
- let { list: M, index: N } = n.childrenRenderablesToUpdate, P = !1;
919
- for (let n = 0; n < N; ++n) {
920
- let N = M[n];
921
- if (P = j[N.renderPipeId].validateRenderable(N), P) break;
922
- }
923
- return n.structureDidChange = P, P;
924
- }
925
- var _RenderGroupSystem, RenderGroupSystem = class {
926
- constructor(n) {
927
- this.renderer = n;
928
- }
929
- _updateRenderGroup(n) {
930
- let j = this.renderer, M = j.renderPipes;
931
- n.runOnRender(j), n.instructionSet.renderPipes = M, n.structureDidChange ? clearList(n.childrenRenderablesToUpdate.list, 0) : validateRenderables(n, M), updateRenderGroupTransform(n), n.structureDidChange && (n.structureDidChange = !1, this._buildInstructions(n, j)), n.childrenRenderablesToUpdate.index = 0;
932
- }
933
- render({ container: n, transform: j }) {
934
- let M = this.renderer;
935
- j && n.renderGroup.localTransform.copyFrom(j), M.canvasContext.globalTransform = j ? n.renderGroup.localTransform : n.renderGroup.worldTransform, this._updateRenderGroup(n.renderGroup), executeInstructions(n.renderGroup, M.renderPipes);
936
- }
937
- _buildInstructions(n, j) {
938
- let M = j.renderPipes, N = n.root;
939
- n.instructionSet.reset(), N.sortableChildren && N.sortChildren(), M.batch.buildStart(), N.collectRenderablesWithEffects(M, n.instructionSet), M.batch.buildEnd(n.instructionSet);
940
- }
941
- };
942
- _RenderGroupSystem = RenderGroupSystem, _RenderGroupSystem.desc = { name: "renderGroup" };
943
- function executeInstructions(n, j) {
944
- let { instructionSet: M } = n, N = M.instructions;
945
- for (let n = 0; n < M.instructionSize; n++) {
946
- let M = N[n];
947
- j[M.renderPipeId].execute(M);
948
- }
949
- }
950
- var _SpritePipe, SpritePipe = class {
951
- constructor(n) {
952
- this._renderer = n;
953
- }
954
- addRenderable(n, j) {
955
- this._renderer.renderPipes.batch.addToBatch({
956
- renderable: n,
957
- texture: n.texture,
958
- transform: n.relativeGroupTransform,
959
- bounds: n.bounds,
960
- roundPixels: this._renderer._roundPixels | n._roundPixels
961
- }, j);
962
- }
963
- destroy() {
964
- this._renderer = null;
965
- }
966
- };
967
- _SpritePipe = SpritePipe, _SpritePipe.desc = { name: "sprite" };
968
- var _TextPipe, TextPipe = class {
969
- constructor(n) {
970
- this._renderer = n;
971
- }
972
- addRenderable(n, j) {
973
- let M = this._getRuntimeText(n);
974
- if (n._didTextUpdate) {
975
- let j = n._autoResolution ? this._renderer.resolution : n.resolution;
976
- (M.currentKey !== n.styleKey || n._resolution !== j) && this._updateRuntimeText(n), n._didTextUpdate = !1, updateBounds(M.bounds, n._anchor, M.texture);
977
- }
978
- this._renderer.renderPipes.batch.addToBatch(M, j);
979
- }
980
- validateRenderable(n) {
981
- let j = this._getRuntimeText(n), M = n.styleKey;
982
- return j.currentKey === M ? n._didTextUpdate : !0;
983
- }
984
- initCacheText(n) {
985
- let j = {
986
- currentKey: "--",
987
- transform: n.relativeGroupTransform,
988
- bounds: n.bounds,
989
- roundPixels: this._renderer._roundPixels | n._roundPixels,
990
- renderable: n,
991
- texture: null,
992
- destroy: function() {
993
- this.renderable = null, this.texture = null, this.bounds = null;
994
- }
995
- };
996
- return n._runtimeData[this._renderer.uid] = j, j;
997
- }
998
- _getRuntimeText(n) {
999
- return n._runtimeData[this._renderer.uid] || this.initCacheText(n);
1000
- }
1001
- _updateRuntimeText(n) {
1002
- let j = this._getRuntimeText(n);
1003
- j.texture, n._resolution = n._autoResolution ? this._renderer.resolution : n.resolution, j.texture = this._renderer.text.getManagedTexture(n), j.currentKey = n.styleKey;
1004
- }
1005
- destroy() {
1006
- this._renderer = null;
1007
- }
1008
- };
1009
- _TextPipe = TextPipe, _TextPipe.desc = { name: "text" };
1010
- var ViewContainer = class extends Container {
1011
- constructor(...n) {
1012
- super(...n), this._runtimeData = Object.create(null), this._roundPixels = 0, this._bounds = new Bounds(0, 1, 0, 0), this._boundsDirty = !0;
877
+ oe(N, he, fe, pe, se);
878
+ //#endregion
879
+ //#region lib/scene/ViewContainer.ts
880
+ var P = class extends N {
881
+ constructor(...e) {
882
+ super(...e), f(this, "_runtimeData", Object.create(null)), f(this, "_resolution", void 0), f(this, "_roundPixels", 0), f(this, "_bounds", new w(0, 1, 0, 0)), f(this, "_boundsDirty", !0);
1013
883
  }
1014
884
  get bounds() {
1015
885
  return this._boundsDirty ? (this.updateBounds(), this._boundsDirty = !1, this._bounds) : this._bounds;
@@ -1017,32 +887,32 @@ var ViewContainer = class extends Container {
1017
887
  onViewUpdate() {
1018
888
  if (this._didViewChangeTick++, this._boundsDirty = !0, this.didViewUpdate) return;
1019
889
  this.didViewUpdate = !0;
1020
- let n = this.renderGroup || this.parentRenderGroup;
1021
- n && n.onChildViewUpdate(this);
890
+ let e = this.renderGroup || this.parentRenderGroup;
891
+ e && e.onChildViewUpdate(this);
1022
892
  }
1023
- collectRenderableSimple(n, j) {
1024
- let M = n[this.renderPipeId];
1025
- M && M.addRenderable && M.addRenderable(this, j), this.didViewUpdate = !1;
1026
- let N = this.children;
1027
- for (let M = 0; M < N.length; ++M) N[M].collectRenderables(n, j);
893
+ collectRenderableSimple(e, t) {
894
+ let n = e[this.renderPipeId];
895
+ n && n.addRenderable && n.addRenderable(this, t), this.didViewUpdate = !1;
896
+ let r = this.children;
897
+ for (let n = 0; n < r.length; ++n) r[n].collectRenderables(e, t);
1028
898
  }
1029
- containsPoint(n) {
1030
- let j = this.bounds, { x: M, y: N } = n;
1031
- return M > j.minX && M < j.maxX && N > j.minY && N < j.maxY;
899
+ containsPoint(e) {
900
+ let t = this.bounds, { x: n, y: r } = e;
901
+ return n > t.minX && n < t.maxX && r > t.minY && r < t.maxY;
1032
902
  }
1033
903
  get roundPixels() {
1034
904
  return !!this._roundPixels;
1035
905
  }
1036
- set roundPixels(n) {
1037
- this._roundPixels = n ? 1 : 0;
906
+ set roundPixels(e) {
907
+ this._roundPixels = +!!e;
1038
908
  }
1039
- destroy(n = !1) {
1040
- for (let n in this._runtimeData) this._runtimeData[n].destroy();
1041
- this._runtimeData = Object.create(null), this.onViewUpdate(), super.destroy(n), this._bounds = null;
909
+ destroy(e = !1) {
910
+ for (let e in this._runtimeData) this._runtimeData[e].destroy();
911
+ this._runtimeData = Object.create(null), this.onViewUpdate(), super.destroy(e), this._bounds = null;
1042
912
  }
1043
- }, Polygon = class {
913
+ }, Ee = class {
1044
914
  constructor() {
1045
- this.points = [], this.type = "polygon";
915
+ f(this, "points", []), f(this, "closePath", void 0), f(this, "type", "polygon");
1046
916
  }
1047
917
  construction() {}
1048
918
  get lastX() {
@@ -1051,171 +921,153 @@ var ViewContainer = class extends Container {
1051
921
  get lastY() {
1052
922
  return this.points[this.points.length - 1];
1053
923
  }
1054
- getBounds() {
1055
- let n = new Rectangle(), j = this.points, M = Infinity, N = Infinity, P = -Infinity, F = -Infinity;
1056
- for (let n = 0; n < j.length; n += 2) {
1057
- let I = j[n], L = j[n + 1];
1058
- M = Math.min(M, I), N = Math.min(N, L), P = Math.max(P, I), F = Math.max(F, L);
924
+ strokeContains(e, t, n, r = .5) {
925
+ let i = n * n, a = i * (1 - r), o = i - a, { points: s } = this, c = s.length - (this.closePath ? 0 : 2);
926
+ for (let n = 0; n < c; n += 2) {
927
+ let r = s[n], i = s[n + 1], c = s[(n + 2) % s.length], l = s[(n + 3) % s.length];
928
+ if (ie(e, t, r, i, c, l) <= (Math.sign((c - r) * (t - i) - (l - i) * (e - r)) < 0 ? o : a)) return !0;
1059
929
  }
1060
- return n.x = M, n.width = P - M, n.y = N, n.height = F - N, n;
930
+ return !1;
931
+ }
932
+ contains(e, t) {
933
+ let n = !1, r = this.points.length / 2;
934
+ for (let i = 0, a = r - 1; i < r; a = i++) {
935
+ let r = this.points[i * 2], o = this.points[i * 2 + 1], s = this.points[a * 2], c = this.points[a * 2 + 1];
936
+ o > t != c > t && e < (s - r) * ((t - o) / (c - o)) + r && (n = !n);
937
+ }
938
+ return n;
1061
939
  }
1062
- }, RECURSION_LIMIT = 8, FLT_EPSILON = 1.1920929e-7, PATH_DISTANCE_EPSILON = 1, curveAngleToleranceEpsilon = .01, mAngleTolerance = 0, mCuspLimit = 0;
1063
- function buildAdaptiveBezier(n, j, M, N, P, F, I, L, R, z) {
1064
- let B = (PATH_DISTANCE_EPSILON - Math.min(.99, Math.max(0, z == null ? .5 : z))) / 1;
1065
- return B *= B, begin(j, M, N, P, F, I, L, R, n, B), n;
940
+ getBounds(e) {
941
+ e || (e = new y());
942
+ let t = this.points, n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
943
+ for (let e = 0; e < t.length; e += 2) {
944
+ let o = t[e], s = t[e + 1];
945
+ n = o < n ? o : n, r = s < r ? s : r, i = o > i ? o : i, a = s > a ? s : a;
946
+ }
947
+ return e.x = n, e.width = i - n, e.y = r, e.height = a - r, e;
948
+ }
949
+ }, De = 8, F = 1.1920929e-7, Oe = 1;
950
+ function ke(e, t, n, r, i, a, o, s, c, l) {
951
+ let u = (Oe - Math.min(.99, Math.max(0, l == null ? .5 : l))) / 1;
952
+ return u *= u, Ae(t, n, r, i, a, o, s, c, e, u), e;
1066
953
  }
1067
- function begin(n, j, M, N, P, F, I, L, R, z) {
1068
- recursive(n, j, M, N, P, F, I, L, R, z, 0), R.push(I, L);
954
+ function Ae(e, t, n, r, i, a, o, s, c, l) {
955
+ I(e, t, n, r, i, a, o, s, c, l, 0), c.push(o, s);
1069
956
  }
1070
- function recursive(n, j, M, N, P, F, I, L, R, z, B) {
1071
- if (B > RECURSION_LIMIT) return;
1072
- let V = Math.PI, H = (n + M) / 2, U = (j + N) / 2, W = (M + P) / 2, G = (N + F) / 2, K = (P + I) / 2, q = (F + L) / 2, J = (H + W) / 2, Y = (U + G) / 2, X = (W + K) / 2, Z = (G + q) / 2, Q = (J + X) / 2, $ = (Y + Z) / 2;
1073
- if (B > 0) {
1074
- let B = I - n, H = L - j, U = Math.abs((M - I) * H - (N - L) * B), W = Math.abs((P - I) * H - (F - L) * B), G, K;
1075
- if (U > FLT_EPSILON && W > FLT_EPSILON) {
1076
- if ((U + W) * (U + W) <= z * (B * B + H * H)) {
1077
- if (mAngleTolerance < curveAngleToleranceEpsilon) {
1078
- R.push(Q, $);
1079
- return;
1080
- }
1081
- let z = Math.atan2(F - N, P - M);
1082
- if (G = Math.abs(z - Math.atan2(N - j, M - n)), K = Math.abs(Math.atan2(L - F, I - P) - z), G >= V && (G = 2 * V - G), K >= V && (K = 2 * V - K), G + K < mAngleTolerance) {
1083
- R.push(Q, $);
1084
- return;
1085
- }
1086
- if (mCuspLimit !== 0) {
1087
- if (G > mCuspLimit) {
1088
- R.push(M, N);
1089
- return;
1090
- }
1091
- if (K > mCuspLimit) {
1092
- R.push(P, F);
1093
- return;
1094
- }
1095
- }
957
+ function I(e, t, n, r, i, a, o, s, c, l, u) {
958
+ if (u > De) return;
959
+ let d = (e + n) / 2, f = (t + r) / 2, p = (n + i) / 2, m = (r + a) / 2, h = (i + o) / 2, g = (a + s) / 2, _ = (d + p) / 2, v = (f + m) / 2, y = (p + h) / 2, b = (m + g) / 2, x = (_ + y) / 2, S = (v + b) / 2;
960
+ if (u > 0) {
961
+ let u = o - e, d = s - t, f = Math.abs((n - o) * d - (r - s) * u), p = Math.abs((i - o) * d - (a - s) * u);
962
+ if (f > F && p > F) {
963
+ if ((f + p) * (f + p) <= l * (u * u + d * d)) {
964
+ c.push(x, S);
965
+ return;
1096
966
  }
1097
- } else if (U > FLT_EPSILON) {
1098
- if (U * U <= z * (B * B + H * H)) {
1099
- if (mAngleTolerance < curveAngleToleranceEpsilon) {
1100
- R.push(Q, $);
1101
- return;
1102
- }
1103
- if (G = Math.abs(Math.atan2(F - N, P - M) - Math.atan2(N - j, M - n)), G >= V && (G = 2 * V - G), G < mAngleTolerance) {
1104
- R.push(M, N), R.push(P, F);
1105
- return;
1106
- }
1107
- if (mCuspLimit !== 0 && G > mCuspLimit) {
1108
- R.push(M, N);
1109
- return;
1110
- }
967
+ } else if (f > F) {
968
+ if (f * f <= l * (u * u + d * d)) {
969
+ c.push(x, S);
970
+ return;
1111
971
  }
1112
- } else if (W > FLT_EPSILON) {
1113
- if (W * W <= z * (B * B + H * H)) {
1114
- if (mAngleTolerance < curveAngleToleranceEpsilon) {
1115
- R.push(Q, $);
1116
- return;
1117
- }
1118
- if (G = Math.abs(Math.atan2(L - F, I - P) - Math.atan2(F - N, P - M)), G >= V && (G = 2 * V - G), G < mAngleTolerance) {
1119
- R.push(M, N), R.push(P, F);
1120
- return;
1121
- }
1122
- if (mCuspLimit !== 0 && G > mCuspLimit) {
1123
- R.push(P, F);
1124
- return;
1125
- }
972
+ } else if (p > F) {
973
+ if (p * p <= l * (u * u + d * d)) {
974
+ c.push(x, S);
975
+ return;
1126
976
  }
1127
- } else if (B = Q - (n + I) / 2, H = $ - (j + L) / 2, B * B + H * H <= z) {
1128
- R.push(Q, $);
977
+ } else if (u = x - (e + o) / 2, d = S - (t + s) / 2, u * u + d * d <= l) {
978
+ c.push(x, S);
1129
979
  return;
1130
980
  }
1131
981
  }
1132
- recursive(n, j, H, U, J, Y, Q, $, R, z, B + 1), recursive(Q, $, X, Z, K, q, I, L, R, z, B + 1);
982
+ I(e, t, d, f, _, v, x, S, c, l, u + 1), I(x, S, y, b, h, g, o, s, c, l, u + 1);
1133
983
  }
1134
- var ShapePath = class {
1135
- constructor(n) {
1136
- this.shapePrimitives = [], this._bounds = new Bounds(), this._graphicsPath = n;
984
+ //#endregion
985
+ //#region lib/scene/graphics/path/ShapePath.ts
986
+ var je = new y(), Me = class {
987
+ constructor(e) {
988
+ f(this, "_currentPoly", void 0), f(this, "shapePrimitives", []), f(this, "_graphicsPath", void 0), f(this, "_bounds", new w()), this._graphicsPath = e;
1137
989
  }
1138
- _ensurePoly(n = !0) {
1139
- this._currentPoly || (this._currentPoly = new Polygon(), n && this._currentPoly.points.push(0, 0));
990
+ _ensurePoly(e = !0) {
991
+ this._currentPoly || (this._currentPoly = new Ee(), e && this._currentPoly.points.push(0, 0));
1140
992
  }
1141
- lineTo(n, j) {
993
+ lineTo(e, t) {
1142
994
  this._ensurePoly();
1143
- let M = this._currentPoly.points, N = M[M.length - 2], P = M[M.length - 1];
1144
- return (N !== n || P !== j) && M.push(n, j), this;
995
+ let n = this._currentPoly.points, r = n[n.length - 2], i = n[n.length - 1];
996
+ return (r !== e || i !== t) && n.push(e, t), this;
1145
997
  }
1146
- rect(n, j, M, N) {
1147
- return this.drawShape(new Rectangle(n, j, M, N)), this;
998
+ rect(e, t, n, r) {
999
+ return this.drawShape(new y(e, t, n, r)), this;
1148
1000
  }
1149
- drawShape(n) {
1150
- return this.endPloy(), this.shapePrimitives.push({ shape: n }), this;
1001
+ drawShape(e) {
1002
+ return this.endPloy(), this.shapePrimitives.push({ shape: e }), this;
1151
1003
  }
1152
- moveTo(n, j) {
1153
- return this.startPoly(n, j), this;
1004
+ moveTo(e, t) {
1005
+ return this.startPoly(e, t), this;
1154
1006
  }
1155
- bezierCurveTo(n, j, M, N, P, F, I) {
1007
+ bezierCurveTo(e, t, n, r, i, a, o) {
1156
1008
  this._ensurePoly();
1157
- let L = this._currentPoly.points;
1158
- return buildAdaptiveBezier(L, this._currentPoly.lastX, this._currentPoly.lastY, n, j, M, N, P, F, I), this;
1009
+ let s = this._currentPoly.points;
1010
+ return ke(s, this._currentPoly.lastX, this._currentPoly.lastY, e, t, n, r, i, a, o), this;
1159
1011
  }
1160
- startPoly(n, j) {
1161
- return this._currentPoly && this.endPloy(), this._currentPoly = new Polygon(), this._currentPoly.points.push(n, j), this;
1012
+ startPoly(e, t) {
1013
+ return this._currentPoly && this.endPloy(), this._currentPoly = new Ee(), this._currentPoly.points.push(e, t), this;
1162
1014
  }
1163
- endPloy(n = !1) {
1164
- let j = this._currentPoly;
1165
- j && j.points.length > 2 && (j.closePath = n, this.shapePrimitives.push({ shape: j })), this._currentPoly = null;
1015
+ endPloy(e = !1) {
1016
+ let t = this._currentPoly;
1017
+ return t && t.points.length > 2 && (t.closePath = e, this.shapePrimitives.push({ shape: t })), this._currentPoly = null, this;
1166
1018
  }
1167
1019
  closePath() {
1168
1020
  return this.endPloy(!0), this;
1169
1021
  }
1170
1022
  buildPath() {
1171
- let n = this._graphicsPath;
1172
- for (let j = 0; j < n.instructions.length; ++j) {
1173
- let M = n.instructions[j];
1174
- this[M.action](...M.data);
1023
+ let e = this._graphicsPath;
1024
+ for (let t = 0; t < e.instructions.length; ++t) {
1025
+ let n = e.instructions[t];
1026
+ this[n.action](...n.data);
1175
1027
  }
1176
- return this;
1028
+ return this.endPloy(!1), this;
1177
1029
  }
1178
1030
  get bounds() {
1179
- let n = this._bounds;
1180
- n.clear();
1181
- let j = this.shapePrimitives;
1182
- for (let M = 0; M < j.length; ++M) {
1183
- let N = j[M].shape.getBounds();
1184
- n.addRect(N);
1031
+ let e = this._bounds;
1032
+ e.clear();
1033
+ let t = this.shapePrimitives;
1034
+ for (let n = 0; n < t.length; ++n) {
1035
+ let r = t[n].shape.getBounds(je);
1036
+ e.addRect(r);
1185
1037
  }
1186
- return n;
1038
+ return e;
1187
1039
  }
1188
- }, GraphicsPath = class n {
1040
+ }, Ne = class e {
1189
1041
  constructor() {
1190
- this.instructions = [], this._dirty = !0;
1042
+ f(this, "instructions", []), f(this, "_dirty", !0), f(this, "_shapePath", void 0);
1191
1043
  }
1192
- rect(n, j, M, N) {
1044
+ rect(e, t, n, r) {
1193
1045
  return this.instructions.push({
1194
1046
  action: "rect",
1195
1047
  data: [
1048
+ e,
1049
+ t,
1196
1050
  n,
1197
- j,
1198
- M,
1199
- N
1051
+ r
1200
1052
  ]
1201
1053
  }), this._dirty = !0, this;
1202
1054
  }
1203
- lineTo(...n) {
1055
+ lineTo(...e) {
1204
1056
  return this.instructions.push({
1205
1057
  action: "lineTo",
1206
- data: n
1058
+ data: e
1207
1059
  }), this._dirty = !0, this;
1208
1060
  }
1209
- bezierCurveTo(...n) {
1061
+ bezierCurveTo(...e) {
1210
1062
  return this.instructions.push({
1211
1063
  action: "bezierCurveTo",
1212
- data: n
1064
+ data: e
1213
1065
  }), this;
1214
1066
  }
1215
- moveTo(...n) {
1067
+ moveTo(...e) {
1216
1068
  return this.instructions.push({
1217
1069
  action: "moveTo",
1218
- data: n
1070
+ data: e
1219
1071
  }), this;
1220
1072
  }
1221
1073
  closePath() {
@@ -1225,22 +1077,22 @@ var ShapePath = class {
1225
1077
  }), this._dirty = !0, this;
1226
1078
  }
1227
1079
  get shapePath() {
1228
- return this._shapePath || (this._shapePath = new ShapePath(this)), this._dirty && (this._dirty = !1, this._shapePath.buildPath()), this._shapePath;
1080
+ return this._shapePath || (this._shapePath = new Me(this)), this._dirty && (this._dirty = !1, this._shapePath.buildPath()), this._shapePath;
1229
1081
  }
1230
1082
  get bounds() {
1231
1083
  return this.shapePath.bounds;
1232
1084
  }
1233
1085
  getLastPoint() {
1234
- let n = this.instructions.length - 1, j = this.instructions[n];
1235
- if (!j) return {
1086
+ let e = this.instructions.length - 1, t = this.instructions[e];
1087
+ if (!t) return {
1236
1088
  x: 0,
1237
1089
  y: 0
1238
1090
  };
1239
- switch (j.action) {
1091
+ switch (t.action) {
1240
1092
  case "moveTo":
1241
1093
  case "lineTo": return {
1242
- x: j.data[0],
1243
- y: j.data[1]
1094
+ x: t.data[0],
1095
+ y: t.data[1]
1244
1096
  };
1245
1097
  }
1246
1098
  return {
@@ -1252,15 +1104,77 @@ var ShapePath = class {
1252
1104
  this.instructions.length = 0, this._dirty = !0;
1253
1105
  }
1254
1106
  clone() {
1255
- let j = new n();
1256
- return j.instructions = this.instructions.slice(), j;
1107
+ let t = new e();
1108
+ return t.instructions = this.instructions.slice(), t;
1109
+ }
1110
+ };
1111
+ //#endregion
1112
+ //#region lib/utils/color.ts
1113
+ function Pe(e) {
1114
+ let t = e.replace("#", ""), n = t;
1115
+ t.length === 4 && (n = t.split("").map((e) => e + e).join(""));
1116
+ let r = n.substring(0, 2), i = n.substring(2, 4), a = n.substring(4, 6), o = n.substring(6, 8) || "ff", s = Number.parseInt(r, 16), c = Number.parseInt(i, 16), l = Number.parseInt(a, 16);
1117
+ return {
1118
+ r: s,
1119
+ g: c,
1120
+ b: l,
1121
+ a: +(Number.parseInt(o, 16) / 255).toFixed(2),
1122
+ rgb: `rgb(${s}, ${c}, ${l})`,
1123
+ hex: `#${r}${i}${a}`
1124
+ };
1125
+ }
1126
+ //#endregion
1127
+ //#region lib/scene/graphics/utils/convertInputToStyle.ts
1128
+ function L(e, t) {
1129
+ return {
1130
+ ...t,
1131
+ ...e
1132
+ };
1133
+ }
1134
+ function Fe(e, t) {
1135
+ if (e == null) return null;
1136
+ let n = {
1137
+ ...t,
1138
+ ...e
1139
+ };
1140
+ if (n.color.startsWith("#")) {
1141
+ let { a: e, hex: t } = Pe(n.color);
1142
+ n.alpha *= e, n.color = t;
1143
+ }
1144
+ return n;
1145
+ }
1146
+ //#endregion
1147
+ //#region lib/scene/graphics/utils/getMaxMiterRatio.ts
1148
+ function Ie(e, t) {
1149
+ let n = 1, r = e.shapePath.shapePrimitives;
1150
+ for (let e = 0; e < r.length; e++) {
1151
+ let i = r[e].shape;
1152
+ if (i.type !== "polygon") continue;
1153
+ let a = i.points, o = a.length;
1154
+ if (o < 6) continue;
1155
+ let s = i.closePath;
1156
+ for (let e = 0; e < o; e += 2) {
1157
+ if (!s && (e === 0 || e === o - 2)) continue;
1158
+ let r = (e - 2 + o) % o, i = (e + 2) % o, c = a[r], l = a[r + 1], u = a[e], d = a[e + 1], f = a[i], p = a[i + 1], m = c - u, h = l - d, g = f - u, _ = p - d, v = m * m + h * h, y = g * g + _ * _;
1159
+ if (v < 1e-12 || y < 1e-12) continue;
1160
+ let b = (m * g + h * _) / Math.sqrt(v * y);
1161
+ b < -1 ? b = -1 : b > 1 && (b = 1);
1162
+ let x = Math.sqrt((1 - b) * .5);
1163
+ if (x < 1e-6) continue;
1164
+ let S = Math.min(1 / x, t);
1165
+ S > n && (n = S);
1166
+ }
1257
1167
  }
1258
- }, _GraphicsContext, GraphicsContext = class n {
1168
+ return n;
1169
+ }
1170
+ //#endregion
1171
+ //#region lib/scene/graphics/GraphicsContext.ts
1172
+ var R = class e {
1259
1173
  constructor() {
1260
- this._activePath = new GraphicsPath(), this._bounds = new Bounds(), this._boundsDirty = !0, this.instructions = [];
1174
+ f(this, "_strokeStyle", { ...e.defaultStrokeStyle }), f(this, "_fillStyle", { ...e.defaultFillStyle }), f(this, "_activePath", new Ne()), f(this, "_bounds", new w()), f(this, "_boundsDirty", !0), f(this, "_tick", 0), f(this, "instructions", []);
1261
1175
  }
1262
- setStrokeStyle(j) {
1263
- this._strokeStyle = toStrokeStyle(j, n.defaultStrokeStyle);
1176
+ setStrokeStyle(t) {
1177
+ this._strokeStyle = L(t, e.defaultStrokeStyle);
1264
1178
  }
1265
1179
  clear() {
1266
1180
  return this._activePath.clear(), this.instructions.length = 0, this.onUpdate(), this;
@@ -1268,75 +1182,106 @@ var ShapePath = class {
1268
1182
  onUpdate() {
1269
1183
  this._boundsDirty = !0;
1270
1184
  }
1271
- moveTo(n, j) {
1272
- return this._activePath.moveTo(n, j), this;
1185
+ moveTo(e, t) {
1186
+ return ++this._tick, this._activePath.moveTo(e, t), this;
1273
1187
  }
1274
- lineTo(n, j) {
1275
- return this._activePath.lineTo(n, j), this;
1188
+ lineTo(e, t) {
1189
+ return ++this._tick, this._activePath.lineTo(e, t), this;
1276
1190
  }
1277
- bezierCurveTo(n, j, M, N, P, F, I) {
1278
- return this._activePath.bezierCurveTo(n, j, M, N, P, F, I), this;
1191
+ bezierCurveTo(e, t, n, r, i, a, o) {
1192
+ return ++this._tick, this._activePath.bezierCurveTo(e, t, n, r, i, a, o), this;
1279
1193
  }
1280
- rect(n, j, M, N) {
1281
- return this._activePath.rect(n, j, M, N), this;
1194
+ rect(e, t, n, r) {
1195
+ return ++this._tick, this._activePath.rect(e, t, n, r), this;
1282
1196
  }
1283
1197
  beginPath() {
1284
- return this._activePath = new GraphicsPath(), this;
1198
+ return this._activePath = new Ne(), this;
1285
1199
  }
1286
1200
  closePath() {
1287
- return this._activePath.closePath(), this;
1201
+ return ++this._tick, this._activePath.closePath(), this;
1288
1202
  }
1289
- fill(j) {
1290
- let M = {
1291
- ...n.defaultStrokeStyle,
1292
- color: j
1293
- };
1294
- return this.instructions.push({
1203
+ get fillStyle() {
1204
+ return this._fillStyle;
1205
+ }
1206
+ set fillStyle(t) {
1207
+ this._fillStyle = Fe(t, e.defaultFillStyle);
1208
+ }
1209
+ get strokeStyle() {
1210
+ return this._strokeStyle;
1211
+ }
1212
+ set strokeStyle(t) {
1213
+ this._strokeStyle = L(t, e.defaultStrokeStyle);
1214
+ }
1215
+ fill(t) {
1216
+ let n = this.instructions[this.instructions.length - 1], r;
1217
+ return r = this._tick === 0 && (n == null ? void 0 : n.action) === "stroke" ? n.data.path : this._activePath.clone(), r ? (t != null && (this._fillStyle = Fe(t, e.defaultFillStyle)), this.instructions.push({
1295
1218
  action: "fill",
1296
1219
  data: {
1297
- style: M,
1298
- path: this._activePath.clone()
1220
+ style: this.fillStyle,
1221
+ path: r
1299
1222
  }
1300
- }), this;
1223
+ }), this.onUpdate(), this._initNextPathLocation(), this._tick = 0, this) : this;
1301
1224
  }
1302
- stroke() {
1303
- this.instructions.push({
1225
+ stroke(t) {
1226
+ let n, r = this.instructions[this.instructions.length - 1];
1227
+ return n = this._tick === 0 && (r == null ? void 0 : r.action) === "fill" ? r.data.path : this._activePath.clone(), n ? (t != null && (this._strokeStyle = L(t, e.defaultStrokeStyle)), this.instructions.push({
1304
1228
  action: "stroke",
1305
1229
  data: {
1306
- style: this._strokeStyle,
1307
- path: this._activePath.clone()
1230
+ style: this.strokeStyle,
1231
+ path: n
1308
1232
  }
1309
- }), this._initNextPathLocation();
1233
+ }), this.onUpdate(), this._initNextPathLocation(), this._tick = 0, this) : this;
1310
1234
  }
1311
1235
  _initNextPathLocation() {
1312
- let { x: n, y: j } = this._activePath.getLastPoint();
1313
- this._activePath.clear(), this._activePath.moveTo(n, j);
1236
+ let { x: e, y: t } = this._activePath.getLastPoint();
1237
+ this._activePath.clear(), this._activePath.moveTo(e, t);
1314
1238
  }
1315
1239
  get bounds() {
1316
1240
  if (!this._boundsDirty) return this._bounds;
1317
1241
  this._boundsDirty = !1;
1318
- let n = this._bounds;
1319
- n.clear();
1320
- for (let j = 0; j < this.instructions.length; ++j) {
1321
- let M = this.instructions[j], N = M.action;
1322
- if (N === "fill") {
1323
- let j = M.data;
1324
- n.addBounds(j.path.bounds);
1325
- } else if (N === "stroke") {
1326
- let j = M.data, N = j.style.alignment, P = j.style.width * (1 - N);
1327
- j.style.join;
1328
- let F = j.path.bounds;
1329
- n.addFrame(F.minX - P, F.minY - P, F.maxX + P, F.maxY + P);
1242
+ let e = this._bounds;
1243
+ e.clear();
1244
+ for (let t = 0; t < this.instructions.length; ++t) {
1245
+ let n = this.instructions[t], r = n.action;
1246
+ if (r === "fill") {
1247
+ let t = n.data;
1248
+ e.addBounds(t.path.bounds);
1249
+ } else if (r === "stroke") {
1250
+ let t = n.data, r = t.style.alignment, i = t.style.width * (1 - r);
1251
+ t.style.join === "miter" && (i *= Ie(t.path, t.style.miterLimit));
1252
+ let a = t.path.bounds;
1253
+ e.addFrame(a.minX - i, a.minY - i, a.maxX + i, a.maxY + i);
1330
1254
  }
1331
1255
  }
1332
- return n.isValid || n.set(0, 0, 0, 0), n;
1256
+ return e.isValid || e.set(0, 0, 0, 0), e;
1257
+ }
1258
+ containsPoint(e) {
1259
+ if (!this.bounds.containsPoint(e.x, e.y)) return !1;
1260
+ let t = this.instructions, n = !1;
1261
+ for (let r = 0; r < t.length; ++r) {
1262
+ let i = t[r], a = i.data, o = a.path;
1263
+ if (!i.action || !o) continue;
1264
+ let s = a.style, c = o.shapePath.shapePrimitives;
1265
+ for (let t = 0; t < c.length; ++t) {
1266
+ let t = c[r].shape;
1267
+ if (!s || !t) continue;
1268
+ let a = e;
1269
+ if (i.action === "fill") n = t.contains(a.x, a.y);
1270
+ else {
1271
+ let e = s;
1272
+ n = t.strokeContains(a.x, a.y, e.width, e.alignment);
1273
+ }
1274
+ if (n) return !0;
1275
+ }
1276
+ }
1277
+ return n;
1333
1278
  }
1334
1279
  clone() {
1335
- let j = new n();
1336
- return j.instructions = this.instructions.slice(), j._activePath = this._activePath.clone(), j._bounds = this._bounds.clone(), j._strokeStyle = { ...this._strokeStyle }, j;
1280
+ let t = new e();
1281
+ return t.instructions = this.instructions.slice(), t._activePath = this._activePath.clone(), t._bounds = this._bounds.clone(), t._strokeStyle = { ...this._strokeStyle }, t;
1337
1282
  }
1338
1283
  };
1339
- _GraphicsContext = GraphicsContext, _GraphicsContext.defaultStrokeStyle = {
1284
+ f(R, "defaultStrokeStyle", {
1340
1285
  width: 1,
1341
1286
  color: "#ffffff",
1342
1287
  alignment: .5,
@@ -1345,45 +1290,56 @@ _GraphicsContext = GraphicsContext, _GraphicsContext.defaultStrokeStyle = {
1345
1290
  join: "miter",
1346
1291
  pixelLine: !1,
1347
1292
  alpha: 1
1348
- };
1349
- function toStrokeStyle(n, j) {
1350
- return {
1351
- ...j,
1352
- ...n
1353
- };
1354
- }
1355
- var Graphics = class extends ViewContainer {
1356
- constructor(n) {
1357
- n instanceof GraphicsContext && (n = { context: n });
1358
- let { context: j, ...M } = n || {};
1293
+ }), f(R, "defaultFillStyle", {
1294
+ color: "#ffffff",
1295
+ alpha: 1
1296
+ });
1297
+ //#endregion
1298
+ //#region lib/scene/graphics/Graphics.ts
1299
+ var Le = class extends P {
1300
+ constructor(e) {
1301
+ e instanceof R && (e = { context: e });
1302
+ let { context: t, ...n } = e || {};
1359
1303
  super({
1360
1304
  label: "Graphics",
1361
- ...M
1362
- }), this.renderPipeId = "graphics", j ? this.context = j : this.context = new GraphicsContext(), this.didViewUpdate = !0;
1305
+ ...n
1306
+ }), f(this, "renderPipeId", "graphics"), f(this, "_context", void 0), t ? this.context = t : this.context = new R(), this.didViewUpdate = !0;
1363
1307
  }
1364
1308
  get context() {
1365
1309
  return this._context;
1366
1310
  }
1367
- set context(n) {
1368
- n !== this._context && (this._context = n, this.onViewUpdate());
1311
+ set context(e) {
1312
+ e !== this._context && (this._context = e, this.onViewUpdate());
1313
+ }
1314
+ get fillStyle() {
1315
+ return this._context.fillStyle;
1316
+ }
1317
+ set fillStyle(e) {
1318
+ this._context.fillStyle = e;
1319
+ }
1320
+ get strokeStyle() {
1321
+ return this._context.strokeStyle;
1369
1322
  }
1370
- setStrokeStyle(...n) {
1371
- return this._callContextMethod("setStrokeStyle", n);
1323
+ set strokeStyle(e) {
1324
+ this._context.strokeStyle = e;
1372
1325
  }
1373
- rect(...n) {
1374
- return this._callContextMethod("rect", n);
1326
+ setStrokeStyle(...e) {
1327
+ return this._callContextMethod("setStrokeStyle", e);
1375
1328
  }
1376
- bezierCurveTo(...n) {
1377
- return this._callContextMethod("bezierCurveTo", n);
1329
+ rect(...e) {
1330
+ return this._callContextMethod("rect", e);
1378
1331
  }
1379
- lineTo(...n) {
1380
- return this._callContextMethod("lineTo", n);
1332
+ bezierCurveTo(...e) {
1333
+ return this._callContextMethod("bezierCurveTo", e);
1381
1334
  }
1382
- moveTo(...n) {
1383
- return this._callContextMethod("moveTo", n);
1335
+ lineTo(...e) {
1336
+ return this._callContextMethod("lineTo", e);
1384
1337
  }
1385
- stroke(...n) {
1386
- return this._callContextMethod("stroke", n);
1338
+ moveTo(...e) {
1339
+ return this._callContextMethod("moveTo", e);
1340
+ }
1341
+ stroke(...e) {
1342
+ return this._callContextMethod("stroke", e);
1387
1343
  }
1388
1344
  beginPath() {
1389
1345
  return this._callContextMethod("beginPath", []);
@@ -1391,11 +1347,11 @@ var Graphics = class extends ViewContainer {
1391
1347
  closePath() {
1392
1348
  return this._callContextMethod("closePath", []);
1393
1349
  }
1394
- fill(n) {
1395
- return this._callContextMethod("fill", [n]);
1350
+ fill(...e) {
1351
+ return this._callContextMethod("fill", e);
1396
1352
  }
1397
- _callContextMethod(n, j) {
1398
- return this.context[n](...j), this;
1353
+ _callContextMethod(e, t) {
1354
+ return this.context[e](...t), this;
1399
1355
  }
1400
1356
  updateBounds() {}
1401
1357
  get bounds() {
@@ -1404,150 +1360,213 @@ var Graphics = class extends ViewContainer {
1404
1360
  clear() {
1405
1361
  return this._callContextMethod("clear", []);
1406
1362
  }
1407
- }, _GraphicsPipe, GraphicsPipe = class {
1408
- constructor(n) {
1409
- this._renderer = n;
1410
- }
1411
- addRenderable(n, j) {
1412
- this._renderer.renderPipes.batch.break(j), j.add(n);
1413
- }
1414
- execute(n) {
1415
- let j = this._renderer, M = j.canvasContext, N = M.activeConext, P = j.roundPixels, F = (n.groupColorAlpha >>> 24 & 255) / 255;
1416
- if (!(F <= 0)) {
1417
- N.save(), M.setContextTransform(n.relativeGroupTransform, P);
1418
- for (let j = 0; j < n.context.instructions.length; ++j) {
1419
- let M = n.context.instructions[j], P = M.data.style, I = P.alpha * F;
1420
- if (I <= 0) continue;
1421
- N.globalAlpha = I;
1422
- let L = M.action === "stroke";
1423
- if (L) {
1424
- let n = P.color;
1425
- N.lineWidth = P.width, N.lineCap = P.cap, N.lineJoin = P.join, N.miterLimit = P.miterLimit, N.strokeStyle = n;
1426
- } else N.fillStyle = M.data.style.color;
1427
- let R = M.data.path.shapePath.shapePrimitives;
1428
- for (let n = 0; n < R.length; ++n) {
1429
- let j = R[n];
1430
- j.shape && (N.beginPath(), buildShapePath(N, j.shape), L ? N.stroke() : N.fill());
1363
+ }, z = class {
1364
+ constructor(e) {
1365
+ f(this, "_renderer", void 0), this._renderer = e;
1366
+ }
1367
+ addRenderable(e, t) {
1368
+ this._renderer.renderPipes.batch.break(t), t.add(e);
1369
+ }
1370
+ validateRenderable(e) {
1371
+ return !1;
1372
+ }
1373
+ execute(e) {
1374
+ let t = this._renderer, n = t.canvasContext, r = n.activeConext, i = t.roundPixels, a = (e.groupColorAlpha >>> 24 & 255) / 255;
1375
+ if (!(a <= 0)) {
1376
+ r.save(), n.setContextTransform(e.relativeGroupTransform, i);
1377
+ for (let t = 0; t < e.context.instructions.length; ++t) {
1378
+ let n = e.context.instructions[t], i = n.data.style, o = i.alpha * a;
1379
+ if (o <= 0) continue;
1380
+ r.globalAlpha = o;
1381
+ let s = n.action === "stroke";
1382
+ if (s) {
1383
+ let e = i.color;
1384
+ r.lineWidth = i.width, r.lineCap = i.cap, r.lineJoin = i.join, r.miterLimit = i.miterLimit, r.strokeStyle = e;
1385
+ } else r.fillStyle = n.data.style.color;
1386
+ let c = n.data.path.shapePath.shapePrimitives;
1387
+ for (let e = 0; e < c.length; ++e) {
1388
+ let t = c[e];
1389
+ t.shape && (r.beginPath(), B(r, t.shape), s ? r.stroke() : r.fill());
1431
1390
  }
1432
1391
  }
1433
- N.restore();
1392
+ r.restore();
1434
1393
  }
1435
1394
  }
1436
1395
  destroy() {
1437
1396
  this._renderer = null;
1438
1397
  }
1439
1398
  };
1440
- _GraphicsPipe = GraphicsPipe, _GraphicsPipe.desc = { name: "graphics" };
1441
- function buildShapePath(n, j) {
1442
- switch (j.type) {
1399
+ f(z, "desc", { name: "graphics" });
1400
+ function B(e, t) {
1401
+ switch (t.type) {
1443
1402
  case "rectangle": {
1444
- let M = j;
1445
- n.rect(M.x, M.y, M.width, M.height);
1403
+ let n = t;
1404
+ e.rect(n.x, n.y, n.width, n.height);
1446
1405
  break;
1447
1406
  }
1448
1407
  case "polygon": {
1449
- let M = j, N = M.points;
1450
- if (!N.length) return;
1451
- n.moveTo(N[0], N[1]);
1452
- for (let j = 2; j < N.length; j += 2) n.lineTo(N[j], N[j + 1]);
1453
- M.closePath && n.closePath();
1408
+ let n = t, r = n.points;
1409
+ if (!r.length) return;
1410
+ e.moveTo(r[0], r[1]);
1411
+ for (let t = 2; t < r.length; t += 2) e.lineTo(r[t], r[t + 1]);
1412
+ n.closePath && e.closePath();
1454
1413
  break;
1455
1414
  }
1456
1415
  }
1457
1416
  }
1458
- var _BatchPipe, Batch = class {
1459
- constructor() {
1460
- this.renderPipeId = "batch", this.elements = [];
1461
- }
1462
- }, BatchPipe = class {
1463
- constructor(n) {
1464
- this._renderer = n;
1465
- }
1466
- get batch() {
1467
- return this._activeBatch;
1468
- }
1469
- buildStart() {
1470
- this._activeBatch = new Batcher();
1471
- }
1472
- buildEnd(n) {
1473
- this.break(n);
1474
- }
1475
- break(n) {
1476
- this._activeBatch.build(n);
1417
+ //#endregion
1418
+ //#region lib/scene/mask/StencilMaskPipe.ts
1419
+ var Re = class {
1420
+ constructor(e) {
1421
+ f(this, "_renderer", void 0), f(this, "_canvasMaskStack", []), this._renderer = e;
1422
+ }
1423
+ push(e, t) {
1424
+ t.add({
1425
+ renderPipeId: "stencilMask",
1426
+ action: "pushMaskBegin",
1427
+ mask: e
1428
+ });
1477
1429
  }
1478
- addToBatch(n, j) {
1479
- this._activeBatch.add({
1480
- ...n,
1481
- getColor: () => n.renderable.groupColorAlpha
1430
+ pop(e, t) {
1431
+ this._renderer.renderPipes.batch.break(t), t.add({
1432
+ renderPipeId: "stencilMask",
1433
+ action: "popMaskEnd",
1434
+ mask: e
1482
1435
  });
1483
1436
  }
1484
- execute(n) {
1485
- let j = n.elements;
1486
- if (!j || !j.length) return;
1487
- let M = this._renderer.canvasContext, N = M.activeConext;
1488
- for (let n = 0; n < j.length; n++) {
1489
- let P = j[n], F = P.roundPixels, I = (P.getColor() >>> 24 & 255) / 255;
1490
- if (I <= 0) continue;
1491
- N.globalAlpha = I, M.setContextTransform(P.transform, F === 1);
1492
- let L = P.bounds, R = P.texture, z = R.frame, B = R.source._resolution || 1, V = z.x * B, H = z.y * B, U = z.width * B, W = z.height * B, G = L.minX, K = L.minY, q = L.maxX - L.minX, J = L.maxY - L.minY, Y = G, X = K, Z = q, Q = J;
1493
- N.drawImage(R.source.resource, V, H, U, W, Y, X, Z, Q);
1437
+ execute(e) {
1438
+ if (e.action !== "pushMaskBegin" && e.action !== "popMaskEnd") return;
1439
+ let t = this._renderer.canvasContext, n = t.activeConext;
1440
+ if (e.action === "popMaskEnd") {
1441
+ this._canvasMaskStack.pop() && n.restore();
1442
+ return;
1443
+ }
1444
+ let r = e.mask.mask, i = r.context.instructions, a = r._roundPixels === 1;
1445
+ n.save(), t.setContextTransform(r.relativeGroupTransform, a), n.beginPath();
1446
+ for (let e = 0; e < i.length; ++e) {
1447
+ let t = i[e], r = t.action;
1448
+ if (r !== "fill" && r !== "stroke") return;
1449
+ let a = t.data.path.shapePath.shapePrimitives;
1450
+ for (let e = 0; e < a.length; ++e) {
1451
+ let t = a[e].shape;
1452
+ B(n, t);
1453
+ }
1494
1454
  }
1455
+ n.clip(), this._canvasMaskStack.push(!0);
1495
1456
  }
1496
1457
  destroy() {
1497
- var n;
1498
- this._renderer = null, (n = this._activeBatch) == null || n.destroy(), this._activeBatch = null;
1458
+ this._renderer = null;
1499
1459
  }
1500
1460
  };
1501
- _BatchPipe = BatchPipe, _BatchPipe.desc = { name: "batch" };
1502
- var Batcher = class {
1503
- constructor() {
1504
- this.renderPipeId = "batch", this.elements = [], this.elementSize = 0;
1461
+ f(Re, "desc", { name: "stencilMask" });
1462
+ //#endregion
1463
+ //#region lib/scene/sprite/SpritePipe.ts
1464
+ var ze = class {
1465
+ constructor(e) {
1466
+ f(this, "_renderer", void 0), this._renderer = e;
1467
+ }
1468
+ addRenderable(e, t) {
1469
+ let n = this._getRuntimeSprite(e);
1470
+ e.didViewUpdate && this._updateBatchableSprite(e, n), this._renderer.renderPipes.batch.addToBatch(n, t);
1471
+ }
1472
+ _updateBatchableSprite(e, t) {
1473
+ t.texture = e._texture, t.bounds = e.bounds;
1474
+ }
1475
+ validateRenderable(e) {
1476
+ return this._getRuntimeSprite(e).texture._source.uid !== e._texture._source.uid;
1477
+ }
1478
+ _getRuntimeSprite(e) {
1479
+ return e._runtimeData[this._renderer.uid] || this._initCacheSprite(e);
1480
+ }
1481
+ _initCacheSprite(e) {
1482
+ let t = {
1483
+ renderable: e,
1484
+ texture: e.texture,
1485
+ transform: e.relativeGroupTransform,
1486
+ bounds: e.bounds,
1487
+ roundPixels: this._renderer._roundPixels | e._roundPixels,
1488
+ destroy() {
1489
+ this.renderable = null, this.texture = null, this.transform = null, this.bounds = null;
1490
+ }
1491
+ };
1492
+ return e._runtimeData[this._renderer.uid] = t, t;
1505
1493
  }
1506
- add(n) {
1507
- this.elements[this.elementSize++] = n;
1494
+ destroy() {
1495
+ this._renderer = null;
1508
1496
  }
1509
- build(n) {
1510
- let j = new Batch(), M = this.elements;
1511
- if (M[0]) {
1512
- for (let n = 0; n < M.length; n++) {
1513
- let N = M[n];
1514
- this.elements[n] = null, j.elements.push(N);
1515
- }
1516
- n.add(j);
1497
+ };
1498
+ f(ze, "desc", { name: "sprite" });
1499
+ //#endregion
1500
+ //#region lib/scene/text/TextPipe.ts
1501
+ var V = class {
1502
+ constructor(e) {
1503
+ f(this, "_renderer", void 0), this._renderer = e;
1504
+ }
1505
+ addRenderable(e, t) {
1506
+ let n = this._getRuntimeText(e);
1507
+ if (e._didTextUpdate) {
1508
+ let t = e._autoResolution ? this._renderer.resolution : e.resolution;
1509
+ (n.currentKey !== e.styleKey || e._resolution !== t) && this._updateRuntimeText(e), e._didTextUpdate = !1, ae(n.bounds, e._anchor, n.texture);
1517
1510
  }
1511
+ this._renderer.renderPipes.batch.addToBatch(n, t);
1512
+ }
1513
+ validateRenderable(e) {
1514
+ let t = this._getRuntimeText(e), n = e.styleKey;
1515
+ return t.currentKey === n ? e._didTextUpdate : !0;
1516
+ }
1517
+ initCacheText(e) {
1518
+ let t = {
1519
+ currentKey: "--",
1520
+ transform: e.relativeGroupTransform,
1521
+ bounds: e.bounds,
1522
+ roundPixels: this._renderer._roundPixels | e._roundPixels,
1523
+ renderable: e,
1524
+ texture: null,
1525
+ destroy() {
1526
+ this.renderable = null, this.texture = null, this.bounds = null;
1527
+ }
1528
+ };
1529
+ return e._runtimeData[this._renderer.uid] = t, t;
1530
+ }
1531
+ _getRuntimeText(e) {
1532
+ return e._runtimeData[this._renderer.uid] || this.initCacheText(e);
1533
+ }
1534
+ _updateRuntimeText(e) {
1535
+ let t = this._getRuntimeText(e);
1536
+ t.texture, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, t.texture = this._renderer.text.getManagedTexture(e), t.currentKey = e.styleKey;
1518
1537
  }
1519
1538
  destroy() {
1520
- this.elements = null;
1539
+ this._renderer = null;
1521
1540
  }
1522
1541
  };
1523
- const CanvasPool = new class {
1542
+ f(V, "desc", { name: "text" });
1543
+ var Be = new class {
1524
1544
  constructor() {
1525
- this._canvasPool = Object.create(null);
1545
+ f(this, "_canvasPool", void 0), this._canvasPool = Object.create(null);
1526
1546
  }
1527
- getOptimalCanvasAndContext(n, j, M = 1) {
1528
- let N = nextPow2(n * M - 1e-6), P = nextPow2(j * M - 1e-6), F = N << 17 + P << 1;
1529
- this._canvasPool[F] || (this._canvasPool[F] = []);
1530
- let I = this._canvasPool[F].pop();
1531
- if (I) return I;
1547
+ getOptimalCanvasAndContext(e, t, n = 1) {
1548
+ let r = x(e * n - 1e-6), i = x(t * n - 1e-6), a = r << 17 + i << 1;
1549
+ this._canvasPool[a] || (this._canvasPool[a] = []);
1550
+ let o = this._canvasPool[a].pop();
1551
+ if (o) return o;
1532
1552
  {
1533
- let n = document.createElement("canvas");
1534
- return n.width = N, n.height = P, {
1535
- canvas: n,
1536
- context: n.getContext("2d")
1553
+ let e = document.createElement("canvas");
1554
+ return e.width = r, e.height = i, {
1555
+ canvas: e,
1556
+ context: e.getContext("2d")
1537
1557
  };
1538
1558
  }
1539
1559
  }
1540
- }();
1541
- var _TextStyle, TextStyle = class n {
1542
- constructor(j) {
1543
- this.uid = uid("textStyle"), this._tick = 0;
1544
- let M = {
1545
- ...n.defaultStyle,
1546
- ...j
1560
+ }(), H = class e {
1561
+ constructor(t) {
1562
+ f(this, "uid", D("textStyle")), f(this, "_cachedFontString", void 0), f(this, "_fontSize", void 0), f(this, "_fontFamily", void 0), f(this, "_fontStyle", void 0), f(this, "_lineHeight", void 0), f(this, "_leading", void 0), f(this, "_fontVariant", void 0), f(this, "_fontWeight", void 0), f(this, "_letterSpacing", void 0), f(this, "_textBaseline", void 0), f(this, "_align", void 0), f(this, "_wordWrap", void 0), f(this, "_fill", void 0), f(this, "_tick", 0);
1563
+ let n = {
1564
+ ...e.defaultStyle,
1565
+ ...t
1547
1566
  };
1548
- for (let n in M) {
1549
- let j = n;
1550
- this[j] = M[n];
1567
+ for (let e in n) {
1568
+ let t = e;
1569
+ this[t] = n[e];
1551
1570
  }
1552
1571
  }
1553
1572
  get styleKey() {
@@ -1556,86 +1575,86 @@ var _TextStyle, TextStyle = class n {
1556
1575
  get fontSize() {
1557
1576
  return this._fontSize;
1558
1577
  }
1559
- set fontSize(n) {
1560
- this._fontSize !== n && (this._fontSize = n, this.update());
1578
+ set fontSize(e) {
1579
+ this._fontSize !== e && (this._fontSize = e, this.update());
1561
1580
  }
1562
1581
  get fill() {
1563
1582
  return this._fill;
1564
1583
  }
1565
- set fill(n) {
1566
- this._fill !== n && (this._fill = n, this.update());
1584
+ set fill(e) {
1585
+ this._fill !== e && (this._fill = e, this.update());
1567
1586
  }
1568
1587
  get align() {
1569
1588
  return this._align;
1570
1589
  }
1571
- set align(n) {
1572
- this._align !== n && (this._align = n, this.update());
1590
+ set align(e) {
1591
+ this._align !== e && (this._align = e, this.update());
1573
1592
  }
1574
- get wordWarp() {
1593
+ get wordWrap() {
1575
1594
  return this._wordWrap;
1576
1595
  }
1577
- set wordWrap(n) {
1578
- this._wordWrap !== n && (this._wordWrap = n, this.update());
1596
+ set wordWrap(e) {
1597
+ this._wordWrap !== e && (this._wordWrap = e, this.update());
1579
1598
  }
1580
1599
  get fontFamily() {
1581
1600
  return this._fontFamily;
1582
1601
  }
1583
- set fontFamily(n) {
1584
- this._fontFamily !== n && (this._fontFamily = n, this.update());
1602
+ set fontFamily(e) {
1603
+ this._fontFamily !== e && (this._fontFamily = e, this.update());
1585
1604
  }
1586
1605
  get leading() {
1587
1606
  return this._leading;
1588
1607
  }
1589
- set leading(n) {
1590
- this._leading !== n && (this._leading = n, this.update());
1608
+ set leading(e) {
1609
+ this._leading !== e && (this._leading = e, this.update());
1591
1610
  }
1592
1611
  get fontStyle() {
1593
1612
  return this._fontStyle;
1594
1613
  }
1595
- set fontStyle(n) {
1596
- this._fontStyle !== n && (this._fontStyle = n.toLowerCase(), this.update());
1614
+ set fontStyle(e) {
1615
+ this._fontStyle !== e && (this._fontStyle = e.toLowerCase(), this.update());
1597
1616
  }
1598
1617
  get textBaseline() {
1599
1618
  return this._textBaseline;
1600
1619
  }
1601
- set textBaseline(n) {
1602
- this._textBaseline = n, this.update();
1620
+ set textBaseline(e) {
1621
+ this._textBaseline = e, this.update();
1603
1622
  }
1604
1623
  get lineHeight() {
1605
1624
  return this._lineHeight;
1606
1625
  }
1607
- set lineHeight(n) {
1608
- this._lineHeight !== n && (this._lineHeight = n, this.update());
1626
+ set lineHeight(e) {
1627
+ this._lineHeight !== e && (this._lineHeight = e, this.update());
1609
1628
  }
1610
1629
  get letterSpacing() {
1611
1630
  return this._letterSpacing;
1612
1631
  }
1613
- set letterSpacing(n) {
1614
- this._letterSpacing !== n && (this._letterSpacing = n, this.update());
1632
+ set letterSpacing(e) {
1633
+ this._letterSpacing !== e && (this._letterSpacing = e, this.update());
1615
1634
  }
1616
1635
  get fontVariant() {
1617
1636
  return this._fontVariant;
1618
1637
  }
1619
- set fontVariant(n) {
1620
- this._fontVariant !== n && (this._fontVariant = n, this.update());
1638
+ set fontVariant(e) {
1639
+ this._fontVariant !== e && (this._fontVariant = e, this.update());
1621
1640
  }
1622
1641
  get fontWeight() {
1623
1642
  return this._fontWeight;
1624
1643
  }
1625
- set fontWeight(n) {
1626
- this._fontWeight !== n && (this._fontWeight = n, this.update());
1644
+ set fontWeight(e) {
1645
+ this._fontWeight !== e && (this._fontWeight = e, this.update());
1627
1646
  }
1628
1647
  get _fontString() {
1629
- return this._cachedFontString === null && (this._cachedFontString = fontStringFromTextStyle(this)), this._cachedFontString;
1648
+ return this._cachedFontString === null && (this._cachedFontString = He(this)), this._cachedFontString;
1630
1649
  }
1631
1650
  update() {
1632
1651
  this._tick++, this._cachedFontString = null;
1633
1652
  }
1634
- destroy(n = !1) {
1653
+ destroy(e = !1) {
1635
1654
  this._fill = null;
1636
1655
  }
1637
1656
  };
1638
- _TextStyle = TextStyle, _TextStyle.defaultStyle = {
1657
+ f(H, "defaultStyle", {
1639
1658
  align: "left",
1640
1659
  breakWords: !1,
1641
1660
  dropShadow: null,
@@ -1655,8 +1674,8 @@ _TextStyle = TextStyle, _TextStyle.defaultStyle = {
1655
1674
  whiteSpace: "pre",
1656
1675
  wordWrap: !1,
1657
1676
  wordWrapWidth: 100
1658
- };
1659
- var genericFontFamilies = [
1677
+ });
1678
+ var Ve = [
1660
1679
  "serif",
1661
1680
  "sans-serif",
1662
1681
  "monospace",
@@ -1664,199 +1683,201 @@ var genericFontFamilies = [
1664
1683
  "fantasy",
1665
1684
  "system-ui"
1666
1685
  ];
1667
- function fontStringFromTextStyle(n) {
1668
- let j = typeof n.fontSize == "number" ? `${n.fontSize}px` : n.fontSize, M = n.fontFamily;
1669
- Array.isArray(n.fontFamily) || (M = n.fontFamily.split(","));
1670
- for (let n = M.length - 1; n >= 0; n--) {
1671
- let j = M[n].trim();
1672
- !/([\"\'])[^\'\"]+\1/.test(j) && !genericFontFamilies.includes(j) && (j = `"${j}"`), M[n] = j;
1673
- }
1674
- return `${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${j} ${M.join(",")}`;
1686
+ function He(e) {
1687
+ let t = typeof e.fontSize == "number" ? `${e.fontSize}px` : e.fontSize, n = e.fontFamily;
1688
+ Array.isArray(e.fontFamily) || (n = e.fontFamily.split(","));
1689
+ for (let e = n.length - 1; e >= 0; e--) {
1690
+ let t = n[e].trim();
1691
+ !/(["'])[^'"]+\1/.test(t) && !Ve.includes(t) && (t = `"${t}"`), n[e] = t;
1692
+ }
1693
+ return `${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(",")}`;
1675
1694
  }
1676
- var _TextMetrics;
1677
- const NEWLINE_MATCH_REGEX = /(?:\r\n|\r|\n)/;
1678
- var TextMetrics = class n {
1679
- constructor(n, j, M, N, P, F, I, L, R) {
1680
- this.text = n, this.style = j, this.width = M, this.height = N, this.lines = P, this.lineWidths = F, this.lineHeight = I, this.maxLineWidth = L, this.fontProperties = R;
1695
+ //#endregion
1696
+ //#region lib/scene/text/utils.ts
1697
+ var Ue = /(?:\r\n|\r|\n)/, U = class e {
1698
+ constructor(e, t, n, r, i, a, o, s, c) {
1699
+ f(this, "text", void 0), f(this, "style", void 0), f(this, "width", void 0), f(this, "height", void 0), f(this, "lines", void 0), f(this, "lineWidths", void 0), f(this, "lineHeight", void 0), f(this, "maxLineWidth", void 0), f(this, "fontProperties", void 0), this.text = e, this.style = t, this.width = n, this.height = r, this.lines = i, this.lineWidths = a, this.lineHeight = o, this.maxLineWidth = s, this.fontProperties = c;
1681
1700
  }
1682
1701
  static get canvas() {
1683
- if (!n._canvas) {
1684
- let j;
1702
+ if (!e._canvas) {
1703
+ let t;
1685
1704
  try {
1686
- let M = new OffscreenCanvas(0, 0);
1687
- if (M.getContext("2d", { willReadFrequently: !0 }).measureText) return n._canvas = M, M;
1688
- j = createCanvas(10, 10);
1689
- } catch (n) {
1690
- j = createCanvas(10, 10);
1705
+ let n = new OffscreenCanvas(0, 0);
1706
+ if (n.getContext("2d", { willReadFrequently: !0 }).measureText) return e._canvas = n, n;
1707
+ t = W(10, 10);
1708
+ } catch (e) {
1709
+ t = W(10, 10);
1691
1710
  }
1692
- n._canvas = j;
1711
+ e._canvas = t;
1693
1712
  }
1694
- return n._canvas;
1713
+ return e._canvas;
1695
1714
  }
1696
1715
  static get context() {
1697
- return n._context || (n._context = n.canvas.getContext("2d", { willReadFrequently: !0 })), n._context;
1698
- }
1699
- static measureText(j, M) {
1700
- let N = `${j}-${M.styleKey}`;
1701
- if (n._measurementCache.has(N)) return n._measurementCache.get(N);
1702
- let P = M._fontString, F = n.measureFont(P);
1703
- F.fontSize === 0 && (F.fontSize = M.fontSize, F.ascent = M.fontSize, F.descent = 0);
1704
- let I = n.context;
1705
- I.font = P;
1706
- let L = j.split(NEWLINE_MATCH_REGEX), R = Array(L.length), z = 0;
1707
- for (let j = 0; j < L.length; ++j) {
1708
- let N = n._measureText(L[j], M.letterSpacing);
1709
- R[j] = N, z = Math.max(z, N);
1716
+ return e._context || (e._context = e.canvas.getContext("2d", { willReadFrequently: !0 })), e._context;
1717
+ }
1718
+ static measureText(t, n) {
1719
+ let r = `${t}-${n.styleKey}`;
1720
+ if (e._measurementCache.has(r)) return e._measurementCache.get(r);
1721
+ let i = n._fontString, a = e.measureFont(i);
1722
+ a.fontSize === 0 && (a.fontSize = n.fontSize, a.ascent = n.fontSize, a.descent = 0);
1723
+ let o = e.context;
1724
+ o.font = i;
1725
+ let s = t.split(Ue), c = Array.from({ length: s.length }), l = 0;
1726
+ for (let t = 0; t < s.length; ++t) {
1727
+ let r = e._measureText(s[t], n.letterSpacing);
1728
+ c[t] = r, l = Math.max(l, r);
1710
1729
  }
1711
- let B = M.lineHeight || F.fontSize, V = new n(j, M, z, Math.max(B, F.fontSize + (L.length - 1) * (B + M.leading)), L, R, B, z, F);
1712
- return n._measurementCache.set(N, V), V;
1713
- }
1714
- static _measureText(j, M) {
1715
- var N, P;
1716
- let F = n.context;
1717
- F.letterSpacing = "0px", F.textLetterSpacing = M;
1718
- let I = F.measureText(j), L = I.width, R = 0;
1719
- L > 0 && (R = (n.graphemeSegmenter(j).length - 1) * M, L += R);
1720
- let z = -((N = I.actualBoundingBoxLeft) == null ? 0 : N), B = ((P = I.actualBoundingBoxRight) == null ? 0 : P) - z;
1721
- return I.width > 0 && (B += R), Math.max(L, B);
1722
- }
1723
- static measureFont(j) {
1724
- var M, N;
1725
- if (n._fonts[j]) return n._fonts[j];
1726
- let P = n.context;
1727
- P.font = j;
1728
- let F = P.measureText(n.METRICS_STRING + n.BASELINE_SYMBOL), I = (M = F.actualBoundingBoxAscent) == null ? 0 : M, L = (N = F.actualBoundingBoxDescent) == null ? 0 : N, R = {
1729
- ascent: I,
1730
- descent: L,
1731
- fontSize: I + L
1730
+ let u = n.lineHeight || a.fontSize, d = new e(t, n, l, Math.max(u, a.fontSize + (s.length - 1) * (u + n.leading)), s, c, u, l, a);
1731
+ return e._measurementCache.set(r, d), d;
1732
+ }
1733
+ static _measureText(t, n) {
1734
+ var r, i;
1735
+ let a = e.context;
1736
+ a.letterSpacing = "0px", a.textLetterSpacing = n;
1737
+ let o = a.measureText(t), s = o.width, c = 0;
1738
+ s > 0 && (c = (e.graphemeSegmenter(t).length - 1) * n, s += c);
1739
+ let l = -((r = o.actualBoundingBoxLeft) == null ? 0 : r), u = ((i = o.actualBoundingBoxRight) == null ? 0 : i) - l;
1740
+ return o.width > 0 && (u += c), Math.max(s, u);
1741
+ }
1742
+ static measureFont(t) {
1743
+ var n, r;
1744
+ if (e._fonts[t]) return e._fonts[t];
1745
+ let i = e.context;
1746
+ i.font = t;
1747
+ let a = i.measureText(e.METRICS_STRING + e.BASELINE_SYMBOL), o = (n = a.actualBoundingBoxAscent) == null ? 0 : n, s = (r = a.actualBoundingBoxDescent) == null ? 0 : r, c = {
1748
+ ascent: o,
1749
+ descent: s,
1750
+ fontSize: o + s
1732
1751
  };
1733
- return n._fonts[j] = R, R;
1752
+ return e._fonts[t] = c, c;
1734
1753
  }
1735
1754
  };
1736
- _TextMetrics = TextMetrics, _TextMetrics.METRICS_STRING = "|ÉqÅ", _TextMetrics.BASELINE_SYMBOL = "M", _TextMetrics._measurementCache = /* @__PURE__ */ new Map(), _TextMetrics._fonts = {}, _TextMetrics.graphemeSegmenter = (() => {
1737
- var n;
1738
- if (typeof ((n = Intl) == null ? void 0 : n.Segmenter) == "function") {
1739
- let n = new Intl.Segmenter();
1740
- return (j) => {
1741
- let M = n.segment(j), N = [], P = 0;
1742
- for (let n of M) N[P++] = n.segment;
1743
- return N;
1755
+ f(U, "METRICS_STRING", "|ÉqÅ"), f(U, "BASELINE_SYMBOL", "M"), f(U, "_canvas", void 0), f(U, "_context", void 0), f(U, "_measurementCache", /* @__PURE__ */ new Map()), f(U, "_fonts", {}), f(U, "graphemeSegmenter", (() => {
1756
+ var e;
1757
+ if (typeof ((e = Intl) == null ? void 0 : e.Segmenter) == "function") {
1758
+ let e = new Intl.Segmenter();
1759
+ return (t) => {
1760
+ let n = e.segment(t), r = [], i = 0;
1761
+ for (let e of n) r[i++] = e.segment;
1762
+ return r;
1744
1763
  };
1745
1764
  }
1746
- return (n) => [...n];
1747
- })();
1748
- function createCanvas(n, j) {
1749
- let M = document.createElement("canvas");
1750
- return M.width = n, M.height = j, M;
1765
+ return (e) => [...e];
1766
+ })());
1767
+ function W(e, t) {
1768
+ let n = document.createElement("canvas");
1769
+ return n.width = e, n.height = t, n;
1751
1770
  }
1752
- function generateTextTexture(n) {
1753
- let { text: j, style: M, resolution: N = 1, padding: P = 0 } = n, F = TextMetrics.measureText(j, M), I = Math.ceil(Math.ceil(Math.max(1, F.width) + P * 2) * N), L = Math.ceil(Math.ceil(Math.max(1, F.height) + P * 2) * N), R = CanvasPool.getOptimalCanvasAndContext(I, L);
1754
- return renderTextToCanvas(M, N, P, R, F), {
1755
- canvasAndContext: R,
1756
- frame: new Rectangle(0, 0, I, L)
1771
+ function We(e) {
1772
+ let { text: t, style: n, resolution: r = 1, padding: i = 0 } = e, a = U.measureText(t, n), o = Math.ceil(Math.ceil(Math.max(1, a.width) + i * 2) * r), s = Math.ceil(Math.ceil(Math.max(1, a.height) + i * 2) * r), c = Be.getOptimalCanvasAndContext(o, s);
1773
+ return Ge(n, r, i, c, a), {
1774
+ canvasAndContext: c,
1775
+ frame: new y(0, 0, o, s)
1757
1776
  };
1758
1777
  }
1759
- function renderTextToCanvas(n, j, M, N, P) {
1760
- let { context: F } = N, I = fontStringFromTextStyle(n), { lines: L, lineHeight: R, lineWidths: z, maxLineWidth: B, fontProperties: V } = P;
1761
- F.resetTransform(), F.scale(j, j), F.textBaseline = n.textBaseline, F.font = I;
1762
- let H = Math.min(0, (R - V.fontSize) / 2);
1763
- F.fillStyle = n.fill;
1764
- for (let j = 0; j < L.length; ++j) {
1765
- let P = getAlignmentOffset(z[j], B, n.align), F = j * R + V.ascent + H, I = 0;
1766
- if (n.align === "justify" && n.wordWrap && j < L.length - 1) {
1767
- let n = countSpaces(L[j]);
1768
- n > 0 && (I = (B - z[j]) / n);
1778
+ function Ge(e, t, n, r, i) {
1779
+ let { context: a } = r, o = He(e), { lines: s, lineHeight: c, lineWidths: l, maxLineWidth: u, fontProperties: d } = i;
1780
+ a.resetTransform(), a.scale(t, t), a.textBaseline = e.textBaseline, a.font = o;
1781
+ let f = Math.min(0, (c - d.fontSize) / 2);
1782
+ a.fillStyle = e.fill;
1783
+ for (let t = 0; t < s.length; ++t) {
1784
+ let i = Ke(l[t], u, e.align), a = t * c + d.ascent + f, o = 0;
1785
+ if (e.align === "justify" && e.wordWrap && t < s.length - 1) {
1786
+ let e = qe(s[t]);
1787
+ e > 0 && (o = (u - l[t]) / e);
1769
1788
  }
1770
- drawLetterSpacing(L[j], n, N, P + M, F + M, !1, I);
1789
+ Je(s[t], e, r, i + n, a + n, !1, o);
1771
1790
  }
1772
1791
  }
1773
- function getAlignmentOffset(n, j, M) {
1774
- return M === "right" ? j - n : M === "center" ? (j - n) / 2 : 0;
1792
+ function Ke(e, t, n) {
1793
+ return n === "right" ? t - e : n === "center" ? (t - e) / 2 : 0;
1775
1794
  }
1776
- function countSpaces(n) {
1777
- let j = 0;
1778
- for (let M = 0; M < n.length; M++) n.charCodeAt(M) === 32 && j++;
1779
- return j;
1795
+ function qe(e) {
1796
+ let t = 0;
1797
+ for (let n = 0; n < e.length; n++) e.charCodeAt(n) === 32 && t++;
1798
+ return t;
1780
1799
  }
1781
- function drawLetterSpacing(n, j, M, N, P, F = !1, I = 0) {
1782
- let L = M.context, R = j.letterSpacing;
1783
- if (R === 0 && I === 0) {
1784
- L.fillText(n, N, P);
1800
+ function Je(e, t, n, r, i, a = !1, o = 0) {
1801
+ let s = n.context, c = t.letterSpacing;
1802
+ if (c === 0 && o === 0) {
1803
+ s.fillText(e, r, i);
1785
1804
  return;
1786
1805
  }
1787
- if (I !== 0 && R === 0) {
1788
- let j = n.split(" "), M = N, F = L.measureText(" ").width;
1789
- for (let n = 0; n < j.length; ++n) L.fillText(j[n], M, P), M += L.measureText(j[n]).width + F + I;
1806
+ if (o !== 0 && c === 0) {
1807
+ let t = e.split(" "), n = r, a = s.measureText(" ").width;
1808
+ for (let e = 0; e < t.length; ++e) s.fillText(t[e], n, i), n += s.measureText(t[e]).width + a + o;
1790
1809
  return;
1791
1810
  }
1792
- let z = N, B = TextMetrics.graphemeSegmenter(n), V = L.measureText(n).width, H = 0;
1793
- for (let n = 0; n < B.length; ++n) {
1794
- let j = B[n];
1795
- L.fillText(j, z, P);
1796
- let M = "";
1797
- for (let j = n + 1; j < B.length; ++j) M += B[j];
1798
- H = L.measureText(M).width, z += V - H + R, j === "" && (z += I), V = H;
1811
+ let l = r, u = U.graphemeSegmenter(e), d = s.measureText(e).width, f = 0;
1812
+ for (let e = 0; e < u.length; ++e) {
1813
+ let t = u[e];
1814
+ s.fillText(t, l, i);
1815
+ let n = "";
1816
+ for (let t = e + 1; t < u.length; ++t) n += u[t];
1817
+ f = s.measureText(n).width, l += d - f + c, t === "" && (l += o), d = f;
1799
1818
  }
1800
1819
  }
1801
- var _TextureSource, TextureSource = class n extends eventemitter3_default {
1802
- constructor(j) {
1803
- super(), this._resolution = 1, this.pixelWidth = 1, this.pixelHeight = 1, this.width = 1, this.height = 1;
1804
- let M = {
1805
- ...n.defaultOptions,
1806
- ...j
1820
+ //#endregion
1821
+ //#region lib/renderer/texture/TextureSource.ts
1822
+ var G = class e extends c {
1823
+ constructor(t) {
1824
+ super(), f(this, "uid", D("textureSource")), f(this, "label", void 0), f(this, "_resolution", 1), f(this, "pixelWidth", 1), f(this, "pixelHeight", 1), f(this, "width", 1), f(this, "height", 1), f(this, "resource", void 0), f(this, "destroyed", void 0);
1825
+ let n = {
1826
+ ...e.defaultOptions,
1827
+ ...t
1807
1828
  };
1808
- this.label = j.label, this.resource = M.resource, this._resolution = M.resolution, M.width ? this.pixelWidth = j.width * this._resolution : this.pixelWidth = this.resource && this.resourceWidth || 1, M.height ? this.pixelHeight = j.height * this._resolution : this.pixelHeight = this.resource && this.resourceHeight || 1, this.width = this.pixelWidth / this._resolution, this.height = this.pixelHeight / this._resolution, this.destroyed = !1;
1829
+ this.label = t.label, this.resource = n.resource, this._resolution = n.resolution, n.width ? this.pixelWidth = t.width * this._resolution : this.pixelWidth = this.resource && this.resourceWidth || 1, n.height ? this.pixelHeight = t.height * this._resolution : this.pixelHeight = this.resource && this.resourceHeight || 1, this.width = this.pixelWidth / this._resolution, this.height = this.pixelHeight / this._resolution, this.destroyed = !1;
1809
1830
  }
1810
1831
  get resolution() {
1811
1832
  return this._resolution;
1812
1833
  }
1813
- set resolution(n) {
1814
- this._resolution !== n && (this._resolution = n, this.width = this.pixelWidth / n, this.height = this.pixelHeight / n);
1834
+ set resolution(e) {
1835
+ this._resolution !== e && (this._resolution = e, this.width = this.pixelWidth / e, this.height = this.pixelHeight / e);
1815
1836
  }
1816
1837
  get resourceWidth() {
1817
- let n = this.resource;
1818
- return n.naturalWidth || n.width;
1838
+ let e = this.resource;
1839
+ return e.naturalWidth || e.width;
1819
1840
  }
1820
1841
  get resourceHeight() {
1821
- let n = this.resource;
1822
- return n.naturalHeight || n.height;
1842
+ let e = this.resource;
1843
+ return e.naturalHeight || e.height;
1823
1844
  }
1824
- resize(n, j, M) {
1825
- M || (M = this._resolution), n || (n = this.width), j || (j = this.height);
1826
- let N = Math.round(n * M), P = Math.round(j * M);
1827
- return this.width = N / M, this.height = P / M, this._resolution = M, this.pixelWidth === N && this.pixelHeight === P ? !1 : (this.pixelWidth = N, this.pixelHeight = P, this.emit("resize", this), !0);
1845
+ resize(e, t, n) {
1846
+ n || (n = this._resolution), e || (e = this.width), t || (t = this.height);
1847
+ let r = Math.round(e * n), i = Math.round(t * n);
1848
+ return this.width = r / n, this.height = i / n, this._resolution = n, this.pixelWidth === r && this.pixelHeight === i ? !1 : (this.pixelWidth = r, this.pixelHeight = i, this.emit("resize", this), !0);
1828
1849
  }
1829
1850
  destroy() {
1830
1851
  this.destroyed = !0, this.resource = null, this.emit("destroy", this), this.removeAllListeners();
1831
1852
  }
1832
1853
  };
1833
- _TextureSource = TextureSource, _TextureSource.defaultOptions = { resolution: 1 };
1834
- var CanvasSource = class extends TextureSource {
1835
- constructor(n) {
1836
- n.resource || (n.resource = createCanvas()), n.width || (n.width = n.resource.width, n.autoDensity || (n.width /= n.resolution)), n.height || (n.height = n.resource.height, n.autoDensity || (n.height /= n.resolution)), super(n), this.autoDensity = n.autoDensity, this.resizeCanvas();
1854
+ f(G, "defaultOptions", { resolution: 1 });
1855
+ var Ye = class extends G {
1856
+ constructor(e) {
1857
+ e.resource || (e.resource = W()), e.width || (e.width = e.resource.width, e.autoDensity || (e.width /= e.resolution)), e.height || (e.height = e.resource.height, e.autoDensity || (e.height /= e.resolution)), super(e), f(this, "autoDensity", void 0), this.autoDensity = e.autoDensity, this.resizeCanvas();
1837
1858
  }
1838
1859
  resizeCanvas() {
1839
1860
  this.autoDensity && (this.resource.style.width = `${this.width}px`, this.resource.style.height = `${this.height}px`), (this.resource.width !== this.pixelWidth || this.resource.height !== this.pixelHeight) && (this.resource.width = this.pixelWidth, this.resource.height = this.pixelHeight);
1840
1861
  }
1841
- resize(n = this.width, j = this.height, M = this._resolution) {
1842
- let N = super.resize(n, j, M);
1843
- return N && this.resizeCanvas(), N;
1862
+ resize(e = this.width, t = this.height, n = this._resolution) {
1863
+ let r = super.resize(e, t, n);
1864
+ return r && this.resizeCanvas(), r;
1844
1865
  }
1845
- }, Texture = class extends eventemitter3_default {
1846
- constructor({ source: n, label: j, frame: M, orig: N, rotate: P } = {}) {
1847
- if (super(), this.frame = new Rectangle(), this.noFrame = !1, this.label = j, this.source = n, M) this.frame.copyFrom(M);
1866
+ }, K = class extends c {
1867
+ constructor({ source: e, label: t, frame: n, orig: r, rotate: i } = {}) {
1868
+ if (super(), f(this, "label", void 0), f(this, "_source", void 0), f(this, "orig", void 0), f(this, "frame", new y()), f(this, "rotate", void 0), f(this, "destroyed", void 0), f(this, "noFrame", !1), this.label = t, this.source = e, n) this.frame.copyFrom(n);
1848
1869
  else {
1849
1870
  this.noFrame = !0;
1850
- let { width: j, height: M } = n;
1851
- this.frame.width = j, this.frame.height = M;
1871
+ let { width: t, height: n } = e;
1872
+ this.frame.width = t, this.frame.height = n;
1852
1873
  }
1853
- this.orig = N || this.frame, this.rotate = P == null ? 0 : P, this.destroyed = !1;
1874
+ this.orig = r || this.frame, this.rotate = i == null ? 0 : i, this.destroyed = !1;
1854
1875
  }
1855
1876
  get source() {
1856
1877
  return this._source;
1857
1878
  }
1858
- set source(n) {
1859
- this._source && this._source.off("resize", this.update, this), this._source = n, n.on("resize", this.update, this);
1879
+ set source(e) {
1880
+ this._source && this._source.off("resize", this.update, this), this._source = e, e.on("resize", this.update, this);
1860
1881
  }
1861
1882
  get width() {
1862
1883
  return this.orig.width;
@@ -1867,100 +1888,76 @@ var CanvasSource = class extends TextureSource {
1867
1888
  update() {
1868
1889
  this.noFrame && (this.frame.width = this._source.width, this.frame.height = this._source.height);
1869
1890
  }
1870
- destroy(n = !1) {
1871
- this._source && (this._source.off("resize", this.update, this), n && (this._source.destroy(), this._source = null)), this.destroyed = !0, this.emit("destroy", this), this.removeAllListeners();
1891
+ destroy(e = !1) {
1892
+ this._source && (this._source.off("resize", this.update, this), e && (this._source.destroy(), this._source = null)), this.destroyed = !0, this.emit("destroy", this), this.removeAllListeners();
1872
1893
  }
1873
1894
  };
1874
- Texture.EMPTY = new Texture({
1895
+ f(K, "EMPTY", void 0), K.EMPTY = new K({
1875
1896
  label: "EMPTY",
1876
- source: new TextureSource({ label: "EMPTY" })
1897
+ source: new G({ label: "EMPTY" })
1877
1898
  });
1878
- var _TextSystem, TextSystem = class {
1879
- constructor(n) {
1880
- this._activeTexture = {}, this.renderer = n;
1881
- }
1882
- getManagedTexture(n) {
1883
- n._resolution = n._autoResolution ? this.renderer.resolution : n.resolution;
1884
- let j = n.styleKey;
1885
- if (this._activeTexture[j]) return this._activeTexture[j];
1886
- let M = this.getTexture({
1887
- text: n.text,
1888
- style: n.style,
1889
- resolution: n._resolution
1899
+ //#endregion
1900
+ //#region lib/scene/text/TextSystem.ts
1901
+ var Xe = class {
1902
+ constructor(e) {
1903
+ f(this, "renderer", void 0), f(this, "_activeTexture", {}), this.renderer = e;
1904
+ }
1905
+ getManagedTexture(e) {
1906
+ e._resolution = e._autoResolution ? this.renderer.resolution : e.resolution;
1907
+ let t = e.styleKey;
1908
+ if (this._activeTexture[t]) return this._activeTexture[t];
1909
+ let n = this.getTexture({
1910
+ text: e.text,
1911
+ style: e.style,
1912
+ resolution: e._resolution
1890
1913
  });
1891
- return this._activeTexture[j] = M, M;
1892
- }
1893
- getTexture(n) {
1894
- let { text: j, style: M } = n, N = n.resolution || this.renderer.resolution, { frame: P, canvasAndContext: F } = generateTextTexture({
1895
- text: j,
1896
- style: M,
1897
- resolution: N
1898
- }), I = F.canvas, L = new Texture({ source: new TextureSource({
1899
- resource: I,
1900
- resolution: N
1914
+ return this._activeTexture[t] = n, n;
1915
+ }
1916
+ getTexture(e) {
1917
+ let { text: t, style: n } = e, r = e.resolution || this.renderer.resolution, { frame: i, canvasAndContext: a } = We({
1918
+ text: t,
1919
+ style: n,
1920
+ resolution: r
1921
+ }), o = a.canvas, s = new K({ source: new G({
1922
+ resource: o,
1923
+ resolution: r
1901
1924
  }) });
1902
- return L.frame.width = P.width / N, L.frame.height = P.height / N, L;
1925
+ return s.frame.width = i.width / r, s.frame.height = i.height / r, s;
1903
1926
  }
1904
1927
  };
1905
- _TextSystem = TextSystem, _TextSystem.desc = { name: "text" };
1906
- var _StencilMaskPipe, StencilMaskPipe = class {
1907
- constructor(n) {
1908
- this._canvasMaskStack = [], this._renderer = n;
1909
- }
1910
- push(n, j) {
1911
- j.add({
1912
- renderPipeId: "stencilMask",
1913
- action: "pushMaskBegin",
1914
- mask: n
1915
- });
1928
+ f(Xe, "desc", { name: "text" });
1929
+ //#endregion
1930
+ //#region lib/system/CanvasContextSystem.ts
1931
+ var Ze = class {
1932
+ constructor(e) {
1933
+ f(this, "_renderer", void 0), f(this, "rootContext", void 0), f(this, "activeConext", void 0), f(this, "activeResolution", 1), f(this, "globalTransform", new _()), this._renderer = e;
1916
1934
  }
1917
- pop(n, j) {
1918
- this._renderer.renderPipes.batch.break(j), j.add({
1919
- renderPipeId: "stencilMask",
1920
- action: "popMaskEnd",
1921
- mask: n
1922
- });
1923
- }
1924
- execute(n) {
1925
- if (n.action !== "pushMaskBegin" && n.action !== "popMaskEnd") return;
1926
- let j = this._renderer.canvasContext, M = j.activeConext;
1927
- if (n.action === "popMaskEnd") {
1928
- this._canvasMaskStack.pop() && M.restore();
1929
- return;
1930
- }
1931
- let N = n.mask.mask, P = N.context.instructions, F = N._roundPixels === 1;
1932
- M.save(), j.setContextTransform(N.relativeGroupTransform, F), M.beginPath();
1933
- for (let n = 0; n < P.length; ++n) {
1934
- let j = P[n], N = j.action;
1935
- if (N !== "fill" && N !== "stroke") return;
1936
- let F = j.data.path.shapePath.shapePrimitives;
1937
- for (let n = 0; n < F.length; ++n) {
1938
- let j = F[n].shape;
1939
- buildShapePath(M, j);
1940
- }
1941
- }
1942
- M.clip(), this._canvasMaskStack.push(!0);
1935
+ init() {
1936
+ this.activeConext = this._renderer.canvas.getContext("2d"), this.rootContext = this.activeConext, this.activeResolution = this._renderer.resolution;
1943
1937
  }
1944
- destroy() {
1945
- this._renderer = null;
1938
+ setContextTransform(e, t, n) {
1939
+ let r = this.activeResolution, i = _.append(this.globalTransform, e);
1940
+ n || (n = this.activeResolution), t ? this.activeConext.setTransform(i.a * n, i.b * n, i.c * n, i.d * n, i.tx * r | 0, i.ty * r | 0) : this.activeConext.setTransform(i.a * n, i.b * n, i.c * n, i.d * n, i.tx * r, i.ty * r);
1946
1941
  }
1947
1942
  };
1948
- _StencilMaskPipe = StencilMaskPipe, _StencilMaskPipe.desc = { name: "stencilMask" };
1949
- var RenderTexture = class n extends Texture {
1950
- static create(j) {
1951
- return new n({ source: new TextureSource(j) });
1952
- }
1953
- }, Sprite = class extends ViewContainer {
1954
- constructor(n = Texture.EMPTY) {
1955
- n instanceof Texture && (n = { texture: n });
1956
- let { texture: j = Texture.EMPTY, width: M, height: N, ...P } = n;
1943
+ f(Ze, "desc", { name: "canvasContext" });
1944
+ //#endregion
1945
+ //#region lib/renderer/texture/RenderTexture.ts
1946
+ var Qe = class e extends K {
1947
+ static create(t) {
1948
+ return new e({ source: new G(t) });
1949
+ }
1950
+ }, $e = class extends P {
1951
+ constructor(e = K.EMPTY) {
1952
+ e instanceof K && (e = { texture: e });
1953
+ let { texture: t = K.EMPTY, width: n, height: r, ...i } = e;
1957
1954
  super({
1958
1955
  label: "Sprite",
1959
- ...P
1960
- }), this.renderPipeId = "sprite", this.texture = j, this.anchor = new Vector2(), M != null && (this.width = M), N != null && (this.height = N);
1956
+ ...i
1957
+ }), f(this, "_texture", void 0), f(this, "anchor", void 0), f(this, "renderPipeId", "sprite"), f(this, "_width", void 0), f(this, "_height", void 0), this.texture = t, this.anchor = new b(), n != null && (this.width = n), r != null && (this.height = r);
1961
1958
  }
1962
- set texture(n) {
1963
- n || (n = Texture.EMPTY), this._texture !== n && (this._texture = n, this._width && this._setWidth(this.width, this._texture.orig.width), this._height && this._setHeight(this.height, this._texture.orig.height), this.onViewUpdate());
1959
+ set texture(e) {
1960
+ e || (e = K.EMPTY), this._texture !== e && (this._texture = e, this._width && this._setWidth(this.width, this._texture.orig.width), this._height && this._setHeight(this.height, this._texture.orig.height), this.onViewUpdate());
1964
1961
  }
1965
1962
  get texture() {
1966
1963
  return this._texture;
@@ -1968,31 +1965,31 @@ var RenderTexture = class n extends Texture {
1968
1965
  get height() {
1969
1966
  return Math.abs(this.scale.y) * this.texture.orig.height;
1970
1967
  }
1971
- set height(n) {
1972
- let j = this.texture.orig.height, M = Math.sign(this.scale.y) || 1;
1973
- j === 0 ? this.scale.y = M : this.scale.y = n / j * M, this._height = n;
1968
+ set height(e) {
1969
+ let t = this.texture.orig.height, n = Math.sign(this.scale.y) || 1;
1970
+ t === 0 ? this.scale.y = n : this.scale.y = e / t * n, this._height = e;
1974
1971
  }
1975
1972
  get width() {
1976
1973
  return Math.abs(this.scale.x) * this.texture.orig.width;
1977
1974
  }
1978
- set width(n) {
1979
- let j = this.texture.orig.width, M = Math.sign(this.scale.x) || 1;
1980
- j === 0 ? this.scale.x = M : this.scale.x = n / j * M, this._width = n;
1975
+ set width(e) {
1976
+ let t = this.texture.orig.width, n = Math.sign(this.scale.x) || 1;
1977
+ t === 0 ? this.scale.x = n : this.scale.x = e / t * n, this._width = e;
1981
1978
  }
1982
1979
  updateBounds() {
1983
- let n = this._bounds, { width: j, height: M } = this.texture.orig;
1984
- n.minX = -this.anchor.x * j, n.maxX = n.minX + j, n.minY = -this.anchor.y * M, n.maxY = n.minY + M;
1985
- }
1986
- }, Text = class extends ViewContainer {
1987
- constructor(n) {
1988
- var j;
1989
- let { text: M, resolution: N, style: P, width: F, height: I, ...L } = n;
1990
- super(L), this.renderPipeId = "text", this._didTextUpdate = !0, this._resolution = null, this._autoResolution = !0, this._anchor = new ObservablePoint({ _onUpdate: () => {
1980
+ let e = this._bounds, { width: t, height: n } = this.texture.orig;
1981
+ e.minX = -this.anchor.x * t, e.maxX = e.minX + t, e.minY = -this.anchor.y * n, e.maxY = e.minY + n;
1982
+ }
1983
+ }, et = class extends P {
1984
+ constructor(e) {
1985
+ var t;
1986
+ let { text: n, resolution: r, style: i, width: a, height: o, ...s } = e;
1987
+ super(s), f(this, "renderPipeId", "text"), f(this, "_anchor", void 0), f(this, "_didTextUpdate", !0), f(this, "_resolution", null), f(this, "_autoResolution", !0), f(this, "_text", void 0), f(this, "_style", void 0), this._anchor = new C({ _onUpdate: () => {
1991
1988
  this.onViewUpdate();
1992
- } }, 0, 0), this.text = (j = n.text) == null ? "" : j, this.style = P, this.resolution = N == null ? null : N, F != null && (this.width = F), I != null && (this.height = I);
1989
+ } }, 0, 0), this.text = (t = e.text) == null ? "" : t, this.style = i, this.resolution = r == null ? null : r, a != null && (this.width = a), o != null && (this.height = o);
1993
1990
  }
1994
- set resolution(n) {
1995
- this._autoResolution = n === null, this._resolution = n, this.onViewUpdate();
1991
+ set resolution(e) {
1992
+ this._autoResolution = e === null, this._resolution = e, this.onViewUpdate();
1996
1993
  }
1997
1994
  get resolution() {
1998
1995
  return this._resolution;
@@ -2000,226 +1997,497 @@ var RenderTexture = class n extends Texture {
2000
1997
  get anchor() {
2001
1998
  return this._anchor;
2002
1999
  }
2003
- set anchor(n) {
2004
- this._anchor.copyFrom(n);
2000
+ set anchor(e) {
2001
+ this._anchor.copyFrom(e);
2005
2002
  }
2006
2003
  get text() {
2007
2004
  return this._text;
2008
2005
  }
2009
- set text(n) {
2010
- let j = String(n);
2011
- this._text !== j && (this._text = j, this.onViewUpdate());
2006
+ set text(e) {
2007
+ let t = String(e);
2008
+ this._text !== t && (this._text = t, this.onViewUpdate());
2012
2009
  }
2013
2010
  get style() {
2014
2011
  return this._style;
2015
2012
  }
2016
- set style(n) {
2017
- n || (n = {}), n instanceof TextStyle ? this._style = n : this._style = new TextStyle(n), this.onViewUpdate();
2013
+ set style(e) {
2014
+ e || (e = {}), e instanceof H ? this._style = e : this._style = new H(e), this.onViewUpdate();
2018
2015
  }
2019
2016
  get width() {
2020
2017
  return Math.abs(this.scale.x) * this.bounds.width;
2021
2018
  }
2022
- set width(n) {
2023
- this._setWidth(n, this.bounds.width);
2019
+ set width(e) {
2020
+ this._setWidth(e, this.bounds.width);
2024
2021
  }
2025
2022
  get height() {
2026
2023
  return Math.abs(this.scale.y) * this.bounds.height;
2027
2024
  }
2028
- set height(n) {
2029
- this._setHeight(n, this.bounds.height);
2025
+ set height(e) {
2026
+ this._setHeight(e, this.bounds.height);
2030
2027
  }
2031
2028
  onViewUpdate() {
2032
2029
  this.didViewUpdate || (this._didTextUpdate = !0), super.onViewUpdate();
2033
2030
  }
2034
2031
  updateBounds() {
2035
- let n = this._bounds, j = this._anchor, M = TextMetrics.measureText(this._text, this._style), N = M.width, P = M.height;
2036
- n.minX = -j._x * N, n.minY = -j._y * P, n.maxX = n.minX + N, n.maxY = n.minY + P;
2032
+ let e = this._bounds, t = this._anchor, n = U.measureText(this._text, this._style), r = n.width, i = n.height;
2033
+ e.minX = -t._x * r, e.minY = -t._y * i, e.maxX = e.minX + r, e.maxY = e.minY + i;
2037
2034
  }
2038
2035
  get styleKey() {
2039
2036
  return `${this._text}:${this._style.styleKey}:${this._resolution}`;
2040
2037
  }
2041
- destroy(n = !1) {
2042
- super.destroy(n), this._bounds = null, this._anchor = null, (typeof n == "boolean" ? n : n != null && n.style) && this._style.destroy(n), this._style = null, this._text = null;
2043
- }
2044
- }, _ExtractSystem, ExtractSystem = class {
2045
- constructor(n) {
2046
- this._renderer = n;
2047
- }
2048
- texture(n) {
2049
- return this._generateTexture(n);
2050
- }
2051
- _generateTexture(n) {
2052
- n instanceof Container && (n = { target: n });
2053
- let j = n.resolution || this._renderer.resolution, M = n.target, N = new Bounds(), P = n.frame || getLocalBounds(M, N).rectangle;
2054
- P.width = Math.max(P.width, 1 / j) | 0, P.height = Math.max(P.height, 1 / j) | 0;
2055
- let F = RenderTexture.create({
2056
- width: P.width,
2057
- height: P.height,
2058
- resolution: j
2059
- }), I = new Matrix();
2060
- return I.tx = -P.x, I.ty = -P.y, this._renderer.render({
2038
+ destroy(e = !1) {
2039
+ super.destroy(e), this._bounds = null, this._anchor = null, (typeof e == "boolean" ? e : e != null && e.style) && this._style.destroy(e), this._style = null, this._text = null;
2040
+ }
2041
+ }, tt = class {
2042
+ constructor(e) {
2043
+ f(this, "_renderer", void 0), this._renderer = e;
2044
+ }
2045
+ texture(e) {
2046
+ return this._generateTexture(e);
2047
+ }
2048
+ _generateTexture(e) {
2049
+ e instanceof N && (e = { target: e });
2050
+ let t = e.resolution || this._renderer.resolution, n = e.target, r = new w(), i = e.frame || O(n, r).rectangle;
2051
+ i.width = Math.max(i.width, 1 / t) | 0, i.height = Math.max(i.height, 1 / t) | 0;
2052
+ let a = Qe.create({
2053
+ width: i.width,
2054
+ height: i.height,
2055
+ resolution: t
2056
+ }), o = T.get();
2057
+ return o.tx = -i.x, o.ty = -i.y, this._renderer.render({
2061
2058
  clearColor: "transparent",
2062
- container: M,
2063
- transform: I,
2064
- target: F
2065
- }), F;
2059
+ container: n,
2060
+ transform: o,
2061
+ target: a
2062
+ }), T.return(o), a;
2066
2063
  }
2067
2064
  };
2068
- _ExtractSystem = ExtractSystem, _ExtractSystem.desc = { name: "extract" };
2069
- var _CanvasContextSystem, CanvasContextSystem = class {
2070
- constructor(n) {
2071
- this.activeResolution = 1, this.globalTransform = new Matrix(), this._renderer = n;
2072
- }
2073
- init() {
2074
- this.activeConext = this._renderer.canvas.getContext("2d"), this.rootContext = this.activeConext, this.activeResolution = this._renderer.resolution;
2075
- }
2076
- setContextTransform(n, j, M) {
2077
- let N = this.activeResolution, P = Matrix.append(this.globalTransform, n);
2078
- M || (M = this.activeResolution), j ? this.activeConext.setTransform(P.a * M, P.b * M, P.c * M, P.d * M, P.tx * N | 0, P.ty * N | 0) : this.activeConext.setTransform(P.a * M, P.b * M, P.c * M, P.d * M, P.tx * N, P.ty * N);
2065
+ f(tt, "desc", { name: "extract" });
2066
+ //#endregion
2067
+ //#region lib/system/ViewSystem.ts
2068
+ var q = class e {
2069
+ constructor() {
2070
+ f(this, "canvas", void 0), f(this, "screen", void 0), f(this, "texture", void 0);
2079
2071
  }
2080
- };
2081
- _CanvasContextSystem = CanvasContextSystem, _CanvasContextSystem.desc = { name: "canvasContext" };
2082
- var _ViewSystem, ViewSystem = class n {
2083
2072
  get resolution() {
2084
2073
  return this.texture.source._resolution;
2085
2074
  }
2086
- set resolution(n) {
2087
- this.texture.source.resize(this.texture.source.width, this.texture.source.height, n);
2075
+ set resolution(e) {
2076
+ this.texture.source.resize(this.texture.source.width, this.texture.source.height, e);
2088
2077
  }
2089
- init(j) {
2090
- j = {
2091
- ...n.defaultOptions,
2092
- ...j
2093
- }, this.screen = new Rectangle(0, 0, j.width, j.height), this.canvas = createCanvas(), this.texture = new Texture({ source: new CanvasSource({
2078
+ init(t) {
2079
+ t = {
2080
+ ...e.defaultOptions,
2081
+ ...t
2082
+ }, this.screen = new y(0, 0, t.width, t.height), this.canvas = W(), this.texture = new K({ source: new Ye({
2094
2083
  resource: this.canvas,
2095
- ...j
2096
- }) }), this.resolution = j.resolution;
2084
+ ...t
2085
+ }) }), this.resolution = t.resolution;
2097
2086
  }
2098
- resize(n, j, M) {
2099
- this.texture.source.resize(n, j, M), this.screen.width = this.texture.frame.width, this.screen.height = this.texture.frame.height;
2087
+ resize(e, t, n) {
2088
+ this.texture.source.resize(e, t, n), this.screen.width = this.texture.frame.width, this.screen.height = this.texture.frame.height;
2100
2089
  }
2101
2090
  };
2102
- _ViewSystem = ViewSystem, _ViewSystem.desc = { name: "view" }, _ViewSystem.defaultOptions = {
2091
+ f(q, "desc", { name: "view" }), f(q, "defaultOptions", {
2103
2092
  width: 800,
2104
2093
  height: 600,
2105
2094
  autoDensity: !1
2095
+ });
2096
+ //#endregion
2097
+ //#region lib/events/FederatedEvent.ts
2098
+ var J = class {
2099
+ constructor(e) {
2100
+ f(this, "system", void 0), f(this, "target", void 0), f(this, "currentTarget", void 0), f(this, "nativeEvent", void 0), f(this, "type", void 0), f(this, "global", new b()), f(this, "screen", new b()), f(this, "path", void 0), this.system = e;
2101
+ }
2102
+ getLocalPosition(e, t) {
2103
+ return e.worldTransform.applyInverse(t || this.global);
2104
+ }
2105
+ composedPath() {
2106
+ return (!this.path || this.path[this.path.length - 1] !== this.target) && (this.path = this.target ? this.system.propagationPath(this.target) : []), this.path;
2107
+ }
2108
+ }, nt = 2048, rt = class {
2109
+ constructor(e) {
2110
+ f(this, "renderer", void 0), f(this, "domElement", null), f(this, "rootTarget", null), f(this, "resolution", 1), f(this, "eventPool", /* @__PURE__ */ new Map()), f(this, "_allInteractiveElements", []), f(this, "_hitElements", []), f(this, "_rootPointerEvent", void 0), f(this, "_isPointerMoveEvent", !1), f(this, "mappingState", { trackingData: {} }), this.renderer = e, this.resolution = e.resolution, this._rootPointerEvent = new J(null), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
2111
+ }
2112
+ get pointer() {
2113
+ return this._rootPointerEvent;
2114
+ }
2115
+ trackingData(e) {
2116
+ return this.mappingState.trackingData[e] || (this.mappingState.trackingData[e] = {
2117
+ pressTargetsByButton: {},
2118
+ clicksByButton: {},
2119
+ overTargets: null
2120
+ }), this.mappingState.trackingData[e];
2121
+ }
2122
+ init() {
2123
+ let e = this.renderer.canvas;
2124
+ this.setTargetElement(e);
2125
+ }
2126
+ setTargetElement(e) {
2127
+ this._removeEvents(), this.domElement = e, this._addEvents();
2128
+ }
2129
+ dispatchEvent(e, t) {
2130
+ if (!e.target) return;
2131
+ let n = e.composedPath();
2132
+ for (let r = 0; r < n.length - 1; ++r) e.currentTarget = n[r], this._notifyTarget(e, t);
2133
+ e.currentTarget = e.target, this._notifyTarget(e, t);
2134
+ }
2135
+ _notifyTarget(e, t) {
2136
+ t != null || (t = e.type);
2137
+ let n = e.currentTarget._events[t];
2138
+ if (n) if ("fn" in n) n.once && e.target.removeListener(t, n.fn, void 0, !0), n.fn.call(n.context, e);
2139
+ else for (let r = 0; r < n.length; ++r) {
2140
+ let i = n[r];
2141
+ i.once && e.target.removeListener(t, i.fn, void 0, !0), i.fn.call(i.context, e);
2142
+ }
2143
+ }
2144
+ propagationPath(e) {
2145
+ let t = [e];
2146
+ for (let n = 0; n < nt && (e !== this.rootTarget || e.parent); ++n) {
2147
+ if (!e.parent) throw Error("Cannot find propagation path to disconnected target");
2148
+ t.push(e.parent), e = e.parent;
2149
+ }
2150
+ return t.reverse(), t;
2151
+ }
2152
+ _removeEvents() {
2153
+ let e = this.domElement;
2154
+ e && (globalThis.document.removeEventListener("pointermove", this._onPointerMove, !0), e.removeEventListener("pointerdown", this._onPointerDown, !0), e.removeEventListener("pointerleave", this._onPointerOverOut, !0), e.removeEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.removeEventListener("pointerup", this._onPointerUp, !0));
2155
+ }
2156
+ _addEvents() {
2157
+ let e = this.domElement;
2158
+ if (!e) return;
2159
+ let t = e.style;
2160
+ t && (t.touchAction = "none"), globalThis.document.addEventListener("pointermove", this._onPointerMove, !0), e.addEventListener("pointerdown", this._onPointerDown, !0), e.addEventListener("pointerleave", this._onPointerOverOut, !0), e.addEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.addEventListener("pointerup", this._onPointerUp, !0);
2161
+ }
2162
+ _onPointerMove(e) {
2163
+ var t;
2164
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2165
+ this._isPointerMoveEvent = !0, this._allInteractiveElements.length = 0, this._hitElements.length = 0;
2166
+ let n = this._bootstrapEvent(this._rootPointerEvent, e), r = this.createPointEvent(n);
2167
+ this._isPointerMoveEvent = !1;
2168
+ let i = this.trackingData(e.pointerId), a = it(i.overTargets);
2169
+ if (((t = i.overTargets) == null ? void 0 : t.length) > 0 && a !== r.target) {
2170
+ let e = this.createPointEvent(n, "pointerout", a);
2171
+ this.dispatchEvent(e, "pointerout");
2172
+ let t = r.composedPath();
2173
+ if (!t.includes(a)) {
2174
+ let e = this.createPointEvent(n, "pointerleave", a);
2175
+ for (; e.target && !t.includes(e.target);) e.currentTarget = e.target, this._notifyTarget(e), e.target = e.target.parent;
2176
+ }
2177
+ }
2178
+ if (a !== r.target) {
2179
+ let e = "pointerover", t = this.clonePointEvent(r, e);
2180
+ this.dispatchEvent(t, e);
2181
+ let n = a == null ? void 0 : a.parent;
2182
+ for (; n && n !== this.rootTarget.parent && n !== r.target;) n = n.parent;
2183
+ if (!n || n === this.rootTarget.parent) {
2184
+ let e = this.clonePointEvent(r, "pointerenter");
2185
+ for (; e.target && e.target !== a && e.target !== this.rootTarget.parent;) e.currentTarget = e.target, this._notifyTarget(e), e.target = e.target.parent;
2186
+ }
2187
+ this.freeEvent(t);
2188
+ }
2189
+ this.dispatchEvent(r, "pointermove");
2190
+ let o = this._allInteractiveElements;
2191
+ for (let e = o.length - 1; e >= 0; --e) r.currentTarget = o[e], this._notifyTarget(r, "globalpointermove");
2192
+ this._allInteractiveElements.length = 0, this._hitElements.length = 0, i.overTargets = r.composedPath(), this.freeEvent(r);
2193
+ }
2194
+ _onPointerDown(e) {
2195
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2196
+ let t = this._bootstrapEvent(this._rootPointerEvent, e), n = this.createPointEvent(t);
2197
+ this.dispatchEvent(n, "pointerdown");
2198
+ let r = this.trackingData(e.pointerId);
2199
+ r.pressTargetsByButton[e.button] = n.composedPath(), this.freeEvent(n);
2200
+ }
2201
+ _onPointerOverOut(e) {
2202
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2203
+ let t = this._bootstrapEvent(this._rootPointerEvent, e), n = this.createPointEvent(t);
2204
+ this.dispatchEvent(n, "pointerout"), this.freeEvent(n);
2205
+ }
2206
+ _onPointerUp(e) {
2207
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2208
+ let t = e.target;
2209
+ e.composedPath && e.composedPath().length > 1 && (t = e.composedPath()[0]);
2210
+ let n = this._bootstrapEvent(this._rootPointerEvent, e), r = t === this.domElement ? "" : "outside", i = this.createPointEvent(n);
2211
+ this.dispatchEvent(i, `pointerup${r}`), this.freeEvent(i);
2212
+ }
2213
+ _isInteractive(e) {
2214
+ return e === "static";
2215
+ }
2216
+ _bootstrapEvent(e, t) {
2217
+ return e.nativeEvent = t, this.mapPositionToPoint(e.screen, t.clientX, t.clientY), e.global.copyFrom(e.screen), t.type === "pointerleave" ? e.type = "pointerout" : e.type = t.type, e;
2218
+ }
2219
+ allocateEvent(e) {
2220
+ this.eventPool.has(e) || this.eventPool.set(e, []);
2221
+ let t = this.eventPool.get(e).pop() || new e(this);
2222
+ return t.currentTarget = null, t.path = null, t.target = null, t;
2223
+ }
2224
+ freeEvent(e) {
2225
+ let t = e.constructor;
2226
+ this.eventPool.has(t) || this.eventPool.set(t, []), this.eventPool.get(t).push(e);
2227
+ }
2228
+ createPointEvent(e, t, n) {
2229
+ var r;
2230
+ let i = this.allocateEvent(J);
2231
+ return i.global.copyFrom(e.global), i.screen.copyFrom(e.screen), i.nativeEvent = e.nativeEvent, i.target = (r = n == null ? this.hitTest(i.global.x, i.global.y) : n) == null ? this._hitElements[0] : r, t && (i.type = t), i;
2232
+ }
2233
+ clonePointEvent(e, t) {
2234
+ let n = this.allocateEvent(J);
2235
+ return n.nativeEvent = e.nativeEvent, n.global = e.global, n.type = t == null ? e.type : t, n.path = e.composedPath().slice(), n.target = e.target, n;
2236
+ }
2237
+ mapPositionToPoint(e, t, n) {
2238
+ let r = this.domElement, i = r.isConnected ? r.getBoundingClientRect() : {
2239
+ x: 0,
2240
+ y: 0,
2241
+ width: r.width,
2242
+ height: r.height,
2243
+ left: 0,
2244
+ top: 0
2245
+ }, a = 1 / this.resolution;
2246
+ return e.x = (t - i.left) * (r.width / i.width) * a, e.y = (n - i.top) * (r.height / i.height) * a, e;
2247
+ }
2248
+ hitTest(e, t) {
2249
+ let n = this._isPointerMoveEvent, r = this[n ? "hitTestMoveRecursive" : "hitTestRecursive"](this.rootTarget, this.rootTarget.eventMode, new b(e, t));
2250
+ return r && r[0];
2251
+ }
2252
+ _interactivePrune(e) {
2253
+ return !e || !e.visible || !e.renderable || !e.measurable || e.eventMode === "none";
2254
+ }
2255
+ hitTestMoveRecursive(e, t, n) {
2256
+ let r = !1;
2257
+ if (this._interactivePrune(e)) return;
2258
+ let i = e.children;
2259
+ if (i && i.length > 0) for (let a = i.length - 1; a >= 0; --a) {
2260
+ let o = i[a], s = this.hitTestMoveRecursive(o, this._isInteractive(t) ? t : o.eventMode, n);
2261
+ if (s) {
2262
+ if (s.length > 0 && !s[s.length - 1].parent) continue;
2263
+ let t = this._isInteractive(e.eventMode);
2264
+ (s.length > 0 || t) && (t && this._allInteractiveElements.push(e), s.push(e)), this._hitElements.length === 0 && (this._hitElements = s), r = !0;
2265
+ }
2266
+ }
2267
+ let a = this._isInteractive(t), o = this._isInteractive(e.eventMode);
2268
+ if (o && this._allInteractiveElements.push(e), !(this._hitElements.length > 0)) {
2269
+ if (r) return this._hitElements;
2270
+ if (a && this.hitTestFn(e, n)) return o ? [e] : [];
2271
+ }
2272
+ }
2273
+ hitTestRecursive(e, t, n) {
2274
+ if (this._interactivePrune(e)) return;
2275
+ let r = e.children;
2276
+ for (let i = r.length - 1; i >= 0; i--) {
2277
+ let a = r[i], o = this.hitTestRecursive(a, this._isInteractive(t) ? t : a.eventMode, n);
2278
+ if (o) {
2279
+ let t = this._isInteractive(e.eventMode);
2280
+ return (o.length > 0 || t) && o.push(e), o;
2281
+ }
2282
+ }
2283
+ let i = this._isInteractive(t), a = this._isInteractive(e.eventMode);
2284
+ return i && this.hitTestFn(e, n) ? a ? [e] : [] : null;
2285
+ }
2286
+ hitTestFn(e, t) {
2287
+ if (e.hitArea) return !0;
2288
+ if (e.containsPoint) {
2289
+ let n = e.worldTransform.applyInverse(t);
2290
+ return e.containsPoint(n);
2291
+ }
2292
+ return !1;
2293
+ }
2294
+ };
2295
+ f(rt, "desc", { name: "events" });
2296
+ function it(e) {
2297
+ if (!e) return;
2298
+ let t = e[0];
2299
+ for (let n = 1; n < e.length && e[n].parent === t; ++n) t = e[n];
2300
+ return t;
2301
+ }
2302
+ //#endregion
2303
+ //#region lib/scene/container/utils/updateRenderGroupTransform.ts
2304
+ var at = 7;
2305
+ function ot(e, t = !1) {
2306
+ let n = e.root;
2307
+ e.worldTransform.copyFrom(n.localTransform);
2308
+ let r = e.childrenToUpdate;
2309
+ for (let t in r) {
2310
+ let n = Number(t), i = r[n], a = i.list, o = i.index;
2311
+ for (let t = 0; t < o; ++t) {
2312
+ let r = a[t];
2313
+ r.parentRenderGroup === e && r.relativeRenderGroupDepth === n && st(r, 0);
2314
+ }
2315
+ ve(a, o), i.index = 0;
2316
+ }
2317
+ if (t) for (let n = 0; n < e.renderGroupChildren.length; ++n) ot(e.renderGroupChildren[n], t);
2318
+ }
2319
+ function st(e, t) {
2320
+ e.didChange = !1;
2321
+ let n = e.parent, r = e.localTransform;
2322
+ e.updateLocalTransform(), n && (t |= e._updateFlags, e.relativeGroupTransform.appendFrom(r, n.relativeGroupTransform), t & at && ct(e, n, t));
2323
+ let i = e.children;
2324
+ for (let e = 0; e < i.length; e++) st(i[e], t);
2325
+ }
2326
+ function ct(e, t, n) {
2327
+ if (n & 1) {
2328
+ e.groupColor = t.groupColor;
2329
+ let n = e.localAlpha * t.groupAlpha;
2330
+ n = n < 0 ? 0 : n > 1 ? 1 : n, e.groupAlpha = n, e.groupColorAlpha = e.groupColor + ((n * 255 | 0) << 24);
2331
+ }
2332
+ n & 4 && (e.globalDisplayStatus = e.localDisplayStatus & t.globalDisplayStatus), e._updateFlags = 0;
2333
+ }
2334
+ //#endregion
2335
+ //#region lib/scene/container/utils/validateRenderables.ts
2336
+ function lt(e, t) {
2337
+ let { list: n, index: r } = e.childrenRenderablesToUpdate, i = !1;
2338
+ for (let e = 0; e < r; ++e) {
2339
+ let r = n[e];
2340
+ if (i = t[r.renderPipeId].validateRenderable(r), i) break;
2341
+ }
2342
+ return e.structureDidChange = i, i;
2343
+ }
2344
+ //#endregion
2345
+ //#region lib/system/RenderGroupSystem.ts
2346
+ var ut = class {
2347
+ constructor(e) {
2348
+ f(this, "renderer", void 0), this.renderer = e;
2349
+ }
2350
+ _updateRenderGroup(e) {
2351
+ let t = this.renderer, n = t.renderPipes;
2352
+ e.runOnRender(t), e.instructionSet.renderPipes = n, e.structureDidChange ? ve(e.childrenRenderablesToUpdate.list, 0) : lt(e, n), ot(e), e.structureDidChange && (e.structureDidChange = !1, this._buildInstructions(e, t)), e.childrenRenderablesToUpdate.index = 0;
2353
+ }
2354
+ render({ container: e, transform: t }) {
2355
+ let n = this.renderer;
2356
+ t && e.renderGroup.localTransform.copyFrom(t), n.canvasContext.globalTransform = t ? e.renderGroup.localTransform : e.renderGroup.worldTransform, this._updateRenderGroup(e.renderGroup), dt(e.renderGroup, n.renderPipes);
2357
+ }
2358
+ _buildInstructions(e, t) {
2359
+ let n = t.renderPipes, r = e.root;
2360
+ e.instructionSet.reset(), r.sortableChildren && r.sortChildren(), n.batch.buildStart(), r.collectRenderablesWithEffects(n, e.instructionSet), n.batch.buildEnd(e.instructionSet);
2361
+ }
2106
2362
  };
2107
- var systems = [
2108
- ViewSystem,
2109
- EventSystem,
2110
- RenderGroupSystem,
2111
- TextSystem,
2112
- ExtractSystem,
2113
- CanvasContextSystem
2114
- ], pipes = [
2115
- BatchPipe,
2116
- GraphicsPipe,
2117
- TextPipe,
2118
- SpritePipe,
2119
- StencilMaskPipe
2120
- ], CanvasRenderer = class extends eventemitter3_default {
2363
+ f(ut, "desc", { name: "renderGroup" });
2364
+ function dt(e, t) {
2365
+ let { instructionSet: n } = e, r = n.instructions;
2366
+ for (let e = 0; e < n.instructionSize; e++) {
2367
+ let n = r[e];
2368
+ t[n.renderPipeId].execute(n);
2369
+ }
2370
+ }
2371
+ //#endregion
2372
+ //#region lib/renderer/index.ts
2373
+ var Y = [
2374
+ q,
2375
+ rt,
2376
+ ut,
2377
+ Xe,
2378
+ tt,
2379
+ Ze
2380
+ ], ft = [
2381
+ m,
2382
+ z,
2383
+ V,
2384
+ ze,
2385
+ Re
2386
+ ], pt = class extends c {
2121
2387
  constructor() {
2122
- super(), this.uid = uid("renderer"), this.renderedObject = null, this.renderPipes = {}, this.background = { color: "#000000" };
2388
+ super(), f(this, "uid", D("renderer")), f(this, "context", void 0), f(this, "background", void 0), f(this, "renderedObject", null), f(this, "_roundPixels", void 0), f(this, "resolution", void 0), f(this, "activeRenderGroup", void 0), f(this, "renderPipes", {}), this.background = { color: "#000000" };
2123
2389
  }
2124
2390
  get canvas() {
2125
2391
  return this.view.canvas;
2126
2392
  }
2127
2393
  _addPipes() {
2128
- pipes.forEach((n) => {
2129
- this.renderPipes[n.desc.name] = new n(this);
2394
+ ft.forEach((e) => {
2395
+ this.renderPipes[e.desc.name] = new e(this);
2130
2396
  });
2131
2397
  }
2132
2398
  _addSystems() {
2133
- systems.forEach((n) => {
2134
- this[n.desc.name] = new n(this);
2399
+ Y.forEach((e) => {
2400
+ this[e.desc.name] = new e(this);
2135
2401
  });
2136
2402
  }
2137
- async init(n) {
2138
- this.resolution = n.resolution || 1, this._addSystems(), this._addPipes();
2139
- for (let N = 0; N < systems.length; ++N) {
2140
- var j, M;
2141
- await ((j = (M = this[systems[N].desc.name]).init) == null ? void 0 : j.call(M, n));
2403
+ async init(e) {
2404
+ this.resolution = e.resolution || 1, this._addSystems(), this._addPipes();
2405
+ for (let r = 0; r < Y.length; ++r) {
2406
+ var t, n;
2407
+ await ((t = (n = this[Y[r].desc.name]).init) == null ? void 0 : t.call(n, e));
2142
2408
  }
2143
- n.backgroundColor && (this.background.color = n.backgroundColor), this._roundPixels = n.roundPixels ? 1 : 0;
2409
+ e.backgroundColor && (this.background.color = e.backgroundColor), this._roundPixels = +!!e.roundPixels;
2144
2410
  }
2145
2411
  get roundPixels() {
2146
2412
  return !!this._roundPixels;
2147
2413
  }
2148
- render(n) {
2149
- let j = n;
2150
- if (j instanceof Container && (j = { container: j }), this.renderedObject = j.container, j.transform || (j.container.updateLocalTransform(), j.transform = j.container.localTransform), j.clearColor != null || (j.clearColor = this.background.color), !j.container.visible) return;
2151
- j.container.enableRenderGroup();
2152
- let M = j.container.renderGroup;
2153
- if (this.activeRenderGroup = M, this.canvasContext.globalTransform = M.worldTransform, this.canvasContext.activeConext = this.canvasContext.rootContext, j.target) {
2154
- let { context: n } = ensureCanvas(j.target.source);
2155
- this.canvasContext.activeConext = n;
2414
+ render(e) {
2415
+ let t = e;
2416
+ if (t instanceof N && (t = { container: t }), this.renderedObject = t.container, t.transform || (t.container.updateLocalTransform(), t.transform = t.container.localTransform), t.clearColor != null || (t.clearColor = this.background.color), !t.container.visible) return;
2417
+ t.container.enableRenderGroup();
2418
+ let n = t.container.renderGroup;
2419
+ if (this.activeRenderGroup = n, this.canvasContext.globalTransform = n.worldTransform, this.canvasContext.activeConext = this.canvasContext.rootContext, t.target) {
2420
+ let { context: e } = mt(t.target.source);
2421
+ this.canvasContext.activeConext = e;
2156
2422
  }
2157
- this.clear(j), systems.forEach((n) => {
2158
- var M, N;
2159
- (M = (N = this[n.desc.name]).render) == null || M.call(N, j);
2423
+ this.clear(t), Y.forEach((e) => {
2424
+ var n, r;
2425
+ (n = (r = this[e.desc.name]).render) == null || n.call(r, t);
2160
2426
  });
2161
2427
  }
2162
- clear(n) {
2163
- let j = this.canvasContext.activeConext;
2164
- j.setTransform(1, 0, 0, 1, 0, 0), j.clearRect(0, 0, this.canvas.width, this.canvas.height), j.globalAlpha = 1, j.fillStyle = n.clearColor, j.fillRect(0, 0, this.canvas.width, this.canvas.height), j.globalAlpha = 1;
2428
+ clear(e) {
2429
+ let t = this.canvasContext.activeConext;
2430
+ t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, this.canvas.width, this.canvas.height), t.globalAlpha = 1, t.fillStyle = e.clearColor, t.fillRect(0, 0, this.canvas.width, this.canvas.height), t.globalAlpha = 1;
2165
2431
  }
2166
2432
  destroy() {
2167
- this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), pipes.forEach((n) => {
2168
- var j;
2169
- (j = this.renderPipes[n.desc.name]) == null || j.destroy();
2433
+ this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), ft.forEach((e) => {
2434
+ var t;
2435
+ (t = this.renderPipes[e.desc.name]) == null || t.destroy();
2170
2436
  }), this.renderPipes = null;
2171
2437
  }
2172
- resize(n, j, M) {
2173
- this.view.resize(n, j, M), this.emit("resize", this.view.screen.width, this.view.screen.height, this.view.resolution);
2438
+ resize(e, t, n) {
2439
+ this.view.resize(e, t, n), this.emit("resize", this.view.screen.width, this.view.screen.height, this.view.resolution);
2174
2440
  }
2175
2441
  };
2176
- function ensureCanvas(n) {
2177
- let j = n.resource;
2178
- return j || (j = createCanvas(n.pixelWidth, n.pixelHeight), n.resource = j), (j.width !== n.pixelWidth || j.height !== n.pixelHeight) && (j.width = n.pixelWidth, j.height = n.pixelHeight), {
2179
- canvas: j,
2180
- context: j.getContext("2d")
2442
+ function mt(e) {
2443
+ let t = e.resource;
2444
+ return t || (t = W(e.pixelWidth, e.pixelHeight), e.resource = t), (t.width !== e.pixelWidth || t.height !== e.pixelHeight) && (t.width = e.pixelWidth, t.height = e.pixelHeight), {
2445
+ canvas: t,
2446
+ context: t.getContext("2d")
2181
2447
  };
2182
2448
  }
2183
- var TickerListener = class {
2184
- constructor(n, j, M = 0, N = !1) {
2185
- this.next = null, this.previous = null, this.priority = 0, this._destroyed = !1, this._fn = n, this._context = j, this.priority = M, this._once = N;
2449
+ //#endregion
2450
+ //#region lib/ticker/TickerListener.ts
2451
+ var X = class {
2452
+ constructor(e, t, n = 0, r = !1) {
2453
+ f(this, "next", null), f(this, "previous", null), f(this, "priority", 0), f(this, "_fn", void 0), f(this, "_context", void 0), f(this, "_once", void 0), f(this, "_destroyed", !1), this._fn = e, this._context = t, this.priority = n, this._once = r;
2186
2454
  }
2187
- match(n, j) {
2188
- return this._fn === n && this._context === j;
2455
+ match(e, t) {
2456
+ return this._fn === e && this._context === t;
2189
2457
  }
2190
- emit(n) {
2191
- this._fn && (this._context ? this._fn.call(this._context, n) : this._fn(n));
2192
- let j = this.next;
2193
- return this._once && this.destroy(!0), this._destroyed && (this.next = null), j;
2458
+ emit(e) {
2459
+ this._fn && (this._context ? this._fn.call(this._context, e) : this._fn(e));
2460
+ let t = this.next;
2461
+ return this._once && this.destroy(!0), this._destroyed && (this.next = null), t;
2194
2462
  }
2195
- destroy(n) {
2463
+ destroy(e) {
2196
2464
  this._destroyed = !0, this._fn = null, this._context = null, this.previous && (this.previous.next = this.next), this.next && (this.next.previous = this.previous);
2197
- let j = this.next;
2198
- return this.next = n ? null : j, this.previous = null, j;
2465
+ let t = this.next;
2466
+ return this.next = e ? null : t, this.previous = null, t;
2199
2467
  }
2200
- connect(n) {
2201
- this.previous = n, n.next && (n.next.previous = this), this.next = n.next, n.next = this;
2468
+ connect(e) {
2469
+ this.previous = e, e.next && (e.next.previous = this), this.next = e.next, e.next = this;
2202
2470
  }
2203
- }, _Ticker, Ticker = class n {
2471
+ }, Z = class e {
2204
2472
  constructor() {
2205
- this.autoStart = !1, this.deltaTime = 1, this.lastTime = -1, this.speed = 1, this.started = !1, this._requestId = null, this._maxElapsedMS = 100, this._minElapsedMS = 0, this._lastFrame = -1, this._head = null, this._head = new TickerListener(null, null, Infinity), this.deltaMS = 1 / n.targetFPMS, this.elapsedMS = this.deltaMS, this._tick = (n) => {
2206
- this._requestId = null, this.started && (this.update(n), this.started && this._requestId === null && (this._requestId = requestAnimationFrame(this._tick)));
2473
+ f(this, "autoStart", !1), f(this, "deltaTime", 1), f(this, "deltaMS", void 0), f(this, "elapsedMS", void 0), f(this, "lastTime", -1), f(this, "speed", 1), f(this, "started", !1), f(this, "_tick", void 0), f(this, "_requestId", null), f(this, "_maxElapsedMS", 100), f(this, "_minElapsedMS", 0), f(this, "_lastFrame", -1), f(this, "_head", null), this._head = new X(null, null, Infinity), this.deltaMS = 1 / e.targetFPMS, this.elapsedMS = this.deltaMS, this._tick = (e) => {
2474
+ this._requestId = null, this.started && (this.update(e), this.started && this._requestId === null && (this._requestId = requestAnimationFrame(this._tick)));
2207
2475
  };
2208
2476
  }
2209
- update(j = performance.now()) {
2210
- let M;
2211
- if (j > this.lastTime) {
2212
- if (M = this.elapsedMS = j - this.lastTime, M > this._maxElapsedMS && (M = this._maxElapsedMS), M *= this.speed, this._minElapsedMS) {
2213
- let n = j - this._lastFrame | 0;
2214
- if (n < this._minElapsedMS) return;
2215
- this._lastFrame = j - n % this._minElapsedMS;
2477
+ update(t = performance.now()) {
2478
+ let n;
2479
+ if (t > this.lastTime) {
2480
+ if (n = this.elapsedMS = t - this.lastTime, n > this._maxElapsedMS && (n = this._maxElapsedMS), n *= this.speed, this._minElapsedMS) {
2481
+ let e = t - this._lastFrame | 0;
2482
+ if (e < this._minElapsedMS) return;
2483
+ this._lastFrame = t - e % this._minElapsedMS;
2216
2484
  }
2217
- this.deltaMS = M, this.deltaTime = this.deltaMS * n.targetFPMS;
2218
- let N = this._head, P = N.next;
2219
- for (; P;) P = P.emit(this);
2220
- N.next || this._cancelIfNeeded();
2485
+ this.deltaMS = n, this.deltaTime = this.deltaMS * e.targetFPMS;
2486
+ let r = this._head, i = r.next;
2487
+ for (; i;) i = i.emit(this);
2488
+ r.next || this._cancelIfNeeded();
2221
2489
  } else this.deltaTime = this.deltaMS = this.elapsedMS = 0;
2222
- this.lastTime = j;
2490
+ this.lastTime = t;
2223
2491
  }
2224
2492
  get FPS() {
2225
2493
  return 1e3 / this.elapsedMS;
@@ -2227,27 +2495,28 @@ var TickerListener = class {
2227
2495
  get maxFPS() {
2228
2496
  return this._minElapsedMS ? Math.round(1e3 / this._minElapsedMS) : 0;
2229
2497
  }
2230
- set maxFPS(n) {
2231
- n === 0 ? this._minElapsedMS = 0 : (n < this.minFPS && (this.minFPS = n), this._minElapsedMS = 1 / (n / 1e3));
2498
+ set maxFPS(e) {
2499
+ e === 0 ? this._minElapsedMS = 0 : (e < this.minFPS && (this.minFPS = e), this._minElapsedMS = 1 / (e / 1e3));
2232
2500
  }
2233
2501
  get minFPS() {
2234
2502
  return 1e3 / this._maxElapsedMS;
2235
2503
  }
2236
- set minFPS(j) {
2237
- this._maxElapsedMS = 1 / Math.min(Math.max(0, j) / 1e3, n.targetFPMS), this._minElapsedMS && j > this.maxFPS && (this.maxFPS = j);
2504
+ set minFPS(t) {
2505
+ let n = Math.min(Math.max(0, t) / 1e3, e.targetFPMS);
2506
+ this._maxElapsedMS = 1 / n, this._minElapsedMS && t > this.maxFPS && (this.maxFPS = t);
2238
2507
  }
2239
- add(n, j, M = 0) {
2240
- let N = new TickerListener(n, j, M), P = this._head.next, F = this._head;
2241
- if (!P) N.connect(F);
2508
+ add(e, t, n = 0) {
2509
+ let r = new X(e, t, n), i = this._head.next, a = this._head;
2510
+ if (!i) r.connect(a);
2242
2511
  else {
2243
- for (; P;) {
2244
- if (N.priority > P.priority) {
2245
- N.connect(F);
2512
+ for (; i;) {
2513
+ if (r.priority > i.priority) {
2514
+ r.connect(a);
2246
2515
  break;
2247
2516
  }
2248
- F = P, P = P.next;
2517
+ a = i, i = i.next;
2249
2518
  }
2250
- N.previous || N.connect(F);
2519
+ r.previous || r.connect(a);
2251
2520
  }
2252
2521
  return this._startIfPossible(), this;
2253
2522
  }
@@ -2257,9 +2526,9 @@ var TickerListener = class {
2257
2526
  stop() {
2258
2527
  this.started && (this.started = !1, this._cancelIfNeeded());
2259
2528
  }
2260
- remove(n, j) {
2261
- let M = this._head.next;
2262
- for (; M;) M = M.match(n, j) ? M.destroy() : M.next;
2529
+ remove(e, t) {
2530
+ let n = this._head.next;
2531
+ for (; n;) n = n.match(e, t) ? n.destroy() : n.next;
2263
2532
  return this._head.next || this._cancelIfNeeded(), this;
2264
2533
  }
2265
2534
  _startIfPossible() {
@@ -2273,18 +2542,20 @@ var TickerListener = class {
2273
2542
  }
2274
2543
  destroy() {
2275
2544
  this.stop();
2276
- let n = this._head.next;
2277
- for (; n;) n = n.destroy(!0);
2545
+ let e = this._head.next;
2546
+ for (; e;) e = e.destroy(!0);
2278
2547
  this._head.destroy(), this._head = null;
2279
2548
  }
2280
2549
  };
2281
- _Ticker = Ticker, _Ticker.targetFPMS = .06;
2282
- var plugins = [class {
2283
- static init(n) {
2550
+ f(Z, "targetFPMS", .06);
2551
+ //#endregion
2552
+ //#region lib/app/ResizePlugin.ts
2553
+ var Q = class {
2554
+ static init(e) {
2284
2555
  Object.defineProperty(this, "resizeTo", {
2285
2556
  configurable: !0,
2286
- set(n) {
2287
- globalThis.removeEventListener("resize", this.queueResize), this._resizeTo = n, n && (globalThis.addEventListener("resize", this.queueResize), this.resize());
2557
+ set(e) {
2558
+ globalThis.removeEventListener("resize", this.queueResize), this._resizeTo = e, e && (globalThis.addEventListener("resize", this.queueResize), this.resize());
2288
2559
  },
2289
2560
  get() {
2290
2561
  return this._resizeTo;
@@ -2296,26 +2567,30 @@ var plugins = [class {
2296
2567
  }, this.resize = () => {
2297
2568
  if (!this._resizeTo) return;
2298
2569
  this._cancelResize();
2299
- let n, j;
2300
- if (this._resizeTo === globalThis.window) n = globalThis.innerWidth, j = globalThis.innerHeight;
2570
+ let e, t;
2571
+ if (this._resizeTo === globalThis.window) e = globalThis.innerWidth, t = globalThis.innerHeight;
2301
2572
  else {
2302
- let { clientWidth: M, clientHeight: N } = this._resizeTo;
2303
- n = M, j = N;
2573
+ let { clientWidth: n, clientHeight: r } = this._resizeTo;
2574
+ e = n, t = r;
2304
2575
  }
2305
- this.renderer.resize(n, j), this.render();
2306
- }, this._resizeId = null, this._resizeTo = null, this.resizeTo = n.resizeTo || null;
2576
+ this.renderer.resize(e, t), this.render();
2577
+ }, this._resizeId = null, this._resizeTo = null, this.resizeTo = e.resizeTo || null;
2307
2578
  }
2308
2579
  static destroy() {
2309
2580
  globalThis.removeEventListener("resize", this.queueResize), this._cancelResize(), this._cancelResize = null, this.queueResize = null, this.resizeTo = null, this.resize = null;
2310
2581
  }
2311
- }], Application = class {
2582
+ };
2583
+ f(Q, "resizeTo", void 0), f(Q, "queueResize", void 0), f(Q, "_resizeTo", void 0), f(Q, "_resizeId", void 0), f(Q, "resize", void 0), f(Q, "_cancelResize", void 0), f(Q, "renderer", void 0), f(Q, "render", void 0);
2584
+ //#endregion
2585
+ //#region lib/app/Application.ts
2586
+ var ht = [Q], gt = class {
2312
2587
  constructor() {
2313
- this.stage = new Container();
2588
+ f(this, "renderer", void 0), f(this, "stage", new N()), f(this, "_ticker", void 0);
2314
2589
  }
2315
- async init(n = {}) {
2316
- n = { ...n }, this.stage || (this.stage = new Container()), this.renderer = new CanvasRenderer(), await this.renderer.init(n), plugins.forEach((j) => {
2317
- j.init.call(this, n);
2318
- }), this.ticker = new Ticker(), (n.autoStart || n.autoStart == null) && this._ticker.start();
2590
+ async init(e = {}) {
2591
+ e = { ...e }, this.stage || (this.stage = new N()), this.renderer = new pt(), await this.renderer.init(e), ht.forEach((t) => {
2592
+ t.init.call(this, e);
2593
+ }), this.ticker = new Z(), (e.autoStart || e.autoStart == null) && this._ticker.start();
2319
2594
  }
2320
2595
  get canvas() {
2321
2596
  return this.renderer.canvas;
@@ -2326,199 +2601,199 @@ var plugins = [class {
2326
2601
  get ticker() {
2327
2602
  return this._ticker;
2328
2603
  }
2329
- set ticker(n) {
2330
- this._ticker && this._ticker.remove(this.render, this), this._ticker = n, n && n.add(this.render, this);
2604
+ set ticker(e) {
2605
+ this._ticker && this._ticker.remove(this.render, this), this._ticker = e, e && e.add(this.render, this);
2331
2606
  }
2332
2607
  render() {
2333
2608
  this.renderer.render({ container: this.stage });
2334
2609
  }
2335
2610
  destroy() {
2336
- let n = plugins.slice(0);
2337
- if (n.reverse(), n.forEach((n) => {
2338
- n.destroy.call(this);
2611
+ let e = ht.slice(0);
2612
+ if (e.reverse(), e.forEach((e) => {
2613
+ e.destroy.call(this);
2339
2614
  }), this.stage.destroy(), this.stage = null, this.renderer.destroy(), this.renderer = null, this._ticker) {
2340
- let n = this._ticker;
2341
- this._ticker = null, n.destroy();
2615
+ let e = this._ticker;
2616
+ this._ticker = null, e.destroy();
2342
2617
  }
2343
2618
  }
2344
- };
2345
- const Cache = new class {
2619
+ }, $ = new class {
2346
2620
  constructor() {
2347
2621
  this._cache = /* @__PURE__ */ new Map(), this._cacheMap = /* @__PURE__ */ new Map();
2348
2622
  }
2349
2623
  reset() {
2350
2624
  this._cache.clear(), this._cacheMap.clear();
2351
2625
  }
2352
- has(n) {
2353
- return this._cache.has(n);
2626
+ has(e) {
2627
+ return this._cache.has(e);
2354
2628
  }
2355
- get(n) {
2356
- let j = this._cache.get(n);
2357
- if (!j) throw Error(`Asset ${n} not found`);
2358
- return j;
2629
+ get(e) {
2630
+ let t = this._cache.get(e);
2631
+ if (!t) throw Error(`Asset ${e} not found`);
2632
+ return t;
2359
2633
  }
2360
- set(n, j) {
2361
- let M = Array.isArray(n) ? n : [n], N = /* @__PURE__ */ new Map();
2362
- M.forEach((n) => {
2363
- N.set(n, j);
2634
+ set(e, t) {
2635
+ let n = Array.isArray(e) ? e : [e], r = /* @__PURE__ */ new Map();
2636
+ n.forEach((e) => {
2637
+ r.set(e, t);
2364
2638
  });
2365
- let P = [...N.keys()], F = {
2366
- cacheKeys: P,
2367
- keys: M
2639
+ let i = [...r.keys()], a = {
2640
+ cacheKeys: i,
2641
+ keys: n
2368
2642
  };
2369
- M.forEach((n) => {
2370
- this._cacheMap.set(n, F);
2371
- }), P.forEach((n) => {
2372
- this._cache.has(n) && this._cache.has(n), this._cache.set(n, N.get(n));
2643
+ n.forEach((e) => {
2644
+ this._cacheMap.set(e, a);
2645
+ }), i.forEach((e) => {
2646
+ this._cache.set(e, r.get(e));
2373
2647
  });
2374
2648
  }
2375
- remove(n) {
2376
- if (!this._cacheMap.has(n)) return;
2377
- let j = this._cacheMap.get(n);
2378
- ((j == null ? void 0 : j.cacheKeys) || []).forEach((n) => {
2379
- this._cache.delete(n);
2380
- }), j == null || j.keys.forEach((n) => {
2381
- this._cacheMap.delete(n);
2649
+ remove(e) {
2650
+ if (!this._cacheMap.has(e)) return;
2651
+ let t = this._cacheMap.get(e);
2652
+ ((t == null ? void 0 : t.cacheKeys) || []).forEach((e) => {
2653
+ this._cache.delete(e);
2654
+ }), t == null || t.keys.forEach((e) => {
2655
+ this._cacheMap.delete(e);
2382
2656
  });
2383
2657
  }
2384
- }();
2385
- var _Loader, Loader = class n {
2658
+ }(), _t = class e {
2386
2659
  constructor() {
2387
- this.promiseCache = {}, this.loadOptions = { ...n.defaultOptions };
2388
- }
2389
- getAlias(n) {
2390
- let { alias: j, src: M } = n, N = j || M;
2391
- return (Array.isArray(N) ? N : [N]).map((n) => typeof n == "string" ? n : Array.isArray(n) ? n.map((n) => {
2392
- var j;
2393
- return (j = n.src) == null ? n : j;
2394
- }) : n != null && n.src ? n.src : n);
2395
- }
2396
- async load(j, M) {
2397
- let { onProgress: N, onError: P, strategy: F, retryCount: I, retryDelay: L } = typeof M == "function" ? {
2398
- ...n.defaultOptions,
2660
+ f(this, "promiseCache", {}), f(this, "loadOptions", { ...e.defaultOptions });
2661
+ }
2662
+ getAlias(e) {
2663
+ let { alias: t, src: n } = e, r = t || n;
2664
+ return (Array.isArray(r) ? r : [r]).map((e) => typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => {
2665
+ var t;
2666
+ return (t = e.src) == null ? e : t;
2667
+ }) : e != null && e.src ? e.src : e);
2668
+ }
2669
+ async load(t, n) {
2670
+ let { onProgress: r, onError: i, strategy: a, retryCount: o, retryDelay: s } = typeof n == "function" ? {
2671
+ ...e.defaultOptions,
2399
2672
  ...this.loadOptions,
2400
- onProgress: M
2673
+ onProgress: n
2401
2674
  } : {
2402
- ...n.defaultOptions,
2675
+ ...e.defaultOptions,
2403
2676
  ...this.loadOptions,
2404
- ...M || {}
2405
- }, R = 0, z = {}, B = j.reduce((n, j) => n + (j.progressSize || 1), 0), V = j.map(async (n) => {
2406
- if (z[n.src]) return;
2407
- let j = n.src;
2408
- await this._loadAssetWithRetry(j, n, {
2409
- onProgress: N,
2410
- onError: P,
2411
- strategy: F,
2412
- retryCount: I,
2413
- retryDelay: L
2414
- }, z), R += n.progressSize || 1, N && N(R / B);
2677
+ ...n || {}
2678
+ }, c = 0, l = {}, u = t.reduce((e, t) => e + (t.progressSize || 1), 0), d = t.map(async (e) => {
2679
+ if (l[e.src]) return;
2680
+ let t = e.src;
2681
+ await this._loadAssetWithRetry(t, e, {
2682
+ onProgress: r,
2683
+ onError: i,
2684
+ strategy: a,
2685
+ retryCount: o,
2686
+ retryDelay: s
2687
+ }, l), c += e.progressSize || 1, r && r(c / u);
2415
2688
  });
2416
- return await Promise.all(V), z;
2417
- }
2418
- async unload(n) {
2419
- let j = n.map(async (n) => {
2420
- let j = n.src, M = this.promiseCache[j];
2421
- if (M) {
2422
- let n = await M;
2423
- delete this.promiseCache[j], n.destroy(!0);
2689
+ return await Promise.all(d), l;
2690
+ }
2691
+ async unload(e) {
2692
+ let t = e.map(async (e) => {
2693
+ let t = e.src, n = this.promiseCache[t];
2694
+ if (n) {
2695
+ let e = await n;
2696
+ delete this.promiseCache[t], e.destroy(!0);
2424
2697
  }
2425
2698
  });
2426
- await Promise.all(j);
2699
+ await Promise.all(t);
2427
2700
  }
2428
- _getLoadPromise(n, j) {
2429
- return (async () => await loadTextures(n, j, this))();
2701
+ _getLoadPromise(e, t) {
2702
+ return (async () => await vt(e, t, this))();
2430
2703
  }
2431
- async _loadAssetWithRetry(n, j, M, N) {
2432
- let P = 0, { onError: F, strategy: I, retryCount: L, retryDelay: R } = M, z = (n) => new Promise((j) => setTimeout(j, n));
2704
+ async _loadAssetWithRetry(e, t, n, r) {
2705
+ let i = 0, { onError: a, strategy: o, retryCount: s, retryDelay: c } = n, l = (e) => new Promise((t) => setTimeout(t, e));
2433
2706
  for (;;) try {
2434
- this.promiseCache[n] || (this.promiseCache[n] = this._getLoadPromise(n, j)), N[j.src] = await this.promiseCache[n];
2707
+ this.promiseCache[e] || (this.promiseCache[e] = this._getLoadPromise(e, t)), r[t.src] = await this.promiseCache[e];
2435
2708
  return;
2436
- } catch (M) {
2437
- if (delete this.promiseCache[n], delete N[j.src], P++, I === "retry" && !(I !== "retry" || P > L)) {
2438
- F && F(M, j.src), await z(R);
2709
+ } catch (n) {
2710
+ if (delete this.promiseCache[e], delete r[t.src], i++, o === "retry" && !(o !== "retry" || i > s)) {
2711
+ a && a(n, t.src), await l(c);
2439
2712
  continue;
2440
2713
  }
2441
- if (I === "skip") {
2442
- F && F(M, j.src);
2714
+ if (o === "skip") {
2715
+ a && a(n, t.src);
2443
2716
  return;
2444
2717
  }
2445
- F && F(M, j.src);
2446
- let B = /* @__PURE__ */ Error(`[Loader.load] Failed to load ${n}.\n${M}`);
2447
- throw M instanceof Error && M.stack && (B.stack = M.stack), B;
2718
+ a && a(n, t.src);
2719
+ let u = /* @__PURE__ */ Error(`[Loader.load] Failed to load ${e}.\n${n}`);
2720
+ throw n instanceof Error && n.stack && (u.stack = n.stack), u;
2448
2721
  }
2449
2722
  }
2450
2723
  reset() {
2451
2724
  this.promiseCache = {};
2452
2725
  }
2453
2726
  };
2454
- _Loader = Loader, _Loader.defaultOptions = {
2727
+ f(_t, "defaultOptions", {
2455
2728
  strategy: "throw",
2456
2729
  retryCount: 3,
2457
2730
  retryDelay: 250
2458
- };
2459
- async function loadTextures(n, j, M) {
2460
- let N = null;
2461
- return N = globalThis.createImageBitmap ? await loadImageBitmap(n) : await new Promise((j, M) => {
2462
- N = new Image(), N.crossOrigin = "anonymous", N.src = n, N.complete ? j(N) : (N.onload = () => {
2463
- j(N);
2464
- }, N.onerror = M);
2465
- }), createTexture(new TextureSource({ resource: N }), M, n);
2731
+ });
2732
+ async function vt(e, t, n) {
2733
+ let r = null;
2734
+ return r = globalThis.createImageBitmap ? await yt(e) : await new Promise((t, n) => {
2735
+ r = new Image(), r.crossOrigin = "anonymous", r.src = e, r.complete ? t(r) : (r.onload = () => {
2736
+ t(r);
2737
+ }, r.onerror = n);
2738
+ }), bt(new G({ resource: r }), n, e);
2466
2739
  }
2467
- async function loadImageBitmap(n) {
2468
- let j = await window.fetch(n);
2469
- if (j.headers.get("content-type") === "text/html" || !j.ok) throw Error(`[loadImageBitmap] Failed to fetch ${n}: ${j.status} ${j.statusText}`);
2470
- let M = await j.blob();
2471
- return window.createImageBitmap(M);
2740
+ async function yt(e) {
2741
+ let t = await window.fetch(e);
2742
+ if (t.headers.get("content-type") === "text/html" || !t.ok) throw Error(`[loadImageBitmap] Failed to fetch ${e}: ${t.status} ${t.statusText}`);
2743
+ let n = await t.blob();
2744
+ return window.createImageBitmap(n);
2472
2745
  }
2473
- function createTexture(n, j, M) {
2474
- n.label = M;
2475
- let N = new Texture({
2476
- source: n,
2477
- label: M
2478
- }), P = () => {
2479
- delete j.promiseCache[M], Cache.has(M) && Cache.remove(M);
2746
+ function bt(e, t, n) {
2747
+ e.label = n;
2748
+ let r = new K({
2749
+ source: e,
2750
+ label: n
2751
+ }), i = () => {
2752
+ delete t.promiseCache[n], $.has(n) && $.remove(n);
2480
2753
  };
2481
- return N.source.on("destroy", () => {
2482
- j.promiseCache[M] && P();
2483
- }), N.on("destroy", () => {
2484
- n.destroyed || P();
2485
- }), N;
2754
+ return r.source.on("destroy", () => {
2755
+ t.promiseCache[n] && i();
2756
+ }), r.on("destroy", () => {
2757
+ e.destroyed || i();
2758
+ }), r;
2486
2759
  }
2487
- var AssetsClass = class {
2760
+ //#endregion
2761
+ //#region lib/assets/Assets.ts
2762
+ var xt = class {
2488
2763
  constructor() {
2489
- this._initialized = !1, this.loader = new Loader(), this.cache = Cache;
2764
+ f(this, "cache", void 0), f(this, "loader", void 0), f(this, "basePath", void 0), f(this, "_initialized", !1), this.loader = new _t(), this.cache = $;
2490
2765
  }
2491
- init(n = {}) {
2492
- this._initialized || (this._initialized = !0, n.basePath && (this.basePath = n.basePath), n.loadOptions && (this.loader.loadOptions = {
2766
+ init(e = {}) {
2767
+ this._initialized || (this._initialized = !0, e.basePath && (this.basePath = e.basePath), e.loadOptions && (this.loader.loadOptions = {
2493
2768
  ...this.loader.loadOptions,
2494
- ...n.loadOptions
2769
+ ...e.loadOptions
2495
2770
  }));
2496
2771
  }
2497
- async load(n, j) {
2772
+ async load(e, t) {
2498
2773
  this._initialized || this.init();
2499
- let M = n.map((n) => ({
2500
- ...n,
2501
- src: toAbsolutePath(n.src, this.basePath)
2774
+ let n = e.map((e) => ({
2775
+ ...e,
2776
+ src: Ct(e.src, this.basePath)
2502
2777
  }));
2503
- return await this._mapLoadToResolve(M, j);
2778
+ return await this._mapLoadToResolve(n, t);
2504
2779
  }
2505
- async _mapLoadToResolve(n, j) {
2506
- let M = Object.values(n), N = await this.loader.load(M, j), P = {};
2507
- return M.forEach((n) => {
2508
- let j = N[n.src], M = Array.isArray(n.alias) ? n.alias : [n.alias], F = [n.src, ...M];
2509
- F.forEach((n) => {
2510
- P[n] = j;
2511
- }), Cache.set(F, j);
2512
- }), P;
2780
+ async _mapLoadToResolve(e, t) {
2781
+ let n = Object.values(e), r = await this.loader.load(n, t), i = {};
2782
+ return n.forEach((e) => {
2783
+ let t = r[e.src], n = Array.isArray(e.alias) ? e.alias : [e.alias], a = [e.src, ...n];
2784
+ a.forEach((e) => {
2785
+ i[e] = t;
2786
+ }), $.set(a, t);
2787
+ }), i;
2513
2788
  }
2514
2789
  reset() {
2515
2790
  this._initialized = !1, this.cache.reset(), this.loader.reset();
2516
2791
  }
2517
- };
2518
- const Assets = new AssetsClass();
2519
- function toAbsolutePath(n, j) {
2520
- return n.startsWith("http") || !j ? n : n.startsWith("/") && j.endsWith("/") ? j + n.slice(1) : n.startsWith("/") && !j.endsWith("/") || !n.startsWith("/") && j.endsWith("/") ? j + n : `${j}/${n}`;
2792
+ }, St = new xt();
2793
+ function Ct(e, t) {
2794
+ return e.startsWith("http") || !t ? e : e.startsWith("/") && t.endsWith("/") ? t + e.slice(1) : e.startsWith("/") && !t.endsWith("/") || !e.startsWith("/") && t.endsWith("/") ? t + e : `${t}/${e}`;
2521
2795
  }
2522
- export { Application, Assets, AssetsClass, CanvasRenderer, Container, Graphics, GraphicsContext, GraphicsPipe, Matrix, PI_2, Rectangle, RenderGroup, RenderTexture, Sprite, Text, TextPipe, Texture, Ticker, TickerListener, UPDATE_BLEND, UPDATE_COLOR, UPDATE_TRANSFORM, UPDATE_VISIBLE, Vector2, ViewContainer, buildShapePath, nextPow2 };
2796
+ //#endregion
2797
+ export { gt as Application, St as Assets, xt as AssetsClass, pt as CanvasRenderer, N as Container, Le as Graphics, R as GraphicsContext, z as GraphicsPipe, _ as Matrix, g as PI_2, y as Rectangle, _e as RenderGroup, Qe as RenderTexture, $e as Sprite, et as Text, V as TextPipe, K as Texture, Z as Ticker, X as TickerListener, xe as UPDATE_BLEND, be as UPDATE_COLOR, Ce as UPDATE_TRANSFORM, Se as UPDATE_VISIBLE, b as Vector2, P as ViewContainer, B as buildShapePath, x as nextPow2 };
2523
2798
 
2524
2799
  //# sourceMappingURL=dao.js.map