crmbonus-component-wake 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3039 +0,0 @@
1
- const NAMESPACE = 'crmbonus-component-wake';
2
- const BUILD = /* crmbonus-component-wake */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: false, cssAnnotations: true, devTools: true, disconnectedCallback: false, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: true, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: false, lazyLoad: true, lifecycle: false, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: true, prop: true, propBoolean: true, propMutable: false, propNumber: false, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: true, slotChildNodesFix: false, slotRelocation: false, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: false };
3
- const Env = /* crmbonus-component-wake */ {};
4
-
5
- /*
6
- Stencil Client Platform v4.22.2 | MIT Licensed | https://stenciljs.com
7
- */
8
- var __defProp = Object.defineProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var Build = {
14
- isDev: BUILD.isDev ? true : false,
15
- isBrowser: true,
16
- isServer: false,
17
- isTesting: BUILD.isTesting ? true : false
18
- };
19
- var hostRefs = BUILD.hotModuleReplacement ? window.__STENCIL_HOSTREFS__ || (window.__STENCIL_HOSTREFS__ = /* @__PURE__ */ new WeakMap()) : /* @__PURE__ */ new WeakMap();
20
- var getHostRef = (ref) => hostRefs.get(ref);
21
- var registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
22
- var registerHost = (hostElement, cmpMeta) => {
23
- const hostRef = {
24
- $flags$: 0,
25
- $hostElement$: hostElement,
26
- $cmpMeta$: cmpMeta,
27
- $instanceValues$: /* @__PURE__ */ new Map()
28
- };
29
- if (BUILD.isDev) {
30
- hostRef.$renderCount$ = 0;
31
- }
32
- if (BUILD.method && BUILD.lazyLoad) {
33
- hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
34
- }
35
- if (BUILD.asyncLoading) {
36
- hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
37
- hostElement["s-p"] = [];
38
- hostElement["s-rc"] = [];
39
- }
40
- return hostRefs.set(hostElement, hostRef);
41
- };
42
- var isMemberInElement = (elm, memberName) => memberName in elm;
43
- var customError;
44
- var consoleError = (e, el) => (customError || console.error)(e, el);
45
- var STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : [
46
- "%cstencil",
47
- "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"
48
- ];
49
- var consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
50
- var consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
51
- var consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
52
- var setErrorHandler = (handler) => customError = handler;
53
-
54
- // src/client/client-load-module.ts
55
- var cmpModules = /* @__PURE__ */ new Map();
56
- var MODULE_IMPORT_PREFIX = "./";
57
- var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
58
- const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
59
- const bundleId = cmpMeta.$lazyBundleId$;
60
- if (BUILD.isDev && typeof bundleId !== "string") {
61
- consoleDevError(
62
- `Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`
63
- );
64
- return void 0;
65
- } else if (!bundleId) {
66
- return void 0;
67
- }
68
- const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
69
- if (module) {
70
- return module[exportName];
71
- }
72
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
73
- return import(
74
- /* @vite-ignore */
75
- /* webpackInclude: /\.entry\.js$/ */
76
- /* webpackExclude: /\.system\.entry\.js$/ */
77
- /* webpackMode: "lazy" */
78
- `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? "?s-hmr=" + hmrVersionId : ""}`
79
- ).then((importedModule) => {
80
- if (!BUILD.hotModuleReplacement) {
81
- cmpModules.set(bundleId, importedModule);
82
- }
83
- return importedModule[exportName];
84
- }, consoleError);
85
- };
86
-
87
- // src/client/client-style.ts
88
- var styles = /* @__PURE__ */ new Map();
89
- var modeResolutionChain = [];
90
-
91
- // src/runtime/runtime-constants.ts
92
- var CONTENT_REF_ID = "r";
93
- var ORG_LOCATION_ID = "o";
94
- var SLOT_NODE_ID = "s";
95
- var TEXT_NODE_ID = "t";
96
- var HYDRATE_ID = "s-id";
97
- var HYDRATED_STYLE_ID = "sty-id";
98
- var HYDRATE_CHILD_ID = "c-id";
99
- var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
100
- var STENCIL_DOC_DATA = "_stencilDocData";
101
- var DEFAULT_DOC_DATA = {
102
- hostIds: 0,
103
- rootLevelIds: 0,
104
- staticComponents: /* @__PURE__ */ new Set()
105
- };
106
- var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
107
- var XLINK_NS = "http://www.w3.org/1999/xlink";
108
- var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
109
- "formAssociatedCallback",
110
- "formResetCallback",
111
- "formDisabledCallback",
112
- "formStateRestoreCallback"
113
- ];
114
- var win = typeof window !== "undefined" ? window : {};
115
- var doc = win.document || { head: {} };
116
- var H = win.HTMLElement || class {
117
- };
118
- var plt = {
119
- $flags$: 0,
120
- $resourcesUrl$: "",
121
- jmp: (h2) => h2(),
122
- raf: (h2) => requestAnimationFrame(h2),
123
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
124
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
125
- ce: (eventName, opts) => new CustomEvent(eventName, opts)
126
- };
127
- var setPlatformHelpers = (helpers) => {
128
- Object.assign(plt, helpers);
129
- };
130
- var supportsShadow = BUILD.shadowDom;
131
- var supportsListenerOptions = /* @__PURE__ */ (() => {
132
- let supportsListenerOptions2 = false;
133
- try {
134
- doc.addEventListener(
135
- "e",
136
- null,
137
- Object.defineProperty({}, "passive", {
138
- get() {
139
- supportsListenerOptions2 = true;
140
- }
141
- })
142
- );
143
- } catch (e) {
144
- }
145
- return supportsListenerOptions2;
146
- })();
147
- var promiseResolve = (v) => Promise.resolve(v);
148
- var supportsConstructableStylesheets = BUILD.constructableCSS ? /* @__PURE__ */ (() => {
149
- try {
150
- new CSSStyleSheet();
151
- return typeof new CSSStyleSheet().replaceSync === "function";
152
- } catch (e) {
153
- }
154
- return false;
155
- })() : false;
156
-
157
- // src/client/client-task-queue.ts
158
- var queueCongestion = 0;
159
- var queuePending = false;
160
- var queueDomReads = [];
161
- var queueDomWrites = [];
162
- var queueDomWritesLow = [];
163
- var queueTask = (queue, write) => (cb) => {
164
- queue.push(cb);
165
- if (!queuePending) {
166
- queuePending = true;
167
- if (write && plt.$flags$ & 4 /* queueSync */) {
168
- nextTick(flush);
169
- } else {
170
- plt.raf(flush);
171
- }
172
- }
173
- };
174
- var consume = (queue) => {
175
- for (let i2 = 0; i2 < queue.length; i2++) {
176
- try {
177
- queue[i2](performance.now());
178
- } catch (e) {
179
- consoleError(e);
180
- }
181
- }
182
- queue.length = 0;
183
- };
184
- var consumeTimeout = (queue, timeout) => {
185
- let i2 = 0;
186
- let ts = 0;
187
- while (i2 < queue.length && (ts = performance.now()) < timeout) {
188
- try {
189
- queue[i2++](ts);
190
- } catch (e) {
191
- consoleError(e);
192
- }
193
- }
194
- if (i2 === queue.length) {
195
- queue.length = 0;
196
- } else if (i2 !== 0) {
197
- queue.splice(0, i2);
198
- }
199
- };
200
- var flush = () => {
201
- if (BUILD.asyncQueue) {
202
- queueCongestion++;
203
- }
204
- consume(queueDomReads);
205
- if (BUILD.asyncQueue) {
206
- const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */ ? performance.now() + 14 * Math.ceil(queueCongestion * (1 / 10)) : Infinity;
207
- consumeTimeout(queueDomWrites, timeout);
208
- consumeTimeout(queueDomWritesLow, timeout);
209
- if (queueDomWrites.length > 0) {
210
- queueDomWritesLow.push(...queueDomWrites);
211
- queueDomWrites.length = 0;
212
- }
213
- if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) {
214
- plt.raf(flush);
215
- } else {
216
- queueCongestion = 0;
217
- }
218
- } else {
219
- consume(queueDomWrites);
220
- if (queuePending = queueDomReads.length > 0) {
221
- plt.raf(flush);
222
- }
223
- }
224
- };
225
- var nextTick = (cb) => promiseResolve().then(cb);
226
- var readTask = /* @__PURE__ */ queueTask(queueDomReads, false);
227
- var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
228
-
229
- // src/runtime/asset-path.ts
230
- var getAssetPath = (path) => {
231
- const assetUrl = new URL(path, plt.$resourcesUrl$);
232
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
233
- };
234
- var setAssetPath = (path) => plt.$resourcesUrl$ = path;
235
-
236
- // src/utils/constants.ts
237
- var EMPTY_OBJ = {};
238
- var SVG_NS = "http://www.w3.org/2000/svg";
239
- var HTML_NS = "http://www.w3.org/1999/xhtml";
240
-
241
- // src/utils/helpers.ts
242
- var isDef = (v) => v != null;
243
- var isComplexType = (o) => {
244
- o = typeof o;
245
- return o === "object" || o === "function";
246
- };
247
-
248
- // src/utils/query-nonce-meta-tag-content.ts
249
- function queryNonceMetaTagContent(doc2) {
250
- var _a, _b, _c;
251
- return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
252
- }
253
-
254
- // src/utils/result.ts
255
- var result_exports = {};
256
- __export(result_exports, {
257
- err: () => err,
258
- map: () => map,
259
- ok: () => ok,
260
- unwrap: () => unwrap,
261
- unwrapErr: () => unwrapErr
262
- });
263
- var ok = (value) => ({
264
- isOk: true,
265
- isErr: false,
266
- value
267
- });
268
- var err = (value) => ({
269
- isOk: false,
270
- isErr: true,
271
- value
272
- });
273
- function map(result, fn) {
274
- if (result.isOk) {
275
- const val = fn(result.value);
276
- if (val instanceof Promise) {
277
- return val.then((newVal) => ok(newVal));
278
- } else {
279
- return ok(val);
280
- }
281
- }
282
- if (result.isErr) {
283
- const value = result.value;
284
- return err(value);
285
- }
286
- throw "should never get here";
287
- }
288
- var unwrap = (result) => {
289
- if (result.isOk) {
290
- return result.value;
291
- } else {
292
- throw result.value;
293
- }
294
- };
295
- var unwrapErr = (result) => {
296
- if (result.isErr) {
297
- return result.value;
298
- } else {
299
- throw result.value;
300
- }
301
- };
302
- var i = 0;
303
- var createTime = (fnName, tagName = "") => {
304
- if (BUILD.profile && performance.mark) {
305
- const key = `st:${fnName}:${tagName}:${i++}`;
306
- performance.mark(key);
307
- return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
308
- } else {
309
- return () => {
310
- return;
311
- };
312
- }
313
- };
314
- var uniqueTime = (key, measureText) => {
315
- if (BUILD.profile && performance.mark) {
316
- if (performance.getEntriesByName(key, "mark").length === 0) {
317
- performance.mark(key);
318
- }
319
- return () => {
320
- if (performance.getEntriesByName(measureText, "measure").length === 0) {
321
- performance.measure(measureText, key);
322
- }
323
- };
324
- } else {
325
- return () => {
326
- return;
327
- };
328
- }
329
- };
330
- var inspect = (ref) => {
331
- const hostRef = getHostRef(ref);
332
- if (!hostRef) {
333
- return void 0;
334
- }
335
- const flags = hostRef.$flags$;
336
- const hostElement = hostRef.$hostElement$;
337
- return {
338
- renderCount: hostRef.$renderCount$,
339
- flags: {
340
- hasRendered: !!(flags & 2 /* hasRendered */),
341
- hasConnected: !!(flags & 1 /* hasConnected */),
342
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
343
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
344
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
345
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
346
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
347
- isWatchReady: !!(flags & 128 /* isWatchReady */),
348
- isListenReady: !!(flags & 256 /* isListenReady */),
349
- needsRerender: !!(flags & 512 /* needsRerender */)
350
- },
351
- instanceValues: hostRef.$instanceValues$,
352
- ancestorComponent: hostRef.$ancestorComponent$,
353
- hostElement,
354
- lazyInstance: hostRef.$lazyInstance$,
355
- vnode: hostRef.$vnode$,
356
- modeName: hostRef.$modeName$,
357
- onReadyPromise: hostRef.$onReadyPromise$,
358
- onReadyResolve: hostRef.$onReadyResolve$,
359
- onInstancePromise: hostRef.$onInstancePromise$,
360
- onInstanceResolve: hostRef.$onInstanceResolve$,
361
- onRenderResolve: hostRef.$onRenderResolve$,
362
- queuedListeners: hostRef.$queuedListeners$,
363
- rmListeners: hostRef.$rmListeners$,
364
- ["s-id"]: hostElement["s-id"],
365
- ["s-cr"]: hostElement["s-cr"],
366
- ["s-lr"]: hostElement["s-lr"],
367
- ["s-p"]: hostElement["s-p"],
368
- ["s-rc"]: hostElement["s-rc"],
369
- ["s-sc"]: hostElement["s-sc"]
370
- };
371
- };
372
- var installDevTools = () => {
373
- if (BUILD.devTools) {
374
- const stencil = win.stencil = win.stencil || {};
375
- const originalInspect = stencil.inspect;
376
- stencil.inspect = (ref) => {
377
- let result = inspect(ref);
378
- if (!result && typeof originalInspect === "function") {
379
- result = originalInspect(ref);
380
- }
381
- return result;
382
- };
383
- }
384
- };
385
- var h = (nodeName, vnodeData, ...children) => {
386
- let child = null;
387
- let key = null;
388
- let slotName = null;
389
- let simple = false;
390
- let lastSimple = false;
391
- const vNodeChildren = [];
392
- const walk = (c) => {
393
- for (let i2 = 0; i2 < c.length; i2++) {
394
- child = c[i2];
395
- if (Array.isArray(child)) {
396
- walk(child);
397
- } else if (child != null && typeof child !== "boolean") {
398
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
399
- child = String(child);
400
- } else if (BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
401
- consoleDevError(`vNode passed as children has unexpected type.
402
- Make sure it's using the correct h() function.
403
- Empty objects can also be the cause, look for JSX comments that became objects.`);
404
- }
405
- if (simple && lastSimple) {
406
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
407
- } else {
408
- vNodeChildren.push(simple ? newVNode(null, child) : child);
409
- }
410
- lastSimple = simple;
411
- }
412
- }
413
- };
414
- walk(children);
415
- if (vnodeData) {
416
- if (BUILD.isDev && nodeName === "input") {
417
- validateInputProperties(vnodeData);
418
- }
419
- if (BUILD.vdomKey && vnodeData.key) {
420
- key = vnodeData.key;
421
- }
422
- if (BUILD.slotRelocation && vnodeData.name) {
423
- slotName = vnodeData.name;
424
- }
425
- if (BUILD.vdomClass) {
426
- const classData = vnodeData.className || vnodeData.class;
427
- if (classData) {
428
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
429
- }
430
- }
431
- }
432
- if (BUILD.isDev && vNodeChildren.some(isHost)) {
433
- consoleDevError(`The <Host> must be the single root component. Make sure:
434
- - You are NOT using hostData() and <Host> in the same component.
435
- - <Host> is used once, and it's the single root component of the render() function.`);
436
- }
437
- if (BUILD.vdomFunctional && typeof nodeName === "function") {
438
- return nodeName(
439
- vnodeData === null ? {} : vnodeData,
440
- vNodeChildren,
441
- vdomFnUtils
442
- );
443
- }
444
- const vnode = newVNode(nodeName, null);
445
- vnode.$attrs$ = vnodeData;
446
- if (vNodeChildren.length > 0) {
447
- vnode.$children$ = vNodeChildren;
448
- }
449
- if (BUILD.vdomKey) {
450
- vnode.$key$ = key;
451
- }
452
- if (BUILD.slotRelocation) {
453
- vnode.$name$ = slotName;
454
- }
455
- return vnode;
456
- };
457
- var newVNode = (tag, text) => {
458
- const vnode = {
459
- $flags$: 0,
460
- $tag$: tag,
461
- $text$: text,
462
- $elm$: null,
463
- $children$: null
464
- };
465
- if (BUILD.vdomAttribute) {
466
- vnode.$attrs$ = null;
467
- }
468
- if (BUILD.vdomKey) {
469
- vnode.$key$ = null;
470
- }
471
- if (BUILD.slotRelocation) {
472
- vnode.$name$ = null;
473
- }
474
- return vnode;
475
- };
476
- var Host = {};
477
- var isHost = (node) => node && node.$tag$ === Host;
478
- var vdomFnUtils = {
479
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
480
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
481
- };
482
- var convertToPublic = (node) => ({
483
- vattrs: node.$attrs$,
484
- vchildren: node.$children$,
485
- vkey: node.$key$,
486
- vname: node.$name$,
487
- vtag: node.$tag$,
488
- vtext: node.$text$
489
- });
490
- var convertToPrivate = (node) => {
491
- if (typeof node.vtag === "function") {
492
- const vnodeData = { ...node.vattrs };
493
- if (node.vkey) {
494
- vnodeData.key = node.vkey;
495
- }
496
- if (node.vname) {
497
- vnodeData.name = node.vname;
498
- }
499
- return h(node.vtag, vnodeData, ...node.vchildren || []);
500
- }
501
- const vnode = newVNode(node.vtag, node.vtext);
502
- vnode.$attrs$ = node.vattrs;
503
- vnode.$children$ = node.vchildren;
504
- vnode.$key$ = node.vkey;
505
- vnode.$name$ = node.vname;
506
- return vnode;
507
- };
508
- var validateInputProperties = (inputElm) => {
509
- const props = Object.keys(inputElm);
510
- const value = props.indexOf("value");
511
- if (value === -1) {
512
- return;
513
- }
514
- const typeIndex = props.indexOf("type");
515
- const minIndex = props.indexOf("min");
516
- const maxIndex = props.indexOf("max");
517
- const stepIndex = props.indexOf("step");
518
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
519
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
520
- }
521
- };
522
-
523
- // src/runtime/client-hydrate.ts
524
- var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
525
- const endHydrate = createTime("hydrateClient", tagName);
526
- const shadowRoot = hostElm.shadowRoot;
527
- const childRenderNodes = [];
528
- const slotNodes = [];
529
- const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
530
- const vnode = hostRef.$vnode$ = newVNode(tagName, null);
531
- if (!plt.$orgLocNodes$) {
532
- initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
533
- }
534
- hostElm[HYDRATE_ID] = hostId;
535
- hostElm.removeAttribute(HYDRATE_ID);
536
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
537
- childRenderNodes.map((c) => {
538
- const orgLocationId = c.$hostId$ + "." + c.$nodeId$;
539
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
540
- const node = c.$elm$;
541
- if (orgLocationNode && supportsShadow && orgLocationNode["s-en"] === "") {
542
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
543
- }
544
- if (!shadowRoot) {
545
- node["s-hn"] = tagName;
546
- if (orgLocationNode) {
547
- node["s-ol"] = orgLocationNode;
548
- node["s-ol"]["s-nr"] = node;
549
- }
550
- }
551
- plt.$orgLocNodes$.delete(orgLocationId);
552
- });
553
- if (BUILD.shadowDom && shadowRoot) {
554
- shadowRootNodes.map((shadowRootNode) => {
555
- if (shadowRootNode) {
556
- shadowRoot.appendChild(shadowRootNode);
557
- }
558
- });
559
- }
560
- endHydrate();
561
- };
562
- var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
563
- let childNodeType;
564
- let childIdSplt;
565
- let childVNode;
566
- let i2;
567
- if (node.nodeType === 1 /* ElementNode */) {
568
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
569
- if (childNodeType) {
570
- childIdSplt = childNodeType.split(".");
571
- if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
572
- childVNode = {
573
- $flags$: 0,
574
- $hostId$: childIdSplt[0],
575
- $nodeId$: childIdSplt[1],
576
- $depth$: childIdSplt[2],
577
- $index$: childIdSplt[3],
578
- $tag$: node.tagName.toLowerCase(),
579
- $elm$: node,
580
- $attrs$: null,
581
- $children$: null,
582
- $key$: null,
583
- $name$: null,
584
- $text$: null
585
- };
586
- childRenderNodes.push(childVNode);
587
- node.removeAttribute(HYDRATE_CHILD_ID);
588
- if (!parentVNode.$children$) {
589
- parentVNode.$children$ = [];
590
- }
591
- parentVNode.$children$[childVNode.$index$] = childVNode;
592
- parentVNode = childVNode;
593
- if (shadowRootNodes && childVNode.$depth$ === "0") {
594
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
595
- }
596
- }
597
- }
598
- if (node.shadowRoot) {
599
- for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
600
- clientHydrate(
601
- parentVNode,
602
- childRenderNodes,
603
- slotNodes,
604
- shadowRootNodes,
605
- hostElm,
606
- node.shadowRoot.childNodes[i2],
607
- hostId
608
- );
609
- }
610
- }
611
- for (i2 = node.childNodes.length - 1; i2 >= 0; i2--) {
612
- clientHydrate(
613
- parentVNode,
614
- childRenderNodes,
615
- slotNodes,
616
- shadowRootNodes,
617
- hostElm,
618
- node.childNodes[i2],
619
- hostId
620
- );
621
- }
622
- } else if (node.nodeType === 8 /* CommentNode */) {
623
- childIdSplt = node.nodeValue.split(".");
624
- if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
625
- childNodeType = childIdSplt[0];
626
- childVNode = {
627
- $flags$: 0,
628
- $hostId$: childIdSplt[1],
629
- $nodeId$: childIdSplt[2],
630
- $depth$: childIdSplt[3],
631
- $index$: childIdSplt[4],
632
- $elm$: node,
633
- $attrs$: null,
634
- $children$: null,
635
- $key$: null,
636
- $name$: null,
637
- $tag$: null,
638
- $text$: null
639
- };
640
- if (childNodeType === TEXT_NODE_ID) {
641
- childVNode.$elm$ = node.nextSibling;
642
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
643
- childVNode.$text$ = childVNode.$elm$.textContent;
644
- childRenderNodes.push(childVNode);
645
- node.remove();
646
- if (!parentVNode.$children$) {
647
- parentVNode.$children$ = [];
648
- }
649
- parentVNode.$children$[childVNode.$index$] = childVNode;
650
- if (shadowRootNodes && childVNode.$depth$ === "0") {
651
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
652
- }
653
- }
654
- } else if (childVNode.$hostId$ === hostId) {
655
- if (childNodeType === SLOT_NODE_ID) {
656
- childVNode.$tag$ = "slot";
657
- if (childIdSplt[5]) {
658
- node["s-sn"] = childVNode.$name$ = childIdSplt[5];
659
- } else {
660
- node["s-sn"] = "";
661
- }
662
- node["s-sr"] = true;
663
- if (BUILD.shadowDom && shadowRootNodes) {
664
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
665
- if (childVNode.$name$) {
666
- childVNode.$elm$.setAttribute("name", childVNode.$name$);
667
- }
668
- node.parentNode.insertBefore(childVNode.$elm$, node);
669
- node.remove();
670
- if (childVNode.$depth$ === "0") {
671
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
672
- }
673
- }
674
- slotNodes.push(childVNode);
675
- if (!parentVNode.$children$) {
676
- parentVNode.$children$ = [];
677
- }
678
- parentVNode.$children$[childVNode.$index$] = childVNode;
679
- } else if (childNodeType === CONTENT_REF_ID) {
680
- if (BUILD.shadowDom && shadowRootNodes) {
681
- node.remove();
682
- } else if (BUILD.slotRelocation) {
683
- hostElm["s-cr"] = node;
684
- node["s-cn"] = true;
685
- }
686
- }
687
- }
688
- }
689
- } else if (parentVNode && parentVNode.$tag$ === "style") {
690
- const vnode = newVNode(null, node.textContent);
691
- vnode.$elm$ = node;
692
- vnode.$index$ = "0";
693
- parentVNode.$children$ = [vnode];
694
- }
695
- };
696
- var initializeDocumentHydrate = (node, orgLocNodes) => {
697
- if (node.nodeType === 1 /* ElementNode */) {
698
- let i2 = 0;
699
- if (node.shadowRoot) {
700
- for (; i2 < node.shadowRoot.childNodes.length; i2++) {
701
- initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
702
- }
703
- }
704
- for (i2 = 0; i2 < node.childNodes.length; i2++) {
705
- initializeDocumentHydrate(node.childNodes[i2], orgLocNodes);
706
- }
707
- } else if (node.nodeType === 8 /* CommentNode */) {
708
- const childIdSplt = node.nodeValue.split(".");
709
- if (childIdSplt[0] === ORG_LOCATION_ID) {
710
- orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
711
- node.nodeValue = "";
712
- node["s-en"] = childIdSplt[3];
713
- }
714
- }
715
- };
716
-
717
- // src/runtime/mode.ts
718
- var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
719
- var setMode = (handler) => modeResolutionChain.push(handler);
720
- var getMode = (ref) => getHostRef(ref).$modeName$;
721
- var parsePropertyValue = (propValue, propType) => {
722
- if (propValue != null && !isComplexType(propValue)) {
723
- if (BUILD.propBoolean && propType & 4 /* Boolean */) {
724
- return propValue === "false" ? false : propValue === "" || !!propValue;
725
- }
726
- if (BUILD.propNumber && propType & 2 /* Number */) {
727
- return parseFloat(propValue);
728
- }
729
- if (BUILD.propString && propType & 1 /* String */) {
730
- return String(propValue);
731
- }
732
- return propValue;
733
- }
734
- return propValue;
735
- };
736
- var getElement = (ref) => BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
737
-
738
- // src/runtime/event-emitter.ts
739
- var createEvent = (ref, name, flags) => {
740
- const elm = getElement(ref);
741
- return {
742
- emit: (detail) => {
743
- if (BUILD.isDev && !elm.isConnected) {
744
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
745
- }
746
- return emitEvent(elm, name, {
747
- bubbles: !!(flags & 4 /* Bubbles */),
748
- composed: !!(flags & 2 /* Composed */),
749
- cancelable: !!(flags & 1 /* Cancellable */),
750
- detail
751
- });
752
- }
753
- };
754
- };
755
- var emitEvent = (elm, name, opts) => {
756
- const ev = plt.ce(name, opts);
757
- elm.dispatchEvent(ev);
758
- return ev;
759
- };
760
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
761
- var registerStyle = (scopeId2, cssText, allowCS) => {
762
- let style = styles.get(scopeId2);
763
- if (supportsConstructableStylesheets && allowCS) {
764
- style = style || new CSSStyleSheet();
765
- if (typeof style === "string") {
766
- style = cssText;
767
- } else {
768
- style.replaceSync(cssText);
769
- }
770
- } else {
771
- style = cssText;
772
- }
773
- styles.set(scopeId2, style);
774
- };
775
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
776
- var _a;
777
- const scopeId2 = getScopeId(cmpMeta, mode);
778
- const style = styles.get(scopeId2);
779
- if (!BUILD.attachStyles) {
780
- return scopeId2;
781
- }
782
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
783
- if (style) {
784
- if (typeof style === "string") {
785
- styleContainerNode = styleContainerNode.head || styleContainerNode;
786
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
787
- let styleElm;
788
- if (!appliedStyles) {
789
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
790
- }
791
- if (!appliedStyles.has(scopeId2)) {
792
- if (BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
793
- styleElm.innerHTML = style;
794
- } else {
795
- styleElm = doc.createElement("style");
796
- styleElm.innerHTML = style;
797
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
798
- if (nonce != null) {
799
- styleElm.setAttribute("nonce", nonce);
800
- }
801
- if ((BUILD.hydrateServerSide || BUILD.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
802
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
803
- }
804
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
805
- if (styleContainerNode.nodeName === "HEAD") {
806
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
807
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
808
- styleContainerNode.insertBefore(styleElm, referenceNode2);
809
- } else if ("host" in styleContainerNode) {
810
- if (supportsConstructableStylesheets) {
811
- const stylesheet = new CSSStyleSheet();
812
- stylesheet.replaceSync(style);
813
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
814
- } else {
815
- const existingStyleContainer = styleContainerNode.querySelector("style");
816
- if (existingStyleContainer) {
817
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
818
- } else {
819
- styleContainerNode.prepend(styleElm);
820
- }
821
- }
822
- } else {
823
- styleContainerNode.append(styleElm);
824
- }
825
- }
826
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
827
- styleContainerNode.insertBefore(styleElm, null);
828
- }
829
- }
830
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
831
- styleElm.innerHTML += SLOT_FB_CSS;
832
- }
833
- if (appliedStyles) {
834
- appliedStyles.add(scopeId2);
835
- }
836
- }
837
- } else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
838
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
839
- }
840
- }
841
- return scopeId2;
842
- };
843
- var attachStyles = (hostRef) => {
844
- const cmpMeta = hostRef.$cmpMeta$;
845
- const elm = hostRef.$hostElement$;
846
- const flags = cmpMeta.$flags$;
847
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
848
- const scopeId2 = addStyle(
849
- BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
850
- cmpMeta,
851
- hostRef.$modeName$
852
- );
853
- if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
854
- elm["s-sc"] = scopeId2;
855
- elm.classList.add(scopeId2 + "-h");
856
- if (BUILD.scoped && flags & 2 /* scopedCssEncapsulation */) {
857
- elm.classList.add(scopeId2 + "-s");
858
- }
859
- }
860
- endAttachStyles();
861
- };
862
- var getScopeId = (cmp, mode) => "sc-" + (BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
863
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
864
- if (oldValue !== newValue) {
865
- let isProp = isMemberInElement(elm, memberName);
866
- let ln = memberName.toLowerCase();
867
- if (BUILD.vdomClass && memberName === "class") {
868
- const classList = elm.classList;
869
- const oldClasses = parseClassList(oldValue);
870
- const newClasses = parseClassList(newValue);
871
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
872
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
873
- } else if (BUILD.vdomStyle && memberName === "style") {
874
- if (BUILD.updatable) {
875
- for (const prop in oldValue) {
876
- if (!newValue || newValue[prop] == null) {
877
- if (!BUILD.hydrateServerSide && prop.includes("-")) {
878
- elm.style.removeProperty(prop);
879
- } else {
880
- elm.style[prop] = "";
881
- }
882
- }
883
- }
884
- }
885
- for (const prop in newValue) {
886
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
887
- if (!BUILD.hydrateServerSide && prop.includes("-")) {
888
- elm.style.setProperty(prop, newValue[prop]);
889
- } else {
890
- elm.style[prop] = newValue[prop];
891
- }
892
- }
893
- }
894
- } else if (BUILD.vdomKey && memberName === "key") {
895
- } else if (BUILD.vdomRef && memberName === "ref") {
896
- if (newValue) {
897
- newValue(elm);
898
- }
899
- } else if (BUILD.vdomListener && (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
900
- if (memberName[2] === "-") {
901
- memberName = memberName.slice(3);
902
- } else if (isMemberInElement(win, ln)) {
903
- memberName = ln.slice(2);
904
- } else {
905
- memberName = ln[2] + memberName.slice(3);
906
- }
907
- if (oldValue || newValue) {
908
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
909
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
910
- if (oldValue) {
911
- plt.rel(elm, memberName, oldValue, capture);
912
- }
913
- if (newValue) {
914
- plt.ael(elm, memberName, newValue, capture);
915
- }
916
- }
917
- } else if (BUILD.vdomPropOrAttr) {
918
- const isComplex = isComplexType(newValue);
919
- if ((isProp || isComplex && newValue !== null) && !isSvg) {
920
- try {
921
- if (!elm.tagName.includes("-")) {
922
- const n = newValue == null ? "" : newValue;
923
- if (memberName === "list") {
924
- isProp = false;
925
- } else if (oldValue == null || elm[memberName] != n) {
926
- if (typeof elm.__lookupSetter__(memberName) === "function") {
927
- elm[memberName] = n;
928
- } else {
929
- elm.setAttribute(memberName, n);
930
- }
931
- }
932
- } else {
933
- elm[memberName] = newValue;
934
- }
935
- } catch (e) {
936
- }
937
- }
938
- let xlink = false;
939
- if (BUILD.vdomXlink) {
940
- if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
941
- memberName = ln;
942
- xlink = true;
943
- }
944
- }
945
- if (newValue == null || newValue === false) {
946
- if (newValue !== false || elm.getAttribute(memberName) === "") {
947
- if (BUILD.vdomXlink && xlink) {
948
- elm.removeAttributeNS(XLINK_NS, memberName);
949
- } else {
950
- elm.removeAttribute(memberName);
951
- }
952
- }
953
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
954
- newValue = newValue === true ? "" : newValue;
955
- if (BUILD.vdomXlink && xlink) {
956
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
957
- } else {
958
- elm.setAttribute(memberName, newValue);
959
- }
960
- }
961
- }
962
- }
963
- };
964
- var parseClassListRegex = /\s/;
965
- var parseClassList = (value) => !value ? [] : value.split(parseClassListRegex);
966
- var CAPTURE_EVENT_SUFFIX = "Capture";
967
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
968
-
969
- // src/runtime/vdom/update-element.ts
970
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
971
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
972
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || EMPTY_OBJ;
973
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
974
- if (BUILD.updatable) {
975
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
976
- if (!(memberName in newVnodeAttrs)) {
977
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
978
- }
979
- }
980
- }
981
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
982
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
983
- }
984
- };
985
- function sortedAttrNames(attrNames) {
986
- return attrNames.includes("ref") ? (
987
- // we need to sort these to ensure that `'ref'` is the last attr
988
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
989
- ) : (
990
- // no need to sort, return the original array
991
- attrNames
992
- );
993
- }
994
-
995
- // src/runtime/vdom/vdom-render.ts
996
- var scopeId;
997
- var contentRef;
998
- var hostTagName;
999
- var useNativeShadowDom = false;
1000
- var checkSlotFallbackVisibility = false;
1001
- var checkSlotRelocate = false;
1002
- var isSvgMode = false;
1003
- var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
1004
- var _a;
1005
- const newVNode2 = newParentVNode.$children$[childIndex];
1006
- let i2 = 0;
1007
- let elm;
1008
- let childNode;
1009
- let oldVNode;
1010
- if (BUILD.slotRelocation && !useNativeShadowDom) {
1011
- checkSlotRelocate = true;
1012
- if (newVNode2.$tag$ === "slot") {
1013
- if (scopeId) {
1014
- parentElm.classList.add(scopeId + "-s");
1015
- }
1016
- newVNode2.$flags$ |= newVNode2.$children$ ? (
1017
- // slot element has fallback content
1018
- // still create an element that "mocks" the slot element
1019
- 2 /* isSlotFallback */
1020
- ) : (
1021
- // slot element does not have fallback content
1022
- // create an html comment we'll use to always reference
1023
- // where actual slot content should sit next to
1024
- 1 /* isSlotReference */
1025
- );
1026
- }
1027
- }
1028
- if (BUILD.isDev && newVNode2.$elm$) {
1029
- consoleDevError(
1030
- `The JSX ${newVNode2.$text$ !== null ? `"${newVNode2.$text$}" text` : `"${newVNode2.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`
1031
- );
1032
- }
1033
- if (BUILD.vdomText && newVNode2.$text$ !== null) {
1034
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
1035
- } else if (BUILD.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
1036
- elm = newVNode2.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
1037
- } else {
1038
- if (BUILD.svg && !isSvgMode) {
1039
- isSvgMode = newVNode2.$tag$ === "svg";
1040
- }
1041
- elm = newVNode2.$elm$ = BUILD.svg ? doc.createElementNS(
1042
- isSvgMode ? SVG_NS : HTML_NS,
1043
- !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1044
- ) : doc.createElement(
1045
- !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1046
- );
1047
- if (BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
1048
- isSvgMode = false;
1049
- }
1050
- if (BUILD.vdomAttribute) {
1051
- updateElement(null, newVNode2, isSvgMode);
1052
- }
1053
- const rootNode = elm.getRootNode();
1054
- const isElementWithinShadowRoot = !rootNode.querySelector("body");
1055
- if (!isElementWithinShadowRoot && BUILD.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
1056
- elm.classList.add(elm["s-si"] = scopeId);
1057
- }
1058
- if (BUILD.scoped) {
1059
- updateElementScopeIds(elm, parentElm);
1060
- }
1061
- if (newVNode2.$children$) {
1062
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
1063
- childNode = createElm(oldParentVNode, newVNode2, i2, elm);
1064
- if (childNode) {
1065
- elm.appendChild(childNode);
1066
- }
1067
- }
1068
- }
1069
- if (BUILD.svg) {
1070
- if (newVNode2.$tag$ === "svg") {
1071
- isSvgMode = false;
1072
- } else if (elm.tagName === "foreignObject") {
1073
- isSvgMode = true;
1074
- }
1075
- }
1076
- }
1077
- elm["s-hn"] = hostTagName;
1078
- if (BUILD.slotRelocation) {
1079
- if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
1080
- elm["s-sr"] = true;
1081
- elm["s-cr"] = contentRef;
1082
- elm["s-sn"] = newVNode2.$name$ || "";
1083
- elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1084
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1085
- if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
1086
- if (BUILD.experimentalSlotFixes) {
1087
- relocateToHostRoot(oldParentVNode.$elm$);
1088
- } else {
1089
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
1090
- }
1091
- }
1092
- }
1093
- }
1094
- return elm;
1095
- };
1096
- var relocateToHostRoot = (parentElm) => {
1097
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1098
- const host = parentElm.closest(hostTagName.toLowerCase());
1099
- if (host != null) {
1100
- const contentRefNode = Array.from(host.childNodes).find((ref) => ref["s-cr"]);
1101
- const childNodeArray = Array.from(parentElm.childNodes);
1102
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1103
- if (childNode["s-sh"] != null) {
1104
- insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1105
- childNode["s-sh"] = void 0;
1106
- checkSlotRelocate = true;
1107
- }
1108
- }
1109
- }
1110
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1111
- };
1112
- var putBackInOriginalLocation = (parentElm, recursive) => {
1113
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1114
- const oldSlotChildNodes = Array.from(parentElm.childNodes);
1115
- if (parentElm["s-sr"] && BUILD.experimentalSlotFixes) {
1116
- let node = parentElm;
1117
- while (node = node.nextSibling) {
1118
- if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
1119
- oldSlotChildNodes.push(node);
1120
- }
1121
- }
1122
- }
1123
- for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1124
- const childNode = oldSlotChildNodes[i2];
1125
- if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1126
- insertBefore(parentReferenceNode(childNode), childNode, referenceNode(childNode));
1127
- childNode["s-ol"].remove();
1128
- childNode["s-ol"] = void 0;
1129
- childNode["s-sh"] = void 0;
1130
- checkSlotRelocate = true;
1131
- }
1132
- if (recursive) {
1133
- putBackInOriginalLocation(childNode, recursive);
1134
- }
1135
- }
1136
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1137
- };
1138
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1139
- let containerElm = BUILD.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
1140
- let childNode;
1141
- if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1142
- containerElm = containerElm.shadowRoot;
1143
- }
1144
- for (; startIdx <= endIdx; ++startIdx) {
1145
- if (vnodes[startIdx]) {
1146
- childNode = createElm(null, parentVNode, startIdx, parentElm);
1147
- if (childNode) {
1148
- vnodes[startIdx].$elm$ = childNode;
1149
- insertBefore(containerElm, childNode, BUILD.slotRelocation ? referenceNode(before) : before);
1150
- }
1151
- }
1152
- }
1153
- };
1154
- var removeVnodes = (vnodes, startIdx, endIdx) => {
1155
- for (let index = startIdx; index <= endIdx; ++index) {
1156
- const vnode = vnodes[index];
1157
- if (vnode) {
1158
- const elm = vnode.$elm$;
1159
- nullifyVNodeRefs(vnode);
1160
- if (elm) {
1161
- if (BUILD.slotRelocation) {
1162
- checkSlotFallbackVisibility = true;
1163
- if (elm["s-ol"]) {
1164
- elm["s-ol"].remove();
1165
- } else {
1166
- putBackInOriginalLocation(elm, true);
1167
- }
1168
- }
1169
- elm.remove();
1170
- }
1171
- }
1172
- }
1173
- };
1174
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
1175
- let oldStartIdx = 0;
1176
- let newStartIdx = 0;
1177
- let idxInOld = 0;
1178
- let i2 = 0;
1179
- let oldEndIdx = oldCh.length - 1;
1180
- let oldStartVnode = oldCh[0];
1181
- let oldEndVnode = oldCh[oldEndIdx];
1182
- let newEndIdx = newCh.length - 1;
1183
- let newStartVnode = newCh[0];
1184
- let newEndVnode = newCh[newEndIdx];
1185
- let node;
1186
- let elmToMove;
1187
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1188
- if (oldStartVnode == null) {
1189
- oldStartVnode = oldCh[++oldStartIdx];
1190
- } else if (oldEndVnode == null) {
1191
- oldEndVnode = oldCh[--oldEndIdx];
1192
- } else if (newStartVnode == null) {
1193
- newStartVnode = newCh[++newStartIdx];
1194
- } else if (newEndVnode == null) {
1195
- newEndVnode = newCh[--newEndIdx];
1196
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1197
- patch(oldStartVnode, newStartVnode, isInitialRender);
1198
- oldStartVnode = oldCh[++oldStartIdx];
1199
- newStartVnode = newCh[++newStartIdx];
1200
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1201
- patch(oldEndVnode, newEndVnode, isInitialRender);
1202
- oldEndVnode = oldCh[--oldEndIdx];
1203
- newEndVnode = newCh[--newEndIdx];
1204
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1205
- if (BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1206
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1207
- }
1208
- patch(oldStartVnode, newEndVnode, isInitialRender);
1209
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1210
- oldStartVnode = oldCh[++oldStartIdx];
1211
- newEndVnode = newCh[--newEndIdx];
1212
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1213
- if (BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1214
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1215
- }
1216
- patch(oldEndVnode, newStartVnode, isInitialRender);
1217
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1218
- oldEndVnode = oldCh[--oldEndIdx];
1219
- newStartVnode = newCh[++newStartIdx];
1220
- } else {
1221
- idxInOld = -1;
1222
- if (BUILD.vdomKey) {
1223
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
1224
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
1225
- idxInOld = i2;
1226
- break;
1227
- }
1228
- }
1229
- }
1230
- if (BUILD.vdomKey && idxInOld >= 0) {
1231
- elmToMove = oldCh[idxInOld];
1232
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1233
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld, parentElm);
1234
- } else {
1235
- patch(elmToMove, newStartVnode, isInitialRender);
1236
- oldCh[idxInOld] = void 0;
1237
- node = elmToMove.$elm$;
1238
- }
1239
- newStartVnode = newCh[++newStartIdx];
1240
- } else {
1241
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx, parentElm);
1242
- newStartVnode = newCh[++newStartIdx];
1243
- }
1244
- if (node) {
1245
- if (BUILD.slotRelocation) {
1246
- insertBefore(parentReferenceNode(oldStartVnode.$elm$), node, referenceNode(oldStartVnode.$elm$));
1247
- } else {
1248
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1249
- }
1250
- }
1251
- }
1252
- }
1253
- if (oldStartIdx > oldEndIdx) {
1254
- addVnodes(
1255
- parentElm,
1256
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
1257
- newVNode2,
1258
- newCh,
1259
- newStartIdx,
1260
- newEndIdx
1261
- );
1262
- } else if (BUILD.updatable && newStartIdx > newEndIdx) {
1263
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1264
- }
1265
- };
1266
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1267
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1268
- if (BUILD.slotRelocation && leftVNode.$tag$ === "slot") {
1269
- if (
1270
- // The component gets hydrated and no VDOM has been initialized.
1271
- // Here the comparison can't happen as $name$ property is not set for `leftNode`.
1272
- "$nodeId$" in leftVNode && isInitialRender && // `leftNode` is not from type HTMLComment which would cause many
1273
- // hydration comments to be removed
1274
- leftVNode.$elm$.nodeType !== 8
1275
- ) {
1276
- return false;
1277
- }
1278
- return leftVNode.$name$ === rightVNode.$name$;
1279
- }
1280
- if (BUILD.vdomKey && !isInitialRender) {
1281
- return leftVNode.$key$ === rightVNode.$key$;
1282
- }
1283
- return true;
1284
- }
1285
- return false;
1286
- };
1287
- var referenceNode = (node) => {
1288
- return node && node["s-ol"] || node;
1289
- };
1290
- var parentReferenceNode = (node) => (node["s-ol"] ? node["s-ol"] : node).parentNode;
1291
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1292
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
1293
- const oldChildren = oldVNode.$children$;
1294
- const newChildren = newVNode2.$children$;
1295
- const tag = newVNode2.$tag$;
1296
- const text = newVNode2.$text$;
1297
- let defaultHolder;
1298
- if (!BUILD.vdomText || text === null) {
1299
- if (BUILD.svg) {
1300
- isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
1301
- }
1302
- if (BUILD.vdomAttribute || BUILD.reflect) {
1303
- if (BUILD.slot && tag === "slot" && !useNativeShadowDom) {
1304
- if (BUILD.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
1305
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
1306
- relocateToHostRoot(newVNode2.$elm$.parentElement);
1307
- }
1308
- } else {
1309
- updateElement(oldVNode, newVNode2, isSvgMode);
1310
- }
1311
- }
1312
- if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1313
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
1314
- } else if (newChildren !== null) {
1315
- if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1316
- elm.textContent = "";
1317
- }
1318
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
1319
- } else if (
1320
- // don't do this on initial render as it can cause non-hydrated content to be removed
1321
- !isInitialRender && BUILD.updatable && oldChildren !== null
1322
- ) {
1323
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1324
- }
1325
- if (BUILD.svg && isSvgMode && tag === "svg") {
1326
- isSvgMode = false;
1327
- }
1328
- } else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) {
1329
- defaultHolder.parentNode.textContent = text;
1330
- } else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1331
- elm.data = text;
1332
- }
1333
- };
1334
- var updateFallbackSlotVisibility = (elm) => {
1335
- const childNodes = elm.childNodes;
1336
- for (const childNode of childNodes) {
1337
- if (childNode.nodeType === 1 /* ElementNode */) {
1338
- if (childNode["s-sr"]) {
1339
- const slotName = childNode["s-sn"];
1340
- childNode.hidden = false;
1341
- for (const siblingNode of childNodes) {
1342
- if (siblingNode !== childNode) {
1343
- if (siblingNode["s-hn"] !== childNode["s-hn"] || slotName !== "") {
1344
- if (siblingNode.nodeType === 1 /* ElementNode */ && (slotName === siblingNode.getAttribute("slot") || slotName === siblingNode["s-sn"]) || siblingNode.nodeType === 3 /* TextNode */ && slotName === siblingNode["s-sn"]) {
1345
- childNode.hidden = true;
1346
- break;
1347
- }
1348
- } else {
1349
- if (siblingNode.nodeType === 1 /* ElementNode */ || siblingNode.nodeType === 3 /* TextNode */ && siblingNode.textContent.trim() !== "") {
1350
- childNode.hidden = true;
1351
- break;
1352
- }
1353
- }
1354
- }
1355
- }
1356
- }
1357
- updateFallbackSlotVisibility(childNode);
1358
- }
1359
- }
1360
- };
1361
- var relocateNodes = [];
1362
- var markSlotContentForRelocation = (elm) => {
1363
- let node;
1364
- let hostContentNodes;
1365
- let j;
1366
- for (const childNode of elm.childNodes) {
1367
- if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1368
- hostContentNodes = node.parentNode.childNodes;
1369
- const slotName = childNode["s-sn"];
1370
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1371
- node = hostContentNodes[j];
1372
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1373
- if (isNodeLocatedInSlot(node, slotName)) {
1374
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1375
- checkSlotFallbackVisibility = true;
1376
- node["s-sn"] = node["s-sn"] || slotName;
1377
- if (relocateNodeData) {
1378
- relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1379
- relocateNodeData.$slotRefNode$ = childNode;
1380
- } else {
1381
- node["s-sh"] = childNode["s-hn"];
1382
- relocateNodes.push({
1383
- $slotRefNode$: childNode,
1384
- $nodeToRelocate$: node
1385
- });
1386
- }
1387
- if (node["s-sr"]) {
1388
- relocateNodes.map((relocateNode) => {
1389
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1390
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1391
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1392
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1393
- }
1394
- }
1395
- });
1396
- }
1397
- } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1398
- relocateNodes.push({
1399
- $nodeToRelocate$: node
1400
- });
1401
- }
1402
- }
1403
- }
1404
- }
1405
- if (childNode.nodeType === 1 /* ElementNode */) {
1406
- markSlotContentForRelocation(childNode);
1407
- }
1408
- }
1409
- };
1410
- var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1411
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1412
- if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
1413
- return true;
1414
- }
1415
- if (nodeToRelocate.getAttribute("slot") === slotName) {
1416
- return true;
1417
- }
1418
- return false;
1419
- }
1420
- if (nodeToRelocate["s-sn"] === slotName) {
1421
- return true;
1422
- }
1423
- return slotName === "";
1424
- };
1425
- var nullifyVNodeRefs = (vNode) => {
1426
- if (BUILD.vdomRef) {
1427
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1428
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1429
- }
1430
- };
1431
- var insertBefore = (parent, newNode, reference) => {
1432
- const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1433
- if (BUILD.scoped) {
1434
- updateElementScopeIds(newNode, parent);
1435
- }
1436
- return inserted;
1437
- };
1438
- var findScopeIds = (element) => {
1439
- const scopeIds = [];
1440
- if (element) {
1441
- scopeIds.push(
1442
- ...element["s-scs"] || [],
1443
- element["s-si"],
1444
- element["s-sc"],
1445
- ...findScopeIds(element.parentElement)
1446
- );
1447
- }
1448
- return scopeIds;
1449
- };
1450
- var updateElementScopeIds = (element, parent, iterateChildNodes = false) => {
1451
- var _a;
1452
- if (element && parent && element.nodeType === 1 /* ElementNode */) {
1453
- const scopeIds = new Set(findScopeIds(parent).filter(Boolean));
1454
- if (scopeIds.size) {
1455
- (_a = element.classList) == null ? void 0 : _a.add(...element["s-scs"] = [...scopeIds]);
1456
- if (element["s-ol"] || iterateChildNodes) {
1457
- for (const childNode of Array.from(element.childNodes)) {
1458
- updateElementScopeIds(childNode, element, true);
1459
- }
1460
- }
1461
- }
1462
- }
1463
- };
1464
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1465
- var _a, _b, _c, _d, _e;
1466
- const hostElm = hostRef.$hostElement$;
1467
- const cmpMeta = hostRef.$cmpMeta$;
1468
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1469
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1470
- hostTagName = hostElm.tagName;
1471
- if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1472
- throw new Error(`The <Host> must be the single root component.
1473
- Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1474
-
1475
- The render() function should look like this instead:
1476
-
1477
- render() {
1478
- // Do not return an array
1479
- return (
1480
- <Host>{content}</Host>
1481
- );
1482
- }
1483
- `);
1484
- }
1485
- if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1486
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1487
- cmpMeta.$attrsToReflect$.map(
1488
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
1489
- );
1490
- }
1491
- if (isInitialLoad && rootVnode.$attrs$) {
1492
- for (const key of Object.keys(rootVnode.$attrs$)) {
1493
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
1494
- rootVnode.$attrs$[key] = hostElm[key];
1495
- }
1496
- }
1497
- }
1498
- rootVnode.$tag$ = null;
1499
- rootVnode.$flags$ |= 4 /* isHost */;
1500
- hostRef.$vnode$ = rootVnode;
1501
- rootVnode.$elm$ = oldVNode.$elm$ = BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
1502
- if (BUILD.scoped || BUILD.shadowDom) {
1503
- scopeId = hostElm["s-sc"];
1504
- }
1505
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1506
- if (BUILD.slotRelocation) {
1507
- contentRef = hostElm["s-cr"];
1508
- checkSlotFallbackVisibility = false;
1509
- }
1510
- patch(oldVNode, rootVnode, isInitialLoad);
1511
- if (BUILD.slotRelocation) {
1512
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1513
- if (checkSlotRelocate) {
1514
- markSlotContentForRelocation(rootVnode.$elm$);
1515
- for (const relocateData of relocateNodes) {
1516
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1517
- if (!nodeToRelocate["s-ol"]) {
1518
- const orgLocationNode = BUILD.isDebug || BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1519
- orgLocationNode["s-nr"] = nodeToRelocate;
1520
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1521
- }
1522
- }
1523
- for (const relocateData of relocateNodes) {
1524
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1525
- const slotRefNode = relocateData.$slotRefNode$;
1526
- if (slotRefNode) {
1527
- const parentNodeRef = slotRefNode.parentNode;
1528
- let insertBeforeNode = slotRefNode.nextSibling;
1529
- if (!BUILD.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */) {
1530
- let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
1531
- while (orgLocationNode) {
1532
- let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
1533
- if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
1534
- refNode = refNode.nextSibling;
1535
- while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1536
- refNode = refNode == null ? void 0 : refNode.nextSibling;
1537
- }
1538
- if (!refNode || !refNode["s-nr"]) {
1539
- insertBeforeNode = refNode;
1540
- break;
1541
- }
1542
- }
1543
- orgLocationNode = orgLocationNode.previousSibling;
1544
- }
1545
- }
1546
- if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
1547
- if (nodeToRelocate !== insertBeforeNode) {
1548
- if (!BUILD.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1549
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1550
- }
1551
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1552
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1553
- nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1554
- }
1555
- }
1556
- }
1557
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1558
- } else {
1559
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1560
- if (isInitialLoad) {
1561
- nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
1562
- }
1563
- nodeToRelocate.hidden = true;
1564
- }
1565
- }
1566
- }
1567
- }
1568
- if (checkSlotFallbackVisibility) {
1569
- updateFallbackSlotVisibility(rootVnode.$elm$);
1570
- }
1571
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1572
- relocateNodes.length = 0;
1573
- }
1574
- if (BUILD.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1575
- for (const childNode of rootVnode.$elm$.childNodes) {
1576
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1577
- if (isInitialLoad && childNode["s-ih"] == null) {
1578
- childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1579
- }
1580
- childNode.hidden = true;
1581
- }
1582
- }
1583
- }
1584
- contentRef = void 0;
1585
- };
1586
- var slotReferenceDebugNode = (slotVNode) => doc.createComment(
1587
- `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
1588
- );
1589
- var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
1590
- `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
1591
- );
1592
-
1593
- // src/runtime/update-component.ts
1594
- var attachToAncestor = (hostRef, ancestorComponent) => {
1595
- if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
1596
- ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
1597
- }
1598
- };
1599
- var scheduleUpdate = (hostRef, isInitialLoad) => {
1600
- if (BUILD.taskQueue && BUILD.updatable) {
1601
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1602
- }
1603
- if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1604
- hostRef.$flags$ |= 512 /* needsRerender */;
1605
- return;
1606
- }
1607
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1608
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1609
- return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1610
- };
1611
- var dispatchHooks = (hostRef, isInitialLoad) => {
1612
- const elm = hostRef.$hostElement$;
1613
- const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
1614
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1615
- if (!instance) {
1616
- throw new Error(
1617
- `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`
1618
- );
1619
- }
1620
- let maybePromise;
1621
- if (isInitialLoad) {
1622
- if (BUILD.lazyLoad && BUILD.hostListener) {
1623
- hostRef.$flags$ |= 256 /* isListenReady */;
1624
- if (hostRef.$queuedListeners$) {
1625
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1626
- hostRef.$queuedListeners$ = void 0;
1627
- }
1628
- }
1629
- emitLifecycleEvent(elm, "componentWillLoad");
1630
- if (BUILD.cmpWillLoad) {
1631
- maybePromise = safeCall(instance, "componentWillLoad");
1632
- }
1633
- } else {
1634
- emitLifecycleEvent(elm, "componentWillUpdate");
1635
- if (BUILD.cmpWillUpdate) {
1636
- maybePromise = safeCall(instance, "componentWillUpdate");
1637
- }
1638
- }
1639
- emitLifecycleEvent(elm, "componentWillRender");
1640
- if (BUILD.cmpWillRender) {
1641
- maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender"));
1642
- }
1643
- endSchedule();
1644
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1645
- };
1646
- var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
1647
- console.error(err2);
1648
- fn();
1649
- }) : fn();
1650
- var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
1651
- var updateComponent = async (hostRef, instance, isInitialLoad) => {
1652
- var _a;
1653
- const elm = hostRef.$hostElement$;
1654
- const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
1655
- const rc = elm["s-rc"];
1656
- if (BUILD.style && isInitialLoad) {
1657
- attachStyles(hostRef);
1658
- }
1659
- const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
1660
- if (BUILD.isDev) {
1661
- hostRef.$flags$ |= 1024 /* devOnRender */;
1662
- }
1663
- if (BUILD.hydrateServerSide) {
1664
- await callRender(hostRef, instance, elm, isInitialLoad);
1665
- } else {
1666
- callRender(hostRef, instance, elm, isInitialLoad);
1667
- }
1668
- if (BUILD.isDev) {
1669
- hostRef.$renderCount$ = hostRef.$renderCount$ === void 0 ? 1 : hostRef.$renderCount$ + 1;
1670
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1671
- }
1672
- if (BUILD.hydrateServerSide) {
1673
- try {
1674
- serverSideConnected(elm);
1675
- if (isInitialLoad) {
1676
- if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1677
- elm["s-en"] = "";
1678
- } else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
1679
- elm["s-en"] = "c";
1680
- }
1681
- }
1682
- } catch (e) {
1683
- consoleError(e, elm);
1684
- }
1685
- }
1686
- if (BUILD.asyncLoading && rc) {
1687
- rc.map((cb) => cb());
1688
- elm["s-rc"] = void 0;
1689
- }
1690
- endRender();
1691
- endUpdate();
1692
- if (BUILD.asyncLoading) {
1693
- const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
1694
- const postUpdate = () => postUpdateComponent(hostRef);
1695
- if (childrenPromises.length === 0) {
1696
- postUpdate();
1697
- } else {
1698
- Promise.all(childrenPromises).then(postUpdate);
1699
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1700
- childrenPromises.length = 0;
1701
- }
1702
- } else {
1703
- postUpdateComponent(hostRef);
1704
- }
1705
- };
1706
- var renderingRef = null;
1707
- var callRender = (hostRef, instance, elm, isInitialLoad) => {
1708
- const allRenderFn = BUILD.allRenderFn ? true : false;
1709
- const lazyLoad = BUILD.lazyLoad ? true : false;
1710
- const taskQueue = BUILD.taskQueue ? true : false;
1711
- const updatable = BUILD.updatable ? true : false;
1712
- try {
1713
- renderingRef = instance;
1714
- instance = allRenderFn ? instance.render() : instance.render && instance.render();
1715
- if (updatable && taskQueue) {
1716
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1717
- }
1718
- if (updatable || lazyLoad) {
1719
- hostRef.$flags$ |= 2 /* hasRendered */;
1720
- }
1721
- if (BUILD.hasRenderFn || BUILD.reflect) {
1722
- if (BUILD.vdomRender || BUILD.reflect) {
1723
- if (BUILD.hydrateServerSide) {
1724
- return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
1725
- } else {
1726
- renderVdom(hostRef, instance, isInitialLoad);
1727
- }
1728
- } else {
1729
- const shadowRoot = elm.shadowRoot;
1730
- if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1731
- shadowRoot.textContent = instance;
1732
- } else {
1733
- elm.textContent = instance;
1734
- }
1735
- }
1736
- }
1737
- } catch (e) {
1738
- consoleError(e, hostRef.$hostElement$);
1739
- }
1740
- renderingRef = null;
1741
- return null;
1742
- };
1743
- var getRenderingRef = () => renderingRef;
1744
- var postUpdateComponent = (hostRef) => {
1745
- const tagName = hostRef.$cmpMeta$.$tagName$;
1746
- const elm = hostRef.$hostElement$;
1747
- const endPostUpdate = createTime("postUpdate", tagName);
1748
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1749
- const ancestorComponent = hostRef.$ancestorComponent$;
1750
- if (BUILD.cmpDidRender) {
1751
- if (BUILD.isDev) {
1752
- hostRef.$flags$ |= 1024 /* devOnRender */;
1753
- }
1754
- safeCall(instance, "componentDidRender");
1755
- if (BUILD.isDev) {
1756
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1757
- }
1758
- }
1759
- emitLifecycleEvent(elm, "componentDidRender");
1760
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1761
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1762
- if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1763
- addHydratedFlag(elm);
1764
- }
1765
- if (BUILD.cmpDidLoad) {
1766
- if (BUILD.isDev) {
1767
- hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1768
- }
1769
- safeCall(instance, "componentDidLoad");
1770
- if (BUILD.isDev) {
1771
- hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1772
- }
1773
- }
1774
- emitLifecycleEvent(elm, "componentDidLoad");
1775
- endPostUpdate();
1776
- if (BUILD.asyncLoading) {
1777
- hostRef.$onReadyResolve$(elm);
1778
- if (!ancestorComponent) {
1779
- appDidLoad(tagName);
1780
- }
1781
- }
1782
- } else {
1783
- if (BUILD.cmpDidUpdate) {
1784
- if (BUILD.isDev) {
1785
- hostRef.$flags$ |= 1024 /* devOnRender */;
1786
- }
1787
- safeCall(instance, "componentDidUpdate");
1788
- if (BUILD.isDev) {
1789
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1790
- }
1791
- }
1792
- emitLifecycleEvent(elm, "componentDidUpdate");
1793
- endPostUpdate();
1794
- }
1795
- if (BUILD.method && BUILD.lazyLoad) {
1796
- hostRef.$onInstanceResolve$(elm);
1797
- }
1798
- if (BUILD.asyncLoading) {
1799
- if (hostRef.$onRenderResolve$) {
1800
- hostRef.$onRenderResolve$();
1801
- hostRef.$onRenderResolve$ = void 0;
1802
- }
1803
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1804
- nextTick(() => scheduleUpdate(hostRef, false));
1805
- }
1806
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1807
- }
1808
- };
1809
- var forceUpdate = (ref) => {
1810
- if (BUILD.updatable && (Build.isBrowser || Build.isTesting)) {
1811
- const hostRef = getHostRef(ref);
1812
- const isConnected = hostRef.$hostElement$.isConnected;
1813
- if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1814
- scheduleUpdate(hostRef, false);
1815
- }
1816
- return isConnected;
1817
- }
1818
- return false;
1819
- };
1820
- var appDidLoad = (who) => {
1821
- if (BUILD.cssAnnotations) {
1822
- addHydratedFlag(doc.documentElement);
1823
- }
1824
- if (BUILD.asyncQueue) {
1825
- plt.$flags$ |= 2 /* appLoaded */;
1826
- }
1827
- nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
1828
- if (BUILD.profile && performance.measure) {
1829
- performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, "st:app:start");
1830
- }
1831
- };
1832
- var safeCall = (instance, method, arg) => {
1833
- if (instance && instance[method]) {
1834
- try {
1835
- return instance[method](arg);
1836
- } catch (e) {
1837
- consoleError(e);
1838
- }
1839
- }
1840
- return void 0;
1841
- };
1842
- var emitLifecycleEvent = (elm, lifecycleName) => {
1843
- if (BUILD.lifecycleDOMEvents) {
1844
- emitEvent(elm, "stencil_" + lifecycleName, {
1845
- bubbles: true,
1846
- composed: true,
1847
- detail: {
1848
- namespace: NAMESPACE
1849
- }
1850
- });
1851
- }
1852
- };
1853
- var addHydratedFlag = (elm) => {
1854
- var _a, _b;
1855
- return BUILD.hydratedClass ? elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") : BUILD.hydratedAttribute ? elm.setAttribute((_b = BUILD.hydratedSelectorName) != null ? _b : "hydrated", "") : void 0;
1856
- };
1857
- var serverSideConnected = (elm) => {
1858
- const children = elm.children;
1859
- if (children != null) {
1860
- for (let i2 = 0, ii = children.length; i2 < ii; i2++) {
1861
- const childElm = children[i2];
1862
- if (typeof childElm.connectedCallback === "function") {
1863
- childElm.connectedCallback();
1864
- }
1865
- serverSideConnected(childElm);
1866
- }
1867
- }
1868
- };
1869
-
1870
- // src/runtime/set-value.ts
1871
- var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1872
- var setValue = (ref, propName, newVal, cmpMeta) => {
1873
- const hostRef = getHostRef(ref);
1874
- if (BUILD.lazyLoad && !hostRef) {
1875
- throw new Error(
1876
- `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/ionic-team/stencil/issues/5457).`
1877
- );
1878
- }
1879
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1880
- const oldVal = hostRef.$instanceValues$.get(propName);
1881
- const flags = hostRef.$flags$;
1882
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1883
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1884
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1885
- const didValueChange = newVal !== oldVal && !areBothNaN;
1886
- if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
1887
- hostRef.$instanceValues$.set(propName, newVal);
1888
- if (BUILD.isDev) {
1889
- if (hostRef.$flags$ & 1024 /* devOnRender */) {
1890
- consoleDevWarn(
1891
- `The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`,
1892
- "\nElement",
1893
- elm,
1894
- "\nNew value",
1895
- newVal,
1896
- "\nOld value",
1897
- oldVal
1898
- );
1899
- } else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
1900
- consoleDevWarn(
1901
- `The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`,
1902
- "\nElement",
1903
- elm,
1904
- "\nNew value",
1905
- newVal,
1906
- "\nOld value",
1907
- oldVal
1908
- );
1909
- }
1910
- }
1911
- if (!BUILD.lazyLoad || instance) {
1912
- if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1913
- const watchMethods = cmpMeta.$watchers$[propName];
1914
- if (watchMethods) {
1915
- watchMethods.map((watchMethodName) => {
1916
- try {
1917
- instance[watchMethodName](newVal, oldVal, propName);
1918
- } catch (e) {
1919
- consoleError(e, elm);
1920
- }
1921
- });
1922
- }
1923
- }
1924
- if (BUILD.updatable && (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1925
- if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1926
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1927
- return;
1928
- }
1929
- }
1930
- scheduleUpdate(hostRef, false);
1931
- }
1932
- }
1933
- }
1934
- };
1935
-
1936
- // src/runtime/proxy-component.ts
1937
- var proxyComponent = (Cstr, cmpMeta, flags) => {
1938
- var _a, _b;
1939
- const prototype = Cstr.prototype;
1940
- if (BUILD.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
1941
- FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach(
1942
- (cbName) => Object.defineProperty(prototype, cbName, {
1943
- value(...args) {
1944
- const hostRef = getHostRef(this);
1945
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : this;
1946
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1947
- if (!instance) {
1948
- hostRef.$onReadyPromise$.then((instance2) => {
1949
- const cb = instance2[cbName];
1950
- typeof cb === "function" && cb.call(instance2, ...args);
1951
- });
1952
- } else {
1953
- const cb = instance[cbName];
1954
- typeof cb === "function" && cb.call(instance, ...args);
1955
- }
1956
- }
1957
- })
1958
- );
1959
- }
1960
- if (BUILD.member && cmpMeta.$members$ || BUILD.watchCallback && (cmpMeta.$watchers$ || Cstr.watchers)) {
1961
- if (BUILD.watchCallback && Cstr.watchers && !cmpMeta.$watchers$) {
1962
- cmpMeta.$watchers$ = Cstr.watchers;
1963
- }
1964
- const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
1965
- members.map(([memberName, [memberFlags]]) => {
1966
- if ((BUILD.prop || BUILD.state) && (memberFlags & 31 /* Prop */ || (!BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
1967
- Object.defineProperty(prototype, memberName, {
1968
- get() {
1969
- return getValue(this, memberName);
1970
- },
1971
- set(newValue) {
1972
- if (BUILD.isDev) {
1973
- const ref = getHostRef(this);
1974
- if (
1975
- // we are proxying the instance (not element)
1976
- (flags & 1 /* isElementConstructor */) === 0 && // the element is not constructing
1977
- (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
1978
- (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
1979
- (memberFlags & 1024 /* Mutable */) === 0
1980
- ) {
1981
- consoleDevWarn(
1982
- `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
1983
- More information: https://stenciljs.com/docs/properties#prop-mutability`
1984
- );
1985
- }
1986
- }
1987
- setValue(this, memberName, newValue, cmpMeta);
1988
- },
1989
- configurable: true,
1990
- enumerable: true
1991
- });
1992
- } else if (BUILD.lazyLoad && BUILD.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1993
- Object.defineProperty(prototype, memberName, {
1994
- value(...args) {
1995
- var _a2;
1996
- const ref = getHostRef(this);
1997
- return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
1998
- var _a3;
1999
- return (_a3 = ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
2000
- });
2001
- }
2002
- });
2003
- }
2004
- });
2005
- if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
2006
- const attrNameToPropName = /* @__PURE__ */ new Map();
2007
- prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
2008
- plt.jmp(() => {
2009
- var _a2;
2010
- const propName = attrNameToPropName.get(attrName);
2011
- if (this.hasOwnProperty(propName)) {
2012
- newValue = this[propName];
2013
- delete this[propName];
2014
- } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
2015
- this[propName] == newValue) {
2016
- return;
2017
- } else if (propName == null) {
2018
- const hostRef = getHostRef(this);
2019
- const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
2020
- if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
2021
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : this;
2022
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2023
- const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
2024
- entry == null ? void 0 : entry.forEach((callbackName) => {
2025
- if (instance[callbackName] != null) {
2026
- instance[callbackName].call(instance, newValue, oldValue, attrName);
2027
- }
2028
- });
2029
- }
2030
- return;
2031
- }
2032
- this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2033
- });
2034
- };
2035
- Cstr.observedAttributes = Array.from(
2036
- /* @__PURE__ */ new Set([
2037
- ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
2038
- ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
2039
- var _a2;
2040
- const attrName = m[1] || propName;
2041
- attrNameToPropName.set(attrName, propName);
2042
- if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
2043
- (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
2044
- }
2045
- return attrName;
2046
- })
2047
- ])
2048
- );
2049
- }
2050
- }
2051
- return Cstr;
2052
- };
2053
-
2054
- // src/runtime/initialize-component.ts
2055
- var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2056
- let Cstr;
2057
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2058
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2059
- const bundleId = cmpMeta.$lazyBundleId$;
2060
- if ((BUILD.lazyLoad || BUILD.hydrateClientSide) && bundleId) {
2061
- const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
2062
- if (CstrImport && "then" in CstrImport) {
2063
- const endLoad = uniqueTime(
2064
- `st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`,
2065
- `[Stencil] Load module for <${cmpMeta.$tagName$}>`
2066
- );
2067
- Cstr = await CstrImport;
2068
- endLoad();
2069
- } else {
2070
- Cstr = CstrImport;
2071
- }
2072
- if (!Cstr) {
2073
- throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2074
- }
2075
- if (BUILD.member && !Cstr.isProxied) {
2076
- if (BUILD.watchCallback) {
2077
- cmpMeta.$watchers$ = Cstr.watchers;
2078
- }
2079
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
2080
- Cstr.isProxied = true;
2081
- }
2082
- const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
2083
- if (BUILD.member) {
2084
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
2085
- }
2086
- try {
2087
- new Cstr(hostRef);
2088
- } catch (e) {
2089
- consoleError(e);
2090
- }
2091
- if (BUILD.member) {
2092
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
2093
- }
2094
- if (BUILD.watchCallback) {
2095
- hostRef.$flags$ |= 128 /* isWatchReady */;
2096
- }
2097
- endNewInstance();
2098
- fireConnectedCallback(hostRef.$lazyInstance$);
2099
- } else {
2100
- Cstr = elm.constructor;
2101
- const cmpTag = elm.localName;
2102
- customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
2103
- }
2104
- if (BUILD.style && Cstr && Cstr.style) {
2105
- let style;
2106
- if (typeof Cstr.style === "string") {
2107
- style = Cstr.style;
2108
- } else if (BUILD.mode && typeof Cstr.style !== "string") {
2109
- hostRef.$modeName$ = computeMode(elm);
2110
- if (hostRef.$modeName$) {
2111
- style = Cstr.style[hostRef.$modeName$];
2112
- }
2113
- if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2114
- elm.setAttribute("s-mode", hostRef.$modeName$);
2115
- }
2116
- }
2117
- const scopeId2 = getScopeId(cmpMeta, hostRef.$modeName$);
2118
- if (!styles.has(scopeId2)) {
2119
- const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
2120
- if (!BUILD.hydrateServerSide && BUILD.shadowDom && // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2121
- BUILD.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2122
- style = await import('./shadow-css-7ad5caf8.js').then((m) => m.scopeCss(style, scopeId2));
2123
- }
2124
- registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2125
- endRegisterStyles();
2126
- }
2127
- }
2128
- }
2129
- const ancestorComponent = hostRef.$ancestorComponent$;
2130
- const schedule = () => scheduleUpdate(hostRef, true);
2131
- if (BUILD.asyncLoading && ancestorComponent && ancestorComponent["s-rc"]) {
2132
- ancestorComponent["s-rc"].push(schedule);
2133
- } else {
2134
- schedule();
2135
- }
2136
- };
2137
- var fireConnectedCallback = (instance) => {
2138
- if (BUILD.lazyLoad && BUILD.connectedCallback) {
2139
- safeCall(instance, "connectedCallback");
2140
- }
2141
- };
2142
-
2143
- // src/runtime/connected-callback.ts
2144
- var connectedCallback = (elm) => {
2145
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2146
- const hostRef = getHostRef(elm);
2147
- const cmpMeta = hostRef.$cmpMeta$;
2148
- const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
2149
- if (BUILD.hostListenerTargetParent) {
2150
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2151
- }
2152
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2153
- hostRef.$flags$ |= 1 /* hasConnected */;
2154
- let hostId;
2155
- if (BUILD.hydrateClientSide) {
2156
- hostId = elm.getAttribute(HYDRATE_ID);
2157
- if (hostId) {
2158
- if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2159
- const scopeId2 = BUILD.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute("s-mode")) : addStyle(elm.shadowRoot, cmpMeta);
2160
- elm.classList.remove(scopeId2 + "-h", scopeId2 + "-s");
2161
- }
2162
- initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2163
- }
2164
- }
2165
- if (BUILD.slotRelocation && !hostId) {
2166
- if (BUILD.hydrateServerSide || (BUILD.slot || BUILD.shadowDom) && // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2167
- cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
2168
- setContentReference(elm);
2169
- }
2170
- }
2171
- if (BUILD.asyncLoading) {
2172
- let ancestorComponent = elm;
2173
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
2174
- if (BUILD.hydrateClientSide && ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
2175
- attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
2176
- break;
2177
- }
2178
- }
2179
- }
2180
- if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2181
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2182
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2183
- const value = elm[memberName];
2184
- delete elm[memberName];
2185
- elm[memberName] = value;
2186
- }
2187
- });
2188
- }
2189
- if (BUILD.initializeNextTick) {
2190
- nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2191
- } else {
2192
- initializeComponent(elm, hostRef, cmpMeta);
2193
- }
2194
- } else {
2195
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2196
- if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
2197
- fireConnectedCallback(hostRef.$lazyInstance$);
2198
- } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
2199
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
2200
- }
2201
- }
2202
- endConnected();
2203
- }
2204
- };
2205
- var setContentReference = (elm) => {
2206
- const contentRefElm = elm["s-cr"] = doc.createComment(
2207
- BUILD.isDebug ? `content-ref (host=${elm.localName})` : ""
2208
- );
2209
- contentRefElm["s-cn"] = true;
2210
- insertBefore(elm, contentRefElm, elm.firstChild);
2211
- };
2212
- var disconnectInstance = (instance) => {
2213
- if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2214
- safeCall(instance, "disconnectedCallback");
2215
- }
2216
- if (BUILD.cmpDidUnload) {
2217
- safeCall(instance, "componentDidUnload");
2218
- }
2219
- };
2220
- var disconnectedCallback = async (elm) => {
2221
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2222
- const hostRef = getHostRef(elm);
2223
- if (BUILD.hostListener) {
2224
- if (hostRef.$rmListeners$) {
2225
- hostRef.$rmListeners$.map((rmListener) => rmListener());
2226
- hostRef.$rmListeners$ = void 0;
2227
- }
2228
- }
2229
- if (!BUILD.lazyLoad) {
2230
- disconnectInstance(elm);
2231
- } else if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
2232
- disconnectInstance(hostRef.$lazyInstance$);
2233
- } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
2234
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
2235
- }
2236
- }
2237
- };
2238
- var patchPseudoShadowDom = (hostElementPrototype, descriptorPrototype) => {
2239
- patchCloneNode(hostElementPrototype);
2240
- patchSlotAppendChild(hostElementPrototype);
2241
- patchSlotAppend(hostElementPrototype);
2242
- patchSlotPrepend(hostElementPrototype);
2243
- patchSlotInsertAdjacentElement(hostElementPrototype);
2244
- patchSlotInsertAdjacentHTML(hostElementPrototype);
2245
- patchSlotInsertAdjacentText(hostElementPrototype);
2246
- patchTextContent(hostElementPrototype);
2247
- patchChildSlotNodes(hostElementPrototype, descriptorPrototype);
2248
- patchSlotRemoveChild(hostElementPrototype);
2249
- };
2250
- var patchCloneNode = (HostElementPrototype) => {
2251
- const orgCloneNode = HostElementPrototype.cloneNode;
2252
- HostElementPrototype.cloneNode = function(deep) {
2253
- const srcNode = this;
2254
- const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2255
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2256
- if (BUILD.slot && !isShadowDom && deep) {
2257
- let i2 = 0;
2258
- let slotted, nonStencilNode;
2259
- const stencilPrivates = [
2260
- "s-id",
2261
- "s-cr",
2262
- "s-lr",
2263
- "s-rc",
2264
- "s-sc",
2265
- "s-p",
2266
- "s-cn",
2267
- "s-sr",
2268
- "s-sn",
2269
- "s-hn",
2270
- "s-ol",
2271
- "s-nr",
2272
- "s-si",
2273
- "s-rf",
2274
- "s-scs"
2275
- ];
2276
- for (; i2 < srcNode.childNodes.length; i2++) {
2277
- slotted = srcNode.childNodes[i2]["s-nr"];
2278
- nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i2][privateField]);
2279
- if (slotted) {
2280
- if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2281
- clonedNode.__appendChild(slotted.cloneNode(true));
2282
- } else {
2283
- clonedNode.appendChild(slotted.cloneNode(true));
2284
- }
2285
- }
2286
- if (nonStencilNode) {
2287
- clonedNode.appendChild(srcNode.childNodes[i2].cloneNode(true));
2288
- }
2289
- }
2290
- }
2291
- return clonedNode;
2292
- };
2293
- };
2294
- var patchSlotAppendChild = (HostElementPrototype) => {
2295
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2296
- HostElementPrototype.appendChild = function(newChild) {
2297
- const slotName = newChild["s-sn"] = getSlotName(newChild);
2298
- const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
2299
- if (slotNode) {
2300
- const slotPlaceholder = document.createTextNode("");
2301
- slotPlaceholder["s-nr"] = newChild;
2302
- slotNode["s-cr"].parentNode.__appendChild(slotPlaceholder);
2303
- newChild["s-ol"] = slotPlaceholder;
2304
- newChild["s-sh"] = slotNode["s-hn"];
2305
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2306
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2307
- const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2308
- updateFallbackSlotVisibility(this);
2309
- return insertedNode;
2310
- }
2311
- return this.__appendChild(newChild);
2312
- };
2313
- };
2314
- var patchSlotRemoveChild = (ElementPrototype) => {
2315
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
2316
- ElementPrototype.removeChild = function(toRemove) {
2317
- if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
2318
- const slotNode = getHostSlotNode(this.childNodes, toRemove["s-sn"], this.tagName);
2319
- if (slotNode) {
2320
- const slotChildNodes = getHostSlotChildNodes(slotNode, toRemove["s-sn"]);
2321
- const existingNode = slotChildNodes.find((n) => n === toRemove);
2322
- if (existingNode) {
2323
- existingNode.remove();
2324
- updateFallbackSlotVisibility(this);
2325
- return;
2326
- }
2327
- }
2328
- }
2329
- return this.__removeChild(toRemove);
2330
- };
2331
- };
2332
- var patchSlotPrepend = (HostElementPrototype) => {
2333
- const originalPrepend = HostElementPrototype.prepend;
2334
- HostElementPrototype.prepend = function(...newChildren) {
2335
- newChildren.forEach((newChild) => {
2336
- if (typeof newChild === "string") {
2337
- newChild = this.ownerDocument.createTextNode(newChild);
2338
- }
2339
- const slotName = newChild["s-sn"] = getSlotName(newChild);
2340
- const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
2341
- if (slotNode) {
2342
- const slotPlaceholder = document.createTextNode("");
2343
- slotPlaceholder["s-nr"] = newChild;
2344
- slotNode["s-cr"].parentNode.__appendChild(slotPlaceholder);
2345
- newChild["s-ol"] = slotPlaceholder;
2346
- newChild["s-sh"] = slotNode["s-hn"];
2347
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2348
- const appendAfter = slotChildNodes[0];
2349
- return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2350
- }
2351
- if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
2352
- newChild.hidden = true;
2353
- }
2354
- return originalPrepend.call(this, newChild);
2355
- });
2356
- };
2357
- };
2358
- var patchSlotAppend = (HostElementPrototype) => {
2359
- HostElementPrototype.append = function(...newChildren) {
2360
- newChildren.forEach((newChild) => {
2361
- if (typeof newChild === "string") {
2362
- newChild = this.ownerDocument.createTextNode(newChild);
2363
- }
2364
- this.appendChild(newChild);
2365
- });
2366
- };
2367
- };
2368
- var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
2369
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
2370
- HostElementPrototype.insertAdjacentHTML = function(position, text) {
2371
- if (position !== "afterbegin" && position !== "beforeend") {
2372
- return originalInsertAdjacentHtml.call(this, position, text);
2373
- }
2374
- const container = this.ownerDocument.createElement("_");
2375
- let node;
2376
- container.innerHTML = text;
2377
- if (position === "afterbegin") {
2378
- while (node = container.firstChild) {
2379
- this.prepend(node);
2380
- }
2381
- } else if (position === "beforeend") {
2382
- while (node = container.firstChild) {
2383
- this.append(node);
2384
- }
2385
- }
2386
- };
2387
- };
2388
- var patchSlotInsertAdjacentText = (HostElementPrototype) => {
2389
- HostElementPrototype.insertAdjacentText = function(position, text) {
2390
- this.insertAdjacentHTML(position, text);
2391
- };
2392
- };
2393
- var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
2394
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
2395
- HostElementPrototype.insertAdjacentElement = function(position, element) {
2396
- if (position !== "afterbegin" && position !== "beforeend") {
2397
- return originalInsertAdjacentElement.call(this, position, element);
2398
- }
2399
- if (position === "afterbegin") {
2400
- this.prepend(element);
2401
- return element;
2402
- } else if (position === "beforeend") {
2403
- this.append(element);
2404
- return element;
2405
- }
2406
- return element;
2407
- };
2408
- };
2409
- var patchTextContent = (hostElementPrototype) => {
2410
- const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, "textContent");
2411
- Object.defineProperty(hostElementPrototype, "__textContent", descriptor);
2412
- if (BUILD.experimentalScopedSlotChanges) {
2413
- Object.defineProperty(hostElementPrototype, "textContent", {
2414
- // To mimic shadow root behavior, we need to return the text content of all
2415
- // nodes in a slot reference node
2416
- get() {
2417
- const slotRefNodes = getAllChildSlotNodes(this.childNodes);
2418
- const textContent = slotRefNodes.map((node) => {
2419
- var _a, _b;
2420
- const text = [];
2421
- let slotContent = node.nextSibling;
2422
- while (slotContent && slotContent["s-sn"] === node["s-sn"]) {
2423
- if (slotContent.nodeType === 3 /* TEXT_NODE */ || slotContent.nodeType === 1 /* ELEMENT_NODE */) {
2424
- text.push((_b = (_a = slotContent.textContent) == null ? void 0 : _a.trim()) != null ? _b : "");
2425
- }
2426
- slotContent = slotContent.nextSibling;
2427
- }
2428
- return text.filter((ref) => ref !== "").join(" ");
2429
- }).filter((text) => text !== "").join(" ");
2430
- return " " + textContent + " ";
2431
- },
2432
- // To mimic shadow root behavior, we need to overwrite all nodes in a slot
2433
- // reference node. If a default slot reference node exists, the text content will be
2434
- // placed there. Otherwise, the new text node will be hidden
2435
- set(value) {
2436
- const slotRefNodes = getAllChildSlotNodes(this.childNodes);
2437
- slotRefNodes.forEach((node) => {
2438
- let slotContent = node.nextSibling;
2439
- while (slotContent && slotContent["s-sn"] === node["s-sn"]) {
2440
- const tmp = slotContent;
2441
- slotContent = slotContent.nextSibling;
2442
- tmp.remove();
2443
- }
2444
- if (node["s-sn"] === "") {
2445
- const textNode = this.ownerDocument.createTextNode(value);
2446
- textNode["s-sn"] = "";
2447
- insertBefore(node.parentElement, textNode, node.nextSibling);
2448
- } else {
2449
- node.remove();
2450
- }
2451
- });
2452
- }
2453
- });
2454
- } else {
2455
- Object.defineProperty(hostElementPrototype, "textContent", {
2456
- get() {
2457
- var _a;
2458
- const slotNode = getHostSlotNode(this.childNodes, "", this.tagName);
2459
- if (((_a = slotNode == null ? void 0 : slotNode.nextSibling) == null ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2460
- return slotNode.nextSibling.textContent;
2461
- } else if (slotNode) {
2462
- return slotNode.textContent;
2463
- } else {
2464
- return this.__textContent;
2465
- }
2466
- },
2467
- set(value) {
2468
- var _a;
2469
- const slotNode = getHostSlotNode(this.childNodes, "", this.tagName);
2470
- if (((_a = slotNode == null ? void 0 : slotNode.nextSibling) == null ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2471
- slotNode.nextSibling.textContent = value;
2472
- } else if (slotNode) {
2473
- slotNode.textContent = value;
2474
- } else {
2475
- this.__textContent = value;
2476
- const contentRefElm = this["s-cr"];
2477
- if (contentRefElm) {
2478
- insertBefore(this, contentRefElm, this.firstChild);
2479
- }
2480
- }
2481
- }
2482
- });
2483
- }
2484
- };
2485
- var patchChildSlotNodes = (elm, cmpMeta) => {
2486
- class FakeNodeList extends Array {
2487
- item(n) {
2488
- return this[n];
2489
- }
2490
- }
2491
- if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2492
- const childNodesFn = elm.__lookupGetter__("childNodes");
2493
- Object.defineProperty(elm, "children", {
2494
- get() {
2495
- return this.childNodes.map((n) => n.nodeType === 1);
2496
- }
2497
- });
2498
- Object.defineProperty(elm, "childElementCount", {
2499
- get() {
2500
- return elm.children.length;
2501
- }
2502
- });
2503
- Object.defineProperty(elm, "childNodes", {
2504
- get() {
2505
- const childNodes = childNodesFn.call(this);
2506
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && getHostRef(this).$flags$ & 2 /* hasRendered */) {
2507
- const result = new FakeNodeList();
2508
- for (let i2 = 0; i2 < childNodes.length; i2++) {
2509
- const slot = childNodes[i2]["s-nr"];
2510
- if (slot) {
2511
- result.push(slot);
2512
- }
2513
- }
2514
- return result;
2515
- }
2516
- return FakeNodeList.from(childNodes);
2517
- }
2518
- });
2519
- }
2520
- };
2521
- var getAllChildSlotNodes = (childNodes) => {
2522
- const slotRefNodes = [];
2523
- for (const childNode of Array.from(childNodes)) {
2524
- if (childNode["s-sr"]) {
2525
- slotRefNodes.push(childNode);
2526
- }
2527
- slotRefNodes.push(...getAllChildSlotNodes(childNode.childNodes));
2528
- }
2529
- return slotRefNodes;
2530
- };
2531
- var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
2532
- var getHostSlotNode = (childNodes, slotName, hostName) => {
2533
- let i2 = 0;
2534
- let childNode;
2535
- for (; i2 < childNodes.length; i2++) {
2536
- childNode = childNodes[i2];
2537
- if (childNode["s-sr"] && childNode["s-sn"] === slotName && childNode["s-hn"] === hostName) {
2538
- return childNode;
2539
- }
2540
- childNode = getHostSlotNode(childNode.childNodes, slotName, hostName);
2541
- if (childNode) {
2542
- return childNode;
2543
- }
2544
- }
2545
- return null;
2546
- };
2547
- var getHostSlotChildNodes = (n, slotName) => {
2548
- const childNodes = [n];
2549
- while ((n = n.nextSibling) && n["s-sn"] === slotName) {
2550
- childNodes.push(n);
2551
- }
2552
- return childNodes;
2553
- };
2554
-
2555
- // src/runtime/bootstrap-custom-element.ts
2556
- var defineCustomElement = (Cstr, compactMeta) => {
2557
- customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2558
- };
2559
- var proxyCustomElement = (Cstr, compactMeta) => {
2560
- const cmpMeta = {
2561
- $flags$: compactMeta[0],
2562
- $tagName$: compactMeta[1]
2563
- };
2564
- if (BUILD.member) {
2565
- cmpMeta.$members$ = compactMeta[2];
2566
- }
2567
- if (BUILD.hostListener) {
2568
- cmpMeta.$listeners$ = compactMeta[3];
2569
- }
2570
- if (BUILD.watchCallback) {
2571
- cmpMeta.$watchers$ = Cstr.$watchers$;
2572
- }
2573
- if (BUILD.reflect) {
2574
- cmpMeta.$attrsToReflect$ = [];
2575
- }
2576
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2577
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2578
- }
2579
- if (BUILD.experimentalSlotFixes) {
2580
- if (BUILD.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2581
- patchPseudoShadowDom(Cstr.prototype, cmpMeta);
2582
- }
2583
- } else {
2584
- if (BUILD.slotChildNodesFix) {
2585
- patchChildSlotNodes(Cstr.prototype, cmpMeta);
2586
- }
2587
- if (BUILD.cloneNodeFix) {
2588
- patchCloneNode(Cstr.prototype);
2589
- }
2590
- if (BUILD.appendChildSlotFix) {
2591
- patchSlotAppendChild(Cstr.prototype);
2592
- }
2593
- if (BUILD.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2594
- patchTextContent(Cstr.prototype);
2595
- }
2596
- }
2597
- const originalConnectedCallback = Cstr.prototype.connectedCallback;
2598
- const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2599
- Object.assign(Cstr.prototype, {
2600
- __registerHost() {
2601
- registerHost(this, cmpMeta);
2602
- },
2603
- connectedCallback() {
2604
- const hostRef = getHostRef(this);
2605
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2606
- connectedCallback(this);
2607
- if (BUILD.connectedCallback && originalConnectedCallback) {
2608
- originalConnectedCallback.call(this);
2609
- }
2610
- },
2611
- disconnectedCallback() {
2612
- disconnectedCallback(this);
2613
- if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2614
- originalDisconnectedCallback.call(this);
2615
- }
2616
- },
2617
- __attachShadow() {
2618
- if (supportsShadow) {
2619
- if (!this.shadowRoot) {
2620
- if (BUILD.shadowDelegatesFocus) {
2621
- this.attachShadow({
2622
- mode: "open",
2623
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2624
- });
2625
- } else {
2626
- this.attachShadow({ mode: "open" });
2627
- }
2628
- } else {
2629
- if (this.shadowRoot.mode !== "open") {
2630
- throw new Error(
2631
- `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
2632
- );
2633
- }
2634
- }
2635
- } else {
2636
- this.shadowRoot = this;
2637
- }
2638
- }
2639
- });
2640
- Cstr.is = cmpMeta.$tagName$;
2641
- return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2642
- };
2643
- var forceModeUpdate = (elm) => {
2644
- if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2645
- const mode = computeMode(elm);
2646
- const hostRef = getHostRef(elm);
2647
- if (hostRef.$modeName$ !== mode) {
2648
- const cmpMeta = hostRef.$cmpMeta$;
2649
- const oldScopeId = elm["s-sc"];
2650
- const scopeId2 = getScopeId(cmpMeta, mode);
2651
- const style = elm.constructor.style[mode];
2652
- const flags = cmpMeta.$flags$;
2653
- if (style) {
2654
- if (!styles.has(scopeId2)) {
2655
- registerStyle(scopeId2, style, !!(flags & 1 /* shadowDomEncapsulation */));
2656
- }
2657
- hostRef.$modeName$ = mode;
2658
- elm.classList.remove(oldScopeId + "-h", oldScopeId + "-s");
2659
- attachStyles(hostRef);
2660
- forceUpdate(elm);
2661
- }
2662
- }
2663
- }
2664
- };
2665
-
2666
- // src/runtime/hmr-component.ts
2667
- var hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
2668
- const hostRef = getHostRef(hostElement);
2669
- hostRef.$flags$ = 1 /* hasConnected */;
2670
- initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
2671
- };
2672
-
2673
- // src/runtime/bootstrap-lazy.ts
2674
- var bootstrapLazy = (lazyBundles, options = {}) => {
2675
- var _a;
2676
- if (BUILD.profile && performance.mark) {
2677
- performance.mark("st:app:start");
2678
- }
2679
- installDevTools();
2680
- const endBootstrap = createTime("bootstrapLazy");
2681
- const cmpTags = [];
2682
- const exclude = options.exclude || [];
2683
- const customElements2 = win.customElements;
2684
- const head = doc.head;
2685
- const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
2686
- const dataStyles = /* @__PURE__ */ doc.createElement("style");
2687
- const deferredConnectedCallbacks = [];
2688
- let appLoadFallback;
2689
- let isBootstrapping = true;
2690
- Object.assign(plt, options);
2691
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", doc.baseURI).href;
2692
- if (BUILD.asyncQueue) {
2693
- if (options.syncQueue) {
2694
- plt.$flags$ |= 4 /* queueSync */;
2695
- }
2696
- }
2697
- if (BUILD.hydrateClientSide) {
2698
- plt.$flags$ |= 2 /* appLoaded */;
2699
- }
2700
- let hasSlotRelocation = false;
2701
- lazyBundles.map((lazyBundle) => {
2702
- lazyBundle[1].map((compactMeta) => {
2703
- var _a2;
2704
- const cmpMeta = {
2705
- $flags$: compactMeta[0],
2706
- $tagName$: compactMeta[1],
2707
- $members$: compactMeta[2],
2708
- $listeners$: compactMeta[3]
2709
- };
2710
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2711
- hasSlotRelocation = true;
2712
- }
2713
- if (BUILD.member) {
2714
- cmpMeta.$members$ = compactMeta[2];
2715
- }
2716
- if (BUILD.hostListener) {
2717
- cmpMeta.$listeners$ = compactMeta[3];
2718
- }
2719
- if (BUILD.reflect) {
2720
- cmpMeta.$attrsToReflect$ = [];
2721
- }
2722
- if (BUILD.watchCallback) {
2723
- cmpMeta.$watchers$ = (_a2 = compactMeta[4]) != null ? _a2 : {};
2724
- }
2725
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2726
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2727
- }
2728
- const tagName = BUILD.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : cmpMeta.$tagName$;
2729
- const HostElement = class extends HTMLElement {
2730
- // StencilLazyHost
2731
- constructor(self) {
2732
- super(self);
2733
- this.hasRegisteredEventListeners = false;
2734
- self = this;
2735
- registerHost(self, cmpMeta);
2736
- if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2737
- if (supportsShadow) {
2738
- if (!self.shadowRoot) {
2739
- if (BUILD.shadowDelegatesFocus) {
2740
- self.attachShadow({
2741
- mode: "open",
2742
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2743
- });
2744
- } else {
2745
- self.attachShadow({ mode: "open" });
2746
- }
2747
- } else {
2748
- if (self.shadowRoot.mode !== "open") {
2749
- throw new Error(
2750
- `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
2751
- );
2752
- }
2753
- }
2754
- } else if (!BUILD.hydrateServerSide && !("shadowRoot" in self)) {
2755
- self.shadowRoot = self;
2756
- }
2757
- }
2758
- }
2759
- connectedCallback() {
2760
- const hostRef = getHostRef(this);
2761
- if (!this.hasRegisteredEventListeners) {
2762
- this.hasRegisteredEventListeners = true;
2763
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2764
- }
2765
- if (appLoadFallback) {
2766
- clearTimeout(appLoadFallback);
2767
- appLoadFallback = null;
2768
- }
2769
- if (isBootstrapping) {
2770
- deferredConnectedCallbacks.push(this);
2771
- } else {
2772
- plt.jmp(() => connectedCallback(this));
2773
- }
2774
- }
2775
- disconnectedCallback() {
2776
- plt.jmp(() => disconnectedCallback(this));
2777
- }
2778
- componentOnReady() {
2779
- return getHostRef(this).$onReadyPromise$;
2780
- }
2781
- };
2782
- if (BUILD.experimentalSlotFixes) {
2783
- if (BUILD.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2784
- patchPseudoShadowDom(HostElement.prototype, cmpMeta);
2785
- }
2786
- } else {
2787
- if (BUILD.slotChildNodesFix) {
2788
- patchChildSlotNodes(HostElement.prototype, cmpMeta);
2789
- }
2790
- if (BUILD.cloneNodeFix) {
2791
- patchCloneNode(HostElement.prototype);
2792
- }
2793
- if (BUILD.appendChildSlotFix) {
2794
- patchSlotAppendChild(HostElement.prototype);
2795
- }
2796
- if (BUILD.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2797
- patchTextContent(HostElement.prototype);
2798
- }
2799
- }
2800
- if (BUILD.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */) {
2801
- HostElement.formAssociated = true;
2802
- }
2803
- if (BUILD.hotModuleReplacement) {
2804
- HostElement.prototype["s-hmr"] = function(hmrVersionId) {
2805
- hmrStart(this, cmpMeta, hmrVersionId);
2806
- };
2807
- }
2808
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
2809
- if (!exclude.includes(tagName) && !customElements2.get(tagName)) {
2810
- cmpTags.push(tagName);
2811
- customElements2.define(
2812
- tagName,
2813
- proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */)
2814
- );
2815
- }
2816
- });
2817
- });
2818
- if (cmpTags.length > 0) {
2819
- if (hasSlotRelocation) {
2820
- dataStyles.textContent += SLOT_FB_CSS;
2821
- }
2822
- if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2823
- dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
2824
- }
2825
- if (dataStyles.innerHTML.length) {
2826
- dataStyles.setAttribute("data-styles", "");
2827
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
2828
- if (nonce != null) {
2829
- dataStyles.setAttribute("nonce", nonce);
2830
- }
2831
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
2832
- }
2833
- }
2834
- isBootstrapping = false;
2835
- if (deferredConnectedCallbacks.length) {
2836
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
2837
- } else {
2838
- if (BUILD.profile) {
2839
- plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30, "timeout"));
2840
- } else {
2841
- plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
2842
- }
2843
- }
2844
- endBootstrap();
2845
- };
2846
-
2847
- // src/runtime/fragment.ts
2848
- var Fragment = (_, children) => children;
2849
- var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2850
- if (BUILD.hostListener && listeners) {
2851
- if (BUILD.hostListenerTargetParent) {
2852
- if (attachParentListeners) {
2853
- listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
2854
- } else {
2855
- listeners = listeners.filter(([flags]) => !(flags & 32 /* TargetParent */));
2856
- }
2857
- }
2858
- listeners.map(([flags, name, method]) => {
2859
- const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
2860
- const handler = hostListenerProxy(hostRef, method);
2861
- const opts = hostListenerOpts(flags);
2862
- plt.ael(target, name, handler, opts);
2863
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2864
- });
2865
- }
2866
- };
2867
- var hostListenerProxy = (hostRef, methodName) => (ev) => {
2868
- var _a;
2869
- try {
2870
- if (BUILD.lazyLoad) {
2871
- if (hostRef.$flags$ & 256 /* isListenReady */) {
2872
- (_a = hostRef.$lazyInstance$) == null ? void 0 : _a[methodName](ev);
2873
- } else {
2874
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2875
- }
2876
- } else {
2877
- hostRef.$hostElement$[methodName](ev);
2878
- }
2879
- } catch (e) {
2880
- consoleError(e);
2881
- }
2882
- };
2883
- var getHostListenerTarget = (elm, flags) => {
2884
- if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
2885
- if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
2886
- if (BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
2887
- if (BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */ && elm.parentElement)
2888
- return elm.parentElement;
2889
- return elm;
2890
- };
2891
- var hostListenerOpts = (flags) => supportsListenerOptions ? {
2892
- passive: (flags & 1 /* Passive */) !== 0,
2893
- capture: (flags & 2 /* Capture */) !== 0
2894
- } : (flags & 2 /* Capture */) !== 0;
2895
-
2896
- // src/runtime/nonce.ts
2897
- var setNonce = (nonce) => plt.$nonce$ = nonce;
2898
-
2899
- // src/runtime/platform-options.ts
2900
- var setPlatformOptions = (opts) => Object.assign(plt, opts);
2901
-
2902
- // src/runtime/vdom/vdom-annotations.ts
2903
- var insertVdomAnnotations = (doc2, staticComponents) => {
2904
- if (doc2 != null) {
2905
- const docData = STENCIL_DOC_DATA in doc2 ? doc2[STENCIL_DOC_DATA] : { ...DEFAULT_DOC_DATA };
2906
- docData.staticComponents = new Set(staticComponents);
2907
- const orgLocationNodes = [];
2908
- parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
2909
- orgLocationNodes.forEach((orgLocationNode) => {
2910
- var _a;
2911
- if (orgLocationNode != null && orgLocationNode["s-nr"]) {
2912
- const nodeRef = orgLocationNode["s-nr"];
2913
- let hostId = nodeRef["s-host-id"];
2914
- let nodeId = nodeRef["s-node-id"];
2915
- let childId = `${hostId}.${nodeId}`;
2916
- if (hostId == null) {
2917
- hostId = 0;
2918
- docData.rootLevelIds++;
2919
- nodeId = docData.rootLevelIds;
2920
- childId = `${hostId}.${nodeId}`;
2921
- if (nodeRef.nodeType === 1 /* ElementNode */) {
2922
- nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2923
- } else if (nodeRef.nodeType === 3 /* TextNode */) {
2924
- if (hostId === 0) {
2925
- const textContent = (_a = nodeRef.nodeValue) == null ? void 0 : _a.trim();
2926
- if (textContent === "") {
2927
- orgLocationNode.remove();
2928
- return;
2929
- }
2930
- }
2931
- const commentBeforeTextNode = doc2.createComment(childId);
2932
- commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2933
- insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
2934
- }
2935
- }
2936
- let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2937
- const orgLocationParentNode = orgLocationNode.parentElement;
2938
- if (orgLocationParentNode) {
2939
- if (orgLocationParentNode["s-en"] === "") {
2940
- orgLocationNodeId += `.`;
2941
- } else if (orgLocationParentNode["s-en"] === "c") {
2942
- orgLocationNodeId += `.c`;
2943
- }
2944
- }
2945
- orgLocationNode.nodeValue = orgLocationNodeId;
2946
- }
2947
- });
2948
- }
2949
- };
2950
- var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
2951
- var _a;
2952
- if (node == null) {
2953
- return;
2954
- }
2955
- if (node["s-nr"] != null) {
2956
- orgLocationNodes.push(node);
2957
- }
2958
- if (node.nodeType === 1 /* ElementNode */) {
2959
- const childNodes = [...Array.from(node.childNodes), ...Array.from(((_a = node.shadowRoot) == null ? void 0 : _a.childNodes) || [])];
2960
- childNodes.forEach((childNode) => {
2961
- const hostRef = getHostRef(childNode);
2962
- if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
2963
- const cmpData = {
2964
- nodeIds: 0
2965
- };
2966
- insertVNodeAnnotations(doc2, childNode, hostRef.$vnode$, docData, cmpData);
2967
- }
2968
- parseVNodeAnnotations(doc2, childNode, docData, orgLocationNodes);
2969
- });
2970
- }
2971
- };
2972
- var insertVNodeAnnotations = (doc2, hostElm, vnode, docData, cmpData) => {
2973
- if (vnode != null) {
2974
- const hostId = ++docData.hostIds;
2975
- hostElm.setAttribute(HYDRATE_ID, hostId);
2976
- if (hostElm["s-cr"] != null) {
2977
- hostElm["s-cr"].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
2978
- }
2979
- if (vnode.$children$ != null) {
2980
- const depth = 0;
2981
- vnode.$children$.forEach((vnodeChild, index) => {
2982
- insertChildVNodeAnnotations(doc2, vnodeChild, cmpData, hostId, depth, index);
2983
- });
2984
- }
2985
- if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute(HYDRATE_CHILD_ID)) {
2986
- const parent = hostElm.parentElement;
2987
- if (parent && parent.childNodes) {
2988
- const parentChildNodes = Array.from(parent.childNodes);
2989
- const comment = parentChildNodes.find(
2990
- (node) => node.nodeType === 8 /* CommentNode */ && node["s-sr"]
2991
- );
2992
- if (comment) {
2993
- const index = parentChildNodes.indexOf(hostElm) - 1;
2994
- vnode.$elm$.setAttribute(
2995
- HYDRATE_CHILD_ID,
2996
- `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`
2997
- );
2998
- }
2999
- }
3000
- }
3001
- }
3002
- };
3003
- var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, index) => {
3004
- const childElm = vnodeChild.$elm$;
3005
- if (childElm == null) {
3006
- return;
3007
- }
3008
- const nodeId = cmpData.nodeIds++;
3009
- const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3010
- childElm["s-host-id"] = hostId;
3011
- childElm["s-node-id"] = nodeId;
3012
- if (childElm.nodeType === 1 /* ElementNode */) {
3013
- childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3014
- } else if (childElm.nodeType === 3 /* TextNode */) {
3015
- const parentNode = childElm.parentNode;
3016
- const nodeName = parentNode == null ? void 0 : parentNode.nodeName;
3017
- if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
3018
- const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3019
- const commentBeforeTextNode = doc2.createComment(textNodeId);
3020
- insertBefore(parentNode, commentBeforeTextNode, childElm);
3021
- }
3022
- } else if (childElm.nodeType === 8 /* CommentNode */) {
3023
- if (childElm["s-sr"]) {
3024
- const slotName = childElm["s-sn"] || "";
3025
- const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3026
- childElm.nodeValue = slotNodeId;
3027
- }
3028
- }
3029
- if (vnodeChild.$children$ != null) {
3030
- const childDepth = depth + 1;
3031
- vnodeChild.$children$.forEach((vnode, index2) => {
3032
- insertChildVNodeAnnotations(doc2, vnode, cmpData, hostId, childDepth, index2);
3033
- });
3034
- }
3035
- };
3036
-
3037
- export { BUILD as B, H, NAMESPACE as N, createEvent as a, bootstrapLazy as b, consoleDevInfo as c, doc as d, Host as e, h, promiseResolve as p, registerInstance as r, setNonce as s };
3038
-
3039
- //# sourceMappingURL=index-eeb8f9f2.js.map