hemfixarna-web-components 0.3.1 → 0.9.2

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