proto-table-wc 0.0.501 → 0.0.503

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1086 @@
1
+ const NAMESPACE = 'proto-table-wc';
2
+
3
+ /*
4
+ Stencil Client Platform v4.17.0 | MIT Licensed | https://stenciljs.com
5
+ */
6
+ var __defProp = Object.defineProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // src/utils/constants.ts
13
+ var EMPTY_OBJ = {};
14
+ var SVG_NS = "http://www.w3.org/2000/svg";
15
+ var HTML_NS = "http://www.w3.org/1999/xhtml";
16
+
17
+ // src/utils/helpers.ts
18
+ var isDef = (v) => v != null;
19
+ var isComplexType = (o) => {
20
+ o = typeof o;
21
+ return o === "object" || o === "function";
22
+ };
23
+
24
+ // src/utils/query-nonce-meta-tag-content.ts
25
+ function queryNonceMetaTagContent(doc2) {
26
+ var _a, _b, _c;
27
+ 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;
28
+ }
29
+
30
+ // src/utils/result.ts
31
+ var result_exports = {};
32
+ __export(result_exports, {
33
+ err: () => err,
34
+ map: () => map,
35
+ ok: () => ok,
36
+ unwrap: () => unwrap,
37
+ unwrapErr: () => unwrapErr
38
+ });
39
+ var ok = (value) => ({
40
+ isOk: true,
41
+ isErr: false,
42
+ value
43
+ });
44
+ var err = (value) => ({
45
+ isOk: false,
46
+ isErr: true,
47
+ value
48
+ });
49
+ function map(result, fn) {
50
+ if (result.isOk) {
51
+ const val = fn(result.value);
52
+ if (val instanceof Promise) {
53
+ return val.then((newVal) => ok(newVal));
54
+ } else {
55
+ return ok(val);
56
+ }
57
+ }
58
+ if (result.isErr) {
59
+ const value = result.value;
60
+ return err(value);
61
+ }
62
+ throw "should never get here";
63
+ }
64
+ var unwrap = (result) => {
65
+ if (result.isOk) {
66
+ return result.value;
67
+ } else {
68
+ throw result.value;
69
+ }
70
+ };
71
+ var unwrapErr = (result) => {
72
+ if (result.isErr) {
73
+ return result.value;
74
+ } else {
75
+ throw result.value;
76
+ }
77
+ };
78
+ var createTime = (fnName, tagName = "") => {
79
+ {
80
+ return () => {
81
+ return;
82
+ };
83
+ }
84
+ };
85
+ var uniqueTime = (key, measureText) => {
86
+ {
87
+ return () => {
88
+ return;
89
+ };
90
+ }
91
+ };
92
+ var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
93
+ var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
94
+ var h = (nodeName, vnodeData, ...children) => {
95
+ let child = null;
96
+ let key = null;
97
+ let simple = false;
98
+ let lastSimple = false;
99
+ const vNodeChildren = [];
100
+ const walk = (c) => {
101
+ for (let i2 = 0; i2 < c.length; i2++) {
102
+ child = c[i2];
103
+ if (Array.isArray(child)) {
104
+ walk(child);
105
+ } else if (child != null && typeof child !== "boolean") {
106
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
107
+ child = String(child);
108
+ }
109
+ if (simple && lastSimple) {
110
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
111
+ } else {
112
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
113
+ }
114
+ lastSimple = simple;
115
+ }
116
+ }
117
+ };
118
+ walk(children);
119
+ if (vnodeData) {
120
+ if (vnodeData.key) {
121
+ key = vnodeData.key;
122
+ }
123
+ {
124
+ const classData = vnodeData.className || vnodeData.class;
125
+ if (classData) {
126
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
127
+ }
128
+ }
129
+ }
130
+ const vnode = newVNode(nodeName, null);
131
+ vnode.$attrs$ = vnodeData;
132
+ if (vNodeChildren.length > 0) {
133
+ vnode.$children$ = vNodeChildren;
134
+ }
135
+ {
136
+ vnode.$key$ = key;
137
+ }
138
+ return vnode;
139
+ };
140
+ var newVNode = (tag, text) => {
141
+ const vnode = {
142
+ $flags$: 0,
143
+ $tag$: tag,
144
+ $text$: text,
145
+ $elm$: null,
146
+ $children$: null
147
+ };
148
+ {
149
+ vnode.$attrs$ = null;
150
+ }
151
+ {
152
+ vnode.$key$ = null;
153
+ }
154
+ return vnode;
155
+ };
156
+ var Host = {};
157
+ var isHost = (node) => node && node.$tag$ === Host;
158
+ var parsePropertyValue = (propValue, propType) => {
159
+ if (propValue != null && !isComplexType(propValue)) {
160
+ return propValue;
161
+ }
162
+ return propValue;
163
+ };
164
+ var emitEvent = (elm, name, opts) => {
165
+ const ev = plt.ce(name, opts);
166
+ elm.dispatchEvent(ev);
167
+ return ev;
168
+ };
169
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
170
+ var registerStyle = (scopeId2, cssText, allowCS) => {
171
+ let style = styles.get(scopeId2);
172
+ if (supportsConstructableStylesheets && allowCS) {
173
+ style = style || new CSSStyleSheet();
174
+ if (typeof style === "string") {
175
+ style = cssText;
176
+ } else {
177
+ style.replaceSync(cssText);
178
+ }
179
+ } else {
180
+ style = cssText;
181
+ }
182
+ styles.set(scopeId2, style);
183
+ };
184
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
185
+ var _a;
186
+ const scopeId2 = getScopeId(cmpMeta);
187
+ const style = styles.get(scopeId2);
188
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
189
+ if (style) {
190
+ if (typeof style === "string") {
191
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
192
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
193
+ let styleElm;
194
+ if (!appliedStyles) {
195
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
196
+ }
197
+ if (!appliedStyles.has(scopeId2)) {
198
+ {
199
+ styleElm = doc.createElement("style");
200
+ styleElm.innerHTML = style;
201
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
202
+ if (nonce != null) {
203
+ styleElm.setAttribute("nonce", nonce);
204
+ }
205
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector("link"));
206
+ }
207
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
208
+ styleElm.innerHTML += SLOT_FB_CSS;
209
+ }
210
+ if (appliedStyles) {
211
+ appliedStyles.add(scopeId2);
212
+ }
213
+ }
214
+ } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
215
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
216
+ }
217
+ }
218
+ return scopeId2;
219
+ };
220
+ var attachStyles = (hostRef) => {
221
+ const cmpMeta = hostRef.$cmpMeta$;
222
+ const elm = hostRef.$hostElement$;
223
+ const flags = cmpMeta.$flags$;
224
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
225
+ const scopeId2 = addStyle(
226
+ elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
227
+ cmpMeta);
228
+ if (flags & 10 /* needsScopedEncapsulation */) {
229
+ elm["s-sc"] = scopeId2;
230
+ elm.classList.add(scopeId2 + "-h");
231
+ }
232
+ endAttachStyles();
233
+ };
234
+ var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
235
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
236
+ if (oldValue !== newValue) {
237
+ let isProp = isMemberInElement(elm, memberName);
238
+ let ln = memberName.toLowerCase();
239
+ if (memberName === "class") {
240
+ const classList = elm.classList;
241
+ const oldClasses = parseClassList(oldValue);
242
+ const newClasses = parseClassList(newValue);
243
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
244
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
245
+ } else if (memberName === "key") ; else if (memberName === "ref") {
246
+ if (newValue) {
247
+ newValue(elm);
248
+ }
249
+ } else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
250
+ if (memberName[2] === "-") {
251
+ memberName = memberName.slice(3);
252
+ } else if (isMemberInElement(win, ln)) {
253
+ memberName = ln.slice(2);
254
+ } else {
255
+ memberName = ln[2] + memberName.slice(3);
256
+ }
257
+ if (oldValue || newValue) {
258
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
259
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
260
+ if (oldValue) {
261
+ plt.rel(elm, memberName, oldValue, capture);
262
+ }
263
+ if (newValue) {
264
+ plt.ael(elm, memberName, newValue, capture);
265
+ }
266
+ }
267
+ } else {
268
+ const isComplex = isComplexType(newValue);
269
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
270
+ try {
271
+ if (!elm.tagName.includes("-")) {
272
+ const n = newValue == null ? "" : newValue;
273
+ if (memberName === "list") {
274
+ isProp = false;
275
+ } else if (oldValue == null || elm[memberName] != n) {
276
+ elm[memberName] = n;
277
+ }
278
+ } else {
279
+ elm[memberName] = newValue;
280
+ }
281
+ } catch (e) {
282
+ }
283
+ }
284
+ if (newValue == null || newValue === false) {
285
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
286
+ {
287
+ elm.removeAttribute(memberName);
288
+ }
289
+ }
290
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
291
+ newValue = newValue === true ? "" : newValue;
292
+ {
293
+ elm.setAttribute(memberName, newValue);
294
+ }
295
+ }
296
+ }
297
+ }
298
+ };
299
+ var parseClassListRegex = /\s/;
300
+ var parseClassList = (value) => !value ? [] : value.split(parseClassListRegex);
301
+ var CAPTURE_EVENT_SUFFIX = "Capture";
302
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
303
+
304
+ // src/runtime/vdom/update-element.ts
305
+ var updateElement = (oldVnode, newVnode, isSvgMode2, memberName) => {
306
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
307
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || EMPTY_OBJ;
308
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
309
+ {
310
+ for (memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
311
+ if (!(memberName in newVnodeAttrs)) {
312
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
313
+ }
314
+ }
315
+ }
316
+ for (memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
317
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
318
+ }
319
+ };
320
+ function sortedAttrNames(attrNames) {
321
+ return attrNames.includes("ref") ? (
322
+ // we need to sort these to ensure that `'ref'` is the last attr
323
+ [...attrNames.filter((attr) => attr !== "ref"), "ref"]
324
+ ) : (
325
+ // no need to sort, return the original array
326
+ attrNames
327
+ );
328
+ }
329
+
330
+ // src/runtime/vdom/vdom-render.ts
331
+ var scopeId;
332
+ var hostTagName;
333
+ var isSvgMode = false;
334
+ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
335
+ const newVNode2 = newParentVNode.$children$[childIndex];
336
+ let i2 = 0;
337
+ let elm;
338
+ let childNode;
339
+ if (newVNode2.$text$ !== null) {
340
+ elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
341
+ } else {
342
+ if (!isSvgMode) {
343
+ isSvgMode = newVNode2.$tag$ === "svg";
344
+ }
345
+ elm = newVNode2.$elm$ = doc.createElementNS(
346
+ isSvgMode ? SVG_NS : HTML_NS,
347
+ newVNode2.$tag$
348
+ ) ;
349
+ if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
350
+ isSvgMode = false;
351
+ }
352
+ {
353
+ updateElement(null, newVNode2, isSvgMode);
354
+ }
355
+ if (isDef(scopeId) && elm["s-si"] !== scopeId) {
356
+ elm.classList.add(elm["s-si"] = scopeId);
357
+ }
358
+ if (newVNode2.$children$) {
359
+ for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
360
+ childNode = createElm(oldParentVNode, newVNode2, i2);
361
+ if (childNode) {
362
+ elm.appendChild(childNode);
363
+ }
364
+ }
365
+ }
366
+ {
367
+ if (newVNode2.$tag$ === "svg") {
368
+ isSvgMode = false;
369
+ } else if (elm.tagName === "foreignObject") {
370
+ isSvgMode = true;
371
+ }
372
+ }
373
+ }
374
+ elm["s-hn"] = hostTagName;
375
+ return elm;
376
+ };
377
+ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
378
+ let containerElm = parentElm;
379
+ let childNode;
380
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
381
+ containerElm = containerElm.shadowRoot;
382
+ }
383
+ for (; startIdx <= endIdx; ++startIdx) {
384
+ if (vnodes[startIdx]) {
385
+ childNode = createElm(null, parentVNode, startIdx);
386
+ if (childNode) {
387
+ vnodes[startIdx].$elm$ = childNode;
388
+ containerElm.insertBefore(childNode, before);
389
+ }
390
+ }
391
+ }
392
+ };
393
+ var removeVnodes = (vnodes, startIdx, endIdx) => {
394
+ for (let index = startIdx; index <= endIdx; ++index) {
395
+ const vnode = vnodes[index];
396
+ if (vnode) {
397
+ const elm = vnode.$elm$;
398
+ nullifyVNodeRefs(vnode);
399
+ if (elm) {
400
+ elm.remove();
401
+ }
402
+ }
403
+ }
404
+ };
405
+ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
406
+ let oldStartIdx = 0;
407
+ let newStartIdx = 0;
408
+ let idxInOld = 0;
409
+ let i2 = 0;
410
+ let oldEndIdx = oldCh.length - 1;
411
+ let oldStartVnode = oldCh[0];
412
+ let oldEndVnode = oldCh[oldEndIdx];
413
+ let newEndIdx = newCh.length - 1;
414
+ let newStartVnode = newCh[0];
415
+ let newEndVnode = newCh[newEndIdx];
416
+ let node;
417
+ let elmToMove;
418
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
419
+ if (oldStartVnode == null) {
420
+ oldStartVnode = oldCh[++oldStartIdx];
421
+ } else if (oldEndVnode == null) {
422
+ oldEndVnode = oldCh[--oldEndIdx];
423
+ } else if (newStartVnode == null) {
424
+ newStartVnode = newCh[++newStartIdx];
425
+ } else if (newEndVnode == null) {
426
+ newEndVnode = newCh[--newEndIdx];
427
+ } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
428
+ patch(oldStartVnode, newStartVnode, isInitialRender);
429
+ oldStartVnode = oldCh[++oldStartIdx];
430
+ newStartVnode = newCh[++newStartIdx];
431
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
432
+ patch(oldEndVnode, newEndVnode, isInitialRender);
433
+ oldEndVnode = oldCh[--oldEndIdx];
434
+ newEndVnode = newCh[--newEndIdx];
435
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
436
+ patch(oldStartVnode, newEndVnode, isInitialRender);
437
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
438
+ oldStartVnode = oldCh[++oldStartIdx];
439
+ newEndVnode = newCh[--newEndIdx];
440
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
441
+ patch(oldEndVnode, newStartVnode, isInitialRender);
442
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
443
+ oldEndVnode = oldCh[--oldEndIdx];
444
+ newStartVnode = newCh[++newStartIdx];
445
+ } else {
446
+ idxInOld = -1;
447
+ {
448
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
449
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
450
+ idxInOld = i2;
451
+ break;
452
+ }
453
+ }
454
+ }
455
+ if (idxInOld >= 0) {
456
+ elmToMove = oldCh[idxInOld];
457
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
458
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
459
+ } else {
460
+ patch(elmToMove, newStartVnode, isInitialRender);
461
+ oldCh[idxInOld] = void 0;
462
+ node = elmToMove.$elm$;
463
+ }
464
+ newStartVnode = newCh[++newStartIdx];
465
+ } else {
466
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
467
+ newStartVnode = newCh[++newStartIdx];
468
+ }
469
+ if (node) {
470
+ {
471
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
472
+ }
473
+ }
474
+ }
475
+ }
476
+ if (oldStartIdx > oldEndIdx) {
477
+ addVnodes(
478
+ parentElm,
479
+ newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
480
+ newVNode2,
481
+ newCh,
482
+ newStartIdx,
483
+ newEndIdx
484
+ );
485
+ } else if (newStartIdx > newEndIdx) {
486
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
487
+ }
488
+ };
489
+ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
490
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
491
+ if (!isInitialRender) {
492
+ return leftVNode.$key$ === rightVNode.$key$;
493
+ }
494
+ return true;
495
+ }
496
+ return false;
497
+ };
498
+ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
499
+ const elm = newVNode2.$elm$ = oldVNode.$elm$;
500
+ const oldChildren = oldVNode.$children$;
501
+ const newChildren = newVNode2.$children$;
502
+ const tag = newVNode2.$tag$;
503
+ const text = newVNode2.$text$;
504
+ if (text === null) {
505
+ {
506
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
507
+ }
508
+ {
509
+ {
510
+ updateElement(oldVNode, newVNode2, isSvgMode);
511
+ }
512
+ }
513
+ if (oldChildren !== null && newChildren !== null) {
514
+ updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
515
+ } else if (newChildren !== null) {
516
+ if (oldVNode.$text$ !== null) {
517
+ elm.textContent = "";
518
+ }
519
+ addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
520
+ } else if (oldChildren !== null) {
521
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
522
+ }
523
+ if (isSvgMode && tag === "svg") {
524
+ isSvgMode = false;
525
+ }
526
+ } else if (oldVNode.$text$ !== text) {
527
+ elm.data = text;
528
+ }
529
+ };
530
+ var nullifyVNodeRefs = (vNode) => {
531
+ {
532
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
533
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
534
+ }
535
+ };
536
+ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
537
+ const hostElm = hostRef.$hostElement$;
538
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
539
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
540
+ hostTagName = hostElm.tagName;
541
+ if (isInitialLoad && rootVnode.$attrs$) {
542
+ for (const key of Object.keys(rootVnode.$attrs$)) {
543
+ if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
544
+ rootVnode.$attrs$[key] = hostElm[key];
545
+ }
546
+ }
547
+ }
548
+ rootVnode.$tag$ = null;
549
+ rootVnode.$flags$ |= 4 /* isHost */;
550
+ hostRef.$vnode$ = rootVnode;
551
+ rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
552
+ {
553
+ scopeId = hostElm["s-sc"];
554
+ }
555
+ patch(oldVNode, rootVnode, isInitialLoad);
556
+ };
557
+
558
+ // src/runtime/update-component.ts
559
+ var attachToAncestor = (hostRef, ancestorComponent) => {
560
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
561
+ ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
562
+ }
563
+ };
564
+ var scheduleUpdate = (hostRef, isInitialLoad) => {
565
+ {
566
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
567
+ }
568
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
569
+ hostRef.$flags$ |= 512 /* needsRerender */;
570
+ return;
571
+ }
572
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
573
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
574
+ return writeTask(dispatch) ;
575
+ };
576
+ var dispatchHooks = (hostRef, isInitialLoad) => {
577
+ const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
578
+ const instance = hostRef.$lazyInstance$ ;
579
+ let maybePromise;
580
+ if (isInitialLoad) {
581
+ {
582
+ maybePromise = safeCall(instance, "componentWillLoad");
583
+ }
584
+ }
585
+ endSchedule();
586
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
587
+ };
588
+ var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
589
+ var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
590
+ var updateComponent = async (hostRef, instance, isInitialLoad) => {
591
+ var _a;
592
+ const elm = hostRef.$hostElement$;
593
+ const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
594
+ const rc = elm["s-rc"];
595
+ if (isInitialLoad) {
596
+ attachStyles(hostRef);
597
+ }
598
+ const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
599
+ {
600
+ callRender(hostRef, instance, elm, isInitialLoad);
601
+ }
602
+ if (rc) {
603
+ rc.map((cb) => cb());
604
+ elm["s-rc"] = void 0;
605
+ }
606
+ endRender();
607
+ endUpdate();
608
+ {
609
+ const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
610
+ const postUpdate = () => postUpdateComponent(hostRef);
611
+ if (childrenPromises.length === 0) {
612
+ postUpdate();
613
+ } else {
614
+ Promise.all(childrenPromises).then(postUpdate);
615
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
616
+ childrenPromises.length = 0;
617
+ }
618
+ }
619
+ };
620
+ var callRender = (hostRef, instance, elm, isInitialLoad) => {
621
+ try {
622
+ instance = instance.render() ;
623
+ {
624
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
625
+ }
626
+ {
627
+ hostRef.$flags$ |= 2 /* hasRendered */;
628
+ }
629
+ {
630
+ {
631
+ {
632
+ renderVdom(hostRef, instance, isInitialLoad);
633
+ }
634
+ }
635
+ }
636
+ } catch (e) {
637
+ consoleError(e, hostRef.$hostElement$);
638
+ }
639
+ return null;
640
+ };
641
+ var postUpdateComponent = (hostRef) => {
642
+ const tagName = hostRef.$cmpMeta$.$tagName$;
643
+ const elm = hostRef.$hostElement$;
644
+ const endPostUpdate = createTime("postUpdate", tagName);
645
+ const instance = hostRef.$lazyInstance$ ;
646
+ const ancestorComponent = hostRef.$ancestorComponent$;
647
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
648
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
649
+ {
650
+ addHydratedFlag(elm);
651
+ }
652
+ {
653
+ safeCall(instance, "componentDidLoad");
654
+ }
655
+ endPostUpdate();
656
+ {
657
+ hostRef.$onReadyResolve$(elm);
658
+ if (!ancestorComponent) {
659
+ appDidLoad();
660
+ }
661
+ }
662
+ } else {
663
+ endPostUpdate();
664
+ }
665
+ {
666
+ if (hostRef.$onRenderResolve$) {
667
+ hostRef.$onRenderResolve$();
668
+ hostRef.$onRenderResolve$ = void 0;
669
+ }
670
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
671
+ nextTick(() => scheduleUpdate(hostRef, false));
672
+ }
673
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
674
+ }
675
+ };
676
+ var appDidLoad = (who) => {
677
+ {
678
+ addHydratedFlag(doc.documentElement);
679
+ }
680
+ nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
681
+ };
682
+ var safeCall = (instance, method, arg) => {
683
+ if (instance && instance[method]) {
684
+ try {
685
+ return instance[method](arg);
686
+ } catch (e) {
687
+ consoleError(e);
688
+ }
689
+ }
690
+ return void 0;
691
+ };
692
+ var addHydratedFlag = (elm) => elm.classList.add("hydrated") ;
693
+
694
+ // src/runtime/set-value.ts
695
+ var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
696
+ var setValue = (ref, propName, newVal, cmpMeta) => {
697
+ const hostRef = getHostRef(ref);
698
+ const oldVal = hostRef.$instanceValues$.get(propName);
699
+ const flags = hostRef.$flags$;
700
+ const instance = hostRef.$lazyInstance$ ;
701
+ newVal = parsePropertyValue(newVal);
702
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
703
+ const didValueChange = newVal !== oldVal && !areBothNaN;
704
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
705
+ hostRef.$instanceValues$.set(propName, newVal);
706
+ if (instance) {
707
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
708
+ scheduleUpdate(hostRef, false);
709
+ }
710
+ }
711
+ }
712
+ };
713
+
714
+ // src/runtime/proxy-component.ts
715
+ var proxyComponent = (Cstr, cmpMeta, flags) => {
716
+ var _a;
717
+ const prototype = Cstr.prototype;
718
+ if (cmpMeta.$members$) {
719
+ const members = Object.entries(cmpMeta.$members$);
720
+ members.map(([memberName, [memberFlags]]) => {
721
+ if ((memberFlags & 31 /* Prop */ || (flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
722
+ Object.defineProperty(prototype, memberName, {
723
+ get() {
724
+ return getValue(this, memberName);
725
+ },
726
+ set(newValue) {
727
+ setValue(this, memberName, newValue);
728
+ },
729
+ configurable: true,
730
+ enumerable: true
731
+ });
732
+ }
733
+ });
734
+ if ((flags & 1 /* isElementConstructor */)) {
735
+ const attrNameToPropName = /* @__PURE__ */ new Map();
736
+ prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
737
+ plt.jmp(() => {
738
+ var _a2;
739
+ const propName = attrNameToPropName.get(attrName);
740
+ if (this.hasOwnProperty(propName)) {
741
+ newValue = this[propName];
742
+ delete this[propName];
743
+ } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) {
744
+ return;
745
+ } else if (propName == null) {
746
+ const hostRef = getHostRef(this);
747
+ const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
748
+ if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
749
+ const instance = hostRef.$lazyInstance$ ;
750
+ const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
751
+ entry == null ? void 0 : entry.forEach((callbackName) => {
752
+ if (instance[callbackName] != null) {
753
+ instance[callbackName].call(instance, newValue, oldValue, attrName);
754
+ }
755
+ });
756
+ }
757
+ return;
758
+ }
759
+ this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
760
+ });
761
+ };
762
+ Cstr.observedAttributes = Array.from(
763
+ /* @__PURE__ */ new Set([
764
+ ...Object.keys((_a = cmpMeta.$watchers$) != null ? _a : {}),
765
+ ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
766
+ const attrName = m[1] || propName;
767
+ attrNameToPropName.set(attrName, propName);
768
+ return attrName;
769
+ })
770
+ ])
771
+ );
772
+ }
773
+ }
774
+ return Cstr;
775
+ };
776
+
777
+ // src/runtime/initialize-component.ts
778
+ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
779
+ let Cstr;
780
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
781
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
782
+ const bundleId = cmpMeta.$lazyBundleId$;
783
+ if (bundleId) {
784
+ Cstr = loadModule(cmpMeta);
785
+ if (Cstr.then) {
786
+ const endLoad = uniqueTime();
787
+ Cstr = await Cstr;
788
+ endLoad();
789
+ }
790
+ if (!Cstr.isProxied) {
791
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
792
+ Cstr.isProxied = true;
793
+ }
794
+ const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
795
+ {
796
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
797
+ }
798
+ try {
799
+ new Cstr(hostRef);
800
+ } catch (e) {
801
+ consoleError(e);
802
+ }
803
+ {
804
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
805
+ }
806
+ endNewInstance();
807
+ } else {
808
+ Cstr = elm.constructor;
809
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
810
+ }
811
+ if (Cstr.style) {
812
+ let style = Cstr.style;
813
+ const scopeId2 = getScopeId(cmpMeta);
814
+ if (!styles.has(scopeId2)) {
815
+ const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
816
+ registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
817
+ endRegisterStyles();
818
+ }
819
+ }
820
+ }
821
+ const ancestorComponent = hostRef.$ancestorComponent$;
822
+ const schedule = () => scheduleUpdate(hostRef, true);
823
+ if (ancestorComponent && ancestorComponent["s-rc"]) {
824
+ ancestorComponent["s-rc"].push(schedule);
825
+ } else {
826
+ schedule();
827
+ }
828
+ };
829
+ var fireConnectedCallback = (instance) => {
830
+ };
831
+
832
+ // src/runtime/connected-callback.ts
833
+ var connectedCallback = (elm) => {
834
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
835
+ const hostRef = getHostRef(elm);
836
+ const cmpMeta = hostRef.$cmpMeta$;
837
+ const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
838
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
839
+ hostRef.$flags$ |= 1 /* hasConnected */;
840
+ {
841
+ let ancestorComponent = elm;
842
+ while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
843
+ if (ancestorComponent["s-p"]) {
844
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
845
+ break;
846
+ }
847
+ }
848
+ }
849
+ if (cmpMeta.$members$) {
850
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
851
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
852
+ const value = elm[memberName];
853
+ delete elm[memberName];
854
+ elm[memberName] = value;
855
+ }
856
+ });
857
+ }
858
+ {
859
+ initializeComponent(elm, hostRef, cmpMeta);
860
+ }
861
+ } else {
862
+ if (hostRef == null ? void 0 : hostRef.$lazyInstance$) ; else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
863
+ hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
864
+ }
865
+ }
866
+ endConnected();
867
+ }
868
+ };
869
+ var disconnectInstance = (instance) => {
870
+ };
871
+ var disconnectedCallback = async (elm) => {
872
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
873
+ const hostRef = getHostRef(elm);
874
+ if (hostRef == null ? void 0 : hostRef.$lazyInstance$) ; else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
875
+ hostRef.$onReadyPromise$.then(() => disconnectInstance());
876
+ }
877
+ }
878
+ };
879
+
880
+ // src/runtime/bootstrap-lazy.ts
881
+ var bootstrapLazy = (lazyBundles, options = {}) => {
882
+ var _a;
883
+ const endBootstrap = createTime();
884
+ const cmpTags = [];
885
+ const exclude = options.exclude || [];
886
+ const customElements2 = win.customElements;
887
+ const head = doc.head;
888
+ const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
889
+ const dataStyles = /* @__PURE__ */ doc.createElement("style");
890
+ const deferredConnectedCallbacks = [];
891
+ let appLoadFallback;
892
+ let isBootstrapping = true;
893
+ Object.assign(plt, options);
894
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", doc.baseURI).href;
895
+ let hasSlotRelocation = false;
896
+ lazyBundles.map((lazyBundle) => {
897
+ lazyBundle[1].map((compactMeta) => {
898
+ const cmpMeta = {
899
+ $flags$: compactMeta[0],
900
+ $tagName$: compactMeta[1],
901
+ $members$: compactMeta[2],
902
+ $listeners$: compactMeta[3]
903
+ };
904
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
905
+ hasSlotRelocation = true;
906
+ }
907
+ {
908
+ cmpMeta.$members$ = compactMeta[2];
909
+ }
910
+ const tagName = cmpMeta.$tagName$;
911
+ const HostElement = class extends HTMLElement {
912
+ // StencilLazyHost
913
+ constructor(self) {
914
+ super(self);
915
+ self = this;
916
+ registerHost(self, cmpMeta);
917
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
918
+ {
919
+ {
920
+ self.attachShadow({ mode: "open" });
921
+ }
922
+ }
923
+ }
924
+ }
925
+ connectedCallback() {
926
+ if (appLoadFallback) {
927
+ clearTimeout(appLoadFallback);
928
+ appLoadFallback = null;
929
+ }
930
+ if (isBootstrapping) {
931
+ deferredConnectedCallbacks.push(this);
932
+ } else {
933
+ plt.jmp(() => connectedCallback(this));
934
+ }
935
+ }
936
+ disconnectedCallback() {
937
+ plt.jmp(() => disconnectedCallback(this));
938
+ }
939
+ componentOnReady() {
940
+ return getHostRef(this).$onReadyPromise$;
941
+ }
942
+ };
943
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
944
+ if (!exclude.includes(tagName) && !customElements2.get(tagName)) {
945
+ cmpTags.push(tagName);
946
+ customElements2.define(
947
+ tagName,
948
+ proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */)
949
+ );
950
+ }
951
+ });
952
+ });
953
+ if (cmpTags.length > 0) {
954
+ if (hasSlotRelocation) {
955
+ dataStyles.textContent += SLOT_FB_CSS;
956
+ }
957
+ {
958
+ dataStyles.textContent += cmpTags + HYDRATED_CSS;
959
+ }
960
+ if (dataStyles.innerHTML.length) {
961
+ dataStyles.setAttribute("data-styles", "");
962
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
963
+ if (nonce != null) {
964
+ dataStyles.setAttribute("nonce", nonce);
965
+ }
966
+ head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
967
+ }
968
+ }
969
+ isBootstrapping = false;
970
+ if (deferredConnectedCallbacks.length) {
971
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
972
+ } else {
973
+ {
974
+ plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
975
+ }
976
+ }
977
+ endBootstrap();
978
+ };
979
+
980
+ // src/runtime/nonce.ts
981
+ var setNonce = (nonce) => plt.$nonce$ = nonce;
982
+
983
+ // src/client/client-host-ref.ts
984
+ var hostRefs = /* @__PURE__ */ new WeakMap();
985
+ var getHostRef = (ref) => hostRefs.get(ref);
986
+ var registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
987
+ var registerHost = (hostElement, cmpMeta) => {
988
+ const hostRef = {
989
+ $flags$: 0,
990
+ $hostElement$: hostElement,
991
+ $cmpMeta$: cmpMeta,
992
+ $instanceValues$: /* @__PURE__ */ new Map()
993
+ };
994
+ {
995
+ hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
996
+ hostElement["s-p"] = [];
997
+ hostElement["s-rc"] = [];
998
+ }
999
+ return hostRefs.set(hostElement, hostRef);
1000
+ };
1001
+ var isMemberInElement = (elm, memberName) => memberName in elm;
1002
+ var consoleError = (e, el) => (0, console.error)(e, el);
1003
+
1004
+ // src/client/client-load-module.ts
1005
+ var cmpModules = /* @__PURE__ */ new Map();
1006
+ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1007
+ const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
1008
+ const bundleId = cmpMeta.$lazyBundleId$;
1009
+ const module = cmpModules.get(bundleId) ;
1010
+ if (module) {
1011
+ return module[exportName];
1012
+ }
1013
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1014
+ return import(
1015
+ /* @vite-ignore */
1016
+ /* webpackInclude: /\.entry\.js$/ */
1017
+ /* webpackExclude: /\.system\.entry\.js$/ */
1018
+ /* webpackMode: "lazy" */
1019
+ `./${bundleId}.entry.js${""}`
1020
+ ).then((importedModule) => {
1021
+ {
1022
+ cmpModules.set(bundleId, importedModule);
1023
+ }
1024
+ return importedModule[exportName];
1025
+ }, consoleError);
1026
+ };
1027
+
1028
+ // src/client/client-style.ts
1029
+ var styles = /* @__PURE__ */ new Map();
1030
+ var win = typeof window !== "undefined" ? window : {};
1031
+ var doc = win.document || { head: {} };
1032
+ var plt = {
1033
+ $flags$: 0,
1034
+ $resourcesUrl$: "",
1035
+ jmp: (h2) => h2(),
1036
+ raf: (h2) => requestAnimationFrame(h2),
1037
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1038
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1039
+ ce: (eventName, opts) => new CustomEvent(eventName, opts)
1040
+ };
1041
+ var promiseResolve = (v) => Promise.resolve(v);
1042
+ var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
1043
+ try {
1044
+ new CSSStyleSheet();
1045
+ return typeof new CSSStyleSheet().replaceSync === "function";
1046
+ } catch (e) {
1047
+ }
1048
+ return false;
1049
+ })() ;
1050
+ var queuePending = false;
1051
+ var queueDomReads = [];
1052
+ var queueDomWrites = [];
1053
+ var queueTask = (queue, write) => (cb) => {
1054
+ queue.push(cb);
1055
+ if (!queuePending) {
1056
+ queuePending = true;
1057
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1058
+ nextTick(flush);
1059
+ } else {
1060
+ plt.raf(flush);
1061
+ }
1062
+ }
1063
+ };
1064
+ var consume = (queue) => {
1065
+ for (let i2 = 0; i2 < queue.length; i2++) {
1066
+ try {
1067
+ queue[i2](performance.now());
1068
+ } catch (e) {
1069
+ consoleError(e);
1070
+ }
1071
+ }
1072
+ queue.length = 0;
1073
+ };
1074
+ var flush = () => {
1075
+ consume(queueDomReads);
1076
+ {
1077
+ consume(queueDomWrites);
1078
+ if (queuePending = queueDomReads.length > 0) {
1079
+ plt.raf(flush);
1080
+ }
1081
+ }
1082
+ };
1083
+ var nextTick = (cb) => promiseResolve().then(cb);
1084
+ var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
1085
+
1086
+ export { bootstrapLazy as b, h, promiseResolve as p, registerInstance as r, setNonce as s };