@stencil/core 4.43.2 → 5.0.0-next.0

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 (368) hide show
  1. package/bin/stencil.mjs +2 -0
  2. package/dist/chunk-ClPoSABd.mjs +21 -0
  3. package/dist/client-DR9zhmKG.mjs +4449 -0
  4. package/dist/compiler/index.d.mts +187 -0
  5. package/dist/compiler/index.mjs +9 -0
  6. package/dist/compiler/utils/index.d.mts +3 -0
  7. package/dist/compiler/utils/index.mjs +5 -0
  8. package/dist/declarations/stencil-public-compiler.d.ts +4401 -0
  9. package/dist/declarations/stencil-public-compiler.js +53 -0
  10. package/dist/declarations/stencil-public-runtime.d.ts +1857 -0
  11. package/dist/index-Bxo2jCf6.d.mts +77 -0
  12. package/dist/index-szczUd2l.d.mts +6851 -0
  13. package/{internal/stencil-core/index.d.ts → dist/index.d.mts} +7 -3
  14. package/dist/index.mjs +4 -0
  15. package/dist/mock-doc.d.mts +1 -0
  16. package/dist/mock-doc.mjs +3 -0
  17. package/dist/node-sys-BGURUNOZ.mjs +1954 -0
  18. package/{internal → dist/runtime}/app-data/index.d.ts +11 -7
  19. package/dist/runtime/app-data/index.js +100 -0
  20. package/dist/runtime/app-globals/index.d.ts +5 -0
  21. package/dist/runtime/app-globals/index.js +6 -0
  22. package/dist/runtime/client/index.d.ts +2286 -0
  23. package/dist/runtime/client/index.js +4839 -0
  24. package/dist/runtime/index.d.ts +221 -0
  25. package/dist/runtime/index.js +4819 -0
  26. package/dist/runtime/server/index.d.mts +1277 -0
  27. package/dist/runtime/server/index.mjs +5376 -0
  28. package/dist/runtime/server/runner.d.mts +298 -0
  29. package/dist/runtime/server/runner.mjs +1976 -0
  30. package/dist/serialize-BJvhE9aQ.mjs +775 -0
  31. package/dist/stencil-private-Cgcr414u.d.ts +1893 -0
  32. package/dist/sys/node/index.d.mts +33 -0
  33. package/dist/sys/node/index.mjs +7 -0
  34. package/dist/sys/node/worker.d.mts +1 -0
  35. package/dist/sys/node/worker.mjs +60 -0
  36. package/dist/testing/index.d.mts +207 -0
  37. package/dist/testing/index.mjs +1188 -0
  38. package/dist/transpile-CJQcQEVa.mjs +21854 -0
  39. package/dist/validation-BdcPruW_.mjs +1451 -0
  40. package/package.json +88 -232
  41. package/bin/stencil +0 -57
  42. package/cli/config-flags.d.ts +0 -132
  43. package/cli/index.cjs +0 -5816
  44. package/cli/index.d.ts +0 -19
  45. package/cli/index.js +0 -5809
  46. package/cli/package.json +0 -14
  47. package/compiler/lib.d.ts +0 -22
  48. package/compiler/lib.decorators.d.ts +0 -384
  49. package/compiler/lib.decorators.legacy.d.ts +0 -22
  50. package/compiler/lib.dom.asynciterable.d.ts +0 -41
  51. package/compiler/lib.dom.d.ts +0 -29610
  52. package/compiler/lib.dom.iterable.d.ts +0 -493
  53. package/compiler/lib.es2015.collection.d.ts +0 -147
  54. package/compiler/lib.es2015.core.d.ts +0 -597
  55. package/compiler/lib.es2015.d.ts +0 -28
  56. package/compiler/lib.es2015.generator.d.ts +0 -77
  57. package/compiler/lib.es2015.iterable.d.ts +0 -605
  58. package/compiler/lib.es2015.promise.d.ts +0 -81
  59. package/compiler/lib.es2015.proxy.d.ts +0 -128
  60. package/compiler/lib.es2015.reflect.d.ts +0 -144
  61. package/compiler/lib.es2015.symbol.d.ts +0 -46
  62. package/compiler/lib.es2015.symbol.wellknown.d.ts +0 -326
  63. package/compiler/lib.es2016.array.include.d.ts +0 -116
  64. package/compiler/lib.es2016.d.ts +0 -21
  65. package/compiler/lib.es2016.full.d.ts +0 -23
  66. package/compiler/lib.es2016.intl.d.ts +0 -31
  67. package/compiler/lib.es2017.arraybuffer.d.ts +0 -21
  68. package/compiler/lib.es2017.d.ts +0 -26
  69. package/compiler/lib.es2017.date.d.ts +0 -31
  70. package/compiler/lib.es2017.full.d.ts +0 -23
  71. package/compiler/lib.es2017.intl.d.ts +0 -44
  72. package/compiler/lib.es2017.object.d.ts +0 -49
  73. package/compiler/lib.es2017.sharedmemory.d.ts +0 -135
  74. package/compiler/lib.es2017.string.d.ts +0 -45
  75. package/compiler/lib.es2017.typedarrays.d.ts +0 -53
  76. package/compiler/lib.es2018.asyncgenerator.d.ts +0 -77
  77. package/compiler/lib.es2018.asynciterable.d.ts +0 -53
  78. package/compiler/lib.es2018.d.ts +0 -24
  79. package/compiler/lib.es2018.full.d.ts +0 -24
  80. package/compiler/lib.es2018.intl.d.ts +0 -83
  81. package/compiler/lib.es2018.promise.d.ts +0 -30
  82. package/compiler/lib.es2018.regexp.d.ts +0 -37
  83. package/compiler/lib.es2019.array.d.ts +0 -79
  84. package/compiler/lib.es2019.d.ts +0 -24
  85. package/compiler/lib.es2019.full.d.ts +0 -24
  86. package/compiler/lib.es2019.intl.d.ts +0 -23
  87. package/compiler/lib.es2019.object.d.ts +0 -33
  88. package/compiler/lib.es2019.string.d.ts +0 -37
  89. package/compiler/lib.es2019.symbol.d.ts +0 -24
  90. package/compiler/lib.es2020.bigint.d.ts +0 -765
  91. package/compiler/lib.es2020.d.ts +0 -27
  92. package/compiler/lib.es2020.date.d.ts +0 -42
  93. package/compiler/lib.es2020.full.d.ts +0 -24
  94. package/compiler/lib.es2020.intl.d.ts +0 -474
  95. package/compiler/lib.es2020.number.d.ts +0 -28
  96. package/compiler/lib.es2020.promise.d.ts +0 -47
  97. package/compiler/lib.es2020.sharedmemory.d.ts +0 -99
  98. package/compiler/lib.es2020.string.d.ts +0 -44
  99. package/compiler/lib.es2020.symbol.wellknown.d.ts +0 -41
  100. package/compiler/lib.es2021.d.ts +0 -23
  101. package/compiler/lib.es2021.full.d.ts +0 -24
  102. package/compiler/lib.es2021.intl.d.ts +0 -166
  103. package/compiler/lib.es2021.promise.d.ts +0 -48
  104. package/compiler/lib.es2021.string.d.ts +0 -33
  105. package/compiler/lib.es2021.weakref.d.ts +0 -78
  106. package/compiler/lib.es2022.array.d.ts +0 -121
  107. package/compiler/lib.es2022.d.ts +0 -25
  108. package/compiler/lib.es2022.error.d.ts +0 -75
  109. package/compiler/lib.es2022.full.d.ts +0 -24
  110. package/compiler/lib.es2022.intl.d.ts +0 -121
  111. package/compiler/lib.es2022.object.d.ts +0 -26
  112. package/compiler/lib.es2022.regexp.d.ts +0 -39
  113. package/compiler/lib.es2022.string.d.ts +0 -25
  114. package/compiler/lib.es2023.array.d.ts +0 -924
  115. package/compiler/lib.es2023.collection.d.ts +0 -21
  116. package/compiler/lib.es2023.d.ts +0 -22
  117. package/compiler/lib.es2023.full.d.ts +0 -24
  118. package/compiler/lib.es2023.intl.d.ts +0 -56
  119. package/compiler/lib.es2024.arraybuffer.d.ts +0 -65
  120. package/compiler/lib.es2024.collection.d.ts +0 -29
  121. package/compiler/lib.es2024.d.ts +0 -26
  122. package/compiler/lib.es2024.full.d.ts +0 -24
  123. package/compiler/lib.es2024.object.d.ts +0 -29
  124. package/compiler/lib.es2024.promise.d.ts +0 -35
  125. package/compiler/lib.es2024.regexp.d.ts +0 -25
  126. package/compiler/lib.es2024.sharedmemory.d.ts +0 -68
  127. package/compiler/lib.es2024.string.d.ts +0 -29
  128. package/compiler/lib.es5.d.ts +0 -4594
  129. package/compiler/lib.es6.d.ts +0 -23
  130. package/compiler/lib.esnext.array.d.ts +0 -35
  131. package/compiler/lib.esnext.collection.d.ts +0 -96
  132. package/compiler/lib.esnext.d.ts +0 -27
  133. package/compiler/lib.esnext.decorators.d.ts +0 -28
  134. package/compiler/lib.esnext.disposable.d.ts +0 -193
  135. package/compiler/lib.esnext.float16.d.ts +0 -443
  136. package/compiler/lib.esnext.full.d.ts +0 -24
  137. package/compiler/lib.esnext.intl.d.ts +0 -21
  138. package/compiler/lib.esnext.iterator.d.ts +0 -148
  139. package/compiler/lib.esnext.promise.d.ts +0 -34
  140. package/compiler/lib.scripthost.d.ts +0 -322
  141. package/compiler/lib.webworker.asynciterable.d.ts +0 -41
  142. package/compiler/lib.webworker.d.ts +0 -9894
  143. package/compiler/lib.webworker.importscripts.d.ts +0 -23
  144. package/compiler/lib.webworker.iterable.d.ts +0 -287
  145. package/compiler/package.json +0 -8
  146. package/compiler/stencil.d.ts +0 -73
  147. package/compiler/stencil.js +0 -287816
  148. package/compiler/sys/in-memory-fs.d.ts +0 -227
  149. package/compiler/transpile.d.ts +0 -32
  150. package/dev-server/client/app-error.d.ts +0 -20
  151. package/dev-server/client/events.d.ts +0 -6
  152. package/dev-server/client/hmr-components.d.ts +0 -12
  153. package/dev-server/client/hmr-external-styles.d.ts +0 -1
  154. package/dev-server/client/hmr-images.d.ts +0 -1
  155. package/dev-server/client/hmr-inline-styles.d.ts +0 -1
  156. package/dev-server/client/hmr-util.d.ts +0 -39
  157. package/dev-server/client/hmr-window.d.ts +0 -10
  158. package/dev-server/client/index.d.ts +0 -6
  159. package/dev-server/client/index.js +0 -793
  160. package/dev-server/client/logger.d.ts +0 -6
  161. package/dev-server/client/package.json +0 -8
  162. package/dev-server/client/progress.d.ts +0 -3
  163. package/dev-server/client/status.d.ts +0 -4
  164. package/dev-server/client/test/hmr-util.spec.d.ts +0 -1
  165. package/dev-server/client/test/status.spec.d.ts +0 -1
  166. package/dev-server/connector.html +0 -6
  167. package/dev-server/index.d.ts +0 -3
  168. package/dev-server/index.js +0 -247
  169. package/dev-server/package.json +0 -8
  170. package/dev-server/server-process.js +0 -12095
  171. package/dev-server/server-worker-thread.js +0 -39
  172. package/dev-server/static/favicon.ico +0 -0
  173. package/dev-server/templates/directory-index.html +0 -176
  174. package/dev-server/templates/initial-load.html +0 -168
  175. package/dev-server/visualstudio.vbs +0 -82
  176. package/dev-server/xdg-open +0 -1066
  177. package/internal/app-data/index.cjs +0 -119
  178. package/internal/app-data/index.js +0 -92
  179. package/internal/app-data/package.json +0 -15
  180. package/internal/app-globals/index.d.ts +0 -2
  181. package/internal/app-globals/index.js +0 -14
  182. package/internal/app-globals/package.json +0 -14
  183. package/internal/child_process.d.ts +0 -7
  184. package/internal/client/index.js +0 -4736
  185. package/internal/client/package.json +0 -10
  186. package/internal/client/patch-browser.js +0 -45
  187. package/internal/client/polyfills/core-js.js +0 -11
  188. package/internal/client/polyfills/dom.js +0 -79
  189. package/internal/client/polyfills/es5-html-element.js +0 -1
  190. package/internal/client/polyfills/index.js +0 -34
  191. package/internal/client/polyfills/system.js +0 -6
  192. package/internal/client/shadow-css.js +0 -414
  193. package/internal/hydrate/index.js +0 -6671
  194. package/internal/hydrate/package.json +0 -7
  195. package/internal/hydrate/runner.d.ts +0 -287
  196. package/internal/hydrate/runner.js +0 -17950
  197. package/internal/index.d.ts +0 -4
  198. package/internal/index.js +0 -2
  199. package/internal/package.json +0 -9
  200. package/internal/stencil-core/index.cjs +0 -1
  201. package/internal/stencil-core/index.js +0 -18
  202. package/internal/stencil-core/jsx-dev-runtime.cjs +0 -7
  203. package/internal/stencil-core/jsx-dev-runtime.d.ts +0 -41
  204. package/internal/stencil-core/jsx-dev-runtime.js +0 -2
  205. package/internal/stencil-core/jsx-runtime.cjs +0 -8
  206. package/internal/stencil-core/jsx-runtime.d.ts +0 -40
  207. package/internal/stencil-core/jsx-runtime.js +0 -2
  208. package/internal/stencil-private.d.ts +0 -2549
  209. package/internal/stencil-public-compiler.d.ts +0 -2867
  210. package/internal/stencil-public-runtime.d.ts +0 -1860
  211. package/internal/testing/index.js +0 -6528
  212. package/internal/testing/jsx-dev-runtime.d.ts +0 -2
  213. package/internal/testing/jsx-dev-runtime.js +0 -8
  214. package/internal/testing/jsx-runtime.d.ts +0 -2
  215. package/internal/testing/jsx-runtime.js +0 -9
  216. package/internal/testing/package.json +0 -7
  217. package/internal/utils/index.d.ts +0 -1
  218. package/internal/utils/result.d.ts +0 -112
  219. package/mock-doc/index.cjs +0 -10165
  220. package/mock-doc/index.d.ts +0 -1172
  221. package/mock-doc/index.js +0 -10144
  222. package/mock-doc/package.json +0 -15
  223. package/readme.md +0 -94
  224. package/screenshot/compare/assets/favicon.ico +0 -0
  225. package/screenshot/compare/assets/logo.png +0 -0
  226. package/screenshot/compare/build/app.css +0 -1
  227. package/screenshot/compare/build/app.esm.js +0 -1
  228. package/screenshot/compare/build/app.js +0 -33
  229. package/screenshot/compare/build/p-081b0641.js +0 -1
  230. package/screenshot/compare/build/p-227a1e18.entry.js +0 -1
  231. package/screenshot/compare/build/p-2c298727.entry.js +0 -1
  232. package/screenshot/compare/build/p-5479268c.entry.js +0 -1
  233. package/screenshot/compare/build/p-573ec8a4.entry.js +0 -1
  234. package/screenshot/compare/build/p-6ba08604.entry.js +0 -1
  235. package/screenshot/compare/build/p-6bc63295.entry.js +0 -1
  236. package/screenshot/compare/build/p-7a3759fd.entry.js +0 -1
  237. package/screenshot/compare/build/p-7b4e3ba7.js +0 -1
  238. package/screenshot/compare/build/p-988eb362.css +0 -1
  239. package/screenshot/compare/build/p-9b6a9315.js +0 -1
  240. package/screenshot/compare/build/p-b4cc611c.entry.js +0 -1
  241. package/screenshot/compare/build/p-d1bf53f5.entry.js +0 -1
  242. package/screenshot/compare/build/p-e2efe0df.js +0 -1
  243. package/screenshot/compare/build/p-e8ca6d97.entry.js +0 -1
  244. package/screenshot/compare/build/p-ec2f13e0.entry.js +0 -1
  245. package/screenshot/compare/build/p-f0b99977.entry.js +0 -1
  246. package/screenshot/compare/build/p-f4745c2f.entry.js +0 -1
  247. package/screenshot/compare/build/p-fbbae598.js +0 -1
  248. package/screenshot/compare/host.config.json +0 -15
  249. package/screenshot/compare/index.html +0 -1
  250. package/screenshot/compare/manifest.json +0 -13
  251. package/screenshot/connector-base.d.ts +0 -42
  252. package/screenshot/connector-local.d.ts +0 -7
  253. package/screenshot/connector.js +0 -2
  254. package/screenshot/index.d.ts +0 -3
  255. package/screenshot/index.js +0 -2433
  256. package/screenshot/local-connector.js +0 -2
  257. package/screenshot/package.json +0 -15
  258. package/screenshot/pixel-match.d.ts +0 -1
  259. package/screenshot/pixel-match.js +0 -2315
  260. package/screenshot/screenshot-compare.d.ts +0 -20
  261. package/screenshot/screenshot-fs.d.ts +0 -14
  262. package/sys/node/460.node-fetch.js +0 -451
  263. package/sys/node/autoprefixer.js +0 -9
  264. package/sys/node/glob.js +0 -1
  265. package/sys/node/graceful-fs.js +0 -1
  266. package/sys/node/index.d.ts +0 -39
  267. package/sys/node/index.js +0 -64
  268. package/sys/node/node-fetch.js +0 -12
  269. package/sys/node/package.json +0 -8
  270. package/sys/node/prompts.js +0 -1
  271. package/sys/node/worker.js +0 -4
  272. package/testing/index.d.ts +0 -9
  273. package/testing/index.js +0 -13064
  274. package/testing/jest/jest-27-and-under/jest-config.d.ts +0 -16
  275. package/testing/jest/jest-27-and-under/jest-environment.d.ts +0 -2
  276. package/testing/jest/jest-27-and-under/jest-facade.d.ts +0 -155
  277. package/testing/jest/jest-27-and-under/jest-preprocessor.d.ts +0 -59
  278. package/testing/jest/jest-27-and-under/jest-preset.d.ts +0 -3
  279. package/testing/jest/jest-27-and-under/jest-runner.d.ts +0 -11
  280. package/testing/jest/jest-27-and-under/jest-screenshot.d.ts +0 -2
  281. package/testing/jest/jest-27-and-under/jest-serializer.d.ts +0 -4
  282. package/testing/jest/jest-27-and-under/jest-setup-test-framework.d.ts +0 -9
  283. package/testing/jest/jest-27-and-under/matchers/attributes.d.ts +0 -14
  284. package/testing/jest/jest-27-and-under/matchers/class-list.d.ts +0 -12
  285. package/testing/jest/jest-27-and-under/matchers/events.d.ts +0 -25
  286. package/testing/jest/jest-27-and-under/matchers/html.d.ts +0 -13
  287. package/testing/jest/jest-27-and-under/matchers/index.d.ts +0 -24
  288. package/testing/jest/jest-27-and-under/matchers/screenshot.d.ts +0 -5
  289. package/testing/jest/jest-27-and-under/matchers/text.d.ts +0 -4
  290. package/testing/jest/jest-27-and-under/test/jest-config.spec.d.ts +0 -1
  291. package/testing/jest/jest-27-and-under/test/jest-preprocessor.spec.d.ts +0 -1
  292. package/testing/jest/jest-27-and-under/test/jest-runner.spec.d.ts +0 -1
  293. package/testing/jest/jest-27-and-under/test/jest-serializer.spec.d.ts +0 -1
  294. package/testing/jest/jest-27-and-under/test/jest-setup-test-framework.spec.d.ts +0 -1
  295. package/testing/jest/jest-28/jest-config.d.ts +0 -16
  296. package/testing/jest/jest-28/jest-environment.d.ts +0 -2
  297. package/testing/jest/jest-28/jest-facade.d.ts +0 -134
  298. package/testing/jest/jest-28/jest-preprocessor.d.ts +0 -35
  299. package/testing/jest/jest-28/jest-preset.d.ts +0 -3
  300. package/testing/jest/jest-28/jest-runner.d.ts +0 -11
  301. package/testing/jest/jest-28/jest-screenshot.d.ts +0 -2
  302. package/testing/jest/jest-28/jest-serializer.d.ts +0 -4
  303. package/testing/jest/jest-28/jest-setup-test-framework.d.ts +0 -9
  304. package/testing/jest/jest-28/matchers/attributes.d.ts +0 -14
  305. package/testing/jest/jest-28/matchers/class-list.d.ts +0 -12
  306. package/testing/jest/jest-28/matchers/events.d.ts +0 -25
  307. package/testing/jest/jest-28/matchers/html.d.ts +0 -13
  308. package/testing/jest/jest-28/matchers/index.d.ts +0 -24
  309. package/testing/jest/jest-28/matchers/screenshot.d.ts +0 -5
  310. package/testing/jest/jest-28/matchers/text.d.ts +0 -4
  311. package/testing/jest/jest-28/test/jest-config.spec.d.ts +0 -1
  312. package/testing/jest/jest-28/test/jest-preprocessor.spec.d.ts +0 -1
  313. package/testing/jest/jest-28/test/jest-runner.spec.d.ts +0 -1
  314. package/testing/jest/jest-28/test/jest-serializer.spec.d.ts +0 -1
  315. package/testing/jest/jest-28/test/jest-setup-test-framework.spec.d.ts +0 -1
  316. package/testing/jest/jest-29/jest-config.d.ts +0 -16
  317. package/testing/jest/jest-29/jest-environment.d.ts +0 -2
  318. package/testing/jest/jest-29/jest-facade.d.ts +0 -136
  319. package/testing/jest/jest-29/jest-preprocessor.d.ts +0 -35
  320. package/testing/jest/jest-29/jest-preset.d.ts +0 -3
  321. package/testing/jest/jest-29/jest-runner.d.ts +0 -11
  322. package/testing/jest/jest-29/jest-screenshot.d.ts +0 -2
  323. package/testing/jest/jest-29/jest-serializer.d.ts +0 -4
  324. package/testing/jest/jest-29/jest-setup-test-framework.d.ts +0 -9
  325. package/testing/jest/jest-29/matchers/attributes.d.ts +0 -14
  326. package/testing/jest/jest-29/matchers/class-list.d.ts +0 -12
  327. package/testing/jest/jest-29/matchers/events.d.ts +0 -25
  328. package/testing/jest/jest-29/matchers/html.d.ts +0 -13
  329. package/testing/jest/jest-29/matchers/index.d.ts +0 -24
  330. package/testing/jest/jest-29/matchers/screenshot.d.ts +0 -5
  331. package/testing/jest/jest-29/matchers/text.d.ts +0 -4
  332. package/testing/jest/jest-29/test/jest-config.spec.d.ts +0 -1
  333. package/testing/jest/jest-29/test/jest-preprocessor.spec.d.ts +0 -1
  334. package/testing/jest/jest-29/test/jest-runner.spec.d.ts +0 -1
  335. package/testing/jest/jest-29/test/jest-serializer.spec.d.ts +0 -1
  336. package/testing/jest/jest-29/test/jest-setup-test-framework.spec.d.ts +0 -1
  337. package/testing/jest/jest-apis.d.ts +0 -86
  338. package/testing/jest/jest-facade.d.ts +0 -74
  339. package/testing/jest/jest-stencil-connector.d.ts +0 -65
  340. package/testing/jest/test/jest-stencil-connector.spec.d.ts +0 -1
  341. package/testing/jest-environment.js +0 -3
  342. package/testing/jest-preprocessor.js +0 -3
  343. package/testing/jest-preset.js +0 -2
  344. package/testing/jest-runner.js +0 -3
  345. package/testing/jest-setuptestframework.js +0 -3
  346. package/testing/mock-fetch.d.ts +0 -11
  347. package/testing/mocks.d.ts +0 -56
  348. package/testing/package.json +0 -8
  349. package/testing/puppeteer/index.d.ts +0 -2
  350. package/testing/puppeteer/puppeteer-browser.d.ts +0 -6
  351. package/testing/puppeteer/puppeteer-declarations.d.ts +0 -414
  352. package/testing/puppeteer/puppeteer-element.d.ts +0 -67
  353. package/testing/puppeteer/puppeteer-emulate.d.ts +0 -2
  354. package/testing/puppeteer/puppeteer-events.d.ts +0 -21
  355. package/testing/puppeteer/puppeteer-page.d.ts +0 -2
  356. package/testing/puppeteer/puppeteer-screenshot.d.ts +0 -27
  357. package/testing/puppeteer/test/puppeteer-screenshot.spec.d.ts +0 -1
  358. package/testing/reset-build-conditionals.d.ts +0 -12
  359. package/testing/spec-page.d.ts +0 -7
  360. package/testing/test/testing-utils.spec.d.ts +0 -1
  361. package/testing/test-transpile.d.ts +0 -2
  362. package/testing/testing-logger.d.ts +0 -26
  363. package/testing/testing-sys.d.ts +0 -6
  364. package/testing/testing-utils.d.ts +0 -80
  365. package/testing/testing.d.ts +0 -2
  366. /package/{internal → dist/declarations}/stencil-ext-modules.d.ts +0 -0
  367. /package/{internal → dist/declarations}/stencil-public-docs.d.ts +0 -0
  368. /package/{screenshot/compare/build/index.esm.js → dist/declarations/stencil-public-runtime.js} +0 -0
@@ -0,0 +1,4819 @@
1
+ import { BUILD, NAMESPACE } from "./app-data/index.js";
2
+ import { globalStyles } from "./app-globals/index.js";
3
+
4
+ //#region src/client/client-build.ts
5
+ const Build = {
6
+ isDev: BUILD.isDev ? true : false,
7
+ isBrowser: true,
8
+ isServer: false,
9
+ isTesting: BUILD.isTesting ? true : false
10
+ };
11
+
12
+ //#endregion
13
+ //#region src/utils/constants.ts
14
+ const MF_String = 1;
15
+ const MF_Number = 2;
16
+ const MF_Boolean = 4;
17
+ const MF_Any = 8;
18
+ const MF_Unknown = 16;
19
+ const MF_State = 32;
20
+ const MEMBER_FLAGS = {
21
+ String: MF_String,
22
+ Number: MF_Number,
23
+ Boolean: MF_Boolean,
24
+ Any: MF_Any,
25
+ Unknown: MF_Unknown,
26
+ State: MF_State,
27
+ Method: 64,
28
+ Event: 128,
29
+ Element: 256,
30
+ ReflectAttr: 512,
31
+ Mutable: 1024,
32
+ Getter: 2048,
33
+ Setter: 4096,
34
+ Prop: 31,
35
+ HasAttribute: 31,
36
+ PropLike: 63
37
+ };
38
+ const WATCH_FLAGS = { Immediate: 1 };
39
+ const EVENT_FLAGS = {
40
+ Cancellable: 1,
41
+ Composed: 2,
42
+ Bubbles: 4
43
+ };
44
+ const LISTENER_FLAGS = {
45
+ Passive: 1,
46
+ Capture: 2,
47
+ TargetDocument: 4,
48
+ TargetWindow: 8,
49
+ TargetBody: 16,
50
+ TargetParent: 32
51
+ };
52
+ const HOST_FLAGS = {
53
+ hasConnected: 1,
54
+ hasRendered: 2,
55
+ isWaitingForChildren: 4,
56
+ isConstructingInstance: 8,
57
+ isQueuedForUpdate: 16,
58
+ hasInitializedComponent: 32,
59
+ hasLoadedComponent: 64,
60
+ isWatchReady: 128,
61
+ isListenReady: 256,
62
+ needsRerender: 512,
63
+ devOnRender: 1024,
64
+ devOnDidLoad: 2048
65
+ };
66
+ const CF_scopedCssEncapsulation = 2;
67
+ const CF_needsShadowDomShim = 8;
68
+ /**
69
+ * A set of flags used for bitwise calculations against {@link ComponentRuntimeMeta#$flags$}.
70
+ *
71
+ * These flags should only be used in conjunction with {@link ComponentRuntimeMeta#$flags$}.
72
+ * They should _not_ be used for calculations against other fields/numbers
73
+ */
74
+ const CMP_FLAGS = {
75
+ shadowDomEncapsulation: 1,
76
+ scopedCssEncapsulation: CF_scopedCssEncapsulation,
77
+ hasSlotRelocation: 4,
78
+ needsShadowDomShim: CF_needsShadowDomShim,
79
+ shadowDelegatesFocus: 16,
80
+ hasMode: 32,
81
+ needsScopedEncapsulation: CF_scopedCssEncapsulation | CF_needsShadowDomShim,
82
+ formAssociated: 64,
83
+ shadowNeedsScopedCss: 128,
84
+ hasSlot: 256,
85
+ hasModernPropertyDecls: 512,
86
+ shadowSlotAssignmentManual: 1024
87
+ };
88
+ /**
89
+ * Namespaces
90
+ */
91
+ const SVG_NS = "http://www.w3.org/2000/svg";
92
+ const HTML_NS = "http://www.w3.org/1999/xhtml";
93
+ /**
94
+ * DOM Node types
95
+ *
96
+ * See https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
97
+ *
98
+ * Note: this is a duplicate of the `NODE_TYPES` enum in mock-doc, it's
99
+ * copied over here so that we do not need to introduce a dependency on the
100
+ * mock-doc bundle in the runtime. See
101
+ * https://github.com/stenciljs/core/pull/5705 for more details.
102
+ */
103
+ const NODE_TYPES = {
104
+ ELEMENT_NODE: 1,
105
+ ATTRIBUTE_NODE: 2,
106
+ TEXT_NODE: 3,
107
+ CDATA_SECTION_NODE: 4,
108
+ ENTITY_REFERENCE_NODE: 5,
109
+ ENTITY_NODE: 6,
110
+ PROCESSING_INSTRUCTION_NODE: 7,
111
+ COMMENT_NODE: 8,
112
+ DOCUMENT_NODE: 9,
113
+ DOCUMENT_TYPE_NODE: 10,
114
+ DOCUMENT_FRAGMENT_NODE: 11,
115
+ NOTATION_NODE: 12
116
+ };
117
+ /**
118
+ * Represents a primitive type.
119
+ * Described in https://w3c.github.io/webdriver-bidi/#type-script-PrimitiveProtocolValue.
120
+ */
121
+ const PrimitiveType = {
122
+ Undefined: "undefined",
123
+ Null: "null",
124
+ String: "string",
125
+ Number: "number",
126
+ SpecialNumber: "number",
127
+ Boolean: "boolean",
128
+ BigInt: "bigint"
129
+ };
130
+ /**
131
+ * Represents a non-primitive type.
132
+ * Described in https://w3c.github.io/webdriver-bidi/#type-script-RemoteValue.
133
+ * @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead.
134
+ */
135
+ const NonPrimitiveType = {
136
+ Array: "array",
137
+ Date: "date",
138
+ Map: "map",
139
+ Object: "object",
140
+ RegularExpression: "regexp",
141
+ Set: "set",
142
+ Channel: "channel",
143
+ Symbol: "symbol"
144
+ };
145
+ /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
146
+ const TYPE_CONSTANT = "type";
147
+ /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
148
+ const VALUE_CONSTANT = "value";
149
+ /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
150
+ const SERIALIZED_PREFIX = "serialized:";
151
+
152
+ //#endregion
153
+ //#region src/utils/get-prop-descriptor.ts
154
+ /**
155
+ * Walks up a prototype chain to find a property descriptor.
156
+ * Stops before reaching native DOM prototypes (HTMLElement, etc.) to avoid
157
+ * treating native properties like `hidden` as component-defined getters.
158
+ * @param obj - The object to search on.
159
+ * @param memberName - The name of the member to find.
160
+ * @param getOnly - If true, only returns descriptors with a getter (i.e. ignores properties that are only fields or have setters without getters).
161
+ * @returns The property descriptor if found, otherwise undefined.
162
+ */
163
+ function getPropertyDescriptor(obj, memberName, getOnly) {
164
+ const stopAt = typeof HTMLElement !== "undefined" ? HTMLElement.prototype : null;
165
+ while (obj && obj !== stopAt) {
166
+ const desc = Object.getOwnPropertyDescriptor(obj, memberName);
167
+ if (desc && (!getOnly || desc.get)) return desc;
168
+ obj = Object.getPrototypeOf(obj);
169
+ }
170
+ }
171
+
172
+ //#endregion
173
+ //#region src/utils/es2022-rewire-class-members.ts
174
+ /**
175
+ * - Re-wires component prototype `get` / `set` with instance `@State` / `@Prop` decorated fields.
176
+ * - Makes sure the initial value from the `Element` is synced to the instance `@Prop` decorated fields.
177
+ *
178
+ * Background:
179
+ * During component init, Stencil loops through any `@Prop()` or `@State()` decorated properties
180
+ * and sets up getters and setters for each (within `src/runtime/proxy-component.ts`) on a component prototype.
181
+ *
182
+ * These accessors sync-up class instances with their `Element` and controls re-renders.
183
+ * With modern JS, compiled classes (e.g. `target: 'es2022'`) compiled Stencil components went from:
184
+ *
185
+ * ```ts
186
+ * class MyComponent {
187
+ * constructor() {
188
+ * this.prop1 = 'value1';
189
+ * }
190
+ * }
191
+ * ```
192
+ * To:
193
+ * ```ts
194
+ * class MyComponent {
195
+ * prop1 = 'value2';
196
+ * // ^^ These override the accessors originally set on the prototype
197
+ * }
198
+ * ```
199
+ *
200
+ * @param instance - class instance to re-wire
201
+ * @param hostRef - component reference meta
202
+ */
203
+ const reWireGetterSetter = (instance, hostRef) => {
204
+ const cmpMeta = hostRef.$cmpMeta$;
205
+ Object.entries(cmpMeta.$members$ ?? {}).map(([memberName, [memberFlags]]) => {
206
+ if ((BUILD.state || BUILD.prop) && (memberFlags & MEMBER_FLAGS.Prop || memberFlags & MEMBER_FLAGS.State)) {
207
+ const ogValue = instance[memberName];
208
+ const ogDescriptor = getPropertyDescriptor(Object.getPrototypeOf(instance), memberName, true) || Object.getOwnPropertyDescriptor(instance, memberName);
209
+ if (ogDescriptor) Object.defineProperty(instance, memberName, {
210
+ get() {
211
+ return ogDescriptor.get.call(this);
212
+ },
213
+ set(newValue) {
214
+ ogDescriptor.set.call(this, newValue);
215
+ },
216
+ configurable: true,
217
+ enumerable: true
218
+ });
219
+ if (hostRef.$instanceValues$.has(memberName)) instance[memberName] = hostRef.$instanceValues$.get(memberName);
220
+ else if (ogValue !== void 0) instance[memberName] = ogValue;
221
+ }
222
+ });
223
+ };
224
+
225
+ //#endregion
226
+ //#region src/client/client-host-ref.ts
227
+ /**
228
+ * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
229
+ *
230
+ * @param ref the runtime ref of interest
231
+ * @returns the Host reference (if found) or undefined
232
+ */
233
+ const getHostRef = (ref) => {
234
+ if (ref.__stencil__getHostRef) return ref.__stencil__getHostRef();
235
+ };
236
+ /**
237
+ * Register a host element for a Stencil component, setting up various metadata
238
+ * and callbacks based on {@link BUILD} flags as well as the component's runtime
239
+ * metadata.
240
+ *
241
+ * @param hostElement the host element to register
242
+ * @param cmpMeta runtime metadata for that component
243
+ * @returns a reference to the host ref WeakMap
244
+ */
245
+ const registerHost = (hostElement, cmpMeta) => {
246
+ const hostRef = {
247
+ $flags$: 0,
248
+ $hostElement$: hostElement,
249
+ $cmpMeta$: cmpMeta,
250
+ $instanceValues$: /* @__PURE__ */ new Map(),
251
+ $serializerValues$: /* @__PURE__ */ new Map()
252
+ };
253
+ if (BUILD.isDev) hostRef.$renderCount$ = 0;
254
+ if (BUILD.method && BUILD.lazyLoad) hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
255
+ if (BUILD.asyncLoading) {
256
+ hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
257
+ hostElement["s-p"] = [];
258
+ hostElement["s-rc"] = [];
259
+ }
260
+ if (BUILD.lazyLoad) hostRef.$fetchedCbList$ = [];
261
+ const ref = hostRef;
262
+ hostElement.__stencil__getHostRef = () => ref;
263
+ if (!BUILD.lazyLoad && cmpMeta.$flags$ & CMP_FLAGS.hasModernPropertyDecls && (BUILD.state || BUILD.prop)) reWireGetterSetter(hostElement, hostRef);
264
+ return ref;
265
+ };
266
+ const isMemberInElement = (elm, memberName) => memberName in elm;
267
+
268
+ //#endregion
269
+ //#region src/client/client-log.ts
270
+ let customError;
271
+ const consoleError = (e, el) => (customError || console.error)(e, el);
272
+ const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
273
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
274
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
275
+
276
+ //#endregion
277
+ //#region src/client/client-load-module.ts
278
+ const cmpModules = /* @__PURE__ */ new Map();
279
+ /**
280
+ * We need to separate out this prefix so that Esbuild doesn't try to resolve
281
+ * the below, but instead retains a dynamic `import()` statement in the
282
+ * emitted code.
283
+ *
284
+ * See here for details https://esbuild.github.io/api/#non-analyzable-imports
285
+ *
286
+ * We need to do this in order to prevent Esbuild from analyzing / transforming
287
+ * the input. However some _other_ bundlers will _not_ work with such an import
288
+ * if it _lacks_ a leading `"./"`, so we thus we have to do a little dance
289
+ * where here in the source code it must be like this, so that an undesirable
290
+ * transformation that Esbuild would otherwise carry out doesn't occur, but we
291
+ * actually need to then manually edit the bundled Esbuild code later on to fix
292
+ * that. We do this with plugins in the Esbuild and Rollup bundles which
293
+ * include this file.
294
+ */
295
+ const MODULE_IMPORT_PREFIX = "./";
296
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
297
+ const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
298
+ const bundleId = cmpMeta.$lazyBundleId$;
299
+ if (BUILD.isDev && typeof bundleId !== "string") {
300
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
301
+ return;
302
+ } else if (!bundleId) return;
303
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
304
+ if (module) return module[exportName];
305
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
306
+ return import(
307
+ /* @vite-ignore */
308
+ /* webpackInclude: /\.entry\.js$/ */
309
+ /* webpackExclude: /\.system\.entry\.js$/ */
310
+ /* webpackMode: "lazy" */
311
+ `${MODULE_IMPORT_PREFIX}${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? "?s-hmr=" + hmrVersionId : ""}`
312
+ ).then((importedModule) => {
313
+ if (!BUILD.hotModuleReplacement) cmpModules.set(bundleId, importedModule);
314
+ return importedModule[exportName];
315
+ }, (e) => {
316
+ consoleError(e, hostRef.$hostElement$);
317
+ });
318
+ };
319
+
320
+ //#endregion
321
+ //#region src/client/client-style.ts
322
+ const styles = /* @__PURE__ */ new Map();
323
+ const modeResolutionChain = [];
324
+ const needsScopedSSR = () => false;
325
+
326
+ //#endregion
327
+ //#region src/runtime/runtime-constants.ts
328
+ /**
329
+ * Bit flags for recording various properties of VDom nodes
330
+ */
331
+ const VNODE_FLAGS = {
332
+ isSlotReference: 1,
333
+ isSlotFallback: 2,
334
+ isHost: 4
335
+ };
336
+ const PROXY_FLAGS = {
337
+ isElementConstructor: 1,
338
+ proxyState: 2
339
+ };
340
+ const PF_appLoaded = 2;
341
+ const PF_queueSync = 4;
342
+ const PLATFORM_FLAGS = {
343
+ isTmpDisconnected: 1,
344
+ appLoaded: PF_appLoaded,
345
+ queueSync: PF_queueSync,
346
+ queueMask: PF_appLoaded | PF_queueSync
347
+ };
348
+ /**
349
+ * A (subset) of node types which are relevant for the Stencil runtime. These
350
+ * values are based on the values which can possibly be returned by the
351
+ * `.nodeType` property of a DOM node. See here for details:
352
+ *
353
+ * {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
354
+ */
355
+ const NODE_TYPE = {
356
+ ElementNode: 1,
357
+ TextNode: 3,
358
+ CommentNode: 8,
359
+ DocumentNode: 9,
360
+ DocumentTypeNode: 10,
361
+ DocumentFragment: 11
362
+ };
363
+ const CONTENT_REF_ID = "r";
364
+ const ORG_LOCATION_ID = "o";
365
+ const SLOT_NODE_ID = "s";
366
+ const TEXT_NODE_ID = "t";
367
+ const COMMENT_NODE_ID = "c";
368
+ const HYDRATE_ID = "s-id";
369
+ const HYDRATED_STYLE_ID = "sty-id";
370
+ const HYDRATE_CHILD_ID = "c-id";
371
+ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
372
+ const STENCIL_DOC_DATA = "_stencilDocData";
373
+ const DEFAULT_DOC_DATA = {
374
+ hostIds: 0,
375
+ rootLevelIds: 0,
376
+ staticComponents: /* @__PURE__ */ new Set()
377
+ };
378
+ /**
379
+ * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
380
+ *
381
+ * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
382
+ * support as of Stencil v4.
383
+ */
384
+ const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
385
+ const XLINK_NS = "http://www.w3.org/1999/xlink";
386
+ const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
387
+ "formAssociatedCallback",
388
+ "formResetCallback",
389
+ "formDisabledCallback",
390
+ "formStateRestoreCallback"
391
+ ];
392
+
393
+ //#endregion
394
+ //#region src/client/client-window.ts
395
+ const win = typeof window !== "undefined" ? window : {};
396
+ const H = win.HTMLElement || class {};
397
+ const plt = {
398
+ $flags$: 0,
399
+ $resourcesUrl$: "",
400
+ jmp: (h) => h(),
401
+ raf: (h) => requestAnimationFrame(h),
402
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
403
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
404
+ ce: (eventName, opts) => new CustomEvent(eventName, opts)
405
+ };
406
+ const supportsShadow = BUILD.shadowDom;
407
+ const supportsListenerOptions = /* @__PURE__ */ (() => {
408
+ let supportsListenerOptions = false;
409
+ try {
410
+ win.document?.addEventListener("e", null, Object.defineProperty({}, "passive", { get() {
411
+ supportsListenerOptions = true;
412
+ } }));
413
+ } catch (e) {}
414
+ return supportsListenerOptions;
415
+ })();
416
+ const promiseResolve = (v) => Promise.resolve(v);
417
+ const supportsConstructableStylesheets = BUILD.constructableCSS ? /* @__PURE__ */ (() => {
418
+ try {
419
+ if (!win.document.adoptedStyleSheets) return false;
420
+ new CSSStyleSheet();
421
+ return typeof new CSSStyleSheet().replaceSync === "function";
422
+ } catch (e) {}
423
+ return false;
424
+ })() : false;
425
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable : false;
426
+
427
+ //#endregion
428
+ //#region src/client/client-task-queue.ts
429
+ let queueCongestion = 0;
430
+ let queuePending = false;
431
+ const queueDomReads = [];
432
+ const queueDomWrites = [];
433
+ const queueDomWritesLow = [];
434
+ const queueTask = (queue, write) => (cb) => {
435
+ queue.push(cb);
436
+ if (!queuePending) {
437
+ queuePending = true;
438
+ if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush);
439
+ else plt.raf(flush);
440
+ }
441
+ };
442
+ const consume = (queue) => {
443
+ for (let i = 0; i < queue.length; i++) try {
444
+ queue[i](performance.now());
445
+ } catch (e) {
446
+ consoleError(e);
447
+ }
448
+ queue.length = 0;
449
+ };
450
+ const consumeTimeout = (queue, timeout) => {
451
+ let i = 0;
452
+ let ts = 0;
453
+ while (i < queue.length && (ts = performance.now()) < timeout) try {
454
+ queue[i++](ts);
455
+ } catch (e) {
456
+ consoleError(e);
457
+ }
458
+ if (i === queue.length) queue.length = 0;
459
+ else if (i !== 0) queue.splice(0, i);
460
+ };
461
+ const flush = () => {
462
+ if (BUILD.asyncQueue) queueCongestion++;
463
+ consume(queueDomReads);
464
+ if (BUILD.asyncQueue) {
465
+ const timeout = (plt.$flags$ & PLATFORM_FLAGS.queueMask) === PLATFORM_FLAGS.appLoaded ? performance.now() + 14 * Math.ceil(queueCongestion * (1 / 10)) : Infinity;
466
+ consumeTimeout(queueDomWrites, timeout);
467
+ consumeTimeout(queueDomWritesLow, timeout);
468
+ if (queueDomWrites.length > 0) {
469
+ queueDomWritesLow.push(...queueDomWrites);
470
+ queueDomWrites.length = 0;
471
+ }
472
+ if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) plt.raf(flush);
473
+ else queueCongestion = 0;
474
+ } else {
475
+ consume(queueDomWrites);
476
+ if (queuePending = queueDomReads.length > 0) plt.raf(flush);
477
+ }
478
+ };
479
+ const nextTick = (cb) => promiseResolve().then(cb);
480
+ const writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
481
+
482
+ //#endregion
483
+ //#region src/runtime/asset-path.ts
484
+ const getAssetPath = (path) => {
485
+ const base = plt.$resourcesUrl$ || new URL(".", import.meta.url).href;
486
+ const assetUrl = new URL(path, base);
487
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
488
+ };
489
+ const setAssetPath = (path) => plt.$resourcesUrl$ = path;
490
+
491
+ //#endregion
492
+ //#region src/utils/style.ts
493
+ /**
494
+ * If (1) styles is not empty string, and (2) constructable stylesheets are supported,
495
+ * then make a stylesheet.
496
+ *
497
+ * @param styles - The styles to add to the stylesheet. If empty string, then no stylesheet is returned.
498
+ * @returns A stylesheet if it can be created, otherwise undefined.
499
+ */
500
+ function createStyleSheetIfNeededAndSupported(styles) {
501
+ if (!styles || !supportsConstructableStylesheets) return void 0;
502
+ const sheet = new CSSStyleSheet();
503
+ sheet.replaceSync(styles);
504
+ return sheet;
505
+ }
506
+
507
+ //#endregion
508
+ //#region src/utils/shadow-root.ts
509
+ let globalStyleSheet;
510
+ const GLOBAL_STYLE_ID = "sc-global";
511
+ function createShadowRoot(cmpMeta) {
512
+ const opts = { mode: "open" };
513
+ if (BUILD.shadowDelegatesFocus) opts.delegatesFocus = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDelegatesFocus);
514
+ if (BUILD.shadowSlotAssignmentManual) {
515
+ if (!!(cmpMeta.$flags$ & CMP_FLAGS.shadowSlotAssignmentManual)) opts.slotAssignment = "manual";
516
+ }
517
+ const shadowRoot = this.attachShadow(opts);
518
+ if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported(globalStyles) ?? null;
519
+ if (globalStyleSheet) if (supportsMutableAdoptedStyleSheets) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
520
+ else shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
521
+ else if (globalStyles && !supportsConstructableStylesheets) {
522
+ const styleElm = document.createElement("style");
523
+ styleElm.innerHTML = globalStyles;
524
+ if (BUILD.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, GLOBAL_STYLE_ID);
525
+ shadowRoot.prepend(styleElm);
526
+ }
527
+ }
528
+
529
+ //#endregion
530
+ //#region src/runtime/slot-polyfill-utils.ts
531
+ /**
532
+ * Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
533
+ * are slot fallback nodes - `<slot-fb>...</slot-fb>`
534
+ *
535
+ * A slot fallback node should be visible by default. Then, it should be
536
+ * conditionally hidden if:
537
+ *
538
+ * - it has a sibling with a `slot` property set to its slot name or if
539
+ * - it is a default fallback slot node, in which case we hide if it has any
540
+ * content
541
+ *
542
+ * @param elm the element of interest
543
+ */
544
+ const updateFallbackSlotVisibility = (elm) => {
545
+ const childNodes = internalCall(elm, "childNodes");
546
+ if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
547
+ if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
548
+ else slotNode.hidden = false;
549
+ });
550
+ let i = 0;
551
+ for (i = 0; i < childNodes.length; i++) {
552
+ const childNode = childNodes[i];
553
+ if (childNode.nodeType === NODE_TYPE.ElementNode && internalCall(childNode, "childNodes").length) updateFallbackSlotVisibility(childNode);
554
+ }
555
+ };
556
+ /**
557
+ * Get's the child nodes of a component that are actually slotted.
558
+ * It does this by using root nodes of a component; for each slotted node there is a
559
+ * corresponding slot location node which points to the slotted node (via `['s-nr']`).
560
+ *
561
+ * This is only required until all patches are unified / switched on all the time (then we can rely on `childNodes`)
562
+ * either under 'experimentalSlotFixes' or on by default
563
+ * @param childNodes all 'internal' child nodes of the component
564
+ * @returns An array of slotted reference nodes.
565
+ */
566
+ const getSlottedChildNodes = (childNodes) => {
567
+ const result = [];
568
+ for (let i = 0; i < childNodes.length; i++) {
569
+ const slottedNode = childNodes[i]["s-nr"] || void 0;
570
+ if (slottedNode && slottedNode.isConnected) result.push(slottedNode);
571
+ }
572
+ return result;
573
+ };
574
+ /**
575
+ * Recursively searches a series of child nodes for slot node/s, optionally with a provided slot name.
576
+ * @param childNodes the nodes to search for a slot with a specific name. Should be an element's root nodes.
577
+ * @param hostName the host name of the slot to match on.
578
+ * @param slotName the name of the slot to match on.
579
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
580
+ */
581
+ function getHostSlotNodes(childNodes, hostName, slotName) {
582
+ let i = 0;
583
+ let slottedNodes = [];
584
+ let childNode;
585
+ for (; i < childNodes.length; i++) {
586
+ childNode = childNodes[i];
587
+ if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
588
+ slottedNodes.push(childNode);
589
+ if (typeof slotName !== "undefined") return slottedNodes;
590
+ }
591
+ slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
592
+ }
593
+ return slottedNodes;
594
+ }
595
+ /**
596
+ * Get all 'child' sibling nodes of a slot node
597
+ * @param slot - the slot node to get the child nodes from
598
+ * @param slotName - the name of the slot to match on
599
+ * @param includeSlot - whether to include the slot node in the result
600
+ * @returns child nodes of the slot node
601
+ */
602
+ const getSlotChildSiblings = (slot, slotName, includeSlot = true) => {
603
+ const childNodes = [];
604
+ if (includeSlot && slot["s-sr"] || !slot["s-sr"]) childNodes.push(slot);
605
+ let node = slot;
606
+ while (node = node.nextSibling) if (getSlotName(node) === slotName && (includeSlot || !node["s-sr"])) childNodes.push(node);
607
+ return childNodes;
608
+ };
609
+ /**
610
+ * Check whether a node is located in a given named slot.
611
+ *
612
+ * @param nodeToRelocate the node of interest
613
+ * @param slotName the slot name to check
614
+ * @returns whether the node is located in the slot or not
615
+ */
616
+ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
617
+ if (nodeToRelocate.nodeType === NODE_TYPE.ElementNode) {
618
+ if (nodeToRelocate.getAttribute("slot") === null && slotName === "") return true;
619
+ if (nodeToRelocate.getAttribute("slot") === slotName) return true;
620
+ return false;
621
+ }
622
+ if (nodeToRelocate["s-sn"] === slotName) return true;
623
+ return slotName === "";
624
+ };
625
+ /**
626
+ * Creates an empty text node to act as a forwarding address to a slotted node:
627
+ * 1) When non-shadow components re-render, they need a place to temporarily put 'lightDOM' elements.
628
+ * 2) Patched dom methods and accessors use this node to calculate what 'lightDOM' nodes are in the host.
629
+ *
630
+ * @param newChild a node that's going to be added to the component
631
+ * @param slotNode the slot node that the node will be added to
632
+ * @param prepend move the slotted location node to the beginning of the host
633
+ * @param position an ordered position to add the ref node which mirrors the lightDom nodes' order. Used during SSR hydration
634
+ * (the order of the slot location nodes determines the order of the slotted nodes in our patched accessors)
635
+ */
636
+ const addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
637
+ if (newChild["s-ol"] && newChild["s-ol"].isConnected) return;
638
+ const slottedNodeLocation = document.createTextNode("");
639
+ slottedNodeLocation["s-nr"] = newChild;
640
+ if (!slotNode["s-cr"] || !slotNode["s-cr"].parentNode) return;
641
+ const parent = slotNode["s-cr"].parentNode;
642
+ const appendMethod = prepend ? internalCall(parent, "prepend") : internalCall(parent, "appendChild");
643
+ if (BUILD.hydrateClientSide && typeof position !== "undefined") {
644
+ slottedNodeLocation["s-oo"] = position;
645
+ const childNodes = internalCall(parent, "childNodes");
646
+ const slotRelocateNodes = [slottedNodeLocation];
647
+ childNodes.forEach((n) => {
648
+ if (n["s-nr"]) slotRelocateNodes.push(n);
649
+ });
650
+ slotRelocateNodes.sort((a, b) => {
651
+ if (!a["s-oo"] || a["s-oo"] < (b["s-oo"] || 0)) return -1;
652
+ else if (!b["s-oo"] || b["s-oo"] < a["s-oo"]) return 1;
653
+ return 0;
654
+ });
655
+ slotRelocateNodes.forEach((n) => appendMethod.call(parent, n));
656
+ } else appendMethod.call(parent, slottedNodeLocation);
657
+ newChild["s-ol"] = slottedNodeLocation;
658
+ newChild["s-sh"] = slotNode["s-hn"];
659
+ };
660
+ const getSlotName = (node) => typeof node["s-sn"] === "string" ? node["s-sn"] : node.nodeType === 1 && node.getAttribute("slot") || void 0;
661
+ /**
662
+ * Add `assignedElements` and `assignedNodes` methods on a fake slot node
663
+ *
664
+ * @param node - slot node to patch
665
+ */
666
+ function patchSlotNode(node) {
667
+ if (node.assignedElements || node.assignedNodes || !node["s-sr"]) return;
668
+ const assignedFactory = (elementsOnly) => function(opts) {
669
+ const toReturn = [];
670
+ const slotName = this["s-sn"];
671
+ if (opts?.flatten) console.error(`
672
+ Flattening is not supported for Stencil non-shadow slots.
673
+ You can use \`.childNodes\` to nested slot fallback content.
674
+ If you have a particular use case, please open an issue on the Stencil repo.
675
+ `);
676
+ const parent = this["s-cr"].parentElement;
677
+ (parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
678
+ if (slotName === getSlotName(n)) toReturn.push(n);
679
+ });
680
+ if (elementsOnly) return toReturn.filter((n) => n.nodeType === NODE_TYPE.ElementNode);
681
+ return toReturn;
682
+ }.bind(node);
683
+ node.assignedElements = assignedFactory(true);
684
+ node.assignedNodes = assignedFactory(false);
685
+ }
686
+ /**
687
+ * Dispatches a `slotchange` event on a fake `<slot />` node.
688
+ *
689
+ * @param elm the slot node to dispatch the event from
690
+ */
691
+ function dispatchSlotChangeEvent(elm) {
692
+ elm.dispatchEvent(new CustomEvent("slotchange", {
693
+ bubbles: false,
694
+ cancelable: false,
695
+ composed: false
696
+ }));
697
+ }
698
+ /**
699
+ * Find the slot node that a slotted node belongs to
700
+ *
701
+ * @param slottedNode - the slotted node to find the slot for
702
+ * @param parentHost - the parent host element of the slotted node
703
+ * @returns the slot node and slot name
704
+ */
705
+ function findSlotFromSlottedNode(slottedNode, parentHost) {
706
+ parentHost = parentHost || slottedNode["s-ol"]?.parentElement;
707
+ if (!parentHost) return {
708
+ slotNode: null,
709
+ slotName: ""
710
+ };
711
+ const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
712
+ return {
713
+ slotNode: getHostSlotNodes(internalCall(parentHost, "childNodes"), parentHost.tagName, slotName)[0],
714
+ slotName
715
+ };
716
+ }
717
+
718
+ //#endregion
719
+ //#region src/runtime/dom-extras.ts
720
+ const patchPseudoShadowDom = (hostElementPrototype) => {
721
+ patchCloneNode(hostElementPrototype);
722
+ patchSlotAppendChild(hostElementPrototype);
723
+ patchSlotAppend(hostElementPrototype);
724
+ patchSlotPrepend(hostElementPrototype);
725
+ patchSlotInsertAdjacentElement(hostElementPrototype);
726
+ patchSlotInsertAdjacentHTML(hostElementPrototype);
727
+ patchSlotInsertAdjacentText(hostElementPrototype);
728
+ patchInsertBefore(hostElementPrototype);
729
+ patchTextContent(hostElementPrototype);
730
+ patchChildSlotNodes(hostElementPrototype);
731
+ patchSlotRemoveChild(hostElementPrototype);
732
+ };
733
+ /**
734
+ * Patches the `cloneNode` method on a `scoped` Stencil component.
735
+ *
736
+ * @param HostElementPrototype The Stencil component to be patched
737
+ */
738
+ const patchCloneNode = (HostElementPrototype) => {
739
+ if (HostElementPrototype.__cloneNode) return;
740
+ const orgCloneNode = HostElementPrototype.__cloneNode = HostElementPrototype.cloneNode;
741
+ HostElementPrototype.cloneNode = function(deep) {
742
+ const srcNode = this;
743
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
744
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
745
+ if (BUILD.slot && !isShadowDom && deep) {
746
+ let i = 0;
747
+ let slotted, nonStencilNode;
748
+ const stencilPrivates = [
749
+ "s-id",
750
+ "s-cr",
751
+ "s-lr",
752
+ "s-rc",
753
+ "s-sc",
754
+ "s-p",
755
+ "s-cn",
756
+ "s-sr",
757
+ "s-sn",
758
+ "s-hn",
759
+ "s-ol",
760
+ "s-nr",
761
+ "s-si",
762
+ "s-rf",
763
+ "s-scs"
764
+ ];
765
+ const childNodes = this.__childNodes || this.childNodes;
766
+ for (; i < childNodes.length; i++) {
767
+ slotted = childNodes[i]["s-nr"];
768
+ nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
769
+ if (slotted) if (BUILD.appendChildSlotFix && clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
770
+ else clonedNode.appendChild(slotted.cloneNode(true));
771
+ if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
772
+ }
773
+ }
774
+ return clonedNode;
775
+ };
776
+ };
777
+ /**
778
+ * Patches the `appendChild` method on a `scoped` Stencil component.
779
+ * The patch will attempt to find a slot with the same name as the node being appended
780
+ * and insert it into the slot reference if found. Otherwise, it falls-back to the original
781
+ * `appendChild` method.
782
+ *
783
+ * @param HostElementPrototype The Stencil component to be patched
784
+ */
785
+ const patchSlotAppendChild = (HostElementPrototype) => {
786
+ if (HostElementPrototype.__appendChild) return;
787
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
788
+ HostElementPrototype.appendChild = function(newChild) {
789
+ const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
790
+ if (slotNode) {
791
+ addSlotRelocateNode(newChild, slotNode);
792
+ const slotChildNodes = getSlotChildSiblings(slotNode, slotName);
793
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
794
+ const insertedNode = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, appendAfter.nextSibling);
795
+ dispatchSlotChangeEvent(slotNode);
796
+ updateFallbackSlotVisibility(this);
797
+ return insertedNode;
798
+ }
799
+ return this.__appendChild(newChild);
800
+ };
801
+ };
802
+ /**
803
+ * Patches the `removeChild` method on a `scoped` Stencil component.
804
+ * This patch attempts to remove the specified node from a slot reference
805
+ * if the slot exists. Otherwise, it falls-back to the original `removeChild` method.
806
+ *
807
+ * @param ElementPrototype The Stencil component to be patched
808
+ */
809
+ const patchSlotRemoveChild = (ElementPrototype) => {
810
+ if (ElementPrototype.__removeChild) return;
811
+ ElementPrototype.__removeChild = ElementPrototype.removeChild;
812
+ ElementPrototype.removeChild = function(toRemove) {
813
+ if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
814
+ if (getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, toRemove["s-sn"]) && toRemove.isConnected) {
815
+ toRemove.remove();
816
+ updateFallbackSlotVisibility(this);
817
+ return;
818
+ }
819
+ }
820
+ return this.__removeChild(toRemove);
821
+ };
822
+ };
823
+ /**
824
+ * Patches the `prepend` method for a slotted node inside a scoped component.
825
+ *
826
+ * @param HostElementPrototype the `Element` to be patched
827
+ */
828
+ const patchSlotPrepend = (HostElementPrototype) => {
829
+ if (HostElementPrototype.__prepend) return;
830
+ HostElementPrototype.__prepend = HostElementPrototype.prepend;
831
+ HostElementPrototype.prepend = function(...newChildren) {
832
+ newChildren.forEach((newChild) => {
833
+ if (typeof newChild === "string") newChild = this.ownerDocument.createTextNode(newChild);
834
+ const slotName = (newChild["s-sn"] = getSlotName(newChild)) || "";
835
+ const slotNode = getHostSlotNodes(internalCall(this, "childNodes"), this.tagName, slotName)[0];
836
+ if (slotNode) {
837
+ addSlotRelocateNode(newChild, slotNode, true);
838
+ const appendAfter = getSlotChildSiblings(slotNode, slotName)[0];
839
+ const toReturn = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, internalCall(appendAfter, "nextSibling"));
840
+ dispatchSlotChangeEvent(slotNode);
841
+ return toReturn;
842
+ }
843
+ if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
844
+ return HostElementPrototype.__prepend(newChild);
845
+ });
846
+ };
847
+ };
848
+ /**
849
+ * Patches the `append` method for a slotted node inside a scoped component. The patched method uses
850
+ * `appendChild` under-the-hood while creating text nodes for any new children that passed as bare strings.
851
+ *
852
+ * @param HostElementPrototype the `Element` to be patched
853
+ */
854
+ const patchSlotAppend = (HostElementPrototype) => {
855
+ if (HostElementPrototype.__append) return;
856
+ HostElementPrototype.__append = HostElementPrototype.append;
857
+ HostElementPrototype.append = function(...newChildren) {
858
+ newChildren.forEach((newChild) => {
859
+ if (typeof newChild === "string") newChild = this.ownerDocument.createTextNode(newChild);
860
+ this.appendChild(newChild);
861
+ });
862
+ };
863
+ };
864
+ /**
865
+ * Patches the `insertAdjacentHTML` method for a slotted node inside a scoped component. Specifically,
866
+ * we only need to patch the behavior for the specific `beforeend` and `afterbegin` positions so the element
867
+ * gets inserted into the DOM in the correct location.
868
+ *
869
+ * @param HostElementPrototype the `Element` to be patched
870
+ */
871
+ const patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
872
+ if (HostElementPrototype.__insertAdjacentHTML) return;
873
+ const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
874
+ HostElementPrototype.insertAdjacentHTML = function(position, text) {
875
+ if (position !== "afterbegin" && position !== "beforeend") return originalInsertAdjacentHtml.call(this, position, text);
876
+ const container = this.ownerDocument.createElement("_");
877
+ let node;
878
+ container.innerHTML = text;
879
+ if (position === "afterbegin") while (node = container.firstChild) this.prepend(node);
880
+ else if (position === "beforeend") while (node = container.firstChild) this.append(node);
881
+ };
882
+ };
883
+ /**
884
+ * Patches the `insertAdjacentText` method for a slotted node inside a scoped component. Specifically,
885
+ * we only need to patch the behavior for the specific `beforeend` and `afterbegin` positions so the text node
886
+ * gets inserted into the DOM in the correct location.
887
+ *
888
+ * @param HostElementPrototype the `Element` to be patched
889
+ */
890
+ const patchSlotInsertAdjacentText = (HostElementPrototype) => {
891
+ HostElementPrototype.insertAdjacentText = function(position, text) {
892
+ this.insertAdjacentHTML(position, text);
893
+ };
894
+ };
895
+ /**
896
+ * Patches the `insertBefore` of a non-shadow component.
897
+ *
898
+ * The *current* node to insert before may not be in the root of our component
899
+ * (e.g. if it's 'slotted' it appears in the root, but isn't really)
900
+ *
901
+ * This tries to find where the *current* node lives within the component and insert the new node before it
902
+ * *If* the new node is in the same slot as the *current* node. Otherwise the new node is appended to it's 'slot'
903
+ *
904
+ * @param HostElementPrototype the custom element prototype to patch
905
+ */
906
+ const patchInsertBefore = (HostElementPrototype) => {
907
+ if (HostElementPrototype.__insertBefore) return;
908
+ const eleProto = HostElementPrototype;
909
+ if (eleProto.__insertBefore) return;
910
+ eleProto.__insertBefore = HostElementPrototype.insertBefore;
911
+ HostElementPrototype.insertBefore = function(newChild, currentChild) {
912
+ const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
913
+ const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
914
+ if (slotNode) {
915
+ let found = false;
916
+ slottedNodes.forEach((childNode) => {
917
+ if (childNode === currentChild || currentChild === null) {
918
+ found = true;
919
+ if (currentChild === null || slotName !== currentChild["s-sn"]) {
920
+ this.appendChild(newChild);
921
+ return;
922
+ }
923
+ if (slotName === currentChild["s-sn"]) {
924
+ addSlotRelocateNode(newChild, slotNode);
925
+ internalCall(internalCall(currentChild, "parentNode"), "insertBefore")(newChild, currentChild);
926
+ dispatchSlotChangeEvent(slotNode);
927
+ }
928
+ return;
929
+ }
930
+ });
931
+ if (found) return newChild;
932
+ }
933
+ /**
934
+ * Fixes an issue where slotted elements are dynamically relocated in React, such as after data fetch.
935
+ *
936
+ * When a slotted element is passed to another scoped component (e.g., <A><C slot="header"/></A>),
937
+ * the child’s __parentNode (original parent node property) does not match this.
938
+ *
939
+ * To prevent errors, this checks if the current child's parent node differs from this.
940
+ * If so, appendChild(newChild) is called to ensure the child is correctly inserted,
941
+ * allowing Stencil to properly manage the slot placement.
942
+ */
943
+ const parentNode = currentChild?.__parentNode;
944
+ if (parentNode && !this.isSameNode(parentNode)) return this.appendChild(newChild);
945
+ return this.__insertBefore(newChild, currentChild);
946
+ };
947
+ };
948
+ /**
949
+ * Patches the `insertAdjacentElement` method for a slotted node inside a scoped component. Specifically,
950
+ * we only need to patch the behavior for the specific `beforeend` and `afterbegin` positions so the element
951
+ * gets inserted into the DOM in the correct location.
952
+ *
953
+ * @param HostElementPrototype the `Element` to be patched
954
+ */
955
+ const patchSlotInsertAdjacentElement = (HostElementPrototype) => {
956
+ if (HostElementPrototype.__insertAdjacentElement) return;
957
+ const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
958
+ HostElementPrototype.insertAdjacentElement = function(position, element) {
959
+ if (position !== "afterbegin" && position !== "beforeend") return originalInsertAdjacentElement.call(this, position, element);
960
+ if (position === "afterbegin") {
961
+ this.prepend(element);
962
+ return element;
963
+ } else if (position === "beforeend") {
964
+ this.append(element);
965
+ return element;
966
+ }
967
+ return element;
968
+ };
969
+ };
970
+ /**
971
+ * Patches the `textContent` of an unnamed slotted node inside a scoped component
972
+ *
973
+ * @param hostElementPrototype the `Element` to be patched
974
+ */
975
+ const patchTextContent = (hostElementPrototype) => {
976
+ patchHostOriginalAccessor("textContent", hostElementPrototype);
977
+ Object.defineProperty(hostElementPrototype, "textContent", {
978
+ get: function() {
979
+ let text = "";
980
+ (this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) => text += node.textContent || "");
981
+ return text;
982
+ },
983
+ set: function(value) {
984
+ (this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) => {
985
+ if (node["s-ol"]) node["s-ol"].remove();
986
+ node.remove();
987
+ });
988
+ this.insertAdjacentHTML("beforeend", value);
989
+ }
990
+ });
991
+ };
992
+ const patchChildSlotNodes = (elm) => {
993
+ class FakeNodeList extends Array {
994
+ item(n) {
995
+ return this[n];
996
+ }
997
+ }
998
+ patchHostOriginalAccessor("children", elm);
999
+ Object.defineProperty(elm, "children", { get() {
1000
+ return this.childNodes.filter((n) => n.nodeType === 1);
1001
+ } });
1002
+ Object.defineProperty(elm, "childElementCount", { get() {
1003
+ return this.children.length;
1004
+ } });
1005
+ patchHostOriginalAccessor("firstChild", elm);
1006
+ Object.defineProperty(elm, "firstChild", { get() {
1007
+ return this.childNodes[0];
1008
+ } });
1009
+ patchHostOriginalAccessor("lastChild", elm);
1010
+ Object.defineProperty(elm, "lastChild", { get() {
1011
+ return this.childNodes[this.childNodes.length - 1];
1012
+ } });
1013
+ patchHostOriginalAccessor("childNodes", elm);
1014
+ Object.defineProperty(elm, "childNodes", { get() {
1015
+ const result = new FakeNodeList();
1016
+ result.push(...getSlottedChildNodes(this.__childNodes));
1017
+ return result;
1018
+ } });
1019
+ };
1020
+ /**
1021
+ * Patches sibling accessors of a 'slotted' node within a non-shadow component.
1022
+ * Meaning whilst stepping through a non-shadow element's nodes, only the mock 'lightDOM' nodes are returned.
1023
+ * Especially relevant when rendering components via SSR... Frameworks will often try to reconcile their
1024
+ * VDOM with the real DOM by stepping through nodes with 'nextSibling' et al.
1025
+ * - `nextSibling`
1026
+ * - `nextElementSibling`
1027
+ * - `previousSibling`
1028
+ * - `previousElementSibling`
1029
+ *
1030
+ * @param node the slotted node to be patched
1031
+ */
1032
+ const patchSlottedNode = (node) => {
1033
+ if (!node || node.__nextSibling !== void 0 || !globalThis.Node) return;
1034
+ patchNextSibling(node);
1035
+ patchPreviousSibling(node);
1036
+ patchParentNode(node);
1037
+ if (node.nodeType === Node.ELEMENT_NODE) {
1038
+ patchNextElementSibling(node);
1039
+ patchPreviousElementSibling(node);
1040
+ }
1041
+ };
1042
+ /**
1043
+ * Patches the `nextSibling` accessor of a non-shadow slotted node
1044
+ *
1045
+ * @param node the slotted node to be patched
1046
+ */
1047
+ const patchNextSibling = (node) => {
1048
+ if (!node || node.__nextSibling) return;
1049
+ patchHostOriginalAccessor("nextSibling", node);
1050
+ Object.defineProperty(node, "nextSibling", { get: function() {
1051
+ const parentNodes = this["s-ol"]?.parentNode.childNodes;
1052
+ const index = parentNodes?.indexOf(this);
1053
+ if (parentNodes && index > -1) return parentNodes[index + 1];
1054
+ return this.__nextSibling;
1055
+ } });
1056
+ };
1057
+ /**
1058
+ * Patches the `nextElementSibling` accessor of a non-shadow slotted node
1059
+ *
1060
+ * @param element the slotted element node to be patched
1061
+ */
1062
+ const patchNextElementSibling = (element) => {
1063
+ if (!element || element.__nextElementSibling) return;
1064
+ patchHostOriginalAccessor("nextElementSibling", element);
1065
+ Object.defineProperty(element, "nextElementSibling", { get: function() {
1066
+ const parentEles = this["s-ol"]?.parentNode.children;
1067
+ const index = parentEles?.indexOf(this);
1068
+ if (parentEles && index > -1) return parentEles[index + 1];
1069
+ return this.__nextElementSibling;
1070
+ } });
1071
+ };
1072
+ /**
1073
+ * Patches the `previousSibling` accessor of a non-shadow slotted node
1074
+ *
1075
+ * @param node the slotted node to be patched
1076
+ */
1077
+ const patchPreviousSibling = (node) => {
1078
+ if (!node || node.__previousSibling) return;
1079
+ patchHostOriginalAccessor("previousSibling", node);
1080
+ Object.defineProperty(node, "previousSibling", { get: function() {
1081
+ const parentNodes = this["s-ol"]?.parentNode.childNodes;
1082
+ const index = parentNodes?.indexOf(this);
1083
+ if (parentNodes && index > -1) return parentNodes[index - 1];
1084
+ return this.__previousSibling;
1085
+ } });
1086
+ };
1087
+ /**
1088
+ * Patches the `previousElementSibling` accessor of a non-shadow slotted node
1089
+ *
1090
+ * @param element the slotted element node to be patched
1091
+ */
1092
+ const patchPreviousElementSibling = (element) => {
1093
+ if (!element || element.__previousElementSibling) return;
1094
+ patchHostOriginalAccessor("previousElementSibling", element);
1095
+ Object.defineProperty(element, "previousElementSibling", { get: function() {
1096
+ const parentNodes = this["s-ol"]?.parentNode.children;
1097
+ const index = parentNodes?.indexOf(this);
1098
+ if (parentNodes && index > -1) return parentNodes[index - 1];
1099
+ return this.__previousElementSibling;
1100
+ } });
1101
+ };
1102
+ /**
1103
+ * Patches the `parentNode` accessor of a non-shadow slotted node
1104
+ *
1105
+ * @param node the slotted node to be patched
1106
+ */
1107
+ const patchParentNode = (node) => {
1108
+ if (!node || node.__parentNode) return;
1109
+ patchHostOriginalAccessor("parentNode", node);
1110
+ Object.defineProperty(node, "parentNode", {
1111
+ get: function() {
1112
+ return this["s-ol"]?.parentNode || this.__parentNode;
1113
+ },
1114
+ set: function(value) {
1115
+ this.__parentNode = value;
1116
+ }
1117
+ });
1118
+ };
1119
+ const validElementPatches = [
1120
+ "children",
1121
+ "nextElementSibling",
1122
+ "previousElementSibling"
1123
+ ];
1124
+ const validNodesPatches = [
1125
+ "childNodes",
1126
+ "firstChild",
1127
+ "lastChild",
1128
+ "nextSibling",
1129
+ "previousSibling",
1130
+ "textContent",
1131
+ "parentNode"
1132
+ ];
1133
+ /**
1134
+ * Patches a node or element; making it's original accessor method available under a new name.
1135
+ * e.g. `nextSibling` -> `__nextSibling`
1136
+ *
1137
+ * @param accessorName - the name of the accessor to patch
1138
+ * @param node - the node to patch
1139
+ */
1140
+ function patchHostOriginalAccessor(accessorName, node) {
1141
+ /**
1142
+ * skip this method if a component was imported from a non-browser environment
1143
+ */
1144
+ if (!globalThis.Node || !globalThis.Element) return;
1145
+ let accessor;
1146
+ if (validElementPatches.includes(accessorName)) accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
1147
+ else if (validNodesPatches.includes(accessorName)) accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1148
+ if (!accessor) accessor = Object.getOwnPropertyDescriptor(node, accessorName);
1149
+ if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
1150
+ }
1151
+ /**
1152
+ * Get the original / internal accessor or method of a node or element.
1153
+ *
1154
+ * @param node - the node to get the accessor from
1155
+ * @param method - the name of the accessor to get
1156
+ *
1157
+ * @returns the original accessor or method of the node
1158
+ */
1159
+ function internalCall(node, method) {
1160
+ if ("__" + method in node) {
1161
+ const toReturn = node["__" + method];
1162
+ if (typeof toReturn !== "function") return toReturn;
1163
+ return toReturn.bind(node);
1164
+ } else {
1165
+ if (typeof node[method] !== "function") return node[method];
1166
+ return node[method].bind(node);
1167
+ }
1168
+ }
1169
+
1170
+ //#endregion
1171
+ //#region src/runtime/profile.ts
1172
+ let i = 0;
1173
+ const createTime = (fnName, tagName = "") => {
1174
+ if (BUILD.profile && performance.mark) {
1175
+ const key = `st:${fnName}:${tagName}:${i++}`;
1176
+ performance.mark(key);
1177
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
1178
+ } else return () => {};
1179
+ };
1180
+ const uniqueTime = (key, measureText) => {
1181
+ if (BUILD.profile && performance.mark) {
1182
+ if (performance.getEntriesByName(key, "mark").length === 0) performance.mark(key);
1183
+ return () => {
1184
+ if (performance.getEntriesByName(measureText, "measure").length === 0) performance.measure(measureText, key);
1185
+ };
1186
+ } else return () => {};
1187
+ };
1188
+ const inspect = (ref) => {
1189
+ const hostRef = getHostRef(ref);
1190
+ if (!hostRef) return;
1191
+ const flags = hostRef.$flags$;
1192
+ const hostElement = hostRef.$hostElement$;
1193
+ return {
1194
+ renderCount: hostRef.$renderCount$,
1195
+ flags: {
1196
+ hasRendered: !!(flags & HOST_FLAGS.hasRendered),
1197
+ hasConnected: !!(flags & HOST_FLAGS.hasConnected),
1198
+ isWaitingForChildren: !!(flags & HOST_FLAGS.isWaitingForChildren),
1199
+ isConstructingInstance: !!(flags & HOST_FLAGS.isConstructingInstance),
1200
+ isQueuedForUpdate: !!(flags & HOST_FLAGS.isQueuedForUpdate),
1201
+ hasInitializedComponent: !!(flags & HOST_FLAGS.hasInitializedComponent),
1202
+ hasLoadedComponent: !!(flags & HOST_FLAGS.hasLoadedComponent),
1203
+ isWatchReady: !!(flags & HOST_FLAGS.isWatchReady),
1204
+ isListenReady: !!(flags & HOST_FLAGS.isListenReady),
1205
+ needsRerender: !!(flags & HOST_FLAGS.needsRerender)
1206
+ },
1207
+ instanceValues: hostRef.$instanceValues$,
1208
+ serializerValues: hostRef.$serializerValues$,
1209
+ ancestorComponent: hostRef.$ancestorComponent$,
1210
+ hostElement,
1211
+ lazyInstance: hostRef.$lazyInstance$,
1212
+ vnode: hostRef.$vnode$,
1213
+ modeName: hostRef.$modeName$,
1214
+ fetchedCbList: hostRef.$fetchedCbList$,
1215
+ onReadyPromise: hostRef.$onReadyPromise$,
1216
+ onReadyResolve: hostRef.$onReadyResolve$,
1217
+ onInstancePromise: hostRef.$onInstancePromise$,
1218
+ onInstanceResolve: hostRef.$onInstanceResolve$,
1219
+ onRenderResolve: hostRef.$onRenderResolve$,
1220
+ queuedListeners: hostRef.$queuedListeners$,
1221
+ rmListeners: hostRef.$rmListeners$,
1222
+ ["s-id"]: hostElement["s-id"],
1223
+ ["s-cr"]: hostElement["s-cr"],
1224
+ ["s-lr"]: hostElement["s-lr"],
1225
+ ["s-p"]: hostElement["s-p"],
1226
+ ["s-rc"]: hostElement["s-rc"],
1227
+ ["s-sc"]: hostElement["s-sc"]
1228
+ };
1229
+ };
1230
+ const installDevTools = () => {
1231
+ if (BUILD.devTools) {
1232
+ const stencil = win.stencil = win.stencil || {};
1233
+ const originalInspect = stencil.inspect;
1234
+ stencil.inspect = (ref) => {
1235
+ let result = inspect(ref);
1236
+ if (!result && typeof originalInspect === "function") result = originalInspect(ref);
1237
+ return result;
1238
+ };
1239
+ }
1240
+ };
1241
+
1242
+ //#endregion
1243
+ //#region src/utils/query-nonce-meta-tag-content.ts
1244
+ /**
1245
+ * Helper method for querying a `meta` tag that contains a nonce value
1246
+ * out of a DOM's head.
1247
+ *
1248
+ * @param doc The DOM containing the `head` to query against
1249
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
1250
+ * exists or the tag has no content.
1251
+ */
1252
+ function queryNonceMetaTagContent(doc) {
1253
+ return doc.head?.querySelector("meta[name=\"csp-nonce\"]")?.getAttribute("content") ?? void 0;
1254
+ }
1255
+
1256
+ //#endregion
1257
+ //#region src/runtime/styles.ts
1258
+ const rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1259
+ /**
1260
+ * Register the styles for a component by creating a stylesheet and then
1261
+ * registering it under the component's scope ID in a `WeakMap` for later use.
1262
+ *
1263
+ * If constructable stylesheet are not supported or `allowCS` is set to
1264
+ * `false` then the styles will be registered as a string instead.
1265
+ *
1266
+ * @param scopeId the scope ID for the component of interest
1267
+ * @param cssText styles for the component of interest
1268
+ * @param allowCS whether or not to use a constructable stylesheet
1269
+ */
1270
+ const registerStyle = (scopeId, cssText, allowCS) => {
1271
+ let style = styles.get(scopeId);
1272
+ if (supportsConstructableStylesheets && allowCS) {
1273
+ style = style || new CSSStyleSheet();
1274
+ if (typeof style === "string") style = cssText;
1275
+ else style.replaceSync(cssText);
1276
+ } else style = cssText;
1277
+ styles.set(scopeId, style);
1278
+ };
1279
+ /**
1280
+ * Attach the styles for a given component to the DOM
1281
+ *
1282
+ * If the element uses shadow or is already attached to the DOM then we can
1283
+ * create a stylesheet inside of its associated document fragment, otherwise
1284
+ * we'll stick the stylesheet into the document head.
1285
+ *
1286
+ * @param styleContainerNode the node within which a style element for the
1287
+ * component of interest should be added
1288
+ * @param cmpMeta runtime metadata for the component of interest
1289
+ * @param mode an optional current mode
1290
+ * @returns the scope ID for the component of interest
1291
+ */
1292
+ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1293
+ const scopeId = getScopeId(cmpMeta, mode);
1294
+ const style = styles.get(scopeId);
1295
+ if (!BUILD.attachStyles || !win.document) return scopeId;
1296
+ styleContainerNode = styleContainerNode.nodeType === NODE_TYPE.DocumentFragment ? styleContainerNode : win.document;
1297
+ if (style) {
1298
+ if (typeof style === "string") {
1299
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
1300
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1301
+ let styleElm;
1302
+ if (!appliedStyles) rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1303
+ const existingStyleElm = (BUILD.hydrateClientSide || BUILD.hotModuleReplacement) && styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`);
1304
+ if (existingStyleElm) existingStyleElm.textContent = style;
1305
+ else if (!appliedStyles.has(scopeId)) {
1306
+ styleElm = win.document.createElement("style");
1307
+ styleElm.textContent = style;
1308
+ const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
1309
+ if (nonce != null) styleElm.setAttribute("nonce", nonce);
1310
+ if ((BUILD.hydrateServerSide || BUILD.hotModuleReplacement) && (cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation || cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss || cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
1311
+ /**
1312
+ * attach styles at the end of the head tag if we render scoped components
1313
+ */
1314
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) if (styleContainerNode.nodeName === "HEAD") {
1315
+ /**
1316
+ * if the page contains preconnect links, we want to insert the styles
1317
+ * after the last preconnect link to ensure the styles are preloaded
1318
+ */
1319
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1320
+ const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1321
+ styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1322
+ } else if ("host" in styleContainerNode) if (supportsConstructableStylesheets) {
1323
+ const stylesheet = new (styleContainerNode.defaultView ?? styleContainerNode.ownerDocument.defaultView).CSSStyleSheet();
1324
+ stylesheet.replaceSync(style);
1325
+ /**
1326
+ * > If the array needs to be modified, use in-place mutations like push().
1327
+ * https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets
1328
+ */
1329
+ if (supportsMutableAdoptedStyleSheets) styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
1330
+ else styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
1331
+ } else {
1332
+ /**
1333
+ * If a scoped component is used within a shadow root and constructable stylesheets are
1334
+ * not supported, we want to insert the styles at the beginning of the shadow root node.
1335
+ *
1336
+ * However, if there is already a style node in the shadow root, we just append
1337
+ * the styles to the existing node.
1338
+ *
1339
+ * Note: order of how styles are applied is important. The new style node
1340
+ * should be inserted before the existing style node.
1341
+ *
1342
+ * During HMR, create separate style elements for scoped components so they can be
1343
+ * updated independently without affecting other components' styles.
1344
+ */
1345
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1346
+ if (existingStyleContainer && !BUILD.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1347
+ else styleContainerNode.prepend(styleElm);
1348
+ }
1349
+ else styleContainerNode.append(styleElm);
1350
+ /**
1351
+ * attach styles at the beginning of a shadow root node if we render shadow components
1352
+ */
1353
+ if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) styleContainerNode.insertBefore(styleElm, null);
1354
+ if (cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.textContent += SLOT_FB_CSS;
1355
+ if (appliedStyles) appliedStyles.add(scopeId);
1356
+ }
1357
+ } else if (BUILD.constructableCSS) {
1358
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1359
+ if (!appliedStyles) rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1360
+ if (!appliedStyles.has(scopeId)) {
1361
+ /**
1362
+ * Constructable stylesheets can't be shared between windows,
1363
+ * we need to create a new one for the current window if necessary
1364
+ */
1365
+ const currentWindow = styleContainerNode.defaultView ?? styleContainerNode.ownerDocument.defaultView;
1366
+ let stylesheet;
1367
+ if (style.constructor === currentWindow.CSSStyleSheet) stylesheet = style;
1368
+ else {
1369
+ stylesheet = new currentWindow.CSSStyleSheet();
1370
+ for (let i = 0; i < style.cssRules.length; i++) stylesheet.insertRule(style.cssRules[i].cssText, i);
1371
+ }
1372
+ /**
1373
+ * > If the array needs to be modified, use in-place mutations like push().
1374
+ * https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets
1375
+ */
1376
+ if (supportsMutableAdoptedStyleSheets) styleContainerNode.adoptedStyleSheets.push(stylesheet);
1377
+ else styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, stylesheet];
1378
+ appliedStyles.add(scopeId);
1379
+ if (BUILD.hydrateClientSide && "host" in styleContainerNode) {
1380
+ const ssrStyleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`);
1381
+ if (ssrStyleElm) writeTask(() => ssrStyleElm.remove());
1382
+ }
1383
+ }
1384
+ }
1385
+ }
1386
+ return scopeId;
1387
+ };
1388
+ /**
1389
+ * Add styles for a given component to the DOM, optionally handling 'scoped'
1390
+ * encapsulation by adding an appropriate class name to the host element.
1391
+ *
1392
+ * @param hostRef the host reference for the component of interest
1393
+ */
1394
+ const attachStyles = (hostRef) => {
1395
+ const cmpMeta = hostRef.$cmpMeta$;
1396
+ const elm = hostRef.$hostElement$;
1397
+ const flags = cmpMeta.$flags$;
1398
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
1399
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$);
1400
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
1401
+ elm["s-sc"] = scopeId;
1402
+ elm.classList.add(scopeId + "-h");
1403
+ }
1404
+ endAttachStyles();
1405
+ };
1406
+ /**
1407
+ * Get the scope ID for a given component
1408
+ *
1409
+ * @param cmp runtime metadata for the component of interest
1410
+ * @param mode the current mode (optional)
1411
+ * @returns a scope ID for the component of interest
1412
+ */
1413
+ const getScopeId = (cmp, mode) => "sc-" + (BUILD.mode && mode && cmp.$flags$ & CMP_FLAGS.hasMode ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
1414
+ /**
1415
+ * Convert a 'scoped' CSS string to one appropriate for use in the shadow DOM.
1416
+ *
1417
+ * Given a 'scoped' CSS string that looks like this:
1418
+ *
1419
+ * ```
1420
+ * /*!@div*\/div.class-name { display: flex };
1421
+ * ```
1422
+ *
1423
+ * Convert it to a 'shadow' appropriate string, like so:
1424
+ *
1425
+ * ```
1426
+ * /*!@div*\/div.class-name { display: flex }
1427
+ * ─┬─ ────────┬────────
1428
+ * │ │
1429
+ * │ ┌─────────────────┘
1430
+ * ▼ ▼
1431
+ * div{ display: flex }
1432
+ * ```
1433
+ *
1434
+ * Note that forward-slashes in the above are escaped so they don't end the
1435
+ * comment.
1436
+ *
1437
+ * @param css a CSS string to convert
1438
+ * @returns the converted string
1439
+ */
1440
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{");
1441
+ /**
1442
+ * Hydrate styles after SSR for components *not* using DSD. Convert 'scoped' styles to 'shadow'
1443
+ * and add them to a constructable stylesheet.
1444
+ */
1445
+ const hydrateScopedToShadow = () => {
1446
+ if (!win.document) return;
1447
+ const styles = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1448
+ let i = 0;
1449
+ for (; i < styles.length; i++) registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
1450
+ };
1451
+
1452
+ //#endregion
1453
+ //#region src/utils/helpers.ts
1454
+ const isDef = (v) => v != null && v !== void 0;
1455
+ /**
1456
+ * Check whether a value is a 'complex type', defined here as an object or a
1457
+ * function.
1458
+ *
1459
+ * @param o the value to check
1460
+ * @returns whether it's a complex type or not
1461
+ */
1462
+ const isComplexType = (o) => {
1463
+ o = typeof o;
1464
+ return o === "object" || o === "function";
1465
+ };
1466
+
1467
+ //#endregion
1468
+ //#region src/runtime/vdom/h.ts
1469
+ /**
1470
+ * Production h() function based on Preact by
1471
+ * Jason Miller (@developit)
1472
+ * Licensed under the MIT License
1473
+ * https://github.com/developit/preact/blob/master/LICENSE
1474
+ *
1475
+ * Modified for Stencil's compiler and vdom
1476
+ */
1477
+ const h = (nodeName, vnodeData, ...children) => {
1478
+ if (typeof nodeName === "string") nodeName = transformTag(nodeName);
1479
+ let child = null;
1480
+ let key = null;
1481
+ let slotName = null;
1482
+ let simple = false;
1483
+ let lastSimple = false;
1484
+ const vNodeChildren = [];
1485
+ const walk = (c) => {
1486
+ for (let i = 0; i < c.length; i++) {
1487
+ child = c[i];
1488
+ if (Array.isArray(child)) walk(child);
1489
+ else if (child != null && typeof child !== "boolean") {
1490
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
1491
+ else if (BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) consoleDevError(`vNode passed as children has unexpected type.
1492
+ Make sure it's using the correct h() function.
1493
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
1494
+ if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
1495
+ else vNodeChildren.push(simple ? newVNode(null, child) : child);
1496
+ lastSimple = simple;
1497
+ }
1498
+ }
1499
+ };
1500
+ walk(children);
1501
+ if (vnodeData) {
1502
+ if (BUILD.isDev && nodeName === "input") validateInputProperties(vnodeData);
1503
+ if (BUILD.vdomKey && vnodeData.key) key = vnodeData.key;
1504
+ if (BUILD.slotRelocation && vnodeData.name) slotName = vnodeData.name;
1505
+ if (BUILD.vdomClass) {
1506
+ const classData = vnodeData.className || vnodeData.class;
1507
+ if (classData) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
1508
+ }
1509
+ }
1510
+ if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component. Make sure:
1511
+ - You are NOT using hostData() and <Host> in the same component.
1512
+ - <Host> is used once, and it's the single root component of the render() function.`);
1513
+ if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
1514
+ const vnode = newVNode(nodeName, null);
1515
+ vnode.$attrs$ = vnodeData;
1516
+ if (vNodeChildren.length > 0) vnode.$children$ = vNodeChildren;
1517
+ if (BUILD.vdomKey) vnode.$key$ = key;
1518
+ if (BUILD.slotRelocation) vnode.$name$ = slotName;
1519
+ return vnode;
1520
+ };
1521
+ /**
1522
+ * A utility function for creating a virtual DOM node from a tag and some
1523
+ * possible text content.
1524
+ *
1525
+ * @param tag the tag for this element
1526
+ * @param text possible text content for the node
1527
+ * @returns a newly-minted virtual DOM node
1528
+ */
1529
+ const newVNode = (tag, text) => {
1530
+ const vnode = {
1531
+ $flags$: 0,
1532
+ $tag$: tag,
1533
+ $text$: text ?? null,
1534
+ $elm$: null,
1535
+ $children$: null
1536
+ };
1537
+ if (BUILD.vdomAttribute) vnode.$attrs$ = null;
1538
+ if (BUILD.vdomKey) vnode.$key$ = null;
1539
+ if (BUILD.slotRelocation) vnode.$name$ = null;
1540
+ return vnode;
1541
+ };
1542
+ const Host = {};
1543
+ /**
1544
+ * Check whether a given node is a Host node or not
1545
+ *
1546
+ * @param node the virtual DOM node to check
1547
+ * @returns whether it's a Host node or not
1548
+ */
1549
+ const isHost = (node) => node && node.$tag$ === Host;
1550
+ /**
1551
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
1552
+ *
1553
+ * Note that these functions convert from {@link d.VNode} to
1554
+ * {@link d.ChildNode} to give functional component developers a friendly
1555
+ * interface.
1556
+ */
1557
+ const vdomFnUtils = {
1558
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
1559
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
1560
+ };
1561
+ /**
1562
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
1563
+ * friendlier public interface (hence, 'convertToPublic').
1564
+ *
1565
+ * @param node the virtual DOM node to convert
1566
+ * @returns a converted child node
1567
+ */
1568
+ const convertToPublic = (node) => ({
1569
+ vattrs: node.$attrs$,
1570
+ vchildren: node.$children$,
1571
+ vkey: node.$key$,
1572
+ vname: node.$name$,
1573
+ vtag: node.$tag$,
1574
+ vtext: node.$text$
1575
+ });
1576
+ /**
1577
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
1578
+ * order to use the resulting object in the virtual DOM. The initial object was
1579
+ * likely created as part of presenting a public API, so converting it back
1580
+ * involved making it 'private' again (hence, `convertToPrivate`).
1581
+ *
1582
+ * @param node the child node to convert
1583
+ * @returns a converted virtual DOM node
1584
+ */
1585
+ const convertToPrivate = (node) => {
1586
+ if (typeof node.vtag === "function") {
1587
+ const vnodeData = { ...node.vattrs };
1588
+ if (node.vkey) vnodeData.key = node.vkey;
1589
+ if (node.vname) vnodeData.name = node.vname;
1590
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
1591
+ }
1592
+ const vnode = newVNode(node.vtag, node.vtext);
1593
+ vnode.$attrs$ = node.vattrs;
1594
+ vnode.$children$ = node.vchildren;
1595
+ vnode.$key$ = node.vkey;
1596
+ vnode.$name$ = node.vname;
1597
+ return vnode;
1598
+ };
1599
+ /**
1600
+ * Validates the ordering of attributes on an input element
1601
+ *
1602
+ * @param inputElm the element to validate
1603
+ */
1604
+ const validateInputProperties = (inputElm) => {
1605
+ const props = Object.keys(inputElm);
1606
+ const value = props.indexOf("value");
1607
+ if (value === -1) return;
1608
+ const typeIndex = props.indexOf("type");
1609
+ const minIndex = props.indexOf("min");
1610
+ const maxIndex = props.indexOf("max");
1611
+ const stepIndex = props.indexOf("step");
1612
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
1613
+ };
1614
+
1615
+ //#endregion
1616
+ //#region src/runtime/client-hydrate.ts
1617
+ /**
1618
+ * Takes an SSR rendered document, as annotated by 'vdom-annotations.ts' and:
1619
+ *
1620
+ * 1) Recreate an accurate VDOM which is fed to 'vdom-render.ts'. A failure to do so can cause hydration errors; extra renders, duplicated nodes
1621
+ * 2) Add shadowDOM trees to their respective #document-fragment
1622
+ * 3) Move forwarded, slotted nodes out of shadowDOMs
1623
+ * 4) Add meta nodes to non-shadow DOMs and their 'slotted' nodes
1624
+ *
1625
+ * @param hostElm The element to hydrate.
1626
+ * @param tagName The element's tag name.
1627
+ * @param hostId The host ID assigned to the element by the server. e.g. `s-id="1"`
1628
+ * @param hostRef The host reference for the element.
1629
+ */
1630
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1631
+ const endHydrate = createTime("hydrateClient", tagName);
1632
+ const shadowRoot = hostElm.shadowRoot;
1633
+ const childRenderNodes = [];
1634
+ const slotNodes = [];
1635
+ const slottedNodes = [];
1636
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
1637
+ const vnode = newVNode(tagName, null);
1638
+ vnode.$elm$ = hostElm;
1639
+ let scopeId;
1640
+ if (BUILD.scoped) {
1641
+ const cmpMeta = hostRef.$cmpMeta$;
1642
+ if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
1643
+ scopeId = hostElm["s-sc"];
1644
+ hostElm.classList.add(scopeId + "-h");
1645
+ } else if (hostElm["s-sc"]) delete hostElm["s-sc"];
1646
+ }
1647
+ if (win.document && (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size)) initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1648
+ hostElm[HYDRATE_ID] = hostId;
1649
+ hostElm.removeAttribute(HYDRATE_ID);
1650
+ hostRef.$vnode$ = clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId, slottedNodes);
1651
+ let crIndex = 0;
1652
+ const crLength = childRenderNodes.length;
1653
+ let childRenderNode;
1654
+ for (; crIndex < crLength; crIndex++) {
1655
+ childRenderNode = childRenderNodes[crIndex];
1656
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1657
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1658
+ const node = childRenderNode.$elm$;
1659
+ if (!shadowRoot) {
1660
+ node["s-hn"] = transformTag(tagName).toUpperCase();
1661
+ if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
1662
+ } else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
1663
+ const cmpMeta = getHostRef(childRenderNode.$elm$);
1664
+ if (cmpMeta) {
1665
+ const scopeId = getScopeId(cmpMeta.$cmpMeta$, BUILD.mode ? childRenderNode.$elm$.getAttribute("s-mode") : void 0);
1666
+ const styleSheet = win.document.querySelector(`style[sty-id="${scopeId}"]`);
1667
+ if (styleSheet) shadowRootNodes.unshift(styleSheet.cloneNode(true));
1668
+ }
1669
+ }
1670
+ if (childRenderNode.$tag$ === "slot") {
1671
+ childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
1672
+ if (childRenderNode.$children$) {
1673
+ childRenderNode.$flags$ |= VNODE_FLAGS.isSlotFallback;
1674
+ if (!childRenderNode.$elm$.childNodes.length) childRenderNode.$children$.forEach((c) => {
1675
+ childRenderNode.$elm$.appendChild(c.$elm$);
1676
+ });
1677
+ } else childRenderNode.$flags$ |= VNODE_FLAGS.isSlotReference;
1678
+ }
1679
+ if (orgLocationNode && orgLocationNode.isConnected) {
1680
+ if (orgLocationNode.parentElement.shadowRoot && orgLocationNode["s-en"] === "") orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1681
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
1682
+ if (!shadowRoot) node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1683
+ }
1684
+ if (orgLocationNode && !orgLocationNode["s-id"]) plt.$orgLocNodes$.delete(orgLocationId);
1685
+ }
1686
+ const hosts = [];
1687
+ const snLen = slottedNodes.length;
1688
+ let snIndex = 0;
1689
+ let slotGroup;
1690
+ let snGroupIdx;
1691
+ let snGroupLen;
1692
+ let slottedItem;
1693
+ let currentPos = 0;
1694
+ for (; snIndex < snLen; snIndex++) {
1695
+ slotGroup = slottedNodes[snIndex];
1696
+ if (!slotGroup || !slotGroup.length) continue;
1697
+ snGroupLen = slotGroup.length;
1698
+ snGroupIdx = 0;
1699
+ for (; snGroupIdx < snGroupLen; snGroupIdx++) {
1700
+ slottedItem = slotGroup[snGroupIdx];
1701
+ if (!hosts[slottedItem.hostId]) hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1702
+ if (!hosts[slottedItem.hostId]) continue;
1703
+ const hostEle = hosts[slottedItem.hostId];
1704
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) hostEle.insertBefore(slottedItem.node, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
1705
+ if (!hostEle.shadowRoot || !shadowRoot) {
1706
+ if (!slottedItem.slot["s-cr"]) {
1707
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
1708
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) slottedItem.slot["s-cr"] = hostEle;
1709
+ else slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1710
+ }
1711
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"] || currentPos);
1712
+ if (slottedItem.node.parentElement?.shadowRoot && slottedItem.node["getAttribute"] && slottedItem.node.getAttribute("slot")) slottedItem.node.removeAttribute("slot");
1713
+ if (BUILD.experimentalSlotFixes) patchSlottedNode(slottedItem.node);
1714
+ }
1715
+ currentPos = (slottedItem.node["s-oo"] || currentPos) + 1;
1716
+ }
1717
+ }
1718
+ if (BUILD.scoped && scopeId && slotNodes.length) slotNodes.forEach((slot) => {
1719
+ slot.$elm$.parentElement.classList.add(scopeId + "-s");
1720
+ });
1721
+ if (BUILD.shadowDom && shadowRoot && !shadowRoot.childNodes.length) {
1722
+ let rnIdex = 0;
1723
+ const rnLen = shadowRootNodes.length;
1724
+ if (rnLen) {
1725
+ for (; rnIdex < rnLen; rnIdex++) {
1726
+ const node = shadowRootNodes[rnIdex];
1727
+ /**
1728
+ * in apps with a lot of components the `shadowRootNodes` array can be modified while iterating over it
1729
+ * so we need to check if the node is still in the array before appending it to avoid any errors like:
1730
+ *
1731
+ * TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
1732
+ */
1733
+ if (node) shadowRoot.appendChild(node);
1734
+ }
1735
+ Array.from(hostElm.childNodes).forEach((node) => {
1736
+ if (typeof node["s-en"] !== "string" && typeof node["s-sn"] !== "string") {
1737
+ if (node.nodeType === NODE_TYPE.ElementNode && node.slot && node.hidden) node.removeAttribute("hidden");
1738
+ else if (node.nodeType === NODE_TYPE.CommentNode && !node.nodeValue) node.parentNode.removeChild(node);
1739
+ }
1740
+ });
1741
+ }
1742
+ }
1743
+ hostRef.$hostElement$ = hostElm;
1744
+ endHydrate();
1745
+ };
1746
+ /**
1747
+ * Recursively constructs the virtual node tree for a host element and its children.
1748
+ * The tree is constructed by parsing the annotations set on the nodes by the server (`vdom-annotations.ts`).
1749
+ *
1750
+ * In addition to constructing the VNode tree, we also track information about the node's descendants:
1751
+ * - which are slots
1752
+ * - which should exist in the shadow root
1753
+ * - which are nodes that should be rendered as children of the parent node
1754
+ *
1755
+ * @param parentVNode The vNode representing the parent node.
1756
+ * @param childRenderNodes An array of all child nodes in the parent's node tree.
1757
+ * @param slotNodes An array of all slot nodes in the parent's node tree.
1758
+ * @param shadowRootNodes An array of nodes that should be rendered in the shadowDOM of the parent.
1759
+ * @param hostElm The parent element.
1760
+ * @param node The node to construct the vNode tree for.
1761
+ * @param hostId The host ID assigned to the element by the server.
1762
+ * @param slottedNodes - nodes that have been slotted
1763
+ * @returns - the constructed VNode
1764
+ */
1765
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1766
+ let childNodeType;
1767
+ let childIdSplt;
1768
+ let childVNode;
1769
+ let i;
1770
+ const scopeId = hostElm["s-sc"];
1771
+ if (node.nodeType === NODE_TYPE.ElementNode) {
1772
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1773
+ if (childNodeType) {
1774
+ childIdSplt = childNodeType.split(".");
1775
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1776
+ childVNode = createSimpleVNode({
1777
+ $flags$: 0,
1778
+ $hostId$: childIdSplt[0],
1779
+ $nodeId$: childIdSplt[1],
1780
+ $depth$: childIdSplt[2],
1781
+ $index$: childIdSplt[3],
1782
+ $tag$: node.tagName.toLowerCase(),
1783
+ $elm$: node,
1784
+ $attrs$: { class: node.className || "" }
1785
+ });
1786
+ childRenderNodes.push(childVNode);
1787
+ node.removeAttribute(HYDRATE_CHILD_ID);
1788
+ if (!parentVNode.$children$) parentVNode.$children$ = [];
1789
+ if (BUILD.scoped && scopeId && childIdSplt[0] === hostId) {
1790
+ node["s-si"] = scopeId;
1791
+ childVNode.$attrs$.class += " " + scopeId;
1792
+ }
1793
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
1794
+ if (typeof slotName === "string") {
1795
+ if (childVNode.$tag$ === "slot-fb") {
1796
+ addSlot(slotName, childIdSplt[2], childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes);
1797
+ if (BUILD.scoped && scopeId) node.classList.add(scopeId);
1798
+ }
1799
+ childVNode.$elm$["s-sn"] = slotName;
1800
+ childVNode.$elm$.removeAttribute("s-sn");
1801
+ }
1802
+ if (childVNode.$index$ !== void 0) parentVNode.$children$[childVNode.$index$] = childVNode;
1803
+ parentVNode = childVNode;
1804
+ if (shadowRootNodes && childVNode.$depth$ === "0") shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1805
+ }
1806
+ }
1807
+ if (node.shadowRoot) for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId, slottedNodes);
1808
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1809
+ for (i = nonShadowNodes.length - 1; i >= 0; i--) clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, nonShadowNodes[i], hostId, slottedNodes);
1810
+ } else if (node.nodeType === NODE_TYPE.CommentNode) {
1811
+ childIdSplt = node.nodeValue.split(".");
1812
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1813
+ childNodeType = childIdSplt[0];
1814
+ childVNode = createSimpleVNode({
1815
+ $hostId$: childIdSplt[1],
1816
+ $nodeId$: childIdSplt[2],
1817
+ $depth$: childIdSplt[3],
1818
+ $index$: childIdSplt[4] || "0",
1819
+ $elm$: node,
1820
+ $attrs$: null,
1821
+ $children$: null,
1822
+ $key$: null,
1823
+ $name$: null,
1824
+ $tag$: null,
1825
+ $text$: null
1826
+ });
1827
+ if (childNodeType === TEXT_NODE_ID) {
1828
+ childVNode.$elm$ = findCorrespondingNode(node, NODE_TYPE.TextNode);
1829
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === NODE_TYPE.TextNode) {
1830
+ childVNode.$text$ = childVNode.$elm$.textContent;
1831
+ childRenderNodes.push(childVNode);
1832
+ node.remove();
1833
+ if (hostId === childVNode.$hostId$) {
1834
+ if (!parentVNode.$children$) parentVNode.$children$ = [];
1835
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1836
+ }
1837
+ if (shadowRootNodes && childVNode.$depth$ === "0") shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1838
+ }
1839
+ } else if (childNodeType === COMMENT_NODE_ID) {
1840
+ childVNode.$elm$ = findCorrespondingNode(node, NODE_TYPE.CommentNode);
1841
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === NODE_TYPE.CommentNode) {
1842
+ childRenderNodes.push(childVNode);
1843
+ node.remove();
1844
+ }
1845
+ } else if (childVNode.$hostId$ === hostId) {
1846
+ if (childNodeType === SLOT_NODE_ID) addSlot(node["s-sn"] = childIdSplt[5] || "", childIdSplt[2], childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes);
1847
+ else if (childNodeType === CONTENT_REF_ID) {
1848
+ if (BUILD.shadowDom && shadowRootNodes) node.remove();
1849
+ else if (BUILD.slotRelocation) {
1850
+ hostElm["s-cr"] = node;
1851
+ node["s-cn"] = true;
1852
+ }
1853
+ }
1854
+ }
1855
+ }
1856
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
1857
+ const vnode = newVNode(null, node.textContent);
1858
+ vnode.$elm$ = node;
1859
+ vnode.$index$ = "0";
1860
+ parentVNode.$children$ = [vnode];
1861
+ }
1862
+ return parentVNode;
1863
+ };
1864
+ /**
1865
+ * Recursively locate any comments representing an 'original location' for a node; in a node's children or shadowRoot children.
1866
+ * Creates a map of component IDs and 'original location' ID's which are derived from comment nodes placed by 'vdom-annotations.ts'.
1867
+ * Each 'original location' relates to a lightDOM node that was moved deeper into the SSR markup. e.g. `<!--o.1-->` maps to `<div c-id="0.1">`
1868
+ *
1869
+ * @param node The node to search.
1870
+ * @param orgLocNodes A map of the original location annotations and the current node being searched.
1871
+ */
1872
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
1873
+ if (node.nodeType === NODE_TYPE.ElementNode) {
1874
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
1875
+ if (componentId) orgLocNodes.set(componentId, node);
1876
+ let i = 0;
1877
+ if (node.shadowRoot) for (; i < node.shadowRoot.childNodes.length; i++) initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1878
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1879
+ for (i = 0; i < nonShadowNodes.length; i++) initializeDocumentHydrate(nonShadowNodes[i], orgLocNodes);
1880
+ } else if (node.nodeType === NODE_TYPE.CommentNode) {
1881
+ const childIdSplt = node.nodeValue.split(".");
1882
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1883
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
1884
+ node.nodeValue = "";
1885
+ node["s-en"] = childIdSplt[3];
1886
+ }
1887
+ }
1888
+ };
1889
+ /**
1890
+ * Creates a VNode to add to a hydrated component VDOM
1891
+ *
1892
+ * @param vnode - a vnode partial which will be augmented
1893
+ * @returns an complete vnode
1894
+ */
1895
+ const createSimpleVNode = (vnode) => {
1896
+ return {
1897
+ $flags$: 0,
1898
+ $hostId$: null,
1899
+ $nodeId$: null,
1900
+ $depth$: null,
1901
+ $index$: "0",
1902
+ $elm$: null,
1903
+ $attrs$: null,
1904
+ $children$: null,
1905
+ $key$: null,
1906
+ $name$: null,
1907
+ $tag$: null,
1908
+ $text$: null,
1909
+ ...vnode
1910
+ };
1911
+ };
1912
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
1913
+ node["s-sr"] = true;
1914
+ childVNode.$name$ = slotName || null;
1915
+ childVNode.$tag$ = "slot";
1916
+ const parentNodeId = parentVNode?.$elm$ ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1917
+ if (BUILD.shadowDom && shadowRootNodes && win.document) {
1918
+ const slot = childVNode.$elm$ = win.document.createElement(childVNode.$tag$);
1919
+ if (childVNode.$name$) childVNode.$elm$.setAttribute("name", slotName);
1920
+ if (parentVNode.$elm$.shadowRoot && parentNodeId && parentNodeId !== childVNode.$hostId$) internalCall(parentVNode.$elm$, "insertBefore")(slot, internalCall(parentVNode.$elm$, "children")[0]);
1921
+ else internalCall(internalCall(node, "parentNode"), "insertBefore")(slot, node);
1922
+ addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1923
+ node.remove();
1924
+ if (childVNode.$depth$ === "0") shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1925
+ } else {
1926
+ const slot = childVNode.$elm$;
1927
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1928
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1929
+ patchSlotNode(node);
1930
+ if (shouldMove) parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1931
+ }
1932
+ childRenderNodes.push(childVNode);
1933
+ slotNodes.push(childVNode);
1934
+ if (!parentVNode.$children$) parentVNode.$children$ = [];
1935
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1936
+ }
1937
+ /**
1938
+ * Adds groups of slotted nodes (grouped by slot ID) to this host element's 'master' array.
1939
+ * We'll use this after the host element's VDOM is completely constructed to finally position and add meta required by non-shadow slotted nodes
1940
+ *
1941
+ * @param slottedNodes - the main host element 'master' array to add to
1942
+ * @param slotNodeId - the slot node unique ID
1943
+ * @param slotName - the slot node name (can be '')
1944
+ * @param slotNode - the slot node
1945
+ * @param hostId - the host element id where this node should be slotted
1946
+ */
1947
+ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1948
+ let slottedNode = slotNode.nextSibling;
1949
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1950
+ if (!slottedNode || slottedNode.nodeValue?.startsWith(SLOT_NODE_ID + ".")) return;
1951
+ do {
1952
+ if (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (!slottedNode["getAttribute"] || !slottedNode.getAttribute("slot")) && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode))) {
1953
+ slottedNode["s-sn"] = slotName;
1954
+ slottedNodes[slotNodeId].push({
1955
+ slot: slotNode,
1956
+ node: slottedNode,
1957
+ hostId
1958
+ });
1959
+ }
1960
+ slottedNode = slottedNode?.nextSibling;
1961
+ } while (slottedNode && !slottedNode.nodeValue?.startsWith(SLOT_NODE_ID + "."));
1962
+ };
1963
+ /**
1964
+ * Steps through the node's siblings to find the next node of a specific type, with a value.
1965
+ * e.g. when we find a position comment `<!--t.1-->`, we need to find the next text node with a value.
1966
+ * (it's a guard against whitespace which is never accounted for in the SSR output)
1967
+ * @param node - the starting node
1968
+ * @param type - the type of node to find
1969
+ * @returns the first corresponding node of the type
1970
+ */
1971
+ const findCorrespondingNode = (node, type) => {
1972
+ let sibling = node;
1973
+ do
1974
+ sibling = sibling.nextSibling;
1975
+ while (sibling && (sibling.nodeType !== type || !sibling.nodeValue));
1976
+ return sibling;
1977
+ };
1978
+
1979
+ //#endregion
1980
+ //#region src/utils/regular-expression.ts
1981
+ /**
1982
+ * Utility function that will escape all regular expression special characters in a string.
1983
+ *
1984
+ * @param text The string potentially containing special characters.
1985
+ * @returns The string with all special characters escaped.
1986
+ */
1987
+ const escapeRegExpSpecialCharacters = (text) => {
1988
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1989
+ };
1990
+
1991
+ //#endregion
1992
+ //#region src/utils/shadow-css.ts
1993
+ /**
1994
+ * @license
1995
+ * Copyright Google Inc. All Rights Reserved.
1996
+ *
1997
+ * Use of this source code is governed by an MIT-style license that can be
1998
+ * found in the LICENSE file at https://angular.io/license
1999
+ *
2000
+ * This file is a port of shadowCSS from `webcomponents.js` to TypeScript.
2001
+ * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
2002
+ * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
2003
+ */
2004
+ const safeSelector = (selector) => {
2005
+ const placeholders = [];
2006
+ let index = 0;
2007
+ selector = selector.replace(/(\[\s*part~=\s*("[^"]*"|'[^']*')\s*\])/g, (_, keep) => {
2008
+ const replaceBy = `__part-${index}__`;
2009
+ placeholders.push(keep);
2010
+ index++;
2011
+ return replaceBy;
2012
+ });
2013
+ selector = selector.replace(/(\[[^\]]*\])/g, (_, keep) => {
2014
+ const replaceBy = `__ph-${index}__`;
2015
+ placeholders.push(keep);
2016
+ index++;
2017
+ return replaceBy;
2018
+ });
2019
+ return {
2020
+ content: selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, (_, pseudo, exp) => {
2021
+ const replaceBy = `__ph-${index}__`;
2022
+ placeholders.push(exp);
2023
+ index++;
2024
+ return pseudo + replaceBy;
2025
+ }),
2026
+ placeholders
2027
+ };
2028
+ };
2029
+ const restoreSafeSelector = (placeholders, content) => {
2030
+ content = content.replace(/__part-(\d+)__/g, (_, index) => placeholders[+index]);
2031
+ return content.replace(/__ph-(\d+)__/g, (_, index) => placeholders[+index]);
2032
+ };
2033
+ const _polyfillHost = "-shadowcsshost";
2034
+ const _polyfillSlotted = "-shadowcssslotted";
2035
+ const _polyfillHostContext = "-shadowcsscontext";
2036
+ const _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
2037
+ const _cssColonHostRe = new RegExp("(" + _polyfillHost + _parenSuffix, "gim");
2038
+ const _cssColonHostContextRe = new RegExp("(" + _polyfillHostContext + _parenSuffix, "gim");
2039
+ const _cssColonSlottedRe = new RegExp("(" + _polyfillSlotted + _parenSuffix, "gim");
2040
+ const _polyfillHostNoCombinator = _polyfillHost + "-no-combinator";
2041
+ const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
2042
+ const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
2043
+ const _safePartRe = /__part-(\d+)__/g;
2044
+ const _polyfillHostRe = /-shadowcsshost/gim;
2045
+ /**
2046
+ * Little helper for generating a regex that will match a specified
2047
+ * CSS selector when that selector is _not_ a part of a `@supports` rule.
2048
+ *
2049
+ * The pattern will match the provided `selector` (i.e. ':host', ':host-context', etc.)
2050
+ * when that selector is not a part of a `@supports` selector rule _or_ if the selector
2051
+ * is a part of the rule's declaration.
2052
+ *
2053
+ * For instance, if we create the regex with the selector ':host-context':
2054
+ * - '@supports selector(:host-context())' will return no matches (starts with '@supports')
2055
+ * - '@supports selector(:host-context()) { :host-context() { ... }}' will match the second ':host-context' (part of declaration)
2056
+ * - ':host-context() { ... }' will match ':host-context' (selector is not a '@supports' rule)
2057
+ * - ':host() { ... }' will return no matches (selector doesn't match selector used to create regex)
2058
+ *
2059
+ * @param selector The CSS selector we want to match for replacement
2060
+ * @returns A look-behind regex containing the selector
2061
+ */
2062
+ const createSupportsRuleRe = (selector) => {
2063
+ const safeSelector = escapeRegExpSpecialCharacters(selector);
2064
+ return new RegExp(`(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector}))(${safeSelector}\\b)`, "g");
2065
+ };
2066
+ const _commentRe = /\/\*\s*[\s\S]*?\*\//g;
2067
+ const stripComments = (input) => {
2068
+ return input.replace(_commentRe, "");
2069
+ };
2070
+ const _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
2071
+ const extractCommentsWithHash = (input) => {
2072
+ return input.match(_commentWithHashRe) || [];
2073
+ };
2074
+ const _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
2075
+ const _curlyRe = /([{}])/g;
2076
+ const _selectorPartsRe = /(^.*?[^\\])??((:+)(.*)|$)/;
2077
+ const OPEN_CURLY = "{";
2078
+ const CLOSE_CURLY = "}";
2079
+ const BLOCK_PLACEHOLDER = "%BLOCK%";
2080
+ const processRules = (input, ruleCallback) => {
2081
+ const inputWithEscapedBlocks = escapeBlocks(input);
2082
+ let nextBlockIndex = 0;
2083
+ return inputWithEscapedBlocks.escapedString.replace(_ruleRe, (...m) => {
2084
+ const selector = m[2];
2085
+ let content = "";
2086
+ let suffix = m[4];
2087
+ let contentPrefix = "";
2088
+ if (suffix && suffix.startsWith("{" + BLOCK_PLACEHOLDER)) {
2089
+ content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
2090
+ suffix = suffix.substring(8);
2091
+ contentPrefix = "{";
2092
+ }
2093
+ const rule = ruleCallback({
2094
+ selector,
2095
+ content
2096
+ });
2097
+ return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;
2098
+ });
2099
+ };
2100
+ const escapeBlocks = (input) => {
2101
+ const inputParts = input.split(_curlyRe);
2102
+ const resultParts = [];
2103
+ const escapedBlocks = [];
2104
+ let bracketCount = 0;
2105
+ let currentBlockParts = [];
2106
+ for (let partIndex = 0; partIndex < inputParts.length; partIndex++) {
2107
+ const part = inputParts[partIndex];
2108
+ if (part === CLOSE_CURLY) bracketCount--;
2109
+ if (bracketCount > 0) currentBlockParts.push(part);
2110
+ else {
2111
+ if (currentBlockParts.length > 0) {
2112
+ escapedBlocks.push(currentBlockParts.join(""));
2113
+ resultParts.push(BLOCK_PLACEHOLDER);
2114
+ currentBlockParts = [];
2115
+ }
2116
+ resultParts.push(part);
2117
+ }
2118
+ if (part === OPEN_CURLY) bracketCount++;
2119
+ }
2120
+ if (currentBlockParts.length > 0) {
2121
+ escapedBlocks.push(currentBlockParts.join(""));
2122
+ resultParts.push(BLOCK_PLACEHOLDER);
2123
+ }
2124
+ return {
2125
+ escapedString: resultParts.join(""),
2126
+ blocks: escapedBlocks
2127
+ };
2128
+ };
2129
+ /**
2130
+ * Replaces certain strings within the CSS with placeholders
2131
+ * that will later be replaced with class selectors appropriate
2132
+ * for the level of encapsulation (shadow or scoped).
2133
+ *
2134
+ * When performing these replacements, we want to ignore selectors that are a
2135
+ * part of an `@supports` rule. Replacing these selectors will result in invalid
2136
+ * CSS that gets passed to autoprefixer/postcss once the placeholders are replaced.
2137
+ * For example, a rule like:
2138
+ *
2139
+ * ```css
2140
+ * @supports selector(:host()) {
2141
+ * :host {
2142
+ * color: red;
2143
+ * }
2144
+ * }
2145
+ * ```
2146
+ *
2147
+ * Should be converted to:
2148
+ *
2149
+ * ```css
2150
+ * @supports selector(:host()) {
2151
+ * -shadowcsshost {
2152
+ * color: red;
2153
+ * }
2154
+ * }
2155
+ * ```
2156
+ *
2157
+ * The order the regex replacements happen in matters since we match
2158
+ * against a whole selector word so we need to match all of `:host-context`
2159
+ * before we try to replace `:host`. Otherwise the pattern for `:host` would match
2160
+ * `:host-context` resulting in something like `:-shadowcsshost-context`.
2161
+ *
2162
+ * @param cssText A CSS string for a component
2163
+ * @returns The modified CSS string
2164
+ */
2165
+ const insertPolyfillHostInCssText = (cssText) => {
2166
+ const supportsBlocks = [];
2167
+ cssText = cssText.replace(/@supports\s+selector\s*\(\s*([^)]*)\s*\)/g, (_, selectorContent) => {
2168
+ const placeholder = `__supports_${supportsBlocks.length}__`;
2169
+ supportsBlocks.push(selectorContent);
2170
+ return `@supports selector(${placeholder})`;
2171
+ });
2172
+ const _colonSlottedRe = createSupportsRuleRe("::slotted");
2173
+ const _colonHostRe = createSupportsRuleRe(":host");
2174
+ const _colonHostContextRe = createSupportsRuleRe(":host-context");
2175
+ cssText = cssText.replace(_colonHostContextRe, `$1${_polyfillHostContext}`).replace(_colonHostRe, `$1${_polyfillHost}`).replace(_colonSlottedRe, `$1${_polyfillSlotted}`);
2176
+ supportsBlocks.forEach((originalSelector, index) => {
2177
+ cssText = cssText.replace(`__supports_${index}__`, originalSelector);
2178
+ });
2179
+ return cssText;
2180
+ };
2181
+ const convertColonRule = (cssText, regExp, partReplacer) => {
2182
+ return cssText.replace(regExp, (...m) => {
2183
+ if (m[2]) {
2184
+ const parts = m[2].split(",");
2185
+ const r = [];
2186
+ for (let i = 0; i < parts.length; i++) {
2187
+ const p = parts[i].trim();
2188
+ if (!p) break;
2189
+ r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
2190
+ }
2191
+ return r.join(",");
2192
+ } else return _polyfillHostNoCombinator + m[3];
2193
+ });
2194
+ };
2195
+ const colonHostPartReplacer = (host, part, suffix) => {
2196
+ return host + part.replace(_polyfillHost, "") + suffix;
2197
+ };
2198
+ const convertColonHost = (cssText) => {
2199
+ return convertColonRule(cssText, _cssColonHostRe, colonHostPartReplacer);
2200
+ };
2201
+ const colonHostContextPartReplacer = (host, part, suffix) => {
2202
+ if (part.indexOf(_polyfillHost) > -1) return colonHostPartReplacer(host, part, suffix);
2203
+ else return host + part + suffix + ", " + part + " " + host + suffix;
2204
+ };
2205
+ const convertColonSlotted = (cssText, slotScopeId) => {
2206
+ const slotClass = "." + slotScopeId + " > ";
2207
+ const selectors = [];
2208
+ cssText = cssText.replace(_cssColonSlottedRe, (...m) => {
2209
+ if (m[2]) {
2210
+ const compound = m[2].trim();
2211
+ const suffix = m[3];
2212
+ const slottedSelector = slotClass + compound + suffix;
2213
+ let prefixSelector = "";
2214
+ for (let i = m[4] - 1; i >= 0; i--) {
2215
+ const char = m[5][i];
2216
+ if (char === "}" || char === ",") break;
2217
+ prefixSelector = char + prefixSelector;
2218
+ }
2219
+ const orgSelector = (prefixSelector + slottedSelector).trim();
2220
+ const addedSelector = `${prefixSelector.trimEnd()}${slottedSelector.trim()}`.trim();
2221
+ if (orgSelector !== addedSelector) {
2222
+ const updatedSelector = `${addedSelector}, ${orgSelector}`;
2223
+ selectors.push({
2224
+ orgSelector,
2225
+ updatedSelector
2226
+ });
2227
+ }
2228
+ return slottedSelector;
2229
+ } else return _polyfillHostNoCombinator + m[3];
2230
+ });
2231
+ return {
2232
+ selectors,
2233
+ cssText
2234
+ };
2235
+ };
2236
+ const convertColonHostContext = (cssText) => {
2237
+ return convertColonRule(cssText, _cssColonHostContextRe, colonHostContextPartReplacer);
2238
+ };
2239
+ const convertShadowDOMSelectors = (cssText) => {
2240
+ return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, " "), cssText);
2241
+ };
2242
+ const makeScopeMatcher = (scopeSelector) => {
2243
+ scopeSelector = scopeSelector.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
2244
+ return new RegExp("^(" + scopeSelector + ")([>\\s~+[.,{:][\\s\\S]*)?$", "m");
2245
+ };
2246
+ const selectorNeedsScoping = (selector, scopeSelector) => {
2247
+ return !makeScopeMatcher(scopeSelector).test(selector);
2248
+ };
2249
+ const injectScopingSelector = (selector, scopingSelector) => {
2250
+ return selector.replace(_selectorPartsRe, (_, before = "", _colonGroup, colon = "", after = "") => {
2251
+ return before + scopingSelector + colon + after;
2252
+ });
2253
+ };
2254
+ const applySimpleSelectorScope = (selector, scopeSelector, hostSelector) => {
2255
+ _polyfillHostRe.lastIndex = 0;
2256
+ if (_polyfillHostRe.test(selector)) {
2257
+ const replaceBy = `.${hostSelector}`;
2258
+ return selector.replace(_polyfillHostNoCombinatorRe, (_, selector) => injectScopingSelector(selector, replaceBy)).replace(_polyfillHostRe, replaceBy + " ");
2259
+ }
2260
+ return scopeSelector + " " + selector;
2261
+ };
2262
+ const applyStrictSelectorScope = (selector, scopeSelector, hostSelector) => {
2263
+ scopeSelector = scopeSelector.replace(/\[is=([^\]]*)\]/g, (_, ...parts) => parts[0]);
2264
+ const className = "." + scopeSelector;
2265
+ const _scopeSelectorPart = (p) => {
2266
+ let scopedP = p.trim();
2267
+ if (!scopedP) return "";
2268
+ if (p.indexOf(_polyfillHostNoCombinator) > -1) scopedP = applySimpleSelectorScope(p, scopeSelector, hostSelector);
2269
+ else {
2270
+ const t = p.replace(_polyfillHostRe, "");
2271
+ if (t.length > 0) scopedP = injectScopingSelector(t, className);
2272
+ }
2273
+ return scopedP;
2274
+ };
2275
+ const safeContent = safeSelector(selector);
2276
+ selector = safeContent.content;
2277
+ let scopedSelector = "";
2278
+ let startIndex = 0;
2279
+ let res;
2280
+ const sep = /( |>|\+|~(?!=))(?=(?:[^()]*\([^()]*\))*[^()]*$)\s*/g;
2281
+ let shouldScope = !(selector.indexOf(_polyfillHostNoCombinator) > -1);
2282
+ while ((res = sep.exec(selector)) !== null) {
2283
+ const separator = res[1];
2284
+ const part = selector.slice(startIndex, res.index).trim();
2285
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
2286
+ const scopedPart = shouldScope ? _scopeSelectorPart(part) : part;
2287
+ scopedSelector += `${scopedPart} ${separator} `;
2288
+ startIndex = sep.lastIndex;
2289
+ }
2290
+ const part = selector.substring(startIndex);
2291
+ shouldScope = !part.match(_safePartRe) && (shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1);
2292
+ scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
2293
+ return restoreSafeSelector(safeContent.placeholders, scopedSelector);
2294
+ };
2295
+ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector) => {
2296
+ return selector.split(",").map((shallowPart) => {
2297
+ if (slotSelector && shallowPart.indexOf("." + slotSelector) > -1) return shallowPart.trim();
2298
+ if (selectorNeedsScoping(shallowPart, scopeSelectorText)) return applyStrictSelectorScope(shallowPart, scopeSelectorText, hostSelector).trim();
2299
+ else return shallowPart.trim();
2300
+ }).join(", ");
2301
+ };
2302
+ const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
2303
+ return processRules(cssText, (rule) => {
2304
+ let selector = rule.selector;
2305
+ let content = rule.content;
2306
+ if (rule.selector[0] !== "@") selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
2307
+ else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
2308
+ return {
2309
+ selector: selector.replace(/\s{2,}/g, " ").trim(),
2310
+ content
2311
+ };
2312
+ });
2313
+ };
2314
+ const scopeCssText = (cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector) => {
2315
+ cssText = insertPolyfillHostInCssText(cssText);
2316
+ cssText = convertColonHost(cssText);
2317
+ cssText = convertColonHostContext(cssText);
2318
+ const slotted = convertColonSlotted(cssText, slotScopeId);
2319
+ cssText = slotted.cssText;
2320
+ cssText = convertShadowDOMSelectors(cssText);
2321
+ if (scopeId) cssText = scopeSelectors(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
2322
+ cssText = replaceShadowCssHost(cssText, hostScopeId);
2323
+ cssText = cssText.replace(/>\s*\*\s+([^{, ]+)/gm, " $1 ");
2324
+ return {
2325
+ cssText: cssText.trim(),
2326
+ slottedSelectors: slotted.selectors.map((ref) => ({
2327
+ orgSelector: replaceShadowCssHost(ref.orgSelector, hostScopeId),
2328
+ updatedSelector: replaceShadowCssHost(ref.updatedSelector, hostScopeId)
2329
+ }))
2330
+ };
2331
+ };
2332
+ /**
2333
+ * Helper function that replaces the interim string representing a `:host` selector with
2334
+ * the host scope selector class for the element.
2335
+ *
2336
+ * @param cssText The CSS string to make the replacement in
2337
+ * @param hostScopeId The scope ID that will be used as the class representing the host element
2338
+ * @returns CSS with the selector replaced
2339
+ */
2340
+ const replaceShadowCssHost = (cssText, hostScopeId) => {
2341
+ return cssText.replace(/-shadowcsshost-no-combinator/g, `.${hostScopeId}`);
2342
+ };
2343
+ /**
2344
+ * Expands selectors with ::part(...) to also include [part~="..."] selectors.
2345
+ * For example:
2346
+ * ```css
2347
+ * selectors-like-this::part(demo) { ... }
2348
+ * .something .selectors::part(demo demo2):hover { ... }
2349
+ * ```
2350
+ * Becomes:
2351
+ * ```
2352
+ * selectors-like-this::part(demo), selectors-like-this [part~="demo"] { ... }
2353
+ * .something .selectors::part(demo demo2):hover, .something .selectors [part~="demo"][part~="demo2"]:hover { ... }
2354
+ * ```
2355
+ *
2356
+ * @param cssText The CSS text to process
2357
+ * @returns The CSS text with expanded ::part(...) selectors
2358
+ */
2359
+ const expandPartSelectors = (cssText) => {
2360
+ const partSelectorRe = /([^\s,{][^,{]*?)::part\(\s*([^)]+?)\s*\)((?:[:.][^,{]*)*)/g;
2361
+ return processRules(cssText, (rule) => {
2362
+ if (rule.selector[0] === "@") return rule;
2363
+ rule.selector = rule.selector.split(",").map((sel) => {
2364
+ const out = [sel.trim()];
2365
+ let m;
2366
+ while ((m = partSelectorRe.exec(sel)) !== null) {
2367
+ const before = m[1].trimEnd();
2368
+ const partNames = m[2].trim().split(/\s+/);
2369
+ const after = m[3] || "";
2370
+ const partAttr = partNames.flatMap((p) => {
2371
+ if (!rule.selector.includes(`[part~="${p}"]`)) return [`[part~="${p}"]`];
2372
+ return [];
2373
+ }).join("");
2374
+ const expanded = `${before} ${partAttr}${after}`;
2375
+ if (!!partAttr && expanded !== sel.trim()) out.push(expanded);
2376
+ }
2377
+ return out.join(", ");
2378
+ }).join(", ");
2379
+ return rule;
2380
+ });
2381
+ };
2382
+ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
2383
+ const hostScopeId = scopeId + "-h";
2384
+ const slotScopeId = scopeId + "-s";
2385
+ const commentsWithHash = extractCommentsWithHash(cssText);
2386
+ cssText = stripComments(cssText);
2387
+ const orgSelectors = [];
2388
+ if (commentOriginalSelector) {
2389
+ const processCommentedSelector = (rule) => {
2390
+ const placeholder = `/*!@___${orgSelectors.length}___*/`;
2391
+ const comment = `/*!@${rule.selector}*/`;
2392
+ orgSelectors.push({
2393
+ placeholder,
2394
+ comment
2395
+ });
2396
+ rule.selector = placeholder + rule.selector;
2397
+ return rule;
2398
+ };
2399
+ cssText = processRules(cssText, (rule) => {
2400
+ if (rule.selector[0] !== "@") return processCommentedSelector(rule);
2401
+ else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
2402
+ rule.content = processRules(rule.content, processCommentedSelector);
2403
+ return rule;
2404
+ }
2405
+ return rule;
2406
+ });
2407
+ }
2408
+ const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
2409
+ cssText = [scoped.cssText, ...commentsWithHash].join("\n");
2410
+ if (commentOriginalSelector) orgSelectors.forEach(({ placeholder, comment }) => {
2411
+ cssText = cssText.replace(placeholder, comment);
2412
+ });
2413
+ scoped.slottedSelectors.forEach((slottedSelector) => {
2414
+ const regex = new RegExp(escapeRegExpSpecialCharacters(slottedSelector.orgSelector) + "(?=\\s*[,{]|$)", "g");
2415
+ cssText = cssText.replace(regex, slottedSelector.updatedSelector);
2416
+ });
2417
+ cssText = expandPartSelectors(cssText);
2418
+ return cssText;
2419
+ };
2420
+
2421
+ //#endregion
2422
+ //#region src/runtime/mode.ts
2423
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
2424
+ const setMode = (handler) => modeResolutionChain.push(handler);
2425
+ const getMode = (ref) => getHostRef(ref)?.$modeName$;
2426
+
2427
+ //#endregion
2428
+ //#region src/utils/remote-value.ts
2429
+ /**
2430
+ * RemoteValue class for deserializing LocalValue serialized objects back into their original form
2431
+ * @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead.
2432
+ */
2433
+ var RemoteValue = class RemoteValue {
2434
+ /**
2435
+ * Deserializes a LocalValue serialized object back to its original JavaScript representation
2436
+ *
2437
+ * @param serialized The serialized LocalValue object
2438
+ * @returns The original JavaScript value/object
2439
+ */
2440
+ static fromLocalValue(serialized) {
2441
+ const type = serialized[TYPE_CONSTANT];
2442
+ const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
2443
+ switch (type) {
2444
+ case PrimitiveType.String: return value;
2445
+ case PrimitiveType.Boolean: return value;
2446
+ case PrimitiveType.BigInt: return BigInt(value);
2447
+ case PrimitiveType.Undefined: return;
2448
+ case PrimitiveType.Null: return null;
2449
+ case PrimitiveType.Number:
2450
+ if (value === "NaN") return NaN;
2451
+ if (value === "-0") return -0;
2452
+ if (value === "Infinity") return Infinity;
2453
+ if (value === "-Infinity") return -Infinity;
2454
+ return value;
2455
+ case NonPrimitiveType.Array: return value.map((item) => RemoteValue.fromLocalValue(item));
2456
+ case NonPrimitiveType.Date: return new Date(value);
2457
+ case NonPrimitiveType.Map:
2458
+ const map = /* @__PURE__ */ new Map();
2459
+ for (const [key, val] of value) {
2460
+ const deserializedKey = typeof key === "object" && key !== null ? RemoteValue.fromLocalValue(key) : key;
2461
+ const deserializedValue = RemoteValue.fromLocalValue(val);
2462
+ map.set(deserializedKey, deserializedValue);
2463
+ }
2464
+ return map;
2465
+ case NonPrimitiveType.Object:
2466
+ const obj = {};
2467
+ for (const [key, val] of value) obj[key] = RemoteValue.fromLocalValue(val);
2468
+ return obj;
2469
+ case NonPrimitiveType.RegularExpression:
2470
+ const { pattern, flags } = value;
2471
+ return new RegExp(pattern, flags);
2472
+ case NonPrimitiveType.Set:
2473
+ const set = /* @__PURE__ */ new Set();
2474
+ for (const item of value) set.add(RemoteValue.fromLocalValue(item));
2475
+ return set;
2476
+ case NonPrimitiveType.Symbol: return Symbol(value);
2477
+ default: throw new Error(`Unsupported type: ${type}`);
2478
+ }
2479
+ }
2480
+ /**
2481
+ * Utility method to deserialize multiple LocalValues at once
2482
+ *
2483
+ * @param serializedValues Array of serialized LocalValue objects
2484
+ * @returns Array of deserialized JavaScript values
2485
+ */
2486
+ static fromLocalValueArray(serializedValues) {
2487
+ return serializedValues.map((value) => RemoteValue.fromLocalValue(value));
2488
+ }
2489
+ /**
2490
+ * Verifies if the given object matches the structure of a serialized LocalValue
2491
+ *
2492
+ * @param obj Object to verify
2493
+ * @returns boolean indicating if the object has LocalValue structure
2494
+ */
2495
+ static isLocalValueObject(obj) {
2496
+ if (typeof obj !== "object" || obj === null) return false;
2497
+ if (!obj.hasOwnProperty(TYPE_CONSTANT)) return false;
2498
+ const type = obj[TYPE_CONSTANT];
2499
+ if (!Object.values({
2500
+ ...PrimitiveType,
2501
+ ...NonPrimitiveType
2502
+ }).includes(type)) return false;
2503
+ if (type !== PrimitiveType.Null && type !== PrimitiveType.Undefined) return obj.hasOwnProperty(VALUE_CONSTANT);
2504
+ return true;
2505
+ }
2506
+ };
2507
+
2508
+ //#endregion
2509
+ //#region src/utils/serialize.ts
2510
+ /**
2511
+ * Deserialize a value from a string that was serialized earlier.
2512
+ * @param {string} value - The string to deserialize.
2513
+ * @returns {unknown} The deserialized value.
2514
+ * @deprecated will be removed in v5. Use `@AttrDeserialize()` decorator instead.
2515
+ */
2516
+ function deserializeProperty(value) {
2517
+ if (typeof value !== "string" || !value.startsWith(SERIALIZED_PREFIX)) return value;
2518
+ return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
2519
+ }
2520
+
2521
+ //#endregion
2522
+ //#region src/runtime/parse-property-value.ts
2523
+ /**
2524
+ * Parse a new property value for a given property type.
2525
+ *
2526
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
2527
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
2528
+ * 1. `any`, the type given to `propValue` in the function signature
2529
+ * 2. the type stored from `propType`.
2530
+ *
2531
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
2532
+ *
2533
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
2534
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
2535
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
2536
+ * ```tsx
2537
+ * <my-cmp prop-val={0}></my-cmp>
2538
+ * ```
2539
+ *
2540
+ * HTML prop values on the other hand, will always a string
2541
+ *
2542
+ * @param propValue the new value to coerce to some type
2543
+ * @param propType the type of the prop, expressed as a binary number
2544
+ * @param isFormAssociated whether the component is form-associated (optional)
2545
+ * @returns the parsed/coerced value
2546
+ */
2547
+ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
2548
+ /**
2549
+ * Allow hydrate parameters that contain a complex non-serialized values.
2550
+ * This is SSR-specific and should only run during hydration.
2551
+ */
2552
+ if ((BUILD.hydrateClientSide || BUILD.hydrateServerSide) && typeof propValue === "string" && propValue.startsWith(SERIALIZED_PREFIX)) {
2553
+ propValue = deserializeProperty(propValue);
2554
+ return propValue;
2555
+ }
2556
+ if (propValue != null && !isComplexType(propValue)) {
2557
+ /**
2558
+ * ensure this value is of the correct prop type
2559
+ */
2560
+ if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
2561
+ /**
2562
+ * For form-associated components, according to HTML spec, the presence of any boolean attribute
2563
+ * (regardless of its value, even "false") should make the property true.
2564
+ * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
2565
+ */
2566
+ if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
2567
+ else return propValue === "false" ? false : propValue === "" || !!propValue;
2568
+ /**
2569
+ * force it to be a number
2570
+ */
2571
+ if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
2572
+ /**
2573
+ * could have been passed as a number or boolean but we still want it as a string
2574
+ */
2575
+ if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
2576
+ return propValue;
2577
+ }
2578
+ /**
2579
+ * not sure exactly what type we want so no need to change to a different type
2580
+ */
2581
+ return propValue;
2582
+ };
2583
+
2584
+ //#endregion
2585
+ //#region src/runtime/element.ts
2586
+ const getElement = (ref) => BUILD.lazyLoad ? getHostRef(ref)?.$hostElement$ : ref;
2587
+
2588
+ //#endregion
2589
+ //#region src/runtime/event-emitter.ts
2590
+ const createEvent = (ref, name, flags) => {
2591
+ const elm = getElement(ref);
2592
+ return { emit: (detail) => {
2593
+ if (BUILD.isDev && !elm.isConnected) consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
2594
+ return emitEvent(elm, name, {
2595
+ bubbles: !!(flags & EVENT_FLAGS.Bubbles),
2596
+ composed: !!(flags & EVENT_FLAGS.Composed),
2597
+ cancelable: !!(flags & EVENT_FLAGS.Cancellable),
2598
+ detail
2599
+ });
2600
+ } };
2601
+ };
2602
+ /**
2603
+ * Helper function to create & dispatch a custom Event on a provided target
2604
+ * @param elm the target of the Event
2605
+ * @param name the name to give the custom Event
2606
+ * @param opts options for configuring a custom Event
2607
+ * @returns the custom Event
2608
+ */
2609
+ const emitEvent = (elm, name, opts) => {
2610
+ const ev = plt.ce(name, opts);
2611
+ elm.dispatchEvent(ev);
2612
+ return ev;
2613
+ };
2614
+
2615
+ //#endregion
2616
+ //#region src/runtime/vdom/set-accessor.ts
2617
+ /**
2618
+ * Production setAccessor() function based on Preact by
2619
+ * Jason Miller (@developit)
2620
+ * Licensed under the MIT License
2621
+ * https://github.com/developit/preact/blob/master/LICENSE
2622
+ *
2623
+ * Modified for Stencil's compiler and vdom
2624
+ */
2625
+ /**
2626
+ * When running a VDom render set properties present on a VDom node onto the
2627
+ * corresponding HTML element.
2628
+ *
2629
+ * Note that this function has special functionality for the `class`,
2630
+ * `style`, `key`, and `ref` attributes, as well as event handlers (like
2631
+ * `onClick`, etc). All others are just passed through as-is.
2632
+ *
2633
+ * @param elm the HTMLElement onto which attributes should be set
2634
+ * @param memberName the name of the attribute to set
2635
+ * @param oldValue the old value for the attribute
2636
+ * @param newValue the new value for the attribute
2637
+ * @param isSvg whether we're in an svg context or not
2638
+ * @param flags bitflags for Vdom variables
2639
+ * @param initialRender whether this is the first render of the VDom
2640
+ */
2641
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
2642
+ if (oldValue === newValue) return;
2643
+ let isProp = isMemberInElement(elm, memberName);
2644
+ let ln = memberName.toLowerCase();
2645
+ if (BUILD.vdomClass && memberName === "class") {
2646
+ const classList = elm.classList;
2647
+ const oldClasses = parseClassList(oldValue);
2648
+ let newClasses = parseClassList(newValue);
2649
+ if (BUILD.hydrateClientSide && (elm["s-si"] || elm["s-sc"]) && initialRender) {
2650
+ const scopeId = elm["s-sc"] || elm["s-si"];
2651
+ newClasses.push(scopeId);
2652
+ oldClasses.forEach((c) => {
2653
+ if (c.startsWith(scopeId)) newClasses.push(c);
2654
+ });
2655
+ newClasses = [...new Set(newClasses)].filter((c) => c);
2656
+ classList.add(...newClasses);
2657
+ } else {
2658
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
2659
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
2660
+ }
2661
+ } else if (BUILD.vdomStyle && memberName === "style") {
2662
+ if (BUILD.updatable) {
2663
+ for (const prop in oldValue) if (!newValue || newValue[prop] == null) if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
2664
+ else elm.style[prop] = "";
2665
+ }
2666
+ for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
2667
+ else elm.style[prop] = newValue[prop];
2668
+ } else if (BUILD.vdomKey && memberName === "key") {} else if (BUILD.vdomRef && memberName === "ref") {
2669
+ if (newValue) queueRefAttachment(newValue, elm);
2670
+ } else if (BUILD.vdomListener && (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
2671
+ if (memberName[2] === "-") memberName = memberName.slice(3);
2672
+ else if (isMemberInElement(win, ln)) memberName = ln.slice(2);
2673
+ else memberName = ln[2] + memberName.slice(3);
2674
+ if (oldValue || newValue) {
2675
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
2676
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
2677
+ if (oldValue) plt.rel(elm, memberName, oldValue, capture);
2678
+ if (newValue) plt.ael(elm, memberName, newValue, capture);
2679
+ }
2680
+ } else if (BUILD.vdomPropOrAttr && memberName[0] === "a" && memberName.startsWith("attr:")) {
2681
+ const propName = memberName.slice(5);
2682
+ let attrName;
2683
+ if (BUILD.member) {
2684
+ const hostRef = getHostRef(elm);
2685
+ if (hostRef && hostRef.$cmpMeta$ && hostRef.$cmpMeta$.$members$) {
2686
+ const memberMeta = hostRef.$cmpMeta$.$members$[propName];
2687
+ if (memberMeta && memberMeta[1]) attrName = memberMeta[1];
2688
+ }
2689
+ }
2690
+ if (!attrName) attrName = propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
2691
+ if (newValue == null || newValue === false) {
2692
+ if (newValue !== false || elm.getAttribute(attrName) === "") elm.removeAttribute(attrName);
2693
+ } else elm.setAttribute(attrName, newValue === true ? "" : newValue);
2694
+ return;
2695
+ } else if (BUILD.vdomPropOrAttr && memberName[0] === "p" && memberName.startsWith("prop:")) {
2696
+ const propName = memberName.slice(5);
2697
+ try {
2698
+ elm[propName] = newValue;
2699
+ } catch (e) {}
2700
+ return;
2701
+ } else if (BUILD.vdomPropOrAttr) {
2702
+ const isComplex = isComplexType(newValue);
2703
+ if ((isProp || isComplex && newValue !== null) && !isSvg) try {
2704
+ if (!elm.tagName.includes("-")) {
2705
+ const n = newValue == null ? "" : newValue;
2706
+ if (memberName === "list") isProp = false;
2707
+ else if (oldValue == null || elm[memberName] !== n) if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
2708
+ else elm.setAttribute(memberName, n);
2709
+ } else if (elm[memberName] !== newValue) elm[memberName] = newValue;
2710
+ } catch (e) {}
2711
+ /**
2712
+ * Need to manually update attribute if:
2713
+ * - memberName is not an attribute
2714
+ * - if we are rendering the host element in order to reflect attribute
2715
+ * - if it's a SVG, since properties might not work in <svg>
2716
+ * - if the newValue is null/undefined or 'false'.
2717
+ */
2718
+ let xlink = false;
2719
+ if (BUILD.vdomXlink) {
2720
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
2721
+ memberName = ln;
2722
+ xlink = true;
2723
+ }
2724
+ }
2725
+ if (newValue == null || newValue === false) {
2726
+ if (newValue !== false || elm.getAttribute(memberName) === "") if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
2727
+ else elm.removeAttribute(memberName);
2728
+ } else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
2729
+ newValue = newValue === true ? "" : newValue;
2730
+ if (BUILD.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
2731
+ else elm.setAttribute(memberName, newValue);
2732
+ }
2733
+ }
2734
+ };
2735
+ const parseClassListRegex = /\s/;
2736
+ /**
2737
+ * Parsed a string of classnames into an array
2738
+ * @param value className string, e.g. "foo bar baz"
2739
+ * @returns list of classes, e.g. ["foo", "bar", "baz"]
2740
+ */
2741
+ const parseClassList = (value) => {
2742
+ if (typeof value === "object" && value && "baseVal" in value) value = value.baseVal;
2743
+ if (!value || typeof value !== "string") return [];
2744
+ return value.split(parseClassListRegex);
2745
+ };
2746
+ const CAPTURE_EVENT_SUFFIX = "Capture";
2747
+ const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
2748
+
2749
+ //#endregion
2750
+ //#region src/runtime/vdom/update-element.ts
2751
+ /**
2752
+ * Handle updating attributes on the component element based on the current
2753
+ * values present in the virtual DOM.
2754
+ *
2755
+ * If the component of interest uses shadow DOM these are added to the shadow
2756
+ * root's host element.
2757
+ *
2758
+ * @param oldVnode an old virtual DOM node or null
2759
+ * @param newVnode a new virtual DOM node
2760
+ * @param isSvgMode whether or not we're in an SVG context
2761
+ * @param isInitialRender whether this is the first render of the VDOM
2762
+ */
2763
+ const updateElement = (oldVnode, newVnode, isSvgMode, isInitialRender) => {
2764
+ const elm = newVnode.$elm$.nodeType === NODE_TYPE.DocumentFragment && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
2765
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
2766
+ const newVnodeAttrs = newVnode.$attrs$ || {};
2767
+ if (BUILD.updatable) {
2768
+ for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) if (!(memberName in newVnodeAttrs)) setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode, newVnode.$flags$, isInitialRender);
2769
+ }
2770
+ for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$, isInitialRender);
2771
+ };
2772
+ /**
2773
+ * Sort a list of attribute names to ensure that all the attribute names which
2774
+ * are _not_ `"ref"` come before `"ref"`. Preserve the order of the non-ref
2775
+ * attributes.
2776
+ *
2777
+ * **Note**: if the supplied attributes do not include `'ref'` then the same
2778
+ * (by reference) array will be returned without modification.
2779
+ *
2780
+ * @param attrNames attribute names to sort
2781
+ * @returns a list of attribute names, sorted if they include `"ref"`
2782
+ */
2783
+ function sortedAttrNames(attrNames) {
2784
+ return attrNames.includes("ref") ? [...attrNames.filter((attr) => attr !== "ref"), "ref"] : attrNames;
2785
+ }
2786
+
2787
+ //#endregion
2788
+ //#region src/runtime/vdom/vdom-render.ts
2789
+ /**
2790
+ * Virtual DOM patching algorithm based on Snabbdom by
2791
+ * Simon Friis Vindum (@paldepind)
2792
+ * Licensed under the MIT License
2793
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
2794
+ *
2795
+ * Modified for Stencil's renderer and slot projection
2796
+ */
2797
+ let scopeId;
2798
+ let contentRef;
2799
+ let hostTagName;
2800
+ let useNativeShadowDom = false;
2801
+ let checkSlotFallbackVisibility = false;
2802
+ let checkSlotRelocate = false;
2803
+ let isSvgMode = false;
2804
+ /**
2805
+ * Queues for ref callbacks that need to be called during rendering.
2806
+ * These ensure that ref callbacks are called in the correct order:
2807
+ * first all removal callbacks (with null), then all attachment callbacks (with elements).
2808
+ */
2809
+ let refCallbacksToRemove = [];
2810
+ let refCallbacksToAttach = [];
2811
+ /**
2812
+ * Create a DOM Node corresponding to one of the children of a given VNode.
2813
+ *
2814
+ * @param oldParentVNode the parent VNode from the previous render
2815
+ * @param newParentVNode the parent VNode from the current render
2816
+ * @param childIndex the index of the VNode, in the _new_ parent node's
2817
+ * children, for which we will create a new DOM node
2818
+ * @returns the newly created node
2819
+ */
2820
+ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
2821
+ const newVNode = newParentVNode.$children$[childIndex];
2822
+ let i = 0;
2823
+ let elm;
2824
+ let childNode;
2825
+ let oldVNode;
2826
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
2827
+ checkSlotRelocate = true;
2828
+ if (newVNode.$tag$ === "slot") newVNode.$flags$ |= newVNode.$children$ ? VNODE_FLAGS.isSlotFallback : VNODE_FLAGS.isSlotReference;
2829
+ }
2830
+ if (BUILD.isDev && newVNode.$elm$) 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`);
2831
+ if (BUILD.vdomText && newVNode.$text$ != null) elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
2832
+ else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
2833
+ elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
2834
+ if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
2835
+ } else {
2836
+ if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
2837
+ if (!win.document) throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");
2838
+ elm = newVNode.$elm$ = BUILD.svg ? win.document.createElementNS(isSvgMode ? SVG_NS : HTML_NS, !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$) : win.document.createElement(!useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$);
2839
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
2840
+ if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
2841
+ if ((BUILD.scoped || BUILD.hydrateServerSide && CMP_FLAGS.shadowNeedsScopedCss) && isDef(scopeId) && elm["s-si"] !== scopeId) elm.classList.add(elm["s-si"] = scopeId);
2842
+ if (newVNode.$children$) {
2843
+ const appendTarget = newVNode.$tag$ === "template" ? elm.content : elm;
2844
+ for (i = 0; i < newVNode.$children$.length; ++i) {
2845
+ childNode = createElm(oldParentVNode, newVNode, i);
2846
+ if (childNode) appendTarget.appendChild(childNode);
2847
+ }
2848
+ }
2849
+ if (BUILD.svg) {
2850
+ if (newVNode.$tag$ === "svg") isSvgMode = false;
2851
+ else if (elm.tagName === "foreignObject") isSvgMode = true;
2852
+ }
2853
+ }
2854
+ elm["s-hn"] = hostTagName;
2855
+ if (BUILD.slotRelocation) {
2856
+ if (newVNode.$flags$ & (VNODE_FLAGS.isSlotFallback | VNODE_FLAGS.isSlotReference)) {
2857
+ elm["s-sr"] = true;
2858
+ elm["s-cr"] = contentRef;
2859
+ elm["s-sn"] = newVNode.$name$ || "";
2860
+ elm["s-rf"] = newVNode.$attrs$?.ref;
2861
+ patchSlotNode(elm);
2862
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
2863
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) relocateToHostRoot(oldParentVNode.$elm$);
2864
+ if (BUILD.scoped || BUILD.hydrateServerSide && CMP_FLAGS.shadowNeedsScopedCss) addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode?.$elm$);
2865
+ }
2866
+ }
2867
+ return elm;
2868
+ };
2869
+ /**
2870
+ * Relocates all child nodes of an element that were a part of a previous slot relocation
2871
+ * to the root of the Stencil component currently being rendered. This happens when a parent
2872
+ * element of a slot reference node dynamically changes and triggers a re-render. We cannot use
2873
+ * `putBackInOriginalLocation()` because that may relocate nodes to elements that will not be re-rendered
2874
+ * and so they will not be relocated again.
2875
+ *
2876
+ * @param parentElm The element potentially containing relocated nodes.
2877
+ */
2878
+ const relocateToHostRoot = (parentElm) => {
2879
+ plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
2880
+ const host = parentElm.closest(hostTagName.toLowerCase());
2881
+ if (host != null) {
2882
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find((ref) => ref["s-cr"]);
2883
+ const childNodeArray = Array.from(parentElm.__childNodes || parentElm.childNodes);
2884
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) if (childNode["s-sh"] != null) {
2885
+ insertBefore(host, childNode, contentRefNode ?? null);
2886
+ childNode["s-sh"] = void 0;
2887
+ checkSlotRelocate = true;
2888
+ }
2889
+ }
2890
+ plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
2891
+ };
2892
+ /**
2893
+ * Puts `<slot>` nodes and any slotted nodes back to their original location (wherever they were before being slotted).
2894
+ *
2895
+ * @param parentElm - The parent element of the nodes to relocate.
2896
+ * @param recursive - Whether or not to relocate nodes in child nodes as well.
2897
+ */
2898
+ const putBackInOriginalLocation = (parentElm, recursive) => {
2899
+ plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
2900
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
2901
+ if (parentElm["s-sr"]) {
2902
+ let node = parentElm;
2903
+ while (node = node.nextSibling) if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) oldSlotChildNodes.push(node);
2904
+ }
2905
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
2906
+ const childNode = oldSlotChildNodes[i];
2907
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
2908
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
2909
+ childNode["s-ol"].remove();
2910
+ childNode["s-ol"] = void 0;
2911
+ childNode["s-sh"] = void 0;
2912
+ checkSlotRelocate = true;
2913
+ }
2914
+ if (recursive) putBackInOriginalLocation(childNode, recursive);
2915
+ }
2916
+ plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
2917
+ };
2918
+ /**
2919
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
2920
+ * add them to the DOM in the appropriate place.
2921
+ *
2922
+ * @param parentElm the DOM node which should be used as a parent for the new
2923
+ * DOM nodes
2924
+ * @param before a child of the `parentElm` which the new children should be
2925
+ * inserted before (optional)
2926
+ * @param parentVNode the parent virtual DOM node
2927
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
2928
+ * @param startIdx the index in the child virtual DOM nodes at which to start
2929
+ * creating DOM nodes (inclusive)
2930
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
2931
+ * creating DOM nodes (inclusive)
2932
+ */
2933
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
2934
+ let containerElm = BUILD.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
2935
+ let childNode;
2936
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) containerElm = containerElm.shadowRoot;
2937
+ if (parentVNode.$tag$ === "template") containerElm = containerElm.content;
2938
+ for (; startIdx <= endIdx; ++startIdx) if (vnodes[startIdx]) {
2939
+ childNode = createElm(null, parentVNode, startIdx);
2940
+ if (childNode) {
2941
+ vnodes[startIdx].$elm$ = childNode;
2942
+ insertBefore(containerElm, childNode, BUILD.slotRelocation ? referenceNode(before) : before);
2943
+ }
2944
+ }
2945
+ };
2946
+ /**
2947
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
2948
+ * This can be used to, for instance, clean up after a list of children which
2949
+ * should no longer be shown.
2950
+ *
2951
+ * This function also handles some of Stencil's slot relocation logic.
2952
+ *
2953
+ * @param vnodes a list of virtual DOM nodes to remove
2954
+ * @param startIdx the index at which to start removing nodes (inclusive)
2955
+ * @param endIdx the index at which to stop removing nodes (inclusive)
2956
+ */
2957
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
2958
+ for (let index = startIdx; index <= endIdx; ++index) {
2959
+ const vnode = vnodes[index];
2960
+ if (vnode) {
2961
+ const elm = vnode.$elm$;
2962
+ nullifyVNodeRefs(vnode);
2963
+ if (elm) {
2964
+ if (BUILD.slotRelocation) {
2965
+ checkSlotFallbackVisibility = true;
2966
+ if (elm["s-ol"]) elm["s-ol"].remove();
2967
+ else putBackInOriginalLocation(elm, true);
2968
+ }
2969
+ elm.remove();
2970
+ }
2971
+ }
2972
+ }
2973
+ };
2974
+ /**
2975
+ * Reconcile the children of a new VNode with the children of an old VNode by
2976
+ * traversing the two collections of children, identifying nodes that are
2977
+ * conserved or changed, calling out to `patch` to make any necessary
2978
+ * updates to the DOM, and rearranging DOM nodes as needed.
2979
+ *
2980
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
2981
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
2982
+ * 'windows' by storing start and end indices and references to the
2983
+ * corresponding array entries. Initially the two 'windows' are basically equal
2984
+ * to the entire array, but we progressively narrow the windows until there are
2985
+ * no children left to update by doing the following:
2986
+ *
2987
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
2988
+ * that if we have an initial array like the following we'll end up dealing
2989
+ * only with a window bounded by the highlighted elements:
2990
+ *
2991
+ * [null, null, VNode1 , ... , VNode2, null, null]
2992
+ * ^^^^^^ ^^^^^^
2993
+ *
2994
+ * 2. Check to see if the elements at the head and tail positions are equal
2995
+ * across the windows. This will basically detect elements which haven't
2996
+ * been added, removed, or changed position, i.e. if you had the following
2997
+ * VNode elements (represented as HTML):
2998
+ *
2999
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
3000
+ * newVNode: `<div><p><span>THERE</span></p></div>`
3001
+ *
3002
+ * Then when comparing the children of the `<div>` tag we check the equality
3003
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
3004
+ * same tag in the same position, we'd be able to avoid completely
3005
+ * re-rendering the subtree under them with a new DOM element and would just
3006
+ * call out to `patch` to handle reconciling their children and so on.
3007
+ *
3008
+ * 3. Check, for both windows, to see if the element at the beginning of the
3009
+ * window corresponds to the element at the end of the other window. This is
3010
+ * a heuristic which will let us identify _some_ situations in which
3011
+ * elements have changed position, for instance it _should_ detect that the
3012
+ * children nodes themselves have not changed but merely moved in the
3013
+ * following example:
3014
+ *
3015
+ * oldVNode: `<div><element-one /><element-two /></div>`
3016
+ * newVNode: `<div><element-two /><element-one /></div>`
3017
+ *
3018
+ * If we find cases like this then we also need to move the concrete DOM
3019
+ * elements corresponding to the moved children to write the re-order to the
3020
+ * DOM.
3021
+ *
3022
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
3023
+ * nodes in the old children which have the same key as the first element in
3024
+ * our window on the new children. If we find such a node we handle calling
3025
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
3026
+ * what we find.
3027
+ *
3028
+ * Finally, once we've narrowed our 'windows' to the point that either of them
3029
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
3030
+ * insertion or deletion that needs to happen to get a DOM state that correctly
3031
+ * reflects the new child VNodes. If, for instance, after our window on the old
3032
+ * children has collapsed we still have more nodes on the new children that
3033
+ * we haven't dealt with yet then we need to add them, or if the new children
3034
+ * collapse but we still have unhandled _old_ children then we need to make
3035
+ * sure the corresponding DOM nodes are removed.
3036
+ *
3037
+ * @param parentElm the node into which the parent VNode is rendered
3038
+ * @param oldCh the old children of the parent node
3039
+ * @param newVNode the new VNode which will replace the parent
3040
+ * @param newCh the new children of the parent node
3041
+ * @param isInitialRender whether or not this is the first render of the vdom
3042
+ */
3043
+ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
3044
+ let oldStartIdx = 0;
3045
+ let newStartIdx = 0;
3046
+ let idxInOld = 0;
3047
+ let i = 0;
3048
+ let oldEndIdx = oldCh.length - 1;
3049
+ let oldStartVnode = oldCh[0];
3050
+ let oldEndVnode = oldCh[oldEndIdx];
3051
+ let newEndIdx = newCh.length - 1;
3052
+ let newStartVnode = newCh[0];
3053
+ let newEndVnode = newCh[newEndIdx];
3054
+ let node;
3055
+ let elmToMove;
3056
+ const containerElm = newVNode.$tag$ === "template" ? parentElm.content : parentElm;
3057
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) if (oldStartVnode == null) oldStartVnode = oldCh[++oldStartIdx];
3058
+ else if (oldEndVnode == null) oldEndVnode = oldCh[--oldEndIdx];
3059
+ else if (newStartVnode == null) newStartVnode = newCh[++newStartIdx];
3060
+ else if (newEndVnode == null) newEndVnode = newCh[--newEndIdx];
3061
+ else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
3062
+ patch(oldStartVnode, newStartVnode, isInitialRender);
3063
+ oldStartVnode = oldCh[++oldStartIdx];
3064
+ newStartVnode = newCh[++newStartIdx];
3065
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
3066
+ patch(oldEndVnode, newEndVnode, isInitialRender);
3067
+ oldEndVnode = oldCh[--oldEndIdx];
3068
+ newEndVnode = newCh[--newEndIdx];
3069
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
3070
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
3071
+ patch(oldStartVnode, newEndVnode, isInitialRender);
3072
+ insertBefore(containerElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
3073
+ oldStartVnode = oldCh[++oldStartIdx];
3074
+ newEndVnode = newCh[--newEndIdx];
3075
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
3076
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
3077
+ patch(oldEndVnode, newStartVnode, isInitialRender);
3078
+ insertBefore(containerElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
3079
+ oldEndVnode = oldCh[--oldEndIdx];
3080
+ newStartVnode = newCh[++newStartIdx];
3081
+ } else {
3082
+ idxInOld = -1;
3083
+ if (BUILD.vdomKey) {
3084
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
3085
+ idxInOld = i;
3086
+ break;
3087
+ }
3088
+ }
3089
+ if (BUILD.vdomKey && idxInOld >= 0) {
3090
+ elmToMove = oldCh[idxInOld];
3091
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
3092
+ else {
3093
+ patch(elmToMove, newStartVnode, isInitialRender);
3094
+ oldCh[idxInOld] = void 0;
3095
+ node = elmToMove.$elm$;
3096
+ }
3097
+ newStartVnode = newCh[++newStartIdx];
3098
+ } else {
3099
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
3100
+ newStartVnode = newCh[++newStartIdx];
3101
+ }
3102
+ if (node) if (BUILD.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
3103
+ else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
3104
+ }
3105
+ if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
3106
+ else if (BUILD.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
3107
+ };
3108
+ /**
3109
+ * Compare two VNodes to determine if they are the same
3110
+ *
3111
+ * **NB**: This function is an equality _heuristic_ based on the available
3112
+ * information set on the two VNodes and can be misleading under certain
3113
+ * circumstances. In particular, if the two nodes do not have `key` attrs
3114
+ * (available under `$key$` on VNodes) then the function falls back on merely
3115
+ * checking that they have the same tag.
3116
+ *
3117
+ * So, in other words, if `key` attrs are not set on VNodes which may be
3118
+ * changing order within a `children` array or something along those lines then
3119
+ * we could obtain a false negative and then have to do needless re-rendering
3120
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
3121
+ *
3122
+ * @param leftVNode the first VNode to check
3123
+ * @param rightVNode the second VNode to check
3124
+ * @param isInitialRender whether or not this is the first render of the vdom
3125
+ * @returns whether they're equal or not
3126
+ */
3127
+ const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
3128
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
3129
+ if (BUILD.slotRelocation && leftVNode.$tag$ === "slot") return leftVNode.$name$ === rightVNode.$name$;
3130
+ if (BUILD.vdomKey && !isInitialRender) return leftVNode.$key$ === rightVNode.$key$;
3131
+ if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) leftVNode.$key$ = rightVNode.$key$;
3132
+ return true;
3133
+ }
3134
+ return false;
3135
+ };
3136
+ /**
3137
+ * Returns the reference node (a comment which represents the
3138
+ * original location of a node in the vdom - before it was moved to its slot)
3139
+ * of a given node.
3140
+ *
3141
+ * (slot nodes can be relocated to a new location in the dom because of
3142
+ * some other component's slot)
3143
+ * @param node the node to find the original location reference node for
3144
+ * @returns reference node
3145
+ */
3146
+ const referenceNode = (node) => node && node["s-ol"] || node;
3147
+ /**
3148
+ * Handle reconciling an outdated VNode with a new one which corresponds to
3149
+ * it. This function handles flushing updates to the DOM and reconciling the
3150
+ * children of the two nodes (if any).
3151
+ *
3152
+ * @param oldVNode an old VNode whose DOM element and children we want to update
3153
+ * @param newVNode a new VNode representing an updated version of the old one
3154
+ * @param isInitialRender whether or not this is the first render of the vdom
3155
+ */
3156
+ const patch = (oldVNode, newVNode, isInitialRender = false) => {
3157
+ const elm = newVNode.$elm$ = oldVNode.$elm$;
3158
+ const oldChildren = oldVNode.$children$;
3159
+ const newChildren = newVNode.$children$;
3160
+ const tag = newVNode.$tag$;
3161
+ const text = newVNode.$text$;
3162
+ let defaultHolder;
3163
+ if (!BUILD.vdomText || text == null) {
3164
+ if (BUILD.svg) isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
3165
+ if (BUILD.vdomAttribute || BUILD.reflect) {
3166
+ if (BUILD.slot && tag === "slot" && !useNativeShadowDom) {
3167
+ if (oldVNode.$name$ !== newVNode.$name$) {
3168
+ newVNode.$elm$["s-sn"] = newVNode.$name$ || "";
3169
+ relocateToHostRoot(newVNode.$elm$.parentElement);
3170
+ }
3171
+ }
3172
+ updateElement(oldVNode, newVNode, isSvgMode, isInitialRender);
3173
+ }
3174
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
3175
+ else if (newChildren !== null) {
3176
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) elm.textContent = "";
3177
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
3178
+ } else if (!isInitialRender && BUILD.updatable && oldChildren !== null) removeVnodes(oldChildren, 0, oldChildren.length - 1);
3179
+ else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
3180
+ if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
3181
+ } else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
3182
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) elm.data = text;
3183
+ };
3184
+ /**
3185
+ * Component-global information about nodes which are either currently being
3186
+ * relocated or will be shortly.
3187
+ */
3188
+ const relocateNodes = [];
3189
+ /**
3190
+ * Mark the contents of a slot for relocation via adding references to them to
3191
+ * the {@link relocateNodes} data structure. The actual work of relocating them
3192
+ * will then be handled in {@link renderVdom}.
3193
+ *
3194
+ * @param elm a render node whose child nodes need to be relocated
3195
+ */
3196
+ const markSlotContentForRelocation = (elm) => {
3197
+ let node;
3198
+ let hostContentNodes;
3199
+ let j;
3200
+ const children = elm.__childNodes || elm.childNodes;
3201
+ for (const childNode of children) {
3202
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
3203
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
3204
+ const slotName = childNode["s-sn"];
3205
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
3206
+ node = hostContentNodes[j];
3207
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
3208
+ if (isNodeLocatedInSlot(node, slotName)) {
3209
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
3210
+ checkSlotFallbackVisibility = true;
3211
+ node["s-sn"] = node["s-sn"] || slotName;
3212
+ if (relocateNodeData) {
3213
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
3214
+ relocateNodeData.$slotRefNode$ = childNode;
3215
+ } else {
3216
+ node["s-sh"] = childNode["s-hn"];
3217
+ relocateNodes.push({
3218
+ $slotRefNode$: childNode,
3219
+ $nodeToRelocate$: node
3220
+ });
3221
+ }
3222
+ if (node["s-sr"]) relocateNodes.map((relocateNode) => {
3223
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
3224
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
3225
+ if (relocateNodeData && !relocateNode.$slotRefNode$) relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
3226
+ }
3227
+ });
3228
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) relocateNodes.push({ $nodeToRelocate$: node });
3229
+ }
3230
+ }
3231
+ }
3232
+ if (childNode.nodeType === NODE_TYPE.ElementNode) markSlotContentForRelocation(childNode);
3233
+ }
3234
+ };
3235
+ /**
3236
+ * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
3237
+ * them with `null`. This signals that the DOM element corresponding to the VDom
3238
+ * node has been removed from the DOM.
3239
+ *
3240
+ * @param vNode a virtual DOM node
3241
+ */
3242
+ const nullifyVNodeRefs = (vNode) => {
3243
+ if (BUILD.vdomRef) {
3244
+ if (vNode.$attrs$ && vNode.$attrs$.ref) refCallbacksToRemove.push(() => vNode.$attrs$.ref(null));
3245
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
3246
+ }
3247
+ };
3248
+ /**
3249
+ * Queue a ref callback to be called with an element during rendering.
3250
+ * This ensures ref callbacks are called in the correct order.
3251
+ *
3252
+ * @param refCallback the ref callback function to queue
3253
+ * @param elm the element to pass to the callback
3254
+ */
3255
+ const queueRefAttachment = (refCallback, elm) => {
3256
+ if (BUILD.vdomRef) refCallbacksToAttach.push(() => refCallback(elm));
3257
+ };
3258
+ /**
3259
+ * Flush all queued ref callbacks in the correct order:
3260
+ * first all removal callbacks (with null), then all attachment callbacks (with elements).
3261
+ * This ensures that when elements are replaced/reordered, the ref is always left
3262
+ * pointing to the current element, not null.
3263
+ */
3264
+ const flushQueuedRefCallbacks = () => {
3265
+ if (BUILD.vdomRef) {
3266
+ refCallbacksToRemove.forEach((cb) => cb());
3267
+ refCallbacksToRemove.length = 0;
3268
+ refCallbacksToAttach.forEach((cb) => cb());
3269
+ refCallbacksToAttach.length = 0;
3270
+ }
3271
+ };
3272
+ /**
3273
+ * Inserts a node before a reference node as a child of a specified parent node.
3274
+ * Additionally, adds parent elements' scope ids as class names to the new node.
3275
+ *
3276
+ * @param parent parent node
3277
+ * @param newNode element to be inserted
3278
+ * @param reference anchor element
3279
+ * @param isInitialLoad whether or not this is the first render
3280
+ * @returns inserted node
3281
+ */
3282
+ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
3283
+ if (BUILD.slotRelocation) {
3284
+ if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
3285
+ else if (typeof newNode["s-sn"] === "string") {
3286
+ if (BUILD.experimentalSlotFixes && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchParentNode(newNode);
3287
+ parent.insertBefore(newNode, reference);
3288
+ const { slotNode } = findSlotFromSlottedNode(newNode);
3289
+ if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
3290
+ return newNode;
3291
+ }
3292
+ }
3293
+ if (parent.__insertBefore) return parent.__insertBefore(newNode, reference);
3294
+ else return parent?.insertBefore(newNode, reference);
3295
+ };
3296
+ /**
3297
+ * Adds or removes a scoped class to the parent element of a slotted node.
3298
+ * This is used for styling slotted content (e.g. with `::scoped(...) {...}` selectors )
3299
+ * in `scoped: true` components.
3300
+ *
3301
+ * @param reference - Content Reference Node. Used to get the scope id of the parent component.
3302
+ * @param slotNode - the `<slot>` node to apply the class for
3303
+ * @param newParent - the slots' new parent element that requires the scoped class
3304
+ * @param oldParent - optionally, an old parent element that may no longer require the scoped class
3305
+ */
3306
+ function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
3307
+ let scopeId;
3308
+ if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId = slotNode["s-si"] || reference.parentNode["s-sc"])) {
3309
+ const scopeName = slotNode["s-sn"];
3310
+ const hostName = slotNode["s-hn"];
3311
+ newParent.classList?.add(scopeId + "-s");
3312
+ if (oldParent && oldParent.classList?.contains(scopeId + "-s")) {
3313
+ let child = (oldParent.__childNodes || oldParent.childNodes)[0];
3314
+ let found = false;
3315
+ while (child) {
3316
+ if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
3317
+ found = true;
3318
+ break;
3319
+ }
3320
+ child = child.nextSibling;
3321
+ }
3322
+ if (!found) oldParent.classList.remove(scopeId + "-s");
3323
+ }
3324
+ }
3325
+ }
3326
+ /**
3327
+ * The main entry point for Stencil's virtual DOM-based rendering engine
3328
+ *
3329
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
3330
+ * function will handle creating a virtual DOM tree with a single root, patching
3331
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
3332
+ * relocation, and reflecting attributes.
3333
+ *
3334
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
3335
+ * the DOM node into which it should be rendered.
3336
+ * @param renderFnResults the virtual DOM nodes to be rendered
3337
+ * @param isInitialLoad whether or not this is the first call after page load
3338
+ */
3339
+ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
3340
+ const hostElm = hostRef.$hostElement$;
3341
+ const cmpMeta = hostRef.$cmpMeta$;
3342
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
3343
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
3344
+ hostTagName = hostElm.tagName;
3345
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
3346
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
3347
+
3348
+ The render() function should look like this instead:
3349
+
3350
+ render() {
3351
+ // Do not return an array
3352
+ return (
3353
+ <Host>{content}</Host>
3354
+ );
3355
+ }
3356
+ `);
3357
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
3358
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
3359
+ cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => {
3360
+ if (BUILD.serializer && hostRef.$serializerValues$.has(propName)) rootVnode.$attrs$[attribute] = hostRef.$serializerValues$.get(propName);
3361
+ else rootVnode.$attrs$[attribute] = hostElm[propName];
3362
+ });
3363
+ }
3364
+ if (isInitialLoad && rootVnode.$attrs$) {
3365
+ for (const key of Object.keys(rootVnode.$attrs$)) if (hostElm.hasAttribute(key) && ![
3366
+ "key",
3367
+ "ref",
3368
+ "style",
3369
+ "class"
3370
+ ].includes(key)) rootVnode.$attrs$[key] = hostElm[key];
3371
+ }
3372
+ rootVnode.$tag$ = null;
3373
+ rootVnode.$flags$ |= VNODE_FLAGS.isHost;
3374
+ hostRef.$vnode$ = rootVnode;
3375
+ rootVnode.$elm$ = oldVNode.$elm$ = BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
3376
+ if (BUILD.scoped || BUILD.shadowDom) scopeId = hostElm["s-sc"];
3377
+ useNativeShadowDom = supportsShadow && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && !(cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss);
3378
+ if (BUILD.slotRelocation) {
3379
+ contentRef = hostElm["s-cr"];
3380
+ checkSlotFallbackVisibility = false;
3381
+ }
3382
+ patch(oldVNode, rootVnode, isInitialLoad);
3383
+ if (BUILD.slotRelocation) {
3384
+ plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
3385
+ if (checkSlotRelocate) {
3386
+ markSlotContentForRelocation(rootVnode.$elm$);
3387
+ for (const relocateData of relocateNodes) {
3388
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
3389
+ if (!nodeToRelocate["s-ol"] && win.document) {
3390
+ const orgLocationNode = BUILD.isDebug || BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : win.document.createTextNode("");
3391
+ orgLocationNode["s-nr"] = nodeToRelocate;
3392
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate, isInitialLoad);
3393
+ }
3394
+ }
3395
+ for (const relocateData of relocateNodes) {
3396
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
3397
+ const slotRefNode = relocateData.$slotRefNode$;
3398
+ if (nodeToRelocate.nodeType === NODE_TYPE.ElementNode && isInitialLoad) nodeToRelocate["s-ih"] = nodeToRelocate.hidden ?? false;
3399
+ if (slotRefNode) {
3400
+ const parentNodeRef = slotRefNode.parentNode;
3401
+ let insertBeforeNode = slotRefNode.nextSibling;
3402
+ if (!BUILD.hydrateServerSide && insertBeforeNode && insertBeforeNode.nodeType === NODE_TYPE.ElementNode) {
3403
+ let orgLocationNode = nodeToRelocate["s-ol"]?.previousSibling;
3404
+ while (orgLocationNode) {
3405
+ let refNode = orgLocationNode["s-nr"] ?? null;
3406
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
3407
+ refNode = refNode.nextSibling;
3408
+ while (refNode === nodeToRelocate || refNode?.["s-sr"]) refNode = refNode?.nextSibling;
3409
+ if (!refNode || !refNode["s-nr"]) {
3410
+ insertBeforeNode = refNode;
3411
+ break;
3412
+ }
3413
+ }
3414
+ orgLocationNode = orgLocationNode.previousSibling;
3415
+ }
3416
+ }
3417
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
3418
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
3419
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
3420
+ if (nodeToRelocate !== insertBeforeNode) {
3421
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode, isInitialLoad);
3422
+ if (nodeToRelocate.nodeType === NODE_TYPE.CommentNode && nodeToRelocate.nodeValue.startsWith("s-nt-")) {
3423
+ const textNode = win.document.createTextNode(nodeToRelocate.nodeValue.replace(/^s-nt-/, ""));
3424
+ textNode["s-hn"] = nodeToRelocate["s-hn"];
3425
+ textNode["s-sn"] = nodeToRelocate["s-sn"];
3426
+ textNode["s-sh"] = nodeToRelocate["s-sh"];
3427
+ textNode["s-sr"] = nodeToRelocate["s-sr"];
3428
+ textNode["s-ol"] = nodeToRelocate["s-ol"];
3429
+ textNode["s-ol"]["s-nr"] = textNode;
3430
+ insertBefore(nodeToRelocate.parentNode, textNode, nodeToRelocate, isInitialLoad);
3431
+ nodeToRelocate.parentNode.removeChild(nodeToRelocate);
3432
+ }
3433
+ if (nodeToRelocate.nodeType === NODE_TYPE.ElementNode && nodeToRelocate.tagName !== "SLOT-FB") nodeToRelocate.hidden = nodeToRelocate["s-ih"] ?? false;
3434
+ }
3435
+ }
3436
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](slotRefNode);
3437
+ } else if (nodeToRelocate.nodeType === NODE_TYPE.ElementNode) nodeToRelocate.hidden = true;
3438
+ }
3439
+ }
3440
+ if (checkSlotFallbackVisibility) updateFallbackSlotVisibility(rootVnode.$elm$);
3441
+ plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
3442
+ relocateNodes.length = 0;
3443
+ }
3444
+ if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
3445
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
3446
+ for (const childNode of children) if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
3447
+ if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
3448
+ if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
3449
+ else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
3450
+ const textCommentNode = win.document.createComment("s-nt-" + childNode.nodeValue);
3451
+ textCommentNode["s-sn"] = childNode["s-sn"];
3452
+ insertBefore(childNode.parentNode, textCommentNode, childNode, isInitialLoad);
3453
+ childNode.parentNode.removeChild(childNode);
3454
+ }
3455
+ }
3456
+ }
3457
+ contentRef = void 0;
3458
+ flushQueuedRefCallbacks();
3459
+ };
3460
+ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot${slotVNode.$name$ ? " name=\"" + slotVNode.$name$ + "\"" : ""}> (host=${hostTagName.toLowerCase()})`);
3461
+ const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
3462
+
3463
+ //#endregion
3464
+ //#region src/runtime/update-component.ts
3465
+ const attachToAncestor = (hostRef, ancestorComponent) => {
3466
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
3467
+ const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
3468
+ ancestorComponent["s-p"].splice(index - 1, 1);
3469
+ r();
3470
+ }));
3471
+ }
3472
+ };
3473
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
3474
+ if (BUILD.taskQueue && BUILD.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
3475
+ if (BUILD.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
3476
+ hostRef.$flags$ |= HOST_FLAGS.needsRerender;
3477
+ return;
3478
+ }
3479
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
3480
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
3481
+ if (isInitialLoad) {
3482
+ queueMicrotask(() => {
3483
+ dispatch();
3484
+ });
3485
+ return;
3486
+ }
3487
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
3488
+ };
3489
+ /**
3490
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
3491
+ * component lifecycle methods like `componentWillLoad` as well as
3492
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
3493
+ *
3494
+ * @param hostRef a reference to a host DOM node
3495
+ * @param isInitialLoad whether we're on the initial load or not
3496
+ * @returns an empty Promise which is used to enqueue a series of operations for
3497
+ * the component
3498
+ */
3499
+ const dispatchHooks = (hostRef, isInitialLoad) => {
3500
+ const elm = hostRef.$hostElement$;
3501
+ const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
3502
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3503
+ /**
3504
+ * Given a user imports a component compiled with a `dist-custom-element`
3505
+ * output target into a Stencil project compiled with a `dist` output target,
3506
+ * then `instance` will be `undefined` as `hostRef` won't have a `lazyInstance`
3507
+ * property. In this case, the component will fail to render in one of the
3508
+ * subsequent functions.
3509
+ *
3510
+ * For this scenario to work the user needs to set the `externalRuntime` flag
3511
+ * for the `dist-custom-element` component that is being imported into the `dist`
3512
+ * Stencil project.
3513
+ */
3514
+ if (!instance) throw new Error(`Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);
3515
+ let maybePromise;
3516
+ if (isInitialLoad) {
3517
+ if (BUILD.lazyLoad) {
3518
+ if (BUILD.slotRelocation && hostRef.$deferredConnectedCallback$) {
3519
+ hostRef.$deferredConnectedCallback$ = false;
3520
+ safeCall(instance, "connectedCallback", void 0, elm);
3521
+ }
3522
+ if (BUILD.hostListener) {
3523
+ hostRef.$flags$ |= HOST_FLAGS.isListenReady;
3524
+ if (hostRef.$queuedListeners$) {
3525
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
3526
+ hostRef.$queuedListeners$ = void 0;
3527
+ }
3528
+ }
3529
+ if (hostRef.$fetchedCbList$.length) hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
3530
+ }
3531
+ emitLifecycleEvent(elm, "componentWillLoad");
3532
+ maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
3533
+ } else {
3534
+ emitLifecycleEvent(elm, "componentWillUpdate");
3535
+ maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
3536
+ }
3537
+ emitLifecycleEvent(elm, "componentWillRender");
3538
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
3539
+ endSchedule();
3540
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
3541
+ };
3542
+ /**
3543
+ * This function uses a Promise to implement a simple first-in, first-out queue
3544
+ * of functions to be called.
3545
+ *
3546
+ * The queue is ordered on the basis of the first argument. If it's
3547
+ * `undefined`, then nothing is on the queue yet, so the provided function can
3548
+ * be called synchronously (although note that this function may return a
3549
+ * `Promise`). The idea is that then the return value of that enqueueing
3550
+ * operation is kept around, so that if it was a `Promise` then subsequent
3551
+ * functions can be enqueued by calling this function again with that `Promise`
3552
+ * as the first argument.
3553
+ *
3554
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
3555
+ * @param fn a function to enqueue
3556
+ * @returns either a `Promise` or the return value of the provided function
3557
+ */
3558
+ const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err) => {
3559
+ console.error(err);
3560
+ fn();
3561
+ }) : fn();
3562
+ /**
3563
+ * Check that a value is a `Promise`. To check, we first see if the value is an
3564
+ * instance of the `Promise` global. In a few circumstances, in particular if
3565
+ * the global has been overwritten, this is could be misleading, so we also do
3566
+ * a little 'duck typing' check to see if the `.then` property of the value is
3567
+ * defined and a function.
3568
+ *
3569
+ * @param maybePromise it might be a promise!
3570
+ * @returns whether it is or not
3571
+ */
3572
+ const isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
3573
+ /**
3574
+ * Update a component given reference to its host elements and so on.
3575
+ *
3576
+ * @param hostRef an object containing references to the element's host node,
3577
+ * VDom nodes, and other metadata
3578
+ * @param instance a reference to the underlying host element where it will be
3579
+ * rendered
3580
+ * @param isInitialLoad whether or not this function is being called as part of
3581
+ * the first render cycle
3582
+ */
3583
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
3584
+ const elm = hostRef.$hostElement$;
3585
+ const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
3586
+ const rc = elm["s-rc"];
3587
+ if (BUILD.style && isInitialLoad) attachStyles(hostRef);
3588
+ const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
3589
+ if (BUILD.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnRender;
3590
+ if (BUILD.hydrateServerSide) await callRender(hostRef, instance, elm, isInitialLoad);
3591
+ else callRender(hostRef, instance, elm, isInitialLoad);
3592
+ if (BUILD.isDev) {
3593
+ hostRef.$renderCount$ = hostRef.$renderCount$ === void 0 ? 1 : hostRef.$renderCount$ + 1;
3594
+ hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
3595
+ }
3596
+ if (BUILD.hydrateServerSide) try {
3597
+ serverSideConnected(elm);
3598
+ if (isInitialLoad) {
3599
+ if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) elm["s-en"] = "";
3600
+ else if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.scopedCssEncapsulation) elm["s-en"] = "c";
3601
+ }
3602
+ } catch (e) {
3603
+ consoleError(e, elm);
3604
+ }
3605
+ if (BUILD.asyncLoading && rc) {
3606
+ rc.map((cb) => cb());
3607
+ elm["s-rc"] = void 0;
3608
+ }
3609
+ endRender();
3610
+ endUpdate();
3611
+ if (BUILD.asyncLoading) {
3612
+ const childrenPromises = elm["s-p"] ?? [];
3613
+ const postUpdate = () => postUpdateComponent(hostRef);
3614
+ if (childrenPromises.length === 0) postUpdate();
3615
+ else {
3616
+ Promise.all(childrenPromises).then(postUpdate).catch(postUpdate);
3617
+ hostRef.$flags$ |= HOST_FLAGS.isWaitingForChildren;
3618
+ childrenPromises.length = 0;
3619
+ }
3620
+ } else postUpdateComponent(hostRef);
3621
+ };
3622
+ let renderingRef = null;
3623
+ /**
3624
+ * Handle making the call to the VDom renderer with the proper context given
3625
+ * various build variables
3626
+ *
3627
+ * @param hostRef an object containing references to the element's host node,
3628
+ * VDom nodes, and other metadata
3629
+ * @param instance a reference to the underlying host element where it will be
3630
+ * rendered
3631
+ * @param elm the Host element for the component
3632
+ * @param isInitialLoad whether or not this function is being called as part of
3633
+ * @returns an empty promise
3634
+ */
3635
+ const callRender = (hostRef, instance, elm, isInitialLoad) => {
3636
+ const allRenderFn = BUILD.allRenderFn ? true : false;
3637
+ const lazyLoad = BUILD.lazyLoad ? true : false;
3638
+ const taskQueue = BUILD.taskQueue ? true : false;
3639
+ const updatable = BUILD.updatable ? true : false;
3640
+ try {
3641
+ renderingRef = instance;
3642
+ /**
3643
+ * minification optimization: `allRenderFn` is `true` if all components have a `render`
3644
+ * method, so we can call the method immediately. If not, check before calling it.
3645
+ */
3646
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
3647
+ if (updatable && taskQueue) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
3648
+ if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
3649
+ if (BUILD.hasRenderFn || BUILD.reflect) if (BUILD.vdomRender || BUILD.reflect) if (BUILD.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
3650
+ else renderVdom(hostRef, instance, isInitialLoad);
3651
+ else {
3652
+ const shadowRoot = elm.shadowRoot;
3653
+ if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
3654
+ else elm.textContent = instance;
3655
+ }
3656
+ } catch (e) {
3657
+ consoleError(e, hostRef.$hostElement$);
3658
+ }
3659
+ renderingRef = null;
3660
+ return null;
3661
+ };
3662
+ const getRenderingRef = () => renderingRef;
3663
+ const postUpdateComponent = (hostRef) => {
3664
+ const tagName = hostRef.$cmpMeta$.$tagName$;
3665
+ const elm = hostRef.$hostElement$;
3666
+ const endPostUpdate = createTime("postUpdate", tagName);
3667
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3668
+ const ancestorComponent = hostRef.$ancestorComponent$;
3669
+ if (BUILD.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnRender;
3670
+ safeCall(instance, "componentDidRender", void 0, elm);
3671
+ if (BUILD.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
3672
+ emitLifecycleEvent(elm, "componentDidRender");
3673
+ if (!(hostRef.$flags$ & HOST_FLAGS.hasLoadedComponent)) {
3674
+ hostRef.$flags$ |= HOST_FLAGS.hasLoadedComponent;
3675
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) addHydratedFlag(elm);
3676
+ if (BUILD.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnDidLoad;
3677
+ safeCall(instance, "componentDidLoad", void 0, elm);
3678
+ if (BUILD.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnDidLoad;
3679
+ emitLifecycleEvent(elm, "componentDidLoad");
3680
+ endPostUpdate();
3681
+ if (BUILD.asyncLoading) {
3682
+ hostRef.$onReadyResolve$(elm);
3683
+ if (!ancestorComponent) appDidLoad(tagName);
3684
+ }
3685
+ } else {
3686
+ if (BUILD.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnRender;
3687
+ safeCall(instance, "componentDidUpdate", void 0, elm);
3688
+ if (BUILD.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
3689
+ emitLifecycleEvent(elm, "componentDidUpdate");
3690
+ endPostUpdate();
3691
+ }
3692
+ if (BUILD.method && BUILD.lazyLoad) hostRef.$onInstanceResolve$(elm);
3693
+ if (BUILD.asyncLoading) {
3694
+ if (hostRef.$onRenderResolve$) {
3695
+ hostRef.$onRenderResolve$();
3696
+ hostRef.$onRenderResolve$ = void 0;
3697
+ }
3698
+ if (hostRef.$flags$ & HOST_FLAGS.needsRerender) nextTick(() => scheduleUpdate(hostRef, false));
3699
+ hostRef.$flags$ &= ~(HOST_FLAGS.isWaitingForChildren | HOST_FLAGS.needsRerender);
3700
+ }
3701
+ };
3702
+ const forceUpdate = (ref) => {
3703
+ if (BUILD.updatable && (Build.isBrowser || Build.isTesting)) {
3704
+ const hostRef = getHostRef(ref);
3705
+ const isConnected = hostRef?.$hostElement$?.isConnected;
3706
+ if (isConnected && (hostRef.$flags$ & (HOST_FLAGS.hasRendered | HOST_FLAGS.isQueuedForUpdate)) === HOST_FLAGS.hasRendered) scheduleUpdate(hostRef, false);
3707
+ return isConnected;
3708
+ }
3709
+ return false;
3710
+ };
3711
+ const appDidLoad = (who) => {
3712
+ if (BUILD.asyncQueue) plt.$flags$ |= PLATFORM_FLAGS.appLoaded;
3713
+ nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
3714
+ if (BUILD.hydrateClientSide) {
3715
+ if (plt.$orgLocNodes$?.size) plt.$orgLocNodes$.clear();
3716
+ }
3717
+ if (BUILD.profile && performance.measure) performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, "st:app:start");
3718
+ };
3719
+ /**
3720
+ * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
3721
+ * e.g. custom element node. If a build figures out that e.g. no component
3722
+ * has a `componentDidLoad` method, the instance method gets removed from the
3723
+ * output bundle and this function returns `undefined`.
3724
+ * @param instance any object that may or may not contain methods
3725
+ * @param method method name
3726
+ * @param arg single arbitrary argument
3727
+ * @param elm the element which made the call
3728
+ * @returns result of method call if it exists, otherwise `undefined`
3729
+ */
3730
+ const safeCall = (instance, method, arg, elm) => {
3731
+ if (instance && instance[method]) try {
3732
+ return instance[method](arg);
3733
+ } catch (e) {
3734
+ consoleError(e, elm);
3735
+ }
3736
+ };
3737
+ /**
3738
+ * For debugging purposes as `BUILD.lifecycleDOMEvents` is `false` by default and will
3739
+ * get removed by the compiler. Used for timing events to see how long they take.
3740
+ * @param elm the target of the Event
3741
+ * @param lifecycleName name of the event
3742
+ */
3743
+ const emitLifecycleEvent = (elm, lifecycleName) => {
3744
+ if (BUILD.lifecycleDOMEvents) emitEvent(elm, "stencil_" + lifecycleName, {
3745
+ bubbles: true,
3746
+ composed: true,
3747
+ detail: { namespace: NAMESPACE }
3748
+ });
3749
+ };
3750
+ /**
3751
+ * Set the hydrated flag on a DOM element
3752
+ *
3753
+ * @param elm a reference to a DOM element
3754
+ * @returns undefined
3755
+ */
3756
+ const addHydratedFlag = (elm) => BUILD.hydratedClass ? elm.classList.add(BUILD.hydratedSelectorName ?? "hydrated") : BUILD.hydratedAttribute ? elm.setAttribute(BUILD.hydratedSelectorName ?? "hydrated", "") : void 0;
3757
+ const serverSideConnected = (elm) => {
3758
+ const children = elm.children;
3759
+ if (children != null) for (let i = 0, ii = children.length; i < ii; i++) {
3760
+ const childElm = children[i];
3761
+ if (typeof childElm.connectedCallback === "function") childElm.connectedCallback();
3762
+ serverSideConnected(childElm);
3763
+ }
3764
+ };
3765
+
3766
+ //#endregion
3767
+ //#region src/runtime/set-value.ts
3768
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
3769
+ const setValue = (ref, propName, newVal, cmpMeta) => {
3770
+ const hostRef = getHostRef(ref);
3771
+ if (!hostRef) return;
3772
+ /**
3773
+ * If the host element is not found, let's fail with a better error message and provide
3774
+ * details on why this may happen. In certain cases, e.g. see https://github.com/stenciljs/core/issues/5457,
3775
+ * users might import a component through e.g. a loader script, which causes confusions in runtime
3776
+ * as there are multiple runtimes being loaded and/or different components used with different
3777
+ * loading strategies, e.g. lazy vs implicitly loaded.
3778
+ *
3779
+ * Todo(STENCIL-1308): remove, once a solution for this was identified and implemented
3780
+ */
3781
+ if (BUILD.lazyLoad && !hostRef) throw new Error(`Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`);
3782
+ if (BUILD.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
3783
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
3784
+ const oldVal = hostRef.$instanceValues$.get(propName);
3785
+ const flags = hostRef.$flags$;
3786
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3787
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
3788
+ const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
3789
+ if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
3790
+ hostRef.$instanceValues$.set(propName, newVal);
3791
+ if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$) {
3792
+ if (cmpMeta.$serializers$ && cmpMeta.$serializers$[propName]) {
3793
+ const runSerializer = (inst) => {
3794
+ let attrVal = newVal;
3795
+ for (const serializer of cmpMeta.$serializers$[propName]) {
3796
+ const [[methodName]] = Object.entries(serializer);
3797
+ attrVal = inst[methodName](attrVal, propName);
3798
+ }
3799
+ hostRef.$serializerValues$.set(propName, attrVal);
3800
+ };
3801
+ if (instance) runSerializer(instance);
3802
+ else hostRef.$fetchedCbList$.push(() => {
3803
+ runSerializer(hostRef.$lazyInstance$);
3804
+ });
3805
+ }
3806
+ }
3807
+ if (BUILD.isDev) {
3808
+ if (hostRef.$flags$ & HOST_FLAGS.devOnRender) 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);
3809
+ else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) 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);
3810
+ }
3811
+ if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
3812
+ const watchMethods = cmpMeta.$watchers$[propName];
3813
+ if (watchMethods) watchMethods.map((watcher) => {
3814
+ try {
3815
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
3816
+ if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) if (!instance) hostRef.$fetchedCbList$.push(() => {
3817
+ hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
3818
+ });
3819
+ else instance[watchMethodName](newVal, oldVal, propName);
3820
+ } catch (e) {
3821
+ consoleError(e, elm);
3822
+ }
3823
+ });
3824
+ }
3825
+ if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
3826
+ if (instance.componentShouldUpdate) {
3827
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false && !(flags & HOST_FLAGS.isQueuedForUpdate)) return;
3828
+ }
3829
+ if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3830
+ }
3831
+ }
3832
+ };
3833
+
3834
+ //#endregion
3835
+ //#region src/runtime/proxy-component.ts
3836
+ /**
3837
+ * Attach a series of runtime constructs to a compiled Stencil component
3838
+ * constructor, including getters and setters for the `@Prop` and `@State`
3839
+ * decorators, callbacks for when attributes change, and so on.
3840
+ *
3841
+ * On a lazy loaded component, this is wired up to both the class instance
3842
+ * and the element separately. A `hostRef` keeps the 2 in sync.
3843
+ *
3844
+ * On a traditional component, this is wired up to the element only.
3845
+ *
3846
+ * @param Cstr the constructor for a component that we need to process
3847
+ * @param cmpMeta metadata collected previously about the component
3848
+ * @param flags a number used to store a series of bit flags
3849
+ * @returns a reference to the same constructor passed in (but now mutated)
3850
+ */
3851
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
3852
+ const prototype = Cstr.prototype;
3853
+ if (BUILD.isTesting) {
3854
+ if (prototype.__stencilAugmented) return;
3855
+ prototype.__stencilAugmented = true;
3856
+ }
3857
+ /**
3858
+ * proxy form associated custom element lifecycle callbacks
3859
+ * @ref https://web.dev/articles/more-capable-form-controls#lifecycle_callbacks
3860
+ */
3861
+ if (BUILD.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated && flags & PROXY_FLAGS.isElementConstructor) FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach((cbName) => {
3862
+ const originalFormAssociatedCallback = prototype[cbName];
3863
+ Object.defineProperty(prototype, cbName, { value(...args) {
3864
+ const hostRef = getHostRef(this);
3865
+ const instance = BUILD.lazyLoad ? hostRef?.$lazyInstance$ : this;
3866
+ if (!instance) hostRef?.$onReadyPromise$?.then((asyncInstance) => {
3867
+ const cb = asyncInstance[cbName];
3868
+ typeof cb === "function" && cb.call(asyncInstance, ...args);
3869
+ });
3870
+ else {
3871
+ const cb = BUILD.lazyLoad ? instance[cbName] : originalFormAssociatedCallback;
3872
+ typeof cb === "function" && cb.call(instance, ...args);
3873
+ }
3874
+ } });
3875
+ });
3876
+ if (BUILD.member && cmpMeta.$members$ || BUILD.propChangeCallback) {
3877
+ if (BUILD.propChangeCallback) {
3878
+ if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = Cstr.watchers;
3879
+ if (Cstr.deserializers && !cmpMeta.$deserializers$) cmpMeta.$deserializers$ = Cstr.deserializers;
3880
+ if (Cstr.serializers && !cmpMeta.$serializers$) cmpMeta.$serializers$ = Cstr.serializers;
3881
+ }
3882
+ const members = Object.entries(cmpMeta.$members$ ?? {});
3883
+ members.map(([memberName, [memberFlags]]) => {
3884
+ if ((BUILD.prop || BUILD.state) && (memberFlags & MEMBER_FLAGS.Prop || (!BUILD.lazyLoad || flags & PROXY_FLAGS.proxyState) && memberFlags & MEMBER_FLAGS.State)) {
3885
+ const { get: origGetter, set: origSetter } = getPropertyDescriptor(prototype, memberName) || {};
3886
+ if (origGetter) cmpMeta.$members$[memberName][0] |= MEMBER_FLAGS.Getter;
3887
+ if (origSetter) cmpMeta.$members$[memberName][0] |= MEMBER_FLAGS.Setter;
3888
+ if (flags & PROXY_FLAGS.isElementConstructor || !origGetter) Object.defineProperty(prototype, memberName, {
3889
+ get() {
3890
+ if (BUILD.lazyLoad) {
3891
+ if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
3892
+ const ref = getHostRef(this);
3893
+ const instance = ref ? ref.$lazyInstance$ : prototype;
3894
+ if (!instance) return;
3895
+ return instance[memberName];
3896
+ }
3897
+ if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
3898
+ },
3899
+ configurable: true,
3900
+ enumerable: true
3901
+ });
3902
+ Object.defineProperty(prototype, memberName, { set(newValue) {
3903
+ const ref = getHostRef(this);
3904
+ if (!ref) return;
3905
+ if (BUILD.isDev) {
3906
+ if ((flags & PROXY_FLAGS.isElementConstructor) === 0 && (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0 && (ref && ref.$flags$ & HOST_FLAGS.isConstructingInstance) === 0 && (memberFlags & MEMBER_FLAGS.Prop) !== 0 && (memberFlags & MEMBER_FLAGS.Mutable) === 0) consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
3907
+ }
3908
+ if (origSetter) {
3909
+ if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
3910
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated))]);
3911
+ newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
3912
+ setValue(this, memberName, newValue, cmpMeta);
3913
+ return;
3914
+ }
3915
+ if (!BUILD.lazyLoad) {
3916
+ setValue(this, memberName, newValue, cmpMeta);
3917
+ return;
3918
+ }
3919
+ if (BUILD.lazyLoad) {
3920
+ if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
3921
+ setValue(this, memberName, newValue, cmpMeta);
3922
+ if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
3923
+ if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
3924
+ });
3925
+ return;
3926
+ }
3927
+ const setterSetVal = () => {
3928
+ const currentValue = ref.$lazyInstance$[memberName];
3929
+ if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
3930
+ ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
3931
+ setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
3932
+ };
3933
+ if (ref.$lazyInstance$) setterSetVal();
3934
+ else ref.$fetchedCbList$.push(() => {
3935
+ setterSetVal();
3936
+ });
3937
+ }
3938
+ } });
3939
+ } else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
3940
+ const ref = getHostRef(this);
3941
+ return ref?.$onInstancePromise$?.then(() => ref.$lazyInstance$?.[memberName](...args));
3942
+ } });
3943
+ });
3944
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & PROXY_FLAGS.isElementConstructor)) {
3945
+ const attrNameToPropName = /* @__PURE__ */ new Map();
3946
+ prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
3947
+ plt.jmp(() => {
3948
+ const propName = attrNameToPropName.get(attrName);
3949
+ const hostRef = getHostRef(this);
3950
+ if (BUILD.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) return;
3951
+ if (this.hasOwnProperty(propName) && BUILD.lazyLoad) {
3952
+ newValue = this[propName];
3953
+ delete this[propName];
3954
+ }
3955
+ if (BUILD.deserializer && cmpMeta.$deserializers$ && cmpMeta.$deserializers$[propName]) {
3956
+ const setVal = (methodName, instance) => {
3957
+ const deserializeVal = instance?.[methodName](newValue, propName);
3958
+ if (deserializeVal !== this[propName]) this[propName] = deserializeVal;
3959
+ };
3960
+ for (const deserializer of cmpMeta.$deserializers$[propName]) {
3961
+ const [[methodName]] = Object.entries(deserializer);
3962
+ if (BUILD.lazyLoad) if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
3963
+ else hostRef.$fetchedCbList$.push(() => {
3964
+ setVal(methodName, hostRef.$lazyInstance$);
3965
+ });
3966
+ else setVal(methodName, this);
3967
+ }
3968
+ return;
3969
+ } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
3970
+ else if (propName == null) {
3971
+ const flags = hostRef?.$flags$;
3972
+ if (hostRef && flags && !(flags & HOST_FLAGS.isConstructingInstance) && newValue !== oldValue) {
3973
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : this;
3974
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3975
+ (cmpMeta.$watchers$?.[attrName])?.forEach((watcher) => {
3976
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
3977
+ if (instance[watchMethodName] != null && (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate)) instance[watchMethodName].call(instance, newValue, oldValue, attrName);
3978
+ });
3979
+ }
3980
+ return;
3981
+ }
3982
+ const propFlags = members.find(([m]) => m === propName);
3983
+ if (propFlags && propFlags[1][0] & MEMBER_FLAGS.Boolean) newValue = newValue === null || newValue === "false" ? false : true;
3984
+ const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
3985
+ if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
3986
+ });
3987
+ };
3988
+ Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
3989
+ const attrName = m[1] || propName;
3990
+ attrNameToPropName.set(attrName, propName);
3991
+ if (BUILD.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
3992
+ return attrName;
3993
+ })]));
3994
+ }
3995
+ }
3996
+ return Cstr;
3997
+ };
3998
+
3999
+ //#endregion
4000
+ //#region src/runtime/initialize-component.ts
4001
+ /**
4002
+ * Initialize a Stencil component given a reference to its host element, its
4003
+ * runtime bookkeeping data structure, runtime metadata about the component,
4004
+ * and (optionally) an HMR version ID.
4005
+ *
4006
+ * @param elm a host element
4007
+ * @param hostRef the element's runtime bookkeeping object
4008
+ * @param cmpMeta runtime metadata for the Stencil component
4009
+ * @param hmrVersionId an (optional) HMR version ID
4010
+ */
4011
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4012
+ let Cstr;
4013
+ try {
4014
+ if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
4015
+ hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
4016
+ const bundleId = cmpMeta.$lazyBundleId$;
4017
+ if (BUILD.lazyLoad && bundleId) {
4018
+ const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
4019
+ if (CstrImport && "then" in CstrImport) {
4020
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
4021
+ Cstr = await CstrImport;
4022
+ endLoad();
4023
+ } else Cstr = CstrImport;
4024
+ if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4025
+ if (BUILD.member && !Cstr.isProxied) {
4026
+ if (BUILD.propChangeCallback) {
4027
+ cmpMeta.$watchers$ = Cstr.watchers;
4028
+ cmpMeta.$serializers$ = Cstr.serializers;
4029
+ cmpMeta.$deserializers$ = Cstr.deserializers;
4030
+ }
4031
+ proxyComponent(Cstr, cmpMeta, PROXY_FLAGS.proxyState);
4032
+ Cstr.isProxied = true;
4033
+ }
4034
+ const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
4035
+ if (BUILD.member) hostRef.$flags$ |= HOST_FLAGS.isConstructingInstance;
4036
+ try {
4037
+ new Cstr(hostRef);
4038
+ } catch (e) {
4039
+ consoleError(e, elm);
4040
+ }
4041
+ if (BUILD.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4042
+ if (BUILD.propChangeCallback) hostRef.$flags$ |= HOST_FLAGS.isWatchReady;
4043
+ endNewInstance();
4044
+ if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4045
+ else hostRef.$deferredConnectedCallback$ = true;
4046
+ } else {
4047
+ Cstr = elm.constructor;
4048
+ /**
4049
+ * Instead of using e.g. `cmpMeta.$tagName$` we use `elm.localName` to get the tag name of the component.
4050
+ * This is because we can't guarantee that the component class is actually registered with the tag name
4051
+ * defined in the component class as users can very well also do this:
4052
+ *
4053
+ * ```html
4054
+ * <script type="module">
4055
+ * import { MyComponent } from 'my-stencil-component-library';
4056
+ * customElements.define('my-other-component', MyComponent);
4057
+ * <\/script>
4058
+ * ```
4059
+ */
4060
+ const cmpTag = elm.localName;
4061
+ customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= HOST_FLAGS.isWatchReady);
4062
+ }
4063
+ if (BUILD.style && Cstr && Cstr.style) {
4064
+ /**
4065
+ * this component has styles but we haven't registered them yet
4066
+ */
4067
+ let style;
4068
+ if (typeof Cstr.style === "string")
4069
+ /**
4070
+ * in case the component has a `styleUrl` defined, e.g.
4071
+ * ```ts
4072
+ * @Component({
4073
+ * tag: 'my-component',
4074
+ * styleUrl: 'my-component.css'
4075
+ * })
4076
+ * ```
4077
+ */
4078
+ style = Cstr.style;
4079
+ else if (BUILD.mode && typeof Cstr.style !== "string") {
4080
+ /**
4081
+ * in case the component has a `styleUrl` object defined, e.g.
4082
+ * ```ts
4083
+ * @Component({
4084
+ * tag: 'my-component',
4085
+ * styleUrl: {
4086
+ * ios: 'my-component.ios.css',
4087
+ * md: 'my-component.md.css'
4088
+ * }
4089
+ * })
4090
+ * ```
4091
+ */
4092
+ hostRef.$modeName$ = computeMode(elm);
4093
+ if (hostRef.$modeName$) style = Cstr.style[hostRef.$modeName$];
4094
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) elm.setAttribute("s-mode", hostRef.$modeName$);
4095
+ }
4096
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
4097
+ if (!styles.has(scopeId) || BUILD.hotModuleReplacement && hmrVersionId) {
4098
+ const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
4099
+ if (BUILD.hydrateServerSide && BUILD.shadowDom) {
4100
+ if (cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) style = scopeCss(style, scopeId, true);
4101
+ else if (needsScopedSSR()) style = expandPartSelectors(style);
4102
+ }
4103
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation));
4104
+ endRegisterStyles();
4105
+ }
4106
+ }
4107
+ }
4108
+ const ancestorComponent = hostRef.$ancestorComponent$;
4109
+ const schedule = () => scheduleUpdate(hostRef, true);
4110
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent["s-rc"]) ancestorComponent["s-rc"].push(schedule);
4111
+ else schedule();
4112
+ } catch (e) {
4113
+ consoleError(e, elm);
4114
+ if (BUILD.asyncLoading && hostRef.$onRenderResolve$) {
4115
+ hostRef.$onRenderResolve$();
4116
+ hostRef.$onRenderResolve$ = void 0;
4117
+ }
4118
+ if (BUILD.asyncLoading && hostRef.$onReadyResolve$) hostRef.$onReadyResolve$(elm);
4119
+ }
4120
+ };
4121
+ const fireConnectedCallback = (instance, elm) => {
4122
+ if (BUILD.lazyLoad) safeCall(instance, "connectedCallback", void 0, elm);
4123
+ };
4124
+
4125
+ //#endregion
4126
+ //#region src/runtime/connected-callback.ts
4127
+ const connectedCallback = (elm) => {
4128
+ if ((plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) {
4129
+ const hostRef = getHostRef(elm);
4130
+ if (!hostRef) return;
4131
+ const cmpMeta = hostRef.$cmpMeta$;
4132
+ const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
4133
+ if (BUILD.hostListenerTargetParent) addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
4134
+ if (!(hostRef.$flags$ & HOST_FLAGS.hasConnected)) {
4135
+ hostRef.$flags$ |= HOST_FLAGS.hasConnected;
4136
+ let hostId;
4137
+ if (BUILD.hydrateClientSide) {
4138
+ hostId = elm.getAttribute(HYDRATE_ID);
4139
+ if (hostId) {
4140
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
4141
+ const scopeId = BUILD.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute("s-mode")) : addStyle(elm.shadowRoot, cmpMeta);
4142
+ elm.classList.remove(scopeId + "-h", scopeId + "-s");
4143
+ } else if (BUILD.scoped && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) elm["s-sc"] = getScopeId(cmpMeta, BUILD.mode ? elm.getAttribute("s-mode") : void 0);
4144
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
4145
+ }
4146
+ }
4147
+ if (BUILD.slotRelocation && !hostId) {
4148
+ if (BUILD.hydrateServerSide || (BUILD.slot || BUILD.shadowDom) && cmpMeta.$flags$ & (CMP_FLAGS.hasSlotRelocation | CMP_FLAGS.needsShadowDomShim)) setContentReference(elm);
4149
+ }
4150
+ if (BUILD.asyncLoading) {
4151
+ let ancestorComponent = elm;
4152
+ while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) if (BUILD.hydrateClientSide && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
4153
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4154
+ break;
4155
+ }
4156
+ }
4157
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
4158
+ if (memberFlags & MEMBER_FLAGS.Prop && Object.prototype.hasOwnProperty.call(elm, memberName)) {
4159
+ const value = elm[memberName];
4160
+ delete elm[memberName];
4161
+ elm[memberName] = value;
4162
+ }
4163
+ });
4164
+ if (BUILD.initializeNextTick) nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
4165
+ else initializeComponent(elm, hostRef, cmpMeta);
4166
+ } else {
4167
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
4168
+ if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4169
+ else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
4170
+ }
4171
+ endConnected();
4172
+ }
4173
+ };
4174
+ const setContentReference = (elm) => {
4175
+ if (!win.document) return;
4176
+ const contentRefElm = elm["s-cr"] = win.document.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : "");
4177
+ contentRefElm["s-cn"] = true;
4178
+ insertBefore(elm, contentRefElm, elm.firstChild);
4179
+ };
4180
+
4181
+ //#endregion
4182
+ //#region src/runtime/disconnected-callback.ts
4183
+ const disconnectInstance = (instance, elm) => {
4184
+ if (BUILD.lazyLoad) safeCall(instance, "disconnectedCallback", void 0, elm || instance);
4185
+ };
4186
+ const disconnectedCallback = async (elm) => {
4187
+ if ((plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) {
4188
+ const hostRef = getHostRef(elm);
4189
+ if (BUILD.hostListener) {
4190
+ if (hostRef?.$rmListeners$) {
4191
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
4192
+ hostRef.$rmListeners$ = void 0;
4193
+ }
4194
+ }
4195
+ if (!BUILD.lazyLoad) disconnectInstance(elm);
4196
+ else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
4197
+ else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
4198
+ }
4199
+ /**
4200
+ * Remove the element from the `rootAppliedStyles` WeakMap
4201
+ */
4202
+ if (rootAppliedStyles.has(elm)) rootAppliedStyles.delete(elm);
4203
+ /**
4204
+ * Remove the shadow root from the `rootAppliedStyles` WeakMap
4205
+ */
4206
+ if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) rootAppliedStyles.delete(elm.shadowRoot);
4207
+ };
4208
+
4209
+ //#endregion
4210
+ //#region src/runtime/bootstrap-custom-element.ts
4211
+ const defineCustomElement = (Cstr, compactMeta) => {
4212
+ customElements.define(transformTag(compactMeta[1]), proxyCustomElement(Cstr, compactMeta));
4213
+ };
4214
+ const proxyCustomElement = (Cstr, compactMeta) => {
4215
+ const cmpMeta = {
4216
+ $flags$: compactMeta[0],
4217
+ $tagName$: compactMeta[1]
4218
+ };
4219
+ try {
4220
+ if (BUILD.member) cmpMeta.$members$ = compactMeta[2];
4221
+ if (BUILD.hostListener) cmpMeta.$listeners$ = compactMeta[3];
4222
+ if (BUILD.propChangeCallback) {
4223
+ cmpMeta.$watchers$ = Cstr.$watchers$;
4224
+ cmpMeta.$deserializers$ = Cstr.$deserializers$;
4225
+ cmpMeta.$serializers$ = Cstr.$serializers$;
4226
+ }
4227
+ if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
4228
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4229
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD.experimentalSlotFixes) patchPseudoShadowDom(Cstr.prototype);
4230
+ else {
4231
+ if (BUILD.slotChildNodesFix) patchChildSlotNodes(Cstr.prototype);
4232
+ if (BUILD.cloneNodeFix) patchCloneNode(Cstr.prototype);
4233
+ if (BUILD.appendChildSlotFix) patchSlotAppendChild(Cstr.prototype);
4234
+ if (BUILD.scopedSlotTextContentFix && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) patchTextContent(Cstr.prototype);
4235
+ }
4236
+ else if (BUILD.cloneNodeFix) patchCloneNode(Cstr.prototype);
4237
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow();
4238
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
4239
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
4240
+ Object.assign(Cstr.prototype, {
4241
+ __hasHostListenerAttached: false,
4242
+ __registerHost() {
4243
+ registerHost(this, cmpMeta);
4244
+ },
4245
+ connectedCallback() {
4246
+ if (!this.__hasHostListenerAttached) {
4247
+ const hostRef = getHostRef(this);
4248
+ if (!hostRef) return;
4249
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
4250
+ this.__hasHostListenerAttached = true;
4251
+ }
4252
+ connectedCallback(this);
4253
+ if (originalConnectedCallback) originalConnectedCallback.call(this);
4254
+ },
4255
+ disconnectedCallback() {
4256
+ disconnectedCallback(this);
4257
+ if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
4258
+ },
4259
+ __attachShadow() {
4260
+ if (supportsShadow) {
4261
+ if (!this.shadowRoot) createShadowRoot.call(this, cmpMeta);
4262
+ else if (this.shadowRoot.mode !== "open") throw new Error(`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`);
4263
+ } else this.shadowRoot = this;
4264
+ }
4265
+ });
4266
+ Object.defineProperty(Cstr, "is", {
4267
+ value: cmpMeta.$tagName$,
4268
+ configurable: true
4269
+ });
4270
+ return proxyComponent(Cstr, cmpMeta, PROXY_FLAGS.isElementConstructor | PROXY_FLAGS.proxyState);
4271
+ } catch (e) {
4272
+ consoleError(e);
4273
+ return Cstr;
4274
+ }
4275
+ };
4276
+ const forceModeUpdate = (elm) => {
4277
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
4278
+ const mode = computeMode(elm);
4279
+ const hostRef = getHostRef(elm);
4280
+ if (hostRef && hostRef.$modeName$ !== mode) {
4281
+ const cmpMeta = hostRef.$cmpMeta$;
4282
+ const oldScopeId = elm["s-sc"];
4283
+ const scopeId = getScopeId(cmpMeta, mode);
4284
+ const style = elm.constructor.style[mode];
4285
+ const flags = cmpMeta.$flags$;
4286
+ if (style) {
4287
+ if (!styles.has(scopeId)) registerStyle(scopeId, style, !!(flags & CMP_FLAGS.shadowDomEncapsulation));
4288
+ hostRef.$modeName$ = mode;
4289
+ elm.classList.remove(oldScopeId + "-h", oldScopeId + "-s");
4290
+ attachStyles(hostRef);
4291
+ forceUpdate(elm);
4292
+ }
4293
+ }
4294
+ }
4295
+ };
4296
+
4297
+ //#endregion
4298
+ //#region src/runtime/hmr-component.ts
4299
+ /**
4300
+ * Kick off hot-module-replacement for a component. In order to replace the
4301
+ * component in-place we:
4302
+ *
4303
+ * 1. get a reference to the {@link d.HostRef} for the element
4304
+ * 2. reset the element's runtime flags
4305
+ * 3. re-run the initialization logic for the element (via
4306
+ * {@link initializeComponent})
4307
+ *
4308
+ * @param hostElement the host element for the component which we want to start
4309
+ * doing HMR
4310
+ * @param cmpMeta runtime metadata for the component
4311
+ * @param hmrVersionId the current HMR version ID
4312
+ */
4313
+ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
4314
+ const hostRef = getHostRef(hostElement);
4315
+ if (!hostRef) return;
4316
+ hostRef.$flags$ = HOST_FLAGS.hasConnected;
4317
+ initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
4318
+ };
4319
+
4320
+ //#endregion
4321
+ //#region src/runtime/bootstrap-lazy.ts
4322
+ const bootstrapLazy = (lazyBundles, options = {}) => {
4323
+ if (BUILD.profile && performance.mark) performance.mark("st:app:start");
4324
+ installDevTools();
4325
+ if (!win.document) {
4326
+ console.warn("Stencil: No document found. Skipping bootstrapping lazy components.");
4327
+ return;
4328
+ }
4329
+ const endBootstrap = createTime("bootstrapLazy");
4330
+ const cmpTags = [];
4331
+ const exclude = options.exclude || [];
4332
+ const customElements = win.customElements;
4333
+ const head = win.document.head;
4334
+ const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
4335
+ const dataStyles = /* @__PURE__ */ win.document.createElement("style");
4336
+ const deferredConnectedCallbacks = [];
4337
+ let appLoadFallback;
4338
+ let isBootstrapping = true;
4339
+ Object.assign(plt, options);
4340
+ if (BUILD.asyncQueue && options.syncQueue) plt.$flags$ |= PLATFORM_FLAGS.queueSync;
4341
+ if (BUILD.hydrateClientSide) plt.$flags$ |= PLATFORM_FLAGS.appLoaded;
4342
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow();
4343
+ let hasSlotRelocation = false;
4344
+ lazyBundles.map((lazyBundle) => {
4345
+ lazyBundle[1].map((compactMeta) => {
4346
+ const cmpMeta = {
4347
+ $flags$: compactMeta[0],
4348
+ $tagName$: compactMeta[1],
4349
+ $members$: compactMeta[2],
4350
+ $listeners$: compactMeta[3]
4351
+ };
4352
+ if (cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) hasSlotRelocation = true;
4353
+ if (BUILD.member) cmpMeta.$members$ = compactMeta[2];
4354
+ if (BUILD.hostListener) cmpMeta.$listeners$ = compactMeta[3];
4355
+ if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
4356
+ if (BUILD.propChangeCallback) {
4357
+ cmpMeta.$watchers$ = compactMeta[4] ?? {};
4358
+ cmpMeta.$serializers$ = compactMeta[5] ?? {};
4359
+ cmpMeta.$deserializers$ = compactMeta[6] ?? {};
4360
+ }
4361
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4362
+ const tagName = BUILD.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : transformTag(cmpMeta.$tagName$);
4363
+ const HostElement = class extends HTMLElement {
4364
+ ["s-p"];
4365
+ ["s-rc"];
4366
+ hasRegisteredEventListeners = false;
4367
+ constructor(self) {
4368
+ super(self);
4369
+ self = this;
4370
+ registerHost(self, cmpMeta);
4371
+ if (BUILD.shadowDom && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
4372
+ if (supportsShadow) {
4373
+ if (!self.shadowRoot) createShadowRoot.call(self, cmpMeta);
4374
+ else if (self.shadowRoot.mode !== "open") throw new Error(`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`);
4375
+ } else if (!BUILD.hydrateServerSide && !("shadowRoot" in self)) self.shadowRoot = self;
4376
+ }
4377
+ }
4378
+ connectedCallback() {
4379
+ const hostRef = getHostRef(this);
4380
+ if (!hostRef) return;
4381
+ /**
4382
+ * The `connectedCallback` lifecycle event can potentially be fired multiple times
4383
+ * if the element is removed from the DOM and re-inserted. This is not a common use case,
4384
+ * but it can happen in some scenarios. To prevent registering the same event listeners
4385
+ * multiple times, we will only register them once.
4386
+ */
4387
+ if (!this.hasRegisteredEventListeners) {
4388
+ this.hasRegisteredEventListeners = true;
4389
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
4390
+ }
4391
+ if (appLoadFallback) {
4392
+ clearTimeout(appLoadFallback);
4393
+ appLoadFallback = null;
4394
+ }
4395
+ if (isBootstrapping) deferredConnectedCallbacks.push(this);
4396
+ else plt.jmp(() => connectedCallback(this));
4397
+ }
4398
+ disconnectedCallback() {
4399
+ plt.jmp(() => disconnectedCallback(this));
4400
+ /**
4401
+ * Clear up references within the `$vnode$` object to the DOM
4402
+ * node that was removed. This is necessary to ensure that these
4403
+ * references used as keys in the `hostRef` object can be properly
4404
+ * garbage collected.
4405
+ *
4406
+ * Also remove the reference from `deferredConnectedCallbacks` array
4407
+ * otherwise removed instances won't get garbage collected.
4408
+ */
4409
+ plt.raf(() => {
4410
+ const hostRef = getHostRef(this);
4411
+ if (!hostRef) return;
4412
+ const i = deferredConnectedCallbacks.findIndex((host) => host === this);
4413
+ if (i > -1) deferredConnectedCallbacks.splice(i, 1);
4414
+ if (hostRef?.$vnode$?.$elm$ instanceof Node && !hostRef.$vnode$.$elm$.isConnected) delete hostRef.$vnode$.$elm$;
4415
+ });
4416
+ }
4417
+ componentOnReady() {
4418
+ return getHostRef(this)?.$onReadyPromise$;
4419
+ }
4420
+ };
4421
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD.experimentalSlotFixes) patchPseudoShadowDom(HostElement.prototype);
4422
+ else {
4423
+ if (BUILD.slotChildNodesFix) patchChildSlotNodes(HostElement.prototype);
4424
+ if (BUILD.cloneNodeFix) patchCloneNode(HostElement.prototype);
4425
+ if (BUILD.appendChildSlotFix) patchSlotAppendChild(HostElement.prototype);
4426
+ if (BUILD.scopedSlotTextContentFix && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) patchTextContent(HostElement.prototype);
4427
+ }
4428
+ else if (BUILD.cloneNodeFix) patchCloneNode(HostElement.prototype);
4429
+ if (BUILD.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
4430
+ if (BUILD.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
4431
+ hmrStart(this, cmpMeta, hmrVersionId);
4432
+ };
4433
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
4434
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
4435
+ cmpTags.push(tagName);
4436
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, PROXY_FLAGS.isElementConstructor));
4437
+ }
4438
+ });
4439
+ });
4440
+ if (cmpTags.length > 0) {
4441
+ if (BUILD.slotRelocation && hasSlotRelocation) dataStyles.textContent += SLOT_FB_CSS;
4442
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
4443
+ if (dataStyles.innerHTML.length) {
4444
+ dataStyles.setAttribute("data-styles", "");
4445
+ const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
4446
+ if (nonce != null) dataStyles.setAttribute("nonce", nonce);
4447
+ head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
4448
+ }
4449
+ }
4450
+ isBootstrapping = false;
4451
+ if (deferredConnectedCallbacks.length) deferredConnectedCallbacks.map((host) => host.connectedCallback());
4452
+ else if (BUILD.profile) plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30, "timeout"));
4453
+ else plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
4454
+ endBootstrap();
4455
+ };
4456
+
4457
+ //#endregion
4458
+ //#region src/runtime/fragment.ts
4459
+ const Fragment = (_, children) => children;
4460
+
4461
+ //#endregion
4462
+ //#region src/runtime/host-listener.ts
4463
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
4464
+ if (BUILD.hostListener && listeners && win.document) {
4465
+ if (BUILD.hostListenerTargetParent) if (attachParentListeners) listeners = listeners.filter(([flags]) => flags & LISTENER_FLAGS.TargetParent);
4466
+ else listeners = listeners.filter(([flags]) => !(flags & LISTENER_FLAGS.TargetParent));
4467
+ listeners.map(([flags, name, method]) => {
4468
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(win.document, elm, flags) : elm;
4469
+ const handler = hostListenerProxy(hostRef, method);
4470
+ const opts = hostListenerOpts(flags);
4471
+ plt.ael(target, name, handler, opts);
4472
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
4473
+ });
4474
+ }
4475
+ };
4476
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
4477
+ try {
4478
+ if (BUILD.lazyLoad) if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4479
+ else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4480
+ else hostRef.$hostElement$[methodName](ev);
4481
+ } catch (e) {
4482
+ consoleError(e, hostRef.$hostElement$);
4483
+ }
4484
+ };
4485
+ const getHostListenerTarget = (doc, elm, flags) => {
4486
+ if (BUILD.hostListenerTargetDocument && flags & LISTENER_FLAGS.TargetDocument) return doc;
4487
+ if (BUILD.hostListenerTargetWindow && flags & LISTENER_FLAGS.TargetWindow) return win;
4488
+ if (BUILD.hostListenerTargetBody && flags & LISTENER_FLAGS.TargetBody) return doc.body;
4489
+ if (BUILD.hostListenerTargetParent && flags & LISTENER_FLAGS.TargetParent && elm.parentElement) return elm.parentElement;
4490
+ return elm;
4491
+ };
4492
+ const hostListenerOpts = (flags) => supportsListenerOptions ? {
4493
+ passive: (flags & LISTENER_FLAGS.Passive) !== 0,
4494
+ capture: (flags & LISTENER_FLAGS.Capture) !== 0
4495
+ } : (flags & LISTENER_FLAGS.Capture) !== 0;
4496
+
4497
+ //#endregion
4498
+ //#region src/runtime/mixin.ts
4499
+ const baseClass = BUILD.lazyLoad ? class {} : globalThis.HTMLElement || class {};
4500
+ function Mixin(...mixins) {
4501
+ return mixins.reduceRight((acc, mixin) => mixin(acc), baseClass);
4502
+ }
4503
+
4504
+ //#endregion
4505
+ //#region src/runtime/nonce.ts
4506
+ /**
4507
+ * Assigns the given value to the nonce property on the runtime platform object.
4508
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
4509
+ * @param nonce The value to be assigned to the platform nonce property.
4510
+ * @returns void
4511
+ */
4512
+ const setNonce = (nonce) => plt.$nonce$ = nonce;
4513
+
4514
+ //#endregion
4515
+ //#region src/runtime/platform-options.ts
4516
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
4517
+
4518
+ //#endregion
4519
+ //#region src/runtime/render.ts
4520
+ /**
4521
+ * Method to render a virtual DOM tree to a container element.
4522
+ *
4523
+ * @example
4524
+ * ```tsx
4525
+ * import { render } from '@stencil/core';
4526
+ *
4527
+ * const vnode = (
4528
+ * <div>
4529
+ * <h1>Hello, world!</h1>
4530
+ * </div>
4531
+ * );
4532
+ * render(vnode, document.body);
4533
+ * ```
4534
+ *
4535
+ * @param vnode - The virtual DOM tree to render
4536
+ * @param container - The container element to render the virtual DOM tree to
4537
+ */
4538
+ function render(vnode, container) {
4539
+ renderVdom({
4540
+ $flags$: 0,
4541
+ $cmpMeta$: {
4542
+ $flags$: 0,
4543
+ $tagName$: container.tagName
4544
+ },
4545
+ $hostElement$: container
4546
+ }, vnode);
4547
+ }
4548
+
4549
+ //#endregion
4550
+ //#region src/runtime/tag-transform.ts
4551
+ let tagTransformer = void 0;
4552
+ /**
4553
+ * Transforms a tag name using the current tag transformer
4554
+ * @param tag - the tag to transform e.g. `my-tag`
4555
+ * @returns the transformed tag e.g. `new-my-tag`
4556
+ */
4557
+ function transformTag(tag) {
4558
+ if (!tagTransformer) return tag;
4559
+ return tagTransformer(tag);
4560
+ }
4561
+ /**
4562
+ * Sets the tag transformer to be used when rendering custom elements
4563
+ * @param transformer the transformer function to use. Must return a string
4564
+ */
4565
+ function setTagTransformer(transformer) {
4566
+ if (tagTransformer) console.warn(`
4567
+ A tagTransformer has already been set.
4568
+ Overwriting it may lead to error and unexpected results if your components have already been defined.
4569
+ `);
4570
+ tagTransformer = transformer;
4571
+ }
4572
+
4573
+ //#endregion
4574
+ //#region src/runtime/vdom/jsx-dev-runtime.ts
4575
+ /**
4576
+ * Automatic JSX Development Runtime for Stencil
4577
+ *
4578
+ * This module provides the automatic JSX runtime functions required by
4579
+ * TypeScript when using "jsx": "react-jsxdev" mode. This is used during
4580
+ * development and includes additional debugging information.
4581
+ *
4582
+ * For more information, see:
4583
+ * https://www.typescriptlang.org/docs/handbook/jsx.html
4584
+ */
4585
+ /**
4586
+ * JSX development runtime function for creating elements with debug info.
4587
+ * Called by TypeScript's jsx transform in development mode.
4588
+ *
4589
+ * @param type - The element type (string tag name or functional component)
4590
+ * @param props - The element props (includes children, key, etc.)
4591
+ * @param key - The element's key (passed separately in dev mode)
4592
+ * @param isStaticChildren - Whether children are static (optimization hint)
4593
+ * @param source - Source location information for debugging
4594
+ * @param self - The component instance (for debugging)
4595
+ * @returns A virtual DOM node
4596
+ */
4597
+ function jsxDEV(type, props, key, _isStaticChildren, _source, _self) {
4598
+ const { children, ...rest } = props || {};
4599
+ let vnodeData = rest;
4600
+ if (key !== void 0 && !("key" in rest)) vnodeData = {
4601
+ ...rest,
4602
+ key
4603
+ };
4604
+ if (vnodeData && Object.keys(vnodeData).length === 0) vnodeData = null;
4605
+ if (children !== void 0) {
4606
+ if (Array.isArray(children)) return h(type, vnodeData, ...children);
4607
+ if (typeof children === "object" && children !== null && "$flags$" in children) return h(type, vnodeData, children);
4608
+ return h(type, vnodeData, children);
4609
+ }
4610
+ return h(type, vnodeData);
4611
+ }
4612
+
4613
+ //#endregion
4614
+ //#region src/runtime/vdom/jsx-runtime.ts
4615
+ /**
4616
+ * Automatic JSX Runtime for Stencil
4617
+ *
4618
+ * This module provides the automatic JSX runtime functions required by
4619
+ * TypeScript when using "jsx": "react-jsx" mode. This allows developers
4620
+ * to write JSX without explicitly importing the `h` function.
4621
+ *
4622
+ * For more information, see:
4623
+ * https://www.typescriptlang.org/docs/handbook/jsx.html
4624
+ */
4625
+ /**
4626
+ * JSX runtime function for creating elements in production mode.
4627
+ * Called by TypeScript's jsx transform for elements without static children.
4628
+ *
4629
+ * @param type - The element type (string tag name or functional component)
4630
+ * @param props - The element props (includes children)
4631
+ * @param key - Optional key for the element
4632
+ * @returns A virtual DOM node
4633
+ */
4634
+ function jsx(type, props, key) {
4635
+ const { children, ...rest } = props || {};
4636
+ let vnodeData = rest;
4637
+ if (key !== void 0 && !("key" in rest)) vnodeData = {
4638
+ ...rest,
4639
+ key
4640
+ };
4641
+ if (vnodeData && Object.keys(vnodeData).length === 0) vnodeData = null;
4642
+ if (children !== void 0) {
4643
+ if (Array.isArray(children)) return h(type, vnodeData, ...children);
4644
+ if (typeof children === "object" && children !== null && "$flags$" in children) return h(type, vnodeData, children);
4645
+ return h(type, vnodeData, children);
4646
+ }
4647
+ return h(type, vnodeData);
4648
+ }
4649
+ /**
4650
+ * JSX runtime function for creating elements with static children.
4651
+ * Called by TypeScript's jsx transform as an optimization when children are static.
4652
+ *
4653
+ * @param type - The element type (string tag name or functional component)
4654
+ * @param props - The element props (includes children)
4655
+ * @param key - Optional key for the element
4656
+ * @returns A virtual DOM node
4657
+ */
4658
+ function jsxs(type, props, key) {
4659
+ return jsx(type, props, key);
4660
+ }
4661
+
4662
+ //#endregion
4663
+ //#region src/runtime/vdom/vdom-annotations.ts
4664
+ /**
4665
+ * Updates the DOM generated on the server with annotations such as node attributes and
4666
+ * comment nodes to facilitate future client-side hydration. These annotations are used for things
4667
+ * like moving elements back to their original hosts if using Shadow DOM on the client, and for quickly
4668
+ * reconstructing the vNode representations of the DOM.
4669
+ *
4670
+ * @param doc The DOM generated by the server.
4671
+ * @param staticComponents Any components that should be considered static and do not need client-side hydration.
4672
+ */
4673
+ const insertVdomAnnotations = (doc, staticComponents) => {
4674
+ if (doc != null) {
4675
+ /**
4676
+ * Initiated `docData` object from the document if it exists to ensure we
4677
+ * maintain the same `docData` object across multiple hydration hydration runs.
4678
+ */
4679
+ const docData = STENCIL_DOC_DATA in doc ? doc[STENCIL_DOC_DATA] : { ...DEFAULT_DOC_DATA };
4680
+ docData.staticComponents = new Set(staticComponents);
4681
+ const orgLocationNodes = [];
4682
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
4683
+ orgLocationNodes.forEach((orgLocationNode) => {
4684
+ if (orgLocationNode != null && orgLocationNode["s-nr"]) {
4685
+ const nodeRef = orgLocationNode["s-nr"];
4686
+ let hostId = nodeRef["s-host-id"];
4687
+ let nodeId = nodeRef["s-node-id"];
4688
+ let childId = `${hostId}.${nodeId}`;
4689
+ if (hostId == null) {
4690
+ hostId = 0;
4691
+ docData.rootLevelIds++;
4692
+ nodeId = docData.rootLevelIds;
4693
+ childId = `${hostId}.${nodeId}`;
4694
+ if (nodeRef.nodeType === NODE_TYPE.ElementNode) {
4695
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
4696
+ if (typeof nodeRef["s-sn"] === "string" && !nodeRef.getAttribute("slot")) nodeRef.setAttribute("s-sn", nodeRef["s-sn"]);
4697
+ } else if (nodeRef.nodeType === NODE_TYPE.TextNode) {
4698
+ if (hostId === 0) {
4699
+ if (nodeRef.nodeValue?.trim() === "") {
4700
+ orgLocationNode.remove();
4701
+ return;
4702
+ }
4703
+ }
4704
+ const commentBeforeTextNode = doc.createComment(childId);
4705
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
4706
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
4707
+ } else if (nodeRef.nodeType === NODE_TYPE.CommentNode) {
4708
+ const commentBeforeTextNode = doc.createComment(childId);
4709
+ commentBeforeTextNode.nodeValue = `${COMMENT_NODE_ID}.${childId}`;
4710
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
4711
+ }
4712
+ }
4713
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
4714
+ const orgLocationParentNode = orgLocationNode.parentElement;
4715
+ if (orgLocationParentNode) {
4716
+ if (orgLocationParentNode["s-en"] === "") orgLocationNodeId += `.`;
4717
+ else if (orgLocationParentNode["s-en"] === "c") orgLocationNodeId += `.c`;
4718
+ }
4719
+ orgLocationNode.nodeValue = orgLocationNodeId;
4720
+ }
4721
+ });
4722
+ }
4723
+ };
4724
+ /**
4725
+ * Recursively parses a node generated by the server and its children to set host and child id
4726
+ * attributes read during client-side hydration. This function also tracks whether each node is
4727
+ * an original location reference node meaning that a node has been moved via slot relocation.
4728
+ *
4729
+ * @param doc The DOM generated by the server.
4730
+ * @param node The node to parse.
4731
+ * @param docData An object containing metadata about the document.
4732
+ * @param orgLocationNodes An array of nodes that have been moved via slot relocation.
4733
+ */
4734
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
4735
+ if (node == null) return;
4736
+ if (node["s-nr"] != null) orgLocationNodes.push(node);
4737
+ if (node.nodeType === NODE_TYPE.ElementNode) [...Array.from(node.childNodes), ...Array.from(node.shadowRoot?.childNodes || [])].forEach((childNode) => {
4738
+ const hostRef = getHostRef(childNode);
4739
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, { nodeIds: 0 });
4740
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
4741
+ });
4742
+ };
4743
+ /**
4744
+ * Insert attribute annotations on an element for its host ID and, potentially, its child ID.
4745
+ * Also makes calls to insert annotations on the element's children, keeping track of the depth of
4746
+ * the component tree.
4747
+ *
4748
+ * @param doc The DOM generated by the server.
4749
+ * @param hostElm The element to insert annotations for.
4750
+ * @param vnode The vNode representation of the element.
4751
+ * @param docData An object containing metadata about the document.
4752
+ * @param cmpData An object containing metadata about the component.
4753
+ */
4754
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
4755
+ if (vnode != null) {
4756
+ const hostId = ++docData.hostIds;
4757
+ hostElm.setAttribute(HYDRATE_ID, hostId);
4758
+ if (hostElm["s-cr"] != null) hostElm["s-cr"].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
4759
+ if (vnode.$children$ != null) {
4760
+ const depth = 0;
4761
+ vnode.$children$.forEach((vnodeChild, index) => {
4762
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
4763
+ });
4764
+ }
4765
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute(HYDRATE_CHILD_ID)) {
4766
+ const parent = hostElm.parentElement;
4767
+ if (parent && parent.childNodes) {
4768
+ const parentChildNodes = Array.from(parent.childNodes);
4769
+ const comment = parentChildNodes.find((node) => node.nodeType === NODE_TYPE.CommentNode && node["s-sr"]);
4770
+ if (comment) {
4771
+ const index = parentChildNodes.indexOf(hostElm) - 1;
4772
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`);
4773
+ }
4774
+ }
4775
+ }
4776
+ }
4777
+ };
4778
+ /**
4779
+ * Recursively analyzes the type of a child vNode and inserts annotations on the vNodes's element based on its type.
4780
+ * Element nodes receive a child ID attribute, text nodes have a comment with the child ID inserted before them,
4781
+ * and comment nodes representing a slot have their node value set to a slot node ID containing the child ID.
4782
+ *
4783
+ * @param doc The DOM generated by the server.
4784
+ * @param vnodeChild The vNode to insert annotations for.
4785
+ * @param cmpData An object containing metadata about the component.
4786
+ * @param hostId The host ID of this element's parent.
4787
+ * @param depth How deep this element sits in the component tree relative to its parent.
4788
+ * @param index The index of this element in its parent's children array.
4789
+ */
4790
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
4791
+ const childElm = vnodeChild.$elm$;
4792
+ if (childElm == null) return;
4793
+ const nodeId = cmpData.nodeIds++;
4794
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
4795
+ childElm["s-host-id"] = hostId;
4796
+ childElm["s-node-id"] = nodeId;
4797
+ if (childElm.nodeType === NODE_TYPE.ElementNode) {
4798
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
4799
+ if (typeof childElm["s-sn"] === "string" && !childElm.getAttribute("slot")) childElm.setAttribute("s-sn", childElm["s-sn"]);
4800
+ } else if (childElm.nodeType === NODE_TYPE.TextNode) {
4801
+ const parentNode = childElm.parentNode;
4802
+ const nodeName = parentNode?.nodeName;
4803
+ if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
4804
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
4805
+ insertBefore(parentNode, doc.createComment(textNodeId), childElm);
4806
+ }
4807
+ } else if (childElm.nodeType === NODE_TYPE.CommentNode) {
4808
+ if (childElm["s-sr"]) childElm.nodeValue = `${SLOT_NODE_ID}.${childId}.${childElm["s-sn"] || ""}`;
4809
+ }
4810
+ if (vnodeChild.$children$ != null) {
4811
+ const childDepth = depth + 1;
4812
+ vnodeChild.$children$.forEach((vnode, index) => {
4813
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
4814
+ });
4815
+ }
4816
+ };
4817
+
4818
+ //#endregion
4819
+ export { Fragment, HYDRATED_STYLE_ID, Host, Mixin, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getValue, h, insertVdomAnnotations, jsx, jsxDEV, jsxs, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, render, renderVdom, setAssetPath, setMode, setNonce, setPlatformOptions, setTagTransformer, setValue, transformTag };