pushfeedback 0.0.7 → 0.0.9

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