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