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