@skaldapp/monaco-sfc 1.2.5 → 1.2.7

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 (2) hide show
  1. package/dist/vue.worker.js +1714 -542
  2. package/package.json +5 -5
@@ -46,6 +46,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
46
46
  //#endregion
47
47
  //#region node_modules/@remote-dom/polyfill/build/esm/constants.mjs
48
48
  var NAME = Symbol("name");
49
+ var PREFIX = Symbol("prefix");
49
50
  var VALUE = Symbol("value");
50
51
  var NS = Symbol("ns");
51
52
  var OWNER_ELEMENT = Symbol("owner");
@@ -55,50 +56,84 @@ var PREV = Symbol("prev");
55
56
  var NEXT = Symbol("next");
56
57
  var CHILD = Symbol("child");
57
58
  var PARENT = Symbol("parent");
59
+ var HOST = Symbol("host");
58
60
  var DATA = Symbol("data");
59
61
  var LISTENERS = Symbol("listeners");
60
62
  var IS_TRUSTED = Symbol("isTrusted");
61
63
  var PATH = Symbol("path");
62
64
  var STOP_IMMEDIATE_PROPAGATION = Symbol("stop_immediate_propagation");
65
+ var DISPATCHING = Symbol("dispatching");
63
66
  var CONTENT = Symbol("content");
64
67
  var HOOKS = Symbol("hooks");
68
+ var EXTENSIONS = Symbol("extensions");
69
+ var HOOKS_DISPATCH = Symbol("hooks_dispatch");
65
70
  var IS_CONNECTED = Symbol("is_connected");
66
- var NodeType$1 = /*#__PURE__*/ function(NodeType) {
67
- NodeType[NodeType["NODE"] = 0] = "NODE";
68
- NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
69
- NodeType[NodeType["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE";
70
- NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE";
71
- NodeType[NodeType["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE";
72
- NodeType[NodeType["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE";
73
- NodeType[NodeType["ENTITY_NODE"] = 6] = "ENTITY_NODE";
74
- NodeType[NodeType["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE";
75
- NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE";
76
- NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE";
77
- NodeType[NodeType["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE";
78
- NodeType[NodeType["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE";
79
- return NodeType;
80
- }({});
81
- var NamespaceURI = /*#__PURE__*/ function(NamespaceURI) {
82
- NamespaceURI["XHTML"] = "http://www.w3.org/1999/xhtml";
83
- NamespaceURI["SVG"] = "http://www.w3.org/2000/svg";
84
- return NamespaceURI;
85
- }({});
71
+ var CREATE_ELEMENT = Symbol("create_element");
72
+ var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
73
+ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
74
+ var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
75
+ function splitOnASCIIWhitespace(value) {
76
+ return value.split(/[\t\n\f\r ]+/).filter(Boolean);
77
+ }
78
+ function asciiLowercase(value) {
79
+ return value.replace(/[A-Z]/g, (character) => String.fromCharCode(character.charCodeAt(0) + 32));
80
+ }
81
+ function asciiUppercase(value) {
82
+ return value.replace(/[a-z]/g, (character) => String.fromCharCode(character.charCodeAt(0) - 32));
83
+ }
84
+ //#endregion
85
+ //#region node_modules/@remote-dom/polyfill/build/esm/dom-exception.mjs
86
+ function createDOMException(message, name) {
87
+ const DOMExceptionConstructor = globalThis.DOMException;
88
+ if (typeof DOMExceptionConstructor === "function") return new DOMExceptionConstructor(message, name);
89
+ const error = new Error(message);
90
+ error.name = name;
91
+ return error;
92
+ }
86
93
  //#endregion
87
- //#region node_modules/@remote-dom/polyfill/build/esm/Event.mjs
88
- var EventPhase = /*#__PURE__*/ function(EventPhase) {
89
- EventPhase[EventPhase["NONE"] = 0] = "NONE";
90
- EventPhase[EventPhase["CAPTURING_PHASE"] = 1] = "CAPTURING_PHASE";
91
- EventPhase[EventPhase["AT_TARGET"] = 2] = "AT_TARGET";
92
- EventPhase[EventPhase["BUBBLING_PHASE"] = 3] = "BUBBLING_PHASE";
93
- return EventPhase;
94
- }({});
94
+ //#region node_modules/@remote-dom/polyfill/build/esm/names.mjs
95
+ var VALID_ELEMENT_LOCAL_NAME = /^(?:[A-Za-z][^\0\t\n\f\r\u0020/>]*|[:_\u0080-\u{10FFFF}][A-Za-z0-9-.:_\u0080-\u{10FFFF}]*)$/u;
96
+ var INVALID_ATTRIBUTE_LOCAL_NAME = /[\0\t\n\f\r />=]/u;
97
+ var INVALID_NAMESPACE_PREFIX = /[\0\t\n\f\r />]/u;
98
+ function normalizeNamespace(namespace) {
99
+ if (namespace == null) return null;
100
+ const normalized = String(namespace);
101
+ return normalized === "" ? null : normalized;
102
+ }
103
+ function validateElementLocalName(name) {
104
+ if (!VALID_ELEMENT_LOCAL_NAME.test(name)) throwInvalidCharacterError(name);
105
+ }
106
+ function validateAttributeLocalName(name) {
107
+ if (name === "" || INVALID_ATTRIBUTE_LOCAL_NAME.test(name)) throwInvalidCharacterError(name);
108
+ }
109
+ function validateAndExtractQualifiedName(namespaceValue, qualifiedNameValue, kind) {
110
+ const namespace = normalizeNamespace(namespaceValue);
111
+ const qualifiedName = String(qualifiedNameValue);
112
+ const separator = qualifiedName.indexOf(":");
113
+ const prefix = separator < 0 ? null : qualifiedName.slice(0, separator);
114
+ const localName = separator < 0 ? qualifiedName : qualifiedName.slice(separator + 1);
115
+ if (prefix != null && (prefix === "" || INVALID_NAMESPACE_PREFIX.test(prefix)) || (kind === "element" ? !VALID_ELEMENT_LOCAL_NAME.test(localName) : localName === "" || INVALID_ATTRIBUTE_LOCAL_NAME.test(localName))) throwInvalidCharacterError(qualifiedName);
116
+ if (prefix != null && namespace == null) throw createDOMException(`A namespace is required for the prefix in "${qualifiedName}"`, "NamespaceError");
117
+ if (prefix === "xml" && namespace !== "http://www.w3.org/XML/1998/namespace") throw createDOMException(`The xml prefix requires the XML namespace`, "NamespaceError");
118
+ if ((qualifiedName === "xmlns" || prefix === "xmlns") && namespace !== "http://www.w3.org/2000/xmlns/") throw createDOMException(`The xmlns name requires the XMLNS namespace`, "NamespaceError");
119
+ if (namespace === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && prefix !== "xmlns") throw createDOMException(`The XMLNS namespace requires the xmlns name or prefix`, "NamespaceError");
120
+ return {
121
+ namespace,
122
+ qualifiedName,
123
+ prefix,
124
+ localName
125
+ };
126
+ }
127
+ function throwInvalidCharacterError(name) {
128
+ throw createDOMException(`Invalid name: "${name}"`, "InvalidCharacterError");
129
+ }
95
130
  var now = typeof performance === "undefined" ? Date.now : performance.now.bind(performance);
96
131
  var Event = class {
97
- static NONE = (() => EventPhase.NONE)();
98
- static CAPTURING_PHASE = (() => EventPhase.CAPTURING_PHASE)();
99
- static AT_TARGET = (() => EventPhase.AT_TARGET)();
100
- static BUBBLING_PHASE = (() => EventPhase.BUBBLING_PHASE)();
101
- timeStamp = (() => now())();
132
+ static NONE = 0;
133
+ static CAPTURING_PHASE = 1;
134
+ static AT_TARGET = 2;
135
+ static BUBBLING_PHASE = 3;
136
+ timeStamp = now();
102
137
  target = null;
103
138
  currentTarget = null;
104
139
  srcElement = null;
@@ -110,6 +145,7 @@ var Event = class {
110
145
  eventPhase = 0;
111
146
  [PATH] = [];
112
147
  [STOP_IMMEDIATE_PROPAGATION] = false;
148
+ [DISPATCHING] = false;
113
149
  constructor(type, options) {
114
150
  this.type = type;
115
151
  Object.defineProperty(this, IS_TRUSTED, {
@@ -126,7 +162,7 @@ var Event = class {
126
162
  return this[IS_TRUSTED];
127
163
  }
128
164
  composedPath() {
129
- return this[PATH];
165
+ return [...this[PATH]];
130
166
  }
131
167
  stopPropagation() {
132
168
  this.cancelBubble = true;
@@ -136,13 +172,13 @@ var Event = class {
136
172
  this.cancelBubble = true;
137
173
  }
138
174
  preventDefault() {
139
- this.defaultPrevented = true;
175
+ if (this.cancelable) this.defaultPrevented = true;
140
176
  }
141
177
  set returnValue(value) {
142
- this.defaultPrevented = value;
178
+ if (!value) this.preventDefault();
143
179
  }
144
180
  get returnValue() {
145
- return this.defaultPrevented;
181
+ return !this.defaultPrevented;
146
182
  }
147
183
  /** @deprecated */
148
184
  initEvent(type, bubbles, cancelable) {
@@ -152,11 +188,14 @@ var Event = class {
152
188
  }
153
189
  };
154
190
  function fireEvent(event, currentTarget, phase) {
155
- const list = currentTarget[LISTENERS]?.get(`${event.type}${phase === EventPhase.CAPTURING_PHASE ? "@" : ""}`);
191
+ if (event.cancelBubble) return;
192
+ const list = currentTarget[LISTENERS]?.get(event.type)?.[phase === 1 ? "capture" : "bubble"];
156
193
  if (!list) return;
157
- for (const listener of list) {
158
- event.eventPhase = event.target === currentTarget ? EventPhase.AT_TARGET : phase;
194
+ for (const registration of [...list]) {
195
+ if (!list.has(registration) || registration.signal?.aborted) continue;
196
+ event.eventPhase = event.target === currentTarget ? 2 : phase;
159
197
  event.currentTarget = currentTarget;
198
+ const listener = registration.normalizedListener;
160
199
  try {
161
200
  if (typeof listener === "object") listener.handleEvent(event);
162
201
  else listener.call(currentTarget, event);
@@ -170,140 +209,649 @@ function thrower(error) {
170
209
  throw error;
171
210
  }
172
211
  //#endregion
212
+ //#region node_modules/@remote-dom/polyfill/build/esm/custom-element-reactions.mjs
213
+ var scopes = [];
214
+ var reactionsByTarget = /* @__PURE__ */ new WeakMap();
215
+ function enqueueCustomElementReaction(target, reaction) {
216
+ const reactions = reactionsByTarget.get(target);
217
+ if (reactions) reactions.push(reaction);
218
+ else reactionsByTarget.set(target, [reaction]);
219
+ scopes[scopes.length - 1].push(target);
220
+ }
221
+ function performWithCustomElementReactions(mutation) {
222
+ const scope = [];
223
+ scopes.push(scope);
224
+ let result;
225
+ try {
226
+ result = mutation();
227
+ } catch (error) {
228
+ scopes.pop();
229
+ try {
230
+ flushCustomElementReactions(scope);
231
+ } catch {}
232
+ throw error;
233
+ }
234
+ scopes.pop();
235
+ flushCustomElementReactions(scope);
236
+ return result;
237
+ }
238
+ function flushCustomElementReactions(scope) {
239
+ let firstError;
240
+ let didThrow = false;
241
+ for (const target of scope) {
242
+ const reactions = reactionsByTarget.get(target);
243
+ if (!reactions) continue;
244
+ while (reactions.length > 0) {
245
+ const reaction = reactions.shift();
246
+ try {
247
+ reaction();
248
+ } catch (error) {
249
+ if (!didThrow) {
250
+ firstError = error;
251
+ didThrow = true;
252
+ }
253
+ }
254
+ }
255
+ reactionsByTarget.delete(target);
256
+ }
257
+ if (didThrow) throw firstError;
258
+ }
259
+ //#endregion
260
+ //#region node_modules/@remote-dom/polyfill/build/esm/hook-effects.mjs
261
+ var hookEffects = [];
262
+ var pendingPublications = [];
263
+ var isDispatchingHookEffects = false;
264
+ function performHookEffects(effects) {
265
+ for (const effect of effects) {
266
+ hookEffects.push(effect);
267
+ if (effect[1]) pendingPublications.push(effect[1]);
268
+ }
269
+ if (isDispatchingHookEffects) return;
270
+ isDispatchingHookEffects = true;
271
+ try {
272
+ let firstError;
273
+ let didThrow = false;
274
+ for (let index = 0; index < hookEffects.length; index++) {
275
+ const [run, publication] = hookEffects[index];
276
+ if (publication) pendingPublications.splice(pendingPublications.indexOf(publication), 1);
277
+ try {
278
+ run();
279
+ } catch (error) {
280
+ if (!didThrow) {
281
+ firstError = error;
282
+ didThrow = true;
283
+ }
284
+ }
285
+ }
286
+ if (didThrow) throw firstError;
287
+ } finally {
288
+ hookEffects.length = 0;
289
+ pendingPublications.length = 0;
290
+ isDispatchingHookEffects = false;
291
+ }
292
+ }
293
+ function isCoveredByPendingPublication(node) {
294
+ let current = node;
295
+ while (current) {
296
+ if (pendingPublications.includes(current)) return true;
297
+ current = current[PARENT] ?? current[HOST];
298
+ }
299
+ return false;
300
+ }
301
+ //#endregion
173
302
  //#region node_modules/@remote-dom/polyfill/build/esm/EventTarget.mjs
174
- var ONCE_LISTENERS = Symbol("onceListeners");
303
+ var LISTENER_REGISTRATIONS = Symbol("listenerRegistrations");
175
304
  var EventTarget = class {
176
- [LISTENERS] = (() => void 0)();
177
- [ONCE_LISTENERS] = (() => void 0)();
305
+ [LISTENERS] = void 0;
306
+ [LISTENER_REGISTRATIONS] = void 0;
178
307
  /**
179
308
  * Property set by entities that extend this class that are part of the DOM tree.
180
309
  * @internal
181
310
  */
182
- [OWNER_DOCUMENT] = (() => void 0)();
311
+ [OWNER_DOCUMENT] = void 0;
183
312
  addEventListener(type, listener, options) {
184
313
  if (listener == null) return;
185
- const capture = options === true || options && options.capture === true;
314
+ const capture = options === true || typeof options === "object" && options.capture === true;
186
315
  const once = typeof options === "object" && options.once === true;
187
316
  const signal = typeof options === "object" ? options.signal : void 0;
188
- const key = `${type}${capture ? "@" : ""}`;
189
- let normalizedListener = listener;
190
- if (once) {
191
- normalizedListener = function normalizedListener(...args) {
192
- this.removeEventListener(type, listener, options);
193
- return typeof listener === "object" ? listener.handleEvent(...args) : listener.call(this, ...args);
194
- };
195
- let onceListeners = this[ONCE_LISTENERS];
196
- if (!onceListeners) {
197
- onceListeners = /* @__PURE__ */ new WeakMap();
198
- this[ONCE_LISTENERS] = onceListeners;
317
+ if (signal?.aborted) return;
318
+ const phase = listenerPhase(capture);
319
+ let registrations = this[LISTENER_REGISTRATIONS];
320
+ if (!registrations) {
321
+ registrations = /* @__PURE__ */ new Map();
322
+ this[LISTENER_REGISTRATIONS] = registrations;
323
+ }
324
+ let registrationsForType = registrations.get(type);
325
+ if (!registrationsForType) {
326
+ registrationsForType = {};
327
+ registrations.set(type, registrationsForType);
328
+ }
329
+ let registrationsForPhase = registrationsForType[phase];
330
+ if (!registrationsForPhase) {
331
+ registrationsForPhase = /* @__PURE__ */ new Map();
332
+ registrationsForType[phase] = registrationsForPhase;
333
+ }
334
+ if (registrationsForPhase.has(listener)) return;
335
+ const target = this;
336
+ const registration = {
337
+ type,
338
+ listener,
339
+ capture,
340
+ once,
341
+ normalizedListener: listener,
342
+ signal
343
+ };
344
+ if (once || signal) registration.normalizedListener = function normalizedListener(...args) {
345
+ if (registration.signal?.aborted) {
346
+ removeListenerRegistration(target, registration);
347
+ return;
199
348
  }
200
- onceListeners.set(listener, normalizedListener);
201
- }
349
+ if (registration.once) removeListenerRegistration(target, registration);
350
+ return typeof registration.listener === "object" ? registration.listener.handleEvent(...args) : registration.listener.call(this, ...args);
351
+ };
202
352
  let listeners = this[LISTENERS];
203
353
  if (!listeners) {
204
354
  listeners = /* @__PURE__ */ new Map();
205
355
  this[LISTENERS] = listeners;
206
356
  }
207
- let list = listeners.get(key);
357
+ let listenersForType = listeners.get(type);
358
+ if (!listenersForType) {
359
+ listenersForType = {};
360
+ listeners.set(type, listenersForType);
361
+ }
362
+ let list = listenersForType[phase];
208
363
  if (!list) {
209
364
  list = /* @__PURE__ */ new Set();
210
- listeners.set(key, list);
365
+ listenersForType[phase] = list;
366
+ }
367
+ registrationsForPhase.set(listener, registration);
368
+ list.add(registration);
369
+ if (signal) {
370
+ const abortListener = () => {
371
+ removeListenerRegistration(target, registration);
372
+ };
373
+ registration.abortListener = abortListener;
374
+ signal.addEventListener("abort", abortListener, { once: true });
211
375
  }
212
- if (list.has(normalizedListener)) return;
213
- signal?.addEventListener("abort", () => {
214
- removeEventListener.call(this, type, listener, options);
215
- }, { once: true });
216
- list.add(normalizedListener);
217
- this[OWNER_DOCUMENT]?.defaultView[HOOKS].addEventListener?.(this, type, listener, options);
376
+ this[OWNER_DOCUMENT]?.defaultView[HOOKS_DISPATCH].addEventListener?.(this, type, listener, options);
218
377
  }
219
378
  removeEventListener(type, listener, options) {
220
379
  return removeEventListener.call(this, type, listener, options);
221
380
  }
222
381
  dispatchEvent(event) {
223
- const path = [];
224
- let target = this;
225
- while (target != null) {
226
- path.push(target);
227
- target = target.parentNode;
228
- }
229
- event.target = this;
230
- event.srcElement = this;
231
- event[PATH] = path;
232
- for (let i = path.length; i--;) {
233
- fireEvent(event, path[i], EventPhase.CAPTURING_PHASE);
234
- if (event.cancelBubble) return event.defaultPrevented;
235
- }
236
- const bubblePath = event.bubbles ? path : path.slice(0, 1);
237
- for (let i = 0; i < bubblePath.length; i++) {
238
- fireEvent(event, bubblePath[i], EventPhase.BUBBLING_PHASE);
239
- if (event.cancelBubble) return event.defaultPrevented;
240
- }
241
- return event.defaultPrevented;
382
+ if (event[DISPATCHING]) throw createDOMException(`Failed to execute 'dispatchEvent' on 'EventTarget': The event is already being dispatched.`, "InvalidStateError");
383
+ event[DISPATCHING] = true;
384
+ try {
385
+ const path = [];
386
+ let target = this;
387
+ while (target != null) {
388
+ path.push(target);
389
+ target = target.parentNode;
390
+ }
391
+ event.target = this;
392
+ event.srcElement = this;
393
+ event[PATH] = path;
394
+ for (let i = path.length; i--;) {
395
+ fireEvent(event, path[i], 1);
396
+ if (event.cancelBubble) return !event.defaultPrevented;
397
+ }
398
+ const bubblePath = event.bubbles ? path : path.slice(0, 1);
399
+ for (let i = 0; i < bubblePath.length; i++) {
400
+ fireEvent(event, bubblePath[i], 3);
401
+ if (event.cancelBubble) return !event.defaultPrevented;
402
+ }
403
+ return !event.defaultPrevented;
404
+ } finally {
405
+ event[DISPATCHING] = false;
406
+ event.cancelBubble = false;
407
+ event[STOP_IMMEDIATE_PROPAGATION] = false;
408
+ event.eventPhase = 0;
409
+ event.currentTarget = null;
410
+ event[PATH] = [];
411
+ }
242
412
  }
243
413
  };
244
414
  function removeEventListener(type, listener, options) {
245
415
  if (listener == null) return;
246
- const onceListeners = this[ONCE_LISTENERS];
247
- const normalizedListener = onceListeners?.get(listener) ?? listener;
248
- onceListeners?.delete(listener);
249
- const key = `${type}${options === true || options && options.capture === true ? "@" : ""}`;
250
- const list = this[LISTENERS]?.get(key);
251
- if (list) {
252
- if (list.delete(normalizedListener)) this[OWNER_DOCUMENT]?.defaultView[HOOKS].removeEventListener?.(this, type, listener, options);
416
+ const capture = options === true || options && options.capture === true;
417
+ const phase = listenerPhase(Boolean(capture));
418
+ const registration = this[LISTENER_REGISTRATIONS]?.get(type)?.[phase]?.get(listener);
419
+ if (!registration) return;
420
+ removeListenerRegistration(this, registration);
421
+ }
422
+ function listenerPhase(capture) {
423
+ return capture ? "capture" : "bubble";
424
+ }
425
+ function removeListenerRegistration(target, registration) {
426
+ const phase = listenerPhase(registration.capture);
427
+ const registrations = target[LISTENER_REGISTRATIONS];
428
+ const registrationsForType = registrations?.get(registration.type);
429
+ if (!registrationsForType) return;
430
+ const registrationsForPhase = registrationsForType[phase];
431
+ if (!registrationsForPhase || registrationsForPhase.get(registration.listener) !== registration) return;
432
+ registrationsForPhase.delete(registration.listener);
433
+ if (registrationsForPhase.size === 0) delete registrationsForType[phase];
434
+ if (!registrationsForType.bubble && !registrationsForType.capture) registrations?.delete(registration.type);
435
+ if (registration.signal && registration.abortListener) registration.signal.removeEventListener("abort", registration.abortListener);
436
+ const listeners = target[LISTENERS];
437
+ const listenersForType = listeners?.get(registration.type);
438
+ if (!listenersForType) return;
439
+ const list = listenersForType[phase];
440
+ if (!list?.delete(registration)) return;
441
+ if (list.size === 0) delete listenersForType[phase];
442
+ if (!listenersForType.bubble && !listenersForType.capture) listeners?.delete(registration.type);
443
+ target[OWNER_DOCUMENT]?.defaultView[HOOKS_DISPATCH].removeEventListener?.(target, registration.type, registration.listener, registration.capture);
444
+ }
445
+ //#endregion
446
+ //#region node_modules/@remote-dom/polyfill/build/esm/NodeList.mjs
447
+ var NodeList = class extends Array {
448
+ item(index) {
449
+ return this[index] ?? null;
253
450
  }
451
+ };
452
+ var SUPPORTED_IDENTIFIER_TEST = /^(?:--|-?[A-Za-z_\u0080-\u{10FFFF}])[A-Za-z0-9_\u0080-\u{10FFFF}-]*$/u;
453
+ function readFunctionArgument(selector, start) {
454
+ let depth = 1;
455
+ let quote = null;
456
+ for (let index = start; index < selector.length; index++) {
457
+ const character = selector[index];
458
+ if (quote) {
459
+ if (character === "\\") index++;
460
+ else if (character === quote) quote = null;
461
+ continue;
462
+ }
463
+ if (character === "\"" || character === "'") quote = character;
464
+ else if (character === "(") depth++;
465
+ else if (character === ")" && --depth === 0) return [selector.slice(start, index), index + 1];
466
+ }
467
+ return [selector.slice(start), selector.length];
468
+ }
469
+ function throwSelectorSyntaxError(selector) {
470
+ throw createDOMException(`Invalid or unsupported selector: "${selector}"`, "SyntaxError");
471
+ }
472
+ function querySelector(within, selector) {
473
+ const parts = typeof selector === "string" ? parseSelector(selector) : [{
474
+ combinator: 4,
475
+ matchers: selector
476
+ }];
477
+ let result = null;
478
+ const child = within[CHILD];
479
+ if (child && parts[0].matchers.length) walkNodesForSelector(child, parts, (node) => {
480
+ result = node;
481
+ return false;
482
+ });
483
+ return result;
484
+ }
485
+ function querySelectorAll(within, selector) {
486
+ const parts = typeof selector === "string" ? parseSelector(selector) : [{
487
+ combinator: 4,
488
+ matchers: selector
489
+ }];
490
+ const results = new NodeList();
491
+ const child = within[CHILD];
492
+ if (child && parts[0].matchers.length) walkNodesForSelector(child, parts, (node) => {
493
+ results.push(node);
494
+ });
495
+ return results;
496
+ }
497
+ function parseSelector(selector, insideHas = false, allowLeadingCombinator = false) {
498
+ let part = {
499
+ combinator: 4,
500
+ matchers: []
501
+ };
502
+ const parts = [part];
503
+ const tokenizer = /[\t\n\f\r ]*?([>\t\n\f\r +~]?)[\t\n\f\r ]*?(?:(?:\[[\t\n\f\r ]*([^\]=\t\n\f\r ]+)[\t\n\f\r ]*(?:=[\t\n\f\r ]*(?:(['"])(.*?)\3|([^\]\t\n\f\r ]+)))?[\t\n\f\r ]*(?:\]|$))|([#.]?)([^\t\n\f\r #.[>:+~()]+)|:(\w+)(\()?)/gi;
504
+ const normalizedSelector = selector.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, "");
505
+ if (normalizedSelector === "") throwSelectorSyntaxError(selector);
506
+ let consumed = 0;
507
+ let token;
508
+ while (token = tokenizer.exec(normalizedSelector)) {
509
+ if (token.index !== consumed) throwSelectorSyntaxError(selector);
510
+ if (token[1]) {
511
+ if (part.matchers.length === 0 && !(allowLeadingCombinator && parts.length === 1)) throwSelectorSyntaxError(selector);
512
+ if (token[1] === ">") part.combinator = 1;
513
+ else if (token[1] === "+") part.combinator = 3;
514
+ else if (token[1] === "~") part.combinator = 2;
515
+ else part.combinator = 0;
516
+ part = {
517
+ combinator: 4,
518
+ matchers: []
519
+ };
520
+ parts.push(part);
521
+ }
522
+ const name = token[8] ? asciiLowercase(token[8]) : token[2] || token[7];
523
+ if (token[7] != null && !token[6] && part.matchers.length > 0) throwSelectorSyntaxError(selector);
524
+ let type;
525
+ let value = token[4] ?? token[5] ?? token[7];
526
+ if (token[2]) {
527
+ if (!SUPPORTED_IDENTIFIER_TEST.test(name)) throwSelectorSyntaxError(selector);
528
+ const unquotedValue = token[5];
529
+ const openingQuote = unquotedValue?.[0];
530
+ if (token[3] == null && (openingQuote === "\"" || openingQuote === "'")) {
531
+ const valueOffset = token[0].lastIndexOf(unquotedValue);
532
+ value = normalizedSelector.slice(token.index + valueOffset + 1);
533
+ tokenizer.lastIndex = normalizedSelector.length;
534
+ } else if (unquotedValue != null && !SUPPORTED_IDENTIFIER_TEST.test(unquotedValue)) throwSelectorSyntaxError(selector);
535
+ type = 4;
536
+ } else if (token[6]) {
537
+ if (!SUPPORTED_IDENTIFIER_TEST.test(name)) throwSelectorSyntaxError(selector);
538
+ type = token[6] === "#" ? 2 : 3;
539
+ } else if (token[8]) type = token[9] == null ? 5 : 6;
540
+ else if (token[7] === "*") type = 0;
541
+ else if (token[7] && SUPPORTED_IDENTIFIER_TEST.test(token[7])) type = 1;
542
+ else throwSelectorSyntaxError(selector);
543
+ if (token[9]) {
544
+ [value, tokenizer.lastIndex] = readFunctionArgument(normalizedSelector, tokenizer.lastIndex);
545
+ if (name !== "has" && name !== "not") throwSelectorSyntaxError(selector);
546
+ if (name === "has" && insideHas) throwSelectorSyntaxError(selector);
547
+ parseSelector(value, insideHas || name === "has", name === "has");
548
+ } else if (type === 5) throwSelectorSyntaxError(selector);
549
+ part.matchers.push({
550
+ type,
551
+ name,
552
+ value
553
+ });
554
+ consumed = tokenizer.lastIndex;
555
+ }
556
+ if (consumed !== normalizedSelector.length || part.matchers.length === 0) throwSelectorSyntaxError(selector);
557
+ return parts;
558
+ }
559
+ function matchesSelector(element, selector) {
560
+ const parsed = parseSelector(selector);
561
+ return parsed[0]?.matchers.length ? matchesSelectorRecursive(element, parsed) : false;
562
+ }
563
+ function matchesRelativeSelector(scope, selector) {
564
+ const parts = parseSelector(selector, true, true);
565
+ const first = parts[0];
566
+ if (parts.length === 1 && first.matchers.length === 0) return false;
567
+ let leadingCombinator = 0;
568
+ const scopeMatcher = {
569
+ type: 7,
570
+ name: ":scope"
571
+ };
572
+ if (first.matchers.length === 0) {
573
+ leadingCombinator = first.combinator;
574
+ first.matchers.push(scopeMatcher);
575
+ } else parts.unshift({
576
+ combinator: 0,
577
+ matchers: [scopeMatcher]
578
+ });
579
+ if (parts.some(({ matchers }) => matchers.length === 0)) return false;
580
+ const root = leadingCombinator === 3 || leadingCombinator === 2 ? scope[NEXT] : scope[CHILD];
581
+ if (!root) return false;
582
+ let matched = false;
583
+ walkNodesForSelector(root, parts, () => {
584
+ matched = true;
585
+ return false;
586
+ }, scope);
587
+ return matched;
588
+ }
589
+ function walkNodesForSelector(node, parts, callback, scope) {
590
+ const pendingSiblings = [];
591
+ let current = node;
592
+ while (current) {
593
+ if (isElementNode(current)) {
594
+ if (matchesSelectorRecursive(current, parts, scope)) {
595
+ if (callback(current) === false) return false;
596
+ }
597
+ const child = current[CHILD];
598
+ if (child) {
599
+ const sibling = current[NEXT];
600
+ if (sibling) pendingSiblings.push(sibling);
601
+ current = child;
602
+ continue;
603
+ }
604
+ }
605
+ current = current[NEXT] ?? pendingSiblings.pop() ?? null;
606
+ }
607
+ return true;
608
+ }
609
+ function matchesSelectorRecursive(element, parts, scope) {
610
+ const { combinator, matchers } = parts[parts.length - 1];
611
+ if (combinator === 4) {
612
+ if (!matchesSelectorMatcher(element, matchers, scope)) return false;
613
+ const pp = parts.slice(0, -1);
614
+ return pp.length === 0 || matchesSelectorRecursive(element, pp, scope);
615
+ }
616
+ const link = combinator === 1 || combinator === 0 ? PARENT : PREV;
617
+ let ref = element[link];
618
+ if (!ref) return false;
619
+ if (combinator === 0 || combinator === 2) {
620
+ while (ref) {
621
+ if (isElementNode(ref) && matchesSelectorMatcher(ref, matchers, scope)) {
622
+ const pp = parts.slice(0, -1);
623
+ if (pp.length === 0) return true;
624
+ if (matchesSelectorRecursive(ref, pp, scope)) return true;
625
+ }
626
+ ref = ref[link];
627
+ }
628
+ return false;
629
+ } else {
630
+ if (combinator === 3 && !isElementNode(ref)) {
631
+ while (ref && !isElementNode(ref)) ref = ref[link];
632
+ if (!ref) return false;
633
+ }
634
+ if (!isElementNode(ref) || !matchesSelectorMatcher(ref, matchers, scope)) return false;
635
+ const pp = parts.slice(0, -1);
636
+ return pp.length === 0 || matchesSelectorRecursive(ref, pp, scope);
637
+ }
638
+ }
639
+ function getSelectorAttribute(element, name) {
640
+ return element.getAttributeNS(null, element.namespaceURI === "http://www.w3.org/1999/xhtml" ? asciiLowercase(name) : name);
641
+ }
642
+ function matchesSelectorMatcher(element, matcher, scope) {
643
+ if (!element) return false;
644
+ if (Array.isArray(matcher)) {
645
+ for (const single of matcher) if (matchesSelectorMatcher(element, single, scope) === false) return false;
646
+ return true;
647
+ }
648
+ const { type, name, value } = matcher;
649
+ switch (type) {
650
+ case 0: return name === "*";
651
+ case 1: return element.namespaceURI === "http://www.w3.org/1999/xhtml" ? element.localName === asciiLowercase(name) : element.localName === name;
652
+ case 2: return getSelectorAttribute(element, "id") === name;
653
+ case 3:
654
+ const classAttr = getSelectorAttribute(element, "class");
655
+ if (!classAttr) return false;
656
+ return splitOnASCIIWhitespace(classAttr).includes(name);
657
+ case 4:
658
+ const attribute = getSelectorAttribute(element, name);
659
+ return value == null ? attribute != null : attribute === value;
660
+ case 7: return element === scope;
661
+ case 5: throwSelectorSyntaxError(`:${name}`);
662
+ case 6: switch (name) {
663
+ case "has": return matchesRelativeSelector(element, value || "");
664
+ case "not": return !matchesSelector(element, value || "");
665
+ default: throwSelectorSyntaxError(`:${name}(${value})`);
666
+ }
667
+ }
668
+ return false;
254
669
  }
255
670
  //#endregion
256
671
  //#region node_modules/@remote-dom/polyfill/build/esm/shared.mjs
672
+ function isAttributeNode(node) {
673
+ return node.nodeType === 2;
674
+ }
257
675
  function isCharacterData(node) {
258
676
  return DATA in node;
259
677
  }
260
678
  function isTextNode(node) {
261
- return node.nodeType === NodeType$1.TEXT_NODE;
679
+ return node.nodeType === 3;
262
680
  }
263
681
  function isCommentNode(node) {
264
- return node.nodeType === NodeType$1.COMMENT_NODE;
682
+ return node.nodeType === 8;
265
683
  }
266
684
  function isElementNode(node) {
267
- return node.nodeType === NodeType$1.ELEMENT_NODE;
685
+ return node.nodeType === 1;
268
686
  }
269
687
  function isDocumentFragmentNode(node) {
270
- return node.nodeType === NodeType$1.DOCUMENT_FRAGMENT_NODE;
688
+ return node.nodeType === 11;
271
689
  }
272
690
  function isParentNode(node) {
273
691
  return "appendChild" in node;
274
692
  }
275
- function cloneNode(node, deep, document = node.ownerDocument) {
693
+ function collectAdoptionSnapshot(root) {
694
+ const nodes = [];
695
+ const pendingRoots = [root];
696
+ const pending = new Set(pendingRoots);
697
+ const visited = /* @__PURE__ */ new Set();
698
+ let treeNodes;
699
+ while (pendingRoots.length > 0) {
700
+ const currentRoot = pendingRoots.pop();
701
+ pending.delete(currentRoot);
702
+ if (visited.has(currentRoot)) continue;
703
+ const currentTreeNodes = [];
704
+ for (const node of selfAndDescendants(currentRoot)) {
705
+ if (visited.has(node)) continue;
706
+ visited.add(node);
707
+ nodes.push(node);
708
+ currentTreeNodes.push(node);
709
+ if (!isElementNode(node)) continue;
710
+ const attributes = node[ATTRIBUTES];
711
+ if (attributes) for (const attribute of attributes) {
712
+ if (visited.has(attribute)) continue;
713
+ visited.add(attribute);
714
+ nodes.push(attribute);
715
+ }
716
+ const content = node[CONTENT];
717
+ if (content && !visited.has(content) && !pending.has(content)) {
718
+ pending.add(content);
719
+ pendingRoots.push(content);
720
+ }
721
+ }
722
+ treeNodes ??= currentTreeNodes;
723
+ }
724
+ return {
725
+ nodes,
726
+ treeNodes
727
+ };
728
+ }
729
+ function adoptNodes(nodes, document) {
730
+ for (const node of nodes) node[OWNER_DOCUMENT] = document;
731
+ }
732
+ function cloneAttribute(attribute, document) {
733
+ const Attribute = attribute.constructor;
734
+ const cloned = new Attribute(attribute.name, attribute.value, attribute.namespaceURI);
735
+ cloned[OWNER_DOCUMENT] = document;
736
+ return cloned;
737
+ }
738
+ function cloneNodeShallow(node, document) {
276
739
  if (isTextNode(node)) return document.createTextNode(node.data);
277
740
  else if (isCommentNode(node)) return document.createComment(node.data);
741
+ else if (isAttributeNode(node)) return cloneAttribute(node, document);
278
742
  else if (isElementNode(node)) {
279
- const cloned = document.createElement(node.localName);
743
+ const cloned = document[CREATE_ELEMENT](node[NAME], node.namespaceURI, node[PREFIX], node.localName);
280
744
  if (node[ATTRIBUTES]) for (let i = 0; i < node[ATTRIBUTES].length; i++) {
281
745
  const attribute = node[ATTRIBUTES].item(i);
282
- cloned.setAttributeNS(attribute.namespaceURI, attribute.name, attribute.value);
746
+ cloned.attributes.setNamedItem(cloneAttribute(attribute, document));
283
747
  }
284
- if (deep) for (const child of node.childNodes) cloned.appendChild(cloneNode(child, true, document));
285
748
  return cloned;
286
- } else if (isDocumentFragmentNode(node)) {
287
- const fragment = document.createDocumentFragment();
288
- if (deep) for (const child of node.childNodes) fragment.appendChild(cloneNode(child, true, document));
289
- return fragment;
290
- } else {
749
+ } else if (isDocumentFragmentNode(node)) return document.createDocumentFragment();
750
+ else {
291
751
  const cloned = new node.constructor();
292
752
  cloned[OWNER_DOCUMENT] = document;
293
753
  return cloned;
294
754
  }
295
755
  }
756
+ function cloneNode(node, deep, document = node.ownerDocument) {
757
+ if (node.nodeType === 9) throw createDOMException("Cannot clone a document node", "NotSupportedError");
758
+ const cloned = cloneNodeShallow(node, document);
759
+ if (!deep || !isElementNode(node) && !isDocumentFragmentNode(node)) return cloned;
760
+ const visited = /* @__PURE__ */ new Set([node]);
761
+ const frames = [{
762
+ source: node,
763
+ destination: cloned,
764
+ childIndex: 0,
765
+ cloningContent: false
766
+ }];
767
+ while (frames.length > 0) {
768
+ const frame = frames[frames.length - 1];
769
+ let sourceChild;
770
+ let destinationParent;
771
+ if (!frame.cloningContent) {
772
+ sourceChild = frame.source.childNodes[frame.childIndex++];
773
+ destinationParent = frame.destination;
774
+ if (!sourceChild) {
775
+ frame.cloningContent = true;
776
+ frame.childIndex = 0;
777
+ if (isElementNode(frame.source) && frame.source.namespaceURI === "http://www.w3.org/1999/xhtml" && frame.source.localName === "template") {
778
+ const content = frame.source[CONTENT];
779
+ if (content) {
780
+ if (visited.has(content)) throwCloneGraphError();
781
+ visited.add(content);
782
+ frame.contentSource = content;
783
+ frame.contentDestination = frame.destination.content;
784
+ }
785
+ }
786
+ continue;
787
+ }
788
+ } else if (frame.contentSource && frame.contentDestination) {
789
+ sourceChild = frame.contentSource.childNodes[frame.childIndex++];
790
+ destinationParent = frame.contentDestination;
791
+ } else {
792
+ frames.pop();
793
+ if (frame.appendTo) frame.appendTo.appendChild(frame.destination);
794
+ continue;
795
+ }
796
+ if (!sourceChild) {
797
+ frames.pop();
798
+ if (frame.appendTo) frame.appendTo.appendChild(frame.destination);
799
+ continue;
800
+ }
801
+ if (visited.has(sourceChild)) throwCloneGraphError();
802
+ visited.add(sourceChild);
803
+ const clonedChild = cloneNodeShallow(sourceChild, document);
804
+ if (isElementNode(sourceChild) || isDocumentFragmentNode(sourceChild)) frames.push({
805
+ source: sourceChild,
806
+ destination: clonedChild,
807
+ appendTo: destinationParent,
808
+ childIndex: 0,
809
+ cloningContent: false
810
+ });
811
+ else destinationParent.appendChild(clonedChild);
812
+ }
813
+ return cloned;
814
+ }
815
+ function throwCloneGraphError() {
816
+ throw new Error("Cannot clone a cyclic or repeated node graph");
817
+ }
818
+ function getElementById(within, elementId) {
819
+ const id = String(elementId);
820
+ if (id === "") return null;
821
+ return querySelector(within, [{
822
+ type: 2,
823
+ name: id
824
+ }]);
825
+ }
826
+ function getElementsByClassName(within, classNames) {
827
+ return querySelectorAll(within, [...new Set(splitOnASCIIWhitespace(String(classNames)))].map((name) => ({
828
+ type: 3,
829
+ name
830
+ })));
831
+ }
832
+ function getElementsByTagName(within, qualifiedName) {
833
+ const name = String(qualifiedName);
834
+ const normalizedHtmlName = asciiLowercase(name);
835
+ const elements = [];
836
+ for (const node of descendants(within)) {
837
+ if (!isElementNode(node)) continue;
838
+ if (name === "*" || (node.namespaceURI === "http://www.w3.org/1999/xhtml" ? node[NAME] === normalizedHtmlName : node[NAME] === name)) elements.push(node);
839
+ }
840
+ return elements;
841
+ }
296
842
  function descendants(node) {
297
843
  const nodes = [];
298
- const walk = (node) => {
299
- nodes.push(node);
300
- const child = node[CHILD];
301
- if (child) walk(child);
302
- const sibling = node[NEXT];
303
- if (sibling) walk(sibling);
304
- };
305
- const child = node[CHILD];
306
- if (child) walk(child);
844
+ const pendingSiblings = [];
845
+ let current = node[CHILD];
846
+ while (current) {
847
+ nodes.push(current);
848
+ const child = current[CHILD];
849
+ const sibling = current[NEXT];
850
+ if (child) {
851
+ if (sibling) pendingSiblings.push(sibling);
852
+ current = child;
853
+ } else current = sibling ?? pendingSiblings.pop() ?? null;
854
+ }
307
855
  return nodes;
308
856
  }
309
857
  function selfAndDescendants(node) {
@@ -314,21 +862,22 @@ function selfAndDescendants(node) {
314
862
  //#endregion
315
863
  //#region node_modules/@remote-dom/polyfill/build/esm/Node.mjs
316
864
  var Node$2 = class extends EventTarget {
317
- nodeType = (() => NodeType$1.NODE)();
865
+ nodeType = 0;
318
866
  [NAME] = "";
319
867
  [PARENT] = null;
868
+ [HOST] = null;
320
869
  [CHILD] = null;
321
870
  [PREV] = null;
322
871
  [NEXT] = null;
323
872
  [IS_CONNECTED] = false;
324
873
  get [HOOKS]() {
325
- return this[OWNER_DOCUMENT].defaultView[HOOKS];
874
+ return this[OWNER_DOCUMENT].defaultView[HOOKS_DISPATCH];
326
875
  }
327
876
  get localName() {
328
877
  return this[NAME];
329
878
  }
330
879
  get nodeName() {
331
- return this[NAME].toUpperCase();
880
+ return this[NAME];
332
881
  }
333
882
  get ownerDocument() {
334
883
  return this[OWNER_DOCUMENT];
@@ -337,7 +886,8 @@ var Node$2 = class extends EventTarget {
337
886
  return this[IS_CONNECTED];
338
887
  }
339
888
  isDefaultNamespace(namespace) {
340
- return namespace === NamespaceURI.XHTML;
889
+ const normalizedNamespace = normalizeNamespace(namespace);
890
+ return locateNamespace(this) === normalizedNamespace;
341
891
  }
342
892
  get parentNode() {
343
893
  return this[PARENT];
@@ -399,9 +949,9 @@ var Node$2 = class extends EventTarget {
399
949
  set textContent(data) {
400
950
  if (isCharacterData(this)) this.data = data;
401
951
  else if (isParentNode(this)) {
402
- let child;
403
- while (child = this[CHILD]) this.removeChild(child);
404
- this.append(data);
952
+ const text = data == null ? "" : String(data);
953
+ if (text === "") this.replaceChildren();
954
+ else this.replaceChildren(text);
405
955
  }
406
956
  }
407
957
  cloneNode(deep) {
@@ -409,15 +959,41 @@ var Node$2 = class extends EventTarget {
409
959
  }
410
960
  contains(node) {
411
961
  let currentNode = node;
412
- while (true) {
413
- if (currentNode == null) return false;
962
+ while (currentNode != null) {
414
963
  if (currentNode === this) return true;
415
- currentNode = node.parentNode;
964
+ currentNode = currentNode.parentNode;
416
965
  }
966
+ return false;
417
967
  }
418
968
  };
969
+ function locateNamespace(node) {
970
+ let current = node;
971
+ while (current) switch (current.nodeType) {
972
+ case 1: {
973
+ const element = current;
974
+ if (element.prefix == null && element.namespaceURI != null) return element.namespaceURI;
975
+ const namespace = element.attributes.getNamedItemNS(XMLNS_NAMESPACE, "xmlns");
976
+ if (namespace != null && namespace.prefix == null) return normalizeNamespace(namespace.value);
977
+ current = element.parentElement;
978
+ break;
979
+ }
980
+ case 9:
981
+ current = current.documentElement;
982
+ break;
983
+ case 10:
984
+ case 11: return null;
985
+ case 2:
986
+ current = current.ownerElement;
987
+ break;
988
+ default: current = current.parentElement;
989
+ }
990
+ return null;
991
+ }
419
992
  //#endregion
420
993
  //#region node_modules/@remote-dom/polyfill/build/esm/ChildNode.mjs
994
+ var INSERT_NODE = Symbol("insertNode");
995
+ var PREFLIGHT_INSERTIONS = Symbol("preflightInsertions");
996
+ var REPLACE_NODE = Symbol("replaceNode");
421
997
  var ChildNode = class extends Node$2 {
422
998
  remove() {
423
999
  const parent = this.parentNode;
@@ -425,259 +1001,297 @@ var ChildNode = class extends Node$2 {
425
1001
  parent.removeChild(this);
426
1002
  }
427
1003
  replaceWith(...nodes) {
1004
+ const staged = stageNodes(nodes);
428
1005
  const parent = this.parentNode;
429
1006
  if (!parent) return;
430
- const node = toNode(parent, nodes[0]);
431
- const next = node[NEXT];
432
- parent.replaceChild(this, node);
433
- for (let i = 1; i < nodes.length; i++) parent.insertBefore(toNode(parent, nodes[i]), next);
1007
+ return performChildNodeMutation((hookEffects) => {
1008
+ validateInsertionNodes(parent, staged);
1009
+ let next = this[NEXT];
1010
+ while (next && staged.includes(next)) next = next[NEXT];
1011
+ const replacement = convertNodesIntoNode(parent, staged, hookEffects);
1012
+ if (this.parentNode === parent) parent[REPLACE_NODE](replacement, this, hookEffects);
1013
+ else parent[INSERT_NODE](replacement, next, hookEffects);
1014
+ });
434
1015
  }
435
1016
  before(...nodes) {
1017
+ const staged = stageNodes(nodes);
436
1018
  const parent = this.parentNode;
437
1019
  if (!parent) return;
438
- for (const node of nodes) parent.insertBefore(toNode(parent, node), this);
1020
+ return performChildNodeMutation((hookEffects) => {
1021
+ validateInsertionNodes(parent, staged);
1022
+ let previous = this[PREV];
1023
+ while (previous && staged.includes(previous)) previous = previous[PREV];
1024
+ const node = convertNodesIntoNode(parent, staged, hookEffects);
1025
+ parent[INSERT_NODE](node, previous ? previous[NEXT] : parent.firstChild, hookEffects);
1026
+ });
439
1027
  }
440
1028
  after(...nodes) {
1029
+ const staged = stageNodes(nodes);
441
1030
  const parent = this.parentNode;
442
1031
  if (!parent) return;
443
- const next = this[NEXT];
444
- for (const node of nodes) parent.insertBefore(toNode(parent, node), next);
1032
+ return performChildNodeMutation((hookEffects) => {
1033
+ validateInsertionNodes(parent, staged);
1034
+ let next = this[NEXT];
1035
+ while (next && staged.includes(next)) next = next[NEXT];
1036
+ const node = convertNodesIntoNode(parent, staged, hookEffects);
1037
+ parent[INSERT_NODE](node, next, hookEffects);
1038
+ });
445
1039
  }
446
1040
  };
1041
+ function performChildNodeMutation(mutation) {
1042
+ return performWithCustomElementReactions(() => {
1043
+ const hookEffects = [];
1044
+ try {
1045
+ mutation(hookEffects);
1046
+ } catch (error) {
1047
+ try {
1048
+ performHookEffects(hookEffects);
1049
+ } catch {}
1050
+ throw error;
1051
+ }
1052
+ performHookEffects(hookEffects);
1053
+ });
1054
+ }
1055
+ function stageNodes(nodes) {
1056
+ return nodes.map((node) => node instanceof Node$2 ? node : String(node));
1057
+ }
447
1058
  function toNode(parent, node) {
448
1059
  if (node instanceof Node$2) return node;
449
1060
  return parent.ownerDocument.createTextNode(String(node));
450
1061
  }
451
- //#endregion
452
- //#region node_modules/@remote-dom/polyfill/build/esm/NodeList.mjs
453
- var NodeList = class extends Array {
454
- item(index) {
455
- return this[index];
456
- }
457
- };
458
- //#endregion
459
- //#region node_modules/@remote-dom/polyfill/build/esm/selectors.mjs
460
- var Combinator = /*#__PURE__*/ function(Combinator) {
461
- Combinator[Combinator["Descendant"] = 0] = "Descendant";
462
- Combinator[Combinator["Child"] = 1] = "Child";
463
- Combinator[Combinator["Sibling"] = 2] = "Sibling";
464
- Combinator[Combinator["Adjacent"] = 3] = "Adjacent";
465
- Combinator[Combinator["Inner"] = 4] = "Inner";
466
- return Combinator;
467
- }(Combinator || {});
468
- var MatcherType = /*#__PURE__*/ function(MatcherType) {
469
- MatcherType[MatcherType["Unknown"] = 0] = "Unknown";
470
- MatcherType[MatcherType["Element"] = 1] = "Element";
471
- MatcherType[MatcherType["Id"] = 2] = "Id";
472
- MatcherType[MatcherType["Class"] = 3] = "Class";
473
- MatcherType[MatcherType["Attribute"] = 4] = "Attribute";
474
- MatcherType[MatcherType["Pseudo"] = 5] = "Pseudo";
475
- MatcherType[MatcherType["Function"] = 6] = "Function";
476
- return MatcherType;
477
- }(MatcherType || {});
478
- var ELEMENT_SELECTOR_TEST = /[a-z]/;
479
- function querySelector(within, selector) {
480
- const parts = parseSelector(selector);
481
- let result = null;
482
- const child = within[CHILD];
483
- if (child && parts[0].matchers.length) walkNodesForSelector(child, parts, (node) => {
484
- result = node;
485
- return false;
486
- });
487
- return result;
488
- }
489
- function querySelectorAll(within, selector) {
490
- const parts = parseSelector(selector);
491
- const results = [];
492
- const child = within[CHILD];
493
- if (child && parts[0].matchers.length) walkNodesForSelector(child, parts, (node) => {
494
- results.push(node);
495
- });
496
- return results;
497
- }
498
- function parseSelector(selector) {
499
- let part = {
500
- combinator: Combinator.Inner,
501
- matchers: []
502
- };
503
- const parts = [part];
504
- const tokenizer = /\s*?([>\s+~]?)\s*?(?:(?:\[\s*([^\]=]+)(?:=(['"])(.*?)\3)?\s*\])|([#.]?)([^\s#.[>:+~]+)|:(\w+)(?:\((.*?)\))?)/gi;
505
- let token;
506
- while (token = tokenizer.exec(selector)) {
507
- if (token[1]) {
508
- if (token[1] === ">") part.combinator = Combinator.Child;
509
- else if (token[1] === "+") part.combinator = Combinator.Adjacent;
510
- else if (token[1] === "~") part.combinator = Combinator.Sibling;
511
- else part.combinator = Combinator.Descendant;
512
- part = {
513
- combinator: Combinator.Inner,
514
- matchers: []
515
- };
516
- parts.push(part);
517
- }
518
- let type = MatcherType.Unknown;
519
- if (token[2]) type = MatcherType.Attribute;
520
- else if (token[5]) type = token[5] === "#" ? MatcherType.Id : MatcherType.Class;
521
- else if (token[7]) type = token[8] == null ? MatcherType.Pseudo : MatcherType.Function;
522
- else if (token[6]) {
523
- if (token[6] === "*") type = MatcherType.Unknown;
524
- else if (ELEMENT_SELECTOR_TEST.test(token[6])) type = MatcherType.Element;
1062
+ function validateInsertionNodes(parent, nodes) {
1063
+ for (const node of nodes) {
1064
+ if (!(node instanceof Node$2)) continue;
1065
+ let ancestor = parent;
1066
+ while (ancestor) {
1067
+ if (ancestor === node) throw createDOMException("Cannot insert a node into itself or one of its descendants", "HierarchyRequestError");
1068
+ ancestor = ancestor[PARENT] ?? ancestor[HOST];
525
1069
  }
526
- part.matchers.push({
527
- type,
528
- name: token[2] || token[6] || token[7],
529
- value: token[4] ?? token[6] ?? token[8]
530
- });
531
1070
  }
532
- return parts;
533
1071
  }
534
- function matchesSelector(element, selector) {
535
- const parsed = parseSelector(selector);
536
- let part;
537
- while (part = parsed.pop()) if (!matchesSelectorPart(element, part)) return false;
538
- return true;
1072
+ function convertNodesIntoNode(parent, nodes, hookEffects) {
1073
+ const convertedNodes = [];
1074
+ for (const node of nodes) convertedNodes.push(toNode(parent, node));
1075
+ if (convertedNodes.length === 1) return convertedNodes[0];
1076
+ const fragment = parent.ownerDocument.createDocumentFragment();
1077
+ fragment[PREFLIGHT_INSERTIONS](convertedNodes);
1078
+ for (const node of convertedNodes) fragment[INSERT_NODE](node, null, hookEffects);
1079
+ return fragment;
539
1080
  }
540
- function walkNodesForSelector(node, parts, callback) {
541
- if (isElementNode(node)) {
542
- if (matchesSelectorRecursive(node, parts)) {
543
- if (callback(node) === false) return false;
544
- }
545
- const child = node[CHILD];
546
- if (child && walkNodesForSelector(child, parts, callback) === false) return false;
1081
+ //#endregion
1082
+ //#region node_modules/@remote-dom/polyfill/build/esm/MutationObserver.mjs
1083
+ var registrations;
1084
+ var registrationCount = 0;
1085
+ var attributeRegistrationCount = 0;
1086
+ var characterDataRegistrationCount = 0;
1087
+ var childListRegistrationCount = 0;
1088
+ /** @internal */
1089
+ var attributeObserversActive = false;
1090
+ /** @internal */
1091
+ var characterDataObserversActive = false;
1092
+ /** @internal */
1093
+ var childListObserversActive = false;
1094
+ var MutationObserver = class {
1095
+ #callback;
1096
+ #records = [];
1097
+ #targets = /* @__PURE__ */ new Set();
1098
+ #scheduled = false;
1099
+ constructor(callback) {
1100
+ if (typeof callback !== "function") throw new TypeError("MutationObserver callback must be a function");
1101
+ this.#callback = callback;
1102
+ }
1103
+ observe(target, options = {}) {
1104
+ const normalizedOptions = normalizeOptions(options);
1105
+ const currentRegistrations = registrations ??= /* @__PURE__ */ new WeakMap();
1106
+ let targetRegistrations = currentRegistrations.get(target);
1107
+ if (targetRegistrations == null) {
1108
+ targetRegistrations = /* @__PURE__ */ new Map();
1109
+ currentRegistrations.set(target, targetRegistrations);
1110
+ }
1111
+ const previousOptions = targetRegistrations.get(this);
1112
+ if (previousOptions == null) registrationCount++;
1113
+ else updateRegistrationCounts(previousOptions, -1);
1114
+ targetRegistrations.set(this, normalizedOptions);
1115
+ updateRegistrationCounts(normalizedOptions, 1);
1116
+ this.#targets.add(target);
1117
+ }
1118
+ disconnect() {
1119
+ const currentRegistrations = registrations;
1120
+ if (currentRegistrations == null) return;
1121
+ for (const target of this.#targets) {
1122
+ const targetRegistrations = currentRegistrations.get(target);
1123
+ const options = targetRegistrations?.get(this);
1124
+ if (options != null) {
1125
+ targetRegistrations.delete(this);
1126
+ registrationCount--;
1127
+ updateRegistrationCounts(options, -1);
1128
+ }
1129
+ if (targetRegistrations?.size === 0) currentRegistrations.delete(target);
1130
+ }
1131
+ this.#targets.clear();
1132
+ this.#records.length = 0;
1133
+ if (registrationCount === 0) registrations = void 0;
1134
+ }
1135
+ takeRecords() {
1136
+ return this.#records.splice(0);
1137
+ }
1138
+ /** @internal */
1139
+ enqueue(record) {
1140
+ this.#records.push(record);
1141
+ if (this.#scheduled) return;
1142
+ this.#scheduled = true;
1143
+ queueMicrotask(() => {
1144
+ this.#scheduled = false;
1145
+ const records = this.takeRecords();
1146
+ if (records.length > 0) this.#callback.call(this, records, this);
1147
+ });
547
1148
  }
548
- const next = node[NEXT];
549
- if (next && walkNodesForSelector(next, parts, callback) === false) return false;
550
- return true;
1149
+ };
1150
+ /** @internal */
1151
+ function queueMutationRecord(init) {
1152
+ const currentRegistrations = registrations;
1153
+ if (currentRegistrations == null) return;
1154
+ const interestedObservers = /* @__PURE__ */ new Map();
1155
+ let node = init.target;
1156
+ while (node) {
1157
+ const targetRegistrations = currentRegistrations.get(node);
1158
+ if (targetRegistrations) for (const [observer, options] of targetRegistrations) {
1159
+ if (node !== init.target && !options.subtree) continue;
1160
+ let includeOldValue = false;
1161
+ if (init.type === "attributes") {
1162
+ if (!options.attributes) continue;
1163
+ if (options.attributeFilter && !options.attributeFilter.has(init.attributeName ?? "")) continue;
1164
+ includeOldValue = options.attributeOldValue;
1165
+ } else if (init.type === "characterData") {
1166
+ if (!options.characterData) continue;
1167
+ includeOldValue = options.characterDataOldValue;
1168
+ } else if (!options.childList) continue;
1169
+ interestedObservers.set(observer, interestedObservers.get(observer) === true || includeOldValue);
1170
+ }
1171
+ node = node.parentNode;
1172
+ }
1173
+ for (const [observer, includeOldValue] of interestedObservers) observer.enqueue({
1174
+ addedNodes: init.addedNodes ?? new NodeList(),
1175
+ attributeName: init.attributeName ?? null,
1176
+ attributeNamespace: init.attributeNamespace ?? null,
1177
+ nextSibling: init.nextSibling ?? null,
1178
+ oldValue: includeOldValue ? init.oldValue ?? null : null,
1179
+ previousSibling: init.previousSibling ?? null,
1180
+ removedNodes: init.removedNodes ?? new NodeList(),
1181
+ target: init.target,
1182
+ type: init.type
1183
+ });
551
1184
  }
552
- function matchesSelectorRecursive(element, parts) {
553
- const { combinator, matchers } = parts[parts.length - 1];
554
- if (combinator === Combinator.Inner) {
555
- if (!matchesSelectorMatcher(element, matchers)) return false;
556
- const pp = parts.slice(0, -1);
557
- return pp.length === 0 || matchesSelectorRecursive(element, pp);
558
- }
559
- const link = combinator === Combinator.Child || combinator === Combinator.Descendant ? PARENT : PREV;
560
- let ref = element[link];
561
- if (!ref) return false;
562
- if (combinator === Combinator.Descendant || combinator === Combinator.Sibling) {
563
- while (ref) {
564
- if (isElementNode(ref) && matchesSelectorMatcher(ref, matchers)) {
565
- const pp = parts.slice(0, -1);
566
- if (pp.length === 0) return true;
567
- if (matchesSelectorRecursive(element, pp)) return true;
568
- }
569
- ref = ref[link];
570
- }
571
- return false;
572
- } else {
573
- if (combinator === Combinator.Adjacent && !isElementNode(ref)) {
574
- while (ref && !isElementNode(ref)) ref = ref[link];
575
- if (!ref) return false;
576
- }
577
- if (!isElementNode(ref) || !matchesSelectorMatcher(ref, matchers)) return false;
578
- const pp = parts.slice(0, -1);
579
- return pp.length === 0 || matchesSelectorRecursive(element, pp);
580
- }
1185
+ /** @internal */
1186
+ function mutationNodeList(...nodes) {
1187
+ const list = new NodeList();
1188
+ list.push(...nodes);
1189
+ return list;
581
1190
  }
582
- function matchesSelectorPart(element, { combinator, matchers }) {
583
- if (combinator === Combinator.Inner) return matchesSelectorMatcher(element, matchers);
584
- const link = combinator === Combinator.Child || combinator === Combinator.Descendant ? PARENT : PREV;
585
- let ref = element[link];
586
- if (!ref) return false;
587
- if (combinator === Combinator.Adjacent && !isElementNode(ref)) {
588
- while (ref && !isElementNode(ref)) ref = ref[link];
589
- if (!ref) return false;
590
- }
591
- if (!isElementNode(ref) || !matchesSelectorMatcher(ref, matchers)) return false;
592
- if (combinator === Combinator.Descendant || combinator === Combinator.Sibling) {
593
- while (ref = ref[link]) if (isElementNode(ref) && matchesSelectorMatcher(ref, matchers)) return true;
594
- }
595
- return true;
1191
+ function normalizeOptions(options) {
1192
+ if (options.attributes === false && (options.attributeOldValue || options.attributeFilter != null)) throw new TypeError("attributeOldValue and attributeFilter require attributes to be enabled");
1193
+ if (options.characterData === false && options.characterDataOldValue) throw new TypeError("characterDataOldValue requires characterData to be enabled");
1194
+ const attributes = options.attributes ?? (options.attributeOldValue === true || options.attributeFilter != null);
1195
+ const characterData = options.characterData ?? options.characterDataOldValue === true;
1196
+ const childList = options.childList === true;
1197
+ if (!attributes && !characterData && !childList) throw new TypeError("MutationObserver options must enable childList, attributes, or characterData");
1198
+ return {
1199
+ attributes,
1200
+ attributeFilter: options.attributeFilter == null ? void 0 : new Set(options.attributeFilter.map(String)),
1201
+ attributeOldValue: options.attributeOldValue === true,
1202
+ characterData,
1203
+ characterDataOldValue: options.characterDataOldValue === true,
1204
+ childList,
1205
+ subtree: options.subtree === true
1206
+ };
596
1207
  }
597
- function matchesSelectorMatcher(element, matcher) {
598
- if (!element) return false;
599
- if (Array.isArray(matcher)) {
600
- for (const single of matcher) if (matchesSelectorMatcher(element, single) === false) return false;
601
- return true;
602
- }
603
- const { type, name, value } = matcher;
604
- switch (type) {
605
- case MatcherType.Unknown: return name === "*";
606
- case MatcherType.Element: return element.localName === name;
607
- case MatcherType.Id: return element.getAttribute("id") === name;
608
- case MatcherType.Class:
609
- const classAttr = element.getAttribute("class");
610
- if (!classAttr) return false;
611
- return classAttr.split(/\s+/).includes(name);
612
- case MatcherType.Attribute: return value == null ? element.hasAttribute(name) : element.getAttribute(name) === value;
613
- case MatcherType.Pseudo: switch (name) {
614
- default: throw Error(`Pseudo :${name} not implemented`);
615
- }
616
- case MatcherType.Function: switch (name) {
617
- case "has": return matchesSelector(element, value || "");
618
- case "not": return !matchesSelector(element, value || "");
619
- default: throw Error(`Function :${name}(${value}) not implemented`);
620
- }
621
- }
622
- return false;
1208
+ function updateRegistrationCounts(options, delta) {
1209
+ if (options.attributes) attributeRegistrationCount += delta;
1210
+ if (options.characterData) characterDataRegistrationCount += delta;
1211
+ if (options.childList) childListRegistrationCount += delta;
1212
+ attributeObserversActive = attributeRegistrationCount > 0;
1213
+ characterDataObserversActive = characterDataRegistrationCount > 0;
1214
+ childListObserversActive = childListRegistrationCount > 0;
623
1215
  }
624
1216
  //#endregion
625
1217
  //#region node_modules/@remote-dom/polyfill/build/esm/ParentNode.mjs
626
1218
  var ParentNode = class extends ChildNode {
627
- childNodes = (() => new NodeList())();
628
- children = (() => new NodeList())();
1219
+ childNodes = new NodeList();
1220
+ children = new NodeList();
629
1221
  appendChild(child) {
630
- this.insertInto(child, null);
1222
+ return performWithCustomElementReactions(() => this[INSERT_NODE](child, null));
631
1223
  }
632
1224
  insertBefore(child, ref) {
633
- this.insertInto(child, ref || null);
1225
+ return performWithCustomElementReactions(() => this[INSERT_NODE](child, ref || null));
634
1226
  }
635
1227
  append(...nodes) {
636
- for (const child of nodes) {
637
- if (child == null) continue;
638
- this.appendChild(toNode(this, child));
639
- }
1228
+ return performWithCustomElementReactions(() => {
1229
+ const staged = stageNodes(nodes.filter((node) => node != null));
1230
+ if (staged.length > 1) validateInsertionNodes(this, staged);
1231
+ for (const child of staged) this[INSERT_NODE](toNode(this, child), null);
1232
+ });
640
1233
  }
641
1234
  prepend(...nodes) {
642
- const before = this.firstChild;
643
- for (const child of nodes) {
644
- if (child == null) continue;
645
- this.insertBefore(toNode(this, child), before);
646
- }
1235
+ return performWithCustomElementReactions(() => {
1236
+ const staged = stageNodes(nodes.filter((node) => node != null));
1237
+ if (staged.length > 1) validateInsertionNodes(this, staged);
1238
+ const before = this.firstChild;
1239
+ for (const child of staged) this[INSERT_NODE](toNode(this, child), before);
1240
+ });
647
1241
  }
648
1242
  replaceChildren(...nodes) {
649
- let child;
650
- while (child = this.firstChild) this.removeChild(child);
651
- this.append(...nodes);
1243
+ return performWithCustomElementReactions(() => {
1244
+ const staged = stageNodes(nodes.filter((node) => node != null));
1245
+ validateInsertionNodes(this, staged);
1246
+ let child;
1247
+ while (child = this.firstChild) this.removeChildImmediately(child);
1248
+ for (const node of staged) this[INSERT_NODE](toNode(this, node), null);
1249
+ });
652
1250
  }
653
1251
  removeChild(child) {
654
- if (child.parentNode !== this) throw Error(`not a child of this node`);
655
- const prev = child[PREV];
656
- const next = child[NEXT];
657
- if (prev) prev[NEXT] = next;
658
- else this[CHILD] = next;
659
- if (next) next[PREV] = prev;
660
- const childNodes = this.childNodes;
661
- const childNodesIndex = childNodes.indexOf(child);
662
- childNodes.splice(childNodesIndex, 1);
663
- if (child.nodeType === 1) {
664
- const children = this.children;
665
- children.splice(children.indexOf(child), 1);
666
- }
667
- child[PARENT] = null;
668
- child[NEXT] = null;
669
- child[PREV] = null;
670
- if (this[IS_CONNECTED]) for (const node of selfAndDescendants(child)) {
671
- node[IS_CONNECTED] = false;
672
- node.disconnectedCallback?.();
673
- }
674
- if (this.nodeType === NodeType$1.ELEMENT_NODE) this[HOOKS].removeChild?.(this, child, childNodesIndex);
1252
+ return performWithCustomElementReactions(() => {
1253
+ this.removeChildImmediately(child);
1254
+ return child;
1255
+ });
1256
+ }
1257
+ removeChildImmediately(child) {
1258
+ if (child.parentNode !== this) throw createDOMException("The node is not a child of this node", "NotFoundError");
1259
+ const disconnectedNodes = this[IS_CONNECTED] ? selfAndDescendants(child) : void 0;
1260
+ const previousSibling = child[PREV];
1261
+ const nextSibling = child[NEXT];
1262
+ const childNodesIndex = detachChild(this, child);
1263
+ if (disconnectedNodes) for (const node of disconnectedNodes) node[IS_CONNECTED] = false;
1264
+ this.queueRemovalMutationRecord(this, child, previousSibling, nextSibling);
1265
+ if (disconnectedNodes) this.enqueueTreeReactions(disconnectedNodes, "disconnectedCallback");
1266
+ performHookEffects(this.collectRemovalHookEffects(child, childNodesIndex));
675
1267
  }
676
1268
  replaceChild(newChild, oldChild) {
677
- if (oldChild.parentNode !== this) throw Error("reference node is not a child of this parent");
1269
+ return performWithCustomElementReactions(() => this[REPLACE_NODE](newChild, oldChild));
1270
+ }
1271
+ [REPLACE_NODE](newChild, oldChild, hookEffects) {
1272
+ validateInsertionNodes(this, [newChild]);
1273
+ if (oldChild.parentNode !== this) throw createDOMException("The reference node is not a child of this parent", "NotFoundError");
1274
+ const previous = oldChild[PREV];
678
1275
  const next = oldChild[NEXT];
679
- this.removeChild(oldChild);
680
- this.insertInto(newChild, next);
1276
+ const insertion = this.prepareInsertion(newChild);
1277
+ const removedNodes = this[IS_CONNECTED] ? selfAndDescendants(oldChild) : void 0;
1278
+ const insertionRoots = new Set(insertion.map(({ node }) => node));
1279
+ let before = next;
1280
+ while (before && insertionRoots.has(before)) before = before[NEXT];
1281
+ const oldChildIndex = detachChild(this, oldChild);
1282
+ if (removedNodes) {
1283
+ for (const node of removedNodes) node[IS_CONNECTED] = false;
1284
+ const removedNodeSet = new Set(removedNodes);
1285
+ for (const prepared of insertion) if (removedNodeSet.has(prepared.node)) prepared.shouldDisconnect = false;
1286
+ }
1287
+ this.commitInsertion(insertion, before);
1288
+ const destinationIsConnected = this[IS_CONNECTED];
1289
+ this.queueRemovalMutationRecord(this, oldChild, previous, next);
1290
+ this.queueInsertionMutationRecords(insertion);
1291
+ if (removedNodes) this.enqueueTreeReactions(removedNodes, "disconnectedCallback");
1292
+ this.enqueueInsertionReactions(insertion, destinationIsConnected);
1293
+ this.performOrCollectHookEffects([...this.collectRemovalHookEffects(oldChild, oldChildIndex), ...this.collectInsertionHookEffects(insertion)], hookEffects);
1294
+ return oldChild;
681
1295
  }
682
1296
  querySelectorAll(selector) {
683
1297
  return querySelectorAll(this, selector);
@@ -685,22 +1299,99 @@ var ParentNode = class extends ChildNode {
685
1299
  querySelector(selector) {
686
1300
  return querySelector(this, selector);
687
1301
  }
688
- insertInto(child, before) {
689
- if (child.nodeType === NodeType$1.DOCUMENT_FRAGMENT_NODE) {
1302
+ [INSERT_NODE](child, before, hookEffects) {
1303
+ this.validateInsertion(child, before);
1304
+ this.insertIntoValidated(child, before, hookEffects);
1305
+ return child;
1306
+ }
1307
+ [PREFLIGHT_INSERTIONS](children) {
1308
+ for (const child of children) {
1309
+ this.validateInsertion(child, null);
1310
+ this.prepareInsertion(child);
1311
+ }
1312
+ }
1313
+ validateInsertion(child, before) {
1314
+ validateInsertionNodes(this, [child]);
1315
+ if (before && before.parentNode !== this) throw createDOMException("The reference node is not a child of this parent", "NotFoundError");
1316
+ }
1317
+ insertIntoValidated(child, before, hookEffects) {
1318
+ if (child === before) before = child[NEXT];
1319
+ const insertion = this.prepareInsertion(child);
1320
+ this.commitInsertion(insertion, before);
1321
+ const destinationIsConnected = this[IS_CONNECTED];
1322
+ this.queueInsertionMutationRecords(insertion);
1323
+ this.enqueueInsertionReactions(insertion, destinationIsConnected);
1324
+ this.performOrCollectHookEffects(this.collectInsertionHookEffects(insertion), hookEffects);
1325
+ }
1326
+ performOrCollectHookEffects(effects, hookEffects) {
1327
+ if (hookEffects) hookEffects.push(...effects);
1328
+ else performHookEffects(effects);
1329
+ }
1330
+ prepareInsertion(child) {
1331
+ const roots = [];
1332
+ if (child.nodeType === 11) {
690
1333
  let node = child[CHILD];
691
1334
  while (node) {
692
- const next = node[NEXT];
693
- this.insertInto(node, before);
694
- node = next;
1335
+ roots.push(node);
1336
+ node = node[NEXT];
695
1337
  }
696
- return;
1338
+ } else roots.push(child);
1339
+ const destinationIsConnected = this[IS_CONNECTED];
1340
+ const ownerDocument = this[OWNER_DOCUMENT];
1341
+ const insertion = [];
1342
+ for (const node of roots) {
1343
+ const wasConnected = node[IS_CONNECTED];
1344
+ const shouldTraverse = wasConnected || destinationIsConnected;
1345
+ let nodes;
1346
+ let adoption;
1347
+ if (node[OWNER_DOCUMENT] === ownerDocument) {
1348
+ if (shouldTraverse) nodes = selfAndDescendants(node);
1349
+ } else {
1350
+ const snapshot = collectAdoptionSnapshot(node);
1351
+ adoption = snapshot.nodes;
1352
+ if (shouldTraverse) nodes = snapshot.treeNodes;
1353
+ }
1354
+ insertion.push({
1355
+ node,
1356
+ nodes,
1357
+ adoption,
1358
+ shouldDisconnect: wasConnected
1359
+ });
1360
+ }
1361
+ return insertion;
1362
+ }
1363
+ commitInsertion(insertion, before) {
1364
+ for (const prepared of insertion) {
1365
+ const sourceParent = prepared.node[PARENT];
1366
+ if (sourceParent) {
1367
+ const previousSibling = prepared.node[PREV];
1368
+ const nextSibling = prepared.node[NEXT];
1369
+ prepared.source = {
1370
+ parent: sourceParent,
1371
+ index: detachChild(sourceParent, prepared.node),
1372
+ previousSibling,
1373
+ nextSibling
1374
+ };
1375
+ }
1376
+ }
1377
+ for (const prepared of insertion) {
1378
+ const attached = this.attachChild(prepared.node, before);
1379
+ prepared.insertIndex = attached.index;
1380
+ prepared.previousSibling = attached.previousSibling;
1381
+ prepared.nextSibling = attached.nextSibling;
697
1382
  }
698
- if (child.parentNode !== null) child.parentNode.removeChild(child);
1383
+ const ownerDocument = this[OWNER_DOCUMENT];
1384
+ for (const { adoption } of insertion) if (adoption) adoptNodes(adoption, ownerDocument);
1385
+ const isConnected = this[IS_CONNECTED];
1386
+ for (const { nodes } of insertion) if (nodes) for (const node of nodes) node[IS_CONNECTED] = isConnected;
1387
+ }
1388
+ attachChild(child, before) {
699
1389
  if (before) {
700
- if (before.parentNode !== this) throw Error("reference node is not a child of this parent");
1390
+ const previous = before[PREV];
701
1391
  child[NEXT] = before;
702
- child[PREV] = before[PREV];
703
- if (before[PREV] === null) this[CHILD] = child;
1392
+ child[PREV] = previous;
1393
+ if (previous) previous[NEXT] = child;
1394
+ else this[CHILD] = child;
704
1395
  before[PREV] = child;
705
1396
  } else {
706
1397
  child[NEXT] = null;
@@ -715,34 +1406,127 @@ var ParentNode = class extends ChildNode {
715
1406
  child[PREV] = null;
716
1407
  }
717
1408
  }
718
- const ownerDocument = this[OWNER_DOCUMENT];
719
- const isElement = child.nodeType === NodeType$1.ELEMENT_NODE;
1409
+ const isElement = isElementNode(child);
720
1410
  child[PARENT] = this;
721
- child[OWNER_DOCUMENT] = ownerDocument;
722
- const childNodes = this.childNodes;
723
1411
  let insertIndex;
724
1412
  if (before) {
725
- insertIndex = childNodes.indexOf(before);
726
- childNodes.splice(insertIndex, 0, child);
1413
+ insertIndex = this.childNodes.indexOf(before);
1414
+ this.childNodes.splice(insertIndex, 0, child);
727
1415
  if (isElement) {
728
- const children = this.children;
729
- let ref = before;
730
- while (ref && ref.nodeType !== 1) ref = ref[NEXT];
731
- if (ref) children.splice(children.indexOf(ref), 0, child);
732
- else children.push(child);
1416
+ let reference = before;
1417
+ while (reference && !isElementNode(reference)) reference = reference[NEXT];
1418
+ if (reference) this.children.splice(this.children.indexOf(reference), 0, child);
1419
+ else this.children.push(child);
733
1420
  }
734
1421
  } else {
735
- insertIndex = childNodes.length;
736
- childNodes.push(child);
1422
+ insertIndex = this.childNodes.length;
1423
+ this.childNodes.push(child);
737
1424
  if (isElement) this.children.push(child);
738
1425
  }
739
- if (this[IS_CONNECTED]) for (const node of selfAndDescendants(child)) {
740
- node[IS_CONNECTED] = true;
741
- node.connectedCallback?.();
1426
+ return {
1427
+ index: insertIndex,
1428
+ previousSibling: child[PREV],
1429
+ nextSibling: child[NEXT]
1430
+ };
1431
+ }
1432
+ queueRemovalMutationRecord(parent, child, previousSibling, nextSibling) {
1433
+ if (!childListObserversActive) return;
1434
+ queueMutationRecord({
1435
+ type: "childList",
1436
+ target: parent,
1437
+ removedNodes: mutationNodeList(child),
1438
+ previousSibling,
1439
+ nextSibling
1440
+ });
1441
+ }
1442
+ queueInsertionMutationRecords(insertion) {
1443
+ if (!childListObserversActive) return;
1444
+ for (const prepared of insertion) {
1445
+ const { node, source } = prepared;
1446
+ if (source) this.queueRemovalMutationRecord(source.parent, node, source.previousSibling, source.nextSibling);
1447
+ queueMutationRecord({
1448
+ type: "childList",
1449
+ target: this,
1450
+ addedNodes: mutationNodeList(node),
1451
+ previousSibling: prepared.previousSibling,
1452
+ nextSibling: prepared.nextSibling
1453
+ });
1454
+ }
1455
+ }
1456
+ collectRemovalHookEffects(child, childNodesIndex) {
1457
+ if (this.nodeType !== 1 || isCoveredByPendingPublication(this)) return [];
1458
+ return [[() => this[HOOKS].removeChild?.(this, child, childNodesIndex)]];
1459
+ }
1460
+ collectInsertionHookEffects(insertion) {
1461
+ const effects = [];
1462
+ for (const prepared of insertion) {
1463
+ const { node, source } = prepared;
1464
+ if (source?.parent.nodeType === 1 && !isCoveredByPendingPublication(source.parent)) effects.push([() => source.parent[HOOKS].removeChild?.(source.parent, node, source.index)]);
1465
+ if (this.nodeType === 1 && !isCoveredByPendingPublication(this)) effects.push([() => this[HOOKS].insertChild?.(this, node, prepared.insertIndex), node]);
1466
+ }
1467
+ return effects;
1468
+ }
1469
+ enqueueInsertionReactions(insertion, destinationIsConnected) {
1470
+ for (const prepared of insertion) {
1471
+ const { nodes } = prepared;
1472
+ if (nodes) {
1473
+ if (prepared.shouldDisconnect) this.enqueueTreeReactions(nodes, "disconnectedCallback");
1474
+ if (destinationIsConnected) this.enqueueTreeReactions(nodes, "connectedCallback");
1475
+ }
742
1476
  }
743
- if (this.nodeType === NodeType$1.ELEMENT_NODE) this[HOOKS].insertChild?.(this, child, insertIndex);
1477
+ }
1478
+ enqueueTreeReactions(nodes, callbackName) {
1479
+ enqueueTreeReactions(nodes, callbackName);
744
1480
  }
745
1481
  };
1482
+ function removeChildForAdoption(parent, child, adoption, destination) {
1483
+ if (child.parentNode !== parent) throw Error(`not a child of this node`);
1484
+ const disconnectedNodes = parent[IS_CONNECTED] ? adoption.treeNodes : void 0;
1485
+ const previousSibling = child[PREV];
1486
+ const nextSibling = child[NEXT];
1487
+ const childNodesIndex = detachChild(parent, child);
1488
+ if (disconnectedNodes) for (const node of disconnectedNodes) node[IS_CONNECTED] = false;
1489
+ adoptNodes(adoption.nodes, destination);
1490
+ if (childListObserversActive) queueMutationRecord({
1491
+ type: "childList",
1492
+ target: parent,
1493
+ removedNodes: mutationNodeList(child),
1494
+ previousSibling,
1495
+ nextSibling
1496
+ });
1497
+ if (disconnectedNodes) enqueueTreeReactions(disconnectedNodes, "disconnectedCallback");
1498
+ const effects = [];
1499
+ if (parent.nodeType === 1 && !isCoveredByPendingPublication(parent)) effects.push([() => parent[HOOKS].removeChild?.(parent, child, childNodesIndex)]);
1500
+ performHookEffects(effects);
1501
+ }
1502
+ function detachChild(parent, child) {
1503
+ const previous = child[PREV];
1504
+ const next = child[NEXT];
1505
+ if (previous) previous[NEXT] = next;
1506
+ else parent[CHILD] = next;
1507
+ if (next) next[PREV] = previous;
1508
+ const childNodesIndex = parent.childNodes.indexOf(child);
1509
+ parent.childNodes.splice(childNodesIndex, 1);
1510
+ if (isElementNode(child)) parent.children.splice(parent.children.indexOf(child), 1);
1511
+ child[PARENT] = null;
1512
+ child[NEXT] = null;
1513
+ child[PREV] = null;
1514
+ return childNodesIndex;
1515
+ }
1516
+ function enqueueTreeReactions(nodes, callbackName) {
1517
+ for (const node of nodes) {
1518
+ const callback = node[callbackName];
1519
+ if (typeof callback === "function") enqueueCustomElementReaction(node, () => callback.call(node));
1520
+ }
1521
+ }
1522
+ //#endregion
1523
+ //#region node_modules/@remote-dom/polyfill/build/esm/attribute-reactions.mjs
1524
+ function enqueueAttributeReaction(element, localName, oldValue, newValue, namespace) {
1525
+ const { observedAttributes } = element.constructor;
1526
+ const { attributeChangedCallback } = element;
1527
+ if (attributeChangedCallback == null || observedAttributes == null || !observedAttributes.includes(localName)) return;
1528
+ enqueueCustomElementReaction(element, () => attributeChangedCallback.call(element, localName, oldValue, newValue, namespace));
1529
+ }
746
1530
  //#endregion
747
1531
  //#region node_modules/@remote-dom/polyfill/build/esm/NamedNodeMap.mjs
748
1532
  var NamedNodeMap = class {
@@ -751,12 +1535,21 @@ var NamedNodeMap = class {
751
1535
  this[OWNER_ELEMENT] = ownerElement;
752
1536
  }
753
1537
  getNamedItem(name) {
754
- return this.getNamedItemNS(null, name);
1538
+ const qualifiedName = String(name);
1539
+ const normalizedName = this[OWNER_ELEMENT][NS] === "http://www.w3.org/1999/xhtml" ? asciiLowercase(qualifiedName) : qualifiedName;
1540
+ let attr = this[CHILD];
1541
+ while (attr) {
1542
+ if (attr.name === normalizedName) return attr;
1543
+ attr = attr[NEXT];
1544
+ }
1545
+ return null;
755
1546
  }
756
- getNamedItemNS(namespaceURI, name) {
1547
+ getNamedItemNS(namespaceURI, localName) {
1548
+ const namespace = normalizeNamespace(namespaceURI);
1549
+ const normalizedLocalName = String(localName);
757
1550
  let attr = this[CHILD];
758
1551
  while (attr) {
759
- if (attr.name === name && attr[NS] == namespaceURI) return attr;
1552
+ if (attr.localName === normalizedLocalName && attr[NS] === namespace) return attr;
760
1553
  attr = attr[NEXT];
761
1554
  }
762
1555
  return null;
@@ -780,18 +1573,35 @@ var NamedNodeMap = class {
780
1573
  return index;
781
1574
  }
782
1575
  removeNamedItem(name) {
783
- return this.removeNamedItemNS(null, name);
1576
+ const qualifiedName = String(name);
1577
+ const normalizedName = this[OWNER_ELEMENT][NS] === "http://www.w3.org/1999/xhtml" ? asciiLowercase(qualifiedName) : qualifiedName;
1578
+ return performWithCustomElementReactions(() => this.removeNamedItemImmediately((attr) => attr.name === normalizedName));
1579
+ }
1580
+ removeNamedItemNS(namespaceURI, localName) {
1581
+ const namespace = normalizeNamespace(namespaceURI);
1582
+ const normalizedLocalName = String(localName);
1583
+ return performWithCustomElementReactions(() => this.removeNamedItemImmediately((attr) => attr.localName === normalizedLocalName && attr[NS] === namespace));
784
1584
  }
785
- removeNamedItemNS(namespaceURI, name) {
1585
+ removeNamedItemImmediately(matches) {
786
1586
  const ownerElement = this[OWNER_ELEMENT];
787
1587
  let attr = this[CHILD];
788
1588
  let prev = null;
789
1589
  while (attr != null) {
790
- if (attr.name === name && attr[NS] == namespaceURI) {
1590
+ if (matches(attr)) {
791
1591
  if (prev) prev[NEXT] = attr[NEXT];
792
1592
  if (this[CHILD] === attr) this[CHILD] = attr[NEXT];
793
- updateElementAttribute(ownerElement, attr.name, attr.value, null);
794
- ownerElement[HOOKS].removeAttribute?.(ownerElement, name, namespaceURI);
1593
+ const oldValue = attr.value;
1594
+ attr[NEXT] = null;
1595
+ attr[OWNER_ELEMENT] = null;
1596
+ if (attributeObserversActive) queueMutationRecord({
1597
+ type: "attributes",
1598
+ target: ownerElement,
1599
+ attributeName: attr.name,
1600
+ attributeNamespace: attr[NS],
1601
+ oldValue
1602
+ });
1603
+ ownerElement[HOOKS].removeAttribute?.(ownerElement, attr.name, attr[NS]);
1604
+ enqueueAttributeReaction(ownerElement, attr.localName, oldValue, null, attr[NS]);
795
1605
  return attr;
796
1606
  }
797
1607
  prev = attr;
@@ -800,32 +1610,47 @@ var NamedNodeMap = class {
800
1610
  return null;
801
1611
  }
802
1612
  setNamedItem(attr) {
1613
+ return performWithCustomElementReactions(() => this.setNamedItemImmediately(attr));
1614
+ }
1615
+ setNamedItemImmediately(attr) {
803
1616
  const ownerElement = this[OWNER_ELEMENT];
1617
+ const currentOwner = attr[OWNER_ELEMENT];
1618
+ if (currentOwner != null && currentOwner !== ownerElement) throw createDOMException("The attribute is already in use by another element.", "InUseAttributeError");
804
1619
  let old = null;
805
1620
  let child = this[CHILD];
806
- attr[OWNER_ELEMENT] = ownerElement;
807
- if (child == null) this[CHILD] = attr;
808
- else {
809
- let prev;
810
- while (child) {
811
- if (child.name === attr.name && child[NS] == attr[NS]) {
812
- if (prev) prev[NEXT] = attr;
813
- else this[CHILD] = attr;
814
- attr[NEXT] = child[NEXT];
815
- child[NEXT] = null;
816
- old = child;
817
- break;
818
- }
819
- prev = child;
820
- child = child[NEXT];
1621
+ let prev = null;
1622
+ while (child) {
1623
+ if (child.localName === attr.localName && child[NS] === attr[NS]) {
1624
+ if (child === attr) return child;
1625
+ if (prev) prev[NEXT] = attr;
1626
+ else this[CHILD] = attr;
1627
+ attr[NEXT] = child[NEXT];
1628
+ child[NEXT] = null;
1629
+ old = child;
1630
+ break;
821
1631
  }
1632
+ prev = child;
1633
+ child = child[NEXT];
1634
+ }
1635
+ if (old == null) {
822
1636
  if (prev) prev[NEXT] = attr;
823
1637
  else this[CHILD] = attr;
824
1638
  }
825
- if (!old || old.value !== attr.value) {
826
- updateElementAttribute(ownerElement, attr.name, old?.value ?? null, attr.value);
827
- ownerElement[HOOKS].setAttribute?.(ownerElement, attr.name, attr.value, attr[NS]);
828
- }
1639
+ attr[OWNER_ELEMENT] = ownerElement;
1640
+ attr[OWNER_DOCUMENT] = ownerElement[OWNER_DOCUMENT];
1641
+ if (old) old[OWNER_ELEMENT] = null;
1642
+ const valueChanged = old == null || old.value !== attr.value;
1643
+ const qualifiedNameChanged = old != null && old.name !== attr.name;
1644
+ if (valueChanged && attributeObserversActive) queueMutationRecord({
1645
+ type: "attributes",
1646
+ target: ownerElement,
1647
+ attributeName: attr.name,
1648
+ attributeNamespace: attr[NS],
1649
+ oldValue: old?.value ?? null
1650
+ });
1651
+ if (qualifiedNameChanged) ownerElement[HOOKS].removeAttribute?.(ownerElement, old.name, old[NS]);
1652
+ if (valueChanged || qualifiedNameChanged) ownerElement[HOOKS].setAttribute?.(ownerElement, attr.name, attr.value, attr[NS]);
1653
+ if (valueChanged) enqueueAttributeReaction(ownerElement, attr.localName, old?.value ?? null, attr.value, attr[NS]);
829
1654
  return old;
830
1655
  }
831
1656
  setNamedItemNS(attr) {
@@ -839,17 +1664,10 @@ var NamedNodeMap = class {
839
1664
  }
840
1665
  }
841
1666
  };
842
- function updateElementAttribute(element, name, oldValue, newValue) {
843
- const { observedAttributes } = element.constructor;
844
- const { attributeChangedCallback } = element;
845
- if (name === "slot") element.slot = newValue ?? "";
846
- if (attributeChangedCallback == null || observedAttributes == null || !observedAttributes.includes(name)) return;
847
- return attributeChangedCallback.call(element, name, oldValue, newValue);
848
- }
849
1667
  //#endregion
850
1668
  //#region node_modules/@remote-dom/polyfill/build/esm/Attr.mjs
851
1669
  var Attr = class extends Node$2 {
852
- nodeType = (() => NodeType$1.ATTRIBUTE_NODE)();
1670
+ nodeType = 2;
853
1671
  [NS] = null;
854
1672
  [NEXT] = null;
855
1673
  [OWNER_ELEMENT] = null;
@@ -867,15 +1685,39 @@ var Attr = class extends Node$2 {
867
1685
  return this[NAME];
868
1686
  }
869
1687
  set name(_readonly) {}
1688
+ get localName() {
1689
+ if (this[NS] == null) return this[NAME];
1690
+ const separator = this[NAME].indexOf(":");
1691
+ return separator < 0 ? this[NAME] : this[NAME].slice(separator + 1);
1692
+ }
1693
+ get prefix() {
1694
+ if (this[NS] == null) return null;
1695
+ const separator = this[NAME].indexOf(":");
1696
+ return separator < 0 ? null : this[NAME].slice(0, separator);
1697
+ }
870
1698
  get value() {
871
1699
  return this[VALUE];
872
1700
  }
873
1701
  set value(value) {
874
1702
  const str = String(value);
875
- this[VALUE] = str;
876
1703
  const ownerElement = this[OWNER_ELEMENT];
877
- if (!ownerElement) return;
878
- this[HOOKS].setAttribute?.(ownerElement, this[NAME], str, this[NS]);
1704
+ if (!ownerElement) {
1705
+ this[VALUE] = str;
1706
+ return;
1707
+ }
1708
+ performWithCustomElementReactions(() => {
1709
+ const oldValue = this[VALUE];
1710
+ this[VALUE] = str;
1711
+ if (attributeObserversActive && oldValue !== str) queueMutationRecord({
1712
+ type: "attributes",
1713
+ target: ownerElement,
1714
+ attributeName: this[NAME],
1715
+ attributeNamespace: this[NS],
1716
+ oldValue
1717
+ });
1718
+ this[HOOKS].setAttribute?.(ownerElement, this[NAME], str, this[NS]);
1719
+ enqueueAttributeReaction(ownerElement, this.localName, oldValue, str, this[NS]);
1720
+ });
879
1721
  }
880
1722
  get nodeValue() {
881
1723
  return this.value;
@@ -895,83 +1737,223 @@ var Attr = class extends Node$2 {
895
1737
  };
896
1738
  //#endregion
897
1739
  //#region node_modules/@remote-dom/polyfill/build/esm/serialization.mjs
898
- var elementTokenizer = /(?:<([a-z][a-z0-9-:]*)((?:[\s]+[^<>'"=\s]+(?:=(['"])[^]*?\3|=[^>'"\s]*|))*)[\s]*(\/?)\s*>|<\/([a-z][a-z0-9-:]*)>|<!--(.*?)-->|([^&<>]+))/gi;
899
- var attributeTokenizer = /\s([^<>'"=\n\s]+)(?:=(["'])([\s\S]*?)\2|=([^>'"\n\s]*)|)/g;
1740
+ var CHARACTER_REFERENCES = {
1741
+ amp: "&",
1742
+ AMP: "&",
1743
+ apos: "'",
1744
+ gt: ">",
1745
+ GT: ">",
1746
+ lt: "<",
1747
+ LT: "<",
1748
+ quot: "\"",
1749
+ QUOT: "\""
1750
+ };
1751
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
1752
+ "area",
1753
+ "base",
1754
+ "br",
1755
+ "col",
1756
+ "embed",
1757
+ "hr",
1758
+ "img",
1759
+ "input",
1760
+ "link",
1761
+ "meta",
1762
+ "param",
1763
+ "source",
1764
+ "track",
1765
+ "wbr"
1766
+ ]);
1767
+ var ELEMENT_TOKENIZER = /(?:<([a-z][a-z0-9-:]*)((?:[\s]+[^<>'"=/\s]+(?:=(['"])[^]*?\3|=[^>'"\s]*|))*)[\s]*(\/?)\s*>|<\/([a-z][a-z0-9-:]*)>|<!--(.*?)-->|([^<>]+))/gi;
1768
+ var ATTRIBUTE_TOKENIZER = /\s([^<>'"=/\n\s]+)(?:=(["'])([\s\S]*?)\2|=([^>'"\n\s]*)|)/g;
1769
+ var SVG_HTML_BREAKOUTS = "|b|big|blockquote|body|br|center|code|dd|div|dl|dt|em|embed|h1|h2|h3|h4|h5|h6|head|hr|i|img|li|listing|menu|meta|nobr|ol|p|pre|ruby|s|small|span|strong|strike|sub|sup|table|tt|u|ul|var|";
1770
+ var SVG_HTML_FONT_ATTRIBUTE = /^(?:color|face|size)$/i;
1771
+ function decodeCharacterReferences(value) {
1772
+ return value.replace(/&(?:(amp|AMP|apos|gt|GT|lt|LT|quot|QUOT)|#(\d+)|#[xX]([\da-fA-F]+));/g, (reference, name, decimal, hexadecimal) => {
1773
+ if (name) return CHARACTER_REFERENCES[name];
1774
+ const codePoint = Number.parseInt(decimal ?? hexadecimal, decimal ? 10 : 16);
1775
+ try {
1776
+ return String.fromCodePoint(codePoint);
1777
+ } catch {
1778
+ return reference;
1779
+ }
1780
+ });
1781
+ }
1782
+ function isVoidElement(element) {
1783
+ return element.namespaceURI === "http://www.w3.org/1999/xhtml" && VOID_ELEMENTS.has(element.localName);
1784
+ }
1785
+ function isHtmlIntegrationPoint(element) {
1786
+ const name = element.localName;
1787
+ return element[NS] === "http://www.w3.org/2000/svg" && (name === "foreignObject" || name === "desc" || name === "title");
1788
+ }
1789
+ function isSvgHtmlBreakout(tag, attributes) {
1790
+ if (SVG_HTML_BREAKOUTS.includes(`|${tag}|`)) return true;
1791
+ if (tag !== "font") return false;
1792
+ for (const attribute of attributes.matchAll(ATTRIBUTE_TOKENIZER)) if (SVG_HTML_FONT_ATTRIBUTE.test(attribute[1])) return true;
1793
+ return false;
1794
+ }
900
1795
  function parseHtml(html, contextNode) {
901
1796
  const document = contextNode.ownerDocument;
902
1797
  const root = document.createDocumentFragment();
903
- const stack = [root];
1798
+ const stack = [];
904
1799
  let parent = root;
905
- let token;
906
- elementTokenizer.lastIndex = 0;
907
- while (token = elementTokenizer.exec(html)) {
1800
+ for (const token of html.matchAll(ELEMENT_TOKENIZER)) {
908
1801
  const tag = token[1];
909
1802
  if (tag) {
910
- const node = document.createElement(tag);
911
1803
  const attrs = token[2];
912
- attributeTokenizer.lastIndex = 0;
913
- let t;
914
- while (t = attributeTokenizer.exec(attrs)) node.setAttribute(t[1], t[3] || t[4] || "");
1804
+ const normalizedTag = asciiLowercase(tag);
1805
+ const openElement = stack[stack.length - 1]?.element ?? contextNode;
1806
+ let namespace = openElement[NS] === "http://www.w3.org/2000/svg" ? SVG_NAMESPACE : HTML_NAMESPACE;
1807
+ if (normalizedTag === "svg") namespace = SVG_NAMESPACE;
1808
+ else if (namespace === "http://www.w3.org/2000/svg") {
1809
+ if (isHtmlIntegrationPoint(openElement)) namespace = HTML_NAMESPACE;
1810
+ else if (isSvgHtmlBreakout(normalizedTag, attrs)) {
1811
+ while (stack.length > 0) {
1812
+ const frame = stack[stack.length - 1];
1813
+ if (frame.element[NS] !== "http://www.w3.org/2000/svg" || isHtmlIntegrationPoint(frame.element)) break;
1814
+ stack.pop();
1815
+ parent = frame.target;
1816
+ }
1817
+ namespace = HTML_NAMESPACE;
1818
+ }
1819
+ }
1820
+ const name = namespace === "http://www.w3.org/1999/xhtml" ? normalizedTag : tag;
1821
+ const node = document[CREATE_ELEMENT](name, namespace, null, name);
1822
+ for (const attribute of attrs.matchAll(ATTRIBUTE_TOKENIZER)) node.setAttribute(attribute[1], decodeCharacterReferences(attribute[3] || attribute[4] || ""));
915
1823
  parent.append(node);
916
- stack.push(parent);
917
- parent = node;
918
- } else if (token[5]) parent = stack.pop() || root;
919
- else if (token[6]) parent.append(document.createComment(token[6]));
920
- else parent.append(token[7]);
1824
+ if (isVoidElement(node) || namespace !== "http://www.w3.org/1999/xhtml" && token[4]) continue;
1825
+ stack.push({
1826
+ element: node,
1827
+ target: parent
1828
+ });
1829
+ parent = namespace === "http://www.w3.org/1999/xhtml" && normalizedTag === "template" ? node.content : node;
1830
+ } else if (token[5]) {
1831
+ const closingTag = asciiLowercase(token[5]);
1832
+ for (let index = stack.length - 1; index >= 0; index--) {
1833
+ const frame = stack[index];
1834
+ const frameName = asciiLowercase(frame.element[NAME]);
1835
+ if (frameName === closingTag) {
1836
+ parent = frame.target;
1837
+ stack.length = index;
1838
+ break;
1839
+ }
1840
+ if (frame.element[NS] === "http://www.w3.org/1999/xhtml" && frameName === "template") break;
1841
+ }
1842
+ } else if (token[6]) parent.append(document.createComment(token[6]));
1843
+ else parent.append(decodeCharacterReferences(token[7]));
921
1844
  }
922
1845
  return root;
923
1846
  }
924
1847
  function serializeChildren(parentNode) {
925
- let out = "";
926
- let child = parentNode[CHILD];
927
- while (child) {
928
- out += serializeNode(child);
929
- child = child[NEXT];
930
- }
931
- return out;
1848
+ return serialize([{
1849
+ type: "content",
1850
+ child: parentNode[CHILD]
1851
+ }]);
932
1852
  }
933
1853
  function serializeNode(node) {
934
- switch (node.nodeType) {
935
- case NodeType$1.ELEMENT_NODE: {
936
- const el = node;
937
- let out = `<${el[NAME]}`;
938
- let attr = el[ATTRIBUTES]?.[CHILD];
939
- while (attr) {
940
- out += ` ${attr[NAME]}`;
941
- let value = attr[VALUE];
942
- if (value !== "") {
943
- value = String(value).replace(/&/g, "&amp;").replace(/"/g, "&quot;");
944
- out += `="${value}"`;
945
- }
946
- attr = attr[NEXT];
947
- }
948
- out += ">";
949
- out += serializeChildren(el);
950
- out += `</${el[NAME]}>`;
951
- return out;
1854
+ return serialize([{
1855
+ type: "opening",
1856
+ node
1857
+ }]);
1858
+ }
1859
+ function serialize(workItems) {
1860
+ const chunks = [];
1861
+ let workItem;
1862
+ while (workItem = workItems.pop()) switch (workItem.type) {
1863
+ case "opening": {
1864
+ const node = workItem.node;
1865
+ switch (node.nodeType) {
1866
+ case 1: {
1867
+ const el = node;
1868
+ chunks.push(`<${el[NAME]}`);
1869
+ let attr = el[ATTRIBUTES]?.[CHILD];
1870
+ while (attr) {
1871
+ chunks.push(` ${attr[NAME]}`);
1872
+ let value = attr[VALUE];
1873
+ if (value !== "") {
1874
+ value = String(value).replace(/&/g, "&amp;").replace(/"/g, "&quot;");
1875
+ chunks.push(`="${value}"`);
1876
+ }
1877
+ attr = attr[NEXT];
1878
+ }
1879
+ chunks.push(">");
1880
+ if (isVoidElement(el)) break;
1881
+ const content = el.namespaceURI === "http://www.w3.org/1999/xhtml" && el.localName === "template" ? el[CONTENT] : el;
1882
+ workItems.push({
1883
+ type: "closing",
1884
+ name: el[NAME]
1885
+ });
1886
+ workItems.push({
1887
+ type: "content",
1888
+ child: content?.[CHILD] ?? null
1889
+ });
1890
+ break;
1891
+ }
1892
+ case 3: {
1893
+ const text = node;
1894
+ chunks.push(text[DATA].replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
1895
+ break;
1896
+ }
1897
+ case 8: {
1898
+ const text = node;
1899
+ chunks.push(`<!--${text[DATA]}-->`);
1900
+ break;
1901
+ }
1902
+ }
1903
+ break;
952
1904
  }
953
- case NodeType$1.TEXT_NODE: return node[DATA].replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
954
- case NodeType$1.COMMENT_NODE: return `<!--${node[DATA]}-->`;
1905
+ case "content": {
1906
+ const child = workItem.child;
1907
+ if (child) {
1908
+ workItems.push({
1909
+ type: "content",
1910
+ child: child[NEXT]
1911
+ });
1912
+ workItems.push({
1913
+ type: "opening",
1914
+ node: child
1915
+ });
1916
+ }
1917
+ break;
1918
+ }
1919
+ case "closing": chunks.push(`</${workItem.name}>`);
955
1920
  }
956
- return "";
1921
+ return chunks.join("");
957
1922
  }
958
1923
  //#endregion
959
1924
  //#region node_modules/@remote-dom/polyfill/build/esm/Element.mjs
960
1925
  var Element$2 = class extends ParentNode {
961
- nodeType = (() => NodeType$1.ELEMENT_NODE)();
962
- [NS] = (() => NamespaceURI.XHTML)();
1926
+ nodeType = 1;
1927
+ [NS] = HTML_NAMESPACE;
1928
+ [PREFIX] = null;
963
1929
  get namespaceURI() {
964
1930
  return this[NS];
965
1931
  }
1932
+ get prefix() {
1933
+ return this[PREFIX];
1934
+ }
1935
+ get localName() {
1936
+ const prefix = this[PREFIX];
1937
+ return prefix == null ? this[NAME] : this[NAME].slice(prefix.length + 1);
1938
+ }
1939
+ get nodeName() {
1940
+ return this[NS] === "http://www.w3.org/1999/xhtml" ? asciiUppercase(this[NAME]) : this[NAME];
1941
+ }
966
1942
  get tagName() {
967
1943
  return this.nodeName;
968
1944
  }
1945
+ get id() {
1946
+ return this.getAttributeNS(null, "id") ?? "";
1947
+ }
1948
+ set id(id) {
1949
+ this.setAttribute("id", String(id));
1950
+ }
969
1951
  get slot() {
970
- return this.getAttribute("slot") ?? "";
1952
+ return this.getAttributeNS(null, "slot") ?? "";
971
1953
  }
972
1954
  set slot(slot) {
973
1955
  const finalSlot = String(slot);
974
- if (this.getAttribute("slot") !== finalSlot) this.attributes.setNamedItem(new Attr("slot", finalSlot));
1956
+ if (this.getAttributeNS(null, "slot") !== finalSlot) this.attributes.setNamedItem(new Attr("slot", finalSlot));
975
1957
  }
976
1958
  get attributes() {
977
1959
  let attributes = this[ATTRIBUTES];
@@ -984,9 +1966,15 @@ var Element$2 = class extends ParentNode {
984
1966
  getAttributeNames() {
985
1967
  return [...this.attributes].map((attr) => attr.name);
986
1968
  }
1969
+ getElementsByTagName(qualifiedName) {
1970
+ return getElementsByTagName(this, qualifiedName);
1971
+ }
987
1972
  get firstElementChild() {
988
1973
  return this.children[0] ?? null;
989
1974
  }
1975
+ getElementsByClassName(classNames) {
1976
+ return getElementsByClassName(this, classNames);
1977
+ }
990
1978
  get lastElementChild() {
991
1979
  return this.children[this.children.length - 1] ?? null;
992
1980
  }
@@ -1001,10 +1989,37 @@ var Element$2 = class extends ParentNode {
1001
1989
  return sib;
1002
1990
  }
1003
1991
  setAttribute(name, value) {
1004
- this.attributes.setNamedItem(new Attr(name, String(value)));
1005
- }
1006
- setAttributeNS(namespace, name, value) {
1007
- this.attributes.setNamedItemNS(new Attr(name, String(value), namespace));
1992
+ const qualifiedName = String(name);
1993
+ const normalizedValue = String(value);
1994
+ validateAttributeLocalName(qualifiedName);
1995
+ const normalizedName = this[NS] === "http://www.w3.org/1999/xhtml" ? asciiLowercase(qualifiedName) : qualifiedName;
1996
+ const attribute = this.attributes.getNamedItemNS(null, normalizedName);
1997
+ if (attribute) attribute.value = normalizedValue;
1998
+ else this.attributes.setNamedItem(new Attr(normalizedName, normalizedValue));
1999
+ }
2000
+ setAttributeNS(namespace, qualifiedName, value) {
2001
+ const normalizedNamespace = normalizeNamespace(namespace);
2002
+ const normalizedQualifiedName = String(qualifiedName);
2003
+ const normalizedValue = String(value);
2004
+ const name = validateAndExtractQualifiedName(normalizedNamespace, normalizedQualifiedName, "attribute");
2005
+ const attribute = this.attributes.getNamedItemNS(name.namespace, name.localName);
2006
+ if (attribute) attribute.value = normalizedValue;
2007
+ else this.attributes.setNamedItemNS(new Attr(name.qualifiedName, normalizedValue, name.namespace));
2008
+ }
2009
+ toggleAttribute(name, force) {
2010
+ const qualifiedName = String(name);
2011
+ validateAttributeLocalName(qualifiedName);
2012
+ const normalizedName = this[NS] === "http://www.w3.org/1999/xhtml" ? asciiLowercase(qualifiedName) : qualifiedName;
2013
+ const attribute = this.attributes.getNamedItemNS(null, normalizedName);
2014
+ const normalizedForce = force === void 0 ? void 0 : Boolean(force);
2015
+ if (attribute == null) {
2016
+ if (normalizedForce === false) return false;
2017
+ this.attributes.setNamedItem(new Attr(normalizedName, ""));
2018
+ return true;
2019
+ }
2020
+ if (normalizedForce === true) return true;
2021
+ this.attributes.removeNamedItemNS(null, normalizedName);
2022
+ return false;
1008
2023
  }
1009
2024
  getAttribute(name) {
1010
2025
  const attr = this.attributes.getNamedItem(name);
@@ -1021,7 +2036,9 @@ var Element$2 = class extends ParentNode {
1021
2036
  return this.attributes.getNamedItemNS(namespace, name) != null;
1022
2037
  }
1023
2038
  removeAttribute(name) {
1024
- this.attributes.removeNamedItem(name);
2039
+ const qualifiedName = String(name);
2040
+ const normalizedName = this[NS] === "http://www.w3.org/1999/xhtml" ? asciiLowercase(qualifiedName) : qualifiedName;
2041
+ this.attributes.removeNamedItemNS(null, normalizedName);
1025
2042
  }
1026
2043
  removeAttributeNS(namespace, name) {
1027
2044
  this.attributes.removeNamedItemNS(namespace, name);
@@ -1043,7 +2060,7 @@ var Element$2 = class extends ParentNode {
1043
2060
  //#endregion
1044
2061
  //#region node_modules/@remote-dom/polyfill/build/esm/SVGElement.mjs
1045
2062
  var SVGElement = class SVGElement extends Element$2 {
1046
- [NS] = (() => NamespaceURI.SVG)();
2063
+ [NS] = SVG_NAMESPACE;
1047
2064
  get ownerSVGElement() {
1048
2065
  let root = null;
1049
2066
  let parent = this.parentNode;
@@ -1063,9 +2080,16 @@ var CharacterData = class extends ChildNode {
1063
2080
  this[DATA] = data == null ? "" : String(data);
1064
2081
  }
1065
2082
  setData(data) {
2083
+ const shouldQueueMutation = characterDataObserversActive;
2084
+ const oldValue = shouldQueueMutation ? this[DATA] : null;
1066
2085
  let str = "";
1067
2086
  if (data != null) str = typeof data === "string" ? data : String(data);
1068
2087
  this[DATA] = str;
2088
+ if (shouldQueueMutation && oldValue !== str) queueMutationRecord({
2089
+ type: "characterData",
2090
+ target: this,
2091
+ oldValue
2092
+ });
1069
2093
  this[HOOKS].setText?.(this, str);
1070
2094
  }
1071
2095
  get data() {
@@ -1078,7 +2102,7 @@ var CharacterData = class extends ChildNode {
1078
2102
  //#endregion
1079
2103
  //#region node_modules/@remote-dom/polyfill/build/esm/Text.mjs
1080
2104
  var Text = class extends CharacterData {
1081
- nodeType = (() => NodeType$1.TEXT_NODE)();
2105
+ nodeType = 3;
1082
2106
  [NAME] = "#text";
1083
2107
  };
1084
2108
  //#endregion
@@ -1090,9 +2114,12 @@ var Comment = class extends CharacterData {
1090
2114
  //#endregion
1091
2115
  //#region node_modules/@remote-dom/polyfill/build/esm/DocumentFragment.mjs
1092
2116
  var DocumentFragment = class extends ParentNode {
1093
- nodeType = (() => NodeType$1.DOCUMENT_FRAGMENT_NODE)();
2117
+ nodeType = 11;
1094
2118
  [NAME] = "#document-fragment";
1095
- [OWNER_DOCUMENT] = (() => typeof window !== "undefined" ? window.document : null)();
2119
+ [OWNER_DOCUMENT] = typeof window !== "undefined" ? window.document : null;
2120
+ getElementById(elementId) {
2121
+ return getElementById(this, elementId);
2122
+ }
1096
2123
  };
1097
2124
  //#endregion
1098
2125
  //#region node_modules/@remote-dom/polyfill/build/esm/HTMLTemplateElement.mjs
@@ -1101,6 +2128,7 @@ var HTMLTemplateElement = class extends Element$2 {
1101
2128
  let content = this[CONTENT];
1102
2129
  if (!content) {
1103
2130
  content = this.ownerDocument.createDocumentFragment();
2131
+ content[HOST] = this;
1104
2132
  this[CONTENT] = content;
1105
2133
  }
1106
2134
  return content;
@@ -1126,7 +2154,7 @@ var HTMLHtmlElement = class extends Element$2 {};
1126
2154
  //#endregion
1127
2155
  //#region node_modules/@remote-dom/polyfill/build/esm/Document.mjs
1128
2156
  var Document$1 = class extends ParentNode {
1129
- nodeType = (() => NodeType$1.DOCUMENT_NODE)();
2157
+ nodeType = 9;
1130
2158
  [NAME] = "#document";
1131
2159
  [IS_CONNECTED] = true;
1132
2160
  constructor(defaultView) {
@@ -1140,15 +2168,28 @@ var Document$1 = class extends ParentNode {
1140
2168
  this.documentElement.appendChild(this.head);
1141
2169
  this.documentElement.appendChild(this.body);
1142
2170
  }
2171
+ get textContent() {
2172
+ return null;
2173
+ }
2174
+ set textContent(data) {}
2175
+ getElementsByClassName(classNames) {
2176
+ return getElementsByClassName(this, classNames);
2177
+ }
1143
2178
  createElement(localName) {
1144
- return createElement(this, localName);
2179
+ const name = String(localName);
2180
+ validateElementLocalName(name);
2181
+ return createElement(this, asciiLowercase(name));
2182
+ }
2183
+ createElementNS(namespaceURI, qualifiedName) {
2184
+ const name = validateAndExtractQualifiedName(namespaceURI, qualifiedName, "element");
2185
+ return createElement(this, name.qualifiedName, name.namespace, name.prefix, name.localName);
1145
2186
  }
1146
- createElementNS(namespaceURI, localName) {
1147
- return createElement(this, localName, namespaceURI);
2187
+ [CREATE_ELEMENT](qualifiedName, namespace, prefix, localName) {
2188
+ return createElement(this, qualifiedName, namespace, prefix, localName);
1148
2189
  }
1149
2190
  createTextNode(data) {
1150
2191
  const text = createNode(new Text(data), this);
1151
- this[HOOKS].createText?.(text, String(data));
2192
+ this[HOOKS].createText?.(text, text.data);
1152
2193
  return text;
1153
2194
  }
1154
2195
  createComment(data) {
@@ -1160,14 +2201,25 @@ var Document$1 = class extends ParentNode {
1160
2201
  createEvent() {
1161
2202
  return new Event("");
1162
2203
  }
2204
+ getElementById(elementId) {
2205
+ return getElementById(this, elementId);
2206
+ }
2207
+ getElementsByTagName(qualifiedName) {
2208
+ return getElementsByTagName(this, qualifiedName);
2209
+ }
1163
2210
  importNode(node, deep) {
2211
+ if (node.nodeType === 9) throw createDOMException("Cannot import a document node", "NotSupportedError");
1164
2212
  return cloneNode(node, deep, this);
1165
2213
  }
1166
2214
  adoptNode(node) {
1167
2215
  if (node[OWNER_DOCUMENT] === this) return node;
1168
- node.parentNode?.removeChild(node);
1169
- adoptNode(node, this);
1170
- return node;
2216
+ const adoption = collectAdoptionSnapshot(node);
2217
+ return performWithCustomElementReactions(() => {
2218
+ const parent = node.parentNode;
2219
+ if (parent) removeChildForAdoption(parent, node, adoption, this);
2220
+ else adoptNodes(adoption.nodes, this);
2221
+ return node;
2222
+ });
1171
2223
  }
1172
2224
  };
1173
2225
  function createNode(node, ownerDocument) {
@@ -1178,28 +2230,26 @@ function createNode(node, ownerDocument) {
1178
2230
  });
1179
2231
  return node;
1180
2232
  }
1181
- function createElement(ownerDocument, name, namespace) {
2233
+ function createElement(ownerDocument, qualifiedName, namespace = HTML_NAMESPACE, prefix = null, localName = qualifiedName) {
1182
2234
  let element;
1183
- const lowerName = String(name).toLowerCase();
1184
- if (namespace === NamespaceURI.SVG) element = new SVGElement();
1185
- else if (lowerName === "template") element = new HTMLTemplateElement();
1186
- else {
1187
- const CustomElement = ownerDocument.defaultView.customElements.get(name);
2235
+ if (namespace === "http://www.w3.org/2000/svg") element = new SVGElement();
2236
+ else if (namespace === "http://www.w3.org/1999/xhtml" && localName === "template") element = new HTMLTemplateElement();
2237
+ else if (namespace === "http://www.w3.org/1999/xhtml") {
2238
+ const CustomElement = ownerDocument.defaultView.customElements.get(localName);
1188
2239
  element = CustomElement ? new CustomElement() : new Element$2();
1189
- }
1190
- return setupElement(element, ownerDocument, name, namespace);
2240
+ } else element = new Element$2();
2241
+ return setupElement(element, ownerDocument, qualifiedName, namespace, prefix);
1191
2242
  }
1192
- function setupElement(element, ownerDocument, name, namespace) {
2243
+ function setupElement(element, ownerDocument, qualifiedName, namespace = HTML_NAMESPACE, prefix = null) {
1193
2244
  createNode(element, ownerDocument);
1194
- Object.defineProperty(element, NAME, { value: name });
1195
- if (namespace) Object.defineProperty(element, NS, { value: namespace });
2245
+ Object.defineProperties(element, {
2246
+ [NAME]: { value: qualifiedName },
2247
+ [NS]: { value: namespace },
2248
+ [PREFIX]: { value: prefix }
2249
+ });
1196
2250
  ownerDocument[HOOKS].createElement?.(element, namespace);
1197
2251
  return element;
1198
2252
  }
1199
- function adoptNode(node, document) {
1200
- node[OWNER_DOCUMENT] = document;
1201
- if (isParentNode(node)) for (const child of node.childNodes) adoptNode(child, document);
1202
- }
1203
2253
  //#endregion
1204
2254
  //#region node_modules/@remote-dom/polyfill/build/esm/CustomEvent.mjs
1205
2255
  var CustomEvent = class extends Event {
@@ -1210,7 +2260,7 @@ var CustomEvent = class extends Event {
1210
2260
  */
1211
2261
  constructor(type, eventInitDict) {
1212
2262
  super(type, eventInitDict);
1213
- this.detail = eventInitDict?.detail;
2263
+ this.detail = eventInitDict?.detail ?? null;
1214
2264
  }
1215
2265
  /**
1216
2266
  * Returns any custom data event was created with. Typically used for synthetic events.
@@ -1219,7 +2269,7 @@ var CustomEvent = class extends Event {
1219
2269
  */
1220
2270
  initCustomEvent(type, bubbles, cancelable, detail) {
1221
2271
  super.initEvent(type, bubbles, cancelable);
1222
- this.detail = detail;
2272
+ this.detail = detail ?? null;
1223
2273
  }
1224
2274
  };
1225
2275
  //#endregion
@@ -1273,10 +2323,30 @@ var ClipboardEvent = class extends Event {
1273
2323
  var HTMLElement = class extends Element$2 {};
1274
2324
  //#endregion
1275
2325
  //#region node_modules/@remote-dom/polyfill/build/esm/CustomElementRegistry.mjs
2326
+ var VALID_CUSTOM_ELEMENT_NAME = /^[a-z][^A-Z\u0000\t\n\f\r />]*-[^A-Z\u0000\t\n\f\r />]*$/u;
2327
+ var RESERVED_CUSTOM_ELEMENT_NAMES = /* @__PURE__ */ new Set([
2328
+ "annotation-xml",
2329
+ "color-profile",
2330
+ "font-face",
2331
+ "font-face-src",
2332
+ "font-face-uri",
2333
+ "font-face-format",
2334
+ "font-face-name",
2335
+ "missing-glyph"
2336
+ ]);
2337
+ function isValidCustomElementName(name) {
2338
+ return VALID_CUSTOM_ELEMENT_NAME.test(name) && !RESERVED_CUSTOM_ELEMENT_NAMES.has(name);
2339
+ }
2340
+ function createInvalidCustomElementNameError(name) {
2341
+ return createDOMException(`Invalid custom element name: "${name}"`, "SyntaxError");
2342
+ }
1276
2343
  var CustomElementRegistryImplementation = class {
1277
- registry = (() => /* @__PURE__ */ new Map())();
1278
- listenersByName = (() => /* @__PURE__ */ new Map())();
2344
+ registry = /* @__PURE__ */ new Map();
2345
+ listenersByName = /* @__PURE__ */ new Map();
1279
2346
  define(name, Constructor, _options) {
2347
+ if (!isValidCustomElementName(name)) throw createInvalidCustomElementNameError(name);
2348
+ if (this.registry.has(name)) throw createDOMException(`A custom element named "${name}" has already been defined`, "NotSupportedError");
2349
+ if (this.getName(Constructor) != null) throw createDOMException("This constructor has already been registered in this custom element registry", "NotSupportedError");
1280
2350
  this.registry.set(name, Constructor);
1281
2351
  const listeners = this.listenersByName.get(name);
1282
2352
  if (listeners == null) return;
@@ -1291,6 +2361,7 @@ var CustomElementRegistryImplementation = class {
1291
2361
  return null;
1292
2362
  }
1293
2363
  whenDefined(name) {
2364
+ if (!isValidCustomElementName(name)) return Promise.reject(createInvalidCustomElementNameError(name));
1294
2365
  const Constructor = this.registry.get(name);
1295
2366
  if (Constructor != null) return Promise.resolve(Constructor);
1296
2367
  let listeners = this.listenersByName.get(name);
@@ -1303,47 +2374,109 @@ var CustomElementRegistryImplementation = class {
1303
2374
  });
1304
2375
  }
1305
2376
  upgrade(_root) {}
2377
+ initialize(_root) {}
1306
2378
  };
1307
2379
  //#endregion
1308
- //#region node_modules/@remote-dom/polyfill/build/esm/MutationObserver.mjs
1309
- var MutationObserver = class {};
1310
- //#endregion
1311
2380
  //#region node_modules/@remote-dom/polyfill/build/esm/Window.mjs
2381
+ var EVENT_HANDLER_PROPERTIES = ["onerror", "onunhandledrejection"];
2382
+ var POLYFILL_GLOBAL_PROPERTY = Symbol.for("@remote-dom/polyfill/global-property");
2383
+ function windowPropertyDescriptors(window) {
2384
+ return Object.getOwnPropertyDescriptors(window);
2385
+ }
2386
+ function eventTargetPropertyDescriptors(window) {
2387
+ const properties = {};
2388
+ for (const [property, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(EventTarget.prototype))) if (property !== "constructor" && typeof descriptor.value === "function") {
2389
+ descriptor.value = markPolyfillGlobalProperty(descriptor.value.bind(window));
2390
+ properties[property] = descriptor;
2391
+ }
2392
+ return properties;
2393
+ }
2394
+ function eventHandlerPropertyDescriptors(window) {
2395
+ const properties = {};
2396
+ for (const property of EVENT_HANDLER_PROPERTIES) properties[property] = {
2397
+ configurable: true,
2398
+ enumerable: true,
2399
+ get: markPolyfillGlobalProperty(() => window[property]),
2400
+ set: markPolyfillGlobalProperty((handler) => {
2401
+ window[property] = handler;
2402
+ })
2403
+ };
2404
+ return properties;
2405
+ }
2406
+ function globalPropertyDescriptors(window) {
2407
+ return Object.assign(windowPropertyDescriptors(window), eventTargetPropertyDescriptors(window), eventHandlerPropertyDescriptors(window));
2408
+ }
2409
+ function markPolyfillGlobalProperty(value) {
2410
+ Object.defineProperty(value, POLYFILL_GLOBAL_PROPERTY, { value: true });
2411
+ return value;
2412
+ }
2413
+ function installMissingGlobalProperties(target, properties) {
2414
+ for (const property of Reflect.ownKeys(properties)) {
2415
+ const currentDescriptor = findPropertyDescriptor(target, property);
2416
+ if (currentDescriptor == null || isPolyfillGlobalProperty(currentDescriptor)) Object.defineProperty(target, property, properties[property]);
2417
+ }
2418
+ }
2419
+ function findPropertyDescriptor(target, property) {
2420
+ let currentTarget = target;
2421
+ while (currentTarget) {
2422
+ const descriptor = Object.getOwnPropertyDescriptor(currentTarget, property);
2423
+ if (descriptor) return descriptor;
2424
+ currentTarget = Object.getPrototypeOf(currentTarget);
2425
+ }
2426
+ }
2427
+ function isPolyfillGlobalProperty(descriptor) {
2428
+ return [
2429
+ descriptor.value,
2430
+ descriptor.get,
2431
+ descriptor.set
2432
+ ].some((value) => typeof value === "function" && value[POLYFILL_GLOBAL_PROPERTY] === true);
2433
+ }
1312
2434
  var Window = class extends EventTarget {
1313
2435
  [HOOKS] = {};
2436
+ [EXTENSIONS] = [];
2437
+ [HOOKS_DISPATCH] = createHooksDispatcher(this);
1314
2438
  name = "";
1315
2439
  window = this;
1316
2440
  parent = this;
1317
2441
  self = this;
1318
2442
  top = this;
1319
- document = (() => new Document$1(this))();
1320
- customElements = (() => new CustomElementRegistryImplementation())();
1321
- location = (() => globalThis.location)();
1322
- navigator = (() => globalThis.navigator)();
1323
- Event = (() => Event)();
1324
- ErrorEvent = (() => ErrorEvent)();
1325
- PromiseRejectionEvent = (() => PromiseRejectionEvent)();
1326
- ToggleEvent = (() => ToggleEvent)();
1327
- FocusEvent = (() => FocusEvent)();
1328
- ClipboardEvent = (() => ClipboardEvent)();
1329
- EventTarget = (() => EventTarget)();
1330
- CustomEvent = (() => CustomEvent)();
1331
- Node = (() => Node$2)();
1332
- ParentNode = (() => ParentNode)();
1333
- ChildNode = (() => ChildNode)();
1334
- DocumentFragment = (() => DocumentFragment)();
1335
- Document = (() => Document$1)();
1336
- CharacterData = (() => CharacterData)();
1337
- Comment = (() => Comment)();
1338
- Text = (() => Text)();
1339
- Element = (() => Element$2)();
1340
- HTMLElement = (() => HTMLElement)();
1341
- SVGElement = (() => SVGElement)();
1342
- HTMLTemplateElement = (() => HTMLTemplateElement)();
1343
- MutationObserver = (() => MutationObserver)();
2443
+ document = new Document$1(this);
2444
+ customElements = new CustomElementRegistryImplementation();
2445
+ location = globalThis.location;
2446
+ navigator = globalThis.navigator;
2447
+ Event = Event;
2448
+ ErrorEvent = ErrorEvent;
2449
+ PromiseRejectionEvent = PromiseRejectionEvent;
2450
+ ToggleEvent = ToggleEvent;
2451
+ FocusEvent = FocusEvent;
2452
+ ClipboardEvent = ClipboardEvent;
2453
+ EventTarget = EventTarget;
2454
+ CustomEvent = CustomEvent;
2455
+ Node = Node$2;
2456
+ ParentNode = ParentNode;
2457
+ ChildNode = ChildNode;
2458
+ DocumentFragment = DocumentFragment;
2459
+ Document = Document$1;
2460
+ CharacterData = CharacterData;
2461
+ Comment = Comment;
2462
+ Text = Text;
2463
+ Element = Element$2;
2464
+ HTMLElement = HTMLElement;
2465
+ SVGElement = SVGElement;
2466
+ HTMLTemplateElement = HTMLTemplateElement;
2467
+ MutationObserver = MutationObserver;
1344
2468
  #currentOnErrorHandler = null;
1345
2469
  #currentOriginalOnErrorHandler = null;
1346
2470
  #currentOnUnhandledRejectionHandler = null;
2471
+ static with(...extensions) {
2472
+ const BaseWindow = this;
2473
+ return class ExtendedWindow extends BaseWindow {
2474
+ constructor() {
2475
+ super();
2476
+ for (const extension of extensions) installExtension(this, extension);
2477
+ }
2478
+ };
2479
+ }
1347
2480
  get onerror() {
1348
2481
  return this.#currentOriginalOnErrorHandler;
1349
2482
  }
@@ -1371,26 +2504,50 @@ var Window = class extends EventTarget {
1371
2504
  } else this.#currentOnUnhandledRejectionHandler = null;
1372
2505
  }
1373
2506
  static setGlobal(window) {
1374
- const properties = Object.getOwnPropertyDescriptors(window);
2507
+ const currentSelf = globalThis.self;
2508
+ const currentWindow = globalThis.window;
2509
+ const properties = windowPropertyDescriptors(window);
2510
+ const missingProperties = Object.assign(eventTargetPropertyDescriptors(window), eventHandlerPropertyDescriptors(window));
1375
2511
  delete properties.self;
1376
2512
  Object.defineProperties(globalThis, properties);
1377
- if (typeof globalThis.self === "undefined") Object.defineProperty(globalThis, "self", {
2513
+ installMissingGlobalProperties(globalThis, missingProperties);
2514
+ if (typeof currentSelf === "undefined" || currentSelf === currentWindow && currentSelf !== globalThis) Object.defineProperty(globalThis, "self", {
1378
2515
  value: window,
1379
2516
  configurable: true,
1380
2517
  writable: true,
1381
2518
  enumerable: true
1382
2519
  });
1383
- else Object.defineProperties(self, properties);
2520
+ else if (currentSelf !== globalThis) {
2521
+ Object.defineProperties(currentSelf, properties);
2522
+ installMissingGlobalProperties(currentSelf, missingProperties);
2523
+ }
1384
2524
  }
1385
2525
  static setGlobalThis(window) {
1386
2526
  for (const property in window) if (window[property] === window) window[property] = globalThis;
1387
- const properties = Object.getOwnPropertyDescriptors(window);
1388
- const eventTargetPrototypeProperties = Object.getOwnPropertyDescriptors(EventTarget.prototype);
1389
- for (const descriptor of Object.values(eventTargetPrototypeProperties)) if (typeof descriptor.value === "function") descriptor.value = descriptor.value.bind(window);
1390
- Object.defineProperties(globalThis, properties);
1391
- Object.defineProperties(globalThis, eventTargetPrototypeProperties);
2527
+ Object.defineProperties(globalThis, globalPropertyDescriptors(window));
1392
2528
  }
1393
2529
  };
2530
+ function installExtension(window, extension) {
2531
+ window[EXTENSIONS].push(extension(window) ?? {});
2532
+ }
2533
+ function createHooksDispatcher(window) {
2534
+ return {
2535
+ createElement: dispatchHook.bind(null, window, "createElement"),
2536
+ setAttribute: dispatchHook.bind(null, window, "setAttribute"),
2537
+ removeAttribute: dispatchHook.bind(null, window, "removeAttribute"),
2538
+ createText: dispatchHook.bind(null, window, "createText"),
2539
+ setText: dispatchHook.bind(null, window, "setText"),
2540
+ insertChild: dispatchHook.bind(null, window, "insertChild"),
2541
+ removeChild: dispatchHook.bind(null, window, "removeChild"),
2542
+ addEventListener: dispatchHook.bind(null, window, "addEventListener"),
2543
+ removeEventListener: dispatchHook.bind(null, window, "removeEventListener")
2544
+ };
2545
+ }
2546
+ function dispatchHook(window, name, ...args) {
2547
+ for (const hooks of window[EXTENSIONS]) hooks[name]?.apply(hooks, args);
2548
+ const hooks = window[HOOKS];
2549
+ hooks[name]?.apply(hooks, args);
2550
+ }
1394
2551
  //#endregion
1395
2552
  //#region node_modules/@volar/jsdelivr/lib/npm.js
1396
2553
  var require_npm = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -9942,7 +11099,7 @@ var shared_esm_bundler_exports = /* @__PURE__ */ __exportAll({
9942
11099
  toTypeString: () => toTypeString
9943
11100
  });
9944
11101
  /**
9945
- * @vue/shared v3.5.42
11102
+ * @vue/shared v3.5.43
9946
11103
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
9947
11104
  * @license MIT
9948
11105
  **/
@@ -10006,7 +11163,7 @@ function normalizeStyle(value) {
10006
11163
  }
10007
11164
  function parseStringStyle(cssText) {
10008
11165
  const ret = {};
10009
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
11166
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
10010
11167
  if (item) {
10011
11168
  const tmp = item.split(propertyDelimiterRE);
10012
11169
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -10104,19 +11261,19 @@ function escapeHtmlComment(src) {
10104
11261
  function getEscapedCssVarName(key, doubleEscape) {
10105
11262
  return key.replace(cssVarNameEscapeSymbolsRE, (s) => doubleEscape ? s === "\"" ? "\\\\\\\"" : `\\\\${s}` : `\\${s}`);
10106
11263
  }
10107
- function looseCompareArrays(a, b) {
11264
+ function looseCompareArrays(a, b, seen) {
10108
11265
  if (a.length !== b.length) return false;
10109
11266
  let equal = true;
10110
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
11267
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
10111
11268
  return equal;
10112
11269
  }
10113
- function looseCompareCollections(a, b) {
11270
+ function looseCompareCollections(a, b, seen) {
10114
11271
  if (a.size !== b.size) return false;
10115
11272
  const candidates = Array.from(b);
10116
11273
  const matched = new Uint8Array(candidates.length);
10117
11274
  for (const item of a) {
10118
11275
  let index = -1;
10119
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
11276
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
10120
11277
  index = i;
10121
11278
  break;
10122
11279
  }
@@ -10125,7 +11282,33 @@ function looseCompareCollections(a, b) {
10125
11282
  }
10126
11283
  return true;
10127
11284
  }
10128
- function looseEqual(a, b) {
11285
+ function looseCompareObjects(a, b, seen) {
11286
+ let aValidType = isMap(a);
11287
+ let bValidType = isMap(b);
11288
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
11289
+ aValidType = isSet(a);
11290
+ bValidType = isSet(b);
11291
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
11292
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
11293
+ for (const key in a) {
11294
+ const aHasKey = a.hasOwnProperty(key);
11295
+ const bHasKey = b.hasOwnProperty(key);
11296
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
11297
+ }
11298
+ return String(a) === String(b);
11299
+ }
11300
+ function looseCompareNested(a, b, seen, compare) {
11301
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
11302
+ const [seenA, seenB] = seen;
11303
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
11304
+ seenA.set(a, b);
11305
+ seenB.set(b, a);
11306
+ const equal = compare(a, b, seen);
11307
+ seenA.delete(a);
11308
+ seenB.delete(b);
11309
+ return equal;
11310
+ }
11311
+ function looseEqual(a, b, seen) {
10129
11312
  if (a === b) return true;
10130
11313
  let aValidType = isDate(a);
10131
11314
  let bValidType = isDate(b);
@@ -10135,23 +11318,12 @@ function looseEqual(a, b) {
10135
11318
  if (aValidType || bValidType) return a === b;
10136
11319
  aValidType = isArray(a);
10137
11320
  bValidType = isArray(b);
10138
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
11321
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
10139
11322
  aValidType = isObject$1(a);
10140
11323
  bValidType = isObject$1(b);
10141
11324
  if (aValidType || bValidType) {
10142
11325
  if (!aValidType || !bValidType) return false;
10143
- aValidType = isMap(a);
10144
- bValidType = isMap(b);
10145
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
10146
- aValidType = isSet(a);
10147
- bValidType = isSet(b);
10148
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
10149
- if (Object.keys(a).length !== Object.keys(b).length) return false;
10150
- for (const key in a) {
10151
- const aHasKey = a.hasOwnProperty(key);
10152
- const bHasKey = b.hasOwnProperty(key);
10153
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
10154
- }
11326
+ return looseCompareNested(a, b, seen, looseCompareObjects);
10155
11327
  }
10156
11328
  return String(a) === String(b);
10157
11329
  }
@@ -10332,7 +11504,7 @@ var init_shared_esm_bundler = __esmMin((() => {
10332
11504
  range = 2;
10333
11505
  listDelimiterRE = /;(?![^(]*\))/g;
10334
11506
  propertyDelimiterRE = /:([^]+)/;
10335
- styleCommentRE = /\/\*[^]*?\*\//g;
11507
+ styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
10336
11508
  HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
10337
11509
  SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
10338
11510
  MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
@@ -10383,7 +11555,7 @@ var init_shared_esm_bundler = __esmMin((() => {
10383
11555
  //#endregion
10384
11556
  //#region node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
10385
11557
  /**
10386
- * @vue/compiler-core v3.5.42
11558
+ * @vue/compiler-core v3.5.43
10387
11559
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
10388
11560
  * @license MIT
10389
11561
  **/
@@ -14741,7 +15913,7 @@ var compiler_dom_esm_bundler_exports = /* @__PURE__ */ __exportAll({
14741
15913
  warnDeprecation: () => warnDeprecation
14742
15914
  });
14743
15915
  /**
14744
- * @vue/compiler-dom v3.5.42
15916
+ * @vue/compiler-dom v3.5.43
14745
15917
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
14746
15918
  * @license MIT
14747
15919
  **/