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