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