wrec 0.21.4 → 0.22.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.
package/dist/wrec.es.js CHANGED
@@ -1,68 +1,67 @@
1
- var K = (r) => {
2
- throw TypeError(r);
1
+ var V = (n) => {
2
+ throw TypeError(n);
3
3
  };
4
- var D = (r, t, e) => t.has(r) || K("Cannot " + e);
5
- var p = (r, t, e) => (D(r, t, "read from private field"), e ? e.call(r) : t.get(r)), E = (r, t, e) => t.has(r) ? K("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), M = (r, t, e, s) => (D(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), Z = (r, t, e) => (D(r, t, "access private method"), e);
6
- import { HTMLElement as nt, NodeType as F, parse as rt, TextNode as ct } from "node-html-parser";
7
- import X from "xss";
8
- function G(r, t, e = "") {
4
+ var O = (n, t, e) => t.has(n) || V("Cannot " + e);
5
+ var p = (n, t, e) => (O(n, t, "read from private field"), e ? e.call(n) : t.get(n)), b = (n, t, e) => t.has(n) ? V("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), w = (n, t, e, s) => (O(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), B = (n, t, e) => (O(n, t, "access private method"), e);
6
+ import W from "xss";
7
+ function K(n, t, e = "") {
9
8
  const s = /* @__PURE__ */ new WeakMap(), o = {
10
9
  // Intercept property reads.
11
10
  // This creates nested proxies lazily.
12
- get(i, n) {
13
- const c = Reflect.get(i, n);
11
+ get(i, r) {
12
+ const c = Reflect.get(i, r);
14
13
  if (c === null || typeof c != "object") return c;
15
14
  const a = s.get(c);
16
15
  if (a) return a;
17
- const f = e ? `${e}.${n}` : n, l = G(c, t, f);
18
- return s.set(c, l), l;
16
+ const h = e ? `${e}.${r}` : r, f = K(c, t, h);
17
+ return s.set(c, f), f;
19
18
  },
20
19
  // Intercept property writes.
21
- set(i, n, c) {
22
- const a = Reflect.get(i, n);
20
+ set(i, r, c) {
21
+ const a = Reflect.get(i, r);
23
22
  if (a !== c) {
24
- Reflect.set(i, n, c);
25
- const f = e ? `${e}.${n}` : n;
26
- t(f, a, c);
23
+ Reflect.set(i, r, c);
24
+ const h = e ? `${e}.${r}` : r;
25
+ t(h, a, c);
27
26
  }
28
27
  return !0;
29
28
  }
30
29
  };
31
- return new Proxy(r, o);
30
+ return new Proxy(n, o);
32
31
  }
33
- function Q(r) {
32
+ function Z(n) {
34
33
  const t = {};
35
- for (const [e, s] of Object.entries(r)) {
34
+ for (const [e, s] of Object.entries(n)) {
36
35
  const o = typeof s == "object" && s !== null;
37
- t[e] = o ? Q(s) : s;
36
+ t[e] = o ? Z(s) : s;
38
37
  }
39
38
  return t;
40
39
  }
41
- const O = typeof window < "u" && typeof window.document < "u";
42
- let U = class extends Error {
40
+ const P = typeof window < "u" && typeof window.document < "u";
41
+ let z = class extends Error {
43
42
  };
44
- var T, H, m, N, $, w, _, tt;
45
- const A = class A {
43
+ var y, N, d, v, C, g, $, U;
44
+ const T = class T {
46
45
  constructor(t, e, s) {
47
- E(this, _);
48
- E(this, H, /* @__PURE__ */ Symbol("objectId"));
46
+ b(this, $);
47
+ b(this, N, /* @__PURE__ */ Symbol("objectId"));
49
48
  // This cannot be replaced by a WeakMap<ChangeListener, Set<string>>
50
49
  // because there is no way to iterate over the keys of a WeakMap.
51
- E(this, m, []);
52
- E(this, N);
53
- E(this, $);
54
- E(this, w);
55
- if (!t) throw new U("name cannot be empty");
56
- if (p(A, T).has(t))
57
- throw new U(`WrecState with name "${t}" already exists`);
58
- if (M(this, N, t), M(this, $, e), M(this, w, G({}, Z(this, _, tt).bind(this))), e && O) {
50
+ b(this, d, []);
51
+ b(this, v);
52
+ b(this, C);
53
+ b(this, g);
54
+ if (!t) throw new z("name cannot be empty");
55
+ if (p(T, y).has(t))
56
+ throw new z(`WrecState with name "${t}" already exists`);
57
+ if (w(this, v, t), w(this, C, e), w(this, g, K({}, B(this, $, U).bind(this))), e && P) {
59
58
  const o = sessionStorage.getItem("wrec-state-" + t), i = o ? JSON.parse(o) : void 0;
60
59
  i && (s = i);
61
60
  }
62
61
  if (s)
63
62
  for (const [o, i] of Object.entries(s))
64
63
  this.addProperty(o, i);
65
- p(A, T).set(t, this);
64
+ p(T, y).set(t, this);
66
65
  }
67
66
  // This static method is useful for accessing a specific WrecState object
68
67
  // from the DevTools console. For example:
@@ -75,22 +74,22 @@ const A = class A {
75
74
  // state.color = 'blue';
76
75
  // state.team.leader.name = 'Mark';
77
76
  static get(t) {
78
- return p(this, T).get(t);
77
+ return p(this, y).get(t);
79
78
  }
80
79
  /**
81
80
  * @param listener - object that has a "changed" method
82
81
  * @param map - map from state property paths to component properties
83
82
  */
84
83
  addListener(t, e = {}) {
85
- const s = p(this, m).find(
84
+ const s = p(this, d).find(
86
85
  (o) => o.listenerRef.deref() === t
87
86
  );
88
87
  if (s) {
89
88
  const { propertyMap: o } = s;
90
- for (const [i, n] of Object.entries(e))
91
- o[i] = n;
89
+ for (const [i, r] of Object.entries(e))
90
+ o[i] = r;
92
91
  } else
93
- p(this, m).push({
92
+ p(this, d).push({
94
93
  listenerRef: new WeakRef(t),
95
94
  propertyMap: e
96
95
  });
@@ -99,38 +98,38 @@ const A = class A {
99
98
  Object.defineProperty(this, t, {
100
99
  enumerable: !0,
101
100
  get() {
102
- return p(this, w)[t];
101
+ return p(this, g)[t];
103
102
  },
104
103
  set(s) {
105
- p(this, w)[t] = s;
104
+ p(this, g)[t] = s;
106
105
  }
107
- }), p(this, w)[t] = e;
106
+ }), p(this, g)[t] = e;
108
107
  }
109
108
  get id() {
110
- return p(this, H);
109
+ return p(this, N);
111
110
  }
112
111
  // This is useful for debugging from the DevTools console.
113
112
  // For example: state.log()
114
113
  log() {
115
- console.log("WrecState:", p(this, N));
116
- for (const [t, e] of Object.entries(p(this, w)))
114
+ console.log("WrecState:", p(this, v));
115
+ for (const [t, e] of Object.entries(p(this, g)))
117
116
  console.log(` ${t} = ${JSON.stringify(e)}`);
118
117
  }
119
118
  removeListener(t) {
120
- M(this, m, p(this, m).filter((e) => e.listenerRef.deref() !== t));
119
+ w(this, d, p(this, d).filter((e) => e.listenerRef.deref() !== t));
121
120
  }
122
121
  };
123
- T = new WeakMap(), H = new WeakMap(), m = new WeakMap(), N = new WeakMap(), $ = new WeakMap(), w = new WeakMap(), _ = new WeakSet(), tt = function(t, e, s) {
122
+ y = new WeakMap(), N = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C = new WeakMap(), g = new WeakMap(), $ = new WeakSet(), U = function(t, e, s) {
124
123
  const o = /* @__PURE__ */ new Set();
125
- for (const i of p(this, m)) {
126
- const n = i.listenerRef.deref();
127
- if (!n)
124
+ for (const i of p(this, d)) {
125
+ const r = i.listenerRef.deref();
126
+ if (!r)
128
127
  o.add(i);
129
- else if (O && n instanceof HTMLElement && !n.isConnected)
128
+ else if (P && r instanceof HTMLElement && !r.isConnected)
130
129
  o.add(i);
131
130
  else {
132
131
  const { propertyMap: c } = i, a = Object.keys(c);
133
- (a.length === 0 || a.includes(t)) && n.changed(
132
+ (a.length === 0 || a.includes(t)) && r.changed(
134
133
  t,
135
134
  c[t],
136
135
  s,
@@ -139,165 +138,174 @@ T = new WeakMap(), H = new WeakMap(), m = new WeakMap(), N = new WeakMap(), $ =
139
138
  );
140
139
  }
141
140
  }
142
- M(this, m, p(this, m).filter(
141
+ w(this, d, p(this, d).filter(
143
142
  (i) => !o.has(i)
144
143
  ));
145
- }, E(A, T, /* @__PURE__ */ new Map()), O && window.addEventListener("beforeunload", () => {
146
- for (const [t, e] of p(A, T).entries())
147
- if (p(e, $)) {
148
- const s = Q(e);
144
+ }, b(T, y, /* @__PURE__ */ new Map()), P && window.addEventListener("beforeunload", () => {
145
+ for (const [t, e] of p(T, y).entries())
146
+ if (p(e, C)) {
147
+ const s = Z(e);
149
148
  sessionStorage.setItem("wrec-state-" + t, JSON.stringify(s));
150
149
  }
151
150
  });
152
- let z = A;
153
- O && process.env.NODE_ENV === "development" && (window.WrecState = z);
154
- function Y(r, t) {
155
- let e = r;
151
+ let _ = T;
152
+ P && process.env.NODE_ENV === "development" && (window.WrecState = _);
153
+ function q(n, t) {
154
+ let e = n;
156
155
  for (const s of t.split("."))
157
156
  e = e[s];
158
157
  return e;
159
158
  }
160
- function at(r, t, e) {
159
+ function st(n, t, e) {
161
160
  const s = t.split("."), o = s.length - 1;
162
- let i = r;
163
- s.forEach((n, c) => {
164
- c === o ? i[n] = e : i = i[n];
161
+ let i = n;
162
+ s.forEach((r, c) => {
163
+ c === o ? i[r] = e : i = i[r];
165
164
  });
166
165
  }
167
- const ft = /* @__PURE__ */ new Set(["input", "label", "option", "th"]);
168
- function lt(r) {
166
+ const ot = /* @__PURE__ */ new Set(["input", "label", "option", "th"]), J = "__WREC", X = "__";
167
+ function it(n) {
169
168
  const t = {
170
169
  allowCommentTag: !0,
171
170
  onTag: (o, i) => {
172
- if (ft.has(o)) return i;
171
+ if (ot.has(o)) return i;
173
172
  },
174
- onTagAttr(o, i, n) {
173
+ onTagAttr(o, i, r) {
175
174
  if (i.startsWith("on")) return "";
176
175
  },
177
- safeAttrValue(o, i, n) {
178
- return i === "class" || o === "a" && i === "href" && !n.startsWith("javascript") || o === "img" && i === "src" ? n : "";
176
+ safeAttrValue(o, i, r) {
177
+ return i === "class" || o === "a" && i === "href" && !r.startsWith("javascript") || o === "img" && i === "src" ? r : "";
179
178
  },
180
179
  stripIgnoreTagBody: ["script", "style", "iframe"],
181
180
  whiteList: {
182
- ...X.getDefaultWhiteList(),
181
+ ...W.getDefaultWhiteList(),
183
182
  label: ["class", "for"],
184
183
  span: ["class"]
185
184
  }
186
185
  }, e = [];
187
- r = r.replace(/<!--[\s\S]*?-->/g, (o) => {
188
- const i = `__COMMENT_${e.length}__`;
186
+ n = n.replace(/<!--[\s\S]*?-->/g, (o) => {
187
+ let i = "";
188
+ do
189
+ i = J + e.length + X;
190
+ while (n.includes(i));
189
191
  return e.push(o), i;
190
192
  });
191
- let s = X(r, t);
192
- return s = s.replace(/__COMMENT_(\d+)__/g, (o, i) => e[i]), s;
193
+ let s = W(n, t);
194
+ return e.forEach((o, i) => {
195
+ const r = new RegExp(
196
+ `${J}${i}${X}`,
197
+ "g"
198
+ );
199
+ s = s.replace(r, o);
200
+ }), s;
193
201
  }
194
- const ht = /* @__PURE__ */ new Set([
202
+ const nt = /* @__PURE__ */ new Set([
195
203
  "class",
196
204
  "disabled",
197
205
  "hidden",
198
206
  "id",
199
207
  "tabindex",
200
208
  "title"
201
- ]);
202
- typeof window > "u" && (global.HTMLElement = nt, global.customElements = {
203
- get: (r) => {
209
+ ]), rt = globalThis.HTMLElement ?? class {
210
+ }, F = globalThis.customElements ?? {
211
+ get: (n) => {
204
212
  },
205
213
  getName: () => "",
206
214
  define: () => {
207
215
  },
208
216
  upgrade: () => {
209
217
  },
210
- whenDefined: () => Promise.reject()
211
- });
212
- class x extends Error {
218
+ whenDefined: () => Promise.reject(new Error("customElements is not available in this environment"))
219
+ };
220
+ class E extends Error {
213
221
  }
214
- const ut = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, et = "a-zA-Z_$", pt = et + "0-9", P = `[${et}][${pt}]*`, dt = /<!--\s*(.*?)\s*-->/, mt = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, V = new RegExp(`^this\\.${P}$`), I = new RegExp(`this\\.${P}(\\.${P})*`, "g"), L = new RegExp(`this\\.${P}(\\.${P})*`), bt = 5;
215
- function gt(r) {
216
- return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof b;
222
+ const ct = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, Y = "a-zA-Z_$", at = Y + "0-9", S = `[${Y}][${at}]*`, ft = /<!--\s*(.*?)\s*-->/, ht = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, L = new RegExp(`^this\\.${S}$`), j = new RegExp(`this\\.${S}(\\.${S})*`, "g"), G = new RegExp(`this\\.${S}(\\.${S})*`), lt = 5;
223
+ function pt(n) {
224
+ return n instanceof HTMLButtonElement || n instanceof HTMLFieldSetElement || n instanceof HTMLInputElement || n instanceof HTMLSelectElement || n instanceof HTMLTextAreaElement || n instanceof u;
217
225
  }
218
- function St(r, t, e) {
219
- const s = document.createElement(r);
226
+ function wt(n, t, e) {
227
+ const s = document.createElement(n);
220
228
  if (t)
221
229
  for (const [o, i] of Object.entries(t))
222
230
  s.setAttribute(o, i);
223
231
  return e && (s.innerHTML = e), s;
224
232
  }
225
- const yt = (r) => r === String ? "" : r === Number ? 0 : r === Boolean ? !1 : r === Array ? [] : r === Object ? {} : void 0;
226
- function j(r) {
233
+ const ut = (n) => n === String ? "" : n === Number ? 0 : n === Boolean ? !1 : n === Array ? [] : n === Object ? {} : void 0;
234
+ function R(n) {
227
235
  const t = [];
228
- let e = r.firstElementChild;
236
+ let e = n.firstElementChild;
229
237
  for (; e; )
230
- t.push(e), e.shadowRoot && t.push(...j(e.shadowRoot)), e.firstElementChild && t.push(...j(e)), e = e.nextElementSibling;
238
+ t.push(e), e.shadowRoot && t.push(...R(e.shadowRoot)), e.firstElementChild && t.push(...R(e)), e = e.nextElementSibling;
231
239
  return t;
232
240
  }
233
- const S = (r) => r.substring(bt).split(".")[0];
234
- function st(r, t) {
235
- let e = r[0];
241
+ const M = (n) => n.substring(lt).split(".")[0];
242
+ function Q(n, t) {
243
+ let e = n[0];
236
244
  return t.forEach((s, o) => {
237
- e += s + r[o + 1];
245
+ e += s + n[o + 1];
238
246
  }), e;
239
247
  }
240
- function q(r) {
241
- const t = typeof r;
248
+ function I(n) {
249
+ const t = typeof n;
242
250
  return t === "string" || t === "number" || t === "boolean";
243
251
  }
244
- function C(r) {
245
- return r.localName === "textarea";
252
+ function A(n) {
253
+ return n.localName === "textarea";
246
254
  }
247
- function J(r) {
248
- const { localName: t } = r;
255
+ function D(n) {
256
+ const { localName: t } = n;
249
257
  return t === "input" || t === "select";
250
258
  }
251
- const Et = (r) => r.replace(/<!--[\s\S]*?-->/g, "");
252
- function ot(r, t, e, s) {
253
- return r.slice(0, t) + s + r.slice(t + e);
259
+ const dt = (n) => n.replace(/<!--[\s\S]*?-->/g, "");
260
+ function tt(n, t, e, s) {
261
+ return n.slice(0, t) + s + n.slice(t + e);
254
262
  }
255
- function W(r) {
256
- const t = Number(r);
257
- if (isNaN(t)) throw new x(`can't convert "${r}" to a number`);
263
+ function H(n) {
264
+ const t = Number(n);
265
+ if (isNaN(t)) throw new E(`can't convert "${n}" to a number`);
258
266
  return t;
259
267
  }
260
- function it(r, t, e) {
268
+ function et(n, t, e) {
261
269
  const [s, o] = t.split(":");
262
- if (q(e))
270
+ if (I(e))
263
271
  if (typeof e == "boolean") {
264
- e ? r.setAttribute(s, s) : r.removeAttribute(s);
265
- const i = b.getPropName(s);
266
- r[i] = e;
272
+ e ? n.setAttribute(s, s) : n.removeAttribute(s);
273
+ const i = u.getPropName(s);
274
+ n[i] = e;
267
275
  } else {
268
- const i = r.getAttribute(t), n = String(e);
269
- i !== n && (r.setAttribute(s, n), s === "value" && J(r) && (r.value = n));
276
+ const i = n.getAttribute(t), r = String(e);
277
+ i !== r && (n.setAttribute(s, r), s === "value" && D(n) && (n.value = r));
270
278
  }
271
279
  else {
272
- const i = b.getPropName(t);
273
- r[i] = e;
280
+ const i = u.getPropName(t);
281
+ n[i] = e;
274
282
  }
275
283
  }
276
- function B(r, t, e) {
284
+ function k(n, t, e) {
277
285
  const [s, o] = t.split(":");
278
- r instanceof CSSStyleRule ? r.style.setProperty(s, e) : (it(r, s, e), s === "value" && J(r) && (r.value = e));
286
+ n instanceof CSSStyleRule ? n.style.setProperty(s, e) : (et(n, s, e), s === "value" && D(n) && (n.value = e));
279
287
  }
280
- async function wt(r) {
288
+ async function mt(n) {
281
289
  const t = /* @__PURE__ */ new Set();
282
- for (const s of j(r.content)) {
290
+ for (const s of R(n.content)) {
283
291
  const { localName: o } = s;
284
292
  o.includes("-") && t.add(o);
285
293
  }
286
294
  function e(s) {
287
295
  return new Promise((o, i) => {
288
296
  setTimeout(() => {
289
- const n = `custom element <${s}> not defined`;
290
- i(new Error(n));
297
+ const r = `custom element <${s}> not defined`;
298
+ i(new Error(r));
291
299
  }, 1e3);
292
300
  });
293
301
  }
294
302
  return Promise.all(
295
303
  [...t].map(
296
- async (s) => Promise.race([customElements.whenDefined(s), e(s)])
304
+ async (s) => Promise.race([F.whenDefined(s), e(s)])
297
305
  )
298
306
  );
299
307
  }
300
- class b extends HTMLElement {
308
+ class u extends rt {
301
309
  // There is one instance of `attrToPropMap`, `properties`, `propToAttrMap`,
302
310
  // `propToComputedMap`, and `propToExprsMap` per Wrec subclass,
303
311
  // not one for only the Wrec class.
@@ -339,21 +347,21 @@ class b extends HTMLElement {
339
347
  static propToExprsMap;
340
348
  static template = null;
341
349
  // This is true while the batchSet method is running.
342
- #a = !1;
350
+ #f = !1;
343
351
  #t = this.constructor;
344
352
  // This is a map from expressions to references to them
345
353
  // which can be found in element text content,
346
354
  // attribute values, and CSS property values.
347
355
  // Each component instance needs its own map.
348
356
  #o = /* @__PURE__ */ new Map();
349
- #f = {};
357
+ #h = {};
350
358
  #i;
351
359
  // For components that set `formAssociated` to true,
352
360
  // this stores in the initial value of each property
353
361
  // in the formAssociatedCallback method
354
362
  // so they can be restored in the formResetCallback method.
355
363
  #l = {};
356
- #h = null;
364
+ #p = null;
357
365
  // This is a map from properties in this web component
358
366
  // to corresponding properties in a parent web component.
359
367
  // This must be an instance property because
@@ -362,64 +370,68 @@ class b extends HTMLElement {
362
370
  // This is used to update a parent property
363
371
  // when the corresponding child property value changes.
364
372
  #u = /* @__PURE__ */ new Map();
373
+ // This is a map from component properties to state bindings.
374
+ // It must be instance-specific because each component instance
375
+ // can bind the same property to a different WrecState/path.
376
+ #m = /* @__PURE__ */ new Map();
365
377
  static define(t) {
366
- if (this.elementName = t, customElements.get(t))
367
- throw new x(`custom element ${t} is already defined`);
368
- customElements.define(t, this);
378
+ if (this.elementName = t, F.get(t))
379
+ throw new E(`custom element ${t} is already defined`);
380
+ F.define(t, this);
369
381
  }
370
382
  constructor() {
371
383
  super(), this.attachShadow({ mode: "open" });
372
384
  const t = this.#t;
373
- t.attrToPropMap || (t.attrToPropMap = /* @__PURE__ */ new Map()), t.properties || (t.properties = {}), t.propToAttrMap || (t.propToExprsMap = /* @__PURE__ */ new Map()), t.propToComputedMap || (t.propToComputedMap = /* @__PURE__ */ new Map()), t.propToExprsMap || (t.propToExprsMap = /* @__PURE__ */ new Map());
385
+ this.#n("attrToPropMap") || (t.attrToPropMap = /* @__PURE__ */ new Map()), this.#n("properties") || (t.properties = {}), this.#n("propToAttrMap") || (t.propToAttrMap = /* @__PURE__ */ new Map()), this.#n("propToComputedMap") || (t.propToComputedMap = /* @__PURE__ */ new Map()), this.#n("propToExprsMap") || (t.propToExprsMap = /* @__PURE__ */ new Map());
374
386
  }
375
387
  attributeChangedCallback(t, e, s) {
376
- t === "disabled" && this.#m();
377
- const o = b.getPropName(t);
378
- if (this.#n(o)) {
379
- const i = this.#M(o, String(s));
388
+ t === "disabled" && this.#g();
389
+ const o = u.getPropName(t);
390
+ if (this.#r(o)) {
391
+ const i = this.#S(o, String(s));
380
392
  this[o] = i;
381
- const n = this.#f[o];
382
- n && this.setFormValue(n, String(i)), this.propertyChangedCallback(o, e, s);
393
+ const r = this.#h[o];
394
+ r && this.setFormValue(r, String(i)), this.propertyChangedCallback(o, e, s);
383
395
  }
384
396
  }
385
397
  // This applies multiple property changes and only updates
386
398
  // the affected parts of the DOM after all of them are made.
387
399
  batchSet(t) {
388
- this.#a = !0;
400
+ this.#f = !0;
389
401
  const e = this.#t.propToExprsMap, s = /* @__PURE__ */ new Set();
390
402
  for (const [c, a] of Object.entries(t)) {
391
403
  this[c] = a;
392
- const f = e.get(c) ?? [];
393
- for (const l of f)
394
- s.add(l);
404
+ const h = e.get(c) ?? [];
405
+ for (const f of h)
406
+ s.add(f);
395
407
  }
396
- const o = this.#t.propToComputedMap, i = /* @__PURE__ */ new Set(), n = {};
408
+ const o = this.#t.propToComputedMap, i = /* @__PURE__ */ new Set(), r = {};
397
409
  for (const c of Object.keys(t)) {
398
410
  const a = o.get(c) || [];
399
- for (const [f, l] of a)
400
- i.add(f), n[f] = l;
411
+ for (const [h, f] of a)
412
+ i.add(h), r[h] = f;
401
413
  }
402
414
  for (const c of i) {
403
- const a = n[c];
415
+ const a = r[c];
404
416
  this[c] = this.#s(a);
405
- const f = e.get(c) ?? [];
406
- for (const l of f)
407
- s.add(l);
417
+ const h = e.get(c) ?? [];
418
+ for (const f of h)
419
+ s.add(f);
408
420
  }
409
421
  for (; ; ) {
410
422
  let c = !1;
411
423
  for (const a of i) {
412
- const f = n[a], l = this.#s(f), u = this[a];
413
- JSON.stringify(l) !== JSON.stringify(u) && (this[a] = l, c = !0);
424
+ const h = r[a], f = this.#s(h), l = this[a];
425
+ JSON.stringify(f) !== JSON.stringify(l) && (this[a] = f, c = !0);
414
426
  }
415
427
  if (!c) break;
416
428
  }
417
- this.#b([...s]), this.#a = !1;
429
+ this.#y([...s]), this.#f = !1;
418
430
  }
419
- async #S() {
431
+ async #x() {
420
432
  const t = this.#t;
421
433
  let { template: e } = t;
422
- e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await wt(e), this.shadowRoot.replaceChildren(e.content.cloneNode(!0));
434
+ e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await mt(e), this.shadowRoot.replaceChildren(e.content.cloneNode(!0));
423
435
  }
424
436
  static buildHTML() {
425
437
  let t = `<style>
@@ -427,63 +439,63 @@ class b extends HTMLElement {
427
439
  this.css && (t += this.css), t += `</style>
428
440
  `;
429
441
  let e = this.html.trim();
430
- if (!e) throw new x("static property html must be set");
442
+ if (!e) throw new E("static property html must be set");
431
443
  return e.startsWith("<") || (e = `<span><!--${e}--></span>`), t + e;
432
444
  }
433
445
  changed(t, e, s) {
434
446
  this[e] = s;
435
447
  }
436
448
  connectedCallback() {
437
- this.#H(), this.#x(), this.#S().then(() => {
438
- this.hasAttribute("disabled") && this.#m(), this.#v(this.shadowRoot), this.#g(this.shadowRoot), this.#C();
449
+ this.#_(), this.#R(), this.#x().then(() => {
450
+ this.hasAttribute("disabled") && this.#g(), this.#C(this.shadowRoot), this.#w(this.shadowRoot), this.#P();
439
451
  });
440
452
  }
441
- #C() {
453
+ #P() {
442
454
  const t = this.#t, { properties: e } = t;
443
455
  for (const [s, { computed: o }] of Object.entries(e))
444
456
  o && (this[s] = this.#s(o));
445
457
  }
446
- #x() {
458
+ #R() {
447
459
  const t = this.#t, { observedAttributes: e, properties: s } = t;
448
460
  for (const [o, i] of Object.entries(s))
449
- i.computed || this.#d(o, i, e);
461
+ i.computed || this.#b(o, i, e);
450
462
  for (const [o, i] of Object.entries(s))
451
- i.computed && this.#d(o, i, e);
463
+ i.computed && this.#b(o, i, e);
452
464
  }
453
- #d(t, e, s) {
465
+ #b(t, e, s) {
454
466
  if (t === "class" || t === "style")
455
- throw new x(`"${t}" is a reserved property`);
456
- const o = b.getAttrName(t), i = this.hasAttribute(o);
467
+ throw new E(`"${t}" is a reserved property`);
468
+ const o = u.getAttrName(t), i = this.hasAttribute(o);
457
469
  e.required && !i && this.#e(this, o, "is a required attribute");
458
- let n = e.value;
459
- this.hasOwnProperty(t) && (n = this[t], delete this[t]);
460
- const { type: c } = e, a = c === Boolean ? n || i : s.includes(o) && i ? this.#T(t, o) : n || yt(c), f = "#" + t;
461
- this[f] = a, e.computed && this.#R(t, e), Object.defineProperty(this, t, {
470
+ let r = e.value;
471
+ this.hasOwnProperty(t) && (r = this[t], delete this[t]);
472
+ const { type: c } = e, a = c === Boolean ? r || i : s.includes(o) && i ? this.#A(t, o) : r || ut(c), h = "#" + t;
473
+ this[h] = a, e.computed && this.#L(t, e), Object.defineProperty(this, t, {
462
474
  enumerable: !0,
463
475
  get() {
464
- return this[f];
476
+ return this[h];
465
477
  },
466
- set(l) {
467
- c === Number && typeof l == "string" && (l = W(l));
468
- const u = this[f];
469
- if (l === u) return;
470
- this.#k(t, c, l), this[f] = l;
471
- const { state: h, stateProp: d } = this.#t.properties[t];
472
- d && at(h, d, l), this.#O(t, c, l, o), this.#a || (this.#L(t), this.#w(t)), this.#j(t, l);
473
- const g = this.#f[t];
474
- g && this.setFormValue(g, String(l)), this.propertyChangedCallback(t, u, l), e.dispatch && this.dispatch("change", {
478
+ set(f) {
479
+ c === Number && typeof f == "string" && (f = H(f));
480
+ const l = this[h];
481
+ if (f === l) return;
482
+ this.#I(t, c, f), this[h] = f;
483
+ const m = this.#m.get(t);
484
+ m && st(m.state, m.stateProp, f), this.#j(t, c, f, o), this.#f || (this.#H(t), this.#M(t)), this.#k(t, f);
485
+ const x = this.#h[t];
486
+ x && this.setFormValue(x, String(f)), this.propertyChangedCallback(t, l, f), e.dispatch && this.dispatch("change", {
475
487
  tagName: this.localName,
476
488
  property: t,
477
- oldValue: u,
478
- value: l
489
+ oldValue: l,
490
+ value: f
479
491
  });
480
492
  }
481
493
  });
482
494
  }
483
- #m() {
484
- const t = this.hasAttribute("disabled"), e = j(this.shadowRoot);
495
+ #g() {
496
+ const t = this.hasAttribute("disabled"), e = R(this.shadowRoot);
485
497
  for (const s of e)
486
- gt(s) && (s.disabled = t);
498
+ pt(s) && (s.disabled = t);
487
499
  }
488
500
  disconnectedCallback() {
489
501
  this.#o.clear(), this.#l.clear(), this.#u.clear();
@@ -502,31 +514,32 @@ class b extends HTMLElement {
502
514
  displayIfSet(t, e = "block") {
503
515
  return `display: ${t ? e : "none"}`;
504
516
  }
505
- #P(t) {
506
- const e = t instanceof b;
517
+ #N(t) {
518
+ const e = t instanceof u;
507
519
  for (const s of t.getAttributeNames()) {
508
- const o = t.getAttribute(s), i = this.#E(t, o);
520
+ const o = t.getAttribute(s), i = this.#T(t, o);
509
521
  if (i) {
510
- const n = this[i];
511
- n === void 0 && this.#c(t, s, i), t[i] = n;
522
+ const r = this[i];
523
+ r === void 0 && this.#a(t, s, i);
512
524
  let [c, a] = s.split(":");
513
- c === "value" && (a ? (t["on" + a] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(c, this[i])) : a = "change"), e && t.#u.set(
514
- b.getPropName(c),
525
+ const h = u.getPropName(c);
526
+ t[h] = r, c === "value" && (a ? (t["on" + a] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(c, this[i])) : a = "change"), e && t.#u.set(
527
+ u.getPropName(c),
515
528
  i
516
529
  );
517
530
  }
518
- this.#r(o, t, s);
531
+ this.#c(o, t, s);
519
532
  }
520
533
  }
521
- #b(t) {
534
+ #y(t) {
522
535
  for (const e of t) {
523
536
  const s = this.#s(e), o = this.#o.get(e) ?? [];
524
537
  for (const i of o)
525
538
  if (i instanceof HTMLElement)
526
- this.#A(i, s);
539
+ this.#v(i, s);
527
540
  else if (!(i instanceof CSSStyleRule)) {
528
- const { element: n, attrName: c } = i;
529
- n instanceof CSSStyleRule ? n.style.setProperty(c, s) : B(n, c, s);
541
+ const { element: r, attrName: c } = i;
542
+ r instanceof CSSStyleRule ? r.style.setProperty(c, s) : k(r, c, s);
530
543
  }
531
544
  }
532
545
  }
@@ -537,34 +550,34 @@ class b extends HTMLElement {
537
550
  `const {${Object.keys(e).join(",")}} = context; return ${t};`
538
551
  ).call(this, e);
539
552
  }
540
- #N(t) {
553
+ #$(t) {
541
554
  const { localName: e } = t;
542
555
  if (e === "style") {
543
556
  const { sheet: s } = t, o = s?.cssRules ?? [], i = Array.from(o);
544
- for (const n of i)
545
- if (n.constructor === CSSStyleRule) {
546
- const c = Array.from(n.style);
557
+ for (const r of i)
558
+ if (r.constructor === CSSStyleRule) {
559
+ const c = Array.from(r.style);
547
560
  for (const a of c)
548
561
  if (a.startsWith("--")) {
549
- const f = n.style.getPropertyValue(a);
550
- this.#r(f, n, a);
562
+ const h = r.style.getPropertyValue(a);
563
+ this.#c(h, r, a);
551
564
  }
552
565
  }
553
566
  } else {
554
567
  let s = "";
555
- if (C(t)) {
556
- this.#r(t.textContent, t);
557
- const o = t.textContent?.match(dt);
568
+ if (A(t)) {
569
+ this.#c(t.textContent, t);
570
+ const o = t.textContent?.match(ft);
558
571
  o && (s = o[1]);
559
572
  } else {
560
573
  const o = Array.from(t.childNodes).find(
561
- (i) => i.nodeType === F.COMMENT_NODE
574
+ (i) => i.nodeType === Node.COMMENT_NODE
562
575
  );
563
576
  o && (s = o.textContent?.trim() ?? "");
564
577
  }
565
578
  if (s) {
566
- const o = this.#E(t, s);
567
- o && C(t) ? t.textContent = this[o] : this.#r(s, t);
579
+ const o = this.#T(t, s);
580
+ o && A(t) ? t.textContent = this[o] : this.#c(s, t);
568
581
  }
569
582
  }
570
583
  }
@@ -575,30 +588,30 @@ class b extends HTMLElement {
575
588
  formAssociatedCallback() {
576
589
  let t = this.getAttribute("form-assoc");
577
590
  if (!t) {
578
- const n = this.getAttribute("name");
579
- if (n)
580
- if (this.#n("value"))
581
- t = `value:${n}`;
591
+ const r = this.getAttribute("name");
592
+ if (r)
593
+ if (this.#r("value"))
594
+ t = `value:${r}`;
582
595
  else
583
596
  return;
584
597
  else
585
598
  return;
586
599
  }
587
600
  const e = {}, s = t.split(",");
588
- for (const n of s) {
589
- const [c, a] = n.split(":");
601
+ for (const r of s) {
602
+ const [c, a] = r.split(":");
590
603
  e[c.trim()] = a.trim();
591
604
  }
592
- this.#f = e, this.#i = new FormData(), this.#h = this.attachInternals(), this.#h.setFormValue(this.#i);
605
+ this.#h = e, this.#i = new FormData(), this.#p = this.attachInternals(), this.#p.setFormValue(this.#i);
593
606
  const o = Object.keys(this.#t.properties), i = this.#l;
594
- for (const n of o)
595
- i[n] = this[n];
607
+ for (const r of o)
608
+ i[r] = this[r];
596
609
  }
597
610
  formResetCallback() {
598
611
  const t = this.#l;
599
612
  for (const e of Object.keys(t)) {
600
613
  let s = t[e];
601
- V.test(s) && (s = this.#s(s)), this[e] = s;
614
+ L.test(s) && (s = this.#s(s)), this[e] = s;
602
615
  }
603
616
  }
604
617
  static getAttrName(t) {
@@ -609,32 +622,35 @@ class b extends HTMLElement {
609
622
  let e = this.attrToPropMap.get(t);
610
623
  return e || (e = t.replace(/-([a-z])/g, (s, o) => o.toUpperCase()), this.attrToPropMap.set(t, e)), e;
611
624
  }
612
- #$(t, e, s) {
625
+ #O(t, e, s) {
613
626
  if (s.length !== 1) return;
614
627
  const [o] = s;
615
- if (!V.test(o)) return;
616
- const i = J(t) || C(t);
617
- let [n, c] = (e ?? "").split(":");
618
- if (!(i && n === "value" || C(t))) return;
628
+ if (!L.test(o)) return;
629
+ const i = D(t) || A(t);
630
+ let [r, c] = (e ?? "").split(":");
631
+ if (!(i && r === "value" || A(t))) return;
619
632
  c ? t["on" + c] === void 0 && this.#e(t, e, "refers to an unsupported event name") : c = "change";
620
- const f = S(o);
621
- t.addEventListener(c, (l) => {
622
- const { target: u } = l;
623
- if (!u) return;
624
- const h = u.value, { type: d } = this.#t.properties[f];
625
- this[f] = d === Number ? W(h) : h, this.#w(f);
633
+ const h = M(o);
634
+ t.addEventListener(c, (f) => {
635
+ const { target: l } = f;
636
+ if (!l) return;
637
+ const m = l.value, { type: x } = this.#t.properties[h];
638
+ this[h] = x === Number ? H(m) : m, this.#M(h);
626
639
  });
627
640
  }
628
641
  #n(t) {
642
+ return Object.hasOwn(this.#t, t);
643
+ }
644
+ #r(t) {
629
645
  return !!this.#t.properties[t];
630
646
  }
631
- #g(t) {
647
+ #w(t) {
632
648
  const e = Array.from(t.querySelectorAll("*"));
633
649
  for (const s of e)
634
- this.#P(s), s.firstElementChild || this.#N(s);
650
+ this.#N(s), s.firstElementChild || this.#$(s);
635
651
  }
636
652
  // formAssociated is only needed when the component is inside a form.
637
- #y() {
653
+ #E() {
638
654
  if (this.#t.formAssociated || this.closest("form") === null) return;
639
655
  const t = this.#t.name;
640
656
  this.#e(
@@ -645,67 +661,67 @@ class b extends HTMLElement {
645
661
  }
646
662
  static get observedAttributes() {
647
663
  const t = Object.keys(this.properties || {}).map(
648
- (e) => b.getAttrName(e)
664
+ (e) => u.getAttrName(e)
649
665
  );
650
666
  return t.includes("disabled") || t.push("disabled"), t;
651
667
  }
652
668
  // Subclasses can override this to add functionality.
653
669
  propertyChangedCallback(t, e, s) {
654
670
  }
655
- #E(t, e) {
656
- if (!e || !V.test(e)) return;
657
- const s = S(e);
658
- return this[s] === void 0 && this.#c(t, "", s), s;
671
+ #T(t, e) {
672
+ if (!e || !L.test(e)) return;
673
+ const s = M(e);
674
+ return this[s] === void 0 && this.#a(t, "", s), s;
659
675
  }
660
- #w(t) {
676
+ #M(t) {
661
677
  const e = this.#t.propToExprsMap.get(t) || [];
662
- this.#b(e);
678
+ this.#y(e);
663
679
  }
664
- #R(t, e) {
680
+ #L(t, e) {
665
681
  const { computed: s, uses: o } = e, i = this.#t.propToComputedMap;
666
- function n(a, f) {
667
- let l = i.get(a);
668
- l || (l = [], i.set(a, l)), l.push([t, f]);
682
+ function r(a, h) {
683
+ let f = i.get(a);
684
+ f || (f = [], i.set(a, f)), f.push([t, h]);
669
685
  }
670
- const c = s.match(I) || [];
686
+ const c = s.match(j) || [];
671
687
  for (const a of c) {
672
- const f = S(a);
673
- this[f] === void 0 && this.#c(null, t, f), typeof this[f] != "function" && n(f, s);
688
+ const h = M(a);
689
+ this[h] === void 0 && this.#a(null, t, h), typeof this[h] != "function" && r(h, s);
674
690
  }
675
691
  if (o)
676
692
  for (const a of o.split(","))
677
- n(a.trim(), s);
693
+ r(a.trim(), s);
678
694
  }
679
695
  // WARNING: Do not place untrusted JavaScript expressions
680
696
  // in attribute values or the text content of elements!
681
- #r(t, e, s = void 0) {
697
+ #c(t, e, s = void 0) {
682
698
  if (!t) return;
683
- const o = this.#p(e, s, t);
699
+ const o = this.#d(e, s, t);
684
700
  if (!o) {
685
701
  const a = t.replaceAll("this..", "this.");
686
- s ? B(e, s, a) : "textContent" in e && (e.textContent = a);
702
+ s ? k(e, s, a) : "textContent" in e && (e.textContent = a);
687
703
  return;
688
704
  }
689
705
  const i = this.#t;
690
706
  o.forEach((a) => {
691
- const f = S(a);
692
- if (typeof this[f] == "function") return;
693
- const l = i.propToExprsMap;
694
- let u = l.get(f);
695
- u || (u = [], l.set(f, u)), u.includes(t) || u.push(t);
707
+ const h = M(a);
708
+ if (typeof this[h] == "function") return;
709
+ const f = i.propToExprsMap;
710
+ let l = f.get(h);
711
+ l || (l = [], f.set(h, l)), l.includes(t) || l.push(t);
696
712
  });
697
- for (const [a, f] of this.#o.entries())
698
- for (const l of f) {
699
- const u = l instanceof HTMLElement || l instanceof CSSStyleRule ? l : l.element;
700
- u instanceof CSSStyleRule || u.isConnected || this.#o.set(
713
+ for (const [a, h] of this.#o.entries())
714
+ for (const f of h) {
715
+ const l = f instanceof HTMLElement || f instanceof CSSStyleRule ? f : f.element;
716
+ l instanceof CSSStyleRule || l.isConnected || this.#o.set(
701
717
  a,
702
- f.filter((h) => h !== l)
718
+ h.filter((m) => m !== f)
703
719
  );
704
720
  }
705
- let n = this.#o.get(t);
706
- n || (n = [], this.#o.set(t, n)), n.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && this.#$(e, s, o);
721
+ let r = this.#o.get(t);
722
+ r || (r = [], this.#o.set(t, r)), r.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && this.#O(e, s, o);
707
723
  const c = this.#s(t);
708
- s ? B(e, s, c) : this.#A(e, c);
724
+ s ? k(e, s, c) : this.#v(e, c);
709
725
  }
710
726
  // This follows the best practice
711
727
  // "Do not override author-set, global attributes."
@@ -713,97 +729,57 @@ class b extends HTMLElement {
713
729
  this.hasAttribute(t) || this.setAttribute(t, e);
714
730
  }
715
731
  setFormValue(t, e) {
716
- !this.#i || !q(e) || (this.#i.set(t, e), this.#h?.setFormValue(this.#i));
732
+ !this.#i || !I(e) || (this.#i.set(t, e), this.#p?.setFormValue(this.#i));
717
733
  }
718
734
  static ssr(t = {}) {
719
- let e = "";
720
- const s = Object.keys(t);
721
- s.sort();
722
- for (const h of s) {
723
- const d = this.getAttrName(h);
724
- e += ` ${d}="${t[h]}"`;
725
- }
726
- const o = this.properties;
727
- for (const [h, d] of Object.entries(o))
728
- if (t[h] === void 0) {
729
- const { value: g } = d;
730
- g !== void 0 && (t[h] = g);
731
- }
732
- function i(h) {
733
- return new Function("return " + h).call(t);
734
- }
735
- function n(h) {
736
- const { attributes: d } = h;
737
- for (const [y, R] of Object.entries(d))
738
- if (L.test(R)) {
739
- const v = i(R), k = o[y].value;
740
- v === k ? h.removeAttribute(y) : h.setAttribute(y, v);
741
- }
742
- const { childNodes: g } = h;
743
- g.forEach((y, R) => {
744
- if (y.nodeType === F.ELEMENT_NODE)
745
- n(y);
746
- else if (y.nodeType === F.COMMENT_NODE) {
747
- const v = y.textContent ?? "";
748
- if (L.test(v)) {
749
- const k = i(v);
750
- g[R] = new ct(k);
751
- }
752
- }
753
- });
754
- }
755
- const c = this.buildHTML(), a = rt(c, { comment: !0 }), { children: f } = a;
756
- f.forEach(n);
757
- const l = f.map((h) => h.outerHTML).join(`
758
- `), { elementName: u } = this;
759
- return `
760
- <${u}${e}>
761
- <template shadowrootmode="open">
762
- ${l}
763
- </template>
764
- </${u}>
765
- `;
735
+ throw new E(
736
+ 'SSR support moved to the "wrec/ssr" entry. Import from "wrec/ssr" to use Wrec.ssr().'
737
+ );
766
738
  }
767
739
  #e(t, e, s) {
768
740
  const o = t instanceof HTMLElement ? t.localName : "CSS rule";
769
- throw new x(
741
+ throw new E(
770
742
  `component ${this.#t.elementName}` + (t ? `, element "${o}"` : "") + (e ? `, attribute "${e}"` : "") + ` ${s}`
771
743
  );
772
744
  }
773
- #c(t, e, s) {
745
+ #a(t, e, s) {
774
746
  this.#e(t, e, `refers to missing property "${s}"`);
775
747
  }
776
- #T(t, e) {
777
- return this.#M(t, this.getAttribute(e));
748
+ #A(t, e) {
749
+ return this.#S(t, this.getAttribute(e));
778
750
  }
779
- #M(t, e) {
780
- if (e?.match(I)) return e;
751
+ #S(t, e) {
752
+ if (e?.match(j)) return e;
781
753
  const s = this.#t, { type: o } = s.properties[t];
782
754
  if (o || this.#e(null, t, "does not specify its type"), o === String) return e;
783
- if (o === Number) return W(e);
784
- if (o === Boolean)
785
- return e === "true" ? !0 : e === "false" || e === "null" ? !1 : (e && e !== t && this.#e(
755
+ if (o === Number) return H(e);
756
+ if (o === Boolean) {
757
+ if (e === "true") return !0;
758
+ if (e === "false" || e === "null") return !1;
759
+ const i = u.getAttrName(t);
760
+ return e && e !== i && this.#e(
786
761
  null,
787
762
  t,
788
763
  "is a Boolean attribute, so its value must match attribute name or be missing"
789
- ), e === t);
764
+ ), e === "" || e === i;
765
+ }
790
766
  }
791
767
  // Updates the matching attribute for a property.
792
768
  // VS Code thinks this is never called, but it is called by #defineProp.
793
- #O(t, e, s, o) {
794
- if (q(s)) {
795
- const i = e === Boolean ? this.hasAttribute(o) : this.#T(t, o);
796
- s !== i && it(this, o || t, s);
769
+ #j(t, e, s, o) {
770
+ if (I(s)) {
771
+ const i = e === Boolean ? this.hasAttribute(o) : this.#A(t, o);
772
+ s !== i && et(this, o || t, s);
797
773
  }
798
774
  }
799
775
  // Updates all computed properties that reference this property.
800
776
  // VS Code thinks this is never called, but it is called by #defineProp.
801
- #L(t) {
777
+ #H(t) {
802
778
  const s = this.#t.propToComputedMap.get(t) || [];
803
779
  for (const [o, i] of s)
804
780
  this[o] = this.#s(i);
805
781
  }
806
- #A(t, e) {
782
+ #v(t, e) {
807
783
  if (e === void 0) return;
808
784
  const s = t instanceof HTMLElement;
809
785
  Array.isArray(e) && (e = e.join(""));
@@ -814,24 +790,24 @@ class b extends HTMLElement {
814
790
  " computed content is not a string or number"
815
791
  );
816
792
  const i = String(e);
817
- if (t instanceof HTMLElement && C(t))
793
+ if (t instanceof HTMLElement && A(t))
818
794
  t.value = i;
819
795
  else if (s && o === "string" && i.trim().startsWith("<")) {
820
- const n = lt(i);
821
- t.innerHTML = n, this.#v(t), this.#g(t);
796
+ const r = it(i);
797
+ t.innerHTML = r, this.#C(t), this.#w(t);
822
798
  } else s && (t.textContent = i);
823
799
  }
824
800
  // Update corresponding parent web component property if bound to one.
825
801
  // VS Code thinks this is never called, but it is called by #defineProp.
826
- #j(t, e) {
802
+ #k(t, e) {
827
803
  const s = this.#u.get(t);
828
804
  if (!s) return;
829
805
  const o = this.getRootNode();
830
806
  if (!(o instanceof ShadowRoot)) return;
831
807
  const { host: i } = o;
832
808
  if (!i) return;
833
- const n = i;
834
- n[s] = e;
809
+ const r = i;
810
+ r[s] = e;
835
811
  }
836
812
  /**
837
813
  * @param state - WrecState object
@@ -844,45 +820,43 @@ class b extends HTMLElement {
844
820
  for (const s of Object.keys(t))
845
821
  e[s] = s;
846
822
  }
847
- this.#_(t, e);
823
+ this.#F(t, e);
848
824
  for (const [s, o] of Object.entries(e))
849
- if (this.#n(o)) {
850
- const i = Y(t, s);
851
- i !== void 0 && (this[o] = i);
852
- const n = this.#t.properties[o];
853
- n.state = t, n.stateProp = s;
825
+ if (this.#r(o)) {
826
+ const i = q(t, s);
827
+ i !== void 0 && (this[o] = i), this.#m.set(o, { state: t, stateProp: s });
854
828
  }
855
829
  t.addListener(this, e);
856
830
  }
857
- #H() {
831
+ #_() {
858
832
  const t = new Set(Object.keys(this.#t.properties));
859
833
  for (const e of this.getAttributeNames())
860
- if (!ht.has(e) && !e.startsWith("on")) {
834
+ if (!nt.has(e) && !e.startsWith("on")) {
861
835
  if (e === "form-assoc") {
862
- this.#y();
836
+ this.#E();
863
837
  continue;
864
838
  }
865
- if (!t.has(b.getPropName(e))) {
839
+ if (!t.has(u.getPropName(e))) {
866
840
  if (e === "name") {
867
- this.#y();
841
+ this.#E();
868
842
  continue;
869
843
  }
870
844
  this.#e(null, e, "is not a supported attribute");
871
845
  }
872
846
  }
873
847
  }
874
- #p(t, e, s) {
875
- const o = s.match(I);
848
+ #d(t, e, s) {
849
+ const o = s.match(j);
876
850
  if (o)
877
851
  return o.forEach((i) => {
878
- const n = S(i);
879
- this[n] === void 0 && this.#c(t, e, n);
852
+ const r = M(i);
853
+ this[r] === void 0 && this.#a(t, e, r);
880
854
  }), o;
881
855
  }
882
- #_(t, e) {
856
+ #F(t, e) {
883
857
  for (const [s, o] of Object.entries(e)) {
884
- let i = Y(t, s);
885
- i === void 0 && this.#e(this, void 0, `invalid state path "${s}"`), i = this[o], this.#n(o) || this.#e(
858
+ let i = q(t, s);
859
+ i === void 0 && this.#e(this, void 0, `invalid state path "${s}"`), i = this[o], this.#r(o) || this.#e(
886
860
  null,
887
861
  o,
888
862
  "refers to missing property in useState map"
@@ -891,7 +865,7 @@ class b extends HTMLElement {
891
865
  }
892
866
  // When type is an array, this can't validate the type of the array elements.
893
867
  // This is called by #defineProp.
894
- #k(t, e, s) {
868
+ #I(t, e, s) {
895
869
  if (s instanceof e) return;
896
870
  let o = typeof s;
897
871
  if (o === "object") {
@@ -908,19 +882,19 @@ class b extends HTMLElement {
908
882
  `was set to a ${o}, but must be a ${e.name}`
909
883
  );
910
884
  }
911
- #v(t) {
885
+ #C(t) {
912
886
  const e = Array.from(t.querySelectorAll("*"));
913
887
  for (const s of e) {
914
888
  const o = [];
915
889
  for (const i of Array.from(s.attributes)) {
916
- const n = i.name;
917
- if (n.startsWith("on")) {
918
- let c = n.slice(2);
890
+ const r = i.name;
891
+ if (r.startsWith("on")) {
892
+ let c = r.slice(2);
919
893
  c = c[0].toLowerCase() + c.slice(1).toLowerCase();
920
894
  const a = i.value;
921
- this.#p(s, n, a);
922
- let f;
923
- typeof this[a] == "function" ? f = (l) => this[a](l) : (this.#p(s, n, a), f = () => this.#s(a)), s.addEventListener(c, f), o.push(n);
895
+ this.#d(s, r, a);
896
+ let h;
897
+ typeof this[a] == "function" ? h = (f) => this[a](f) : (this.#d(s, r, a), h = () => this.#s(a)), s.addEventListener(c, h), o.push(r);
924
898
  }
925
899
  }
926
900
  for (const i of o)
@@ -928,40 +902,40 @@ class b extends HTMLElement {
928
902
  }
929
903
  }
930
904
  }
931
- function Ct(r, ...t) {
932
- let e = st(r, t);
905
+ function Et(n, ...t) {
906
+ let e = Q(n, t);
933
907
  for (; ; ) {
934
- const s = ut.exec(e);
908
+ const s = ct.exec(e);
935
909
  if (!s) break;
936
910
  const o = s[2];
937
- if (L.test(o)) {
911
+ if (G.test(o)) {
938
912
  const i = s[1];
939
913
  if (!i.startsWith("--")) {
940
- const n = `--${i}: ${o};
914
+ const r = `--${i}: ${o};
941
915
  ${i}: var(--${i})`;
942
- e = ot(e, s.index, s[0].length, n);
916
+ e = tt(e, s.index, s[0].length, r);
943
917
  }
944
918
  }
945
919
  }
946
920
  return e;
947
921
  }
948
- function xt(r, ...t) {
949
- let e = st(r, t);
922
+ function Tt(n, ...t) {
923
+ let e = Q(n, t);
950
924
  for (; ; ) {
951
- const s = mt.exec(e);
925
+ const s = ht.exec(e);
952
926
  if (!s || s[1] === "style") break;
953
- const o = Et(s[2]);
954
- if (L.test(o)) {
955
- const i = `<!-- ${o.trim()} -->`, n = s.index + s[0].indexOf(">") + 1;
956
- e = ot(e, n, o.length, i);
927
+ const o = dt(s[2]);
928
+ if (G.test(o)) {
929
+ const i = `<!-- ${o.trim()} -->`, r = s.index + s[0].indexOf(">") + 1;
930
+ e = tt(e, r, o.length, i);
957
931
  }
958
932
  }
959
933
  return e;
960
934
  }
961
935
  export {
962
- b as Wrec,
963
- z as WrecState,
964
- St as createElement,
965
- Ct as css,
966
- xt as html
936
+ u as Wrec,
937
+ _ as WrecState,
938
+ wt as createElement,
939
+ Et as css,
940
+ Tt as html
967
941
  };