@gataca/qr 2.0.2 → 2.0.3

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