@caperjs/core 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/build/index.mjs +2 -0
  2. package/build/plugins/viewport.mjs +52 -0
  3. package/lib/{CaptionsPlugin-DeGyPecB.js → CaptionsPlugin-WPAcfAkx.js} +13 -12
  4. package/lib/CaptionsPlugin-WPAcfAkx.js.map +1 -0
  5. package/lib/{DataAdapter-DeI2kIxC.js → DataAdapter-DS-twowe.js} +11 -11
  6. package/lib/{DataAdapter-DeI2kIxC.js.map → DataAdapter-DS-twowe.js.map} +1 -1
  7. package/lib/{DebugRenderer-wjV0tMwL.js → DebugRenderer-D1ryrRYx.js} +2 -2
  8. package/lib/{DebugRenderer-wjV0tMwL.js.map → DebugRenderer-D1ryrRYx.js.map} +1 -1
  9. package/lib/{DevToolsPlugin-D4iWQwkO.js → DevToolsPlugin-DH7zX7HU.js} +2 -2
  10. package/lib/{DevToolsPlugin-D4iWQwkO.js.map → DevToolsPlugin-DH7zX7HU.js.map} +1 -1
  11. package/lib/{GSAPPlugin-DQTyIwcC.js → GSAPPlugin-BBtRjUqe.js} +2 -2
  12. package/lib/{GSAPPlugin-DQTyIwcC.js.map → GSAPPlugin-BBtRjUqe.js.map} +1 -1
  13. package/lib/{LayoutPlugin-vR_h-BaG.js → LayoutPlugin-Co6vcoV4.js} +4 -4
  14. package/lib/{LayoutPlugin-vR_h-BaG.js.map → LayoutPlugin-Co6vcoV4.js.map} +1 -1
  15. package/lib/{SpinePlugin-DJ-PpxFj.js → SpinePlugin-uN641Hmk.js} +2 -2
  16. package/lib/{SpinePlugin-DJ-PpxFj.js.map → SpinePlugin-uN641Hmk.js.map} +1 -1
  17. package/lib/{StatsPlugin-BYNnKYOm.js → StatsPlugin-vZQRm6wh.js} +4 -4
  18. package/lib/{StatsPlugin-BYNnKYOm.js.map → StatsPlugin-vZQRm6wh.js.map} +1 -1
  19. package/lib/{VoiceOverPlugin-BLSbq3DU.js → VoiceOverPlugin-KlZdGj1G.js} +32 -32
  20. package/lib/{VoiceOverPlugin-BLSbq3DU.js.map → VoiceOverPlugin-KlZdGj1G.js.map} +1 -1
  21. package/lib/caper.mjs +2112 -353
  22. package/lib/caper.mjs.map +1 -1
  23. package/lib/core/Application.d.ts +7 -1
  24. package/lib/core/Application.d.ts.map +1 -1
  25. package/lib/core/interfaces/IApplicationOptions.d.ts +1 -1
  26. package/lib/core/interfaces/IApplicationOptions.d.ts.map +1 -1
  27. package/lib/core/interfaces/ICoreFunctions.d.ts +1 -0
  28. package/lib/core/interfaces/ICoreFunctions.d.ts.map +1 -1
  29. package/lib/display/AnimatedSprite.d.ts +1 -1
  30. package/lib/display/AnimatedSprite.d.ts.map +1 -1
  31. package/lib/display/Container.d.ts.map +1 -1
  32. package/lib/display/SpineAnimation.d.ts +1 -1
  33. package/lib/display/SpineAnimation.d.ts.map +1 -1
  34. package/lib/importOrder.containerFirst.test.d.ts +2 -0
  35. package/lib/importOrder.containerFirst.test.d.ts.map +1 -0
  36. package/lib/importOrder.displayFirst.test.d.ts +2 -0
  37. package/lib/importOrder.displayFirst.test.d.ts.map +1 -0
  38. package/lib/importOrder.mixinsFirst.test.d.ts +2 -0
  39. package/lib/importOrder.mixinsFirst.test.d.ts.map +1 -0
  40. package/lib/importOrder.sceneFirst.test.d.ts +2 -0
  41. package/lib/importOrder.sceneFirst.test.d.ts.map +1 -0
  42. package/lib/importOrder.toastFirst.test.d.ts +2 -0
  43. package/lib/importOrder.toastFirst.test.d.ts.map +1 -0
  44. package/lib/importOrder.uiFirst.test.d.ts +2 -0
  45. package/lib/importOrder.uiFirst.test.d.ts.map +1 -0
  46. package/lib/mixins/factory/Factory.d.ts +1 -1
  47. package/lib/mixins/factory/Factory.d.ts.map +1 -1
  48. package/lib/mixins/factory/Factory.test.d.ts +1 -0
  49. package/lib/mixins/factory/Factory.test.d.ts.map +1 -0
  50. package/lib/mixins/factory/const.d.ts +9 -2
  51. package/lib/mixins/factory/const.d.ts.map +1 -1
  52. package/lib/mixins/factory/defaults.d.ts +5 -0
  53. package/lib/mixins/factory/defaults.d.ts.map +1 -0
  54. package/lib/mixins/factory/methods.d.ts +1 -1
  55. package/lib/mixins/factory/methods.d.ts.map +1 -1
  56. package/lib/mixins/factory/props.d.ts +4 -2
  57. package/lib/mixins/factory/props.d.ts.map +1 -1
  58. package/lib/plugins/PopupManagerPlugin.d.ts +1 -1
  59. package/lib/plugins/PopupManagerPlugin.d.ts.map +1 -1
  60. package/lib/plugins/ResizerPlugin.d.ts +29 -0
  61. package/lib/plugins/ResizerPlugin.d.ts.map +1 -1
  62. package/lib/plugins/ResizerPlugin.test.d.ts +2 -0
  63. package/lib/plugins/ResizerPlugin.test.d.ts.map +1 -0
  64. package/lib/plugins/WebEventsPlugin.d.ts +5 -0
  65. package/lib/plugins/WebEventsPlugin.d.ts.map +1 -1
  66. package/lib/plugins/WebEventsPlugin.test.d.ts +2 -0
  67. package/lib/plugins/WebEventsPlugin.test.d.ts.map +1 -0
  68. package/lib/plugins/captions/CaptionsRenderer.d.ts +1 -1
  69. package/lib/plugins/captions/CaptionsRenderer.d.ts.map +1 -1
  70. package/lib/plugins/i18nPlugin.d.ts +29 -3
  71. package/lib/plugins/i18nPlugin.d.ts.map +1 -1
  72. package/lib/plugins/i18nPlugin.test.d.ts +2 -0
  73. package/lib/plugins/i18nPlugin.test.d.ts.map +1 -0
  74. package/lib/plugins/input/touch/VirtualControls.d.ts.map +1 -1
  75. package/lib/plugins/spine/pixi-spine/require-shim.d.ts +0 -1
  76. package/lib/plugins/spine/pixi-spine/require-shim.d.ts.map +1 -1
  77. package/lib/{registries-aN0y0Xha.js → registries-BLrxALZ0.js} +1124 -2801
  78. package/lib/registries-BLrxALZ0.js.map +1 -0
  79. package/lib/ui/Button.d.ts +9 -2
  80. package/lib/ui/Button.d.ts.map +1 -1
  81. package/lib/ui/Button.test.d.ts +2 -0
  82. package/lib/ui/Button.test.d.ts.map +1 -0
  83. package/lib/ui/FlexContainer.d.ts +1 -1
  84. package/lib/ui/FlexContainer.d.ts.map +1 -1
  85. package/lib/ui/Input.d.ts +2 -2
  86. package/lib/ui/Input.d.ts.map +1 -1
  87. package/lib/ui/Joystick.d.ts +1 -1
  88. package/lib/ui/Joystick.d.ts.map +1 -1
  89. package/lib/ui/Toast.d.ts +1 -1
  90. package/lib/ui/Toast.d.ts.map +1 -1
  91. package/lib/ui/UICanvas.d.ts +11 -1
  92. package/lib/ui/UICanvas.d.ts.map +1 -1
  93. package/lib/ui/UICanvas.test.d.ts +2 -0
  94. package/lib/ui/UICanvas.test.d.ts.map +1 -0
  95. package/lib/utils/types.d.ts +1 -2
  96. package/lib/utils/types.d.ts.map +1 -1
  97. package/package.json +1 -1
  98. package/src/core/Application.ts +15 -2
  99. package/src/core/interfaces/IApplicationOptions.ts +1 -1
  100. package/src/core/interfaces/ICoreFunctions.ts +1 -0
  101. package/src/display/AnimatedSprite.ts +2 -1
  102. package/src/display/Container.ts +3 -1
  103. package/src/display/SpineAnimation.ts +3 -2
  104. package/src/importOrder.containerFirst.test.ts +32 -0
  105. package/src/importOrder.displayFirst.test.ts +19 -0
  106. package/src/importOrder.mixinsFirst.test.ts +18 -0
  107. package/src/importOrder.sceneFirst.test.ts +21 -0
  108. package/src/importOrder.toastFirst.test.ts +20 -0
  109. package/src/importOrder.uiFirst.test.ts +24 -0
  110. package/src/mixins/factory/Factory.test.ts +22 -0
  111. package/src/mixins/factory/Factory.ts +9 -2
  112. package/src/mixins/factory/const.ts +18 -11
  113. package/src/mixins/factory/defaults.ts +28 -0
  114. package/src/mixins/factory/methods.ts +1 -1
  115. package/src/mixins/factory/props.ts +5 -3
  116. package/src/plugins/LookupPlugin.ts +1 -1
  117. package/src/plugins/PopupManagerPlugin.ts +1 -1
  118. package/src/plugins/ResizerPlugin.test.ts +84 -0
  119. package/src/plugins/ResizerPlugin.ts +59 -1
  120. package/src/plugins/WebEventsPlugin.test.ts +75 -0
  121. package/src/plugins/WebEventsPlugin.ts +15 -0
  122. package/src/plugins/captions/CaptionsRenderer.ts +1 -1
  123. package/src/plugins/i18nPlugin.test.ts +124 -0
  124. package/src/plugins/i18nPlugin.ts +57 -18
  125. package/src/plugins/input/keyboard/KeyboardContols.ts +1 -1
  126. package/src/plugins/input/touch/VirtualControls.ts +2 -2
  127. package/src/plugins/spine/pixi-spine/require-shim.ts +3 -1
  128. package/src/ui/Button.test.ts +236 -0
  129. package/src/ui/Button.ts +46 -11
  130. package/src/ui/FlexContainer.ts +3 -2
  131. package/src/ui/Input.ts +5 -2
  132. package/src/ui/Joystick.ts +1 -1
  133. package/src/ui/Toast.ts +2 -1
  134. package/src/ui/Toaster.ts +1 -1
  135. package/src/ui/UICanvas.test.ts +35 -0
  136. package/src/ui/UICanvas.ts +46 -8
  137. package/src/utils/types.ts +1 -1
  138. package/src/version.ts +1 -1
  139. package/lib/CaptionsPlugin-DeGyPecB.js.map +0 -1
  140. package/lib/registries-aN0y0Xha.js.map +0 -1
package/lib/caper.mjs CHANGED
@@ -1,18 +1,18 @@
1
- import { $ as e, $t as t, A as n, At as r, B as i, Bt as a, C as o, Cn as s, Ct as c, D as l, Dt as u, E as d, Et as f, F as ee, Ft as p, G as te, Gt as m, H as ne, Ht as re, I as ie, It as ae, J as h, Jt as oe, K as se, Kt as ce, L as le, Lt as ue, M as de, Mt as g, N as fe, Nt as pe, O as me, Ot as he, P as ge, Pt as _e, Q as ve, Qt as ye, R as be, Rt as xe, S as Se, Sn as Ce, St as we, T as Te, Tt as Ee, U as De, Ut as Oe, V as ke, Vt as Ae, W as je, Wt as Me, X as Ne, Xt as Pe, Y as Fe, Yt as Ie, Z as _, Zt as Le, _ as Re, _n as ze, _t as Be, a as Ve, an as He, at as Ue, b as We, bn as Ge, bt as Ke, c as qe, cn as Je, ct as Ye, d as Xe, dn as Ze, dt as Qe, en as $e, et, f as tt, fn as nt, ft as rt, g as it, gn as at, gt as v, h as ot, hn as y, ht as st, i as ct, in as lt, it as ut, j as dt, jt as ft, k as pt, kt as mt, l as ht, ln as b, lt as gt, m as _t, mn as vt, mt as x, n as yt, nn as bt, nt as xt, o as St, on as Ct, ot as wt, p as Tt, pn as Et, pt as S, q as Dt, qt as Ot, r as C, rn as kt, rt as At, s as jt, sn as Mt, st as Nt, t as Pt, tn as Ft, tt as It, u as Lt, un as Rt, ut as w, v as zt, vn as Bt, vt as T, w as Vt, wt as Ht, x as Ut, xn as E, xt as Wt, y as Gt, yn as Kt, yt as D, z as qt, zt as Jt } from "./registries-aN0y0Xha.js";
2
- import { r as Yt, t as Xt } from "./DataAdapter-DeI2kIxC.js";
3
- import { CanvasTextMetrics as O, Container as Zt, Graphics as k, Point as A, Polygon as Qt, Rectangle as $t, Sprite as en, Texture as j, isMobile as M } from "pixi.js";
4
- import { gsap as N } from "gsap";
1
+ import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as ee, H as te, I as ne, It as re, J as ie, K as p, L as ae, Lt as oe, M as se, Mt as ce, N as le, Nt as m, O as ue, Ot as de, P as fe, Pt as pe, Q as me, R as he, Rt as ge, S as _e, St as ve, T as ye, Tt as be, U as xe, V as Se, Vt as Ce, W as we, X as Te, Y as Ee, Z as De, _ as Oe, _t as ke, a as Ae, at as je, b as h, bt as Me, c as Ne, ct as Pe, d as Fe, dt as g, et as Ie, f as _, ft as Le, g as Re, gt as ze, h as Be, ht as Ve, i as He, it as Ue, j as We, jt as Ge, k as Ke, kt as qe, l as Je, lt as Ye, m as v, mt as Xe, n as Ze, nt as Qe, o as $e, ot as y, p as b, pt as et, q as x, r as S, rt as tt, s as nt, st as rt, t as it, tt as at, u as ot, ut as st, v as ct, vt as lt, w as ut, wt as dt, x as ft, xt as pt, y as mt, yt as ht, z as gt, zt as _t } from "./registries-BLrxALZ0.js";
2
+ import { r as vt, t as yt } from "./DataAdapter-DS-twowe.js";
3
+ import { AnimatedSprite as bt, Assets as C, BitmapText as w, CanvasTextMetrics as T, Container as xt, Graphics as E, HTMLText as St, ParticleContainer as Ct, Point as D, Polygon as wt, Rectangle as Tt, Sprite as Et, Text as O, Texture as k, TilingSprite as Dt, isMobile as Ot } from "pixi.js";
4
+ import { gsap as A } from "gsap";
5
5
  //#region src/utils/array.ts
6
- function tn(e) {
6
+ function kt(e) {
7
7
  let t, n;
8
- for (let r = 0; r < e.length; ++r) n = E(0, e.length), t = e[r], e[r] = e[n], e[n] = t;
8
+ for (let r = 0; r < e.length; ++r) n = _t(0, e.length), t = e[r], e[r] = e[n], e[n] = t;
9
9
  }
10
- function nn(e) {
11
- return e[E(0, e.length)];
10
+ function At(e) {
11
+ return e[_t(0, e.length)];
12
12
  }
13
13
  //#endregion
14
14
  //#region src/utils/canvas.ts
15
- function rn(e) {
15
+ function jt(e) {
16
16
  let t = e.getContext("webgl");
17
17
  if (t) {
18
18
  let e = t.getExtension("WEBGL_lose_context");
@@ -23,13 +23,13 @@ function rn(e) {
23
23
  }
24
24
  //#endregion
25
25
  //#region src/utils/color.ts
26
- function an(e) {
26
+ function Mt(e) {
27
27
  return `#${e.toString(16)}`;
28
28
  }
29
- function on(e) {
29
+ function Nt(e) {
30
30
  return parseInt(e.replace(/^#/, ""), 16);
31
31
  }
32
- var sn = class e {
32
+ var Pt = class e {
33
33
  static {
34
34
  this.WHITE = new e(255, 255, 255);
35
35
  }
@@ -94,106 +94,193 @@ var sn = class e {
94
94
  this.b / 255
95
95
  ];
96
96
  }
97
+ }, j = {
98
+ bounds: 65535,
99
+ innerBounds: 65280,
100
+ outerBounds: 16711680,
101
+ direction: 16776960,
102
+ gap: 16711935,
103
+ region: 30975
104
+ }, M = {
105
+ stroke: .6,
106
+ fill: .1,
107
+ fillActive: .2,
108
+ crosshair: .5
97
109
  };
110
+ function Ft(e) {
111
+ let t = new E();
112
+ return t.eventMode = "none", t.interactiveChildren = !1, t.layout = !1, t.label = e ?? "DebugGraphics", t;
113
+ }
114
+ function N(e, t = j.bounds) {
115
+ let n = new O({
116
+ text: e,
117
+ style: {
118
+ fontFamily: "monospace",
119
+ fontSize: 10,
120
+ fill: t,
121
+ stroke: {
122
+ color: 0,
123
+ width: 2
124
+ }
125
+ }
126
+ });
127
+ return n.eventMode = "none", n.layout = !1, n.label = "DebugLabel", n;
128
+ }
129
+ var It = /* @__PURE__ */ new Map();
130
+ function P(e, t, n) {
131
+ It.set(e, {
132
+ label: t,
133
+ color: n
134
+ });
135
+ }
136
+ function F(e) {
137
+ It.delete(e);
138
+ }
139
+ function Lt() {
140
+ return It;
141
+ }
98
142
  //#endregion
99
143
  //#region src/utils/define.ts
100
- function cn(e) {
144
+ function Rt(e) {
101
145
  return e;
102
146
  }
103
- function ln(e) {
147
+ function zt(e) {
104
148
  return e;
105
149
  }
106
- function un(e) {
150
+ function Bt(e) {
107
151
  return e;
108
152
  }
109
- function dn(e) {
153
+ function Vt(e) {
110
154
  return e;
111
155
  }
112
- function fn(e) {
156
+ function Ht(e) {
113
157
  return e;
114
158
  }
115
159
  //#endregion
160
+ //#region src/utils/number.ts
161
+ function Ut(e, t = 0) {
162
+ return e.toString().padStart(t, "0");
163
+ }
164
+ //#endregion
165
+ //#region src/utils/padding.ts
166
+ function Wt(e, t) {
167
+ return e >= 0 && e <= 1 ? e * t : e;
168
+ }
169
+ function I(e) {
170
+ if (Array.isArray(e)) return {
171
+ top: e[0],
172
+ right: e?.[1] ?? e[0],
173
+ bottom: e?.[2] ?? e[0],
174
+ left: e?.[3] ?? e?.[1] ?? e[0] ?? 0
175
+ };
176
+ if (typeof e == "number") return {
177
+ top: e,
178
+ right: e,
179
+ bottom: e,
180
+ left: e
181
+ };
182
+ if (typeof e == "object") {
183
+ let t = e;
184
+ return t.x !== void 0 && t.y !== void 0 ? {
185
+ top: t.y,
186
+ right: t.x,
187
+ bottom: t.y,
188
+ left: t.x
189
+ } : {
190
+ top: e.top ?? 0,
191
+ right: e.right ?? 0,
192
+ bottom: e.bottom ?? 0,
193
+ left: e.left ?? 0
194
+ };
195
+ } else return {
196
+ top: 0,
197
+ right: 0,
198
+ bottom: 0,
199
+ left: 0
200
+ };
201
+ }
202
+ //#endregion
116
203
  //#region src/utils/pixi.ts
117
- function pn(e, t) {
204
+ function Gt(e, t) {
118
205
  e.parent && e.parent.worldTransform.apply(e.position, e.position), t.worldTransform.applyInverse(e.position, e.position), e.parent?.removeChild(e), t.addChild(e);
119
206
  }
120
- function mn(e) {
207
+ function Kt(e) {
121
208
  return Math.sqrt(e.width * e.width + e.height * e.height);
122
209
  }
123
- function hn(e) {
210
+ function qt(e) {
124
211
  let t = e.parent;
125
212
  t && (t.removeChild(e), t.addChild(e));
126
213
  }
127
- function gn(e) {
214
+ function Jt(e) {
128
215
  let t = e.parent;
129
216
  t && (t.removeChild(e), t.addChildAt(e, 0));
130
217
  }
131
- function _n(e, t) {
132
- if (e instanceof Qt) {
218
+ function Yt(e, t) {
219
+ if (e instanceof wt) {
133
220
  for (let n = 0; n < e.points.length; n += 2) e.points[n] += t.x, e.points[n + 1] += t.y;
134
221
  return e;
135
222
  } else return e.x += t.x, e.y += t.y, e;
136
223
  }
137
- function vn(e, t) {
224
+ function Xt(e, t) {
138
225
  return e.x += t.x, e.y += t.y, e;
139
226
  }
140
- function P(e, t, n = "width") {
227
+ function L(e, t, n = "width") {
141
228
  let r = n === "width" ? "y" : "x", i = n === "width" ? "x" : "y";
142
229
  e[n] = t, e.scale[r] = e.scale[i];
143
230
  }
144
- function F(e, t) {
145
- P(e, t, "width");
231
+ function R(e, t) {
232
+ L(e, t, "width");
146
233
  }
147
- function I(e, t) {
148
- P(e, t, "height");
234
+ function z(e, t) {
235
+ L(e, t, "height");
149
236
  }
150
- function yn(e, t, n = "width") {
237
+ function Zt(e, t, n = "width") {
151
238
  let r;
152
239
  r = t?.width && t?.height ? {
153
240
  x: t.width,
154
241
  y: t.height
155
- } : g(t), n === "width" ? (F(e, r.x), e.height < r.y && I(e, r.y)) : (I(e, r.y), e.width < r.x && F(e, r.x));
242
+ } : y(t), n === "width" ? (R(e, r.x), e.height < r.y && z(e, r.y)) : (z(e, r.y), e.width < r.x && R(e, r.x));
156
243
  }
157
244
  //#endregion
158
245
  //#region src/utils/platform.ts
159
- var bn = typeof window < "u" ? window.devicePixelRatio > 1 || window.matchMedia && window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)").matches : !1, L = typeof window < "u" ? "ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator?.maxTouchPoints > 0 : !1, R = M.any, z = M.android.device, xn = M.apple.device;
246
+ var Qt = typeof window < "u" ? window.devicePixelRatio > 1 || window.matchMedia && window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)").matches : !1, B = typeof window < "u" ? "ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator?.maxTouchPoints > 0 : !1, $t = Ot.any, en = Ot.android.device, tn = Ot.apple.device;
160
247
  //#endregion
161
248
  //#region src/utils/rect.ts
162
- function Sn(e, t) {
249
+ function nn(e, t) {
163
250
  return e.x += t.x, e.y += t.y, e;
164
251
  }
165
- function Cn(e, t) {
166
- return t === void 0 && (t = new A()), t.set(e.x + e.width * .5, e.y + e.height * .5), t;
252
+ function rn(e, t) {
253
+ return t === void 0 && (t = new D()), t.set(e.x + e.width * .5, e.y + e.height * .5), t;
167
254
  }
168
- function wn(e, t) {
255
+ function an(e, t) {
169
256
  return e.x *= t, e.y *= t, e.width *= t, e.height *= t, e;
170
257
  }
171
- function Tn(e, t) {
172
- return t === void 0 && (t = new A()), t.set(e.width, e.height), t;
258
+ function on(e, t) {
259
+ return t === void 0 && (t = new D()), t.set(e.width, e.height), t;
173
260
  }
174
261
  //#endregion
175
262
  //#region src/utils/set.ts
176
- function En(e, t) {
263
+ function sn(e, t) {
177
264
  let n = /* @__PURE__ */ new Set();
178
265
  for (let r of e) t(r) && n.add(r);
179
266
  return n;
180
267
  }
181
- function Dn(e) {
268
+ function cn(e) {
182
269
  return e?.values().next().value;
183
270
  }
184
- function On(e) {
271
+ function ln(e) {
185
272
  let t;
186
273
  for (let n of e) t = n;
187
274
  return t;
188
275
  }
189
276
  //#endregion
190
277
  //#region src/utils/text.ts
191
- function B(e, t) {
192
- let n = O.measureText(e.text, e.style), r = n.lines, i = n.lineHeight, a = e.toLocal(new A(t.pageX, t.pageY)), o = 0, s = Infinity, c = 0;
278
+ function un(e, t) {
279
+ let n = T.measureText(e.text, e.style), r = n.lines, i = n.lineHeight, a = e.toLocal(new D(t.pageX, t.pageY)), o = 0, s = Infinity, c = 0;
193
280
  for (let t = 0; t < r.length; t++) {
194
281
  let n = r[t];
195
282
  for (let r = 0; r <= n.length; r++) {
196
- let l = n.substring(0, r), u = O.measureText(l, e.style).width, d = t * i, f = Math.hypot(u - a.x, d - a.y);
283
+ let l = n.substring(0, r), u = T.measureText(l, e.style).width, d = t * i, f = Math.hypot(u - a.x, d - a.y);
197
284
  f < s && (s = f, o = c + r);
198
285
  }
199
286
  c += n.length;
@@ -202,25 +289,260 @@ function B(e, t) {
202
289
  }
203
290
  //#endregion
204
291
  //#region src/version.ts
205
- var V = "0.2.2", H = "8.19.0", kn = " ........ ..... ............ ............. ........... \n ............. ....... ................ ............. .............. \n .............. ......... ............... ............. .............. \n ..... ........... .............. ............ .............. \n ..... ...... ...... .............. ............. ............. \n .............. ...... ..... ............ ............. ..... ...... \n ................... ..... ..... ............. ..... ....... \n ................ .......... ............. ..... ..... ";
206
- function U() {
207
- let e = `\n${kn}\n\n v${V} | %cPixi.js v${H} %c| %chttps://github.com/anthonysapp/caper\n\n`;
292
+ var dn = "0.2.4", fn = "8.19.0", pn = " ........ ..... ............ ............. ........... \n ............. ....... ................ ............. .............. \n .............. ......... ............... ............. .............. \n ..... ........... .............. ............ .............. \n ..... ...... ...... .............. ............. ............. \n .............. ...... ..... ............ ............. ..... ...... \n ................... ..... ..... ............. ..... ....... \n ................ .......... ............. ..... ..... ";
293
+ function mn() {
294
+ let e = `\n${pn}\n\n v${dn} | %cPixi.js v${fn} %c| %chttps://github.com/anthonysapp/caper\n\n`;
208
295
  console.log(e, "color: #E91E63; font-weight: 600;", "color: inherit;", "color: #00BCD4; text-decoration: underline;");
209
296
  }
210
297
  //#endregion
211
298
  //#region src/webgl-check.ts
212
- function An() {
299
+ function hn() {
213
300
  if (typeof document > "u") return;
214
301
  let e = document.createElement("canvas");
215
302
  e.getContext("webgl") || e.getContext("experimental-webgl") || console.error("Your browser does not support WebGL.");
216
303
  }
217
304
  //#endregion
305
+ //#region src/plugins/actions/methods.ts
306
+ function gn(e) {
307
+ return e ?? le;
308
+ }
309
+ function _n(e, t, n = !0) {
310
+ return n && (t = {
311
+ ...ne,
312
+ ...t
313
+ }), t;
314
+ }
315
+ function vn(e) {
316
+ return e || [];
317
+ }
318
+ //#endregion
319
+ //#region src/plugins/breakpoints/methods.ts
320
+ function yn(e) {
321
+ return {
322
+ tiers: e.tiers,
323
+ modes: e.modes ?? {}
324
+ };
325
+ }
326
+ //#endregion
327
+ //#region src/plugins/input/touch/constants.ts
328
+ var V = /* @__PURE__ */ function(e) {
329
+ return e.None = "none", e.Left = "left", e.Top = "top", e.Bottom = "bottom", e.Right = "right", e.TopLeft = "top_left", e.TopRight = "top_right", e.BottomLeft = "bottom_left", e.BottomRight = "bottom_right", e;
330
+ }({}), bn = [
331
+ V.None,
332
+ V.Left,
333
+ V.Top,
334
+ V.Bottom,
335
+ V.Right,
336
+ V.TopLeft,
337
+ V.TopRight,
338
+ V.BottomLeft,
339
+ V.BottomRight
340
+ ];
341
+ //#endregion
342
+ //#region src/plugins/input/methods.ts
343
+ function xn(e, t, n) {
344
+ return n || [];
345
+ }
346
+ //#endregion
347
+ //#region src/core/globals.ts
348
+ var Sn = 200, Cn = "CaperApplication";
349
+ function wn() {
350
+ try {
351
+ return globalThis.Caper?.__dev === !0;
352
+ } catch {
353
+ return !1;
354
+ }
355
+ }
356
+ function Tn() {
357
+ try {
358
+ return !1;
359
+ } catch {
360
+ return !1;
361
+ }
362
+ }
363
+ var En = "__first__";
364
+ function Dn() {
365
+ let e = globalThis, t = e.Caper ||= {};
366
+ return t.apps instanceof Map || (t.apps = /* @__PURE__ */ new Map()), (typeof t.automation != "object" || t.automation === null) && (t.automation = {}), t.__readyResolvers instanceof Map || (t.__readyResolvers = /* @__PURE__ */ new Map()), t.__readyApps instanceof Set || (t.__readyApps = /* @__PURE__ */ new Set()), typeof t.ready != "function" && (t.ready = (e) => {
367
+ let n = t.__readyResolvers, r = t.__readyApps;
368
+ if (e && r.has(e)) return Promise.resolve(t.apps.get(e));
369
+ if (!e && r.size > 0) {
370
+ let e = r.values().next().value;
371
+ return Promise.resolve(t.apps.get(e));
372
+ }
373
+ let i = e ?? En, a = n.get(i);
374
+ if (!a) {
375
+ let e, t = new Promise((t) => {
376
+ e = t;
377
+ });
378
+ a = {
379
+ resolve: e,
380
+ promise: t
381
+ }, n.set(i, a);
382
+ }
383
+ return a.promise;
384
+ }), t;
385
+ }
386
+ function On() {
387
+ Dn();
388
+ }
389
+ function kn(e) {
390
+ return e.config?.id || Cn;
391
+ }
392
+ function An(e) {
393
+ let t = kn(e), n = [], r, i = [], a = (e) => {
394
+ n.push(e), n.length > Sn && n.splice(0, n.length - Sn);
395
+ }, o = () => r ? r() : void 0, s = (e) => {
396
+ if (i.length !== 0) for (let t = i.length - 1; t >= 0; t--) {
397
+ let n = !1;
398
+ try {
399
+ n = i[t].predicate(e);
400
+ } catch {
401
+ n = !1;
402
+ }
403
+ if (n) {
404
+ let [n] = i.splice(t, 1);
405
+ n.resolve(e);
406
+ }
407
+ }
408
+ }, c = {
409
+ appId: t,
410
+ get log() {
411
+ return n;
412
+ },
413
+ action(t, n) {
414
+ e.sendAction(t, n);
415
+ },
416
+ getContext() {
417
+ return String(e.actionContext);
418
+ },
419
+ getState: o,
420
+ registerStateGetter(e) {
421
+ r = e;
422
+ },
423
+ notifyStateChanged(e) {
424
+ a({
425
+ t: Date.now(),
426
+ kind: "state",
427
+ data: e
428
+ }), s(e);
429
+ },
430
+ waitFor(e, t) {
431
+ let n = o();
432
+ try {
433
+ if (e(n)) return Promise.resolve(n);
434
+ } catch {}
435
+ return new Promise((n, r) => {
436
+ let a, o = {
437
+ predicate: e,
438
+ resolve: (e) => {
439
+ a && clearTimeout(a), n(e);
440
+ }
441
+ };
442
+ i.push(o), t?.timeoutMs != null && (a = setTimeout(() => {
443
+ let e = i.indexOf(o);
444
+ e >= 0 && i.splice(e, 1), r(/* @__PURE__ */ Error(`waitFor timed out after ${t.timeoutMs}ms`));
445
+ }, t.timeoutMs));
446
+ });
447
+ }
448
+ }, l = e.getPlugin("actions");
449
+ return l && (l.onActionDispatched?.connect((e) => {
450
+ a({
451
+ t: Date.now(),
452
+ kind: "action",
453
+ name: String(e.id),
454
+ data: e.data
455
+ }), s(o());
456
+ }), l.onActionContextChanged.connect((e) => {
457
+ a({
458
+ t: Date.now(),
459
+ kind: "context",
460
+ name: String(e)
461
+ });
462
+ })), c;
463
+ }
464
+ function jn(e) {
465
+ let t = Dn(), n = kn(e);
466
+ if (t.apps.set(n, e), t.app = e, wn() || e.config?.automation === !0 || Tn()) {
467
+ let r = An(e);
468
+ t.automation[n] = r, e.automation = r;
469
+ }
470
+ }
471
+ function Mn(e) {
472
+ let t = Dn(), n = kn(e);
473
+ t.__readyApps.add(n);
474
+ let r = t.__readyResolvers, i = r.get(n);
475
+ i && (i.resolve(e), r.delete(n));
476
+ let a = r.get(En);
477
+ a && (a.resolve(e), r.delete(En));
478
+ }
479
+ //#endregion
480
+ //#region src/core/create.ts
481
+ var Nn = "caper-game-container";
482
+ function Pn(e) {
483
+ let t = document.createElement("div");
484
+ return t.setAttribute("id", e), document.body.appendChild(t), t;
485
+ }
486
+ async function Fn() {
487
+ return new Promise((e) => {
488
+ document.readyState === "complete" || document.readyState === "interactive" ? e(!0) : document.addEventListener("DOMContentLoaded", () => {
489
+ e(!0);
490
+ });
491
+ });
492
+ }
493
+ async function In(e = { id: "CaperApplication" }, t = Nn, n = !0) {
494
+ await Fn(), hn(), n && mn();
495
+ let r = null;
496
+ if (typeof t == "string" ? (r = document.getElementById(t), r ||= Pn(t)) : t instanceof HTMLElement ? r = t : t === window && (r = document.body), !r) throw Error("You passed in a DOM Element, but none was found. If you instead pass in a string, a container will be created for you, using the string for its id.");
497
+ e.resizeToContainer && (e.resizeTo = r), e.useLayout && (e.layout = {
498
+ autoUpdate: !1,
499
+ enableDebug: !1,
500
+ debugModificationCount: 0,
501
+ throttle: 100
502
+ }), e.container = r;
503
+ let i = new (e.application || S)();
504
+ return await i.initialize(e, r), e.useLayout && (i.stage.layout = {
505
+ position: "absolute",
506
+ width: "100%",
507
+ height: "100%"
508
+ }), await i._postInitialize(), jn(i), globalThis.Caper?.__runtimeManaged || Mn(i), i;
509
+ }
510
+ //#endregion
218
511
  //#region src/display/Entity.ts
219
- var jn = class extends w {
512
+ var Ln = class extends _ {
220
513
  constructor(e) {
221
514
  super(), this.props = e ?? {};
222
515
  }
223
- }, Mn = class extends w {
516
+ }, Rn = ["autoUpdate", "priority"], zn = {
517
+ autoUpdate: !0,
518
+ priority: 0
519
+ }, Bn = class extends Ct {
520
+ static {
521
+ this.__caper_method_binding_root = !0;
522
+ }
523
+ constructor(e = {}) {
524
+ super(e), this.onDestroy = new p(), this.__config = {
525
+ ...zn,
526
+ ...e
527
+ }, m(this), this.on("added", this._added), this.on("removed", this._removed);
528
+ }
529
+ get app() {
530
+ return S.getInstance();
531
+ }
532
+ update(e) {}
533
+ resize(e) {}
534
+ added() {}
535
+ destroy(e) {
536
+ this.__config.autoUpdate && this.app.ticker.remove(this.update, this), this.onDestroy.emit(), super.destroy(e);
537
+ }
538
+ removed() {}
539
+ _added() {
540
+ this.__config.autoUpdate && this.app.ticker.add(this.update, this, this.__config.priority), this.added();
541
+ }
542
+ _removed() {
543
+ this.__config.autoUpdate && this.app.ticker.remove(this.update, this), this.removed();
544
+ }
545
+ }, Vn = class extends _ {
224
546
  get animationContext() {
225
547
  return this._animationContext ?? `__scene_${this.id}`;
226
548
  }
@@ -255,7 +577,7 @@ var jn = class extends w {
255
577
  }
256
578
  onPause(e) {}
257
579
  onResume(e) {}
258
- }, Nn = class extends w {
580
+ }, Hn = class extends _ {
259
581
  get active() {
260
582
  return this._active;
261
583
  }
@@ -296,9 +618,163 @@ var jn = class extends w {
296
618
  _update(e) {
297
619
  this.active && this.initialized && this.update(e);
298
620
  }
299
- }, Pn = class extends Zt {
621
+ }, Un = class extends E {
300
622
  constructor(e) {
301
- return super({ isRenderGroup: !0 }), this.config = e, this.onZoom = new T(), this.onZoomComplete = new T(), this.minX = 0, this.minY = 0, this._zooming = !1, this._zoomLerp = .1, this._targetPivot = new A(0, 0), this._targetScale = new A(1, 1), this._lerp = 0, this._target = null, this._followOffset = new A(0, 0), y(this), e && (this.container = e.container, this.addChild(this.container), e.minX && (this.minX = e.minX), e.maxX && (this.maxX = e.maxX), e.minY && (this.minY = e.minY), this.viewportWidth = e.viewportWidth ?? this.app.size.width, this.viewportHeight = e.viewportHeight ?? this.app.size.width, this.worldWidth = e.worldWidth ?? this.viewportWidth, this.worldHeight = e.worldHeight ?? this.viewportHeight, this.maxX = e.maxX ?? this.worldWidth - this.viewportWidth, this.maxY = e.maxY ?? this.worldHeight - this.viewportHeight), this._targetPivot.set(this.viewportWidth * .5, this.viewportHeight * .5), e.target && (this.target = e.target), this._lerp = 1, this.update(), e.lerp && (this.lerp = e.lerp), this;
623
+ super(typeof e == "string" ? C.get(e) : e);
624
+ let t = this.getLocalBounds();
625
+ this.pivot.set((t.x + t.width) / 2, (t.y + t.height) / 2);
626
+ }
627
+ }, Wn;
628
+ function H(e, t) {
629
+ for (let n in e) try {
630
+ t[n] = e[n];
631
+ } catch (e) {
632
+ c.warn(`Error setting property ${n}`, e);
633
+ }
634
+ }
635
+ function U() {
636
+ if (!Wn) {
637
+ let e = new E();
638
+ e.rect(0, 0, 100, 100), e.fill({ color: 16711680 }), e.stroke({
639
+ color: 16777215,
640
+ width: 1,
641
+ alignment: 0
642
+ }), e.moveTo(0, 0), e.lineTo(100, 100), e.moveTo(100, 0), e.lineTo(0, 100), e.stroke({
643
+ color: 16777215,
644
+ width: 2,
645
+ alignment: .5
646
+ }), Wn = S.getInstance().renderer.generateTexture(e), e.destroy();
647
+ }
648
+ return Wn;
649
+ }
650
+ function W(e) {
651
+ let t, n = e?.asset, r = n, i = e?.sheet;
652
+ if (n instanceof k) t = n;
653
+ else if (!i || i?.length === 0) C.cache.has(r) ? t = C.get(r) : C.get(r) ? t = C.get(r).texture : (c.error("Asset \"" + n + "\" not loaded into Pixi cache"), t = U());
654
+ else if (C.get(i)) {
655
+ let e = C.get(i), a = e.textures;
656
+ if (a !== void 0) if (a.hasOwnProperty(r)) t = a[r];
657
+ else if (e.linkedSheets !== void 0 && e.linkedSheets.length > 0) {
658
+ for (let n of e.linkedSheets) if (n.textures !== void 0 && n.textures.hasOwnProperty(r)) {
659
+ t = n.textures[r];
660
+ break;
661
+ }
662
+ t === void 0 && (c.error("Asset \"" + n + "\" not found inside spritesheet \"" + n + "' or any of its linked sheets"), t = U());
663
+ } else c.error("Asset \"" + n + "\" not found inside spritesheet \"" + i + "'"), t = U();
664
+ else c.error("Spritesheet \"" + i + "\" loaded but textures arent?!"), t = U();
665
+ } else return c.error("Spritesheet \"" + i + "\" not loaded into Pixi cache"), U();
666
+ return t || new Et().texture;
667
+ }
668
+ function G(e, t) {
669
+ let n = y(e.position, !1, e.x, e.y);
670
+ t.x = n.x, t.y = n.y;
671
+ }
672
+ function K(e, t) {
673
+ if (!e) return;
674
+ if (e.scale === void 0) {
675
+ if (e.scaleX === void 0 && e.scaleY === void 0) return;
676
+ e.scaleX === void 0 && (e.scaleX = 1), e.scaleY === void 0 && (e.scaleY = 1);
677
+ }
678
+ let n = y(e.scale, !1, e.scaleX, e.scaleY);
679
+ t.scale.set(n.x, n.y);
680
+ }
681
+ function Gn(e, t) {
682
+ if (e !== void 0) {
683
+ let n = y(e);
684
+ t.anchor.set(n.x, n.y);
685
+ }
686
+ }
687
+ function q(e, t) {
688
+ if (e !== void 0) {
689
+ let n = y(e);
690
+ t.pivot.set(n.x, n.y);
691
+ }
692
+ }
693
+ //#endregion
694
+ //#region src/display/AnimatedSprite.ts
695
+ var Kn = class e extends bt {
696
+ constructor(t) {
697
+ let n = t?.animations ?? {}, r = t?.animation ?? Object.keys(n)[0], i = n[r], a = t?.sheet, o = t?.texturePrefix || "", s = t?.zeroPad, c = t?.startIndex ?? 0;
698
+ super(e.generateTexturesFromProps(r, i, o, a, s, c), t?.autoUpdate !== !1), this.config = t, this.onAnimationChange = new p(), this.onAnimationStart = new p(), this.onAnimationStop = new p(), this.onAnimationLoop = new p(), this.onAnimationComplete = new p(), this.onAnimationFrameChange = new p(), this.defaultTexturePrefix = "", this._paused = !1, this._isReversed = !1, m(this), this.defaultSheet = a, this.defaultTexturePrefix = o, this.defaultZeroPad = s, this._generateAnimations(), this.currentAnimation = this.defaultAnimation = r, this.autoPlay = t?.autoPlay ?? !0, this.loop = t?.loop ?? !0, this.updateAnchor = t?.updateAnchor ?? !1, this.animationSpeed = this.defaultAnimationSpeed = t?.animationSpeed ?? 1, this.on("added", this._added);
699
+ }
700
+ get paused() {
701
+ return this._paused;
702
+ }
703
+ set paused(e) {
704
+ this._paused = e;
705
+ }
706
+ get speed() {
707
+ return this.animationSpeed;
708
+ }
709
+ set speed(e) {
710
+ this.animationSpeed = this.defaultAnimationSpeed = e;
711
+ }
712
+ get isReversed() {
713
+ return this._isReversed;
714
+ }
715
+ static generateTexturesFromProps(e, t, n = "", r = void 0, i, a) {
716
+ let o = [], s = "", c = t?.sheet ?? r;
717
+ if (t?.numFrames > 1) {
718
+ let r = t?.startIndex ?? a ?? 0;
719
+ for (let a = r; a < r + t?.numFrames; a++) s = `${n}${t?.texturePrefix ?? e}${Ut(a, t?.zeroPad ?? i)}`, o.push(W({
720
+ asset: s,
721
+ sheet: c
722
+ }));
723
+ } else s = `${n}${t?.texturePrefix ?? e}`, o.push(W({
724
+ asset: s,
725
+ sheet: c
726
+ }));
727
+ return o;
728
+ }
729
+ reverse() {
730
+ this._isReversed = !this._isReversed, this._isReversed ? this.setAnimation(`${this.currentAnimation}_reverse`) : this.setAnimation(this.currentAnimation.split("_reverse")[0]);
731
+ }
732
+ setAnimation(e, t = !0) {
733
+ if (!this._animations.has(e)) throw Error(`Animation ${e} does not exist`);
734
+ this.textures = this._animations.get(e), this.currentAnimation = e;
735
+ let n = this.config?.animations?.[e.split("_reverse")[0]]?.animationSpeed;
736
+ n ? this.animationSpeed = n : this.animationSpeed = this.defaultAnimationSpeed, this.onAnimationChange.emit(e), t && this.play();
737
+ }
738
+ play() {
739
+ super.play(), this.onAnimationStart?.emit();
740
+ }
741
+ stop() {
742
+ super.stop(), this.onAnimationStop?.emit();
743
+ }
744
+ nextAnimation() {
745
+ let e = lt(this._animations, this.currentAnimation) ?? ze(this._animations);
746
+ e && this.setAnimation(e[0]);
747
+ }
748
+ previousAnimation() {
749
+ let e = ht(this._animations, this.currentAnimation) ?? ke(this._animations);
750
+ e && this.setAnimation(e[0]);
751
+ }
752
+ update(e) {
753
+ this._paused || super.update(e);
754
+ }
755
+ _generateAnimations() {
756
+ this._animations = /* @__PURE__ */ new Map();
757
+ let t = this.config?.animations ?? {};
758
+ if (t) {
759
+ for (let [n, r] of Object.entries(t)) this._animations.set(n, e.generateTexturesFromProps(n, r, this.defaultTexturePrefix, this.defaultSheet, this.defaultZeroPad));
760
+ if (this.config?.reversible) for (let [n, r] of Object.entries(t)) {
761
+ let t = e.generateTexturesFromProps(n, r, this.defaultTexturePrefix, this.defaultSheet, this.defaultZeroPad);
762
+ t.reverse(), this._animations.set(`${n}_reverse`, t);
763
+ }
764
+ }
765
+ }
766
+ _added() {
767
+ this.onLoop = () => {
768
+ this.onAnimationLoop.emit();
769
+ }, this.onComplete = () => {
770
+ this.onAnimationComplete.emit();
771
+ }, this.onFrameChange = () => {
772
+ this.onAnimationFrameChange.emit();
773
+ }, this.autoPlay && this.play();
774
+ }
775
+ }, qn = class extends xt {
776
+ constructor(e) {
777
+ return super({ isRenderGroup: !0 }), this.config = e, this.onZoom = new p(), this.onZoomComplete = new p(), this.minX = 0, this.minY = 0, this._zooming = !1, this._zoomLerp = .1, this._targetPivot = new D(0, 0), this._targetScale = new D(1, 1), this._lerp = 0, this._target = null, this._followOffset = new D(0, 0), m(this), e && (this.container = e.container, this.addChild(this.container), e.minX && (this.minX = e.minX), e.maxX && (this.maxX = e.maxX), e.minY && (this.minY = e.minY), this.viewportWidth = e.viewportWidth ?? this.app.size.width, this.viewportHeight = e.viewportHeight ?? this.app.size.width, this.worldWidth = e.worldWidth ?? this.viewportWidth, this.worldHeight = e.worldHeight ?? this.viewportHeight, this.maxX = e.maxX ?? this.worldWidth - this.viewportWidth, this.maxY = e.maxY ?? this.worldHeight - this.viewportHeight), this._targetPivot.set(this.viewportWidth * .5, this.viewportHeight * .5), e.target && (this.target = e.target), this._lerp = 1, this.update(), e.lerp && (this.lerp = e.lerp), this;
302
778
  }
303
779
  get zooming() {
304
780
  return this._zooming;
@@ -329,10 +805,10 @@ var jn = class extends w {
329
805
  return this._followOffset;
330
806
  }
331
807
  set followOffset(e) {
332
- this._followOffset = g(e, !0);
808
+ this._followOffset = y(e, !0);
333
809
  }
334
810
  get app() {
335
- return C.getInstance();
811
+ return S.getInstance();
336
812
  }
337
813
  follow(e, t) {
338
814
  t ||= {
@@ -369,54 +845,1551 @@ var jn = class extends w {
369
845
  } else this.pivot.set(this._targetPivot.x, this._targetPivot.y);
370
846
  this.position.set(this.viewportWidth / 2, this.viewportHeight / 2);
371
847
  }
372
- }, Fn = class {
848
+ }, Jn = class {
373
849
  constructor(e, t) {
374
- this.camera = e, this.interactiveArea = t, this.dragging = !1, this.previousPointerPosition = null, y(this), this.camera = e, this.interactiveArea = t, this.app.keyboard.onKeyDown().connect(this.handleKeyDown), this.interactiveArea.on("pointerdown", this.onPointerDown.bind(this)), this.interactiveArea.on("pointermove", this.onPointerMove.bind(this)), this.app.stage.on("pointerup", this.onPointerUp.bind(this)), this.app.stage.on("pointerupoutside", this.onPointerUp.bind(this)), this.interactiveArea.on("touchstart", this.onPointerDown.bind(this)), this.interactiveArea.on("touchmove", this.onPointerMove.bind(this)), this.interactiveArea.on("touchend", this.onPointerUp.bind(this));
850
+ this.camera = e, this.interactiveArea = t, this.dragging = !1, this.previousPointerPosition = null, m(this), this.camera = e, this.interactiveArea = t, this.app.keyboard.onKeyDown().connect(this.handleKeyDown), this.interactiveArea.on("pointerdown", this.onPointerDown.bind(this)), this.interactiveArea.on("pointermove", this.onPointerMove.bind(this)), this.app.stage.on("pointerup", this.onPointerUp.bind(this)), this.app.stage.on("pointerupoutside", this.onPointerUp.bind(this)), this.interactiveArea.on("touchstart", this.onPointerDown.bind(this)), this.interactiveArea.on("touchmove", this.onPointerMove.bind(this)), this.interactiveArea.on("touchend", this.onPointerUp.bind(this));
851
+ }
852
+ get app() {
853
+ return S.getInstance();
854
+ }
855
+ destroy() {
856
+ this.interactiveArea.removeAllListeners(), this.app.stage.off("pointerup", this.onPointerUp.bind(this)), this.app.stage.off("pointerupoutside", this.onPointerUp.bind(this));
857
+ }
858
+ handleKeyDown(e) {
859
+ let t = 1.1;
860
+ switch (e.event.key) {
861
+ case "ArrowUp":
862
+ this.camera.pan(0, -10);
863
+ break;
864
+ case "ArrowDown":
865
+ this.camera.pan(0, 10);
866
+ break;
867
+ case "ArrowLeft":
868
+ this.camera.pan(-10, 0);
869
+ break;
870
+ case "ArrowRight":
871
+ this.camera.pan(10, 0);
872
+ break;
873
+ case "+":
874
+ this.camera.zoom(t);
875
+ break;
876
+ case "-":
877
+ this.camera.zoom(1 / t);
878
+ break;
879
+ }
880
+ }
881
+ onPointerDown(e) {
882
+ this.dragging = !0, this.previousPointerPosition = this.getEventPosition(e);
883
+ }
884
+ onPointerMove(e) {
885
+ if (!this.dragging || !this.previousPointerPosition) return;
886
+ let t = this.getEventPosition(e), n = t.x - this.previousPointerPosition.x, r = t.y - this.previousPointerPosition.y;
887
+ this.camera.pan(n, r), this.previousPointerPosition = t;
888
+ }
889
+ onPointerUp() {
890
+ this.dragging = !1, this.previousPointerPosition = null;
891
+ }
892
+ getEventPosition(e) {
893
+ return e instanceof TouchEvent ? new D(e.touches[0].clientX, e.touches[0].clientY) : new D(e.clientX, e.clientY);
894
+ }
895
+ }, Yn = h(v()), Xn = class extends Yn {
896
+ get app() {
897
+ return S.getInstance();
898
+ }
899
+ get animationNames() {
900
+ return this.spine.state.data.skeletonData.animations.map((e) => e.name);
901
+ }
902
+ get currentEntry() {
903
+ return this.spine.state.getCurrent(0);
904
+ }
905
+ get elapsedAnimationTime() {
906
+ return this.currentEntry ? this.currentEntry.trackTime : -1;
907
+ }
908
+ constructor(e) {
909
+ super(), this.onAnimationComplete = new p(), this.onAnimationStart = new p(), this.onAnimationInterrupt = new p(), this.onAnimationDispose = new p(), this.onAnimationEnd = new p(), this.onAnimationEvent = new p(), this.onPaused = new p(), this.onResumed = new p(), m(this);
910
+ let t = e?.data, n = "";
911
+ if (typeof t == "string") {
912
+ let e = t.slice(-5);
913
+ e !== ".json" && e !== ".skel" ? e = ".json" : t = t.substring(0, t.length - 5), n = {
914
+ skeleton: t + e,
915
+ atlas: t + ".atlas"
916
+ };
917
+ }
918
+ this.spine = window.Spine.from(n), this.add.existing(this.spine), e && (e.autoUpdate !== void 0 && (this.spine.autoUpdate = e.autoUpdate), e.animationName && this.setAnimation(e.animationName, e.loop, e.trackIndex ?? 0)), this.addSignalConnection(this.app.actions("toggle_pause").connect(this.togglePause)), e?.paused && this.pause(), this._stateListener = {
919
+ start: this._handleAnimationStart,
920
+ interrupt: this._handleAnimationInterrupt,
921
+ dispose: this._handleAnimationDispose,
922
+ end: this._handleAnimationEnd,
923
+ event: this._handleAnimationEvent,
924
+ complete: this._handleAnimationComplete
925
+ }, this.spine.state.addListener(this._stateListener);
926
+ }
927
+ destroy() {
928
+ this.spine.state.removeListener(this._stateListener), super.destroy();
929
+ }
930
+ getCurrentAnimation(e = 0) {
931
+ return this.spine.state.getCurrent(e)?.animation?.name || "";
932
+ }
933
+ setAnimation(e, t = !1, n = 0) {
934
+ this.spine.state.setAnimation(n, e, t);
935
+ }
936
+ pause() {
937
+ this.paused = !0, this.spine.autoUpdate = !1, this.currentEntry && (this.currentEntry.timeScale = 0), this.onPaused.emit(this.currentEntry);
938
+ }
939
+ resume() {
940
+ this.paused = !1, this.spine.autoUpdate = !0, this.currentEntry && (this.currentEntry.timeScale = 1), this.onResumed.emit(this.currentEntry);
941
+ }
942
+ togglePause() {
943
+ this.paused ? this.resume() : this.pause();
944
+ }
945
+ _handleAnimationComplete(e) {
946
+ this.onAnimationComplete.emit(e);
947
+ }
948
+ _handleAnimationStart(e) {
949
+ this.onAnimationStart.emit(e);
950
+ }
951
+ _handleAnimationInterrupt(e) {
952
+ this.onAnimationInterrupt.emit(e);
953
+ }
954
+ _handleAnimationDispose(e) {
955
+ this.onAnimationDispose.emit(e);
956
+ }
957
+ _handleAnimationEnd(e) {
958
+ this.onAnimationEnd.emit(e);
959
+ }
960
+ _handleAnimationEvent(e, t) {
961
+ this.onAnimationEvent.emit(e, t);
962
+ }
963
+ };
964
+ //#endregion
965
+ //#region src/mixins/focus.ts
966
+ function J(e) {
967
+ return class extends e {
968
+ constructor(...e) {
969
+ super(...e), this.isFocused = !1, this.isKeyDown = !1, this.focusEnabled = !0, this.tabIndex = 0, this.accessible = !1, this.accessibleType = "button", this.accessibleTitle = "Focusable", this.accessibleHint = "Press enter to focus", this.accessiblePointerEvents = "auto", this.accessibleChildren = !0, this.onFocus = new p(), this.onFocusIn = new p(), this.onFocusOut = new p(), this.onBlur = new p(), this._eventsDisabled = !1, this.eventMode = "static", this.on("mouseover", this._onMouseOver), this.on("mousedown", this._onMouseDown), this.on("click", this._handleClick), this.on("tap", this._handleClick);
970
+ }
971
+ get app() {
972
+ return S.getInstance();
973
+ }
974
+ destroy(e) {
975
+ this.off("mouseover", this._onMouseOver), this.off("mousedown", this._onMouseDown), this.off("click", this._handleClick), this.off("tap", this._handleClick), super.destroy(e);
976
+ }
977
+ focusIn() {
978
+ this.app.focus.active && this.emit("pointerover", { type: "pointerover" });
979
+ }
980
+ blur() {
981
+ this.isKeyDown || window.removeEventListener("keyup", this._handleKeyUp.bind(this));
982
+ }
983
+ focusOut() {
984
+ this.isKeyDown || window.removeEventListener("keyup", this._handleKeyUp.bind(this)), this.app.focus.active && this.emit("pointerout", { type: "pointerout" });
985
+ }
986
+ click() {}
987
+ getFocusPosition() {
988
+ return null;
989
+ }
990
+ getFocusArea() {
991
+ return this.getBounds();
992
+ }
993
+ getFocusSize() {
994
+ return [this.getFocusArea().width, this.getFocusArea().height];
995
+ }
996
+ _onMouseOver(e) {
997
+ this.app.focus.setFocus(this);
998
+ }
999
+ _onMouseDown(e) {
1000
+ this._maybeEmit("pointerdown", e);
1001
+ }
1002
+ _handleClick(e) {
1003
+ this._maybeEmit("click", e), this.click();
1004
+ }
1005
+ _handleKeyUp(e) {}
1006
+ _maybeEmit(e, t) {
1007
+ this._eventsDisabled || t.type || (this._eventsDisabled = !0, this.emit(e, { type: e }), this._eventsDisabled = !1);
1008
+ }
1009
+ };
1010
+ }
1011
+ J.INITTED = !1;
1012
+ //#endregion
1013
+ //#region src/mixins/interaction.ts
1014
+ function Zn(e) {
1015
+ return class extends e {
1016
+ constructor(...e) {
1017
+ super(...e), this._signals = /* @__PURE__ */ new Map(), this._emitSignal = this._emitSignal.bind(this), this.eventMode = "static";
1018
+ }
1019
+ onInteraction(e) {
1020
+ if (!this._signals.has(e)) {
1021
+ let t = new p();
1022
+ this._signals.set(e, t), this.on(e, this._emitSignal);
1023
+ }
1024
+ return this._signals.get(e);
1025
+ }
1026
+ destroy(e) {
1027
+ for (let e of this._signals.keys()) this.off(e, this._emitSignal);
1028
+ this._signals.clear(), super.destroy(e);
1029
+ }
1030
+ _emitSignal(e) {
1031
+ let t = e.type, n = this._signals.get(t);
1032
+ n && n.emit(e);
1033
+ }
1034
+ };
1035
+ }
1036
+ //#endregion
1037
+ //#region src/ui/Button.ts
1038
+ var Qn = [
1039
+ "textures",
1040
+ "sounds",
1041
+ "actions",
1042
+ "cursor",
1043
+ "disabledCursor",
1044
+ "sheet",
1045
+ "enabled",
1046
+ "layout",
1047
+ "textLabel"
1048
+ ], $n = J(Zn(h(v()))), er = class extends $n {
1049
+ get textLabel() {
1050
+ return this._textLabel;
1051
+ }
1052
+ constructor(e) {
1053
+ super(), this.onDown = new p(), this.onUp = new p(), this.onUpOutside = new p(), this.onOut = new p(), this.onOver = new p(), this.onClick = new p(), this.onEnabled = new p(), this.onDisabled = new p(), this.onKeyboardEvent = new p(), this.onDestroy = new p(), this._isDownCallbacks = /* @__PURE__ */ new Map(), this._isDownListenerAdded = !1, m(this), this.config = Object.assign({
1054
+ id: "button",
1055
+ textures: { default: "" },
1056
+ sheet: void 0,
1057
+ enabled: !0,
1058
+ cursor: "default",
1059
+ disabledCursor: "not-allowed"
1060
+ }, e), this.id = this.config.id, e.layout === void 0 ? this.layout = !1 : this.layout = e.layout, this.view = this.add.sprite({
1061
+ asset: this.config.textures.default,
1062
+ sheet: this.config.sheet ?? void 0
1063
+ }), this.cursor = this.config.cursor, this.enabled = e.enabled !== !1, this.layout?.style.transformOrigin !== "top left" && (this.layout = { transformOrigin: "top left" }, this.app.renderer.layout && this.app.renderer.layout.update(this)), this.config.textLabel && this.addLabel(this.config.textLabel), this.addSignalConnection(this.onInteraction("pointerover").connect(this.handlePointerOver, -1), this.onInteraction("pointerout").connect(this.handlePointerOut, -1), this.onInteraction("pointerup").connect(this.handlePointerUp, -1), this.onInteraction("click").connect(this.handleClick, -1), this.onInteraction("tap").connect(this.handleClick, -1), this.onInteraction("pointerdown").connect(this.handlePointerDown, -1)), this.on("removed", this._resetPressState);
1064
+ }
1065
+ set enabled(e) {
1066
+ this._enabled !== e && (this._enabled = e, this.cursor = this._enabled ? this.config.cursor : this.config.disabledCursor, this.focusEnabled = e, this._enabled ? (this.view.texture = this.make.texture({
1067
+ asset: this.config.textures.default,
1068
+ sheet: this.config.sheet ?? void 0
1069
+ }), this.onEnabled.emit()) : (this._resetPressState(), this.view.texture = this.make.texture({
1070
+ asset: this.config.textures.disabled || this.config.textures.default,
1071
+ sheet: this.config.sheet ?? void 0
1072
+ }), this.onDisabled.emit()));
1073
+ }
1074
+ _resetPressState() {
1075
+ window.removeEventListener("pointerup", this.handlePointerUpOutside), this.off("pointerupoutside", this.handlePointerUpOutside), this.isDown = !1, this._pointerId = void 0;
1076
+ }
1077
+ addLabel(e) {
1078
+ if (e instanceof O || e instanceof St || e instanceof w) e.anchor.set(.5, .5), this._textLabel = this.add.existing(e), this._textLabel.layout = !1;
1079
+ else switch (e.anchor = .5, e.type) {
1080
+ case "bitmap":
1081
+ this._textLabel = this.add.bitmapText({
1082
+ ...e,
1083
+ layout: !1
1084
+ });
1085
+ break;
1086
+ case "html":
1087
+ this._textLabel = this.add.htmlText({
1088
+ ...e,
1089
+ layout: !1
1090
+ });
1091
+ break;
1092
+ default:
1093
+ this._textLabel = this.add.text({
1094
+ ...e,
1095
+ layout: !1
1096
+ });
1097
+ break;
1098
+ }
1099
+ return this.positionLabel(), this._textLabel;
1100
+ }
1101
+ positionLabel() {
1102
+ this._textLabel && this._textLabel.position.set(this.view.width * .5, this.view.height * .5);
1103
+ }
1104
+ get enabled() {
1105
+ return this._enabled;
1106
+ }
1107
+ get app() {
1108
+ return S.getInstance();
1109
+ }
1110
+ destroy(e) {
1111
+ this.onDestroy.emit(), this._resetPressState(), this._isDownListenerAdded &&= (this.app.ticker.remove(this._handleIsDownCallbacks), !1), super.destroy(e);
1112
+ }
1113
+ focusOut() {
1114
+ super.focusOut(), this.isDown = !1, this.isOver = !1;
1115
+ }
1116
+ blur() {
1117
+ super.blur(), this.isDown = !1, this.isOver = !1;
1118
+ }
1119
+ getFocusArea() {
1120
+ return this.view.getBounds().clone();
1121
+ }
1122
+ addIsDownCallback(e, t) {
1123
+ this._isDownCallbacks.set(e, t), this._checkIsDownCallbacks();
1124
+ }
1125
+ removeIsDownCallback(e) {
1126
+ this._isDownCallbacks.delete(e), this._checkIsDownCallbacks();
1127
+ }
1128
+ setTexture(e, t) {
1129
+ this.config.textures[e] = t, e === "default" && (this.view.texture = this.make.texture({
1130
+ asset: this.config.textures.default,
1131
+ sheet: this.config.sheet
1132
+ })), this.positionLabel();
1133
+ }
1134
+ handlePointerOver() {
1135
+ this._enabled && (this.isOver ||= !0, !this.isDown && (this.view.texture = this.make.texture({
1136
+ asset: this.config.textures.hover || this.config.textures.default,
1137
+ sheet: this.config.sheet
1138
+ }), this.onOver.emit(), this.config.sounds?.hover && this.app.audio.play(this.config.sounds.hover, "sfx"), this.config.actions?.hover && this._doAction(this.config.actions.hover)));
1139
+ }
1140
+ handlePointerOut() {
1141
+ this.isOver = !1, this._enabled && (this.isDown || (this.view.texture = this.make.texture({
1142
+ asset: this.config.textures.default,
1143
+ sheet: this.config.sheet
1144
+ }), this.config.sounds?.out && this.app.audio.play(this.config.sounds.out, "sfx"), this.onOut.emit()));
1145
+ }
1146
+ handlePointerDown(e) {
1147
+ !this._enabled && !this.isKeyDown || !this.isDown && this._pointerId === void 0 && (this._pointerId = e.pointerId, window.removeEventListener("pointerup", this.handlePointerUpOutside), this.off("pointerupoutside", this.handlePointerUpOutside), window.addEventListener("pointerup", this.handlePointerUpOutside), this.on("pointerupoutside", this.handlePointerUpOutside), this.isDown = !0, this.view.texture = this.make.texture({
1148
+ asset: this.config.textures.active || this.config.textures.hover || this.config.textures.default,
1149
+ sheet: this.config.sheet
1150
+ }), this.onDown.emit(), this.config.sounds?.down && this.app.audio.play(this.config.sounds.down, "sfx"), this.config.actions?.down && this._doAction(this.config.actions.down));
1151
+ }
1152
+ handlePointerUp(e) {
1153
+ !this._enabled || !this.isOver || e.pointerId !== this._pointerId || (window.removeEventListener("pointerup", this.handlePointerUpOutside), this.view.texture = this.make.texture({
1154
+ asset: this.config.textures.default,
1155
+ sheet: this.config.sheet
1156
+ }), this.onUp.emit(), this._pointerId = void 0);
1157
+ }
1158
+ handleClick(e) {
1159
+ this._enabled && (e?.pointerId !== void 0 && !this.isDown || e !== void 0 && e === this._lastClickEvent || (this._lastClickEvent = e, this.isDown = !1, this.onClick.emit(), this.config.sounds?.click && this.app.audio.play(this.config.sounds.click, "sfx"), this.config.actions?.click && this._doAction(this.config.actions.click)));
1160
+ }
1161
+ handlePointerUpOutside(e) {
1162
+ if (e.pointerId !== this._pointerId) return;
1163
+ let t = this._enabled;
1164
+ this._resetPressState(), this.isOver = !1, t && (this.view.texture = this.make.texture({
1165
+ asset: this.config.textures.default,
1166
+ sheet: this.config.sheet
1167
+ }), this.onUpOutside.emit());
1168
+ }
1169
+ _doAction(e) {
1170
+ typeof e == "function" ? e() : (e.data.button || (e.data.button = this), this.app.action(e.id, e.data));
1171
+ }
1172
+ _checkIsDownCallbacks() {
1173
+ !this._isDownListenerAdded && this._isDownCallbacks.size > 0 ? (this._isDownListenerAdded = !0, this.app.ticker.add(this._handleIsDownCallbacks)) : this._isDownListenerAdded && this._isDownCallbacks.size === 0 && (this.app.ticker.remove(this._handleIsDownCallbacks), this._isDownListenerAdded = !1);
1174
+ }
1175
+ _handleIsDownCallbacks() {
1176
+ this.isDown && this._isDownCallbacks.forEach((e) => {
1177
+ e();
1178
+ });
1179
+ }
1180
+ }, tr = h(v());
1181
+ function nr(e) {
1182
+ return e instanceof O || e instanceof w;
1183
+ }
1184
+ var rr = [
1185
+ "bindTo",
1186
+ "bindToAppSize",
1187
+ "autoLayoutChildren",
1188
+ "debug"
1189
+ ], ir = class extends tr {
1190
+ constructor(e = {}) {
1191
+ if (super(), this.onLayoutComplete = new p(), this._debugGraphics = null, this._debugLabel = null, !this.app.config.useLayout) throw Error("You must set useLayout to true in your app config to use FlexContainer");
1192
+ m(this), this.config = {
1193
+ autoLayoutChildren: !0,
1194
+ ...e
1195
+ }, this.layout = this.createLayout(e), this.on("added", this.handleAdded), this.on("childAdded", this.handleChildAdded), this.on("childRemoved", this.handleChildRemoved), this.config.bindToAppSize && this.app.onResize.connect(this.handleResize), this.config.bindTo && "on" in this.config.bindTo && this.config.bindTo.on("layout", this.handleBindToResize);
1196
+ }
1197
+ createLayout(e) {
1198
+ e?.layout === !0 && (e.layout = {});
1199
+ let t = { ...e?.layout ?? {} };
1200
+ return this.config.bindToAppSize ? (t.width = this.app.size.width, t.height = this.app.size.height) : this.config.bindTo && (t.width = this.config.bindTo.width, t.height = this.config.bindTo.height), t;
1201
+ }
1202
+ handleAdded() {
1203
+ this.updateLayout();
1204
+ }
1205
+ _updateLayout() {
1206
+ this.app.ticker.addOnce(this.updateLayout);
1207
+ }
1208
+ handleChildAdded(e) {
1209
+ this.config.autoLayoutChildren && (e.layout ? nr(e) && !e.layout?.style?.isLeaf && (e.layout = { isLeaf: !0 }) : e.layout = { isLeaf: !0 }), _.childAdded(e), e.on("layout", this._updateLayout), this._updateLayout();
1210
+ }
1211
+ handleChildRemoved(e) {
1212
+ e.off("layout", this._updateLayout), _.childRemoved(e), this._updateLayout();
1213
+ }
1214
+ handleResize() {
1215
+ this.config.bindToAppSize && (this.layout = {
1216
+ width: this.app.size.width,
1217
+ height: this.app.size.height
1218
+ }), this._updateLayout();
1219
+ }
1220
+ handleBindToResize() {
1221
+ this.config.bindTo && (this.layout = {
1222
+ width: this.config.bindTo.width,
1223
+ height: this.config.bindTo.height
1224
+ }, this._updateLayout());
1225
+ }
1226
+ updateLayout() {
1227
+ this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this.onLayoutComplete.emit(), this.config.debug && this.drawDebug());
1228
+ }
1229
+ get app() {
1230
+ return S.getInstance();
1231
+ }
1232
+ configure(e) {
1233
+ this.layout = e, this._updateLayout();
1234
+ }
1235
+ get gap() {
1236
+ return this.layout?.style?.gap ?? 0;
1237
+ }
1238
+ set gap(e) {
1239
+ this.layout = { gap: e }, this._updateLayout();
1240
+ }
1241
+ get flexWrap() {
1242
+ return this.layout?.style?.flexWrap;
1243
+ }
1244
+ set flexWrap(e) {
1245
+ this.layout = { flexWrap: e }, this._updateLayout();
1246
+ }
1247
+ get flexDirection() {
1248
+ return this.layout?.style?.flexDirection;
1249
+ }
1250
+ set flexDirection(e) {
1251
+ this.layout = { flexDirection: e }, this._updateLayout();
1252
+ }
1253
+ get alignItems() {
1254
+ return this.layout?.style?.alignItems;
1255
+ }
1256
+ set alignItems(e) {
1257
+ this.layout = { alignItems: e }, this._updateLayout();
1258
+ }
1259
+ get justifyContent() {
1260
+ return this.layout?.style?.justifyContent;
1261
+ }
1262
+ set justifyContent(e) {
1263
+ this.layout = { justifyContent: e }, this._updateLayout();
1264
+ }
1265
+ get size() {
1266
+ return {
1267
+ width: this.layout?.style?.width,
1268
+ height: this.layout?.style?.height
1269
+ };
1270
+ }
1271
+ set size(e) {
1272
+ Array.isArray(e) && (e = {
1273
+ width: e[0],
1274
+ height: e[1]
1275
+ }), (typeof e == "number" || typeof e == "string") && (e = {
1276
+ width: e,
1277
+ height: e
1278
+ }), this.layout = { ...e }, this._updateLayout();
1279
+ }
1280
+ get layoutWidth() {
1281
+ return this.layout?.style?.width;
1282
+ }
1283
+ set layoutWidth(e) {
1284
+ this.layout = { width: e }, this._updateLayout();
1285
+ }
1286
+ get layoutHeight() {
1287
+ return this.layout?.style?.height;
1288
+ }
1289
+ set layoutHeight(e) {
1290
+ this.layout = { height: e }, this._updateLayout();
1291
+ }
1292
+ get padding() {
1293
+ return this.layout?.style?.padding;
1294
+ }
1295
+ set padding(e) {
1296
+ this.layout = { padding: e }, this._updateLayout();
1297
+ }
1298
+ get paddingTop() {
1299
+ return this.layout?.style?.paddingTop;
1300
+ }
1301
+ set paddingTop(e) {
1302
+ this.layout = { paddingTop: e }, this._updateLayout();
1303
+ }
1304
+ get paddingRight() {
1305
+ return this.layout?.style?.paddingRight;
1306
+ }
1307
+ set paddingRight(e) {
1308
+ this.layout = { paddingRight: e }, this._updateLayout();
1309
+ }
1310
+ get paddingBottom() {
1311
+ return this.layout?.style?.paddingBottom;
1312
+ }
1313
+ set paddingBottom(e) {
1314
+ this.layout = { paddingBottom: e }, this._updateLayout();
1315
+ }
1316
+ get paddingLeft() {
1317
+ return this.layout?.style?.paddingLeft;
1318
+ }
1319
+ set paddingLeft(e) {
1320
+ this.layout = { paddingLeft: e }, this._updateLayout();
1321
+ }
1322
+ get margin() {
1323
+ return this.layout?.style?.margin;
1324
+ }
1325
+ set margin(e) {
1326
+ this.layout = { margin: e }, this._updateLayout();
1327
+ }
1328
+ get marginTop() {
1329
+ return this.layout?.style?.marginTop;
1330
+ }
1331
+ set marginTop(e) {
1332
+ this.layout = { marginTop: e }, this._updateLayout();
1333
+ }
1334
+ get marginRight() {
1335
+ return this.layout?.style?.marginRight;
1336
+ }
1337
+ set marginRight(e) {
1338
+ this.layout = { marginRight: e }, this._updateLayout();
1339
+ }
1340
+ get marginBottom() {
1341
+ return this.layout?.style?.marginBottom;
1342
+ }
1343
+ set marginBottom(e) {
1344
+ this.layout = { marginBottom: e }, this._updateLayout();
1345
+ }
1346
+ get marginLeft() {
1347
+ return this.layout?.style?.marginLeft;
1348
+ }
1349
+ set marginLeft(e) {
1350
+ this.layout = { marginLeft: e }, this._updateLayout();
1351
+ }
1352
+ get debug() {
1353
+ return this.config.debug ?? !1;
1354
+ }
1355
+ set debug(e) {
1356
+ this.config.debug = e, e ? (P(`FlexContainer:${this.uid}`, this.label || "FlexContainer", j.bounds), this.drawDebug()) : (F(`FlexContainer:${this.uid}`), this._debugGraphics && this._debugGraphics.clear(), this._debugLabel && (this._debugLabel.visible = !1));
1357
+ }
1358
+ drawDebug() {
1359
+ (!this._debugGraphics || this._debugGraphics.parent !== this) && (this._debugGraphics ||= Ft(`${this.label ?? "FlexContainer"}:debug`), this.addChild(this._debugGraphics), this._debugGraphics.layout = !1), (!this._debugLabel || this._debugLabel.parent !== this) && (this._debugLabel ||= N(this.label || "FlexContainer", j.bounds), this.addChild(this._debugLabel), this._debugLabel.layout = !1), this._debugLabel.text = this.label || "FlexContainer", this._debugLabel.visible = !0, this.setChildIndex(this._debugGraphics, this.children.length - 1), this.setChildIndex(this._debugLabel, this.children.length - 1), this._debugGraphics.clear();
1360
+ let e = this.layout?.computedLayout;
1361
+ if (!e) return;
1362
+ let t = e.width, n = e.height, r = this.layout?.style?.flexDirection ?? "row", i = this.layout?.style?.gap ?? 0;
1363
+ this._debugGraphics.rect(0, 0, t, n).stroke({
1364
+ width: 1,
1365
+ color: j.bounds,
1366
+ alpha: M.stroke,
1367
+ pixelLine: !0
1368
+ });
1369
+ let a = this.layout?.style?.paddingTop ?? 0, o = this.layout?.style?.paddingRight ?? 0, s = this.layout?.style?.paddingBottom ?? 0, c = this.layout?.style?.paddingLeft ?? 0;
1370
+ a > 0 && this._debugGraphics.rect(0, 0, t, a).fill({
1371
+ color: j.outerBounds,
1372
+ alpha: M.fill
1373
+ }), s > 0 && this._debugGraphics.rect(0, n - s, t, s).fill({
1374
+ color: j.outerBounds,
1375
+ alpha: M.fill
1376
+ }), c > 0 && this._debugGraphics.rect(0, a, c, n - a - s).fill({
1377
+ color: j.outerBounds,
1378
+ alpha: M.fill
1379
+ }), o > 0 && this._debugGraphics.rect(t - o, a, o, n - a - s).fill({
1380
+ color: j.outerBounds,
1381
+ alpha: M.fill
1382
+ });
1383
+ let l = Math.min(t, n, 40), u = t / 2, d = n / 2, f = r === "row" || r === "row-reverse";
1384
+ if (f) {
1385
+ let e = r === "row" ? 1 : -1, t = u - e * l / 2, n = u + e * l / 2;
1386
+ this._debugGraphics.moveTo(t, d).lineTo(n, d).moveTo(n, d).lineTo(n - e * 6, d - 4).moveTo(n, d).lineTo(n - e * 6, d + 4).stroke({
1387
+ width: 1,
1388
+ color: j.direction,
1389
+ alpha: .8,
1390
+ pixelLine: !0
1391
+ });
1392
+ } else {
1393
+ let e = r === "column" ? 1 : -1, t = d - e * l / 2, n = d + e * l / 2;
1394
+ this._debugGraphics.moveTo(u, t).lineTo(u, n).moveTo(u, n).lineTo(u - 4, n - e * 6).moveTo(u, n).lineTo(u + 4, n - e * 6).stroke({
1395
+ width: 1,
1396
+ color: j.direction,
1397
+ alpha: .8,
1398
+ pixelLine: !0
1399
+ });
1400
+ }
1401
+ if (i > 0) for (let e = 0; e < this.children.length - 1; e++) {
1402
+ let r = this.children[e];
1403
+ if (r === this._debugGraphics || r === this._debugLabel || !r.layout?.computedLayout) continue;
1404
+ let a = r.layout.computedLayout;
1405
+ if (f) {
1406
+ let e = a.left + a.width;
1407
+ this._debugGraphics.rect(e, 0, i, n).fill({
1408
+ color: j.gap,
1409
+ alpha: M.fill
1410
+ });
1411
+ } else {
1412
+ let e = a.top + a.height;
1413
+ this._debugGraphics.rect(0, e, t, i).fill({
1414
+ color: j.gap,
1415
+ alpha: M.fill
1416
+ });
1417
+ }
1418
+ }
1419
+ for (let e of this.children) {
1420
+ if (e === this._debugGraphics || e === this._debugLabel || !e.layout?.computedLayout) continue;
1421
+ let t = e.layout.computedLayout;
1422
+ this._debugGraphics.rect(t.left, t.top, t.width, t.height).stroke({
1423
+ width: 1,
1424
+ color: j.innerBounds,
1425
+ alpha: .4,
1426
+ pixelLine: !0
1427
+ });
1428
+ }
1429
+ this._debugLabel.position.set(2, 2);
1430
+ }
1431
+ destroy() {
1432
+ this.config.debug && F(`FlexContainer:${this.uid}`), this._debugGraphics &&= (this._debugGraphics.destroy(), null), this._debugLabel &&= (this._debugLabel.destroy(), null), this.off("added", this.handleAdded), this.off("childAdded", this.handleChildAdded), this.off("childRemoved", this.handleChildRemoved), this.config.bindToAppSize && this.app.onResize.disconnect(this.handleResize), this.config.bindTo && "off" in this.config.bindTo && this.config.bindTo.off("layout", this.handleBindToResize), super.destroy();
1433
+ }
1434
+ }, Y = {
1435
+ type: "info",
1436
+ duration: 3e3,
1437
+ width: 300,
1438
+ height: 80,
1439
+ backgroundColor: 0,
1440
+ backgroundAlpha: .8,
1441
+ cornerRadius: 0,
1442
+ padding: 10,
1443
+ autoClose: !0,
1444
+ textAlign: "center",
1445
+ verticalAlign: "middle",
1446
+ colorBarWidth: 6,
1447
+ shadow: {
1448
+ color: 0,
1449
+ alpha: .2,
1450
+ offset: {
1451
+ x: 1,
1452
+ y: 3
1453
+ }
1454
+ },
1455
+ closeButton: {
1456
+ show: !1,
1457
+ position: "top right",
1458
+ size: 12,
1459
+ offset: 4
1460
+ },
1461
+ style: {
1462
+ fill: 16777215,
1463
+ fontSize: 16,
1464
+ wordWrap: !0
1465
+ },
1466
+ textColors: {
1467
+ info: 3447003,
1468
+ success: 3066993,
1469
+ warning: 15844367,
1470
+ error: 15158332
1471
+ }
1472
+ }, ar = class extends h(_) {
1473
+ set toaster(e) {
1474
+ this._toaster = e;
1475
+ }
1476
+ get toaster() {
1477
+ return this._toaster;
1478
+ }
1479
+ set text(e) {
1480
+ this.textDisplay.text = e, this.alignText();
1481
+ }
1482
+ constructor(e = {}) {
1483
+ super(), this.onToastClosed = new p(), this.isHiding = !1, this.config = {
1484
+ ...Y,
1485
+ ...e
1486
+ }, this.initialize();
1487
+ }
1488
+ initialize() {
1489
+ if (this.view = this.add.container(), this.config.shadow && (this.shadow = this.view.add.graphics().roundRect(this.config.shadow.offset?.x ?? 4, this.config.shadow.offset?.y ?? 4, this.config.width, this.config.height, this.config.cornerRadius).fill({
1490
+ color: this.config.shadow.color ?? 0,
1491
+ alpha: this.config.shadow.alpha ?? .2
1492
+ })), this.background = this.view.add.graphics().roundRect(0, 0, this.config.width, this.config.height, this.config.cornerRadius).fill({
1493
+ color: this.config.backgroundColor,
1494
+ alpha: this.config.backgroundAlpha
1495
+ }), this.config.type) {
1496
+ let e = new E().roundRect(0, 0, this.config.width, this.config.height, this.config.cornerRadius).fill({ color: 16777215 }), t = this.view.add.graphics().rect(0, 0, this.config.colorBarWidth, this.config.height).fill({ color: this.config.textColors[this.config.type] });
1497
+ t.mask = e, this.view.addChild(e), this.view.addChild(t);
1498
+ }
1499
+ this.config.closeButton?.show && this.addCloseButton();
1500
+ let e = this.config.type ? this.config.colorBarWidth + this.config.padding : this.config.padding, t = this.config.closeButton?.show && this.config.closeButton.position === "top right" ? this.config.closeButton.size + this.config.closeButton.offset * 2 : this.config.padding;
1501
+ this.textDisplay = this.view.add.text({
1502
+ text: this.config.message,
1503
+ style: {
1504
+ ...Y.style,
1505
+ ...this.config.style,
1506
+ wordWrapWidth: this.config.style?.wordWrapWidth ?? this.config.width - e - t
1507
+ },
1508
+ x: e,
1509
+ y: this.config.padding
1510
+ }), this.alignText(), this.view.pivot.set(this.config.width * .5, this.config.height * .5), this.view.position.set(this.config.width * .5, this.config.height * .5), this.alpha = 0, this.addChild(this.view);
1511
+ }
1512
+ addCloseButton() {
1513
+ let e = this.config.closeButton?.class || er, t = this.config.closeButton?.size ?? 12, n = this.config.closeButton?.offset ?? 4, r = this.config.closeButton?.position ?? "top right";
1514
+ this.closeButton = this.view.add.existing(new e({ cursor: "pointer" }));
1515
+ let i = r === "top right" ? this.config.width - t * .5 - n : t * .5 + n, a = t * .5 + n;
1516
+ this.closeButton.position.set(i, a), this.closeButton.onClick.connect(() => {
1517
+ this.hide();
1518
+ });
1519
+ }
1520
+ alignText() {
1521
+ switch (this.config.textAlign) {
1522
+ case "left":
1523
+ this.textDisplay.anchor.set(0, .5);
1524
+ break;
1525
+ case "center":
1526
+ this.textDisplay.anchor.set(.5, .5), this.textDisplay.x = this.config.width / 2;
1527
+ break;
1528
+ case "right":
1529
+ this.textDisplay.anchor.set(1, .5);
1530
+ break;
1531
+ }
1532
+ switch (this.config.verticalAlign) {
1533
+ case "top":
1534
+ this.textDisplay.y = this.config.padding;
1535
+ break;
1536
+ case "middle":
1537
+ this.textDisplay.y = this.config.height * .5;
1538
+ break;
1539
+ case "bottom":
1540
+ this.textDisplay.y = this.config.height - this.textDisplay.height - this.config.padding;
1541
+ break;
1542
+ }
1543
+ }
1544
+ getShowAnimation() {
1545
+ let e = A.timeline({ paused: !0 });
1546
+ return e.to(this, {
1547
+ alpha: 1,
1548
+ duration: .4,
1549
+ ease: "power2.out"
1550
+ }), e;
1551
+ }
1552
+ getHideAnimation() {
1553
+ let e = A.timeline({ paused: !0 });
1554
+ return e.to(this, {
1555
+ alpha: 0,
1556
+ duration: .25,
1557
+ ease: "power2.in"
1558
+ }), e;
1559
+ }
1560
+ async show() {
1561
+ return this.timeline = this.getShowAnimation(), await this.timeline.play(), this.config.autoClose && (this.closeTimeout = setTimeout(() => {
1562
+ this.hide();
1563
+ }, this.config.duration)), this;
1564
+ }
1565
+ async hide() {
1566
+ if (this.isHiding || this.destroyed) return this;
1567
+ this.isHiding = !0, this.closeTimeout &&= (clearTimeout(this.closeTimeout), void 0);
1568
+ try {
1569
+ await this.getHideAnimation().play(), this.destroyed || this.onToastClosed.emit();
1570
+ } catch (e) {
1571
+ console.warn("Toast hide animation error:", e), this.destroyed || this.onToastClosed.emit();
1572
+ }
1573
+ return this;
1574
+ }
1575
+ destroy() {
1576
+ this.isHiding = !0, this.closeTimeout &&= (clearTimeout(this.closeTimeout), void 0), A.killTweensOf(this), this.timeline &&= (this.timeline.kill(), void 0), !this.destroyed && !this.isHiding && this.onToastClosed.emit(), super.destroy({ children: !0 });
1577
+ }
1578
+ }, or = {
1579
+ position: "bottom right",
1580
+ maxToasts: 5,
1581
+ spacing: 10,
1582
+ offset: {
1583
+ x: 20,
1584
+ y: 20
1585
+ },
1586
+ stackDirection: "up",
1587
+ animationSpeed: 1
1588
+ }, sr = class extends h(_) {
1589
+ get size() {
1590
+ return this.toasts.length;
1591
+ }
1592
+ get toastPosition() {
1593
+ return this.config.position ?? "top right";
1594
+ }
1595
+ get stackDirection() {
1596
+ return this.config.stackDirection ?? "up";
1597
+ }
1598
+ get spacing() {
1599
+ return this.config.spacing ?? 10;
1600
+ }
1601
+ get offset() {
1602
+ return this.config.offset ?? {
1603
+ x: 20,
1604
+ y: 20
1605
+ };
1606
+ }
1607
+ get maxToasts() {
1608
+ return this.config.maxToasts ?? 5;
1609
+ }
1610
+ get toastConfig() {
1611
+ return this.defaultToastConfig ?? {};
1612
+ }
1613
+ constructor(e = {}, t = {}) {
1614
+ super({ autoResize: !0 }), this.onToastAdded = new p(), this.onToastRemoved = new p(), this.onAllToastsRemoved = new p(), this.toasts = [], this.config = {
1615
+ ...or,
1616
+ ...e
1617
+ }, this.defaultToastConfig = { ...t }, this.initialize(), this.resize();
1618
+ }
1619
+ initialize() {
1620
+ this.container = this.add.container();
1621
+ }
1622
+ async show(e = this.defaultToastConfig, t = !1) {
1623
+ if (this.size >= this.config.maxToasts) {
1624
+ let e = this.toasts[0];
1625
+ await e.hide(), await this.removeToast(e);
1626
+ }
1627
+ !t && this.defaultToastConfig && (e = {
1628
+ ...this.defaultToastConfig,
1629
+ ...e,
1630
+ style: this.defaultToastConfig.style || e.style ? {
1631
+ ...this.defaultToastConfig.style ?? {},
1632
+ ...e.style ?? {}
1633
+ } : this.defaultToastConfig.style,
1634
+ textColors: this.defaultToastConfig.textColors || e.textColors ? {
1635
+ ...this.defaultToastConfig.textColors ?? {},
1636
+ ...e.textColors ?? {}
1637
+ } : Y.textColors,
1638
+ shadow: this.defaultToastConfig.shadow || e.shadow ? {
1639
+ ...this.defaultToastConfig.shadow ?? {},
1640
+ ...e.shadow ?? {}
1641
+ } : this.defaultToastConfig.shadow,
1642
+ closeButton: this.defaultToastConfig.closeButton || e.closeButton ? {
1643
+ ...this.defaultToastConfig.closeButton ?? {},
1644
+ ...e.closeButton ?? {}
1645
+ } : Y.closeButton
1646
+ });
1647
+ let n = new (e.class ?? ar)(e);
1648
+ return n.toaster = this, this.container.addChild(n), this.toasts.push(n), this.positionToast(n, this.toasts.length - 1, !1), n.onToastClosed.connectOnce(() => this.removeToast(n)), this.positionToasts(), this.onToastAdded.emit(n), n.show();
1649
+ }
1650
+ async hideAll() {
1651
+ let e = [...this.toasts];
1652
+ await Promise.all(e.map((e) => e.hide())), this.onAllToastsRemoved.emit();
1653
+ }
1654
+ async removeAll() {
1655
+ return this.hideAll();
1656
+ }
1657
+ async removeToast(e) {
1658
+ let t = this.toasts.indexOf(e);
1659
+ t === -1 || e.destroyed || (this.toasts.splice(t, 1), this.positionToasts(), e.destroyed || (this.container.removeChild(e), e.destroy()), this.onToastRemoved.emit(e));
1660
+ }
1661
+ positionToasts(e = !0, t = !1) {
1662
+ this.toasts.filter((e, n) => e && !e.destroyed && (t ? n !== this.toasts.length - 1 : !0)).forEach((t, n) => {
1663
+ this.positionToast(t, n, e);
1664
+ });
1665
+ }
1666
+ positionToast(e, t, n = !0) {
1667
+ if (!e?.parent || e.destroyed) return;
1668
+ let { position: r, spacing: i, offset: a, stackDirection: o } = this.config, s = typeof a == "number" ? a : a.x, c = typeof a == "number" ? a : a.y, l = this.app.size.width * .5, u = this.app.size.height * .5;
1669
+ switch (r) {
1670
+ case "top right":
1671
+ case "right top":
1672
+ l += this.app.size.width * .5 - e.width - s, u -= this.app.size.height * .5 - c;
1673
+ break;
1674
+ case "top left":
1675
+ case "left top":
1676
+ l -= this.app.size.width * .5 - s, u -= this.app.size.height * .5 - c;
1677
+ break;
1678
+ case "bottom right":
1679
+ case "right bottom":
1680
+ l += this.app.size.width * .5 - e.width - s, u += this.app.size.height * .5 - e.height - c;
1681
+ break;
1682
+ case "bottom left":
1683
+ case "left bottom":
1684
+ l -= this.app.size.width * .5 - s, u += this.app.size.height * .5 - e.height - c;
1685
+ break;
1686
+ case "top":
1687
+ case "top center":
1688
+ l += -e.width * .5, u -= this.app.size.height * .5 - c;
1689
+ break;
1690
+ case "bottom":
1691
+ case "bottom center":
1692
+ l += -e.width * .5, u += this.app.size.height * .5 - e.height - c;
1693
+ break;
1694
+ }
1695
+ o === "down" ? u += t * (e.height + i) : u -= t * (e.height + i);
1696
+ try {
1697
+ n ? A.to(e, {
1698
+ x: l,
1699
+ y: u,
1700
+ duration: .3 / this.config.animationSpeed,
1701
+ ease: "power2.out"
1702
+ }) : e.position.set(l, u);
1703
+ } catch (e) {
1704
+ console.warn("Error positioning toast:", e);
1705
+ }
1706
+ }
1707
+ resize() {
1708
+ this.position.set(-this.app.size.width * .5, -this.app.size.height * .5), this.positionToasts(!1);
1709
+ }
1710
+ destroy() {
1711
+ this.toasts.forEach((e) => {
1712
+ A.killTweensOf(e);
1713
+ }), this.hideAll(), this.toasts = [], super.destroy({ children: !0 });
1714
+ }
1715
+ }, cr = [
1716
+ "debug",
1717
+ "padding",
1718
+ "size",
1719
+ "useAppSize",
1720
+ "useSafeArea",
1721
+ "layout"
1722
+ ], lr = {
1723
+ top: 0,
1724
+ right: 0,
1725
+ bottom: 0,
1726
+ left: 0
1727
+ };
1728
+ function ur(e, t) {
1729
+ return {
1730
+ top: e.top + t.top,
1731
+ right: e.right + t.right,
1732
+ bottom: e.bottom + t.bottom,
1733
+ left: e.left + t.left
1734
+ };
1735
+ }
1736
+ var dr = {
1737
+ flexGrow: 0,
1738
+ flexShrink: 0,
1739
+ autoLayoutChildren: !0
1740
+ }, fr = h(v()), pr = class e extends fr {
1741
+ constructor(e) {
1742
+ if (super(), this.settingsMap = /* @__PURE__ */ new Map(), this._childMap = /* @__PURE__ */ new Map(), this._debugGraphics = null, this._debugLabel = null, this._regionLabels = [], this._disableAddChildError = !1, this._bindings = [], this._canvasChildren = [], this.removeChildren = (e, t) => super.removeChildren(e, t), this.removeChildAt = (e) => super.removeChildAt(e), this.addChildAt = (e, t) => {
1743
+ throw Error("UICanvas: Do not call addChildAt() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
1744
+ }, this.setChildIndex = (e, t) => {
1745
+ super.setChildIndex(e, t), this._updateLayout();
1746
+ }, this.getChildIndex = (e) => super.getChildIndex(e), this.getChildAt = (e) => super.getChildAt(e), !this.app.config.useLayout) throw Error("You must set useLayout to true in your app config to use UICanvas");
1747
+ m(this), this._positionContainers = /* @__PURE__ */ new Map(), this.config = {
1748
+ debug: e.debug === !0,
1749
+ padding: I(e?.padding ?? 0),
1750
+ size: e.size === void 0 ? {
1751
+ width: 0,
1752
+ height: 0
1753
+ } : et(e.size),
1754
+ useAppSize: e.useAppSize === !0,
1755
+ useSafeArea: e.useSafeArea ?? !0,
1756
+ autoLayoutChildren: e.autoLayoutChildren ?? !0
1757
+ }, e.layout ? typeof e.layout == "boolean" ? this.config.layout = e.layout : this.config.layout = {
1758
+ ...dr,
1759
+ ...e.layout
1760
+ } : this.config.layout = { ...dr }, this.config.useAppSize && (this.config.size = this.app.size), this.layout = {
1761
+ width: this.config.size.width,
1762
+ height: this.config.size.height,
1763
+ flexDirection: "column",
1764
+ justifyContent: "space-between",
1765
+ ...typeof this.config.layout == "object" ? this.config.layout : {}
1766
+ }, this.on("childRemoved", this._childRemoved), this.once("added", this._added), this.addSignalConnection(this.app.onResize.connect(this.resize)), this._initializeLayout(), this._updateLayout(), this.config.debug && P(`UICanvas:${this.uid}`, this.label || "UICanvas", j.outerBounds);
1767
+ }
1768
+ _updateLayout() {
1769
+ this.app.ticker.addOnce(this.updateLayout);
1770
+ }
1771
+ _initializeLayout() {
1772
+ this._disableAddChildError = !0, this.topRow = this.add.flexContainer({
1773
+ label: "Top",
1774
+ layout: {
1775
+ width: "100%",
1776
+ height: "auto",
1777
+ flexDirection: "row",
1778
+ justifyContent: "space-between",
1779
+ alignItems: "flex-start"
1780
+ }
1781
+ }), this.middleRow = this.add.flexContainer({
1782
+ label: "Middle",
1783
+ layout: {
1784
+ width: "100%",
1785
+ flexDirection: "row",
1786
+ justifyContent: "space-between",
1787
+ alignItems: "center"
1788
+ }
1789
+ }), this.bottomRow = this.add.flexContainer({
1790
+ label: "Bottom",
1791
+ layout: {
1792
+ width: "100%",
1793
+ height: "auto",
1794
+ flexDirection: "row",
1795
+ justifyContent: "space-between",
1796
+ alignItems: "flex-end"
1797
+ }
1798
+ }), this._disableAddChildError = !1;
1799
+ let e = this._createPositionContainer(this.topRow, {
1800
+ justifyContent: "flex-start",
1801
+ alignItems: "flex-start",
1802
+ flexGrow: 0,
1803
+ flexShrink: 0
1804
+ }, "Left"), t = this._createPositionContainer(this.topRow, {
1805
+ justifyContent: "center",
1806
+ alignItems: "flex-start",
1807
+ flexGrow: 1,
1808
+ flexShrink: 0
1809
+ }, "Center"), n = this._createPositionContainer(this.topRow, {
1810
+ justifyContent: "flex-end",
1811
+ alignItems: "flex-start",
1812
+ flexGrow: 0,
1813
+ flexShrink: 0
1814
+ }, "Right"), r = this._createPositionContainer(this.middleRow, {
1815
+ justifyContent: "flex-start",
1816
+ alignItems: "center",
1817
+ flexDirection: "row",
1818
+ flexGrow: 0,
1819
+ flexShrink: 0
1820
+ }, "Left"), i = this._createPositionContainer(this.middleRow, {
1821
+ justifyContent: "center",
1822
+ alignItems: "center",
1823
+ flexDirection: "row",
1824
+ flexGrow: 1,
1825
+ flexShrink: 0
1826
+ }, "Center"), a = this._createPositionContainer(this.middleRow, {
1827
+ justifyContent: "flex-end",
1828
+ alignItems: "center",
1829
+ flexDirection: "row",
1830
+ flexGrow: 0,
1831
+ flexShrink: 0
1832
+ }, "Right"), o = this._createPositionContainer(this.bottomRow, {
1833
+ justifyContent: "flex-start",
1834
+ alignItems: "flex-end",
1835
+ flexDirection: "row",
1836
+ flexGrow: 0,
1837
+ flexShrink: 0
1838
+ }, "Left"), s = this._createPositionContainer(this.bottomRow, {
1839
+ justifyContent: "center",
1840
+ alignItems: "flex-end",
1841
+ flexGrow: 1,
1842
+ flexShrink: 0,
1843
+ flexDirection: "row"
1844
+ }, "Center"), c = this._createPositionContainer(this.bottomRow, {
1845
+ justifyContent: "flex-end",
1846
+ alignItems: "flex-end",
1847
+ flexDirection: "row",
1848
+ flexGrow: 0,
1849
+ flexShrink: 0
1850
+ }, "Right");
1851
+ this._positionContainers.set("top left", e), this._positionContainers.set("left top", e), this._positionContainers.set("top center", t), this._positionContainers.set("top", t), this._positionContainers.set("top right", n), this._positionContainers.set("right top", n), this._positionContainers.set("left center", r), this._positionContainers.set("left", r), this._positionContainers.set("left bottom", o), this._positionContainers.set("center", i), this._positionContainers.set("right center", a), this._positionContainers.set("right", a), this._positionContainers.set("right bottom", c), this._positionContainers.set("bottom left", o), this._positionContainers.set("bottom center", s), this._positionContainers.set("bottom", s), this._positionContainers.set("bottom right", c);
1852
+ }
1853
+ _createPositionContainer(e, t, n) {
1854
+ let r = e.add.container({ layout: {
1855
+ width: "auto",
1856
+ height: "auto",
1857
+ ...t
1858
+ } });
1859
+ return r.label = n, r.on("childAdded", this._updateLayout), r.on("childRemoved", this._updateLayout), r.on("layout", this._updateLayout), r;
1860
+ }
1861
+ get canvasChildren() {
1862
+ return this._canvasChildren;
375
1863
  }
376
1864
  get app() {
377
- return C.getInstance();
1865
+ return S.getInstance();
378
1866
  }
379
1867
  destroy() {
380
- this.interactiveArea.removeAllListeners(), this.app.stage.off("pointerup", this.onPointerUp.bind(this)), this.app.stage.off("pointerupoutside", this.onPointerUp.bind(this));
1868
+ this._disableAddChildError = !0, this.config.debug && F(`UICanvas:${this.uid}`), this._debugGraphics &&= (this._debugGraphics.destroy(), null), this._debugLabel &&= (this._debugLabel.destroy(), null);
1869
+ for (let e of this._regionLabels) e.destroy();
1870
+ this._regionLabels = [], this.canvasChildren?.forEach((e) => {
1871
+ e.off("layout", this._updateLayout);
1872
+ }), this.children.forEach((e) => {
1873
+ e.off("layout", this._updateLayout);
1874
+ }), this.off("childAdded", this._updateLayout), this.off("childRemoved", this._updateLayout), this._positionContainers.forEach((e) => {
1875
+ e.off("childAdded", this._updateLayout), e.off("childRemoved", this._updateLayout);
1876
+ }), this._bindings = [], super.destroy();
1877
+ }
1878
+ set size(e) {
1879
+ this.config.size = e === void 0 ? {
1880
+ width: 0,
1881
+ height: 0
1882
+ } : et(e), this.layout = {
1883
+ width: this.config.size.width,
1884
+ height: this.config.size.height
1885
+ }, this.updateLayout();
1886
+ }
1887
+ set padding(e) {
1888
+ this.config.padding = I(e), this._applyPadding(), this._updateLayout();
1889
+ }
1890
+ _applyPadding() {
1891
+ let e = ur(this.config.padding, this.config.useSafeArea ? this.app.safeArea : lr);
1892
+ this.layout = {
1893
+ paddingLeft: e.left,
1894
+ paddingTop: e.top,
1895
+ paddingRight: e.right,
1896
+ paddingBottom: e.bottom
1897
+ };
1898
+ }
1899
+ static isFlexContainer(e) {
1900
+ return e instanceof ir;
1901
+ }
1902
+ addChild(...e) {
1903
+ if (this._disableAddChildError) return super.addChild(...e);
1904
+ throw Error("UICanvas: Do not call addChild() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
1905
+ }
1906
+ removeChild(...e) {
1907
+ if (this._disableAddChildError) return super.removeChild(...e);
1908
+ throw Error("UICanvas: Do not call removeChild() directly. Use removeElement(child) instead.");
381
1909
  }
382
- handleKeyDown(e) {
383
- let t = 1.1;
384
- switch (e.event.key) {
385
- case "ArrowUp":
386
- this.camera.pan(0, -10);
387
- break;
388
- case "ArrowDown":
389
- this.camera.pan(0, 10);
390
- break;
391
- case "ArrowLeft":
392
- this.camera.pan(-10, 0);
393
- break;
394
- case "ArrowRight":
395
- this.camera.pan(10, 0);
396
- break;
397
- case "+":
398
- this.camera.zoom(t);
399
- break;
400
- case "-":
401
- this.camera.zoom(1 / t);
402
- break;
1910
+ resize() {
1911
+ this._applyPadding(), this.config.useAppSize ? (this.size = {
1912
+ width: this.app.size.width,
1913
+ height: this.app.size.height
1914
+ }, this.position.set(-this.app.size.width * .5, -this.app.size.height * .5)) : this._updateLayout();
1915
+ }
1916
+ updateLayout() {
1917
+ this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this._positionContainers.forEach((e) => {
1918
+ this.app.renderer.layout.update(e);
1919
+ }), this.config.useAppSize && this.position.set(-this.config.size.width * .5, -this.config.size.height * .5), this._updateBindings(), this.config.debug && this.app.ticker.addOnce(this.drawDebug));
1920
+ }
1921
+ bindElement(e, t, n) {
1922
+ e.parent !== this && (this._disableAddChildError = !0, super.addChild(e), this._disableAddChildError = !1), e.layout = !1, this._bindings = this._bindings.filter((t) => t.child !== e), this._bindings.push({
1923
+ child: e,
1924
+ anchor: t,
1925
+ place: n
1926
+ }), this._updateLayout();
1927
+ }
1928
+ unbindElement(e) {
1929
+ let t = this._bindings.some((t) => t.child === e);
1930
+ this._bindings = this._bindings.filter((t) => t.child !== e), t && e.parent === this && (this._disableAddChildError = !0, super.removeChild(e), this._disableAddChildError = !1);
1931
+ }
1932
+ _updateBindings() {
1933
+ for (let { child: e, anchor: t, place: n } of this._bindings) {
1934
+ let r = this._anchorRect(t);
1935
+ r && n(r, e);
403
1936
  }
404
1937
  }
405
- onPointerDown(e) {
406
- this.dragging = !0, this.previousPointerPosition = this.getEventPosition(e);
1938
+ _anchorRect(e) {
1939
+ let t = e.layout?.computedLayout;
1940
+ if (!t) return null;
1941
+ let n = 0, r = 0;
1942
+ for (let t = e; t && t !== this; t = t.parent) {
1943
+ let e = t.layout?.computedLayout;
1944
+ e && (n += e.left, r += e.top);
1945
+ }
1946
+ return {
1947
+ left: n,
1948
+ top: r,
1949
+ width: t.width,
1950
+ height: t.height
1951
+ };
1952
+ }
1953
+ addElement(t, n) {
1954
+ let r = n?.align ?? "top left", i = this._positionContainers.get(r);
1955
+ return i ? (e.isFlexContainer(t) && this.addSignalConnection(t.onLayoutComplete.connect(this._updateLayout)), this.settingsMap.set(t, {
1956
+ align: r,
1957
+ padding: n?.padding ? I(n.padding) : {
1958
+ top: 0,
1959
+ left: 0,
1960
+ bottom: 0,
1961
+ right: 0
1962
+ }
1963
+ }), this._childMap.set(t, i), this._canvasChildren = Array.from(this._childMap.keys()), i.add.existing(t), this._childAdded(t), t) : (c.error(`UICanvas:: Invalid position "${r}" for element`), t);
407
1964
  }
408
- onPointerMove(e) {
409
- if (!this.dragging || !this.previousPointerPosition) return;
410
- let t = this.getEventPosition(e), n = t.x - this.previousPointerPosition.x, r = t.y - this.previousPointerPosition.y;
411
- this.camera.pan(n, r), this.previousPointerPosition = t;
1965
+ removeElement(e) {
1966
+ let t = this._childMap.get(e);
1967
+ if (!t) throw Error(`UICanvas: Cannot remove element it was not added via addElement().\nChild label: "${e.label ?? "(unlabeled)"}"`);
1968
+ return t.removeChild(e), e.off("layout", this._updateLayout), this.settingsMap.delete(e), this._childMap.delete(e), this._canvasChildren = Array.from(this._childMap.keys()), this._updateLayout(), e;
412
1969
  }
413
- onPointerUp() {
414
- this.dragging = !1, this.previousPointerPosition = null;
1970
+ _childAdded(e) {
1971
+ this.config.autoLayoutChildren && (e.layout ||= !0, e.layout?.style?.width || (e.layout = { width: "auto" }), e.layout?.style?.height || (e.layout = { height: "auto" })), e.on("layout", this._updateLayout), _.childAdded(e), this._updateLayout();
415
1972
  }
416
- getEventPosition(e) {
417
- return e instanceof TouchEvent ? new A(e.touches[0].clientX, e.touches[0].clientY) : new A(e.clientX, e.clientY);
1973
+ _childRemoved(e) {
1974
+ this.settingsMap.delete(e), this._childMap.delete(e), this._canvasChildren = Array.from(this._childMap.keys()), _.childRemoved(e);
1975
+ }
1976
+ _added() {
1977
+ this._updateLayout();
1978
+ }
1979
+ get debug() {
1980
+ return this.config.debug;
1981
+ }
1982
+ set debug(e) {
1983
+ if (this.config.debug = e, e) P(`UICanvas:${this.uid}`, this.label || "UICanvas", j.outerBounds), this.drawDebug();
1984
+ else {
1985
+ F(`UICanvas:${this.uid}`), this._debugGraphics && this._debugGraphics.clear(), this._debugLabel && (this._debugLabel.visible = !1);
1986
+ for (let e of this._regionLabels) e.visible = !1;
1987
+ }
1988
+ }
1989
+ drawDebug() {
1990
+ this._debugGraphics || (this._disableAddChildError = !0, this._debugGraphics = Ft(`${this.label ?? "UICanvas"}:debug`), super.addChild(this._debugGraphics), this._debugGraphics.layout = !1, this._disableAddChildError = !1), this._debugLabel || (this._disableAddChildError = !0, this._debugLabel = N(this.label || "UICanvas", j.outerBounds), super.addChild(this._debugLabel), this._debugLabel.layout = !1, this._disableAddChildError = !1), this._debugLabel.text = this.label || "UICanvas", this._debugLabel.visible = !0, this._debugLabel.position.set(2, 2), this._debugGraphics.clear();
1991
+ let e = this.config.size.width, t = this.config.size.height, n = this.config.padding;
1992
+ this._debugGraphics.rect(0, 0, e, t).stroke({
1993
+ width: 1,
1994
+ color: j.outerBounds,
1995
+ alpha: M.stroke,
1996
+ pixelLine: !0
1997
+ }), n.top > 0 && this._debugGraphics.rect(0, 0, e, n.top).fill({
1998
+ color: j.outerBounds,
1999
+ alpha: M.fill
2000
+ }), n.bottom > 0 && this._debugGraphics.rect(0, t - n.bottom, e, n.bottom).fill({
2001
+ color: j.outerBounds,
2002
+ alpha: M.fill
2003
+ }), n.left > 0 && this._debugGraphics.rect(0, n.top, n.left, t - n.top - n.bottom).fill({
2004
+ color: j.outerBounds,
2005
+ alpha: M.fill
2006
+ }), n.right > 0 && this._debugGraphics.rect(e - n.right, n.top, n.right, t - n.top - n.bottom).fill({
2007
+ color: j.outerBounds,
2008
+ alpha: M.fill
2009
+ });
2010
+ let r = n.left, i = n.top, a = e - n.left - n.right, o = t - n.top - n.bottom;
2011
+ this._debugGraphics.rect(r, i, a, o).stroke({
2012
+ width: 1,
2013
+ color: j.innerBounds,
2014
+ alpha: M.stroke,
2015
+ pixelLine: !0
2016
+ });
2017
+ let s = /* @__PURE__ */ new Map();
2018
+ this._positionContainers.forEach((e, t) => {
2019
+ (!s.has(e) || t.length < s.get(e).length) && s.set(e, t);
2020
+ });
2021
+ let c = [...new Set(this._positionContainers.values())];
2022
+ for (; this._regionLabels.length < c.length;) {
2023
+ this._disableAddChildError = !0;
2024
+ let e = N("", j.region);
2025
+ super.addChild(e), e.layout = !1, this._regionLabels.push(e), this._disableAddChildError = !1;
2026
+ }
2027
+ c.forEach((e, t) => {
2028
+ if (!e.layout?.computedLayout) return;
2029
+ let n = e.layout.computedLayout, r = e.parent;
2030
+ if (!r?.layout?.computedLayout) return;
2031
+ let i = r.layout.computedLayout, a = i.left + n.left, o = i.top + n.top, c = n.width, l = n.height, u = e.children.length > 0;
2032
+ this._debugGraphics.rect(a, o, c, l).fill({
2033
+ color: j.region,
2034
+ alpha: u ? M.fillActive : M.fill
2035
+ }).stroke({
2036
+ width: 1,
2037
+ color: j.region,
2038
+ alpha: .3,
2039
+ pixelLine: !0
2040
+ });
2041
+ let d = this._regionLabels[t];
2042
+ d.text = s.get(e) ?? "", d.visible = !0, d.position.set(a + 2, o + 2);
2043
+ });
2044
+ for (let e = c.length; e < this._regionLabels.length; e++) this._regionLabels[e].visible = !1;
2045
+ let l = e / 2, u = t / 2;
2046
+ this._debugGraphics.moveTo(l, u - 10).lineTo(l, u + 10).stroke({
2047
+ width: 1,
2048
+ color: j.outerBounds,
2049
+ alpha: M.crosshair,
2050
+ pixelLine: !0
2051
+ }).moveTo(l - 10, u).lineTo(l + 10, u).stroke({
2052
+ width: 1,
2053
+ color: j.outerBounds,
2054
+ alpha: M.crosshair,
2055
+ pixelLine: !0
2056
+ });
2057
+ }
2058
+ }, X = null;
2059
+ function mr() {
2060
+ if (X) return X;
2061
+ X = /* @__PURE__ */ new Map();
2062
+ let e = globalThis.Caper?.get?.("entityList") ?? [];
2063
+ for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && X.set(t.id, t.module);
2064
+ return X;
2065
+ }
2066
+ function hr(e) {
2067
+ return mr().get(e);
2068
+ }
2069
+ function gr() {
2070
+ return [...mr().keys()];
2071
+ }
2072
+ //#endregion
2073
+ //#region src/mixins/factory/ui-registry.ts
2074
+ var Z = null;
2075
+ function _r() {
2076
+ if (Z) return Z;
2077
+ Z = /* @__PURE__ */ new Map();
2078
+ let e = globalThis.Caper?.get?.("uiList") ?? [];
2079
+ for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && Z.set(t.id, t.module);
2080
+ return Z;
2081
+ }
2082
+ function vr(e) {
2083
+ return _r().get(e);
2084
+ }
2085
+ function yr() {
2086
+ return [..._r().keys()];
2087
+ }
2088
+ //#endregion
2089
+ //#region src/mixins/factory/schema.ts
2090
+ var br = [
2091
+ "position",
2092
+ "scale",
2093
+ "pivot"
2094
+ ], xr = [
2095
+ "position",
2096
+ "x",
2097
+ "y",
2098
+ "scale",
2099
+ "scaleX",
2100
+ "scaleY",
2101
+ "pivot",
2102
+ "anchor"
2103
+ ];
2104
+ function Q(e) {
2105
+ let t = e.applies ?? br, n = t.includes("position"), r = t.includes("scale"), i = t.includes("pivot"), a = t.includes("anchor"), o = [...xr, ...e.exclude ?? []];
2106
+ return (t) => {
2107
+ let s = e.build(t);
2108
+ if (t == null) return s;
2109
+ let c = t;
2110
+ return n && G({
2111
+ position: c.position,
2112
+ x: c.x,
2113
+ y: c.y
2114
+ }, s), r && K({
2115
+ scale: c.scale,
2116
+ scaleX: c.scaleX,
2117
+ scaleY: c.scaleY
2118
+ }, s), i && q(c.pivot, s), a && Gn(c.anchor, s), H(st(o, c), s), s;
2119
+ };
2120
+ }
2121
+ //#endregion
2122
+ //#region src/mixins/factory/const.ts
2123
+ var Sr = [
2124
+ "text",
2125
+ "roundPixels",
2126
+ "resolution",
2127
+ "style",
2128
+ "anchor",
2129
+ "pivot"
2130
+ ], Cr = {
2131
+ existing: (e, t) => {
2132
+ if (!t) return e;
2133
+ let { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ...l } = t;
2134
+ return G({
2135
+ position: n,
2136
+ x: r,
2137
+ y: i
2138
+ }, e), K({
2139
+ scale: o,
2140
+ scaleX: s,
2141
+ scaleY: c
2142
+ }, e), q(a, e), H(l, e), e;
2143
+ },
2144
+ container: Q({
2145
+ build: (e) => new _(e ? g(e, b) : void 0),
2146
+ applies: [
2147
+ "position",
2148
+ "scale",
2149
+ "pivot"
2150
+ ],
2151
+ exclude: b
2152
+ }),
2153
+ particleContainer: Q({
2154
+ build: (e) => new Bn(e ? g(e, Rn) : void 0),
2155
+ applies: [
2156
+ "position",
2157
+ "scale",
2158
+ "pivot"
2159
+ ],
2160
+ exclude: Rn
2161
+ }),
2162
+ texture: W,
2163
+ sprite: Q({
2164
+ build: (e) => new Et(e ? W(e) : void 0),
2165
+ applies: [
2166
+ "position",
2167
+ "scale",
2168
+ "pivot",
2169
+ "anchor"
2170
+ ],
2171
+ exclude: ["asset", "sheet"]
2172
+ }),
2173
+ tilingSprite: Q({
2174
+ build: (e) => new Dt(e ? W(e) : void 0),
2175
+ applies: [
2176
+ "position",
2177
+ "scale",
2178
+ "pivot",
2179
+ "anchor"
2180
+ ],
2181
+ exclude: ["asset", "sheet"]
2182
+ }),
2183
+ animatedSprite: Q({
2184
+ build: (e) => new Kn(e),
2185
+ applies: [
2186
+ "position",
2187
+ "scale",
2188
+ "pivot"
2189
+ ],
2190
+ exclude: [
2191
+ "sheet",
2192
+ "texturePrefix",
2193
+ "zeroPad",
2194
+ "animations",
2195
+ "autoPlay",
2196
+ "autoUpdate",
2197
+ "defaultAnimation",
2198
+ "reversible",
2199
+ "animationSpeed",
2200
+ "startIndex",
2201
+ "animation"
2202
+ ]
2203
+ }),
2204
+ graphics: Q({
2205
+ build: (e) => new E(),
2206
+ applies: [
2207
+ "position",
2208
+ "scale",
2209
+ "pivot"
2210
+ ]
2211
+ }),
2212
+ svg(e) {
2213
+ let t = new Un(e.ctx), { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ctx: l, ...u } = e;
2214
+ return G({
2215
+ position: n,
2216
+ x: r,
2217
+ y: i
2218
+ }, t), K({
2219
+ scale: o,
2220
+ scaleX: s,
2221
+ scaleY: c
2222
+ }, t), q(a, t), H(u, t), t;
2223
+ },
2224
+ text: Q({
2225
+ build: (e) => new O(e ? {
2226
+ text: e.text,
2227
+ roundPixels: e.roundPixels,
2228
+ resolution: e.resolution,
2229
+ style: e.style,
2230
+ anchor: e.anchor ? y(e.anchor, !0) : void 0,
2231
+ pivot: e.pivot ? y(e.pivot, !0) : void 0
2232
+ } : {}),
2233
+ applies: [
2234
+ "position",
2235
+ "scale",
2236
+ "pivot"
2237
+ ],
2238
+ exclude: [...Sr]
2239
+ }),
2240
+ htmlText: Q({
2241
+ build: (e) => new St(e ? {
2242
+ text: e.text,
2243
+ roundPixels: e.roundPixels,
2244
+ resolution: e.resolution,
2245
+ style: e.style,
2246
+ anchor: e.anchor ? y(e.anchor, !0) : void 0,
2247
+ pivot: e.pivot ? y(e.pivot, !0) : void 0
2248
+ } : {}),
2249
+ applies: [
2250
+ "position",
2251
+ "scale",
2252
+ "pivot"
2253
+ ],
2254
+ exclude: [...Sr]
2255
+ }),
2256
+ bitmapText: Q({
2257
+ build: (e) => new w(e ? {
2258
+ text: e.text,
2259
+ roundPixels: e.roundPixels,
2260
+ style: e.style,
2261
+ anchor: e.anchor ? y(e.anchor, !0) : void 0,
2262
+ pivot: e.pivot ? y(e.pivot, !0) : void 0
2263
+ } : {}),
2264
+ applies: [
2265
+ "position",
2266
+ "scale",
2267
+ "pivot"
2268
+ ],
2269
+ exclude: [...Sr]
2270
+ }),
2271
+ button: Q({
2272
+ build: (e) => new er(e ? g(e, Qn) : void 0),
2273
+ applies: [
2274
+ "position",
2275
+ "scale",
2276
+ "pivot"
2277
+ ],
2278
+ exclude: Qn
2279
+ }),
2280
+ flexContainer: Q({
2281
+ build: (e) => new ir(e),
2282
+ applies: [
2283
+ "position",
2284
+ "scale",
2285
+ "pivot"
2286
+ ],
2287
+ exclude: rr
2288
+ }),
2289
+ uiCanvas: Q({
2290
+ build: (e) => new pr(e ? g(e, cr) : {}),
2291
+ applies: [
2292
+ "position",
2293
+ "scale",
2294
+ "pivot"
2295
+ ],
2296
+ exclude: cr
2297
+ }),
2298
+ spine: Q({
2299
+ build: (e) => {
2300
+ let t = "", n = e?.data;
2301
+ if (typeof n == "string") {
2302
+ let e = n.slice(-5);
2303
+ e !== ".json" && e !== ".skel" ? e = ".json" : t = n.substring(0, n.length - 5), t = {
2304
+ skeleton: n + e,
2305
+ atlas: n + ".atlas"
2306
+ };
2307
+ }
2308
+ let r = window.Spine.from(t);
2309
+ return e?.autoUpdate !== void 0 && (r.autoUpdate = e.autoUpdate), e?.animationName && r.state.setAnimation(e.trackIndex ?? 0, e.animationName, e.loop), r;
2310
+ },
2311
+ applies: [
2312
+ "position",
2313
+ "scale",
2314
+ "pivot",
2315
+ "anchor"
2316
+ ],
2317
+ exclude: [
2318
+ "data",
2319
+ "autoUpdate",
2320
+ "animationName",
2321
+ "trackIndex",
2322
+ "loop"
2323
+ ]
2324
+ }),
2325
+ spineAnimation: (e) => {
2326
+ let t = new Xn(e);
2327
+ if (!e) return t;
2328
+ let { position: n, x: r, y: i, anchor: a, pivot: o, scale: s, scaleX: c, scaleY: l, ...u } = e;
2329
+ return G({
2330
+ position: n,
2331
+ x: r,
2332
+ y: i
2333
+ }, t), K({
2334
+ scale: s,
2335
+ scaleX: c,
2336
+ scaleY: l
2337
+ }, t), Gn(a, t), q(o, t), H(u, t), t;
2338
+ },
2339
+ toaster: (e, t = {}) => new sr(e, t),
2340
+ entity: (e, t) => {
2341
+ let n = hr(e);
2342
+ if (!n) {
2343
+ let t = gr();
2344
+ throw Error(`[caper] Unknown entity id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
2345
+ }
2346
+ let r = new n(t);
2347
+ if (t) {
2348
+ let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
2349
+ G({
2350
+ position: e,
2351
+ x: n,
2352
+ y: i
2353
+ }, r), K({
2354
+ scale: o,
2355
+ scaleX: s,
2356
+ scaleY: c
2357
+ }, r), q(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
2358
+ }
2359
+ return r;
2360
+ },
2361
+ ui: (e, t) => {
2362
+ let n = vr(e);
2363
+ if (!n) {
2364
+ let t = yr();
2365
+ throw Error(`[caper] Unknown ui id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
2366
+ }
2367
+ let r = new n(t);
2368
+ if (t) {
2369
+ let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
2370
+ G({
2371
+ position: e,
2372
+ x: n,
2373
+ y: i
2374
+ }, r), K({
2375
+ scale: o,
2376
+ scaleX: s,
2377
+ scaleY: c
2378
+ }, r), q(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
2379
+ }
2380
+ return r;
418
2381
  }
419
- }, W = {
2382
+ };
2383
+ we(Cr);
2384
+ //#endregion
2385
+ //#region src/mixins/factory/props.ts
2386
+ var wr = [
2387
+ "text",
2388
+ "anchor",
2389
+ "roundPixels",
2390
+ "style",
2391
+ "pivot"
2392
+ ], $ = {
420
2393
  value: "",
421
2394
  type: "text",
422
2395
  fixed: !0,
@@ -455,32 +2428,32 @@ var jn = class extends w {
455
2428
  scale: 1,
456
2429
  marginTop: 60
457
2430
  }
458
- }, In = [
2431
+ }, Tr = [
459
2432
  "text",
460
2433
  "password",
461
2434
  "number",
462
2435
  "email",
463
2436
  "tel",
464
2437
  "url"
465
- ], Ln = class e extends x(S(v(w))) {
2438
+ ], Er = class e extends J(Zn(h(_))) {
466
2439
  constructor(e, t = !1, n = null) {
467
2440
  if (super({
468
2441
  autoUpdate: !0,
469
2442
  autoResize: !t
470
- }), this.isClone = t, this.clone = n, this.onEnter = new T(), this.onChange = new T(), this.onError = new T(), this._lastWidth = 0, this._lastHeight = 0, this._placeholderPositioned = !1, this._placeholderAnimating = !1, this._caretPosition = -1, this._value = "", this.options = {
471
- ...W,
2443
+ }), this.isClone = t, this.clone = n, this.onEnter = new p(), this.onChange = new p(), this.onError = new p(), this._lastWidth = 0, this._lastHeight = 0, this._placeholderPositioned = !1, this._placeholderAnimating = !1, this._caretPosition = -1, this._value = "", this.options = {
2444
+ ...$,
472
2445
  ...e,
473
2446
  style: {
474
- ...W.style,
2447
+ ...$.style,
475
2448
  ...e?.style ?? {}
476
2449
  },
477
- padding: p(e.padding ?? W.padding),
2450
+ padding: I(e.padding ?? $.padding),
478
2451
  bg: {
479
- ...W.bg,
2452
+ ...$.bg,
480
2453
  ...e.bg ?? {}
481
2454
  },
482
2455
  focusOverlay: {
483
- ...W.focusOverlay,
2456
+ ...$.focusOverlay,
484
2457
  ...e.focusOverlay ?? {}
485
2458
  }
486
2459
  }, this.options.layout && typeof this.options.layout == "object" ? this.layout = { ...this.options.layout } : this.layout = { transformOrigin: "top left" }, this.options.placeholder || (this.options.placeholder = { color: Number(this.options.style?.fill) ?? 6710886 }), this._inner = this.add.container({ layout: {
@@ -507,7 +2480,7 @@ var jn = class extends w {
507
2480
  width: "100%",
508
2481
  height: "100%"
509
2482
  }
510
- }), this._placeholderContainer.eventMode = "none", this.addSelection(), this.addCaret(), this.addInput(), this.addPlaceholder(), this.placeholder.text = this.options.placeholder.text || `Enter ${this.options.type}`, this.input.eventMode = this.placeholder.eventMode = "none", L && this.addSignalConnection(this.onInteraction("pointertap").connect(this.handleClick, -1)), this.addSignalConnection(this.onInteraction("click").connect(this.handleClick, -1)), this.options.fixed) {
2483
+ }), this._placeholderContainer.eventMode = "none", this.addSelection(), this.addCaret(), this.addInput(), this.addPlaceholder(), this.placeholder.text = this.options.placeholder.text || `Enter ${this.options.type}`, this.input.eventMode = this.placeholder.eventMode = "none", B && this.addSignalConnection(this.onInteraction("pointertap").connect(this.handleClick, -1)), this.addSignalConnection(this.onInteraction("click").connect(this.handleClick, -1)), this.options.fixed) {
511
2484
  let e = this.isClone ? this.clone?.options?.focusOverlay?.scale ?? 1 : 1;
512
2485
  this._mask = this._inner.add.graphics().rect(0, 0, this.bg.width * e - this.options.padding.left - this.options.padding.right, this.bg.height * e - this.options.padding.top - this.options.padding.bottom).fill({ color: 0 }), this._inputContainer.mask = this._mask;
513
2486
  }
@@ -555,7 +2528,7 @@ var jn = class extends w {
555
2528
  handleClick(e) {
556
2529
  if (e?.originalEvent?.key) return;
557
2530
  clearTimeout(this._focusTimer), clearTimeout(this._pointerDownTimer);
558
- let t = e ? B(this.input, e) : this.input.text?.length ?? 0;
2531
+ let t = e ? un(this.input, e) : this.input.text?.length ?? 0;
559
2532
  this.createDomElement(t);
560
2533
  }
561
2534
  focusIn() {
@@ -609,7 +2582,7 @@ var jn = class extends w {
609
2582
  if (this.placeholder.visible = !0, !this.isClone && this._placeholderPositioned && !this._placeholderAnimating) {
610
2583
  this._placeholderAnimating = !0;
611
2584
  let e = this.input.x, t = this.input.y;
612
- this.options.placeholder.animationOnType ? this.addAnimation([N.to(this.placeholder, {
2585
+ this.options.placeholder.animationOnType ? this.addAnimation([A.to(this.placeholder, {
613
2586
  x: e,
614
2587
  y: t,
615
2588
  tint: 16777215,
@@ -620,7 +2593,7 @@ var jn = class extends w {
620
2593
  onComplete: () => {
621
2594
  this._placeholderPositioned = !1, this._placeholderAnimating = !1;
622
2595
  }
623
- }), N.to(this.placeholder.scale, {
2596
+ }), A.to(this.placeholder.scale, {
624
2597
  x: 1,
625
2598
  y: 1,
626
2599
  duration: this.options.placeholder.animationOnType.duration || .4,
@@ -641,11 +2614,11 @@ var jn = class extends w {
641
2614
  break;
642
2615
  }
643
2616
  if (this.options.placeholder.offsetOnType) {
644
- let n = g(this.options.placeholder.offsetOnType);
2617
+ let n = y(this.options.placeholder.offsetOnType);
645
2618
  e += n.x, t += n.y;
646
2619
  }
647
2620
  if (this.options.placeholder.animationOnType) {
648
- if (this.addAnimation(N.to(this.placeholder, {
2621
+ if (this.addAnimation(A.to(this.placeholder, {
649
2622
  x: e,
650
2623
  y: t,
651
2624
  duration: this.options.placeholder.animationOnType.duration || .4,
@@ -654,8 +2627,8 @@ var jn = class extends w {
654
2627
  alpha: this.options.placeholder.animationOnType.alpha ?? this.options.placeholder.alpha ?? 1,
655
2628
  overwrite: !0
656
2629
  })), this.options.placeholder.scaleOnType) {
657
- let e = g(this.options.placeholder.scaleOnType);
658
- this.addAnimation(N.to(this.placeholder.scale, {
2630
+ let e = y(this.options.placeholder.scaleOnType);
2631
+ this.addAnimation(A.to(this.placeholder.scale, {
659
2632
  x: e.x,
660
2633
  y: e.y,
661
2634
  duration: this.options.placeholder.animationOnType.duration || .4,
@@ -701,7 +2674,7 @@ var jn = class extends w {
701
2674
  }
702
2675
  addCaret() {
703
2676
  this.caret = this._inputContainer.add.sprite({
704
- asset: j.WHITE,
2677
+ asset: k.WHITE,
705
2678
  width: 3,
706
2679
  height: 10,
707
2680
  tint: this.options.caret.color ?? 0,
@@ -742,9 +2715,9 @@ var jn = class extends w {
742
2715
  this.domElement = this.clone.domElement, this._addDomElementListeners();
743
2716
  return;
744
2717
  }
745
- clearTimeout(this._focusTimer), clearTimeout(this._pointerDownTimer), this.domElement = document.createElement("input"), this.domElement.type = "text", this.options.type && In.includes(this.options.type) && (this.domElement.type = this.options.type), this.options.pattern && (this.domElement.pattern = this.options.pattern), this.options.regex && (this._regex = this.options.regex);
2718
+ clearTimeout(this._focusTimer), clearTimeout(this._pointerDownTimer), this.domElement = document.createElement("input"), this.domElement.type = "text", this.options.type && Tr.includes(this.options.type) && (this.domElement.type = this.options.type), this.options.pattern && (this.domElement.pattern = this.options.pattern), this.options.regex && (this._regex = this.options.regex);
746
2719
  let t = this.getGlobalPosition(), n = this.getBounds();
747
- n.x = t.x, n.y = t.y, n.width = this.width - this.options.padding.left, this.domElement.style.position = "fixed", this.domElement.style.border = "none", this.domElement.style.outline = "none", this.domElement.style.left = z ? "0" : `${n.left}px`, this.domElement.style.top = z ? "0" : `${n.top}px`, this.domElement.style.width = `${n.width}px`, this.domElement.style.height = `${n.height}px`, this.domElement.style.padding = "0", this.options.debug ? this.domElement.style.opacity = "0.8" : this.domElement.style.opacity = "0.0000001", this.app.canvas.parentElement?.appendChild(this.domElement), this.domElement.value = this.value, this.domElement.setAttribute("placeholder", this.options?.placeholder?.text ?? ""), this.options?.maxLength && this.domElement.setAttribute("maxLength", this.options.maxLength.toString()), this._addDomElementListeners(), this._focusDomElement(e);
2720
+ n.x = t.x, n.y = t.y, n.width = this.width - this.options.padding.left, this.domElement.style.position = "fixed", this.domElement.style.border = "none", this.domElement.style.outline = "none", this.domElement.style.left = en ? "0" : `${n.left}px`, this.domElement.style.top = en ? "0" : `${n.top}px`, this.domElement.style.width = `${n.width}px`, this.domElement.style.height = `${n.height}px`, this.domElement.style.padding = "0", this.options.debug ? this.domElement.style.opacity = "0.8" : this.domElement.style.opacity = "0.0000001", this.app.canvas.parentElement?.appendChild(this.domElement), this.domElement.value = this.value, this.domElement.setAttribute("placeholder", this.options?.placeholder?.text ?? ""), this.options?.maxLength && this.domElement.setAttribute("maxLength", this.options.maxLength.toString()), this._addDomElementListeners(), this._focusDomElement(e);
748
2721
  }
749
2722
  destroyDomElement() {
750
2723
  this.isClone || (this.domElement &&= (this._removeDomElementListeners(), this.domElement.remove(), this.domElement.parentNode && this.domElement.parentNode.removeChild(this.domElement), null));
@@ -756,7 +2729,7 @@ var jn = class extends w {
756
2729
  this.cursorAnimation?.kill(), this.caret.visible = !1;
757
2730
  }
758
2731
  blinkCaret() {
759
- this.cursorAnimation && this.cursorAnimation.kill(), this.cursorAnimation = N.fromTo(this.caret, { alpha: 0 }, {
2732
+ this.cursorAnimation && this.cursorAnimation.kill(), this.cursorAnimation = A.fromTo(this.caret, { alpha: 0 }, {
760
2733
  duration: .5,
761
2734
  alpha: 1,
762
2735
  yoyo: !0,
@@ -789,15 +2762,15 @@ var jn = class extends w {
789
2762
  let n = Array.isArray(this.options.focusOverlay.activeFilter), r = !1;
790
2763
  if (n) {
791
2764
  let e = this.options.focusOverlay.activeFilter;
792
- (R && e.includes("mobile") || L && e.includes("touch") || !R && !L && e.includes("desktop")) && (r = !0);
2765
+ ($t && e.includes("mobile") || B && e.includes("touch") || !$t && !B && e.includes("desktop")) && (r = !0);
793
2766
  } else r = typeof this.options.focusOverlay.activeFilter == "function" ? this.options.focusOverlay.activeFilter() : t;
794
2767
  if (r) {
795
2768
  let t = structuredClone(this.options), n = this.options.focusOverlay?.scale || 1;
796
2769
  t.focusOverlay = { activeFilter: !1 };
797
- let r = Number(t.style?.fontSize || W.style?.fontSize || 20) * n;
2770
+ let r = Number(t.style?.fontSize || $.style?.fontSize || 20) * n;
798
2771
  if (t.style ||= {}, t.style.fontSize = r, t.padding && (t.padding.left *= n, t.padding.top *= n, t.padding.right *= n, t.padding.bottom *= n), t.bg?.radius && (t.bg.radius *= n), t.bg?.stroke?.width && (t.bg.stroke.width *= n), t.minWidth && (t.minWidth *= n, t.minWidth > this.app.size.width && (t.minWidth = this.app.size.width - (t.bg?.stroke?.width ? t.bg.stroke.width * 2 + 20 : 20))), this.options.focusOverlay?.backing?.active) {
799
2772
  let e = this.make.sprite({
800
- asset: j.WHITE,
2773
+ asset: k.WHITE,
801
2774
  tint: this.options.focusOverlay.backing.options?.color ?? 0,
802
2775
  alpha: this.options.focusOverlay.backing.options?.alpha ?? .8,
803
2776
  width: this.app.size.width,
@@ -812,12 +2785,12 @@ var jn = class extends w {
812
2785
  }
813
2786
  }
814
2787
  _showCloneOverlay() {
815
- this.cloneOverlay.pivot.y = -20, this.addAnimation(N.to(this.cloneOverlay, {
2788
+ this.cloneOverlay.pivot.y = -20, this.addAnimation(A.to(this.cloneOverlay, {
816
2789
  duration: .5,
817
2790
  alpha: .8,
818
2791
  ease: "sine.out",
819
2792
  delay: .1
820
- })), this.addAnimation(N.to(this.cloneOverlay.pivot, {
2793
+ })), this.addAnimation(A.to(this.cloneOverlay.pivot, {
821
2794
  duration: .5,
822
2795
  y: 0,
823
2796
  ease: "sine.out",
@@ -850,15 +2823,15 @@ var jn = class extends w {
850
2823
  }
851
2824
  _updateCaretAndSelection() {
852
2825
  if (!this.domElement) {
853
- b.warn(this.label, "No dom element");
2826
+ c.warn(this.label, "No dom element");
854
2827
  return;
855
2828
  }
856
2829
  let e = this.domElement.selectionStart || 0, t = this.domElement.selectionEnd || -1, n = this.domElement.selectionDirection, r = "", i = this.options.type === "password" ? this.input.text : this._value;
857
- if (t === void 0) r = i.substring(0, e), this._caretPosition = O.measureText(r, this.input.style).width, this._selectionRect = null;
2830
+ if (t === void 0) r = i.substring(0, e), this._caretPosition = T.measureText(r, this.input.style).width, this._selectionRect = null;
858
2831
  else {
859
2832
  r = i.substring(e > t ? t : e, e > t ? e : t);
860
- let a = i.substring(0, e > t ? t : e), o = O.measureText(a, this.input.style), s = O.measureText(r, this.input.style);
861
- this._selectionRect = new $t(o.width, 0, s.width, this.input.height), this._caretPosition = n === "backward" ? this._selectionRect.left : this._selectionRect.left + this._selectionRect.width;
2833
+ let a = i.substring(0, e > t ? t : e), o = T.measureText(a, this.input.style), s = T.measureText(r, this.input.style);
2834
+ this._selectionRect = new Tt(o.width, 0, s.width, this.input.height), this._caretPosition = n === "backward" ? this._selectionRect.left : this._selectionRect.left + this._selectionRect.width;
862
2835
  }
863
2836
  }
864
2837
  _handleDomElementChange(e) {
@@ -877,62 +2850,17 @@ var jn = class extends w {
877
2850
  let e = this._inputContainer.getBounds();
878
2851
  return e.width = this._lastWidth, e.height = this._lastHeight, e;
879
2852
  }
880
- };
881
- //#endregion
882
- //#region src/plugins/actions/methods.ts
883
- function Rn(e) {
884
- return e ?? h;
885
- }
886
- function zn(e, t, n = !0) {
887
- return n && (t = {
888
- ..._,
889
- ...t
890
- }), t;
891
- }
892
- function Bn(e) {
893
- return e || [];
894
- }
895
- //#endregion
896
- //#region src/plugins/breakpoints/methods.ts
897
- function Vn(e) {
898
- return {
899
- tiers: e.tiers,
900
- modes: e.modes ?? {}
901
- };
902
- }
903
- //#endregion
904
- //#region src/plugins/input/touch/constants.ts
905
- var G = /* @__PURE__ */ function(e) {
906
- return e.None = "none", e.Left = "left", e.Top = "top", e.Bottom = "bottom", e.Right = "right", e.TopLeft = "top_left", e.TopRight = "top_right", e.BottomLeft = "bottom_left", e.BottomRight = "bottom_right", e;
907
- }({}), Hn = [
908
- G.None,
909
- G.Left,
910
- G.Top,
911
- G.Bottom,
912
- G.Right,
913
- G.TopLeft,
914
- G.TopRight,
915
- G.BottomLeft,
916
- G.BottomRight
917
- ];
918
- //#endregion
919
- //#region src/plugins/input/methods.ts
920
- function Un(e, t, n) {
921
- return n || [];
922
- }
923
- //#endregion
924
- //#region src/ui/Joystick.ts
925
- var Wn = class extends w {
2853
+ }, Dr = class extends _ {
926
2854
  constructor(e) {
927
- if (super(), this.onChange = new T(), this.onStart = new T(), this.onEnd = new T(), this.onDestroy = new T(), this.outerRadius = 0, this.innerRadius = 0, this.innerAlphaStandby = .5, this.dragging = !1, this.pointData = new A(), this.direction = G.None, this.settings = Object.assign({
2855
+ if (super(), this.onChange = new p(), this.onStart = new p(), this.onEnd = new p(), this.onDestroy = new p(), this.outerRadius = 0, this.innerRadius = 0, this.innerAlphaStandby = .5, this.dragging = !1, this.pointData = new D(), this.direction = V.None, this.settings = Object.assign({
928
2856
  outerScale: 1,
929
2857
  innerScale: 1
930
2858
  }, e), !this.settings.outer) {
931
- let e = new k();
2859
+ let e = new E();
932
2860
  e.circle(0, 0, 60).fill({ color: 0 }), e.alpha = .5, this.settings.outer = e;
933
2861
  }
934
2862
  if (!this.settings.inner) {
935
- let e = new k();
2863
+ let e = new E();
936
2864
  e.circle(0, 0, 35).fill({ color: 0 }), e.alpha = this.innerAlphaStandby, this.settings.inner = e;
937
2865
  }
938
2866
  this.threshold = this.settings.threshold ?? .01, this.initialize();
@@ -942,12 +2870,12 @@ var Wn = class extends w {
942
2870
  }
943
2871
  handleDragMove(e) {
944
2872
  if (!this.dragging || e.pointerId !== this._pointerId) return;
945
- let t = this.toLocal(e.global), n = t.x - this.startPosition.x, r = t.y - this.startPosition.y, i = new A(0, 0), a = 0, o = G.None;
2873
+ let t = this.toLocal(e.global), n = t.x - this.startPosition.x, r = t.y - this.startPosition.y, i = new D(0, 0), a = 0, o = V.None;
946
2874
  if (n == 0 && r == 0) {
947
2875
  this.direction = o;
948
2876
  return;
949
2877
  }
950
- if (n === 0 && (r > 0 ? (i.set(0, r > this.outerRadius ? this.outerRadius : r), a = 270, o = G.Bottom) : (i.set(0, -(Math.abs(r) > this.outerRadius ? this.outerRadius : Math.abs(r))), a = 90, o = G.Top), this.inner.position.set(i.x, i.y), this.power = this.getPower(i), this.power >= this.threshold)) {
2878
+ if (n === 0 && (r > 0 ? (i.set(0, r > this.outerRadius ? this.outerRadius : r), a = 270, o = V.Bottom) : (i.set(0, -(Math.abs(r) > this.outerRadius ? this.outerRadius : Math.abs(r))), a = 90, o = V.Top), this.inner.position.set(i.x, i.y), this.power = this.getPower(i), this.power >= this.threshold)) {
951
2879
  this.direction = o, this.onChange.emit({
952
2880
  angle: a,
953
2881
  direction: o,
@@ -955,7 +2883,7 @@ var Wn = class extends w {
955
2883
  });
956
2884
  return;
957
2885
  }
958
- if (r === 0 && (n > 0 ? (i.set(Math.abs(n) > this.outerRadius ? this.outerRadius : Math.abs(n), 0), a = 0, o = G.Right) : (i.set(-(Math.abs(n) > this.outerRadius ? this.outerRadius : Math.abs(n)), 0), a = 180, o = G.Left), this.inner.position.set(i.x, i.y), this.power = this.getPower(i), this.power >= this.threshold)) {
2886
+ if (r === 0 && (n > 0 ? (i.set(Math.abs(n) > this.outerRadius ? this.outerRadius : Math.abs(n), 0), a = 0, o = V.Right) : (i.set(-(Math.abs(n) > this.outerRadius ? this.outerRadius : Math.abs(n)), 0), a = 180, o = V.Left), this.inner.position.set(i.x, i.y), this.power = this.getPower(i), this.power >= this.threshold)) {
959
2887
  this.direction = o, this.onChange.emit({
960
2888
  angle: a,
961
2889
  direction: o,
@@ -979,7 +2907,7 @@ var Wn = class extends w {
979
2907
  this._pointerId === void 0 && (this._pointerId = e.pointerId, this.startPosition = this.toLocal(e.global), this.dragging = !0, this.inner.alpha = 1, this.onStart.emit());
980
2908
  }
981
2909
  handleDragEnd(e) {
982
- this._pointerId === e.pointerId && (this.direction = G.None, this.inner.position.set(0, 0), this.dragging = !1, this.inner.alpha = this.innerAlphaStandby, this.onEnd.emit(), this._pointerId = void 0);
2910
+ this._pointerId === e.pointerId && (this.direction = V.None, this.inner.position.set(0, 0), this.dragging = !1, this.inner.alpha = this.innerAlphaStandby, this.onEnd.emit(), this._pointerId = void 0);
983
2911
  }
984
2912
  bindEvents() {
985
2913
  this.eventMode = "static", this.on("pointerdown", this.handleDragStart).on("pointerup", this.handleDragEnd).on("pointerupoutside", this.handleDragEnd).on("pointermove", this.handleDragMove), window.addEventListener("pointerup", this.handleDragEnd);
@@ -990,24 +2918,24 @@ var Wn = class extends w {
990
2918
  }
991
2919
  getDirection(e) {
992
2920
  let t = Math.atan2(e.y, e.x);
993
- return t >= -Math.PI / 8 && t < 0 || t >= 0 && t < Math.PI / 8 ? G.Right : t >= Math.PI / 8 && t < 3 * Math.PI / 8 ? G.BottomRight : t >= 3 * Math.PI / 8 && t < 5 * Math.PI / 8 ? G.Bottom : t >= 5 * Math.PI / 8 && t < 7 * Math.PI / 8 ? G.BottomLeft : t >= 7 * Math.PI / 8 && t < Math.PI || t >= -Math.PI && t < -7 * Math.PI / 8 ? G.Left : t >= -7 * Math.PI / 8 && t < -5 * Math.PI / 8 ? G.TopLeft : t >= -5 * Math.PI / 8 && t < -3 * Math.PI / 8 ? G.Top : G.TopRight;
2921
+ return t >= -Math.PI / 8 && t < 0 || t >= 0 && t < Math.PI / 8 ? V.Right : t >= Math.PI / 8 && t < 3 * Math.PI / 8 ? V.BottomRight : t >= 3 * Math.PI / 8 && t < 5 * Math.PI / 8 ? V.Bottom : t >= 5 * Math.PI / 8 && t < 7 * Math.PI / 8 ? V.BottomLeft : t >= 7 * Math.PI / 8 && t < Math.PI || t >= -Math.PI && t < -7 * Math.PI / 8 ? V.Left : t >= -7 * Math.PI / 8 && t < -5 * Math.PI / 8 ? V.TopLeft : t >= -5 * Math.PI / 8 && t < -3 * Math.PI / 8 ? V.Top : V.TopRight;
994
2922
  }
995
- }, Gn = {
2923
+ }, Or = {
996
2924
  color: 0,
997
2925
  alpha: .75
998
- }, Kn = {
2926
+ }, kr = {
999
2927
  backing: !0,
1000
2928
  closeOnEscape: !0,
1001
2929
  closeOnPointerDownOutside: !0,
1002
2930
  actionContext: "popup"
1003
- }, qn = class e extends w {
2931
+ }, Ar = class e extends _ {
1004
2932
  get actionContext() {
1005
2933
  return this.config.actionContext;
1006
2934
  }
1007
2935
  constructor(e, t = {}) {
1008
2936
  super(), this.id = e, this.isShowing = !1, this._storedActionContext = void 0, this.config = Object.assign({
1009
2937
  id: e,
1010
- ...Kn
2938
+ ...kr
1011
2939
  }, t), this._initialize();
1012
2940
  }
1013
2941
  get data() {
@@ -1016,7 +2944,7 @@ var Wn = class extends w {
1016
2944
  static makeBacking(e, t) {
1017
2945
  let n = {};
1018
2946
  typeof e == "object" && (n = e);
1019
- let r = Object.assign({ ...Gn }, n), i = new en(j.WHITE);
2947
+ let r = Object.assign({ ...Or }, n), i = new Et(k.WHITE);
1020
2948
  return i.anchor.set(.5), i.alpha = r.alpha, i.tint = r.color, i.width = t.width, i.height = t.height, i;
1021
2949
  }
1022
2950
  initialize() {}
@@ -1050,184 +2978,15 @@ var Wn = class extends w {
1050
2978
  this.app.focus.addFocusLayer(this.id, !1), this.config.backing && (this.backing = this.add.existing(e.makeBacking(this.config.backing, this.app.size)), this.backing.eventMode = "static", this.config.closeOnPointerDownOutside && (this.backing.once("click", this.close), this.backing.once("tap", this.close))), this.view = this.add.container(), this.view.eventMode = "static";
1051
2979
  }
1052
2980
  setActionContext() {
1053
- this.actionContext && (this.app.actionContext = this.actionContext, b.log("Popup", "Setting action context", this.app.actionContext));
2981
+ this.actionContext && (this.app.actionContext = this.actionContext, c.log("Popup", "Setting action context", this.app.actionContext));
1054
2982
  }
1055
2983
  storeActionContext() {
1056
- this._storedActionContext = this.app.actionContext, b.log("Popup", "Storing action context", this._storedActionContext);
2984
+ this._storedActionContext = this.app.actionContext, c.log("Popup", "Storing action context", this._storedActionContext);
1057
2985
  }
1058
2986
  restoreActionContext() {
1059
- this._storedActionContext && (b.log("Popup", "Restoring action context", this._storedActionContext), this.app.actionContext = this._storedActionContext), this._storedActionContext = void 0;
1060
- }
1061
- }, K = [
1062
- "text",
1063
- "anchor",
1064
- "roundPixels",
1065
- "style",
1066
- "pivot"
1067
- ], q = 200, Jn = "CaperApplication";
1068
- function Yn() {
1069
- try {
1070
- return globalThis.Caper?.__dev === !0;
1071
- } catch {
1072
- return !1;
1073
- }
1074
- }
1075
- function Xn() {
1076
- try {
1077
- return !1;
1078
- } catch {
1079
- return !1;
1080
- }
1081
- }
1082
- var J = "__first__";
1083
- function Y() {
1084
- let e = globalThis, t = e.Caper ||= {};
1085
- return t.apps instanceof Map || (t.apps = /* @__PURE__ */ new Map()), (typeof t.automation != "object" || t.automation === null) && (t.automation = {}), t.__readyResolvers instanceof Map || (t.__readyResolvers = /* @__PURE__ */ new Map()), t.__readyApps instanceof Set || (t.__readyApps = /* @__PURE__ */ new Set()), typeof t.ready != "function" && (t.ready = (e) => {
1086
- let n = t.__readyResolvers, r = t.__readyApps;
1087
- if (e && r.has(e)) return Promise.resolve(t.apps.get(e));
1088
- if (!e && r.size > 0) {
1089
- let e = r.values().next().value;
1090
- return Promise.resolve(t.apps.get(e));
1091
- }
1092
- let i = e ?? J, a = n.get(i);
1093
- if (!a) {
1094
- let e, t = new Promise((t) => {
1095
- e = t;
1096
- });
1097
- a = {
1098
- resolve: e,
1099
- promise: t
1100
- }, n.set(i, a);
1101
- }
1102
- return a.promise;
1103
- }), t;
1104
- }
1105
- function Zn() {
1106
- Y();
1107
- }
1108
- function X(e) {
1109
- return e.config?.id || Jn;
1110
- }
1111
- function Qn(e) {
1112
- let t = X(e), n = [], r, i = [], a = (e) => {
1113
- n.push(e), n.length > q && n.splice(0, n.length - q);
1114
- }, o = () => r ? r() : void 0, s = (e) => {
1115
- if (i.length !== 0) for (let t = i.length - 1; t >= 0; t--) {
1116
- let n = !1;
1117
- try {
1118
- n = i[t].predicate(e);
1119
- } catch {
1120
- n = !1;
1121
- }
1122
- if (n) {
1123
- let [n] = i.splice(t, 1);
1124
- n.resolve(e);
1125
- }
1126
- }
1127
- }, c = {
1128
- appId: t,
1129
- get log() {
1130
- return n;
1131
- },
1132
- action(t, n) {
1133
- e.sendAction(t, n);
1134
- },
1135
- getContext() {
1136
- return String(e.actionContext);
1137
- },
1138
- getState: o,
1139
- registerStateGetter(e) {
1140
- r = e;
1141
- },
1142
- notifyStateChanged(e) {
1143
- a({
1144
- t: Date.now(),
1145
- kind: "state",
1146
- data: e
1147
- }), s(e);
1148
- },
1149
- waitFor(e, t) {
1150
- let n = o();
1151
- try {
1152
- if (e(n)) return Promise.resolve(n);
1153
- } catch {}
1154
- return new Promise((n, r) => {
1155
- let a, o = {
1156
- predicate: e,
1157
- resolve: (e) => {
1158
- a && clearTimeout(a), n(e);
1159
- }
1160
- };
1161
- i.push(o), t?.timeoutMs != null && (a = setTimeout(() => {
1162
- let e = i.indexOf(o);
1163
- e >= 0 && i.splice(e, 1), r(/* @__PURE__ */ Error(`waitFor timed out after ${t.timeoutMs}ms`));
1164
- }, t.timeoutMs));
1165
- });
1166
- }
1167
- }, l = e.getPlugin("actions");
1168
- return l && (l.onActionDispatched?.connect((e) => {
1169
- a({
1170
- t: Date.now(),
1171
- kind: "action",
1172
- name: String(e.id),
1173
- data: e.data
1174
- }), s(o());
1175
- }), l.onActionContextChanged.connect((e) => {
1176
- a({
1177
- t: Date.now(),
1178
- kind: "context",
1179
- name: String(e)
1180
- });
1181
- })), c;
1182
- }
1183
- function Z(e) {
1184
- let t = Y(), n = X(e);
1185
- if (t.apps.set(n, e), t.app = e, Yn() || e.config?.automation === !0 || Xn()) {
1186
- let r = Qn(e);
1187
- t.automation[n] = r, e.automation = r;
2987
+ this._storedActionContext && (c.log("Popup", "Restoring action context", this._storedActionContext), this.app.actionContext = this._storedActionContext), this._storedActionContext = void 0;
1188
2988
  }
1189
- }
1190
- function Q(e) {
1191
- let t = Y(), n = X(e);
1192
- t.__readyApps.add(n);
1193
- let r = t.__readyResolvers, i = r.get(n);
1194
- i && (i.resolve(e), r.delete(n));
1195
- let a = r.get(J);
1196
- a && (a.resolve(e), r.delete(J));
1197
- }
1198
- //#endregion
1199
- //#region src/core/create.ts
1200
- var $n = "caper-game-container";
1201
- function $(e) {
1202
- let t = document.createElement("div");
1203
- return t.setAttribute("id", e), document.body.appendChild(t), t;
1204
- }
1205
- async function er() {
1206
- return new Promise((e) => {
1207
- document.readyState === "complete" || document.readyState === "interactive" ? e(!0) : document.addEventListener("DOMContentLoaded", () => {
1208
- e(!0);
1209
- });
1210
- });
1211
- }
1212
- async function tr(e = { id: "CaperApplication" }, t = $n, n = !0) {
1213
- await er(), An(), n && U();
1214
- let r = null;
1215
- if (typeof t == "string" ? (r = document.getElementById(t), r ||= $(t)) : t instanceof HTMLElement ? r = t : t === window && (r = document.body), !r) throw Error("You passed in a DOM Element, but none was found. If you instead pass in a string, a container will be created for you, using the string for its id.");
1216
- e.resizeToContainer && (e.resizeTo = r), e.useLayout && (e.layout = {
1217
- autoUpdate: !1,
1218
- enableDebug: !1,
1219
- debugModificationCount: 0,
1220
- throttle: 100
1221
- }), e.container = r;
1222
- let i = new (e.application || C)();
1223
- return await i.initialize(e, r), e.useLayout && (i.stage.layout = {
1224
- position: "absolute",
1225
- width: "100%",
1226
- height: "100%"
1227
- }), await i._postInitialize(), Z(i), globalThis.Caper?.__runtimeManaged || Q(i), i;
1228
- }
1229
- //#endregion
1230
- var nr = D.Collector, rr = D.CollectorArray, ir = D.CollectorLast, ar = D.CollectorUntil0, or = D.CollectorWhile0, sr = D.SignalConnections;
1231
- export { ve as ActionsPlugin, st as Animated, wt as AnimatedSprite, C as Application, se as AssetsPlugin, De as AudioChannel, ne as AudioInstance, ke as AudioManagerPlugin, je as BreakpointPlugin, At as Button, ut as ButtonConfigKeys, Pn as Camera, Fn as CameraController, Ft as CaperEvent, nr as Collector, rr as CollectorArray, ir as CollectorLast, ar as CollectorUntil0, or as CollectorWhile0, sn as Color, w as Container, Qe as ContainerConfigKeys, pt as Controls, Xt as DataAdapter, bt as DebugAlpha, kt as DebugColors, Dt as DefaultActionContexts, h as DefaultActionContextsArray, Fe as DefaultActions, Ne as DefaultButtonIds, jn as Entity, ct as Factory, et as FlexContainer, It as FlexContainerConfigKeys, qt as FocusManagerPlugin, i as FocusOutliner, x as Focusable, be as FullScreenPlugin, ie as GesturePlugin, Ln as Input, ge as InputControllerTypes, me as InputPlugin, S as Interactive, Hn as JOYSTICK_DIRECTIONS, Wn as Joystick, G as JoystickDirection, dt as KeyboardControls, de as KeyboardPlugin, b as Logger, l as LookupPlugin, Ye as ParticleContainer, gt as ParticleContainerConfigKeys, e as Plugin, qn as Popup, d as PopupManagerPlugin, Pe as Queue, Te as ResizerPlugin, Mn as Scene, Vt as SceneManagerPlugin, Nn as SceneTransition, T as Signal, sr as SignalConnections, Ue as SpineAnimation, Be as Store, Nt as Svg, K as TextPropsKeys, Ut as Timer, Se as TimerPlugin, zt as Toast, Re as Toaster, n as TouchControls, n as VirtualControls, ot as UICanvas, it as UICanvasConfigKeys, We as WebEventsPlugin, v as WithSignals, Ee as add, f as addToPoint, y as bindAllMethods, at as bindMethods, Bt as bool, Rt as capitalize, Ze as capitalizeWords, Cn as center, ze as checkAndInvokeMethod, Oe as clamp, Pt as coreFunctionRegistry, yt as coreSignalRegistry, tr as create, $ as createContainer, lt as createDebugGraphics, He as createDebugLabel, rt as createFactoryMethods, Le as createQueue, Ae as debounce, ue as deepMerge, _ as defaultActionsList, te as defaultBreakpoints, Ve as defaultFactoryMethods, le as defaultGestureOptions, Gt as defaultToastConfig, zn as defineActions, Vn as defineBreakpoints, Bn as defineButtons, Wt as defineConfig, Rn as defineContexts, Un as defineControls, Yt as defineData, dn as defineEntity, ln as definePlugin, un as definePopup, cn as defineScene, fn as defineUI, ye as delay, rn as destroyCanvas, u as distance, he as distanceSq, p as ensurePadding, nt as env, En as filterSet, Dn as firstFromSet, Kt as floatBetween, Ge as floatBetweenPoint, o as formatTime, we as generatePluginList, Ct as getDebugRegistry, Ie as getDynamicModuleFromImportListItem, St as getErrorTexture, m as getFirstMapEntry, ce as getLastMapEntry, B as getNearestCharacterIndex, Ot as getNextMapEntry, Ht as getOrientation, oe as getPreviousMapEntry, nn as getRandomElement, _t as getRegisteredEntityIds, Tt as getRegisteredUIIds, a as getZeroPaddedNumber, ee as i18nPlugin, Zn as installCaperGlobal, E as intBetween, Ce as intBetweenPoint, z as isAndroid, Et as isDev, xn as isIos, R as isMobile, vt as isProduction, t as isPromise, bn as isRetina, Ke as isStorageCapable, xt as isText, L as isTouch, On as lastFromSet, Me as lerp, mt as lerpPoint, r as magnitude, ft as multiply, fe as normalizeKey, mn as objectDiagonal, Sn as offset, _n as offsetShape, vn as offsetSimpleShape, xe as omitKeys, H as pixiVersion, Jt as pluck, s as randomUUID, pn as reParent, Z as registerCaperApp, Mt as registerDebug, jt as resolveAnchor, ae as resolvePadding, qe as resolvePivot, g as resolvePointLike, ht as resolvePosition, Lt as resolveScale, re as resolveSizeLike, Xe as resolveTexture, tt as resolveUnknownKeys, U as sayHello, wn as scale, I as scaleToHeight, yn as scaleToSize, F as scaleToWidth, P as scaleUniform, gn as sendToBack, hn as sendToFront, tn as shuffle, Q as signalCaperReady, Tn as size, c as sortPluginsByRequires, pe as subtract, _e as subtractFromPoint, an as toHex, on as toRgb, Je as unregisterDebug, V as version, $e as wait };
2989
+ }, jr = x.Collector, Mr = x.CollectorArray, Nr = x.CollectorLast, Pr = x.CollectorUntil0, Fr = x.CollectorWhile0, Ir = x.SignalConnections;
2990
+ export { ae as ActionsPlugin, Be as Animated, Kn as AnimatedSprite, S as Application, Se as AssetsPlugin, Ke as AudioChannel, ue as AudioInstance, s as AudioManagerPlugin, t as BreakpointPlugin, er as Button, Qn as ButtonConfigKeys, qn as Camera, Jn as CameraController, u as CaperEvent, jr as Collector, Mr as CollectorArray, Nr as CollectorLast, Pr as CollectorUntil0, Fr as CollectorWhile0, Pt as Color, _ as Container, b as ContainerConfigKeys, Oe as Controls, yt as DataAdapter, M as DebugAlpha, j as DebugColors, se as DefaultActionContexts, le as DefaultActionContextsArray, fe as DefaultActions, d as DefaultButtonIds, Ln as Entity, v as Factory, ir as FlexContainer, rr as FlexContainerConfigKeys, ye as FocusManagerPlugin, l as FocusOutliner, J as Focusable, r as FullScreenPlugin, a as GesturePlugin, Er as Input, ft as InputControllerTypes, Re as InputPlugin, Zn as Interactive, bn as JOYSTICK_DIRECTIONS, Dr as Joystick, V as JoystickDirection, mt as KeyboardControls, he as KeyboardPlugin, c as Logger, He as LookupPlugin, Bn as ParticleContainer, Rn as ParticleContainerConfigKeys, te as Plugin, Ar as Popup, Fe as PopupManagerPlugin, pt as Queue, ot as ResizerPlugin, Vn as Scene, Je as SceneManagerPlugin, Hn as SceneTransition, p as Signal, Ir as SignalConnections, Xn as SpineAnimation, ee as Store, Un as Svg, wr as TextPropsKeys, $e as Timer, nt as TimerPlugin, ar as Toast, sr as Toaster, ct as TouchControls, ct as VirtualControls, pr as UICanvas, cr as UICanvasConfigKeys, Ae as WebEventsPlugin, h as WithSignals, e as add, Ie as addToPoint, m as bindAllMethods, pe as bindMethods, re as bool, de as capitalize, qe as capitalizeWords, rn as center, f as checkAndInvokeMethod, Xe as clamp, ur as computeEffectivePadding, it as coreFunctionRegistry, Ze as coreSignalRegistry, In as create, Pn as createContainer, Ft as createDebugGraphics, N as createDebugLabel, xe as createFactoryMethods, ve as createQueue, Le as debounce, Ye as deepMerge, ne as defaultActionsList, We as defaultBreakpoints, Cr as defaultFactoryMethods, ut as defaultGestureOptions, Y as defaultToastConfig, _n as defineActions, yn as defineBreakpoints, vn as defineButtons, Ee as defineConfig, gn as defineContexts, xn as defineControls, vt as defineData, Vt as defineEntity, zt as definePlugin, Bt as definePopup, Rt as defineScene, Ht as defineUI, o as delay, jt as destroyCanvas, at as distance, Qe as distanceSq, I as ensurePadding, n as env, sn as filterSet, cn as firstFromSet, oe as floatBetween, ge as floatBetweenPoint, Ne as formatTime, Te as generatePluginList, Lt as getDebugRegistry, Me as getDynamicModuleFromImportListItem, U as getErrorTexture, ze as getFirstMapEntry, ke as getLastMapEntry, un as getNearestCharacterIndex, lt as getNextMapEntry, me as getOrientation, ht as getPreviousMapEntry, At as getRandomElement, gr as getRegisteredEntityIds, yr as getRegisteredUIIds, Ut as getZeroPaddedNumber, _e as i18nPlugin, On as installCaperGlobal, _t as intBetween, i as intBetweenPoint, en as isAndroid, Ge as isDev, tn as isIos, $t as isMobile, ce as isProduction, dt as isPromise, Qt as isRetina, ie as isStorageCapable, nr as isText, B as isTouch, ln as lastFromSet, Ve as lerp, tt as lerpPoint, Ue as magnitude, je as multiply, gt as normalizeKey, Kt as objectDiagonal, nn as offset, Yt as offsetShape, Xt as offsetSimpleShape, st as omitKeys, fn as pixiVersion, g as pluck, Ce as randomUUID, Gt as reParent, jn as registerCaperApp, P as registerDebug, Gn as resolveAnchor, Wt as resolvePadding, q as resolvePivot, y as resolvePointLike, G as resolvePosition, K as resolveScale, et as resolveSizeLike, W as resolveTexture, H as resolveUnknownKeys, mn as sayHello, an as scale, z as scaleToHeight, Zt as scaleToSize, R as scaleToWidth, L as scaleUniform, Jt as sendToBack, qt as sendToFront, kt as shuffle, Mn as signalCaperReady, on as size, De as sortPluginsByRequires, rt as subtract, Pe as subtractFromPoint, Mt as toHex, Nt as toRgb, F as unregisterDebug, dn as version, be as wait };
1232
2991
 
1233
2992
  //# sourceMappingURL=caper.mjs.map