@everymatrix/general-registration 1.10.0

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 (68) hide show
  1. package/dist/cjs/checkbox-input_11.cjs.entry.js +1165 -0
  2. package/dist/cjs/general-registration.cjs.js +19 -0
  3. package/dist/cjs/index-c04f4a2a.js +1264 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/collection/collection-manifest.json +28 -0
  7. package/dist/collection/components/general-registration/general-registration.css +45 -0
  8. package/dist/collection/components/general-registration/general-registration.js +529 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/utils.js +3 -0
  11. package/dist/components/checkbox-input.js +6 -0
  12. package/dist/components/checkbox-input2.js +78 -0
  13. package/dist/components/date-input.js +6 -0
  14. package/dist/components/date-input2.js +90 -0
  15. package/dist/components/email-input.js +6 -0
  16. package/dist/components/email-input2.js +108 -0
  17. package/dist/components/general-input.js +6 -0
  18. package/dist/components/general-input2.js +120 -0
  19. package/dist/components/general-registration.d.ts +11 -0
  20. package/dist/components/general-registration.js +530 -0
  21. package/dist/components/index.d.ts +26 -0
  22. package/dist/components/index.js +1 -0
  23. package/dist/components/locale.utils.js +29 -0
  24. package/dist/components/number-input.js +6 -0
  25. package/dist/components/number-input2.js +96 -0
  26. package/dist/components/password-input.js +6 -0
  27. package/dist/components/password-input2.js +93 -0
  28. package/dist/components/radio-input.js +6 -0
  29. package/dist/components/radio-input2.js +89 -0
  30. package/dist/components/select-input.js +6 -0
  31. package/dist/components/select-input2.js +127 -0
  32. package/dist/components/tel-input.js +6 -0
  33. package/dist/components/tel-input2.js +111 -0
  34. package/dist/components/text-input.js +6 -0
  35. package/dist/components/text-input2.js +112 -0
  36. package/dist/esm/checkbox-input_11.entry.js +1151 -0
  37. package/dist/esm/general-registration.js +17 -0
  38. package/dist/esm/index-79f297c1.js +1238 -0
  39. package/dist/esm/index.js +1 -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/general-registration/general-registration.esm.js +1 -0
  48. package/dist/general-registration/index.esm.js +0 -0
  49. package/dist/general-registration/p-0e7175cd.js +1 -0
  50. package/dist/general-registration/p-cadaffbe.entry.js +1 -0
  51. package/dist/index.cjs.js +1 -0
  52. package/dist/index.js +1 -0
  53. package/dist/stencil.config.js +22 -0
  54. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/locale.utils.d.ts +5 -0
  55. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +55 -0
  56. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-registration/stencil.config.d.ts +2 -0
  57. package/dist/types/components/general-registration/general-registration.d.ts +67 -0
  58. package/dist/types/components.d.ts +77 -0
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  61. package/dist/types/utils/utils.d.ts +1 -0
  62. package/loader/cdn.js +3 -0
  63. package/loader/index.cjs.js +3 -0
  64. package/loader/index.d.ts +12 -0
  65. package/loader/index.es2017.js +3 -0
  66. package/loader/index.js +4 -0
  67. package/loader/package.json +10 -0
  68. package/package.json +22 -0
@@ -0,0 +1,1238 @@
1
+ const NAMESPACE = 'general-registration';
2
+
3
+ let scopeId;
4
+ let hostTagName;
5
+ let isSvgMode = false;
6
+ let queuePending = false;
7
+ const win = typeof window !== 'undefined' ? window : {};
8
+ const doc = win.document || { head: {} };
9
+ const plt = {
10
+ $flags$: 0,
11
+ $resourcesUrl$: '',
12
+ jmp: (h) => h(),
13
+ raf: (h) => requestAnimationFrame(h),
14
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
15
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
16
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
17
+ };
18
+ const promiseResolve = (v) => Promise.resolve(v);
19
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
20
+ try {
21
+ new CSSStyleSheet();
22
+ return typeof new CSSStyleSheet().replace === 'function';
23
+ }
24
+ catch (e) { }
25
+ return false;
26
+ })()
27
+ ;
28
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
29
+ if (listeners) {
30
+ listeners.map(([flags, name, method]) => {
31
+ const target = elm;
32
+ const handler = hostListenerProxy(hostRef, method);
33
+ const opts = hostListenerOpts(flags);
34
+ plt.ael(target, name, handler, opts);
35
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
36
+ });
37
+ }
38
+ };
39
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
40
+ try {
41
+ {
42
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
43
+ // instance is ready, let's call it's member method for this event
44
+ hostRef.$lazyInstance$[methodName](ev);
45
+ }
46
+ else {
47
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
48
+ }
49
+ }
50
+ }
51
+ catch (e) {
52
+ consoleError(e);
53
+ }
54
+ };
55
+ // prettier-ignore
56
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
57
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
58
+ const createTime = (fnName, tagName = '') => {
59
+ {
60
+ return () => {
61
+ return;
62
+ };
63
+ }
64
+ };
65
+ const uniqueTime = (key, measureText) => {
66
+ {
67
+ return () => {
68
+ return;
69
+ };
70
+ }
71
+ };
72
+ const rootAppliedStyles = new WeakMap();
73
+ const registerStyle = (scopeId, cssText, allowCS) => {
74
+ let style = styles.get(scopeId);
75
+ if (supportsConstructibleStylesheets && allowCS) {
76
+ style = (style || new CSSStyleSheet());
77
+ style.replace(cssText);
78
+ }
79
+ else {
80
+ style = cssText;
81
+ }
82
+ styles.set(scopeId, style);
83
+ };
84
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
85
+ let scopeId = getScopeId(cmpMeta);
86
+ let style = styles.get(scopeId);
87
+ // if an element is NOT connected then getRootNode() will return the wrong root node
88
+ // so the fallback is to always use the document for the root node in those cases
89
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
90
+ if (style) {
91
+ if (typeof style === 'string') {
92
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
93
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
94
+ let styleElm;
95
+ if (!appliedStyles) {
96
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
97
+ }
98
+ if (!appliedStyles.has(scopeId)) {
99
+ {
100
+ {
101
+ styleElm = doc.createElement('style');
102
+ styleElm.innerHTML = style;
103
+ }
104
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
105
+ }
106
+ if (appliedStyles) {
107
+ appliedStyles.add(scopeId);
108
+ }
109
+ }
110
+ }
111
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
112
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
113
+ }
114
+ }
115
+ return scopeId;
116
+ };
117
+ const attachStyles = (hostRef) => {
118
+ const cmpMeta = hostRef.$cmpMeta$;
119
+ const elm = hostRef.$hostElement$;
120
+ const flags = cmpMeta.$flags$;
121
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
122
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
123
+ if (flags & 10 /* needsScopedEncapsulation */) {
124
+ // only required when we're NOT using native shadow dom (slot)
125
+ // or this browser doesn't support native shadow dom
126
+ // and this host element was NOT created with SSR
127
+ // let's pick out the inner content for slot projection
128
+ // create a node to represent where the original
129
+ // content was first placed, which is useful later on
130
+ // DOM WRITE!!
131
+ elm['s-sc'] = scopeId;
132
+ elm.classList.add(scopeId + '-h');
133
+ }
134
+ endAttachStyles();
135
+ };
136
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
137
+ /**
138
+ * Default style mode id
139
+ */
140
+ /**
141
+ * Reusable empty obj/array
142
+ * Don't add values to these!!
143
+ */
144
+ const EMPTY_OBJ = {};
145
+ const isDef = (v) => v != null;
146
+ const isComplexType = (o) => {
147
+ // https://jsperf.com/typeof-fn-object/5
148
+ o = typeof o;
149
+ return o === 'object' || o === 'function';
150
+ };
151
+ /**
152
+ * Production h() function based on Preact by
153
+ * Jason Miller (@developit)
154
+ * Licensed under the MIT License
155
+ * https://github.com/developit/preact/blob/master/LICENSE
156
+ *
157
+ * Modified for Stencil's compiler and vdom
158
+ */
159
+ // const stack: any[] = [];
160
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
161
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
162
+ const h = (nodeName, vnodeData, ...children) => {
163
+ let child = null;
164
+ let simple = false;
165
+ let lastSimple = false;
166
+ let vNodeChildren = [];
167
+ const walk = (c) => {
168
+ for (let i = 0; i < c.length; i++) {
169
+ child = c[i];
170
+ if (Array.isArray(child)) {
171
+ walk(child);
172
+ }
173
+ else if (child != null && typeof child !== 'boolean') {
174
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
175
+ child = String(child);
176
+ }
177
+ if (simple && lastSimple) {
178
+ // If the previous child was simple (string), we merge both
179
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
180
+ }
181
+ else {
182
+ // Append a new vNode, if it's text, we create a text vNode
183
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
184
+ }
185
+ lastSimple = simple;
186
+ }
187
+ }
188
+ };
189
+ walk(children);
190
+ if (vnodeData) {
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
+ return vnode;
209
+ };
210
+ const newVNode = (tag, text) => {
211
+ const vnode = {
212
+ $flags$: 0,
213
+ $tag$: tag,
214
+ $text$: text,
215
+ $elm$: null,
216
+ $children$: null,
217
+ };
218
+ {
219
+ vnode.$attrs$ = null;
220
+ }
221
+ return vnode;
222
+ };
223
+ const Host = {};
224
+ const isHost = (node) => node && node.$tag$ === Host;
225
+ /**
226
+ * Production setAccessor() function based on Preact by
227
+ * Jason Miller (@developit)
228
+ * Licensed under the MIT License
229
+ * https://github.com/developit/preact/blob/master/LICENSE
230
+ *
231
+ * Modified for Stencil's compiler and vdom
232
+ */
233
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
234
+ if (oldValue !== newValue) {
235
+ let isProp = isMemberInElement(elm, memberName);
236
+ let ln = memberName.toLowerCase();
237
+ if (memberName === 'class') {
238
+ const classList = elm.classList;
239
+ const oldClasses = parseClassList(oldValue);
240
+ const newClasses = parseClassList(newValue);
241
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
242
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
243
+ }
244
+ else if (memberName === 'ref') {
245
+ // minifier will clean this up
246
+ if (newValue) {
247
+ newValue(elm);
248
+ }
249
+ }
250
+ else if ((!isProp ) &&
251
+ memberName[0] === 'o' &&
252
+ memberName[1] === 'n') {
253
+ // Event Handlers
254
+ // so if the member name starts with "on" and the 3rd characters is
255
+ // a capital letter, and it's not already a member on the element,
256
+ // then we're assuming it's an event listener
257
+ if (memberName[2] === '-') {
258
+ // on- prefixed events
259
+ // allows to be explicit about the dom event to listen without any magic
260
+ // under the hood:
261
+ // <my-cmp on-click> // listens for "click"
262
+ // <my-cmp on-Click> // listens for "Click"
263
+ // <my-cmp on-ionChange> // listens for "ionChange"
264
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
265
+ memberName = memberName.slice(3);
266
+ }
267
+ else if (isMemberInElement(win, ln)) {
268
+ // standard event
269
+ // the JSX attribute could have been "onMouseOver" and the
270
+ // member name "onmouseover" is on the window's prototype
271
+ // so let's add the listener "mouseover", which is all lowercased
272
+ memberName = ln.slice(2);
273
+ }
274
+ else {
275
+ // custom event
276
+ // the JSX attribute could have been "onMyCustomEvent"
277
+ // so let's trim off the "on" prefix and lowercase the first character
278
+ // and add the listener "myCustomEvent"
279
+ // except for the first character, we keep the event name case
280
+ memberName = ln[2] + memberName.slice(3);
281
+ }
282
+ if (oldValue) {
283
+ plt.rel(elm, memberName, oldValue, false);
284
+ }
285
+ if (newValue) {
286
+ plt.ael(elm, memberName, newValue, false);
287
+ }
288
+ }
289
+ else {
290
+ // Set property if it exists and it's not a SVG
291
+ const isComplex = isComplexType(newValue);
292
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
293
+ try {
294
+ if (!elm.tagName.includes('-')) {
295
+ let n = newValue == null ? '' : newValue;
296
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
297
+ if (memberName === 'list') {
298
+ isProp = false;
299
+ }
300
+ else if (oldValue == null || elm[memberName] != n) {
301
+ elm[memberName] = n;
302
+ }
303
+ }
304
+ else {
305
+ elm[memberName] = newValue;
306
+ }
307
+ }
308
+ catch (e) { }
309
+ }
310
+ if (newValue == null || newValue === false) {
311
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
312
+ {
313
+ elm.removeAttribute(memberName);
314
+ }
315
+ }
316
+ }
317
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
318
+ newValue = newValue === true ? '' : newValue;
319
+ {
320
+ elm.setAttribute(memberName, newValue);
321
+ }
322
+ }
323
+ }
324
+ }
325
+ };
326
+ const parseClassListRegex = /\s/;
327
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
328
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
329
+ // if the element passed in is a shadow root, which is a document fragment
330
+ // then we want to be adding attrs/props to the shadow root's "host" element
331
+ // if it's not a shadow root, then we add attrs/props to the same element
332
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
333
+ ? newVnode.$elm$.host
334
+ : newVnode.$elm$;
335
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
336
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
337
+ {
338
+ // remove attributes no longer present on the vnode by setting them to undefined
339
+ for (memberName in oldVnodeAttrs) {
340
+ if (!(memberName in newVnodeAttrs)) {
341
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
342
+ }
343
+ }
344
+ }
345
+ // add new & update changed attributes
346
+ for (memberName in newVnodeAttrs) {
347
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
348
+ }
349
+ };
350
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
351
+ // tslint:disable-next-line: prefer-const
352
+ let newVNode = newParentVNode.$children$[childIndex];
353
+ let i = 0;
354
+ let elm;
355
+ let childNode;
356
+ if (newVNode.$text$ !== null) {
357
+ // create text node
358
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
359
+ }
360
+ else {
361
+ // create element
362
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
363
+ // add css classes, attrs, props, listeners, etc.
364
+ {
365
+ updateElement(null, newVNode, isSvgMode);
366
+ }
367
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
368
+ // if there is a scopeId and this is the initial render
369
+ // then let's add the scopeId as a css class
370
+ elm.classList.add((elm['s-si'] = scopeId));
371
+ }
372
+ if (newVNode.$children$) {
373
+ for (i = 0; i < newVNode.$children$.length; ++i) {
374
+ // create the node
375
+ childNode = createElm(oldParentVNode, newVNode, i);
376
+ // return node could have been null
377
+ if (childNode) {
378
+ // append our new node
379
+ elm.appendChild(childNode);
380
+ }
381
+ }
382
+ }
383
+ }
384
+ return elm;
385
+ };
386
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
387
+ let containerElm = (parentElm);
388
+ let childNode;
389
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
390
+ containerElm = containerElm.shadowRoot;
391
+ }
392
+ for (; startIdx <= endIdx; ++startIdx) {
393
+ if (vnodes[startIdx]) {
394
+ childNode = createElm(null, parentVNode, startIdx);
395
+ if (childNode) {
396
+ vnodes[startIdx].$elm$ = childNode;
397
+ containerElm.insertBefore(childNode, before);
398
+ }
399
+ }
400
+ }
401
+ };
402
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
403
+ for (; startIdx <= endIdx; ++startIdx) {
404
+ if ((vnode = vnodes[startIdx])) {
405
+ elm = vnode.$elm$;
406
+ callNodeRefs(vnode);
407
+ // remove the vnode's element from the dom
408
+ elm.remove();
409
+ }
410
+ }
411
+ };
412
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
413
+ let oldStartIdx = 0;
414
+ let newStartIdx = 0;
415
+ let oldEndIdx = oldCh.length - 1;
416
+ let oldStartVnode = oldCh[0];
417
+ let oldEndVnode = oldCh[oldEndIdx];
418
+ let newEndIdx = newCh.length - 1;
419
+ let newStartVnode = newCh[0];
420
+ let newEndVnode = newCh[newEndIdx];
421
+ let node;
422
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
423
+ if (oldStartVnode == null) {
424
+ // Vnode might have been moved left
425
+ oldStartVnode = oldCh[++oldStartIdx];
426
+ }
427
+ else if (oldEndVnode == null) {
428
+ oldEndVnode = oldCh[--oldEndIdx];
429
+ }
430
+ else if (newStartVnode == null) {
431
+ newStartVnode = newCh[++newStartIdx];
432
+ }
433
+ else if (newEndVnode == null) {
434
+ newEndVnode = newCh[--newEndIdx];
435
+ }
436
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
437
+ patch(oldStartVnode, newStartVnode);
438
+ oldStartVnode = oldCh[++oldStartIdx];
439
+ newStartVnode = newCh[++newStartIdx];
440
+ }
441
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
442
+ patch(oldEndVnode, newEndVnode);
443
+ oldEndVnode = oldCh[--oldEndIdx];
444
+ newEndVnode = newCh[--newEndIdx];
445
+ }
446
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
447
+ patch(oldStartVnode, newEndVnode);
448
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
449
+ oldStartVnode = oldCh[++oldStartIdx];
450
+ newEndVnode = newCh[--newEndIdx];
451
+ }
452
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
453
+ patch(oldEndVnode, newStartVnode);
454
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
455
+ oldEndVnode = oldCh[--oldEndIdx];
456
+ newStartVnode = newCh[++newStartIdx];
457
+ }
458
+ else {
459
+ {
460
+ // new element
461
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
462
+ newStartVnode = newCh[++newStartIdx];
463
+ }
464
+ if (node) {
465
+ {
466
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
467
+ }
468
+ }
469
+ }
470
+ }
471
+ if (oldStartIdx > oldEndIdx) {
472
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
473
+ }
474
+ else if (newStartIdx > newEndIdx) {
475
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
476
+ }
477
+ };
478
+ const isSameVnode = (vnode1, vnode2) => {
479
+ // compare if two vnode to see if they're "technically" the same
480
+ // need to have the same element tag, and same key to be the same
481
+ if (vnode1.$tag$ === vnode2.$tag$) {
482
+ return true;
483
+ }
484
+ return false;
485
+ };
486
+ const patch = (oldVNode, newVNode) => {
487
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
488
+ const oldChildren = oldVNode.$children$;
489
+ const newChildren = newVNode.$children$;
490
+ const text = newVNode.$text$;
491
+ if (text === null) {
492
+ // element node
493
+ {
494
+ {
495
+ // either this is the first render of an element OR it's an update
496
+ // AND we already know it's possible it could have changed
497
+ // this updates the element's css classes, attrs, props, listeners, etc.
498
+ updateElement(oldVNode, newVNode, isSvgMode);
499
+ }
500
+ }
501
+ if (oldChildren !== null && newChildren !== null) {
502
+ // looks like there's child vnodes for both the old and new vnodes
503
+ updateChildren(elm, oldChildren, newVNode, newChildren);
504
+ }
505
+ else if (newChildren !== null) {
506
+ // no old child vnodes, but there are new child vnodes to add
507
+ if (oldVNode.$text$ !== null) {
508
+ // the old vnode was text, so be sure to clear it out
509
+ elm.textContent = '';
510
+ }
511
+ // add the new vnode children
512
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
513
+ }
514
+ else if (oldChildren !== null) {
515
+ // no new child vnodes, but there are old child vnodes to remove
516
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
517
+ }
518
+ }
519
+ else if (oldVNode.$text$ !== text) {
520
+ // update the text content for the text only vnode
521
+ // and also only if the text is different than before
522
+ elm.data = text;
523
+ }
524
+ };
525
+ const callNodeRefs = (vNode) => {
526
+ {
527
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
528
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
529
+ }
530
+ };
531
+ const renderVdom = (hostRef, renderFnResults) => {
532
+ const hostElm = hostRef.$hostElement$;
533
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
534
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
535
+ hostTagName = hostElm.tagName;
536
+ rootVnode.$tag$ = null;
537
+ rootVnode.$flags$ |= 4 /* isHost */;
538
+ hostRef.$vnode$ = rootVnode;
539
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
540
+ {
541
+ scopeId = hostElm['s-sc'];
542
+ }
543
+ // synchronous patch
544
+ patch(oldVNode, rootVnode);
545
+ };
546
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
547
+ const createEvent = (ref, name, flags) => {
548
+ const elm = getElement(ref);
549
+ return {
550
+ emit: (detail) => {
551
+ return emitEvent(elm, name, {
552
+ bubbles: !!(flags & 4 /* Bubbles */),
553
+ composed: !!(flags & 2 /* Composed */),
554
+ cancelable: !!(flags & 1 /* Cancellable */),
555
+ detail,
556
+ });
557
+ },
558
+ };
559
+ };
560
+ /**
561
+ * Helper function to create & dispatch a custom Event on a provided target
562
+ * @param elm the target of the Event
563
+ * @param name the name to give the custom Event
564
+ * @param opts options for configuring a custom Event
565
+ * @returns the custom Event
566
+ */
567
+ const emitEvent = (elm, name, opts) => {
568
+ const ev = plt.ce(name, opts);
569
+ elm.dispatchEvent(ev);
570
+ return ev;
571
+ };
572
+ const attachToAncestor = (hostRef, ancestorComponent) => {
573
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
574
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
575
+ }
576
+ };
577
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
578
+ {
579
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
580
+ }
581
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
582
+ hostRef.$flags$ |= 512 /* needsRerender */;
583
+ return;
584
+ }
585
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
586
+ // there is no ancestor component or the ancestor component
587
+ // has already fired off its lifecycle update then
588
+ // fire off the initial update
589
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
590
+ return writeTask(dispatch) ;
591
+ };
592
+ const dispatchHooks = (hostRef, isInitialLoad) => {
593
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
594
+ const instance = hostRef.$lazyInstance$ ;
595
+ let promise;
596
+ if (isInitialLoad) {
597
+ {
598
+ hostRef.$flags$ |= 256 /* isListenReady */;
599
+ if (hostRef.$queuedListeners$) {
600
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
601
+ hostRef.$queuedListeners$ = null;
602
+ }
603
+ }
604
+ {
605
+ promise = safeCall(instance, 'componentWillLoad');
606
+ }
607
+ }
608
+ endSchedule();
609
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
610
+ };
611
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
612
+ // updateComponent
613
+ const elm = hostRef.$hostElement$;
614
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
615
+ const rc = elm['s-rc'];
616
+ if (isInitialLoad) {
617
+ // DOM WRITE!
618
+ attachStyles(hostRef);
619
+ }
620
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
621
+ {
622
+ callRender(hostRef, instance);
623
+ }
624
+ if (rc) {
625
+ // ok, so turns out there are some child host elements
626
+ // waiting on this parent element to load
627
+ // let's fire off all update callbacks waiting
628
+ rc.map((cb) => cb());
629
+ elm['s-rc'] = undefined;
630
+ }
631
+ endRender();
632
+ endUpdate();
633
+ {
634
+ const childrenPromises = elm['s-p'];
635
+ const postUpdate = () => postUpdateComponent(hostRef);
636
+ if (childrenPromises.length === 0) {
637
+ postUpdate();
638
+ }
639
+ else {
640
+ Promise.all(childrenPromises).then(postUpdate);
641
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
642
+ childrenPromises.length = 0;
643
+ }
644
+ }
645
+ };
646
+ const callRender = (hostRef, instance, elm) => {
647
+ try {
648
+ instance = instance.render() ;
649
+ {
650
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
651
+ }
652
+ {
653
+ hostRef.$flags$ |= 2 /* hasRendered */;
654
+ }
655
+ {
656
+ {
657
+ // looks like we've got child nodes to render into this host element
658
+ // or we need to update the css class/attrs on the host element
659
+ // DOM WRITE!
660
+ {
661
+ renderVdom(hostRef, instance);
662
+ }
663
+ }
664
+ }
665
+ }
666
+ catch (e) {
667
+ consoleError(e, hostRef.$hostElement$);
668
+ }
669
+ return null;
670
+ };
671
+ const postUpdateComponent = (hostRef) => {
672
+ const tagName = hostRef.$cmpMeta$.$tagName$;
673
+ const elm = hostRef.$hostElement$;
674
+ const endPostUpdate = createTime('postUpdate', tagName);
675
+ const ancestorComponent = hostRef.$ancestorComponent$;
676
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
677
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
678
+ {
679
+ // DOM WRITE!
680
+ addHydratedFlag(elm);
681
+ }
682
+ endPostUpdate();
683
+ {
684
+ hostRef.$onReadyResolve$(elm);
685
+ if (!ancestorComponent) {
686
+ appDidLoad();
687
+ }
688
+ }
689
+ }
690
+ else {
691
+ endPostUpdate();
692
+ }
693
+ // load events fire from bottom to top
694
+ // the deepest elements load first then bubbles up
695
+ {
696
+ if (hostRef.$onRenderResolve$) {
697
+ hostRef.$onRenderResolve$();
698
+ hostRef.$onRenderResolve$ = undefined;
699
+ }
700
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
701
+ nextTick(() => scheduleUpdate(hostRef, false));
702
+ }
703
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
704
+ }
705
+ // ( •_•)
706
+ // ( •_•)>⌐■-■
707
+ // (⌐■_■)
708
+ };
709
+ const appDidLoad = (who) => {
710
+ // on appload
711
+ // we have finish the first big initial render
712
+ {
713
+ addHydratedFlag(doc.documentElement);
714
+ }
715
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
716
+ };
717
+ const safeCall = (instance, method, arg) => {
718
+ if (instance && instance[method]) {
719
+ try {
720
+ return instance[method](arg);
721
+ }
722
+ catch (e) {
723
+ consoleError(e);
724
+ }
725
+ }
726
+ return undefined;
727
+ };
728
+ const then = (promise, thenFn) => {
729
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
730
+ };
731
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
732
+ ;
733
+ /**
734
+ * Parse a new property value for a given property type.
735
+ *
736
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
737
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
738
+ * 1. `any`, the type given to `propValue` in the function signature
739
+ * 2. the type stored from `propType`.
740
+ *
741
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
742
+ *
743
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
744
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
745
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
746
+ * ```tsx
747
+ * <my-cmp prop-val={0}></my-cmp>
748
+ * ```
749
+ *
750
+ * HTML prop values on the other hand, will always a string
751
+ *
752
+ * @param propValue the new value to coerce to some type
753
+ * @param propType the type of the prop, expressed as a binary number
754
+ * @returns the parsed/coerced value
755
+ */
756
+ const parsePropertyValue = (propValue, propType) => {
757
+ // ensure this value is of the correct prop type
758
+ if (propValue != null && !isComplexType(propValue)) {
759
+ if (propType & 4 /* Boolean */) {
760
+ // per the HTML spec, any string value means it is a boolean true value
761
+ // but we'll cheat here and say that the string "false" is the boolean false
762
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
763
+ }
764
+ if (propType & 2 /* Number */) {
765
+ // force it to be a number
766
+ return parseFloat(propValue);
767
+ }
768
+ if (propType & 1 /* String */) {
769
+ // could have been passed as a number or boolean
770
+ // but we still want it as a string
771
+ return String(propValue);
772
+ }
773
+ // redundant return here for better minification
774
+ return propValue;
775
+ }
776
+ // not sure exactly what type we want
777
+ // so no need to change to a different type
778
+ return propValue;
779
+ };
780
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
781
+ const setValue = (ref, propName, newVal, cmpMeta) => {
782
+ // check our new property value against our internal value
783
+ const hostRef = getHostRef(ref);
784
+ const elm = hostRef.$hostElement$ ;
785
+ const oldVal = hostRef.$instanceValues$.get(propName);
786
+ const flags = hostRef.$flags$;
787
+ const instance = hostRef.$lazyInstance$ ;
788
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
789
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
790
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
791
+ const didValueChange = newVal !== oldVal && !areBothNaN;
792
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
793
+ // gadzooks! the property's value has changed!!
794
+ // set our new value!
795
+ hostRef.$instanceValues$.set(propName, newVal);
796
+ if (instance) {
797
+ // get an array of method names of watch functions to call
798
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
799
+ const watchMethods = cmpMeta.$watchers$[propName];
800
+ if (watchMethods) {
801
+ // this instance is watching for when this property changed
802
+ watchMethods.map((watchMethodName) => {
803
+ try {
804
+ // fire off each of the watch methods that are watching this property
805
+ instance[watchMethodName](newVal, oldVal, propName);
806
+ }
807
+ catch (e) {
808
+ consoleError(e, elm);
809
+ }
810
+ });
811
+ }
812
+ }
813
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
814
+ // looks like this value actually changed, so we've got work to do!
815
+ // but only if we've already rendered, otherwise just chill out
816
+ // queue that we need to do an update, but don't worry about queuing
817
+ // up millions cuz this function ensures it only runs once
818
+ scheduleUpdate(hostRef, false);
819
+ }
820
+ }
821
+ }
822
+ };
823
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
824
+ if (cmpMeta.$members$) {
825
+ if (Cstr.watchers) {
826
+ cmpMeta.$watchers$ = Cstr.watchers;
827
+ }
828
+ // It's better to have a const than two Object.entries()
829
+ const members = Object.entries(cmpMeta.$members$);
830
+ const prototype = Cstr.prototype;
831
+ members.map(([memberName, [memberFlags]]) => {
832
+ if ((memberFlags & 31 /* Prop */ ||
833
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
834
+ // proxyComponent - prop
835
+ Object.defineProperty(prototype, memberName, {
836
+ get() {
837
+ // proxyComponent, get value
838
+ return getValue(this, memberName);
839
+ },
840
+ set(newValue) {
841
+ // proxyComponent, set value
842
+ setValue(this, memberName, newValue, cmpMeta);
843
+ },
844
+ configurable: true,
845
+ enumerable: true,
846
+ });
847
+ }
848
+ });
849
+ if ((flags & 1 /* isElementConstructor */)) {
850
+ const attrNameToPropName = new Map();
851
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
852
+ plt.jmp(() => {
853
+ const propName = attrNameToPropName.get(attrName);
854
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
855
+ // in the case where an attribute was set inline.
856
+ // ```html
857
+ // <my-component some-attribute="some-value"></my-component>
858
+ // ```
859
+ //
860
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
861
+ // programmatically changes it before it has been upgraded as shown below:
862
+ //
863
+ // ```html
864
+ // <!-- this component has _not_ been upgraded yet -->
865
+ // <my-component id="test" some-attribute="some-value"></my-component>
866
+ // <script>
867
+ // // grab non-upgraded component
868
+ // el = document.querySelector("#test");
869
+ // el.someAttribute = "another-value";
870
+ // // upgrade component
871
+ // customElements.define('my-component', MyComponent);
872
+ // </script>
873
+ // ```
874
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
875
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
876
+ // to the value that was set inline i.e. "some-value" from above example. When
877
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
878
+ //
879
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
880
+ // by connectedCallback as this attributeChangedCallback will not fire.
881
+ //
882
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
883
+ //
884
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
885
+ // properties here given that this goes against best practices outlined here
886
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
887
+ if (this.hasOwnProperty(propName)) {
888
+ newValue = this[propName];
889
+ delete this[propName];
890
+ }
891
+ else if (prototype.hasOwnProperty(propName) &&
892
+ typeof this[propName] === 'number' &&
893
+ this[propName] == newValue) {
894
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
895
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
896
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
897
+ return;
898
+ }
899
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
900
+ });
901
+ };
902
+ // create an array of attributes to observe
903
+ // and also create a map of html attribute name to js property name
904
+ Cstr.observedAttributes = members
905
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
906
+ .map(([propName, m]) => {
907
+ const attrName = m[1] || propName;
908
+ attrNameToPropName.set(attrName, propName);
909
+ return attrName;
910
+ });
911
+ }
912
+ }
913
+ return Cstr;
914
+ };
915
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
916
+ // initializeComponent
917
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
918
+ {
919
+ // we haven't initialized this element yet
920
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
921
+ // lazy loaded components
922
+ // request the component's implementation to be
923
+ // wired up with the host element
924
+ Cstr = loadModule(cmpMeta);
925
+ if (Cstr.then) {
926
+ // Await creates a micro-task avoid if possible
927
+ const endLoad = uniqueTime();
928
+ Cstr = await Cstr;
929
+ endLoad();
930
+ }
931
+ if (!Cstr.isProxied) {
932
+ // we've never proxied this Constructor before
933
+ // let's add the getters/setters to its prototype before
934
+ // the first time we create an instance of the implementation
935
+ {
936
+ cmpMeta.$watchers$ = Cstr.watchers;
937
+ }
938
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
939
+ Cstr.isProxied = true;
940
+ }
941
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
942
+ // ok, time to construct the instance
943
+ // but let's keep track of when we start and stop
944
+ // so that the getters/setters don't incorrectly step on data
945
+ {
946
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
947
+ }
948
+ // construct the lazy-loaded component implementation
949
+ // passing the hostRef is very important during
950
+ // construction in order to directly wire together the
951
+ // host element and the lazy-loaded instance
952
+ try {
953
+ new Cstr(hostRef);
954
+ }
955
+ catch (e) {
956
+ consoleError(e);
957
+ }
958
+ {
959
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
960
+ }
961
+ {
962
+ hostRef.$flags$ |= 128 /* isWatchReady */;
963
+ }
964
+ endNewInstance();
965
+ fireConnectedCallback(hostRef.$lazyInstance$);
966
+ }
967
+ if (Cstr.style) {
968
+ // this component has styles but we haven't registered them yet
969
+ let style = Cstr.style;
970
+ const scopeId = getScopeId(cmpMeta);
971
+ if (!styles.has(scopeId)) {
972
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
973
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
974
+ endRegisterStyles();
975
+ }
976
+ }
977
+ }
978
+ // we've successfully created a lazy instance
979
+ const ancestorComponent = hostRef.$ancestorComponent$;
980
+ const schedule = () => scheduleUpdate(hostRef, true);
981
+ if (ancestorComponent && ancestorComponent['s-rc']) {
982
+ // this is the initial load and this component it has an ancestor component
983
+ // but the ancestor component has NOT fired its will update lifecycle yet
984
+ // so let's just cool our jets and wait for the ancestor to continue first
985
+ // this will get fired off when the ancestor component
986
+ // finally gets around to rendering its lazy self
987
+ // fire off the initial update
988
+ ancestorComponent['s-rc'].push(schedule);
989
+ }
990
+ else {
991
+ schedule();
992
+ }
993
+ };
994
+ const fireConnectedCallback = (instance) => {
995
+ {
996
+ safeCall(instance, 'connectedCallback');
997
+ }
998
+ };
999
+ const connectedCallback = (elm) => {
1000
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1001
+ const hostRef = getHostRef(elm);
1002
+ const cmpMeta = hostRef.$cmpMeta$;
1003
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1004
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1005
+ // first time this component has connected
1006
+ hostRef.$flags$ |= 1 /* hasConnected */;
1007
+ {
1008
+ // find the first ancestor component (if there is one) and register
1009
+ // this component as one of the actively loading child components for its ancestor
1010
+ let ancestorComponent = elm;
1011
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1012
+ // climb up the ancestors looking for the first
1013
+ // component that hasn't finished its lifecycle update yet
1014
+ if (ancestorComponent['s-p']) {
1015
+ // we found this components first ancestor component
1016
+ // keep a reference to this component's ancestor component
1017
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1018
+ break;
1019
+ }
1020
+ }
1021
+ }
1022
+ // Lazy properties
1023
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1024
+ if (cmpMeta.$members$) {
1025
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1026
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1027
+ const value = elm[memberName];
1028
+ delete elm[memberName];
1029
+ elm[memberName] = value;
1030
+ }
1031
+ });
1032
+ }
1033
+ {
1034
+ initializeComponent(elm, hostRef, cmpMeta);
1035
+ }
1036
+ }
1037
+ else {
1038
+ // not the first time this has connected
1039
+ // reattach any event listeners to the host
1040
+ // since they would have been removed when disconnected
1041
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1042
+ // fire off connectedCallback() on component instance
1043
+ fireConnectedCallback(hostRef.$lazyInstance$);
1044
+ }
1045
+ endConnected();
1046
+ }
1047
+ };
1048
+ const disconnectedCallback = (elm) => {
1049
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1050
+ const hostRef = getHostRef(elm);
1051
+ {
1052
+ if (hostRef.$rmListeners$) {
1053
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1054
+ hostRef.$rmListeners$ = undefined;
1055
+ }
1056
+ }
1057
+ }
1058
+ };
1059
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1060
+ const endBootstrap = createTime();
1061
+ const cmpTags = [];
1062
+ const exclude = options.exclude || [];
1063
+ const customElements = win.customElements;
1064
+ const head = doc.head;
1065
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1066
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1067
+ const deferredConnectedCallbacks = [];
1068
+ let appLoadFallback;
1069
+ let isBootstrapping = true;
1070
+ Object.assign(plt, options);
1071
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1072
+ lazyBundles.map((lazyBundle) => {
1073
+ lazyBundle[1].map((compactMeta) => {
1074
+ const cmpMeta = {
1075
+ $flags$: compactMeta[0],
1076
+ $tagName$: compactMeta[1],
1077
+ $members$: compactMeta[2],
1078
+ $listeners$: compactMeta[3],
1079
+ };
1080
+ {
1081
+ cmpMeta.$members$ = compactMeta[2];
1082
+ }
1083
+ {
1084
+ cmpMeta.$listeners$ = compactMeta[3];
1085
+ }
1086
+ {
1087
+ cmpMeta.$watchers$ = {};
1088
+ }
1089
+ const tagName = cmpMeta.$tagName$;
1090
+ const HostElement = class extends HTMLElement {
1091
+ // StencilLazyHost
1092
+ constructor(self) {
1093
+ // @ts-ignore
1094
+ super(self);
1095
+ self = this;
1096
+ registerHost(self, cmpMeta);
1097
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1098
+ // this component is using shadow dom
1099
+ // and this browser supports shadow dom
1100
+ // add the read-only property "shadowRoot" to the host element
1101
+ // adding the shadow root build conditionals to minimize runtime
1102
+ {
1103
+ {
1104
+ self.attachShadow({ mode: 'open' });
1105
+ }
1106
+ }
1107
+ }
1108
+ }
1109
+ connectedCallback() {
1110
+ if (appLoadFallback) {
1111
+ clearTimeout(appLoadFallback);
1112
+ appLoadFallback = null;
1113
+ }
1114
+ if (isBootstrapping) {
1115
+ // connectedCallback will be processed once all components have been registered
1116
+ deferredConnectedCallbacks.push(this);
1117
+ }
1118
+ else {
1119
+ plt.jmp(() => connectedCallback(this));
1120
+ }
1121
+ }
1122
+ disconnectedCallback() {
1123
+ plt.jmp(() => disconnectedCallback(this));
1124
+ }
1125
+ componentOnReady() {
1126
+ return getHostRef(this).$onReadyPromise$;
1127
+ }
1128
+ };
1129
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1130
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1131
+ cmpTags.push(tagName);
1132
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1133
+ }
1134
+ });
1135
+ });
1136
+ {
1137
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1138
+ visibilityStyle.setAttribute('data-styles', '');
1139
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1140
+ }
1141
+ // Process deferred connectedCallbacks now all components have been registered
1142
+ isBootstrapping = false;
1143
+ if (deferredConnectedCallbacks.length) {
1144
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1145
+ }
1146
+ else {
1147
+ {
1148
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1149
+ }
1150
+ }
1151
+ // Fallback appLoad event
1152
+ endBootstrap();
1153
+ };
1154
+ const hostRefs = new WeakMap();
1155
+ const getHostRef = (ref) => hostRefs.get(ref);
1156
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1157
+ const registerHost = (elm, cmpMeta) => {
1158
+ const hostRef = {
1159
+ $flags$: 0,
1160
+ $hostElement$: elm,
1161
+ $cmpMeta$: cmpMeta,
1162
+ $instanceValues$: new Map(),
1163
+ };
1164
+ {
1165
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1166
+ elm['s-p'] = [];
1167
+ elm['s-rc'] = [];
1168
+ }
1169
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1170
+ return hostRefs.set(elm, hostRef);
1171
+ };
1172
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1173
+ const consoleError = (e, el) => (0, console.error)(e, el);
1174
+ const cmpModules = /*@__PURE__*/ new Map();
1175
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1176
+ // loadModuleImport
1177
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1178
+ const bundleId = cmpMeta.$lazyBundleId$;
1179
+ const module = cmpModules.get(bundleId) ;
1180
+ if (module) {
1181
+ return module[exportName];
1182
+ }
1183
+ return import(
1184
+ /* webpackInclude: /\.entry\.js$/ */
1185
+ /* webpackExclude: /\.system\.entry\.js$/ */
1186
+ /* webpackMode: "lazy" */
1187
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
1188
+ {
1189
+ cmpModules.set(bundleId, importedModule);
1190
+ }
1191
+ return importedModule[exportName];
1192
+ }, consoleError);
1193
+ };
1194
+ const styles = new Map();
1195
+ const queueDomReads = [];
1196
+ const queueDomWrites = [];
1197
+ const queueTask = (queue, write) => (cb) => {
1198
+ queue.push(cb);
1199
+ if (!queuePending) {
1200
+ queuePending = true;
1201
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1202
+ nextTick(flush);
1203
+ }
1204
+ else {
1205
+ plt.raf(flush);
1206
+ }
1207
+ }
1208
+ };
1209
+ const consume = (queue) => {
1210
+ for (let i = 0; i < queue.length; i++) {
1211
+ try {
1212
+ queue[i](performance.now());
1213
+ }
1214
+ catch (e) {
1215
+ consoleError(e);
1216
+ }
1217
+ }
1218
+ queue.length = 0;
1219
+ };
1220
+ const flush = () => {
1221
+ // always force a bunch of medium callbacks to run, but still have
1222
+ // a throttle on how many can run in a certain time
1223
+ // DOM READS!!!
1224
+ consume(queueDomReads);
1225
+ // DOM WRITES!!!
1226
+ {
1227
+ consume(queueDomWrites);
1228
+ if ((queuePending = queueDomReads.length > 0)) {
1229
+ // still more to do yet, but we've run out of time
1230
+ // let's let this thing cool off and try again in the next tick
1231
+ plt.raf(flush);
1232
+ }
1233
+ }
1234
+ };
1235
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1236
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1237
+
1238
+ export { bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };