@tabworthy/components 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  4. package/dist/cjs/index-C15oswCE.js +2148 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +13 -0
  7. package/dist/cjs/moment-CdViwxPQ.js +5681 -0
  8. package/dist/cjs/tabworthy-components.cjs.js +25 -0
  9. package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +884 -0
  10. package/dist/cjs/tabworthy-dates.cjs.entry.js +10906 -0
  11. package/dist/cjs/tabworthy-times-picker.cjs.entry.js +181 -0
  12. package/dist/cjs/tabworthy-times.cjs.entry.js +242 -0
  13. package/dist/cjs/utils-y5Vtky2t.js +214 -0
  14. package/dist/collection/collection-manifest.json +16 -0
  15. package/dist/collection/components/tabworthy-dates/tabworthy-dates.css +10 -0
  16. package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +1197 -0
  17. package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.css +10 -0
  18. package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.js +986 -0
  19. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.css +14 -0
  20. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +237 -0
  21. package/dist/collection/components/tabworthy-times/tabworthy-times.js +832 -0
  22. package/dist/collection/components/tabworthy-times-picker/tabworthy-times-picker.js +356 -0
  23. package/dist/collection/index.js +1 -0
  24. package/dist/components/index.d.ts +35 -0
  25. package/dist/components/index.js +1 -0
  26. package/dist/components/moment.js +8 -0
  27. package/dist/components/tabworthy-dates-calendar.d.ts +11 -0
  28. package/dist/components/tabworthy-dates-calendar.js +1 -0
  29. package/dist/components/tabworthy-dates-calendar2.js +1 -0
  30. package/dist/components/tabworthy-dates-modal.d.ts +11 -0
  31. package/dist/components/tabworthy-dates-modal.js +1 -0
  32. package/dist/components/tabworthy-dates-modal2.js +1 -0
  33. package/dist/components/tabworthy-dates.d.ts +11 -0
  34. package/dist/components/tabworthy-dates.js +1 -0
  35. package/dist/components/tabworthy-times-picker.d.ts +11 -0
  36. package/dist/components/tabworthy-times-picker.js +1 -0
  37. package/dist/components/tabworthy-times-picker2.js +1 -0
  38. package/dist/components/tabworthy-times.d.ts +11 -0
  39. package/dist/components/tabworthy-times.js +1 -0
  40. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  41. package/dist/esm/index-BusoZVTR.js +2139 -0
  42. package/dist/esm/index.js +1 -0
  43. package/dist/esm/loader.js +11 -0
  44. package/dist/esm/moment-Mki5YqAR.js +5679 -0
  45. package/dist/esm/tabworthy-components.js +21 -0
  46. package/dist/esm/tabworthy-dates-calendar_2.entry.js +881 -0
  47. package/dist/esm/tabworthy-dates.entry.js +10904 -0
  48. package/dist/esm/tabworthy-times-picker.entry.js +179 -0
  49. package/dist/esm/tabworthy-times.entry.js +240 -0
  50. package/dist/esm/utils-BVHu5CWV.js +188 -0
  51. package/dist/index.cjs.js +1 -0
  52. package/dist/index.js +1 -0
  53. package/dist/loader/cdn.js +1 -0
  54. package/dist/loader/index.cjs.js +1 -0
  55. package/dist/loader/index.d.ts +24 -0
  56. package/dist/loader/index.es2017.js +1 -0
  57. package/dist/loader/index.js +2 -0
  58. package/dist/shared/utils/chrono-parser/chrono-parser.js +146 -0
  59. package/dist/shared/utils/chrono-parser/chrono-parser.type.js +1 -0
  60. package/dist/shared/utils/utils.js +186 -0
  61. package/dist/tabworthy-components/index.esm.js +0 -0
  62. package/dist/tabworthy-components/p-170bc6ca.entry.js +1 -0
  63. package/dist/tabworthy-components/p-3ce9a767.entry.js +1 -0
  64. package/dist/tabworthy-components/p-77bd1bd4.entry.js +1 -0
  65. package/dist/tabworthy-components/p-BVHu5CWV.js +1 -0
  66. package/dist/tabworthy-components/p-BusoZVTR.js +2 -0
  67. package/dist/tabworthy-components/p-DQuL1Twl.js +1 -0
  68. package/dist/tabworthy-components/p-Mki5YqAR.js +8 -0
  69. package/dist/tabworthy-components/p-ebbb4c46.entry.js +1 -0
  70. package/dist/tabworthy-components/tabworthy-components.esm.js +1 -0
  71. package/dist/themes/dark.css +1 -0
  72. package/dist/themes/light.css +1 -0
  73. package/dist/types/Users/damirbogdanov_1/work/tabworthy-components/.stencil/shared/utils/chrono-parser/chrono-parser.d.ts +3 -0
  74. package/dist/types/Users/damirbogdanov_1/work/tabworthy-components/.stencil/shared/utils/chrono-parser/chrono-parser.type.d.ts +40 -0
  75. package/dist/types/Users/damirbogdanov_1/work/tabworthy-components/.stencil/shared/utils/utils.d.ts +28 -0
  76. package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +80 -0
  77. package/dist/types/components/tabworthy-dates-calendar/tabworthy-dates-calendar.d.ts +89 -0
  78. package/dist/types/components/tabworthy-modal/tabworthy-dates-modal.d.ts +29 -0
  79. package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +65 -0
  80. package/dist/types/components/tabworthy-times-picker/tabworthy-times-picker.d.ts +46 -0
  81. package/dist/types/components.d.ts +879 -0
  82. package/dist/types/index.d.ts +1 -0
  83. package/dist/types/stencil-public-runtime.d.ts +1858 -0
  84. package/package.json +132 -0
@@ -0,0 +1,2139 @@
1
+ const NAMESPACE = 'tabworthy-components';
2
+ const BUILD = /* tabworthy-components */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, propChangeCallback: true, slotRelocation: true, state: true, updatable: true};
3
+
4
+ /*
5
+ Stencil Client Platform v4.42.1 | MIT Licensed | https://stenciljs.com
6
+ */
7
+
8
+
9
+ // src/utils/constants.ts
10
+ var SVG_NS = "http://www.w3.org/2000/svg";
11
+ var HTML_NS = "http://www.w3.org/1999/xhtml";
12
+ var reWireGetterSetter = (instance, hostRef) => {
13
+ var _a;
14
+ const cmpMeta = hostRef.$cmpMeta$;
15
+ const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
16
+ members.map(([memberName, [memberFlags]]) => {
17
+ if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
18
+ const ogValue = instance[memberName];
19
+ const ogDescriptor = getPropertyDescriptor(Object.getPrototypeOf(instance), memberName) || Object.getOwnPropertyDescriptor(instance, memberName);
20
+ if (ogDescriptor) {
21
+ Object.defineProperty(instance, memberName, {
22
+ get() {
23
+ return ogDescriptor.get.call(this);
24
+ },
25
+ set(newValue) {
26
+ ogDescriptor.set.call(this, newValue);
27
+ },
28
+ configurable: true,
29
+ enumerable: true
30
+ });
31
+ }
32
+ instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
33
+ }
34
+ });
35
+ };
36
+ function getPropertyDescriptor(obj, memberName) {
37
+ while (obj) {
38
+ const desc = Object.getOwnPropertyDescriptor(obj, memberName);
39
+ if (desc == null ? void 0 : desc.get) return desc;
40
+ obj = Object.getPrototypeOf(obj);
41
+ }
42
+ return void 0;
43
+ }
44
+
45
+ // src/client/client-host-ref.ts
46
+ var getHostRef = (ref) => {
47
+ if (ref.__stencil__getHostRef) {
48
+ return ref.__stencil__getHostRef();
49
+ }
50
+ return void 0;
51
+ };
52
+ var registerInstance = (lazyInstance, hostRef) => {
53
+ if (!hostRef) return;
54
+ lazyInstance.__stencil__getHostRef = () => hostRef;
55
+ hostRef.$lazyInstance$ = lazyInstance;
56
+ if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.state)) {
57
+ reWireGetterSetter(lazyInstance, hostRef);
58
+ }
59
+ };
60
+ var registerHost = (hostElement, cmpMeta) => {
61
+ const hostRef = {
62
+ $flags$: 0,
63
+ $hostElement$: hostElement,
64
+ $cmpMeta$: cmpMeta,
65
+ $instanceValues$: /* @__PURE__ */ new Map(),
66
+ $serializerValues$: /* @__PURE__ */ new Map()
67
+ };
68
+ {
69
+ hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
70
+ }
71
+ {
72
+ hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
73
+ hostElement["s-p"] = [];
74
+ hostElement["s-rc"] = [];
75
+ }
76
+ {
77
+ hostRef.$fetchedCbList$ = [];
78
+ }
79
+ const ref = hostRef;
80
+ hostElement.__stencil__getHostRef = () => ref;
81
+ return ref;
82
+ };
83
+ var isMemberInElement = (elm, memberName) => memberName in elm;
84
+ var consoleError = (e, el) => (0, console.error)(e, el);
85
+
86
+ // src/client/client-load-module.ts
87
+ var cmpModules = /* @__PURE__ */ new Map();
88
+ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
89
+ const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
90
+ const bundleId = cmpMeta.$lazyBundleId$;
91
+ if (!bundleId) {
92
+ return void 0;
93
+ }
94
+ const module = cmpModules.get(bundleId) ;
95
+ if (module) {
96
+ return module[exportName];
97
+ }
98
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
99
+ return import(
100
+ /* @vite-ignore */
101
+ /* webpackInclude: /\.entry\.js$/ */
102
+ /* webpackExclude: /\.system\.entry\.js$/ */
103
+ /* webpackMode: "lazy" */
104
+ `./${bundleId}.entry.js${""}`
105
+ ).then(
106
+ (importedModule) => {
107
+ {
108
+ cmpModules.set(bundleId, importedModule);
109
+ }
110
+ return importedModule[exportName];
111
+ },
112
+ (e) => {
113
+ consoleError(e, hostRef.$hostElement$);
114
+ }
115
+ );
116
+ };
117
+
118
+ // src/client/client-style.ts
119
+ var styles = /* @__PURE__ */ new Map();
120
+ var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
121
+ var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
122
+ var win = typeof window !== "undefined" ? window : {};
123
+ var plt = {
124
+ $flags$: 0,
125
+ $resourcesUrl$: "",
126
+ jmp: (h2) => h2(),
127
+ raf: (h2) => requestAnimationFrame(h2),
128
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
129
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
130
+ ce: (eventName, opts) => new CustomEvent(eventName, opts)
131
+ };
132
+ var supportsListenerOptions = /* @__PURE__ */ (() => {
133
+ var _a;
134
+ let supportsListenerOptions2 = false;
135
+ try {
136
+ (_a = win.document) == null ? void 0 : _a.addEventListener(
137
+ "e",
138
+ null,
139
+ Object.defineProperty({}, "passive", {
140
+ get() {
141
+ supportsListenerOptions2 = true;
142
+ }
143
+ })
144
+ );
145
+ } catch (e) {
146
+ }
147
+ return supportsListenerOptions2;
148
+ })();
149
+ var promiseResolve = (v) => Promise.resolve(v);
150
+ var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
151
+ try {
152
+ if (!win.document.adoptedStyleSheets) {
153
+ return false;
154
+ }
155
+ new CSSStyleSheet();
156
+ return typeof new CSSStyleSheet().replaceSync === "function";
157
+ } catch (e) {
158
+ }
159
+ return false;
160
+ })() ;
161
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /* @__PURE__ */ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
162
+ var queuePending = false;
163
+ var queueDomReads = [];
164
+ var queueDomWrites = [];
165
+ var queueTask = (queue, write) => (cb) => {
166
+ queue.push(cb);
167
+ if (!queuePending) {
168
+ queuePending = true;
169
+ if (write && plt.$flags$ & 4 /* queueSync */) {
170
+ nextTick(flush);
171
+ } else {
172
+ plt.raf(flush);
173
+ }
174
+ }
175
+ };
176
+ var consume = (queue) => {
177
+ for (let i2 = 0; i2 < queue.length; i2++) {
178
+ try {
179
+ queue[i2](performance.now());
180
+ } catch (e) {
181
+ consoleError(e);
182
+ }
183
+ }
184
+ queue.length = 0;
185
+ };
186
+ var flush = () => {
187
+ consume(queueDomReads);
188
+ {
189
+ consume(queueDomWrites);
190
+ if (queuePending = queueDomReads.length > 0) {
191
+ plt.raf(flush);
192
+ }
193
+ }
194
+ };
195
+ var nextTick = (cb) => promiseResolve().then(cb);
196
+ var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
197
+
198
+ // src/utils/style.ts
199
+ function createStyleSheetIfNeededAndSupported(styles2) {
200
+ return void 0;
201
+ }
202
+
203
+ // src/utils/shadow-root.ts
204
+ var globalStyleSheet;
205
+ function createShadowRoot(cmpMeta) {
206
+ var _a;
207
+ const opts = { mode: "open" };
208
+ const shadowRoot = this.attachShadow(opts);
209
+ if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
210
+ if (globalStyleSheet) {
211
+ if (supportsMutableAdoptedStyleSheets) {
212
+ shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
213
+ } else {
214
+ shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
215
+ }
216
+ }
217
+ }
218
+ var updateFallbackSlotVisibility = (elm) => {
219
+ const childNodes = internalCall(elm, "childNodes");
220
+ if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
221
+ getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
222
+ if (slotNode.nodeType === 1 /* ElementNode */ && slotNode.tagName === "SLOT-FB") {
223
+ if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) {
224
+ slotNode.hidden = true;
225
+ } else {
226
+ slotNode.hidden = false;
227
+ }
228
+ }
229
+ });
230
+ }
231
+ let i2 = 0;
232
+ for (i2 = 0; i2 < childNodes.length; i2++) {
233
+ const childNode = childNodes[i2];
234
+ if (childNode.nodeType === 1 /* ElementNode */ && internalCall(childNode, "childNodes").length) {
235
+ updateFallbackSlotVisibility(childNode);
236
+ }
237
+ }
238
+ };
239
+ var getSlottedChildNodes = (childNodes) => {
240
+ const result = [];
241
+ for (let i2 = 0; i2 < childNodes.length; i2++) {
242
+ const slottedNode = childNodes[i2]["s-nr"] || void 0;
243
+ if (slottedNode && slottedNode.isConnected) {
244
+ result.push(slottedNode);
245
+ }
246
+ }
247
+ return result;
248
+ };
249
+ function getHostSlotNodes(childNodes, hostName, slotName) {
250
+ let i2 = 0;
251
+ let slottedNodes = [];
252
+ let childNode;
253
+ for (; i2 < childNodes.length; i2++) {
254
+ childNode = childNodes[i2];
255
+ if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
256
+ slottedNodes.push(childNode);
257
+ if (typeof slotName !== "undefined") return slottedNodes;
258
+ }
259
+ slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
260
+ }
261
+ return slottedNodes;
262
+ }
263
+ var getSlotChildSiblings = (slot, slotName, includeSlot = true) => {
264
+ const childNodes = [];
265
+ if (includeSlot && slot["s-sr"] || !slot["s-sr"]) childNodes.push(slot);
266
+ let node = slot;
267
+ while (node = node.nextSibling) {
268
+ if (getSlotName(node) === slotName && (includeSlot || !node["s-sr"])) childNodes.push(node);
269
+ }
270
+ return childNodes;
271
+ };
272
+ var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
273
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
274
+ if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
275
+ return true;
276
+ }
277
+ if (nodeToRelocate.getAttribute("slot") === slotName) {
278
+ return true;
279
+ }
280
+ return false;
281
+ }
282
+ if (nodeToRelocate["s-sn"] === slotName) {
283
+ return true;
284
+ }
285
+ return slotName === "";
286
+ };
287
+ var getSlotName = (node) => typeof node["s-sn"] === "string" ? node["s-sn"] : node.nodeType === 1 && node.getAttribute("slot") || void 0;
288
+ function patchSlotNode(node) {
289
+ if (node.assignedElements || node.assignedNodes || !node["s-sr"]) return;
290
+ const assignedFactory = (elementsOnly) => (function(opts) {
291
+ const toReturn = [];
292
+ const slotName = this["s-sn"];
293
+ if (opts == null ? void 0 : opts.flatten) {
294
+ console.error(`
295
+ Flattening is not supported for Stencil non-shadow slots.
296
+ You can use \`.childNodes\` to nested slot fallback content.
297
+ If you have a particular use case, please open an issue on the Stencil repo.
298
+ `);
299
+ }
300
+ const parent = this["s-cr"].parentElement;
301
+ const slottedNodes = parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes);
302
+ slottedNodes.forEach((n) => {
303
+ if (slotName === getSlotName(n)) {
304
+ toReturn.push(n);
305
+ }
306
+ });
307
+ if (elementsOnly) {
308
+ return toReturn.filter((n) => n.nodeType === 1 /* ElementNode */);
309
+ }
310
+ return toReturn;
311
+ }).bind(node);
312
+ node.assignedElements = assignedFactory(true);
313
+ node.assignedNodes = assignedFactory(false);
314
+ }
315
+ function dispatchSlotChangeEvent(elm) {
316
+ elm.dispatchEvent(new CustomEvent("slotchange", { bubbles: false, cancelable: false, composed: false }));
317
+ }
318
+ function findSlotFromSlottedNode(slottedNode, parentHost) {
319
+ var _a;
320
+ parentHost = parentHost || ((_a = slottedNode["s-ol"]) == null ? void 0 : _a.parentElement);
321
+ if (!parentHost) return { slotNode: null, slotName: "" };
322
+ const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
323
+ const childNodes = internalCall(parentHost, "childNodes");
324
+ const slotNode = getHostSlotNodes(childNodes, parentHost.tagName, slotName)[0];
325
+ return { slotNode, slotName };
326
+ }
327
+ function internalCall(node, method) {
328
+ if ("__" + method in node) {
329
+ const toReturn = node["__" + method];
330
+ if (typeof toReturn !== "function") return toReturn;
331
+ return toReturn.bind(node);
332
+ } else {
333
+ if (typeof node[method] !== "function") return node[method];
334
+ return node[method].bind(node);
335
+ }
336
+ }
337
+ var createTime = (fnName, tagName = "") => {
338
+ {
339
+ return () => {
340
+ return;
341
+ };
342
+ }
343
+ };
344
+ var uniqueTime = (key, measureText) => {
345
+ {
346
+ return () => {
347
+ return;
348
+ };
349
+ }
350
+ };
351
+
352
+ // src/utils/query-nonce-meta-tag-content.ts
353
+ function queryNonceMetaTagContent(doc) {
354
+ var _a, _b, _c;
355
+ return (_c = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
356
+ }
357
+
358
+ // src/runtime/styles.ts
359
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
360
+ var registerStyle = (scopeId2, cssText, allowCS) => {
361
+ let style = styles.get(scopeId2);
362
+ if (supportsConstructableStylesheets && allowCS) {
363
+ style = style || new CSSStyleSheet();
364
+ if (typeof style === "string") {
365
+ style = cssText;
366
+ } else {
367
+ style.replaceSync(cssText);
368
+ }
369
+ } else {
370
+ style = cssText;
371
+ }
372
+ styles.set(scopeId2, style);
373
+ };
374
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
375
+ var _a, _b, _c;
376
+ const scopeId2 = getScopeId(cmpMeta);
377
+ const style = styles.get(scopeId2);
378
+ if (!win.document) {
379
+ return scopeId2;
380
+ }
381
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
382
+ if (style) {
383
+ if (typeof style === "string") {
384
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
385
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
386
+ let styleElm;
387
+ if (!appliedStyles) {
388
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
389
+ }
390
+ if (!appliedStyles.has(scopeId2)) {
391
+ styleElm = win.document.createElement("style");
392
+ styleElm.textContent = style;
393
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
394
+ if (nonce != null) {
395
+ styleElm.setAttribute("nonce", nonce);
396
+ }
397
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
398
+ if (styleContainerNode.nodeName === "HEAD") {
399
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
400
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
401
+ styleContainerNode.insertBefore(
402
+ styleElm,
403
+ (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
404
+ );
405
+ } else if ("host" in styleContainerNode) {
406
+ if (supportsConstructableStylesheets) {
407
+ const currentWindow = (_b = styleContainerNode.defaultView) != null ? _b : styleContainerNode.ownerDocument.defaultView;
408
+ const stylesheet = new currentWindow.CSSStyleSheet();
409
+ stylesheet.replaceSync(style);
410
+ if (supportsMutableAdoptedStyleSheets) {
411
+ styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
412
+ } else {
413
+ styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
414
+ }
415
+ } else {
416
+ const existingStyleContainer = styleContainerNode.querySelector("style");
417
+ if (existingStyleContainer) {
418
+ existingStyleContainer.textContent = style + existingStyleContainer.textContent;
419
+ } else {
420
+ styleContainerNode.prepend(styleElm);
421
+ }
422
+ }
423
+ } else {
424
+ styleContainerNode.append(styleElm);
425
+ }
426
+ }
427
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
428
+ styleContainerNode.insertBefore(styleElm, null);
429
+ }
430
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
431
+ styleElm.textContent += SLOT_FB_CSS;
432
+ }
433
+ if (appliedStyles) {
434
+ appliedStyles.add(scopeId2);
435
+ }
436
+ }
437
+ } else {
438
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
439
+ if (!appliedStyles) {
440
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
441
+ }
442
+ if (!appliedStyles.has(scopeId2)) {
443
+ const currentWindow = (_c = styleContainerNode.defaultView) != null ? _c : styleContainerNode.ownerDocument.defaultView;
444
+ let stylesheet;
445
+ if (style.constructor === currentWindow.CSSStyleSheet) {
446
+ stylesheet = style;
447
+ } else {
448
+ stylesheet = new currentWindow.CSSStyleSheet();
449
+ for (let i2 = 0; i2 < style.cssRules.length; i2++) {
450
+ stylesheet.insertRule(style.cssRules[i2].cssText, i2);
451
+ }
452
+ }
453
+ if (supportsMutableAdoptedStyleSheets) {
454
+ styleContainerNode.adoptedStyleSheets.push(stylesheet);
455
+ } else {
456
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, stylesheet];
457
+ }
458
+ appliedStyles.add(scopeId2);
459
+ }
460
+ }
461
+ }
462
+ return scopeId2;
463
+ };
464
+ var attachStyles = (hostRef) => {
465
+ const cmpMeta = hostRef.$cmpMeta$;
466
+ const elm = hostRef.$hostElement$;
467
+ const flags = cmpMeta.$flags$;
468
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
469
+ const scopeId2 = addStyle(
470
+ elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
471
+ cmpMeta);
472
+ if (flags & 10 /* needsScopedEncapsulation */) {
473
+ elm["s-sc"] = scopeId2;
474
+ elm.classList.add(scopeId2 + "-h");
475
+ }
476
+ endAttachStyles();
477
+ };
478
+ var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
479
+
480
+ // src/utils/helpers.ts
481
+ var isDef = (v) => v != null && v !== void 0;
482
+ var isComplexType = (o) => {
483
+ o = typeof o;
484
+ return o === "object" || o === "function";
485
+ };
486
+
487
+ // src/runtime/vdom/h.ts
488
+ var h = (nodeName, vnodeData, ...children) => {
489
+ if (typeof nodeName === "string") {
490
+ nodeName = transformTag(nodeName);
491
+ }
492
+ let child = null;
493
+ let key = null;
494
+ let slotName = null;
495
+ let simple = false;
496
+ let lastSimple = false;
497
+ const vNodeChildren = [];
498
+ const walk = (c) => {
499
+ for (let i2 = 0; i2 < c.length; i2++) {
500
+ child = c[i2];
501
+ if (Array.isArray(child)) {
502
+ walk(child);
503
+ } else if (child != null && typeof child !== "boolean") {
504
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
505
+ child = String(child);
506
+ }
507
+ if (simple && lastSimple) {
508
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
509
+ } else {
510
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
511
+ }
512
+ lastSimple = simple;
513
+ }
514
+ }
515
+ };
516
+ walk(children);
517
+ if (vnodeData) {
518
+ if (vnodeData.key) {
519
+ key = vnodeData.key;
520
+ }
521
+ if (vnodeData.name) {
522
+ slotName = vnodeData.name;
523
+ }
524
+ {
525
+ const classData = vnodeData.className || vnodeData.class;
526
+ if (classData) {
527
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
528
+ }
529
+ }
530
+ }
531
+ if (typeof nodeName === "function") {
532
+ return nodeName(
533
+ vnodeData === null ? {} : vnodeData,
534
+ vNodeChildren,
535
+ vdomFnUtils
536
+ );
537
+ }
538
+ const vnode = newVNode(nodeName, null);
539
+ vnode.$attrs$ = vnodeData;
540
+ if (vNodeChildren.length > 0) {
541
+ vnode.$children$ = vNodeChildren;
542
+ }
543
+ {
544
+ vnode.$key$ = key;
545
+ }
546
+ {
547
+ vnode.$name$ = slotName;
548
+ }
549
+ return vnode;
550
+ };
551
+ var newVNode = (tag, text) => {
552
+ const vnode = {
553
+ $flags$: 0,
554
+ $tag$: tag,
555
+ // Normalize undefined to null to prevent rendering "undefined" as text
556
+ $text$: text != null ? text : null,
557
+ $elm$: null,
558
+ $children$: null
559
+ };
560
+ {
561
+ vnode.$attrs$ = null;
562
+ }
563
+ {
564
+ vnode.$key$ = null;
565
+ }
566
+ {
567
+ vnode.$name$ = null;
568
+ }
569
+ return vnode;
570
+ };
571
+ var Host = {};
572
+ var isHost = (node) => node && node.$tag$ === Host;
573
+ var vdomFnUtils = {
574
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
575
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
576
+ };
577
+ var convertToPublic = (node) => ({
578
+ vattrs: node.$attrs$,
579
+ vchildren: node.$children$,
580
+ vkey: node.$key$,
581
+ vname: node.$name$,
582
+ vtag: node.$tag$,
583
+ vtext: node.$text$
584
+ });
585
+ var convertToPrivate = (node) => {
586
+ if (typeof node.vtag === "function") {
587
+ const vnodeData = { ...node.vattrs };
588
+ if (node.vkey) {
589
+ vnodeData.key = node.vkey;
590
+ }
591
+ if (node.vname) {
592
+ vnodeData.name = node.vname;
593
+ }
594
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
595
+ }
596
+ const vnode = newVNode(node.vtag, node.vtext);
597
+ vnode.$attrs$ = node.vattrs;
598
+ vnode.$children$ = node.vchildren;
599
+ vnode.$key$ = node.vkey;
600
+ vnode.$name$ = node.vname;
601
+ return vnode;
602
+ };
603
+
604
+ // src/runtime/parse-property-value.ts
605
+ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
606
+ if (propValue != null && !isComplexType(propValue)) {
607
+ if (propType & 4 /* Boolean */) {
608
+ {
609
+ return propValue === "false" ? false : propValue === "" || !!propValue;
610
+ }
611
+ }
612
+ if (propType & 2 /* Number */) {
613
+ return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
614
+ }
615
+ if (propType & 1 /* String */) {
616
+ return String(propValue);
617
+ }
618
+ return propValue;
619
+ }
620
+ return propValue;
621
+ };
622
+ var getElement = (ref) => {
623
+ var _a;
624
+ return (_a = getHostRef(ref)) == null ? void 0 : _a.$hostElement$ ;
625
+ };
626
+
627
+ // src/runtime/event-emitter.ts
628
+ var createEvent = (ref, name, flags) => {
629
+ const elm = getElement(ref);
630
+ return {
631
+ emit: (detail) => {
632
+ return emitEvent(elm, name, {
633
+ bubbles: true,
634
+ composed: true,
635
+ cancelable: true,
636
+ detail
637
+ });
638
+ }
639
+ };
640
+ };
641
+ var emitEvent = (elm, name, opts) => {
642
+ const ev = plt.ce(name, opts);
643
+ elm.dispatchEvent(ev);
644
+ return ev;
645
+ };
646
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
647
+ if (oldValue === newValue) {
648
+ return;
649
+ }
650
+ let isProp = isMemberInElement(elm, memberName);
651
+ let ln = memberName.toLowerCase();
652
+ if (memberName === "class") {
653
+ const classList = elm.classList;
654
+ const oldClasses = parseClassList(oldValue);
655
+ let newClasses = parseClassList(newValue);
656
+ {
657
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
658
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
659
+ }
660
+ } else if (memberName === "key") ; else if (memberName === "ref") {
661
+ if (newValue) {
662
+ queueRefAttachment(newValue, elm);
663
+ }
664
+ } else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
665
+ if (memberName[2] === "-") {
666
+ memberName = memberName.slice(3);
667
+ } else if (isMemberInElement(win, ln)) {
668
+ memberName = ln.slice(2);
669
+ } else {
670
+ memberName = ln[2] + memberName.slice(3);
671
+ }
672
+ if (oldValue || newValue) {
673
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
674
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
675
+ if (oldValue) {
676
+ plt.rel(elm, memberName, oldValue, capture);
677
+ }
678
+ if (newValue) {
679
+ plt.ael(elm, memberName, newValue, capture);
680
+ }
681
+ }
682
+ } else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
683
+ const propName = memberName.slice(5);
684
+ let attrName;
685
+ {
686
+ const hostRef = getHostRef(elm);
687
+ if (hostRef && hostRef.$cmpMeta$ && hostRef.$cmpMeta$.$members$) {
688
+ const memberMeta = hostRef.$cmpMeta$.$members$[propName];
689
+ if (memberMeta && memberMeta[1]) {
690
+ attrName = memberMeta[1];
691
+ }
692
+ }
693
+ }
694
+ if (!attrName) {
695
+ attrName = propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
696
+ }
697
+ if (newValue == null || newValue === false) {
698
+ if (newValue !== false || elm.getAttribute(attrName) === "") {
699
+ elm.removeAttribute(attrName);
700
+ }
701
+ } else {
702
+ elm.setAttribute(attrName, newValue === true ? "" : newValue);
703
+ }
704
+ return;
705
+ } else if (memberName[0] === "p" && memberName.startsWith("prop:")) {
706
+ const propName = memberName.slice(5);
707
+ try {
708
+ elm[propName] = newValue;
709
+ } catch (e) {
710
+ }
711
+ return;
712
+ } else {
713
+ const isComplex = isComplexType(newValue);
714
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
715
+ try {
716
+ if (!elm.tagName.includes("-")) {
717
+ const n = newValue == null ? "" : newValue;
718
+ if (memberName === "list") {
719
+ isProp = false;
720
+ } else if (oldValue == null || elm[memberName] !== n) {
721
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
722
+ elm[memberName] = n;
723
+ } else {
724
+ elm.setAttribute(memberName, n);
725
+ }
726
+ }
727
+ } else if (elm[memberName] !== newValue) {
728
+ elm[memberName] = newValue;
729
+ }
730
+ } catch (e) {
731
+ }
732
+ }
733
+ if (newValue == null || newValue === false) {
734
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
735
+ {
736
+ elm.removeAttribute(memberName);
737
+ }
738
+ }
739
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
740
+ newValue = newValue === true ? "" : newValue;
741
+ {
742
+ elm.setAttribute(memberName, newValue);
743
+ }
744
+ }
745
+ }
746
+ };
747
+ var parseClassListRegex = /\s/;
748
+ var parseClassList = (value) => {
749
+ if (typeof value === "object" && value && "baseVal" in value) {
750
+ value = value.baseVal;
751
+ }
752
+ if (!value || typeof value !== "string") {
753
+ return [];
754
+ }
755
+ return value.split(parseClassListRegex);
756
+ };
757
+ var CAPTURE_EVENT_SUFFIX = "Capture";
758
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
759
+
760
+ // src/runtime/vdom/update-element.ts
761
+ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
762
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
763
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
764
+ const newVnodeAttrs = newVnode.$attrs$ || {};
765
+ {
766
+ for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
767
+ if (!(memberName in newVnodeAttrs)) {
768
+ setAccessor(
769
+ elm,
770
+ memberName,
771
+ oldVnodeAttrs[memberName],
772
+ void 0,
773
+ isSvgMode2,
774
+ newVnode.$flags$);
775
+ }
776
+ }
777
+ }
778
+ for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
779
+ setAccessor(
780
+ elm,
781
+ memberName,
782
+ oldVnodeAttrs[memberName],
783
+ newVnodeAttrs[memberName],
784
+ isSvgMode2,
785
+ newVnode.$flags$);
786
+ }
787
+ };
788
+ function sortedAttrNames(attrNames) {
789
+ return attrNames.includes("ref") ? (
790
+ // we need to sort these to ensure that `'ref'` is the last attr
791
+ [...attrNames.filter((attr) => attr !== "ref"), "ref"]
792
+ ) : (
793
+ // no need to sort, return the original array
794
+ attrNames
795
+ );
796
+ }
797
+
798
+ // src/runtime/vdom/vdom-render.ts
799
+ var scopeId;
800
+ var contentRef;
801
+ var hostTagName;
802
+ var useNativeShadowDom = false;
803
+ var checkSlotFallbackVisibility = false;
804
+ var checkSlotRelocate = false;
805
+ var isSvgMode = false;
806
+ var refCallbacksToRemove = [];
807
+ var refCallbacksToAttach = [];
808
+ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
809
+ var _a;
810
+ const newVNode2 = newParentVNode.$children$[childIndex];
811
+ let i2 = 0;
812
+ let elm;
813
+ let childNode;
814
+ let oldVNode;
815
+ if (!useNativeShadowDom) {
816
+ checkSlotRelocate = true;
817
+ if (newVNode2.$tag$ === "slot") {
818
+ newVNode2.$flags$ |= newVNode2.$children$ ? (
819
+ // slot element has fallback content
820
+ // still create an element that "mocks" the slot element
821
+ 2 /* isSlotFallback */
822
+ ) : (
823
+ // slot element does not have fallback content
824
+ // create an html comment we'll use to always reference
825
+ // where actual slot content should sit next to
826
+ 1 /* isSlotReference */
827
+ );
828
+ }
829
+ }
830
+ if (newVNode2.$text$ != null) {
831
+ elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
832
+ } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
833
+ elm = newVNode2.$elm$ = win.document.createTextNode("");
834
+ {
835
+ updateElement(null, newVNode2, isSvgMode);
836
+ }
837
+ } else {
838
+ if (!isSvgMode) {
839
+ isSvgMode = newVNode2.$tag$ === "svg";
840
+ }
841
+ if (!win.document) {
842
+ throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");
843
+ }
844
+ elm = newVNode2.$elm$ = win.document.createElementNS(
845
+ isSvgMode ? SVG_NS : HTML_NS,
846
+ !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
847
+ ) ;
848
+ if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
849
+ isSvgMode = false;
850
+ }
851
+ {
852
+ updateElement(null, newVNode2, isSvgMode);
853
+ }
854
+ if (isDef(scopeId) && elm["s-si"] !== scopeId) {
855
+ elm.classList.add(elm["s-si"] = scopeId);
856
+ }
857
+ if (newVNode2.$children$) {
858
+ const appendTarget = newVNode2.$tag$ === "template" ? elm.content : elm;
859
+ for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
860
+ childNode = createElm(oldParentVNode, newVNode2, i2);
861
+ if (childNode) {
862
+ appendTarget.appendChild(childNode);
863
+ }
864
+ }
865
+ }
866
+ {
867
+ if (newVNode2.$tag$ === "svg") {
868
+ isSvgMode = false;
869
+ } else if (elm.tagName === "foreignObject") {
870
+ isSvgMode = true;
871
+ }
872
+ }
873
+ }
874
+ elm["s-hn"] = hostTagName;
875
+ {
876
+ if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
877
+ elm["s-sr"] = true;
878
+ elm["s-cr"] = contentRef;
879
+ elm["s-sn"] = newVNode2.$name$ || "";
880
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
881
+ patchSlotNode(elm);
882
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
883
+ if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
884
+ relocateToHostRoot(oldParentVNode.$elm$);
885
+ }
886
+ {
887
+ addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
888
+ }
889
+ }
890
+ }
891
+ return elm;
892
+ };
893
+ var relocateToHostRoot = (parentElm) => {
894
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
895
+ const host = parentElm.closest(hostTagName.toLowerCase());
896
+ if (host != null) {
897
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
898
+ (ref) => ref["s-cr"]
899
+ );
900
+ const childNodeArray = Array.from(
901
+ parentElm.__childNodes || parentElm.childNodes
902
+ );
903
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
904
+ if (childNode["s-sh"] != null) {
905
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
906
+ childNode["s-sh"] = void 0;
907
+ checkSlotRelocate = true;
908
+ }
909
+ }
910
+ }
911
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
912
+ };
913
+ var putBackInOriginalLocation = (parentElm, recursive) => {
914
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
915
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
916
+ if (parentElm["s-sr"]) {
917
+ let node = parentElm;
918
+ while (node = node.nextSibling) {
919
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
920
+ oldSlotChildNodes.push(node);
921
+ }
922
+ }
923
+ }
924
+ for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
925
+ const childNode = oldSlotChildNodes[i2];
926
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
927
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
928
+ childNode["s-ol"].remove();
929
+ childNode["s-ol"] = void 0;
930
+ childNode["s-sh"] = void 0;
931
+ checkSlotRelocate = true;
932
+ }
933
+ if (recursive) {
934
+ putBackInOriginalLocation(childNode, recursive);
935
+ }
936
+ }
937
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
938
+ };
939
+ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
940
+ let containerElm = parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
941
+ let childNode;
942
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
943
+ containerElm = containerElm.shadowRoot;
944
+ }
945
+ if (parentVNode.$tag$ === "template") {
946
+ containerElm = containerElm.content;
947
+ }
948
+ for (; startIdx <= endIdx; ++startIdx) {
949
+ if (vnodes[startIdx]) {
950
+ childNode = createElm(null, parentVNode, startIdx);
951
+ if (childNode) {
952
+ vnodes[startIdx].$elm$ = childNode;
953
+ insertBefore(containerElm, childNode, referenceNode(before) );
954
+ }
955
+ }
956
+ }
957
+ };
958
+ var removeVnodes = (vnodes, startIdx, endIdx) => {
959
+ for (let index = startIdx; index <= endIdx; ++index) {
960
+ const vnode = vnodes[index];
961
+ if (vnode) {
962
+ const elm = vnode.$elm$;
963
+ nullifyVNodeRefs(vnode);
964
+ if (elm) {
965
+ {
966
+ checkSlotFallbackVisibility = true;
967
+ if (elm["s-ol"]) {
968
+ elm["s-ol"].remove();
969
+ } else {
970
+ putBackInOriginalLocation(elm, true);
971
+ }
972
+ }
973
+ elm.remove();
974
+ }
975
+ }
976
+ }
977
+ };
978
+ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
979
+ let oldStartIdx = 0;
980
+ let newStartIdx = 0;
981
+ let idxInOld = 0;
982
+ let i2 = 0;
983
+ let oldEndIdx = oldCh.length - 1;
984
+ let oldStartVnode = oldCh[0];
985
+ let oldEndVnode = oldCh[oldEndIdx];
986
+ let newEndIdx = newCh.length - 1;
987
+ let newStartVnode = newCh[0];
988
+ let newEndVnode = newCh[newEndIdx];
989
+ let node;
990
+ let elmToMove;
991
+ const containerElm = newVNode2.$tag$ === "template" ? parentElm.content : parentElm;
992
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
993
+ if (oldStartVnode == null) {
994
+ oldStartVnode = oldCh[++oldStartIdx];
995
+ } else if (oldEndVnode == null) {
996
+ oldEndVnode = oldCh[--oldEndIdx];
997
+ } else if (newStartVnode == null) {
998
+ newStartVnode = newCh[++newStartIdx];
999
+ } else if (newEndVnode == null) {
1000
+ newEndVnode = newCh[--newEndIdx];
1001
+ } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1002
+ patch(oldStartVnode, newStartVnode, isInitialRender);
1003
+ oldStartVnode = oldCh[++oldStartIdx];
1004
+ newStartVnode = newCh[++newStartIdx];
1005
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1006
+ patch(oldEndVnode, newEndVnode, isInitialRender);
1007
+ oldEndVnode = oldCh[--oldEndIdx];
1008
+ newEndVnode = newCh[--newEndIdx];
1009
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1010
+ if ((oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1011
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1012
+ }
1013
+ patch(oldStartVnode, newEndVnode, isInitialRender);
1014
+ insertBefore(containerElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1015
+ oldStartVnode = oldCh[++oldStartIdx];
1016
+ newEndVnode = newCh[--newEndIdx];
1017
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1018
+ if ((oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1019
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1020
+ }
1021
+ patch(oldEndVnode, newStartVnode, isInitialRender);
1022
+ insertBefore(containerElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1023
+ oldEndVnode = oldCh[--oldEndIdx];
1024
+ newStartVnode = newCh[++newStartIdx];
1025
+ } else {
1026
+ idxInOld = -1;
1027
+ {
1028
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
1029
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
1030
+ idxInOld = i2;
1031
+ break;
1032
+ }
1033
+ }
1034
+ }
1035
+ if (idxInOld >= 0) {
1036
+ elmToMove = oldCh[idxInOld];
1037
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1038
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
1039
+ } else {
1040
+ patch(elmToMove, newStartVnode, isInitialRender);
1041
+ oldCh[idxInOld] = void 0;
1042
+ node = elmToMove.$elm$;
1043
+ }
1044
+ newStartVnode = newCh[++newStartIdx];
1045
+ } else {
1046
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
1047
+ newStartVnode = newCh[++newStartIdx];
1048
+ }
1049
+ if (node) {
1050
+ {
1051
+ insertBefore(
1052
+ referenceNode(oldStartVnode.$elm$).parentNode,
1053
+ node,
1054
+ referenceNode(oldStartVnode.$elm$)
1055
+ );
1056
+ }
1057
+ }
1058
+ }
1059
+ }
1060
+ if (oldStartIdx > oldEndIdx) {
1061
+ addVnodes(
1062
+ parentElm,
1063
+ newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
1064
+ newVNode2,
1065
+ newCh,
1066
+ newStartIdx,
1067
+ newEndIdx
1068
+ );
1069
+ } else if (newStartIdx > newEndIdx) {
1070
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1071
+ }
1072
+ };
1073
+ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1074
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1075
+ if (leftVNode.$tag$ === "slot") {
1076
+ return leftVNode.$name$ === rightVNode.$name$;
1077
+ }
1078
+ if (!isInitialRender) {
1079
+ return leftVNode.$key$ === rightVNode.$key$;
1080
+ }
1081
+ if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
1082
+ leftVNode.$key$ = rightVNode.$key$;
1083
+ }
1084
+ return true;
1085
+ }
1086
+ return false;
1087
+ };
1088
+ var referenceNode = (node) => node && node["s-ol"] || node;
1089
+ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1090
+ const elm = newVNode2.$elm$ = oldVNode.$elm$;
1091
+ const oldChildren = oldVNode.$children$;
1092
+ const newChildren = newVNode2.$children$;
1093
+ const tag = newVNode2.$tag$;
1094
+ const text = newVNode2.$text$;
1095
+ let defaultHolder;
1096
+ if (text == null) {
1097
+ {
1098
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
1099
+ }
1100
+ {
1101
+ if (tag === "slot" && !useNativeShadowDom) {
1102
+ if (oldVNode.$name$ !== newVNode2.$name$) {
1103
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
1104
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
1105
+ }
1106
+ }
1107
+ updateElement(oldVNode, newVNode2, isSvgMode);
1108
+ }
1109
+ if (oldChildren !== null && newChildren !== null) {
1110
+ updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
1111
+ } else if (newChildren !== null) {
1112
+ if (oldVNode.$text$ !== null) {
1113
+ elm.textContent = "";
1114
+ }
1115
+ addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
1116
+ } else if (
1117
+ // don't do this on initial render as it can cause non-hydrated content to be removed
1118
+ !isInitialRender && BUILD.updatable && oldChildren !== null
1119
+ ) {
1120
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1121
+ } else ;
1122
+ if (isSvgMode && tag === "svg") {
1123
+ isSvgMode = false;
1124
+ }
1125
+ } else if ((defaultHolder = elm["s-cr"])) {
1126
+ defaultHolder.parentNode.textContent = text;
1127
+ } else if (oldVNode.$text$ !== text) {
1128
+ elm.data = text;
1129
+ }
1130
+ };
1131
+ var relocateNodes = [];
1132
+ var markSlotContentForRelocation = (elm) => {
1133
+ let node;
1134
+ let hostContentNodes;
1135
+ let j;
1136
+ const children = elm.__childNodes || elm.childNodes;
1137
+ for (const childNode of children) {
1138
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1139
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
1140
+ const slotName = childNode["s-sn"];
1141
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1142
+ node = hostContentNodes[j];
1143
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1144
+ if (isNodeLocatedInSlot(node, slotName)) {
1145
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1146
+ checkSlotFallbackVisibility = true;
1147
+ node["s-sn"] = node["s-sn"] || slotName;
1148
+ if (relocateNodeData) {
1149
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1150
+ relocateNodeData.$slotRefNode$ = childNode;
1151
+ } else {
1152
+ node["s-sh"] = childNode["s-hn"];
1153
+ relocateNodes.push({
1154
+ $slotRefNode$: childNode,
1155
+ $nodeToRelocate$: node
1156
+ });
1157
+ }
1158
+ if (node["s-sr"]) {
1159
+ relocateNodes.map((relocateNode) => {
1160
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1161
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1162
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1163
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1164
+ }
1165
+ }
1166
+ });
1167
+ }
1168
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1169
+ relocateNodes.push({
1170
+ $nodeToRelocate$: node
1171
+ });
1172
+ }
1173
+ }
1174
+ }
1175
+ }
1176
+ if (childNode.nodeType === 1 /* ElementNode */) {
1177
+ markSlotContentForRelocation(childNode);
1178
+ }
1179
+ }
1180
+ };
1181
+ var nullifyVNodeRefs = (vNode) => {
1182
+ {
1183
+ if (vNode.$attrs$ && vNode.$attrs$.ref) {
1184
+ refCallbacksToRemove.push(() => vNode.$attrs$.ref(null));
1185
+ }
1186
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1187
+ }
1188
+ };
1189
+ var queueRefAttachment = (refCallback, elm) => {
1190
+ {
1191
+ refCallbacksToAttach.push(() => refCallback(elm));
1192
+ }
1193
+ };
1194
+ var flushQueuedRefCallbacks = () => {
1195
+ {
1196
+ refCallbacksToRemove.forEach((cb) => cb());
1197
+ refCallbacksToRemove.length = 0;
1198
+ refCallbacksToAttach.forEach((cb) => cb());
1199
+ refCallbacksToAttach.length = 0;
1200
+ }
1201
+ };
1202
+ var insertBefore = (parent, newNode, reference, isInitialLoad) => {
1203
+ {
1204
+ if (typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
1205
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
1206
+ } else if (typeof newNode["s-sn"] === "string") {
1207
+ parent.insertBefore(newNode, reference);
1208
+ const { slotNode } = findSlotFromSlottedNode(newNode);
1209
+ if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
1210
+ return newNode;
1211
+ }
1212
+ }
1213
+ if (parent.__insertBefore) {
1214
+ return parent.__insertBefore(newNode, reference);
1215
+ } else {
1216
+ return parent == null ? void 0 : parent.insertBefore(newNode, reference);
1217
+ }
1218
+ };
1219
+ function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
1220
+ var _a, _b;
1221
+ let scopeId2;
1222
+ if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
1223
+ const scopeName = slotNode["s-sn"];
1224
+ const hostName = slotNode["s-hn"];
1225
+ (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
1226
+ if (oldParent && ((_b = oldParent.classList) == null ? void 0 : _b.contains(scopeId2 + "-s"))) {
1227
+ let child = (oldParent.__childNodes || oldParent.childNodes)[0];
1228
+ let found = false;
1229
+ while (child) {
1230
+ if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
1231
+ found = true;
1232
+ break;
1233
+ }
1234
+ child = child.nextSibling;
1235
+ }
1236
+ if (!found) oldParent.classList.remove(scopeId2 + "-s");
1237
+ }
1238
+ }
1239
+ }
1240
+ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1241
+ var _a, _b, _c, _d, _e;
1242
+ const hostElm = hostRef.$hostElement$;
1243
+ const cmpMeta = hostRef.$cmpMeta$;
1244
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1245
+ const isHostElement = isHost(renderFnResults);
1246
+ const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
1247
+ hostTagName = hostElm.tagName;
1248
+ if (cmpMeta.$attrsToReflect$) {
1249
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1250
+ cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => {
1251
+ {
1252
+ rootVnode.$attrs$[attribute] = hostElm[propName];
1253
+ }
1254
+ });
1255
+ }
1256
+ if (isInitialLoad && rootVnode.$attrs$) {
1257
+ for (const key of Object.keys(rootVnode.$attrs$)) {
1258
+ if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
1259
+ rootVnode.$attrs$[key] = hostElm[key];
1260
+ }
1261
+ }
1262
+ }
1263
+ rootVnode.$tag$ = null;
1264
+ rootVnode.$flags$ |= 4 /* isHost */;
1265
+ hostRef.$vnode$ = rootVnode;
1266
+ rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
1267
+ {
1268
+ scopeId = hostElm["s-sc"];
1269
+ }
1270
+ useNativeShadowDom = !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */);
1271
+ {
1272
+ contentRef = hostElm["s-cr"];
1273
+ checkSlotFallbackVisibility = false;
1274
+ }
1275
+ patch(oldVNode, rootVnode, isInitialLoad);
1276
+ {
1277
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1278
+ if (checkSlotRelocate) {
1279
+ markSlotContentForRelocation(rootVnode.$elm$);
1280
+ for (const relocateData of relocateNodes) {
1281
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
1282
+ if (!nodeToRelocate["s-ol"] && win.document) {
1283
+ const orgLocationNode = win.document.createTextNode("");
1284
+ orgLocationNode["s-nr"] = nodeToRelocate;
1285
+ insertBefore(
1286
+ nodeToRelocate.parentNode,
1287
+ nodeToRelocate["s-ol"] = orgLocationNode,
1288
+ nodeToRelocate,
1289
+ isInitialLoad
1290
+ );
1291
+ }
1292
+ }
1293
+ for (const relocateData of relocateNodes) {
1294
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
1295
+ const slotRefNode = relocateData.$slotRefNode$;
1296
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && isInitialLoad) {
1297
+ nodeToRelocate["s-ih"] = (_a = nodeToRelocate.hidden) != null ? _a : false;
1298
+ }
1299
+ if (slotRefNode) {
1300
+ const parentNodeRef = slotRefNode.parentNode;
1301
+ let insertBeforeNode = slotRefNode.nextSibling;
1302
+ if (insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */) {
1303
+ let orgLocationNode = (_b = nodeToRelocate["s-ol"]) == null ? void 0 : _b.previousSibling;
1304
+ while (orgLocationNode) {
1305
+ let refNode = (_c = orgLocationNode["s-nr"]) != null ? _c : null;
1306
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
1307
+ refNode = refNode.nextSibling;
1308
+ while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1309
+ refNode = refNode == null ? void 0 : refNode.nextSibling;
1310
+ }
1311
+ if (!refNode || !refNode["s-nr"]) {
1312
+ insertBeforeNode = refNode;
1313
+ break;
1314
+ }
1315
+ }
1316
+ orgLocationNode = orgLocationNode.previousSibling;
1317
+ }
1318
+ }
1319
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
1320
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
1321
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
1322
+ if (nodeToRelocate !== insertBeforeNode) {
1323
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode, isInitialLoad);
1324
+ if (nodeToRelocate.nodeType === 8 /* CommentNode */ && nodeToRelocate.nodeValue.startsWith("s-nt-")) {
1325
+ const textNode = win.document.createTextNode(nodeToRelocate.nodeValue.replace(/^s-nt-/, ""));
1326
+ textNode["s-hn"] = nodeToRelocate["s-hn"];
1327
+ textNode["s-sn"] = nodeToRelocate["s-sn"];
1328
+ textNode["s-sh"] = nodeToRelocate["s-sh"];
1329
+ textNode["s-sr"] = nodeToRelocate["s-sr"];
1330
+ textNode["s-ol"] = nodeToRelocate["s-ol"];
1331
+ textNode["s-ol"]["s-nr"] = textNode;
1332
+ insertBefore(nodeToRelocate.parentNode, textNode, nodeToRelocate, isInitialLoad);
1333
+ nodeToRelocate.parentNode.removeChild(nodeToRelocate);
1334
+ }
1335
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
1336
+ nodeToRelocate.hidden = (_d = nodeToRelocate["s-ih"]) != null ? _d : false;
1337
+ }
1338
+ }
1339
+ }
1340
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](slotRefNode);
1341
+ } else if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1342
+ nodeToRelocate.hidden = true;
1343
+ }
1344
+ }
1345
+ }
1346
+ if (checkSlotFallbackVisibility) {
1347
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1348
+ }
1349
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
1350
+ relocateNodes.length = 0;
1351
+ }
1352
+ if (!useNativeShadowDom && !(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && hostElm["s-cr"]) {
1353
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1354
+ for (const childNode of children) {
1355
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1356
+ if (isInitialLoad && childNode["s-ih"] == null) {
1357
+ childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1358
+ }
1359
+ if (childNode.nodeType === 1 /* ElementNode */) {
1360
+ childNode.hidden = true;
1361
+ } else if (childNode.nodeType === 3 /* TextNode */ && !!childNode.nodeValue.trim()) {
1362
+ const textCommentNode = win.document.createComment("s-nt-" + childNode.nodeValue);
1363
+ textCommentNode["s-sn"] = childNode["s-sn"];
1364
+ insertBefore(childNode.parentNode, textCommentNode, childNode, isInitialLoad);
1365
+ childNode.parentNode.removeChild(childNode);
1366
+ }
1367
+ }
1368
+ }
1369
+ }
1370
+ contentRef = void 0;
1371
+ flushQueuedRefCallbacks();
1372
+ };
1373
+
1374
+ // src/runtime/update-component.ts
1375
+ var attachToAncestor = (hostRef, ancestorComponent) => {
1376
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
1377
+ const index = ancestorComponent["s-p"].push(
1378
+ new Promise(
1379
+ (r) => hostRef.$onRenderResolve$ = () => {
1380
+ ancestorComponent["s-p"].splice(index - 1, 1);
1381
+ r();
1382
+ }
1383
+ )
1384
+ );
1385
+ }
1386
+ };
1387
+ var scheduleUpdate = (hostRef, isInitialLoad) => {
1388
+ {
1389
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1390
+ }
1391
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1392
+ hostRef.$flags$ |= 512 /* needsRerender */;
1393
+ return;
1394
+ }
1395
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1396
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1397
+ if (isInitialLoad) {
1398
+ queueMicrotask(() => {
1399
+ dispatch();
1400
+ });
1401
+ return;
1402
+ }
1403
+ return writeTask(dispatch) ;
1404
+ };
1405
+ var dispatchHooks = (hostRef, isInitialLoad) => {
1406
+ const elm = hostRef.$hostElement$;
1407
+ const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
1408
+ const instance = hostRef.$lazyInstance$ ;
1409
+ if (!instance) {
1410
+ throw new Error(
1411
+ `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
1412
+ );
1413
+ }
1414
+ let maybePromise;
1415
+ if (isInitialLoad) {
1416
+ {
1417
+ if (hostRef.$deferredConnectedCallback$) {
1418
+ hostRef.$deferredConnectedCallback$ = false;
1419
+ safeCall(instance, "connectedCallback", void 0, elm);
1420
+ }
1421
+ {
1422
+ hostRef.$flags$ |= 256 /* isListenReady */;
1423
+ if (hostRef.$queuedListeners$) {
1424
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
1425
+ hostRef.$queuedListeners$ = void 0;
1426
+ }
1427
+ }
1428
+ if (hostRef.$fetchedCbList$.length) {
1429
+ hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
1430
+ }
1431
+ }
1432
+ maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
1433
+ } else {
1434
+ maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
1435
+ }
1436
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
1437
+ endSchedule();
1438
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1439
+ };
1440
+ var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err) => {
1441
+ console.error(err);
1442
+ fn();
1443
+ }) : fn();
1444
+ var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
1445
+ var updateComponent = async (hostRef, instance, isInitialLoad) => {
1446
+ var _a;
1447
+ const elm = hostRef.$hostElement$;
1448
+ const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
1449
+ const rc = elm["s-rc"];
1450
+ if (isInitialLoad) {
1451
+ attachStyles(hostRef);
1452
+ }
1453
+ const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
1454
+ {
1455
+ callRender(hostRef, instance, elm, isInitialLoad);
1456
+ }
1457
+ if (rc) {
1458
+ rc.map((cb) => cb());
1459
+ elm["s-rc"] = void 0;
1460
+ }
1461
+ endRender();
1462
+ endUpdate();
1463
+ {
1464
+ const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
1465
+ const postUpdate = () => postUpdateComponent(hostRef);
1466
+ if (childrenPromises.length === 0) {
1467
+ postUpdate();
1468
+ } else {
1469
+ Promise.all(childrenPromises).then(postUpdate).catch(postUpdate);
1470
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1471
+ childrenPromises.length = 0;
1472
+ }
1473
+ }
1474
+ };
1475
+ var callRender = (hostRef, instance, elm, isInitialLoad) => {
1476
+ try {
1477
+ instance = instance.render() ;
1478
+ {
1479
+ hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
1480
+ }
1481
+ {
1482
+ hostRef.$flags$ |= 2 /* hasRendered */;
1483
+ }
1484
+ {
1485
+ {
1486
+ {
1487
+ renderVdom(hostRef, instance, isInitialLoad);
1488
+ }
1489
+ }
1490
+ }
1491
+ } catch (e) {
1492
+ consoleError(e, hostRef.$hostElement$);
1493
+ }
1494
+ return null;
1495
+ };
1496
+ var postUpdateComponent = (hostRef) => {
1497
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1498
+ const elm = hostRef.$hostElement$;
1499
+ const endPostUpdate = createTime("postUpdate", tagName);
1500
+ const instance = hostRef.$lazyInstance$ ;
1501
+ const ancestorComponent = hostRef.$ancestorComponent$;
1502
+ safeCall(instance, "componentDidRender", void 0, elm);
1503
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1504
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1505
+ {
1506
+ addHydratedFlag(elm);
1507
+ }
1508
+ safeCall(instance, "componentDidLoad", void 0, elm);
1509
+ endPostUpdate();
1510
+ {
1511
+ hostRef.$onReadyResolve$(elm);
1512
+ if (!ancestorComponent) {
1513
+ appDidLoad();
1514
+ }
1515
+ }
1516
+ } else {
1517
+ safeCall(instance, "componentDidUpdate", void 0, elm);
1518
+ endPostUpdate();
1519
+ }
1520
+ {
1521
+ hostRef.$onInstanceResolve$(elm);
1522
+ }
1523
+ {
1524
+ if (hostRef.$onRenderResolve$) {
1525
+ hostRef.$onRenderResolve$();
1526
+ hostRef.$onRenderResolve$ = void 0;
1527
+ }
1528
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1529
+ nextTick(() => scheduleUpdate(hostRef, false));
1530
+ }
1531
+ hostRef.$flags$ &= -517;
1532
+ }
1533
+ };
1534
+ var appDidLoad = (who) => {
1535
+ nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
1536
+ };
1537
+ var safeCall = (instance, method, arg, elm) => {
1538
+ if (instance && instance[method]) {
1539
+ try {
1540
+ return instance[method](arg);
1541
+ } catch (e) {
1542
+ consoleError(e, elm);
1543
+ }
1544
+ }
1545
+ return void 0;
1546
+ };
1547
+ var addHydratedFlag = (elm) => {
1548
+ var _a;
1549
+ return elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") ;
1550
+ };
1551
+
1552
+ // src/runtime/set-value.ts
1553
+ var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1554
+ var setValue = (ref, propName, newVal, cmpMeta) => {
1555
+ const hostRef = getHostRef(ref);
1556
+ if (!hostRef) {
1557
+ return;
1558
+ }
1559
+ if (!hostRef) {
1560
+ throw new Error(
1561
+ `Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`
1562
+ );
1563
+ }
1564
+ const elm = hostRef.$hostElement$ ;
1565
+ const oldVal = hostRef.$instanceValues$.get(propName);
1566
+ const flags = hostRef.$flags$;
1567
+ const instance = hostRef.$lazyInstance$ ;
1568
+ newVal = parsePropertyValue(
1569
+ newVal,
1570
+ cmpMeta.$members$[propName][0]);
1571
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1572
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1573
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
1574
+ hostRef.$instanceValues$.set(propName, newVal);
1575
+ if (cmpMeta.$watchers$) {
1576
+ const watchMethods = cmpMeta.$watchers$[propName];
1577
+ if (watchMethods) {
1578
+ watchMethods.map((watcher) => {
1579
+ try {
1580
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
1581
+ if (flags & 128 /* isWatchReady */ || watcherFlags & 1 /* Immediate */) {
1582
+ if (!instance) {
1583
+ hostRef.$fetchedCbList$.push(() => {
1584
+ hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
1585
+ });
1586
+ } else {
1587
+ instance[watchMethodName](newVal, oldVal, propName);
1588
+ }
1589
+ }
1590
+ } catch (e) {
1591
+ consoleError(e, elm);
1592
+ }
1593
+ });
1594
+ }
1595
+ }
1596
+ if (flags & 2 /* hasRendered */) {
1597
+ if (instance.componentShouldUpdate) {
1598
+ const shouldUpdate = instance.componentShouldUpdate(newVal, oldVal, propName);
1599
+ if (shouldUpdate === false && !(flags & 16 /* isQueuedForUpdate */)) {
1600
+ return;
1601
+ }
1602
+ }
1603
+ if (!(flags & 16 /* isQueuedForUpdate */)) {
1604
+ scheduleUpdate(hostRef, false);
1605
+ }
1606
+ }
1607
+ }
1608
+ };
1609
+
1610
+ // src/runtime/proxy-component.ts
1611
+ var proxyComponent = (Cstr, cmpMeta, flags) => {
1612
+ var _a, _b;
1613
+ const prototype = Cstr.prototype;
1614
+ if (cmpMeta.$members$ || BUILD.propChangeCallback) {
1615
+ {
1616
+ if (Cstr.watchers && !cmpMeta.$watchers$) {
1617
+ cmpMeta.$watchers$ = Cstr.watchers;
1618
+ }
1619
+ if (Cstr.deserializers && !cmpMeta.$deserializers$) {
1620
+ cmpMeta.$deserializers$ = Cstr.deserializers;
1621
+ }
1622
+ if (Cstr.serializers && !cmpMeta.$serializers$) {
1623
+ cmpMeta.$serializers$ = Cstr.serializers;
1624
+ }
1625
+ }
1626
+ const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
1627
+ members.map(([memberName, [memberFlags]]) => {
1628
+ if ((memberFlags & 31 /* Prop */ || (flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
1629
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
1630
+ if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
1631
+ if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
1632
+ if (flags & 1 /* isElementConstructor */ || !origGetter) {
1633
+ Object.defineProperty(prototype, memberName, {
1634
+ get() {
1635
+ {
1636
+ if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
1637
+ return getValue(this, memberName);
1638
+ }
1639
+ const ref = getHostRef(this);
1640
+ const instance = ref ? ref.$lazyInstance$ : prototype;
1641
+ if (!instance) return;
1642
+ return instance[memberName];
1643
+ }
1644
+ },
1645
+ configurable: true,
1646
+ enumerable: true
1647
+ });
1648
+ }
1649
+ Object.defineProperty(prototype, memberName, {
1650
+ set(newValue) {
1651
+ const ref = getHostRef(this);
1652
+ if (!ref) {
1653
+ return;
1654
+ }
1655
+ if (origSetter) {
1656
+ const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1657
+ if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
1658
+ newValue = ref.$instanceValues$.get(memberName);
1659
+ }
1660
+ origSetter.apply(this, [
1661
+ parsePropertyValue(
1662
+ newValue,
1663
+ memberFlags)
1664
+ ]);
1665
+ newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1666
+ setValue(this, memberName, newValue, cmpMeta);
1667
+ return;
1668
+ }
1669
+ {
1670
+ if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
1671
+ setValue(this, memberName, newValue, cmpMeta);
1672
+ if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
1673
+ ref.$fetchedCbList$.push(() => {
1674
+ if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
1675
+ ref.$lazyInstance$[memberName] = newValue;
1676
+ }
1677
+ });
1678
+ }
1679
+ return;
1680
+ }
1681
+ const setterSetVal = () => {
1682
+ const currentValue = ref.$lazyInstance$[memberName];
1683
+ if (!ref.$instanceValues$.get(memberName) && currentValue) {
1684
+ ref.$instanceValues$.set(memberName, currentValue);
1685
+ }
1686
+ ref.$lazyInstance$[memberName] = parsePropertyValue(
1687
+ newValue,
1688
+ memberFlags);
1689
+ setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
1690
+ };
1691
+ if (ref.$lazyInstance$) {
1692
+ setterSetVal();
1693
+ } else {
1694
+ ref.$fetchedCbList$.push(() => {
1695
+ setterSetVal();
1696
+ });
1697
+ }
1698
+ }
1699
+ }
1700
+ });
1701
+ } else if (flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1702
+ Object.defineProperty(prototype, memberName, {
1703
+ value(...args) {
1704
+ var _a2;
1705
+ const ref = getHostRef(this);
1706
+ return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
1707
+ var _a3;
1708
+ return (_a3 = ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
1709
+ });
1710
+ }
1711
+ });
1712
+ }
1713
+ });
1714
+ if ((flags & 1 /* isElementConstructor */)) {
1715
+ const attrNameToPropName = /* @__PURE__ */ new Map();
1716
+ prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
1717
+ plt.jmp(() => {
1718
+ var _a2;
1719
+ const propName = attrNameToPropName.get(attrName);
1720
+ const hostRef = getHostRef(this);
1721
+ if (this.hasOwnProperty(propName) && BUILD.lazyLoad) {
1722
+ newValue = this[propName];
1723
+ delete this[propName];
1724
+ }
1725
+ if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
1726
+ this[propName] == newValue) {
1727
+ return;
1728
+ } else if (propName == null) {
1729
+ const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
1730
+ if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && newValue !== oldValue) {
1731
+ const instance = hostRef.$lazyInstance$ ;
1732
+ const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
1733
+ entry == null ? void 0 : entry.forEach((watcher) => {
1734
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
1735
+ if (instance[watchMethodName] != null && (flags2 & 128 /* isWatchReady */ || watcherFlags & 1 /* Immediate */)) {
1736
+ instance[watchMethodName].call(instance, newValue, oldValue, attrName);
1737
+ }
1738
+ });
1739
+ }
1740
+ return;
1741
+ }
1742
+ const propFlags = members.find(([m]) => m === propName);
1743
+ if (propFlags && propFlags[1][0] & 4 /* Boolean */) {
1744
+ newValue = newValue === null || newValue === "false" ? false : true;
1745
+ }
1746
+ const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
1747
+ if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
1748
+ this[propName] = newValue;
1749
+ }
1750
+ });
1751
+ };
1752
+ Cstr.observedAttributes = Array.from(
1753
+ /* @__PURE__ */ new Set([
1754
+ ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1755
+ ...members.filter(([_, m]) => m[0] & 31 /* HasAttribute */).map(([propName, m]) => {
1756
+ var _a2;
1757
+ const attrName = m[1] || propName;
1758
+ attrNameToPropName.set(attrName, propName);
1759
+ if (m[0] & 512 /* ReflectAttr */) {
1760
+ (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
1761
+ }
1762
+ return attrName;
1763
+ })
1764
+ ])
1765
+ );
1766
+ }
1767
+ }
1768
+ return Cstr;
1769
+ };
1770
+
1771
+ // src/runtime/initialize-component.ts
1772
+ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1773
+ let Cstr;
1774
+ try {
1775
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1776
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1777
+ const bundleId = cmpMeta.$lazyBundleId$;
1778
+ if (bundleId) {
1779
+ const CstrImport = loadModule(cmpMeta, hostRef);
1780
+ if (CstrImport && "then" in CstrImport) {
1781
+ const endLoad = uniqueTime();
1782
+ Cstr = await CstrImport;
1783
+ endLoad();
1784
+ } else {
1785
+ Cstr = CstrImport;
1786
+ }
1787
+ if (!Cstr) {
1788
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
1789
+ }
1790
+ if (!Cstr.isProxied) {
1791
+ {
1792
+ cmpMeta.$watchers$ = Cstr.watchers;
1793
+ cmpMeta.$serializers$ = Cstr.serializers;
1794
+ cmpMeta.$deserializers$ = Cstr.deserializers;
1795
+ }
1796
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1797
+ Cstr.isProxied = true;
1798
+ }
1799
+ const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
1800
+ {
1801
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1802
+ }
1803
+ try {
1804
+ new Cstr(hostRef);
1805
+ } catch (e) {
1806
+ consoleError(e, elm);
1807
+ }
1808
+ {
1809
+ hostRef.$flags$ &= -9 /* isConstructingInstance */;
1810
+ }
1811
+ {
1812
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1813
+ }
1814
+ endNewInstance();
1815
+ const needsDeferredCallback = cmpMeta.$flags$ & 4 /* hasSlotRelocation */;
1816
+ if (!needsDeferredCallback) {
1817
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
1818
+ } else {
1819
+ hostRef.$deferredConnectedCallback$ = true;
1820
+ }
1821
+ } else {
1822
+ Cstr = elm.constructor;
1823
+ const cmpTag = elm.localName;
1824
+ customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
1825
+ }
1826
+ if (Cstr && Cstr.style) {
1827
+ let style;
1828
+ if (typeof Cstr.style === "string") {
1829
+ style = Cstr.style;
1830
+ }
1831
+ const scopeId2 = getScopeId(cmpMeta);
1832
+ if (!styles.has(scopeId2) || BUILD.hotModuleReplacement) {
1833
+ const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
1834
+ registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1835
+ endRegisterStyles();
1836
+ }
1837
+ }
1838
+ }
1839
+ const ancestorComponent = hostRef.$ancestorComponent$;
1840
+ const schedule = () => scheduleUpdate(hostRef, true);
1841
+ if (ancestorComponent && ancestorComponent["s-rc"]) {
1842
+ ancestorComponent["s-rc"].push(schedule);
1843
+ } else {
1844
+ schedule();
1845
+ }
1846
+ } catch (e) {
1847
+ consoleError(e, elm);
1848
+ if (hostRef.$onRenderResolve$) {
1849
+ hostRef.$onRenderResolve$();
1850
+ hostRef.$onRenderResolve$ = void 0;
1851
+ }
1852
+ if (hostRef.$onReadyResolve$) {
1853
+ hostRef.$onReadyResolve$(elm);
1854
+ }
1855
+ }
1856
+ };
1857
+ var fireConnectedCallback = (instance, elm) => {
1858
+ {
1859
+ safeCall(instance, "connectedCallback", void 0, elm);
1860
+ }
1861
+ };
1862
+
1863
+ // src/runtime/connected-callback.ts
1864
+ var connectedCallback = (elm) => {
1865
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1866
+ const hostRef = getHostRef(elm);
1867
+ if (!hostRef) {
1868
+ return;
1869
+ }
1870
+ const cmpMeta = hostRef.$cmpMeta$;
1871
+ const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
1872
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1873
+ hostRef.$flags$ |= 1 /* hasConnected */;
1874
+ {
1875
+ if (// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
1876
+ cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
1877
+ setContentReference(elm);
1878
+ }
1879
+ }
1880
+ {
1881
+ let ancestorComponent = elm;
1882
+ while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
1883
+ if (ancestorComponent["s-p"]) {
1884
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
1885
+ break;
1886
+ }
1887
+ }
1888
+ }
1889
+ if (cmpMeta.$members$) {
1890
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1891
+ if (memberFlags & 31 /* Prop */ && memberName in elm && elm[memberName] !== Object.prototype[memberName]) {
1892
+ const value = elm[memberName];
1893
+ delete elm[memberName];
1894
+ elm[memberName] = value;
1895
+ }
1896
+ });
1897
+ }
1898
+ {
1899
+ initializeComponent(elm, hostRef, cmpMeta);
1900
+ }
1901
+ } else {
1902
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1903
+ if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
1904
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
1905
+ } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
1906
+ hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
1907
+ }
1908
+ }
1909
+ endConnected();
1910
+ }
1911
+ };
1912
+ var setContentReference = (elm) => {
1913
+ if (!win.document) {
1914
+ return;
1915
+ }
1916
+ const contentRefElm = elm["s-cr"] = win.document.createComment(
1917
+ ""
1918
+ );
1919
+ contentRefElm["s-cn"] = true;
1920
+ insertBefore(elm, contentRefElm, elm.firstChild);
1921
+ };
1922
+ var disconnectInstance = (instance, elm) => {
1923
+ {
1924
+ safeCall(instance, "disconnectedCallback", void 0, elm || instance);
1925
+ }
1926
+ };
1927
+ var disconnectedCallback = async (elm) => {
1928
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1929
+ const hostRef = getHostRef(elm);
1930
+ {
1931
+ if (hostRef == null ? void 0 : hostRef.$rmListeners$) {
1932
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1933
+ hostRef.$rmListeners$ = void 0;
1934
+ }
1935
+ }
1936
+ if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
1937
+ disconnectInstance(hostRef.$lazyInstance$, elm);
1938
+ } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
1939
+ hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
1940
+ }
1941
+ }
1942
+ if (rootAppliedStyles.has(elm)) {
1943
+ rootAppliedStyles.delete(elm);
1944
+ }
1945
+ if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) {
1946
+ rootAppliedStyles.delete(elm.shadowRoot);
1947
+ }
1948
+ };
1949
+
1950
+ // src/runtime/bootstrap-lazy.ts
1951
+ var bootstrapLazy = (lazyBundles, options = {}) => {
1952
+ var _a;
1953
+ if (!win.document) {
1954
+ console.warn("Stencil: No document found. Skipping bootstrapping lazy components.");
1955
+ return;
1956
+ }
1957
+ const endBootstrap = createTime();
1958
+ const cmpTags = [];
1959
+ const exclude = options.exclude || [];
1960
+ const customElements2 = win.customElements;
1961
+ const head = win.document.head;
1962
+ const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
1963
+ const dataStyles = /* @__PURE__ */ win.document.createElement("style");
1964
+ const deferredConnectedCallbacks = [];
1965
+ let appLoadFallback;
1966
+ let isBootstrapping = true;
1967
+ Object.assign(plt, options);
1968
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", win.document.baseURI).href;
1969
+ let hasSlotRelocation = false;
1970
+ lazyBundles.map((lazyBundle) => {
1971
+ lazyBundle[1].map((compactMeta) => {
1972
+ var _a2, _b, _c;
1973
+ const cmpMeta = {
1974
+ $flags$: compactMeta[0],
1975
+ $tagName$: compactMeta[1],
1976
+ $members$: compactMeta[2],
1977
+ $listeners$: compactMeta[3]
1978
+ };
1979
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
1980
+ hasSlotRelocation = true;
1981
+ }
1982
+ {
1983
+ cmpMeta.$members$ = compactMeta[2];
1984
+ }
1985
+ {
1986
+ cmpMeta.$listeners$ = compactMeta[3];
1987
+ }
1988
+ {
1989
+ cmpMeta.$attrsToReflect$ = [];
1990
+ }
1991
+ {
1992
+ cmpMeta.$watchers$ = (_a2 = compactMeta[4]) != null ? _a2 : {};
1993
+ cmpMeta.$serializers$ = (_b = compactMeta[5]) != null ? _b : {};
1994
+ cmpMeta.$deserializers$ = (_c = compactMeta[6]) != null ? _c : {};
1995
+ }
1996
+ const tagName = transformTag(cmpMeta.$tagName$);
1997
+ const HostElement = class extends HTMLElement {
1998
+ ["s-p"];
1999
+ ["s-rc"];
2000
+ hasRegisteredEventListeners = false;
2001
+ // StencilLazyHost
2002
+ constructor(self) {
2003
+ super(self);
2004
+ self = this;
2005
+ registerHost(self, cmpMeta);
2006
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2007
+ {
2008
+ if (!self.shadowRoot) {
2009
+ createShadowRoot.call(self, cmpMeta);
2010
+ } else {
2011
+ if (self.shadowRoot.mode !== "open") {
2012
+ throw new Error(
2013
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
2014
+ );
2015
+ }
2016
+ }
2017
+ }
2018
+ }
2019
+ }
2020
+ connectedCallback() {
2021
+ const hostRef = getHostRef(this);
2022
+ if (!hostRef) {
2023
+ return;
2024
+ }
2025
+ if (!this.hasRegisteredEventListeners) {
2026
+ this.hasRegisteredEventListeners = true;
2027
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
2028
+ }
2029
+ if (appLoadFallback) {
2030
+ clearTimeout(appLoadFallback);
2031
+ appLoadFallback = null;
2032
+ }
2033
+ if (isBootstrapping) {
2034
+ deferredConnectedCallbacks.push(this);
2035
+ } else {
2036
+ plt.jmp(() => connectedCallback(this));
2037
+ }
2038
+ }
2039
+ disconnectedCallback() {
2040
+ plt.jmp(() => disconnectedCallback(this));
2041
+ plt.raf(() => {
2042
+ var _a3;
2043
+ const hostRef = getHostRef(this);
2044
+ if (!hostRef) {
2045
+ return;
2046
+ }
2047
+ const i2 = deferredConnectedCallbacks.findIndex((host) => host === this);
2048
+ if (i2 > -1) {
2049
+ deferredConnectedCallbacks.splice(i2, 1);
2050
+ }
2051
+ if (((_a3 = hostRef == null ? void 0 : hostRef.$vnode$) == null ? void 0 : _a3.$elm$) instanceof Node && !hostRef.$vnode$.$elm$.isConnected) {
2052
+ delete hostRef.$vnode$.$elm$;
2053
+ }
2054
+ });
2055
+ }
2056
+ componentOnReady() {
2057
+ var _a3;
2058
+ return (_a3 = getHostRef(this)) == null ? void 0 : _a3.$onReadyPromise$;
2059
+ }
2060
+ };
2061
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
2062
+ if (!exclude.includes(tagName) && !customElements2.get(tagName)) {
2063
+ cmpTags.push(tagName);
2064
+ customElements2.define(
2065
+ tagName,
2066
+ proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */)
2067
+ );
2068
+ }
2069
+ });
2070
+ });
2071
+ if (cmpTags.length > 0) {
2072
+ if (hasSlotRelocation) {
2073
+ dataStyles.textContent += SLOT_FB_CSS;
2074
+ }
2075
+ {
2076
+ dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
2077
+ }
2078
+ if (dataStyles.innerHTML.length) {
2079
+ dataStyles.setAttribute("data-styles", "");
2080
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
2081
+ if (nonce != null) {
2082
+ dataStyles.setAttribute("nonce", nonce);
2083
+ }
2084
+ head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
2085
+ }
2086
+ }
2087
+ isBootstrapping = false;
2088
+ if (deferredConnectedCallbacks.length) {
2089
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
2090
+ } else {
2091
+ {
2092
+ plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
2093
+ }
2094
+ }
2095
+ endBootstrap();
2096
+ };
2097
+ var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2098
+ if (listeners && win.document) {
2099
+ listeners.map(([flags, name, method]) => {
2100
+ const target = getHostListenerTarget(win.document, elm, flags) ;
2101
+ const handler = hostListenerProxy(hostRef, method);
2102
+ const opts = hostListenerOpts(flags);
2103
+ plt.ael(target, name, handler, opts);
2104
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2105
+ });
2106
+ }
2107
+ };
2108
+ var hostListenerProxy = (hostRef, methodName) => (ev) => {
2109
+ var _a;
2110
+ try {
2111
+ {
2112
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
2113
+ (_a = hostRef.$lazyInstance$) == null ? void 0 : _a[methodName](ev);
2114
+ } else {
2115
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2116
+ }
2117
+ }
2118
+ } catch (e) {
2119
+ consoleError(e, hostRef.$hostElement$);
2120
+ }
2121
+ };
2122
+ var getHostListenerTarget = (doc, elm, flags) => {
2123
+ if (flags & 8 /* TargetWindow */) {
2124
+ return win;
2125
+ }
2126
+ return elm;
2127
+ };
2128
+ var hostListenerOpts = (flags) => supportsListenerOptions ? {
2129
+ passive: (flags & 1 /* Passive */) !== 0,
2130
+ capture: (flags & 2 /* Capture */) !== 0
2131
+ } : (flags & 2 /* Capture */) !== 0;
2132
+
2133
+ // src/runtime/nonce.ts
2134
+ var setNonce = (nonce) => plt.$nonce$ = nonce;
2135
+ function transformTag(tag) {
2136
+ return tag;
2137
+ }
2138
+
2139
+ export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };