@threadlabs/looma 0.2.19 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/{chunk-A5MSXQ7Y.js → chunk-3NVMCHGR.js} +2225 -1255
  2. package/dist/chunk-XDNZIKNI.js +2721 -0
  3. package/dist/declarative-generated.cjs +93 -79
  4. package/dist/declarative-generated.d.cts +7 -1
  5. package/dist/declarative-generated.d.ts +7 -1
  6. package/dist/declarative-generated.js +91 -78
  7. package/dist/declarative.cjs +1499 -1702
  8. package/dist/declarative.d.cts +77 -3
  9. package/dist/declarative.d.ts +77 -3
  10. package/dist/declarative.js +5 -3
  11. package/dist/index.cjs +3732 -3025
  12. package/dist/index.d.cts +211 -35
  13. package/dist/index.d.ts +211 -35
  14. package/dist/index.js +6 -61
  15. package/dist/loader.cjs +3725 -2962
  16. package/dist/loader.js +2 -2
  17. package/editor/{chunk-WI7ZA44X.js → chunk-U36XNFJN.js} +111 -77
  18. package/editor/extensions/index.d.ts +272 -27
  19. package/editor/index.d.ts +1 -1
  20. package/editor/index.js +1 -1
  21. package/editor/{table-overlay-DoiLie4h.d.ts → table-overlay-DZFGHQDt.d.ts} +48 -6
  22. package/editor/ui.d.ts +15 -11
  23. package/editor/ui.js +1 -1
  24. package/layout/index.cjs +197 -340
  25. package/layout/index.d.cts +11 -0
  26. package/layout/index.d.ts +11 -0
  27. package/layout/index.js +197 -340
  28. package/layout.css +31 -134
  29. package/package.json +24 -11
  30. package/react/index.d.ts +1276 -0
  31. package/react/index.js +1526 -0
  32. package/styles.css +5 -10
  33. package/svelte/index.d.ts +204 -0
  34. package/svelte/index.js +1881 -0
  35. package/theme-dark.css +81 -2
  36. package/theme-high-contrast.css +14 -0
  37. package/theme-light.css +30 -1
  38. package/tokens.css +45 -1
  39. package/vue/chunk-UZMTYDP6.js +4355 -0
  40. package/vue/editor/index.d.ts +78 -8
  41. package/vue/editor/index.js +59 -49
  42. package/vue/index.d.ts +67 -78
  43. package/vue/index.js +3 -9
  44. package/dist/chunk-ECJQ4YGC.js +0 -2925
  45. package/dist/valibot.cjs +0 -31
  46. package/dist/valibot.d.cts +0 -10
  47. package/dist/valibot.d.ts +0 -10
  48. package/dist/valibot.js +0 -9
  49. package/dist/validation-bxcou-l-.d.cts +0 -58
  50. package/dist/validation-bxcou-l-.d.ts +0 -58
  51. package/vue/chunk-P7BZ2KJZ.js +0 -3559
@@ -1,2925 +0,0 @@
1
- // ../../tools/migrate-html-next/generated/adoption/runtime.js
2
- var HtmlRuntime = (() => {
3
- var Ue = Object.defineProperty;
4
- var jn = Object.getOwnPropertyDescriptor;
5
- var On = Object.getOwnPropertyNames;
6
- var In = Object.prototype.hasOwnProperty;
7
- var zn = (e, t) => {
8
- for (var n in t) Ue(e, n, { get: t[n], enumerable: true });
9
- }, Un = (e, t, n, r) => {
10
- if (t && typeof t == "object" || typeof t == "function") for (let i of On(t)) !In.call(e, i) && i !== n && Ue(e, i, { get: () => t[i], enumerable: !(r = jn(t, i)) || r.enumerable });
11
- return e;
12
- };
13
- var qn = (e) => Un(Ue({}, "__esModule", { value: true }), e);
14
- var Di = {};
15
- zn(Di, { attachComponent: () => xt, attachRegisteredComponent: () => Li, getComponentHost: () => Tt, installComponentGraph: () => ri, lowerDocument: () => $i, manageComponentLifecycle: () => Mi, observeDocument: () => Hi, registerComponentDefinitions: () => Vi, setControllerModule: () => Pn });
16
- var qe = class extends Error {
17
- diagnostic;
18
- constructor(t) {
19
- let n = t.source ? `${t.source}: ` : "";
20
- super(`${n}${t.code}: ${t.message}`), this.name = "HtmlDiagnosticError", this.diagnostic = Object.freeze({ ...t });
21
- }
22
- };
23
- function y(e, t, n) {
24
- throw new qe(n === void 0 ? { code: e, message: t } : { code: e, message: t, source: n });
25
- }
26
- function oe(e) {
27
- if (typeof e != "object" || e === null || Object.isFrozen(e)) return e;
28
- for (let t of Object.values(e)) oe(t);
29
- return Object.freeze(e);
30
- }
31
- function Nt(e) {
32
- let t = "", n = true;
33
- for (let r of e) r === "-" ? n = true : (t += n ? r.toUpperCase() : r, n = false);
34
- return t;
35
- }
36
- function Ee(e) {
37
- return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
38
- }
39
- var _n = /* @__PURE__ */ new Set(["string", "boolean", "number", "integer", "null", "absent", "email", "url", "date", "time", "datetime-local", "month", "week", "color", "token", "ident", "url-value", "token-list", "trusted-html", "trusted-script", "function", "unknown"]), xe = class extends SyntaxError {
40
- constructor(n, r) {
41
- super(`${n} at character ${r + 1}.`);
42
- this.position = r;
43
- this.name = "TypeSyntaxError";
44
- }
45
- position;
46
- }, Fe = class {
47
- constructor(t) {
48
- this.source = t;
49
- }
50
- source;
51
- #e = 0;
52
- parse() {
53
- let t = this.#t();
54
- return this.#a(), this.#e !== this.source.length && this.#s("Unexpected type syntax"), t;
55
- }
56
- #t() {
57
- let t = [this.#n()];
58
- for (; this.#o("|"); ) t.push(this.#n());
59
- return t.length === 1 ? t[0] : We(t);
60
- }
61
- #n() {
62
- let t = this.#i();
63
- for (; this.#o("?"); ) t = We([t, { kind: "terminal", name: "null" }, { kind: "terminal", name: "absent" }]);
64
- return t;
65
- }
66
- #i() {
67
- if (this.#o("(")) {
68
- let r = this.#t();
69
- return this.#r(")"), r;
70
- }
71
- let t = this.#l();
72
- if (t !== void 0) return { kind: "keyword", value: t };
73
- let n = this.#d();
74
- if (n === void 0 && this.#s("Expected a type, keyword, or group"), n === "list" || n === "record") {
75
- this.#r("(");
76
- let r = this.#t();
77
- return this.#r(")"), n === "list" ? { kind: "list", item: r } : { kind: "record", value: r };
78
- }
79
- return n === "object" ? this.#u() : _n.has(n) ? { kind: "terminal", name: n } : { kind: "keyword", value: n };
80
- }
81
- #u() {
82
- this.#r("("), this.#r("{");
83
- let t = [], n = false;
84
- for (; !this.#o("}"); ) {
85
- if (this.#a(), this.source.startsWith("...", this.#e)) this.#e += 3, n = true;
86
- else {
87
- let r = this.#l() ?? this.#d();
88
- r === void 0 && this.#s("Expected an object field or `...`");
89
- let i = this.#o("?");
90
- this.#r(":");
91
- let o = this.#t();
92
- t.some((a) => a.name === r) && this.#s(`Duplicate object field \`${r}\``), t.push({ name: r, type: o, optional: i });
93
- }
94
- if (this.#o("}")) break;
95
- this.#r(","), n && (this.#a(), this.source.startsWith("}", this.#e) || this.#s("The open marker must be last"));
96
- }
97
- return this.#r(")"), { kind: "object", fields: t, open: n };
98
- }
99
- #d() {
100
- this.#a();
101
- let t = /^[A-Za-z_][A-Za-z0-9_-]*/.exec(this.source.slice(this.#e));
102
- if (t !== null) return this.#e += t[0].length, t[0];
103
- }
104
- #l() {
105
- this.#a();
106
- let t = this.source[this.#e];
107
- if (t !== '"' && t !== "'") return;
108
- this.#e += 1;
109
- let n = "";
110
- for (; this.#e < this.source.length; ) {
111
- let r = this.source[this.#e++];
112
- if (r === t) return n;
113
- if (r !== "\\") {
114
- n += r;
115
- continue;
116
- }
117
- this.#e >= this.source.length && this.#s("Unterminated escape");
118
- let i = this.source[this.#e++];
119
- n += { n: `
120
- `, r: "\r", t: " ", "\\": "\\", '"': '"', "'": "'" }[i] ?? i;
121
- }
122
- this.#s("Unterminated quoted keyword");
123
- }
124
- #o(t) {
125
- return this.#a(), this.source.startsWith(t, this.#e) ? (this.#e += t.length, true) : false;
126
- }
127
- #r(t) {
128
- this.#o(t) || this.#s(`Expected \`${t}\``);
129
- }
130
- #a() {
131
- for (; /\s/.test(this.source[this.#e] ?? ""); ) this.#e += 1;
132
- }
133
- #s(t) {
134
- throw new xe(t, this.#e);
135
- }
136
- };
137
- function We(e) {
138
- let t = e.flatMap((i) => i.kind === "union" ? i.members : [i]), n = new Map(t.map((i) => [K(i), i])), r = Array.from(n.values());
139
- return r.length === 1 ? r[0] : { kind: "union", members: r };
140
- }
141
- function F(e) {
142
- if (e.trim() === "") throw new xe("A type expression cannot be empty", 0);
143
- return oe(new Fe(e).parse());
144
- }
145
- function Be(e) {
146
- return typeof e == "object" && e !== null && "kind" in e && ["terminal", "keyword", "union", "list", "record", "object"].includes(String(e.kind));
147
- }
148
- function Q(e) {
149
- return Be(e) ? e : typeof e == "string" ? { kind: "terminal", name: e } : We(e.enum.map((t) => ({ kind: "keyword", value: t })));
150
- }
151
- function K(e) {
152
- let t = Be(e) ? e : Q(e);
153
- switch (t.kind) {
154
- case "terminal":
155
- return t.name;
156
- case "keyword":
157
- return /^[A-Za-z_][A-Za-z0-9_-]*$/.test(t.value) ? t.value : JSON.stringify(t.value);
158
- case "union":
159
- return t.members.map((n) => K(n)).join(" | ");
160
- case "list":
161
- return `list(${K(t.item)})`;
162
- case "record":
163
- return `record(${K(t.value)})`;
164
- case "object":
165
- return `object({ ${[...t.fields.map((n) => `${n.name}${n.optional ? "?" : ""}: ${K(n.type)}`), ...t.open ? ["..."] : []].join(", ")} })`;
166
- }
167
- }
168
- function T(e, t, n) {
169
- return { ok: false, issues: [{ reason: e, message: t, path: n }] };
170
- }
171
- function O(e, t) {
172
- return typeof t == "number" ? `${e}[${t}]` : /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t) ? `${e}.${t}` : `${e}[${JSON.stringify(t)}]`;
173
- }
174
- function $t(e) {
175
- if (typeof e != "object" || e === null || Array.isArray(e)) return false;
176
- let t = Object.getPrototypeOf(e);
177
- return t === Object.prototype || t === null;
178
- }
179
- function _e(e) {
180
- if (typeof e != "string") return e;
181
- try {
182
- return JSON.parse(e);
183
- } catch {
184
- return /* @__PURE__ */ Symbol.for("html-next.bad-json");
185
- }
186
- }
187
- function Fn(e) {
188
- if (e.length > 254 || /\s/.test(e)) return false;
189
- let t = /^([A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+)@([A-Za-z0-9.-]+)$/.exec(e);
190
- return t === null || t[1].length > 64 ? false : t[2].split(".").every((n) => n !== "" && n.length <= 63 && !n.startsWith("-") && !n.endsWith("-"));
191
- }
192
- function At(e) {
193
- let t = /^(\d{4,})-(\d{2})-(\d{2})$/.exec(e);
194
- if (t === null || t[1] === "0000") return false;
195
- let n = Number(t[1]), r = Number(t[2]), i = Number(t[3]), o = new Date(Date.UTC(n, r - 1, i));
196
- return o.getUTCFullYear() === n && o.getUTCMonth() === r - 1 && o.getUTCDate() === i;
197
- }
198
- function Mt(e) {
199
- let t = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/.exec(e);
200
- return t !== null && Number(t[1]) < 24 && Number(t[2]) < 60 && Number(t[3] ?? 0) < 60;
201
- }
202
- function Wn(e) {
203
- let t = /^(\d{4,})-W(\d{2})$/.exec(e);
204
- if (t === null || t[1] === "0000") return false;
205
- let n = Number(t[1]), r = Number(t[2]);
206
- if (r < 1 || r > 53) return false;
207
- if (r < 53) return true;
208
- let i = new Date(Date.UTC(n, 0, 1)).getUTCDay();
209
- return i === 4 || i === 3 && new Date(Date.UTC(n, 1, 29)).getUTCDate() === 29;
210
- }
211
- function Bn(e, t) {
212
- if (typeof e != "object" || e === null) return false;
213
- if (e.kind === t && "value" in e) return true;
214
- let n = t === "trusted-html" ? "TrustedHTML" : "TrustedScript";
215
- return e.constructor?.name === n || Object.prototype.toString.call(e) === `[object ${n}]`;
216
- }
217
- function Zn(e, t, n) {
218
- switch (t) {
219
- case "string":
220
- return typeof e == "string" ? { ok: true, value: e } : T("typeMismatch", "Must be a string.", n);
221
- case "boolean":
222
- return typeof e == "boolean" ? { ok: true, value: e } : e === "" || e === "true" ? { ok: true, value: true } : e === "false" ? { ok: true, value: false } : T("typeMismatch", "Must be true or false.", n);
223
- case "number":
224
- case "integer": {
225
- let r = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : Number.NaN;
226
- return Number.isFinite(r) ? t === "integer" && !Number.isInteger(r) ? T("typeMismatch", "Must be an integer.", n) : { ok: true, value: r } : T("badInput", `Must be ${t === "integer" ? "an integer" : "a finite number"}.`, n);
227
- }
228
- case "null":
229
- return e === null ? { ok: true, value: null } : T("typeMismatch", "Must be null.", n);
230
- case "absent":
231
- return e === void 0 ? { ok: true, value: void 0 } : T("typeMismatch", "Must be absent.", n);
232
- case "email":
233
- return typeof e == "string" && Fn(e) ? { ok: true, value: e } : T("typeMismatch", "Must be a valid email address.", n);
234
- case "url": {
235
- if (typeof e != "string") return T("typeMismatch", "Must be a URL.", n);
236
- try {
237
- let r = new URL(e);
238
- return r.protocol !== "" ? { ok: true, value: r.href } : T("typeMismatch", "Must be an absolute URL.", n);
239
- } catch {
240
- return T("typeMismatch", "Must be a valid absolute URL.", n);
241
- }
242
- }
243
- case "date":
244
- return typeof e == "string" && At(e) ? { ok: true, value: e } : T("typeMismatch", "Must be a valid date (YYYY-MM-DD).", n);
245
- case "time":
246
- return typeof e == "string" && Mt(e) ? { ok: true, value: e } : T("typeMismatch", "Must be a valid time.", n);
247
- case "datetime-local": {
248
- if (typeof e != "string") return T("typeMismatch", "Must be a local date and time.", n);
249
- let r = e.split("T");
250
- return r.length === 2 && At(r[0]) && Mt(r[1]) ? { ok: true, value: e } : T("typeMismatch", "Must be a valid local date and time.", n);
251
- }
252
- case "month":
253
- return typeof e == "string" && /^(?!0000)\d{4,}-(?:0[1-9]|1[0-2])$/.test(e) ? { ok: true, value: e } : T("typeMismatch", "Must be a valid month.", n);
254
- case "week":
255
- return typeof e == "string" && Wn(e) ? { ok: true, value: e } : T("typeMismatch", "Must be a valid ISO week.", n);
256
- case "color":
257
- return typeof e == "string" && /^#[0-9a-fA-F]{6}$/.test(e) ? { ok: true, value: e.toLowerCase() } : T("typeMismatch", "Must be a six-digit sRGB color.", n);
258
- case "token":
259
- return typeof e == "string" && e !== "" && !/[\t\n\f\r ]/.test(e) ? { ok: true, value: e } : T("typeMismatch", "Must be one non-empty HTML token.", n);
260
- case "ident":
261
- return typeof e == "string" && /^-?(?:-?[A-Za-z_]|[^\0-\x7f])(?:[A-Za-z0-9_-]|[^\0-\x7f])*$/.test(e) && !/^--$/.test(e) ? { ok: true, value: e } : T("typeMismatch", "Must be an identifier.", n);
262
- case "url-value":
263
- return typeof e == "string" && e.trim() !== "" && !/[\u0000-\u001f\u007f]/.test(e) ? { ok: true, value: e } : T("typeMismatch", "Must be a URL value.", n);
264
- case "token-list": {
265
- let r = Array.isArray(e) ? e : typeof e == "string" ? e.trim().split(/\s+/).filter(Boolean) : void 0;
266
- return r !== void 0 && r.every((i) => typeof i == "string" && i !== "" && !/\s/.test(i)) ? { ok: true, value: r } : T("typeMismatch", "Must be a space-separated token list.", n);
267
- }
268
- case "trusted-html":
269
- case "trusted-script":
270
- return Bn(e, t) ? { ok: true, value: e } : T("untrustedValue", `Must be a ${t === "trusted-html" ? "TrustedHTML" : "TrustedScript"} value.`, n);
271
- case "function":
272
- return typeof e == "function" ? { ok: true, value: e } : T("typeMismatch", "Must be a function supplied through a property.", n);
273
- case "unknown":
274
- return { ok: true, value: e };
275
- }
276
- }
277
- function se(e, t, n) {
278
- switch (t.kind) {
279
- case "terminal":
280
- return Zn(e, t.name, n);
281
- case "keyword":
282
- return e === t.value ? { ok: true, value: e } : T("typeMismatch", `Must be ${JSON.stringify(t.value)}.`, n);
283
- case "union": {
284
- for (let r of t.members) {
285
- let i = se(e, r, n);
286
- if (i.ok) return i;
287
- }
288
- return T("typeMismatch", `Must match ${K(t)}.`, n);
289
- }
290
- case "list": {
291
- let r = _e(e);
292
- if (!Array.isArray(r)) return T("typeMismatch", "Must be a list.", n);
293
- let i = [], o = [];
294
- return r.forEach((a, s) => {
295
- let d = se(a, t.item, O(n, s));
296
- d.ok ? i.push(d.value) : o.push(...d.issues);
297
- }), o.length === 0 ? { ok: true, value: i } : { ok: false, issues: o };
298
- }
299
- case "record": {
300
- let r = _e(e);
301
- if (!$t(r)) return T("typeMismatch", "Must be a string-keyed record.", n);
302
- let i = {}, o = [];
303
- for (let [a, s] of Object.entries(r)) {
304
- let d = se(s, t.value, O(n, a));
305
- d.ok ? i[a] = d.value : o.push(...d.issues);
306
- }
307
- return o.length === 0 ? { ok: true, value: i } : { ok: false, issues: o };
308
- }
309
- case "object": {
310
- let r = _e(e);
311
- if (!$t(r)) return T("typeMismatch", "Must be an object.", n);
312
- let i = {}, o = [], a = new Map(t.fields.map((s) => [s.name, s]));
313
- for (let s of t.fields) {
314
- if (!(s.name in r)) {
315
- s.optional || o.push({ reason: "schemaMismatch", message: "Required field is absent.", path: O(n, s.name) });
316
- continue;
317
- }
318
- let d = se(r[s.name], s.type, O(n, s.name));
319
- d.ok ? i[s.name] = d.value : o.push(...d.issues);
320
- }
321
- for (let [s, d] of Object.entries(r)) a.has(s) || (t.open ? i[s] = d : o.push({ reason: "schemaMismatch", message: "Field is not declared by this closed object type.", path: O(n, s) }));
322
- return o.length === 0 ? { ok: true, value: i } : { ok: false, issues: o };
323
- }
324
- }
325
- }
326
- function j(e, t, n = "$") {
327
- return se(e, Q(t), n);
328
- }
329
- function Se(e, t) {
330
- let n = j(e, t);
331
- if (!n.ok) throw new TypeError(n.issues.map((i) => `${i.path}: ${i.message}`).join("; "));
332
- let r = Q(t);
333
- if (r.kind === "terminal" && (r.name === "function" || r.name === "unknown")) throw new TypeError(`The ${r.name} type is property-only and cannot be serialized.`);
334
- return r.kind === "list" || r.kind === "record" || r.kind === "object" || r.kind === "union" && typeof n.value == "object" && n.value !== null ? JSON.stringify(n.value) : r.kind === "terminal" && r.name === "token-list" ? n.value.join(" ") : n.value === null ? "null" : n.value === void 0 ? "" : String(n.value);
335
- }
336
- function G(e) {
337
- let t = Q(e);
338
- return t.kind === "terminal" ? t.name === "function" || t.name === "unknown" || t.name === "trusted-html" || t.name === "trusted-script" : t.kind === "union" ? t.members.some(G) : t.kind === "list" ? G(t.item) : t.kind === "record" ? G(t.value) : t.kind === "object" ? t.fields.some((n) => G(n.type)) : false;
339
- }
340
- function Vt(e) {
341
- let t;
342
- try {
343
- t = F(e);
344
- } catch (n) {
345
- y("HC013", n instanceof Error ? n.message : "Invalid prop type expression.");
346
- }
347
- return t.kind === "terminal" && (t.name === "string" || t.name === "boolean" || t.name === "number") ? t.name : t.kind === "keyword" ? { enum: [t.value] } : t.kind === "union" && t.members.every((n) => n.kind === "keyword") ? { enum: t.members.map((n) => n.value) } : t;
348
- }
349
- var x = /* @__PURE__ */ Symbol("absent"), ae = class extends Error {
350
- constructor(n) {
351
- super(`\`${n}\` is not declared in scope.`);
352
- this.identifier = n;
353
- this.name = "UndeclaredName";
354
- }
355
- identifier;
356
- }, Ze = /\s*(?:(<=|>=|!=|\^=|\$=|\*=)|(\d+(?:\.\d*)?|\.\d+)|("(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*')|([A-Za-z_$][A-Za-z0-9_$]*)|([=<>+*/%(),.:{}[\]-])|$)/y, Jn = /\\([\s\S])/g, Kn = /%s/g, Lt = /* @__PURE__ */ new Map();
357
- function Gn(e) {
358
- let t = Lt.get(e);
359
- return t !== void 0 ? t : (Lt.set(e, e), e);
360
- }
361
- function Ht(e) {
362
- switch (e) {
363
- case "or":
364
- return 1;
365
- case "and":
366
- return 2;
367
- case "=":
368
- case "!=":
369
- case "^=":
370
- case "$=":
371
- case "*=":
372
- return 3;
373
- case "<":
374
- case "<=":
375
- case ">":
376
- case ">=":
377
- return 4;
378
- case "+":
379
- case "-":
380
- return 5;
381
- case "*":
382
- case "/":
383
- case "%":
384
- return 6;
385
- default:
386
- return 0;
387
- }
388
- }
389
- function Yn(e) {
390
- return e === "round" || e === "clamp" || e === "min" || e === "max" || e === "abs" || e === "format";
391
- }
392
- function Qn(e) {
393
- let t = 0, n = 0, r = "";
394
- function i() {
395
- Ze.lastIndex = t;
396
- let l = Ze.exec(e);
397
- if (l === null) {
398
- let m = e.slice(t).trimStart()[0];
399
- throw m === '"' || m === "'" ? new SyntaxError("Unterminated string literal.") : new SyntaxError(`Unexpected character \`${m}\`.`);
400
- }
401
- t = Ze.lastIndex, l[1] !== void 0 || l[5] !== void 0 ? (n = 4, r = l[1] ?? l[5]) : l[2] !== void 0 ? (n = 1, r = Number(l[2])) : l[3] !== void 0 ? (n = 2, r = l[3].slice(1, -1).replace(Jn, "$1")) : l[4] !== void 0 ? (n = 3, r = Gn(l[4])) : (n = 0, r = "");
402
- }
403
- function o(l) {
404
- return r !== l ? false : (i(), true);
405
- }
406
- function a(l) {
407
- if (!o(l)) throw new SyntaxError(`Expected \`${l}\`.`);
408
- }
409
- function s(l) {
410
- let m = d(), f = Ht(r);
411
- for (; f >= l; ) {
412
- let p = String(r);
413
- i(), m = { kind: "binary", op: p, left: m, right: s(f + 1) }, f = Ht(r);
414
- }
415
- return m;
416
- }
417
- function d() {
418
- if (n === 3 && r === "not") return i(), { kind: "unary", op: "not", operand: d() };
419
- if (o("-")) return { kind: "unary", op: "-", operand: d() };
420
- let l = u();
421
- for (; n === 4; ) if (o(".")) {
422
- if (n !== 3) throw new SyntaxError("Expected a property name after `.`.");
423
- let m = String(r);
424
- i(), l = { kind: "member", object: l, key: m };
425
- } else if (o("[")) {
426
- let m = s(1);
427
- a("]"), l = { kind: "index", object: l, index: m };
428
- } else break;
429
- return l;
430
- }
431
- function u() {
432
- let l = n, m = r;
433
- if (l === 1 || l === 2) return i(), { kind: "literal", value: m };
434
- if (l === 4 && m === "(") {
435
- i();
436
- let f = s(1);
437
- return a(")"), f;
438
- }
439
- if (l === 4 && m === "{") {
440
- i();
441
- let f = [];
442
- if (!o("}")) {
443
- do {
444
- if (r === "}") break;
445
- if (n !== 3 && n !== 2) throw new SyntaxError("Object keys must be identifiers or strings.");
446
- let p = String(r);
447
- i(), a(":"), f.push({ key: p, value: s(1) });
448
- } while (o(","));
449
- a("}");
450
- }
451
- return { kind: "object", pairs: f };
452
- }
453
- if (l === 4 && m === "[") {
454
- i();
455
- let f = [];
456
- if (!o("]")) {
457
- do {
458
- if (r === "]") break;
459
- f.push(s(1));
460
- } while (o(","));
461
- a("]");
462
- }
463
- return { kind: "array", items: f };
464
- }
465
- if (l === 3) {
466
- let f = String(m);
467
- if (i(), f === "true") return { kind: "literal", value: true };
468
- if (f === "false") return { kind: "literal", value: false };
469
- if (f === "null") return { kind: "literal", value: null };
470
- if (r === "(" && Yn(f)) {
471
- i();
472
- let p = [];
473
- if (!o(")")) {
474
- do
475
- p.push(s(1));
476
- while (o(","));
477
- a(")");
478
- }
479
- return { kind: "call", fn: f, args: p };
480
- }
481
- return { kind: "id", name: f };
482
- }
483
- throw new SyntaxError("Unexpected end of expression.");
484
- }
485
- i();
486
- let c = s(1);
487
- if (n !== 0) throw new SyntaxError("Unexpected trailing input in expression.");
488
- return c;
489
- }
490
- function Ge(e) {
491
- return e === x || e === null;
492
- }
493
- function D(e) {
494
- if (e === x || e === null || e === false) return false;
495
- if (e === true) return true;
496
- if (typeof e == "string") return e.length > 0;
497
- if (typeof e == "number") return e !== 0 && e === e;
498
- if (Array.isArray(e)) return e.length > 0;
499
- for (let t in e) if (Object.hasOwn(e, t)) return true;
500
- return false;
501
- }
502
- function Te(e) {
503
- return typeof e == "number" && e === e ? e : x;
504
- }
505
- function M(e, t) {
506
- switch (e.kind) {
507
- case "literal":
508
- return e.value;
509
- case "id": {
510
- let n = t.get(e.name);
511
- if (n === void 0) throw new ae(e.name);
512
- return n;
513
- }
514
- case "member": {
515
- let n = M(e.object, t);
516
- if (n === null || n === x || typeof n != "object" || Array.isArray(n)) return x;
517
- let r = n[e.key];
518
- return r === void 0 ? x : r;
519
- }
520
- case "index": {
521
- let n = M(e.object, t), r = M(e.index, t);
522
- if (n === null || n === x || Ge(r)) return x;
523
- if (Array.isArray(n) && typeof r == "number") {
524
- let i = n[r];
525
- return i === void 0 ? x : i;
526
- }
527
- if (typeof n == "object" && typeof r == "string") {
528
- let i = n[r];
529
- return i === void 0 ? x : i;
530
- }
531
- return x;
532
- }
533
- case "unary": {
534
- let n = M(e.operand, t);
535
- if (e.op === "not") return !D(n);
536
- let r = Te(n);
537
- return r === x ? x : -r;
538
- }
539
- case "binary":
540
- return Xn(e, t);
541
- case "call":
542
- return er(e, t);
543
- case "object": {
544
- let n = {};
545
- for (let r of e.pairs) n[r.key] = M(r.value, t);
546
- return n;
547
- }
548
- case "array": {
549
- let n = [];
550
- for (let r of e.items) n.push(M(r, t));
551
- return n;
552
- }
553
- }
554
- }
555
- function Xn(e, t) {
556
- let { op: n } = e;
557
- if (n === "and") return D(M(e.left, t)) && D(M(e.right, t));
558
- if (n === "or") return D(M(e.left, t)) || D(M(e.right, t));
559
- let r = M(e.left, t), i = M(e.right, t);
560
- if (n === "=") return r === i;
561
- if (n === "!=") return r !== i;
562
- if (n === "^=" || n === "$=" || n === "*=") return typeof r != "string" || typeof i != "string" ? x : n === "^=" ? r.startsWith(i) : n === "$=" ? r.endsWith(i) : r.includes(i);
563
- let o = Te(r), a = Te(i);
564
- if (o === x || a === x) return x;
565
- switch (n) {
566
- case "<":
567
- return o < a;
568
- case "<=":
569
- return o <= a;
570
- case ">":
571
- return o > a;
572
- case ">=":
573
- return o >= a;
574
- case "+":
575
- return o + a;
576
- case "-":
577
- return o - a;
578
- case "*":
579
- return o * a;
580
- case "/":
581
- return o / a;
582
- case "%":
583
- return o % a;
584
- default:
585
- return x;
586
- }
587
- }
588
- function er(e, t) {
589
- let { args: n, fn: r } = e, i = [];
590
- for (let a of n) i.push(M(a, t));
591
- if (r === "format") {
592
- let a = i[0];
593
- if (typeof a != "string") return x;
594
- let s = 1;
595
- return a.replace(Kn, () => s < i.length ? L(i[s++]) : "%s");
596
- }
597
- for (let a = 0; a < i.length; a += 1) {
598
- let s = Te(i[a]);
599
- if (s === x) return x;
600
- i[a] = s;
601
- }
602
- let o = i;
603
- switch (r) {
604
- case "abs":
605
- return o.length === 1 ? Math.abs(o[0]) : x;
606
- case "round":
607
- return o.length === 1 ? Math.round(o[0]) : x;
608
- case "min":
609
- return o.length > 0 ? Math.min(...o) : x;
610
- case "max":
611
- return o.length > 0 ? Math.max(...o) : x;
612
- case "clamp":
613
- return o.length === 3 ? Math.min(Math.max(o[0], o[1]), o[2]) : x;
614
- default:
615
- return x;
616
- }
617
- }
618
- var Dt = /* @__PURE__ */ new Map();
619
- function Je(e) {
620
- if (e.kind === "id") return e.name;
621
- if (e.kind === "member") {
622
- let t = Je(e.object);
623
- return t === void 0 ? void 0 : `${t}.${e.key}`;
624
- }
625
- if (e.kind === "index" && e.index.kind === "literal") {
626
- let t = e.index.value;
627
- if (typeof t != "string" && typeof t != "number") return;
628
- let n = Je(e.object);
629
- return n === void 0 ? void 0 : `${n}.${t}`;
630
- }
631
- }
632
- function z(e, t) {
633
- let n = Je(e);
634
- if (n !== void 0) {
635
- t.includes(n) || t.push(n);
636
- return;
637
- }
638
- switch (e.kind) {
639
- case "literal":
640
- return;
641
- case "id":
642
- return;
643
- case "member":
644
- z(e.object, t);
645
- return;
646
- case "index":
647
- z(e.object, t), z(e.index, t);
648
- return;
649
- case "unary":
650
- z(e.operand, t);
651
- return;
652
- case "binary":
653
- z(e.left, t), z(e.right, t);
654
- return;
655
- case "call":
656
- for (let r of e.args) z(r, t);
657
- return;
658
- case "object":
659
- for (let r of e.pairs) z(r.value, t);
660
- return;
661
- case "array":
662
- for (let r of e.items) z(r, t);
663
- }
664
- }
665
- function Ke(e, t) {
666
- if (e.kind === "id") return t.push(e.name), true;
667
- if (e.kind === "member") return Ke(e.object, t) ? (t.push(e.key), true) : false;
668
- if (e.kind !== "index" || !Ke(e.object, t)) return false;
669
- let n = e.index, r = n.kind === "literal" ? n.value : void 0;
670
- return t.push(typeof r == "string" || typeof r == "number" ? r : { kind: "index", expression: n }), true;
671
- }
672
- function Ce(e) {
673
- let t = Dt.get(e);
674
- if (t !== void 0) return t;
675
- let n = Qn(e), r = [];
676
- return z(n, r), r.sort(), t = { source: e, ast: n, dependencies: r }, Dt.set(e, t), t;
677
- }
678
- function Ye(e, t) {
679
- let n = [];
680
- if (!(!Ke(Ce(e).ast, n) || !t.has(String(n[0])))) return n;
681
- }
682
- function Pt(e, t) {
683
- return M(Ce(e).ast, t);
684
- }
685
- function W(e, t) {
686
- return M("ast" in e ? e.ast : e, t);
687
- }
688
- function L(e) {
689
- if (Ge(e)) return "";
690
- if (Array.isArray(e)) {
691
- let t = "", n = "";
692
- for (let r of e) t += n + L(r), n = " ";
693
- return t;
694
- }
695
- return typeof e == "object" ? "" : String(e);
696
- }
697
- function jt(e) {
698
- return Ge(e) || e === false ? null : e === true ? "" : typeof e == "number" || typeof e == "string" ? String(e) : Array.isArray(e) ? e.map(L).join(" ") : null;
699
- }
700
- var tr = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "poster", "data", "xlink:href"]), nr = /* @__PURE__ */ new Set(["base", "embed", "iframe", "link", "meta", "object", "script", "style", "template"]), rr = /* @__PURE__ */ new Set(["srcdoc", "style"]);
701
- function de(e) {
702
- let t = e.replace(/[\u0000-\u0020\u007f]+/g, "");
703
- return /^(?:data|javascript|vbscript):/i.test(t);
704
- }
705
- function ue(e) {
706
- return tr.has(e.toLowerCase());
707
- }
708
- function Qe(e, t, n) {
709
- let r = t.createElement("template");
710
- r.innerHTML = e;
711
- for (let i of Array.from(r.content.querySelectorAll("*"))) {
712
- if (n?.(i), nr.has(i.localName)) {
713
- i.remove();
714
- continue;
715
- }
716
- for (let o of Array.from(i.attributes)) {
717
- let a = o.name.toLowerCase();
718
- (a.startsWith("on") || rr.has(a) || ue(a) && de(o.value)) && i.removeAttribute(o.name);
719
- }
720
- }
721
- return r.content;
722
- }
723
- var ir = /^(?:if|else-if|else|for|with|value|state|computed|data)$/, or = /^(?:@|v-|#|on:|use:|transition:|animate:)/, sr = /^(?:innerhtml|outerhtml|srcdoc)$/, ar = /^(?:base|embed|link|meta|object|script|style)$/;
724
- function Ot(e) {
725
- return ir.test(e);
726
- }
727
- function Xe(e, t) {
728
- return ar.test(e.toLowerCase()) && y("HT009", `<${e}> is not permitted in rendered component markup.`, t), e;
729
- }
730
- function et(e, t, n = "") {
731
- let r = e.toLowerCase();
732
- return (r.startsWith("on") || or.test(r)) && y("HT010", `Literal attribute \`${e}\` uses target-framework directive syntax that is not supported.`, t), r === "srcdoc" && y("HT007", "Literal `srcdoc` is not permitted in a component definition.", t), ue(r) && de(n) && y("HT007", `Literal \`${e}\` contains an executable URL.`, t), e;
733
- }
734
- function It(e, t) {
735
- let n = e.toLowerCase();
736
- return (n.startsWith("on") || sr.test(n)) && y("HT007", `Dynamic ${e} requires a future trusted-content type.`, t), e;
737
- }
738
- function U(e) {
739
- return "tagName" in e;
740
- }
741
- function le(e) {
742
- return e.nodeName === "#text";
743
- }
744
- function N(e) {
745
- return "localName" in e ? e.localName : e.tagName;
746
- }
747
- function Re(e) {
748
- return "attrs" in e ? e.attrs : e.attributes;
749
- }
750
- function q(e) {
751
- return (N(e) === "template" ? e.content : void 0)?.childNodes ?? e.childNodes;
752
- }
753
- function ce(e) {
754
- return "value" in e ? e.value : "nodeValue" in e ? e.nodeValue ?? "" : "";
755
- }
756
- function qt(e) {
757
- let t = [];
758
- for (let n of e) n.nodeName !== "#comment" && (!le(n) || ce(n).trim() !== "") && t.push(n);
759
- return t;
760
- }
761
- function k(e, t) {
762
- return "attrs" in e ? e.attrs.find((n) => n.name === t)?.value : e.getAttribute(t) ?? void 0;
763
- }
764
- function _t(e) {
765
- let t = "";
766
- for (let n of q(e)) le(n) && (t += ce(n));
767
- return t;
768
- }
769
- function Ft(e, t) {
770
- let n = [];
771
- for (let r of q(e)) U(r) && N(r) === t && n.push(r);
772
- return n;
773
- }
774
- function Wt(e, t) {
775
- for (let n of q(e)) {
776
- if (!U(n)) continue;
777
- let r = N(n);
778
- r === "link" && y("HL001", "External definition dependencies require the application-owned graph resolver.", t), Xe(r, t);
779
- for (let i of Re(n)) /^on(?!:)/i.test(i.name) && et(i.name, t, i.value);
780
- Wt(n, t);
781
- }
782
- }
783
- var dr = /^\$(?:if|each|where|sort|limit|key|with|match|when|else)$/, zt = /^(?:innerhtml|outerhtml|textcontent|innertext|srcdoc)$/, ur = /^\s*([A-Za-z_$][\w$]*)\s*(?:,\s*([A-Za-z_$][\w$]*)\s*)?\bof\b\s*(.+)$/, Ut = /^\s*(.+?)\s+\bas\b\s+([A-Za-z_$][\w$]*)\s*$/, tt = /^[a-z][a-z0-9-]*$/, lr = /^(?:prevent|stop|self|once|passive|capture|left|middle|right|ctrl|shift|alt|meta|exact|enter|escape|space|tab|up|down)$/, it = /^[A-Za-z_$][A-Za-z0-9_$-]*$/;
784
- function nt(e, ...t) {
785
- let n = new Set(e.roots);
786
- for (let r of t) r !== void 0 && n.add(r);
787
- return { roots: n, writableRoots: e.writableRoots, handlers: e.handlers };
788
- }
789
- function R(e, t, n) {
790
- let r = yr(e, n);
791
- return cr(r, t, n), r;
792
- }
793
- function cr(e, t, n) {
794
- for (let r of e.dependencies) {
795
- let i = r.split(".", 1)[0];
796
- t.roots.has(i) || y("HT003", `Expression root \`${i}\` is not declared in this scope.`, n);
797
- }
798
- }
799
- function fr(e, t, n) {
800
- let r = /* @__PURE__ */ Object.create(null), i = (a, s) => {
801
- let d = r[a];
802
- d !== void 0 && ("attribute" in d ? !("attribute" in s) || d.attribute !== s.attribute : !("property" in s) || d.property !== s.property) && y("HT004", `Prop \`${a}\` is bound to conflicting targets.`, t), r[a] = s;
803
- }, o = (a) => {
804
- for (let s of Re(a)) if (s.name.startsWith(":")) /^[A-Za-z][A-Za-z0-9_-]*$/.test(s.value) && i(s.value, { attribute: s.name.slice(1).toLowerCase() });
805
- else if (s.name.startsWith(".")) {
806
- let d = s.name.slice(1).toLowerCase();
807
- if (/^[A-Za-z][A-Za-z0-9_-]*$/.test(s.value)) {
808
- let u = n.resolveDomProperty(N(a), d) ?? (s.value.toLowerCase() === d ? s.value : d);
809
- i(s.value, { property: u });
810
- }
811
- }
812
- for (let s of q(a)) U(s) && N(s) !== "slot" && o(s);
813
- };
814
- return o(e), r;
815
- }
816
- function pr(e, t, n, r = true) {
817
- let i = /* @__PURE__ */ Object.create(null), o = /* @__PURE__ */ Object.create(null);
818
- if (e === void 0) return i;
819
- let a = Ft(e, "prop");
820
- a.sort((s, d) => {
821
- let u = k(s, "name") ?? "", c = k(d, "name") ?? "";
822
- return u < c ? -1 : u > c ? 1 : 0;
823
- });
824
- for (let s of a) {
825
- let d = k(s, "name");
826
- (d === void 0 || d === "") && y("HC010", "A <prop> requires a `name` attribute.", n), /^[A-Za-z][A-Za-z0-9_-]*$/.test(d) || y("HC010", `Invalid prop name \`${d}\`.`, n);
827
- let u = k(s, "type");
828
- (u === void 0 || u === "") && y("HC013", `Prop \`${d}\` requires a \`type\` attribute.`, n);
829
- let c = d.toLowerCase(), l = o[c];
830
- l !== void 0 && y("HC011", `Props \`${l}\` and \`${d}\` collide after lowercase normalization.`, n), o[c] = d;
831
- let m = t[d];
832
- m === void 0 && r && y("HC018", `Prop \`${d}\` is declared but never bound in the markup.`, n), m ??= { attribute: d.toLowerCase() };
833
- let f = Vt(u), p = k(s, "required") !== void 0, h = _t(s).trim();
834
- h === "" && y("HC003", `\`props.${d}.description\` must be a non-empty string.`, n), "attribute" in m && G(f) && y("HC017", `Prop \`${d}\` uses a property-only type and must target a DOM property.`, n);
835
- let v = k(s, "default");
836
- p && v !== void 0 && y("HC019", `Required prop \`${d}\` cannot also declare a default.`, n);
837
- let S = { type: f, required: p, target: m, description: h };
838
- if (v !== void 0) {
839
- let w = j(v, f);
840
- w.ok || y("HC015", `Default for prop \`${d}\` does not satisfy its type.`, n), S.default = w.value;
841
- }
842
- i[d] = S;
843
- }
844
- return i;
845
- }
846
- function mr(e, t, n, r, i, o, a) {
847
- let s = k(e, "component") ?? "";
848
- s.trim() === "" && y("HC003", "`component` must be a non-empty string.", o), /^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/.test(s) || y("HC005", "The `component` tag must be lowercase and contain a hyphen.", o);
849
- let d = k(e, "status") ?? "";
850
- /^(?:early|experimental|stable|deprecated)$/.test(d) || y("HC007", "Component `status` is not recognized.", o);
851
- let u = k(e, "summary") ?? "";
852
- return u.trim() === "" && y("HC003", "`summary` must be a non-empty string.", o), (!/^[a-z][a-z0-9-]*$/.test(n) || r && !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/.test(n)) && y("HC008", "`nativeElement` must be a lowercase HTML element or component tag.", o), { version: 1, name: Nt(s), tag: s, status: d, summary: u, nativeElement: n, props: pr(t, i, o, a) };
853
- }
854
- function yr(e, t) {
855
- try {
856
- return Ce(e);
857
- } catch {
858
- y("HT013", `Malformed expression \`${e}\`.`, t);
859
- }
860
- }
861
- function hr(e, t, n) {
862
- let r = [];
863
- for (let i of qt(q(e))) {
864
- U(i) || y("HC023", "Handler bodies contain declarative step elements only.", n);
865
- let o = k(i, "$if"), a = o === void 0 ? void 0 : R(o, t, n);
866
- if (N(i) === "set") {
867
- let s = k(i, "name") ?? "", d = k(i, ":value"), u = k(i, "value");
868
- (s === "" || d === void 0 == (u === void 0)) && y("HC023", "A <set> requires `name` and exactly one of `value` or `:value`.", n), R(s, t, n);
869
- let c = Ye(s, t.writableRoots);
870
- c === void 0 && y("HT005", `Handler write \`${s}\` is not rooted in declared state.`, n);
871
- let l = { kind: "set", path: s, writablePath: c, value: R(d ?? JSON.stringify(u), t, n) };
872
- a !== void 0 && (l.guard = a), r.push(l);
873
- continue;
874
- }
875
- if (N(i) === "dispatch") {
876
- let s = k(i, "event") ?? "";
877
- tt.test(s) || y("HC023", "A <dispatch> requires a valid `event` name.", n);
878
- let d = k(i, ":value"), u = k(i, "value");
879
- d !== void 0 && u !== void 0 && y("HC023", "A <dispatch> may declare only one of `value` or `:value`.", n);
880
- let c = d === void 0 && u === void 0 ? void 0 : R(d ?? JSON.stringify(u), t, n), l = { kind: "dispatch", event: s };
881
- c !== void 0 && (l.value = c), a !== void 0 && (l.guard = a), r.push(l);
882
- continue;
883
- }
884
- if (N(i) === "validate" || N(i) === "focus") {
885
- let s = k(i, "target") ?? k(i, "ref") ?? k(i, "name") ?? "";
886
- it.test(s) || y("HC023", `<${N(i)}> requires a valid target reference.`, n);
887
- let d = { kind: N(i), target: s };
888
- a !== void 0 && (d.guard = a), r.push(d);
889
- continue;
890
- }
891
- y("HC023", `<${N(i)}> is not a recognized handler step.`, n);
892
- }
893
- return r;
894
- }
895
- function gr(e, t, n) {
896
- let r = [], i = new Set(Object.keys(t.props)), o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
897
- if (e === void 0) return { declarations: r, scope: { roots: i, writableRoots: o, handlers: a } };
898
- let s = [], d = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
899
- for (let l of q(e)) {
900
- if (!U(l)) continue;
901
- let m = l;
902
- s.push(m);
903
- let f = N(m);
904
- /^(?:prop|state|computed|data|handler|event|method)$/.test(f) || y("HC021", `<${f}> is not a recognized definition declaration.`, n);
905
- let p = k(m, "name") ?? "";
906
- if (p === "" && y("HC010", `A <${f}> requires a \`name\` attribute.`, n), f === "event") {
907
- u.has(p) && y("HC020", `Event \`${p}\` is declared more than once.`, n), u.add(p);
908
- continue;
909
- }
910
- d.has(p) && y("HC020", `Declaration \`${p}\` collides in the flat component scope.`, n), d.add(p), i.add(p), f === "state" ? o.add(p) : f === "handler" && a.add(p);
911
- }
912
- let c = { roots: i, writableRoots: o, handlers: a };
913
- for (let l of s) {
914
- let m = N(l);
915
- if (m === "prop") continue;
916
- let f = k(l, "name");
917
- if (m === "state") {
918
- let p = k(l, ":value"), h = k(l, "value");
919
- p !== void 0 && h !== void 0 && y("HC013", `<state name="${f}"> may declare only one of \`value\` or \`:value\`.`, n);
920
- let v = p === void 0 && h === void 0 ? void 0 : R(p ?? JSON.stringify(h), c, n), S = { kind: m, name: f };
921
- h !== void 0 && (S.value = h), v !== void 0 && (S.expression = v), r.push(S);
922
- continue;
923
- }
924
- if (m === "computed") {
925
- let p = k(l, "from");
926
- (p === void 0 || p === "") && y("HC013", `<computed name="${f}"> requires a \`from\` expression.`, n), r.push({ kind: m, name: f, expression: R(p, c, n) });
927
- continue;
928
- }
929
- if (m === "data") {
930
- let p = k(l, "src"), h = k(l, "type"), v = k(l, "schema"), S = k(l, "debounce"), w = k(l, "poll"), g = [], b = /* @__PURE__ */ new Set();
931
- for (let A of Ft(l, "param")) {
932
- let P = k(A, "name") ?? "", H = k(A, ":value");
933
- (!it.test(P) || H === void 0) && y("HC024", "A data <param> requires a valid `name` and a `:value` expression.", n), b.has(P) && y("HC024", `Data source \`${f}\` repeats a parameter name.`, n), b.add(P), g.push({ name: P, expression: R(H, c, n) });
934
- }
935
- let E = { kind: m, name: f, parameters: g };
936
- p !== void 0 && (E.source = p), h !== void 0 && (E.type = h), v !== void 0 && (E.schema = v), S !== void 0 && (E.debounce = S), w !== void 0 && (E.poll = w), r.push(E);
937
- continue;
938
- }
939
- if (m === "event") {
940
- r.push({ kind: m, name: f, type: k(l, "type") ?? "object", bubbles: k(l, "bubbles") !== "false", composed: k(l, "composed") !== "false", cancelable: k(l, "cancelable") === "true" });
941
- continue;
942
- }
943
- if (m === "method") {
944
- r.push({ kind: m, name: f, exportName: k(l, "export") ?? f, returns: k(l, "returns") ?? "undefined" });
945
- continue;
946
- }
947
- r.push({ kind: "handler", name: f, steps: hr(l, c, n) });
948
- }
949
- for (let l of r) if (l.kind === "handler") for (let m of l.steps) m.kind === "dispatch" && !u.has(m.event) && y("HC023", `Handler \`${l.name}\` dispatches undeclared component event \`${m.event}\`.`, n);
950
- return { declarations: r, scope: c };
951
- }
952
- function br(e, t, n, r, i, o) {
953
- let a = [];
954
- for (let s of e) {
955
- if (s.name.startsWith("bind:")) {
956
- let d = s.name.slice(5).toLowerCase();
957
- (d === "" || zt.test(d)) && y("HT007", `Two-way binding cannot target \`${d || s.name}\`.`, i);
958
- let u = R(s.value, r, i), c = Ye(s.value, r.writableRoots);
959
- c === void 0 && y("HT005", `\`${s.value}\` is not a writable state-rooted path.`, i), a.push({ kind: "attribute", name: d, expression: s.value, expressionPlan: u, twoWay: true, writablePath: c });
960
- continue;
961
- }
962
- if (s.name.startsWith("class:") || s.name.startsWith("style:")) {
963
- let d = s.name.startsWith("class:") ? "class" : "style", u = s.name.slice(d.length + 1);
964
- (d === "class" ? u !== "" && !/\s/.test(u) : /^(?:--[a-z0-9_-]+|[a-z][a-z0-9-]*)$/.test(u)) || y("HT020", `\`${s.name}\` does not name a valid ${d} binding target.`, i), a.push({ kind: "attribute", name: u, expression: s.value, expressionPlan: R(s.value, r, i), target: d });
965
- continue;
966
- }
967
- if (s.name.startsWith("$")) {
968
- let d = s.name.slice(1).toLowerCase();
969
- d !== "value" && d !== "html" && y("HT012", `\`$${d}\` is not a known content directive.`, i), a.push({ kind: "directive", name: d, expression: s.value, expressionPlan: R(s.value, r, i) });
970
- continue;
971
- }
972
- if (s.name.startsWith(":")) {
973
- let d = s.name.slice(1).toLowerCase();
974
- zt.test(d) && y("HT007", `\`:${d}\` cannot bind a raw content sink.`, i);
975
- let u = R(s.value, r, i), c = n.props[s.value];
976
- c !== void 0 && (!("attribute" in c.target) || c.target.attribute !== d) && y("HT004", `Binding \`:${d}\` does not match prop \`${s.value}\`'s target.`, i), a.push({ kind: "attribute", name: d, expression: s.value, expressionPlan: u });
977
- continue;
978
- }
979
- if (s.name.startsWith(".")) {
980
- let d = s.name.slice(1).toLowerCase(), u = R(s.value, r, i), c = n.props[s.value];
981
- c !== void 0 && (!("property" in c.target) || c.target.property.toLowerCase() !== d) && y("HT004", `Property binding \`.${d}\` does not match prop \`${s.value}\`'s target.`, i);
982
- let l = o.resolveDomProperty(t, d) ?? (c !== void 0 && "property" in c.target ? c.target.property : void 0);
983
- l === void 0 && y("HP001", `\`${d}\` is not a known property of <${t}>.`, i), It(l, i), a.push({ kind: "property", key: d, name: l, expression: s.value, expressionPlan: u });
984
- continue;
985
- }
986
- et(s.name, i, s.value), a.push({ kind: "literal", name: s.name, value: s.value });
987
- }
988
- return a;
989
- }
990
- function vr(e, t, n) {
991
- if (e === void 0) return;
992
- let r = [];
993
- for (let i of e) {
994
- let [o = "", ...a] = i.name.slice(3).split(".");
995
- (!tt.test(o) || a.some((s) => !tt.test(s))) && y("HT010", `\`${i.name}\` is not a valid declarative event binding.`, n);
996
- for (let s = 0; s < a.length; s += 1) {
997
- let d = a[s];
998
- a.indexOf(d) !== s && y("HT010", `\`${i.name}\` repeats an event modifier.`, n), lr.test(d) || y("HT010", `\`${i.name}\` contains an unsupported event modifier.`, n);
999
- }
1000
- a.includes("passive") && a.includes("prevent") && y("HT010", `\`${i.name}\` cannot combine passive and prevent.`, n), t.handlers.has(i.value) || y("HT010", `Event binding \`${i.name}\` names undeclared handler \`${i.value}\`.`, n), r.push({ name: o, handler: i.value, modifiers: a });
1001
- }
1002
- return r;
1003
- }
1004
- function kr(e, t, n) {
1005
- if (e !== void 0) return it.test(e) || y("HT019", "`$ref` requires a valid non-empty name.", n), t.has(e) && y("HT019", `Reference \`${e}\` is duplicated.`, n), t.add(e), e;
1006
- }
1007
- function wr(e, t, n) {
1008
- if (e === void 0) return;
1009
- let r = [], i = [];
1010
- e.$if !== void 0 && r.push("$if"), e.$each !== void 0 && r.push("$each"), e.$with !== void 0 && r.push("$with"), e.$match !== void 0 && r.push("$match"), e.$when !== void 0 && r.push("$when"), e.$else !== void 0 && r.push("$else"), e.$where !== void 0 && i.push("$where"), e.$sort !== void 0 && i.push("$sort"), e.$limit !== void 0 && i.push("$limit"), e.$key !== void 0 && i.push("$key"), r.length > 1 && y("HT014", `An element carries one structural directive; found ${r.join(", ")}.`, n);
1011
- let o = e.$each;
1012
- o === void 0 && i.length > 0 && y("HT014", `${i.join(", ")} may only modify \`$each\`.`, n);
1013
- let a = e.$if;
1014
- if (a !== void 0) {
1015
- let c = a;
1016
- return { kind: "if", test: c, testPlan: R(c, t, n) };
1017
- }
1018
- let s = e.$with;
1019
- if (s !== void 0) {
1020
- let c = Ut.exec(s);
1021
- return c === null && y("HT015", "`$with` must be written `expr as name`.", n), { kind: "with", expr: c[1], expressionPlan: R(c[1], t, n), alias: c[2] };
1022
- }
1023
- if (o !== void 0) {
1024
- let c = ur.exec(o);
1025
- c === null && y("HT016", "`$each` must be written `item of items` (optionally `item, i of items`).", n);
1026
- let l = c[1], m = c[2];
1027
- (t.roots.has(l) || m !== void 0 && t.roots.has(m)) && y("HC020", "Loop locals may not collide with an existing scope name.", n);
1028
- let f = nt(t, l, m, "loop"), p = { kind: "each", item: l, list: c[3], listPlan: R(c[3], t, n) };
1029
- m !== void 0 && (p.index = m);
1030
- let h = e.$where;
1031
- h !== void 0 && (p.where = h, p.wherePlan = R(h, f, n)), e.$sort !== void 0 && (p.sort = e.$sort);
1032
- let v = e.$limit;
1033
- v !== void 0 && (p.limit = v, p.limitPlan = R(v, f, n));
1034
- let S = e.$key;
1035
- return S !== void 0 && (p.key = S, p.keyPlan = R(S, f, n)), p;
1036
- }
1037
- let d = e.$match;
1038
- if (d !== void 0) {
1039
- let c = d.trim();
1040
- if (c === "") return { kind: "match" };
1041
- let l = Ut.exec(c);
1042
- return l === null && y("HT017", "`$match` scope must be written `expr as name`.", n), { kind: "match", expr: l[1], expressionPlan: R(l[1], t, n), alias: l[2] };
1043
- }
1044
- let u = e.$when;
1045
- if (u !== void 0) {
1046
- let c = u;
1047
- return { kind: "when", test: c, testPlan: R(c, t, n) };
1048
- }
1049
- if (e.$else !== void 0) return { kind: "else" };
1050
- }
1051
- function rt(e, t, n, r, i, o) {
1052
- let a = N(e);
1053
- Ot(a) && y("HT009", `<${a}> is reserved but not supported by this profile.`, r), Xe(a, r);
1054
- let s, d = [], u, c;
1055
- for (let g of Re(e)) dr.test(g.name) ? (s ??= {})[g.name] = g.value : g.name === "$ref" ? c = g.value : g.name.startsWith("on:") ? (u ??= []).push(g) : g.name !== "as" && d.push(g);
1056
- let l = wr(s, n, r), m = l?.kind === "each" ? nt(n, l.item, l.index, "loop") : l?.kind === "with" || l?.kind === "match" && l.alias !== void 0 ? nt(n, l.alias) : n, f = br(d, a, t, m, r, o), p = vr(u, m, r), h = kr(c, i.refs, r), v = [], S = q(e);
1057
- for (let g of S) if (g.nodeName !== "#comment") {
1058
- if (le(g)) {
1059
- let b = ce(g);
1060
- b.trim() !== "" && v.push({ kind: "text", value: b });
1061
- continue;
1062
- }
1063
- if (U(g)) {
1064
- if (N(g) === "slot") {
1065
- let b = k(g, "name"), E = k(g, ":name");
1066
- b !== void 0 && E !== void 0 && y("HT008", "A slot cannot declare both `name` and `:name`.", r);
1067
- for (let V of Re(g)) V.name !== "name" && V.name !== ":name" && y("HT008", "A slot has an unsupported attribute.", r);
1068
- b === void 0 && E === void 0 && (i.defaults += 1, i.defaults > 1 && y("HT008", "A component may declare one default slot.", r)), b !== void 0 && ((b === "" || i.names.has(b)) && y("HT008", `Slot name \`${b}\` is empty or duplicated.`, r), i.names.add(b));
1069
- let A = [];
1070
- for (let V of q(g)) if (V.nodeName !== "#comment") if (le(V)) {
1071
- let we = ce(V);
1072
- we.trim() !== "" && A.push({ kind: "text", value: we });
1073
- } else U(V) && A.push(rt(V, t, m, r, i, o));
1074
- let H = { dynamic: E !== void 0, required: A.length === 0 };
1075
- if (b !== void 0 && (H.name = b), i.contracts.push(H), b === void 0 && E === void 0 && A.length === 0) v.push({ kind: "slot" });
1076
- else {
1077
- let V = { kind: "slot", fallback: A };
1078
- b !== void 0 && (V.name = b), E !== void 0 && (V.nameExpression = R(E, m, r)), v.push(V);
1079
- }
1080
- continue;
1081
- }
1082
- v.push(rt(g, t, m, r, i, o));
1083
- }
1084
- }
1085
- if (f.some((g) => g.kind === "directive") && v.length > 0 && y("HT006", "A content directive cannot coexist with children.", r), f.some((g) => g.kind === "property" && g.name === "textContent") && v.length > 0 && y("HT006", "A content-replacing property binding cannot coexist with children.", r), l?.kind === "match") {
1086
- let g = 0;
1087
- for (let E of v) E.kind === "element" && (g += 1);
1088
- let b = false;
1089
- for (let E of v) E.kind === "element" && (g -= 1, E.flow?.kind === "when" ? b && y("HT018", "A `$when` arm may not follow `$else`.", r) : E.flow?.kind === "else" ? (b && y("HT018", "A `$match` has at most one `$else`.", r), b = true, g !== 0 && y("HT018", "`$else` must be the last arm.", r)) : y("HT018", "Every direct child of a `$match` must be a `$when` or `$else` arm.", r));
1090
- }
1091
- let w = { kind: "element", name: a, attributes: f, children: v };
1092
- return l !== void 0 && (w.flow = l), p !== void 0 && (w.events = p), h !== void 0 && (w.ref = h), w;
1093
- }
1094
- function Bt(e, t, n) {
1095
- let r = qt(e);
1096
- (r.length !== 1 || !U(r[0]) || N(r[0]) !== "template" || k(r[0], "component") === void 0) && y("HS001", "A source must contain exactly one top-level <template component>.", t);
1097
- let i = r[0], o, a = false, s, d;
1098
- for (let b of q(i)) {
1099
- if (b.nodeName === "#comment" || le(b) && ce(b).trim() === "") continue;
1100
- U(b) || y("HT001", "A component's markup must be exactly one element root.", t);
1101
- let E = N(b);
1102
- E === "props" || E === "defs" ? (o !== void 0 && y("HS002", "A component has one optional declaration group, one markup root, and one optional <style>.", t), o = b, a = E === "props", Wt(b, t)) : E === "style" ? (s !== void 0 && y("HS002", "A component has one optional declaration group, one markup root, and one optional <style>.", t), s = b) : d === void 0 ? d = b : y("HT001", "A component's markup must be exactly one element root.", t);
1103
- }
1104
- d === void 0 && y("HT001", "A component's markup must be exactly one element root.", t);
1105
- let u = N(d), c = (k(d, "as") ?? u).split("|");
1106
- for (let b = c.length - 1; b >= 0; b -= 1) c[b] = c[b].trim(), c[b] === "" && c.splice(b, 1);
1107
- let l = !n.isNativeElement(u);
1108
- l && k(d, "as") !== void 0 && y("HT021", "A delegated component root cannot also declare native `as` choices.", t), !l && (c.length === 0 || !c.includes(u) || c.some((b, E) => c.indexOf(b) !== E) || c.some((b) => !n.isNativeElement(b))) && y("HT021", "A polymorphic root must list unique native choices including its markup root.", t);
1109
- let m = fr(d, t, n), f = mr(i, o, u, l, m, t, a), { declarations: p, scope: h } = gr(a ? void 0 : o, f, t), v = { defaults: 0, names: /* @__PURE__ */ new Set(), contracts: [], refs: /* @__PURE__ */ new Set() }, S = rt(d, f, h, t, v, n), w = k(i, "controller");
1110
- w === "" && y("HC022", "A controller specifier cannot be empty.", t);
1111
- let g = { source: { file: t }, contract: f, template: S, css: s === void 0 ? "" : _t(s).trim(), declarations: p, slots: v.contracts, root: l ? { kind: "component", tag: u } : { kind: "native", element: u, choices: c } };
1112
- return w !== void 0 && (g.controller = w), oe(g);
1113
- }
1114
- var Zt = /* @__PURE__ */ new WeakMap();
1115
- function Er(e) {
1116
- let t = {}, n = {}, r = (i) => {
1117
- if (i.includes("-")) return false;
1118
- if (Object.hasOwn(t, i)) return t[i];
1119
- let o = e.createElement(i), a = e.defaultView?.HTMLUnknownElement, s = a === void 0 ? o.constructor.name !== "HTMLUnknownElement" : !(o instanceof a);
1120
- return t[i] = s, s;
1121
- };
1122
- return { isNativeElement: r, resolveDomProperty(i, o) {
1123
- if (!r(i)) return;
1124
- let a = `${i}:${o}`;
1125
- if (a in n) return n[a] || void 0;
1126
- let s = e.createElement(i), d = o.toLowerCase();
1127
- for (; s !== null; ) {
1128
- for (let u of Object.getOwnPropertyNames(s)) if (u.toLowerCase() === d) return n[a] = u, u;
1129
- s = Object.getPrototypeOf(s);
1130
- }
1131
- n[a] = "";
1132
- } };
1133
- }
1134
- function Jt(e, t = e.ownerDocument.URL) {
1135
- (e.localName !== "template" || !e.hasAttribute("component")) && y("HS001", "A browser component carrier must be a <template component>.", t);
1136
- let n = e.ownerDocument, r = Zt.get(n);
1137
- return r === void 0 && (r = Er(n), Zt.set(n, r)), Bt([e], t, r);
1138
- }
1139
- function ot(e, t) {
1140
- if (Object.is(e, t)) return true;
1141
- try {
1142
- return JSON.stringify(e) === JSON.stringify(t);
1143
- } catch {
1144
- return false;
1145
- }
1146
- }
1147
- function xr(e, t) {
1148
- return t === "null" ? e === null : t === "array" ? Array.isArray(e) : t === "object" ? e !== null && typeof e == "object" && !Array.isArray(e) : t === "integer" ? typeof e == "number" && Number.isFinite(e) && Number.isInteger(e) : t === "number" ? typeof e == "number" && Number.isFinite(e) : typeof e === t;
1149
- }
1150
- function Sr(e, t) {
1151
- if (t === "#") return e;
1152
- if (!t.startsWith("#/")) return;
1153
- let n = e;
1154
- for (let r of t.slice(2).split("/")) {
1155
- let i = r.replace(/~1/g, "/").replace(/~0/g, "~");
1156
- if (n === null || typeof n != "object") return;
1157
- n = n[i];
1158
- }
1159
- return typeof n == "boolean" || n !== null && typeof n == "object" ? n : void 0;
1160
- }
1161
- function C(e, t) {
1162
- return { reason: "schemaMismatch", path: e, message: t };
1163
- }
1164
- function _(e, t, n, r, i) {
1165
- if (t === true) return [];
1166
- if (t === false) return [C(r, "The schema rejects every value.")];
1167
- let o = typeof t.$ref == "string" ? t.$ref : void 0;
1168
- if (o !== void 0) {
1169
- if (i.has(o)) return [];
1170
- let l = Sr(n, o);
1171
- if (l === void 0) return [C(r, `Schema reference \`${o}\` cannot be resolved.`)];
1172
- let m = new Set(i);
1173
- return m.add(o), _(e, l, n, r, m);
1174
- }
1175
- if (Array.isArray(t.enum) && !t.enum.some((l) => ot(e, l))) return [C(r, "Value is not one of the schema's allowed values.")];
1176
- if ("const" in t && !ot(e, t.const)) return [C(r, "Value does not equal the schema's required constant.")];
1177
- let a = typeof t.type == "string" ? [t.type] : Array.isArray(t.type) ? t.type.filter((l) => typeof l == "string") : [];
1178
- if (a.length > 0 && !a.some((l) => xr(e, l))) return [C(r, `Expected ${a.join(" or ")}.`)];
1179
- let d = (Array.isArray(t.allOf) ? t.allOf : []).flatMap((l) => _(e, l, n, r, i)), u = Array.isArray(t.anyOf) ? t.anyOf : [];
1180
- u.length > 0 && !u.some((l) => _(e, l, n, r, i).length === 0) && d.push(C(r, "Value does not satisfy any allowed schema branch."));
1181
- let c = Array.isArray(t.oneOf) ? t.oneOf : [];
1182
- if (c.length > 0 && c.filter((l) => _(e, l, n, r, i).length === 0).length !== 1 && d.push(C(r, "Value must satisfy exactly one schema branch.")), (typeof t.not == "boolean" || t.not !== null && typeof t.not == "object") && _(e, t.not, n, r, i).length === 0 && d.push(C(r, "Value satisfies a schema branch that is forbidden.")), typeof e == "string") {
1183
- let l = Array.from(e).length;
1184
- if (typeof t.minLength == "number" && l < t.minLength && d.push(C(r, `Use at least ${t.minLength} characters.`)), typeof t.maxLength == "number" && l > t.maxLength && d.push(C(r, `Use no more than ${t.maxLength} characters.`)), typeof t.pattern == "string") try {
1185
- new RegExp(t.pattern, "u").test(e) || d.push(C(r, "Value does not match the schema pattern."));
1186
- } catch {
1187
- d.push(C(r, "The schema pattern is invalid."));
1188
- }
1189
- if (t.format === "email" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(e) && d.push(C(r, "Value is not an email address.")), t.format === "uri" || t.format === "url") try {
1190
- new URL(e);
1191
- } catch {
1192
- d.push(C(r, "Value is not an absolute URL."));
1193
- }
1194
- }
1195
- if (typeof e == "number" && Number.isFinite(e) && (typeof t.minimum == "number" && e < t.minimum && d.push(C(r, `Value must be at least ${t.minimum}.`)), typeof t.maximum == "number" && e > t.maximum && d.push(C(r, `Value must be at most ${t.maximum}.`)), typeof t.exclusiveMinimum == "number" && e <= t.exclusiveMinimum && d.push(C(r, `Value must be greater than ${t.exclusiveMinimum}.`)), typeof t.exclusiveMaximum == "number" && e >= t.exclusiveMaximum && d.push(C(r, `Value must be less than ${t.exclusiveMaximum}.`)), typeof t.multipleOf == "number" && t.multipleOf > 0)) {
1196
- let l = e / t.multipleOf;
1197
- Math.abs(l - Math.round(l)) > 1e-9 && d.push(C(r, `Value must be a multiple of ${t.multipleOf}.`));
1198
- }
1199
- if (Array.isArray(e) && (typeof t.minItems == "number" && e.length < t.minItems && d.push(C(r, `Use at least ${t.minItems} items.`)), typeof t.maxItems == "number" && e.length > t.maxItems && d.push(C(r, `Use no more than ${t.maxItems} items.`)), t.uniqueItems === true && e.some((l, m) => e.slice(0, m).some((f) => ot(f, l))) && d.push(C(r, "Array items must be unique.")), (typeof t.items == "boolean" || t.items !== null && typeof t.items == "object") && e.forEach((l, m) => d.push(..._(l, t.items, n, O(r, m), i)))), e !== null && typeof e == "object" && !Array.isArray(e)) {
1200
- let l = e, m = Array.isArray(t.required) ? t.required.filter((p) => typeof p == "string") : [];
1201
- for (let p of m) p in l || d.push(C(O(r, p), "Required field is absent."));
1202
- let f = t.properties !== null && typeof t.properties == "object" ? t.properties : {};
1203
- for (let [p, h] of Object.entries(f)) p in l && d.push(..._(l[p], h, n, O(r, p), i));
1204
- for (let [p, h] of Object.entries(l)) p in f || (t.additionalProperties === false ? d.push(C(O(r, p), "Field is not allowed by the schema.")) : t.additionalProperties !== void 0 && t.additionalProperties !== true && d.push(..._(h, t.additionalProperties, n, O(r, p), i)));
1205
- }
1206
- return d;
1207
- }
1208
- function Kt(e, t, n = "$") {
1209
- return Object.freeze(_(e, t, t, n, /* @__PURE__ */ new Set()));
1210
- }
1211
- var Ne = class extends TypeError {
1212
- constructor(n) {
1213
- super(n.map((r) => `${r.path}: ${r.message}`).join("; "));
1214
- this.issues = n;
1215
- this.name = "DataValidationError";
1216
- }
1217
- issues;
1218
- };
1219
- function Tr(e, t, n) {
1220
- let r = /* @__PURE__ */ new Set(), i = e.replace(/\{([A-Za-z_$][A-Za-z0-9_$-]*)\}/g, (a, s) => {
1221
- r.add(s);
1222
- let d = n[s];
1223
- return d == null ? "" : encodeURIComponent(String(d));
1224
- }), o = new URL(i, t);
1225
- for (let [a, s] of Object.entries(n)) if (!(r.has(a) || s == null)) if (Array.isArray(s)) for (let d of s) o.searchParams.append(a, String(d));
1226
- else o.searchParams.set(a, String(s));
1227
- return o.href;
1228
- }
1229
- var $e = class {
1230
- constructor(t) {
1231
- this.options = t;
1232
- this.#e = t.fetch ?? globalThis.fetch.bind(globalThis), this.#t = t.setTimer ?? ((n, r) => setTimeout(n, r)), this.#n = t.clearTimer ?? ((n) => clearTimeout(n));
1233
- }
1234
- options;
1235
- #e;
1236
- #t;
1237
- #n;
1238
- #i = {};
1239
- #u;
1240
- #d;
1241
- #l;
1242
- #o = 0;
1243
- #r = false;
1244
- update(t) {
1245
- this.#i = { ...t }, this.#r = true, this.#a();
1246
- let n = ++this.#o, r = () => {
1247
- this.#s(n);
1248
- };
1249
- (this.options.debounce ?? 0) > 0 ? this.#d = this.#t(r, this.options.debounce) : r();
1250
- }
1251
- disconnect() {
1252
- this.#r && (this.#r = false, this.#o += 1, this.#a());
1253
- }
1254
- #a() {
1255
- this.#u?.abort(), this.#u = void 0, this.#d !== void 0 && this.#n(this.#d), this.#d = void 0;
1256
- }
1257
- async #s(t) {
1258
- if (!this.#r || t !== this.#o) return;
1259
- let n = new AbortController();
1260
- this.#u = n;
1261
- let r = this.options;
1262
- r.onState({ pending: true, value: null, error: null, ok: false });
1263
- try {
1264
- let i = await this.#e(Tr(r.source, r.baseURL, this.#i), { signal: n.signal });
1265
- if (!i.ok) throw new TypeError(`Request failed with ${i.status}.`);
1266
- let o = r.schemaURL === void 0 ? void 0 : this.#l ?? await this.#c(r.schemaURL, n.signal), a = r.type === "text" ? await i.text() : await i.json(), s;
1267
- if (r.validate !== void 0) s = r.validate(a);
1268
- else if (r.schema !== void 0) {
1269
- let d = typeof r.schema == "string" ? F(r.schema) : r.schema, u = j(a, d);
1270
- if (!u.ok) throw new Ne(u.issues);
1271
- s = u.value;
1272
- } else if (o !== void 0) {
1273
- let d = Kt(a, o);
1274
- if (d.length > 0) throw new Ne(d);
1275
- s = a;
1276
- } else s = a;
1277
- if (!this.#r || t !== this.#o) return;
1278
- r.onState({ pending: false, value: s, error: null, ok: true });
1279
- } catch (i) {
1280
- if (n.signal.aborted || !this.#r || t !== this.#o) return;
1281
- r.onState({ pending: false, value: null, error: i, ok: false });
1282
- } finally {
1283
- this.#u === n && (this.#u = void 0), this.#r && t === this.#o && (r.poll ?? 0) > 0 && (this.#d = this.#t(() => {
1284
- this.#s(t);
1285
- }, r.poll));
1286
- }
1287
- }
1288
- async #c(t, n) {
1289
- let r = await this.#e(new URL(t, this.options.baseURL), { signal: n });
1290
- if (!r.ok) throw new TypeError(`Schema request failed with ${r.status}.`);
1291
- let i = await r.json();
1292
- if (typeof i != "boolean" && (i === null || typeof i != "object" || Array.isArray(i))) throw new TypeError("A JSON Schema resource must contain a boolean or object schema.");
1293
- return this.#l = i, this.#l;
1294
- }
1295
- };
1296
- var B, Cr = 0, Rr = 100, st = /* @__PURE__ */ new WeakMap(), Ae = /* @__PURE__ */ new WeakMap();
1297
- function Gt(e) {
1298
- let { dependency: t, previousSubscriber: n, nextSubscriber: r } = e;
1299
- n === void 0 ? t.first = r : n.nextSubscriber = r, r === void 0 ? t.last = n : r.previousSubscriber = n;
1300
- }
1301
- var dt = class {
1302
- #e = [];
1303
- #t = 0;
1304
- #n = false;
1305
- #i = false;
1306
- enqueue(t) {
1307
- t.stopped || this.#e.includes(t) || (this.#e.push(t), !this.#n && !this.#i && (this.#n = true, queueMicrotask(() => {
1308
- this.#n = false, this.flush();
1309
- })));
1310
- }
1311
- flush() {
1312
- if (this.#i) return;
1313
- this.#i = true;
1314
- let t = ++this.#t;
1315
- try {
1316
- for (; this.#e.length > 0; ) {
1317
- let n = this.#e.sort((r, i) => r.priority - i.priority || r.id - i.id);
1318
- this.#e = [];
1319
- for (let r of n) r.flushId === t ? r.flushCount += 1 : (r.flushId = t, r.flushCount = 1), r.flushCount > Rr && (this.#e = [], y("HR006", "A reactive effect exceeded the per-flush execution limit.")), r.execute();
1320
- }
1321
- } finally {
1322
- this.#i = false;
1323
- }
1324
- }
1325
- }, ut = class {
1326
- constructor(t, n, r) {
1327
- this.scheduler = t;
1328
- this.run = n;
1329
- this.priority = r;
1330
- }
1331
- scheduler;
1332
- run;
1333
- priority;
1334
- id = Cr++;
1335
- dependencies = void 0;
1336
- flushCount = 0;
1337
- flushId = 0;
1338
- stopped = false;
1339
- paused = false;
1340
- #e = void 0;
1341
- #t = void 0;
1342
- execute() {
1343
- if (this.stopped || this.paused) return;
1344
- this.#t = void 0, this.#e?.(), this.#e = void 0;
1345
- let t = B;
1346
- B = this;
1347
- try {
1348
- this.#e = this.run();
1349
- } finally {
1350
- B = t;
1351
- let n = this.#t, r = n === void 0 ? this.dependencies : n.nextDependency;
1352
- for (n === void 0 ? this.dependencies = void 0 : n.nextDependency = void 0; r !== void 0; ) {
1353
- let i = r.nextDependency;
1354
- Gt(r), r = i;
1355
- }
1356
- }
1357
- }
1358
- track(t) {
1359
- let n = this.#t === void 0 ? this.dependencies : this.#t.nextDependency;
1360
- if (n?.dependency === t) {
1361
- this.#t = n;
1362
- return;
1363
- }
1364
- for (let o = this.dependencies; o !== n; o = o?.nextDependency) if (o?.dependency === t) return;
1365
- let r = { dependency: t, effect: this, nextDependency: n, previousSubscriber: void 0, nextSubscriber: void 0 };
1366
- this.#t === void 0 ? this.dependencies = r : this.#t.nextDependency = r, this.#t = r;
1367
- let i = t.last;
1368
- r.previousSubscriber = i, i === void 0 ? t.first = r : i.nextSubscriber = r, t.last = r;
1369
- }
1370
- schedule() {
1371
- this.paused || this.scheduler.enqueue(this);
1372
- }
1373
- pause() {
1374
- this.stopped || this.paused || (this.paused = true, this.#n(), this.#e?.(), this.#e = void 0);
1375
- }
1376
- resume() {
1377
- this.stopped || !this.paused || (this.paused = false, this.execute());
1378
- }
1379
- stop() {
1380
- this.stopped || (this.stopped = true, this.#n(), this.#e?.(), this.#e = void 0);
1381
- }
1382
- #n() {
1383
- let t = this.dependencies;
1384
- for (; t !== void 0; ) {
1385
- let n = t.nextDependency;
1386
- Gt(t), t = n;
1387
- }
1388
- this.dependencies = void 0, this.#t = void 0;
1389
- }
1390
- };
1391
- function Yt(e) {
1392
- B === void 0 || B.stopped || B.track(e);
1393
- }
1394
- function at(e) {
1395
- for (let t = e?.first; t !== void 0; ) {
1396
- let n = t.nextSubscriber;
1397
- t.effect.schedule(), t = n;
1398
- }
1399
- }
1400
- function X(e, t, n = 1) {
1401
- let r = new ut(e, t, n);
1402
- return r.execute(), r;
1403
- }
1404
- var fe = class e {
1405
- constructor(t = [], n = new dt(), r) {
1406
- this.scheduler = n;
1407
- this.parent = r;
1408
- for (let [i, o] of t) this.#e.set(i, this.#i(o));
1409
- }
1410
- scheduler;
1411
- parent;
1412
- #e = /* @__PURE__ */ new Map();
1413
- #t = /* @__PURE__ */ new Map();
1414
- get size() {
1415
- return new Set(this.keys()).size;
1416
- }
1417
- has(t) {
1418
- return this.#e.has(t) || this.parent?.has(t) === true;
1419
- }
1420
- get(t) {
1421
- if (!this.#e.has(t)) return this.parent?.get(t);
1422
- if (B !== void 0) {
1423
- let n = this.#t.get(t);
1424
- n === void 0 && (n = { first: void 0, last: void 0 }, this.#t.set(t, n)), Yt(n);
1425
- }
1426
- return this.#e.get(t);
1427
- }
1428
- set(t, n) {
1429
- let r = this.#i(n);
1430
- Object.is(this.#e.get(t), r) && this.#e.has(t) || (this.#e.set(t, r), at(this.#t.get(t)));
1431
- }
1432
- fork(t = []) {
1433
- return new e(t, this.scheduler, this);
1434
- }
1435
- entries() {
1436
- return this.#n().entries();
1437
- }
1438
- keys() {
1439
- return this.#n().keys();
1440
- }
1441
- values() {
1442
- return this.#n().values();
1443
- }
1444
- [Symbol.iterator]() {
1445
- return this.entries();
1446
- }
1447
- forEach(t, n) {
1448
- for (let [r, i] of this.entries()) t.call(n, i, r, this);
1449
- }
1450
- #n() {
1451
- return new Map([...Array.from(this.parent?.entries() ?? []), ...Array.from(this.#e)]);
1452
- }
1453
- #i(t) {
1454
- if (t === null || typeof t != "object") return t;
1455
- let n = st.get(t);
1456
- if (n !== void 0) return n;
1457
- let r = new Proxy(t, { get: (i, o, a) => {
1458
- if (B !== void 0) {
1459
- let s = Ae.get(i);
1460
- s === void 0 && (s = /* @__PURE__ */ new Map(), Ae.set(i, s));
1461
- let d = s.get(o);
1462
- d === void 0 && (d = { first: void 0, last: void 0 }, s.set(o, d)), Yt(d);
1463
- }
1464
- return this.#i(Reflect.get(i, o, a));
1465
- }, set: (i, o, a, s) => {
1466
- let d = Reflect.get(i, o, s), u = this.#i(a), c = Reflect.set(i, o, u, s);
1467
- return Object.is(d, u) || at(Ae.get(i)?.get(o)), c;
1468
- }, deleteProperty: (i, o) => {
1469
- let a = Reflect.has(i, o), s = Reflect.deleteProperty(i, o);
1470
- return a && at(Ae.get(i)?.get(o)), s;
1471
- } });
1472
- return st.set(t, r), st.set(r, r), r;
1473
- }
1474
- };
1475
- var Qt = "data-component", te = "data-component-root", ee = "data-slotted", Nr = [[":user-invalid", ":is(:user-invalid, [data-user-invalid])"], [":invalid", ":is(:invalid, [data-invalid])"], [":valid", ":is(:valid, [data-valid])"]], $r = /* @__PURE__ */ new Set(["container", "document", "layer", "media", "scope", "starting-style", "supports"]), Ar = /* @__PURE__ */ new Set(["has", "is", "not", "where"]);
1476
- function lt(e) {
1477
- return e !== void 0 && /[A-Za-z0-9_-]/.test(e);
1478
- }
1479
- function Xt(e, t) {
1480
- let n = 1, r, i = 0;
1481
- for (let o = t + 1; o < e.length; o += 1) {
1482
- let a = e[o];
1483
- if (r !== void 0) {
1484
- a === "\\" ? o += 1 : a === r && (r = void 0);
1485
- continue;
1486
- }
1487
- if (a === '"' || a === "'") {
1488
- r = a;
1489
- continue;
1490
- }
1491
- if (a === "/" && e[o + 1] === "*") {
1492
- let s = e.indexOf("*/", o + 2);
1493
- if (s === -1) return e.length - 1;
1494
- o = s + 1;
1495
- continue;
1496
- }
1497
- if (a === "[") i += 1;
1498
- else if (a === "]") i = Math.max(0, i - 1);
1499
- else if (i === 0 && a === "(") n += 1;
1500
- else if (i === 0 && a === ")" && --n === 0) return o;
1501
- }
1502
- return e.length - 1;
1503
- }
1504
- function en(e) {
1505
- let t = [], n = 0, r = 0, i = 0, o;
1506
- for (let a = 0; a < e.length; a += 1) {
1507
- let s = e[a];
1508
- if (o !== void 0) {
1509
- s === "\\" ? a += 1 : s === o && (o = void 0);
1510
- continue;
1511
- }
1512
- if (s === '"' || s === "'") o = s;
1513
- else if (s === "/" && e[a + 1] === "*") {
1514
- let d = e.indexOf("*/", a + 2);
1515
- if (d === -1) break;
1516
- a = d + 1;
1517
- } else s === "[" ? i += 1 : s === "]" ? i = Math.max(0, i - 1) : i === 0 && s === "(" ? r += 1 : i === 0 && s === ")" ? r = Math.max(0, r - 1) : i === 0 && r === 0 && s === "," && (t.push(e.slice(n, a)), n = a + 1);
1518
- }
1519
- return t.push(e.slice(n)), t;
1520
- }
1521
- function Mr(e) {
1522
- let t = 0, n = 0, r = 0, i;
1523
- for (let o = 0; o < e.length; o += 1) {
1524
- let a = e[o];
1525
- if (i !== void 0) {
1526
- a === "\\" ? o += 1 : a === i && (i = void 0);
1527
- continue;
1528
- }
1529
- if (a === '"' || a === "'") i = a;
1530
- else if (a === "/" && e[o + 1] === "*") {
1531
- let s = e.indexOf("*/", o + 2);
1532
- if (s === -1) return t;
1533
- o = s + 1;
1534
- } else if (a === "[") r += 1;
1535
- else if (a === "]") r = Math.max(0, r - 1);
1536
- else if (r === 0 && a === "(") n += 1;
1537
- else if (r === 0 && a === ")") n = Math.max(0, n - 1);
1538
- else if (r === 0 && n === 0) {
1539
- if (a === ">" || a === "+" || a === "~") t = o + 1;
1540
- else if (/\s/.test(a)) {
1541
- let s = o;
1542
- for (; s + 1 < e.length && /\s/.test(e[s + 1]); ) s += 1;
1543
- e[s + 1] !== void 0 && !/[>+~]/.test(e[s + 1]) && (t = s + 1), o = s;
1544
- }
1545
- }
1546
- }
1547
- for (; t < e.length && /\s/.test(e[t]); ) t += 1;
1548
- return t;
1549
- }
1550
- function Vr(e) {
1551
- let t = 0, n = 0, r;
1552
- for (let i = 0; i < e.length - 1; i += 1) {
1553
- let o = e[i];
1554
- if (r !== void 0) {
1555
- o === "\\" ? i += 1 : o === r && (r = void 0);
1556
- continue;
1557
- }
1558
- if (o === '"' || o === "'") r = o;
1559
- else if (o === "[") n += 1;
1560
- else if (o === "]") n = Math.max(0, n - 1);
1561
- else if (n === 0 && o === "(") t += 1;
1562
- else if (n === 0 && o === ")") t = Math.max(0, t - 1);
1563
- else if (n === 0 && t === 0 && o === ":" && e[i + 1] === ":") return i;
1564
- }
1565
- return e.length;
1566
- }
1567
- function Lr(e, t) {
1568
- let n = `:where([${Qt}~="${t}"])`, r = e.search(/\s*$/), i = e.slice(0, r), o = e.slice(r), a = Mr(i), s = i.slice(a);
1569
- if (s.includes(n)) return e;
1570
- let d = Vr(s);
1571
- return `${i.slice(0, a)}${s.slice(0, d)}${n}${s.slice(d)}${o}`;
1572
- }
1573
- function Hr(e, t, n, r) {
1574
- let i = "", o = true;
1575
- for (let a = 0; a < e.length; ) {
1576
- let s = e[a];
1577
- if (s === '"' || s === "'") {
1578
- let d = s, u = a + 1;
1579
- for (; u < e.length; ) if (e[u] === "\\") u += 2;
1580
- else if (e[u++] === d) break;
1581
- i += e.slice(a, u), a = u;
1582
- continue;
1583
- }
1584
- if (s === "/" && e[a + 1] === "*") {
1585
- let d = e.indexOf("*/", a + 2), u = d === -1 ? e.length : d + 2;
1586
- i += e.slice(a, u), a = u;
1587
- continue;
1588
- }
1589
- if (s === "[") {
1590
- let d = a + 1, u;
1591
- for (; d < e.length; ) {
1592
- let c = e[d];
1593
- if (u !== void 0) c === "\\" ? d += 2 : (c === u && (u = void 0), d += 1);
1594
- else if (c === '"' || c === "'") u = c, d += 1;
1595
- else if (c === "]") {
1596
- d += 1;
1597
- break;
1598
- } else d += 1;
1599
- }
1600
- i += e.slice(a, d), a = d, o = false;
1601
- continue;
1602
- }
1603
- if (s === ":") {
1604
- let d = a + 1;
1605
- for (; lt(e[d]); ) d += 1;
1606
- let u = e.slice(a + 1, d).toLowerCase(), c = false;
1607
- for (let [l, m] of Nr) {
1608
- if (e.startsWith(m, a)) {
1609
- i += m, a += m.length, o = false, c = true;
1610
- break;
1611
- }
1612
- if (e.startsWith(l, a) && !lt(e[a + l.length])) {
1613
- i += m, a += l.length, o = false, c = true;
1614
- break;
1615
- }
1616
- }
1617
- if (c) continue;
1618
- if (u === "scope" && t !== void 0 && n === "attribute") {
1619
- i += `:is(:where([${te}~="${t}"]), ${t})`, a = d, o = false;
1620
- continue;
1621
- }
1622
- if (e[d] === "(") {
1623
- let l = Xt(e, d), m = e.slice(d + 1, l), f = Ar.has(u) ? tn(m, t, n, r, u === "has" && t !== void 0) : m;
1624
- i += `${e.slice(a, d + 1)}${f})`, a = l + 1;
1625
- } else i += e.slice(a, d), a = d;
1626
- o = false;
1627
- continue;
1628
- }
1629
- if (o && /[A-Za-z]/.test(s)) {
1630
- let d = a + 1;
1631
- for (; lt(e[d]); ) d += 1;
1632
- let u = e.slice(a, d), c = u.includes("-") ? `:is(:where([${te}~="${u.toLowerCase()}"]), ${u})` : u;
1633
- i += n === "scope" && u.toLowerCase() === r?.toLowerCase() ? `:is(${c}, :where(:scope))` : c, a = d, o = false;
1634
- continue;
1635
- }
1636
- i += s, a += 1, s === "," || s === ">" || s === "+" || s === "~" || /\s/.test(s) ? o = true : s !== "|" && (o = false);
1637
- }
1638
- return i;
1639
- }
1640
- function tn(e, t, n, r, i) {
1641
- return en(e).map((o) => {
1642
- let a = /^\s*/.exec(o)[0], s = /\s*$/.exec(o)[0], d = o.slice(a.length, o.length - s.length);
1643
- if (d === "") return o;
1644
- let u = Hr(d, t, n, r);
1645
- return `${a}${i && t !== void 0 ? Lr(u, t) : u}${s}`;
1646
- }).join(",");
1647
- }
1648
- function ct(e, t) {
1649
- let n = 1, r;
1650
- for (let i = t + 1; i < e.length; i += 1) {
1651
- let o = e[i];
1652
- if (r !== void 0) {
1653
- o === "\\" ? i += 1 : o === r && (r = void 0);
1654
- continue;
1655
- }
1656
- if (o === '"' || o === "'") r = o;
1657
- else if (o === "/" && e[i + 1] === "*") {
1658
- let a = e.indexOf("*/", i + 2);
1659
- if (a === -1) return e.length - 1;
1660
- i = a + 1;
1661
- } else if (o === "{") n += 1;
1662
- else if (o === "}" && --n === 0) return i;
1663
- }
1664
- return e.length - 1;
1665
- }
1666
- function ft(e, t, n, r) {
1667
- let i = "", o = 0, a, s = 0, d = 0;
1668
- for (let u = 0; u < e.length; u += 1) {
1669
- let c = e[u];
1670
- if (a !== void 0) {
1671
- c === "\\" ? u += 1 : c === a && (a = void 0);
1672
- continue;
1673
- }
1674
- if (c === '"' || c === "'") a = c;
1675
- else if (c === "/" && e[u + 1] === "*") {
1676
- let l = e.indexOf("*/", u + 2);
1677
- if (l === -1) break;
1678
- u = l + 1;
1679
- } else if (c === "(") s += 1;
1680
- else if (c === ")") s = Math.max(0, s - 1);
1681
- else if (c === "[") d += 1;
1682
- else if (c === "]") d = Math.max(0, d - 1);
1683
- else if (s === 0 && d === 0 && c === ";") i += e.slice(o, u + 1), o = u + 1;
1684
- else if (s === 0 && d === 0 && c === "{") {
1685
- let l = ct(e, u), m = e.slice(o, u), f = e.slice(u + 1, l), p = /^\s*@([\w-]+)/.exec(m)?.[1]?.toLowerCase(), h = p === void 0 ? tn(m, t, n, r, t !== void 0 && n === "attribute") : m, v = p === void 0 || $r.has(p) ? ft(f, t, n, r) : f;
1686
- i += `${h}{${v}}`, u = l, o = l + 1;
1687
- }
1688
- }
1689
- return i + e.slice(o);
1690
- }
1691
- function nn(e) {
1692
- return ft(e, void 0, void 0, void 0);
1693
- }
1694
- function Dr(e) {
1695
- let t = "", n = "", r = 0, i, o = 0, a = 0;
1696
- for (let s = 0; s < e.length; s += 1) {
1697
- let d = e[s];
1698
- if (i !== void 0) {
1699
- d === "\\" ? s += 1 : d === i && (i = void 0);
1700
- continue;
1701
- }
1702
- if (d === '"' || d === "'") i = d;
1703
- else if (d === "/" && e[s + 1] === "*") {
1704
- let u = e.indexOf("*/", s + 2);
1705
- if (u === -1) break;
1706
- s = u + 1;
1707
- } else if (d === "(") o += 1;
1708
- else if (d === ")") o = Math.max(0, o - 1);
1709
- else if (d === "[") a += 1;
1710
- else if (d === "]") a = Math.max(0, a - 1);
1711
- else if (o === 0 && a === 0 && d === ";") t += e.slice(r, s + 1), r = s + 1;
1712
- else if (o === 0 && a === 0 && d === "{") {
1713
- let u = ct(e, s), c = e.slice(r, s), l = e.slice(r, u + 1);
1714
- !/^\s*@/.test(c) && c.includes(":slotted(") ? n += l : t += l, s = u, r = u + 1;
1715
- }
1716
- }
1717
- return { normal: t + e.slice(r), slotted: n };
1718
- }
1719
- function Pr(e, t) {
1720
- let n = e.trim();
1721
- if (n.startsWith(">")) {
1722
- let i = n.slice(1).trim();
1723
- return i === "" || i === "*" ? `${t} [${ee}]` : `${t} [${ee}]:is(${i})`;
1724
- }
1725
- let r = `:where([${ee}], [${ee}] *)`;
1726
- return n === "" || n === "*" ? `${t} ${r}` : `${t} ${r}:is(${n})`;
1727
- }
1728
- function jr(e, t) {
1729
- let n = `[${te}~="${t}"]`, r = /^\s*:scope((?:\[[^\]]*\]|:{1,2}[\w-]+(?:\([^)]*\))?|[.#][\w-]+)*)\s+(?=:slotted\()/.exec(e), i = r ? `${n}${r[1]}` : n, o = r ? e.slice(r[0].length) : e, a = "", s = 0;
1730
- for (; ; ) {
1731
- let d = o.indexOf(":slotted(", s);
1732
- if (d === -1) return a += o.slice(s), a;
1733
- a += o.slice(s, d);
1734
- let u = d + 8, c = Xt(o, u);
1735
- a += Pr(o.slice(u + 1, c), i), s = c + 1;
1736
- }
1737
- }
1738
- function Or(e, t) {
1739
- let n = "", r = 0;
1740
- for (let i = 0; i < e.length; i += 1) if (e[i] === "{") {
1741
- let o = ct(e, i), a = e.slice(r, i), s = e.slice(i + 1, o), d = en(a).map((u) => jr(u, t)).join(",");
1742
- n += `${d}{${s}}`, i = o, r = o + 1;
1743
- }
1744
- return n + e.slice(r);
1745
- }
1746
- function Me(e, t, n) {
1747
- if (e === "") return "";
1748
- let { normal: r, slotted: i } = Dr(e), o = ft(r, t, "scope", n), a = o.trim() === "" ? "" : `@scope ([${te}~="${t}"]) to (:scope [${te}] > *, [${ee}]) {
1749
- ${o}
1750
- }`, s = i.trim() === "" ? "" : Or(i, t);
1751
- return [a, s].filter((d) => d !== "").join(`
1752
- `);
1753
- }
1754
- function rn(e, t, n) {
1755
- let r = new Set((e.getAttribute(t) ?? "").split(/\s+/).filter(Boolean));
1756
- r.add(n), e.setAttribute(t, Array.from(r).join(" "));
1757
- }
1758
- function pe(e, t) {
1759
- rn(e, Qt, t);
1760
- }
1761
- function pt(e, t) {
1762
- pe(e, t), rn(e, te, t);
1763
- }
1764
- function Ve(e) {
1765
- e.nodeType === 1 && e.setAttribute(ee, "");
1766
- }
1767
- var mt = { valid: true, errors: [] }, on = 1e-9;
1768
- function Ir(e, t = false) {
1769
- return e == null || e === "" || t && Array.isArray(e) && e.length === 0;
1770
- }
1771
- function zr(e) {
1772
- if (e !== void 0) return typeof e != "string" || ["string", "boolean", "number"].includes(e) ? e : F(e);
1773
- }
1774
- function Ur(e) {
1775
- if (e === void 0) return;
1776
- let t = Q(e);
1777
- return t.kind === "terminal" ? t.name : void 0;
1778
- }
1779
- function sn(e, t) {
1780
- return e.map((n) => ({ reason: n.reason === "schemaMismatch" || n.reason === "untrustedValue" ? n.reason : n.reason === "badInput" && !["email", "url"].includes(t ?? "") ? "badInput" : "typeMismatch", message: n.message, path: n.path }));
1781
- }
1782
- function dn(e, t) {
1783
- if (typeof e == "number" && Number.isFinite(e)) return e;
1784
- if (typeof e == "string") switch (t) {
1785
- case "number":
1786
- case "integer": {
1787
- let n = Number(e);
1788
- return Number.isFinite(n) ? n : void 0;
1789
- }
1790
- case "date": {
1791
- let n = Date.parse(`${e}T00:00:00Z`);
1792
- return Number.isFinite(n) ? n / 864e5 : void 0;
1793
- }
1794
- case "datetime-local": {
1795
- let n = Date.parse(`${e}Z`);
1796
- return Number.isFinite(n) ? n / 1e3 : void 0;
1797
- }
1798
- case "time": {
1799
- let n = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?$/.exec(e);
1800
- return n === null ? void 0 : Number(n[1]) * 3600 + Number(n[2]) * 60 + Number(n[3] ?? 0) + +`0.${n[4] ?? 0}`;
1801
- }
1802
- case "month": {
1803
- let n = /^(\d+)-(\d{2})$/.exec(e);
1804
- return n === null ? void 0 : Number(n[1]) * 12 + Number(n[2]) - 1;
1805
- }
1806
- case "week": {
1807
- let n = /^(\d+)-W(\d{2})$/.exec(e);
1808
- return n === null ? void 0 : Number(n[1]) * 53 + Number(n[2]) - 1;
1809
- }
1810
- default:
1811
- return;
1812
- }
1813
- }
1814
- function an(e, t) {
1815
- return e === void 0 ? void 0 : dn(e, t);
1816
- }
1817
- function un(e, t = {}) {
1818
- if (Ir(e, t.multiple)) return t.required ? { valid: false, errors: [{ reason: "valueMissing", message: "This field is required." }] } : mt;
1819
- let n = [], r = zr(t.type), i = Ur(r), o = e;
1820
- if (i === "email" && t.multiple && typeof e == "string") {
1821
- let u = e.split(",").map((l) => l.trim()), c = u.flatMap((l, m) => {
1822
- let f = j(l, r, `$[${m}]`);
1823
- return f.ok ? [] : sn(f.issues, i);
1824
- });
1825
- n.push(...c), c.length === 0 && (o = u);
1826
- } else if (r !== void 0) {
1827
- let u = j(e, r);
1828
- u.ok ? o = u.value : n.push(...sn(u.issues, i));
1829
- }
1830
- let a = dn(o, i), s = an(t.min, i), d = an(t.max, i);
1831
- if (a !== void 0 && (s !== void 0 && a < s && n.push({ reason: "rangeUnderflow", message: `Value must be at least ${t.min}.` }), d !== void 0 && a > d && n.push({ reason: "rangeOverflow", message: `Value must be at most ${t.max}.` }), t.step !== void 0 && t.step !== "any" && t.step > 0)) {
1832
- let c = Math.abs(a - (s ?? 0)) % t.step;
1833
- c > on && Math.abs(c - t.step) > on && n.push({ reason: "stepMismatch", message: `Value must align to a step of ${t.step}.` });
1834
- }
1835
- if (typeof e == "string" && (t.minLength !== void 0 && e.length < t.minLength && n.push({ reason: "tooShort", message: `Use at least ${t.minLength} characters.` }), t.maxLength !== void 0 && e.length > t.maxLength && n.push({ reason: "tooLong", message: `Use no more than ${t.maxLength} characters.` }), t.pattern !== void 0)) {
1836
- let u;
1837
- try {
1838
- u = new RegExp(`^(?:${t.pattern})$`, "v");
1839
- } catch {
1840
- try {
1841
- u = new RegExp(`^(?:${t.pattern})$`, "u");
1842
- } catch {
1843
- u = void 0;
1844
- }
1845
- }
1846
- u !== void 0 && !u.test(e) && n.push({ reason: "patternMismatch", message: "Value does not match the required format." });
1847
- }
1848
- return n.length === 0 ? mt : { valid: false, errors: n };
1849
- }
1850
- var qr = ["valueMissing", "typeMismatch", "patternMismatch", "tooLong", "tooShort", "rangeUnderflow", "rangeOverflow", "stepMismatch", "badInput", "customError"];
1851
- function yt(e, t) {
1852
- if (e.valid) return mt;
1853
- let n = qr.filter((r) => e[r]).map((r) => ({ reason: r, message: t || _r(r) }));
1854
- return n.length === 0 ? { valid: false, errors: [{ reason: "badInput", message: t || "The value is invalid." }] } : { valid: false, errors: n };
1855
- }
1856
- function _r(e) {
1857
- return { valueMissing: "This field is required.", typeMismatch: "Enter a value in the required format.", patternMismatch: "Value does not match the required format.", tooLong: "The value is too long.", tooShort: "The value is too short.", rangeUnderflow: "The value is below the allowed range.", rangeOverflow: "The value is above the allowed range.", stepMismatch: "The value does not align to the required step.", badInput: "The browser could not parse this value.", customError: "The application marked this value invalid.", schemaMismatch: "The value does not match its schema.", untrustedValue: "The value did not cross an approved trust boundary." }[e];
1858
- }
1859
- function ln(e) {
1860
- return nn(e);
1861
- }
1862
- var He = { valid: true, errors: [] }, I = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new WeakMap(), gt = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakSet(), ne = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap();
1863
- function cn(e, t) {
1864
- let n = [...e.errors, ...t];
1865
- return n.length === 0 ? He : { valid: false, errors: n };
1866
- }
1867
- function he(e) {
1868
- return ["button", "fieldset", "input", "object", "output", "select", "textarea"].includes(e.localName) && "validity" in e && "validationMessage" in e && typeof e.checkValidity == "function" && typeof e.setCustomValidity == "function";
1869
- }
1870
- function ie(e) {
1871
- let t = I.get(e);
1872
- if (t !== void 0) return cn(t.derived, t.external);
1873
- let n = me.get(e), r = vt.get(e) ?? [];
1874
- return n !== void 0 || r.length > 0 ? cn(n ?? He, r) : he(e) ? yt(e.validity, e.validationMessage) : He;
1875
- }
1876
- function hn(e) {
1877
- let t = new Set(e.errors.map((n) => n.reason));
1878
- return Object.freeze({ valid: e.valid, valueMissing: t.has("valueMissing"), typeMismatch: t.has("typeMismatch"), patternMismatch: t.has("patternMismatch"), tooLong: t.has("tooLong"), tooShort: t.has("tooShort"), rangeUnderflow: t.has("rangeUnderflow"), rangeOverflow: t.has("rangeOverflow"), stepMismatch: t.has("stepMismatch"), badInput: t.has("badInput"), customError: t.has("customError"), schemaMismatch: t.has("schemaMismatch"), untrustedValue: t.has("untrustedValue"), errors: e.errors });
1879
- }
1880
- function gn(e) {
1881
- return e.valid ? "" : e.errors[0].message;
1882
- }
1883
- function Fr(e) {
1884
- let t = hn(e);
1885
- return { valueMissing: t.valueMissing, typeMismatch: t.typeMismatch || t.schemaMismatch || t.untrustedValue, patternMismatch: t.patternMismatch, tooLong: t.tooLong, tooShort: t.tooShort, rangeUnderflow: t.rangeUnderflow, rangeOverflow: t.rangeOverflow, stepMismatch: t.stepMismatch, badInput: t.badInput, customError: t.customError };
1886
- }
1887
- function ye(e, t) {
1888
- let n = ie(e), r = gn(n);
1889
- if (he(e)) {
1890
- if (t === void 0 || t.external.length > 0 || Object.keys(t.constraint).length > 0) e.setCustomValidity(r), r === "" ? re.delete(e) : re.set(e, r);
1891
- else {
1892
- let o = re.get(e);
1893
- o !== void 0 && e.validationMessage === o && e.setCustomValidity(""), re.delete(e);
1894
- }
1895
- e.removeAttribute("data-valid"), e.removeAttribute("data-invalid"), e.removeAttribute("data-user-invalid");
1896
- return;
1897
- } else t?.internals !== void 0 && t.internals.setValidity(n.valid ? {} : Fr(n), r);
1898
- n.valid ? (e.removeAttribute("data-invalid"), e.setAttribute("data-valid", ""), Le.has(e) && (e.removeAttribute("aria-invalid"), Le.delete(e))) : (e.removeAttribute("data-valid"), e.setAttribute("data-invalid", ""), (!e.hasAttribute("aria-invalid") || Le.has(e)) && (e.setAttribute("aria-invalid", "true"), Le.add(e))), t?.interacted === true && !n.valid ? e.setAttribute("data-user-invalid", "") : e.removeAttribute("data-user-invalid");
1899
- }
1900
- function Wr(e, t, n) {
1901
- let r = [], i = /* @__PURE__ */ new Set([...Array.from(e.styleSheets), ...Array.from(e.adoptedStyleSheets ?? [])]);
1902
- for (let o of i) if (o.ownerNode !== t) try {
1903
- let a = Array.from(o.cssRules, (d) => d.cssText).join(`
1904
- `), s = ln(a);
1905
- s !== a && r.push(s);
1906
- } catch {
1907
- n.has(o) || (n.add(o), e.dispatchEvent(new CustomEvent("htmlnextdiagnostic", { detail: { code: "HV001", message: "A stylesheet containing validity selectors could not be read. Transform cross-origin CSS with rewriteValiditySelectors() during the package build." } })));
1908
- }
1909
- return r.join(`
1910
- `);
1911
- }
1912
- function bn(e, t) {
1913
- t.queued = false;
1914
- let n = Wr(e, t.companion, t.inaccessible);
1915
- t.companion.textContent !== n && (t.companion.textContent = n);
1916
- }
1917
- function bt(e) {
1918
- let t = gt.get(e);
1919
- t === void 0 || t.queued || (t.queued = true, queueMicrotask(() => bn(e, t)));
1920
- }
1921
- var fn = /* @__PURE__ */ new WeakSet();
1922
- function Br(e) {
1923
- let t = e.defaultView?.CSSStyleSheet?.prototype;
1924
- if (!(t === void 0 || fn.has(t))) {
1925
- fn.add(t);
1926
- for (let n of ["insertRule", "deleteRule", "replace", "replaceSync"]) {
1927
- let r = t[n];
1928
- typeof r == "function" && Object.defineProperty(t, n, { configurable: true, writable: true, value: function(...i) {
1929
- let o = r.apply(this, i), a = () => {
1930
- (Array.from(e.styleSheets).includes(this) || Array.from(e.adoptedStyleSheets ?? []).includes(this)) && bt(e);
1931
- };
1932
- return o instanceof Promise ? o.finally(a) : a(), o;
1933
- } });
1934
- }
1935
- }
1936
- }
1937
- function Zr(e) {
1938
- if (gt.has(e)) return;
1939
- let t = e.createElement("style");
1940
- t.setAttribute("data-html-next-validity-styles", ""), e.head.append(t);
1941
- let n, r = new MutationObserver((i) => {
1942
- if (!i.every((o) => o.target === t || t.contains(o.target))) {
1943
- for (let o of Array.from(e.querySelectorAll("link[rel=stylesheet]"))) o.addEventListener("load", () => bt(e), { once: true });
1944
- bt(e);
1945
- }
1946
- });
1947
- n = { companion: t, observer: r, queued: false, inaccessible: /* @__PURE__ */ new WeakSet() }, r.observe(e.head, { childList: true, subtree: true, characterData: true, attributes: true }), gt.set(e, n), Br(e), bn(e, n);
1948
- }
1949
- function Jr(e) {
1950
- return e instanceof HTMLInputElement ? e.type === "checkbox" || e.type === "radio" ? e.checked : e.value : e instanceof HTMLSelectElement ? e.multiple ? Array.from(e.selectedOptions, (t) => t.value) : e.value : e instanceof HTMLTextAreaElement ? e.value : e.value ?? e.getAttribute("data-value") ?? e.getAttribute("value");
1951
- }
1952
- function Kr(e) {
1953
- return hn(ie(e));
1954
- }
1955
- function Gr(e) {
1956
- return gn(ie(e));
1957
- }
1958
- function pn(e, t) {
1959
- let n = typeof t == "string" ? t === "" ? [] : [{ reason: "customError", message: t }] : t;
1960
- vt.set(e, n);
1961
- let r = I.get(e);
1962
- r !== void 0 && (r.external = n), ye(e, r);
1963
- }
1964
- function Yr(e, t) {
1965
- t.valid || e.dispatchEvent(new Event("invalid", { cancelable: true }));
1966
- }
1967
- function De(e, t) {
1968
- if (he(e) && Object.keys(t.constraint).length === 0) {
1969
- let n = re.get(e);
1970
- return n !== void 0 && e.validationMessage === n && e.setCustomValidity(""), re.delete(e), yt(e.validity, e.validationMessage);
1971
- }
1972
- return un(t.value(), t.constraint);
1973
- }
1974
- function Pe(e, t, n) {
1975
- let r = I.get(e);
1976
- r !== void 0 && (t && (r.interacted = true), r.derived = De(e, r), me.set(e, r.derived)), ye(e, r);
1977
- let i = ie(e);
1978
- return n && Yr(e, i), i.valid;
1979
- }
1980
- function Qr(e, t) {
1981
- let n = e.closest("form");
1982
- if (!(n instanceof HTMLFormElement)) return;
1983
- let r = ne.get(n);
1984
- if (r === void 0) {
1985
- r = /* @__PURE__ */ new Set(), ne.set(n, r);
1986
- let i = (a) => {
1987
- let s;
1988
- for (let d of ne.get(n) ?? []) d.isConnected && (Pe(d, true, true) || (s ??= d));
1989
- s !== void 0 && (a.preventDefault(), s.focus?.());
1990
- }, o = () => {
1991
- queueMicrotask(() => {
1992
- for (let a of ne.get(n) ?? []) {
1993
- let s = I.get(a);
1994
- s !== void 0 && (s.interacted = false, s.derived = De(a, s), me.set(a, s.derived), ye(a, s));
1995
- }
1996
- });
1997
- };
1998
- n.addEventListener("submit", i, true), n.addEventListener("reset", o), ht.set(n, () => {
1999
- n.removeEventListener("submit", i, true), n.removeEventListener("reset", o);
2000
- });
2001
- }
2002
- r.add(e), t.cleanup.push(() => {
2003
- let i = ne.get(n);
2004
- i?.delete(e), i?.size === 0 && (ht.get(n)?.(), ht.delete(n), ne.delete(n));
2005
- });
2006
- }
2007
- function mn(e) {
2008
- let t = e, n = {};
2009
- "validity" in t || (n.validity = { configurable: true, get: () => Kr(e) }), "validationMessage" in t || (n.validationMessage = { configurable: true, get: () => Gr(e) }), "willValidate" in t || (n.willValidate = { configurable: true, get: () => true }), "checkValidity" in t || (n.checkValidity = { configurable: true, value: () => Pe(e, false, true) }), "reportValidity" in t || (n.reportValidity = { configurable: true, value: () => Pe(e, true, true) }), "setCustomValidity" in t || (n.setCustomValidity = { configurable: true, value: (r) => pn(e, r) }), "setValidity" in t || (n.setValidity = { configurable: true, value: (r = []) => pn(e, r) }), "validate" in t || (n.validate = { configurable: true, value: () => he(e) && I.get(e) === void 0 ? (e.checkValidity(), ie(e)) : Xr(e, I.get(e)?.constraint ?? {}) }), Object.defineProperties(t, n);
2010
- }
2011
- function kt(e, t = {}, n = {}) {
2012
- if (yn(e), he(e) && Object.keys(t).length === 0 && n.value === void 0 && n.internals === void 0) return mn(e), () => {
2013
- };
2014
- let r = { constraint: t, derived: He, external: vt.get(e) ?? [], interacted: false, value: n.value ?? (() => Jr(e)), ...n.internals === void 0 ? {} : { internals: n.internals }, cleanup: [] };
2015
- I.set(e, r), Zr(e.ownerDocument), mn(e);
2016
- let i = () => {
2017
- r.interacted = true, r.derived = De(e, r), me.set(e, r.derived), ye(e, r);
2018
- };
2019
- return e.addEventListener("input", i), e.addEventListener("change", i), e.addEventListener("blur", i, true), r.cleanup.push(() => e.removeEventListener("input", i), () => e.removeEventListener("change", i), () => e.removeEventListener("blur", i, true)), Qr(e, r), r.derived = De(e, r), me.set(e, r.derived), ye(e, r), () => yn(e);
2020
- }
2021
- function yn(e) {
2022
- let t = I.get(e);
2023
- if (t !== void 0) {
2024
- for (let n of t.cleanup) n();
2025
- I.delete(e);
2026
- }
2027
- }
2028
- function Xr(e, t) {
2029
- let n = I.get(e);
2030
- return n === void 0 ? (kt(e, t ?? {}), n = I.get(e)) : t !== void 0 && (n.constraint = t), Pe(e, true, true), ie(e);
2031
- }
2032
- var je = /* @__PURE__ */ new WeakSet(), xn = /* @__PURE__ */ new WeakMap(), vn = /* @__PURE__ */ new WeakMap(), ei = /* @__PURE__ */ Symbol.for("@nextwebwg/declarative-components.runtime.v1"), Y = /* @__PURE__ */ Symbol.for("@nextwebwg/declarative-components.lifecycle.v1");
2033
- function Ie(e) {
2034
- return e[ei] ??= {};
2035
- }
2036
- function J(e) {
2037
- return xn.get(e);
2038
- }
2039
- function ke(e) {
2040
- let t = Ie(e), n = t.registry;
2041
- return (n === void 0 || n.root !== e.documentElement) && (n = { root: e.documentElement, definitions: /* @__PURE__ */ new Map(), discoverySelector: void 0 }, t.registry = n), n;
2042
- }
2043
- function ze(e, t, n) {
2044
- e.definitions.set(t, n), e.discoverySelector !== void 0 && (e.discoverySelector += `,${t}`);
2045
- }
2046
- function ti(e) {
2047
- return e.discoverySelector ??= ["template[component]", "[data-component-root]", ...Array.from(e.definitions.keys())].join(",");
2048
- }
2049
- function ni(e, t) {
2050
- let n = e.getAttribute("component") ?? "", r = `${e.ownerDocument.URL}#template[component="${n}"][${t + 1}]`;
2051
- e.hasAttribute("src") && y("HL001", "External definitions require the application-owned graph resolver.", r);
2052
- let i = Jt(e, r), o = Array.from(e.content.children).find((a) => a.localName === "style");
2053
- return { wrapper: e, style: o, definition: i };
2054
- }
2055
- function ri(e, t = document) {
2056
- let n = ke(t), r = 0;
2057
- for (let i of e.nodes.values()) {
2058
- if (i.shadowedByCustomElement) continue;
2059
- let o = i.definition.contract.tag;
2060
- n.definitions.has(o) && y("HR001", `More than one definition declares <${o}>.`);
2061
- let a = i.definition.css === "" ? void 0 : t.createElement("style");
2062
- a !== void 0 && (a.textContent = Me(i.definition.css, o, i.definition.template.name), a.dataset.htmlNextComponent = o, t.head.append(a)), ze(n, o, { definition: i.definition, style: a }), r += 1;
2063
- }
2064
- return r;
2065
- }
2066
- function Oe(e, t, n = false) {
2067
- let r = e.type === "boolean" && n ? true : t, i = j(r, e.type);
2068
- if (!i.ok) {
2069
- let o = i.issues.map((a) => `${a.path}: ${a.message}`).join("; ");
2070
- y("HR002", `A prop invocation value does not satisfy its declared type. ${o}`);
2071
- }
2072
- return i.value;
2073
- }
2074
- function kn(e, t, n) {
2075
- return n !== void 0 ? Oe(t, n) : (t.required && y("HC020", `Required prop \`${e}\` was not provided.`), t.default === void 0 ? x : t.default);
2076
- }
2077
- function ii(e, t) {
2078
- let n = vn.get(e);
2079
- if (n === void 0) {
2080
- let r = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null);
2081
- for (let o of Object.keys(e.contract.props)) {
2082
- let a = Ee(o);
2083
- r[a] = o, i[`data-${a}`] = o, a !== o.toLowerCase() && (i[`data-${o.toLowerCase()}`] = o);
2084
- }
2085
- n = [r, i], vn.set(e, n);
2086
- }
2087
- return n[t ? 1 : 0];
2088
- }
2089
- function oi(e, t, n = false) {
2090
- let r = t.contract, i = ii(t, n), o = /* @__PURE__ */ Object.create(null), a = [], s;
2091
- for (let f of Array.from(e.attributes)) {
2092
- if (f.name.toLowerCase() === "as" && t.root?.kind === "native") {
2093
- s = f.value.toLowerCase();
2094
- continue;
2095
- }
2096
- let p = i[f.name.toLowerCase()];
2097
- if (p === void 0) {
2098
- n || a.push(f);
2099
- continue;
2100
- }
2101
- o[p] = Oe(r.props[p], f.value, !n);
2102
- }
2103
- let d = t.root?.kind === "native" ? n ? e.localName : s ?? t.root.element : t.template.name;
2104
- t.root?.kind === "native" && !t.root.choices.includes(d) && y(n ? "HR005" : "HR002", `<${r.tag}> cannot use root <${d}>; expected one of ${t.root.choices.join(", ")}.`);
2105
- for (let [f, p] of Object.entries(r.props)) {
2106
- if (o[f] !== void 0 || n && !Object.hasOwn(e, f)) continue;
2107
- let h = e[f];
2108
- h !== void 0 && (o[f] = Oe(p, h));
2109
- }
2110
- let u = new fe();
2111
- for (let [f, p] of Object.entries(r.props)) p.required && o[f] === void 0 && y("HC020", `Required prop \`${f}\` was not provided.`), u.set(f, o[f] !== void 0 ? o[f] : p.default === void 0 ? x : p.default);
2112
- let c = t.declarations ?? [];
2113
- for (let f of c) (f.kind === "state" || f.kind === "computed" || f.kind === "data") && u.set(f.name, null);
2114
- for (let f of c) f.kind === "data" ? u.set(f.name, { pending: true, value: null, error: null, ok: false }) : f.kind === "state" && u.set(f.name, f.expression === void 0 ? null : $(f.expression.source, u));
2115
- let l = [];
2116
- for (let f of c) f.kind !== "computed" || f.expression === void 0 || l.push(X(u.scheduler, () => {
2117
- u.set(f.name, $(f.expression.source, u));
2118
- }, 0));
2119
- let m = (() => {
2120
- try {
2121
- return new URL(t.source.file, e.ownerDocument.baseURI).href;
2122
- } catch {
2123
- return e.ownerDocument.baseURI;
2124
- }
2125
- })();
2126
- for (let f of c) {
2127
- if (f.kind !== "data" || f.source === void 0) continue;
2128
- let p = f, h = f.source, v = new $e({ source: h, baseURL: m, ...p.type === void 0 ? {} : { type: p.type }, ...p.schema === void 0 || /^(?:\.?\.?\/|\/|[A-Za-z][A-Za-z+.-]*:)/.test(p.schema) ? {} : { schema: p.schema }, ...p.schema !== void 0 && /^(?:\.?\.?\/|\/|[A-Za-z][A-Za-z+.-]*:)/.test(p.schema) ? { schemaURL: new URL(p.schema, m).href } : {}, ...p.debounce === void 0 ? {} : { debounce: Number(p.debounce) }, ...p.poll === void 0 ? {} : { poll: Number(p.poll) }, onState: (S) => u.set(p.name, S) });
2129
- l.push(X(u.scheduler, () => {
2130
- let S = Object.fromEntries(p.parameters.map((w) => [w.name, W(w.expression, u)]));
2131
- return v.update(S), () => v.disconnect();
2132
- }, 0));
2133
- }
2134
- return { scope: u, passThrough: a, effects: l, rootName: d };
2135
- }
2136
- function be(e, t) {
2137
- return e instanceof fe ? e.fork(Object.entries(t)) : new Map([...Array.from(e), ...Object.entries(t)]);
2138
- }
2139
- function $(e, t) {
2140
- try {
2141
- return Pt(e, t);
2142
- } catch (n) {
2143
- throw n instanceof ae && y("HB001", n.message), n;
2144
- }
2145
- }
2146
- function Z(e, t, n, r = 1) {
2147
- e.effects.push(X(t.scheduler, n, r));
2148
- }
2149
- function Sn(e, t, n) {
2150
- let [r, ...i] = t;
2151
- if (typeof r != "string") return;
2152
- if (i.length === 0) {
2153
- e.set(r, n);
2154
- return;
2155
- }
2156
- let o = e.get(r);
2157
- for (let d = 0; d < i.length - 1; d += 1) {
2158
- let u = i[d], c = typeof u == "object" ? W(u.expression, e) : u;
2159
- if (typeof c != "string" && typeof c != "number" || o == null) return;
2160
- o = o[c];
2161
- }
2162
- let a = i.at(-1), s = typeof a == "object" ? W(a.expression, e) : a;
2163
- (typeof s == "string" || typeof s == "number") && o != null && (o[s] = n);
2164
- }
2165
- function si(e) {
2166
- return e instanceof HTMLInputElement ? e.type === "checkbox" || e.type === "radio" ? e.checked : e.type === "number" || e.type === "range" ? Number.isNaN(e.valueAsNumber) ? null : e.valueAsNumber : e.value : e instanceof HTMLSelectElement ? e.multiple ? Array.from(e.selectedOptions, (t) => t.value) : e.value : e instanceof HTMLTextAreaElement ? e.value : e.value ?? e.getAttribute("value");
2167
- }
2168
- function ai(e, t, n) {
2169
- let r = t.toLowerCase();
2170
- if (r === "checked" && e instanceof HTMLInputElement) return e.checked = D(n), true;
2171
- if (r === "value" && e instanceof HTMLSelectElement && e.multiple) {
2172
- let i = new Set(Array.isArray(n) ? n.map(String) : []);
2173
- for (let o of Array.from(e.options)) o.selected = i.has(o.value);
2174
- return true;
2175
- }
2176
- return r === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) ? (e.value = n == null ? "" : String(n), true) : false;
2177
- }
2178
- function di(e, t, n, r) {
2179
- for (let i of e.steps) if (!(i.guard !== void 0 && !D(W(i.guard, n)))) if (i.kind === "set") Sn(n, i.writablePath, W(i.value, n));
2180
- else if (i.kind === "dispatch") {
2181
- let o = (r.definition.declarations ?? []).find((s) => s.kind === "event" && s.name === i.event), a = i.value === void 0 ? void 0 : W(i.value, n);
2182
- o?.kind === "event" && a !== void 0 && (j(a, F(o.type)).ok || y("HR002", `Event \`${i.event}\` detail does not satisfy its declared type.`)), (r.root ?? t).dispatchEvent(new CustomEvent(i.event, { detail: a, bubbles: o?.kind === "event" ? o.bubbles : true, composed: o?.kind === "event" ? o.composed : true, cancelable: o?.kind === "event" ? o.cancelable : false }));
2183
- } else {
2184
- let o = r.refs[i.target];
2185
- i.kind === "focus" ? o?.focus() : o?.reportValidity?.();
2186
- }
2187
- }
2188
- function ui(e, t, n) {
2189
- if (n.includes("self") && e.target !== t) return false;
2190
- if (e instanceof MouseEvent) {
2191
- let i = n.filter((a) => ["left", "middle", "right"].includes(a)), o = { left: 0, middle: 1, right: 2 };
2192
- if (i.length > 0 && !i.some((a) => e.button === o[a])) return false;
2193
- }
2194
- let r = ["ctrl", "shift", "alt", "meta"];
2195
- for (let i of r) if (n.includes(i) && !e[`${i}Key`]) return false;
2196
- if (n.includes("exact") && r.some((i) => !n.includes(i) && e[`${i}Key`])) return false;
2197
- if (e instanceof KeyboardEvent) {
2198
- let i = n.filter((a) => ["enter", "escape", "space", "tab", "up", "down", "left", "right"].includes(a)), o = { enter: "Enter", escape: "Escape", space: " ", tab: "Tab", up: "ArrowUp", down: "ArrowDown", left: "ArrowLeft", right: "ArrowRight" };
2199
- if (i.length > 0 && !i.some((a) => e.key === o[a])) return false;
2200
- }
2201
- return true;
2202
- }
2203
- function wn(e, t, n, r) {
2204
- for (let i of t.events ?? []) {
2205
- let o = (r.definition.declarations ?? []).find((s) => s.kind === "handler" && s.name === i.handler), a = (s) => {
2206
- ui(s, e, i.modifiers) && (i.modifiers.includes("prevent") && s.preventDefault(), i.modifiers.includes("stop") && s.stopPropagation(), di(o, e, n, r));
2207
- };
2208
- if (i.name === "connect" || i.name === "disconnect") {
2209
- (i.name === "connect" ? r.connectCallbacks : r.disconnectCallbacks).add(() => a(new Event(i.name)));
2210
- continue;
2211
- }
2212
- Z(r, n, () => (e.addEventListener(i.name, a, { capture: i.modifiers.includes("capture"), passive: i.modifiers.includes("passive"), once: i.modifiers.includes("once") }), () => e.removeEventListener(i.name, a, { capture: i.modifiers.includes("capture") })), 2);
2213
- }
2214
- }
2215
- function li(e, t, n) {
2216
- n === null || ue(t) && de(n) ? e.removeAttribute(t) : e.setAttribute(t, n);
2217
- }
2218
- function ci(e, t, n, r) {
2219
- let i = $(t.expression, n);
2220
- t.name === "value" ? e.textContent = L(i) : e.replaceChildren(Qe(L(i), r, (o) => je.add(o)));
2221
- }
2222
- function fi(e, t, n) {
2223
- let r = $(e.expression, t);
2224
- return e.name === "value" ? n.createTextNode(L(r)) : Qe(L(r), n, (i) => je.add(i));
2225
- }
2226
- function pi(e, t) {
2227
- return typeof e == "number" && typeof t == "number" ? e - t : L(e).localeCompare(L(t));
2228
- }
2229
- function Tn(e, t, n) {
2230
- let r = e.slice();
2231
- if (t.where !== void 0) {
2232
- let i = t.where;
2233
- r = r.filter((o) => D($(i, be(n, { [t.item]: o }))));
2234
- }
2235
- if (t.sort !== void 0) {
2236
- let i = t.sort.split(",").map((a) => a.trim()).filter((a) => a !== ""), o = (a, s) => a !== null && typeof a == "object" && !Array.isArray(a) ? $(`${t.item}.${s}`, be(n, { [t.item]: a })) : a;
2237
- r.sort((a, s) => {
2238
- for (let d of i) {
2239
- let u = d.startsWith("-"), c = u ? d.slice(1).trim() : d, l = pi(o(a, c), o(s, c));
2240
- if (l !== 0) return u ? -l : l;
2241
- }
2242
- return 0;
2243
- });
2244
- }
2245
- if (t.limit !== void 0) {
2246
- let i = $(t.limit, n);
2247
- typeof i == "number" && (r = r.slice(0, Math.max(0, Math.trunc(i))));
2248
- }
2249
- return r;
2250
- }
2251
- function mi(e, t) {
2252
- if (e === void 0) return [t];
2253
- switch (e.kind) {
2254
- case "if":
2255
- return D($(e.test, t)) ? [t] : [];
2256
- case "with":
2257
- return [be(t, { [e.alias]: $(e.expr, t) })];
2258
- case "each": {
2259
- let n = $(e.list, t);
2260
- if (!Array.isArray(n)) return [];
2261
- let r = Tn(n, e, t);
2262
- return r.map((i, o) => {
2263
- let a = { [e.item]: i, loop: { index: o, first: o === 0, last: o === r.length - 1, count: r.length } };
2264
- return e.index !== void 0 && (a[e.index] = o), be(t, a);
2265
- });
2266
- }
2267
- default:
2268
- return [t];
2269
- }
2270
- }
2271
- function Cn(e, t) {
2272
- let n = t.createDocumentFragment();
2273
- return n.append(...e), Array.from(n.childNodes);
2274
- }
2275
- function yi(e, t) {
2276
- let n = e.nextSibling;
2277
- for (; n !== null && n !== t; ) {
2278
- let r = n.nextSibling;
2279
- n.remove(), n = r;
2280
- }
2281
- }
2282
- function hi(e, t, n, r, i) {
2283
- if (e.flow?.kind === "each") return ki(e, t, n, r, i);
2284
- let o = n.createComment("html-next:start"), a = n.createComment("html-next:end"), s = n.createDocumentFragment();
2285
- s.append(o, a);
2286
- let d = [];
2287
- return Z(i, t, () => {
2288
- for (let l of d) l.stop();
2289
- d = [], yi(o, a);
2290
- let u = i.effects.length, c = [];
2291
- if (e.flow?.kind === "if") {
2292
- if (D($(e.flow.test, t))) {
2293
- let { flow: l, ...m } = e;
2294
- c = ve(m, t, n, r, i);
2295
- }
2296
- } else if (e.flow?.kind === "with") {
2297
- let l = t.fork([[e.flow.alias, $(e.flow.expr, t)]]), { flow: m, ...f } = e;
2298
- c = ve(f, l, n, r, i);
2299
- } else e.flow?.kind === "match" && (c = wi(e, t, n, i));
2300
- d = i.effects.slice(u), a.before(...Cn(c, n));
2301
- }), [s];
2302
- }
2303
- function gi(e, t) {
2304
- if (e.end.nextSibling === t) return;
2305
- let n = [], r = e.start;
2306
- for (; r !== null && (n.push(r), r !== e.end); ) r = r.nextSibling;
2307
- let i = t.parentNode;
2308
- if (i === null) return;
2309
- let o = i.moveBefore;
2310
- for (let a of n) o === void 0 ? i.insertBefore(a, t) : o.call(i, a, t);
2311
- }
2312
- function bi(e) {
2313
- for (let n of e.effects) n.stop();
2314
- let t = e.start;
2315
- for (; t !== null; ) {
2316
- let n = t.nextSibling;
2317
- if (t.parentNode?.removeChild(t), t === e.end) break;
2318
- t = n;
2319
- }
2320
- }
2321
- function vi(e) {
2322
- let t = -1, n = true;
2323
- for (let s of e) s < 0 || (s < t && (n = false), t = s);
2324
- if (n) return;
2325
- let r = [], i = new Int32Array(e.length).fill(-1);
2326
- for (let s = 0; s < e.length; s += 1) {
2327
- let d = e[s];
2328
- if (d < 0) continue;
2329
- let u = 0, c = r.length;
2330
- for (; u < c; ) {
2331
- let l = u + c >>> 1;
2332
- e[r[l]] < d ? u = l + 1 : c = l;
2333
- }
2334
- u > 0 && (i[s] = r[u - 1]), r[u] = s;
2335
- }
2336
- let o = new Uint8Array(e.length), a = r.at(-1) ?? -1;
2337
- for (; a >= 0; ) o[a] = 1, a = i[a];
2338
- return o;
2339
- }
2340
- function ki(e, t, n, r, i) {
2341
- let o = e.flow, a = n.createComment("html-next:each-start"), s = n.createComment("html-next:each-end"), d = n.createDocumentFragment();
2342
- d.append(a, s);
2343
- let u = /* @__PURE__ */ new Map();
2344
- return Z(i, t, () => {
2345
- let c = $(o.list, t), l = Array.isArray(c) ? Tn(c, o, t) : [], m = /* @__PURE__ */ new Map(), f = o.key !== void 0, p = f ? [] : void 0, h;
2346
- if (f) {
2347
- h = /* @__PURE__ */ new Map();
2348
- let g = 0;
2349
- for (let b of u.keys()) h.set(b, g++);
2350
- }
2351
- let v = f ? [] : void 0, { flow: S, ...w } = e;
2352
- for (let g = 0; g < l.length; g += 1) {
2353
- let b = l[g], E = { [o.item]: b, loop: { index: g, first: g === 0, last: g === l.length - 1, count: l.length } };
2354
- o.index !== void 0 && (E[o.index] = g);
2355
- let A, P = g;
2356
- o.key !== void 0 && (A = t.fork(Object.entries(E)), P = $(o.key, A)), m.has(P) && y("HR004", `A keyed list produced duplicate key \`${L(P)}\`.`);
2357
- let H = u.get(P);
2358
- if (H === void 0) {
2359
- A ??= t.fork(Object.entries(E));
2360
- let V = i.effects.length, we = Cn(ve(w, A, n, r, i), n), Ct = n.createComment("html-next:item-start"), Rt = n.createComment("html-next:item-end");
2361
- s.before(Ct, ...we, Rt), H = { start: Ct, end: Rt, scope: A, effects: i.effects.slice(V) };
2362
- } else H.scope.set(o.item, b), o.index !== void 0 && H.scope.set(o.index, g), H.scope.set("loop", E.loop);
2363
- m.set(P, H), p?.push(H), v?.push(h?.get(P) ?? -1);
2364
- }
2365
- for (let [g, b] of u) m.has(g) || bi(b);
2366
- if (p !== void 0 && v !== void 0) {
2367
- let g = vi(v), b = s;
2368
- for (let E = p.length - 1; E >= 0; E -= 1) {
2369
- let A = p[E];
2370
- (v[E] < 0 || g !== void 0 && g[E] !== 1) && gi(A, b), b = A.start;
2371
- }
2372
- }
2373
- u = m;
2374
- }), [d];
2375
- }
2376
- function Rn(e, t, n, r, i, o) {
2377
- if (e.flow?.kind === "if" || e.flow?.kind === "each" || e.flow?.kind === "with" || e.flow?.kind === "match") {
2378
- if (i.committed && i.root?.getAttribute("data-looma-managed") === "framework" && o !== void 0) return [o];
2379
- return hi(e, t, n, r, i);
2380
- }
2381
- let a = [];
2382
- for (let s of mi(e.flow, t)) a.push(...ve(e, s, n, r, i, o));
2383
- return a;
2384
- }
2385
- function wi(e, t, n, r) {
2386
- let i = e.flow, o = i.expr !== void 0 ? be(t, { [i.alias]: $(i.expr, t) }) : t, a;
2387
- for (let l of e.children) if (l.kind === "element") {
2388
- if (l.flow?.kind === "when" && D($(l.flow.test, o))) {
2389
- a = l;
2390
- break;
2391
- }
2392
- if (l.flow?.kind === "else") {
2393
- a = l;
2394
- break;
2395
- }
2396
- }
2397
- if (a === void 0) return [];
2398
- let { flow: s, ...d } = a, u = ve(d, o, n, [], r);
2399
- if (e.name === "template") return u;
2400
- let c = n.createElement(e.name);
2401
- for (let l of e.attributes) l.kind === "literal" && c.setAttribute(l.name, l.value);
2402
- return c.append(...u), pe(c, r.definition.contract.tag), [c];
2403
- }
2404
- function ve(e, t, n, r, i, o) {
2405
- let a = e.attributes.find((p) => p.kind === "directive");
2406
- if (e.name === "template") {
2407
- if (a !== void 0) {
2408
- let p = n.createTextNode("");
2409
- return Z(i, t, () => {
2410
- let h = $(a.expression, t);
2411
- a.name === "value" && (p.data = L(h));
2412
- }), a.name === "value" ? [p] : [fi(a, t, n)];
2413
- }
2414
- return Nn(e.children, t, n, i);
2415
- }
2416
- let s = e === i.definition.template ? i.rootName : e.name, d = o instanceof Element && o.localName === s, u = d ? o : n.createElement(s);
2417
- e === i.definition.template && (i.root = u);
2418
- let c = d ? Array.from(u.childNodes) : [], l = d && (u instanceof HTMLInputElement || u instanceof HTMLTextAreaElement || u instanceof HTMLSelectElement) ? { value: u.value, focused: u.ownerDocument.activeElement === u, ...u instanceof HTMLInputElement ? { checked: u.checked } : {}, ...u instanceof HTMLInputElement || u instanceof HTMLTextAreaElement ? { selectionStart: u.selectionStart, selectionEnd: u.selectionEnd } : {} } : void 0;
2419
- e.ref !== void 0 && (i.refs[e.ref] = u);
2420
- for (let p of r) u.setAttribute(p.name, p.value);
2421
- for (let p of e.attributes) if (p.kind === "literal") u.setAttribute(p.name, p.value);
2422
- else if (p.kind === "attribute") {
2423
- if (Z(i, t, () => {
2424
- let h = $(p.expression, t);
2425
- p.target === "class" ? u.classList.toggle(p.name, D(h)) : p.target === "style" ? u.style.setProperty(p.name, L(h)) : p.twoWay === true && ai(u, p.name, h) || li(u, p.name, jt(h));
2426
- }), p.twoWay === true && p.writablePath !== void 0) {
2427
- let h = u instanceof HTMLSelectElement || u instanceof HTMLInputElement && ["checkbox", "radio", "file"].includes(u.type) ? "change" : "input", v = () => {
2428
- u instanceof HTMLInputElement && u.type === "radio" && !u.checked || Sn(t, p.writablePath, si(u));
2429
- };
2430
- Z(i, t, () => (u.addEventListener(h, v), () => u.removeEventListener(h, v)), 2);
2431
- }
2432
- } else p.kind === "property" && Z(i, t, () => {
2433
- u[p.name] = $(p.expression, t);
2434
- });
2435
- if (pe(u, i.definition.contract.tag), a !== void 0) return Z(i, t, () => ci(u, a, t, n)), wn(u, e, t, i), [u];
2436
- let m = [], f = 0;
2437
- for (let p of e.children) {
2438
- let h = $n(p, t, n, i, c[f]);
2439
- m.push(...h), f += h.length;
2440
- }
2441
- if (d) {
2442
- m = m.flatMap((p) => p.nodeType === 11 ? Array.from(p.childNodes) : [p]);
2443
- for (let p = 0; p < m.length; p += 1) {
2444
- let h = m[p];
2445
- u.childNodes[p] !== h && u.insertBefore(h, u.childNodes[p] ?? null);
2446
- }
2447
- for (; u.childNodes.length > m.length; ) u.lastChild.remove();
2448
- } else u.append(...m);
2449
- return l !== void 0 && (u.value = l.value, u instanceof HTMLInputElement && "checked" in l && (u.checked = l.checked), (u instanceof HTMLInputElement || u instanceof HTMLTextAreaElement) && "selectionStart" in l && typeof l.selectionStart == "number" && typeof l.selectionEnd == "number" && (l.focused && u.focus({ preventScroll: true }), u.setSelectionRange(l.selectionStart, l.selectionEnd))), wn(u, e, t, i), [u];
2450
- }
2451
- function Nn(e, t, n, r) {
2452
- let i = [];
2453
- for (let o of e) i.push(...$n(o, t, n, r));
2454
- return i;
2455
- }
2456
- function Ei(e) {
2457
- return e.__loomaFrameworkSlot ?? (e instanceof Element ? e.getAttribute("slot") ?? "" : "");
2458
- }
2459
- function xi(e, t, n, r) {
2460
- let i = e.nameExpression === void 0 ? e.name ?? "" : L(W(e.nameExpression, t)), o = r.projectedNodes.filter((s) => Ei(s) === i);
2461
- if (o.length === 0) return Nn(e.fallback ?? [], t, n, r);
2462
- if (r.committed) {
2463
- for (let s of o) Ve(s);
2464
- return [...o];
2465
- }
2466
- let a = n.createComment(`html-next:slot:${i}`);
2467
- return r.slotInsertions.push({ anchor: a, nodes: o }), [a];
2468
- }
2469
- function $n(e, t, n, r, i) {
2470
- if (e.kind === "text") {
2471
- let o = i instanceof Text ? i : n.createTextNode("");
2472
- return o.data = e.value, [o];
2473
- }
2474
- return e.kind === "slot" ? xi(e, t, n, r) : Rn(e, t, n, [], r, i);
2475
- }
2476
- var An = /* @__PURE__ */ new Set(["type", "required", "multiple", "min", "max", "minlength", "maxlength", "pattern", "step"]), wt = ["button", "fieldset", "input", "object", "output", "select", "textarea", ...Array.from(An, (e) => `[${e}]`)].join(",");
2477
- function Si(e) {
2478
- return "validity" in e && typeof e.checkValidity == "function";
2479
- }
2480
- function ge(e, t) {
2481
- let n = e.getAttribute(t);
2482
- if (n === null || n.trim() === "") return;
2483
- let r = Number(n);
2484
- return Number.isFinite(r) ? r : void 0;
2485
- }
2486
- function Ti(e) {
2487
- let t = e.getAttribute("type") ?? void 0, n = e.getAttribute("min") ?? void 0, r = e.getAttribute("max") ?? void 0, o = e.getAttribute("step") === "any" ? "any" : ge(e, "step");
2488
- return { ...t === void 0 ? {} : { type: t }, ...e.hasAttribute("required") ? { required: true } : {}, ...e.hasAttribute("multiple") ? { multiple: true } : {}, ...n === void 0 ? {} : { min: n }, ...r === void 0 ? {} : { max: r }, ...ge(e, "minlength") === void 0 ? {} : { minLength: ge(e, "minlength") }, ...ge(e, "maxlength") === void 0 ? {} : { maxLength: ge(e, "maxlength") }, ...e.getAttribute("pattern") === null ? {} : { pattern: e.getAttribute("pattern") }, ...o === void 0 ? {} : { step: o } };
2489
- }
2490
- function Ci(e, t) {
2491
- let n = [], r = () => {
2492
- if (n.length > 0) return;
2493
- let o = e.matches(wt) ? [e, ...Array.from(e.querySelectorAll(wt))] : Array.from(e.querySelectorAll(wt));
2494
- for (let a of o) {
2495
- let s = Si(a), d = Array.from(a.attributes).some((u) => An.has(u.name.toLowerCase()));
2496
- !s && !d || n.push(kt(a, s ? {} : Ti(a)));
2497
- }
2498
- }, i = () => {
2499
- for (let o of n) o();
2500
- n = [];
2501
- };
2502
- t.connectCallbacks.add(r), t.disconnectCallbacks.add(i);
2503
- }
2504
- function Ri(e, t) {
2505
- let n = t.definition.contract.props, r = {}, i = {};
2506
- for (let [c, l] of Object.entries(n)) {
2507
- if (Object.defineProperty(e, c, { configurable: true, enumerable: true, get: () => {
2508
- let f = t.scope.get(c);
2509
- return f === x ? void 0 : f;
2510
- }, set: (f) => {
2511
- let p = t.scope.get(c);
2512
- Object.is(p === x ? void 0 : p, f) || t.scope.set(c, kn(c, l, f));
2513
- } }), "property" in l.target) continue;
2514
- let m = `data-${Ee(c)}`;
2515
- r[m] = c, t.effects.push(X(t.scope.scheduler, () => {
2516
- let f = t.scope.get(c), p = f === void 0 || f === x ? null : Se(f, l.type);
2517
- i[m] = p, p === null ? e.removeAttribute(m) : e.setAttribute(m, p);
2518
- }, 2));
2519
- }
2520
- let o = e.ownerDocument.defaultView?.MutationObserver, a = Object.keys(r);
2521
- if (o === void 0 || a.length === 0) return;
2522
- let s = new o((c) => {
2523
- for (let l of c) {
2524
- let m = l.attributeName;
2525
- if (m === null) continue;
2526
- let f = r[m];
2527
- if (f === void 0) continue;
2528
- let p = e.getAttribute(m);
2529
- if (m in i && i[m] === p) {
2530
- delete i[m];
2531
- continue;
2532
- }
2533
- delete i[m];
2534
- let h = n[f];
2535
- t.scope.set(f, p === null ? kn(f, h, void 0) : Oe(h, p, true));
2536
- }
2537
- }), d = () => s.observe(e, { attributes: true, attributeFilter: a }), u = () => s.disconnect();
2538
- t.connectCallbacks.add(d), t.disconnectCallbacks.add(u);
2539
- }
2540
- function Ni(e, t) {
2541
- for (let n of t.definition.declarations ?? []) n.kind === "method" && Object.defineProperty(e, n.name, { configurable: true, enumerable: false, value: (...r) => t.controllerModule === void 0 ? Promise.reject(new TypeError(`Controller method \`${n.name}\` is not ready for <${t.definition.contract.tag}>.`)) : t.controllerModule.then((i) => {
2542
- let o = i[n.exportName];
2543
- return typeof o != "function" && y("HJ003", `Controller does not export method \`${n.exportName}\`.`), Reflect.apply(o, void 0, [Tt(e), ...r]);
2544
- }) });
2545
- }
2546
- function Mn(e, t, n, r) {
2547
- let i = n && e.contains(e.ownerDocument.activeElement) ? e.ownerDocument.activeElement : null, o = i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement ? [i.selectionStart, i.selectionEnd] : void 0, { scope: a, passThrough: s, effects: d, rootName: u } = oi(e, t, n), c = n ? r ?? Array.from(e.querySelectorAll("[data-slotted]")) : Array.from(e.childNodes), l = { definition: t, scope: a, refs: {}, effects: d, connectCallbacks: /* @__PURE__ */ new Set(), disconnectCallbacks: /* @__PURE__ */ new Set(), connected: false }, m = { definition: t, effects: d, refs: l.refs, connectCallbacks: l.connectCallbacks, disconnectCallbacks: l.disconnectCallbacks, projectedNodes: c, slotInsertions: [], rootName: u, committed: n }, p = Rn(t.template, a, e.ownerDocument, s, m, n ? e : void 0)[0];
2548
- return n && p !== e && y("HR005", `Server markup for <${t.contract.tag}> has an incompatible root.`), i instanceof HTMLElement && (i.focus({ preventScroll: true }), o !== void 0 && (i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement) && typeof o[0] == "number" && typeof o[1] == "number" && i.setSelectionRange(o[0], o[1])), pt(p, t.contract.tag), l.element = p, { invocation: e, nativeRoot: p, context: m, definition: t, instance: l, replace: !n };
2549
- }
2550
- function Vn(e, t) {
2551
- t.sort((n, r) => n.invocation.contains(r.invocation) ? -1 : r.invocation.contains(n.invocation) ? 1 : 0);
2552
- for (let n of t) {
2553
- for (let r of n.context.slotInsertions) {
2554
- for (let i of r.nodes) Ve(i);
2555
- r.anchor.replaceWith(...r.nodes);
2556
- }
2557
- n.replace && n.invocation.replaceWith(n.nativeRoot), n.context.committed = true, xn.set(n.nativeRoot, n.instance), Ri(n.nativeRoot, n.instance), Ni(n.nativeRoot, n.instance), Ci(n.nativeRoot, n.instance), St(n.instance);
2558
- }
2559
- }
2560
- function En(e, t, n) {
2561
- e.nodeType === 1 && e.matches(t) && n.add(e);
2562
- for (let r of e.querySelectorAll(t)) n.add(r);
2563
- }
2564
- function Ln(e, t) {
2565
- let n = e.nodeType === 1 ? e : void 0;
2566
- if (n?.matches("[data-component-root]") === true && t(n), n?.childElementCount !== 0) for (let r of e.querySelectorAll("[data-component-root]")) t(r);
2567
- }
2568
- function Hn(e, t, n) {
2569
- let r = ke(e), i = /* @__PURE__ */ new Set(), o = ti(r);
2570
- for (let f of t) En(f, o, i);
2571
- let a = [];
2572
- for (let f of i) f.localName === "template" && f.hasAttribute("component") && !je.has(f) && a.push(ni(f, a.length));
2573
- let s = /* @__PURE__ */ new Map();
2574
- for (let f of a) {
2575
- let p = f.definition.contract.tag;
2576
- (r.definitions.has(p) || s.has(p)) && y("HR001", `More than one definition declares <${p}>.`), s.set(p, f);
2577
- }
2578
- let d = [], u = /* @__PURE__ */ new Set(), c = (f, p, h) => {
2579
- let { definition: v } = f;
2580
- return je.has(p) || e.defaultView?.customElements.get(v.contract.tag) !== void 0 || n?.(p, v, h) === false ? false : (d.push(Mn(p, v, h)), true);
2581
- }, l = (f, p) => {
2582
- for (let h of p) {
2583
- let v = f.get(h.localName);
2584
- if (v !== void 0 && c(v, h, false), !h.hasAttribute("data-component-root")) continue;
2585
- if (J(h) !== void 0) {
2586
- u.add(h);
2587
- continue;
2588
- }
2589
- let S = false;
2590
- for (let w of new Set((h.getAttribute("data-component-root") ?? "").split(/\s+/))) {
2591
- let g = f.get(w);
2592
- g !== void 0 && c(g, h, true) && (S = true);
2593
- }
2594
- S && u.add(h);
2595
- }
2596
- };
2597
- if (l(r.definitions, i), s.size > 0) {
2598
- let f = ["[data-component-root]", ...Array.from(s.keys())].join(","), p = /* @__PURE__ */ new Set();
2599
- En(e, f, p), l(s, p);
2600
- }
2601
- for (let f of a) ze(r, f.definition.contract.tag, f), f.style !== void 0 && (f.style.textContent = Me(f.style.textContent ?? "", f.definition.contract.tag, f.definition.template.name), f.wrapper.ownerDocument.head.append(f.style)), f.wrapper.remove();
2602
- Vn(r, d);
2603
- let m = d.map((f) => f.nativeRoot);
2604
- for (let f of m) u.add(f);
2605
- return { lowered: m, roots: Array.from(u) };
2606
- }
2607
- function $i(e = document) {
2608
- return Hn(e, [e]).lowered.length;
2609
- }
2610
- function Dn(e, t) {
2611
- let n = Ie(e), r = n.mutationHub;
2612
- if (r === void 0) {
2613
- let o = e.defaultView?.MutationObserver;
2614
- o === void 0 && y("HR003", "Automatic component management requires a browser MutationObserver.");
2615
- let a = /* @__PURE__ */ new Set(), s = new o((d) => {
2616
- for (let u of Array.from(a)) u(d);
2617
- });
2618
- r = { observer: s, subscribers: a }, n.mutationHub = r, s.observe(e, { childList: true, subtree: true });
2619
- }
2620
- r.subscribers.add(t);
2621
- let i = true;
2622
- return () => {
2623
- i && (i = false, r.subscribers.delete(t), r.subscribers.size === 0 && (r.observer.disconnect(), delete n.mutationHub));
2624
- };
2625
- }
2626
- function Ai(e) {
2627
- let t = Ie(e), n = t.lifecycle;
2628
- if (n !== void 0) return n;
2629
- let r = 0, i = (s) => {
2630
- let d = s[Y];
2631
- d !== void 0 && (s.isConnected && d.disconnect === void 0 ? d.disconnect = d.connect(s) : !s.isConnected && d.disconnect !== void 0 && (d.disconnect(), d.disconnect = void 0));
2632
- }, o = Dn(e, (s) => {
2633
- let d = [], u = (c) => {
2634
- if (c.nodeType !== 1) return;
2635
- let l = c;
2636
- l[Y] !== void 0 && d.push(l), Ln(l, (m) => {
2637
- m[Y] !== void 0 && d.push(m);
2638
- });
2639
- };
2640
- for (let c of s) {
2641
- for (let l of c.addedNodes) u(l);
2642
- for (let l of c.removedNodes) u(l);
2643
- }
2644
- for (let c of d) i(c);
2645
- }), a = { add(s, d) {
2646
- let u = s, c = u[Y];
2647
- c !== d && (c?.disconnect?.(), c === void 0 && (r += 1), u[Y] = d, i(s));
2648
- }, remove(s, d) {
2649
- let u = s;
2650
- u[Y] === d && (d.disconnect?.(), delete u[Y], r -= 1, r === 0 && (o(), delete t.lifecycle));
2651
- } };
2652
- return t.lifecycle = a, a;
2653
- }
2654
- function Mi(e, t, n = {}) {
2655
- let r = Ai(e.ownerDocument), i = { connect: (a) => xt(a, t, n), disconnect: void 0 };
2656
- r.add(e, i);
2657
- let o = false;
2658
- return () => {
2659
- o || (o = true, r.remove(e, i));
2660
- };
2661
- }
2662
- function Vi(e, t = document) {
2663
- let n = ke(t);
2664
- for (let r of e) {
2665
- let i = n.definitions.get(r.contract.tag);
2666
- if (i !== void 0) {
2667
- JSON.stringify(i.definition) !== JSON.stringify(r) && y("HR001", `More than one definition declares <${r.contract.tag}>.`);
2668
- continue;
2669
- }
2670
- if (ze(n, r.contract.tag, { definition: r, style: void 0 }), r.css !== "") {
2671
- let o = t.createElement("style");
2672
- o.dataset.htmlNextPackage = r.contract.tag, o.textContent = Me(r.css, r.contract.tag, r.template.name), t.head.append(o);
2673
- }
2674
- }
2675
- }
2676
- function xt(e, t, n = {}) {
2677
- let r = e.ownerDocument, i = ke(r), o = i.definitions.get(t.contract.tag);
2678
- if (o === void 0 ? ze(i, t.contract.tag, { definition: t, style: void 0 }) : JSON.stringify(o.definition) !== JSON.stringify(t) && y("HR001", `More than one definition declares <${t.contract.tag}>.`), J(e) === void 0) {
2679
- let c = Array.from(e.querySelectorAll("[data-looma-framework-slot]")).filter((w) => w.closest("[data-component-root]") === e);
2680
- for (let w of c) w.__loomaFrameworkSlot = w.getAttribute("data-looma-framework-slot") ?? "", Ve(w);
2681
- let C2 = new Set(c), l = (m, f) => {
2682
- let q2 = f.children.find((w) => w.kind === "slot"), k2 = q2?.name ?? "", p = f.children.filter((w) => w.kind === "text").map((w) => w.value), h = 0, v = f.children.filter((w) => w.kind === "element"), S = 0;
2683
- for (let w of Array.from(m.childNodes)) {
2684
- if (w instanceof Element) {
2685
- if (!(w.getAttribute("data-component")?.split(/\s+/) ?? []).includes(t.contract.tag)) {
2686
- if (!C2.has(w)) w.__loomaFrameworkSlot = w.getAttribute("data-looma-framework-slot") ?? k2, Ve(w), c.push(w);
2687
- } else {
2688
- for (; S < v.length && v[S].name !== w.localName; ) S += 1;
2689
- let b = v[S++];
2690
- b !== void 0 && l(w, b);
2691
- }
2692
- continue;
2693
- }
2694
- if (w instanceof Comment && q2 !== void 0) {
2695
- w.__loomaFrameworkSlot = k2, c.push(w);
2696
- continue;
2697
- }
2698
- if (w instanceof Text && w.data.trim() !== "") {
2699
- for (; h < p.length && p[h] !== w.data; ) h += 1;
2700
- h < p.length ? h += 1 : c.push(w);
2701
- }
2702
- }
2703
- };
2704
- l(e, t.template), pe(e, t.contract.tag), pt(e, t.contract.tag);
2705
- for (let [m, f] of Object.entries(t.contract.props)) {
2706
- let p = Object.hasOwn(n.props ?? {}, m) ? n.props?.[m] : f.default;
2707
- p !== void 0 && (e[m] = p, "attribute" in f.target && e.setAttribute(`data-${Ee(m)}`, Se(p, f.type)));
2708
- }
2709
- Vn(i, [Mn(e, t, true, c)]);
2710
- }
2711
- let s = J(e);
2712
- s === void 0 && y("HR005", `Could not attach <${t.contract.tag}> to its native root.`);
2713
- for (let [c, l] of Object.entries(n.props ?? {})) c in t.contract.props && (e[c] = l);
2714
- St(s);
2715
- let d, u = false;
2716
- if (n.controller !== void 0) {
2717
- let c = Promise.resolve(n.controller);
2718
- Pn(e, c), Promise.resolve(n.controller.default(Tt(e))).then((l) => {
2719
- typeof l == "function" && (u ? l() : d = l);
2720
- });
2721
- }
2722
- return () => {
2723
- u || (u = true, d?.(), Et(s));
2724
- };
2725
- }
2726
- function Li(e, t, n = {}) {
2727
- let r = ke(e.ownerDocument).definitions.get(t);
2728
- return r === void 0 && y("HR005", `No registered definition declares <${t}>.`), xt(e, r.definition, n);
2729
- }
2730
- function St(e) {
2731
- if (!e.connected) {
2732
- e.connected = true;
2733
- for (let t of e.effects) t.resume();
2734
- for (let t of e.connectCallbacks) t();
2735
- e.element?.dispatchEvent(new Event("connect"));
2736
- }
2737
- }
2738
- function Et(e) {
2739
- if (e.connected) {
2740
- e.element?.dispatchEvent(new Event("disconnect"));
2741
- for (let t of e.disconnectCallbacks) t();
2742
- e.connected = false;
2743
- for (let t of e.effects) t.pause();
2744
- }
2745
- }
2746
- function Tt(e) {
2747
- let t = J(e);
2748
- if (t === void 0) return;
2749
- if (t.host !== void 0) return t.host;
2750
- let n = new Set((t.definition.declarations ?? []).filter((a) => a.kind === "state").map((a) => a.name)), r = new Proxy({}, { get: (a, s) => {
2751
- if (typeof s != "string") return;
2752
- let d = t.scope.get(s);
2753
- return d === x ? void 0 : d;
2754
- }, set: (a, s, d) => {
2755
- if (typeof s != "string" || !n.has(s)) throw new TypeError(`Only declared state roots are writable; \`${String(s)}\` is read-only.`);
2756
- return t.scope.set(s, d), true;
2757
- }, has: (a, s) => typeof s == "string" && t.scope.has(s) }), i = new Proxy({}, { get: (a, s) => typeof s != "string" ? void 0 : (e instanceof HTMLFormElement ? e : e.querySelector("form"))?.elements.namedItem(s) ?? e.querySelector(`[name="${CSS.escape(s)}"]`) ?? void 0 }), o = { element: e, state: r, refs: t.refs, elements: i, effect(a) {
2758
- let s = X(t.scope.scheduler, a, 2);
2759
- return t.effects.push(s), () => s.stop();
2760
- }, on(a, s) {
2761
- if (a === "connect") {
2762
- let d = s;
2763
- return t.connectCallbacks.add(d), t.connected && s(), () => t.connectCallbacks.delete(d);
2764
- }
2765
- if (a === "disconnect") {
2766
- let d = s;
2767
- return t.disconnectCallbacks.add(d), () => t.disconnectCallbacks.delete(d);
2768
- }
2769
- return e.addEventListener(a, s), () => e.removeEventListener(a, s);
2770
- }, dispatch(a, s) {
2771
- return e.dispatchEvent(new CustomEvent(a, { detail: s, bubbles: true, composed: true }));
2772
- } };
2773
- return t.host = Object.freeze(o), t.host;
2774
- }
2775
- function Pn(e, t) {
2776
- let n = J(e);
2777
- n === void 0 && y("HJ003", "A controller can attach only to a lowered component root."), n.controllerModule = t;
2778
- }
2779
- function Hi(e = document, t = {}) {
2780
- let n = Ie(e);
2781
- n.observer !== void 0 && y("HR003", "This document is already being observed.");
2782
- let r = /* @__PURE__ */ new Map(), i = t.onError ?? ((l) => console.error(l)), o = false, a = (l) => {
2783
- let m = r.get(l);
2784
- r.delete(l);
2785
- let f = J(l);
2786
- f !== void 0 && Et(f);
2787
- try {
2788
- m?.();
2789
- } catch (p) {
2790
- i(p);
2791
- }
2792
- }, s = (l) => {
2793
- let m = J(l);
2794
- if (!(m === void 0 || r.has(l) || !e.contains(l))) {
2795
- r.set(l, void 0);
2796
- try {
2797
- St(m);
2798
- let f = t.onConnect?.(l, m.definition);
2799
- o ? f?.() : r.set(l, f);
2800
- } catch (f) {
2801
- i(f);
2802
- }
2803
- }
2804
- }, d = (l) => {
2805
- if (o) return;
2806
- let m = [];
2807
- if (l === void 0) m.push(e);
2808
- else {
2809
- let f = [];
2810
- for (let p of l) {
2811
- for (let h of p.removedNodes) h.nodeType === 1 && Ln(h, (v) => {
2812
- r.has(v) && f.push(v);
2813
- });
2814
- for (let h of p.addedNodes) h.nodeType === 1 && m.push(h);
2815
- }
2816
- for (let p of f) e.contains(p) || a(p);
2817
- }
2818
- if (m.length > 0) try {
2819
- for (let f of Hn(e, m, t.shouldLower).roots) {
2820
- if (o) break;
2821
- s(f);
2822
- }
2823
- } catch (f) {
2824
- i(f);
2825
- }
2826
- }, u = Dn(e, d), c = () => {
2827
- if (!o) {
2828
- o = true, u(), delete n.observer;
2829
- for (let l of r.values()) try {
2830
- l?.();
2831
- } catch (m) {
2832
- i(m);
2833
- }
2834
- for (let l of r.keys()) {
2835
- let m = J(l);
2836
- m !== void 0 && Et(m);
2837
- }
2838
- r.clear();
2839
- }
2840
- };
2841
- return n.observer = c, d(), c;
2842
- }
2843
- return qn(Di);
2844
- })();
2845
- var { attachComponent, attachRegisteredComponent, getComponentHost, installComponentGraph, lowerDocument, manageComponentLifecycle, observeDocument, registerComponentDefinitions, setControllerModule } = HtmlRuntime;
2846
-
2847
- // src/declarative.ts
2848
- var stateKey = /* @__PURE__ */ Symbol.for("@threadlabs/looma.declarative.v1");
2849
- var stateTarget = globalThis;
2850
- var state = stateTarget[stateKey] ??= {
2851
- runtime: {
2852
- attachRegisteredComponent,
2853
- getComponentHost,
2854
- manageComponentLifecycle,
2855
- observeDocument,
2856
- setControllerModule
2857
- },
2858
- records: /* @__PURE__ */ new Map(),
2859
- installedPackages: /* @__PURE__ */ new Set(),
2860
- stopObservation: void 0,
2861
- observationScheduled: false
2862
- };
2863
- function connectController(element, tag) {
2864
- if (element.getAttribute("data-looma-managed") === "framework") return;
2865
- const controller = state.records.get(tag)?.controller;
2866
- if (!controller?.default) return;
2867
- state.runtime.setControllerModule(element, Promise.resolve(controller));
2868
- return controller.default(state.runtime.getComponentHost(element));
2869
- }
2870
- function scheduleObservation() {
2871
- if (state.observationScheduled || typeof document === "undefined") return;
2872
- state.observationScheduled = true;
2873
- queueMicrotask(() => {
2874
- state.observationScheduled = false;
2875
- state.stopObservation?.();
2876
- state.stopObservation = state.runtime.observeDocument(document, {
2877
- shouldLower(element) {
2878
- return element.getAttribute("data-looma-managed") !== "framework";
2879
- },
2880
- onConnect(element, definition) {
2881
- return connectController(element, definition.contract.tag);
2882
- }
2883
- });
2884
- });
2885
- }
2886
- function registerLoomaPackage(name, packageRecords, styles) {
2887
- if (typeof document === "undefined" || state.installedPackages.has(name)) return;
2888
- state.stopObservation?.();
2889
- state.stopObservation = void 0;
2890
- state.installedPackages.add(name);
2891
- const definitions = document.createElement("div");
2892
- definitions.hidden = true;
2893
- definitions.dataset.loomaDefinitions = name;
2894
- definitions.innerHTML = packageRecords.map(({ source }) => source).join("\n");
2895
- document.head.append(...Array.from(definitions.children));
2896
- for (const record of packageRecords) state.records.set(record.tag, record);
2897
- if (styles !== "") {
2898
- const style = document.createElement("style");
2899
- style.dataset.loomaStyles = name;
2900
- style.textContent = styles;
2901
- document.head.append(style);
2902
- }
2903
- scheduleObservation();
2904
- }
2905
- function attachLoomaComponent(element, definition, tag, props) {
2906
- if (definition.contract.tag !== tag) {
2907
- throw new TypeError(`Looma definition ${definition.contract.tag} cannot attach as ${tag}.`);
2908
- }
2909
- const controller = state.records.get(tag)?.controller;
2910
- element.setAttribute("data-looma-managed", "framework");
2911
- return state.runtime.attachRegisteredComponent(element, tag, { props, controller });
2912
- }
2913
- function controllerFor(tag) {
2914
- return state.records.get(tag)?.controller;
2915
- }
2916
- function manageComponentLifecycle2(...args) {
2917
- return state.runtime.manageComponentLifecycle(...args);
2918
- }
2919
-
2920
- export {
2921
- registerLoomaPackage,
2922
- attachLoomaComponent,
2923
- controllerFor,
2924
- manageComponentLifecycle2 as manageComponentLifecycle
2925
- };