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