@everymatrix/casino-tournament-slider 1.16.1

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