@stencil/core 4.43.3 → 5.0.0-alpha.1

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