@aerogel/core 0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c → 0.0.0-next.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2

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 (139) hide show
  1. package/dist/aerogel-core.d.ts +2255 -1046
  2. package/dist/aerogel-core.js +2763 -0
  3. package/dist/aerogel-core.js.map +1 -0
  4. package/package.json +23 -37
  5. package/src/bootstrap/bootstrap.test.ts +7 -11
  6. package/src/bootstrap/index.ts +36 -16
  7. package/src/bootstrap/options.ts +4 -1
  8. package/src/components/AGAppLayout.vue +3 -2
  9. package/src/components/AGAppModals.vue +1 -1
  10. package/src/components/AGAppOverlays.vue +6 -2
  11. package/src/components/AGAppSnackbars.vue +1 -1
  12. package/src/components/composition.ts +23 -0
  13. package/src/components/contracts/Modal.ts +16 -0
  14. package/src/components/contracts/index.ts +2 -0
  15. package/src/components/contracts/shared.ts +9 -0
  16. package/src/components/forms/AGButton.vue +2 -2
  17. package/src/components/forms/AGCheckbox.vue +10 -3
  18. package/src/components/forms/AGForm.vue +11 -12
  19. package/src/components/forms/AGInput.vue +13 -7
  20. package/src/components/forms/AGSelect.story.vue +21 -3
  21. package/src/components/forms/AGSelect.vue +20 -19
  22. package/src/components/headless/forms/AGHeadlessButton.ts +3 -0
  23. package/src/components/headless/forms/AGHeadlessButton.vue +24 -13
  24. package/src/components/headless/forms/AGHeadlessInput.ts +22 -14
  25. package/src/components/headless/forms/AGHeadlessInput.vue +19 -6
  26. package/src/components/headless/forms/AGHeadlessInputDescription.vue +28 -0
  27. package/src/components/headless/forms/AGHeadlessInputError.vue +2 -2
  28. package/src/components/headless/forms/AGHeadlessInputInput.vue +45 -6
  29. package/src/components/headless/forms/AGHeadlessInputLabel.vue +1 -1
  30. package/src/components/headless/forms/AGHeadlessInputTextArea.vue +43 -0
  31. package/src/components/headless/forms/AGHeadlessSelect.ts +20 -22
  32. package/src/components/headless/forms/AGHeadlessSelect.vue +34 -33
  33. package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
  34. package/src/components/headless/forms/AGHeadlessSelectOption.vue +14 -22
  35. package/src/components/headless/forms/AGHeadlessSelectOptions.vue +19 -0
  36. package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +25 -0
  37. package/src/components/headless/forms/composition.ts +10 -0
  38. package/src/components/headless/forms/index.ts +6 -3
  39. package/src/components/headless/modals/AGHeadlessModal.ts +25 -8
  40. package/src/components/headless/modals/AGHeadlessModal.vue +12 -12
  41. package/src/components/headless/modals/AGHeadlessModalContent.vue +25 -0
  42. package/src/components/headless/modals/index.ts +3 -2
  43. package/src/components/headless/snackbars/index.ts +25 -10
  44. package/src/components/index.ts +2 -0
  45. package/src/components/lib/AGErrorMessage.vue +4 -4
  46. package/src/components/lib/AGMarkdown.vue +24 -6
  47. package/src/components/lib/AGMeasured.vue +16 -0
  48. package/src/components/lib/AGProgressBar.vue +55 -0
  49. package/src/components/lib/AGStartupCrash.vue +1 -1
  50. package/src/components/lib/index.ts +2 -0
  51. package/src/components/modals/AGAlertModal.ts +18 -0
  52. package/src/components/modals/AGAlertModal.vue +3 -14
  53. package/src/components/modals/AGConfirmModal.ts +33 -1
  54. package/src/components/modals/AGConfirmModal.vue +10 -13
  55. package/src/components/modals/AGErrorReportModal.ts +32 -3
  56. package/src/components/modals/AGErrorReportModal.vue +9 -17
  57. package/src/components/modals/AGErrorReportModalButtons.vue +14 -12
  58. package/src/components/modals/AGErrorReportModalTitle.vue +2 -2
  59. package/src/components/modals/AGLoadingModal.ts +21 -1
  60. package/src/components/modals/AGLoadingModal.vue +3 -7
  61. package/src/components/modals/AGModal.vue +25 -22
  62. package/src/components/modals/AGModalContext.ts +1 -1
  63. package/src/components/modals/AGModalContext.vue +15 -5
  64. package/src/components/modals/AGModalTitle.vue +1 -1
  65. package/src/components/modals/AGPromptModal.ts +41 -0
  66. package/src/components/modals/AGPromptModal.vue +35 -0
  67. package/src/components/modals/index.ts +11 -20
  68. package/src/components/snackbars/AGSnackbar.vue +3 -9
  69. package/src/components/utils.ts +63 -0
  70. package/src/directives/index.ts +13 -5
  71. package/src/directives/measure.ts +40 -0
  72. package/src/errors/Errors.state.ts +1 -1
  73. package/src/errors/Errors.ts +32 -30
  74. package/src/errors/JobCancelledError.ts +3 -0
  75. package/src/errors/index.ts +11 -17
  76. package/src/errors/utils.ts +35 -0
  77. package/src/forms/Form.test.ts +32 -3
  78. package/src/forms/Form.ts +81 -20
  79. package/src/forms/composition.ts +2 -2
  80. package/src/forms/index.ts +3 -1
  81. package/src/forms/utils.ts +34 -3
  82. package/src/forms/validation.ts +19 -0
  83. package/src/{main.ts → index.ts} +3 -0
  84. package/src/jobs/Job.ts +147 -0
  85. package/src/jobs/index.ts +10 -0
  86. package/src/jobs/listeners.ts +3 -0
  87. package/src/jobs/status.ts +4 -0
  88. package/src/lang/DefaultLangProvider.ts +46 -0
  89. package/src/lang/Lang.state.ts +11 -0
  90. package/src/lang/Lang.ts +44 -29
  91. package/src/lang/index.ts +8 -6
  92. package/src/plugins/Plugin.ts +1 -1
  93. package/src/plugins/index.ts +10 -7
  94. package/src/services/App.state.ts +27 -5
  95. package/src/services/App.ts +32 -6
  96. package/src/services/Cache.ts +43 -0
  97. package/src/services/Events.test.ts +39 -0
  98. package/src/services/Events.ts +112 -32
  99. package/src/services/Service.ts +150 -49
  100. package/src/services/Storage.ts +20 -0
  101. package/src/services/index.ts +15 -6
  102. package/src/services/store.ts +8 -5
  103. package/src/services/utils.ts +18 -0
  104. package/src/testing/index.ts +26 -0
  105. package/src/testing/setup.ts +11 -0
  106. package/src/ui/UI.state.ts +9 -2
  107. package/src/ui/UI.ts +233 -45
  108. package/src/ui/index.ts +13 -7
  109. package/src/ui/utils.ts +16 -0
  110. package/src/utils/composition/events.ts +3 -2
  111. package/src/utils/composition/persistent.test.ts +33 -0
  112. package/src/utils/composition/persistent.ts +11 -0
  113. package/src/utils/composition/state.test.ts +47 -0
  114. package/src/utils/composition/state.ts +24 -0
  115. package/src/utils/index.ts +3 -0
  116. package/src/utils/markdown.test.ts +50 -0
  117. package/src/utils/markdown.ts +19 -6
  118. package/src/utils/tailwindcss.test.ts +26 -0
  119. package/src/utils/tailwindcss.ts +7 -0
  120. package/src/utils/vue.ts +33 -17
  121. package/dist/aerogel-core.cjs.js +0 -2
  122. package/dist/aerogel-core.cjs.js.map +0 -1
  123. package/dist/aerogel-core.esm.js +0 -2
  124. package/dist/aerogel-core.esm.js.map +0 -1
  125. package/histoire.config.ts +0 -7
  126. package/noeldemartin.config.js +0 -5
  127. package/postcss.config.js +0 -6
  128. package/src/assets/histoire.css +0 -3
  129. package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
  130. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
  131. package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
  132. package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
  133. package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
  134. package/src/components/modals/AGModal.ts +0 -10
  135. package/src/directives/initial-focus.ts +0 -11
  136. package/src/main.histoire.ts +0 -1
  137. package/tailwind.config.js +0 -4
  138. package/tsconfig.json +0 -11
  139. package/vite.config.ts +0 -14
@@ -0,0 +1,2763 @@
1
+ var ht = Object.defineProperty;
2
+ var gt = (r, t, e) => t in r ? ht(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var b = (r, t, e) => gt(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ref as P, computed as d, watch as Ee, inject as ne, reactive as le, markRaw as Re, nextTick as ze, onUnmounted as fe, defineComponent as h, toRef as Ce, createBlock as _, openBlock as c, unref as l, withCtx as f, createVNode as m, renderSlot as $, provide as me, resolveDynamicComponent as W, normalizeProps as _t, guardReactiveProps as vt, createCommentVNode as I, useAttrs as Be, h as bt, mergeProps as H, createElementVNode as y, onMounted as yt, toRaw as wt, customRef as $t, normalizeClass as F, createTextVNode as j, toDisplayString as M, createElementBlock as w, Fragment as Y, renderList as he, watchEffect as ce, withModifiers as xt, readonly as Fe, useSlots as St, createApp as kt, resolveDirective as At, withDirectives as Ct, normalizeStyle as Pt } from "vue";
5
+ import { JSError as ge, tap as K, MagicObject as Ue, PromisedValue as U, Storage as V, objectOnly as Z, arrayFrom as Ne, isEmpty as Se, objectDeepClone as Mt, fail as N, facade as J, arrayRemove as Pe, getEnv as Et, updateLocationQueryParameters as Gt, forever as It, toString as q, isDevelopment as Q, isTesting as Ge, after as je, uuid as ue, required as Tt, isObject as de, objectWithoutEmpty as We, stringMatchAll as Ht, isInstanceOf as Lt, objectWithout as Ke, noop as Rt, stringExcerpt as jt, ListenersManager as qt, toError as Dt, round as Vt } from "@noeldemartin/utils";
6
+ import O from "virtual:aerogel";
7
+ import { createPinia as zt, setActivePinia as Bt, defineStore as Ft } from "pinia";
8
+ import { DialogRoot as Ut, DialogPortal as Nt, DialogContent as Wt, DialogTitle as Je, SelectRoot as Kt, SelectTrigger as Jt, SelectValue as Ot, SelectItem as Qt, SelectItemText as Xt, SelectPortal as Yt, SelectContent as Zt, SelectViewport as er } from "reka-ui";
9
+ import { DialogTitle as Eo } from "reka-ui";
10
+ import tr from "dompurify";
11
+ import { marked as rr, Renderer as qe } from "marked";
12
+ class Me extends ge {
13
+ constructor(t, e) {
14
+ super(`Service '${t}' failed booting`, { cause: e });
15
+ }
16
+ }
17
+ let Ie = null;
18
+ function Oe() {
19
+ return Ie ?? sr();
20
+ }
21
+ function sr() {
22
+ return K(zt(), (r) => {
23
+ Ie = r, Bt(r);
24
+ });
25
+ }
26
+ function nr() {
27
+ return Ie ?? Oe();
28
+ }
29
+ function or(r, t) {
30
+ return Oe(), Ft(r, t)();
31
+ }
32
+ function _e(r) {
33
+ var t;
34
+ return t = class extends ve {
35
+ usesStore() {
36
+ return !0;
37
+ }
38
+ getName() {
39
+ return r.name ?? null;
40
+ }
41
+ getInitialState() {
42
+ return typeof r.initialState == "function" ? r.initialState() : Object.entries(r.initialState).reduce((e, [s, n]) => {
43
+ try {
44
+ n = structuredClone(n);
45
+ } catch {
46
+ console.warn(
47
+ `Could not clone '${s}' state from ${this.getName()} service, this may cause problems if you're using multiple instances of the service (for example, in unit tests).
48
+ To fix this problem, declare your initialState as a function instead.`
49
+ );
50
+ }
51
+ return e[s] = n, e;
52
+ }, {});
53
+ }
54
+ getComputedStateDefinition() {
55
+ return r.computed ?? {};
56
+ }
57
+ getStateWatchers() {
58
+ return r.watch ?? {};
59
+ }
60
+ serializePersistedState(e) {
61
+ var s;
62
+ return ((s = r.serialize) == null ? void 0 : s.call(r, e)) ?? e;
63
+ }
64
+ deserializePersistedState(e) {
65
+ var s;
66
+ return ((s = r.restore) == null ? void 0 : s.call(r, e)) ?? e;
67
+ }
68
+ }, b(t, "persist", r.persist ?? []), t;
69
+ }
70
+ var Ae;
71
+ let ve = (Ae = class extends Ue {
72
+ constructor() {
73
+ super();
74
+ b(this, "_name");
75
+ b(this, "_booted");
76
+ b(this, "_computedStateKeys");
77
+ b(this, "_watchers");
78
+ b(this, "_store");
79
+ const e = this.getComputedStateDefinition();
80
+ this._name = this.getName() ?? new.target.name, this._booted = new U(), this._computedStateKeys = new Set(Object.keys(e)), this._watchers = this.getStateWatchers(), this._store = this.usesStore() && or(this._name, {
81
+ state: () => this.getInitialState(),
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ getters: e
84
+ });
85
+ }
86
+ get booted() {
87
+ return this._booted;
88
+ }
89
+ static(e) {
90
+ return super.static(e);
91
+ }
92
+ launch() {
93
+ const e = (s) => this._booted.reject(new Me(this._name, s));
94
+ try {
95
+ this.frameworkBoot().then(() => this.boot()).then(() => this._booted.resolve()).catch(e);
96
+ } catch (s) {
97
+ e(s);
98
+ }
99
+ return this._booted;
100
+ }
101
+ hasPersistedState() {
102
+ return V.has(this._name);
103
+ }
104
+ hasState(e) {
105
+ return this._store ? e in this._store.$state || this._computedStateKeys.has(e) : !1;
106
+ }
107
+ getState(e) {
108
+ const s = this._store;
109
+ return e ? s ? s[e] : void 0 : s || {};
110
+ }
111
+ setState(e, s) {
112
+ if (!this._store)
113
+ return;
114
+ const n = typeof e == "string" ? { [e]: s } : e, o = Z(this._store.$state, Object.keys(n));
115
+ Object.assign(this._store.$state, n), this.onStateUpdated(n, o);
116
+ }
117
+ updatePersistedState(e) {
118
+ if (!this._store)
119
+ return;
120
+ const s = Ne(e), n = Z(this._store.$state, s);
121
+ Se(n) || this.onPersistentStateUpdated(n);
122
+ }
123
+ __get(e) {
124
+ return this.hasState(e) ? this.getState(e) : super.__get(e);
125
+ }
126
+ __set(e, s) {
127
+ this.setState({ [e]: s });
128
+ }
129
+ onStateUpdated(e, s) {
130
+ const n = Z(e, this.static("persist"));
131
+ Se(n) || this.onPersistentStateUpdated(n);
132
+ for (const o in e) {
133
+ const a = this._watchers[o];
134
+ !a || e[o] === s[o] || a.call(this, e[o], s[o]);
135
+ }
136
+ }
137
+ onPersistentStateUpdated(e) {
138
+ const s = V.get(this._name);
139
+ s && V.set(this._name, {
140
+ ...s,
141
+ ...this.serializePersistedState(Mt(e))
142
+ });
143
+ }
144
+ usesStore() {
145
+ return !1;
146
+ }
147
+ getName() {
148
+ return null;
149
+ }
150
+ getInitialState() {
151
+ return {};
152
+ }
153
+ getComputedStateDefinition() {
154
+ return {};
155
+ }
156
+ getStateWatchers() {
157
+ return {};
158
+ }
159
+ serializePersistedState(e) {
160
+ return e;
161
+ }
162
+ deserializePersistedState(e) {
163
+ return e;
164
+ }
165
+ async frameworkBoot() {
166
+ this.restorePersistedState();
167
+ }
168
+ async boot() {
169
+ }
170
+ restorePersistedState() {
171
+ if (!(!this.usesStore() || Se(this.static("persist")))) {
172
+ if (V.has(this._name)) {
173
+ const e = V.require(this._name);
174
+ this.setState(this.deserializePersistedState(e));
175
+ return;
176
+ }
177
+ V.set(this._name, Z(this.getState(), this.static("persist")));
178
+ }
179
+ }
180
+ requireStore() {
181
+ return this._store ? this._store : N(`Failed getting '${this._name}' store`);
182
+ }
183
+ }, b(Ae, "persist", []), Ae);
184
+ const Un = {
185
+ Low: -256,
186
+ Default: 0,
187
+ High: 256
188
+ };
189
+ class ar extends ve {
190
+ constructor() {
191
+ super(...arguments);
192
+ b(this, "listeners", {});
193
+ }
194
+ async boot() {
195
+ Object.entries(globalThis.__aerogelEvents__ ?? {}).forEach(([e, s]) => this.on(e, s));
196
+ }
197
+ async emit(e, s) {
198
+ var o;
199
+ const n = this.listeners[e] ?? { priorities: [], handlers: {} };
200
+ for (const a of n.priorities)
201
+ await Promise.all(((o = n.handlers[a]) == null ? void 0 : o.map((i) => i(s))) ?? []);
202
+ }
203
+ // prettier-ignore
204
+ /* eslint-enable max-len */
205
+ on(e, s, n) {
206
+ const o = typeof s == "function" ? {} : typeof s == "number" ? { priority: s } : s, a = typeof s == "function" ? s : n;
207
+ return this.registerListener(e, o, a), () => this.off(e, a);
208
+ }
209
+ // prettier-ignore
210
+ /* eslint-enable max-len */
211
+ once(e, s, n) {
212
+ let o = null;
213
+ const a = typeof s == "function" ? {} : s, i = typeof s == "function" ? s : n;
214
+ return K(
215
+ () => o && this.off(e, o),
216
+ (u) => {
217
+ o = (...p) => (u(), i(...p)), this.registerListener(e, a, i);
218
+ }
219
+ );
220
+ }
221
+ off(e, s) {
222
+ var a;
223
+ const n = this.listeners[e];
224
+ if (!n)
225
+ return;
226
+ const o = [...n.priorities];
227
+ for (const i of o)
228
+ Pe(n.handlers[i] ?? [], s), ((a = n.handlers[i]) == null ? void 0 : a.length) === 0 && (delete n.handlers[i], Pe(n.priorities, i));
229
+ n.priorities.length === 0 && delete this.listeners[e];
230
+ }
231
+ registerListener(e, s, n) {
232
+ var u, p, v;
233
+ const o = s.priority ?? 0;
234
+ e in this.listeners || (this.listeners[e] = { priorities: [], handlers: {} });
235
+ const a = ((u = this.listeners[e]) == null ? void 0 : u.priorities) ?? N(`priorities missing for event '${e}'`), i = ((p = this.listeners[e]) == null ? void 0 : p.handlers) ?? N(`handlers missing for event '${e}'`);
236
+ a.includes(o) || (a.push(o), a.sort((E, A) => A - E), i[o] = []), (v = i[o]) == null || v.push(n);
237
+ }
238
+ }
239
+ const S = J(ar), ir = _e({
240
+ name: "app",
241
+ initialState: {
242
+ plugins: {},
243
+ instance: null,
244
+ environment: Et() ?? "development",
245
+ version: O.version,
246
+ sourceUrl: O.sourceUrl
247
+ },
248
+ computed: {
249
+ development: (r) => r.environment === "development",
250
+ staging: (r) => r.environment === "staging",
251
+ testing: (r) => r.environment === "test" || r.environment === "testing",
252
+ versionName(r) {
253
+ return this.development ? "dev." + O.sourceHash.toString().substring(0, 7) : this.staging ? "staging." + O.sourceHash.toString().substring(0, 7) : `v${r.version}`;
254
+ },
255
+ versionUrl(r) {
256
+ return r.sourceUrl + (this.development || this.staging ? `/tree/${O.sourceHash}` : `/releases/tag/${this.versionName}`);
257
+ }
258
+ }
259
+ });
260
+ class lr extends ir {
261
+ constructor() {
262
+ super(...arguments);
263
+ b(this, "name", O.name);
264
+ b(this, "ready", new U());
265
+ b(this, "mounted", new U());
266
+ }
267
+ isReady() {
268
+ return this.ready.isResolved();
269
+ }
270
+ isMounted() {
271
+ return this.mounted.isResolved();
272
+ }
273
+ async whenReady(e) {
274
+ return await this.ready.then(e);
275
+ }
276
+ async reload(e) {
277
+ e && Gt(e), location.reload(), await It();
278
+ }
279
+ plugin(e) {
280
+ return this.plugins[e] ?? null;
281
+ }
282
+ service(e) {
283
+ var s;
284
+ return ((s = this.instance) == null ? void 0 : s.config.globalProperties[e]) ?? null;
285
+ }
286
+ async boot() {
287
+ S.once("application-ready", () => this.ready.resolve()), S.once("application-mounted", () => this.mounted.resolve());
288
+ }
289
+ }
290
+ const z = J(lr);
291
+ function Nn(r) {
292
+ return r;
293
+ }
294
+ async function cr(r, ...t) {
295
+ z.setState(
296
+ "plugins",
297
+ r.reduce(
298
+ (e, s) => (s.name && (e[s.name] = s), e),
299
+ {}
300
+ )
301
+ ), await Promise.all(r.map((e) => e.install(...t)) ?? []);
302
+ }
303
+ function ur(r) {
304
+ return {
305
+ type: Array,
306
+ default: r ?? (() => [])
307
+ };
308
+ }
309
+ function be(r = !1) {
310
+ return {
311
+ type: Boolean,
312
+ default: r
313
+ };
314
+ }
315
+ function Te() {
316
+ return P();
317
+ }
318
+ function Wn(r) {
319
+ const t = P(), e = d(r);
320
+ return Ee(e, async () => t.value = await e.value, { immediate: !0 }), t;
321
+ }
322
+ function Kn(r) {
323
+ return r;
324
+ }
325
+ function X(r, t) {
326
+ const e = Object.values(r);
327
+ return {
328
+ type: String,
329
+ default: t ?? e[0] ?? null,
330
+ validator: (s) => e.includes(s)
331
+ };
332
+ }
333
+ function dr(r) {
334
+ const t = ne(r);
335
+ return t ? le(t) : void 0;
336
+ }
337
+ function R(r, t) {
338
+ return dr(r) ?? N(t ?? `Could not resolve '${q(r)}' injection key`);
339
+ }
340
+ function Jn(r, t) {
341
+ return ne(r) ?? N(t ?? `Could not resolve '${q(r)}' injection key`);
342
+ }
343
+ function On() {
344
+ return {
345
+ type: Function,
346
+ default: null
347
+ };
348
+ }
349
+ function ye(r, t) {
350
+ return {
351
+ type: r,
352
+ default: t ?? null
353
+ };
354
+ }
355
+ function te(r = null) {
356
+ return {
357
+ type: Number,
358
+ default: r
359
+ };
360
+ }
361
+ function B(r = null) {
362
+ return {
363
+ type: Object,
364
+ default: r
365
+ };
366
+ }
367
+ function Qe() {
368
+ return {
369
+ type: Array,
370
+ required: !0
371
+ };
372
+ }
373
+ function Qn(r) {
374
+ const t = Object.values(r);
375
+ return {
376
+ type: String,
377
+ required: !0,
378
+ validator: (e) => t.includes(e)
379
+ };
380
+ }
381
+ function pr(r) {
382
+ return {
383
+ type: r,
384
+ required: !0
385
+ };
386
+ }
387
+ function Xn() {
388
+ return {
389
+ type: Number,
390
+ required: !0
391
+ };
392
+ }
393
+ function we() {
394
+ return {
395
+ type: Object,
396
+ required: !0
397
+ };
398
+ }
399
+ function re() {
400
+ return {
401
+ type: String,
402
+ required: !0
403
+ };
404
+ }
405
+ function g(r = null) {
406
+ return {
407
+ type: String,
408
+ default: r
409
+ };
410
+ }
411
+ const ke = /* @__PURE__ */ new WeakMap(), fr = {
412
+ mounted(r, { value: t }) {
413
+ const e = typeof t == "function" ? t : null, s = () => {
414
+ const n = r.getBoundingClientRect();
415
+ r.style.setProperty("--width", `${n.width}px`), r.style.setProperty("--height", `${n.height}px`), e == null || e({ width: n.width, height: n.height });
416
+ };
417
+ ke.set(r, K(new ResizeObserver(s)).observe(r)), s();
418
+ },
419
+ unmounted(r) {
420
+ var t;
421
+ (t = ke.get(r)) == null || t.unobserve(r), ke.delete(r);
422
+ }
423
+ }, mr = {
424
+ measure: fr
425
+ }, hr = {
426
+ install(r, t) {
427
+ const e = {
428
+ ...mr,
429
+ ...t.directives
430
+ };
431
+ for (const [s, n] of Object.entries(e))
432
+ r.directive(s, n);
433
+ }
434
+ };
435
+ class gr extends ve {
436
+ constructor() {
437
+ super(...arguments);
438
+ b(this, "cache");
439
+ }
440
+ async get(e) {
441
+ return await (await this.open()).match(e) ?? null;
442
+ }
443
+ async store(e, s) {
444
+ await (await this.open()).put(e, s);
445
+ }
446
+ async replace(e, s) {
447
+ const n = await this.open();
448
+ (await n.keys(e)).length !== 0 && await n.put(e, s);
449
+ }
450
+ async open() {
451
+ return this.cache = this.cache ?? K(new U(), (e) => {
452
+ caches.open("app").then((s) => e.resolve(s));
453
+ });
454
+ }
455
+ }
456
+ const Yn = J(gr);
457
+ class _r extends ve {
458
+ async purge() {
459
+ await S.emit("purge-storage");
460
+ }
461
+ }
462
+ const vr = J(_r);
463
+ function Zn(r, t) {
464
+ return {
465
+ ...r,
466
+ ...Z(t, Object.keys(r))
467
+ };
468
+ }
469
+ const br = {
470
+ $app: z,
471
+ $events: S,
472
+ $storage: vr
473
+ };
474
+ async function $e(r, t) {
475
+ await Promise.all(
476
+ Object.entries(t).map(async ([e, s]) => {
477
+ await s.launch().catch((n) => {
478
+ var o, a;
479
+ return (a = (o = r.config).errorHandler) == null ? void 0 : a.call(o, n, null, `Failed launching ${e}.`);
480
+ });
481
+ })
482
+ ), Object.assign(r.config.globalProperties, t), (Q() || Ge()) && Object.assign(globalThis, t);
483
+ }
484
+ const yr = {
485
+ async install(r, t) {
486
+ const e = {
487
+ ...br,
488
+ ...t.services
489
+ };
490
+ r.use(nr()), await $e(r, e);
491
+ }
492
+ }, Xe = 768, pe = {
493
+ Mobile: "mobile",
494
+ Desktop: "desktop"
495
+ };
496
+ function Ye() {
497
+ return globalThis.innerWidth > Xe ? pe.Desktop : pe.Mobile;
498
+ }
499
+ const wr = _e({
500
+ name: "ui",
501
+ initialState: {
502
+ modals: [],
503
+ snackbars: [],
504
+ layout: Ye()
505
+ },
506
+ computed: {
507
+ mobile: ({ layout: r }) => r === pe.Mobile,
508
+ desktop: ({ layout: r }) => r === pe.Desktop
509
+ }
510
+ }), C = {
511
+ AlertModal: "alert-modal",
512
+ ConfirmModal: "confirm-modal",
513
+ ErrorReportModal: "error-report-modal",
514
+ LoadingModal: "loading-modal",
515
+ PromptModal: "prompt-modal",
516
+ Snackbar: "snackbar",
517
+ StartupCrash: "startup-crash"
518
+ };
519
+ class $r extends wr {
520
+ constructor() {
521
+ super(...arguments);
522
+ b(this, "modalCallbacks", {});
523
+ b(this, "components", {});
524
+ }
525
+ requireComponent(e) {
526
+ return this.components[e] ?? N(`UI Component '${e}' is not defined!`);
527
+ }
528
+ alert(e, s) {
529
+ const n = () => typeof s != "string" ? { message: e } : {
530
+ title: e,
531
+ message: s
532
+ };
533
+ this.openModal(this.requireComponent(C.AlertModal), n());
534
+ }
535
+ // prettier-ignore
536
+ /* eslint-enable max-len */
537
+ async confirm(e, s, n) {
538
+ const a = typeof s != "string" ? {
539
+ ...s ?? {},
540
+ message: e,
541
+ required: !!(s != null && s.required)
542
+ } : {
543
+ ...n ?? {},
544
+ title: e,
545
+ message: s,
546
+ required: !!(n != null && n.required)
547
+ }, u = await (await this.openModal(this.requireComponent(C.ConfirmModal), a)).beforeClose, p = typeof u == "object" ? u[0] : u ?? !1, v = typeof u == "object" ? u[1] : Object.entries(a.checkboxes ?? {}).reduce(
548
+ (E, [A, { default: ae }]) => ({
549
+ [A]: ae ?? !1,
550
+ ...E
551
+ }),
552
+ {}
553
+ );
554
+ for (const [E, A] of Object.entries(a.checkboxes ?? {}))
555
+ if (!(!A.required || v[E]))
556
+ return p && Q() && console.warn(`Confirmed confirm modal was suppressed because required '${E}' checkbox was missing`), [!1, v];
557
+ return "checkboxes" in a ? [p, v] : p;
558
+ }
559
+ async prompt(e, s, n) {
560
+ const o = (n == null ? void 0 : n.trim) ?? !0, a = () => typeof s != "string" ? {
561
+ message: e,
562
+ ...s ?? {}
563
+ } : {
564
+ title: e,
565
+ message: s,
566
+ ...n ?? {}
567
+ }, u = await (await this.openModal(
568
+ this.requireComponent(C.PromptModal),
569
+ a()
570
+ )).beforeClose;
571
+ return (o && typeof u == "string" ? u == null ? void 0 : u.trim() : u) ?? null;
572
+ }
573
+ async loading(e, s) {
574
+ const n = (p) => typeof p == "function" ? Promise.resolve(p()) : p, o = () => typeof e == "string" ? {
575
+ props: { message: e },
576
+ operationPromise: n(s)
577
+ } : typeof e == "function" || e instanceof Promise ? { operationPromise: n(e) } : {
578
+ props: e,
579
+ operationPromise: n(s)
580
+ }, { operationPromise: a, props: i } = o(), u = await this.openModal(this.requireComponent(C.LoadingModal), i);
581
+ try {
582
+ const [p] = await Promise.all([a, je({ seconds: 1 })]);
583
+ return p;
584
+ } finally {
585
+ await this.closeModal(u.id);
586
+ }
587
+ }
588
+ showSnackbar(e, s = {}) {
589
+ const n = {
590
+ id: ue(),
591
+ properties: { message: e, ...s },
592
+ component: Re(s.component ?? this.requireComponent(C.Snackbar))
593
+ };
594
+ this.setState("snackbars", this.snackbars.concat(n)), setTimeout(() => this.hideSnackbar(n.id), 5e3);
595
+ }
596
+ hideSnackbar(e) {
597
+ this.setState(
598
+ "snackbars",
599
+ this.snackbars.filter((s) => s.id !== e)
600
+ );
601
+ }
602
+ registerComponent(e, s) {
603
+ this.components[e] = s;
604
+ }
605
+ async openModal(e, s) {
606
+ const n = ue(), o = {}, a = {
607
+ id: n,
608
+ properties: s ?? {},
609
+ component: Re(e),
610
+ beforeClose: new Promise((p) => o.willClose = p),
611
+ afterClose: new Promise((p) => o.closed = p)
612
+ }, i = this.modals.at(-1), u = this.modals.concat(a);
613
+ return this.modalCallbacks[a.id] = o, this.setState({ modals: u }), await ze(), await (i && S.emit("hide-modal", { id: i.id })), await Promise.all([
614
+ i || S.emit("show-overlays-backdrop"),
615
+ S.emit("show-modal", { id: a.id })
616
+ ]), a;
617
+ }
618
+ async closeModal(e, s) {
619
+ if (!z.isMounted()) {
620
+ await this.removeModal(e, s);
621
+ return;
622
+ }
623
+ await S.emit("close-modal", { id: e, result: s });
624
+ }
625
+ async closeAllModals() {
626
+ for (; this.modals.length > 0; )
627
+ await this.closeModal(Tt(this.modals[this.modals.length - 1]).id);
628
+ }
629
+ async boot() {
630
+ this.watchModalEvents(), this.watchMountedEvent(), this.watchViewportBreakpoints();
631
+ }
632
+ async removeModal(e, s) {
633
+ var o, a;
634
+ this.setState(
635
+ "modals",
636
+ this.modals.filter((i) => i.id !== e)
637
+ ), (a = (o = this.modalCallbacks[e]) == null ? void 0 : o.closed) == null || a.call(o, s), delete this.modalCallbacks[e];
638
+ const n = this.modals.at(-1);
639
+ await (n && S.emit("show-modal", { id: n.id }));
640
+ }
641
+ watchModalEvents() {
642
+ S.on("modal-will-close", ({ modal: e, result: s }) => {
643
+ var n, o;
644
+ (o = (n = this.modalCallbacks[e.id]) == null ? void 0 : n.willClose) == null || o.call(n, s), this.modals.length === 1 && S.emit("hide-overlays-backdrop");
645
+ }), S.on("modal-closed", async ({ modal: { id: e }, result: s }) => {
646
+ await this.removeModal(e, s);
647
+ });
648
+ }
649
+ watchMountedEvent() {
650
+ S.once("application-mounted", async () => {
651
+ if (!globalThis.document || !globalThis.getComputedStyle)
652
+ return;
653
+ const e = globalThis.document.getElementById("splash");
654
+ e && (globalThis.getComputedStyle(e).opacity !== "0" && (e.style.opacity = "0", await je({ ms: 600 })), e.remove());
655
+ });
656
+ }
657
+ watchViewportBreakpoints() {
658
+ if (!globalThis.matchMedia)
659
+ return;
660
+ globalThis.matchMedia(`(min-width: ${Xe}px)`).addEventListener("change", () => this.setState({ layout: Ye() }));
661
+ }
662
+ }
663
+ const G = J($r);
664
+ class xr {
665
+ constructor(t, e) {
666
+ this.locale = t, this.fallbackLocale = e;
667
+ }
668
+ getLocale() {
669
+ return this.locale;
670
+ }
671
+ async setLocale(t) {
672
+ this.locale = t;
673
+ }
674
+ getFallbackLocale() {
675
+ return this.fallbackLocale;
676
+ }
677
+ async setFallbackLocale(t) {
678
+ this.fallbackLocale = t;
679
+ }
680
+ getLocales() {
681
+ return ["en"];
682
+ }
683
+ translate(t) {
684
+ return Q() && console.warn("Lang provider is missing"), t;
685
+ }
686
+ translateWithDefault(t, e) {
687
+ return Q() && console.warn("Lang provider is missing"), e;
688
+ }
689
+ }
690
+ const Sr = _e({
691
+ name: "lang",
692
+ persist: ["locale", "fallbackLocale"],
693
+ initialState: {
694
+ locale: null,
695
+ locales: ["en"],
696
+ fallbackLocale: "en"
697
+ }
698
+ });
699
+ class kr extends Sr {
700
+ constructor() {
701
+ super();
702
+ b(this, "provider");
703
+ this.provider = new xr(
704
+ this.getState("locale") ?? this.getBrowserLocale(),
705
+ this.getState("fallbackLocale")
706
+ );
707
+ }
708
+ async setProvider(e) {
709
+ this.provider = e, this.locales = e.getLocales(), await e.setLocale(this.locale ?? this.getBrowserLocale()), await e.setFallbackLocale(this.fallbackLocale);
710
+ }
711
+ translate(e, s) {
712
+ return this.provider.translate(e, s) ?? e;
713
+ }
714
+ translateWithDefault(e, s, n = {}) {
715
+ return this.provider.translateWithDefault(e, s, n);
716
+ }
717
+ getBrowserLocale() {
718
+ const e = this.getState("locales");
719
+ return navigator.languages.find((s) => e.includes(s)) ?? "en";
720
+ }
721
+ async boot() {
722
+ globalThis.document && this.requireStore().$subscribe(
723
+ async () => {
724
+ var e, s;
725
+ await this.provider.setLocale(this.locale ?? this.getBrowserLocale()), await this.provider.setFallbackLocale(this.fallbackLocale), this.locale ? (e = document.querySelector("html")) == null || e.setAttribute("lang", this.locale) : (s = document.querySelector("html")) == null || s.removeAttribute("lang");
726
+ },
727
+ { immediate: !0 }
728
+ );
729
+ }
730
+ }
731
+ const se = J(kr), Ze = se.translate.bind(se), x = se.translateWithDefault.bind(se), Ar = _e({
732
+ name: "errors",
733
+ initialState: {
734
+ logs: [],
735
+ startupErrors: []
736
+ },
737
+ computed: {
738
+ hasErrors: ({ logs: r }) => r.length > 0,
739
+ hasNewErrors: ({ logs: r }) => r.some((t) => !t.seen),
740
+ hasStartupErrors: ({ startupErrors: r }) => r.length > 0
741
+ }
742
+ }), k = {
743
+ Primary: "primary",
744
+ Secondary: "secondary",
745
+ Danger: "danger",
746
+ Clear: "clear"
747
+ };
748
+ class Cr extends Ar {
749
+ constructor() {
750
+ super(...arguments);
751
+ b(this, "forceReporting", !1);
752
+ b(this, "enabled", !0);
753
+ }
754
+ enable() {
755
+ this.enabled = !0;
756
+ }
757
+ disable() {
758
+ this.enabled = !1;
759
+ }
760
+ async inspect(e) {
761
+ const s = Array.isArray(e) ? e : [await this.createErrorReport(e)];
762
+ if (s.length === 0) {
763
+ G.alert(x("errors.inspectEmpty", "Nothing to inspect!"));
764
+ return;
765
+ }
766
+ G.openModal(G.requireComponent(C.ErrorReportModal), {
767
+ reports: s
768
+ });
769
+ }
770
+ async report(e, s) {
771
+ if (await S.emit("error", { error: e, message: s }), Ge("unit") || (Q() && this.logError(e), !this.enabled))
772
+ throw e;
773
+ if (!z.isMounted()) {
774
+ const a = await this.createStartupErrorReport(e);
775
+ a && this.setState({ startupErrors: this.startupErrors.concat(a) });
776
+ return;
777
+ }
778
+ const n = await this.createErrorReport(e), o = {
779
+ report: n,
780
+ seen: !1,
781
+ date: /* @__PURE__ */ new Date()
782
+ };
783
+ G.showSnackbar(
784
+ s ?? x("errors.notice", "Something went wrong, but it's not your fault. Try again!"),
785
+ {
786
+ color: k.Danger,
787
+ actions: [
788
+ {
789
+ text: x("errors.viewDetails", "View details"),
790
+ dismiss: !0,
791
+ handler: () => G.openModal(
792
+ G.requireComponent(C.ErrorReportModal),
793
+ { reports: [n] }
794
+ )
795
+ }
796
+ ]
797
+ }
798
+ ), this.setState({ logs: [o].concat(this.logs) });
799
+ }
800
+ see(e) {
801
+ this.setState({
802
+ logs: this.logs.map((s) => s.report !== e ? s : {
803
+ ...s,
804
+ seen: !0
805
+ })
806
+ });
807
+ }
808
+ seeAll() {
809
+ this.setState({
810
+ logs: this.logs.map((e) => ({
811
+ ...e,
812
+ seen: !0
813
+ }))
814
+ });
815
+ }
816
+ logError(e) {
817
+ console.error(e), de(e) && e.cause && this.logError(e.cause);
818
+ }
819
+ async createErrorReport(e) {
820
+ return typeof e == "string" ? { title: e } : e instanceof Error || e instanceof ge ? this.createErrorReportFromError(e) : de(e) ? We({
821
+ title: q(
822
+ e.name ?? e.title ?? x("errors.unknown", "Unknown Error")
823
+ ),
824
+ description: q(
825
+ e.message ?? e.description ?? x("errors.unknownDescription", "Unknown error object")
826
+ ),
827
+ error: e
828
+ }) : {
829
+ title: x("errors.unknown", "Unknown Error"),
830
+ error: e
831
+ };
832
+ }
833
+ async createStartupErrorReport(e) {
834
+ return e instanceof Me ? e.cause instanceof Me ? null : this.createErrorReport(e.cause) : this.createErrorReport(e);
835
+ }
836
+ createErrorReportFromError(e, s = {}) {
837
+ return {
838
+ title: e.name,
839
+ description: e.message,
840
+ details: e.stack,
841
+ error: e,
842
+ ...s
843
+ };
844
+ }
845
+ }
846
+ const et = J(Cr), tt = [];
847
+ function eo(r) {
848
+ tt.push(r);
849
+ }
850
+ function Pr(r) {
851
+ for (const t of tt) {
852
+ const e = t(r);
853
+ if (e)
854
+ return e;
855
+ }
856
+ return typeof r == "string" ? r : r instanceof Error || r instanceof ge ? r.message : de(r) ? q(r.message ?? r.description ?? "Unknown error object") : x("errors.unknown", "Unknown Error");
857
+ }
858
+ class De extends ge {
859
+ }
860
+ const Mr = { $errors: et }, Er = (r) => (et.report(r), !0);
861
+ function Gr(r, t = () => !1) {
862
+ const e = (s) => t(s) || Er(s);
863
+ r.config.errorHandler = e, globalThis.onerror = (s, n, o, a, i) => e(i ?? s), globalThis.onunhandledrejection = (s) => e(s.reason);
864
+ }
865
+ const Ir = {
866
+ async install(r, t) {
867
+ Gr(r, t.handleError), await $e(r, Mr);
868
+ }
869
+ }, Tr = { $lang: se }, Hr = {
870
+ async install(r) {
871
+ var t;
872
+ (t = r.config.globalProperties).$t ?? (t.$t = Ze), r.config.globalProperties.$td = x, await $e(r, Tr);
873
+ }
874
+ }, Lr = {
875
+ async install() {
876
+ Ge() && (globalThis.testingRuntime = {
877
+ on: (...r) => S.on(...r)
878
+ });
879
+ }
880
+ };
881
+ function He(r, t) {
882
+ return Object.keys(t).reduce(
883
+ (e, s) => (e[s] = r[s], e),
884
+ {}
885
+ );
886
+ }
887
+ function Rr(r) {
888
+ if (r instanceof HTMLElement)
889
+ return r;
890
+ if (jr(r))
891
+ return r.$el;
892
+ }
893
+ function jr(r) {
894
+ return de(r) && "$el" in r;
895
+ }
896
+ function to(r) {
897
+ return He(r, Le());
898
+ }
899
+ function Le() {
900
+ return {
901
+ cancellable: be(!0),
902
+ description: g(),
903
+ title: g()
904
+ };
905
+ }
906
+ function qr(r) {
907
+ return {
908
+ cancellable: d(() => {
909
+ var t;
910
+ return !!((t = r.value) != null && t.cancellable);
911
+ }),
912
+ close: async () => {
913
+ var t;
914
+ return (t = r.value) == null ? void 0 : t.close();
915
+ }
916
+ };
917
+ }
918
+ function ee(r, t) {
919
+ const e = S.on(r, t);
920
+ fe(() => e());
921
+ }
922
+ const Dr = /* @__PURE__ */ h({
923
+ __name: "AGHeadlessModal",
924
+ props: Le(),
925
+ setup(r, { expose: t }) {
926
+ const e = r, s = P(null), n = P(!0), o = P(!1), { modal: a } = R(
927
+ "modal",
928
+ "could not obtain modal reference from <AGHeadlessModal>, did you render this component manually? Show it using $ui.openModal() instead"
929
+ );
930
+ async function i() {
931
+ var v;
932
+ (v = s.value) != null && v.$el && (n.value = !0);
933
+ }
934
+ async function u() {
935
+ var v;
936
+ (v = s.value) != null && v.$el && (n.value = !1);
937
+ }
938
+ async function p(v) {
939
+ o.value || (S.emit("modal-will-close", { modal: a, result: v }), await i(), o.value = !0, S.emit("modal-closed", { modal: a, result: v }));
940
+ }
941
+ return ee("close-modal", async ({ id: v, result: E }) => {
942
+ v === a.id && await p(E);
943
+ }), ee("hide-modal", async ({ id: v }) => {
944
+ v === a.id && await i();
945
+ }), ee("show-modal", async ({ id: v }) => {
946
+ v === a.id && await u();
947
+ }), t({ close: p, cancellable: Ce(e, "cancellable") }), (v, E) => (c(), _(l(Ut), {
948
+ ref_key: "$root",
949
+ ref: s,
950
+ open: !0,
951
+ "onUpdate:open": E[0] || (E[0] = (A) => v.cancellable && p())
952
+ }, {
953
+ default: f(() => [
954
+ m(l(Nt), null, {
955
+ default: f(() => [
956
+ $(v.$slots, "default", { close: p })
957
+ ]),
958
+ _: 3
959
+ })
960
+ ]),
961
+ _: 3
962
+ }, 512));
963
+ }
964
+ }), rt = /* @__PURE__ */ h({
965
+ __name: "AGModalContext",
966
+ props: {
967
+ modal: we(),
968
+ childIndex: te(0)
969
+ },
970
+ setup(r) {
971
+ const t = r, e = d(() => {
972
+ const s = {};
973
+ for (const n in t.modal.properties)
974
+ s[n] = l(t.modal.properties[n]);
975
+ return s;
976
+ });
977
+ return me("modal", {
978
+ modal: Ce(t, "modal"),
979
+ childIndex: Ce(t, "childIndex")
980
+ }), (s, n) => (c(), _(W(r.modal.component), _t(vt(e.value)), null, 16));
981
+ }
982
+ }), Vr = /* @__PURE__ */ h({
983
+ __name: "AGHeadlessModalContent",
984
+ setup(r) {
985
+ const { childIndex: t } = R(
986
+ "modal",
987
+ "could not obtain modal reference from <AGHeadlessModalContent>, did you render this component manually? Show it using $ui.openModal() instead"
988
+ ), e = d(() => G.modals[t] ?? null);
989
+ return (s, n) => (c(), _(l(Wt), null, {
990
+ default: f(() => [
991
+ $(s.$slots, "default"),
992
+ e.value ? (c(), _(rt, {
993
+ key: 0,
994
+ "child-index": l(t) + 1,
995
+ modal: e.value
996
+ }, null, 8, ["child-index", "modal"])) : I("", !0)
997
+ ]),
998
+ _: 3
999
+ }));
1000
+ }
1001
+ });
1002
+ function zr() {
1003
+ return K(new qe(), (r) => {
1004
+ r.link = function(t) {
1005
+ return qe.prototype.link.apply(this, [t]).replace("<a", '<a target="_blank"');
1006
+ };
1007
+ });
1008
+ }
1009
+ function Br(r) {
1010
+ const t = Ht(r, /<a[^>]*href="#action:([^"]+)"[^>]*>([^<]+)<\/a>/g);
1011
+ for (const [e, s, n] of t)
1012
+ r = r.replace(e, `<button type="button" data-markdown-action="${s}">${n}</button>`);
1013
+ return r;
1014
+ }
1015
+ function Fr(r) {
1016
+ let t = rr(r, { renderer: zr(), async: !1 });
1017
+ return t = Ur(t), t = Br(t), t;
1018
+ }
1019
+ function Ur(r) {
1020
+ return tr.sanitize(r, { ADD_ATTR: ["target"] });
1021
+ }
1022
+ const T = /* @__PURE__ */ h({
1023
+ __name: "AGMarkdown",
1024
+ props: {
1025
+ as: g(),
1026
+ inline: be(),
1027
+ langKey: g(),
1028
+ langParams: ye(),
1029
+ text: g(),
1030
+ actions: B()
1031
+ },
1032
+ setup(r) {
1033
+ const t = r, e = Be(), s = d(() => t.text ?? (t.langKey && Ze(t.langKey, t.langParams ?? {}))), n = d(() => {
1034
+ if (!s.value)
1035
+ return null;
1036
+ let i = Fr(s.value);
1037
+ return t.inline && (i = i.replace("<p>", "<span>").replace("</p>", "</span>")), i;
1038
+ }), o = () => bt(t.as ?? (t.inline ? "span" : "div"), {
1039
+ innerHTML: n.value,
1040
+ onClick: a,
1041
+ ...e,
1042
+ class: `${e.class ?? ""} ${t.inline ? "" : "prose"}`
1043
+ });
1044
+ async function a(i) {
1045
+ var p, v;
1046
+ const { target: u } = i;
1047
+ if (Lt(u, HTMLElement) && u.dataset.markdownAction) {
1048
+ (v = (p = t.actions) == null ? void 0 : p[u.dataset.markdownAction]) == null || v.call(p);
1049
+ return;
1050
+ }
1051
+ }
1052
+ return (i, u) => (c(), _(o));
1053
+ }
1054
+ }), oe = /* @__PURE__ */ h({
1055
+ inheritAttrs: !1,
1056
+ __name: "AGModal",
1057
+ props: Le(),
1058
+ setup(r, { expose: t }) {
1059
+ const e = r, s = P();
1060
+ return t(qr(s)), (n, o) => (c(), _(Dr, H({
1061
+ ref_key: "$modal",
1062
+ ref: s
1063
+ }, e, { class: "relative" }), {
1064
+ default: f(({ close: a }) => [
1065
+ m(Vr, { class: "fixed top-1/2 left-1/2 z-50 max-w-lg -translate-x-1/2 -translate-y-1/2 bg-white p-4" }, {
1066
+ default: f(() => [
1067
+ n.title ? (c(), _(l(Je), {
1068
+ key: 0,
1069
+ class: "mb-2 text-lg font-semibold"
1070
+ }, {
1071
+ default: f(() => [
1072
+ m(T, {
1073
+ text: n.title,
1074
+ inline: ""
1075
+ }, null, 8, ["text"])
1076
+ ]),
1077
+ _: 1
1078
+ })) : I("", !0),
1079
+ y("div", H({ class: "flex max-h-full flex-col overflow-auto" }, n.$attrs), [
1080
+ $(n.$slots, "default", { close: a })
1081
+ ], 16)
1082
+ ]),
1083
+ _: 2
1084
+ }, 1024)
1085
+ ]),
1086
+ _: 3
1087
+ }, 16));
1088
+ }
1089
+ });
1090
+ function Nr() {
1091
+ const r = Be(), t = d(() => r.class);
1092
+ return [d(() => Ke(r, "class")), t];
1093
+ }
1094
+ function ro(r) {
1095
+ let t = Rt;
1096
+ yt(() => t = r()), fe(() => t());
1097
+ }
1098
+ function so(r, t) {
1099
+ const e = le(V.get(r) ?? t);
1100
+ return Ee(e, () => V.set(r, wt(e))), e;
1101
+ }
1102
+ function no(r) {
1103
+ return r.split(/\s+/).filter((t) => !/^(hover|focus|focus-visible):/.test(t)).join(" ").trim();
1104
+ }
1105
+ const Wr = {
1106
+ title: g(),
1107
+ message: re()
1108
+ };
1109
+ function Kr() {
1110
+ return Wr;
1111
+ }
1112
+ const Jr = /* @__PURE__ */ h({
1113
+ __name: "AGAlertModal",
1114
+ props: Kr(),
1115
+ setup(r) {
1116
+ return (t, e) => (c(), _(oe, { title: t.title }, {
1117
+ default: f(() => [
1118
+ m(T, { text: t.message }, null, 8, ["text"])
1119
+ ]),
1120
+ _: 1
1121
+ }, 8, ["title"]));
1122
+ }
1123
+ }), Or = {
1124
+ title: g(),
1125
+ message: re(),
1126
+ acceptText: g(),
1127
+ acceptColor: X(k, k.Primary),
1128
+ cancelText: g(),
1129
+ cancelColor: X(k, k.Clear),
1130
+ checkboxes: B(),
1131
+ actions: B(),
1132
+ required: be(!1)
1133
+ };
1134
+ function Qr() {
1135
+ return Or;
1136
+ }
1137
+ function Xr(r) {
1138
+ const t = d(() => r.acceptText ?? x("ui.accept", "Ok")), e = d(() => r.cancelText ?? x("ui.cancel", "Cancel"));
1139
+ return { renderedAcceptText: t, renderedCancelText: e };
1140
+ }
1141
+ function Yr() {
1142
+ return $t((r, t) => {
1143
+ let e;
1144
+ return {
1145
+ get() {
1146
+ return r(), e;
1147
+ },
1148
+ set(s) {
1149
+ e = Rr(s), t();
1150
+ }
1151
+ };
1152
+ });
1153
+ }
1154
+ const st = /* @__PURE__ */ h({
1155
+ __name: "AGHeadlessButton",
1156
+ props: {
1157
+ as: B(),
1158
+ href: g(),
1159
+ url: g(),
1160
+ route: g(),
1161
+ routeParams: B(() => ({})),
1162
+ routeQuery: B(() => ({})),
1163
+ submit: be()
1164
+ },
1165
+ setup(r, { expose: t }) {
1166
+ const e = r, s = Yr(), n = d(() => e.as ? { as: e.as, props: {} } : e.route ? {
1167
+ as: "router-link",
1168
+ props: {
1169
+ to: We({
1170
+ name: e.route,
1171
+ params: e.routeParams,
1172
+ query: e.routeQuery
1173
+ })
1174
+ }
1175
+ } : e.href || e.url ? {
1176
+ as: "a",
1177
+ props: {
1178
+ target: "_blank",
1179
+ href: e.href || e.url
1180
+ }
1181
+ } : {
1182
+ as: "button",
1183
+ props: { type: e.submit ? "submit" : "button" }
1184
+ });
1185
+ return t({ $el: s }), (o, a) => (c(), _(W(n.value.as), H({
1186
+ ref_key: "$root",
1187
+ ref: s
1188
+ }, n.value.props), {
1189
+ default: f(() => [
1190
+ $(o.$slots, "default")
1191
+ ]),
1192
+ _: 3
1193
+ }, 16));
1194
+ }
1195
+ }), L = /* @__PURE__ */ h({
1196
+ __name: "AGButton",
1197
+ props: {
1198
+ color: X(k, k.Primary)
1199
+ },
1200
+ setup(r) {
1201
+ const t = r, e = d(() => {
1202
+ switch (t.color) {
1203
+ case k.Secondary:
1204
+ return [
1205
+ "text-white bg-gray-600",
1206
+ "hover:bg-gray-500",
1207
+ "focus-visible:outline-offset-2 focus-visible:outline-gray-600"
1208
+ ].join(" ");
1209
+ case k.Clear:
1210
+ return "hover:bg-gray-500/20 focus-visible:outline-gray-500/60";
1211
+ case k.Danger:
1212
+ return [
1213
+ "text-white bg-red-600",
1214
+ "hover:bg-red-500",
1215
+ "focus-visible:outline-offset-2 focus-visible:outline-red-600"
1216
+ ].join(" ");
1217
+ case k.Primary:
1218
+ default:
1219
+ return [
1220
+ "text-white bg-indigo-600",
1221
+ "hover:bg-indigo-500",
1222
+ "focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
1223
+ ].join(" ");
1224
+ }
1225
+ });
1226
+ return (s, n) => (c(), _(st, {
1227
+ class: F(["px-2.5 py-1.5 focus-visible:outline focus-visible:outline-2", e.value])
1228
+ }, {
1229
+ default: f(() => [
1230
+ $(s.$slots, "default")
1231
+ ]),
1232
+ _: 3
1233
+ }, 8, ["class"]));
1234
+ }
1235
+ }), Zr = { class: "mt-2 flex flex-row-reverse gap-2" }, es = /* @__PURE__ */ h({
1236
+ __name: "AGConfirmModal",
1237
+ props: Qr(),
1238
+ setup(r) {
1239
+ const t = r, { renderedAcceptText: e, renderedCancelText: s } = Xr(t);
1240
+ return (n, o) => (c(), _(oe, {
1241
+ cancellable: !1,
1242
+ title: n.title
1243
+ }, {
1244
+ default: f(({ close: a }) => [
1245
+ m(T, {
1246
+ text: n.message,
1247
+ actions: n.actions
1248
+ }, null, 8, ["text", "actions"]),
1249
+ y("div", Zr, [
1250
+ m(L, {
1251
+ color: n.acceptColor,
1252
+ onClick: (i) => a(!0)
1253
+ }, {
1254
+ default: f(() => [
1255
+ j(M(l(e)), 1)
1256
+ ]),
1257
+ _: 2
1258
+ }, 1032, ["color", "onClick"]),
1259
+ n.required ? I("", !0) : (c(), _(L, {
1260
+ key: 0,
1261
+ color: n.cancelColor,
1262
+ onClick: (i) => a()
1263
+ }, {
1264
+ default: f(() => [
1265
+ j(M(l(s)), 1)
1266
+ ]),
1267
+ _: 2
1268
+ }, 1032, ["color", "onClick"]))
1269
+ ])
1270
+ ]),
1271
+ _: 1
1272
+ }, 8, ["title"]));
1273
+ }
1274
+ }), ts = {
1275
+ viewBox: "0 0 20 20",
1276
+ width: "1.2em",
1277
+ height: "1.2em"
1278
+ };
1279
+ function rs(r, t) {
1280
+ return c(), w("svg", ts, t[0] || (t[0] = [
1281
+ y("path", {
1282
+ fill: "currentColor",
1283
+ d: "m12.95 10.707l.707-.707L8 4.343L6.586 5.757L10.828 10l-4.242 4.243L8 15.657z"
1284
+ }, null, -1)
1285
+ ]));
1286
+ }
1287
+ const ss = { name: "zondicons-cheveron-right", render: rs }, ns = {
1288
+ viewBox: "0 0 20 20",
1289
+ width: "1.2em",
1290
+ height: "1.2em"
1291
+ };
1292
+ function os(r, t) {
1293
+ return c(), w("svg", ns, t[0] || (t[0] = [
1294
+ y("path", {
1295
+ fill: "currentColor",
1296
+ d: "M7.05 9.293L6.343 10L12 15.657l1.414-1.414L9.172 10l4.242-4.243L12 4.343z"
1297
+ }, null, -1)
1298
+ ]));
1299
+ }
1300
+ const as = { name: "zondicons-cheveron-left", render: os }, is = {
1301
+ reports: Qe()
1302
+ };
1303
+ function ls() {
1304
+ return is;
1305
+ }
1306
+ function cs(r) {
1307
+ const t = P(0), e = d(() => r.reports[t.value]), s = d(
1308
+ () => {
1309
+ var a;
1310
+ return ((a = e.value.details) == null ? void 0 : a.trim()) || x("errors.detailsEmpty", "This error is missing a stacktrace.");
1311
+ }
1312
+ ), n = x("errors.previousReport", "Show previous report"), o = x("errors.nextReport", "Show next report");
1313
+ return {
1314
+ activeReportIndex: t,
1315
+ details: s,
1316
+ nextReportText: o,
1317
+ previousReportText: n,
1318
+ report: e
1319
+ };
1320
+ }
1321
+ const us = {
1322
+ viewBox: "0 0 24 24",
1323
+ width: "1.2em",
1324
+ height: "1.2em"
1325
+ };
1326
+ function ds(r, t) {
1327
+ return c(), w("svg", us, t[0] || (t[0] = [
1328
+ y("path", {
1329
+ fill: "currentColor",
1330
+ d: "M20 19V7H4v12zm0-16a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm-7 14v-2h5v2zm-3.42-4L5.57 9H8.4l3.3 3.3c.39.39.39 1.03 0 1.42L8.42 17H5.59z"
1331
+ }, null, -1)
1332
+ ]));
1333
+ }
1334
+ const ps = { name: "mdi-console", render: ds }, fs = {
1335
+ viewBox: "0 0 20 20",
1336
+ width: "1.2em",
1337
+ height: "1.2em"
1338
+ };
1339
+ function ms(r, t) {
1340
+ return c(), w("svg", fs, t[0] || (t[0] = [
1341
+ y("path", {
1342
+ fill: "currentColor",
1343
+ d: "M6 6V2c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-4v4a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V8c0-1.1.9-2 2-2zm2 0h4a2 2 0 0 1 2 2v4h4V2H8zM2 8v10h10V8z"
1344
+ }, null, -1)
1345
+ ]));
1346
+ }
1347
+ const hs = { name: "zondicons-copy", render: ms }, gs = {
1348
+ viewBox: "0 0 24 24",
1349
+ width: "1.2em",
1350
+ height: "1.2em"
1351
+ };
1352
+ function _s(r, t) {
1353
+ return c(), w("svg", gs, t[0] || (t[0] = [
1354
+ y("path", {
1355
+ fill: "currentColor",
1356
+ d: "M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33s1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2"
1357
+ }, null, -1)
1358
+ ]));
1359
+ }
1360
+ const vs = { name: "mdi-github", render: _s }, bs = { class: "flex" }, ys = /* @__PURE__ */ h({
1361
+ __name: "AGErrorReportModalButtons",
1362
+ props: {
1363
+ report: we()
1364
+ },
1365
+ setup(r) {
1366
+ const t = r, e = d(() => t.report.description ? `${t.report.title}: ${t.report.description}` : t.report.title), s = d(() => {
1367
+ if (!z.sourceUrl)
1368
+ return !1;
1369
+ const o = encodeURIComponent(e.value), a = encodeURIComponent(
1370
+ [
1371
+ "[Please, explain here what you were trying to do when this error appeared]",
1372
+ "",
1373
+ "Error details:",
1374
+ "```",
1375
+ jt(
1376
+ t.report.details ?? "Details missing from report",
1377
+ 1800 - o.length - z.sourceUrl.length
1378
+ ).trim(),
1379
+ "```"
1380
+ ].join(`
1381
+ `)
1382
+ );
1383
+ return `${z.sourceUrl}/issues/new?title=${o}&body=${a}`;
1384
+ }), n = d(() => K(
1385
+ [
1386
+ {
1387
+ id: "clipboard",
1388
+ description: "Copy to clipboard",
1389
+ iconComponent: hs,
1390
+ async handler() {
1391
+ await navigator.clipboard.writeText(`${e.value}
1392
+
1393
+ ${t.report.details}`), G.showSnackbar(
1394
+ x("errors.copiedToClipboard", "Debug information copied to clipboard")
1395
+ );
1396
+ }
1397
+ },
1398
+ {
1399
+ id: "console",
1400
+ description: "Log to console",
1401
+ iconComponent: ps,
1402
+ handler() {
1403
+ const o = t.report.error ?? t.report;
1404
+ window.error = o, console.error(o), G.showSnackbar(
1405
+ x(
1406
+ "errors.addedToConsole",
1407
+ "You can now use the **error** variable in the console"
1408
+ )
1409
+ );
1410
+ }
1411
+ }
1412
+ ],
1413
+ (o) => {
1414
+ s.value && o.push({
1415
+ id: "github",
1416
+ description: "Report in GitHub",
1417
+ iconComponent: vs,
1418
+ url: s.value
1419
+ });
1420
+ }
1421
+ ));
1422
+ return (o, a) => (c(), w("div", bs, [
1423
+ (c(!0), w(Y, null, he(n.value, (i, u) => $(o.$slots, "default", H({ ref_for: !0 }, i, { key: u }), () => [
1424
+ m(L, {
1425
+ color: "clear",
1426
+ url: i.url,
1427
+ title: o.$td(`errors.report_${i.id}`, i.description),
1428
+ "aria-label": o.$td(`errors.report_${i.id}`, i.description),
1429
+ onClick: i.handler
1430
+ }, {
1431
+ default: f(() => [
1432
+ (c(), _(W(i.iconComponent), {
1433
+ class: "size-4",
1434
+ "aria-hidden": "true"
1435
+ }))
1436
+ ]),
1437
+ _: 2
1438
+ }, 1032, ["url", "title", "aria-label", "onClick"])
1439
+ ])), 128))
1440
+ ]));
1441
+ }
1442
+ }), ws = /* @__PURE__ */ h({
1443
+ __name: "AGErrorReportModalTitle",
1444
+ props: {
1445
+ report: we(),
1446
+ currentReport: te(),
1447
+ totalReports: te()
1448
+ },
1449
+ setup(r) {
1450
+ const t = r, e = d(() => !t.totalReports || t.totalReports <= 1 ? t.report.title : `${t.report.title} (${t.currentReport}/${t.totalReports})`);
1451
+ return (s, n) => (c(), _(T, {
1452
+ text: e.value,
1453
+ inline: ""
1454
+ }, null, 8, ["text"]));
1455
+ }
1456
+ }), $s = { class: "flex items-center justify-between text-lg font-medium" }, xs = { class: "flex items-center" }, Ss = ["textContent"], ks = /* @__PURE__ */ h({
1457
+ __name: "AGErrorReportModal",
1458
+ props: ls(),
1459
+ setup(r) {
1460
+ const t = r, { activeReportIndex: e, details: s, nextReportText: n, previousReportText: o, report: a } = cs(t);
1461
+ return (i, u) => (c(), _(oe, null, {
1462
+ default: f(() => [
1463
+ y("div", null, [
1464
+ y("h2", $s, [
1465
+ y("div", xs, [
1466
+ m(ws, {
1467
+ report: l(a),
1468
+ "current-report": l(e) + 1,
1469
+ "total-reports": i.reports.length
1470
+ }, null, 8, ["report", "current-report", "total-reports"]),
1471
+ i.reports.length > 1 ? (c(), w(Y, { key: 0 }, [
1472
+ m(L, {
1473
+ color: "clear",
1474
+ disabled: l(e) === 0,
1475
+ title: l(o),
1476
+ "aria-label": l(o),
1477
+ onClick: u[0] || (u[0] = (p) => e.value--)
1478
+ }, {
1479
+ default: f(() => [
1480
+ m(l(as), {
1481
+ "aria-hidden": "true",
1482
+ class: "size-4"
1483
+ })
1484
+ ]),
1485
+ _: 1
1486
+ }, 8, ["disabled", "title", "aria-label"]),
1487
+ m(L, {
1488
+ color: "clear",
1489
+ disabled: l(e) === i.reports.length - 1,
1490
+ title: l(n),
1491
+ "aria-label": l(n),
1492
+ onClick: u[1] || (u[1] = (p) => e.value++)
1493
+ }, {
1494
+ default: f(() => [
1495
+ m(l(ss), {
1496
+ "aria-hidden": "true",
1497
+ class: "size-4"
1498
+ })
1499
+ ]),
1500
+ _: 1
1501
+ }, 8, ["disabled", "title", "aria-label"])
1502
+ ], 64)) : I("", !0)
1503
+ ]),
1504
+ m(ys, { report: l(a) }, null, 8, ["report"])
1505
+ ]),
1506
+ l(a).description ? (c(), _(T, {
1507
+ key: 0,
1508
+ text: l(a).description,
1509
+ class: "mt-2"
1510
+ }, null, 8, ["text"])) : I("", !0)
1511
+ ]),
1512
+ y("pre", {
1513
+ class: "h-full overflow-auto bg-gray-200 p-4 text-xs text-red-900",
1514
+ textContent: M(l(s))
1515
+ }, null, 8, Ss)
1516
+ ]),
1517
+ _: 1
1518
+ }));
1519
+ }
1520
+ }), As = {
1521
+ title: g(),
1522
+ message: g(),
1523
+ progress: te()
1524
+ };
1525
+ function Cs() {
1526
+ return As;
1527
+ }
1528
+ function Ps(r) {
1529
+ const t = d(() => r.message ?? x("ui.loading", "Loading...")), e = d(() => typeof r.progress == "number");
1530
+ return { renderedMessage: t, showProgress: e };
1531
+ }
1532
+ const Ms = /* @__PURE__ */ h({
1533
+ __name: "AGLoadingModal",
1534
+ props: Cs(),
1535
+ setup(r) {
1536
+ const t = r, { renderedMessage: e } = Ps(t);
1537
+ return (s, n) => (c(), _(oe, { cancellable: !1 }, {
1538
+ default: f(() => [
1539
+ m(T, { text: l(e) }, null, 8, ["text"])
1540
+ ]),
1541
+ _: 1
1542
+ }));
1543
+ }
1544
+ }), Es = {
1545
+ title: g(),
1546
+ message: re(),
1547
+ label: g(),
1548
+ defaultValue: g(),
1549
+ placeholder: g(),
1550
+ acceptText: g(),
1551
+ acceptColor: X(k, k.Primary),
1552
+ cancelText: g(),
1553
+ cancelColor: X(k, k.Clear)
1554
+ };
1555
+ function Gs() {
1556
+ return Es;
1557
+ }
1558
+ function Is(r) {
1559
+ const t = d(() => r.acceptText ?? x("ui.accept", "Ok")), e = d(() => r.cancelText ?? x("ui.cancel", "Cancel"));
1560
+ return { renderedAcceptText: t, renderedCancelText: e };
1561
+ }
1562
+ const Ts = /* @__PURE__ */ h({
1563
+ __name: "AGForm",
1564
+ props: { form: B() },
1565
+ emits: ["submit"],
1566
+ setup(r, { emit: t }) {
1567
+ let e;
1568
+ const s = r, n = t;
1569
+ return ce((o) => {
1570
+ var a;
1571
+ e == null || e(), e = (a = s.form) == null ? void 0 : a.on("submit", () => n("submit")), o(() => e == null ? void 0 : e());
1572
+ }), me("form", s.form), (o, a) => (c(), w("form", {
1573
+ onSubmit: a[0] || (a[0] = xt((i) => {
1574
+ var u;
1575
+ return (u = r.form) == null ? void 0 : u.submit();
1576
+ }, ["prevent"]))
1577
+ }, [
1578
+ $(o.$slots, "default")
1579
+ ], 32));
1580
+ }
1581
+ }), nt = {
1582
+ name: g(),
1583
+ label: g(),
1584
+ description: g(),
1585
+ modelValue: ye([String, Number, Boolean])
1586
+ }, Hs = ["update:modelValue"];
1587
+ function ot() {
1588
+ return [...Hs];
1589
+ }
1590
+ function at() {
1591
+ return nt;
1592
+ }
1593
+ function oo(r) {
1594
+ return He(r, nt);
1595
+ }
1596
+ const it = /* @__PURE__ */ h({
1597
+ __name: "AGHeadlessInput",
1598
+ props: {
1599
+ as: g("div"),
1600
+ ...at()
1601
+ },
1602
+ emits: ["update:modelValue"],
1603
+ setup(r, { expose: t, emit: e }) {
1604
+ const s = e, n = r, o = P(), a = d(() => !i || !n.name ? null : i.errors[n.name] ?? null), i = ne("form", null), u = {
1605
+ $el: o,
1606
+ id: `input-${ue()}`,
1607
+ name: d(() => n.name),
1608
+ label: d(() => n.label),
1609
+ description: d(() => n.description),
1610
+ value: d(() => i && n.name ? i.getFieldValue(n.name) : n.modelValue),
1611
+ errors: Fe(a),
1612
+ required: d(() => !n.name || !i ? null : i.getFieldRules(n.name).includes("required")),
1613
+ update(p) {
1614
+ if (i && n.name) {
1615
+ i.setFieldValue(n.name, p);
1616
+ return;
1617
+ }
1618
+ s("update:modelValue", p);
1619
+ },
1620
+ __setElement(p) {
1621
+ o.value = p;
1622
+ }
1623
+ };
1624
+ return me("input", u), t(u), (p, v) => r.as ? (c(), _(W(r.as), { key: 0 }, {
1625
+ default: f(() => [
1626
+ $(p.$slots, "default")
1627
+ ]),
1628
+ _: 3
1629
+ })) : $(p.$slots, "default", { key: 1 });
1630
+ }
1631
+ }), Ls = /* @__PURE__ */ h({
1632
+ inheritAttrs: !1,
1633
+ __name: "AGHeadlessInputDescription",
1634
+ setup(r) {
1635
+ const t = R(
1636
+ "input",
1637
+ "<AGHeadlessInputDescription> must be a child of a <AGHeadlessInput>"
1638
+ ), e = d(() => typeof t.description == "string" ? t.description : ""), s = d(() => !!t.description);
1639
+ return (n, o) => $(n.$slots, "default", {
1640
+ id: `${l(t).id}-description`
1641
+ }, () => [
1642
+ s.value ? (c(), _(T, H({ key: 0 }, n.$attrs, {
1643
+ id: `${l(t).id}-description`,
1644
+ text: e.value
1645
+ }), null, 16, ["id", "text"])) : I("", !0)
1646
+ ]);
1647
+ }
1648
+ }), Rs = ["id"], lt = /* @__PURE__ */ h({
1649
+ __name: "AGHeadlessInputError",
1650
+ setup(r) {
1651
+ const t = R(
1652
+ "input",
1653
+ "<AGHeadlessInputError> must be a child of a <AGHeadlessInput>"
1654
+ ), e = d(() => t.errors ? x(`errors.${t.errors[0]}`, `Error: ${t.errors[0]}`) : null);
1655
+ return (s, n) => e.value ? (c(), w("p", {
1656
+ key: 0,
1657
+ id: `${l(t).id}-error`
1658
+ }, M(e.value), 9, Rs)) : I("", !0);
1659
+ }
1660
+ });
1661
+ function ct(r, t) {
1662
+ const e = ne("form", null), s = e == null ? void 0 : e.on("focus", (n) => r.name === n && t());
1663
+ fe(() => s == null ? void 0 : s());
1664
+ }
1665
+ const js = ["id", "name", "type", "required", "aria-invalid", "aria-describedby", "checked"], ut = /* @__PURE__ */ h({
1666
+ __name: "AGHeadlessInputInput",
1667
+ props: {
1668
+ type: g("text")
1669
+ },
1670
+ setup(r) {
1671
+ const t = r, e = P(), s = R(
1672
+ "input",
1673
+ "<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>"
1674
+ ), n = d(() => s.name ?? void 0), o = d(() => s.value), a = d(() => {
1675
+ if (t.type === "checkbox")
1676
+ return !!o.value;
1677
+ });
1678
+ function i() {
1679
+ e.value && s.update(u());
1680
+ }
1681
+ function u() {
1682
+ if (!e.value)
1683
+ return null;
1684
+ switch (t.type) {
1685
+ case "checkbox":
1686
+ return e.value.checked;
1687
+ case "date":
1688
+ return e.value.valueAsDate;
1689
+ default:
1690
+ return e.value.value;
1691
+ }
1692
+ }
1693
+ return ct(s, () => {
1694
+ var p;
1695
+ return (p = e.value) == null ? void 0 : p.focus();
1696
+ }), ce(() => s.__setElement(e.value)), ce(() => {
1697
+ if (e.value) {
1698
+ if (t.type === "date") {
1699
+ e.value.valueAsDate = o.value;
1700
+ return;
1701
+ }
1702
+ e.value.value = o.value;
1703
+ }
1704
+ }), (p, v) => (c(), w("input", {
1705
+ id: l(s).id,
1706
+ ref_key: "$input",
1707
+ ref: e,
1708
+ name: n.value,
1709
+ type: r.type,
1710
+ required: l(s).required ?? void 0,
1711
+ "aria-invalid": l(s).errors ? "true" : "false",
1712
+ "aria-describedby": l(s).errors ? `${l(s).id}-error` : l(s).description ? `${l(s).id}-description` : void 0,
1713
+ checked: a.value,
1714
+ onInput: i
1715
+ }, null, 40, js));
1716
+ }
1717
+ }), qs = ["for"], dt = /* @__PURE__ */ h({
1718
+ __name: "AGHeadlessInputLabel",
1719
+ setup(r) {
1720
+ const t = R(
1721
+ "input",
1722
+ "<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>"
1723
+ ), e = St(), s = d(() => !!(t.label || e.default));
1724
+ return (n, o) => s.value ? (c(), w("label", {
1725
+ key: 0,
1726
+ for: l(t).id
1727
+ }, [
1728
+ $(n.$slots, "default", {}, () => [
1729
+ j(M(l(t).label), 1)
1730
+ ])
1731
+ ], 8, qs)) : I("", !0);
1732
+ }
1733
+ }), Ds = { class: "absolute bottom-0 left-0 translate-y-full" }, Vs = /* @__PURE__ */ h({
1734
+ inheritAttrs: !1,
1735
+ __name: "AGInput",
1736
+ props: at(),
1737
+ emits: ot(),
1738
+ setup(r) {
1739
+ const t = r, e = Te(), [s, n] = Nr();
1740
+ return (o, a) => (c(), _(it, H({
1741
+ ref_key: "$input",
1742
+ ref: e,
1743
+ class: ["relative flex flex-col items-center", l(n)]
1744
+ }, t, {
1745
+ "onUpdate:modelValue": a[0] || (a[0] = (i) => o.$emit("update:modelValue", i))
1746
+ }), {
1747
+ default: f(() => {
1748
+ var i;
1749
+ return [
1750
+ m(dt, { class: "sr-only" }),
1751
+ m(ut, H(l(s), {
1752
+ class: ["block w-full border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600", {
1753
+ "ring-1 ring-red-500": (i = l(e)) == null ? void 0 : i.errors
1754
+ }]
1755
+ }), null, 16, ["class"]),
1756
+ m(Ls),
1757
+ y("div", Ds, [
1758
+ m(lt, { class: "mt-1 text-sm text-red-500" })
1759
+ ])
1760
+ ];
1761
+ }),
1762
+ _: 1
1763
+ }, 16, ["class"]));
1764
+ }
1765
+ }), zs = {
1766
+ required: (r) => r ? void 0 : "required"
1767
+ }, ie = { ...zs };
1768
+ function ao(r, t) {
1769
+ ie[r] = t;
1770
+ }
1771
+ function Bs(r, t) {
1772
+ var s;
1773
+ const e = (s = ie[t]) == null ? void 0 : s.call(ie, r);
1774
+ return e ? Ne(e) : [];
1775
+ }
1776
+ const D = {
1777
+ String: "string",
1778
+ Number: "number",
1779
+ Boolean: "boolean",
1780
+ Object: "object",
1781
+ Date: "date"
1782
+ }, Ve = /* @__PURE__ */ new WeakMap();
1783
+ class Fs extends Ue {
1784
+ constructor(e) {
1785
+ super();
1786
+ b(this, "errors");
1787
+ b(this, "_fields");
1788
+ b(this, "_data");
1789
+ b(this, "_submitted");
1790
+ b(this, "_errors");
1791
+ b(this, "_listeners", {});
1792
+ this._fields = e, this._submitted = P(!1), this._data = this.getInitialData(e), this._errors = this.getInitialErrors(e), Ve.set(
1793
+ this,
1794
+ d(() => !Object.values(this._errors).some((s) => s !== null))
1795
+ ), this.errors = Fe(this._errors);
1796
+ }
1797
+ get valid() {
1798
+ var e;
1799
+ return !!((e = Ve.get(this)) != null && e.value);
1800
+ }
1801
+ get submitted() {
1802
+ return this._submitted.value;
1803
+ }
1804
+ setFieldValue(e, s) {
1805
+ const n = this._fields[e] ?? N(`Trying to set undefined '${q(e)}' field`);
1806
+ this._data[e] = n.type === D.String && (n.trim ?? !0) ? q(s).trim() : s, this._submitted.value && this.validate();
1807
+ }
1808
+ getFieldValue(e) {
1809
+ return this._data[e];
1810
+ }
1811
+ getFieldRules(e) {
1812
+ var s, n;
1813
+ return ((n = (s = this._fields[e]) == null ? void 0 : s.rules) == null ? void 0 : n.split("|")) ?? [];
1814
+ }
1815
+ data() {
1816
+ return { ...this._data };
1817
+ }
1818
+ validate() {
1819
+ const e = Object.entries(this._fields).reduce(
1820
+ (s, [n, o]) => (s[n] = this.getFieldErrors(n, o), s),
1821
+ {}
1822
+ );
1823
+ return this.resetErrors(e), this.valid;
1824
+ }
1825
+ reset(e = {}) {
1826
+ this._submitted.value = !1, e.keepData || this.resetData(), e.keepErrors || this.resetErrors();
1827
+ }
1828
+ submit() {
1829
+ var s;
1830
+ this._submitted.value = !0;
1831
+ const e = this.validate();
1832
+ return e && ((s = this._listeners.submit) == null || s.forEach((n) => n())), e;
1833
+ }
1834
+ on(e, s) {
1835
+ var n, o;
1836
+ return (n = this._listeners)[e] ?? (n[e] = []), (o = this._listeners[e]) == null || o.push(s), () => this.off(e, s);
1837
+ }
1838
+ off(e, s) {
1839
+ Pe(this._listeners[e] ?? [], s);
1840
+ }
1841
+ async focus(e) {
1842
+ var s;
1843
+ await ze(), (s = this._listeners.focus) == null || s.forEach((n) => n(e));
1844
+ }
1845
+ __get(e) {
1846
+ return e in this._fields ? this.getFieldValue(e) : super.__get(e);
1847
+ }
1848
+ __set(e, s) {
1849
+ if (!(e in this._fields)) {
1850
+ super.__set(e, s);
1851
+ return;
1852
+ }
1853
+ this.setFieldValue(e, s);
1854
+ }
1855
+ getFieldErrors(e, s) {
1856
+ var i;
1857
+ const n = [], o = this._data[e], a = ((i = s.rules) == null ? void 0 : i.split("|")) ?? [];
1858
+ for (const u of a)
1859
+ u !== "required" && o == null || n.push(...Bs(o, u));
1860
+ return n.length > 0 ? n : null;
1861
+ }
1862
+ getInitialData(e) {
1863
+ if (this.static().isConjuring())
1864
+ return {};
1865
+ const s = Object.entries(e).reduce((n, [o, a]) => (n[o] = a.default ?? null, n), {});
1866
+ return le(s);
1867
+ }
1868
+ getInitialErrors(e) {
1869
+ if (this.static().isConjuring())
1870
+ return {};
1871
+ const s = Object.keys(e).reduce((n, o) => (n[o] = null, n), {});
1872
+ return le(s);
1873
+ }
1874
+ resetData() {
1875
+ for (const [e, s] of Object.entries(this._fields))
1876
+ this._data[e] = s.default ?? null;
1877
+ }
1878
+ resetErrors(e) {
1879
+ Object.keys(this._errors).forEach((s) => delete this._errors[s]), e && Object.assign(this._errors, e);
1880
+ }
1881
+ }
1882
+ function Us(r) {
1883
+ return new Fs(r);
1884
+ }
1885
+ function io(r, t = {}) {
1886
+ return {
1887
+ default: r,
1888
+ type: D.Boolean,
1889
+ rules: t.rules
1890
+ };
1891
+ }
1892
+ function lo(r, t = {}) {
1893
+ return {
1894
+ default: r,
1895
+ type: D.Date,
1896
+ rules: t.rules
1897
+ };
1898
+ }
1899
+ function co(r) {
1900
+ return {
1901
+ default: r,
1902
+ type: D.Boolean,
1903
+ rules: "required"
1904
+ };
1905
+ }
1906
+ function uo(r) {
1907
+ return {
1908
+ default: r,
1909
+ type: D.Date,
1910
+ rules: "required"
1911
+ };
1912
+ }
1913
+ function po(r) {
1914
+ return {
1915
+ default: r,
1916
+ type: D.Number,
1917
+ rules: "required"
1918
+ };
1919
+ }
1920
+ function Ns(r) {
1921
+ return {
1922
+ default: r,
1923
+ type: D.String,
1924
+ rules: "required"
1925
+ };
1926
+ }
1927
+ function fo(r, t = {}) {
1928
+ return {
1929
+ default: r,
1930
+ type: D.Number,
1931
+ rules: t.rules
1932
+ };
1933
+ }
1934
+ function mo(r, t = {}) {
1935
+ return {
1936
+ default: r,
1937
+ type: D.String,
1938
+ rules: t.rules
1939
+ };
1940
+ }
1941
+ const Ws = { class: "mt-2 flex flex-row-reverse gap-2" }, Ks = /* @__PURE__ */ h({
1942
+ __name: "AGPromptModal",
1943
+ props: Gs(),
1944
+ setup(r) {
1945
+ const t = r, e = Us({ draft: Ns(t.defaultValue ?? "") }), { renderedAcceptText: s, renderedCancelText: n } = Is(t);
1946
+ return (o, a) => (c(), _(oe, {
1947
+ cancellable: !1,
1948
+ title: o.title
1949
+ }, {
1950
+ default: f(({ close: i }) => [
1951
+ m(T, { text: o.message }, null, 8, ["text"]),
1952
+ m(Ts, {
1953
+ form: l(e),
1954
+ onSubmit: (u) => i(l(e).draft)
1955
+ }, {
1956
+ default: f(() => [
1957
+ m(Vs, {
1958
+ name: "draft",
1959
+ placeholder: o.placeholder,
1960
+ label: o.label
1961
+ }, null, 8, ["placeholder", "label"]),
1962
+ y("div", Ws, [
1963
+ m(L, {
1964
+ color: o.acceptColor,
1965
+ submit: ""
1966
+ }, {
1967
+ default: f(() => [
1968
+ j(M(l(s)), 1)
1969
+ ]),
1970
+ _: 1
1971
+ }, 8, ["color"]),
1972
+ m(L, {
1973
+ color: o.cancelColor,
1974
+ onClick: (u) => i()
1975
+ }, {
1976
+ default: f(() => [
1977
+ j(M(l(n)), 1)
1978
+ ]),
1979
+ _: 2
1980
+ }, 1032, ["color", "onClick"])
1981
+ ])
1982
+ ]),
1983
+ _: 2
1984
+ }, 1032, ["form", "onSubmit"])
1985
+ ]),
1986
+ _: 1
1987
+ }, 8, ["title"]));
1988
+ }
1989
+ }), Js = { class: "pointer-events-auto" }, Os = /* @__PURE__ */ h({
1990
+ __name: "AGHeadlessSnackbar",
1991
+ setup(r) {
1992
+ return (t, e) => (c(), w("div", Js, [
1993
+ $(t.$slots, "default")
1994
+ ]));
1995
+ }
1996
+ }), Qs = Ke(k, ["Primary", "Clear"]), Xs = {
1997
+ id: re(),
1998
+ message: re(),
1999
+ actions: ur(() => []),
2000
+ color: X(Qs, k.Secondary)
2001
+ };
2002
+ function Ys() {
2003
+ return Xs;
2004
+ }
2005
+ function Zs(r) {
2006
+ function t(e) {
2007
+ var s;
2008
+ (s = e.handler) == null || s.call(e), e.dismiss && G.hideSnackbar(r.id);
2009
+ }
2010
+ return { activate: t };
2011
+ }
2012
+ const en = /* @__PURE__ */ h({
2013
+ __name: "AGSnackbar",
2014
+ props: Ys(),
2015
+ setup(r) {
2016
+ const t = r, { activate: e } = Zs(t), s = d(() => {
2017
+ switch (t.color) {
2018
+ case k.Danger:
2019
+ return "bg-red-200 text-red-900";
2020
+ default:
2021
+ case k.Secondary:
2022
+ return "bg-gray-900 text-white";
2023
+ }
2024
+ });
2025
+ return (n, o) => (c(), _(Os, {
2026
+ class: F(["flex flex-row items-center justify-center gap-3 p-4", s.value])
2027
+ }, {
2028
+ default: f(() => [
2029
+ m(T, {
2030
+ text: n.message,
2031
+ inline: ""
2032
+ }, null, 8, ["text"]),
2033
+ (c(!0), w(Y, null, he(n.actions, (a, i) => (c(), _(L, {
2034
+ key: i,
2035
+ color: n.color,
2036
+ onClick: (u) => l(e)(a)
2037
+ }, {
2038
+ default: f(() => [
2039
+ j(M(a.text), 1)
2040
+ ]),
2041
+ _: 2
2042
+ }, 1032, ["color", "onClick"]))), 128))
2043
+ ]),
2044
+ _: 1
2045
+ }, 8, ["class"]));
2046
+ }
2047
+ }), tn = { class: "grid grow place-items-center" }, rn = { class: "flex flex-col items-center space-y-6 p-8" }, sn = { class: "mt-2 text-center text-4xl font-medium text-red-600" }, nn = { class: "mt-4 flex flex-col space-y-4" }, on = /* @__PURE__ */ h({
2048
+ __name: "AGStartupCrash",
2049
+ setup(r) {
2050
+ return (t, e) => (c(), w("div", tn, [
2051
+ y("div", rn, [
2052
+ y("h1", sn, M(t.$td("startupCrash.title", "Something went wrong!")), 1),
2053
+ m(T, {
2054
+ text: t.$td(
2055
+ "startupCrash.message",
2056
+ `Something failed trying to start the application.
2057
+
2058
+ Here's some things you can do:`
2059
+ ),
2060
+ class: "mt-4 text-center"
2061
+ }, null, 8, ["text"]),
2062
+ y("div", nn, [
2063
+ m(L, {
2064
+ color: "danger",
2065
+ onClick: e[0] || (e[0] = (s) => t.$app.reload())
2066
+ }, {
2067
+ default: f(() => [
2068
+ j(M(t.$td("startupCrash.reload", "Try again")), 1)
2069
+ ]),
2070
+ _: 1
2071
+ }),
2072
+ m(L, {
2073
+ color: "danger",
2074
+ onClick: e[1] || (e[1] = (s) => t.$errors.inspect(t.$errors.startupErrors))
2075
+ }, {
2076
+ default: f(() => [
2077
+ j(M(t.$td("startupCrash.inspect", "View error details")), 1)
2078
+ ]),
2079
+ _: 1
2080
+ })
2081
+ ])
2082
+ ])
2083
+ ]));
2084
+ }
2085
+ }), an = { $ui: G }, ln = {
2086
+ async install(r, t) {
2087
+ const e = {
2088
+ [C.AlertModal]: Jr,
2089
+ [C.ConfirmModal]: es,
2090
+ [C.ErrorReportModal]: ks,
2091
+ [C.LoadingModal]: Ms,
2092
+ [C.PromptModal]: Ks,
2093
+ [C.Snackbar]: en,
2094
+ [C.StartupCrash]: on
2095
+ };
2096
+ Object.entries({
2097
+ ...e,
2098
+ ...t.components
2099
+ }).forEach(([s, n]) => G.registerComponent(s, n)), await $e(r, an);
2100
+ }
2101
+ };
2102
+ async function cn(r, t = {}) {
2103
+ var s;
2104
+ const e = [Lr, hr, Ir, Hr, yr, ln, ...t.plugins ?? []];
2105
+ z.instance = r, await cr(e, r, t), await ((s = t.install) == null ? void 0 : s.call(t, r)), await S.emit("application-ready");
2106
+ }
2107
+ async function ho(r, t = {}) {
2108
+ var s;
2109
+ const e = kt(r);
2110
+ Q() && (window.$aerogel = e), await cn(e, t), e.mount("#app"), (s = e._container) == null || s.classList.remove("loading"), await S.emit("application-mounted");
2111
+ }
2112
+ const un = { key: 0 }, dn = /* @__PURE__ */ h({
2113
+ __name: "AGAppModals",
2114
+ setup(r) {
2115
+ const t = d(() => G.modals[0] ?? null);
2116
+ return (e, s) => t.value ? (c(), w("aside", un, [
2117
+ m(rt, {
2118
+ "child-index": 1,
2119
+ modal: t.value
2120
+ }, null, 8, ["modal"])
2121
+ ])) : I("", !0);
2122
+ }
2123
+ }), pn = (r, t) => {
2124
+ const e = r.__vccOpts || r;
2125
+ for (const [s, n] of t)
2126
+ e[s] = n;
2127
+ return e;
2128
+ }, fn = {}, mn = {
2129
+ "aria-live": "assertive",
2130
+ class: "pointer-events-none fixed inset-0 z-50 flex items-end px-4 py-6 sm:p-6"
2131
+ }, hn = { class: "flex w-full flex-col items-end space-y-4" };
2132
+ function gn(r, t) {
2133
+ return c(), w("div", mn, [
2134
+ y("div", hn, [
2135
+ (c(!0), w(Y, null, he(r.$ui.snackbars, (e) => (c(), _(W(e.component), H({
2136
+ id: e.id,
2137
+ key: e.id,
2138
+ ref_for: !0
2139
+ }, e.properties), null, 16, ["id"]))), 128))
2140
+ ])
2141
+ ]);
2142
+ }
2143
+ const _n = /* @__PURE__ */ pn(fn, [["render", gn]]), vn = /* @__PURE__ */ h({
2144
+ __name: "AGAppOverlays",
2145
+ setup(r) {
2146
+ const t = P(null), e = P(!0);
2147
+ return ee("show-overlays-backdrop", async () => {
2148
+ !t.value || !e.value || (e.value = !1, t.value.classList.remove("opacity-0"));
2149
+ }), ee("hide-overlays-backdrop", async () => {
2150
+ !t.value || e.value || (e.value = !0, t.value.classList.add("opacity-0"));
2151
+ }), (s, n) => (c(), w(Y, null, [
2152
+ y("div", {
2153
+ id: "aerogel-overlays-backdrop",
2154
+ ref_key: "$backdrop",
2155
+ ref: t,
2156
+ class: "pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0"
2157
+ }, null, 512),
2158
+ m(dn),
2159
+ m(_n)
2160
+ ], 64));
2161
+ }
2162
+ }), bn = { class: "flex min-h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased" }, go = /* @__PURE__ */ h({
2163
+ __name: "AGAppLayout",
2164
+ setup(r) {
2165
+ return (t, e) => (c(), w("div", bn, [
2166
+ t.$errors.hasStartupErrors ? $(t.$slots, "startup-crash", { key: 0 }, () => [
2167
+ (c(), _(W(t.$ui.requireComponent(l(C).StartupCrash))))
2168
+ ]) : $(t.$slots, "default", { key: 1 }),
2169
+ m(vn)
2170
+ ]));
2171
+ }
2172
+ }), yn = { class: "ml-2" }, _o = /* @__PURE__ */ h({
2173
+ inheritAttrs: !1,
2174
+ __name: "AGCheckbox",
2175
+ props: { name: g() },
2176
+ emits: ot(),
2177
+ setup(r) {
2178
+ const t = Te();
2179
+ return (e, s) => (c(), _(it, {
2180
+ ref_key: "$input",
2181
+ ref: t,
2182
+ name: r.name,
2183
+ class: "flex",
2184
+ "onUpdate:modelValue": s[0] || (s[0] = (n) => e.$emit("update:modelValue", n))
2185
+ }, {
2186
+ default: f(() => {
2187
+ var n, o;
2188
+ return [
2189
+ m(ut, H(e.$attrs, {
2190
+ type: "checkbox",
2191
+ class: {
2192
+ "text-indigo-600 focus:ring-indigo-600": !((n = l(t)) != null && n.errors),
2193
+ "border-red-200 text-red-600 focus:ring-red-600": (o = l(t)) == null ? void 0 : o.errors
2194
+ }
2195
+ }), null, 16, ["class"]),
2196
+ y("div", yn, [
2197
+ e.$slots.default ? (c(), _(dt, { key: 0 }, {
2198
+ default: f(() => [
2199
+ $(e.$slots, "default")
2200
+ ]),
2201
+ _: 3
2202
+ })) : I("", !0),
2203
+ m(lt, { class: "text-sm text-red-600" })
2204
+ ])
2205
+ ];
2206
+ }),
2207
+ _: 3
2208
+ }, 8, ["name"]));
2209
+ }
2210
+ }), wn = {
2211
+ viewBox: "0 0 20 20",
2212
+ width: "1.2em",
2213
+ height: "1.2em"
2214
+ };
2215
+ function $n(r, t) {
2216
+ return c(), w("svg", wn, t[0] || (t[0] = [
2217
+ y("path", {
2218
+ fill: "currentColor",
2219
+ d: "m9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828L5.757 6.586L4.343 8z"
2220
+ }, null, -1)
2221
+ ]));
2222
+ }
2223
+ const xn = { name: "zondicons-cheveron-down", render: $n }, pt = {
2224
+ name: g(),
2225
+ label: g(),
2226
+ options: Qe(),
2227
+ noSelectionText: g(),
2228
+ optionsText: ye()
2229
+ }, Sn = ["update:modelValue"];
2230
+ function ft() {
2231
+ return pt;
2232
+ }
2233
+ function mt() {
2234
+ return [...Sn];
2235
+ }
2236
+ function vo(r) {
2237
+ return He(r, pt);
2238
+ }
2239
+ const kn = /* @__PURE__ */ h({
2240
+ __name: "AGHeadlessSelect",
2241
+ props: {
2242
+ modelValue: ye(),
2243
+ ...ft()
2244
+ },
2245
+ emits: mt(),
2246
+ setup(r, { expose: t, emit: e }) {
2247
+ const s = e, n = r, o = d(() => typeof n.optionsText == "function" ? n.optionsText : typeof n.optionsText == "string" ? (A) => q(A[n.optionsText]) : (A) => q(A)), a = ne("form", null), i = d(() => n.noSelectionText ?? x("select.noSelection", "-")), u = d(
2248
+ () => a && n.name ? a.getFieldValue(n.name) : n.modelValue
2249
+ ), p = d(() => !a || !n.name ? null : a.errors[n.name] ?? null);
2250
+ function v(A) {
2251
+ if (a && n.name) {
2252
+ a.setFieldValue(n.name, A);
2253
+ return;
2254
+ }
2255
+ s("update:modelValue", A);
2256
+ }
2257
+ const E = {
2258
+ id: `select-${ue()}`,
2259
+ noSelectionText: i,
2260
+ selectedOption: u,
2261
+ errors: p,
2262
+ options: d(() => n.options),
2263
+ label: d(() => n.label),
2264
+ buttonText: d(() => u.value === null ? i.value : o.value(u.value)),
2265
+ renderText: o,
2266
+ update: v
2267
+ };
2268
+ return me("select", E), t(E), (A, ae) => (c(), _(l(Kt), {
2269
+ "model-value": u.value,
2270
+ "onUpdate:modelValue": ae[0] || (ae[0] = (xe) => v(xe))
2271
+ }, {
2272
+ default: f(({ open: xe }) => [
2273
+ $(A.$slots, "default", {
2274
+ modelValue: r.modelValue,
2275
+ open: xe
2276
+ })
2277
+ ]),
2278
+ _: 3
2279
+ }, 8, ["model-value"]));
2280
+ }
2281
+ }), An = /* @__PURE__ */ h({
2282
+ __name: "AGHeadlessSelectTrigger",
2283
+ props: { textClass: g() },
2284
+ setup(r) {
2285
+ const t = R(
2286
+ "select",
2287
+ "<AGHeadlessSelectTrigger> must be a child of a <AGHeadlessSelect>"
2288
+ );
2289
+ return (e, s) => (c(), _(l(Jt), null, {
2290
+ default: f(() => [
2291
+ m(l(Ot), null, {
2292
+ default: f(() => [
2293
+ $(e.$slots, "default", {}, () => {
2294
+ var n;
2295
+ return [
2296
+ y("span", {
2297
+ class: F(r.textClass)
2298
+ }, M((n = l(t)) == null ? void 0 : n.buttonText), 3)
2299
+ ];
2300
+ }),
2301
+ $(e.$slots, "icon")
2302
+ ]),
2303
+ _: 3
2304
+ })
2305
+ ]),
2306
+ _: 3
2307
+ }));
2308
+ }
2309
+ }), Cn = ["id"], Pn = /* @__PURE__ */ h({
2310
+ __name: "AGHeadlessSelectError",
2311
+ setup(r) {
2312
+ const t = R(
2313
+ "select",
2314
+ "<AGHeadlessSelectError> must be a child of a <AGHeadlessSelect>"
2315
+ ), e = d(() => t.errors ? x(`errors.${t.errors[0]}`, `Error: ${t.errors[0]}`) : null);
2316
+ return (s, n) => e.value ? (c(), w("p", {
2317
+ key: 0,
2318
+ id: `${l(t).id}-error`
2319
+ }, M(e.value), 9, Cn)) : I("", !0);
2320
+ }
2321
+ }), Mn = /* @__PURE__ */ h({
2322
+ __name: "AGHeadlessSelectOption",
2323
+ props: {
2324
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2325
+ value: pr(),
2326
+ selectedClass: g(),
2327
+ unselectedClass: g(),
2328
+ activeClass: g(),
2329
+ inactiveClass: g()
2330
+ },
2331
+ setup(r) {
2332
+ const t = R(
2333
+ "select",
2334
+ "<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>"
2335
+ );
2336
+ return (e, s) => (c(), _(l(Qt), {
2337
+ value: r.value,
2338
+ as: "template"
2339
+ }, {
2340
+ default: f(() => [
2341
+ m(l(Xt), null, {
2342
+ default: f(() => [
2343
+ $(e.$slots, "default", {}, () => [
2344
+ j(M(l(t).renderText(r.value)), 1)
2345
+ ])
2346
+ ]),
2347
+ _: 3
2348
+ })
2349
+ ]),
2350
+ _: 3
2351
+ }, 8, ["value"]));
2352
+ }
2353
+ }), En = /* @__PURE__ */ h({
2354
+ __name: "AGHeadlessSelectOptions",
2355
+ props: { class: g("") },
2356
+ setup(r) {
2357
+ const t = r, e = d(() => t.class);
2358
+ return (s, n) => (c(), _(l(Yt), null, {
2359
+ default: f(() => [
2360
+ m(l(Zt), {
2361
+ class: F(e.value)
2362
+ }, {
2363
+ default: f(() => [
2364
+ m(l(er), null, {
2365
+ default: f(() => [
2366
+ $(s.$slots, "default")
2367
+ ]),
2368
+ _: 3
2369
+ })
2370
+ ]),
2371
+ _: 3
2372
+ }, 8, ["class"])
2373
+ ]),
2374
+ _: 3
2375
+ }));
2376
+ }
2377
+ }), Gn = { class: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2" }, bo = /* @__PURE__ */ h({
2378
+ __name: "AGSelect",
2379
+ props: ft(),
2380
+ emits: mt(),
2381
+ setup(r) {
2382
+ const t = r, e = Te();
2383
+ return (s, n) => (c(), _(kn, H(t, {
2384
+ ref_key: "$select",
2385
+ ref: e,
2386
+ as: "div",
2387
+ "onUpdate:modelValue": n[0] || (n[0] = (o) => s.$emit("update:modelValue", o))
2388
+ }), {
2389
+ default: f(() => {
2390
+ var o, a;
2391
+ return [
2392
+ y("div", {
2393
+ class: F(["relative", { "mt-2": (o = l(e)) == null ? void 0 : o.label }])
2394
+ }, [
2395
+ m(An, {
2396
+ class: F(["relative w-full cursor-default bg-white py-1.5 pr-10 pl-3 text-left text-gray-900 ring-1 ring-gray-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-hidden", {
2397
+ "ring-1 ring-red-500": (a = l(e)) == null ? void 0 : a.errors
2398
+ }]),
2399
+ "text-class": "block truncate"
2400
+ }, {
2401
+ icon: f(() => [
2402
+ y("span", Gn, [
2403
+ m(l(xn), { class: "size-5 text-gray-400" })
2404
+ ])
2405
+ ]),
2406
+ _: 1
2407
+ }, 8, ["class"]),
2408
+ m(En, { class: "absolute z-10 mt-1 max-h-60 w-full overflow-auto border border-gray-300 bg-white py-1 text-base ring-1 ring-black/5 focus:outline-hidden" }, {
2409
+ default: f(() => {
2410
+ var i;
2411
+ return [
2412
+ (c(!0), w(Y, null, he(((i = l(e)) == null ? void 0 : i.options) ?? [], (u, p) => (c(), _(Mn, {
2413
+ key: p,
2414
+ value: u,
2415
+ class: "relative block cursor-default truncate py-2 pr-9 pl-3 text-gray-900 select-none data-[highlighted]:bg-indigo-600 data-[highlighted]:text-white data-[state=checked]:font-semibold data-[state=unchecked]:font-normal"
2416
+ }, null, 8, ["value"]))), 128))
2417
+ ];
2418
+ }),
2419
+ _: 1
2420
+ })
2421
+ ], 2),
2422
+ m(Pn, { class: "mt-2 text-sm text-red-600" })
2423
+ ];
2424
+ }),
2425
+ _: 1
2426
+ }, 16));
2427
+ }
2428
+ }), In = ["id", "name", "required", "value", "aria-invalid", "aria-describedby"], yo = /* @__PURE__ */ h({
2429
+ __name: "AGHeadlessInputTextArea",
2430
+ setup(r) {
2431
+ const t = P(), e = R(
2432
+ "input",
2433
+ "<AGHeadlessInputTextArea> must be a child of a <AGHeadlessInput>"
2434
+ ), s = d(() => e.name ?? void 0), n = d(() => e.value);
2435
+ function o() {
2436
+ t.value && e.update(t.value.value);
2437
+ }
2438
+ return ce(() => e.__setElement(t.value)), ct(e, () => {
2439
+ var a;
2440
+ return (a = t.value) == null ? void 0 : a.focus();
2441
+ }), (a, i) => (c(), w("textarea", {
2442
+ id: l(e).id,
2443
+ ref_key: "$textArea",
2444
+ ref: t,
2445
+ name: s.value,
2446
+ required: l(e).required ?? void 0,
2447
+ value: n.value,
2448
+ "aria-invalid": l(e).errors ? "true" : "false",
2449
+ "aria-describedby": l(e).errors ? `${l(e).id}-error` : l(e).description ? `${l(e).id}-description` : void 0,
2450
+ onInput: o
2451
+ }, null, 40, In));
2452
+ }
2453
+ }), wo = /* @__PURE__ */ h({
2454
+ __name: "AGErrorMessage",
2455
+ props: { error: we() },
2456
+ setup(r) {
2457
+ const t = r, e = d(() => Pr(t.error));
2458
+ return (s, n) => (c(), _(T, {
2459
+ text: e.value,
2460
+ inline: ""
2461
+ }, null, 8, ["text"]));
2462
+ }
2463
+ }), $o = /* @__PURE__ */ h({
2464
+ __name: "AGLink",
2465
+ setup(r) {
2466
+ return (t, e) => (c(), _(st, { class: "font-medium hover:underline" }, {
2467
+ default: f(() => [
2468
+ $(t.$slots, "default")
2469
+ ]),
2470
+ _: 3
2471
+ }));
2472
+ }
2473
+ }), xo = /* @__PURE__ */ h({
2474
+ __name: "AGMeasured",
2475
+ props: { as: g("span") },
2476
+ setup(r) {
2477
+ const t = P(!1);
2478
+ return (e, s) => {
2479
+ const n = At("measure");
2480
+ return Ct((c(), _(W(r.as), {
2481
+ class: F({ "invisible! absolute! w-auto!": !t.value })
2482
+ }, {
2483
+ default: f(() => [
2484
+ $(e.$slots, "default")
2485
+ ]),
2486
+ _: 3
2487
+ }, 8, ["class"])), [
2488
+ [n, () => t.value = !0]
2489
+ ]);
2490
+ };
2491
+ }
2492
+ }), Tn = { class: "mt-1 h-2 w-full overflow-hidden rounded-full bg-gray-200" }, Hn = { class: "sr-only" }, So = /* @__PURE__ */ h({
2493
+ __name: "AGProgressBar",
2494
+ props: {
2495
+ progress: te(),
2496
+ barClass: g(""),
2497
+ job: B()
2498
+ },
2499
+ setup(r) {
2500
+ const t = r;
2501
+ let e;
2502
+ const s = P(0), n = d(() => {
2503
+ const a = t.barClass ?? "";
2504
+ return `size-full transition-transform duration-500 ease-linear ${a.includes("bg-") ? a : `${a} bg-gray-700`}`;
2505
+ }), o = d(() => typeof t.progress == "number" ? t.progress : s.value);
2506
+ return Ee(
2507
+ () => t.job,
2508
+ () => {
2509
+ var a, i;
2510
+ e == null || e(), s.value = ((a = t.job) == null ? void 0 : a.progress) ?? 0, e = (i = t.job) == null ? void 0 : i.listeners.add({ onUpdated: (u) => s.value = u });
2511
+ },
2512
+ { immediate: !0 }
2513
+ ), fe(() => e == null ? void 0 : e()), (a, i) => (c(), w("div", Tn, [
2514
+ y("div", {
2515
+ class: F(n.value),
2516
+ style: Pt(`transform:translateX(-${(1 - o.value) * 100}%)`)
2517
+ }, null, 6),
2518
+ y("span", Hn, M(a.$td("ui.progress", "{progress}% complete", {
2519
+ progress: o.value * 100
2520
+ })), 1)
2521
+ ]));
2522
+ }
2523
+ }), ko = /* @__PURE__ */ h({
2524
+ __name: "AGModalTitle",
2525
+ setup(r) {
2526
+ return (t, e) => (c(), _(l(Je), { class: "mb-2 font-semibold" }, {
2527
+ default: f(() => [
2528
+ $(t.$slots, "default")
2529
+ ]),
2530
+ _: 3
2531
+ }));
2532
+ }
2533
+ });
2534
+ class Ao {
2535
+ constructor() {
2536
+ b(this, "status");
2537
+ b(this, "_listeners");
2538
+ b(this, "_progress");
2539
+ b(this, "_cancelled");
2540
+ b(this, "_started");
2541
+ b(this, "_completed");
2542
+ this.status = this.getInitialStatus(), this._listeners = new qt(), this._started = new U(), this._completed = new U();
2543
+ }
2544
+ async start() {
2545
+ this.beforeStart(), this._started.resolve();
2546
+ try {
2547
+ await this.updateProgress(), await this.run(), await this.updateProgress(), this._completed.resolve();
2548
+ } catch (t) {
2549
+ if (t instanceof De)
2550
+ return;
2551
+ throw K(Dt(t), (e) => {
2552
+ this._completed.reject(e);
2553
+ });
2554
+ }
2555
+ }
2556
+ async cancel() {
2557
+ this._cancelled = new U(), await this._cancelled;
2558
+ }
2559
+ serialize() {
2560
+ return this.serializeStatus(this.status);
2561
+ }
2562
+ get listeners() {
2563
+ return this._listeners;
2564
+ }
2565
+ get progress() {
2566
+ return this._progress ?? 0;
2567
+ }
2568
+ get cancelled() {
2569
+ var t;
2570
+ return !!((t = this._cancelled) != null && t.isResolved());
2571
+ }
2572
+ get started() {
2573
+ return this._started;
2574
+ }
2575
+ get completed() {
2576
+ return this._completed;
2577
+ }
2578
+ getInitialStatus() {
2579
+ return { completed: !1 };
2580
+ }
2581
+ beforeStart() {
2582
+ if (this._started.isResolved()) {
2583
+ if (this._cancelled) {
2584
+ delete this._progress, delete this._cancelled;
2585
+ return;
2586
+ }
2587
+ throw new Error("Job already started!");
2588
+ }
2589
+ }
2590
+ assertNotCancelled() {
2591
+ if (this._cancelled)
2592
+ throw this._cancelled.resolve(), new De();
2593
+ }
2594
+ calculateCurrentProgress(t) {
2595
+ return t ?? (t = this.status), t.completed ? 1 : t.children ? Vt(
2596
+ t.children.reduce((e, s) => e + this.calculateCurrentProgress(s), 0) / t.children.length,
2597
+ 2
2598
+ ) : 0;
2599
+ }
2600
+ async updateProgress(t) {
2601
+ await (t == null ? void 0 : t(this.status));
2602
+ const e = this.calculateCurrentProgress();
2603
+ e !== this._progress && (this._progress = e, await this._listeners.emit("onUpdated", e));
2604
+ }
2605
+ serializeStatus(t) {
2606
+ return { ...t };
2607
+ }
2608
+ }
2609
+ async function Co(r) {
2610
+ await r.start();
2611
+ }
2612
+ export {
2613
+ Jr as AGAlertModal,
2614
+ go as AGAppLayout,
2615
+ vn as AGAppOverlays,
2616
+ L as AGButton,
2617
+ _o as AGCheckbox,
2618
+ es as AGConfirmModal,
2619
+ wo as AGErrorMessage,
2620
+ ys as AGErrorReportModalButtons,
2621
+ ws as AGErrorReportModalTitle,
2622
+ Ts as AGForm,
2623
+ st as AGHeadlessButton,
2624
+ it as AGHeadlessInput,
2625
+ Ls as AGHeadlessInputDescription,
2626
+ lt as AGHeadlessInputError,
2627
+ ut as AGHeadlessInputInput,
2628
+ dt as AGHeadlessInputLabel,
2629
+ yo as AGHeadlessInputTextArea,
2630
+ Dr as AGHeadlessModal,
2631
+ Vr as AGHeadlessModalContent,
2632
+ Eo as AGHeadlessModalTitle,
2633
+ kn as AGHeadlessSelect,
2634
+ Pn as AGHeadlessSelectError,
2635
+ Mn as AGHeadlessSelectOption,
2636
+ En as AGHeadlessSelectOptions,
2637
+ An as AGHeadlessSelectTrigger,
2638
+ Os as AGHeadlessSnackbar,
2639
+ Vs as AGInput,
2640
+ $o as AGLink,
2641
+ Ms as AGLoadingModal,
2642
+ T as AGMarkdown,
2643
+ xo as AGMeasured,
2644
+ oe as AGModal,
2645
+ rt as AGModalContext,
2646
+ ko as AGModalTitle,
2647
+ So as AGProgressBar,
2648
+ Ks as AGPromptModal,
2649
+ bo as AGSelect,
2650
+ en as AGSnackbar,
2651
+ on as AGStartupCrash,
2652
+ z as App,
2653
+ lr as AppService,
2654
+ Yn as Cache,
2655
+ gr as CacheService,
2656
+ k as Colors,
2657
+ et as Errors,
2658
+ Un as EventListenerPriorities,
2659
+ S as Events,
2660
+ ar as EventsService,
2661
+ Fs as Form,
2662
+ D as FormFieldTypes,
2663
+ Ao as Job,
2664
+ De as JobCancelledError,
2665
+ se as Lang,
2666
+ pe as Layouts,
2667
+ Xe as MOBILE_BREAKPOINT,
2668
+ ve as Service,
2669
+ Me as ServiceBootError,
2670
+ Qs as SnackbarColors,
2671
+ vr as Storage,
2672
+ G as UI,
2673
+ C as UIComponents,
2674
+ $r as UIService,
2675
+ Wr as alertModalProps,
2676
+ ur as arrayProp,
2677
+ io as booleanInput,
2678
+ be as booleanProp,
2679
+ $e as bootServices,
2680
+ ho as bootstrap,
2681
+ cn as bootstrapApplication,
2682
+ Te as componentRef,
2683
+ Wn as computedAsync,
2684
+ Or as confirmModalProps,
2685
+ lo as dateInput,
2686
+ Kn as defineDirective,
2687
+ ao as defineFormValidationRule,
2688
+ Nn as definePlugin,
2689
+ _e as defineServiceState,
2690
+ or as defineServiceStore,
2691
+ Co as dispatch,
2692
+ Yr as elementRef,
2693
+ X as enumProp,
2694
+ is as errorReportModalProps,
2695
+ oo as extractInputProps,
2696
+ to as extractModalProps,
2697
+ vo as extractSelectProps,
2698
+ Ye as getCurrentLayout,
2699
+ Pr as getErrorMessage,
2700
+ nr as getPiniaStore,
2701
+ Jn as injectOrFail,
2702
+ dr as injectReactive,
2703
+ R as injectReactiveOrFail,
2704
+ Hs as inputEmits,
2705
+ nt as inputProps,
2706
+ cr as installPlugins,
2707
+ On as listenerProp,
2708
+ As as loadingModalProps,
2709
+ ye as mixedProp,
2710
+ qr as modalExpose,
2711
+ Le as modalProps,
2712
+ fo as numberInput,
2713
+ te as numberProp,
2714
+ B as objectProp,
2715
+ ro as onCleanMounted,
2716
+ ct as onFormFocus,
2717
+ so as persistent,
2718
+ Es as promptModalProps,
2719
+ eo as registerErrorHandler,
2720
+ no as removeInteractiveClasses,
2721
+ Fr as renderMarkdown,
2722
+ Zn as replaceExisting,
2723
+ Qe as requiredArrayProp,
2724
+ co as requiredBooleanInput,
2725
+ uo as requiredDateInput,
2726
+ Qn as requiredEnumProp,
2727
+ pr as requiredMixedProp,
2728
+ po as requiredNumberInput,
2729
+ Xn as requiredNumberProp,
2730
+ we as requiredObjectProp,
2731
+ Ns as requiredStringInput,
2732
+ re as requiredStringProp,
2733
+ sr as resetPiniaStore,
2734
+ Ur as safeHtml,
2735
+ Sn as selectEmits,
2736
+ pt as selectProps,
2737
+ Xs as snackbarProps,
2738
+ mo as stringInput,
2739
+ g as stringProp,
2740
+ Ze as translate,
2741
+ x as translateWithDefault,
2742
+ Kr as useAlertModalProps,
2743
+ Xr as useConfirmModal,
2744
+ Qr as useConfirmModalProps,
2745
+ cs as useErrorReportModal,
2746
+ ls as useErrorReportModalProps,
2747
+ ee as useEvent,
2748
+ Us as useForm,
2749
+ Nr as useInputAttrs,
2750
+ ot as useInputEmits,
2751
+ at as useInputProps,
2752
+ Ps as useLoadingModal,
2753
+ Cs as useLoadingModalProps,
2754
+ Is as usePromptModal,
2755
+ Gs as usePromptModalProps,
2756
+ mt as useSelectEmits,
2757
+ ft as useSelectProps,
2758
+ Zs as useSnackbar,
2759
+ Ys as useSnackbarProps,
2760
+ Bs as validate,
2761
+ ie as validators
2762
+ };
2763
+ //# sourceMappingURL=aerogel-core.js.map