hemfixarna-web-components 1.8.4 → 1.8.5

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 (363) hide show
  1. package/dist/{collection/utils/api.js → hemfixarna-components/api-e3c51cb3.js} +7 -4
  2. package/dist/hemfixarna-components/api-e3c51cb3.js.map +1 -0
  3. package/dist/hemfixarna-components/app-globals-0f993ce5.js +5 -0
  4. package/dist/hemfixarna-components/app-globals-0f993ce5.js.map +1 -0
  5. package/dist/{collection/utils/calc.js → hemfixarna-components/calc-b3b6593c.js} +7 -13
  6. package/dist/hemfixarna-components/calc-b3b6593c.js.map +1 -0
  7. package/dist/hemfixarna-components/css-shim-4fde41f0.js +6 -0
  8. package/dist/hemfixarna-components/css-shim-4fde41f0.js.map +1 -0
  9. package/dist/hemfixarna-components/dom-8de30773.js +75 -0
  10. package/dist/hemfixarna-components/dom-8de30773.js.map +1 -0
  11. package/dist/{collection/utils/enviroment.js → hemfixarna-components/enviroment-fd0a763a.js} +8 -6
  12. package/dist/hemfixarna-components/enviroment-fd0a763a.js.map +1 -0
  13. package/dist/{collection/utils/form.js → hemfixarna-components/form-c53dca29.js} +4 -2
  14. package/dist/hemfixarna-components/form-c53dca29.js.map +1 -0
  15. package/dist/{collection/components/hemfixarna-address/hemfixarna-address.js → hemfixarna-components/hemfixarna-address.entry.js} +14 -20
  16. package/dist/hemfixarna-components/hemfixarna-address.entry.js.map +1 -0
  17. package/dist/hemfixarna-components/hemfixarna-box.entry.js +49 -0
  18. package/dist/hemfixarna-components/hemfixarna-box.entry.js.map +1 -0
  19. package/dist/{collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js → hemfixarna-components/hemfixarna-breadcrumbs.entry.js} +13 -28
  20. package/dist/hemfixarna-components/hemfixarna-breadcrumbs.entry.js.map +1 -0
  21. package/dist/{esm → hemfixarna-components}/hemfixarna-byggmax.entry.js +1 -1
  22. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js.map +1 -0
  23. package/dist/{collection/components/hemfixarna-cart/hemfixarna-cart.js → hemfixarna-components/hemfixarna-cart.entry.js} +12 -6
  24. package/dist/hemfixarna-components/hemfixarna-cart.entry.js.map +1 -0
  25. package/dist/{esm → hemfixarna-components}/hemfixarna-category.entry.js +2 -2
  26. package/dist/hemfixarna-components/hemfixarna-category.entry.js.map +1 -0
  27. package/dist/{collection/components/hemfixarna-checkout/hemfixarna-checkout.js → hemfixarna-components/hemfixarna-checkout.entry.js} +33 -26
  28. package/dist/hemfixarna-components/hemfixarna-checkout.entry.js.map +1 -0
  29. package/dist/hemfixarna-components/hemfixarna-component.entry.js +189 -0
  30. package/dist/hemfixarna-components/hemfixarna-component.entry.js.map +1 -0
  31. package/dist/hemfixarna-components/hemfixarna-components.esm.js +162 -1
  32. package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
  33. package/dist/{collection/components/hemfixarna-contact/hemfixarna-contact.js → hemfixarna-components/hemfixarna-contact.entry.js} +11 -29
  34. package/dist/hemfixarna-components/hemfixarna-contact.entry.js.map +1 -0
  35. package/dist/{collection/components/hemfixarna-demo/hemfixarna-demo.js → hemfixarna-components/hemfixarna-demo.entry.js} +21 -46
  36. package/dist/hemfixarna-components/hemfixarna-demo.entry.js.map +1 -0
  37. package/dist/{esm → hemfixarna-components}/hemfixarna-doro.entry.js +1 -1
  38. package/dist/hemfixarna-components/hemfixarna-doro.entry.js.map +1 -0
  39. package/dist/{esm → hemfixarna-components}/hemfixarna-elfa.entry.js +1 -1
  40. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js.map +1 -0
  41. package/dist/{esm → hemfixarna-components}/hemfixarna-fargvaruhuset.entry.js +1 -1
  42. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js.map +1 -0
  43. package/dist/{esm → hemfixarna-components}/hemfixarna-flyttsmart.entry.js +1 -1
  44. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js.map +1 -0
  45. package/dist/{esm → hemfixarna-components}/hemfixarna-forebygg.entry.js +1 -1
  46. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js.map +1 -0
  47. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js +770 -0
  48. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js.map +1 -0
  49. package/dist/{esm → hemfixarna-components}/hemfixarna-hornbach.entry.js +1 -1
  50. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js.map +1 -0
  51. package/dist/{collection/components/hemfixarna-info/hemfixarna-info.js → hemfixarna-components/hemfixarna-info.entry.js} +11 -7
  52. package/dist/hemfixarna-components/hemfixarna-info.entry.js.map +1 -0
  53. package/dist/{collection/components/hemfixarna-invoice/hemfixarna-invoice.js → hemfixarna-components/hemfixarna-invoice.entry.js} +16 -27
  54. package/dist/hemfixarna-components/hemfixarna-invoice.entry.js.map +1 -0
  55. package/dist/{esm → hemfixarna-components}/hemfixarna-kbygg.entry.js +1 -1
  56. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js.map +1 -0
  57. package/dist/{esm → hemfixarna-components}/hemfixarna-klint.entry.js +1 -1
  58. package/dist/hemfixarna-components/hemfixarna-klint.entry.js.map +1 -0
  59. package/dist/{esm → hemfixarna-components}/hemfixarna-kund.entry.js +1 -1
  60. package/dist/hemfixarna-components/hemfixarna-kund.entry.js.map +1 -0
  61. package/dist/{esm → hemfixarna-components}/hemfixarna-norrgavel.entry.js +1 -1
  62. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js.map +1 -0
  63. package/dist/{collection/components/hemfixarna-order/hemfixarna-order.js → hemfixarna-components/hemfixarna-order.entry.js} +11 -7
  64. package/dist/hemfixarna-components/hemfixarna-order.entry.js.map +1 -0
  65. package/dist/{collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js → hemfixarna-components/hemfixarna-orderrows.entry.js} +12 -30
  66. package/dist/hemfixarna-components/hemfixarna-orderrows.entry.js.map +1 -0
  67. package/dist/{esm → hemfixarna-components}/hemfixarna-power.entry.js +1 -1
  68. package/dist/hemfixarna-components/hemfixarna-power.entry.js.map +1 -0
  69. package/dist/{collection/components/hemfixarna-product/hemfixarna-product.js → hemfixarna-components/hemfixarna-product.entry.js} +18 -27
  70. package/dist/hemfixarna-components/hemfixarna-product.entry.js.map +1 -0
  71. package/dist/{esm → hemfixarna-components}/hemfixarna-service.entry.js +2 -2
  72. package/dist/hemfixarna-components/hemfixarna-service.entry.js.map +1 -0
  73. package/dist/{esm → hemfixarna-components}/hemfixarna-skanska.entry.js +1 -1
  74. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js.map +1 -0
  75. package/dist/{esm → hemfixarna-components}/hemfixarna-sparfonster.entry.js +1 -1
  76. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js.map +1 -0
  77. package/dist/{collection/components/hemfixarna-start/hemfixarna-start.js → hemfixarna-components/hemfixarna-start.entry.js} +11 -48
  78. package/dist/hemfixarna-components/hemfixarna-start.entry.js.map +1 -0
  79. package/dist/{esm → hemfixarna-components}/hemfixarna-string-furniture.entry.js +1 -1
  80. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js.map +1 -0
  81. package/dist/{esm → hemfixarna-components}/hemfixarna-superfront.entry.js +1 -1
  82. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js.map +1 -0
  83. package/dist/{esm → hemfixarna-components}/hemfixarna-tesla.entry.js +1 -1
  84. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js.map +1 -0
  85. package/dist/{esm → hemfixarna-components}/hemfixarna-traningspartner.entry.js +1 -1
  86. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js.map +1 -0
  87. package/dist/{esm → hemfixarna-components}/hemfixarna-zaptec.entry.js +1 -1
  88. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js.map +1 -0
  89. package/dist/{esm/index-aa51ad9d.js → hemfixarna-components/index-21ba2b05.js} +2 -2
  90. package/dist/{esm/index-aa51ad9d.js.map → hemfixarna-components/index-21ba2b05.js.map} +1 -1
  91. package/dist/hemfixarna-components/index-2ce8b901.js +3461 -0
  92. package/dist/hemfixarna-components/index-2ce8b901.js.map +1 -0
  93. package/dist/hemfixarna-components/index.esm.js +1 -0
  94. package/dist/hemfixarna-components/index.esm.js.map +1 -1
  95. package/dist/{collection/utils/scroll.js → hemfixarna-components/scroll-6c26b5da.js} +4 -2
  96. package/dist/hemfixarna-components/scroll-6c26b5da.js.map +1 -0
  97. package/dist/hemfixarna-components/shadow-css-af2290df.js +389 -0
  98. package/dist/hemfixarna-components/shadow-css-af2290df.js.map +1 -0
  99. package/dist/{collection/utils/types.js → hemfixarna-components/types-6da209ae.js} +6 -3
  100. package/dist/hemfixarna-components/types-6da209ae.js.map +1 -0
  101. package/package.json +1 -1
  102. package/dist/cjs/hemfixarna-address_15.cjs.entry.js +0 -2180
  103. package/dist/cjs/hemfixarna-address_15.cjs.entry.js.map +0 -1
  104. package/dist/cjs/hemfixarna-byggmax.cjs.entry.js +0 -27
  105. package/dist/cjs/hemfixarna-byggmax.cjs.entry.js.map +0 -1
  106. package/dist/cjs/hemfixarna-category.cjs.entry.js +0 -28
  107. package/dist/cjs/hemfixarna-category.cjs.entry.js.map +0 -1
  108. package/dist/cjs/hemfixarna-components.cjs.js +0 -28
  109. package/dist/cjs/hemfixarna-components.cjs.js.map +0 -1
  110. package/dist/cjs/hemfixarna-doro.cjs.entry.js +0 -26
  111. package/dist/cjs/hemfixarna-doro.cjs.entry.js.map +0 -1
  112. package/dist/cjs/hemfixarna-elfa.cjs.entry.js +0 -26
  113. package/dist/cjs/hemfixarna-elfa.cjs.entry.js.map +0 -1
  114. package/dist/cjs/hemfixarna-fargvaruhuset.cjs.entry.js +0 -23
  115. package/dist/cjs/hemfixarna-fargvaruhuset.cjs.entry.js.map +0 -1
  116. package/dist/cjs/hemfixarna-flyttsmart.cjs.entry.js +0 -23
  117. package/dist/cjs/hemfixarna-flyttsmart.cjs.entry.js.map +0 -1
  118. package/dist/cjs/hemfixarna-forebygg.cjs.entry.js +0 -26
  119. package/dist/cjs/hemfixarna-forebygg.cjs.entry.js.map +0 -1
  120. package/dist/cjs/hemfixarna-hornbach.cjs.entry.js +0 -26
  121. package/dist/cjs/hemfixarna-hornbach.cjs.entry.js.map +0 -1
  122. package/dist/cjs/hemfixarna-kbygg.cjs.entry.js +0 -23
  123. package/dist/cjs/hemfixarna-kbygg.cjs.entry.js.map +0 -1
  124. package/dist/cjs/hemfixarna-klint.cjs.entry.js +0 -23
  125. package/dist/cjs/hemfixarna-klint.cjs.entry.js.map +0 -1
  126. package/dist/cjs/hemfixarna-kund.cjs.entry.js +0 -23
  127. package/dist/cjs/hemfixarna-kund.cjs.entry.js.map +0 -1
  128. package/dist/cjs/hemfixarna-norrgavel.cjs.entry.js +0 -23
  129. package/dist/cjs/hemfixarna-norrgavel.cjs.entry.js.map +0 -1
  130. package/dist/cjs/hemfixarna-power.cjs.entry.js +0 -23
  131. package/dist/cjs/hemfixarna-power.cjs.entry.js.map +0 -1
  132. package/dist/cjs/hemfixarna-service.cjs.entry.js +0 -24
  133. package/dist/cjs/hemfixarna-service.cjs.entry.js.map +0 -1
  134. package/dist/cjs/hemfixarna-skanska.cjs.entry.js +0 -26
  135. package/dist/cjs/hemfixarna-skanska.cjs.entry.js.map +0 -1
  136. package/dist/cjs/hemfixarna-sparfonster.cjs.entry.js +0 -23
  137. package/dist/cjs/hemfixarna-sparfonster.cjs.entry.js.map +0 -1
  138. package/dist/cjs/hemfixarna-string-furniture.cjs.entry.js +0 -26
  139. package/dist/cjs/hemfixarna-string-furniture.cjs.entry.js.map +0 -1
  140. package/dist/cjs/hemfixarna-superfront.cjs.entry.js +0 -24
  141. package/dist/cjs/hemfixarna-superfront.cjs.entry.js.map +0 -1
  142. package/dist/cjs/hemfixarna-tesla.cjs.entry.js +0 -23
  143. package/dist/cjs/hemfixarna-tesla.cjs.entry.js.map +0 -1
  144. package/dist/cjs/hemfixarna-traningspartner.cjs.entry.js +0 -23
  145. package/dist/cjs/hemfixarna-traningspartner.cjs.entry.js.map +0 -1
  146. package/dist/cjs/hemfixarna-zaptec.cjs.entry.js +0 -23
  147. package/dist/cjs/hemfixarna-zaptec.cjs.entry.js.map +0 -1
  148. package/dist/cjs/index-3e8dcb29.js +0 -265
  149. package/dist/cjs/index-3e8dcb29.js.map +0 -1
  150. package/dist/cjs/index-e6926623.js +0 -1741
  151. package/dist/cjs/index-e6926623.js.map +0 -1
  152. package/dist/cjs/index-e81df82e.js +0 -49
  153. package/dist/cjs/index-e81df82e.js.map +0 -1
  154. package/dist/cjs/index.cjs.js +0 -4
  155. package/dist/cjs/index.cjs.js.map +0 -1
  156. package/dist/cjs/loader.cjs.js +0 -24
  157. package/dist/cjs/loader.cjs.js.map +0 -1
  158. package/dist/collection/assets/back.svg +0 -3
  159. package/dist/collection/assets/cart.svg +0 -10
  160. package/dist/collection/assets/checked.svg +0 -10
  161. package/dist/collection/assets/close.svg +0 -5
  162. package/dist/collection/assets/copy.png +0 -0
  163. package/dist/collection/assets/date.svg +0 -6
  164. package/dist/collection/assets/down.svg +0 -3
  165. package/dist/collection/assets/drag-drop.svg +0 -3
  166. package/dist/collection/assets/elfa.png +0 -0
  167. package/dist/collection/assets/gubbe-pensel.svg +0 -1
  168. package/dist/collection/assets/hemfixarna.svg +0 -11
  169. package/dist/collection/assets/hornbach/logo.svg +0 -42
  170. package/dist/collection/assets/hornbach/nav.jpg +0 -0
  171. package/dist/collection/assets/info.svg +0 -5
  172. package/dist/collection/assets/kbygg.svg +0 -29
  173. package/dist/collection/assets/minus.svg +0 -4
  174. package/dist/collection/assets/montering.svg +0 -15
  175. package/dist/collection/assets/norrgavel.svg +0 -1
  176. package/dist/collection/assets/pensel.svg +0 -1
  177. package/dist/collection/assets/plus.svg +0 -5
  178. package/dist/collection/assets/spinner.gif +0 -0
  179. package/dist/collection/assets/tesla.svg +0 -1
  180. package/dist/collection/assets/zaptec.svg +0 -1
  181. package/dist/collection/collection-manifest.json +0 -47
  182. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.css +0 -0
  183. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js +0 -122
  184. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js.map +0 -1
  185. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.css +0 -0
  186. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js +0 -104
  187. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js.map +0 -1
  188. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.css +0 -0
  189. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js +0 -104
  190. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js.map +0 -1
  191. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js +0 -94
  192. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js.map +0 -1
  193. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js +0 -94
  194. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js.map +0 -1
  195. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.css +0 -0
  196. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js +0 -104
  197. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js.map +0 -1
  198. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.css +0 -0
  199. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js +0 -104
  200. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js.map +0 -1
  201. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js +0 -94
  202. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js.map +0 -1
  203. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js +0 -94
  204. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js.map +0 -1
  205. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js +0 -94
  206. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js.map +0 -1
  207. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js +0 -94
  208. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js.map +0 -1
  209. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js +0 -94
  210. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js.map +0 -1
  211. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.css +0 -0
  212. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js +0 -104
  213. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js.map +0 -1
  214. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js +0 -94
  215. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js.map +0 -1
  216. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js +0 -104
  217. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js.map +0 -1
  218. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string.css +0 -0
  219. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js +0 -113
  220. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js.map +0 -1
  221. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js +0 -94
  222. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js.map +0 -1
  223. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js +0 -94
  224. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js.map +0 -1
  225. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js +0 -94
  226. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js.map +0 -1
  227. package/dist/collection/components/hemfixarna-address/hemfixarna-address.js.map +0 -1
  228. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js +0 -138
  229. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js.map +0 -1
  230. package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +0 -1
  231. package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +0 -1
  232. package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js +0 -18
  233. package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js.map +0 -1
  234. package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js.map +0 -1
  235. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +0 -330
  236. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +0 -1
  237. package/dist/collection/components/hemfixarna-component/hemfixarna.css +0 -1061
  238. package/dist/collection/components/hemfixarna-contact/hemfixarna-contact.js.map +0 -1
  239. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.css +0 -135
  240. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +0 -1
  241. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js +0 -91
  242. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js.map +0 -1
  243. package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +0 -1
  244. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.css +0 -76
  245. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js.map +0 -1
  246. package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +0 -1
  247. package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +0 -1
  248. package/dist/collection/components/hemfixarna-product/hemfixarna-product.css +0 -0
  249. package/dist/collection/components/hemfixarna-product/hemfixarna-product.js.map +0 -1
  250. package/dist/collection/components/hemfixarna-service/hemfixarna-service.js +0 -14
  251. package/dist/collection/components/hemfixarna-service/hemfixarna-service.js.map +0 -1
  252. package/dist/collection/components/hemfixarna-start/hemfixarna-start.js.map +0 -1
  253. package/dist/collection/index.js +0 -2
  254. package/dist/collection/index.js.map +0 -1
  255. package/dist/collection/store/index.js +0 -69
  256. package/dist/collection/store/index.js.map +0 -1
  257. package/dist/collection/types/felixtypes.js +0 -3
  258. package/dist/collection/types/felixtypes.js.map +0 -1
  259. package/dist/collection/types/index.js +0 -46
  260. package/dist/collection/types/index.js.map +0 -1
  261. package/dist/collection/utils/api.js.map +0 -1
  262. package/dist/collection/utils/calc.js.map +0 -1
  263. package/dist/collection/utils/creditSafe.js +0 -18
  264. package/dist/collection/utils/creditSafe.js.map +0 -1
  265. package/dist/collection/utils/enviroment.js.map +0 -1
  266. package/dist/collection/utils/felixApi.js +0 -19
  267. package/dist/collection/utils/felixApi.js.map +0 -1
  268. package/dist/collection/utils/felixFunctions.js +0 -188
  269. package/dist/collection/utils/felixFunctions.js.map +0 -1
  270. package/dist/collection/utils/form.js.map +0 -1
  271. package/dist/collection/utils/scroll.js.map +0 -1
  272. package/dist/collection/utils/types.js.map +0 -1
  273. package/dist/esm/hemfixarna-address_15.entry.js +0 -2162
  274. package/dist/esm/hemfixarna-address_15.entry.js.map +0 -1
  275. package/dist/esm/hemfixarna-byggmax.entry.js.map +0 -1
  276. package/dist/esm/hemfixarna-category.entry.js.map +0 -1
  277. package/dist/esm/hemfixarna-components.js +0 -23
  278. package/dist/esm/hemfixarna-components.js.map +0 -1
  279. package/dist/esm/hemfixarna-doro.entry.js.map +0 -1
  280. package/dist/esm/hemfixarna-elfa.entry.js.map +0 -1
  281. package/dist/esm/hemfixarna-fargvaruhuset.entry.js.map +0 -1
  282. package/dist/esm/hemfixarna-flyttsmart.entry.js.map +0 -1
  283. package/dist/esm/hemfixarna-forebygg.entry.js.map +0 -1
  284. package/dist/esm/hemfixarna-hornbach.entry.js.map +0 -1
  285. package/dist/esm/hemfixarna-kbygg.entry.js.map +0 -1
  286. package/dist/esm/hemfixarna-klint.entry.js.map +0 -1
  287. package/dist/esm/hemfixarna-kund.entry.js.map +0 -1
  288. package/dist/esm/hemfixarna-norrgavel.entry.js.map +0 -1
  289. package/dist/esm/hemfixarna-power.entry.js.map +0 -1
  290. package/dist/esm/hemfixarna-service.entry.js.map +0 -1
  291. package/dist/esm/hemfixarna-skanska.entry.js.map +0 -1
  292. package/dist/esm/hemfixarna-sparfonster.entry.js.map +0 -1
  293. package/dist/esm/hemfixarna-string-furniture.entry.js.map +0 -1
  294. package/dist/esm/hemfixarna-superfront.entry.js.map +0 -1
  295. package/dist/esm/hemfixarna-tesla.entry.js.map +0 -1
  296. package/dist/esm/hemfixarna-traningspartner.entry.js.map +0 -1
  297. package/dist/esm/hemfixarna-zaptec.entry.js.map +0 -1
  298. package/dist/esm/index-ea1d222e.js +0 -1710
  299. package/dist/esm/index-ea1d222e.js.map +0 -1
  300. package/dist/esm/index.js +0 -3
  301. package/dist/esm/index.js.map +0 -1
  302. package/dist/esm/loader.js +0 -20
  303. package/dist/esm/loader.js.map +0 -1
  304. package/dist/esm/polyfills/core-js.js +0 -11
  305. package/dist/esm/polyfills/css-shim.js +0 -1
  306. package/dist/esm/polyfills/dom.js +0 -79
  307. package/dist/esm/polyfills/es5-html-element.js +0 -1
  308. package/dist/esm/polyfills/index.js +0 -34
  309. package/dist/esm/polyfills/system.js +0 -6
  310. package/dist/hemfixarna-components/p-0106398c.entry.js +0 -2
  311. package/dist/hemfixarna-components/p-0106398c.entry.js.map +0 -1
  312. package/dist/hemfixarna-components/p-2171ef72.entry.js +0 -2
  313. package/dist/hemfixarna-components/p-2171ef72.entry.js.map +0 -1
  314. package/dist/hemfixarna-components/p-21f904c4.entry.js +0 -2
  315. package/dist/hemfixarna-components/p-21f904c4.entry.js.map +0 -1
  316. package/dist/hemfixarna-components/p-30539ae5.entry.js +0 -2
  317. package/dist/hemfixarna-components/p-30539ae5.entry.js.map +0 -1
  318. package/dist/hemfixarna-components/p-3064ec85.entry.js +0 -2
  319. package/dist/hemfixarna-components/p-3064ec85.entry.js.map +0 -1
  320. package/dist/hemfixarna-components/p-31254a9b.entry.js +0 -2
  321. package/dist/hemfixarna-components/p-31254a9b.entry.js.map +0 -1
  322. package/dist/hemfixarna-components/p-5cc10f3e.js +0 -2
  323. package/dist/hemfixarna-components/p-5cc10f3e.js.map +0 -1
  324. package/dist/hemfixarna-components/p-5f8e1f23.entry.js +0 -2
  325. package/dist/hemfixarna-components/p-5f8e1f23.entry.js.map +0 -1
  326. package/dist/hemfixarna-components/p-62fdb014.entry.js +0 -2
  327. package/dist/hemfixarna-components/p-62fdb014.entry.js.map +0 -1
  328. package/dist/hemfixarna-components/p-642db21e.js +0 -2
  329. package/dist/hemfixarna-components/p-642db21e.js.map +0 -1
  330. package/dist/hemfixarna-components/p-695b4ab5.entry.js +0 -2
  331. package/dist/hemfixarna-components/p-695b4ab5.entry.js.map +0 -1
  332. package/dist/hemfixarna-components/p-6f9913cb.entry.js +0 -2
  333. package/dist/hemfixarna-components/p-6f9913cb.entry.js.map +0 -1
  334. package/dist/hemfixarna-components/p-80044bef.entry.js +0 -2
  335. package/dist/hemfixarna-components/p-80044bef.entry.js.map +0 -1
  336. package/dist/hemfixarna-components/p-9defa3dc.entry.js +0 -2
  337. package/dist/hemfixarna-components/p-9defa3dc.entry.js.map +0 -1
  338. package/dist/hemfixarna-components/p-a66f910f.entry.js +0 -2
  339. package/dist/hemfixarna-components/p-a66f910f.entry.js.map +0 -1
  340. package/dist/hemfixarna-components/p-b904e94f.entry.js +0 -2
  341. package/dist/hemfixarna-components/p-b904e94f.entry.js.map +0 -1
  342. package/dist/hemfixarna-components/p-c707b937.js +0 -3
  343. package/dist/hemfixarna-components/p-c707b937.js.map +0 -1
  344. package/dist/hemfixarna-components/p-cc0920f6.entry.js +0 -2
  345. package/dist/hemfixarna-components/p-cc0920f6.entry.js.map +0 -1
  346. package/dist/hemfixarna-components/p-d2135574.entry.js +0 -2
  347. package/dist/hemfixarna-components/p-d2135574.entry.js.map +0 -1
  348. package/dist/hemfixarna-components/p-d31b9a6e.entry.js +0 -2
  349. package/dist/hemfixarna-components/p-d31b9a6e.entry.js.map +0 -1
  350. package/dist/hemfixarna-components/p-d452b6c8.entry.js +0 -2
  351. package/dist/hemfixarna-components/p-d452b6c8.entry.js.map +0 -1
  352. package/dist/hemfixarna-components/p-d522ece7.entry.js +0 -2
  353. package/dist/hemfixarna-components/p-d522ece7.entry.js.map +0 -1
  354. package/dist/hemfixarna-components/p-dcf4f921.entry.js +0 -2
  355. package/dist/hemfixarna-components/p-dcf4f921.entry.js.map +0 -1
  356. package/dist/hemfixarna-components/p-e2cd711c.entry.js +0 -2
  357. package/dist/hemfixarna-components/p-e2cd711c.entry.js.map +0 -1
  358. package/dist/hemfixarna-components/p-ff1548ae.entry.js +0 -2
  359. package/dist/hemfixarna-components/p-ff1548ae.entry.js.map +0 -1
  360. package/dist/index.cjs.js +0 -1
  361. package/dist/index.js +0 -1
  362. /package/dist/{esm → hemfixarna-components}/index-c8ce6f4b.js +0 -0
  363. /package/dist/{esm → hemfixarna-components}/index-c8ce6f4b.js.map +0 -0
@@ -0,0 +1,3461 @@
1
+ const NAMESPACE = 'hemfixarna-components';
2
+ const BUILD = /* hemfixarna-components */ { allRenderFn: false, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: false, cssAnnotations: true, cssVarShim: false, devTools: true, disconnectedCallback: true, dynamicImportShim: false, element: false, event: false, hasRenderFn: true, hostListener: true, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: true, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute: true, profile: true, prop: true, propBoolean: true, propMutable: false, propNumber: false, propString: true, reflect: false, safari10: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: false, slotChildNodesFix: false, slotRelocation: false, state: true, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: false, watchCallback: true };
3
+ const Env = /* hemfixarna-components */ {};
4
+
5
+ /**
6
+ * Virtual DOM patching algorithm based on Snabbdom by
7
+ * Simon Friis Vindum (@paldepind)
8
+ * Licensed under the MIT License
9
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
10
+ *
11
+ * Modified for Stencil's renderer and slot projection
12
+ */
13
+ let scopeId;
14
+ let contentRef;
15
+ let hostTagName;
16
+ let customError;
17
+ let i = 0;
18
+ let useNativeShadowDom = false;
19
+ let checkSlotFallbackVisibility = false;
20
+ let checkSlotRelocate = false;
21
+ let isSvgMode = false;
22
+ let renderingRef = null;
23
+ let queueCongestion = 0;
24
+ let queuePending = false;
25
+ const Build = {
26
+ isDev: BUILD.isDev ? true : false,
27
+ isBrowser: true,
28
+ isServer: false,
29
+ isTesting: BUILD.isTesting ? true : false,
30
+ };
31
+ const Context = {};
32
+ const getAssetPath = (path) => {
33
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
34
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
35
+ };
36
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
37
+ const createTime = (fnName, tagName = '') => {
38
+ if (BUILD.profile && performance.mark) {
39
+ const key = `st:${fnName}:${tagName}:${i++}`;
40
+ // Start
41
+ performance.mark(key);
42
+ // End
43
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
44
+ }
45
+ else {
46
+ return () => {
47
+ return;
48
+ };
49
+ }
50
+ };
51
+ const uniqueTime = (key, measureText) => {
52
+ if (BUILD.profile && performance.mark) {
53
+ if (performance.getEntriesByName(key, 'mark').length === 0) {
54
+ performance.mark(key);
55
+ }
56
+ return () => {
57
+ if (performance.getEntriesByName(measureText, 'measure').length === 0) {
58
+ performance.measure(measureText, key);
59
+ }
60
+ };
61
+ }
62
+ else {
63
+ return () => {
64
+ return;
65
+ };
66
+ }
67
+ };
68
+ const inspect = (ref) => {
69
+ const hostRef = getHostRef(ref);
70
+ if (!hostRef) {
71
+ return undefined;
72
+ }
73
+ const flags = hostRef.$flags$;
74
+ const hostElement = hostRef.$hostElement$;
75
+ return {
76
+ renderCount: hostRef.$renderCount$,
77
+ flags: {
78
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
79
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
80
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
81
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
82
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
83
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
84
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
85
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
86
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
87
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
88
+ },
89
+ instanceValues: hostRef.$instanceValues$,
90
+ ancestorComponent: hostRef.$ancestorComponent$,
91
+ hostElement,
92
+ lazyInstance: hostRef.$lazyInstance$,
93
+ vnode: hostRef.$vnode$,
94
+ modeName: hostRef.$modeName$,
95
+ onReadyPromise: hostRef.$onReadyPromise$,
96
+ onReadyResolve: hostRef.$onReadyResolve$,
97
+ onInstancePromise: hostRef.$onInstancePromise$,
98
+ onInstanceResolve: hostRef.$onInstanceResolve$,
99
+ onRenderResolve: hostRef.$onRenderResolve$,
100
+ queuedListeners: hostRef.$queuedListeners$,
101
+ rmListeners: hostRef.$rmListeners$,
102
+ ['s-id']: hostElement['s-id'],
103
+ ['s-cr']: hostElement['s-cr'],
104
+ ['s-lr']: hostElement['s-lr'],
105
+ ['s-p']: hostElement['s-p'],
106
+ ['s-rc']: hostElement['s-rc'],
107
+ ['s-sc']: hostElement['s-sc'],
108
+ };
109
+ };
110
+ const installDevTools = () => {
111
+ if (BUILD.devTools) {
112
+ const stencil = (win.stencil = win.stencil || {});
113
+ const originalInspect = stencil.inspect;
114
+ stencil.inspect = (ref) => {
115
+ let result = inspect(ref);
116
+ if (!result && typeof originalInspect === 'function') {
117
+ result = originalInspect(ref);
118
+ }
119
+ return result;
120
+ };
121
+ }
122
+ };
123
+ const CONTENT_REF_ID = 'r';
124
+ const ORG_LOCATION_ID = 'o';
125
+ const SLOT_NODE_ID = 's';
126
+ const TEXT_NODE_ID = 't';
127
+ const HYDRATE_ID = 's-id';
128
+ const HYDRATED_STYLE_ID = 'sty-id';
129
+ const HYDRATE_CHILD_ID = 'c-id';
130
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
131
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
132
+ /**
133
+ * Default style mode id
134
+ */
135
+ /**
136
+ * Reusable empty obj/array
137
+ * Don't add values to these!!
138
+ */
139
+ const EMPTY_OBJ = {};
140
+ /**
141
+ * Namespaces
142
+ */
143
+ const SVG_NS = 'http://www.w3.org/2000/svg';
144
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
145
+ const isDef = (v) => v != null;
146
+ /**
147
+ * Check whether a value is a 'complex type', defined here as an object or a
148
+ * function.
149
+ *
150
+ * @param o the value to check
151
+ * @returns whether it's a complex type or not
152
+ */
153
+ const isComplexType = (o) => {
154
+ // https://jsperf.com/typeof-fn-object/5
155
+ o = typeof o;
156
+ return o === 'object' || o === 'function';
157
+ };
158
+ /**
159
+ * Helper method for querying a `meta` tag that contains a nonce value
160
+ * out of a DOM's head.
161
+ *
162
+ * @param doc The DOM containing the `head` to query against
163
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
164
+ * exists or the tag has no content.
165
+ */
166
+ function queryNonceMetaTagContent(doc) {
167
+ var _a, _b, _c;
168
+ 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;
169
+ }
170
+ /**
171
+ * Production h() function based on Preact by
172
+ * Jason Miller (@developit)
173
+ * Licensed under the MIT License
174
+ * https://github.com/developit/preact/blob/master/LICENSE
175
+ *
176
+ * Modified for Stencil's compiler and vdom
177
+ */
178
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
179
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
180
+ const h = (nodeName, vnodeData, ...children) => {
181
+ let child = null;
182
+ let key = null;
183
+ let slotName = null;
184
+ let simple = false;
185
+ let lastSimple = false;
186
+ const vNodeChildren = [];
187
+ const walk = (c) => {
188
+ for (let i = 0; i < c.length; i++) {
189
+ child = c[i];
190
+ if (Array.isArray(child)) {
191
+ walk(child);
192
+ }
193
+ else if (child != null && typeof child !== 'boolean') {
194
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
195
+ child = String(child);
196
+ }
197
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
198
+ consoleDevError(`vNode passed as children has unexpected type.
199
+ Make sure it's using the correct h() function.
200
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
201
+ }
202
+ if (simple && lastSimple) {
203
+ // If the previous child was simple (string), we merge both
204
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
205
+ }
206
+ else {
207
+ // Append a new vNode, if it's text, we create a text vNode
208
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
209
+ }
210
+ lastSimple = simple;
211
+ }
212
+ }
213
+ };
214
+ walk(children);
215
+ if (vnodeData) {
216
+ if (BUILD.isDev && nodeName === 'input') {
217
+ validateInputProperties(vnodeData);
218
+ }
219
+ // normalize class / classname attributes
220
+ if (BUILD.vdomKey && vnodeData.key) {
221
+ key = vnodeData.key;
222
+ }
223
+ if (BUILD.slotRelocation && vnodeData.name) {
224
+ slotName = vnodeData.name;
225
+ }
226
+ if (BUILD.vdomClass) {
227
+ const classData = vnodeData.className || vnodeData.class;
228
+ if (classData) {
229
+ vnodeData.class =
230
+ typeof classData !== 'object'
231
+ ? classData
232
+ : Object.keys(classData)
233
+ .filter((k) => classData[k])
234
+ .join(' ');
235
+ }
236
+ }
237
+ }
238
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
239
+ consoleDevError(`The <Host> must be the single root component. Make sure:
240
+ - You are NOT using hostData() and <Host> in the same component.
241
+ - <Host> is used once, and it's the single root component of the render() function.`);
242
+ }
243
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
244
+ // nodeName is a functional component
245
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
246
+ }
247
+ const vnode = newVNode(nodeName, null);
248
+ vnode.$attrs$ = vnodeData;
249
+ if (vNodeChildren.length > 0) {
250
+ vnode.$children$ = vNodeChildren;
251
+ }
252
+ if (BUILD.vdomKey) {
253
+ vnode.$key$ = key;
254
+ }
255
+ if (BUILD.slotRelocation) {
256
+ vnode.$name$ = slotName;
257
+ }
258
+ return vnode;
259
+ };
260
+ /**
261
+ * A utility function for creating a virtual DOM node from a tag and some
262
+ * possible text content.
263
+ *
264
+ * @param tag the tag for this element
265
+ * @param text possible text content for the node
266
+ * @returns a newly-minted virtual DOM node
267
+ */
268
+ const newVNode = (tag, text) => {
269
+ const vnode = {
270
+ $flags$: 0,
271
+ $tag$: tag,
272
+ $text$: text,
273
+ $elm$: null,
274
+ $children$: null,
275
+ };
276
+ if (BUILD.vdomAttribute) {
277
+ vnode.$attrs$ = null;
278
+ }
279
+ if (BUILD.vdomKey) {
280
+ vnode.$key$ = null;
281
+ }
282
+ if (BUILD.slotRelocation) {
283
+ vnode.$name$ = null;
284
+ }
285
+ return vnode;
286
+ };
287
+ const Host = {};
288
+ /**
289
+ * Check whether a given node is a Host node or not
290
+ *
291
+ * @param node the virtual DOM node to check
292
+ * @returns whether it's a Host node or not
293
+ */
294
+ const isHost = (node) => node && node.$tag$ === Host;
295
+ /**
296
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
297
+ *
298
+ * Note that these functions convert from {@link d.VNode} to
299
+ * {@link d.ChildNode} to give functional component developers a friendly
300
+ * interface.
301
+ */
302
+ const vdomFnUtils = {
303
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
304
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
305
+ };
306
+ /**
307
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
308
+ * friendlier public interface (hence, 'convertToPublic').
309
+ *
310
+ * @param node the virtual DOM node to convert
311
+ * @returns a converted child node
312
+ */
313
+ const convertToPublic = (node) => ({
314
+ vattrs: node.$attrs$,
315
+ vchildren: node.$children$,
316
+ vkey: node.$key$,
317
+ vname: node.$name$,
318
+ vtag: node.$tag$,
319
+ vtext: node.$text$,
320
+ });
321
+ /**
322
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
323
+ * order to use the resulting object in the virtual DOM. The initial object was
324
+ * likely created as part of presenting a public API, so converting it back
325
+ * involved making it 'private' again (hence, `convertToPrivate`).
326
+ *
327
+ * @param node the child node to convert
328
+ * @returns a converted virtual DOM node
329
+ */
330
+ const convertToPrivate = (node) => {
331
+ if (typeof node.vtag === 'function') {
332
+ const vnodeData = Object.assign({}, node.vattrs);
333
+ if (node.vkey) {
334
+ vnodeData.key = node.vkey;
335
+ }
336
+ if (node.vname) {
337
+ vnodeData.name = node.vname;
338
+ }
339
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
340
+ }
341
+ const vnode = newVNode(node.vtag, node.vtext);
342
+ vnode.$attrs$ = node.vattrs;
343
+ vnode.$children$ = node.vchildren;
344
+ vnode.$key$ = node.vkey;
345
+ vnode.$name$ = node.vname;
346
+ return vnode;
347
+ };
348
+ /**
349
+ * Validates the ordering of attributes on an input element
350
+ *
351
+ * @param inputElm the element to validate
352
+ */
353
+ const validateInputProperties = (inputElm) => {
354
+ const props = Object.keys(inputElm);
355
+ const value = props.indexOf('value');
356
+ if (value === -1) {
357
+ return;
358
+ }
359
+ const typeIndex = props.indexOf('type');
360
+ const minIndex = props.indexOf('min');
361
+ const maxIndex = props.indexOf('max');
362
+ const stepIndex = props.indexOf('step');
363
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
364
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
365
+ }
366
+ };
367
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
368
+ const endHydrate = createTime('hydrateClient', tagName);
369
+ const shadowRoot = hostElm.shadowRoot;
370
+ const childRenderNodes = [];
371
+ const slotNodes = [];
372
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
373
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
374
+ if (!plt.$orgLocNodes$) {
375
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
376
+ }
377
+ hostElm[HYDRATE_ID] = hostId;
378
+ hostElm.removeAttribute(HYDRATE_ID);
379
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
380
+ childRenderNodes.map((c) => {
381
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
382
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
383
+ const node = c.$elm$;
384
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
385
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
386
+ }
387
+ if (!shadowRoot) {
388
+ node['s-hn'] = tagName;
389
+ if (orgLocationNode) {
390
+ node['s-ol'] = orgLocationNode;
391
+ node['s-ol']['s-nr'] = node;
392
+ }
393
+ }
394
+ plt.$orgLocNodes$.delete(orgLocationId);
395
+ });
396
+ if (BUILD.shadowDom && shadowRoot) {
397
+ shadowRootNodes.map((shadowRootNode) => {
398
+ if (shadowRootNode) {
399
+ shadowRoot.appendChild(shadowRootNode);
400
+ }
401
+ });
402
+ }
403
+ endHydrate();
404
+ };
405
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
406
+ let childNodeType;
407
+ let childIdSplt;
408
+ let childVNode;
409
+ let i;
410
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
411
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
412
+ if (childNodeType) {
413
+ // got the node data from the element's attribute
414
+ // `${hostId}.${nodeId}.${depth}.${index}`
415
+ childIdSplt = childNodeType.split('.');
416
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
417
+ childVNode = {
418
+ $flags$: 0,
419
+ $hostId$: childIdSplt[0],
420
+ $nodeId$: childIdSplt[1],
421
+ $depth$: childIdSplt[2],
422
+ $index$: childIdSplt[3],
423
+ $tag$: node.tagName.toLowerCase(),
424
+ $elm$: node,
425
+ $attrs$: null,
426
+ $children$: null,
427
+ $key$: null,
428
+ $name$: null,
429
+ $text$: null,
430
+ };
431
+ childRenderNodes.push(childVNode);
432
+ node.removeAttribute(HYDRATE_CHILD_ID);
433
+ // this is a new child vnode
434
+ // so ensure its parent vnode has the vchildren array
435
+ if (!parentVNode.$children$) {
436
+ parentVNode.$children$ = [];
437
+ }
438
+ // add our child vnode to a specific index of the vnode's children
439
+ parentVNode.$children$[childVNode.$index$] = childVNode;
440
+ // this is now the new parent vnode for all the next child checks
441
+ parentVNode = childVNode;
442
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
443
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
444
+ }
445
+ }
446
+ }
447
+ // recursively drill down, end to start so we can remove nodes
448
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
449
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
450
+ }
451
+ if (node.shadowRoot) {
452
+ // keep drilling down through the shadow root nodes
453
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
454
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
455
+ }
456
+ }
457
+ }
458
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
459
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
460
+ childIdSplt = node.nodeValue.split('.');
461
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
462
+ // comment node for either the host id or a 0 host id
463
+ childNodeType = childIdSplt[0];
464
+ childVNode = {
465
+ $flags$: 0,
466
+ $hostId$: childIdSplt[1],
467
+ $nodeId$: childIdSplt[2],
468
+ $depth$: childIdSplt[3],
469
+ $index$: childIdSplt[4],
470
+ $elm$: node,
471
+ $attrs$: null,
472
+ $children$: null,
473
+ $key$: null,
474
+ $name$: null,
475
+ $tag$: null,
476
+ $text$: null,
477
+ };
478
+ if (childNodeType === TEXT_NODE_ID) {
479
+ childVNode.$elm$ = node.nextSibling;
480
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
481
+ childVNode.$text$ = childVNode.$elm$.textContent;
482
+ childRenderNodes.push(childVNode);
483
+ // remove the text comment since it's no longer needed
484
+ node.remove();
485
+ if (!parentVNode.$children$) {
486
+ parentVNode.$children$ = [];
487
+ }
488
+ parentVNode.$children$[childVNode.$index$] = childVNode;
489
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
490
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
491
+ }
492
+ }
493
+ }
494
+ else if (childVNode.$hostId$ === hostId) {
495
+ // this comment node is specifcally for this host id
496
+ if (childNodeType === SLOT_NODE_ID) {
497
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
498
+ childVNode.$tag$ = 'slot';
499
+ if (childIdSplt[5]) {
500
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
501
+ }
502
+ else {
503
+ node['s-sn'] = '';
504
+ }
505
+ node['s-sr'] = true;
506
+ if (BUILD.shadowDom && shadowRootNodes) {
507
+ // browser support shadowRoot and this is a shadow dom component
508
+ // create an actual slot element
509
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
510
+ if (childVNode.$name$) {
511
+ // add the slot name attribute
512
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
513
+ }
514
+ // insert the new slot element before the slot comment
515
+ node.parentNode.insertBefore(childVNode.$elm$, node);
516
+ // remove the slot comment since it's not needed for shadow
517
+ node.remove();
518
+ if (childVNode.$depth$ === '0') {
519
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
520
+ }
521
+ }
522
+ slotNodes.push(childVNode);
523
+ if (!parentVNode.$children$) {
524
+ parentVNode.$children$ = [];
525
+ }
526
+ parentVNode.$children$[childVNode.$index$] = childVNode;
527
+ }
528
+ else if (childNodeType === CONTENT_REF_ID) {
529
+ // `${CONTENT_REF_ID}.${hostId}`;
530
+ if (BUILD.shadowDom && shadowRootNodes) {
531
+ // remove the content ref comment since it's not needed for shadow
532
+ node.remove();
533
+ }
534
+ else if (BUILD.slotRelocation) {
535
+ hostElm['s-cr'] = node;
536
+ node['s-cn'] = true;
537
+ }
538
+ }
539
+ }
540
+ }
541
+ }
542
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
543
+ const vnode = newVNode(null, node.textContent);
544
+ vnode.$elm$ = node;
545
+ vnode.$index$ = '0';
546
+ parentVNode.$children$ = [vnode];
547
+ }
548
+ };
549
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
550
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
551
+ let i = 0;
552
+ for (; i < node.childNodes.length; i++) {
553
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
554
+ }
555
+ if (node.shadowRoot) {
556
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
557
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
558
+ }
559
+ }
560
+ }
561
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
562
+ const childIdSplt = node.nodeValue.split('.');
563
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
564
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
565
+ node.nodeValue = '';
566
+ // useful to know if the original location is
567
+ // the root light-dom of a shadow dom component
568
+ node['s-en'] = childIdSplt[3];
569
+ }
570
+ }
571
+ };
572
+ // Private
573
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
574
+ // Public
575
+ const setMode = (handler) => modeResolutionChain.push(handler);
576
+ const getMode = (ref) => getHostRef(ref).$modeName$;
577
+ /**
578
+ * Parse a new property value for a given property type.
579
+ *
580
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
581
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
582
+ * 1. `any`, the type given to `propValue` in the function signature
583
+ * 2. the type stored from `propType`.
584
+ *
585
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
586
+ *
587
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
588
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
589
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
590
+ * ```tsx
591
+ * <my-cmp prop-val={0}></my-cmp>
592
+ * ```
593
+ *
594
+ * HTML prop values on the other hand, will always a string
595
+ *
596
+ * @param propValue the new value to coerce to some type
597
+ * @param propType the type of the prop, expressed as a binary number
598
+ * @returns the parsed/coerced value
599
+ */
600
+ const parsePropertyValue = (propValue, propType) => {
601
+ // ensure this value is of the correct prop type
602
+ if (propValue != null && !isComplexType(propValue)) {
603
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
604
+ // per the HTML spec, any string value means it is a boolean true value
605
+ // but we'll cheat here and say that the string "false" is the boolean false
606
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
607
+ }
608
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
609
+ // force it to be a number
610
+ return parseFloat(propValue);
611
+ }
612
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
613
+ // could have been passed as a number or boolean
614
+ // but we still want it as a string
615
+ return String(propValue);
616
+ }
617
+ // redundant return here for better minification
618
+ return propValue;
619
+ }
620
+ // not sure exactly what type we want
621
+ // so no need to change to a different type
622
+ return propValue;
623
+ };
624
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
625
+ const createEvent = (ref, name, flags) => {
626
+ const elm = getElement(ref);
627
+ return {
628
+ emit: (detail) => {
629
+ if (BUILD.isDev && !elm.isConnected) {
630
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
631
+ }
632
+ return emitEvent(elm, name, {
633
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
634
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
635
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
636
+ detail,
637
+ });
638
+ },
639
+ };
640
+ };
641
+ /**
642
+ * Helper function to create & dispatch a custom Event on a provided target
643
+ * @param elm the target of the Event
644
+ * @param name the name to give the custom Event
645
+ * @param opts options for configuring a custom Event
646
+ * @returns the custom Event
647
+ */
648
+ const emitEvent = (elm, name, opts) => {
649
+ const ev = plt.ce(name, opts);
650
+ elm.dispatchEvent(ev);
651
+ return ev;
652
+ };
653
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
654
+ const registerStyle = (scopeId, cssText, allowCS) => {
655
+ let style = styles.get(scopeId);
656
+ if (supportsConstructableStylesheets && allowCS) {
657
+ style = (style || new CSSStyleSheet());
658
+ if (typeof style === 'string') {
659
+ style = cssText;
660
+ }
661
+ else {
662
+ style.replaceSync(cssText);
663
+ }
664
+ }
665
+ else {
666
+ style = cssText;
667
+ }
668
+ styles.set(scopeId, style);
669
+ };
670
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
671
+ var _a;
672
+ let scopeId = getScopeId(cmpMeta, mode);
673
+ const style = styles.get(scopeId);
674
+ if (!BUILD.attachStyles) {
675
+ return scopeId;
676
+ }
677
+ // if an element is NOT connected then getRootNode() will return the wrong root node
678
+ // so the fallback is to always use the document for the root node in those cases
679
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
680
+ if (style) {
681
+ if (typeof style === 'string') {
682
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
683
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
684
+ let styleElm;
685
+ if (!appliedStyles) {
686
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
687
+ }
688
+ if (!appliedStyles.has(scopeId)) {
689
+ if (BUILD.hydrateClientSide &&
690
+ styleContainerNode.host &&
691
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
692
+ // This is only happening on native shadow-dom, do not needs CSS var shim
693
+ styleElm.innerHTML = style;
694
+ }
695
+ else {
696
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
697
+ if (BUILD.cssVarShim && plt.$cssShim$) {
698
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
699
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style,
700
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
701
+ !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
702
+ const newScopeId = styleElm['s-sc'];
703
+ if (newScopeId) {
704
+ scopeId = newScopeId;
705
+ // we don't want to add this styleID to the appliedStyles Set
706
+ // since the cssVarShim might need to apply several different
707
+ // stylesheets for the same component
708
+ appliedStyles = null;
709
+ }
710
+ }
711
+ else {
712
+ styleElm = doc.createElement('style');
713
+ styleElm.innerHTML = style;
714
+ }
715
+ // Apply CSP nonce to the style tag if it exists
716
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
717
+ if (nonce != null) {
718
+ styleElm.setAttribute('nonce', nonce);
719
+ }
720
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
721
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
722
+ }
723
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
724
+ }
725
+ if (appliedStyles) {
726
+ appliedStyles.add(scopeId);
727
+ }
728
+ }
729
+ }
730
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
731
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
732
+ }
733
+ }
734
+ return scopeId;
735
+ };
736
+ const attachStyles = (hostRef) => {
737
+ const cmpMeta = hostRef.$cmpMeta$;
738
+ const elm = hostRef.$hostElement$;
739
+ const flags = cmpMeta.$flags$;
740
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
741
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
742
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
743
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
744
+ // only required when we're NOT using native shadow dom (slot)
745
+ // or this browser doesn't support native shadow dom
746
+ // and this host element was NOT created with SSR
747
+ // let's pick out the inner content for slot projection
748
+ // create a node to represent where the original
749
+ // content was first placed, which is useful later on
750
+ // DOM WRITE!!
751
+ elm['s-sc'] = scopeId;
752
+ elm.classList.add(scopeId + '-h');
753
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
754
+ elm.classList.add(scopeId + '-s');
755
+ }
756
+ }
757
+ endAttachStyles();
758
+ };
759
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
760
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
761
+ /**
762
+ * Production setAccessor() function based on Preact by
763
+ * Jason Miller (@developit)
764
+ * Licensed under the MIT License
765
+ * https://github.com/developit/preact/blob/master/LICENSE
766
+ *
767
+ * Modified for Stencil's compiler and vdom
768
+ */
769
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
770
+ if (oldValue !== newValue) {
771
+ let isProp = isMemberInElement(elm, memberName);
772
+ let ln = memberName.toLowerCase();
773
+ if (BUILD.vdomClass && memberName === 'class') {
774
+ const classList = elm.classList;
775
+ const oldClasses = parseClassList(oldValue);
776
+ const newClasses = parseClassList(newValue);
777
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
778
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
779
+ }
780
+ else if (BUILD.vdomStyle && memberName === 'style') {
781
+ // update style attribute, css properties and values
782
+ if (BUILD.updatable) {
783
+ for (const prop in oldValue) {
784
+ if (!newValue || newValue[prop] == null) {
785
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
786
+ elm.style.removeProperty(prop);
787
+ }
788
+ else {
789
+ elm.style[prop] = '';
790
+ }
791
+ }
792
+ }
793
+ }
794
+ for (const prop in newValue) {
795
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
796
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
797
+ elm.style.setProperty(prop, newValue[prop]);
798
+ }
799
+ else {
800
+ elm.style[prop] = newValue[prop];
801
+ }
802
+ }
803
+ }
804
+ }
805
+ else if (BUILD.vdomKey && memberName === 'key')
806
+ ;
807
+ else if (BUILD.vdomRef && memberName === 'ref') {
808
+ // minifier will clean this up
809
+ if (newValue) {
810
+ newValue(elm);
811
+ }
812
+ }
813
+ else if (BUILD.vdomListener &&
814
+ (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
815
+ memberName[0] === 'o' &&
816
+ memberName[1] === 'n') {
817
+ // Event Handlers
818
+ // so if the member name starts with "on" and the 3rd characters is
819
+ // a capital letter, and it's not already a member on the element,
820
+ // then we're assuming it's an event listener
821
+ if (memberName[2] === '-') {
822
+ // on- prefixed events
823
+ // allows to be explicit about the dom event to listen without any magic
824
+ // under the hood:
825
+ // <my-cmp on-click> // listens for "click"
826
+ // <my-cmp on-Click> // listens for "Click"
827
+ // <my-cmp on-ionChange> // listens for "ionChange"
828
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
829
+ memberName = memberName.slice(3);
830
+ }
831
+ else if (isMemberInElement(win, ln)) {
832
+ // standard event
833
+ // the JSX attribute could have been "onMouseOver" and the
834
+ // member name "onmouseover" is on the window's prototype
835
+ // so let's add the listener "mouseover", which is all lowercased
836
+ memberName = ln.slice(2);
837
+ }
838
+ else {
839
+ // custom event
840
+ // the JSX attribute could have been "onMyCustomEvent"
841
+ // so let's trim off the "on" prefix and lowercase the first character
842
+ // and add the listener "myCustomEvent"
843
+ // except for the first character, we keep the event name case
844
+ memberName = ln[2] + memberName.slice(3);
845
+ }
846
+ if (oldValue) {
847
+ plt.rel(elm, memberName, oldValue, false);
848
+ }
849
+ if (newValue) {
850
+ plt.ael(elm, memberName, newValue, false);
851
+ }
852
+ }
853
+ else if (BUILD.vdomPropOrAttr) {
854
+ // Set property if it exists and it's not a SVG
855
+ const isComplex = isComplexType(newValue);
856
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
857
+ try {
858
+ if (!elm.tagName.includes('-')) {
859
+ const n = newValue == null ? '' : newValue;
860
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
861
+ if (memberName === 'list') {
862
+ isProp = false;
863
+ }
864
+ else if (oldValue == null || elm[memberName] != n) {
865
+ elm[memberName] = n;
866
+ }
867
+ }
868
+ else {
869
+ elm[memberName] = newValue;
870
+ }
871
+ }
872
+ catch (e) { }
873
+ }
874
+ /**
875
+ * Need to manually update attribute if:
876
+ * - memberName is not an attribute
877
+ * - if we are rendering the host element in order to reflect attribute
878
+ * - if it's a SVG, since properties might not work in <svg>
879
+ * - if the newValue is null/undefined or 'false'.
880
+ */
881
+ let xlink = false;
882
+ if (BUILD.vdomXlink) {
883
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
884
+ memberName = ln;
885
+ xlink = true;
886
+ }
887
+ }
888
+ if (newValue == null || newValue === false) {
889
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
890
+ if (BUILD.vdomXlink && xlink) {
891
+ elm.removeAttributeNS(XLINK_NS, memberName);
892
+ }
893
+ else {
894
+ elm.removeAttribute(memberName);
895
+ }
896
+ }
897
+ }
898
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
899
+ newValue = newValue === true ? '' : newValue;
900
+ if (BUILD.vdomXlink && xlink) {
901
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
902
+ }
903
+ else {
904
+ elm.setAttribute(memberName, newValue);
905
+ }
906
+ }
907
+ }
908
+ }
909
+ };
910
+ const parseClassListRegex = /\s/;
911
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
912
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
913
+ // if the element passed in is a shadow root, which is a document fragment
914
+ // then we want to be adding attrs/props to the shadow root's "host" element
915
+ // if it's not a shadow root, then we add attrs/props to the same element
916
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
917
+ ? newVnode.$elm$.host
918
+ : newVnode.$elm$;
919
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
920
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
921
+ if (BUILD.updatable) {
922
+ // remove attributes no longer present on the vnode by setting them to undefined
923
+ for (memberName in oldVnodeAttrs) {
924
+ if (!(memberName in newVnodeAttrs)) {
925
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
926
+ }
927
+ }
928
+ }
929
+ // add new & update changed attributes
930
+ for (memberName in newVnodeAttrs) {
931
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
932
+ }
933
+ };
934
+ /**
935
+ * Create a DOM Node corresponding to one of the children of a given VNode.
936
+ *
937
+ * @param oldParentVNode the parent VNode from the previous render
938
+ * @param newParentVNode the parent VNode from the current render
939
+ * @param childIndex the index of the VNode, in the _new_ parent node's
940
+ * children, for which we will create a new DOM node
941
+ * @param parentElm the parent DOM node which our new node will be a child of
942
+ * @returns the newly created node
943
+ */
944
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
945
+ // tslint:disable-next-line: prefer-const
946
+ const newVNode = newParentVNode.$children$[childIndex];
947
+ let i = 0;
948
+ let elm;
949
+ let childNode;
950
+ let oldVNode;
951
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
952
+ // remember for later we need to check to relocate nodes
953
+ checkSlotRelocate = true;
954
+ if (newVNode.$tag$ === 'slot') {
955
+ if (scopeId) {
956
+ // scoped css needs to add its scoped id to the parent element
957
+ parentElm.classList.add(scopeId + '-s');
958
+ }
959
+ newVNode.$flags$ |= newVNode.$children$
960
+ ? // slot element has fallback content
961
+ 2 /* VNODE_FLAGS.isSlotFallback */
962
+ : // slot element does not have fallback content
963
+ 1 /* VNODE_FLAGS.isSlotReference */;
964
+ }
965
+ }
966
+ if (BUILD.isDev && newVNode.$elm$) {
967
+ consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
968
+ }
969
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
970
+ // create text node
971
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
972
+ }
973
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
974
+ // create a slot reference node
975
+ elm = newVNode.$elm$ =
976
+ BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
977
+ }
978
+ else {
979
+ if (BUILD.svg && !isSvgMode) {
980
+ isSvgMode = newVNode.$tag$ === 'svg';
981
+ }
982
+ // create element
983
+ elm = newVNode.$elm$ = (BUILD.svg
984
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
985
+ ? 'slot-fb'
986
+ : newVNode.$tag$)
987
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
988
+ ? 'slot-fb'
989
+ : newVNode.$tag$));
990
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
991
+ isSvgMode = false;
992
+ }
993
+ // add css classes, attrs, props, listeners, etc.
994
+ if (BUILD.vdomAttribute) {
995
+ updateElement(null, newVNode, isSvgMode);
996
+ }
997
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
998
+ // if there is a scopeId and this is the initial render
999
+ // then let's add the scopeId as a css class
1000
+ elm.classList.add((elm['s-si'] = scopeId));
1001
+ }
1002
+ if (newVNode.$children$) {
1003
+ for (i = 0; i < newVNode.$children$.length; ++i) {
1004
+ // create the node
1005
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
1006
+ // return node could have been null
1007
+ if (childNode) {
1008
+ // append our new node
1009
+ elm.appendChild(childNode);
1010
+ }
1011
+ }
1012
+ }
1013
+ if (BUILD.svg) {
1014
+ if (newVNode.$tag$ === 'svg') {
1015
+ // Only reset the SVG context when we're exiting <svg> element
1016
+ isSvgMode = false;
1017
+ }
1018
+ else if (elm.tagName === 'foreignObject') {
1019
+ // Reenter SVG context when we're exiting <foreignObject> element
1020
+ isSvgMode = true;
1021
+ }
1022
+ }
1023
+ }
1024
+ if (BUILD.slotRelocation) {
1025
+ elm['s-hn'] = hostTagName;
1026
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
1027
+ // remember the content reference comment
1028
+ elm['s-sr'] = true;
1029
+ // remember the content reference comment
1030
+ elm['s-cr'] = contentRef;
1031
+ // remember the slot name, or empty string for default slot
1032
+ elm['s-sn'] = newVNode.$name$ || '';
1033
+ // check if we've got an old vnode for this slot
1034
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1035
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
1036
+ // we've got an old slot vnode and the wrapper is being replaced
1037
+ // so let's move the old slot content back to it's original location
1038
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
1039
+ }
1040
+ }
1041
+ }
1042
+ return elm;
1043
+ };
1044
+ const putBackInOriginalLocation = (parentElm, recursive) => {
1045
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1046
+ const oldSlotChildNodes = parentElm.childNodes;
1047
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
1048
+ const childNode = oldSlotChildNodes[i];
1049
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
1050
+ // // this child node in the old element is from another component
1051
+ // // remove this node from the old slot's parent
1052
+ // childNode.remove();
1053
+ // and relocate it back to it's original location
1054
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
1055
+ // remove the old original location comment entirely
1056
+ // later on the patch function will know what to do
1057
+ // and move this to the correct spot in need be
1058
+ childNode['s-ol'].remove();
1059
+ childNode['s-ol'] = undefined;
1060
+ checkSlotRelocate = true;
1061
+ }
1062
+ if (recursive) {
1063
+ putBackInOriginalLocation(childNode, recursive);
1064
+ }
1065
+ }
1066
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1067
+ };
1068
+ /**
1069
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
1070
+ * add them to the DOM in the appropriate place.
1071
+ *
1072
+ * @param parentElm the DOM node which should be used as a parent for the new
1073
+ * DOM nodes
1074
+ * @param before a child of the `parentElm` which the new children should be
1075
+ * inserted before (optional)
1076
+ * @param parentVNode the parent virtual DOM node
1077
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
1078
+ * @param startIdx the index in the child virtual DOM nodes at which to start
1079
+ * creating DOM nodes (inclusive)
1080
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
1081
+ * creating DOM nodes (inclusive)
1082
+ */
1083
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1084
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1085
+ let childNode;
1086
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1087
+ containerElm = containerElm.shadowRoot;
1088
+ }
1089
+ for (; startIdx <= endIdx; ++startIdx) {
1090
+ if (vnodes[startIdx]) {
1091
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
1092
+ if (childNode) {
1093
+ vnodes[startIdx].$elm$ = childNode;
1094
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
1095
+ }
1096
+ }
1097
+ }
1098
+ };
1099
+ /**
1100
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
1101
+ * This can be used to, for instance, clean up after a list of children which
1102
+ * should no longer be shown.
1103
+ *
1104
+ * This function also handles some of Stencil's slot relocation logic.
1105
+ *
1106
+ * @param vnodes a list of virtual DOM nodes to remove
1107
+ * @param startIdx the index at which to start removing nodes (inclusive)
1108
+ * @param endIdx the index at which to stop removing nodes (inclusive)
1109
+ */
1110
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
1111
+ for (let index = startIdx; index <= endIdx; ++index) {
1112
+ const vnode = vnodes[index];
1113
+ if (vnode) {
1114
+ const elm = vnode.$elm$;
1115
+ nullifyVNodeRefs(vnode);
1116
+ if (elm) {
1117
+ if (BUILD.slotRelocation) {
1118
+ // we're removing this element
1119
+ // so it's possible we need to show slot fallback content now
1120
+ checkSlotFallbackVisibility = true;
1121
+ if (elm['s-ol']) {
1122
+ // remove the original location comment
1123
+ elm['s-ol'].remove();
1124
+ }
1125
+ else {
1126
+ // it's possible that child nodes of the node
1127
+ // that's being removed are slot nodes
1128
+ putBackInOriginalLocation(elm, true);
1129
+ }
1130
+ }
1131
+ // remove the vnode's element from the dom
1132
+ elm.remove();
1133
+ }
1134
+ }
1135
+ }
1136
+ };
1137
+ /**
1138
+ * Reconcile the children of a new VNode with the children of an old VNode by
1139
+ * traversing the two collections of children, identifying nodes that are
1140
+ * conserved or changed, calling out to `patch` to make any necessary
1141
+ * updates to the DOM, and rearranging DOM nodes as needed.
1142
+ *
1143
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
1144
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1145
+ * 'windows' by storing start and end indices and references to the
1146
+ * corresponding array entries. Initially the two 'windows' are basically equal
1147
+ * to the entire array, but we progressively narrow the windows until there are
1148
+ * no children left to update by doing the following:
1149
+ *
1150
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1151
+ * that if we have an initial array like the following we'll end up dealing
1152
+ * only with a window bounded by the highlighted elements:
1153
+ *
1154
+ * [null, null, VNode1 , ... , VNode2, null, null]
1155
+ * ^^^^^^ ^^^^^^
1156
+ *
1157
+ * 2. Check to see if the elements at the head and tail positions are equal
1158
+ * across the windows. This will basically detect elements which haven't
1159
+ * been added, removed, or changed position, i.e. if you had the following
1160
+ * VNode elements (represented as HTML):
1161
+ *
1162
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
1163
+ * newVNode: `<div><p><span>THERE</span></p></div>`
1164
+ *
1165
+ * Then when comparing the children of the `<div>` tag we check the equality
1166
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
1167
+ * same tag in the same position, we'd be able to avoid completely
1168
+ * re-rendering the subtree under them with a new DOM element and would just
1169
+ * call out to `patch` to handle reconciling their children and so on.
1170
+ *
1171
+ * 3. Check, for both windows, to see if the element at the beginning of the
1172
+ * window corresponds to the element at the end of the other window. This is
1173
+ * a heuristic which will let us identify _some_ situations in which
1174
+ * elements have changed position, for instance it _should_ detect that the
1175
+ * children nodes themselves have not changed but merely moved in the
1176
+ * following example:
1177
+ *
1178
+ * oldVNode: `<div><element-one /><element-two /></div>`
1179
+ * newVNode: `<div><element-two /><element-one /></div>`
1180
+ *
1181
+ * If we find cases like this then we also need to move the concrete DOM
1182
+ * elements corresponding to the moved children to write the re-order to the
1183
+ * DOM.
1184
+ *
1185
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1186
+ * nodes in the old children which have the same key as the first element in
1187
+ * our window on the new children. If we find such a node we handle calling
1188
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1189
+ * what we find.
1190
+ *
1191
+ * Finally, once we've narrowed our 'windows' to the point that either of them
1192
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
1193
+ * insertion or deletion that needs to happen to get a DOM state that correctly
1194
+ * reflects the new child VNodes. If, for instance, after our window on the old
1195
+ * children has collapsed we still have more nodes on the new children that
1196
+ * we haven't dealt with yet then we need to add them, or if the new children
1197
+ * collapse but we still have unhandled _old_ children then we need to make
1198
+ * sure the corresponding DOM nodes are removed.
1199
+ *
1200
+ * @param parentElm the node into which the parent VNode is rendered
1201
+ * @param oldCh the old children of the parent node
1202
+ * @param newVNode the new VNode which will replace the parent
1203
+ * @param newCh the new children of the parent node
1204
+ */
1205
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
1206
+ let oldStartIdx = 0;
1207
+ let newStartIdx = 0;
1208
+ let idxInOld = 0;
1209
+ let i = 0;
1210
+ let oldEndIdx = oldCh.length - 1;
1211
+ let oldStartVnode = oldCh[0];
1212
+ let oldEndVnode = oldCh[oldEndIdx];
1213
+ let newEndIdx = newCh.length - 1;
1214
+ let newStartVnode = newCh[0];
1215
+ let newEndVnode = newCh[newEndIdx];
1216
+ let node;
1217
+ let elmToMove;
1218
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1219
+ if (oldStartVnode == null) {
1220
+ // VNode might have been moved left
1221
+ oldStartVnode = oldCh[++oldStartIdx];
1222
+ }
1223
+ else if (oldEndVnode == null) {
1224
+ oldEndVnode = oldCh[--oldEndIdx];
1225
+ }
1226
+ else if (newStartVnode == null) {
1227
+ newStartVnode = newCh[++newStartIdx];
1228
+ }
1229
+ else if (newEndVnode == null) {
1230
+ newEndVnode = newCh[--newEndIdx];
1231
+ }
1232
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
1233
+ // if the start nodes are the same then we should patch the new VNode
1234
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1235
+ // indices to reflect that. We don't need to move any DOM Nodes around
1236
+ // since things are matched up in order.
1237
+ patch(oldStartVnode, newStartVnode);
1238
+ oldStartVnode = oldCh[++oldStartIdx];
1239
+ newStartVnode = newCh[++newStartIdx];
1240
+ }
1241
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
1242
+ // likewise, if the end nodes are the same we patch new onto old and
1243
+ // decrement our end indices, and also likewise in this case we don't
1244
+ // need to move any DOM Nodes.
1245
+ patch(oldEndVnode, newEndVnode);
1246
+ oldEndVnode = oldCh[--oldEndIdx];
1247
+ newEndVnode = newCh[--newEndIdx];
1248
+ }
1249
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
1250
+ // case: "Vnode moved right"
1251
+ //
1252
+ // We've found that the last node in our window on the new children is
1253
+ // the same VNode as the _first_ node in our window on the old children
1254
+ // we're dealing with now. Visually, this is the layout of these two
1255
+ // nodes:
1256
+ //
1257
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1258
+ // ^^^^^^^^^^^
1259
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1260
+ // ^^^^^^^^^^^^^
1261
+ //
1262
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1263
+ // and move the DOM element for `oldStartVnode`.
1264
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1265
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1266
+ }
1267
+ patch(oldStartVnode, newEndVnode);
1268
+ // We need to move the element for `oldStartVnode` into a position which
1269
+ // will be appropriate for `newEndVnode`. For this we can use
1270
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1271
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1272
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1273
+ //
1274
+ // <old-start-node />
1275
+ // <some-intervening-node />
1276
+ // <old-end-node />
1277
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1278
+ // <next-sibling />
1279
+ //
1280
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1281
+ // the node for `oldStartVnode` at the end of the children of
1282
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1283
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
1284
+ // append it to the children of the parent element.
1285
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1286
+ oldStartVnode = oldCh[++oldStartIdx];
1287
+ newEndVnode = newCh[--newEndIdx];
1288
+ }
1289
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
1290
+ // case: "Vnode moved left"
1291
+ //
1292
+ // We've found that the first node in our window on the new children is
1293
+ // the same VNode as the _last_ node in our window on the old children.
1294
+ // Visually, this is the layout of these two nodes:
1295
+ //
1296
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1297
+ // ^^^^^^^^^^^^^
1298
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1299
+ // ^^^^^^^^^^^
1300
+ //
1301
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1302
+ // (which will handle updating any changed attributes, reconciling their
1303
+ // children etc) but we also need to move the DOM node to which
1304
+ // `oldEndVnode` corresponds.
1305
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1306
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1307
+ }
1308
+ patch(oldEndVnode, newStartVnode);
1309
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
1310
+ // the same node, so since we're here we know that they are not. Thus we
1311
+ // can move the element for `oldEndVnode` _before_ the element for
1312
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1313
+ // future.
1314
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1315
+ oldEndVnode = oldCh[--oldEndIdx];
1316
+ newStartVnode = newCh[++newStartIdx];
1317
+ }
1318
+ else {
1319
+ // Here we do some checks to match up old and new nodes based on the
1320
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1321
+ // in the JSX for a DOM element in the implementation of a Stencil
1322
+ // component.
1323
+ //
1324
+ // First we check to see if there are any nodes in the array of old
1325
+ // children which have the same key as the first node in the new
1326
+ // children.
1327
+ idxInOld = -1;
1328
+ if (BUILD.vdomKey) {
1329
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1330
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1331
+ idxInOld = i;
1332
+ break;
1333
+ }
1334
+ }
1335
+ }
1336
+ if (BUILD.vdomKey && idxInOld >= 0) {
1337
+ // We found a node in the old children which matches up with the first
1338
+ // node in the new children! So let's deal with that
1339
+ elmToMove = oldCh[idxInOld];
1340
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1341
+ // the tag doesn't match so we'll need a new DOM element
1342
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1343
+ }
1344
+ else {
1345
+ patch(elmToMove, newStartVnode);
1346
+ // invalidate the matching old node so that we won't try to update it
1347
+ // again later on
1348
+ oldCh[idxInOld] = undefined;
1349
+ node = elmToMove.$elm$;
1350
+ }
1351
+ newStartVnode = newCh[++newStartIdx];
1352
+ }
1353
+ else {
1354
+ // We either didn't find an element in the old children that matches
1355
+ // the key of the first new child OR the build is not using `key`
1356
+ // attributes at all. In either case we need to create a new element
1357
+ // for the new node.
1358
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1359
+ newStartVnode = newCh[++newStartIdx];
1360
+ }
1361
+ if (node) {
1362
+ // if we created a new node then handle inserting it to the DOM
1363
+ if (BUILD.slotRelocation) {
1364
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1365
+ }
1366
+ else {
1367
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1368
+ }
1369
+ }
1370
+ }
1371
+ }
1372
+ if (oldStartIdx > oldEndIdx) {
1373
+ // we have some more new nodes to add which don't match up with old nodes
1374
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1375
+ }
1376
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
1377
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
1378
+ // in the new array, so lets remove them (which entails cleaning up the
1379
+ // relevant DOM nodes)
1380
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1381
+ }
1382
+ };
1383
+ /**
1384
+ * Compare two VNodes to determine if they are the same
1385
+ *
1386
+ * **NB**: This function is an equality _heuristic_ based on the available
1387
+ * information set on the two VNodes and can be misleading under certain
1388
+ * circumstances. In particular, if the two nodes do not have `key` attrs
1389
+ * (available under `$key$` on VNodes) then the function falls back on merely
1390
+ * checking that they have the same tag.
1391
+ *
1392
+ * So, in other words, if `key` attrs are not set on VNodes which may be
1393
+ * changing order within a `children` array or something along those lines then
1394
+ * we could obtain a false negative and then have to do needless re-rendering
1395
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1396
+ *
1397
+ * @param leftVNode the first VNode to check
1398
+ * @param rightVNode the second VNode to check
1399
+ * @returns whether they're equal or not
1400
+ */
1401
+ const isSameVnode = (leftVNode, rightVNode) => {
1402
+ // compare if two vnode to see if they're "technically" the same
1403
+ // need to have the same element tag, and same key to be the same
1404
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1405
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1406
+ return leftVNode.$name$ === rightVNode.$name$;
1407
+ }
1408
+ // this will be set if components in the build have `key` attrs set on them
1409
+ if (BUILD.vdomKey) {
1410
+ return leftVNode.$key$ === rightVNode.$key$;
1411
+ }
1412
+ return true;
1413
+ }
1414
+ return false;
1415
+ };
1416
+ const referenceNode = (node) => {
1417
+ // this node was relocated to a new location in the dom
1418
+ // because of some other component's slot
1419
+ // but we still have an html comment in place of where
1420
+ // it's original location was according to it's original vdom
1421
+ return (node && node['s-ol']) || node;
1422
+ };
1423
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1424
+ /**
1425
+ * Handle reconciling an outdated VNode with a new one which corresponds to
1426
+ * it. This function handles flushing updates to the DOM and reconciling the
1427
+ * children of the two nodes (if any).
1428
+ *
1429
+ * @param oldVNode an old VNode whose DOM element and children we want to update
1430
+ * @param newVNode a new VNode representing an updated version of the old one
1431
+ */
1432
+ const patch = (oldVNode, newVNode) => {
1433
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
1434
+ const oldChildren = oldVNode.$children$;
1435
+ const newChildren = newVNode.$children$;
1436
+ const tag = newVNode.$tag$;
1437
+ const text = newVNode.$text$;
1438
+ let defaultHolder;
1439
+ if (!BUILD.vdomText || text === null) {
1440
+ if (BUILD.svg) {
1441
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1442
+ // only add this to the when the compiler sees we're using an svg somewhere
1443
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1444
+ }
1445
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1446
+ if (BUILD.slot && tag === 'slot')
1447
+ ;
1448
+ else {
1449
+ // either this is the first render of an element OR it's an update
1450
+ // AND we already know it's possible it could have changed
1451
+ // this updates the element's css classes, attrs, props, listeners, etc.
1452
+ updateElement(oldVNode, newVNode, isSvgMode);
1453
+ }
1454
+ }
1455
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1456
+ // looks like there's child vnodes for both the old and new vnodes
1457
+ // so we need to call `updateChildren` to reconcile them
1458
+ updateChildren(elm, oldChildren, newVNode, newChildren);
1459
+ }
1460
+ else if (newChildren !== null) {
1461
+ // no old child vnodes, but there are new child vnodes to add
1462
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1463
+ // the old vnode was text, so be sure to clear it out
1464
+ elm.textContent = '';
1465
+ }
1466
+ // add the new vnode children
1467
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1468
+ }
1469
+ else if (BUILD.updatable && oldChildren !== null) {
1470
+ // no new child vnodes, but there are old child vnodes to remove
1471
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1472
+ }
1473
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1474
+ isSvgMode = false;
1475
+ }
1476
+ }
1477
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1478
+ // this element has slotted content
1479
+ defaultHolder.parentNode.textContent = text;
1480
+ }
1481
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1482
+ // update the text content for the text only vnode
1483
+ // and also only if the text is different than before
1484
+ elm.data = text;
1485
+ }
1486
+ };
1487
+ const updateFallbackSlotVisibility = (elm) => {
1488
+ // tslint:disable-next-line: prefer-const
1489
+ const childNodes = elm.childNodes;
1490
+ let childNode;
1491
+ let i;
1492
+ let ilen;
1493
+ let j;
1494
+ let slotNameAttr;
1495
+ let nodeType;
1496
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1497
+ childNode = childNodes[i];
1498
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1499
+ if (childNode['s-sr']) {
1500
+ // this is a slot fallback node
1501
+ // get the slot name for this slot reference node
1502
+ slotNameAttr = childNode['s-sn'];
1503
+ // by default always show a fallback slot node
1504
+ // then hide it if there are other slots in the light dom
1505
+ childNode.hidden = false;
1506
+ for (j = 0; j < ilen; j++) {
1507
+ nodeType = childNodes[j].nodeType;
1508
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1509
+ // this sibling node is from a different component OR is a named fallback slot node
1510
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1511
+ childNode.hidden = true;
1512
+ break;
1513
+ }
1514
+ }
1515
+ else {
1516
+ // this is a default fallback slot node
1517
+ // any element or text node (with content)
1518
+ // should hide the default fallback slot node
1519
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1520
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
1521
+ childNode.hidden = true;
1522
+ break;
1523
+ }
1524
+ }
1525
+ }
1526
+ }
1527
+ // keep drilling down
1528
+ updateFallbackSlotVisibility(childNode);
1529
+ }
1530
+ }
1531
+ };
1532
+ const relocateNodes = [];
1533
+ const relocateSlotContent = (elm) => {
1534
+ // tslint:disable-next-line: prefer-const
1535
+ let childNode;
1536
+ let node;
1537
+ let hostContentNodes;
1538
+ let slotNameAttr;
1539
+ let relocateNodeData;
1540
+ let j;
1541
+ let i = 0;
1542
+ const childNodes = elm.childNodes;
1543
+ const ilen = childNodes.length;
1544
+ for (; i < ilen; i++) {
1545
+ childNode = childNodes[i];
1546
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1547
+ // first got the content reference comment node
1548
+ // then we got it's parent, which is where all the host content is in now
1549
+ hostContentNodes = node.parentNode.childNodes;
1550
+ slotNameAttr = childNode['s-sn'];
1551
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1552
+ node = hostContentNodes[j];
1553
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1554
+ // let's do some relocating to its new home
1555
+ // but never relocate a content reference node
1556
+ // that is suppose to always represent the original content location
1557
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
1558
+ // it's possible we've already decided to relocate this node
1559
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1560
+ // made some changes to slots
1561
+ // let's make sure we also double check
1562
+ // fallbacks are correctly hidden or shown
1563
+ checkSlotFallbackVisibility = true;
1564
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
1565
+ if (relocateNodeData) {
1566
+ // previously we never found a slot home for this node
1567
+ // but turns out we did, so let's remember it now
1568
+ relocateNodeData.$slotRefNode$ = childNode;
1569
+ }
1570
+ else {
1571
+ // add to our list of nodes to relocate
1572
+ relocateNodes.push({
1573
+ $slotRefNode$: childNode,
1574
+ $nodeToRelocate$: node,
1575
+ });
1576
+ }
1577
+ if (node['s-sr']) {
1578
+ relocateNodes.map((relocateNode) => {
1579
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1580
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1581
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1582
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1583
+ }
1584
+ }
1585
+ });
1586
+ }
1587
+ }
1588
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1589
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1590
+ // if we never find a home for this element then we'll need to hide it
1591
+ relocateNodes.push({
1592
+ $nodeToRelocate$: node,
1593
+ });
1594
+ }
1595
+ }
1596
+ }
1597
+ }
1598
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1599
+ relocateSlotContent(childNode);
1600
+ }
1601
+ }
1602
+ };
1603
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1604
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1605
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1606
+ return true;
1607
+ }
1608
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1609
+ return true;
1610
+ }
1611
+ return false;
1612
+ }
1613
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1614
+ return true;
1615
+ }
1616
+ return slotNameAttr === '';
1617
+ };
1618
+ /**
1619
+ * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
1620
+ * calling them with `null`. This signals that the DOM element corresponding to
1621
+ * the VDom node has been removed from the DOM.
1622
+ *
1623
+ * @param vNode a virtual DOM node
1624
+ */
1625
+ const nullifyVNodeRefs = (vNode) => {
1626
+ if (BUILD.vdomRef) {
1627
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1628
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1629
+ }
1630
+ };
1631
+ /**
1632
+ * The main entry point for Stencil's virtual DOM-based rendering engine
1633
+ *
1634
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1635
+ * function will handle creating a virtual DOM tree with a single root, patching
1636
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1637
+ * relocation, and reflecting attributes.
1638
+ *
1639
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1640
+ * the DOM node into which it should be rendered.
1641
+ * @param renderFnResults the virtual DOM nodes to be rendered
1642
+ */
1643
+ const renderVdom = (hostRef, renderFnResults) => {
1644
+ const hostElm = hostRef.$hostElement$;
1645
+ const cmpMeta = hostRef.$cmpMeta$;
1646
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1647
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1648
+ hostTagName = hostElm.tagName;
1649
+ // <Host> runtime check
1650
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1651
+ throw new Error(`The <Host> must be the single root component.
1652
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1653
+
1654
+ The render() function should look like this instead:
1655
+
1656
+ render() {
1657
+ // Do not return an array
1658
+ return (
1659
+ <Host>{content}</Host>
1660
+ );
1661
+ }
1662
+ `);
1663
+ }
1664
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1665
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1666
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1667
+ }
1668
+ rootVnode.$tag$ = null;
1669
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1670
+ hostRef.$vnode$ = rootVnode;
1671
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1672
+ if (BUILD.scoped || BUILD.shadowDom) {
1673
+ scopeId = hostElm['s-sc'];
1674
+ }
1675
+ if (BUILD.slotRelocation) {
1676
+ contentRef = hostElm['s-cr'];
1677
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1678
+ // always reset
1679
+ checkSlotFallbackVisibility = false;
1680
+ }
1681
+ // synchronous patch
1682
+ patch(oldVNode, rootVnode);
1683
+ if (BUILD.slotRelocation) {
1684
+ // while we're moving nodes around existing nodes, temporarily disable
1685
+ // the disconnectCallback from working
1686
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1687
+ if (checkSlotRelocate) {
1688
+ relocateSlotContent(rootVnode.$elm$);
1689
+ let relocateData;
1690
+ let nodeToRelocate;
1691
+ let orgLocationNode;
1692
+ let parentNodeRef;
1693
+ let insertBeforeNode;
1694
+ let refNode;
1695
+ let i = 0;
1696
+ for (; i < relocateNodes.length; i++) {
1697
+ relocateData = relocateNodes[i];
1698
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1699
+ if (!nodeToRelocate['s-ol']) {
1700
+ // add a reference node marking this node's original location
1701
+ // keep a reference to this node for later lookups
1702
+ orgLocationNode =
1703
+ BUILD.isDebug || BUILD.hydrateServerSide
1704
+ ? originalLocationDebugNode(nodeToRelocate)
1705
+ : doc.createTextNode('');
1706
+ orgLocationNode['s-nr'] = nodeToRelocate;
1707
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1708
+ }
1709
+ }
1710
+ for (i = 0; i < relocateNodes.length; i++) {
1711
+ relocateData = relocateNodes[i];
1712
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1713
+ if (relocateData.$slotRefNode$) {
1714
+ // by default we're just going to insert it directly
1715
+ // after the slot reference node
1716
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1717
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1718
+ orgLocationNode = nodeToRelocate['s-ol'];
1719
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1720
+ refNode = orgLocationNode['s-nr'];
1721
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1722
+ refNode = refNode.nextSibling;
1723
+ if (!refNode || !refNode['s-nr']) {
1724
+ insertBeforeNode = refNode;
1725
+ break;
1726
+ }
1727
+ }
1728
+ }
1729
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1730
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1731
+ // we've checked that it's worth while to relocate
1732
+ // since that the node to relocate
1733
+ // has a different next sibling or parent relocated
1734
+ if (nodeToRelocate !== insertBeforeNode) {
1735
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1736
+ // probably a component in the index.html that doesn't have it's hostname set
1737
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1738
+ }
1739
+ // add it back to the dom but in its new home
1740
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1741
+ }
1742
+ }
1743
+ }
1744
+ else {
1745
+ // this node doesn't have a slot home to go to, so let's hide it
1746
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1747
+ nodeToRelocate.hidden = true;
1748
+ }
1749
+ }
1750
+ }
1751
+ }
1752
+ if (checkSlotFallbackVisibility) {
1753
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1754
+ }
1755
+ // done moving nodes around
1756
+ // allow the disconnect callback to work again
1757
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1758
+ // always reset
1759
+ relocateNodes.length = 0;
1760
+ }
1761
+ };
1762
+ // slot comment debug nodes only created with the `--debug` flag
1763
+ // otherwise these nodes are text nodes w/out content
1764
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1765
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1766
+ (nodeToRelocate.localName
1767
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1768
+ : `[${nodeToRelocate.textContent}]`));
1769
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1770
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1771
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1772
+ }
1773
+ };
1774
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1775
+ if (BUILD.taskQueue && BUILD.updatable) {
1776
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1777
+ }
1778
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1779
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1780
+ return;
1781
+ }
1782
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1783
+ // there is no ancestor component or the ancestor component
1784
+ // has already fired off its lifecycle update then
1785
+ // fire off the initial update
1786
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1787
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1788
+ };
1789
+ /**
1790
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1791
+ * component lifecycle methods like `componentWillLoad` as well as
1792
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
1793
+ *
1794
+ * @param hostRef a reference to a host DOM node
1795
+ * @param isInitialLoad whether we're on the initial load or not
1796
+ * @returns an empty Promise which is used to enqueue a series of operations for
1797
+ * the component
1798
+ */
1799
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1800
+ const elm = hostRef.$hostElement$;
1801
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1802
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1803
+ // We're going to use this variable together with `enqueue` to implement a
1804
+ // little promise-based queue. We start out with it `undefined`. When we add
1805
+ // the first function to the queue we'll set this variable to be that
1806
+ // function's return value. When we attempt to add subsequent values to the
1807
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
1808
+ // the new function off of that `Promise` using `.then()`. This will give our
1809
+ // queue two nice properties:
1810
+ //
1811
+ // 1. If all functions added to the queue are synchronous they'll be called
1812
+ // synchronously right away.
1813
+ // 2. If all functions added to the queue are asynchronous they'll all be
1814
+ // called in order after `dispatchHooks` exits.
1815
+ let maybePromise;
1816
+ if (isInitialLoad) {
1817
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1818
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1819
+ if (hostRef.$queuedListeners$) {
1820
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1821
+ hostRef.$queuedListeners$ = undefined;
1822
+ }
1823
+ }
1824
+ emitLifecycleEvent(elm, 'componentWillLoad');
1825
+ if (BUILD.cmpWillLoad) {
1826
+ // If `componentWillLoad` returns a `Promise` then we want to wait on
1827
+ // whatever's going on in that `Promise` before we launch into
1828
+ // rendering the component, doing other lifecycle stuff, etc. So
1829
+ // in that case we assign the returned promise to the variable we
1830
+ // declared above to hold a possible 'queueing' Promise
1831
+ maybePromise = safeCall(instance, 'componentWillLoad');
1832
+ }
1833
+ }
1834
+ else {
1835
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1836
+ if (BUILD.cmpWillUpdate) {
1837
+ // Like `componentWillLoad` above, we allow Stencil component
1838
+ // authors to return a `Promise` from this lifecycle callback, and
1839
+ // we specify that our runtime will wait for that `Promise` to
1840
+ // resolve before the component re-renders. So if the method
1841
+ // returns a `Promise` we need to keep it around!
1842
+ maybePromise = safeCall(instance, 'componentWillUpdate');
1843
+ }
1844
+ }
1845
+ emitLifecycleEvent(elm, 'componentWillRender');
1846
+ if (BUILD.cmpWillRender) {
1847
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, 'componentWillRender'));
1848
+ }
1849
+ endSchedule();
1850
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1851
+ };
1852
+ /**
1853
+ * This function uses a Promise to implement a simple first-in, first-out queue
1854
+ * of functions to be called.
1855
+ *
1856
+ * The queue is ordered on the basis of the first argument. If it's
1857
+ * `undefined`, then nothing is on the queue yet, so the provided function can
1858
+ * be called synchronously (although note that this function may return a
1859
+ * `Promise`). The idea is that then the return value of that enqueueing
1860
+ * operation is kept around, so that if it was a `Promise` then subsequent
1861
+ * functions can be enqueued by calling this function again with that `Promise`
1862
+ * as the first argument.
1863
+ *
1864
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1865
+ * @param fn a function to enqueue
1866
+ * @returns either a `Promise` or the return value of the provided function
1867
+ */
1868
+ const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1869
+ /**
1870
+ * Check that a value is a `Promise`. To check, we first see if the value is an
1871
+ * instance of the `Promise` global. In a few circumstances, in particular if
1872
+ * the global has been overwritten, this is could be misleading, so we also do
1873
+ * a little 'duck typing' check to see if the `.then` property of the value is
1874
+ * defined and a function.
1875
+ *
1876
+ * @param maybePromise it might be a promise!
1877
+ * @returns whether it is or not
1878
+ */
1879
+ const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1880
+ (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1881
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1882
+ var _a;
1883
+ const elm = hostRef.$hostElement$;
1884
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1885
+ const rc = elm['s-rc'];
1886
+ if (BUILD.style && isInitialLoad) {
1887
+ // DOM WRITE!
1888
+ attachStyles(hostRef);
1889
+ }
1890
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1891
+ if (BUILD.isDev) {
1892
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1893
+ }
1894
+ if (BUILD.hydrateServerSide) {
1895
+ await callRender(hostRef, instance, elm);
1896
+ }
1897
+ else {
1898
+ callRender(hostRef, instance, elm);
1899
+ }
1900
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1901
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1902
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1903
+ plt.$cssShim$.updateHost(elm);
1904
+ }
1905
+ if (BUILD.isDev) {
1906
+ hostRef.$renderCount$ = hostRef.$renderCount$ === undefined ? 1 : hostRef.$renderCount$ + 1;
1907
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1908
+ }
1909
+ if (BUILD.hydrateServerSide) {
1910
+ try {
1911
+ // manually connected child components during server-side hydrate
1912
+ serverSideConnected(elm);
1913
+ if (isInitialLoad) {
1914
+ // using only during server-side hydrate
1915
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1916
+ elm['s-en'] = '';
1917
+ }
1918
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1919
+ elm['s-en'] = 'c';
1920
+ }
1921
+ }
1922
+ }
1923
+ catch (e) {
1924
+ consoleError(e, elm);
1925
+ }
1926
+ }
1927
+ if (BUILD.asyncLoading && rc) {
1928
+ // ok, so turns out there are some child host elements
1929
+ // waiting on this parent element to load
1930
+ // let's fire off all update callbacks waiting
1931
+ rc.map((cb) => cb());
1932
+ elm['s-rc'] = undefined;
1933
+ }
1934
+ endRender();
1935
+ endUpdate();
1936
+ if (BUILD.asyncLoading) {
1937
+ const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1938
+ const postUpdate = () => postUpdateComponent(hostRef);
1939
+ if (childrenPromises.length === 0) {
1940
+ postUpdate();
1941
+ }
1942
+ else {
1943
+ Promise.all(childrenPromises).then(postUpdate);
1944
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1945
+ childrenPromises.length = 0;
1946
+ }
1947
+ }
1948
+ else {
1949
+ postUpdateComponent(hostRef);
1950
+ }
1951
+ };
1952
+ const callRender = (hostRef, instance, elm) => {
1953
+ // in order for bundlers to correctly treeshake the BUILD object
1954
+ // we need to ensure BUILD is not deoptimized within a try/catch
1955
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1956
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1957
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1958
+ const taskQueue = BUILD.taskQueue ? true : false;
1959
+ const updatable = BUILD.updatable ? true : false;
1960
+ try {
1961
+ renderingRef = instance;
1962
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1963
+ if (updatable && taskQueue) {
1964
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1965
+ }
1966
+ if (updatable || lazyLoad) {
1967
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1968
+ }
1969
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1970
+ if (BUILD.vdomRender || BUILD.reflect) {
1971
+ // looks like we've got child nodes to render into this host element
1972
+ // or we need to update the css class/attrs on the host element
1973
+ // DOM WRITE!
1974
+ if (BUILD.hydrateServerSide) {
1975
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1976
+ }
1977
+ else {
1978
+ renderVdom(hostRef, instance);
1979
+ }
1980
+ }
1981
+ else {
1982
+ elm.textContent = instance;
1983
+ }
1984
+ }
1985
+ }
1986
+ catch (e) {
1987
+ consoleError(e, hostRef.$hostElement$);
1988
+ }
1989
+ renderingRef = null;
1990
+ return null;
1991
+ };
1992
+ const getRenderingRef = () => renderingRef;
1993
+ const postUpdateComponent = (hostRef) => {
1994
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1995
+ const elm = hostRef.$hostElement$;
1996
+ const endPostUpdate = createTime('postUpdate', tagName);
1997
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1998
+ const ancestorComponent = hostRef.$ancestorComponent$;
1999
+ if (BUILD.cmpDidRender) {
2000
+ if (BUILD.isDev) {
2001
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
2002
+ }
2003
+ safeCall(instance, 'componentDidRender');
2004
+ if (BUILD.isDev) {
2005
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
2006
+ }
2007
+ }
2008
+ emitLifecycleEvent(elm, 'componentDidRender');
2009
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
2010
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
2011
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
2012
+ // DOM WRITE!
2013
+ addHydratedFlag(elm);
2014
+ }
2015
+ if (BUILD.cmpDidLoad) {
2016
+ if (BUILD.isDev) {
2017
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
2018
+ }
2019
+ safeCall(instance, 'componentDidLoad');
2020
+ if (BUILD.isDev) {
2021
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
2022
+ }
2023
+ }
2024
+ emitLifecycleEvent(elm, 'componentDidLoad');
2025
+ endPostUpdate();
2026
+ if (BUILD.asyncLoading) {
2027
+ hostRef.$onReadyResolve$(elm);
2028
+ if (!ancestorComponent) {
2029
+ appDidLoad(tagName);
2030
+ }
2031
+ }
2032
+ }
2033
+ else {
2034
+ if (BUILD.cmpDidUpdate) {
2035
+ // we've already loaded this component
2036
+ // fire off the user's componentDidUpdate method (if one was provided)
2037
+ // componentDidUpdate runs AFTER render() has been called
2038
+ // and all child components have finished updating
2039
+ if (BUILD.isDev) {
2040
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
2041
+ }
2042
+ safeCall(instance, 'componentDidUpdate');
2043
+ if (BUILD.isDev) {
2044
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
2045
+ }
2046
+ }
2047
+ emitLifecycleEvent(elm, 'componentDidUpdate');
2048
+ endPostUpdate();
2049
+ }
2050
+ if (BUILD.hotModuleReplacement) {
2051
+ elm['s-hmr-load'] && elm['s-hmr-load']();
2052
+ }
2053
+ if (BUILD.method && BUILD.lazyLoad) {
2054
+ hostRef.$onInstanceResolve$(elm);
2055
+ }
2056
+ // load events fire from bottom to top
2057
+ // the deepest elements load first then bubbles up
2058
+ if (BUILD.asyncLoading) {
2059
+ if (hostRef.$onRenderResolve$) {
2060
+ hostRef.$onRenderResolve$();
2061
+ hostRef.$onRenderResolve$ = undefined;
2062
+ }
2063
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
2064
+ nextTick(() => scheduleUpdate(hostRef, false));
2065
+ }
2066
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
2067
+ }
2068
+ // ( •_•)
2069
+ // ( •_•)>⌐■-■
2070
+ // (⌐■_■)
2071
+ };
2072
+ const forceUpdate = (ref) => {
2073
+ if (BUILD.updatable) {
2074
+ const hostRef = getHostRef(ref);
2075
+ const isConnected = hostRef.$hostElement$.isConnected;
2076
+ if (isConnected &&
2077
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2078
+ scheduleUpdate(hostRef, false);
2079
+ }
2080
+ // Returns "true" when the forced update was successfully scheduled
2081
+ return isConnected;
2082
+ }
2083
+ return false;
2084
+ };
2085
+ const appDidLoad = (who) => {
2086
+ // on appload
2087
+ // we have finish the first big initial render
2088
+ if (BUILD.cssAnnotations) {
2089
+ addHydratedFlag(doc.documentElement);
2090
+ }
2091
+ if (BUILD.asyncQueue) {
2092
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2093
+ }
2094
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2095
+ if (BUILD.profile && performance.measure) {
2096
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
2097
+ }
2098
+ };
2099
+ const safeCall = (instance, method, arg) => {
2100
+ if (instance && instance[method]) {
2101
+ try {
2102
+ return instance[method](arg);
2103
+ }
2104
+ catch (e) {
2105
+ consoleError(e);
2106
+ }
2107
+ }
2108
+ return undefined;
2109
+ };
2110
+ const emitLifecycleEvent = (elm, lifecycleName) => {
2111
+ if (BUILD.lifecycleDOMEvents) {
2112
+ emitEvent(elm, 'stencil_' + lifecycleName, {
2113
+ bubbles: true,
2114
+ composed: true,
2115
+ detail: {
2116
+ namespace: NAMESPACE,
2117
+ },
2118
+ });
2119
+ }
2120
+ };
2121
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
2122
+ ? elm.classList.add('hydrated')
2123
+ : BUILD.hydratedAttribute
2124
+ ? elm.setAttribute('hydrated', '')
2125
+ : undefined;
2126
+ const serverSideConnected = (elm) => {
2127
+ const children = elm.children;
2128
+ if (children != null) {
2129
+ for (let i = 0, ii = children.length; i < ii; i++) {
2130
+ const childElm = children[i];
2131
+ if (typeof childElm.connectedCallback === 'function') {
2132
+ childElm.connectedCallback();
2133
+ }
2134
+ serverSideConnected(childElm);
2135
+ }
2136
+ }
2137
+ };
2138
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
2139
+ const setValue = (ref, propName, newVal, cmpMeta) => {
2140
+ // check our new property value against our internal value
2141
+ const hostRef = getHostRef(ref);
2142
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
2143
+ const oldVal = hostRef.$instanceValues$.get(propName);
2144
+ const flags = hostRef.$flags$;
2145
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2146
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2147
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
2148
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
2149
+ const didValueChange = newVal !== oldVal && !areBothNaN;
2150
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2151
+ // gadzooks! the property's value has changed!!
2152
+ // set our new value!
2153
+ hostRef.$instanceValues$.set(propName, newVal);
2154
+ if (BUILD.isDev) {
2155
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
2156
+ consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2157
+ }
2158
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
2159
+ consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2160
+ }
2161
+ }
2162
+ if (!BUILD.lazyLoad || instance) {
2163
+ // get an array of method names of watch functions to call
2164
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2165
+ const watchMethods = cmpMeta.$watchers$[propName];
2166
+ if (watchMethods) {
2167
+ // this instance is watching for when this property changed
2168
+ watchMethods.map((watchMethodName) => {
2169
+ try {
2170
+ // fire off each of the watch methods that are watching this property
2171
+ instance[watchMethodName](newVal, oldVal, propName);
2172
+ }
2173
+ catch (e) {
2174
+ consoleError(e, elm);
2175
+ }
2176
+ });
2177
+ }
2178
+ }
2179
+ if (BUILD.updatable &&
2180
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2181
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
2182
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
2183
+ return;
2184
+ }
2185
+ }
2186
+ // looks like this value actually changed, so we've got work to do!
2187
+ // but only if we've already rendered, otherwise just chill out
2188
+ // queue that we need to do an update, but don't worry about queuing
2189
+ // up millions cuz this function ensures it only runs once
2190
+ scheduleUpdate(hostRef, false);
2191
+ }
2192
+ }
2193
+ }
2194
+ };
2195
+ /**
2196
+ * Attach a series of runtime constructs to a compiled Stencil component
2197
+ * constructor, including getters and setters for the `@Prop` and `@State`
2198
+ * decorators, callbacks for when attributes change, and so on.
2199
+ *
2200
+ * @param Cstr the constructor for a component that we need to process
2201
+ * @param cmpMeta metadata collected previously about the component
2202
+ * @param flags a number used to store a series of bit flags
2203
+ * @returns a reference to the same constructor passed in (but now mutated)
2204
+ */
2205
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
2206
+ if (BUILD.member && cmpMeta.$members$) {
2207
+ if (BUILD.watchCallback && Cstr.watchers) {
2208
+ cmpMeta.$watchers$ = Cstr.watchers;
2209
+ }
2210
+ // It's better to have a const than two Object.entries()
2211
+ const members = Object.entries(cmpMeta.$members$);
2212
+ const prototype = Cstr.prototype;
2213
+ members.map(([memberName, [memberFlags]]) => {
2214
+ if ((BUILD.prop || BUILD.state) &&
2215
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2216
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2217
+ // proxyComponent - prop
2218
+ Object.defineProperty(prototype, memberName, {
2219
+ get() {
2220
+ // proxyComponent, get value
2221
+ return getValue(this, memberName);
2222
+ },
2223
+ set(newValue) {
2224
+ // only during dev time
2225
+ if (BUILD.isDev) {
2226
+ const ref = getHostRef(this);
2227
+ if (
2228
+ // we are proxying the instance (not element)
2229
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
2230
+ // the element is not constructing
2231
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
2232
+ // the member is a prop
2233
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
2234
+ // the member is not mutable
2235
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
2236
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
2237
+ }
2238
+ }
2239
+ // proxyComponent, set value
2240
+ setValue(this, memberName, newValue, cmpMeta);
2241
+ },
2242
+ configurable: true,
2243
+ enumerable: true,
2244
+ });
2245
+ }
2246
+ else if (BUILD.lazyLoad &&
2247
+ BUILD.method &&
2248
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2249
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
2250
+ // proxyComponent - method
2251
+ Object.defineProperty(prototype, memberName, {
2252
+ value(...args) {
2253
+ const ref = getHostRef(this);
2254
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
2255
+ },
2256
+ });
2257
+ }
2258
+ });
2259
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2260
+ const attrNameToPropName = new Map();
2261
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
2262
+ plt.jmp(() => {
2263
+ const propName = attrNameToPropName.get(attrName);
2264
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
2265
+ // in the case where an attribute was set inline.
2266
+ // ```html
2267
+ // <my-component some-attribute="some-value"></my-component>
2268
+ // ```
2269
+ //
2270
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
2271
+ // programmatically changes it before it has been upgraded as shown below:
2272
+ //
2273
+ // ```html
2274
+ // <!-- this component has _not_ been upgraded yet -->
2275
+ // <my-component id="test" some-attribute="some-value"></my-component>
2276
+ // <script>
2277
+ // // grab non-upgraded component
2278
+ // el = document.querySelector("#test");
2279
+ // el.someAttribute = "another-value";
2280
+ // // upgrade component
2281
+ // customElements.define('my-component', MyComponent);
2282
+ // </script>
2283
+ // ```
2284
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
2285
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
2286
+ // to the value that was set inline i.e. "some-value" from above example. When
2287
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
2288
+ //
2289
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
2290
+ // by connectedCallback as this attributeChangedCallback will not fire.
2291
+ //
2292
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2293
+ //
2294
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
2295
+ // properties here given that this goes against best practices outlined here
2296
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2297
+ if (this.hasOwnProperty(propName)) {
2298
+ newValue = this[propName];
2299
+ delete this[propName];
2300
+ }
2301
+ else if (prototype.hasOwnProperty(propName) &&
2302
+ typeof this[propName] === 'number' &&
2303
+ this[propName] == newValue) {
2304
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
2305
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
2306
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
2307
+ return;
2308
+ }
2309
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2310
+ });
2311
+ };
2312
+ // create an array of attributes to observe
2313
+ // and also create a map of html attribute name to js property name
2314
+ Cstr.observedAttributes = members
2315
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
2316
+ .map(([propName, m]) => {
2317
+ const attrName = m[1] || propName;
2318
+ attrNameToPropName.set(attrName, propName);
2319
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2320
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
2321
+ }
2322
+ return attrName;
2323
+ });
2324
+ }
2325
+ }
2326
+ return Cstr;
2327
+ };
2328
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2329
+ // initializeComponent
2330
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2331
+ // Let the runtime know that the component has been initialized
2332
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2333
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2334
+ // lazy loaded components
2335
+ // request the component's implementation to be
2336
+ // wired up with the host element
2337
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
2338
+ if (Cstr.then) {
2339
+ // Await creates a micro-task avoid if possible
2340
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
2341
+ Cstr = await Cstr;
2342
+ endLoad();
2343
+ }
2344
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2345
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2346
+ }
2347
+ if (BUILD.member && !Cstr.isProxied) {
2348
+ // we've never proxied this Constructor before
2349
+ // let's add the getters/setters to its prototype before
2350
+ // the first time we create an instance of the implementation
2351
+ if (BUILD.watchCallback) {
2352
+ cmpMeta.$watchers$ = Cstr.watchers;
2353
+ }
2354
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2355
+ Cstr.isProxied = true;
2356
+ }
2357
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2358
+ // ok, time to construct the instance
2359
+ // but let's keep track of when we start and stop
2360
+ // so that the getters/setters don't incorrectly step on data
2361
+ if (BUILD.member) {
2362
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2363
+ }
2364
+ // construct the lazy-loaded component implementation
2365
+ // passing the hostRef is very important during
2366
+ // construction in order to directly wire together the
2367
+ // host element and the lazy-loaded instance
2368
+ try {
2369
+ new Cstr(hostRef);
2370
+ }
2371
+ catch (e) {
2372
+ consoleError(e);
2373
+ }
2374
+ if (BUILD.member) {
2375
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2376
+ }
2377
+ if (BUILD.watchCallback) {
2378
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2379
+ }
2380
+ endNewInstance();
2381
+ fireConnectedCallback(hostRef.$lazyInstance$);
2382
+ }
2383
+ else {
2384
+ // sync constructor component
2385
+ Cstr = elm.constructor;
2386
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2387
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2388
+ // Stencil has completed instantiating the component.
2389
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2390
+ }
2391
+ if (BUILD.style && Cstr.style) {
2392
+ // this component has styles but we haven't registered them yet
2393
+ let style = Cstr.style;
2394
+ if (BUILD.mode && typeof style !== 'string') {
2395
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2396
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2397
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2398
+ }
2399
+ }
2400
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2401
+ if (!styles.has(scopeId)) {
2402
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2403
+ if (!BUILD.hydrateServerSide &&
2404
+ BUILD.shadowDom &&
2405
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2406
+ BUILD.shadowDomShim &&
2407
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2408
+ style = await import('./shadow-css-af2290df.js').then((m) => m.scopeCss(style, scopeId, false));
2409
+ }
2410
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2411
+ endRegisterStyles();
2412
+ }
2413
+ }
2414
+ }
2415
+ // we've successfully created a lazy instance
2416
+ const ancestorComponent = hostRef.$ancestorComponent$;
2417
+ const schedule = () => scheduleUpdate(hostRef, true);
2418
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2419
+ // this is the initial load and this component it has an ancestor component
2420
+ // but the ancestor component has NOT fired its will update lifecycle yet
2421
+ // so let's just cool our jets and wait for the ancestor to continue first
2422
+ // this will get fired off when the ancestor component
2423
+ // finally gets around to rendering its lazy self
2424
+ // fire off the initial update
2425
+ ancestorComponent['s-rc'].push(schedule);
2426
+ }
2427
+ else {
2428
+ schedule();
2429
+ }
2430
+ };
2431
+ const fireConnectedCallback = (instance) => {
2432
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
2433
+ safeCall(instance, 'connectedCallback');
2434
+ }
2435
+ };
2436
+ const connectedCallback = (elm) => {
2437
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2438
+ const hostRef = getHostRef(elm);
2439
+ const cmpMeta = hostRef.$cmpMeta$;
2440
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2441
+ if (BUILD.hostListenerTargetParent) {
2442
+ // only run if we have listeners being attached to a parent
2443
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2444
+ }
2445
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2446
+ // first time this component has connected
2447
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2448
+ let hostId;
2449
+ if (BUILD.hydrateClientSide) {
2450
+ hostId = elm.getAttribute(HYDRATE_ID);
2451
+ if (hostId) {
2452
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2453
+ const scopeId = BUILD.mode
2454
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2455
+ : addStyle(elm.shadowRoot, cmpMeta);
2456
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2457
+ }
2458
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2459
+ }
2460
+ }
2461
+ if (BUILD.slotRelocation && !hostId) {
2462
+ // initUpdate
2463
+ // if the slot polyfill is required we'll need to put some nodes
2464
+ // in here to act as original content anchors as we move nodes around
2465
+ // host element has been connected to the DOM
2466
+ if (BUILD.hydrateServerSide ||
2467
+ ((BUILD.slot || BUILD.shadowDom) &&
2468
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2469
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2470
+ setContentReference(elm);
2471
+ }
2472
+ }
2473
+ if (BUILD.asyncLoading) {
2474
+ // find the first ancestor component (if there is one) and register
2475
+ // this component as one of the actively loading child components for its ancestor
2476
+ let ancestorComponent = elm;
2477
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2478
+ // climb up the ancestors looking for the first
2479
+ // component that hasn't finished its lifecycle update yet
2480
+ if ((BUILD.hydrateClientSide &&
2481
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2482
+ ancestorComponent.hasAttribute('s-id') &&
2483
+ ancestorComponent['s-p']) ||
2484
+ ancestorComponent['s-p']) {
2485
+ // we found this components first ancestor component
2486
+ // keep a reference to this component's ancestor component
2487
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2488
+ break;
2489
+ }
2490
+ }
2491
+ }
2492
+ // Lazy properties
2493
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2494
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2495
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2496
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2497
+ const value = elm[memberName];
2498
+ delete elm[memberName];
2499
+ elm[memberName] = value;
2500
+ }
2501
+ });
2502
+ }
2503
+ if (BUILD.initializeNextTick) {
2504
+ // connectedCallback, taskQueue, initialLoad
2505
+ // angular sets attribute AFTER connectCallback
2506
+ // https://github.com/angular/angular/issues/18909
2507
+ // https://github.com/angular/angular/issues/19940
2508
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2509
+ }
2510
+ else {
2511
+ initializeComponent(elm, hostRef, cmpMeta);
2512
+ }
2513
+ }
2514
+ else {
2515
+ // not the first time this has connected
2516
+ // reattach any event listeners to the host
2517
+ // since they would have been removed when disconnected
2518
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2519
+ // fire off connectedCallback() on component instance
2520
+ fireConnectedCallback(hostRef.$lazyInstance$);
2521
+ }
2522
+ endConnected();
2523
+ }
2524
+ };
2525
+ const setContentReference = (elm) => {
2526
+ // only required when we're NOT using native shadow dom (slot)
2527
+ // or this browser doesn't support native shadow dom
2528
+ // and this host element was NOT created with SSR
2529
+ // let's pick out the inner content for slot projection
2530
+ // create a node to represent where the original
2531
+ // content was first placed, which is useful later on
2532
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
2533
+ contentRefElm['s-cn'] = true;
2534
+ elm.insertBefore(contentRefElm, elm.firstChild);
2535
+ };
2536
+ const disconnectedCallback = (elm) => {
2537
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2538
+ const hostRef = getHostRef(elm);
2539
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2540
+ if (BUILD.hostListener) {
2541
+ if (hostRef.$rmListeners$) {
2542
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
2543
+ hostRef.$rmListeners$ = undefined;
2544
+ }
2545
+ }
2546
+ // clear CSS var-shim tracking
2547
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
2548
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2549
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
2550
+ plt.$cssShim$.removeHost(elm);
2551
+ }
2552
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2553
+ safeCall(instance, 'disconnectedCallback');
2554
+ }
2555
+ if (BUILD.cmpDidUnload) {
2556
+ safeCall(instance, 'componentDidUnload');
2557
+ }
2558
+ }
2559
+ };
2560
+ const defineCustomElement = (Cstr, compactMeta) => {
2561
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2562
+ };
2563
+ const proxyCustomElement = (Cstr, compactMeta) => {
2564
+ const cmpMeta = {
2565
+ $flags$: compactMeta[0],
2566
+ $tagName$: compactMeta[1],
2567
+ };
2568
+ if (BUILD.member) {
2569
+ cmpMeta.$members$ = compactMeta[2];
2570
+ }
2571
+ if (BUILD.hostListener) {
2572
+ cmpMeta.$listeners$ = compactMeta[3];
2573
+ }
2574
+ if (BUILD.watchCallback) {
2575
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2576
+ }
2577
+ if (BUILD.reflect) {
2578
+ cmpMeta.$attrsToReflect$ = [];
2579
+ }
2580
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2581
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2582
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2583
+ }
2584
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2585
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2586
+ Object.assign(Cstr.prototype, {
2587
+ __registerHost() {
2588
+ registerHost(this, cmpMeta);
2589
+ },
2590
+ connectedCallback() {
2591
+ connectedCallback(this);
2592
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2593
+ originalConnectedCallback.call(this);
2594
+ }
2595
+ },
2596
+ disconnectedCallback() {
2597
+ disconnectedCallback(this);
2598
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2599
+ originalDisconnectedCallback.call(this);
2600
+ }
2601
+ },
2602
+ __attachShadow() {
2603
+ if (supportsShadow) {
2604
+ if (BUILD.shadowDelegatesFocus) {
2605
+ this.attachShadow({
2606
+ mode: 'open',
2607
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2608
+ });
2609
+ }
2610
+ else {
2611
+ this.attachShadow({ mode: 'open' });
2612
+ }
2613
+ }
2614
+ else {
2615
+ this.shadowRoot = this;
2616
+ }
2617
+ },
2618
+ });
2619
+ Cstr.is = cmpMeta.$tagName$;
2620
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2621
+ };
2622
+ const forceModeUpdate = (elm) => {
2623
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2624
+ const mode = computeMode(elm);
2625
+ const hostRef = getHostRef(elm);
2626
+ if (hostRef.$modeName$ !== mode) {
2627
+ const cmpMeta = hostRef.$cmpMeta$;
2628
+ const oldScopeId = elm['s-sc'];
2629
+ const scopeId = getScopeId(cmpMeta, mode);
2630
+ const style = elm.constructor.style[mode];
2631
+ const flags = cmpMeta.$flags$;
2632
+ if (style) {
2633
+ if (!styles.has(scopeId)) {
2634
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2635
+ }
2636
+ hostRef.$modeName$ = mode;
2637
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2638
+ attachStyles(hostRef);
2639
+ forceUpdate(elm);
2640
+ }
2641
+ }
2642
+ }
2643
+ };
2644
+ const patchCloneNode = (HostElementPrototype) => {
2645
+ const orgCloneNode = HostElementPrototype.cloneNode;
2646
+ HostElementPrototype.cloneNode = function (deep) {
2647
+ const srcNode = this;
2648
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2649
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2650
+ if (BUILD.slot && !isShadowDom && deep) {
2651
+ let i = 0;
2652
+ let slotted, nonStencilNode;
2653
+ const stencilPrivates = [
2654
+ 's-id',
2655
+ 's-cr',
2656
+ 's-lr',
2657
+ 's-rc',
2658
+ 's-sc',
2659
+ 's-p',
2660
+ 's-cn',
2661
+ 's-sr',
2662
+ 's-sn',
2663
+ 's-hn',
2664
+ 's-ol',
2665
+ 's-nr',
2666
+ 's-si',
2667
+ ];
2668
+ for (; i < srcNode.childNodes.length; i++) {
2669
+ slotted = srcNode.childNodes[i]['s-nr'];
2670
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2671
+ if (slotted) {
2672
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2673
+ clonedNode.__appendChild(slotted.cloneNode(true));
2674
+ }
2675
+ else {
2676
+ clonedNode.appendChild(slotted.cloneNode(true));
2677
+ }
2678
+ }
2679
+ if (nonStencilNode) {
2680
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2681
+ }
2682
+ }
2683
+ }
2684
+ return clonedNode;
2685
+ };
2686
+ };
2687
+ const patchSlotAppendChild = (HostElementPrototype) => {
2688
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2689
+ HostElementPrototype.appendChild = function (newChild) {
2690
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2691
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2692
+ if (slotNode) {
2693
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2694
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2695
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2696
+ }
2697
+ return this.__appendChild(newChild);
2698
+ };
2699
+ };
2700
+ /**
2701
+ * Patches the text content of an unnamed slotted node inside a scoped component
2702
+ * @param hostElementPrototype the `Element` to be patched
2703
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2704
+ */
2705
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2706
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2707
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2708
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2709
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2710
+ get() {
2711
+ var _a;
2712
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2713
+ // the empty string
2714
+ const slotNode = getHostSlotNode(this.childNodes, '');
2715
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2716
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2717
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2718
+ return slotNode.nextSibling.textContent;
2719
+ }
2720
+ else if (slotNode) {
2721
+ return slotNode.textContent;
2722
+ }
2723
+ else {
2724
+ // fallback to the original implementation
2725
+ return this.__textContent;
2726
+ }
2727
+ },
2728
+ set(value) {
2729
+ var _a;
2730
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2731
+ // the empty string
2732
+ const slotNode = getHostSlotNode(this.childNodes, '');
2733
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2734
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2735
+ // sibling.
2736
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2737
+ slotNode.nextSibling.textContent = value;
2738
+ }
2739
+ else if (slotNode) {
2740
+ slotNode.textContent = value;
2741
+ }
2742
+ else {
2743
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2744
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2745
+ // it there
2746
+ this.__textContent = value;
2747
+ const contentRefElm = this['s-cr'];
2748
+ if (contentRefElm) {
2749
+ this.insertBefore(contentRefElm, this.firstChild);
2750
+ }
2751
+ }
2752
+ },
2753
+ });
2754
+ }
2755
+ };
2756
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2757
+ class FakeNodeList extends Array {
2758
+ item(n) {
2759
+ return this[n];
2760
+ }
2761
+ }
2762
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2763
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2764
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2765
+ Object.defineProperty(elm, 'children', {
2766
+ get() {
2767
+ return this.childNodes.map((n) => n.nodeType === 1);
2768
+ },
2769
+ });
2770
+ Object.defineProperty(elm, 'childElementCount', {
2771
+ get() {
2772
+ return elm.children.length;
2773
+ },
2774
+ });
2775
+ Object.defineProperty(elm, 'childNodes', {
2776
+ get() {
2777
+ const childNodes = childNodesFn.call(this);
2778
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2779
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2780
+ const result = new FakeNodeList();
2781
+ for (let i = 0; i < childNodes.length; i++) {
2782
+ const slot = childNodes[i]['s-nr'];
2783
+ if (slot) {
2784
+ result.push(slot);
2785
+ }
2786
+ }
2787
+ return result;
2788
+ }
2789
+ return FakeNodeList.from(childNodes);
2790
+ },
2791
+ });
2792
+ }
2793
+ };
2794
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2795
+ /**
2796
+ * Recursively searches a series of child nodes for a slot with the provided name.
2797
+ * @param childNodes the nodes to search for a slot with a specific name.
2798
+ * @param slotName the name of the slot to match on.
2799
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2800
+ */
2801
+ const getHostSlotNode = (childNodes, slotName) => {
2802
+ let i = 0;
2803
+ let childNode;
2804
+ for (; i < childNodes.length; i++) {
2805
+ childNode = childNodes[i];
2806
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2807
+ return childNode;
2808
+ }
2809
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2810
+ if (childNode) {
2811
+ return childNode;
2812
+ }
2813
+ }
2814
+ return null;
2815
+ };
2816
+ const getHostSlotChildNodes = (n, slotName) => {
2817
+ const childNodes = [n];
2818
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2819
+ childNodes.push(n);
2820
+ }
2821
+ return childNodes;
2822
+ };
2823
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2824
+ // ¯\_(ツ)_/¯
2825
+ const hostRef = getHostRef(elm);
2826
+ // reset state flags to only have been connected
2827
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2828
+ // TODO
2829
+ // detatch any event listeners that may have been added
2830
+ // because we're not passing an exact event name it'll
2831
+ // remove all of this element's event, which is good
2832
+ // create a callback for when this component finishes hmr
2833
+ elm['s-hmr-load'] = () => {
2834
+ // finished hmr for this element
2835
+ delete elm['s-hmr-load'];
2836
+ };
2837
+ // re-initialize the component
2838
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2839
+ };
2840
+ const bootstrapLazy = (lazyBundles, options = {}) => {
2841
+ var _a;
2842
+ if (BUILD.profile && performance.mark) {
2843
+ performance.mark('st:app:start');
2844
+ }
2845
+ installDevTools();
2846
+ const endBootstrap = createTime('bootstrapLazy');
2847
+ const cmpTags = [];
2848
+ const exclude = options.exclude || [];
2849
+ const customElements = win.customElements;
2850
+ const head = doc.head;
2851
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2852
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2853
+ const deferredConnectedCallbacks = [];
2854
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2855
+ let appLoadFallback;
2856
+ let isBootstrapping = true;
2857
+ let i = 0;
2858
+ Object.assign(plt, options);
2859
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2860
+ if (BUILD.asyncQueue) {
2861
+ if (options.syncQueue) {
2862
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2863
+ }
2864
+ }
2865
+ if (BUILD.hydrateClientSide) {
2866
+ // If the app is already hydrated there is not point to disable the
2867
+ // async queue. This will improve the first input delay
2868
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2869
+ }
2870
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2871
+ for (; i < styles.length; i++) {
2872
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2873
+ }
2874
+ }
2875
+ lazyBundles.map((lazyBundle) => {
2876
+ lazyBundle[1].map((compactMeta) => {
2877
+ const cmpMeta = {
2878
+ $flags$: compactMeta[0],
2879
+ $tagName$: compactMeta[1],
2880
+ $members$: compactMeta[2],
2881
+ $listeners$: compactMeta[3],
2882
+ };
2883
+ if (BUILD.member) {
2884
+ cmpMeta.$members$ = compactMeta[2];
2885
+ }
2886
+ if (BUILD.hostListener) {
2887
+ cmpMeta.$listeners$ = compactMeta[3];
2888
+ }
2889
+ if (BUILD.reflect) {
2890
+ cmpMeta.$attrsToReflect$ = [];
2891
+ }
2892
+ if (BUILD.watchCallback) {
2893
+ cmpMeta.$watchers$ = {};
2894
+ }
2895
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2896
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2897
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2898
+ }
2899
+ const tagName = BUILD.transformTagName && options.transformTagName
2900
+ ? options.transformTagName(cmpMeta.$tagName$)
2901
+ : cmpMeta.$tagName$;
2902
+ const HostElement = class extends HTMLElement {
2903
+ // StencilLazyHost
2904
+ constructor(self) {
2905
+ // @ts-ignore
2906
+ super(self);
2907
+ self = this;
2908
+ registerHost(self, cmpMeta);
2909
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2910
+ // this component is using shadow dom
2911
+ // and this browser supports shadow dom
2912
+ // add the read-only property "shadowRoot" to the host element
2913
+ // adding the shadow root build conditionals to minimize runtime
2914
+ if (supportsShadow) {
2915
+ if (BUILD.shadowDelegatesFocus) {
2916
+ self.attachShadow({
2917
+ mode: 'open',
2918
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2919
+ });
2920
+ }
2921
+ else {
2922
+ self.attachShadow({ mode: 'open' });
2923
+ }
2924
+ }
2925
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2926
+ self.shadowRoot = self;
2927
+ }
2928
+ }
2929
+ if (BUILD.slotChildNodesFix) {
2930
+ patchChildSlotNodes(self, cmpMeta);
2931
+ }
2932
+ }
2933
+ connectedCallback() {
2934
+ if (appLoadFallback) {
2935
+ clearTimeout(appLoadFallback);
2936
+ appLoadFallback = null;
2937
+ }
2938
+ if (isBootstrapping) {
2939
+ // connectedCallback will be processed once all components have been registered
2940
+ deferredConnectedCallbacks.push(this);
2941
+ }
2942
+ else {
2943
+ plt.jmp(() => connectedCallback(this));
2944
+ }
2945
+ }
2946
+ disconnectedCallback() {
2947
+ plt.jmp(() => disconnectedCallback(this));
2948
+ }
2949
+ componentOnReady() {
2950
+ return getHostRef(this).$onReadyPromise$;
2951
+ }
2952
+ };
2953
+ if (BUILD.cloneNodeFix) {
2954
+ patchCloneNode(HostElement.prototype);
2955
+ }
2956
+ if (BUILD.appendChildSlotFix) {
2957
+ patchSlotAppendChild(HostElement.prototype);
2958
+ }
2959
+ if (BUILD.hotModuleReplacement) {
2960
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2961
+ hmrStart(this, cmpMeta, hmrVersionId);
2962
+ };
2963
+ }
2964
+ if (BUILD.scopedSlotTextContentFix) {
2965
+ patchTextContent(HostElement.prototype, cmpMeta);
2966
+ }
2967
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
2968
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2969
+ cmpTags.push(tagName);
2970
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2971
+ }
2972
+ });
2973
+ });
2974
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2975
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2976
+ visibilityStyle.setAttribute('data-styles', '');
2977
+ // Apply CSP nonce to the style tag if it exists
2978
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2979
+ if (nonce != null) {
2980
+ visibilityStyle.setAttribute('nonce', nonce);
2981
+ }
2982
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2983
+ }
2984
+ // Process deferred connectedCallbacks now all components have been registered
2985
+ isBootstrapping = false;
2986
+ if (deferredConnectedCallbacks.length) {
2987
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
2988
+ }
2989
+ else {
2990
+ if (BUILD.profile) {
2991
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2992
+ }
2993
+ else {
2994
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2995
+ }
2996
+ }
2997
+ // Fallback appLoad event
2998
+ endBootstrap();
2999
+ };
3000
+ const getConnect = (_ref, tagName) => {
3001
+ const componentOnReady = () => {
3002
+ let elm = doc.querySelector(tagName);
3003
+ if (!elm) {
3004
+ elm = doc.createElement(tagName);
3005
+ doc.body.appendChild(elm);
3006
+ }
3007
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
3008
+ };
3009
+ const create = (...args) => {
3010
+ return componentOnReady().then((el) => el.create(...args));
3011
+ };
3012
+ return {
3013
+ create,
3014
+ componentOnReady,
3015
+ };
3016
+ };
3017
+ const getContext = (_elm, context) => {
3018
+ if (context in Context) {
3019
+ return Context[context];
3020
+ }
3021
+ else if (context === 'window') {
3022
+ return win;
3023
+ }
3024
+ else if (context === 'document') {
3025
+ return doc;
3026
+ }
3027
+ else if (context === 'isServer' || context === 'isPrerender') {
3028
+ return BUILD.hydrateServerSide ? true : false;
3029
+ }
3030
+ else if (context === 'isClient') {
3031
+ return BUILD.hydrateServerSide ? false : true;
3032
+ }
3033
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
3034
+ return getAssetPath('.');
3035
+ }
3036
+ else if (context === 'queue') {
3037
+ return {
3038
+ write: writeTask,
3039
+ read: readTask,
3040
+ tick: {
3041
+ then(cb) {
3042
+ return nextTick(cb);
3043
+ },
3044
+ },
3045
+ };
3046
+ }
3047
+ return undefined;
3048
+ };
3049
+ const Fragment = (_, children) => children;
3050
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
3051
+ if (BUILD.hostListener && listeners) {
3052
+ // this is called immediately within the element's constructor
3053
+ // initialize our event listeners on the host element
3054
+ // we do this now so that we can listen to events that may
3055
+ // have fired even before the instance is ready
3056
+ if (BUILD.hostListenerTargetParent) {
3057
+ // this component may have event listeners that should be attached to the parent
3058
+ if (attachParentListeners) {
3059
+ // this is being ran from within the connectedCallback
3060
+ // which is important so that we know the host element actually has a parent element
3061
+ // filter out the listeners to only have the ones that ARE being attached to the parent
3062
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
3063
+ }
3064
+ else {
3065
+ // this is being ran from within the component constructor
3066
+ // everything BUT the parent element listeners should be attached at this time
3067
+ // filter out the listeners that are NOT being attached to the parent
3068
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
3069
+ }
3070
+ }
3071
+ listeners.map(([flags, name, method]) => {
3072
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
3073
+ const handler = hostListenerProxy(hostRef, method);
3074
+ const opts = hostListenerOpts(flags);
3075
+ plt.ael(target, name, handler, opts);
3076
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
3077
+ });
3078
+ }
3079
+ };
3080
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
3081
+ try {
3082
+ if (BUILD.lazyLoad) {
3083
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
3084
+ // instance is ready, let's call it's member method for this event
3085
+ hostRef.$lazyInstance$[methodName](ev);
3086
+ }
3087
+ else {
3088
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
3089
+ }
3090
+ }
3091
+ else {
3092
+ hostRef.$hostElement$[methodName](ev);
3093
+ }
3094
+ }
3095
+ catch (e) {
3096
+ consoleError(e);
3097
+ }
3098
+ };
3099
+ const getHostListenerTarget = (elm, flags) => {
3100
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3101
+ return doc;
3102
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3103
+ return win;
3104
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
3105
+ return doc.body;
3106
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
3107
+ return elm.parentElement;
3108
+ return elm;
3109
+ };
3110
+ // prettier-ignore
3111
+ const hostListenerOpts = (flags) => supportsListenerOptions
3112
+ ? ({
3113
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3114
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3115
+ })
3116
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3117
+ /**
3118
+ * Assigns the given value to the nonce property on the runtime platform object.
3119
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
3120
+ * @param nonce The value to be assigned to the platform nonce property.
3121
+ * @returns void
3122
+ */
3123
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
3124
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
3125
+ const insertVdomAnnotations = (doc, staticComponents) => {
3126
+ if (doc != null) {
3127
+ const docData = {
3128
+ hostIds: 0,
3129
+ rootLevelIds: 0,
3130
+ staticComponents: new Set(staticComponents),
3131
+ };
3132
+ const orgLocationNodes = [];
3133
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
3134
+ orgLocationNodes.forEach((orgLocationNode) => {
3135
+ if (orgLocationNode != null) {
3136
+ const nodeRef = orgLocationNode['s-nr'];
3137
+ let hostId = nodeRef['s-host-id'];
3138
+ let nodeId = nodeRef['s-node-id'];
3139
+ let childId = `${hostId}.${nodeId}`;
3140
+ if (hostId == null) {
3141
+ hostId = 0;
3142
+ docData.rootLevelIds++;
3143
+ nodeId = docData.rootLevelIds;
3144
+ childId = `${hostId}.${nodeId}`;
3145
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3146
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
3147
+ }
3148
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
3149
+ if (hostId === 0) {
3150
+ const textContent = nodeRef.nodeValue.trim();
3151
+ if (textContent === '') {
3152
+ // useless whitespace node at the document root
3153
+ orgLocationNode.remove();
3154
+ return;
3155
+ }
3156
+ }
3157
+ const commentBeforeTextNode = doc.createComment(childId);
3158
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3159
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
3160
+ }
3161
+ }
3162
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
3163
+ const orgLocationParentNode = orgLocationNode.parentElement;
3164
+ if (orgLocationParentNode) {
3165
+ if (orgLocationParentNode['s-en'] === '') {
3166
+ // ending with a "." means that the parent element
3167
+ // of this node's original location is a SHADOW dom element
3168
+ // and this node is apart of the root level light dom
3169
+ orgLocationNodeId += `.`;
3170
+ }
3171
+ else if (orgLocationParentNode['s-en'] === 'c') {
3172
+ // ending with a ".c" means that the parent element
3173
+ // of this node's original location is a SCOPED element
3174
+ // and this node is apart of the root level light dom
3175
+ orgLocationNodeId += `.c`;
3176
+ }
3177
+ }
3178
+ orgLocationNode.nodeValue = orgLocationNodeId;
3179
+ }
3180
+ });
3181
+ }
3182
+ };
3183
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3184
+ if (node == null) {
3185
+ return;
3186
+ }
3187
+ if (node['s-nr'] != null) {
3188
+ orgLocationNodes.push(node);
3189
+ }
3190
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3191
+ node.childNodes.forEach((childNode) => {
3192
+ const hostRef = getHostRef(childNode);
3193
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3194
+ const cmpData = {
3195
+ nodeIds: 0,
3196
+ };
3197
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3198
+ }
3199
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3200
+ });
3201
+ }
3202
+ };
3203
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3204
+ if (vnode != null) {
3205
+ const hostId = ++docData.hostIds;
3206
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3207
+ if (hostElm['s-cr'] != null) {
3208
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3209
+ }
3210
+ if (vnode.$children$ != null) {
3211
+ const depth = 0;
3212
+ vnode.$children$.forEach((vnodeChild, index) => {
3213
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3214
+ });
3215
+ }
3216
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
3217
+ const parent = hostElm.parentElement;
3218
+ if (parent && parent.childNodes) {
3219
+ const parentChildNodes = Array.from(parent.childNodes);
3220
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
3221
+ if (comment) {
3222
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3223
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
3224
+ }
3225
+ }
3226
+ }
3227
+ }
3228
+ };
3229
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3230
+ const childElm = vnodeChild.$elm$;
3231
+ if (childElm == null) {
3232
+ return;
3233
+ }
3234
+ const nodeId = cmpData.nodeIds++;
3235
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3236
+ childElm['s-host-id'] = hostId;
3237
+ childElm['s-node-id'] = nodeId;
3238
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3239
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3240
+ }
3241
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
3242
+ const parentNode = childElm.parentNode;
3243
+ const nodeName = parentNode.nodeName;
3244
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
3245
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3246
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3247
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
3248
+ }
3249
+ }
3250
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
3251
+ if (childElm['s-sr']) {
3252
+ const slotName = childElm['s-sn'] || '';
3253
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3254
+ childElm.nodeValue = slotNodeId;
3255
+ }
3256
+ }
3257
+ if (vnodeChild.$children$ != null) {
3258
+ const childDepth = depth + 1;
3259
+ vnodeChild.$children$.forEach((vnode, index) => {
3260
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
3261
+ });
3262
+ }
3263
+ };
3264
+ const hostRefs = /*@__PURE__*/ new WeakMap();
3265
+ const getHostRef = (ref) => hostRefs.get(ref);
3266
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
3267
+ const registerHost = (elm, cmpMeta) => {
3268
+ const hostRef = {
3269
+ $flags$: 0,
3270
+ $hostElement$: elm,
3271
+ $cmpMeta$: cmpMeta,
3272
+ $instanceValues$: new Map(),
3273
+ };
3274
+ if (BUILD.isDev) {
3275
+ hostRef.$renderCount$ = 0;
3276
+ }
3277
+ if (BUILD.method && BUILD.lazyLoad) {
3278
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
3279
+ }
3280
+ if (BUILD.asyncLoading) {
3281
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
3282
+ elm['s-p'] = [];
3283
+ elm['s-rc'] = [];
3284
+ }
3285
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3286
+ return hostRefs.set(elm, hostRef);
3287
+ };
3288
+ const isMemberInElement = (elm, memberName) => memberName in elm;
3289
+ const consoleError = (e, el) => (customError || console.error)(e, el);
3290
+ const STENCIL_DEV_MODE = BUILD.isTesting
3291
+ ? ['STENCIL:'] // E2E testing
3292
+ : [
3293
+ '%cstencil',
3294
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
3295
+ ];
3296
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
3297
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
3298
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
3299
+ const setErrorHandler = (handler) => (customError = handler);
3300
+ const cmpModules = /*@__PURE__*/ new Map();
3301
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
3302
+ // loadModuleImport
3303
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
3304
+ const bundleId = cmpMeta.$lazyBundleId$;
3305
+ if (BUILD.isDev && typeof bundleId !== 'string') {
3306
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
3307
+ return undefined;
3308
+ }
3309
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
3310
+ if (module) {
3311
+ return module[exportName];
3312
+ }
3313
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
3314
+ return import(
3315
+ /* @vite-ignore */
3316
+ /* webpackInclude: /\.entry\.js$/ */
3317
+ /* webpackExclude: /\.system\.entry\.js$/ */
3318
+ /* webpackMode: "lazy" */
3319
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`).then((importedModule) => {
3320
+ if (!BUILD.hotModuleReplacement) {
3321
+ cmpModules.set(bundleId, importedModule);
3322
+ }
3323
+ return importedModule[exportName];
3324
+ }, consoleError);
3325
+ };
3326
+ const styles = /*@__PURE__*/ new Map();
3327
+ const modeResolutionChain = [];
3328
+ const win = typeof window !== 'undefined' ? window : {};
3329
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
3330
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
3331
+ const doc = win.document || { head: {} };
3332
+ const H = (win.HTMLElement || class {
3333
+ });
3334
+ const plt = {
3335
+ $flags$: 0,
3336
+ $resourcesUrl$: '',
3337
+ jmp: (h) => h(),
3338
+ raf: (h) => requestAnimationFrame(h),
3339
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3340
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3341
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
3342
+ };
3343
+ const setPlatformHelpers = (helpers) => {
3344
+ Object.assign(plt, helpers);
3345
+ };
3346
+ const supportsShadow =
3347
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
3348
+ BUILD.shadowDomShim && BUILD.shadowDom
3349
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3350
+ : true;
3351
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3352
+ let supportsListenerOptions = false;
3353
+ try {
3354
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3355
+ get() {
3356
+ supportsListenerOptions = true;
3357
+ },
3358
+ }));
3359
+ }
3360
+ catch (e) { }
3361
+ return supportsListenerOptions;
3362
+ })();
3363
+ const promiseResolve = (v) => Promise.resolve(v);
3364
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3365
+ ? /*@__PURE__*/ (() => {
3366
+ try {
3367
+ new CSSStyleSheet();
3368
+ return typeof new CSSStyleSheet().replaceSync === 'function';
3369
+ }
3370
+ catch (e) { }
3371
+ return false;
3372
+ })()
3373
+ : false;
3374
+ const queueDomReads = [];
3375
+ const queueDomWrites = [];
3376
+ const queueDomWritesLow = [];
3377
+ const queueTask = (queue, write) => (cb) => {
3378
+ queue.push(cb);
3379
+ if (!queuePending) {
3380
+ queuePending = true;
3381
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
3382
+ nextTick(flush);
3383
+ }
3384
+ else {
3385
+ plt.raf(flush);
3386
+ }
3387
+ }
3388
+ };
3389
+ const consume = (queue) => {
3390
+ for (let i = 0; i < queue.length; i++) {
3391
+ try {
3392
+ queue[i](performance.now());
3393
+ }
3394
+ catch (e) {
3395
+ consoleError(e);
3396
+ }
3397
+ }
3398
+ queue.length = 0;
3399
+ };
3400
+ const consumeTimeout = (queue, timeout) => {
3401
+ let i = 0;
3402
+ let ts = 0;
3403
+ while (i < queue.length && (ts = performance.now()) < timeout) {
3404
+ try {
3405
+ queue[i++](ts);
3406
+ }
3407
+ catch (e) {
3408
+ consoleError(e);
3409
+ }
3410
+ }
3411
+ if (i === queue.length) {
3412
+ queue.length = 0;
3413
+ }
3414
+ else if (i !== 0) {
3415
+ queue.splice(0, i);
3416
+ }
3417
+ };
3418
+ const flush = () => {
3419
+ if (BUILD.asyncQueue) {
3420
+ queueCongestion++;
3421
+ }
3422
+ // always force a bunch of medium callbacks to run, but still have
3423
+ // a throttle on how many can run in a certain time
3424
+ // DOM READS!!!
3425
+ consume(queueDomReads);
3426
+ // DOM WRITES!!!
3427
+ if (BUILD.asyncQueue) {
3428
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3429
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3430
+ : Infinity;
3431
+ consumeTimeout(queueDomWrites, timeout);
3432
+ consumeTimeout(queueDomWritesLow, timeout);
3433
+ if (queueDomWrites.length > 0) {
3434
+ queueDomWritesLow.push(...queueDomWrites);
3435
+ queueDomWrites.length = 0;
3436
+ }
3437
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3438
+ // still more to do yet, but we've run out of time
3439
+ // let's let this thing cool off and try again in the next tick
3440
+ plt.raf(flush);
3441
+ }
3442
+ else {
3443
+ queueCongestion = 0;
3444
+ }
3445
+ }
3446
+ else {
3447
+ consume(queueDomWrites);
3448
+ if ((queuePending = queueDomReads.length > 0)) {
3449
+ // still more to do yet, but we've run out of time
3450
+ // let's let this thing cool off and try again in the next tick
3451
+ plt.raf(flush);
3452
+ }
3453
+ }
3454
+ };
3455
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3456
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3457
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3458
+
3459
+ export { BUILD as B, CSS as C, Fragment as F, H, NAMESPACE as N, promiseResolve as a, bootstrapLazy as b, consoleDevInfo as c, doc as d, getAssetPath as e, forceUpdate as f, getRenderingRef as g, h, getElement as i, plt as p, registerInstance as r, setNonce as s, win as w };
3460
+
3461
+ //# sourceMappingURL=index-2ce8b901.js.map