@salla.sa/twilight-components 1.0.21 → 1.0.22

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