@caperjs/core 0.2.2 → 0.2.3

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 (137) 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 +2107 -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 +1 -1
  80. package/lib/ui/Button.d.ts.map +1 -1
  81. package/lib/ui/FlexContainer.d.ts +1 -1
  82. package/lib/ui/FlexContainer.d.ts.map +1 -1
  83. package/lib/ui/Input.d.ts +2 -2
  84. package/lib/ui/Input.d.ts.map +1 -1
  85. package/lib/ui/Joystick.d.ts +1 -1
  86. package/lib/ui/Joystick.d.ts.map +1 -1
  87. package/lib/ui/Toast.d.ts +1 -1
  88. package/lib/ui/Toast.d.ts.map +1 -1
  89. package/lib/ui/UICanvas.d.ts +11 -1
  90. package/lib/ui/UICanvas.d.ts.map +1 -1
  91. package/lib/ui/UICanvas.test.d.ts +2 -0
  92. package/lib/ui/UICanvas.test.d.ts.map +1 -0
  93. package/lib/utils/types.d.ts +1 -2
  94. package/lib/utils/types.d.ts.map +1 -1
  95. package/package.json +1 -1
  96. package/src/core/Application.ts +15 -2
  97. package/src/core/interfaces/IApplicationOptions.ts +1 -1
  98. package/src/core/interfaces/ICoreFunctions.ts +1 -0
  99. package/src/display/AnimatedSprite.ts +2 -1
  100. package/src/display/Container.ts +3 -1
  101. package/src/display/SpineAnimation.ts +3 -2
  102. package/src/importOrder.containerFirst.test.ts +32 -0
  103. package/src/importOrder.displayFirst.test.ts +19 -0
  104. package/src/importOrder.mixinsFirst.test.ts +18 -0
  105. package/src/importOrder.sceneFirst.test.ts +21 -0
  106. package/src/importOrder.toastFirst.test.ts +20 -0
  107. package/src/importOrder.uiFirst.test.ts +24 -0
  108. package/src/mixins/factory/Factory.test.ts +22 -0
  109. package/src/mixins/factory/Factory.ts +9 -2
  110. package/src/mixins/factory/const.ts +18 -11
  111. package/src/mixins/factory/defaults.ts +28 -0
  112. package/src/mixins/factory/methods.ts +1 -1
  113. package/src/mixins/factory/props.ts +5 -3
  114. package/src/plugins/LookupPlugin.ts +1 -1
  115. package/src/plugins/PopupManagerPlugin.ts +1 -1
  116. package/src/plugins/ResizerPlugin.test.ts +84 -0
  117. package/src/plugins/ResizerPlugin.ts +59 -1
  118. package/src/plugins/WebEventsPlugin.test.ts +75 -0
  119. package/src/plugins/WebEventsPlugin.ts +15 -0
  120. package/src/plugins/captions/CaptionsRenderer.ts +1 -1
  121. package/src/plugins/i18nPlugin.test.ts +124 -0
  122. package/src/plugins/i18nPlugin.ts +57 -18
  123. package/src/plugins/input/keyboard/KeyboardContols.ts +1 -1
  124. package/src/plugins/input/touch/VirtualControls.ts +2 -2
  125. package/src/plugins/spine/pixi-spine/require-shim.ts +3 -1
  126. package/src/ui/Button.ts +5 -1
  127. package/src/ui/FlexContainer.ts +3 -2
  128. package/src/ui/Input.ts +5 -2
  129. package/src/ui/Joystick.ts +1 -1
  130. package/src/ui/Toast.ts +2 -1
  131. package/src/ui/Toaster.ts +1 -1
  132. package/src/ui/UICanvas.test.ts +35 -0
  133. package/src/ui/UICanvas.ts +46 -8
  134. package/src/utils/types.ts +1 -1
  135. package/src/version.ts +1 -1
  136. package/lib/CaptionsPlugin-DeGyPecB.js.map +0 -1
  137. 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.3", 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 {
622
+ constructor(e) {
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 {
300
776
  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;
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,1546 @@ 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));
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.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
+ addLabel(e) {
1075
+ 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;
1076
+ else switch (e.anchor = .5, e.type) {
1077
+ case "bitmap":
1078
+ this._textLabel = this.add.bitmapText({
1079
+ ...e,
1080
+ layout: !1
1081
+ });
1082
+ break;
1083
+ case "html":
1084
+ this._textLabel = this.add.htmlText({
1085
+ ...e,
1086
+ layout: !1
1087
+ });
1088
+ break;
1089
+ default:
1090
+ this._textLabel = this.add.text({
1091
+ ...e,
1092
+ layout: !1
1093
+ });
1094
+ break;
1095
+ }
1096
+ return this.positionLabel(), this._textLabel;
1097
+ }
1098
+ positionLabel() {
1099
+ this._textLabel && this._textLabel.position.set(this.view.width * .5, this.view.height * .5);
1100
+ }
1101
+ get enabled() {
1102
+ return this._enabled;
1103
+ }
1104
+ get app() {
1105
+ return S.getInstance();
1106
+ }
1107
+ destroy(e) {
1108
+ this.onDestroy.emit(), super.destroy(e);
1109
+ }
1110
+ focusOut() {
1111
+ super.focusOut(), this.isDown = !1, this.isOver = !1;
1112
+ }
1113
+ blur() {
1114
+ super.blur(), this.isDown = !1, this.isOver = !1;
1115
+ }
1116
+ getFocusArea() {
1117
+ return this.view.getBounds().clone();
1118
+ }
1119
+ addIsDownCallback(e, t) {
1120
+ this._isDownCallbacks.set(e, t), this._checkIsDownCallbacks();
1121
+ }
1122
+ removeIsDownCallback(e) {
1123
+ this._isDownCallbacks.delete(e);
1124
+ }
1125
+ setTexture(e, t) {
1126
+ this.config.textures[e] = t, e === "default" && (this.view.texture = this.make.texture({
1127
+ asset: this.config.textures.default,
1128
+ sheet: this.config.sheet
1129
+ })), this.positionLabel();
1130
+ }
1131
+ handlePointerOver() {
1132
+ this._enabled && (this.isOver ||= !0, !this.isDown && (this.view.texture = this.make.texture({
1133
+ asset: this.config.textures.hover || this.config.textures.default,
1134
+ sheet: this.config.sheet
1135
+ }), 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)));
1136
+ }
1137
+ handlePointerOut() {
1138
+ this.isOver = !1, this._enabled && (this.isDown || (this.view.texture = this.make.texture({
1139
+ asset: this.config.textures.default,
1140
+ sheet: this.config.sheet
1141
+ }), this.config.sounds?.out && this.app.audio.play(this.config.sounds.out, "sfx"), this.onOut.emit()));
1142
+ }
1143
+ handlePointerDown(e) {
1144
+ !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({
1145
+ asset: this.config.textures.active || this.config.textures.hover || this.config.textures.default,
1146
+ sheet: this.config.sheet
1147
+ }), 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));
1148
+ }
1149
+ handlePointerUp(e) {
1150
+ !this._enabled || !this.isOver || e.pointerId !== this._pointerId || (window.removeEventListener("pointerup", this.handlePointerUpOutside), this.view.texture = this.make.texture({
1151
+ asset: this.config.textures.default,
1152
+ sheet: this.config.sheet
1153
+ }), this.onUp.emit(), this._pointerId = void 0);
1154
+ }
1155
+ handleClick() {
1156
+ this._enabled && (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));
1157
+ }
1158
+ handlePointerUpOutside(e) {
1159
+ !this._enabled || e.pointerId !== this._pointerId || (window.removeEventListener("pointerup", this.handlePointerUpOutside), this.off("pointerupoutside", this.handlePointerUpOutside), this.view.texture = this.make.texture({
1160
+ asset: this.config.textures.default,
1161
+ sheet: this.config.sheet
1162
+ }), this.isDown = !1, this.isOver = !1, this.onUpOutside.emit(), this._pointerId = void 0);
1163
+ }
1164
+ _doAction(e) {
1165
+ typeof e == "function" ? e() : (e.data.button || (e.data.button = this), this.app.action(e.id, e.data));
1166
+ }
1167
+ _checkIsDownCallbacks() {
1168
+ !this._isDownListenerAdded && this._isDownCallbacks.size > 0 ? (this._isDownListenerAdded = !0, this.app.ticker.add(this._handleIsDownCallbacks)) : (this.app.ticker.remove(this._handleIsDownCallbacks), this._isDownListenerAdded = !1);
1169
+ }
1170
+ _handleIsDownCallbacks() {
1171
+ this.isDown && this._isDownCallbacks.forEach((e) => {
1172
+ e();
1173
+ });
1174
+ }
1175
+ }, tr = h(v());
1176
+ function nr(e) {
1177
+ return e instanceof O || e instanceof w;
1178
+ }
1179
+ var rr = [
1180
+ "bindTo",
1181
+ "bindToAppSize",
1182
+ "autoLayoutChildren",
1183
+ "debug"
1184
+ ], ir = class extends tr {
1185
+ constructor(e = {}) {
1186
+ 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");
1187
+ m(this), this.config = {
1188
+ autoLayoutChildren: !0,
1189
+ ...e
1190
+ }, 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);
1191
+ }
1192
+ createLayout(e) {
1193
+ e?.layout === !0 && (e.layout = {});
1194
+ let t = { ...e?.layout ?? {} };
1195
+ 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;
1196
+ }
1197
+ handleAdded() {
1198
+ this.updateLayout();
1199
+ }
1200
+ _updateLayout() {
1201
+ this.app.ticker.addOnce(this.updateLayout);
1202
+ }
1203
+ handleChildAdded(e) {
1204
+ 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();
1205
+ }
1206
+ handleChildRemoved(e) {
1207
+ e.off("layout", this._updateLayout), _.childRemoved(e), this._updateLayout();
1208
+ }
1209
+ handleResize() {
1210
+ this.config.bindToAppSize && (this.layout = {
1211
+ width: this.app.size.width,
1212
+ height: this.app.size.height
1213
+ }), this._updateLayout();
1214
+ }
1215
+ handleBindToResize() {
1216
+ this.config.bindTo && (this.layout = {
1217
+ width: this.config.bindTo.width,
1218
+ height: this.config.bindTo.height
1219
+ }, this._updateLayout());
1220
+ }
1221
+ updateLayout() {
1222
+ this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this.onLayoutComplete.emit(), this.config.debug && this.drawDebug());
1223
+ }
1224
+ get app() {
1225
+ return S.getInstance();
1226
+ }
1227
+ configure(e) {
1228
+ this.layout = e, this._updateLayout();
1229
+ }
1230
+ get gap() {
1231
+ return this.layout?.style?.gap ?? 0;
1232
+ }
1233
+ set gap(e) {
1234
+ this.layout = { gap: e }, this._updateLayout();
1235
+ }
1236
+ get flexWrap() {
1237
+ return this.layout?.style?.flexWrap;
1238
+ }
1239
+ set flexWrap(e) {
1240
+ this.layout = { flexWrap: e }, this._updateLayout();
1241
+ }
1242
+ get flexDirection() {
1243
+ return this.layout?.style?.flexDirection;
1244
+ }
1245
+ set flexDirection(e) {
1246
+ this.layout = { flexDirection: e }, this._updateLayout();
1247
+ }
1248
+ get alignItems() {
1249
+ return this.layout?.style?.alignItems;
1250
+ }
1251
+ set alignItems(e) {
1252
+ this.layout = { alignItems: e }, this._updateLayout();
1253
+ }
1254
+ get justifyContent() {
1255
+ return this.layout?.style?.justifyContent;
1256
+ }
1257
+ set justifyContent(e) {
1258
+ this.layout = { justifyContent: e }, this._updateLayout();
1259
+ }
1260
+ get size() {
1261
+ return {
1262
+ width: this.layout?.style?.width,
1263
+ height: this.layout?.style?.height
1264
+ };
1265
+ }
1266
+ set size(e) {
1267
+ Array.isArray(e) && (e = {
1268
+ width: e[0],
1269
+ height: e[1]
1270
+ }), (typeof e == "number" || typeof e == "string") && (e = {
1271
+ width: e,
1272
+ height: e
1273
+ }), this.layout = { ...e }, this._updateLayout();
1274
+ }
1275
+ get layoutWidth() {
1276
+ return this.layout?.style?.width;
1277
+ }
1278
+ set layoutWidth(e) {
1279
+ this.layout = { width: e }, this._updateLayout();
1280
+ }
1281
+ get layoutHeight() {
1282
+ return this.layout?.style?.height;
1283
+ }
1284
+ set layoutHeight(e) {
1285
+ this.layout = { height: e }, this._updateLayout();
1286
+ }
1287
+ get padding() {
1288
+ return this.layout?.style?.padding;
1289
+ }
1290
+ set padding(e) {
1291
+ this.layout = { padding: e }, this._updateLayout();
1292
+ }
1293
+ get paddingTop() {
1294
+ return this.layout?.style?.paddingTop;
1295
+ }
1296
+ set paddingTop(e) {
1297
+ this.layout = { paddingTop: e }, this._updateLayout();
1298
+ }
1299
+ get paddingRight() {
1300
+ return this.layout?.style?.paddingRight;
1301
+ }
1302
+ set paddingRight(e) {
1303
+ this.layout = { paddingRight: e }, this._updateLayout();
1304
+ }
1305
+ get paddingBottom() {
1306
+ return this.layout?.style?.paddingBottom;
1307
+ }
1308
+ set paddingBottom(e) {
1309
+ this.layout = { paddingBottom: e }, this._updateLayout();
1310
+ }
1311
+ get paddingLeft() {
1312
+ return this.layout?.style?.paddingLeft;
1313
+ }
1314
+ set paddingLeft(e) {
1315
+ this.layout = { paddingLeft: e }, this._updateLayout();
1316
+ }
1317
+ get margin() {
1318
+ return this.layout?.style?.margin;
1319
+ }
1320
+ set margin(e) {
1321
+ this.layout = { margin: e }, this._updateLayout();
1322
+ }
1323
+ get marginTop() {
1324
+ return this.layout?.style?.marginTop;
1325
+ }
1326
+ set marginTop(e) {
1327
+ this.layout = { marginTop: e }, this._updateLayout();
1328
+ }
1329
+ get marginRight() {
1330
+ return this.layout?.style?.marginRight;
1331
+ }
1332
+ set marginRight(e) {
1333
+ this.layout = { marginRight: e }, this._updateLayout();
1334
+ }
1335
+ get marginBottom() {
1336
+ return this.layout?.style?.marginBottom;
1337
+ }
1338
+ set marginBottom(e) {
1339
+ this.layout = { marginBottom: e }, this._updateLayout();
1340
+ }
1341
+ get marginLeft() {
1342
+ return this.layout?.style?.marginLeft;
1343
+ }
1344
+ set marginLeft(e) {
1345
+ this.layout = { marginLeft: e }, this._updateLayout();
1346
+ }
1347
+ get debug() {
1348
+ return this.config.debug ?? !1;
1349
+ }
1350
+ set debug(e) {
1351
+ 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));
1352
+ }
1353
+ drawDebug() {
1354
+ (!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();
1355
+ let e = this.layout?.computedLayout;
1356
+ if (!e) return;
1357
+ let t = e.width, n = e.height, r = this.layout?.style?.flexDirection ?? "row", i = this.layout?.style?.gap ?? 0;
1358
+ this._debugGraphics.rect(0, 0, t, n).stroke({
1359
+ width: 1,
1360
+ color: j.bounds,
1361
+ alpha: M.stroke,
1362
+ pixelLine: !0
1363
+ });
1364
+ 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;
1365
+ a > 0 && this._debugGraphics.rect(0, 0, t, a).fill({
1366
+ color: j.outerBounds,
1367
+ alpha: M.fill
1368
+ }), s > 0 && this._debugGraphics.rect(0, n - s, t, s).fill({
1369
+ color: j.outerBounds,
1370
+ alpha: M.fill
1371
+ }), c > 0 && this._debugGraphics.rect(0, a, c, n - a - s).fill({
1372
+ color: j.outerBounds,
1373
+ alpha: M.fill
1374
+ }), o > 0 && this._debugGraphics.rect(t - o, a, o, n - a - s).fill({
1375
+ color: j.outerBounds,
1376
+ alpha: M.fill
1377
+ });
1378
+ let l = Math.min(t, n, 40), u = t / 2, d = n / 2, f = r === "row" || r === "row-reverse";
1379
+ if (f) {
1380
+ let e = r === "row" ? 1 : -1, t = u - e * l / 2, n = u + e * l / 2;
1381
+ 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({
1382
+ width: 1,
1383
+ color: j.direction,
1384
+ alpha: .8,
1385
+ pixelLine: !0
1386
+ });
1387
+ } else {
1388
+ let e = r === "column" ? 1 : -1, t = d - e * l / 2, n = d + e * l / 2;
1389
+ 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({
1390
+ width: 1,
1391
+ color: j.direction,
1392
+ alpha: .8,
1393
+ pixelLine: !0
1394
+ });
1395
+ }
1396
+ if (i > 0) for (let e = 0; e < this.children.length - 1; e++) {
1397
+ let r = this.children[e];
1398
+ if (r === this._debugGraphics || r === this._debugLabel || !r.layout?.computedLayout) continue;
1399
+ let a = r.layout.computedLayout;
1400
+ if (f) {
1401
+ let e = a.left + a.width;
1402
+ this._debugGraphics.rect(e, 0, i, n).fill({
1403
+ color: j.gap,
1404
+ alpha: M.fill
1405
+ });
1406
+ } else {
1407
+ let e = a.top + a.height;
1408
+ this._debugGraphics.rect(0, e, t, i).fill({
1409
+ color: j.gap,
1410
+ alpha: M.fill
1411
+ });
1412
+ }
1413
+ }
1414
+ for (let e of this.children) {
1415
+ if (e === this._debugGraphics || e === this._debugLabel || !e.layout?.computedLayout) continue;
1416
+ let t = e.layout.computedLayout;
1417
+ this._debugGraphics.rect(t.left, t.top, t.width, t.height).stroke({
1418
+ width: 1,
1419
+ color: j.innerBounds,
1420
+ alpha: .4,
1421
+ pixelLine: !0
1422
+ });
1423
+ }
1424
+ this._debugLabel.position.set(2, 2);
1425
+ }
1426
+ destroy() {
1427
+ 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();
1428
+ }
1429
+ }, Y = {
1430
+ type: "info",
1431
+ duration: 3e3,
1432
+ width: 300,
1433
+ height: 80,
1434
+ backgroundColor: 0,
1435
+ backgroundAlpha: .8,
1436
+ cornerRadius: 0,
1437
+ padding: 10,
1438
+ autoClose: !0,
1439
+ textAlign: "center",
1440
+ verticalAlign: "middle",
1441
+ colorBarWidth: 6,
1442
+ shadow: {
1443
+ color: 0,
1444
+ alpha: .2,
1445
+ offset: {
1446
+ x: 1,
1447
+ y: 3
1448
+ }
1449
+ },
1450
+ closeButton: {
1451
+ show: !1,
1452
+ position: "top right",
1453
+ size: 12,
1454
+ offset: 4
1455
+ },
1456
+ style: {
1457
+ fill: 16777215,
1458
+ fontSize: 16,
1459
+ wordWrap: !0
1460
+ },
1461
+ textColors: {
1462
+ info: 3447003,
1463
+ success: 3066993,
1464
+ warning: 15844367,
1465
+ error: 15158332
1466
+ }
1467
+ }, ar = class extends h(_) {
1468
+ set toaster(e) {
1469
+ this._toaster = e;
1470
+ }
1471
+ get toaster() {
1472
+ return this._toaster;
1473
+ }
1474
+ set text(e) {
1475
+ this.textDisplay.text = e, this.alignText();
1476
+ }
1477
+ constructor(e = {}) {
1478
+ super(), this.onToastClosed = new p(), this.isHiding = !1, this.config = {
1479
+ ...Y,
1480
+ ...e
1481
+ }, this.initialize();
1482
+ }
1483
+ initialize() {
1484
+ 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({
1485
+ color: this.config.shadow.color ?? 0,
1486
+ alpha: this.config.shadow.alpha ?? .2
1487
+ })), this.background = this.view.add.graphics().roundRect(0, 0, this.config.width, this.config.height, this.config.cornerRadius).fill({
1488
+ color: this.config.backgroundColor,
1489
+ alpha: this.config.backgroundAlpha
1490
+ }), this.config.type) {
1491
+ 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] });
1492
+ t.mask = e, this.view.addChild(e), this.view.addChild(t);
1493
+ }
1494
+ this.config.closeButton?.show && this.addCloseButton();
1495
+ 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;
1496
+ this.textDisplay = this.view.add.text({
1497
+ text: this.config.message,
1498
+ style: {
1499
+ ...Y.style,
1500
+ ...this.config.style,
1501
+ wordWrapWidth: this.config.style?.wordWrapWidth ?? this.config.width - e - t
1502
+ },
1503
+ x: e,
1504
+ y: this.config.padding
1505
+ }), 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);
1506
+ }
1507
+ addCloseButton() {
1508
+ 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";
1509
+ this.closeButton = this.view.add.existing(new e({ cursor: "pointer" }));
1510
+ let i = r === "top right" ? this.config.width - t * .5 - n : t * .5 + n, a = t * .5 + n;
1511
+ this.closeButton.position.set(i, a), this.closeButton.onClick.connect(() => {
1512
+ this.hide();
1513
+ });
1514
+ }
1515
+ alignText() {
1516
+ switch (this.config.textAlign) {
1517
+ case "left":
1518
+ this.textDisplay.anchor.set(0, .5);
1519
+ break;
1520
+ case "center":
1521
+ this.textDisplay.anchor.set(.5, .5), this.textDisplay.x = this.config.width / 2;
1522
+ break;
1523
+ case "right":
1524
+ this.textDisplay.anchor.set(1, .5);
1525
+ break;
1526
+ }
1527
+ switch (this.config.verticalAlign) {
1528
+ case "top":
1529
+ this.textDisplay.y = this.config.padding;
1530
+ break;
1531
+ case "middle":
1532
+ this.textDisplay.y = this.config.height * .5;
1533
+ break;
1534
+ case "bottom":
1535
+ this.textDisplay.y = this.config.height - this.textDisplay.height - this.config.padding;
1536
+ break;
1537
+ }
1538
+ }
1539
+ getShowAnimation() {
1540
+ let e = A.timeline({ paused: !0 });
1541
+ return e.to(this, {
1542
+ alpha: 1,
1543
+ duration: .4,
1544
+ ease: "power2.out"
1545
+ }), e;
1546
+ }
1547
+ getHideAnimation() {
1548
+ let e = A.timeline({ paused: !0 });
1549
+ return e.to(this, {
1550
+ alpha: 0,
1551
+ duration: .25,
1552
+ ease: "power2.in"
1553
+ }), e;
1554
+ }
1555
+ async show() {
1556
+ return this.timeline = this.getShowAnimation(), await this.timeline.play(), this.config.autoClose && (this.closeTimeout = setTimeout(() => {
1557
+ this.hide();
1558
+ }, this.config.duration)), this;
1559
+ }
1560
+ async hide() {
1561
+ if (this.isHiding || this.destroyed) return this;
1562
+ this.isHiding = !0, this.closeTimeout &&= (clearTimeout(this.closeTimeout), void 0);
1563
+ try {
1564
+ await this.getHideAnimation().play(), this.destroyed || this.onToastClosed.emit();
1565
+ } catch (e) {
1566
+ console.warn("Toast hide animation error:", e), this.destroyed || this.onToastClosed.emit();
1567
+ }
1568
+ return this;
1569
+ }
1570
+ destroy() {
1571
+ 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 });
1572
+ }
1573
+ }, or = {
1574
+ position: "bottom right",
1575
+ maxToasts: 5,
1576
+ spacing: 10,
1577
+ offset: {
1578
+ x: 20,
1579
+ y: 20
1580
+ },
1581
+ stackDirection: "up",
1582
+ animationSpeed: 1
1583
+ }, sr = class extends h(_) {
1584
+ get size() {
1585
+ return this.toasts.length;
1586
+ }
1587
+ get toastPosition() {
1588
+ return this.config.position ?? "top right";
1589
+ }
1590
+ get stackDirection() {
1591
+ return this.config.stackDirection ?? "up";
1592
+ }
1593
+ get spacing() {
1594
+ return this.config.spacing ?? 10;
1595
+ }
1596
+ get offset() {
1597
+ return this.config.offset ?? {
1598
+ x: 20,
1599
+ y: 20
1600
+ };
1601
+ }
1602
+ get maxToasts() {
1603
+ return this.config.maxToasts ?? 5;
1604
+ }
1605
+ get toastConfig() {
1606
+ return this.defaultToastConfig ?? {};
1607
+ }
1608
+ constructor(e = {}, t = {}) {
1609
+ super({ autoResize: !0 }), this.onToastAdded = new p(), this.onToastRemoved = new p(), this.onAllToastsRemoved = new p(), this.toasts = [], this.config = {
1610
+ ...or,
1611
+ ...e
1612
+ }, this.defaultToastConfig = { ...t }, this.initialize(), this.resize();
1613
+ }
1614
+ initialize() {
1615
+ this.container = this.add.container();
1616
+ }
1617
+ async show(e = this.defaultToastConfig, t = !1) {
1618
+ if (this.size >= this.config.maxToasts) {
1619
+ let e = this.toasts[0];
1620
+ await e.hide(), await this.removeToast(e);
1621
+ }
1622
+ !t && this.defaultToastConfig && (e = {
1623
+ ...this.defaultToastConfig,
1624
+ ...e,
1625
+ style: this.defaultToastConfig.style || e.style ? {
1626
+ ...this.defaultToastConfig.style ?? {},
1627
+ ...e.style ?? {}
1628
+ } : this.defaultToastConfig.style,
1629
+ textColors: this.defaultToastConfig.textColors || e.textColors ? {
1630
+ ...this.defaultToastConfig.textColors ?? {},
1631
+ ...e.textColors ?? {}
1632
+ } : Y.textColors,
1633
+ shadow: this.defaultToastConfig.shadow || e.shadow ? {
1634
+ ...this.defaultToastConfig.shadow ?? {},
1635
+ ...e.shadow ?? {}
1636
+ } : this.defaultToastConfig.shadow,
1637
+ closeButton: this.defaultToastConfig.closeButton || e.closeButton ? {
1638
+ ...this.defaultToastConfig.closeButton ?? {},
1639
+ ...e.closeButton ?? {}
1640
+ } : Y.closeButton
1641
+ });
1642
+ let n = new (e.class ?? ar)(e);
1643
+ 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();
1644
+ }
1645
+ async hideAll() {
1646
+ let e = [...this.toasts];
1647
+ await Promise.all(e.map((e) => e.hide())), this.onAllToastsRemoved.emit();
1648
+ }
1649
+ async removeAll() {
1650
+ return this.hideAll();
1651
+ }
1652
+ async removeToast(e) {
1653
+ let t = this.toasts.indexOf(e);
1654
+ t === -1 || e.destroyed || (this.toasts.splice(t, 1), this.positionToasts(), e.destroyed || (this.container.removeChild(e), e.destroy()), this.onToastRemoved.emit(e));
1655
+ }
1656
+ positionToasts(e = !0, t = !1) {
1657
+ this.toasts.filter((e, n) => e && !e.destroyed && (t ? n !== this.toasts.length - 1 : !0)).forEach((t, n) => {
1658
+ this.positionToast(t, n, e);
1659
+ });
1660
+ }
1661
+ positionToast(e, t, n = !0) {
1662
+ if (!e?.parent || e.destroyed) return;
1663
+ 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;
1664
+ switch (r) {
1665
+ case "top right":
1666
+ case "right top":
1667
+ l += this.app.size.width * .5 - e.width - s, u -= this.app.size.height * .5 - c;
1668
+ break;
1669
+ case "top left":
1670
+ case "left top":
1671
+ l -= this.app.size.width * .5 - s, u -= this.app.size.height * .5 - c;
1672
+ break;
1673
+ case "bottom right":
1674
+ case "right bottom":
1675
+ l += this.app.size.width * .5 - e.width - s, u += this.app.size.height * .5 - e.height - c;
1676
+ break;
1677
+ case "bottom left":
1678
+ case "left bottom":
1679
+ l -= this.app.size.width * .5 - s, u += this.app.size.height * .5 - e.height - c;
1680
+ break;
1681
+ case "top":
1682
+ case "top center":
1683
+ l += -e.width * .5, u -= this.app.size.height * .5 - c;
1684
+ break;
1685
+ case "bottom":
1686
+ case "bottom center":
1687
+ l += -e.width * .5, u += this.app.size.height * .5 - e.height - c;
1688
+ break;
1689
+ }
1690
+ o === "down" ? u += t * (e.height + i) : u -= t * (e.height + i);
1691
+ try {
1692
+ n ? A.to(e, {
1693
+ x: l,
1694
+ y: u,
1695
+ duration: .3 / this.config.animationSpeed,
1696
+ ease: "power2.out"
1697
+ }) : e.position.set(l, u);
1698
+ } catch (e) {
1699
+ console.warn("Error positioning toast:", e);
1700
+ }
1701
+ }
1702
+ resize() {
1703
+ this.position.set(-this.app.size.width * .5, -this.app.size.height * .5), this.positionToasts(!1);
1704
+ }
1705
+ destroy() {
1706
+ this.toasts.forEach((e) => {
1707
+ A.killTweensOf(e);
1708
+ }), this.hideAll(), this.toasts = [], super.destroy({ children: !0 });
1709
+ }
1710
+ }, cr = [
1711
+ "debug",
1712
+ "padding",
1713
+ "size",
1714
+ "useAppSize",
1715
+ "useSafeArea",
1716
+ "layout"
1717
+ ], lr = {
1718
+ top: 0,
1719
+ right: 0,
1720
+ bottom: 0,
1721
+ left: 0
1722
+ };
1723
+ function ur(e, t) {
1724
+ return {
1725
+ top: e.top + t.top,
1726
+ right: e.right + t.right,
1727
+ bottom: e.bottom + t.bottom,
1728
+ left: e.left + t.left
1729
+ };
1730
+ }
1731
+ var dr = {
1732
+ flexGrow: 0,
1733
+ flexShrink: 0,
1734
+ autoLayoutChildren: !0
1735
+ }, fr = h(v()), pr = class e extends fr {
1736
+ constructor(e) {
1737
+ 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) => {
1738
+ throw Error("UICanvas: Do not call addChildAt() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
1739
+ }, this.setChildIndex = (e, t) => {
1740
+ super.setChildIndex(e, t), this._updateLayout();
1741
+ }, 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");
1742
+ m(this), this._positionContainers = /* @__PURE__ */ new Map(), this.config = {
1743
+ debug: e.debug === !0,
1744
+ padding: I(e?.padding ?? 0),
1745
+ size: e.size === void 0 ? {
1746
+ width: 0,
1747
+ height: 0
1748
+ } : et(e.size),
1749
+ useAppSize: e.useAppSize === !0,
1750
+ useSafeArea: e.useSafeArea ?? !0,
1751
+ autoLayoutChildren: e.autoLayoutChildren ?? !0
1752
+ }, e.layout ? typeof e.layout == "boolean" ? this.config.layout = e.layout : this.config.layout = {
1753
+ ...dr,
1754
+ ...e.layout
1755
+ } : this.config.layout = { ...dr }, this.config.useAppSize && (this.config.size = this.app.size), this.layout = {
1756
+ width: this.config.size.width,
1757
+ height: this.config.size.height,
1758
+ flexDirection: "column",
1759
+ justifyContent: "space-between",
1760
+ ...typeof this.config.layout == "object" ? this.config.layout : {}
1761
+ }, 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);
1762
+ }
1763
+ _updateLayout() {
1764
+ this.app.ticker.addOnce(this.updateLayout);
1765
+ }
1766
+ _initializeLayout() {
1767
+ this._disableAddChildError = !0, this.topRow = this.add.flexContainer({
1768
+ label: "Top",
1769
+ layout: {
1770
+ width: "100%",
1771
+ height: "auto",
1772
+ flexDirection: "row",
1773
+ justifyContent: "space-between",
1774
+ alignItems: "flex-start"
1775
+ }
1776
+ }), this.middleRow = this.add.flexContainer({
1777
+ label: "Middle",
1778
+ layout: {
1779
+ width: "100%",
1780
+ flexDirection: "row",
1781
+ justifyContent: "space-between",
1782
+ alignItems: "center"
1783
+ }
1784
+ }), this.bottomRow = this.add.flexContainer({
1785
+ label: "Bottom",
1786
+ layout: {
1787
+ width: "100%",
1788
+ height: "auto",
1789
+ flexDirection: "row",
1790
+ justifyContent: "space-between",
1791
+ alignItems: "flex-end"
1792
+ }
1793
+ }), this._disableAddChildError = !1;
1794
+ let e = this._createPositionContainer(this.topRow, {
1795
+ justifyContent: "flex-start",
1796
+ alignItems: "flex-start",
1797
+ flexGrow: 0,
1798
+ flexShrink: 0
1799
+ }, "Left"), t = this._createPositionContainer(this.topRow, {
1800
+ justifyContent: "center",
1801
+ alignItems: "flex-start",
1802
+ flexGrow: 1,
1803
+ flexShrink: 0
1804
+ }, "Center"), n = this._createPositionContainer(this.topRow, {
1805
+ justifyContent: "flex-end",
1806
+ alignItems: "flex-start",
1807
+ flexGrow: 0,
1808
+ flexShrink: 0
1809
+ }, "Right"), r = this._createPositionContainer(this.middleRow, {
1810
+ justifyContent: "flex-start",
1811
+ alignItems: "center",
1812
+ flexDirection: "row",
1813
+ flexGrow: 0,
1814
+ flexShrink: 0
1815
+ }, "Left"), i = this._createPositionContainer(this.middleRow, {
1816
+ justifyContent: "center",
1817
+ alignItems: "center",
1818
+ flexDirection: "row",
1819
+ flexGrow: 1,
1820
+ flexShrink: 0
1821
+ }, "Center"), a = this._createPositionContainer(this.middleRow, {
1822
+ justifyContent: "flex-end",
1823
+ alignItems: "center",
1824
+ flexDirection: "row",
1825
+ flexGrow: 0,
1826
+ flexShrink: 0
1827
+ }, "Right"), o = this._createPositionContainer(this.bottomRow, {
1828
+ justifyContent: "flex-start",
1829
+ alignItems: "flex-end",
1830
+ flexDirection: "row",
1831
+ flexGrow: 0,
1832
+ flexShrink: 0
1833
+ }, "Left"), s = this._createPositionContainer(this.bottomRow, {
1834
+ justifyContent: "center",
1835
+ alignItems: "flex-end",
1836
+ flexGrow: 1,
1837
+ flexShrink: 0,
1838
+ flexDirection: "row"
1839
+ }, "Center"), c = this._createPositionContainer(this.bottomRow, {
1840
+ justifyContent: "flex-end",
1841
+ alignItems: "flex-end",
1842
+ flexDirection: "row",
1843
+ flexGrow: 0,
1844
+ flexShrink: 0
1845
+ }, "Right");
1846
+ 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);
1847
+ }
1848
+ _createPositionContainer(e, t, n) {
1849
+ let r = e.add.container({ layout: {
1850
+ width: "auto",
1851
+ height: "auto",
1852
+ ...t
1853
+ } });
1854
+ return r.label = n, r.on("childAdded", this._updateLayout), r.on("childRemoved", this._updateLayout), r.on("layout", this._updateLayout), r;
1855
+ }
1856
+ get canvasChildren() {
1857
+ return this._canvasChildren;
375
1858
  }
376
1859
  get app() {
377
- return C.getInstance();
1860
+ return S.getInstance();
378
1861
  }
379
1862
  destroy() {
380
- this.interactiveArea.removeAllListeners(), this.app.stage.off("pointerup", this.onPointerUp.bind(this)), this.app.stage.off("pointerupoutside", this.onPointerUp.bind(this));
1863
+ this._disableAddChildError = !0, this.config.debug && F(`UICanvas:${this.uid}`), this._debugGraphics &&= (this._debugGraphics.destroy(), null), this._debugLabel &&= (this._debugLabel.destroy(), null);
1864
+ for (let e of this._regionLabels) e.destroy();
1865
+ this._regionLabels = [], this.canvasChildren?.forEach((e) => {
1866
+ e.off("layout", this._updateLayout);
1867
+ }), this.children.forEach((e) => {
1868
+ e.off("layout", this._updateLayout);
1869
+ }), this.off("childAdded", this._updateLayout), this.off("childRemoved", this._updateLayout), this._positionContainers.forEach((e) => {
1870
+ e.off("childAdded", this._updateLayout), e.off("childRemoved", this._updateLayout);
1871
+ }), this._bindings = [], super.destroy();
1872
+ }
1873
+ set size(e) {
1874
+ this.config.size = e === void 0 ? {
1875
+ width: 0,
1876
+ height: 0
1877
+ } : et(e), this.layout = {
1878
+ width: this.config.size.width,
1879
+ height: this.config.size.height
1880
+ }, this.updateLayout();
1881
+ }
1882
+ set padding(e) {
1883
+ this.config.padding = I(e), this._applyPadding(), this._updateLayout();
1884
+ }
1885
+ _applyPadding() {
1886
+ let e = ur(this.config.padding, this.config.useSafeArea ? this.app.safeArea : lr);
1887
+ this.layout = {
1888
+ paddingLeft: e.left,
1889
+ paddingTop: e.top,
1890
+ paddingRight: e.right,
1891
+ paddingBottom: e.bottom
1892
+ };
1893
+ }
1894
+ static isFlexContainer(e) {
1895
+ return e instanceof ir;
1896
+ }
1897
+ addChild(...e) {
1898
+ if (this._disableAddChildError) return super.addChild(...e);
1899
+ throw Error("UICanvas: Do not call addChild() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
1900
+ }
1901
+ removeChild(...e) {
1902
+ if (this._disableAddChildError) return super.removeChild(...e);
1903
+ throw Error("UICanvas: Do not call removeChild() directly. Use removeElement(child) instead.");
381
1904
  }
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;
1905
+ resize() {
1906
+ this._applyPadding(), this.config.useAppSize ? (this.size = {
1907
+ width: this.app.size.width,
1908
+ height: this.app.size.height
1909
+ }, this.position.set(-this.app.size.width * .5, -this.app.size.height * .5)) : this._updateLayout();
1910
+ }
1911
+ updateLayout() {
1912
+ this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this._positionContainers.forEach((e) => {
1913
+ this.app.renderer.layout.update(e);
1914
+ }), 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));
1915
+ }
1916
+ bindElement(e, t, n) {
1917
+ 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({
1918
+ child: e,
1919
+ anchor: t,
1920
+ place: n
1921
+ }), this._updateLayout();
1922
+ }
1923
+ unbindElement(e) {
1924
+ let t = this._bindings.some((t) => t.child === e);
1925
+ this._bindings = this._bindings.filter((t) => t.child !== e), t && e.parent === this && (this._disableAddChildError = !0, super.removeChild(e), this._disableAddChildError = !1);
1926
+ }
1927
+ _updateBindings() {
1928
+ for (let { child: e, anchor: t, place: n } of this._bindings) {
1929
+ let r = this._anchorRect(t);
1930
+ r && n(r, e);
403
1931
  }
404
1932
  }
405
- onPointerDown(e) {
406
- this.dragging = !0, this.previousPointerPosition = this.getEventPosition(e);
1933
+ _anchorRect(e) {
1934
+ let t = e.layout?.computedLayout;
1935
+ if (!t) return null;
1936
+ let n = 0, r = 0;
1937
+ for (let t = e; t && t !== this; t = t.parent) {
1938
+ let e = t.layout?.computedLayout;
1939
+ e && (n += e.left, r += e.top);
1940
+ }
1941
+ return {
1942
+ left: n,
1943
+ top: r,
1944
+ width: t.width,
1945
+ height: t.height
1946
+ };
1947
+ }
1948
+ addElement(t, n) {
1949
+ let r = n?.align ?? "top left", i = this._positionContainers.get(r);
1950
+ return i ? (e.isFlexContainer(t) && this.addSignalConnection(t.onLayoutComplete.connect(this._updateLayout)), this.settingsMap.set(t, {
1951
+ align: r,
1952
+ padding: n?.padding ? I(n.padding) : {
1953
+ top: 0,
1954
+ left: 0,
1955
+ bottom: 0,
1956
+ right: 0
1957
+ }
1958
+ }), 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
1959
  }
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;
1960
+ removeElement(e) {
1961
+ let t = this._childMap.get(e);
1962
+ if (!t) throw Error(`UICanvas: Cannot remove element it was not added via addElement().\nChild label: "${e.label ?? "(unlabeled)"}"`);
1963
+ 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
1964
  }
413
- onPointerUp() {
414
- this.dragging = !1, this.previousPointerPosition = null;
1965
+ _childAdded(e) {
1966
+ 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
1967
  }
416
- getEventPosition(e) {
417
- return e instanceof TouchEvent ? new A(e.touches[0].clientX, e.touches[0].clientY) : new A(e.clientX, e.clientY);
1968
+ _childRemoved(e) {
1969
+ this.settingsMap.delete(e), this._childMap.delete(e), this._canvasChildren = Array.from(this._childMap.keys()), _.childRemoved(e);
1970
+ }
1971
+ _added() {
1972
+ this._updateLayout();
1973
+ }
1974
+ get debug() {
1975
+ return this.config.debug;
1976
+ }
1977
+ set debug(e) {
1978
+ if (this.config.debug = e, e) P(`UICanvas:${this.uid}`, this.label || "UICanvas", j.outerBounds), this.drawDebug();
1979
+ else {
1980
+ F(`UICanvas:${this.uid}`), this._debugGraphics && this._debugGraphics.clear(), this._debugLabel && (this._debugLabel.visible = !1);
1981
+ for (let e of this._regionLabels) e.visible = !1;
1982
+ }
1983
+ }
1984
+ drawDebug() {
1985
+ 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();
1986
+ let e = this.config.size.width, t = this.config.size.height, n = this.config.padding;
1987
+ this._debugGraphics.rect(0, 0, e, t).stroke({
1988
+ width: 1,
1989
+ color: j.outerBounds,
1990
+ alpha: M.stroke,
1991
+ pixelLine: !0
1992
+ }), n.top > 0 && this._debugGraphics.rect(0, 0, e, n.top).fill({
1993
+ color: j.outerBounds,
1994
+ alpha: M.fill
1995
+ }), n.bottom > 0 && this._debugGraphics.rect(0, t - n.bottom, e, n.bottom).fill({
1996
+ color: j.outerBounds,
1997
+ alpha: M.fill
1998
+ }), n.left > 0 && this._debugGraphics.rect(0, n.top, n.left, t - n.top - n.bottom).fill({
1999
+ color: j.outerBounds,
2000
+ alpha: M.fill
2001
+ }), n.right > 0 && this._debugGraphics.rect(e - n.right, n.top, n.right, t - n.top - n.bottom).fill({
2002
+ color: j.outerBounds,
2003
+ alpha: M.fill
2004
+ });
2005
+ let r = n.left, i = n.top, a = e - n.left - n.right, o = t - n.top - n.bottom;
2006
+ this._debugGraphics.rect(r, i, a, o).stroke({
2007
+ width: 1,
2008
+ color: j.innerBounds,
2009
+ alpha: M.stroke,
2010
+ pixelLine: !0
2011
+ });
2012
+ let s = /* @__PURE__ */ new Map();
2013
+ this._positionContainers.forEach((e, t) => {
2014
+ (!s.has(e) || t.length < s.get(e).length) && s.set(e, t);
2015
+ });
2016
+ let c = [...new Set(this._positionContainers.values())];
2017
+ for (; this._regionLabels.length < c.length;) {
2018
+ this._disableAddChildError = !0;
2019
+ let e = N("", j.region);
2020
+ super.addChild(e), e.layout = !1, this._regionLabels.push(e), this._disableAddChildError = !1;
2021
+ }
2022
+ c.forEach((e, t) => {
2023
+ if (!e.layout?.computedLayout) return;
2024
+ let n = e.layout.computedLayout, r = e.parent;
2025
+ if (!r?.layout?.computedLayout) return;
2026
+ 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;
2027
+ this._debugGraphics.rect(a, o, c, l).fill({
2028
+ color: j.region,
2029
+ alpha: u ? M.fillActive : M.fill
2030
+ }).stroke({
2031
+ width: 1,
2032
+ color: j.region,
2033
+ alpha: .3,
2034
+ pixelLine: !0
2035
+ });
2036
+ let d = this._regionLabels[t];
2037
+ d.text = s.get(e) ?? "", d.visible = !0, d.position.set(a + 2, o + 2);
2038
+ });
2039
+ for (let e = c.length; e < this._regionLabels.length; e++) this._regionLabels[e].visible = !1;
2040
+ let l = e / 2, u = t / 2;
2041
+ this._debugGraphics.moveTo(l, u - 10).lineTo(l, u + 10).stroke({
2042
+ width: 1,
2043
+ color: j.outerBounds,
2044
+ alpha: M.crosshair,
2045
+ pixelLine: !0
2046
+ }).moveTo(l - 10, u).lineTo(l + 10, u).stroke({
2047
+ width: 1,
2048
+ color: j.outerBounds,
2049
+ alpha: M.crosshair,
2050
+ pixelLine: !0
2051
+ });
2052
+ }
2053
+ }, X = null;
2054
+ function mr() {
2055
+ if (X) return X;
2056
+ X = /* @__PURE__ */ new Map();
2057
+ let e = globalThis.Caper?.get?.("entityList") ?? [];
2058
+ for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && X.set(t.id, t.module);
2059
+ return X;
2060
+ }
2061
+ function hr(e) {
2062
+ return mr().get(e);
2063
+ }
2064
+ function gr() {
2065
+ return [...mr().keys()];
2066
+ }
2067
+ //#endregion
2068
+ //#region src/mixins/factory/ui-registry.ts
2069
+ var Z = null;
2070
+ function _r() {
2071
+ if (Z) return Z;
2072
+ Z = /* @__PURE__ */ new Map();
2073
+ let e = globalThis.Caper?.get?.("uiList") ?? [];
2074
+ for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && Z.set(t.id, t.module);
2075
+ return Z;
2076
+ }
2077
+ function vr(e) {
2078
+ return _r().get(e);
2079
+ }
2080
+ function yr() {
2081
+ return [..._r().keys()];
2082
+ }
2083
+ //#endregion
2084
+ //#region src/mixins/factory/schema.ts
2085
+ var br = [
2086
+ "position",
2087
+ "scale",
2088
+ "pivot"
2089
+ ], xr = [
2090
+ "position",
2091
+ "x",
2092
+ "y",
2093
+ "scale",
2094
+ "scaleX",
2095
+ "scaleY",
2096
+ "pivot",
2097
+ "anchor"
2098
+ ];
2099
+ function Q(e) {
2100
+ 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 ?? []];
2101
+ return (t) => {
2102
+ let s = e.build(t);
2103
+ if (t == null) return s;
2104
+ let c = t;
2105
+ return n && G({
2106
+ position: c.position,
2107
+ x: c.x,
2108
+ y: c.y
2109
+ }, s), r && K({
2110
+ scale: c.scale,
2111
+ scaleX: c.scaleX,
2112
+ scaleY: c.scaleY
2113
+ }, s), i && q(c.pivot, s), a && Gn(c.anchor, s), H(st(o, c), s), s;
2114
+ };
2115
+ }
2116
+ //#endregion
2117
+ //#region src/mixins/factory/const.ts
2118
+ var Sr = [
2119
+ "text",
2120
+ "roundPixels",
2121
+ "resolution",
2122
+ "style",
2123
+ "anchor",
2124
+ "pivot"
2125
+ ], Cr = {
2126
+ existing: (e, t) => {
2127
+ if (!t) return e;
2128
+ let { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ...l } = t;
2129
+ return G({
2130
+ position: n,
2131
+ x: r,
2132
+ y: i
2133
+ }, e), K({
2134
+ scale: o,
2135
+ scaleX: s,
2136
+ scaleY: c
2137
+ }, e), q(a, e), H(l, e), e;
2138
+ },
2139
+ container: Q({
2140
+ build: (e) => new _(e ? g(e, b) : void 0),
2141
+ applies: [
2142
+ "position",
2143
+ "scale",
2144
+ "pivot"
2145
+ ],
2146
+ exclude: b
2147
+ }),
2148
+ particleContainer: Q({
2149
+ build: (e) => new Bn(e ? g(e, Rn) : void 0),
2150
+ applies: [
2151
+ "position",
2152
+ "scale",
2153
+ "pivot"
2154
+ ],
2155
+ exclude: Rn
2156
+ }),
2157
+ texture: W,
2158
+ sprite: Q({
2159
+ build: (e) => new Et(e ? W(e) : void 0),
2160
+ applies: [
2161
+ "position",
2162
+ "scale",
2163
+ "pivot",
2164
+ "anchor"
2165
+ ],
2166
+ exclude: ["asset", "sheet"]
2167
+ }),
2168
+ tilingSprite: Q({
2169
+ build: (e) => new Dt(e ? W(e) : void 0),
2170
+ applies: [
2171
+ "position",
2172
+ "scale",
2173
+ "pivot",
2174
+ "anchor"
2175
+ ],
2176
+ exclude: ["asset", "sheet"]
2177
+ }),
2178
+ animatedSprite: Q({
2179
+ build: (e) => new Kn(e),
2180
+ applies: [
2181
+ "position",
2182
+ "scale",
2183
+ "pivot"
2184
+ ],
2185
+ exclude: [
2186
+ "sheet",
2187
+ "texturePrefix",
2188
+ "zeroPad",
2189
+ "animations",
2190
+ "autoPlay",
2191
+ "autoUpdate",
2192
+ "defaultAnimation",
2193
+ "reversible",
2194
+ "animationSpeed",
2195
+ "startIndex",
2196
+ "animation"
2197
+ ]
2198
+ }),
2199
+ graphics: Q({
2200
+ build: (e) => new E(),
2201
+ applies: [
2202
+ "position",
2203
+ "scale",
2204
+ "pivot"
2205
+ ]
2206
+ }),
2207
+ svg(e) {
2208
+ let t = new Un(e.ctx), { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ctx: l, ...u } = e;
2209
+ return G({
2210
+ position: n,
2211
+ x: r,
2212
+ y: i
2213
+ }, t), K({
2214
+ scale: o,
2215
+ scaleX: s,
2216
+ scaleY: c
2217
+ }, t), q(a, t), H(u, t), t;
2218
+ },
2219
+ text: Q({
2220
+ build: (e) => new O(e ? {
2221
+ text: e.text,
2222
+ roundPixels: e.roundPixels,
2223
+ resolution: e.resolution,
2224
+ style: e.style,
2225
+ anchor: e.anchor ? y(e.anchor, !0) : void 0,
2226
+ pivot: e.pivot ? y(e.pivot, !0) : void 0
2227
+ } : {}),
2228
+ applies: [
2229
+ "position",
2230
+ "scale",
2231
+ "pivot"
2232
+ ],
2233
+ exclude: [...Sr]
2234
+ }),
2235
+ htmlText: Q({
2236
+ build: (e) => new St(e ? {
2237
+ text: e.text,
2238
+ roundPixels: e.roundPixels,
2239
+ resolution: e.resolution,
2240
+ style: e.style,
2241
+ anchor: e.anchor ? y(e.anchor, !0) : void 0,
2242
+ pivot: e.pivot ? y(e.pivot, !0) : void 0
2243
+ } : {}),
2244
+ applies: [
2245
+ "position",
2246
+ "scale",
2247
+ "pivot"
2248
+ ],
2249
+ exclude: [...Sr]
2250
+ }),
2251
+ bitmapText: Q({
2252
+ build: (e) => new w(e ? {
2253
+ text: e.text,
2254
+ roundPixels: e.roundPixels,
2255
+ style: e.style,
2256
+ anchor: e.anchor ? y(e.anchor, !0) : void 0,
2257
+ pivot: e.pivot ? y(e.pivot, !0) : void 0
2258
+ } : {}),
2259
+ applies: [
2260
+ "position",
2261
+ "scale",
2262
+ "pivot"
2263
+ ],
2264
+ exclude: [...Sr]
2265
+ }),
2266
+ button: Q({
2267
+ build: (e) => new er(e ? g(e, Qn) : void 0),
2268
+ applies: [
2269
+ "position",
2270
+ "scale",
2271
+ "pivot"
2272
+ ],
2273
+ exclude: Qn
2274
+ }),
2275
+ flexContainer: Q({
2276
+ build: (e) => new ir(e),
2277
+ applies: [
2278
+ "position",
2279
+ "scale",
2280
+ "pivot"
2281
+ ],
2282
+ exclude: rr
2283
+ }),
2284
+ uiCanvas: Q({
2285
+ build: (e) => new pr(e ? g(e, cr) : {}),
2286
+ applies: [
2287
+ "position",
2288
+ "scale",
2289
+ "pivot"
2290
+ ],
2291
+ exclude: cr
2292
+ }),
2293
+ spine: Q({
2294
+ build: (e) => {
2295
+ let t = "", n = e?.data;
2296
+ if (typeof n == "string") {
2297
+ let e = n.slice(-5);
2298
+ e !== ".json" && e !== ".skel" ? e = ".json" : t = n.substring(0, n.length - 5), t = {
2299
+ skeleton: n + e,
2300
+ atlas: n + ".atlas"
2301
+ };
2302
+ }
2303
+ let r = window.Spine.from(t);
2304
+ return e?.autoUpdate !== void 0 && (r.autoUpdate = e.autoUpdate), e?.animationName && r.state.setAnimation(e.trackIndex ?? 0, e.animationName, e.loop), r;
2305
+ },
2306
+ applies: [
2307
+ "position",
2308
+ "scale",
2309
+ "pivot",
2310
+ "anchor"
2311
+ ],
2312
+ exclude: [
2313
+ "data",
2314
+ "autoUpdate",
2315
+ "animationName",
2316
+ "trackIndex",
2317
+ "loop"
2318
+ ]
2319
+ }),
2320
+ spineAnimation: (e) => {
2321
+ let t = new Xn(e);
2322
+ if (!e) return t;
2323
+ let { position: n, x: r, y: i, anchor: a, pivot: o, scale: s, scaleX: c, scaleY: l, ...u } = e;
2324
+ return G({
2325
+ position: n,
2326
+ x: r,
2327
+ y: i
2328
+ }, t), K({
2329
+ scale: s,
2330
+ scaleX: c,
2331
+ scaleY: l
2332
+ }, t), Gn(a, t), q(o, t), H(u, t), t;
2333
+ },
2334
+ toaster: (e, t = {}) => new sr(e, t),
2335
+ entity: (e, t) => {
2336
+ let n = hr(e);
2337
+ if (!n) {
2338
+ let t = gr();
2339
+ throw Error(`[caper] Unknown entity id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
2340
+ }
2341
+ let r = new n(t);
2342
+ if (t) {
2343
+ let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
2344
+ G({
2345
+ position: e,
2346
+ x: n,
2347
+ y: i
2348
+ }, r), K({
2349
+ scale: o,
2350
+ scaleX: s,
2351
+ scaleY: c
2352
+ }, r), q(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
2353
+ }
2354
+ return r;
2355
+ },
2356
+ ui: (e, t) => {
2357
+ let n = vr(e);
2358
+ if (!n) {
2359
+ let t = yr();
2360
+ throw Error(`[caper] Unknown ui id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
2361
+ }
2362
+ let r = new n(t);
2363
+ if (t) {
2364
+ let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
2365
+ G({
2366
+ position: e,
2367
+ x: n,
2368
+ y: i
2369
+ }, r), K({
2370
+ scale: o,
2371
+ scaleX: s,
2372
+ scaleY: c
2373
+ }, r), q(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
2374
+ }
2375
+ return r;
418
2376
  }
419
- }, W = {
2377
+ };
2378
+ we(Cr);
2379
+ //#endregion
2380
+ //#region src/mixins/factory/props.ts
2381
+ var wr = [
2382
+ "text",
2383
+ "anchor",
2384
+ "roundPixels",
2385
+ "style",
2386
+ "pivot"
2387
+ ], $ = {
420
2388
  value: "",
421
2389
  type: "text",
422
2390
  fixed: !0,
@@ -455,32 +2423,32 @@ var jn = class extends w {
455
2423
  scale: 1,
456
2424
  marginTop: 60
457
2425
  }
458
- }, In = [
2426
+ }, Tr = [
459
2427
  "text",
460
2428
  "password",
461
2429
  "number",
462
2430
  "email",
463
2431
  "tel",
464
2432
  "url"
465
- ], Ln = class e extends x(S(v(w))) {
2433
+ ], Er = class e extends J(Zn(h(_))) {
466
2434
  constructor(e, t = !1, n = null) {
467
2435
  if (super({
468
2436
  autoUpdate: !0,
469
2437
  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,
2438
+ }), 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 = {
2439
+ ...$,
472
2440
  ...e,
473
2441
  style: {
474
- ...W.style,
2442
+ ...$.style,
475
2443
  ...e?.style ?? {}
476
2444
  },
477
- padding: p(e.padding ?? W.padding),
2445
+ padding: I(e.padding ?? $.padding),
478
2446
  bg: {
479
- ...W.bg,
2447
+ ...$.bg,
480
2448
  ...e.bg ?? {}
481
2449
  },
482
2450
  focusOverlay: {
483
- ...W.focusOverlay,
2451
+ ...$.focusOverlay,
484
2452
  ...e.focusOverlay ?? {}
485
2453
  }
486
2454
  }, 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 +2475,7 @@ var jn = class extends w {
507
2475
  width: "100%",
508
2476
  height: "100%"
509
2477
  }
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) {
2478
+ }), 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
2479
  let e = this.isClone ? this.clone?.options?.focusOverlay?.scale ?? 1 : 1;
512
2480
  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
2481
  }
@@ -555,7 +2523,7 @@ var jn = class extends w {
555
2523
  handleClick(e) {
556
2524
  if (e?.originalEvent?.key) return;
557
2525
  clearTimeout(this._focusTimer), clearTimeout(this._pointerDownTimer);
558
- let t = e ? B(this.input, e) : this.input.text?.length ?? 0;
2526
+ let t = e ? un(this.input, e) : this.input.text?.length ?? 0;
559
2527
  this.createDomElement(t);
560
2528
  }
561
2529
  focusIn() {
@@ -609,7 +2577,7 @@ var jn = class extends w {
609
2577
  if (this.placeholder.visible = !0, !this.isClone && this._placeholderPositioned && !this._placeholderAnimating) {
610
2578
  this._placeholderAnimating = !0;
611
2579
  let e = this.input.x, t = this.input.y;
612
- this.options.placeholder.animationOnType ? this.addAnimation([N.to(this.placeholder, {
2580
+ this.options.placeholder.animationOnType ? this.addAnimation([A.to(this.placeholder, {
613
2581
  x: e,
614
2582
  y: t,
615
2583
  tint: 16777215,
@@ -620,7 +2588,7 @@ var jn = class extends w {
620
2588
  onComplete: () => {
621
2589
  this._placeholderPositioned = !1, this._placeholderAnimating = !1;
622
2590
  }
623
- }), N.to(this.placeholder.scale, {
2591
+ }), A.to(this.placeholder.scale, {
624
2592
  x: 1,
625
2593
  y: 1,
626
2594
  duration: this.options.placeholder.animationOnType.duration || .4,
@@ -641,11 +2609,11 @@ var jn = class extends w {
641
2609
  break;
642
2610
  }
643
2611
  if (this.options.placeholder.offsetOnType) {
644
- let n = g(this.options.placeholder.offsetOnType);
2612
+ let n = y(this.options.placeholder.offsetOnType);
645
2613
  e += n.x, t += n.y;
646
2614
  }
647
2615
  if (this.options.placeholder.animationOnType) {
648
- if (this.addAnimation(N.to(this.placeholder, {
2616
+ if (this.addAnimation(A.to(this.placeholder, {
649
2617
  x: e,
650
2618
  y: t,
651
2619
  duration: this.options.placeholder.animationOnType.duration || .4,
@@ -654,8 +2622,8 @@ var jn = class extends w {
654
2622
  alpha: this.options.placeholder.animationOnType.alpha ?? this.options.placeholder.alpha ?? 1,
655
2623
  overwrite: !0
656
2624
  })), this.options.placeholder.scaleOnType) {
657
- let e = g(this.options.placeholder.scaleOnType);
658
- this.addAnimation(N.to(this.placeholder.scale, {
2625
+ let e = y(this.options.placeholder.scaleOnType);
2626
+ this.addAnimation(A.to(this.placeholder.scale, {
659
2627
  x: e.x,
660
2628
  y: e.y,
661
2629
  duration: this.options.placeholder.animationOnType.duration || .4,
@@ -701,7 +2669,7 @@ var jn = class extends w {
701
2669
  }
702
2670
  addCaret() {
703
2671
  this.caret = this._inputContainer.add.sprite({
704
- asset: j.WHITE,
2672
+ asset: k.WHITE,
705
2673
  width: 3,
706
2674
  height: 10,
707
2675
  tint: this.options.caret.color ?? 0,
@@ -742,9 +2710,9 @@ var jn = class extends w {
742
2710
  this.domElement = this.clone.domElement, this._addDomElementListeners();
743
2711
  return;
744
2712
  }
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);
2713
+ 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
2714
  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);
2715
+ 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
2716
  }
749
2717
  destroyDomElement() {
750
2718
  this.isClone || (this.domElement &&= (this._removeDomElementListeners(), this.domElement.remove(), this.domElement.parentNode && this.domElement.parentNode.removeChild(this.domElement), null));
@@ -756,7 +2724,7 @@ var jn = class extends w {
756
2724
  this.cursorAnimation?.kill(), this.caret.visible = !1;
757
2725
  }
758
2726
  blinkCaret() {
759
- this.cursorAnimation && this.cursorAnimation.kill(), this.cursorAnimation = N.fromTo(this.caret, { alpha: 0 }, {
2727
+ this.cursorAnimation && this.cursorAnimation.kill(), this.cursorAnimation = A.fromTo(this.caret, { alpha: 0 }, {
760
2728
  duration: .5,
761
2729
  alpha: 1,
762
2730
  yoyo: !0,
@@ -789,15 +2757,15 @@ var jn = class extends w {
789
2757
  let n = Array.isArray(this.options.focusOverlay.activeFilter), r = !1;
790
2758
  if (n) {
791
2759
  let e = this.options.focusOverlay.activeFilter;
792
- (R && e.includes("mobile") || L && e.includes("touch") || !R && !L && e.includes("desktop")) && (r = !0);
2760
+ ($t && e.includes("mobile") || B && e.includes("touch") || !$t && !B && e.includes("desktop")) && (r = !0);
793
2761
  } else r = typeof this.options.focusOverlay.activeFilter == "function" ? this.options.focusOverlay.activeFilter() : t;
794
2762
  if (r) {
795
2763
  let t = structuredClone(this.options), n = this.options.focusOverlay?.scale || 1;
796
2764
  t.focusOverlay = { activeFilter: !1 };
797
- let r = Number(t.style?.fontSize || W.style?.fontSize || 20) * n;
2765
+ let r = Number(t.style?.fontSize || $.style?.fontSize || 20) * n;
798
2766
  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
2767
  let e = this.make.sprite({
800
- asset: j.WHITE,
2768
+ asset: k.WHITE,
801
2769
  tint: this.options.focusOverlay.backing.options?.color ?? 0,
802
2770
  alpha: this.options.focusOverlay.backing.options?.alpha ?? .8,
803
2771
  width: this.app.size.width,
@@ -812,12 +2780,12 @@ var jn = class extends w {
812
2780
  }
813
2781
  }
814
2782
  _showCloneOverlay() {
815
- this.cloneOverlay.pivot.y = -20, this.addAnimation(N.to(this.cloneOverlay, {
2783
+ this.cloneOverlay.pivot.y = -20, this.addAnimation(A.to(this.cloneOverlay, {
816
2784
  duration: .5,
817
2785
  alpha: .8,
818
2786
  ease: "sine.out",
819
2787
  delay: .1
820
- })), this.addAnimation(N.to(this.cloneOverlay.pivot, {
2788
+ })), this.addAnimation(A.to(this.cloneOverlay.pivot, {
821
2789
  duration: .5,
822
2790
  y: 0,
823
2791
  ease: "sine.out",
@@ -850,15 +2818,15 @@ var jn = class extends w {
850
2818
  }
851
2819
  _updateCaretAndSelection() {
852
2820
  if (!this.domElement) {
853
- b.warn(this.label, "No dom element");
2821
+ c.warn(this.label, "No dom element");
854
2822
  return;
855
2823
  }
856
2824
  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;
2825
+ if (t === void 0) r = i.substring(0, e), this._caretPosition = T.measureText(r, this.input.style).width, this._selectionRect = null;
858
2826
  else {
859
2827
  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;
2828
+ let a = i.substring(0, e > t ? t : e), o = T.measureText(a, this.input.style), s = T.measureText(r, this.input.style);
2829
+ 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
2830
  }
863
2831
  }
864
2832
  _handleDomElementChange(e) {
@@ -877,62 +2845,17 @@ var jn = class extends w {
877
2845
  let e = this._inputContainer.getBounds();
878
2846
  return e.width = this._lastWidth, e.height = this._lastHeight, e;
879
2847
  }
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 {
2848
+ }, Dr = class extends _ {
926
2849
  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({
2850
+ 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
2851
  outerScale: 1,
929
2852
  innerScale: 1
930
2853
  }, e), !this.settings.outer) {
931
- let e = new k();
2854
+ let e = new E();
932
2855
  e.circle(0, 0, 60).fill({ color: 0 }), e.alpha = .5, this.settings.outer = e;
933
2856
  }
934
2857
  if (!this.settings.inner) {
935
- let e = new k();
2858
+ let e = new E();
936
2859
  e.circle(0, 0, 35).fill({ color: 0 }), e.alpha = this.innerAlphaStandby, this.settings.inner = e;
937
2860
  }
938
2861
  this.threshold = this.settings.threshold ?? .01, this.initialize();
@@ -942,12 +2865,12 @@ var Wn = class extends w {
942
2865
  }
943
2866
  handleDragMove(e) {
944
2867
  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;
2868
+ 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
2869
  if (n == 0 && r == 0) {
947
2870
  this.direction = o;
948
2871
  return;
949
2872
  }
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)) {
2873
+ 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
2874
  this.direction = o, this.onChange.emit({
952
2875
  angle: a,
953
2876
  direction: o,
@@ -955,7 +2878,7 @@ var Wn = class extends w {
955
2878
  });
956
2879
  return;
957
2880
  }
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)) {
2881
+ 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
2882
  this.direction = o, this.onChange.emit({
960
2883
  angle: a,
961
2884
  direction: o,
@@ -979,7 +2902,7 @@ var Wn = class extends w {
979
2902
  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
2903
  }
981
2904
  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);
2905
+ 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
2906
  }
984
2907
  bindEvents() {
985
2908
  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 +2913,24 @@ var Wn = class extends w {
990
2913
  }
991
2914
  getDirection(e) {
992
2915
  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;
2916
+ 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
2917
  }
995
- }, Gn = {
2918
+ }, Or = {
996
2919
  color: 0,
997
2920
  alpha: .75
998
- }, Kn = {
2921
+ }, kr = {
999
2922
  backing: !0,
1000
2923
  closeOnEscape: !0,
1001
2924
  closeOnPointerDownOutside: !0,
1002
2925
  actionContext: "popup"
1003
- }, qn = class e extends w {
2926
+ }, Ar = class e extends _ {
1004
2927
  get actionContext() {
1005
2928
  return this.config.actionContext;
1006
2929
  }
1007
2930
  constructor(e, t = {}) {
1008
2931
  super(), this.id = e, this.isShowing = !1, this._storedActionContext = void 0, this.config = Object.assign({
1009
2932
  id: e,
1010
- ...Kn
2933
+ ...kr
1011
2934
  }, t), this._initialize();
1012
2935
  }
1013
2936
  get data() {
@@ -1016,7 +2939,7 @@ var Wn = class extends w {
1016
2939
  static makeBacking(e, t) {
1017
2940
  let n = {};
1018
2941
  typeof e == "object" && (n = e);
1019
- let r = Object.assign({ ...Gn }, n), i = new en(j.WHITE);
2942
+ let r = Object.assign({ ...Or }, n), i = new Et(k.WHITE);
1020
2943
  return i.anchor.set(.5), i.alpha = r.alpha, i.tint = r.color, i.width = t.width, i.height = t.height, i;
1021
2944
  }
1022
2945
  initialize() {}
@@ -1050,184 +2973,15 @@ var Wn = class extends w {
1050
2973
  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
2974
  }
1052
2975
  setActionContext() {
1053
- this.actionContext && (this.app.actionContext = this.actionContext, b.log("Popup", "Setting action context", this.app.actionContext));
2976
+ this.actionContext && (this.app.actionContext = this.actionContext, c.log("Popup", "Setting action context", this.app.actionContext));
1054
2977
  }
1055
2978
  storeActionContext() {
1056
- this._storedActionContext = this.app.actionContext, b.log("Popup", "Storing action context", this._storedActionContext);
2979
+ this._storedActionContext = this.app.actionContext, c.log("Popup", "Storing action context", this._storedActionContext);
1057
2980
  }
1058
2981
  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;
2982
+ this._storedActionContext && (c.log("Popup", "Restoring action context", this._storedActionContext), this.app.actionContext = this._storedActionContext), this._storedActionContext = void 0;
1188
2983
  }
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 };
2984
+ }, jr = x.Collector, Mr = x.CollectorArray, Nr = x.CollectorLast, Pr = x.CollectorUntil0, Fr = x.CollectorWhile0, Ir = x.SignalConnections;
2985
+ 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
2986
 
1233
2987
  //# sourceMappingURL=caper.mjs.map