pushfeedback 0.1.45 → 0.1.46

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