@jumpgroup/jump-design-system 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/app-button.cjs.entry.js +29 -0
  3. package/dist/cjs/app-button.cjs.entry.js.map +1 -0
  4. package/dist/cjs/app-icon.cjs.entry.js +2432 -0
  5. package/dist/cjs/app-icon.cjs.entry.js.map +1 -0
  6. package/dist/cjs/index-95f2f619.js +1750 -0
  7. package/dist/cjs/index-95f2f619.js.map +1 -0
  8. package/dist/cjs/index.cjs.js +4 -0
  9. package/dist/cjs/index.cjs.js.map +1 -0
  10. package/dist/cjs/jump-design-system.cjs.js +28 -0
  11. package/dist/cjs/jump-design-system.cjs.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +24 -0
  13. package/dist/cjs/loader.cjs.js.map +1 -0
  14. package/dist/collection/collection-manifest.json +13 -0
  15. package/dist/collection/components/app-button/app-button.css +107 -0
  16. package/dist/collection/components/app-button/app-button.js +158 -0
  17. package/dist/collection/components/app-button/app-button.js.map +1 -0
  18. package/dist/collection/components/app-button/app-button.stories.js +227 -0
  19. package/dist/collection/components/app-button/app-button.stories.js.map +1 -0
  20. package/dist/collection/components/app-icon/app-icon.css +7 -0
  21. package/dist/collection/components/app-icon/app-icon.js +64 -0
  22. package/dist/collection/components/app-icon/app-icon.js.map +1 -0
  23. package/dist/collection/components/app-icon/app-icon.stories.js +25 -0
  24. package/dist/collection/components/app-icon/app-icon.stories.js.map +1 -0
  25. package/dist/collection/index.js +2 -0
  26. package/dist/collection/index.js.map +1 -0
  27. package/dist/collection/stories/Colors.js +14 -0
  28. package/dist/collection/stories/assets/code-brackets.svg +1 -0
  29. package/dist/collection/stories/assets/colors.svg +1 -0
  30. package/dist/collection/stories/assets/comments.svg +1 -0
  31. package/dist/collection/stories/assets/direction.svg +1 -0
  32. package/dist/collection/stories/assets/flow.svg +1 -0
  33. package/dist/collection/stories/assets/plugin.svg +1 -0
  34. package/dist/collection/stories/assets/repo.svg +1 -0
  35. package/dist/collection/stories/assets/stackalt.svg +1 -0
  36. package/dist/collection/utils/utils.js +4 -0
  37. package/dist/collection/utils/utils.js.map +1 -0
  38. package/dist/components/app-button.d.ts +11 -0
  39. package/dist/components/app-button.js +50 -0
  40. package/dist/components/app-button.js.map +1 -0
  41. package/dist/components/app-icon.d.ts +11 -0
  42. package/dist/components/app-icon.js +2448 -0
  43. package/dist/components/app-icon.js.map +1 -0
  44. package/dist/components/index.d.ts +27 -0
  45. package/dist/components/index.js +3 -0
  46. package/dist/components/index.js.map +1 -0
  47. package/dist/esm/app-button.entry.js +25 -0
  48. package/dist/esm/app-button.entry.js.map +1 -0
  49. package/dist/esm/app-icon.entry.js +2428 -0
  50. package/dist/esm/app-icon.entry.js.map +1 -0
  51. package/dist/esm/index-4c9cac2b.js +1723 -0
  52. package/dist/esm/index-4c9cac2b.js.map +1 -0
  53. package/dist/esm/index.js +3 -0
  54. package/dist/esm/index.js.map +1 -0
  55. package/dist/esm/jump-design-system.js +23 -0
  56. package/dist/esm/jump-design-system.js.map +1 -0
  57. package/dist/esm/loader.js +20 -0
  58. package/dist/esm/loader.js.map +1 -0
  59. package/dist/esm/polyfills/core-js.js +11 -0
  60. package/dist/esm/polyfills/css-shim.js +1 -0
  61. package/dist/esm/polyfills/dom.js +79 -0
  62. package/dist/esm/polyfills/es5-html-element.js +1 -0
  63. package/dist/esm/polyfills/index.js +34 -0
  64. package/dist/esm/polyfills/system.js +6 -0
  65. package/dist/index.cjs.js +1 -0
  66. package/dist/index.js +1 -0
  67. package/dist/jump-design-system/index.esm.js +2 -0
  68. package/dist/jump-design-system/index.esm.js.map +1 -0
  69. package/dist/jump-design-system/jump-design-system.esm.js +2 -0
  70. package/dist/jump-design-system/jump-design-system.esm.js.map +1 -0
  71. package/dist/jump-design-system/p-08fde855.entry.js +2 -0
  72. package/dist/jump-design-system/p-08fde855.entry.js.map +1 -0
  73. package/dist/jump-design-system/p-771ebb2a.entry.js +331 -0
  74. package/dist/jump-design-system/p-771ebb2a.entry.js.map +1 -0
  75. package/dist/jump-design-system/p-fce83307.js +3 -0
  76. package/dist/jump-design-system/p-fce83307.js.map +1 -0
  77. package/dist/types/components/app-button/app-button.d.ts +31 -0
  78. package/dist/types/components/app-button/app-button.stories.d.ts +95 -0
  79. package/dist/types/components/app-icon/app-icon.d.ts +12 -0
  80. package/dist/types/components/app-icon/app-icon.stories.d.ts +19 -0
  81. package/dist/types/components.d.ts +122 -0
  82. package/dist/types/index.d.ts +1 -0
  83. package/dist/types/stencil-public-runtime.d.ts +1638 -0
  84. package/dist/types/utils/utils.d.ts +1 -0
  85. package/loader/cdn.js +3 -0
  86. package/loader/index.cjs.js +3 -0
  87. package/loader/index.d.ts +21 -0
  88. package/loader/index.es2017.js +3 -0
  89. package/loader/index.js +4 -0
  90. package/loader/package.json +11 -0
  91. package/package.json +61 -0
  92. package/readme.md +91 -0
@@ -0,0 +1,1750 @@
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 = 'jump-design-system';
24
+
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
33
+ let contentRef;
34
+ let hostTagName;
35
+ let useNativeShadowDom = false;
36
+ let checkSlotFallbackVisibility = false;
37
+ let checkSlotRelocate = false;
38
+ let isSvgMode = false;
39
+ let queuePending = false;
40
+ const createTime = (fnName, tagName = '') => {
41
+ {
42
+ return () => {
43
+ return;
44
+ };
45
+ }
46
+ };
47
+ const uniqueTime = (key, measureText) => {
48
+ {
49
+ return () => {
50
+ return;
51
+ };
52
+ }
53
+ };
54
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
55
+ /**
56
+ * Default style mode id
57
+ */
58
+ /**
59
+ * Reusable empty obj/array
60
+ * Don't add values to these!!
61
+ */
62
+ const EMPTY_OBJ = {};
63
+ /**
64
+ * Check whether a value is a 'complex type', defined here as an object or a
65
+ * function.
66
+ *
67
+ * @param o the value to check
68
+ * @returns whether it's a complex type or not
69
+ */
70
+ const isComplexType = (o) => {
71
+ // https://jsperf.com/typeof-fn-object/5
72
+ o = typeof o;
73
+ return o === 'object' || o === 'function';
74
+ };
75
+ /**
76
+ * Helper method for querying a `meta` tag that contains a nonce value
77
+ * out of a DOM's head.
78
+ *
79
+ * @param doc The DOM containing the `head` to query against
80
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
81
+ * exists or the tag has no content.
82
+ */
83
+ function queryNonceMetaTagContent(doc) {
84
+ var _a, _b, _c;
85
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
86
+ }
87
+ /**
88
+ * Production h() function based on Preact by
89
+ * Jason Miller (@developit)
90
+ * Licensed under the MIT License
91
+ * https://github.com/developit/preact/blob/master/LICENSE
92
+ *
93
+ * Modified for Stencil's compiler and vdom
94
+ */
95
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
96
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
97
+ const h = (nodeName, vnodeData, ...children) => {
98
+ let child = null;
99
+ let slotName = null;
100
+ let simple = false;
101
+ let lastSimple = false;
102
+ const vNodeChildren = [];
103
+ const walk = (c) => {
104
+ for (let i = 0; i < c.length; i++) {
105
+ child = c[i];
106
+ if (Array.isArray(child)) {
107
+ walk(child);
108
+ }
109
+ else if (child != null && typeof child !== 'boolean') {
110
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
111
+ child = String(child);
112
+ }
113
+ if (simple && lastSimple) {
114
+ // If the previous child was simple (string), we merge both
115
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
116
+ }
117
+ else {
118
+ // Append a new vNode, if it's text, we create a text vNode
119
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
120
+ }
121
+ lastSimple = simple;
122
+ }
123
+ }
124
+ };
125
+ walk(children);
126
+ if (vnodeData) {
127
+ if (vnodeData.name) {
128
+ slotName = vnodeData.name;
129
+ }
130
+ {
131
+ const classData = vnodeData.className || vnodeData.class;
132
+ if (classData) {
133
+ vnodeData.class =
134
+ typeof classData !== 'object'
135
+ ? classData
136
+ : Object.keys(classData)
137
+ .filter((k) => classData[k])
138
+ .join(' ');
139
+ }
140
+ }
141
+ }
142
+ const vnode = newVNode(nodeName, null);
143
+ vnode.$attrs$ = vnodeData;
144
+ if (vNodeChildren.length > 0) {
145
+ vnode.$children$ = vNodeChildren;
146
+ }
147
+ {
148
+ vnode.$name$ = slotName;
149
+ }
150
+ return vnode;
151
+ };
152
+ /**
153
+ * A utility function for creating a virtual DOM node from a tag and some
154
+ * possible text content.
155
+ *
156
+ * @param tag the tag for this element
157
+ * @param text possible text content for the node
158
+ * @returns a newly-minted virtual DOM node
159
+ */
160
+ const newVNode = (tag, text) => {
161
+ const vnode = {
162
+ $flags$: 0,
163
+ $tag$: tag,
164
+ $text$: text,
165
+ $elm$: null,
166
+ $children$: null,
167
+ };
168
+ {
169
+ vnode.$attrs$ = null;
170
+ }
171
+ {
172
+ vnode.$name$ = null;
173
+ }
174
+ return vnode;
175
+ };
176
+ const Host = {};
177
+ /**
178
+ * Check whether a given node is a Host node or not
179
+ *
180
+ * @param node the virtual DOM node to check
181
+ * @returns whether it's a Host node or not
182
+ */
183
+ const isHost = (node) => node && node.$tag$ === Host;
184
+ /**
185
+ * Parse a new property value for a given property type.
186
+ *
187
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
188
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
189
+ * 1. `any`, the type given to `propValue` in the function signature
190
+ * 2. the type stored from `propType`.
191
+ *
192
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
193
+ *
194
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
195
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
196
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
197
+ * ```tsx
198
+ * <my-cmp prop-val={0}></my-cmp>
199
+ * ```
200
+ *
201
+ * HTML prop values on the other hand, will always a string
202
+ *
203
+ * @param propValue the new value to coerce to some type
204
+ * @param propType the type of the prop, expressed as a binary number
205
+ * @returns the parsed/coerced value
206
+ */
207
+ const parsePropertyValue = (propValue, propType) => {
208
+ // ensure this value is of the correct prop type
209
+ if (propValue != null && !isComplexType(propValue)) {
210
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
211
+ // per the HTML spec, any string value means it is a boolean true value
212
+ // but we'll cheat here and say that the string "false" is the boolean false
213
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
214
+ }
215
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
216
+ // could have been passed as a number or boolean
217
+ // but we still want it as a string
218
+ return String(propValue);
219
+ }
220
+ // redundant return here for better minification
221
+ return propValue;
222
+ }
223
+ // not sure exactly what type we want
224
+ // so no need to change to a different type
225
+ return propValue;
226
+ };
227
+ /**
228
+ * Helper function to create & dispatch a custom Event on a provided target
229
+ * @param elm the target of the Event
230
+ * @param name the name to give the custom Event
231
+ * @param opts options for configuring a custom Event
232
+ * @returns the custom Event
233
+ */
234
+ const emitEvent = (elm, name, opts) => {
235
+ const ev = plt.ce(name, opts);
236
+ elm.dispatchEvent(ev);
237
+ return ev;
238
+ };
239
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
240
+ const registerStyle = (scopeId, cssText, allowCS) => {
241
+ let style = styles.get(scopeId);
242
+ if (supportsConstructableStylesheets && allowCS) {
243
+ style = (style || new CSSStyleSheet());
244
+ if (typeof style === 'string') {
245
+ style = cssText;
246
+ }
247
+ else {
248
+ style.replaceSync(cssText);
249
+ }
250
+ }
251
+ else {
252
+ style = cssText;
253
+ }
254
+ styles.set(scopeId, style);
255
+ };
256
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
257
+ var _a;
258
+ let scopeId = getScopeId(cmpMeta);
259
+ const style = styles.get(scopeId);
260
+ // if an element is NOT connected then getRootNode() will return the wrong root node
261
+ // so the fallback is to always use the document for the root node in those cases
262
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
263
+ if (style) {
264
+ if (typeof style === 'string') {
265
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
266
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
267
+ let styleElm;
268
+ if (!appliedStyles) {
269
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
270
+ }
271
+ if (!appliedStyles.has(scopeId)) {
272
+ {
273
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
274
+ {
275
+ styleElm = doc.createElement('style');
276
+ styleElm.innerHTML = style;
277
+ }
278
+ // Apply CSP nonce to the style tag if it exists
279
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
280
+ if (nonce != null) {
281
+ styleElm.setAttribute('nonce', nonce);
282
+ }
283
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
284
+ }
285
+ if (appliedStyles) {
286
+ appliedStyles.add(scopeId);
287
+ }
288
+ }
289
+ }
290
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
291
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
292
+ }
293
+ }
294
+ return scopeId;
295
+ };
296
+ const attachStyles = (hostRef) => {
297
+ const cmpMeta = hostRef.$cmpMeta$;
298
+ const elm = hostRef.$hostElement$;
299
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
300
+ addStyle(elm.getRootNode(), cmpMeta);
301
+ endAttachStyles();
302
+ };
303
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
304
+ /**
305
+ * Production setAccessor() function based on Preact by
306
+ * Jason Miller (@developit)
307
+ * Licensed under the MIT License
308
+ * https://github.com/developit/preact/blob/master/LICENSE
309
+ *
310
+ * Modified for Stencil's compiler and vdom
311
+ */
312
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
313
+ if (oldValue !== newValue) {
314
+ let isProp = isMemberInElement(elm, memberName);
315
+ memberName.toLowerCase();
316
+ if (memberName === 'class') {
317
+ const classList = elm.classList;
318
+ const oldClasses = parseClassList(oldValue);
319
+ const newClasses = parseClassList(newValue);
320
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
321
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
322
+ }
323
+ else {
324
+ // Set property if it exists and it's not a SVG
325
+ const isComplex = isComplexType(newValue);
326
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
327
+ try {
328
+ if (!elm.tagName.includes('-')) {
329
+ const n = newValue == null ? '' : newValue;
330
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
331
+ if (memberName === 'list') {
332
+ isProp = false;
333
+ }
334
+ else if (oldValue == null || elm[memberName] != n) {
335
+ elm[memberName] = n;
336
+ }
337
+ }
338
+ else {
339
+ elm[memberName] = newValue;
340
+ }
341
+ }
342
+ catch (e) { }
343
+ }
344
+ if (newValue == null || newValue === false) {
345
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
346
+ {
347
+ elm.removeAttribute(memberName);
348
+ }
349
+ }
350
+ }
351
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
352
+ newValue = newValue === true ? '' : newValue;
353
+ {
354
+ elm.setAttribute(memberName, newValue);
355
+ }
356
+ }
357
+ }
358
+ }
359
+ };
360
+ const parseClassListRegex = /\s/;
361
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
362
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
363
+ // if the element passed in is a shadow root, which is a document fragment
364
+ // then we want to be adding attrs/props to the shadow root's "host" element
365
+ // if it's not a shadow root, then we add attrs/props to the same element
366
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
367
+ ? newVnode.$elm$.host
368
+ : newVnode.$elm$;
369
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
370
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
371
+ {
372
+ // remove attributes no longer present on the vnode by setting them to undefined
373
+ for (memberName in oldVnodeAttrs) {
374
+ if (!(memberName in newVnodeAttrs)) {
375
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
376
+ }
377
+ }
378
+ }
379
+ // add new & update changed attributes
380
+ for (memberName in newVnodeAttrs) {
381
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
382
+ }
383
+ };
384
+ /**
385
+ * Create a DOM Node corresponding to one of the children of a given VNode.
386
+ *
387
+ * @param oldParentVNode the parent VNode from the previous render
388
+ * @param newParentVNode the parent VNode from the current render
389
+ * @param childIndex the index of the VNode, in the _new_ parent node's
390
+ * children, for which we will create a new DOM node
391
+ * @param parentElm the parent DOM node which our new node will be a child of
392
+ * @returns the newly created node
393
+ */
394
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
395
+ // tslint:disable-next-line: prefer-const
396
+ const newVNode = newParentVNode.$children$[childIndex];
397
+ let i = 0;
398
+ let elm;
399
+ let childNode;
400
+ let oldVNode;
401
+ if (!useNativeShadowDom) {
402
+ // remember for later we need to check to relocate nodes
403
+ checkSlotRelocate = true;
404
+ if (newVNode.$tag$ === 'slot') {
405
+ newVNode.$flags$ |= newVNode.$children$
406
+ ? // slot element has fallback content
407
+ 2 /* VNODE_FLAGS.isSlotFallback */
408
+ : // slot element does not have fallback content
409
+ 1 /* VNODE_FLAGS.isSlotReference */;
410
+ }
411
+ }
412
+ if (newVNode.$text$ !== null) {
413
+ // create text node
414
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
415
+ }
416
+ else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
417
+ // create a slot reference node
418
+ elm = newVNode.$elm$ =
419
+ doc.createTextNode('');
420
+ }
421
+ else {
422
+ // create element
423
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
424
+ ? 'slot-fb'
425
+ : newVNode.$tag$));
426
+ // add css classes, attrs, props, listeners, etc.
427
+ {
428
+ updateElement(null, newVNode, isSvgMode);
429
+ }
430
+ if (newVNode.$children$) {
431
+ for (i = 0; i < newVNode.$children$.length; ++i) {
432
+ // create the node
433
+ childNode = createElm(oldParentVNode, newVNode, i);
434
+ // return node could have been null
435
+ if (childNode) {
436
+ // append our new node
437
+ elm.appendChild(childNode);
438
+ }
439
+ }
440
+ }
441
+ }
442
+ {
443
+ elm['s-hn'] = hostTagName;
444
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
445
+ // remember the content reference comment
446
+ elm['s-sr'] = true;
447
+ // remember the content reference comment
448
+ elm['s-cr'] = contentRef;
449
+ // remember the slot name, or empty string for default slot
450
+ elm['s-sn'] = newVNode.$name$ || '';
451
+ // check if we've got an old vnode for this slot
452
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
453
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
454
+ // we've got an old slot vnode and the wrapper is being replaced
455
+ // so let's move the old slot content back to it's original location
456
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
457
+ }
458
+ }
459
+ }
460
+ return elm;
461
+ };
462
+ const putBackInOriginalLocation = (parentElm, recursive) => {
463
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
464
+ const oldSlotChildNodes = parentElm.childNodes;
465
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
466
+ const childNode = oldSlotChildNodes[i];
467
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
468
+ // // this child node in the old element is from another component
469
+ // // remove this node from the old slot's parent
470
+ // childNode.remove();
471
+ // and relocate it back to it's original location
472
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
473
+ // remove the old original location comment entirely
474
+ // later on the patch function will know what to do
475
+ // and move this to the correct spot in need be
476
+ childNode['s-ol'].remove();
477
+ childNode['s-ol'] = undefined;
478
+ checkSlotRelocate = true;
479
+ }
480
+ if (recursive) {
481
+ putBackInOriginalLocation(childNode, recursive);
482
+ }
483
+ }
484
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
485
+ };
486
+ /**
487
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
488
+ * add them to the DOM in the appropriate place.
489
+ *
490
+ * @param parentElm the DOM node which should be used as a parent for the new
491
+ * DOM nodes
492
+ * @param before a child of the `parentElm` which the new children should be
493
+ * inserted before (optional)
494
+ * @param parentVNode the parent virtual DOM node
495
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
496
+ * @param startIdx the index in the child virtual DOM nodes at which to start
497
+ * creating DOM nodes (inclusive)
498
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
499
+ * creating DOM nodes (inclusive)
500
+ */
501
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
502
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
503
+ let childNode;
504
+ for (; startIdx <= endIdx; ++startIdx) {
505
+ if (vnodes[startIdx]) {
506
+ childNode = createElm(null, parentVNode, startIdx);
507
+ if (childNode) {
508
+ vnodes[startIdx].$elm$ = childNode;
509
+ containerElm.insertBefore(childNode, referenceNode(before) );
510
+ }
511
+ }
512
+ }
513
+ };
514
+ /**
515
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
516
+ * This can be used to, for instance, clean up after a list of children which
517
+ * should no longer be shown.
518
+ *
519
+ * This function also handles some of Stencil's slot relocation logic.
520
+ *
521
+ * @param vnodes a list of virtual DOM nodes to remove
522
+ * @param startIdx the index at which to start removing nodes (inclusive)
523
+ * @param endIdx the index at which to stop removing nodes (inclusive)
524
+ */
525
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
526
+ for (let index = startIdx; index <= endIdx; ++index) {
527
+ const vnode = vnodes[index];
528
+ if (vnode) {
529
+ const elm = vnode.$elm$;
530
+ if (elm) {
531
+ {
532
+ // we're removing this element
533
+ // so it's possible we need to show slot fallback content now
534
+ checkSlotFallbackVisibility = true;
535
+ if (elm['s-ol']) {
536
+ // remove the original location comment
537
+ elm['s-ol'].remove();
538
+ }
539
+ else {
540
+ // it's possible that child nodes of the node
541
+ // that's being removed are slot nodes
542
+ putBackInOriginalLocation(elm, true);
543
+ }
544
+ }
545
+ // remove the vnode's element from the dom
546
+ elm.remove();
547
+ }
548
+ }
549
+ }
550
+ };
551
+ /**
552
+ * Reconcile the children of a new VNode with the children of an old VNode by
553
+ * traversing the two collections of children, identifying nodes that are
554
+ * conserved or changed, calling out to `patch` to make any necessary
555
+ * updates to the DOM, and rearranging DOM nodes as needed.
556
+ *
557
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
558
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
559
+ * 'windows' by storing start and end indices and references to the
560
+ * corresponding array entries. Initially the two 'windows' are basically equal
561
+ * to the entire array, but we progressively narrow the windows until there are
562
+ * no children left to update by doing the following:
563
+ *
564
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
565
+ * that if we have an initial array like the following we'll end up dealing
566
+ * only with a window bounded by the highlighted elements:
567
+ *
568
+ * [null, null, VNode1 , ... , VNode2, null, null]
569
+ * ^^^^^^ ^^^^^^
570
+ *
571
+ * 2. Check to see if the elements at the head and tail positions are equal
572
+ * across the windows. This will basically detect elements which haven't
573
+ * been added, removed, or changed position, i.e. if you had the following
574
+ * VNode elements (represented as HTML):
575
+ *
576
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
577
+ * newVNode: `<div><p><span>THERE</span></p></div>`
578
+ *
579
+ * Then when comparing the children of the `<div>` tag we check the equality
580
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
581
+ * same tag in the same position, we'd be able to avoid completely
582
+ * re-rendering the subtree under them with a new DOM element and would just
583
+ * call out to `patch` to handle reconciling their children and so on.
584
+ *
585
+ * 3. Check, for both windows, to see if the element at the beginning of the
586
+ * window corresponds to the element at the end of the other window. This is
587
+ * a heuristic which will let us identify _some_ situations in which
588
+ * elements have changed position, for instance it _should_ detect that the
589
+ * children nodes themselves have not changed but merely moved in the
590
+ * following example:
591
+ *
592
+ * oldVNode: `<div><element-one /><element-two /></div>`
593
+ * newVNode: `<div><element-two /><element-one /></div>`
594
+ *
595
+ * If we find cases like this then we also need to move the concrete DOM
596
+ * elements corresponding to the moved children to write the re-order to the
597
+ * DOM.
598
+ *
599
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
600
+ * nodes in the old children which have the same key as the first element in
601
+ * our window on the new children. If we find such a node we handle calling
602
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
603
+ * what we find.
604
+ *
605
+ * Finally, once we've narrowed our 'windows' to the point that either of them
606
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
607
+ * insertion or deletion that needs to happen to get a DOM state that correctly
608
+ * reflects the new child VNodes. If, for instance, after our window on the old
609
+ * children has collapsed we still have more nodes on the new children that
610
+ * we haven't dealt with yet then we need to add them, or if the new children
611
+ * collapse but we still have unhandled _old_ children then we need to make
612
+ * sure the corresponding DOM nodes are removed.
613
+ *
614
+ * @param parentElm the node into which the parent VNode is rendered
615
+ * @param oldCh the old children of the parent node
616
+ * @param newVNode the new VNode which will replace the parent
617
+ * @param newCh the new children of the parent node
618
+ */
619
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
620
+ let oldStartIdx = 0;
621
+ let newStartIdx = 0;
622
+ let oldEndIdx = oldCh.length - 1;
623
+ let oldStartVnode = oldCh[0];
624
+ let oldEndVnode = oldCh[oldEndIdx];
625
+ let newEndIdx = newCh.length - 1;
626
+ let newStartVnode = newCh[0];
627
+ let newEndVnode = newCh[newEndIdx];
628
+ let node;
629
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
630
+ if (oldStartVnode == null) {
631
+ // VNode might have been moved left
632
+ oldStartVnode = oldCh[++oldStartIdx];
633
+ }
634
+ else if (oldEndVnode == null) {
635
+ oldEndVnode = oldCh[--oldEndIdx];
636
+ }
637
+ else if (newStartVnode == null) {
638
+ newStartVnode = newCh[++newStartIdx];
639
+ }
640
+ else if (newEndVnode == null) {
641
+ newEndVnode = newCh[--newEndIdx];
642
+ }
643
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
644
+ // if the start nodes are the same then we should patch the new VNode
645
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
646
+ // indices to reflect that. We don't need to move any DOM Nodes around
647
+ // since things are matched up in order.
648
+ patch(oldStartVnode, newStartVnode);
649
+ oldStartVnode = oldCh[++oldStartIdx];
650
+ newStartVnode = newCh[++newStartIdx];
651
+ }
652
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
653
+ // likewise, if the end nodes are the same we patch new onto old and
654
+ // decrement our end indices, and also likewise in this case we don't
655
+ // need to move any DOM Nodes.
656
+ patch(oldEndVnode, newEndVnode);
657
+ oldEndVnode = oldCh[--oldEndIdx];
658
+ newEndVnode = newCh[--newEndIdx];
659
+ }
660
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
661
+ // case: "Vnode moved right"
662
+ //
663
+ // We've found that the last node in our window on the new children is
664
+ // the same VNode as the _first_ node in our window on the old children
665
+ // we're dealing with now. Visually, this is the layout of these two
666
+ // nodes:
667
+ //
668
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
669
+ // ^^^^^^^^^^^
670
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
671
+ // ^^^^^^^^^^^^^
672
+ //
673
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
674
+ // and move the DOM element for `oldStartVnode`.
675
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
676
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
677
+ }
678
+ patch(oldStartVnode, newEndVnode);
679
+ // We need to move the element for `oldStartVnode` into a position which
680
+ // will be appropriate for `newEndVnode`. For this we can use
681
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
682
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
683
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
684
+ //
685
+ // <old-start-node />
686
+ // <some-intervening-node />
687
+ // <old-end-node />
688
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
689
+ // <next-sibling />
690
+ //
691
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
692
+ // the node for `oldStartVnode` at the end of the children of
693
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
694
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
695
+ // append it to the children of the parent element.
696
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
697
+ oldStartVnode = oldCh[++oldStartIdx];
698
+ newEndVnode = newCh[--newEndIdx];
699
+ }
700
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
701
+ // case: "Vnode moved left"
702
+ //
703
+ // We've found that the first node in our window on the new children is
704
+ // the same VNode as the _last_ node in our window on the old children.
705
+ // Visually, this is the layout of these two nodes:
706
+ //
707
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
708
+ // ^^^^^^^^^^^^^
709
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
710
+ // ^^^^^^^^^^^
711
+ //
712
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
713
+ // (which will handle updating any changed attributes, reconciling their
714
+ // children etc) but we also need to move the DOM node to which
715
+ // `oldEndVnode` corresponds.
716
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
717
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
718
+ }
719
+ patch(oldEndVnode, newStartVnode);
720
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
721
+ // the same node, so since we're here we know that they are not. Thus we
722
+ // can move the element for `oldEndVnode` _before_ the element for
723
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
724
+ // future.
725
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
726
+ oldEndVnode = oldCh[--oldEndIdx];
727
+ newStartVnode = newCh[++newStartIdx];
728
+ }
729
+ else {
730
+ {
731
+ // We either didn't find an element in the old children that matches
732
+ // the key of the first new child OR the build is not using `key`
733
+ // attributes at all. In either case we need to create a new element
734
+ // for the new node.
735
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
736
+ newStartVnode = newCh[++newStartIdx];
737
+ }
738
+ if (node) {
739
+ // if we created a new node then handle inserting it to the DOM
740
+ {
741
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
742
+ }
743
+ }
744
+ }
745
+ }
746
+ if (oldStartIdx > oldEndIdx) {
747
+ // we have some more new nodes to add which don't match up with old nodes
748
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
749
+ }
750
+ else if (newStartIdx > newEndIdx) {
751
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
752
+ // in the new array, so lets remove them (which entails cleaning up the
753
+ // relevant DOM nodes)
754
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
755
+ }
756
+ };
757
+ /**
758
+ * Compare two VNodes to determine if they are the same
759
+ *
760
+ * **NB**: This function is an equality _heuristic_ based on the available
761
+ * information set on the two VNodes and can be misleading under certain
762
+ * circumstances. In particular, if the two nodes do not have `key` attrs
763
+ * (available under `$key$` on VNodes) then the function falls back on merely
764
+ * checking that they have the same tag.
765
+ *
766
+ * So, in other words, if `key` attrs are not set on VNodes which may be
767
+ * changing order within a `children` array or something along those lines then
768
+ * we could obtain a false negative and then have to do needless re-rendering
769
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
770
+ *
771
+ * @param leftVNode the first VNode to check
772
+ * @param rightVNode the second VNode to check
773
+ * @returns whether they're equal or not
774
+ */
775
+ const isSameVnode = (leftVNode, rightVNode) => {
776
+ // compare if two vnode to see if they're "technically" the same
777
+ // need to have the same element tag, and same key to be the same
778
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
779
+ if (leftVNode.$tag$ === 'slot') {
780
+ return leftVNode.$name$ === rightVNode.$name$;
781
+ }
782
+ return true;
783
+ }
784
+ return false;
785
+ };
786
+ const referenceNode = (node) => {
787
+ // this node was relocated to a new location in the dom
788
+ // because of some other component's slot
789
+ // but we still have an html comment in place of where
790
+ // it's original location was according to it's original vdom
791
+ return (node && node['s-ol']) || node;
792
+ };
793
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
794
+ /**
795
+ * Handle reconciling an outdated VNode with a new one which corresponds to
796
+ * it. This function handles flushing updates to the DOM and reconciling the
797
+ * children of the two nodes (if any).
798
+ *
799
+ * @param oldVNode an old VNode whose DOM element and children we want to update
800
+ * @param newVNode a new VNode representing an updated version of the old one
801
+ */
802
+ const patch = (oldVNode, newVNode) => {
803
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
804
+ const oldChildren = oldVNode.$children$;
805
+ const newChildren = newVNode.$children$;
806
+ const tag = newVNode.$tag$;
807
+ const text = newVNode.$text$;
808
+ let defaultHolder;
809
+ if (text === null) {
810
+ {
811
+ if (tag === 'slot')
812
+ ;
813
+ else {
814
+ // either this is the first render of an element OR it's an update
815
+ // AND we already know it's possible it could have changed
816
+ // this updates the element's css classes, attrs, props, listeners, etc.
817
+ updateElement(oldVNode, newVNode, isSvgMode);
818
+ }
819
+ }
820
+ if (oldChildren !== null && newChildren !== null) {
821
+ // looks like there's child vnodes for both the old and new vnodes
822
+ // so we need to call `updateChildren` to reconcile them
823
+ updateChildren(elm, oldChildren, newVNode, newChildren);
824
+ }
825
+ else if (newChildren !== null) {
826
+ // no old child vnodes, but there are new child vnodes to add
827
+ if (oldVNode.$text$ !== null) {
828
+ // the old vnode was text, so be sure to clear it out
829
+ elm.textContent = '';
830
+ }
831
+ // add the new vnode children
832
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
833
+ }
834
+ else if (oldChildren !== null) {
835
+ // no new child vnodes, but there are old child vnodes to remove
836
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
837
+ }
838
+ }
839
+ else if ((defaultHolder = elm['s-cr'])) {
840
+ // this element has slotted content
841
+ defaultHolder.parentNode.textContent = text;
842
+ }
843
+ else if (oldVNode.$text$ !== text) {
844
+ // update the text content for the text only vnode
845
+ // and also only if the text is different than before
846
+ elm.data = text;
847
+ }
848
+ };
849
+ const updateFallbackSlotVisibility = (elm) => {
850
+ // tslint:disable-next-line: prefer-const
851
+ const childNodes = elm.childNodes;
852
+ let childNode;
853
+ let i;
854
+ let ilen;
855
+ let j;
856
+ let slotNameAttr;
857
+ let nodeType;
858
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
859
+ childNode = childNodes[i];
860
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
861
+ if (childNode['s-sr']) {
862
+ // this is a slot fallback node
863
+ // get the slot name for this slot reference node
864
+ slotNameAttr = childNode['s-sn'];
865
+ // by default always show a fallback slot node
866
+ // then hide it if there are other slots in the light dom
867
+ childNode.hidden = false;
868
+ for (j = 0; j < ilen; j++) {
869
+ nodeType = childNodes[j].nodeType;
870
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
871
+ // this sibling node is from a different component OR is a named fallback slot node
872
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
873
+ childNode.hidden = true;
874
+ break;
875
+ }
876
+ }
877
+ else {
878
+ // this is a default fallback slot node
879
+ // any element or text node (with content)
880
+ // should hide the default fallback slot node
881
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
882
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
883
+ childNode.hidden = true;
884
+ break;
885
+ }
886
+ }
887
+ }
888
+ }
889
+ // keep drilling down
890
+ updateFallbackSlotVisibility(childNode);
891
+ }
892
+ }
893
+ };
894
+ const relocateNodes = [];
895
+ const relocateSlotContent = (elm) => {
896
+ // tslint:disable-next-line: prefer-const
897
+ let childNode;
898
+ let node;
899
+ let hostContentNodes;
900
+ let slotNameAttr;
901
+ let relocateNodeData;
902
+ let j;
903
+ let i = 0;
904
+ const childNodes = elm.childNodes;
905
+ const ilen = childNodes.length;
906
+ for (; i < ilen; i++) {
907
+ childNode = childNodes[i];
908
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
909
+ // first got the content reference comment node
910
+ // then we got it's parent, which is where all the host content is in now
911
+ hostContentNodes = node.parentNode.childNodes;
912
+ slotNameAttr = childNode['s-sn'];
913
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
914
+ node = hostContentNodes[j];
915
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
916
+ // let's do some relocating to its new home
917
+ // but never relocate a content reference node
918
+ // that is suppose to always represent the original content location
919
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
920
+ // it's possible we've already decided to relocate this node
921
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
922
+ // made some changes to slots
923
+ // let's make sure we also double check
924
+ // fallbacks are correctly hidden or shown
925
+ checkSlotFallbackVisibility = true;
926
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
927
+ if (relocateNodeData) {
928
+ // previously we never found a slot home for this node
929
+ // but turns out we did, so let's remember it now
930
+ relocateNodeData.$slotRefNode$ = childNode;
931
+ }
932
+ else {
933
+ // add to our list of nodes to relocate
934
+ relocateNodes.push({
935
+ $slotRefNode$: childNode,
936
+ $nodeToRelocate$: node,
937
+ });
938
+ }
939
+ if (node['s-sr']) {
940
+ relocateNodes.map((relocateNode) => {
941
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
942
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
943
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
944
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
945
+ }
946
+ }
947
+ });
948
+ }
949
+ }
950
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
951
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
952
+ // if we never find a home for this element then we'll need to hide it
953
+ relocateNodes.push({
954
+ $nodeToRelocate$: node,
955
+ });
956
+ }
957
+ }
958
+ }
959
+ }
960
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
961
+ relocateSlotContent(childNode);
962
+ }
963
+ }
964
+ };
965
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
966
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
967
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
968
+ return true;
969
+ }
970
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
971
+ return true;
972
+ }
973
+ return false;
974
+ }
975
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
976
+ return true;
977
+ }
978
+ return slotNameAttr === '';
979
+ };
980
+ /**
981
+ * The main entry point for Stencil's virtual DOM-based rendering engine
982
+ *
983
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
984
+ * function will handle creating a virtual DOM tree with a single root, patching
985
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
986
+ * relocation, and reflecting attributes.
987
+ *
988
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
989
+ * the DOM node into which it should be rendered.
990
+ * @param renderFnResults the virtual DOM nodes to be rendered
991
+ */
992
+ const renderVdom = (hostRef, renderFnResults) => {
993
+ const hostElm = hostRef.$hostElement$;
994
+ const cmpMeta = hostRef.$cmpMeta$;
995
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
996
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
997
+ hostTagName = hostElm.tagName;
998
+ if (cmpMeta.$attrsToReflect$) {
999
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1000
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1001
+ }
1002
+ rootVnode.$tag$ = null;
1003
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1004
+ hostRef.$vnode$ = rootVnode;
1005
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
1006
+ {
1007
+ contentRef = hostElm['s-cr'];
1008
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1009
+ // always reset
1010
+ checkSlotFallbackVisibility = false;
1011
+ }
1012
+ // synchronous patch
1013
+ patch(oldVNode, rootVnode);
1014
+ {
1015
+ // while we're moving nodes around existing nodes, temporarily disable
1016
+ // the disconnectCallback from working
1017
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1018
+ if (checkSlotRelocate) {
1019
+ relocateSlotContent(rootVnode.$elm$);
1020
+ let relocateData;
1021
+ let nodeToRelocate;
1022
+ let orgLocationNode;
1023
+ let parentNodeRef;
1024
+ let insertBeforeNode;
1025
+ let refNode;
1026
+ let i = 0;
1027
+ for (; i < relocateNodes.length; i++) {
1028
+ relocateData = relocateNodes[i];
1029
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1030
+ if (!nodeToRelocate['s-ol']) {
1031
+ // add a reference node marking this node's original location
1032
+ // keep a reference to this node for later lookups
1033
+ orgLocationNode =
1034
+ doc.createTextNode('');
1035
+ orgLocationNode['s-nr'] = nodeToRelocate;
1036
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1037
+ }
1038
+ }
1039
+ for (i = 0; i < relocateNodes.length; i++) {
1040
+ relocateData = relocateNodes[i];
1041
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1042
+ if (relocateData.$slotRefNode$) {
1043
+ // by default we're just going to insert it directly
1044
+ // after the slot reference node
1045
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1046
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1047
+ orgLocationNode = nodeToRelocate['s-ol'];
1048
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1049
+ refNode = orgLocationNode['s-nr'];
1050
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1051
+ refNode = refNode.nextSibling;
1052
+ if (!refNode || !refNode['s-nr']) {
1053
+ insertBeforeNode = refNode;
1054
+ break;
1055
+ }
1056
+ }
1057
+ }
1058
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1059
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1060
+ // we've checked that it's worth while to relocate
1061
+ // since that the node to relocate
1062
+ // has a different next sibling or parent relocated
1063
+ if (nodeToRelocate !== insertBeforeNode) {
1064
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1065
+ // probably a component in the index.html that doesn't have it's hostname set
1066
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1067
+ }
1068
+ // add it back to the dom but in its new home
1069
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1070
+ }
1071
+ }
1072
+ }
1073
+ else {
1074
+ // this node doesn't have a slot home to go to, so let's hide it
1075
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1076
+ nodeToRelocate.hidden = true;
1077
+ }
1078
+ }
1079
+ }
1080
+ }
1081
+ if (checkSlotFallbackVisibility) {
1082
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1083
+ }
1084
+ // done moving nodes around
1085
+ // allow the disconnect callback to work again
1086
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1087
+ // always reset
1088
+ relocateNodes.length = 0;
1089
+ }
1090
+ };
1091
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1092
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1093
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1094
+ }
1095
+ };
1096
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1097
+ {
1098
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1099
+ }
1100
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1101
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1102
+ return;
1103
+ }
1104
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1105
+ // there is no ancestor component or the ancestor component
1106
+ // has already fired off its lifecycle update then
1107
+ // fire off the initial update
1108
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1109
+ return writeTask(dispatch) ;
1110
+ };
1111
+ /**
1112
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1113
+ * component lifecycle methods like `componentWillLoad` as well as
1114
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
1115
+ *
1116
+ * @param hostRef a reference to a host DOM node
1117
+ * @param isInitialLoad whether we're on the initial load or not
1118
+ * @returns an empty Promise which is used to enqueue a series of operations for
1119
+ * the component
1120
+ */
1121
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1122
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1123
+ const instance = hostRef.$lazyInstance$ ;
1124
+ // We're going to use this variable together with `enqueue` to implement a
1125
+ // little promise-based queue. We start out with it `undefined`. When we add
1126
+ // the first function to the queue we'll set this variable to be that
1127
+ // function's return value. When we attempt to add subsequent values to the
1128
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
1129
+ // the new function off of that `Promise` using `.then()`. This will give our
1130
+ // queue two nice properties:
1131
+ //
1132
+ // 1. If all functions added to the queue are synchronous they'll be called
1133
+ // synchronously right away.
1134
+ // 2. If all functions added to the queue are asynchronous they'll all be
1135
+ // called in order after `dispatchHooks` exits.
1136
+ let maybePromise;
1137
+ endSchedule();
1138
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1139
+ };
1140
+ /**
1141
+ * This function uses a Promise to implement a simple first-in, first-out queue
1142
+ * of functions to be called.
1143
+ *
1144
+ * The queue is ordered on the basis of the first argument. If it's
1145
+ * `undefined`, then nothing is on the queue yet, so the provided function can
1146
+ * be called synchronously (although note that this function may return a
1147
+ * `Promise`). The idea is that then the return value of that enqueueing
1148
+ * operation is kept around, so that if it was a `Promise` then subsequent
1149
+ * functions can be enqueued by calling this function again with that `Promise`
1150
+ * as the first argument.
1151
+ *
1152
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1153
+ * @param fn a function to enqueue
1154
+ * @returns either a `Promise` or the return value of the provided function
1155
+ */
1156
+ const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
1157
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1158
+ const elm = hostRef.$hostElement$;
1159
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1160
+ const rc = elm['s-rc'];
1161
+ if (isInitialLoad) {
1162
+ // DOM WRITE!
1163
+ attachStyles(hostRef);
1164
+ }
1165
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1166
+ {
1167
+ callRender(hostRef, instance);
1168
+ }
1169
+ if (rc) {
1170
+ // ok, so turns out there are some child host elements
1171
+ // waiting on this parent element to load
1172
+ // let's fire off all update callbacks waiting
1173
+ rc.map((cb) => cb());
1174
+ elm['s-rc'] = undefined;
1175
+ }
1176
+ endRender();
1177
+ endUpdate();
1178
+ {
1179
+ const childrenPromises = elm['s-p'];
1180
+ const postUpdate = () => postUpdateComponent(hostRef);
1181
+ if (childrenPromises.length === 0) {
1182
+ postUpdate();
1183
+ }
1184
+ else {
1185
+ Promise.all(childrenPromises).then(postUpdate);
1186
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1187
+ childrenPromises.length = 0;
1188
+ }
1189
+ }
1190
+ };
1191
+ const callRender = (hostRef, instance, elm) => {
1192
+ try {
1193
+ instance = instance.render() ;
1194
+ {
1195
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1196
+ }
1197
+ {
1198
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1199
+ }
1200
+ {
1201
+ {
1202
+ // looks like we've got child nodes to render into this host element
1203
+ // or we need to update the css class/attrs on the host element
1204
+ // DOM WRITE!
1205
+ {
1206
+ renderVdom(hostRef, instance);
1207
+ }
1208
+ }
1209
+ }
1210
+ }
1211
+ catch (e) {
1212
+ consoleError(e, hostRef.$hostElement$);
1213
+ }
1214
+ return null;
1215
+ };
1216
+ const postUpdateComponent = (hostRef) => {
1217
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1218
+ const elm = hostRef.$hostElement$;
1219
+ const endPostUpdate = createTime('postUpdate', tagName);
1220
+ const instance = hostRef.$lazyInstance$ ;
1221
+ const ancestorComponent = hostRef.$ancestorComponent$;
1222
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1223
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1224
+ {
1225
+ // DOM WRITE!
1226
+ addHydratedFlag(elm);
1227
+ }
1228
+ {
1229
+ safeCall(instance, 'componentDidLoad');
1230
+ }
1231
+ endPostUpdate();
1232
+ {
1233
+ hostRef.$onReadyResolve$(elm);
1234
+ if (!ancestorComponent) {
1235
+ appDidLoad();
1236
+ }
1237
+ }
1238
+ }
1239
+ else {
1240
+ endPostUpdate();
1241
+ }
1242
+ // load events fire from bottom to top
1243
+ // the deepest elements load first then bubbles up
1244
+ {
1245
+ if (hostRef.$onRenderResolve$) {
1246
+ hostRef.$onRenderResolve$();
1247
+ hostRef.$onRenderResolve$ = undefined;
1248
+ }
1249
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1250
+ nextTick(() => scheduleUpdate(hostRef, false));
1251
+ }
1252
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1253
+ }
1254
+ // ( •_•)
1255
+ // ( •_•)>⌐■-■
1256
+ // (⌐■_■)
1257
+ };
1258
+ const appDidLoad = (who) => {
1259
+ // on appload
1260
+ // we have finish the first big initial render
1261
+ {
1262
+ addHydratedFlag(doc.documentElement);
1263
+ }
1264
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1265
+ };
1266
+ const safeCall = (instance, method, arg) => {
1267
+ if (instance && instance[method]) {
1268
+ try {
1269
+ return instance[method](arg);
1270
+ }
1271
+ catch (e) {
1272
+ consoleError(e);
1273
+ }
1274
+ }
1275
+ return undefined;
1276
+ };
1277
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1278
+ ;
1279
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1280
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1281
+ // check our new property value against our internal value
1282
+ const hostRef = getHostRef(ref);
1283
+ const oldVal = hostRef.$instanceValues$.get(propName);
1284
+ const flags = hostRef.$flags$;
1285
+ const instance = hostRef.$lazyInstance$ ;
1286
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1287
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1288
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1289
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1290
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1291
+ // gadzooks! the property's value has changed!!
1292
+ // set our new value!
1293
+ hostRef.$instanceValues$.set(propName, newVal);
1294
+ if (instance) {
1295
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1296
+ // looks like this value actually changed, so we've got work to do!
1297
+ // but only if we've already rendered, otherwise just chill out
1298
+ // queue that we need to do an update, but don't worry about queuing
1299
+ // up millions cuz this function ensures it only runs once
1300
+ scheduleUpdate(hostRef, false);
1301
+ }
1302
+ }
1303
+ }
1304
+ };
1305
+ /**
1306
+ * Attach a series of runtime constructs to a compiled Stencil component
1307
+ * constructor, including getters and setters for the `@Prop` and `@State`
1308
+ * decorators, callbacks for when attributes change, and so on.
1309
+ *
1310
+ * @param Cstr the constructor for a component that we need to process
1311
+ * @param cmpMeta metadata collected previously about the component
1312
+ * @param flags a number used to store a series of bit flags
1313
+ * @returns a reference to the same constructor passed in (but now mutated)
1314
+ */
1315
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1316
+ if (cmpMeta.$members$) {
1317
+ // It's better to have a const than two Object.entries()
1318
+ const members = Object.entries(cmpMeta.$members$);
1319
+ const prototype = Cstr.prototype;
1320
+ members.map(([memberName, [memberFlags]]) => {
1321
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1322
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1323
+ // proxyComponent - prop
1324
+ Object.defineProperty(prototype, memberName, {
1325
+ get() {
1326
+ // proxyComponent, get value
1327
+ return getValue(this, memberName);
1328
+ },
1329
+ set(newValue) {
1330
+ // proxyComponent, set value
1331
+ setValue(this, memberName, newValue, cmpMeta);
1332
+ },
1333
+ configurable: true,
1334
+ enumerable: true,
1335
+ });
1336
+ }
1337
+ });
1338
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1339
+ const attrNameToPropName = new Map();
1340
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1341
+ plt.jmp(() => {
1342
+ const propName = attrNameToPropName.get(attrName);
1343
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1344
+ // in the case where an attribute was set inline.
1345
+ // ```html
1346
+ // <my-component some-attribute="some-value"></my-component>
1347
+ // ```
1348
+ //
1349
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1350
+ // programmatically changes it before it has been upgraded as shown below:
1351
+ //
1352
+ // ```html
1353
+ // <!-- this component has _not_ been upgraded yet -->
1354
+ // <my-component id="test" some-attribute="some-value"></my-component>
1355
+ // <script>
1356
+ // // grab non-upgraded component
1357
+ // el = document.querySelector("#test");
1358
+ // el.someAttribute = "another-value";
1359
+ // // upgrade component
1360
+ // customElements.define('my-component', MyComponent);
1361
+ // </script>
1362
+ // ```
1363
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1364
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1365
+ // to the value that was set inline i.e. "some-value" from above example. When
1366
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1367
+ //
1368
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1369
+ // by connectedCallback as this attributeChangedCallback will not fire.
1370
+ //
1371
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1372
+ //
1373
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1374
+ // properties here given that this goes against best practices outlined here
1375
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1376
+ if (this.hasOwnProperty(propName)) {
1377
+ newValue = this[propName];
1378
+ delete this[propName];
1379
+ }
1380
+ else if (prototype.hasOwnProperty(propName) &&
1381
+ typeof this[propName] === 'number' &&
1382
+ this[propName] == newValue) {
1383
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1384
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1385
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1386
+ return;
1387
+ }
1388
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1389
+ });
1390
+ };
1391
+ // create an array of attributes to observe
1392
+ // and also create a map of html attribute name to js property name
1393
+ Cstr.observedAttributes = members
1394
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1395
+ .map(([propName, m]) => {
1396
+ const attrName = m[1] || propName;
1397
+ attrNameToPropName.set(attrName, propName);
1398
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1399
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1400
+ }
1401
+ return attrName;
1402
+ });
1403
+ }
1404
+ }
1405
+ return Cstr;
1406
+ };
1407
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1408
+ // initializeComponent
1409
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1410
+ // Let the runtime know that the component has been initialized
1411
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1412
+ {
1413
+ // lazy loaded components
1414
+ // request the component's implementation to be
1415
+ // wired up with the host element
1416
+ Cstr = loadModule(cmpMeta);
1417
+ if (Cstr.then) {
1418
+ // Await creates a micro-task avoid if possible
1419
+ const endLoad = uniqueTime();
1420
+ Cstr = await Cstr;
1421
+ endLoad();
1422
+ }
1423
+ if (!Cstr.isProxied) {
1424
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1425
+ Cstr.isProxied = true;
1426
+ }
1427
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1428
+ // ok, time to construct the instance
1429
+ // but let's keep track of when we start and stop
1430
+ // so that the getters/setters don't incorrectly step on data
1431
+ {
1432
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1433
+ }
1434
+ // construct the lazy-loaded component implementation
1435
+ // passing the hostRef is very important during
1436
+ // construction in order to directly wire together the
1437
+ // host element and the lazy-loaded instance
1438
+ try {
1439
+ new Cstr(hostRef);
1440
+ }
1441
+ catch (e) {
1442
+ consoleError(e);
1443
+ }
1444
+ {
1445
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1446
+ }
1447
+ endNewInstance();
1448
+ }
1449
+ if (Cstr.style) {
1450
+ // this component has styles but we haven't registered them yet
1451
+ let style = Cstr.style;
1452
+ const scopeId = getScopeId(cmpMeta);
1453
+ if (!styles.has(scopeId)) {
1454
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1455
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1456
+ endRegisterStyles();
1457
+ }
1458
+ }
1459
+ }
1460
+ // we've successfully created a lazy instance
1461
+ const ancestorComponent = hostRef.$ancestorComponent$;
1462
+ const schedule = () => scheduleUpdate(hostRef, true);
1463
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1464
+ // this is the initial load and this component it has an ancestor component
1465
+ // but the ancestor component has NOT fired its will update lifecycle yet
1466
+ // so let's just cool our jets and wait for the ancestor to continue first
1467
+ // this will get fired off when the ancestor component
1468
+ // finally gets around to rendering its lazy self
1469
+ // fire off the initial update
1470
+ ancestorComponent['s-rc'].push(schedule);
1471
+ }
1472
+ else {
1473
+ schedule();
1474
+ }
1475
+ };
1476
+ const connectedCallback = (elm) => {
1477
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1478
+ const hostRef = getHostRef(elm);
1479
+ const cmpMeta = hostRef.$cmpMeta$;
1480
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1481
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1482
+ // first time this component has connected
1483
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1484
+ {
1485
+ // initUpdate
1486
+ // if the slot polyfill is required we'll need to put some nodes
1487
+ // in here to act as original content anchors as we move nodes around
1488
+ // host element has been connected to the DOM
1489
+ if ((// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
1490
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1491
+ setContentReference(elm);
1492
+ }
1493
+ }
1494
+ {
1495
+ // find the first ancestor component (if there is one) and register
1496
+ // this component as one of the actively loading child components for its ancestor
1497
+ let ancestorComponent = elm;
1498
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1499
+ // climb up the ancestors looking for the first
1500
+ // component that hasn't finished its lifecycle update yet
1501
+ if (ancestorComponent['s-p']) {
1502
+ // we found this components first ancestor component
1503
+ // keep a reference to this component's ancestor component
1504
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1505
+ break;
1506
+ }
1507
+ }
1508
+ }
1509
+ // Lazy properties
1510
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1511
+ if (cmpMeta.$members$) {
1512
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1513
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1514
+ const value = elm[memberName];
1515
+ delete elm[memberName];
1516
+ elm[memberName] = value;
1517
+ }
1518
+ });
1519
+ }
1520
+ {
1521
+ initializeComponent(elm, hostRef, cmpMeta);
1522
+ }
1523
+ }
1524
+ endConnected();
1525
+ }
1526
+ };
1527
+ const setContentReference = (elm) => {
1528
+ // only required when we're NOT using native shadow dom (slot)
1529
+ // or this browser doesn't support native shadow dom
1530
+ // and this host element was NOT created with SSR
1531
+ // let's pick out the inner content for slot projection
1532
+ // create a node to represent where the original
1533
+ // content was first placed, which is useful later on
1534
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1535
+ contentRefElm['s-cn'] = true;
1536
+ elm.insertBefore(contentRefElm, elm.firstChild);
1537
+ };
1538
+ const disconnectedCallback = (elm) => {
1539
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1540
+ getHostRef(elm);
1541
+ }
1542
+ };
1543
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1544
+ var _a;
1545
+ const endBootstrap = createTime();
1546
+ const cmpTags = [];
1547
+ const exclude = options.exclude || [];
1548
+ const customElements = win.customElements;
1549
+ const head = doc.head;
1550
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1551
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1552
+ const deferredConnectedCallbacks = [];
1553
+ let appLoadFallback;
1554
+ let isBootstrapping = true;
1555
+ Object.assign(plt, options);
1556
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1557
+ lazyBundles.map((lazyBundle) => {
1558
+ lazyBundle[1].map((compactMeta) => {
1559
+ const cmpMeta = {
1560
+ $flags$: compactMeta[0],
1561
+ $tagName$: compactMeta[1],
1562
+ $members$: compactMeta[2],
1563
+ $listeners$: compactMeta[3],
1564
+ };
1565
+ {
1566
+ cmpMeta.$members$ = compactMeta[2];
1567
+ }
1568
+ {
1569
+ cmpMeta.$attrsToReflect$ = [];
1570
+ }
1571
+ const tagName = cmpMeta.$tagName$;
1572
+ const HostElement = class extends HTMLElement {
1573
+ // StencilLazyHost
1574
+ constructor(self) {
1575
+ // @ts-ignore
1576
+ super(self);
1577
+ self = this;
1578
+ registerHost(self, cmpMeta);
1579
+ }
1580
+ connectedCallback() {
1581
+ if (appLoadFallback) {
1582
+ clearTimeout(appLoadFallback);
1583
+ appLoadFallback = null;
1584
+ }
1585
+ if (isBootstrapping) {
1586
+ // connectedCallback will be processed once all components have been registered
1587
+ deferredConnectedCallbacks.push(this);
1588
+ }
1589
+ else {
1590
+ plt.jmp(() => connectedCallback(this));
1591
+ }
1592
+ }
1593
+ disconnectedCallback() {
1594
+ plt.jmp(() => disconnectedCallback(this));
1595
+ }
1596
+ componentOnReady() {
1597
+ return getHostRef(this).$onReadyPromise$;
1598
+ }
1599
+ };
1600
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1601
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1602
+ cmpTags.push(tagName);
1603
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1604
+ }
1605
+ });
1606
+ });
1607
+ {
1608
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1609
+ visibilityStyle.setAttribute('data-styles', '');
1610
+ // Apply CSP nonce to the style tag if it exists
1611
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1612
+ if (nonce != null) {
1613
+ visibilityStyle.setAttribute('nonce', nonce);
1614
+ }
1615
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1616
+ }
1617
+ // Process deferred connectedCallbacks now all components have been registered
1618
+ isBootstrapping = false;
1619
+ if (deferredConnectedCallbacks.length) {
1620
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1621
+ }
1622
+ else {
1623
+ {
1624
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1625
+ }
1626
+ }
1627
+ // Fallback appLoad event
1628
+ endBootstrap();
1629
+ };
1630
+ /**
1631
+ * Assigns the given value to the nonce property on the runtime platform object.
1632
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1633
+ * @param nonce The value to be assigned to the platform nonce property.
1634
+ * @returns void
1635
+ */
1636
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1637
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1638
+ const getHostRef = (ref) => hostRefs.get(ref);
1639
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1640
+ const registerHost = (elm, cmpMeta) => {
1641
+ const hostRef = {
1642
+ $flags$: 0,
1643
+ $hostElement$: elm,
1644
+ $cmpMeta$: cmpMeta,
1645
+ $instanceValues$: new Map(),
1646
+ };
1647
+ {
1648
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1649
+ elm['s-p'] = [];
1650
+ elm['s-rc'] = [];
1651
+ }
1652
+ return hostRefs.set(elm, hostRef);
1653
+ };
1654
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1655
+ const consoleError = (e, el) => (0, console.error)(e, el);
1656
+ const cmpModules = /*@__PURE__*/ new Map();
1657
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1658
+ // loadModuleImport
1659
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1660
+ const bundleId = cmpMeta.$lazyBundleId$;
1661
+ const module = cmpModules.get(bundleId) ;
1662
+ if (module) {
1663
+ return module[exportName];
1664
+ }
1665
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1666
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1667
+ /* @vite-ignore */
1668
+ /* webpackInclude: /\.entry\.js$/ */
1669
+ /* webpackExclude: /\.system\.entry\.js$/ */
1670
+ /* webpackMode: "lazy" */
1671
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1672
+ {
1673
+ cmpModules.set(bundleId, importedModule);
1674
+ }
1675
+ return importedModule[exportName];
1676
+ }, consoleError);
1677
+ };
1678
+ const styles = /*@__PURE__*/ new Map();
1679
+ const win = typeof window !== 'undefined' ? window : {};
1680
+ const doc = win.document || { head: {} };
1681
+ const plt = {
1682
+ $flags$: 0,
1683
+ $resourcesUrl$: '',
1684
+ jmp: (h) => h(),
1685
+ raf: (h) => requestAnimationFrame(h),
1686
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1687
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1688
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1689
+ };
1690
+ const promiseResolve = (v) => Promise.resolve(v);
1691
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1692
+ try {
1693
+ new CSSStyleSheet();
1694
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1695
+ }
1696
+ catch (e) { }
1697
+ return false;
1698
+ })()
1699
+ ;
1700
+ const queueDomReads = [];
1701
+ const queueDomWrites = [];
1702
+ const queueTask = (queue, write) => (cb) => {
1703
+ queue.push(cb);
1704
+ if (!queuePending) {
1705
+ queuePending = true;
1706
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1707
+ nextTick(flush);
1708
+ }
1709
+ else {
1710
+ plt.raf(flush);
1711
+ }
1712
+ }
1713
+ };
1714
+ const consume = (queue) => {
1715
+ for (let i = 0; i < queue.length; i++) {
1716
+ try {
1717
+ queue[i](performance.now());
1718
+ }
1719
+ catch (e) {
1720
+ consoleError(e);
1721
+ }
1722
+ }
1723
+ queue.length = 0;
1724
+ };
1725
+ const flush = () => {
1726
+ // always force a bunch of medium callbacks to run, but still have
1727
+ // a throttle on how many can run in a certain time
1728
+ // DOM READS!!!
1729
+ consume(queueDomReads);
1730
+ // DOM WRITES!!!
1731
+ {
1732
+ consume(queueDomWrites);
1733
+ if ((queuePending = queueDomReads.length > 0)) {
1734
+ // still more to do yet, but we've run out of time
1735
+ // let's let this thing cool off and try again in the next tick
1736
+ plt.raf(flush);
1737
+ }
1738
+ }
1739
+ };
1740
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1741
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1742
+
1743
+ exports.Host = Host;
1744
+ exports.bootstrapLazy = bootstrapLazy;
1745
+ exports.h = h;
1746
+ exports.promiseResolve = promiseResolve;
1747
+ exports.registerInstance = registerInstance;
1748
+ exports.setNonce = setNonce;
1749
+
1750
+ //# sourceMappingURL=index-95f2f619.js.map