hemfixarna-web-components 1.6.2 → 1.6.4

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