@salla.sa/twilight-components 1.0.14 → 1.0.15

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