hemfixarna-web-components 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/dist/{collection/utils/api.js → hemfixarna-components/api-36f73d0d.js} +6 -4
  2. package/dist/hemfixarna-components/api-36f73d0d.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-4c79b798.js} +6 -3
  6. package/dist/hemfixarna-components/calc-4c79b798.js.map +1 -0
  7. package/dist/hemfixarna-components/css-shim-62d2171c.js +6 -0
  8. package/dist/hemfixarna-components/css-shim-62d2171c.js.map +1 -0
  9. package/dist/hemfixarna-components/dom-46a68c9b.js +75 -0
  10. package/dist/hemfixarna-components/dom-46a68c9b.js.map +1 -0
  11. package/dist/{collection/utils/form.js → hemfixarna-components/form-c53dca29.js} +4 -2
  12. package/dist/hemfixarna-components/form-c53dca29.js.map +1 -0
  13. package/dist/{collection/components/hemfixarna-address/hemfixarna-address.js → hemfixarna-components/hemfixarna-address.entry.js} +14 -20
  14. package/dist/hemfixarna-components/hemfixarna-address.entry.js.map +1 -0
  15. package/dist/hemfixarna-components/hemfixarna-box.entry.js +49 -0
  16. package/dist/hemfixarna-components/hemfixarna-box.entry.js.map +1 -0
  17. package/dist/{collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js → hemfixarna-components/hemfixarna-breadcrumbs.entry.js} +13 -84
  18. package/dist/hemfixarna-components/hemfixarna-breadcrumbs.entry.js.map +1 -0
  19. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js +27 -0
  20. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js.map +1 -0
  21. package/dist/{collection/components/hemfixarna-cart/hemfixarna-cart.js → hemfixarna-components/hemfixarna-cart.entry.js} +11 -31
  22. package/dist/hemfixarna-components/hemfixarna-cart.entry.js.map +1 -0
  23. package/dist/{collection/components/hemfixarna-category.tsx/hemfixarna-category.js → hemfixarna-components/hemfixarna-category.entry.js} +12 -6
  24. package/dist/hemfixarna-components/hemfixarna-category.entry.js.map +1 -0
  25. package/dist/{collection/components/hemfixarna-checkout/hemfixarna-checkout.js → hemfixarna-components/hemfixarna-checkout.entry.js} +38 -33
  26. package/dist/hemfixarna-components/hemfixarna-checkout.entry.js.map +1 -0
  27. package/dist/hemfixarna-components/hemfixarna-component.entry.js +248 -0
  28. package/dist/hemfixarna-components/hemfixarna-component.entry.js.map +1 -0
  29. package/dist/hemfixarna-components/hemfixarna-components.esm.js +162 -1
  30. package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
  31. package/dist/{collection/components/hemfixarna-contact/hemfixarna-contact.js → hemfixarna-components/hemfixarna-contact.entry.js} +10 -28
  32. package/dist/hemfixarna-components/hemfixarna-contact.entry.js.map +1 -0
  33. package/dist/{collection/components/hemfixarna-demo/hemfixarna-demo.js → hemfixarna-components/hemfixarna-demo.entry.js} +23 -46
  34. package/dist/hemfixarna-components/hemfixarna-demo.entry.js.map +1 -0
  35. package/dist/hemfixarna-components/hemfixarna-doro.entry.js +23 -0
  36. package/dist/hemfixarna-components/hemfixarna-doro.entry.js.map +1 -0
  37. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js +24 -0
  38. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js.map +1 -0
  39. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js +21 -0
  40. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js.map +1 -0
  41. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js +21 -0
  42. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js.map +1 -0
  43. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js +23 -0
  44. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js.map +1 -0
  45. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js +770 -0
  46. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js.map +1 -0
  47. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js +24 -0
  48. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js.map +1 -0
  49. package/dist/{collection/components/hemfixarna-info/hemfixarna-info.js → hemfixarna-components/hemfixarna-info.entry.js} +11 -7
  50. package/dist/hemfixarna-components/hemfixarna-info.entry.js.map +1 -0
  51. package/dist/{collection/components/hemfixarna-invoice/hemfixarna-invoice.js → hemfixarna-components/hemfixarna-invoice.entry.js} +16 -27
  52. package/dist/hemfixarna-components/hemfixarna-invoice.entry.js.map +1 -0
  53. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js +21 -0
  54. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js.map +1 -0
  55. package/dist/hemfixarna-components/hemfixarna-klint.entry.js +20 -0
  56. package/dist/hemfixarna-components/hemfixarna-klint.entry.js.map +1 -0
  57. package/dist/hemfixarna-components/hemfixarna-kund.entry.js +20 -0
  58. package/dist/hemfixarna-components/hemfixarna-kund.entry.js.map +1 -0
  59. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js +21 -0
  60. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js.map +1 -0
  61. package/dist/{collection/components/hemfixarna-order/hemfixarna-order.js → hemfixarna-components/hemfixarna-order.entry.js} +11 -31
  62. package/dist/hemfixarna-components/hemfixarna-order.entry.js.map +1 -0
  63. package/dist/{collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js → hemfixarna-components/hemfixarna-orderrows.entry.js} +12 -50
  64. package/dist/hemfixarna-components/hemfixarna-orderrows.entry.js.map +1 -0
  65. package/dist/hemfixarna-components/hemfixarna-power.entry.js +21 -0
  66. package/dist/hemfixarna-components/hemfixarna-power.entry.js.map +1 -0
  67. package/dist/{collection/components/hemfixarna-product/hemfixarna-product.js → hemfixarna-components/hemfixarna-product.entry.js} +18 -27
  68. package/dist/hemfixarna-components/hemfixarna-product.entry.js.map +1 -0
  69. package/dist/{collection/components/hemfixarna-service/hemfixarna-service.js → hemfixarna-components/hemfixarna-service.entry.js} +12 -6
  70. package/dist/hemfixarna-components/hemfixarna-service.entry.js.map +1 -0
  71. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js +24 -0
  72. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js.map +1 -0
  73. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js +21 -0
  74. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js.map +1 -0
  75. package/dist/{collection/components/hemfixarna-start/hemfixarna-start.js → hemfixarna-components/hemfixarna-start.entry.js} +11 -48
  76. package/dist/hemfixarna-components/hemfixarna-start.entry.js.map +1 -0
  77. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js +23 -0
  78. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js.map +1 -0
  79. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js +20 -0
  80. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js.map +1 -0
  81. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js +21 -0
  82. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js.map +1 -0
  83. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js +20 -0
  84. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js.map +1 -0
  85. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js +21 -0
  86. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js.map +1 -0
  87. package/dist/hemfixarna-components/index-b6a6e994.js +256 -0
  88. package/dist/hemfixarna-components/index-b6a6e994.js.map +1 -0
  89. package/dist/{collection/types/index.js → hemfixarna-components/index-d90ad11b.js} +7 -4
  90. package/dist/hemfixarna-components/index-d90ad11b.js.map +1 -0
  91. package/dist/hemfixarna-components/index-f1a87cf1.js +3397 -0
  92. package/dist/{cjs/hemfixarna-address_36.cjs.entry.js.map → hemfixarna-components/index-f1a87cf1.js.map} +1 -1
  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-05e0c1f4.js +389 -0
  98. package/dist/hemfixarna-components/shadow-css-05e0c1f4.js.map +1 -0
  99. package/dist/{collection/utils/types.js → hemfixarna-components/types-641c9a1c.js} +6 -3
  100. package/dist/hemfixarna-components/types-641c9a1c.js.map +1 -0
  101. package/package.json +1 -1
  102. package/dist/cjs/hemfixarna-address_36.cjs.entry.js +0 -2763
  103. package/dist/cjs/hemfixarna-components.cjs.js +0 -28
  104. package/dist/cjs/hemfixarna-components.cjs.js.map +0 -1
  105. package/dist/cjs/index-b83343b9.js +0 -1687
  106. package/dist/cjs/index-b83343b9.js.map +0 -1
  107. package/dist/cjs/index.cjs.js +0 -4
  108. package/dist/cjs/index.cjs.js.map +0 -1
  109. package/dist/cjs/loader.cjs.js +0 -24
  110. package/dist/cjs/loader.cjs.js.map +0 -1
  111. package/dist/collection/assets/back.svg +0 -3
  112. package/dist/collection/assets/cart.svg +0 -10
  113. package/dist/collection/assets/checked.svg +0 -10
  114. package/dist/collection/assets/close.svg +0 -5
  115. package/dist/collection/assets/copy.png +0 -0
  116. package/dist/collection/assets/date.svg +0 -6
  117. package/dist/collection/assets/down.svg +0 -3
  118. package/dist/collection/assets/drag-drop.svg +0 -3
  119. package/dist/collection/assets/elfa.png +0 -0
  120. package/dist/collection/assets/gubbe-pensel.svg +0 -1
  121. package/dist/collection/assets/hemfixarna.svg +0 -11
  122. package/dist/collection/assets/hornbach/logo.svg +0 -42
  123. package/dist/collection/assets/hornbach/nav.jpg +0 -0
  124. package/dist/collection/assets/info.svg +0 -5
  125. package/dist/collection/assets/kbygg.svg +0 -29
  126. package/dist/collection/assets/minus.svg +0 -4
  127. package/dist/collection/assets/montering.svg +0 -15
  128. package/dist/collection/assets/norrgavel.svg +0 -1
  129. package/dist/collection/assets/pensel.svg +0 -1
  130. package/dist/collection/assets/plus.svg +0 -5
  131. package/dist/collection/assets/spinner.gif +0 -0
  132. package/dist/collection/assets/tesla.svg +0 -1
  133. package/dist/collection/assets/zaptec.svg +0 -1
  134. package/dist/collection/collection-manifest.json +0 -47
  135. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.css +0 -0
  136. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js +0 -184
  137. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js.map +0 -1
  138. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.css +0 -0
  139. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js +0 -123
  140. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js.map +0 -1
  141. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.css +0 -0
  142. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js +0 -142
  143. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js.map +0 -1
  144. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js +0 -132
  145. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js.map +0 -1
  146. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js +0 -132
  147. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js.map +0 -1
  148. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.css +0 -0
  149. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js +0 -123
  150. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js.map +0 -1
  151. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.css +0 -0
  152. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js +0 -142
  153. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js.map +0 -1
  154. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js +0 -132
  155. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js.map +0 -1
  156. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js +0 -113
  157. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js.map +0 -1
  158. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js +0 -113
  159. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js.map +0 -1
  160. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js +0 -132
  161. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js.map +0 -1
  162. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js +0 -131
  163. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js.map +0 -1
  164. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.css +0 -0
  165. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js +0 -141
  166. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js.map +0 -1
  167. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js +0 -131
  168. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js.map +0 -1
  169. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js +0 -123
  170. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js.map +0 -1
  171. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string.css +0 -0
  172. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js +0 -113
  173. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js.map +0 -1
  174. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js +0 -132
  175. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js.map +0 -1
  176. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js +0 -113
  177. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js.map +0 -1
  178. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js +0 -132
  179. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js.map +0 -1
  180. package/dist/collection/components/hemfixarna-address/hemfixarna-address.js.map +0 -1
  181. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js +0 -138
  182. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js.map +0 -1
  183. package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +0 -1
  184. package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +0 -1
  185. package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js.map +0 -1
  186. package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js.map +0 -1
  187. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +0 -483
  188. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +0 -1
  189. package/dist/collection/components/hemfixarna-component/hemfixarna.css +0 -1031
  190. package/dist/collection/components/hemfixarna-contact/hemfixarna-contact.js.map +0 -1
  191. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.css +0 -135
  192. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +0 -1
  193. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js +0 -91
  194. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js.map +0 -1
  195. package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +0 -1
  196. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.css +0 -76
  197. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js.map +0 -1
  198. package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +0 -1
  199. package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +0 -1
  200. package/dist/collection/components/hemfixarna-product/hemfixarna-product.css +0 -0
  201. package/dist/collection/components/hemfixarna-product/hemfixarna-product.js.map +0 -1
  202. package/dist/collection/components/hemfixarna-service/hemfixarna-service.js.map +0 -1
  203. package/dist/collection/components/hemfixarna-start/hemfixarna-start.js.map +0 -1
  204. package/dist/collection/index.js +0 -2
  205. package/dist/collection/index.js.map +0 -1
  206. package/dist/collection/store/index.js +0 -62
  207. package/dist/collection/store/index.js.map +0 -1
  208. package/dist/collection/types/felixtypes.js +0 -3
  209. package/dist/collection/types/felixtypes.js.map +0 -1
  210. package/dist/collection/types/index.js.map +0 -1
  211. package/dist/collection/utils/api.js.map +0 -1
  212. package/dist/collection/utils/calc.js.map +0 -1
  213. package/dist/collection/utils/creditSafe.js +0 -18
  214. package/dist/collection/utils/creditSafe.js.map +0 -1
  215. package/dist/collection/utils/felixApi.js +0 -18
  216. package/dist/collection/utils/felixApi.js.map +0 -1
  217. package/dist/collection/utils/felixFunctions.js +0 -189
  218. package/dist/collection/utils/felixFunctions.js.map +0 -1
  219. package/dist/collection/utils/form.js.map +0 -1
  220. package/dist/collection/utils/scroll.js.map +0 -1
  221. package/dist/collection/utils/types.js.map +0 -1
  222. package/dist/esm/hemfixarna-address_36.entry.js +0 -2724
  223. package/dist/esm/hemfixarna-address_36.entry.js.map +0 -1
  224. package/dist/esm/hemfixarna-components.js +0 -23
  225. package/dist/esm/hemfixarna-components.js.map +0 -1
  226. package/dist/esm/index-8c417125.js +0 -1656
  227. package/dist/esm/index-8c417125.js.map +0 -1
  228. package/dist/esm/index.js +0 -3
  229. package/dist/esm/index.js.map +0 -1
  230. package/dist/esm/loader.js +0 -20
  231. package/dist/esm/loader.js.map +0 -1
  232. package/dist/esm/polyfills/core-js.js +0 -11
  233. package/dist/esm/polyfills/css-shim.js +0 -1
  234. package/dist/esm/polyfills/dom.js +0 -79
  235. package/dist/esm/polyfills/es5-html-element.js +0 -1
  236. package/dist/esm/polyfills/index.js +0 -34
  237. package/dist/esm/polyfills/system.js +0 -6
  238. package/dist/hemfixarna-components/p-211cfa04.entry.js +0 -2
  239. package/dist/hemfixarna-components/p-211cfa04.entry.js.map +0 -1
  240. package/dist/hemfixarna-components/p-852e7173.js +0 -3
  241. package/dist/hemfixarna-components/p-852e7173.js.map +0 -1
  242. package/dist/index.cjs.js +0 -1
  243. package/dist/index.js +0 -1
@@ -0,0 +1,3397 @@
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
+ * @param vnode a VNode
1110
+ * @param elm an element
1111
+ */
1112
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
1113
+ for (; startIdx <= endIdx; ++startIdx) {
1114
+ if ((vnode = vnodes[startIdx])) {
1115
+ elm = vnode.$elm$;
1116
+ callNodeRefs(vnode);
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
+ * Reconcile the children of a new VNode with the children of an old VNode by
1138
+ * traversing the two collections of children, identifying nodes that are
1139
+ * conserved or changed, calling out to `patch` to make any necessary
1140
+ * updates to the DOM, and rearranging DOM nodes as needed.
1141
+ *
1142
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
1143
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1144
+ * 'windows' by storing start and end indices and references to the
1145
+ * corresponding array entries. Initially the two 'windows' are basically equal
1146
+ * to the entire array, but we progressively narrow the windows until there are
1147
+ * no children left to update by doing the following:
1148
+ *
1149
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1150
+ * that if we have an initial array like the following we'll end up dealing
1151
+ * only with a window bounded by the highlighted elements:
1152
+ *
1153
+ * [null, null, VNode1 , ... , VNode2, null, null]
1154
+ * ^^^^^^ ^^^^^^
1155
+ *
1156
+ * 2. Check to see if the elements at the head and tail positions are equal
1157
+ * across the windows. This will basically detect elements which haven't
1158
+ * been added, removed, or changed position, i.e. if you had the following
1159
+ * VNode elements (represented as HTML):
1160
+ *
1161
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
1162
+ * newVNode: `<div><p><span>THERE</span></p></div>`
1163
+ *
1164
+ * Then when comparing the children of the `<div>` tag we check the equality
1165
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
1166
+ * same tag in the same position, we'd be able to avoid completely
1167
+ * re-rendering the subtree under them with a new DOM element and would just
1168
+ * call out to `patch` to handle reconciling their children and so on.
1169
+ *
1170
+ * 3. Check, for both windows, to see if the element at the beginning of the
1171
+ * window corresponds to the element at the end of the other window. This is
1172
+ * a heuristic which will let us identify _some_ situations in which
1173
+ * elements have changed position, for instance it _should_ detect that the
1174
+ * children nodes themselves have not changed but merely moved in the
1175
+ * following example:
1176
+ *
1177
+ * oldVNode: `<div><element-one /><element-two /></div>`
1178
+ * newVNode: `<div><element-two /><element-one /></div>`
1179
+ *
1180
+ * If we find cases like this then we also need to move the concrete DOM
1181
+ * elements corresponding to the moved children to write the re-order to the
1182
+ * DOM.
1183
+ *
1184
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1185
+ * nodes in the old children which have the same key as the first element in
1186
+ * our window on the new children. If we find such a node we handle calling
1187
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1188
+ * what we find.
1189
+ *
1190
+ * Finally, once we've narrowed our 'windows' to the point that either of them
1191
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
1192
+ * insertion or deletion that needs to happen to get a DOM state that correctly
1193
+ * reflects the new child VNodes. If, for instance, after our window on the old
1194
+ * children has collapsed we still have more nodes on the new children that
1195
+ * we haven't dealt with yet then we need to add them, or if the new children
1196
+ * collapse but we still have unhandled _old_ children then we need to make
1197
+ * sure the corresponding DOM nodes are removed.
1198
+ *
1199
+ * @param parentElm the node into which the parent VNode is rendered
1200
+ * @param oldCh the old children of the parent node
1201
+ * @param newVNode the new VNode which will replace the parent
1202
+ * @param newCh the new children of the parent node
1203
+ */
1204
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
1205
+ let oldStartIdx = 0;
1206
+ let newStartIdx = 0;
1207
+ let idxInOld = 0;
1208
+ let i = 0;
1209
+ let oldEndIdx = oldCh.length - 1;
1210
+ let oldStartVnode = oldCh[0];
1211
+ let oldEndVnode = oldCh[oldEndIdx];
1212
+ let newEndIdx = newCh.length - 1;
1213
+ let newStartVnode = newCh[0];
1214
+ let newEndVnode = newCh[newEndIdx];
1215
+ let node;
1216
+ let elmToMove;
1217
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1218
+ if (oldStartVnode == null) {
1219
+ // VNode might have been moved left
1220
+ oldStartVnode = oldCh[++oldStartIdx];
1221
+ }
1222
+ else if (oldEndVnode == null) {
1223
+ oldEndVnode = oldCh[--oldEndIdx];
1224
+ }
1225
+ else if (newStartVnode == null) {
1226
+ newStartVnode = newCh[++newStartIdx];
1227
+ }
1228
+ else if (newEndVnode == null) {
1229
+ newEndVnode = newCh[--newEndIdx];
1230
+ }
1231
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
1232
+ // if the start nodes are the same then we should patch the new VNode
1233
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1234
+ // indices to reflect that. We don't need to move any DOM Nodes around
1235
+ // since things are matched up in order.
1236
+ patch(oldStartVnode, newStartVnode);
1237
+ oldStartVnode = oldCh[++oldStartIdx];
1238
+ newStartVnode = newCh[++newStartIdx];
1239
+ }
1240
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
1241
+ // likewise, if the end nodes are the same we patch new onto old and
1242
+ // decrement our end indices, and also likewise in this case we don't
1243
+ // need to move any DOM Nodes.
1244
+ patch(oldEndVnode, newEndVnode);
1245
+ oldEndVnode = oldCh[--oldEndIdx];
1246
+ newEndVnode = newCh[--newEndIdx];
1247
+ }
1248
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
1249
+ // case: "Vnode moved right"
1250
+ //
1251
+ // We've found that the last node in our window on the new children is
1252
+ // the same VNode as the _first_ node in our window on the old children
1253
+ // we're dealing with now. Visually, this is the layout of these two
1254
+ // nodes:
1255
+ //
1256
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1257
+ // ^^^^^^^^^^^
1258
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1259
+ // ^^^^^^^^^^^^^
1260
+ //
1261
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1262
+ // and move the DOM element for `oldStartVnode`.
1263
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1264
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1265
+ }
1266
+ patch(oldStartVnode, newEndVnode);
1267
+ // We need to move the element for `oldStartVnode` into a position which
1268
+ // will be appropriate for `newEndVnode`. For this we can use
1269
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1270
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1271
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1272
+ //
1273
+ // <old-start-node />
1274
+ // <some-intervening-node />
1275
+ // <old-end-node />
1276
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1277
+ // <next-sibling />
1278
+ //
1279
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1280
+ // the node for `oldStartVnode` at the end of the children of
1281
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1282
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
1283
+ // append it to the children of the parent element.
1284
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1285
+ oldStartVnode = oldCh[++oldStartIdx];
1286
+ newEndVnode = newCh[--newEndIdx];
1287
+ }
1288
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
1289
+ // case: "Vnode moved left"
1290
+ //
1291
+ // We've found that the first node in our window on the new children is
1292
+ // the same VNode as the _last_ node in our window on the old children.
1293
+ // Visually, this is the layout of these two nodes:
1294
+ //
1295
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1296
+ // ^^^^^^^^^^^^^
1297
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1298
+ // ^^^^^^^^^^^
1299
+ //
1300
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1301
+ // (which will handle updating any changed attributes, reconciling their
1302
+ // children etc) but we also need to move the DOM node to which
1303
+ // `oldEndVnode` corresponds.
1304
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1305
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1306
+ }
1307
+ patch(oldEndVnode, newStartVnode);
1308
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
1309
+ // the same node, so since we're here we know that they are not. Thus we
1310
+ // can move the element for `oldEndVnode` _before_ the element for
1311
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1312
+ // future.
1313
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1314
+ oldEndVnode = oldCh[--oldEndIdx];
1315
+ newStartVnode = newCh[++newStartIdx];
1316
+ }
1317
+ else {
1318
+ // Here we do some checks to match up old and new nodes based on the
1319
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1320
+ // in the JSX for a DOM element in the implementation of a Stencil
1321
+ // component.
1322
+ //
1323
+ // First we check to see if there are any nodes in the array of old
1324
+ // children which have the same key as the first node in the new
1325
+ // children.
1326
+ idxInOld = -1;
1327
+ if (BUILD.vdomKey) {
1328
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1329
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1330
+ idxInOld = i;
1331
+ break;
1332
+ }
1333
+ }
1334
+ }
1335
+ if (BUILD.vdomKey && idxInOld >= 0) {
1336
+ // We found a node in the old children which matches up with the first
1337
+ // node in the new children! So let's deal with that
1338
+ elmToMove = oldCh[idxInOld];
1339
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1340
+ // the tag doesn't match so we'll need a new DOM element
1341
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1342
+ }
1343
+ else {
1344
+ patch(elmToMove, newStartVnode);
1345
+ // invalidate the matching old node so that we won't try to update it
1346
+ // again later on
1347
+ oldCh[idxInOld] = undefined;
1348
+ node = elmToMove.$elm$;
1349
+ }
1350
+ newStartVnode = newCh[++newStartIdx];
1351
+ }
1352
+ else {
1353
+ // We either didn't find an element in the old children that matches
1354
+ // the key of the first new child OR the build is not using `key`
1355
+ // attributes at all. In either case we need to create a new element
1356
+ // for the new node.
1357
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1358
+ newStartVnode = newCh[++newStartIdx];
1359
+ }
1360
+ if (node) {
1361
+ // if we created a new node then handle inserting it to the DOM
1362
+ if (BUILD.slotRelocation) {
1363
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1364
+ }
1365
+ else {
1366
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1367
+ }
1368
+ }
1369
+ }
1370
+ }
1371
+ if (oldStartIdx > oldEndIdx) {
1372
+ // we have some more new nodes to add which don't match up with old nodes
1373
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1374
+ }
1375
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
1376
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
1377
+ // in the new array, so lets remove them (which entails cleaning up the
1378
+ // relevant DOM nodes)
1379
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1380
+ }
1381
+ };
1382
+ /**
1383
+ * Compare two VNodes to determine if they are the same
1384
+ *
1385
+ * **NB**: This function is an equality _heuristic_ based on the available
1386
+ * information set on the two VNodes and can be misleading under certain
1387
+ * circumstances. In particular, if the two nodes do not have `key` attrs
1388
+ * (available under `$key$` on VNodes) then the function falls back on merely
1389
+ * checking that they have the same tag.
1390
+ *
1391
+ * So, in other words, if `key` attrs are not set on VNodes which may be
1392
+ * changing order within a `children` array or something along those lines then
1393
+ * we could obtain a false negative and then have to do needless re-rendering
1394
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1395
+ *
1396
+ * @param leftVNode the first VNode to check
1397
+ * @param rightVNode the second VNode to check
1398
+ * @returns whether they're equal or not
1399
+ */
1400
+ const isSameVnode = (leftVNode, rightVNode) => {
1401
+ // compare if two vnode to see if they're "technically" the same
1402
+ // need to have the same element tag, and same key to be the same
1403
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1404
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1405
+ return leftVNode.$name$ === rightVNode.$name$;
1406
+ }
1407
+ // this will be set if components in the build have `key` attrs set on them
1408
+ if (BUILD.vdomKey) {
1409
+ return leftVNode.$key$ === rightVNode.$key$;
1410
+ }
1411
+ return true;
1412
+ }
1413
+ return false;
1414
+ };
1415
+ const referenceNode = (node) => {
1416
+ // this node was relocated to a new location in the dom
1417
+ // because of some other component's slot
1418
+ // but we still have an html comment in place of where
1419
+ // it's original location was according to it's original vdom
1420
+ return (node && node['s-ol']) || node;
1421
+ };
1422
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1423
+ /**
1424
+ * Handle reconciling an outdated VNode with a new one which corresponds to
1425
+ * it. This function handles flushing updates to the DOM and reconciling the
1426
+ * children of the two nodes (if any).
1427
+ *
1428
+ * @param oldVNode an old VNode whose DOM element and children we want to update
1429
+ * @param newVNode a new VNode representing an updated version of the old one
1430
+ */
1431
+ const patch = (oldVNode, newVNode) => {
1432
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
1433
+ const oldChildren = oldVNode.$children$;
1434
+ const newChildren = newVNode.$children$;
1435
+ const tag = newVNode.$tag$;
1436
+ const text = newVNode.$text$;
1437
+ let defaultHolder;
1438
+ if (!BUILD.vdomText || text === null) {
1439
+ if (BUILD.svg) {
1440
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1441
+ // only add this to the when the compiler sees we're using an svg somewhere
1442
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1443
+ }
1444
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1445
+ if (BUILD.slot && tag === 'slot')
1446
+ ;
1447
+ else {
1448
+ // either this is the first render of an element OR it's an update
1449
+ // AND we already know it's possible it could have changed
1450
+ // this updates the element's css classes, attrs, props, listeners, etc.
1451
+ updateElement(oldVNode, newVNode, isSvgMode);
1452
+ }
1453
+ }
1454
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1455
+ // looks like there's child vnodes for both the old and new vnodes
1456
+ // so we need to call `updateChildren` to reconcile them
1457
+ updateChildren(elm, oldChildren, newVNode, newChildren);
1458
+ }
1459
+ else if (newChildren !== null) {
1460
+ // no old child vnodes, but there are new child vnodes to add
1461
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1462
+ // the old vnode was text, so be sure to clear it out
1463
+ elm.textContent = '';
1464
+ }
1465
+ // add the new vnode children
1466
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1467
+ }
1468
+ else if (BUILD.updatable && oldChildren !== null) {
1469
+ // no new child vnodes, but there are old child vnodes to remove
1470
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1471
+ }
1472
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1473
+ isSvgMode = false;
1474
+ }
1475
+ }
1476
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1477
+ // this element has slotted content
1478
+ defaultHolder.parentNode.textContent = text;
1479
+ }
1480
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1481
+ // update the text content for the text only vnode
1482
+ // and also only if the text is different than before
1483
+ elm.data = text;
1484
+ }
1485
+ };
1486
+ const updateFallbackSlotVisibility = (elm) => {
1487
+ // tslint:disable-next-line: prefer-const
1488
+ const childNodes = elm.childNodes;
1489
+ let childNode;
1490
+ let i;
1491
+ let ilen;
1492
+ let j;
1493
+ let slotNameAttr;
1494
+ let nodeType;
1495
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1496
+ childNode = childNodes[i];
1497
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1498
+ if (childNode['s-sr']) {
1499
+ // this is a slot fallback node
1500
+ // get the slot name for this slot reference node
1501
+ slotNameAttr = childNode['s-sn'];
1502
+ // by default always show a fallback slot node
1503
+ // then hide it if there are other slots in the light dom
1504
+ childNode.hidden = false;
1505
+ for (j = 0; j < ilen; j++) {
1506
+ nodeType = childNodes[j].nodeType;
1507
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1508
+ // this sibling node is from a different component OR is a named fallback slot node
1509
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1510
+ childNode.hidden = true;
1511
+ break;
1512
+ }
1513
+ }
1514
+ else {
1515
+ // this is a default fallback slot node
1516
+ // any element or text node (with content)
1517
+ // should hide the default fallback slot node
1518
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1519
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
1520
+ childNode.hidden = true;
1521
+ break;
1522
+ }
1523
+ }
1524
+ }
1525
+ }
1526
+ // keep drilling down
1527
+ updateFallbackSlotVisibility(childNode);
1528
+ }
1529
+ }
1530
+ };
1531
+ const relocateNodes = [];
1532
+ const relocateSlotContent = (elm) => {
1533
+ // tslint:disable-next-line: prefer-const
1534
+ let childNode;
1535
+ let node;
1536
+ let hostContentNodes;
1537
+ let slotNameAttr;
1538
+ let relocateNodeData;
1539
+ let j;
1540
+ let i = 0;
1541
+ const childNodes = elm.childNodes;
1542
+ const ilen = childNodes.length;
1543
+ for (; i < ilen; i++) {
1544
+ childNode = childNodes[i];
1545
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1546
+ // first got the content reference comment node
1547
+ // then we got it's parent, which is where all the host content is in now
1548
+ hostContentNodes = node.parentNode.childNodes;
1549
+ slotNameAttr = childNode['s-sn'];
1550
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1551
+ node = hostContentNodes[j];
1552
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1553
+ // let's do some relocating to its new home
1554
+ // but never relocate a content reference node
1555
+ // that is suppose to always represent the original content location
1556
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
1557
+ // it's possible we've already decided to relocate this node
1558
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1559
+ // made some changes to slots
1560
+ // let's make sure we also double check
1561
+ // fallbacks are correctly hidden or shown
1562
+ checkSlotFallbackVisibility = true;
1563
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
1564
+ if (relocateNodeData) {
1565
+ // previously we never found a slot home for this node
1566
+ // but turns out we did, so let's remember it now
1567
+ relocateNodeData.$slotRefNode$ = childNode;
1568
+ }
1569
+ else {
1570
+ // add to our list of nodes to relocate
1571
+ relocateNodes.push({
1572
+ $slotRefNode$: childNode,
1573
+ $nodeToRelocate$: node,
1574
+ });
1575
+ }
1576
+ if (node['s-sr']) {
1577
+ relocateNodes.map((relocateNode) => {
1578
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1579
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1580
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1581
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1582
+ }
1583
+ }
1584
+ });
1585
+ }
1586
+ }
1587
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1588
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1589
+ // if we never find a home for this element then we'll need to hide it
1590
+ relocateNodes.push({
1591
+ $nodeToRelocate$: node,
1592
+ });
1593
+ }
1594
+ }
1595
+ }
1596
+ }
1597
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1598
+ relocateSlotContent(childNode);
1599
+ }
1600
+ }
1601
+ };
1602
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1603
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1604
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1605
+ return true;
1606
+ }
1607
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1608
+ return true;
1609
+ }
1610
+ return false;
1611
+ }
1612
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1613
+ return true;
1614
+ }
1615
+ return slotNameAttr === '';
1616
+ };
1617
+ const callNodeRefs = (vNode) => {
1618
+ if (BUILD.vdomRef) {
1619
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1620
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
1621
+ }
1622
+ };
1623
+ /**
1624
+ * The main entry point for Stencil's virtual DOM-based rendering engine
1625
+ *
1626
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1627
+ * function will handle creating a virtual DOM tree with a single root, patching
1628
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1629
+ * relocation, and reflecting attributes.
1630
+ *
1631
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1632
+ * the DOM node into which it should be rendered.
1633
+ * @param renderFnResults the virtual DOM nodes to be rendered
1634
+ */
1635
+ const renderVdom = (hostRef, renderFnResults) => {
1636
+ const hostElm = hostRef.$hostElement$;
1637
+ const cmpMeta = hostRef.$cmpMeta$;
1638
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1639
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1640
+ hostTagName = hostElm.tagName;
1641
+ // <Host> runtime check
1642
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1643
+ throw new Error(`The <Host> must be the single root component.
1644
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1645
+
1646
+ The render() function should look like this instead:
1647
+
1648
+ render() {
1649
+ // Do not return an array
1650
+ return (
1651
+ <Host>{content}</Host>
1652
+ );
1653
+ }
1654
+ `);
1655
+ }
1656
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1657
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1658
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1659
+ }
1660
+ rootVnode.$tag$ = null;
1661
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1662
+ hostRef.$vnode$ = rootVnode;
1663
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1664
+ if (BUILD.scoped || BUILD.shadowDom) {
1665
+ scopeId = hostElm['s-sc'];
1666
+ }
1667
+ if (BUILD.slotRelocation) {
1668
+ contentRef = hostElm['s-cr'];
1669
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1670
+ // always reset
1671
+ checkSlotFallbackVisibility = false;
1672
+ }
1673
+ // synchronous patch
1674
+ patch(oldVNode, rootVnode);
1675
+ if (BUILD.slotRelocation) {
1676
+ // while we're moving nodes around existing nodes, temporarily disable
1677
+ // the disconnectCallback from working
1678
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1679
+ if (checkSlotRelocate) {
1680
+ relocateSlotContent(rootVnode.$elm$);
1681
+ let relocateData;
1682
+ let nodeToRelocate;
1683
+ let orgLocationNode;
1684
+ let parentNodeRef;
1685
+ let insertBeforeNode;
1686
+ let refNode;
1687
+ let i = 0;
1688
+ for (; i < relocateNodes.length; i++) {
1689
+ relocateData = relocateNodes[i];
1690
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1691
+ if (!nodeToRelocate['s-ol']) {
1692
+ // add a reference node marking this node's original location
1693
+ // keep a reference to this node for later lookups
1694
+ orgLocationNode =
1695
+ BUILD.isDebug || BUILD.hydrateServerSide
1696
+ ? originalLocationDebugNode(nodeToRelocate)
1697
+ : doc.createTextNode('');
1698
+ orgLocationNode['s-nr'] = nodeToRelocate;
1699
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1700
+ }
1701
+ }
1702
+ for (i = 0; i < relocateNodes.length; i++) {
1703
+ relocateData = relocateNodes[i];
1704
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1705
+ if (relocateData.$slotRefNode$) {
1706
+ // by default we're just going to insert it directly
1707
+ // after the slot reference node
1708
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1709
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1710
+ orgLocationNode = nodeToRelocate['s-ol'];
1711
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1712
+ refNode = orgLocationNode['s-nr'];
1713
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1714
+ refNode = refNode.nextSibling;
1715
+ if (!refNode || !refNode['s-nr']) {
1716
+ insertBeforeNode = refNode;
1717
+ break;
1718
+ }
1719
+ }
1720
+ }
1721
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1722
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1723
+ // we've checked that it's worth while to relocate
1724
+ // since that the node to relocate
1725
+ // has a different next sibling or parent relocated
1726
+ if (nodeToRelocate !== insertBeforeNode) {
1727
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1728
+ // probably a component in the index.html that doesn't have it's hostname set
1729
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1730
+ }
1731
+ // add it back to the dom but in its new home
1732
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1733
+ }
1734
+ }
1735
+ }
1736
+ else {
1737
+ // this node doesn't have a slot home to go to, so let's hide it
1738
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1739
+ nodeToRelocate.hidden = true;
1740
+ }
1741
+ }
1742
+ }
1743
+ }
1744
+ if (checkSlotFallbackVisibility) {
1745
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1746
+ }
1747
+ // done moving nodes around
1748
+ // allow the disconnect callback to work again
1749
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1750
+ // always reset
1751
+ relocateNodes.length = 0;
1752
+ }
1753
+ };
1754
+ // slot comment debug nodes only created with the `--debug` flag
1755
+ // otherwise these nodes are text nodes w/out content
1756
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1757
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1758
+ (nodeToRelocate.localName
1759
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1760
+ : `[${nodeToRelocate.textContent}]`));
1761
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1762
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1763
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1764
+ }
1765
+ };
1766
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1767
+ if (BUILD.taskQueue && BUILD.updatable) {
1768
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1769
+ }
1770
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1771
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1772
+ return;
1773
+ }
1774
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1775
+ // there is no ancestor component or the ancestor component
1776
+ // has already fired off its lifecycle update then
1777
+ // fire off the initial update
1778
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1779
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1780
+ };
1781
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1782
+ const elm = hostRef.$hostElement$;
1783
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1784
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1785
+ let promise;
1786
+ if (isInitialLoad) {
1787
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1788
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1789
+ if (hostRef.$queuedListeners$) {
1790
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1791
+ hostRef.$queuedListeners$ = null;
1792
+ }
1793
+ }
1794
+ emitLifecycleEvent(elm, 'componentWillLoad');
1795
+ if (BUILD.cmpWillLoad) {
1796
+ promise = safeCall(instance, 'componentWillLoad');
1797
+ }
1798
+ }
1799
+ else {
1800
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1801
+ if (BUILD.cmpWillUpdate) {
1802
+ promise = safeCall(instance, 'componentWillUpdate');
1803
+ }
1804
+ }
1805
+ emitLifecycleEvent(elm, 'componentWillRender');
1806
+ if (BUILD.cmpWillRender) {
1807
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1808
+ }
1809
+ endSchedule();
1810
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1811
+ };
1812
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1813
+ // updateComponent
1814
+ const elm = hostRef.$hostElement$;
1815
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1816
+ const rc = elm['s-rc'];
1817
+ if (BUILD.style && isInitialLoad) {
1818
+ // DOM WRITE!
1819
+ attachStyles(hostRef);
1820
+ }
1821
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1822
+ if (BUILD.isDev) {
1823
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1824
+ }
1825
+ if (BUILD.hydrateServerSide) {
1826
+ await callRender(hostRef, instance, elm);
1827
+ }
1828
+ else {
1829
+ callRender(hostRef, instance, elm);
1830
+ }
1831
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1832
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1833
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1834
+ plt.$cssShim$.updateHost(elm);
1835
+ }
1836
+ if (BUILD.isDev) {
1837
+ hostRef.$renderCount$++;
1838
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1839
+ }
1840
+ if (BUILD.hydrateServerSide) {
1841
+ try {
1842
+ // manually connected child components during server-side hydrate
1843
+ serverSideConnected(elm);
1844
+ if (isInitialLoad) {
1845
+ // using only during server-side hydrate
1846
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1847
+ elm['s-en'] = '';
1848
+ }
1849
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1850
+ elm['s-en'] = 'c';
1851
+ }
1852
+ }
1853
+ }
1854
+ catch (e) {
1855
+ consoleError(e, elm);
1856
+ }
1857
+ }
1858
+ if (BUILD.asyncLoading && rc) {
1859
+ // ok, so turns out there are some child host elements
1860
+ // waiting on this parent element to load
1861
+ // let's fire off all update callbacks waiting
1862
+ rc.map((cb) => cb());
1863
+ elm['s-rc'] = undefined;
1864
+ }
1865
+ endRender();
1866
+ endUpdate();
1867
+ if (BUILD.asyncLoading) {
1868
+ const childrenPromises = elm['s-p'];
1869
+ const postUpdate = () => postUpdateComponent(hostRef);
1870
+ if (childrenPromises.length === 0) {
1871
+ postUpdate();
1872
+ }
1873
+ else {
1874
+ Promise.all(childrenPromises).then(postUpdate);
1875
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1876
+ childrenPromises.length = 0;
1877
+ }
1878
+ }
1879
+ else {
1880
+ postUpdateComponent(hostRef);
1881
+ }
1882
+ };
1883
+ const callRender = (hostRef, instance, elm) => {
1884
+ // in order for bundlers to correctly treeshake the BUILD object
1885
+ // we need to ensure BUILD is not deoptimized within a try/catch
1886
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1887
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1888
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1889
+ const taskQueue = BUILD.taskQueue ? true : false;
1890
+ const updatable = BUILD.updatable ? true : false;
1891
+ try {
1892
+ renderingRef = instance;
1893
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1894
+ if (updatable && taskQueue) {
1895
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1896
+ }
1897
+ if (updatable || lazyLoad) {
1898
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1899
+ }
1900
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1901
+ if (BUILD.vdomRender || BUILD.reflect) {
1902
+ // looks like we've got child nodes to render into this host element
1903
+ // or we need to update the css class/attrs on the host element
1904
+ // DOM WRITE!
1905
+ if (BUILD.hydrateServerSide) {
1906
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1907
+ }
1908
+ else {
1909
+ renderVdom(hostRef, instance);
1910
+ }
1911
+ }
1912
+ else {
1913
+ elm.textContent = instance;
1914
+ }
1915
+ }
1916
+ }
1917
+ catch (e) {
1918
+ consoleError(e, hostRef.$hostElement$);
1919
+ }
1920
+ renderingRef = null;
1921
+ return null;
1922
+ };
1923
+ const getRenderingRef = () => renderingRef;
1924
+ const postUpdateComponent = (hostRef) => {
1925
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1926
+ const elm = hostRef.$hostElement$;
1927
+ const endPostUpdate = createTime('postUpdate', tagName);
1928
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1929
+ const ancestorComponent = hostRef.$ancestorComponent$;
1930
+ if (BUILD.cmpDidRender) {
1931
+ if (BUILD.isDev) {
1932
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1933
+ }
1934
+ safeCall(instance, 'componentDidRender');
1935
+ if (BUILD.isDev) {
1936
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1937
+ }
1938
+ }
1939
+ emitLifecycleEvent(elm, 'componentDidRender');
1940
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1941
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1942
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1943
+ // DOM WRITE!
1944
+ addHydratedFlag(elm);
1945
+ }
1946
+ if (BUILD.cmpDidLoad) {
1947
+ if (BUILD.isDev) {
1948
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1949
+ }
1950
+ safeCall(instance, 'componentDidLoad');
1951
+ if (BUILD.isDev) {
1952
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1953
+ }
1954
+ }
1955
+ emitLifecycleEvent(elm, 'componentDidLoad');
1956
+ endPostUpdate();
1957
+ if (BUILD.asyncLoading) {
1958
+ hostRef.$onReadyResolve$(elm);
1959
+ if (!ancestorComponent) {
1960
+ appDidLoad(tagName);
1961
+ }
1962
+ }
1963
+ }
1964
+ else {
1965
+ if (BUILD.cmpDidUpdate) {
1966
+ // we've already loaded this component
1967
+ // fire off the user's componentDidUpdate method (if one was provided)
1968
+ // componentDidUpdate runs AFTER render() has been called
1969
+ // and all child components have finished updating
1970
+ if (BUILD.isDev) {
1971
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1972
+ }
1973
+ safeCall(instance, 'componentDidUpdate');
1974
+ if (BUILD.isDev) {
1975
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1976
+ }
1977
+ }
1978
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1979
+ endPostUpdate();
1980
+ }
1981
+ if (BUILD.hotModuleReplacement) {
1982
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1983
+ }
1984
+ if (BUILD.method && BUILD.lazyLoad) {
1985
+ hostRef.$onInstanceResolve$(elm);
1986
+ }
1987
+ // load events fire from bottom to top
1988
+ // the deepest elements load first then bubbles up
1989
+ if (BUILD.asyncLoading) {
1990
+ if (hostRef.$onRenderResolve$) {
1991
+ hostRef.$onRenderResolve$();
1992
+ hostRef.$onRenderResolve$ = undefined;
1993
+ }
1994
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1995
+ nextTick(() => scheduleUpdate(hostRef, false));
1996
+ }
1997
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1998
+ }
1999
+ // ( •_•)
2000
+ // ( •_•)>⌐■-■
2001
+ // (⌐■_■)
2002
+ };
2003
+ const forceUpdate = (ref) => {
2004
+ if (BUILD.updatable) {
2005
+ const hostRef = getHostRef(ref);
2006
+ const isConnected = hostRef.$hostElement$.isConnected;
2007
+ if (isConnected &&
2008
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2009
+ scheduleUpdate(hostRef, false);
2010
+ }
2011
+ // Returns "true" when the forced update was successfully scheduled
2012
+ return isConnected;
2013
+ }
2014
+ return false;
2015
+ };
2016
+ const appDidLoad = (who) => {
2017
+ // on appload
2018
+ // we have finish the first big initial render
2019
+ if (BUILD.cssAnnotations) {
2020
+ addHydratedFlag(doc.documentElement);
2021
+ }
2022
+ if (BUILD.asyncQueue) {
2023
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2024
+ }
2025
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2026
+ if (BUILD.profile && performance.measure) {
2027
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
2028
+ }
2029
+ };
2030
+ const safeCall = (instance, method, arg) => {
2031
+ if (instance && instance[method]) {
2032
+ try {
2033
+ return instance[method](arg);
2034
+ }
2035
+ catch (e) {
2036
+ consoleError(e);
2037
+ }
2038
+ }
2039
+ return undefined;
2040
+ };
2041
+ const then = (promise, thenFn) => {
2042
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
2043
+ };
2044
+ const emitLifecycleEvent = (elm, lifecycleName) => {
2045
+ if (BUILD.lifecycleDOMEvents) {
2046
+ emitEvent(elm, 'stencil_' + lifecycleName, {
2047
+ bubbles: true,
2048
+ composed: true,
2049
+ detail: {
2050
+ namespace: NAMESPACE,
2051
+ },
2052
+ });
2053
+ }
2054
+ };
2055
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
2056
+ ? elm.classList.add('hydrated')
2057
+ : BUILD.hydratedAttribute
2058
+ ? elm.setAttribute('hydrated', '')
2059
+ : undefined;
2060
+ const serverSideConnected = (elm) => {
2061
+ const children = elm.children;
2062
+ if (children != null) {
2063
+ for (let i = 0, ii = children.length; i < ii; i++) {
2064
+ const childElm = children[i];
2065
+ if (typeof childElm.connectedCallback === 'function') {
2066
+ childElm.connectedCallback();
2067
+ }
2068
+ serverSideConnected(childElm);
2069
+ }
2070
+ }
2071
+ };
2072
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
2073
+ const setValue = (ref, propName, newVal, cmpMeta) => {
2074
+ // check our new property value against our internal value
2075
+ const hostRef = getHostRef(ref);
2076
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
2077
+ const oldVal = hostRef.$instanceValues$.get(propName);
2078
+ const flags = hostRef.$flags$;
2079
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2080
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2081
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
2082
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
2083
+ const didValueChange = newVal !== oldVal && !areBothNaN;
2084
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2085
+ // gadzooks! the property's value has changed!!
2086
+ // set our new value!
2087
+ hostRef.$instanceValues$.set(propName, newVal);
2088
+ if (BUILD.isDev) {
2089
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
2090
+ 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);
2091
+ }
2092
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
2093
+ 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);
2094
+ }
2095
+ }
2096
+ if (!BUILD.lazyLoad || instance) {
2097
+ // get an array of method names of watch functions to call
2098
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2099
+ const watchMethods = cmpMeta.$watchers$[propName];
2100
+ if (watchMethods) {
2101
+ // this instance is watching for when this property changed
2102
+ watchMethods.map((watchMethodName) => {
2103
+ try {
2104
+ // fire off each of the watch methods that are watching this property
2105
+ instance[watchMethodName](newVal, oldVal, propName);
2106
+ }
2107
+ catch (e) {
2108
+ consoleError(e, elm);
2109
+ }
2110
+ });
2111
+ }
2112
+ }
2113
+ if (BUILD.updatable &&
2114
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2115
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
2116
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
2117
+ return;
2118
+ }
2119
+ }
2120
+ // looks like this value actually changed, so we've got work to do!
2121
+ // but only if we've already rendered, otherwise just chill out
2122
+ // queue that we need to do an update, but don't worry about queuing
2123
+ // up millions cuz this function ensures it only runs once
2124
+ scheduleUpdate(hostRef, false);
2125
+ }
2126
+ }
2127
+ }
2128
+ };
2129
+ /**
2130
+ * Attach a series of runtime constructs to a compiled Stencil component
2131
+ * constructor, including getters and setters for the `@Prop` and `@State`
2132
+ * decorators, callbacks for when attributes change, and so on.
2133
+ *
2134
+ * @param Cstr the constructor for a component that we need to process
2135
+ * @param cmpMeta metadata collected previously about the component
2136
+ * @param flags a number used to store a series of bit flags
2137
+ * @returns a reference to the same constructor passed in (but now mutated)
2138
+ */
2139
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
2140
+ if (BUILD.member && cmpMeta.$members$) {
2141
+ if (BUILD.watchCallback && Cstr.watchers) {
2142
+ cmpMeta.$watchers$ = Cstr.watchers;
2143
+ }
2144
+ // It's better to have a const than two Object.entries()
2145
+ const members = Object.entries(cmpMeta.$members$);
2146
+ const prototype = Cstr.prototype;
2147
+ members.map(([memberName, [memberFlags]]) => {
2148
+ if ((BUILD.prop || BUILD.state) &&
2149
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2150
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2151
+ // proxyComponent - prop
2152
+ Object.defineProperty(prototype, memberName, {
2153
+ get() {
2154
+ // proxyComponent, get value
2155
+ return getValue(this, memberName);
2156
+ },
2157
+ set(newValue) {
2158
+ // only during dev time
2159
+ if (BUILD.isDev) {
2160
+ const ref = getHostRef(this);
2161
+ if (
2162
+ // we are proxying the instance (not element)
2163
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
2164
+ // the element is not constructing
2165
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
2166
+ // the member is a prop
2167
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
2168
+ // the member is not mutable
2169
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
2170
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
2171
+ }
2172
+ }
2173
+ // proxyComponent, set value
2174
+ setValue(this, memberName, newValue, cmpMeta);
2175
+ },
2176
+ configurable: true,
2177
+ enumerable: true,
2178
+ });
2179
+ }
2180
+ else if (BUILD.lazyLoad &&
2181
+ BUILD.method &&
2182
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2183
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
2184
+ // proxyComponent - method
2185
+ Object.defineProperty(prototype, memberName, {
2186
+ value(...args) {
2187
+ const ref = getHostRef(this);
2188
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
2189
+ },
2190
+ });
2191
+ }
2192
+ });
2193
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2194
+ const attrNameToPropName = new Map();
2195
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
2196
+ plt.jmp(() => {
2197
+ const propName = attrNameToPropName.get(attrName);
2198
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
2199
+ // in the case where an attribute was set inline.
2200
+ // ```html
2201
+ // <my-component some-attribute="some-value"></my-component>
2202
+ // ```
2203
+ //
2204
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
2205
+ // programmatically changes it before it has been upgraded as shown below:
2206
+ //
2207
+ // ```html
2208
+ // <!-- this component has _not_ been upgraded yet -->
2209
+ // <my-component id="test" some-attribute="some-value"></my-component>
2210
+ // <script>
2211
+ // // grab non-upgraded component
2212
+ // el = document.querySelector("#test");
2213
+ // el.someAttribute = "another-value";
2214
+ // // upgrade component
2215
+ // customElements.define('my-component', MyComponent);
2216
+ // </script>
2217
+ // ```
2218
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
2219
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
2220
+ // to the value that was set inline i.e. "some-value" from above example. When
2221
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
2222
+ //
2223
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
2224
+ // by connectedCallback as this attributeChangedCallback will not fire.
2225
+ //
2226
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2227
+ //
2228
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
2229
+ // properties here given that this goes against best practices outlined here
2230
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2231
+ if (this.hasOwnProperty(propName)) {
2232
+ newValue = this[propName];
2233
+ delete this[propName];
2234
+ }
2235
+ else if (prototype.hasOwnProperty(propName) &&
2236
+ typeof this[propName] === 'number' &&
2237
+ this[propName] == newValue) {
2238
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
2239
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
2240
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
2241
+ return;
2242
+ }
2243
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2244
+ });
2245
+ };
2246
+ // create an array of attributes to observe
2247
+ // and also create a map of html attribute name to js property name
2248
+ Cstr.observedAttributes = members
2249
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
2250
+ .map(([propName, m]) => {
2251
+ const attrName = m[1] || propName;
2252
+ attrNameToPropName.set(attrName, propName);
2253
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2254
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
2255
+ }
2256
+ return attrName;
2257
+ });
2258
+ }
2259
+ }
2260
+ return Cstr;
2261
+ };
2262
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2263
+ // initializeComponent
2264
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2265
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2266
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2267
+ // we haven't initialized this element yet
2268
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2269
+ // lazy loaded components
2270
+ // request the component's implementation to be
2271
+ // wired up with the host element
2272
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
2273
+ if (Cstr.then) {
2274
+ // Await creates a micro-task avoid if possible
2275
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
2276
+ Cstr = await Cstr;
2277
+ endLoad();
2278
+ }
2279
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2280
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2281
+ }
2282
+ if (BUILD.member && !Cstr.isProxied) {
2283
+ // we've never proxied this Constructor before
2284
+ // let's add the getters/setters to its prototype before
2285
+ // the first time we create an instance of the implementation
2286
+ if (BUILD.watchCallback) {
2287
+ cmpMeta.$watchers$ = Cstr.watchers;
2288
+ }
2289
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2290
+ Cstr.isProxied = true;
2291
+ }
2292
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2293
+ // ok, time to construct the instance
2294
+ // but let's keep track of when we start and stop
2295
+ // so that the getters/setters don't incorrectly step on data
2296
+ if (BUILD.member) {
2297
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2298
+ }
2299
+ // construct the lazy-loaded component implementation
2300
+ // passing the hostRef is very important during
2301
+ // construction in order to directly wire together the
2302
+ // host element and the lazy-loaded instance
2303
+ try {
2304
+ new Cstr(hostRef);
2305
+ }
2306
+ catch (e) {
2307
+ consoleError(e);
2308
+ }
2309
+ if (BUILD.member) {
2310
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2311
+ }
2312
+ if (BUILD.watchCallback) {
2313
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2314
+ }
2315
+ endNewInstance();
2316
+ fireConnectedCallback(hostRef.$lazyInstance$);
2317
+ }
2318
+ else {
2319
+ // sync constructor component
2320
+ Cstr = elm.constructor;
2321
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2322
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2323
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2324
+ // Stencil has completed instantiating the component.
2325
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2326
+ }
2327
+ if (BUILD.style && Cstr.style) {
2328
+ // this component has styles but we haven't registered them yet
2329
+ let style = Cstr.style;
2330
+ if (BUILD.mode && typeof style !== 'string') {
2331
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2332
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2333
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2334
+ }
2335
+ }
2336
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2337
+ if (!styles.has(scopeId)) {
2338
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2339
+ if (!BUILD.hydrateServerSide &&
2340
+ BUILD.shadowDom &&
2341
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2342
+ BUILD.shadowDomShim &&
2343
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2344
+ style = await import('./shadow-css-05e0c1f4.js').then((m) => m.scopeCss(style, scopeId, false));
2345
+ }
2346
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2347
+ endRegisterStyles();
2348
+ }
2349
+ }
2350
+ }
2351
+ // we've successfully created a lazy instance
2352
+ const ancestorComponent = hostRef.$ancestorComponent$;
2353
+ const schedule = () => scheduleUpdate(hostRef, true);
2354
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2355
+ // this is the initial load and this component it has an ancestor component
2356
+ // but the ancestor component has NOT fired its will update lifecycle yet
2357
+ // so let's just cool our jets and wait for the ancestor to continue first
2358
+ // this will get fired off when the ancestor component
2359
+ // finally gets around to rendering its lazy self
2360
+ // fire off the initial update
2361
+ ancestorComponent['s-rc'].push(schedule);
2362
+ }
2363
+ else {
2364
+ schedule();
2365
+ }
2366
+ };
2367
+ const fireConnectedCallback = (instance) => {
2368
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
2369
+ safeCall(instance, 'connectedCallback');
2370
+ }
2371
+ };
2372
+ const connectedCallback = (elm) => {
2373
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2374
+ const hostRef = getHostRef(elm);
2375
+ const cmpMeta = hostRef.$cmpMeta$;
2376
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2377
+ if (BUILD.hostListenerTargetParent) {
2378
+ // only run if we have listeners being attached to a parent
2379
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2380
+ }
2381
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2382
+ // first time this component has connected
2383
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2384
+ let hostId;
2385
+ if (BUILD.hydrateClientSide) {
2386
+ hostId = elm.getAttribute(HYDRATE_ID);
2387
+ if (hostId) {
2388
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2389
+ const scopeId = BUILD.mode
2390
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2391
+ : addStyle(elm.shadowRoot, cmpMeta);
2392
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2393
+ }
2394
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2395
+ }
2396
+ }
2397
+ if (BUILD.slotRelocation && !hostId) {
2398
+ // initUpdate
2399
+ // if the slot polyfill is required we'll need to put some nodes
2400
+ // in here to act as original content anchors as we move nodes around
2401
+ // host element has been connected to the DOM
2402
+ if (BUILD.hydrateServerSide ||
2403
+ ((BUILD.slot || BUILD.shadowDom) &&
2404
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2405
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2406
+ setContentReference(elm);
2407
+ }
2408
+ }
2409
+ if (BUILD.asyncLoading) {
2410
+ // find the first ancestor component (if there is one) and register
2411
+ // this component as one of the actively loading child components for its ancestor
2412
+ let ancestorComponent = elm;
2413
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2414
+ // climb up the ancestors looking for the first
2415
+ // component that hasn't finished its lifecycle update yet
2416
+ if ((BUILD.hydrateClientSide &&
2417
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2418
+ ancestorComponent.hasAttribute('s-id') &&
2419
+ ancestorComponent['s-p']) ||
2420
+ ancestorComponent['s-p']) {
2421
+ // we found this components first ancestor component
2422
+ // keep a reference to this component's ancestor component
2423
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2424
+ break;
2425
+ }
2426
+ }
2427
+ }
2428
+ // Lazy properties
2429
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2430
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2431
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2432
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2433
+ const value = elm[memberName];
2434
+ delete elm[memberName];
2435
+ elm[memberName] = value;
2436
+ }
2437
+ });
2438
+ }
2439
+ if (BUILD.initializeNextTick) {
2440
+ // connectedCallback, taskQueue, initialLoad
2441
+ // angular sets attribute AFTER connectCallback
2442
+ // https://github.com/angular/angular/issues/18909
2443
+ // https://github.com/angular/angular/issues/19940
2444
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2445
+ }
2446
+ else {
2447
+ initializeComponent(elm, hostRef, cmpMeta);
2448
+ }
2449
+ }
2450
+ else {
2451
+ // not the first time this has connected
2452
+ // reattach any event listeners to the host
2453
+ // since they would have been removed when disconnected
2454
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2455
+ // fire off connectedCallback() on component instance
2456
+ fireConnectedCallback(hostRef.$lazyInstance$);
2457
+ }
2458
+ endConnected();
2459
+ }
2460
+ };
2461
+ const setContentReference = (elm) => {
2462
+ // only required when we're NOT using native shadow dom (slot)
2463
+ // or this browser doesn't support native shadow dom
2464
+ // and this host element was NOT created with SSR
2465
+ // let's pick out the inner content for slot projection
2466
+ // create a node to represent where the original
2467
+ // content was first placed, which is useful later on
2468
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
2469
+ contentRefElm['s-cn'] = true;
2470
+ elm.insertBefore(contentRefElm, elm.firstChild);
2471
+ };
2472
+ const disconnectedCallback = (elm) => {
2473
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2474
+ const hostRef = getHostRef(elm);
2475
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2476
+ if (BUILD.hostListener) {
2477
+ if (hostRef.$rmListeners$) {
2478
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
2479
+ hostRef.$rmListeners$ = undefined;
2480
+ }
2481
+ }
2482
+ // clear CSS var-shim tracking
2483
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
2484
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2485
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
2486
+ plt.$cssShim$.removeHost(elm);
2487
+ }
2488
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2489
+ safeCall(instance, 'disconnectedCallback');
2490
+ }
2491
+ if (BUILD.cmpDidUnload) {
2492
+ safeCall(instance, 'componentDidUnload');
2493
+ }
2494
+ }
2495
+ };
2496
+ const defineCustomElement = (Cstr, compactMeta) => {
2497
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2498
+ };
2499
+ const proxyCustomElement = (Cstr, compactMeta) => {
2500
+ const cmpMeta = {
2501
+ $flags$: compactMeta[0],
2502
+ $tagName$: compactMeta[1],
2503
+ };
2504
+ if (BUILD.member) {
2505
+ cmpMeta.$members$ = compactMeta[2];
2506
+ }
2507
+ if (BUILD.hostListener) {
2508
+ cmpMeta.$listeners$ = compactMeta[3];
2509
+ }
2510
+ if (BUILD.watchCallback) {
2511
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2512
+ }
2513
+ if (BUILD.reflect) {
2514
+ cmpMeta.$attrsToReflect$ = [];
2515
+ }
2516
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2517
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2518
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2519
+ }
2520
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2521
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2522
+ Object.assign(Cstr.prototype, {
2523
+ __registerHost() {
2524
+ registerHost(this, cmpMeta);
2525
+ },
2526
+ connectedCallback() {
2527
+ connectedCallback(this);
2528
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2529
+ originalConnectedCallback.call(this);
2530
+ }
2531
+ },
2532
+ disconnectedCallback() {
2533
+ disconnectedCallback(this);
2534
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2535
+ originalDisconnectedCallback.call(this);
2536
+ }
2537
+ },
2538
+ __attachShadow() {
2539
+ if (supportsShadow) {
2540
+ if (BUILD.shadowDelegatesFocus) {
2541
+ this.attachShadow({
2542
+ mode: 'open',
2543
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2544
+ });
2545
+ }
2546
+ else {
2547
+ this.attachShadow({ mode: 'open' });
2548
+ }
2549
+ }
2550
+ else {
2551
+ this.shadowRoot = this;
2552
+ }
2553
+ },
2554
+ });
2555
+ Cstr.is = cmpMeta.$tagName$;
2556
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2557
+ };
2558
+ const forceModeUpdate = (elm) => {
2559
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2560
+ const mode = computeMode(elm);
2561
+ const hostRef = getHostRef(elm);
2562
+ if (hostRef.$modeName$ !== mode) {
2563
+ const cmpMeta = hostRef.$cmpMeta$;
2564
+ const oldScopeId = elm['s-sc'];
2565
+ const scopeId = getScopeId(cmpMeta, mode);
2566
+ const style = elm.constructor.style[mode];
2567
+ const flags = cmpMeta.$flags$;
2568
+ if (style) {
2569
+ if (!styles.has(scopeId)) {
2570
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2571
+ }
2572
+ hostRef.$modeName$ = mode;
2573
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2574
+ attachStyles(hostRef);
2575
+ forceUpdate(elm);
2576
+ }
2577
+ }
2578
+ }
2579
+ };
2580
+ const patchCloneNode = (HostElementPrototype) => {
2581
+ const orgCloneNode = HostElementPrototype.cloneNode;
2582
+ HostElementPrototype.cloneNode = function (deep) {
2583
+ const srcNode = this;
2584
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2585
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2586
+ if (BUILD.slot && !isShadowDom && deep) {
2587
+ let i = 0;
2588
+ let slotted, nonStencilNode;
2589
+ const stencilPrivates = [
2590
+ 's-id',
2591
+ 's-cr',
2592
+ 's-lr',
2593
+ 's-rc',
2594
+ 's-sc',
2595
+ 's-p',
2596
+ 's-cn',
2597
+ 's-sr',
2598
+ 's-sn',
2599
+ 's-hn',
2600
+ 's-ol',
2601
+ 's-nr',
2602
+ 's-si',
2603
+ ];
2604
+ for (; i < srcNode.childNodes.length; i++) {
2605
+ slotted = srcNode.childNodes[i]['s-nr'];
2606
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2607
+ if (slotted) {
2608
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2609
+ clonedNode.__appendChild(slotted.cloneNode(true));
2610
+ }
2611
+ else {
2612
+ clonedNode.appendChild(slotted.cloneNode(true));
2613
+ }
2614
+ }
2615
+ if (nonStencilNode) {
2616
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2617
+ }
2618
+ }
2619
+ }
2620
+ return clonedNode;
2621
+ };
2622
+ };
2623
+ const patchSlotAppendChild = (HostElementPrototype) => {
2624
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2625
+ HostElementPrototype.appendChild = function (newChild) {
2626
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2627
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2628
+ if (slotNode) {
2629
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2630
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2631
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2632
+ }
2633
+ return this.__appendChild(newChild);
2634
+ };
2635
+ };
2636
+ /**
2637
+ * Patches the text content of an unnamed slotted node inside a scoped component
2638
+ * @param hostElementPrototype the `Element` to be patched
2639
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2640
+ */
2641
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2642
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2643
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2644
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2645
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2646
+ get() {
2647
+ var _a;
2648
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2649
+ // the empty string
2650
+ const slotNode = getHostSlotNode(this.childNodes, '');
2651
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2652
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2653
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2654
+ return slotNode.nextSibling.textContent;
2655
+ }
2656
+ else if (slotNode) {
2657
+ return slotNode.textContent;
2658
+ }
2659
+ else {
2660
+ // fallback to the original implementation
2661
+ return this.__textContent;
2662
+ }
2663
+ },
2664
+ set(value) {
2665
+ var _a;
2666
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2667
+ // the empty string
2668
+ const slotNode = getHostSlotNode(this.childNodes, '');
2669
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2670
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2671
+ // sibling.
2672
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2673
+ slotNode.nextSibling.textContent = value;
2674
+ }
2675
+ else if (slotNode) {
2676
+ slotNode.textContent = value;
2677
+ }
2678
+ else {
2679
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2680
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2681
+ // it there
2682
+ this.__textContent = value;
2683
+ const contentRefElm = this['s-cr'];
2684
+ if (contentRefElm) {
2685
+ this.insertBefore(contentRefElm, this.firstChild);
2686
+ }
2687
+ }
2688
+ },
2689
+ });
2690
+ }
2691
+ };
2692
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2693
+ class FakeNodeList extends Array {
2694
+ item(n) {
2695
+ return this[n];
2696
+ }
2697
+ }
2698
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2699
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2700
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2701
+ Object.defineProperty(elm, 'children', {
2702
+ get() {
2703
+ return this.childNodes.map((n) => n.nodeType === 1);
2704
+ },
2705
+ });
2706
+ Object.defineProperty(elm, 'childElementCount', {
2707
+ get() {
2708
+ return elm.children.length;
2709
+ },
2710
+ });
2711
+ Object.defineProperty(elm, 'childNodes', {
2712
+ get() {
2713
+ const childNodes = childNodesFn.call(this);
2714
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2715
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2716
+ const result = new FakeNodeList();
2717
+ for (let i = 0; i < childNodes.length; i++) {
2718
+ const slot = childNodes[i]['s-nr'];
2719
+ if (slot) {
2720
+ result.push(slot);
2721
+ }
2722
+ }
2723
+ return result;
2724
+ }
2725
+ return FakeNodeList.from(childNodes);
2726
+ },
2727
+ });
2728
+ }
2729
+ };
2730
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2731
+ /**
2732
+ * Recursively searches a series of child nodes for a slot with the provided name.
2733
+ * @param childNodes the nodes to search for a slot with a specific name.
2734
+ * @param slotName the name of the slot to match on.
2735
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2736
+ */
2737
+ const getHostSlotNode = (childNodes, slotName) => {
2738
+ let i = 0;
2739
+ let childNode;
2740
+ for (; i < childNodes.length; i++) {
2741
+ childNode = childNodes[i];
2742
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2743
+ return childNode;
2744
+ }
2745
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2746
+ if (childNode) {
2747
+ return childNode;
2748
+ }
2749
+ }
2750
+ return null;
2751
+ };
2752
+ const getHostSlotChildNodes = (n, slotName) => {
2753
+ const childNodes = [n];
2754
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2755
+ childNodes.push(n);
2756
+ }
2757
+ return childNodes;
2758
+ };
2759
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2760
+ // ¯\_(ツ)_/¯
2761
+ const hostRef = getHostRef(elm);
2762
+ // reset state flags to only have been connected
2763
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2764
+ // TODO
2765
+ // detatch any event listeners that may have been added
2766
+ // because we're not passing an exact event name it'll
2767
+ // remove all of this element's event, which is good
2768
+ // create a callback for when this component finishes hmr
2769
+ elm['s-hmr-load'] = () => {
2770
+ // finished hmr for this element
2771
+ delete elm['s-hmr-load'];
2772
+ };
2773
+ // re-initialize the component
2774
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2775
+ };
2776
+ const bootstrapLazy = (lazyBundles, options = {}) => {
2777
+ var _a;
2778
+ if (BUILD.profile && performance.mark) {
2779
+ performance.mark('st:app:start');
2780
+ }
2781
+ installDevTools();
2782
+ const endBootstrap = createTime('bootstrapLazy');
2783
+ const cmpTags = [];
2784
+ const exclude = options.exclude || [];
2785
+ const customElements = win.customElements;
2786
+ const head = doc.head;
2787
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2788
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2789
+ const deferredConnectedCallbacks = [];
2790
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2791
+ let appLoadFallback;
2792
+ let isBootstrapping = true;
2793
+ let i = 0;
2794
+ Object.assign(plt, options);
2795
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2796
+ if (BUILD.asyncQueue) {
2797
+ if (options.syncQueue) {
2798
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2799
+ }
2800
+ }
2801
+ if (BUILD.hydrateClientSide) {
2802
+ // If the app is already hydrated there is not point to disable the
2803
+ // async queue. This will improve the first input delay
2804
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2805
+ }
2806
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2807
+ for (; i < styles.length; i++) {
2808
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2809
+ }
2810
+ }
2811
+ lazyBundles.map((lazyBundle) => {
2812
+ lazyBundle[1].map((compactMeta) => {
2813
+ const cmpMeta = {
2814
+ $flags$: compactMeta[0],
2815
+ $tagName$: compactMeta[1],
2816
+ $members$: compactMeta[2],
2817
+ $listeners$: compactMeta[3],
2818
+ };
2819
+ if (BUILD.member) {
2820
+ cmpMeta.$members$ = compactMeta[2];
2821
+ }
2822
+ if (BUILD.hostListener) {
2823
+ cmpMeta.$listeners$ = compactMeta[3];
2824
+ }
2825
+ if (BUILD.reflect) {
2826
+ cmpMeta.$attrsToReflect$ = [];
2827
+ }
2828
+ if (BUILD.watchCallback) {
2829
+ cmpMeta.$watchers$ = {};
2830
+ }
2831
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2832
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2833
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2834
+ }
2835
+ const tagName = BUILD.transformTagName && options.transformTagName
2836
+ ? options.transformTagName(cmpMeta.$tagName$)
2837
+ : cmpMeta.$tagName$;
2838
+ const HostElement = class extends HTMLElement {
2839
+ // StencilLazyHost
2840
+ constructor(self) {
2841
+ // @ts-ignore
2842
+ super(self);
2843
+ self = this;
2844
+ registerHost(self, cmpMeta);
2845
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2846
+ // this component is using shadow dom
2847
+ // and this browser supports shadow dom
2848
+ // add the read-only property "shadowRoot" to the host element
2849
+ // adding the shadow root build conditionals to minimize runtime
2850
+ if (supportsShadow) {
2851
+ if (BUILD.shadowDelegatesFocus) {
2852
+ self.attachShadow({
2853
+ mode: 'open',
2854
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2855
+ });
2856
+ }
2857
+ else {
2858
+ self.attachShadow({ mode: 'open' });
2859
+ }
2860
+ }
2861
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2862
+ self.shadowRoot = self;
2863
+ }
2864
+ }
2865
+ if (BUILD.slotChildNodesFix) {
2866
+ patchChildSlotNodes(self, cmpMeta);
2867
+ }
2868
+ }
2869
+ connectedCallback() {
2870
+ if (appLoadFallback) {
2871
+ clearTimeout(appLoadFallback);
2872
+ appLoadFallback = null;
2873
+ }
2874
+ if (isBootstrapping) {
2875
+ // connectedCallback will be processed once all components have been registered
2876
+ deferredConnectedCallbacks.push(this);
2877
+ }
2878
+ else {
2879
+ plt.jmp(() => connectedCallback(this));
2880
+ }
2881
+ }
2882
+ disconnectedCallback() {
2883
+ plt.jmp(() => disconnectedCallback(this));
2884
+ }
2885
+ componentOnReady() {
2886
+ return getHostRef(this).$onReadyPromise$;
2887
+ }
2888
+ };
2889
+ if (BUILD.cloneNodeFix) {
2890
+ patchCloneNode(HostElement.prototype);
2891
+ }
2892
+ if (BUILD.appendChildSlotFix) {
2893
+ patchSlotAppendChild(HostElement.prototype);
2894
+ }
2895
+ if (BUILD.hotModuleReplacement) {
2896
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2897
+ hmrStart(this, cmpMeta, hmrVersionId);
2898
+ };
2899
+ }
2900
+ if (BUILD.scopedSlotTextContentFix) {
2901
+ patchTextContent(HostElement.prototype, cmpMeta);
2902
+ }
2903
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
2904
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2905
+ cmpTags.push(tagName);
2906
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2907
+ }
2908
+ });
2909
+ });
2910
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2911
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2912
+ visibilityStyle.setAttribute('data-styles', '');
2913
+ // Apply CSP nonce to the style tag if it exists
2914
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2915
+ if (nonce != null) {
2916
+ visibilityStyle.setAttribute('nonce', nonce);
2917
+ }
2918
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2919
+ }
2920
+ // Process deferred connectedCallbacks now all components have been registered
2921
+ isBootstrapping = false;
2922
+ if (deferredConnectedCallbacks.length) {
2923
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
2924
+ }
2925
+ else {
2926
+ if (BUILD.profile) {
2927
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2928
+ }
2929
+ else {
2930
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2931
+ }
2932
+ }
2933
+ // Fallback appLoad event
2934
+ endBootstrap();
2935
+ };
2936
+ const getConnect = (_ref, tagName) => {
2937
+ const componentOnReady = () => {
2938
+ let elm = doc.querySelector(tagName);
2939
+ if (!elm) {
2940
+ elm = doc.createElement(tagName);
2941
+ doc.body.appendChild(elm);
2942
+ }
2943
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2944
+ };
2945
+ const create = (...args) => {
2946
+ return componentOnReady().then((el) => el.create(...args));
2947
+ };
2948
+ return {
2949
+ create,
2950
+ componentOnReady,
2951
+ };
2952
+ };
2953
+ const getContext = (_elm, context) => {
2954
+ if (context in Context) {
2955
+ return Context[context];
2956
+ }
2957
+ else if (context === 'window') {
2958
+ return win;
2959
+ }
2960
+ else if (context === 'document') {
2961
+ return doc;
2962
+ }
2963
+ else if (context === 'isServer' || context === 'isPrerender') {
2964
+ return BUILD.hydrateServerSide ? true : false;
2965
+ }
2966
+ else if (context === 'isClient') {
2967
+ return BUILD.hydrateServerSide ? false : true;
2968
+ }
2969
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2970
+ return getAssetPath('.');
2971
+ }
2972
+ else if (context === 'queue') {
2973
+ return {
2974
+ write: writeTask,
2975
+ read: readTask,
2976
+ tick: {
2977
+ then(cb) {
2978
+ return nextTick(cb);
2979
+ },
2980
+ },
2981
+ };
2982
+ }
2983
+ return undefined;
2984
+ };
2985
+ const Fragment = (_, children) => children;
2986
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2987
+ if (BUILD.hostListener && listeners) {
2988
+ // this is called immediately within the element's constructor
2989
+ // initialize our event listeners on the host element
2990
+ // we do this now so that we can listen to events that may
2991
+ // have fired even before the instance is ready
2992
+ if (BUILD.hostListenerTargetParent) {
2993
+ // this component may have event listeners that should be attached to the parent
2994
+ if (attachParentListeners) {
2995
+ // this is being ran from within the connectedCallback
2996
+ // which is important so that we know the host element actually has a parent element
2997
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2998
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
2999
+ }
3000
+ else {
3001
+ // this is being ran from within the component constructor
3002
+ // everything BUT the parent element listeners should be attached at this time
3003
+ // filter out the listeners that are NOT being attached to the parent
3004
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
3005
+ }
3006
+ }
3007
+ listeners.map(([flags, name, method]) => {
3008
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
3009
+ const handler = hostListenerProxy(hostRef, method);
3010
+ const opts = hostListenerOpts(flags);
3011
+ plt.ael(target, name, handler, opts);
3012
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
3013
+ });
3014
+ }
3015
+ };
3016
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
3017
+ try {
3018
+ if (BUILD.lazyLoad) {
3019
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
3020
+ // instance is ready, let's call it's member method for this event
3021
+ hostRef.$lazyInstance$[methodName](ev);
3022
+ }
3023
+ else {
3024
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
3025
+ }
3026
+ }
3027
+ else {
3028
+ hostRef.$hostElement$[methodName](ev);
3029
+ }
3030
+ }
3031
+ catch (e) {
3032
+ consoleError(e);
3033
+ }
3034
+ };
3035
+ const getHostListenerTarget = (elm, flags) => {
3036
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3037
+ return doc;
3038
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3039
+ return win;
3040
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
3041
+ return doc.body;
3042
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
3043
+ return elm.parentElement;
3044
+ return elm;
3045
+ };
3046
+ // prettier-ignore
3047
+ const hostListenerOpts = (flags) => supportsListenerOptions
3048
+ ? ({
3049
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3050
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3051
+ })
3052
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3053
+ /**
3054
+ * Assigns the given value to the nonce property on the runtime platform object.
3055
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
3056
+ * @param nonce The value to be assigned to the platform nonce property.
3057
+ * @returns void
3058
+ */
3059
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
3060
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
3061
+ const insertVdomAnnotations = (doc, staticComponents) => {
3062
+ if (doc != null) {
3063
+ const docData = {
3064
+ hostIds: 0,
3065
+ rootLevelIds: 0,
3066
+ staticComponents: new Set(staticComponents),
3067
+ };
3068
+ const orgLocationNodes = [];
3069
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
3070
+ orgLocationNodes.forEach((orgLocationNode) => {
3071
+ if (orgLocationNode != null) {
3072
+ const nodeRef = orgLocationNode['s-nr'];
3073
+ let hostId = nodeRef['s-host-id'];
3074
+ let nodeId = nodeRef['s-node-id'];
3075
+ let childId = `${hostId}.${nodeId}`;
3076
+ if (hostId == null) {
3077
+ hostId = 0;
3078
+ docData.rootLevelIds++;
3079
+ nodeId = docData.rootLevelIds;
3080
+ childId = `${hostId}.${nodeId}`;
3081
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3082
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
3083
+ }
3084
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
3085
+ if (hostId === 0) {
3086
+ const textContent = nodeRef.nodeValue.trim();
3087
+ if (textContent === '') {
3088
+ // useless whitespace node at the document root
3089
+ orgLocationNode.remove();
3090
+ return;
3091
+ }
3092
+ }
3093
+ const commentBeforeTextNode = doc.createComment(childId);
3094
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3095
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
3096
+ }
3097
+ }
3098
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
3099
+ const orgLocationParentNode = orgLocationNode.parentElement;
3100
+ if (orgLocationParentNode) {
3101
+ if (orgLocationParentNode['s-en'] === '') {
3102
+ // ending with a "." means that the parent element
3103
+ // of this node's original location is a SHADOW dom element
3104
+ // and this node is apart of the root level light dom
3105
+ orgLocationNodeId += `.`;
3106
+ }
3107
+ else if (orgLocationParentNode['s-en'] === 'c') {
3108
+ // ending with a ".c" means that the parent element
3109
+ // of this node's original location is a SCOPED element
3110
+ // and this node is apart of the root level light dom
3111
+ orgLocationNodeId += `.c`;
3112
+ }
3113
+ }
3114
+ orgLocationNode.nodeValue = orgLocationNodeId;
3115
+ }
3116
+ });
3117
+ }
3118
+ };
3119
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3120
+ if (node == null) {
3121
+ return;
3122
+ }
3123
+ if (node['s-nr'] != null) {
3124
+ orgLocationNodes.push(node);
3125
+ }
3126
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3127
+ node.childNodes.forEach((childNode) => {
3128
+ const hostRef = getHostRef(childNode);
3129
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3130
+ const cmpData = {
3131
+ nodeIds: 0,
3132
+ };
3133
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3134
+ }
3135
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3136
+ });
3137
+ }
3138
+ };
3139
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3140
+ if (vnode != null) {
3141
+ const hostId = ++docData.hostIds;
3142
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3143
+ if (hostElm['s-cr'] != null) {
3144
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3145
+ }
3146
+ if (vnode.$children$ != null) {
3147
+ const depth = 0;
3148
+ vnode.$children$.forEach((vnodeChild, index) => {
3149
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3150
+ });
3151
+ }
3152
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
3153
+ const parent = hostElm.parentElement;
3154
+ if (parent && parent.childNodes) {
3155
+ const parentChildNodes = Array.from(parent.childNodes);
3156
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
3157
+ if (comment) {
3158
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3159
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
3160
+ }
3161
+ }
3162
+ }
3163
+ }
3164
+ };
3165
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3166
+ const childElm = vnodeChild.$elm$;
3167
+ if (childElm == null) {
3168
+ return;
3169
+ }
3170
+ const nodeId = cmpData.nodeIds++;
3171
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3172
+ childElm['s-host-id'] = hostId;
3173
+ childElm['s-node-id'] = nodeId;
3174
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3175
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3176
+ }
3177
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
3178
+ const parentNode = childElm.parentNode;
3179
+ const nodeName = parentNode.nodeName;
3180
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
3181
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3182
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3183
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
3184
+ }
3185
+ }
3186
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
3187
+ if (childElm['s-sr']) {
3188
+ const slotName = childElm['s-sn'] || '';
3189
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3190
+ childElm.nodeValue = slotNodeId;
3191
+ }
3192
+ }
3193
+ if (vnodeChild.$children$ != null) {
3194
+ const childDepth = depth + 1;
3195
+ vnodeChild.$children$.forEach((vnode, index) => {
3196
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
3197
+ });
3198
+ }
3199
+ };
3200
+ const hostRefs = /*@__PURE__*/ new WeakMap();
3201
+ const getHostRef = (ref) => hostRefs.get(ref);
3202
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
3203
+ const registerHost = (elm, cmpMeta) => {
3204
+ const hostRef = {
3205
+ $flags$: 0,
3206
+ $hostElement$: elm,
3207
+ $cmpMeta$: cmpMeta,
3208
+ $instanceValues$: new Map(),
3209
+ };
3210
+ if (BUILD.isDev) {
3211
+ hostRef.$renderCount$ = 0;
3212
+ }
3213
+ if (BUILD.method && BUILD.lazyLoad) {
3214
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
3215
+ }
3216
+ if (BUILD.asyncLoading) {
3217
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
3218
+ elm['s-p'] = [];
3219
+ elm['s-rc'] = [];
3220
+ }
3221
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3222
+ return hostRefs.set(elm, hostRef);
3223
+ };
3224
+ const isMemberInElement = (elm, memberName) => memberName in elm;
3225
+ const consoleError = (e, el) => (customError || console.error)(e, el);
3226
+ const STENCIL_DEV_MODE = BUILD.isTesting
3227
+ ? ['STENCIL:'] // E2E testing
3228
+ : [
3229
+ '%cstencil',
3230
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
3231
+ ];
3232
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
3233
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
3234
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
3235
+ const setErrorHandler = (handler) => (customError = handler);
3236
+ const cmpModules = /*@__PURE__*/ new Map();
3237
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
3238
+ // loadModuleImport
3239
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
3240
+ const bundleId = cmpMeta.$lazyBundleId$;
3241
+ if (BUILD.isDev && typeof bundleId !== 'string') {
3242
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
3243
+ return undefined;
3244
+ }
3245
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
3246
+ if (module) {
3247
+ return module[exportName];
3248
+ }
3249
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
3250
+ return import(
3251
+ /* @vite-ignore */
3252
+ /* webpackInclude: /\.entry\.js$/ */
3253
+ /* webpackExclude: /\.system\.entry\.js$/ */
3254
+ /* webpackMode: "lazy" */
3255
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`).then((importedModule) => {
3256
+ if (!BUILD.hotModuleReplacement) {
3257
+ cmpModules.set(bundleId, importedModule);
3258
+ }
3259
+ return importedModule[exportName];
3260
+ }, consoleError);
3261
+ };
3262
+ const styles = /*@__PURE__*/ new Map();
3263
+ const modeResolutionChain = [];
3264
+ const win = typeof window !== 'undefined' ? window : {};
3265
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
3266
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
3267
+ const doc = win.document || { head: {} };
3268
+ const H = (win.HTMLElement || class {
3269
+ });
3270
+ const plt = {
3271
+ $flags$: 0,
3272
+ $resourcesUrl$: '',
3273
+ jmp: (h) => h(),
3274
+ raf: (h) => requestAnimationFrame(h),
3275
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3276
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3277
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
3278
+ };
3279
+ const setPlatformHelpers = (helpers) => {
3280
+ Object.assign(plt, helpers);
3281
+ };
3282
+ const supportsShadow =
3283
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
3284
+ BUILD.shadowDomShim && BUILD.shadowDom
3285
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3286
+ : true;
3287
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3288
+ let supportsListenerOptions = false;
3289
+ try {
3290
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3291
+ get() {
3292
+ supportsListenerOptions = true;
3293
+ },
3294
+ }));
3295
+ }
3296
+ catch (e) { }
3297
+ return supportsListenerOptions;
3298
+ })();
3299
+ const promiseResolve = (v) => Promise.resolve(v);
3300
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3301
+ ? /*@__PURE__*/ (() => {
3302
+ try {
3303
+ new CSSStyleSheet();
3304
+ return typeof new CSSStyleSheet().replaceSync === 'function';
3305
+ }
3306
+ catch (e) { }
3307
+ return false;
3308
+ })()
3309
+ : false;
3310
+ const queueDomReads = [];
3311
+ const queueDomWrites = [];
3312
+ const queueDomWritesLow = [];
3313
+ const queueTask = (queue, write) => (cb) => {
3314
+ queue.push(cb);
3315
+ if (!queuePending) {
3316
+ queuePending = true;
3317
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
3318
+ nextTick(flush);
3319
+ }
3320
+ else {
3321
+ plt.raf(flush);
3322
+ }
3323
+ }
3324
+ };
3325
+ const consume = (queue) => {
3326
+ for (let i = 0; i < queue.length; i++) {
3327
+ try {
3328
+ queue[i](performance.now());
3329
+ }
3330
+ catch (e) {
3331
+ consoleError(e);
3332
+ }
3333
+ }
3334
+ queue.length = 0;
3335
+ };
3336
+ const consumeTimeout = (queue, timeout) => {
3337
+ let i = 0;
3338
+ let ts = 0;
3339
+ while (i < queue.length && (ts = performance.now()) < timeout) {
3340
+ try {
3341
+ queue[i++](ts);
3342
+ }
3343
+ catch (e) {
3344
+ consoleError(e);
3345
+ }
3346
+ }
3347
+ if (i === queue.length) {
3348
+ queue.length = 0;
3349
+ }
3350
+ else if (i !== 0) {
3351
+ queue.splice(0, i);
3352
+ }
3353
+ };
3354
+ const flush = () => {
3355
+ if (BUILD.asyncQueue) {
3356
+ queueCongestion++;
3357
+ }
3358
+ // always force a bunch of medium callbacks to run, but still have
3359
+ // a throttle on how many can run in a certain time
3360
+ // DOM READS!!!
3361
+ consume(queueDomReads);
3362
+ // DOM WRITES!!!
3363
+ if (BUILD.asyncQueue) {
3364
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3365
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3366
+ : Infinity;
3367
+ consumeTimeout(queueDomWrites, timeout);
3368
+ consumeTimeout(queueDomWritesLow, timeout);
3369
+ if (queueDomWrites.length > 0) {
3370
+ queueDomWritesLow.push(...queueDomWrites);
3371
+ queueDomWrites.length = 0;
3372
+ }
3373
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3374
+ // still more to do yet, but we've run out of time
3375
+ // let's let this thing cool off and try again in the next tick
3376
+ plt.raf(flush);
3377
+ }
3378
+ else {
3379
+ queueCongestion = 0;
3380
+ }
3381
+ }
3382
+ else {
3383
+ consume(queueDomWrites);
3384
+ if ((queuePending = queueDomReads.length > 0)) {
3385
+ // still more to do yet, but we've run out of time
3386
+ // let's let this thing cool off and try again in the next tick
3387
+ plt.raf(flush);
3388
+ }
3389
+ }
3390
+ };
3391
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3392
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3393
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3394
+
3395
+ 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, getElement as e, getRenderingRef as f, getAssetPath as g, h, forceUpdate as i, plt as p, registerInstance as r, setNonce as s, win as w };
3396
+
3397
+ //# sourceMappingURL=index-f1a87cf1.js.map