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