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