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