@everymatrix/general-input 0.0.1

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