@everymatrix/casino-engagement-suite-challenges-list 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.esm.js +1 -0
  2. package/dist/casino-engagement-suite-challenges-list/index.esm.js +0 -0
  3. package/dist/casino-engagement-suite-challenges-list/p-7e171791.js +1 -0
  4. package/dist/casino-engagement-suite-challenges-list/p-eb36cbe7.entry.js +1 -0
  5. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.entry.js +1147 -0
  6. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.js +19 -0
  7. package/dist/cjs/index-79c88755.js +1299 -0
  8. package/dist/cjs/index.cjs.js +2 -0
  9. package/dist/cjs/loader.cjs.js +21 -0
  10. package/dist/collection/collection-manifest.json +12 -0
  11. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.css +225 -0
  12. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.js +368 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/models/challenge.js +15 -0
  15. package/dist/collection/utils/locale.utils.js +16 -0
  16. package/dist/components/casino-engagement-suite-challenges-list.d.ts +11 -0
  17. package/dist/components/casino-engagement-suite-challenges-list.js +1170 -0
  18. package/dist/components/index.d.ts +26 -0
  19. package/dist/components/index.js +1 -0
  20. package/dist/esm/casino-engagement-suite-challenges-list.entry.js +1143 -0
  21. package/dist/esm/casino-engagement-suite-challenges-list.js +17 -0
  22. package/dist/esm/index-70e47fe0.js +1272 -0
  23. package/dist/esm/index.js +1 -0
  24. package/dist/esm/loader.js +17 -0
  25. package/dist/esm/polyfills/core-js.js +11 -0
  26. package/dist/esm/polyfills/css-shim.js +1 -0
  27. package/dist/esm/polyfills/dom.js +79 -0
  28. package/dist/esm/polyfills/es5-html-element.js +1 -0
  29. package/dist/esm/polyfills/index.js +34 -0
  30. package/dist/esm/polyfills/system.js +6 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/stencil.config.js +22 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/casino-engagement-suite-challenges-list/.stencil/packages/casino-engagement-suite-challenges-list/stencil.config.d.ts +2 -0
  35. package/dist/types/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.d.ts +60 -0
  36. package/dist/types/components.d.ts +79 -0
  37. package/dist/types/index.d.ts +1 -0
  38. package/dist/types/models/challenge.d.ts +57 -0
  39. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  40. package/dist/types/utils/locale.utils.d.ts +1 -0
  41. package/loader/cdn.js +3 -0
  42. package/loader/index.cjs.js +3 -0
  43. package/loader/index.d.ts +12 -0
  44. package/loader/index.es2017.js +3 -0
  45. package/loader/index.js +4 -0
  46. package/loader/package.json +10 -0
  47. package/package.json +19 -0
@@ -0,0 +1,1272 @@
1
+ const NAMESPACE = 'casino-engagement-suite-challenges-list';
2
+
3
+ let scopeId;
4
+ let hostTagName;
5
+ let isSvgMode = false;
6
+ let queuePending = false;
7
+ const win = typeof window !== 'undefined' ? window : {};
8
+ const doc = win.document || { head: {} };
9
+ const plt = {
10
+ $flags$: 0,
11
+ $resourcesUrl$: '',
12
+ jmp: (h) => h(),
13
+ raf: (h) => requestAnimationFrame(h),
14
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
15
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
16
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
17
+ };
18
+ const promiseResolve = (v) => Promise.resolve(v);
19
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
20
+ try {
21
+ new CSSStyleSheet();
22
+ return typeof new CSSStyleSheet().replace === 'function';
23
+ }
24
+ catch (e) { }
25
+ return false;
26
+ })()
27
+ ;
28
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
29
+ if (listeners) {
30
+ listeners.map(([flags, name, method]) => {
31
+ const target = getHostListenerTarget(elm, flags) ;
32
+ const handler = hostListenerProxy(hostRef, method);
33
+ const opts = hostListenerOpts(flags);
34
+ plt.ael(target, name, handler, opts);
35
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
36
+ });
37
+ }
38
+ };
39
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
40
+ try {
41
+ {
42
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
43
+ // instance is ready, let's call it's member method for this event
44
+ hostRef.$lazyInstance$[methodName](ev);
45
+ }
46
+ else {
47
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
48
+ }
49
+ }
50
+ }
51
+ catch (e) {
52
+ consoleError(e);
53
+ }
54
+ };
55
+ const getHostListenerTarget = (elm, flags) => {
56
+ if (flags & 8 /* TargetWindow */)
57
+ return win;
58
+ return elm;
59
+ };
60
+ // prettier-ignore
61
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
62
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
63
+ const createTime = (fnName, tagName = '') => {
64
+ {
65
+ return () => {
66
+ return;
67
+ };
68
+ }
69
+ };
70
+ const uniqueTime = (key, measureText) => {
71
+ {
72
+ return () => {
73
+ return;
74
+ };
75
+ }
76
+ };
77
+ const rootAppliedStyles = new WeakMap();
78
+ const registerStyle = (scopeId, cssText, allowCS) => {
79
+ let style = styles.get(scopeId);
80
+ if (supportsConstructibleStylesheets && allowCS) {
81
+ style = (style || new CSSStyleSheet());
82
+ style.replace(cssText);
83
+ }
84
+ else {
85
+ style = cssText;
86
+ }
87
+ styles.set(scopeId, style);
88
+ };
89
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
90
+ let scopeId = getScopeId(cmpMeta);
91
+ let style = styles.get(scopeId);
92
+ // if an element is NOT connected then getRootNode() will return the wrong root node
93
+ // so the fallback is to always use the document for the root node in those cases
94
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
95
+ if (style) {
96
+ if (typeof style === 'string') {
97
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
98
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
99
+ let styleElm;
100
+ if (!appliedStyles) {
101
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
102
+ }
103
+ if (!appliedStyles.has(scopeId)) {
104
+ {
105
+ {
106
+ styleElm = doc.createElement('style');
107
+ styleElm.innerHTML = style;
108
+ }
109
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
110
+ }
111
+ if (appliedStyles) {
112
+ appliedStyles.add(scopeId);
113
+ }
114
+ }
115
+ }
116
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
117
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
118
+ }
119
+ }
120
+ return scopeId;
121
+ };
122
+ const attachStyles = (hostRef) => {
123
+ const cmpMeta = hostRef.$cmpMeta$;
124
+ const elm = hostRef.$hostElement$;
125
+ const flags = cmpMeta.$flags$;
126
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
127
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
128
+ if (flags & 10 /* needsScopedEncapsulation */) {
129
+ // only required when we're NOT using native shadow dom (slot)
130
+ // or this browser doesn't support native shadow dom
131
+ // and this host element was NOT created with SSR
132
+ // let's pick out the inner content for slot projection
133
+ // create a node to represent where the original
134
+ // content was first placed, which is useful later on
135
+ // DOM WRITE!!
136
+ elm['s-sc'] = scopeId;
137
+ elm.classList.add(scopeId + '-h');
138
+ }
139
+ endAttachStyles();
140
+ };
141
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
142
+ /**
143
+ * Default style mode id
144
+ */
145
+ /**
146
+ * Reusable empty obj/array
147
+ * Don't add values to these!!
148
+ */
149
+ const EMPTY_OBJ = {};
150
+ const isDef = (v) => v != null;
151
+ const isComplexType = (o) => {
152
+ // https://jsperf.com/typeof-fn-object/5
153
+ o = typeof o;
154
+ return o === 'object' || o === 'function';
155
+ };
156
+ /**
157
+ * Production h() function based on Preact by
158
+ * Jason Miller (@developit)
159
+ * Licensed under the MIT License
160
+ * https://github.com/developit/preact/blob/master/LICENSE
161
+ *
162
+ * Modified for Stencil's compiler and vdom
163
+ */
164
+ // const stack: any[] = [];
165
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
166
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
167
+ const h = (nodeName, vnodeData, ...children) => {
168
+ let child = null;
169
+ let key = null;
170
+ let simple = false;
171
+ let lastSimple = false;
172
+ let vNodeChildren = [];
173
+ const walk = (c) => {
174
+ for (let i = 0; i < c.length; i++) {
175
+ child = c[i];
176
+ if (Array.isArray(child)) {
177
+ walk(child);
178
+ }
179
+ else if (child != null && typeof child !== 'boolean') {
180
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
181
+ child = String(child);
182
+ }
183
+ if (simple && lastSimple) {
184
+ // If the previous child was simple (string), we merge both
185
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
186
+ }
187
+ else {
188
+ // Append a new vNode, if it's text, we create a text vNode
189
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
190
+ }
191
+ lastSimple = simple;
192
+ }
193
+ }
194
+ };
195
+ walk(children);
196
+ if (vnodeData) {
197
+ // normalize class / classname attributes
198
+ if (vnodeData.key) {
199
+ key = vnodeData.key;
200
+ }
201
+ {
202
+ const classData = vnodeData.className || vnodeData.class;
203
+ if (classData) {
204
+ vnodeData.class =
205
+ typeof classData !== 'object'
206
+ ? classData
207
+ : Object.keys(classData)
208
+ .filter((k) => classData[k])
209
+ .join(' ');
210
+ }
211
+ }
212
+ }
213
+ const vnode = newVNode(nodeName, null);
214
+ vnode.$attrs$ = vnodeData;
215
+ if (vNodeChildren.length > 0) {
216
+ vnode.$children$ = vNodeChildren;
217
+ }
218
+ {
219
+ vnode.$key$ = key;
220
+ }
221
+ return vnode;
222
+ };
223
+ const newVNode = (tag, text) => {
224
+ const vnode = {
225
+ $flags$: 0,
226
+ $tag$: tag,
227
+ $text$: text,
228
+ $elm$: null,
229
+ $children$: null,
230
+ };
231
+ {
232
+ vnode.$attrs$ = null;
233
+ }
234
+ {
235
+ vnode.$key$ = null;
236
+ }
237
+ return vnode;
238
+ };
239
+ const Host = {};
240
+ const isHost = (node) => node && node.$tag$ === Host;
241
+ /**
242
+ * Production setAccessor() function based on Preact by
243
+ * Jason Miller (@developit)
244
+ * Licensed under the MIT License
245
+ * https://github.com/developit/preact/blob/master/LICENSE
246
+ *
247
+ * Modified for Stencil's compiler and vdom
248
+ */
249
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
250
+ if (oldValue !== newValue) {
251
+ let isProp = isMemberInElement(elm, memberName);
252
+ let ln = memberName.toLowerCase();
253
+ if (memberName === 'class') {
254
+ const classList = elm.classList;
255
+ const oldClasses = parseClassList(oldValue);
256
+ const newClasses = parseClassList(newValue);
257
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
258
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
259
+ }
260
+ else if (memberName === 'key')
261
+ ;
262
+ else if ((!isProp ) &&
263
+ memberName[0] === 'o' &&
264
+ memberName[1] === 'n') {
265
+ // Event Handlers
266
+ // so if the member name starts with "on" and the 3rd characters is
267
+ // a capital letter, and it's not already a member on the element,
268
+ // then we're assuming it's an event listener
269
+ if (memberName[2] === '-') {
270
+ // on- prefixed events
271
+ // allows to be explicit about the dom event to listen without any magic
272
+ // under the hood:
273
+ // <my-cmp on-click> // listens for "click"
274
+ // <my-cmp on-Click> // listens for "Click"
275
+ // <my-cmp on-ionChange> // listens for "ionChange"
276
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
277
+ memberName = memberName.slice(3);
278
+ }
279
+ else if (isMemberInElement(win, ln)) {
280
+ // standard event
281
+ // the JSX attribute could have been "onMouseOver" and the
282
+ // member name "onmouseover" is on the window's prototype
283
+ // so let's add the listener "mouseover", which is all lowercased
284
+ memberName = ln.slice(2);
285
+ }
286
+ else {
287
+ // custom event
288
+ // the JSX attribute could have been "onMyCustomEvent"
289
+ // so let's trim off the "on" prefix and lowercase the first character
290
+ // and add the listener "myCustomEvent"
291
+ // except for the first character, we keep the event name case
292
+ memberName = ln[2] + memberName.slice(3);
293
+ }
294
+ if (oldValue) {
295
+ plt.rel(elm, memberName, oldValue, false);
296
+ }
297
+ if (newValue) {
298
+ plt.ael(elm, memberName, newValue, false);
299
+ }
300
+ }
301
+ else {
302
+ // Set property if it exists and it's not a SVG
303
+ const isComplex = isComplexType(newValue);
304
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
305
+ try {
306
+ if (!elm.tagName.includes('-')) {
307
+ let n = newValue == null ? '' : newValue;
308
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
309
+ if (memberName === 'list') {
310
+ isProp = false;
311
+ }
312
+ else if (oldValue == null || elm[memberName] != n) {
313
+ elm[memberName] = n;
314
+ }
315
+ }
316
+ else {
317
+ elm[memberName] = newValue;
318
+ }
319
+ }
320
+ catch (e) { }
321
+ }
322
+ if (newValue == null || newValue === false) {
323
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
324
+ {
325
+ elm.removeAttribute(memberName);
326
+ }
327
+ }
328
+ }
329
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
330
+ newValue = newValue === true ? '' : newValue;
331
+ {
332
+ elm.setAttribute(memberName, newValue);
333
+ }
334
+ }
335
+ }
336
+ }
337
+ };
338
+ const parseClassListRegex = /\s/;
339
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
340
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
341
+ // if the element passed in is a shadow root, which is a document fragment
342
+ // then we want to be adding attrs/props to the shadow root's "host" element
343
+ // if it's not a shadow root, then we add attrs/props to the same element
344
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
345
+ ? newVnode.$elm$.host
346
+ : newVnode.$elm$;
347
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
348
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
349
+ {
350
+ // remove attributes no longer present on the vnode by setting them to undefined
351
+ for (memberName in oldVnodeAttrs) {
352
+ if (!(memberName in newVnodeAttrs)) {
353
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
354
+ }
355
+ }
356
+ }
357
+ // add new & update changed attributes
358
+ for (memberName in newVnodeAttrs) {
359
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
360
+ }
361
+ };
362
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
363
+ // tslint:disable-next-line: prefer-const
364
+ let newVNode = newParentVNode.$children$[childIndex];
365
+ let i = 0;
366
+ let elm;
367
+ let childNode;
368
+ if (newVNode.$text$ !== null) {
369
+ // create text node
370
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
371
+ }
372
+ else {
373
+ // create element
374
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
375
+ // add css classes, attrs, props, listeners, etc.
376
+ {
377
+ updateElement(null, newVNode, isSvgMode);
378
+ }
379
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
380
+ // if there is a scopeId and this is the initial render
381
+ // then let's add the scopeId as a css class
382
+ elm.classList.add((elm['s-si'] = scopeId));
383
+ }
384
+ if (newVNode.$children$) {
385
+ for (i = 0; i < newVNode.$children$.length; ++i) {
386
+ // create the node
387
+ childNode = createElm(oldParentVNode, newVNode, i);
388
+ // return node could have been null
389
+ if (childNode) {
390
+ // append our new node
391
+ elm.appendChild(childNode);
392
+ }
393
+ }
394
+ }
395
+ }
396
+ return elm;
397
+ };
398
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
399
+ let containerElm = (parentElm);
400
+ let childNode;
401
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
402
+ containerElm = containerElm.shadowRoot;
403
+ }
404
+ for (; startIdx <= endIdx; ++startIdx) {
405
+ if (vnodes[startIdx]) {
406
+ childNode = createElm(null, parentVNode, startIdx);
407
+ if (childNode) {
408
+ vnodes[startIdx].$elm$ = childNode;
409
+ containerElm.insertBefore(childNode, before);
410
+ }
411
+ }
412
+ }
413
+ };
414
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
415
+ for (; startIdx <= endIdx; ++startIdx) {
416
+ if ((vnode = vnodes[startIdx])) {
417
+ elm = vnode.$elm$;
418
+ // remove the vnode's element from the dom
419
+ elm.remove();
420
+ }
421
+ }
422
+ };
423
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
424
+ let oldStartIdx = 0;
425
+ let newStartIdx = 0;
426
+ let idxInOld = 0;
427
+ let i = 0;
428
+ let oldEndIdx = oldCh.length - 1;
429
+ let oldStartVnode = oldCh[0];
430
+ let oldEndVnode = oldCh[oldEndIdx];
431
+ let newEndIdx = newCh.length - 1;
432
+ let newStartVnode = newCh[0];
433
+ let newEndVnode = newCh[newEndIdx];
434
+ let node;
435
+ let elmToMove;
436
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
437
+ if (oldStartVnode == null) {
438
+ // Vnode might have been moved left
439
+ oldStartVnode = oldCh[++oldStartIdx];
440
+ }
441
+ else if (oldEndVnode == null) {
442
+ oldEndVnode = oldCh[--oldEndIdx];
443
+ }
444
+ else if (newStartVnode == null) {
445
+ newStartVnode = newCh[++newStartIdx];
446
+ }
447
+ else if (newEndVnode == null) {
448
+ newEndVnode = newCh[--newEndIdx];
449
+ }
450
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
451
+ patch(oldStartVnode, newStartVnode);
452
+ oldStartVnode = oldCh[++oldStartIdx];
453
+ newStartVnode = newCh[++newStartIdx];
454
+ }
455
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
456
+ patch(oldEndVnode, newEndVnode);
457
+ oldEndVnode = oldCh[--oldEndIdx];
458
+ newEndVnode = newCh[--newEndIdx];
459
+ }
460
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
461
+ patch(oldStartVnode, newEndVnode);
462
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
463
+ oldStartVnode = oldCh[++oldStartIdx];
464
+ newEndVnode = newCh[--newEndIdx];
465
+ }
466
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
467
+ patch(oldEndVnode, newStartVnode);
468
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
469
+ oldEndVnode = oldCh[--oldEndIdx];
470
+ newStartVnode = newCh[++newStartIdx];
471
+ }
472
+ else {
473
+ // createKeyToOldIdx
474
+ idxInOld = -1;
475
+ {
476
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
477
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
478
+ idxInOld = i;
479
+ break;
480
+ }
481
+ }
482
+ }
483
+ if (idxInOld >= 0) {
484
+ elmToMove = oldCh[idxInOld];
485
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
486
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
487
+ }
488
+ else {
489
+ patch(elmToMove, newStartVnode);
490
+ oldCh[idxInOld] = undefined;
491
+ node = elmToMove.$elm$;
492
+ }
493
+ newStartVnode = newCh[++newStartIdx];
494
+ }
495
+ else {
496
+ // new element
497
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
498
+ newStartVnode = newCh[++newStartIdx];
499
+ }
500
+ if (node) {
501
+ {
502
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
503
+ }
504
+ }
505
+ }
506
+ }
507
+ if (oldStartIdx > oldEndIdx) {
508
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
509
+ }
510
+ else if (newStartIdx > newEndIdx) {
511
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
512
+ }
513
+ };
514
+ const isSameVnode = (vnode1, vnode2) => {
515
+ // compare if two vnode to see if they're "technically" the same
516
+ // need to have the same element tag, and same key to be the same
517
+ if (vnode1.$tag$ === vnode2.$tag$) {
518
+ {
519
+ return vnode1.$key$ === vnode2.$key$;
520
+ }
521
+ }
522
+ return false;
523
+ };
524
+ const patch = (oldVNode, newVNode) => {
525
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
526
+ const oldChildren = oldVNode.$children$;
527
+ const newChildren = newVNode.$children$;
528
+ const text = newVNode.$text$;
529
+ if (text === null) {
530
+ // element node
531
+ {
532
+ {
533
+ // either this is the first render of an element OR it's an update
534
+ // AND we already know it's possible it could have changed
535
+ // this updates the element's css classes, attrs, props, listeners, etc.
536
+ updateElement(oldVNode, newVNode, isSvgMode);
537
+ }
538
+ }
539
+ if (oldChildren !== null && newChildren !== null) {
540
+ // looks like there's child vnodes for both the old and new vnodes
541
+ updateChildren(elm, oldChildren, newVNode, newChildren);
542
+ }
543
+ else if (newChildren !== null) {
544
+ // no old child vnodes, but there are new child vnodes to add
545
+ if (oldVNode.$text$ !== null) {
546
+ // the old vnode was text, so be sure to clear it out
547
+ elm.textContent = '';
548
+ }
549
+ // add the new vnode children
550
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
551
+ }
552
+ else if (oldChildren !== null) {
553
+ // no new child vnodes, but there are old child vnodes to remove
554
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
555
+ }
556
+ }
557
+ else if (oldVNode.$text$ !== text) {
558
+ // update the text content for the text only vnode
559
+ // and also only if the text is different than before
560
+ elm.data = text;
561
+ }
562
+ };
563
+ const renderVdom = (hostRef, renderFnResults) => {
564
+ const hostElm = hostRef.$hostElement$;
565
+ const cmpMeta = hostRef.$cmpMeta$;
566
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
567
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
568
+ hostTagName = hostElm.tagName;
569
+ if (cmpMeta.$attrsToReflect$) {
570
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
571
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
572
+ }
573
+ rootVnode.$tag$ = null;
574
+ rootVnode.$flags$ |= 4 /* isHost */;
575
+ hostRef.$vnode$ = rootVnode;
576
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
577
+ {
578
+ scopeId = hostElm['s-sc'];
579
+ }
580
+ // synchronous patch
581
+ patch(oldVNode, rootVnode);
582
+ };
583
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
584
+ const createEvent = (ref, name, flags) => {
585
+ const elm = getElement(ref);
586
+ return {
587
+ emit: (detail) => {
588
+ return emitEvent(elm, name, {
589
+ bubbles: !!(flags & 4 /* Bubbles */),
590
+ composed: !!(flags & 2 /* Composed */),
591
+ cancelable: !!(flags & 1 /* Cancellable */),
592
+ detail,
593
+ });
594
+ },
595
+ };
596
+ };
597
+ /**
598
+ * Helper function to create & dispatch a custom Event on a provided target
599
+ * @param elm the target of the Event
600
+ * @param name the name to give the custom Event
601
+ * @param opts options for configuring a custom Event
602
+ * @returns the custom Event
603
+ */
604
+ const emitEvent = (elm, name, opts) => {
605
+ const ev = plt.ce(name, opts);
606
+ elm.dispatchEvent(ev);
607
+ return ev;
608
+ };
609
+ const attachToAncestor = (hostRef, ancestorComponent) => {
610
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
611
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
612
+ }
613
+ };
614
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
615
+ {
616
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
617
+ }
618
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
619
+ hostRef.$flags$ |= 512 /* needsRerender */;
620
+ return;
621
+ }
622
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
623
+ // there is no ancestor component or the ancestor component
624
+ // has already fired off its lifecycle update then
625
+ // fire off the initial update
626
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
627
+ return writeTask(dispatch) ;
628
+ };
629
+ const dispatchHooks = (hostRef, isInitialLoad) => {
630
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
631
+ const instance = hostRef.$lazyInstance$ ;
632
+ let promise;
633
+ if (isInitialLoad) {
634
+ {
635
+ hostRef.$flags$ |= 256 /* isListenReady */;
636
+ if (hostRef.$queuedListeners$) {
637
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
638
+ hostRef.$queuedListeners$ = null;
639
+ }
640
+ }
641
+ {
642
+ promise = safeCall(instance, 'componentWillLoad');
643
+ }
644
+ }
645
+ endSchedule();
646
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
647
+ };
648
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
649
+ // updateComponent
650
+ const elm = hostRef.$hostElement$;
651
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
652
+ const rc = elm['s-rc'];
653
+ if (isInitialLoad) {
654
+ // DOM WRITE!
655
+ attachStyles(hostRef);
656
+ }
657
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
658
+ {
659
+ callRender(hostRef, instance);
660
+ }
661
+ if (rc) {
662
+ // ok, so turns out there are some child host elements
663
+ // waiting on this parent element to load
664
+ // let's fire off all update callbacks waiting
665
+ rc.map((cb) => cb());
666
+ elm['s-rc'] = undefined;
667
+ }
668
+ endRender();
669
+ endUpdate();
670
+ {
671
+ const childrenPromises = elm['s-p'];
672
+ const postUpdate = () => postUpdateComponent(hostRef);
673
+ if (childrenPromises.length === 0) {
674
+ postUpdate();
675
+ }
676
+ else {
677
+ Promise.all(childrenPromises).then(postUpdate);
678
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
679
+ childrenPromises.length = 0;
680
+ }
681
+ }
682
+ };
683
+ const callRender = (hostRef, instance, elm) => {
684
+ try {
685
+ instance = instance.render() ;
686
+ {
687
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
688
+ }
689
+ {
690
+ hostRef.$flags$ |= 2 /* hasRendered */;
691
+ }
692
+ {
693
+ {
694
+ // looks like we've got child nodes to render into this host element
695
+ // or we need to update the css class/attrs on the host element
696
+ // DOM WRITE!
697
+ {
698
+ renderVdom(hostRef, instance);
699
+ }
700
+ }
701
+ }
702
+ }
703
+ catch (e) {
704
+ consoleError(e, hostRef.$hostElement$);
705
+ }
706
+ return null;
707
+ };
708
+ const postUpdateComponent = (hostRef) => {
709
+ const tagName = hostRef.$cmpMeta$.$tagName$;
710
+ const elm = hostRef.$hostElement$;
711
+ const endPostUpdate = createTime('postUpdate', tagName);
712
+ const instance = hostRef.$lazyInstance$ ;
713
+ const ancestorComponent = hostRef.$ancestorComponent$;
714
+ {
715
+ safeCall(instance, 'componentDidRender');
716
+ }
717
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
718
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
719
+ {
720
+ // DOM WRITE!
721
+ addHydratedFlag(elm);
722
+ }
723
+ endPostUpdate();
724
+ {
725
+ hostRef.$onReadyResolve$(elm);
726
+ if (!ancestorComponent) {
727
+ appDidLoad();
728
+ }
729
+ }
730
+ }
731
+ else {
732
+ endPostUpdate();
733
+ }
734
+ // load events fire from bottom to top
735
+ // the deepest elements load first then bubbles up
736
+ {
737
+ if (hostRef.$onRenderResolve$) {
738
+ hostRef.$onRenderResolve$();
739
+ hostRef.$onRenderResolve$ = undefined;
740
+ }
741
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
742
+ nextTick(() => scheduleUpdate(hostRef, false));
743
+ }
744
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
745
+ }
746
+ // ( •_•)
747
+ // ( •_•)>⌐■-■
748
+ // (⌐■_■)
749
+ };
750
+ const appDidLoad = (who) => {
751
+ // on appload
752
+ // we have finish the first big initial render
753
+ {
754
+ addHydratedFlag(doc.documentElement);
755
+ }
756
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
757
+ };
758
+ const safeCall = (instance, method, arg) => {
759
+ if (instance && instance[method]) {
760
+ try {
761
+ return instance[method](arg);
762
+ }
763
+ catch (e) {
764
+ consoleError(e);
765
+ }
766
+ }
767
+ return undefined;
768
+ };
769
+ const then = (promise, thenFn) => {
770
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
771
+ };
772
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
773
+ ;
774
+ /**
775
+ * Parse a new property value for a given property type.
776
+ *
777
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
778
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
779
+ * 1. `any`, the type given to `propValue` in the function signature
780
+ * 2. the type stored from `propType`.
781
+ *
782
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
783
+ *
784
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
785
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
786
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
787
+ * ```tsx
788
+ * <my-cmp prop-val={0}></my-cmp>
789
+ * ```
790
+ *
791
+ * HTML prop values on the other hand, will always a string
792
+ *
793
+ * @param propValue the new value to coerce to some type
794
+ * @param propType the type of the prop, expressed as a binary number
795
+ * @returns the parsed/coerced value
796
+ */
797
+ const parsePropertyValue = (propValue, propType) => {
798
+ // ensure this value is of the correct prop type
799
+ if (propValue != null && !isComplexType(propValue)) {
800
+ if (propType & 1 /* String */) {
801
+ // could have been passed as a number or boolean
802
+ // but we still want it as a string
803
+ return String(propValue);
804
+ }
805
+ // redundant return here for better minification
806
+ return propValue;
807
+ }
808
+ // not sure exactly what type we want
809
+ // so no need to change to a different type
810
+ return propValue;
811
+ };
812
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
813
+ const setValue = (ref, propName, newVal, cmpMeta) => {
814
+ // check our new property value against our internal value
815
+ const hostRef = getHostRef(ref);
816
+ const elm = hostRef.$hostElement$ ;
817
+ const oldVal = hostRef.$instanceValues$.get(propName);
818
+ const flags = hostRef.$flags$;
819
+ const instance = hostRef.$lazyInstance$ ;
820
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
821
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
822
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
823
+ const didValueChange = newVal !== oldVal && !areBothNaN;
824
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
825
+ // gadzooks! the property's value has changed!!
826
+ // set our new value!
827
+ hostRef.$instanceValues$.set(propName, newVal);
828
+ if (instance) {
829
+ // get an array of method names of watch functions to call
830
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
831
+ const watchMethods = cmpMeta.$watchers$[propName];
832
+ if (watchMethods) {
833
+ // this instance is watching for when this property changed
834
+ watchMethods.map((watchMethodName) => {
835
+ try {
836
+ // fire off each of the watch methods that are watching this property
837
+ instance[watchMethodName](newVal, oldVal, propName);
838
+ }
839
+ catch (e) {
840
+ consoleError(e, elm);
841
+ }
842
+ });
843
+ }
844
+ }
845
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
846
+ // looks like this value actually changed, so we've got work to do!
847
+ // but only if we've already rendered, otherwise just chill out
848
+ // queue that we need to do an update, but don't worry about queuing
849
+ // up millions cuz this function ensures it only runs once
850
+ scheduleUpdate(hostRef, false);
851
+ }
852
+ }
853
+ }
854
+ };
855
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
856
+ if (cmpMeta.$members$) {
857
+ if (Cstr.watchers) {
858
+ cmpMeta.$watchers$ = Cstr.watchers;
859
+ }
860
+ // It's better to have a const than two Object.entries()
861
+ const members = Object.entries(cmpMeta.$members$);
862
+ const prototype = Cstr.prototype;
863
+ members.map(([memberName, [memberFlags]]) => {
864
+ if ((memberFlags & 31 /* Prop */ ||
865
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
866
+ // proxyComponent - prop
867
+ Object.defineProperty(prototype, memberName, {
868
+ get() {
869
+ // proxyComponent, get value
870
+ return getValue(this, memberName);
871
+ },
872
+ set(newValue) {
873
+ // proxyComponent, set value
874
+ setValue(this, memberName, newValue, cmpMeta);
875
+ },
876
+ configurable: true,
877
+ enumerable: true,
878
+ });
879
+ }
880
+ });
881
+ if ((flags & 1 /* isElementConstructor */)) {
882
+ const attrNameToPropName = new Map();
883
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
884
+ plt.jmp(() => {
885
+ const propName = attrNameToPropName.get(attrName);
886
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
887
+ // in the case where an attribute was set inline.
888
+ // ```html
889
+ // <my-component some-attribute="some-value"></my-component>
890
+ // ```
891
+ //
892
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
893
+ // programmatically changes it before it has been upgraded as shown below:
894
+ //
895
+ // ```html
896
+ // <!-- this component has _not_ been upgraded yet -->
897
+ // <my-component id="test" some-attribute="some-value"></my-component>
898
+ // <script>
899
+ // // grab non-upgraded component
900
+ // el = document.querySelector("#test");
901
+ // el.someAttribute = "another-value";
902
+ // // upgrade component
903
+ // customElements.define('my-component', MyComponent);
904
+ // </script>
905
+ // ```
906
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
907
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
908
+ // to the value that was set inline i.e. "some-value" from above example. When
909
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
910
+ //
911
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
912
+ // by connectedCallback as this attributeChangedCallback will not fire.
913
+ //
914
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
915
+ //
916
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
917
+ // properties here given that this goes against best practices outlined here
918
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
919
+ if (this.hasOwnProperty(propName)) {
920
+ newValue = this[propName];
921
+ delete this[propName];
922
+ }
923
+ else if (prototype.hasOwnProperty(propName) &&
924
+ typeof this[propName] === 'number' &&
925
+ this[propName] == newValue) {
926
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
927
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
928
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
929
+ return;
930
+ }
931
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
932
+ });
933
+ };
934
+ // create an array of attributes to observe
935
+ // and also create a map of html attribute name to js property name
936
+ Cstr.observedAttributes = members
937
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
938
+ .map(([propName, m]) => {
939
+ const attrName = m[1] || propName;
940
+ attrNameToPropName.set(attrName, propName);
941
+ if (m[0] & 512 /* ReflectAttr */) {
942
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
943
+ }
944
+ return attrName;
945
+ });
946
+ }
947
+ }
948
+ return Cstr;
949
+ };
950
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
951
+ // initializeComponent
952
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
953
+ {
954
+ // we haven't initialized this element yet
955
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
956
+ // lazy loaded components
957
+ // request the component's implementation to be
958
+ // wired up with the host element
959
+ Cstr = loadModule(cmpMeta);
960
+ if (Cstr.then) {
961
+ // Await creates a micro-task avoid if possible
962
+ const endLoad = uniqueTime();
963
+ Cstr = await Cstr;
964
+ endLoad();
965
+ }
966
+ if (!Cstr.isProxied) {
967
+ // we've never proxied this Constructor before
968
+ // let's add the getters/setters to its prototype before
969
+ // the first time we create an instance of the implementation
970
+ {
971
+ cmpMeta.$watchers$ = Cstr.watchers;
972
+ }
973
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
974
+ Cstr.isProxied = true;
975
+ }
976
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
977
+ // ok, time to construct the instance
978
+ // but let's keep track of when we start and stop
979
+ // so that the getters/setters don't incorrectly step on data
980
+ {
981
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
982
+ }
983
+ // construct the lazy-loaded component implementation
984
+ // passing the hostRef is very important during
985
+ // construction in order to directly wire together the
986
+ // host element and the lazy-loaded instance
987
+ try {
988
+ new Cstr(hostRef);
989
+ }
990
+ catch (e) {
991
+ consoleError(e);
992
+ }
993
+ {
994
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
995
+ }
996
+ {
997
+ hostRef.$flags$ |= 128 /* isWatchReady */;
998
+ }
999
+ endNewInstance();
1000
+ }
1001
+ if (Cstr.style) {
1002
+ // this component has styles but we haven't registered them yet
1003
+ let style = Cstr.style;
1004
+ const scopeId = getScopeId(cmpMeta);
1005
+ if (!styles.has(scopeId)) {
1006
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1007
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1008
+ endRegisterStyles();
1009
+ }
1010
+ }
1011
+ }
1012
+ // we've successfully created a lazy instance
1013
+ const ancestorComponent = hostRef.$ancestorComponent$;
1014
+ const schedule = () => scheduleUpdate(hostRef, true);
1015
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1016
+ // this is the initial load and this component it has an ancestor component
1017
+ // but the ancestor component has NOT fired its will update lifecycle yet
1018
+ // so let's just cool our jets and wait for the ancestor to continue first
1019
+ // this will get fired off when the ancestor component
1020
+ // finally gets around to rendering its lazy self
1021
+ // fire off the initial update
1022
+ ancestorComponent['s-rc'].push(schedule);
1023
+ }
1024
+ else {
1025
+ schedule();
1026
+ }
1027
+ };
1028
+ const connectedCallback = (elm) => {
1029
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1030
+ const hostRef = getHostRef(elm);
1031
+ const cmpMeta = hostRef.$cmpMeta$;
1032
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1033
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1034
+ // first time this component has connected
1035
+ hostRef.$flags$ |= 1 /* hasConnected */;
1036
+ {
1037
+ // find the first ancestor component (if there is one) and register
1038
+ // this component as one of the actively loading child components for its ancestor
1039
+ let ancestorComponent = elm;
1040
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1041
+ // climb up the ancestors looking for the first
1042
+ // component that hasn't finished its lifecycle update yet
1043
+ if (ancestorComponent['s-p']) {
1044
+ // we found this components first ancestor component
1045
+ // keep a reference to this component's ancestor component
1046
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1047
+ break;
1048
+ }
1049
+ }
1050
+ }
1051
+ // Lazy properties
1052
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1053
+ if (cmpMeta.$members$) {
1054
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1055
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1056
+ const value = elm[memberName];
1057
+ delete elm[memberName];
1058
+ elm[memberName] = value;
1059
+ }
1060
+ });
1061
+ }
1062
+ {
1063
+ initializeComponent(elm, hostRef, cmpMeta);
1064
+ }
1065
+ }
1066
+ else {
1067
+ // not the first time this has connected
1068
+ // reattach any event listeners to the host
1069
+ // since they would have been removed when disconnected
1070
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1071
+ }
1072
+ endConnected();
1073
+ }
1074
+ };
1075
+ const disconnectedCallback = (elm) => {
1076
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1077
+ const hostRef = getHostRef(elm);
1078
+ const instance = hostRef.$lazyInstance$ ;
1079
+ {
1080
+ if (hostRef.$rmListeners$) {
1081
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1082
+ hostRef.$rmListeners$ = undefined;
1083
+ }
1084
+ }
1085
+ {
1086
+ safeCall(instance, 'disconnectedCallback');
1087
+ }
1088
+ }
1089
+ };
1090
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1091
+ const endBootstrap = createTime();
1092
+ const cmpTags = [];
1093
+ const exclude = options.exclude || [];
1094
+ const customElements = win.customElements;
1095
+ const head = doc.head;
1096
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1097
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1098
+ const deferredConnectedCallbacks = [];
1099
+ let appLoadFallback;
1100
+ let isBootstrapping = true;
1101
+ Object.assign(plt, options);
1102
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1103
+ lazyBundles.map((lazyBundle) => {
1104
+ lazyBundle[1].map((compactMeta) => {
1105
+ const cmpMeta = {
1106
+ $flags$: compactMeta[0],
1107
+ $tagName$: compactMeta[1],
1108
+ $members$: compactMeta[2],
1109
+ $listeners$: compactMeta[3],
1110
+ };
1111
+ {
1112
+ cmpMeta.$members$ = compactMeta[2];
1113
+ }
1114
+ {
1115
+ cmpMeta.$listeners$ = compactMeta[3];
1116
+ }
1117
+ {
1118
+ cmpMeta.$attrsToReflect$ = [];
1119
+ }
1120
+ {
1121
+ cmpMeta.$watchers$ = {};
1122
+ }
1123
+ const tagName = cmpMeta.$tagName$;
1124
+ const HostElement = class extends HTMLElement {
1125
+ // StencilLazyHost
1126
+ constructor(self) {
1127
+ // @ts-ignore
1128
+ super(self);
1129
+ self = this;
1130
+ registerHost(self, cmpMeta);
1131
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1132
+ // this component is using shadow dom
1133
+ // and this browser supports shadow dom
1134
+ // add the read-only property "shadowRoot" to the host element
1135
+ // adding the shadow root build conditionals to minimize runtime
1136
+ {
1137
+ {
1138
+ self.attachShadow({ mode: 'open' });
1139
+ }
1140
+ }
1141
+ }
1142
+ }
1143
+ connectedCallback() {
1144
+ if (appLoadFallback) {
1145
+ clearTimeout(appLoadFallback);
1146
+ appLoadFallback = null;
1147
+ }
1148
+ if (isBootstrapping) {
1149
+ // connectedCallback will be processed once all components have been registered
1150
+ deferredConnectedCallbacks.push(this);
1151
+ }
1152
+ else {
1153
+ plt.jmp(() => connectedCallback(this));
1154
+ }
1155
+ }
1156
+ disconnectedCallback() {
1157
+ plt.jmp(() => disconnectedCallback(this));
1158
+ }
1159
+ componentOnReady() {
1160
+ return getHostRef(this).$onReadyPromise$;
1161
+ }
1162
+ };
1163
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1164
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1165
+ cmpTags.push(tagName);
1166
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1167
+ }
1168
+ });
1169
+ });
1170
+ {
1171
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1172
+ visibilityStyle.setAttribute('data-styles', '');
1173
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1174
+ }
1175
+ // Process deferred connectedCallbacks now all components have been registered
1176
+ isBootstrapping = false;
1177
+ if (deferredConnectedCallbacks.length) {
1178
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1179
+ }
1180
+ else {
1181
+ {
1182
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1183
+ }
1184
+ }
1185
+ // Fallback appLoad event
1186
+ endBootstrap();
1187
+ };
1188
+ const hostRefs = new WeakMap();
1189
+ const getHostRef = (ref) => hostRefs.get(ref);
1190
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1191
+ const registerHost = (elm, cmpMeta) => {
1192
+ const hostRef = {
1193
+ $flags$: 0,
1194
+ $hostElement$: elm,
1195
+ $cmpMeta$: cmpMeta,
1196
+ $instanceValues$: new Map(),
1197
+ };
1198
+ {
1199
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1200
+ elm['s-p'] = [];
1201
+ elm['s-rc'] = [];
1202
+ }
1203
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1204
+ return hostRefs.set(elm, hostRef);
1205
+ };
1206
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1207
+ const consoleError = (e, el) => (0, console.error)(e, el);
1208
+ const cmpModules = /*@__PURE__*/ new Map();
1209
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1210
+ // loadModuleImport
1211
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1212
+ const bundleId = cmpMeta.$lazyBundleId$;
1213
+ const module = cmpModules.get(bundleId) ;
1214
+ if (module) {
1215
+ return module[exportName];
1216
+ }
1217
+ return import(
1218
+ /* webpackInclude: /\.entry\.js$/ */
1219
+ /* webpackExclude: /\.system\.entry\.js$/ */
1220
+ /* webpackMode: "lazy" */
1221
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
1222
+ {
1223
+ cmpModules.set(bundleId, importedModule);
1224
+ }
1225
+ return importedModule[exportName];
1226
+ }, consoleError);
1227
+ };
1228
+ const styles = new Map();
1229
+ const queueDomReads = [];
1230
+ const queueDomWrites = [];
1231
+ const queueTask = (queue, write) => (cb) => {
1232
+ queue.push(cb);
1233
+ if (!queuePending) {
1234
+ queuePending = true;
1235
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1236
+ nextTick(flush);
1237
+ }
1238
+ else {
1239
+ plt.raf(flush);
1240
+ }
1241
+ }
1242
+ };
1243
+ const consume = (queue) => {
1244
+ for (let i = 0; i < queue.length; i++) {
1245
+ try {
1246
+ queue[i](performance.now());
1247
+ }
1248
+ catch (e) {
1249
+ consoleError(e);
1250
+ }
1251
+ }
1252
+ queue.length = 0;
1253
+ };
1254
+ const flush = () => {
1255
+ // always force a bunch of medium callbacks to run, but still have
1256
+ // a throttle on how many can run in a certain time
1257
+ // DOM READS!!!
1258
+ consume(queueDomReads);
1259
+ // DOM WRITES!!!
1260
+ {
1261
+ consume(queueDomWrites);
1262
+ if ((queuePending = queueDomReads.length > 0)) {
1263
+ // still more to do yet, but we've run out of time
1264
+ // let's let this thing cool off and try again in the next tick
1265
+ plt.raf(flush);
1266
+ }
1267
+ }
1268
+ };
1269
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1270
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1271
+
1272
+ export { bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r };