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