@tarojs/taro-h5 3.6.0-beta.2 → 3.6.0-beta.3

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