@juspay/shooter 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/.claude/hooks/notifier.cjs +1431 -0
  2. package/.claude/settings.json +162 -0
  3. package/README.md +515 -0
  4. package/bin/shooter.cjs +141 -0
  5. package/build/client/_app/immutable/assets/0.CM9Hl6d-.css +1 -0
  6. package/build/client/_app/immutable/assets/0.CM9Hl6d-.css.br +0 -0
  7. package/build/client/_app/immutable/assets/0.CM9Hl6d-.css.gz +0 -0
  8. package/build/client/_app/immutable/assets/2.CAShZ7lQ.css +1 -0
  9. package/build/client/_app/immutable/assets/2.CAShZ7lQ.css.br +1 -0
  10. package/build/client/_app/immutable/assets/2.CAShZ7lQ.css.gz +0 -0
  11. package/build/client/_app/immutable/assets/3.C0uFg0IS.css +1 -0
  12. package/build/client/_app/immutable/assets/3.C0uFg0IS.css.br +0 -0
  13. package/build/client/_app/immutable/assets/3.C0uFg0IS.css.gz +0 -0
  14. package/build/client/_app/immutable/assets/4.cJuCkJKZ.css +1 -0
  15. package/build/client/_app/immutable/assets/4.cJuCkJKZ.css.br +0 -0
  16. package/build/client/_app/immutable/assets/4.cJuCkJKZ.css.gz +0 -0
  17. package/build/client/_app/immutable/assets/5.DRjApZQW.css +1 -0
  18. package/build/client/_app/immutable/assets/5.DRjApZQW.css.br +0 -0
  19. package/build/client/_app/immutable/assets/5.DRjApZQW.css.gz +0 -0
  20. package/build/client/_app/immutable/assets/6.AraZrY8I.css +1 -0
  21. package/build/client/_app/immutable/assets/6.AraZrY8I.css.br +0 -0
  22. package/build/client/_app/immutable/assets/6.AraZrY8I.css.gz +0 -0
  23. package/build/client/_app/immutable/assets/7.BCJ1IuMx.css +1 -0
  24. package/build/client/_app/immutable/assets/7.BCJ1IuMx.css.br +0 -0
  25. package/build/client/_app/immutable/assets/7.BCJ1IuMx.css.gz +0 -0
  26. package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css +1 -0
  27. package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css.br +0 -0
  28. package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css.gz +0 -0
  29. package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css +1 -0
  30. package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css.br +0 -0
  31. package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css.gz +0 -0
  32. package/build/client/_app/immutable/assets/xterm.DFuMZ0ql.css +1 -0
  33. package/build/client/_app/immutable/assets/xterm.DFuMZ0ql.css.br +0 -0
  34. package/build/client/_app/immutable/assets/xterm.DFuMZ0ql.css.gz +0 -0
  35. package/build/client/_app/immutable/chunks/BNJphC1q.js +56 -0
  36. package/build/client/_app/immutable/chunks/BNJphC1q.js.br +0 -0
  37. package/build/client/_app/immutable/chunks/BNJphC1q.js.gz +0 -0
  38. package/build/client/_app/immutable/chunks/BTGVxaYV.js +9 -0
  39. package/build/client/_app/immutable/chunks/BTGVxaYV.js.br +0 -0
  40. package/build/client/_app/immutable/chunks/BTGVxaYV.js.gz +0 -0
  41. package/build/client/_app/immutable/chunks/BlxrFPDK.js +1 -0
  42. package/build/client/_app/immutable/chunks/BlxrFPDK.js.br +0 -0
  43. package/build/client/_app/immutable/chunks/BlxrFPDK.js.gz +0 -0
  44. package/build/client/_app/immutable/chunks/Bvk7mfPM.js +1 -0
  45. package/build/client/_app/immutable/chunks/Bvk7mfPM.js.br +0 -0
  46. package/build/client/_app/immutable/chunks/Bvk7mfPM.js.gz +0 -0
  47. package/build/client/_app/immutable/chunks/CAokzuPQ.js +1 -0
  48. package/build/client/_app/immutable/chunks/CAokzuPQ.js.br +0 -0
  49. package/build/client/_app/immutable/chunks/CAokzuPQ.js.gz +0 -0
  50. package/build/client/_app/immutable/chunks/CGLrx-H5.js +1 -0
  51. package/build/client/_app/immutable/chunks/CGLrx-H5.js.br +0 -0
  52. package/build/client/_app/immutable/chunks/CGLrx-H5.js.gz +0 -0
  53. package/build/client/_app/immutable/chunks/CgCpWzEA.js +1 -0
  54. package/build/client/_app/immutable/chunks/CgCpWzEA.js.br +0 -0
  55. package/build/client/_app/immutable/chunks/CgCpWzEA.js.gz +0 -0
  56. package/build/client/_app/immutable/chunks/Cjwk_cGO.js +6 -0
  57. package/build/client/_app/immutable/chunks/Cjwk_cGO.js.br +0 -0
  58. package/build/client/_app/immutable/chunks/Cjwk_cGO.js.gz +0 -0
  59. package/build/client/_app/immutable/chunks/CtQ8EED1.js +11 -0
  60. package/build/client/_app/immutable/chunks/CtQ8EED1.js.br +0 -0
  61. package/build/client/_app/immutable/chunks/CtQ8EED1.js.gz +0 -0
  62. package/build/client/_app/immutable/chunks/DERQCisl.js +1 -0
  63. package/build/client/_app/immutable/chunks/DERQCisl.js.br +0 -0
  64. package/build/client/_app/immutable/chunks/DERQCisl.js.gz +0 -0
  65. package/build/client/_app/immutable/chunks/DKrg8TQs.js +1 -0
  66. package/build/client/_app/immutable/chunks/DKrg8TQs.js.br +0 -0
  67. package/build/client/_app/immutable/chunks/DKrg8TQs.js.gz +0 -0
  68. package/build/client/_app/immutable/chunks/DLu6yJIZ.js +1 -0
  69. package/build/client/_app/immutable/chunks/DLu6yJIZ.js.br +0 -0
  70. package/build/client/_app/immutable/chunks/DLu6yJIZ.js.gz +0 -0
  71. package/build/client/_app/immutable/chunks/Dkkpz_4D.js +126 -0
  72. package/build/client/_app/immutable/chunks/Dkkpz_4D.js.br +0 -0
  73. package/build/client/_app/immutable/chunks/Dkkpz_4D.js.gz +0 -0
  74. package/build/client/_app/immutable/chunks/DoczjQhA.js +1 -0
  75. package/build/client/_app/immutable/chunks/DoczjQhA.js.br +0 -0
  76. package/build/client/_app/immutable/chunks/DoczjQhA.js.gz +0 -0
  77. package/build/client/_app/immutable/chunks/PPVm8Dsz.js +1 -0
  78. package/build/client/_app/immutable/chunks/PPVm8Dsz.js.br +0 -0
  79. package/build/client/_app/immutable/chunks/PPVm8Dsz.js.gz +0 -0
  80. package/build/client/_app/immutable/chunks/RpcNruLP.js +2 -0
  81. package/build/client/_app/immutable/chunks/RpcNruLP.js.br +0 -0
  82. package/build/client/_app/immutable/chunks/RpcNruLP.js.gz +0 -0
  83. package/build/client/_app/immutable/chunks/a-St0Zwo.js +1 -0
  84. package/build/client/_app/immutable/chunks/a-St0Zwo.js.br +0 -0
  85. package/build/client/_app/immutable/chunks/a-St0Zwo.js.gz +0 -0
  86. package/build/client/_app/immutable/chunks/bo70OQUZ.js +1 -0
  87. package/build/client/_app/immutable/chunks/bo70OQUZ.js.br +0 -0
  88. package/build/client/_app/immutable/chunks/bo70OQUZ.js.gz +0 -0
  89. package/build/client/_app/immutable/entry/app.QvGgdvTI.js +2 -0
  90. package/build/client/_app/immutable/entry/app.QvGgdvTI.js.br +0 -0
  91. package/build/client/_app/immutable/entry/app.QvGgdvTI.js.gz +0 -0
  92. package/build/client/_app/immutable/entry/start.BntDNRMC.js +1 -0
  93. package/build/client/_app/immutable/entry/start.BntDNRMC.js.br +0 -0
  94. package/build/client/_app/immutable/entry/start.BntDNRMC.js.gz +0 -0
  95. package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js +1 -0
  96. package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js.br +0 -0
  97. package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js.gz +0 -0
  98. package/build/client/_app/immutable/nodes/1.MG1QhfrI.js +1 -0
  99. package/build/client/_app/immutable/nodes/1.MG1QhfrI.js.br +0 -0
  100. package/build/client/_app/immutable/nodes/1.MG1QhfrI.js.gz +0 -0
  101. package/build/client/_app/immutable/nodes/2.B4MlOSh6.js +1 -0
  102. package/build/client/_app/immutable/nodes/2.B4MlOSh6.js.br +0 -0
  103. package/build/client/_app/immutable/nodes/2.B4MlOSh6.js.gz +0 -0
  104. package/build/client/_app/immutable/nodes/3.DIwYkjDn.js +3 -0
  105. package/build/client/_app/immutable/nodes/3.DIwYkjDn.js.br +0 -0
  106. package/build/client/_app/immutable/nodes/3.DIwYkjDn.js.gz +0 -0
  107. package/build/client/_app/immutable/nodes/4.D-cIe70D.js +1 -0
  108. package/build/client/_app/immutable/nodes/4.D-cIe70D.js.br +0 -0
  109. package/build/client/_app/immutable/nodes/4.D-cIe70D.js.gz +0 -0
  110. package/build/client/_app/immutable/nodes/5.D7zPRe3L.js +1 -0
  111. package/build/client/_app/immutable/nodes/5.D7zPRe3L.js.br +0 -0
  112. package/build/client/_app/immutable/nodes/5.D7zPRe3L.js.gz +0 -0
  113. package/build/client/_app/immutable/nodes/6.BB7QE48r.js +2 -0
  114. package/build/client/_app/immutable/nodes/6.BB7QE48r.js.br +0 -0
  115. package/build/client/_app/immutable/nodes/6.BB7QE48r.js.gz +0 -0
  116. package/build/client/_app/immutable/nodes/7.D8mqsrZG.js +2 -0
  117. package/build/client/_app/immutable/nodes/7.D8mqsrZG.js.br +0 -0
  118. package/build/client/_app/immutable/nodes/7.D8mqsrZG.js.gz +0 -0
  119. package/build/client/_app/version.json +1 -0
  120. package/build/client/_app/version.json.br +0 -0
  121. package/build/client/_app/version.json.gz +0 -0
  122. package/build/client/app-icon.png +0 -0
  123. package/build/client/apple-touch-icon.png +0 -0
  124. package/build/client/favicon.png +0 -0
  125. package/build/client/favicon.svg +10 -0
  126. package/build/client/favicon.svg.br +0 -0
  127. package/build/client/favicon.svg.gz +0 -0
  128. package/build/client/manifest.webmanifest +1 -0
  129. package/build/client/pwa-192x192.png +0 -0
  130. package/build/client/pwa-512x512.png +0 -0
  131. package/build/client/registerSW.js +1 -0
  132. package/build/client/registerSW.js.br +0 -0
  133. package/build/client/registerSW.js.gz +0 -0
  134. package/build/client/sw.js +222 -0
  135. package/build/client/sw.js.br +0 -0
  136. package/build/client/sw.js.gz +0 -0
  137. package/build/client/workbox-5119daf5.js +3395 -0
  138. package/build/client/workbox-5119daf5.js.br +0 -0
  139. package/build/client/workbox-5119daf5.js.gz +0 -0
  140. package/build/env.js +94 -0
  141. package/build/handler.js +1494 -0
  142. package/build/index.js +345 -0
  143. package/build/pty-holder.cjs +510 -0
  144. package/build/server/chunks/0-q2IUp76Y.js +9 -0
  145. package/build/server/chunks/0-q2IUp76Y.js.map +1 -0
  146. package/build/server/chunks/1-CU50G5wZ.js +9 -0
  147. package/build/server/chunks/1-CU50G5wZ.js.map +1 -0
  148. package/build/server/chunks/2-D01t9s8T.js +9 -0
  149. package/build/server/chunks/2-D01t9s8T.js.map +1 -0
  150. package/build/server/chunks/3-5PUQ04wC.js +9 -0
  151. package/build/server/chunks/3-5PUQ04wC.js.map +1 -0
  152. package/build/server/chunks/4-e7gywnSG.js +9 -0
  153. package/build/server/chunks/4-e7gywnSG.js.map +1 -0
  154. package/build/server/chunks/5-CA1SA6KZ.js +9 -0
  155. package/build/server/chunks/5-CA1SA6KZ.js.map +1 -0
  156. package/build/server/chunks/6-71H221sV.js +9 -0
  157. package/build/server/chunks/6-71H221sV.js.map +1 -0
  158. package/build/server/chunks/7-Bo-vmdyz.js +9 -0
  159. package/build/server/chunks/7-Bo-vmdyz.js.map +1 -0
  160. package/build/server/chunks/_layout.svelte-SFHOxs74.js +132 -0
  161. package/build/server/chunks/_layout.svelte-SFHOxs74.js.map +1 -0
  162. package/build/server/chunks/_page.svelte-B4w-2wD-.js +120 -0
  163. package/build/server/chunks/_page.svelte-B4w-2wD-.js.map +1 -0
  164. package/build/server/chunks/_page.svelte-B_qAXjkh.js +213 -0
  165. package/build/server/chunks/_page.svelte-B_qAXjkh.js.map +1 -0
  166. package/build/server/chunks/_page.svelte-CsF1_TRG.js +50 -0
  167. package/build/server/chunks/_page.svelte-CsF1_TRG.js.map +1 -0
  168. package/build/server/chunks/_page.svelte-DJC6U-P0.js +68 -0
  169. package/build/server/chunks/_page.svelte-DJC6U-P0.js.map +1 -0
  170. package/build/server/chunks/_page.svelte-DQ6HBtsz.js +407 -0
  171. package/build/server/chunks/_page.svelte-DQ6HBtsz.js.map +1 -0
  172. package/build/server/chunks/_page.svelte-LbhhjP21.js +148 -0
  173. package/build/server/chunks/_page.svelte-LbhhjP21.js.map +1 -0
  174. package/build/server/chunks/_server.ts-BL2FGb5Z.js +387 -0
  175. package/build/server/chunks/_server.ts-BL2FGb5Z.js.map +1 -0
  176. package/build/server/chunks/_server.ts-BgdjBZco.js +47 -0
  177. package/build/server/chunks/_server.ts-BgdjBZco.js.map +1 -0
  178. package/build/server/chunks/_server.ts-BihKSdj_.js +59 -0
  179. package/build/server/chunks/_server.ts-BihKSdj_.js.map +1 -0
  180. package/build/server/chunks/_server.ts-BjOJsoy4.js +63 -0
  181. package/build/server/chunks/_server.ts-BjOJsoy4.js.map +1 -0
  182. package/build/server/chunks/_server.ts-C29xzfaw.js +77 -0
  183. package/build/server/chunks/_server.ts-C29xzfaw.js.map +1 -0
  184. package/build/server/chunks/_server.ts-CPa6DgIt.js +71 -0
  185. package/build/server/chunks/_server.ts-CPa6DgIt.js.map +1 -0
  186. package/build/server/chunks/_server.ts-CbDRDIoP.js +36 -0
  187. package/build/server/chunks/_server.ts-CbDRDIoP.js.map +1 -0
  188. package/build/server/chunks/_server.ts-Cl1OEWL4.js +54 -0
  189. package/build/server/chunks/_server.ts-Cl1OEWL4.js.map +1 -0
  190. package/build/server/chunks/_server.ts-ColfDHW8.js +60 -0
  191. package/build/server/chunks/_server.ts-ColfDHW8.js.map +1 -0
  192. package/build/server/chunks/_server.ts-Cv_OrRuL.js +494 -0
  193. package/build/server/chunks/_server.ts-Cv_OrRuL.js.map +1 -0
  194. package/build/server/chunks/_server.ts-D4MNi4cD.js +25 -0
  195. package/build/server/chunks/_server.ts-D4MNi4cD.js.map +1 -0
  196. package/build/server/chunks/_server.ts-DRVbgm6k.js +125 -0
  197. package/build/server/chunks/_server.ts-DRVbgm6k.js.map +1 -0
  198. package/build/server/chunks/_server.ts-DfajWaqh.js +39 -0
  199. package/build/server/chunks/_server.ts-DfajWaqh.js.map +1 -0
  200. package/build/server/chunks/_server.ts-y9-WYDMa.js +35 -0
  201. package/build/server/chunks/_server.ts-y9-WYDMa.js.map +1 -0
  202. package/build/server/chunks/auth-CEgFis71.js +32 -0
  203. package/build/server/chunks/auth-CEgFis71.js.map +1 -0
  204. package/build/server/chunks/client-CxCatAKr.js +255 -0
  205. package/build/server/chunks/client-CxCatAKr.js.map +1 -0
  206. package/build/server/chunks/error.svelte-BqdwMWdK.js +26 -0
  207. package/build/server/chunks/error.svelte-BqdwMWdK.js.map +1 -0
  208. package/build/server/chunks/exports-CJ0Q5XmL.js +4081 -0
  209. package/build/server/chunks/exports-CJ0Q5XmL.js.map +1 -0
  210. package/build/server/chunks/index2-DAxIoAO-.js +36 -0
  211. package/build/server/chunks/index2-DAxIoAO-.js.map +1 -0
  212. package/build/server/chunks/jsonl-parser-dmZU_Hyu.js +137 -0
  213. package/build/server/chunks/jsonl-parser-dmZU_Hyu.js.map +1 -0
  214. package/build/server/chunks/library-apns-BHxLmuIx.js +104 -0
  215. package/build/server/chunks/library-apns-BHxLmuIx.js.map +1 -0
  216. package/build/server/chunks/markdown-Bxrl3cCF.js +1241 -0
  217. package/build/server/chunks/markdown-Bxrl3cCF.js.map +1 -0
  218. package/build/server/chunks/pending-requests-D8UiTw7L.js +44 -0
  219. package/build/server/chunks/pending-requests-D8UiTw7L.js.map +1 -0
  220. package/build/server/chunks/pty-manager-C0FhBiVq.js +1697 -0
  221. package/build/server/chunks/pty-manager-C0FhBiVq.js.map +1 -0
  222. package/build/server/chunks/shared-server-BDY8jh20.js +200 -0
  223. package/build/server/chunks/shared-server-BDY8jh20.js.map +1 -0
  224. package/build/server/chunks/stores-D0HorpgL.js +36 -0
  225. package/build/server/chunks/stores-D0HorpgL.js.map +1 -0
  226. package/build/server/index.js +6466 -0
  227. package/build/server/index.js.map +1 -0
  228. package/build/server/manifest.js +184 -0
  229. package/build/server/manifest.js.map +1 -0
  230. package/build/shims.js +32 -0
  231. package/package.json +94 -0
  232. package/scripts/clipboard-shims/wl-paste +48 -0
  233. package/scripts/clipboard-shims/xclip +31 -0
  234. package/scripts/install.sh +477 -0
  235. package/scripts/setup-node-pty.sh +63 -0
  236. package/scripts/setup.cjs +571 -0
  237. package/scripts/test-runner.ts +243 -0
  238. package/scripts/vercel-env-commands.sh +60 -0
  239. package/server.ts +139 -0
  240. package/src/app.css +1835 -0
  241. package/src/app.d.ts +31 -0
  242. package/src/app.html +24 -0
  243. package/src/generated/types/APN.ts +305 -0
  244. package/src/generated/types/CLI.ts +52 -0
  245. package/src/generated/types/JWT.ts +92 -0
  246. package/src/generated/types/Terminal.ts +2736 -0
  247. package/src/generated/types/index.ts +6 -0
  248. package/src/lib/assets/icons/alert-triangle.svg +5 -0
  249. package/src/lib/assets/icons/bell.svg +4 -0
  250. package/src/lib/assets/icons/check-circle.svg +4 -0
  251. package/src/lib/assets/icons/file.svg +4 -0
  252. package/src/lib/assets/icons/folder.svg +3 -0
  253. package/src/lib/assets/icons/play.svg +3 -0
  254. package/src/lib/assets/icons/refresh.svg +4 -0
  255. package/src/lib/assets/icons/settings.svg +4 -0
  256. package/src/lib/assets/icons/terminal.svg +1 -0
  257. package/src/lib/assets/icons/tool.svg +3 -0
  258. package/src/lib/assets/icons/x-circle.svg +5 -0
  259. package/src/lib/modules/client/common/Card.svelte +26 -0
  260. package/src/lib/modules/client/common/EmptyState.svelte +36 -0
  261. package/src/lib/modules/client/common/Icon.svelte +61 -0
  262. package/src/lib/modules/client/common/StatusBadge.svelte +38 -0
  263. package/src/lib/modules/client/common/cache.ts +31 -0
  264. package/src/lib/modules/client/common/config-guard.ts +18 -0
  265. package/src/lib/modules/client/common/index.ts +12 -0
  266. package/src/lib/modules/client/common/markdown.ts +23 -0
  267. package/src/lib/modules/client/common/native-bridge.ts +50 -0
  268. package/src/lib/modules/client/common/time.ts +22 -0
  269. package/src/lib/modules/client/common/tool-title.ts +28 -0
  270. package/src/lib/modules/client/terminal/ChatView.svelte +400 -0
  271. package/src/lib/modules/client/terminal/CommandPalette.svelte +60 -0
  272. package/src/lib/modules/client/terminal/ConnectionStatus.svelte +99 -0
  273. package/src/lib/modules/client/terminal/LaunchSheet.svelte +294 -0
  274. package/src/lib/modules/client/terminal/QuickKeys.svelte +71 -0
  275. package/src/lib/modules/client/terminal/ShortcutsHelp.svelte +79 -0
  276. package/src/lib/modules/client/terminal/keyboard-shortcuts.ts +70 -0
  277. package/src/lib/modules/client/terminal/xterm-wrapper.ts +243 -0
  278. package/src/lib/modules/server/apn/library-apns.ts +137 -0
  279. package/src/lib/modules/server/apn/notification-history.ts +35 -0
  280. package/src/lib/modules/server/apn/notification-sessions.ts +117 -0
  281. package/src/lib/modules/server/apn/pending-requests.ts +65 -0
  282. package/src/lib/modules/server/apn/types.ts +51 -0
  283. package/src/lib/modules/server/auth.ts +34 -0
  284. package/src/lib/modules/server/cli/index.ts +79 -0
  285. package/src/lib/modules/server/cli/runner.ts +162 -0
  286. package/src/lib/modules/server/fcm/fcm-service.ts +72 -0
  287. package/src/lib/modules/server/sessions/jsonl-parser.ts +197 -0
  288. package/src/lib/modules/server/sessions/jsonl-reader.ts +301 -0
  289. package/src/lib/modules/server/sessions/opencode-reader.ts +264 -0
  290. package/src/lib/modules/server/sessions/types.ts +53 -0
  291. package/src/lib/modules/server/terminal/holder-client.ts +273 -0
  292. package/src/lib/modules/server/terminal/opencode-watcher.ts +661 -0
  293. package/src/lib/modules/server/terminal/pty-holder.cjs +510 -0
  294. package/src/lib/modules/server/terminal/pty-manager.ts +1012 -0
  295. package/src/lib/modules/server/terminal/session-watcher.ts +320 -0
  296. package/src/lib/modules/server/terminal/terminal-store.ts +198 -0
  297. package/src/lib/modules/server/ws/events-handler.ts +73 -0
  298. package/src/lib/modules/server/ws/keepalive.ts +108 -0
  299. package/src/lib/modules/server/ws/server.ts +93 -0
  300. package/src/lib/modules/server/ws/session-handler.ts +462 -0
  301. package/src/lib/modules/server/ws/terminal-handler.ts +197 -0
  302. package/src/lib/modules/server/ws/ticket-store.ts +58 -0
  303. package/src/lib/theme.css +529 -0
  304. package/src/lib/types/config.ts +6 -0
  305. package/src/routes/+layout.svelte +218 -0
  306. package/src/routes/+page.svelte +261 -0
  307. package/src/routes/api/debug/+server.ts +33 -0
  308. package/src/routes/api/device-token/+server.ts +85 -0
  309. package/src/routes/api/health/+server.ts +100 -0
  310. package/src/routes/api/notify/+server.ts +418 -0
  311. package/src/routes/api/qr-config/+server.ts +45 -0
  312. package/src/routes/api/response/+server.ts +73 -0
  313. package/src/routes/api/sessions/+server.ts +120 -0
  314. package/src/routes/api/terminals/+server.ts +141 -0
  315. package/src/routes/api/terminals/[id]/+server.ts +75 -0
  316. package/src/routes/api/terminals/[id]/paste-image/+server.ts +61 -0
  317. package/src/routes/api/terminals/[id]/resize/+server.ts +60 -0
  318. package/src/routes/api/webhook/+server.ts +42 -0
  319. package/src/routes/api/ws-status/+server.ts +23 -0
  320. package/src/routes/api/ws-ticket/+server.ts +86 -0
  321. package/src/routes/config/+page.svelte +600 -0
  322. package/src/routes/project/+page.svelte +274 -0
  323. package/src/routes/session/[id]/+page.svelte +434 -0
  324. package/src/routes/terminals/+page.svelte +618 -0
  325. package/src/routes/terminals/[id]/+page.svelte +968 -0
  326. package/svelte.config.js +18 -0
  327. package/tsconfig.json +14 -0
@@ -0,0 +1,4081 @@
1
+ const DEV = true;
2
+
3
+ // eslint-disable-next-line n/prefer-global/process
4
+ const IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
5
+
6
+ /** @import { RequestEvent } from '@sveltejs/kit' */
7
+ /** @import { RequestStore } from 'types' */
8
+ /** @import { AsyncLocalStorage } from 'node:async_hooks' */
9
+
10
+
11
+ /** @type {RequestStore | null} */
12
+ let sync_store = null;
13
+
14
+ /** @type {AsyncLocalStorage<RequestStore | null> | null} */
15
+ let als$1;
16
+
17
+ import('node:async_hooks')
18
+ .then((hooks) => (als$1 = new hooks.AsyncLocalStorage()))
19
+ .catch(() => {
20
+ // can't use AsyncLocalStorage, but can still call getRequestEvent synchronously.
21
+ // this isn't behind `supports` because it's basically just StackBlitz (i.e.
22
+ // in-browser usage) that doesn't support it AFAICT
23
+ });
24
+
25
+ function try_get_request_store() {
26
+ return sync_store ?? als$1?.getStore() ?? null;
27
+ }
28
+
29
+ /**
30
+ * @template T
31
+ * @param {RequestStore | null} store
32
+ * @param {() => T} fn
33
+ */
34
+ function with_request_store(store, fn) {
35
+ try {
36
+ sync_store = store;
37
+ return als$1 ? als$1.run(store, fn) : fn();
38
+ } finally {
39
+ // Since AsyncLocalStorage is not working in webcontainers, we don't reset `sync_store`
40
+ // and handle only one request at a time in `src/runtime/server/index.js`.
41
+ if (!IN_WEBCONTAINER) {
42
+ sync_store = null;
43
+ }
44
+ }
45
+ }
46
+
47
+ /** @type {Record<string, string>} */
48
+ const escaped = {
49
+ '<': '\\u003C',
50
+ '\\': '\\\\',
51
+ '\b': '\\b',
52
+ '\f': '\\f',
53
+ '\n': '\\n',
54
+ '\r': '\\r',
55
+ '\t': '\\t',
56
+ '\u2028': '\\u2028',
57
+ '\u2029': '\\u2029'
58
+ };
59
+
60
+ class DevalueError extends Error {
61
+ /**
62
+ * @param {string} message
63
+ * @param {string[]} keys
64
+ */
65
+ constructor(message, keys) {
66
+ super(message);
67
+ this.name = 'DevalueError';
68
+ this.path = keys.join('');
69
+ }
70
+ }
71
+
72
+ /** @param {any} thing */
73
+ function is_primitive(thing) {
74
+ return Object(thing) !== thing;
75
+ }
76
+
77
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
78
+ Object.prototype
79
+ )
80
+ .sort()
81
+ .join('\0');
82
+
83
+ /** @param {any} thing */
84
+ function is_plain_object(thing) {
85
+ const proto = Object.getPrototypeOf(thing);
86
+
87
+ return (
88
+ proto === Object.prototype ||
89
+ proto === null ||
90
+ Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
91
+ );
92
+ }
93
+
94
+ /** @param {any} thing */
95
+ function get_type(thing) {
96
+ return Object.prototype.toString.call(thing).slice(8, -1);
97
+ }
98
+
99
+ /** @param {string} char */
100
+ function get_escaped_char(char) {
101
+ switch (char) {
102
+ case '"':
103
+ return '\\"';
104
+ case '<':
105
+ return '\\u003C';
106
+ case '\\':
107
+ return '\\\\';
108
+ case '\n':
109
+ return '\\n';
110
+ case '\r':
111
+ return '\\r';
112
+ case '\t':
113
+ return '\\t';
114
+ case '\b':
115
+ return '\\b';
116
+ case '\f':
117
+ return '\\f';
118
+ case '\u2028':
119
+ return '\\u2028';
120
+ case '\u2029':
121
+ return '\\u2029';
122
+ default:
123
+ return char < ' '
124
+ ? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`
125
+ : '';
126
+ }
127
+ }
128
+
129
+ /** @param {string} str */
130
+ function stringify_string(str) {
131
+ let result = '';
132
+ let last_pos = 0;
133
+ const len = str.length;
134
+
135
+ for (let i = 0; i < len; i += 1) {
136
+ const char = str[i];
137
+ const replacement = get_escaped_char(char);
138
+ if (replacement) {
139
+ result += str.slice(last_pos, i) + replacement;
140
+ last_pos = i + 1;
141
+ }
142
+ }
143
+
144
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
145
+ }
146
+
147
+ /** @param {Record<string | symbol, any>} object */
148
+ function enumerable_symbols(object) {
149
+ return Object.getOwnPropertySymbols(object).filter(
150
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
151
+ );
152
+ }
153
+
154
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
155
+
156
+ /** @param {string} key */
157
+ function stringify_key(key) {
158
+ return is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';
159
+ }
160
+
161
+ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
162
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
163
+ const reserved =
164
+ /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
165
+
166
+ /**
167
+ * Turn a value into the JavaScript that creates an equivalent value
168
+ * @param {any} value
169
+ * @param {(value: any) => string | void} [replacer]
170
+ */
171
+ function uneval(value, replacer) {
172
+ const counts = new Map();
173
+
174
+ /** @type {string[]} */
175
+ const keys = [];
176
+
177
+ const custom = new Map();
178
+
179
+ /** @param {any} thing */
180
+ function walk(thing) {
181
+ if (typeof thing === 'function') {
182
+ throw new DevalueError(`Cannot stringify a function`, keys);
183
+ }
184
+
185
+ if (!is_primitive(thing)) {
186
+ if (counts.has(thing)) {
187
+ counts.set(thing, counts.get(thing) + 1);
188
+ return;
189
+ }
190
+
191
+ counts.set(thing, 1);
192
+
193
+ if (replacer) {
194
+ const str = replacer(thing);
195
+
196
+ if (typeof str === 'string') {
197
+ custom.set(thing, str);
198
+ return;
199
+ }
200
+ }
201
+
202
+ const type = get_type(thing);
203
+
204
+ switch (type) {
205
+ case 'Number':
206
+ case 'BigInt':
207
+ case 'String':
208
+ case 'Boolean':
209
+ case 'Date':
210
+ case 'RegExp':
211
+ return;
212
+
213
+ case 'Array':
214
+ /** @type {any[]} */ (thing).forEach((value, i) => {
215
+ keys.push(`[${i}]`);
216
+ walk(value);
217
+ keys.pop();
218
+ });
219
+ break;
220
+
221
+ case 'Set':
222
+ Array.from(thing).forEach(walk);
223
+ break;
224
+
225
+ case 'Map':
226
+ for (const [key, value] of thing) {
227
+ keys.push(
228
+ `.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`
229
+ );
230
+ walk(value);
231
+ keys.pop();
232
+ }
233
+ break;
234
+
235
+ case "Int8Array":
236
+ case "Uint8Array":
237
+ case "Uint8ClampedArray":
238
+ case "Int16Array":
239
+ case "Uint16Array":
240
+ case "Int32Array":
241
+ case "Uint32Array":
242
+ case "Float32Array":
243
+ case "Float64Array":
244
+ case "BigInt64Array":
245
+ case "BigUint64Array":
246
+ return;
247
+
248
+ case "ArrayBuffer":
249
+ return;
250
+
251
+ default:
252
+ if (!is_plain_object(thing)) {
253
+ throw new DevalueError(
254
+ `Cannot stringify arbitrary non-POJOs`,
255
+ keys
256
+ );
257
+ }
258
+
259
+ if (enumerable_symbols(thing).length > 0) {
260
+ throw new DevalueError(
261
+ `Cannot stringify POJOs with symbolic keys`,
262
+ keys
263
+ );
264
+ }
265
+
266
+ for (const key in thing) {
267
+ keys.push(stringify_key(key));
268
+ walk(thing[key]);
269
+ keys.pop();
270
+ }
271
+ }
272
+ }
273
+ }
274
+
275
+ walk(value);
276
+
277
+ const names = new Map();
278
+
279
+ Array.from(counts)
280
+ .filter((entry) => entry[1] > 1)
281
+ .sort((a, b) => b[1] - a[1])
282
+ .forEach((entry, i) => {
283
+ names.set(entry[0], get_name(i));
284
+ });
285
+
286
+ /**
287
+ * @param {any} thing
288
+ * @returns {string}
289
+ */
290
+ function stringify(thing) {
291
+ if (names.has(thing)) {
292
+ return names.get(thing);
293
+ }
294
+
295
+ if (is_primitive(thing)) {
296
+ return stringify_primitive(thing);
297
+ }
298
+
299
+ if (custom.has(thing)) {
300
+ return custom.get(thing);
301
+ }
302
+
303
+ const type = get_type(thing);
304
+
305
+ switch (type) {
306
+ case 'Number':
307
+ case 'String':
308
+ case 'Boolean':
309
+ return `Object(${stringify(thing.valueOf())})`;
310
+
311
+ case 'RegExp':
312
+ return `new RegExp(${stringify_string(thing.source)}, "${
313
+ thing.flags
314
+ }")`;
315
+
316
+ case 'Date':
317
+ return `new Date(${thing.getTime()})`;
318
+
319
+ case 'Array':
320
+ const members = /** @type {any[]} */ (thing).map((v, i) =>
321
+ i in thing ? stringify(v) : ''
322
+ );
323
+ const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
324
+ return `[${members.join(',')}${tail}]`;
325
+
326
+ case 'Set':
327
+ case 'Map':
328
+ return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
329
+
330
+ case "Int8Array":
331
+ case "Uint8Array":
332
+ case "Uint8ClampedArray":
333
+ case "Int16Array":
334
+ case "Uint16Array":
335
+ case "Int32Array":
336
+ case "Uint32Array":
337
+ case "Float32Array":
338
+ case "Float64Array":
339
+ case "BigInt64Array":
340
+ case "BigUint64Array": {
341
+ /** @type {import("./types.js").TypedArray} */
342
+ const typedArray = thing;
343
+ return `new ${type}([${typedArray.toString()}])`;
344
+ }
345
+
346
+ case "ArrayBuffer": {
347
+ const ui8 = new Uint8Array(thing);
348
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
349
+ }
350
+
351
+ default:
352
+ const obj = `{${Object.keys(thing)
353
+ .map((key) => `${safe_key(key)}:${stringify(thing[key])}`)
354
+ .join(',')}}`;
355
+ const proto = Object.getPrototypeOf(thing);
356
+ if (proto === null) {
357
+ return Object.keys(thing).length > 0
358
+ ? `Object.assign(Object.create(null),${obj})`
359
+ : `Object.create(null)`;
360
+ }
361
+
362
+ return obj;
363
+ }
364
+ }
365
+
366
+ const str = stringify(value);
367
+
368
+ if (names.size) {
369
+ /** @type {string[]} */
370
+ const params = [];
371
+
372
+ /** @type {string[]} */
373
+ const statements = [];
374
+
375
+ /** @type {string[]} */
376
+ const values = [];
377
+
378
+ names.forEach((name, thing) => {
379
+ params.push(name);
380
+
381
+ if (custom.has(thing)) {
382
+ values.push(/** @type {string} */ (custom.get(thing)));
383
+ return;
384
+ }
385
+
386
+ if (is_primitive(thing)) {
387
+ values.push(stringify_primitive(thing));
388
+ return;
389
+ }
390
+
391
+ const type = get_type(thing);
392
+
393
+ switch (type) {
394
+ case 'Number':
395
+ case 'String':
396
+ case 'Boolean':
397
+ values.push(`Object(${stringify(thing.valueOf())})`);
398
+ break;
399
+
400
+ case 'RegExp':
401
+ values.push(thing.toString());
402
+ break;
403
+
404
+ case 'Date':
405
+ values.push(`new Date(${thing.getTime()})`);
406
+ break;
407
+
408
+ case 'Array':
409
+ values.push(`Array(${thing.length})`);
410
+ /** @type {any[]} */ (thing).forEach((v, i) => {
411
+ statements.push(`${name}[${i}]=${stringify(v)}`);
412
+ });
413
+ break;
414
+
415
+ case 'Set':
416
+ values.push(`new Set`);
417
+ statements.push(
418
+ `${name}.${Array.from(thing)
419
+ .map((v) => `add(${stringify(v)})`)
420
+ .join('.')}`
421
+ );
422
+ break;
423
+
424
+ case 'Map':
425
+ values.push(`new Map`);
426
+ statements.push(
427
+ `${name}.${Array.from(thing)
428
+ .map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)
429
+ .join('.')}`
430
+ );
431
+ break;
432
+
433
+ default:
434
+ values.push(
435
+ Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'
436
+ );
437
+ Object.keys(thing).forEach((key) => {
438
+ statements.push(
439
+ `${name}${safe_prop(key)}=${stringify(thing[key])}`
440
+ );
441
+ });
442
+ }
443
+ });
444
+
445
+ statements.push(`return ${str}`);
446
+
447
+ return `(function(${params.join(',')}){${statements.join(
448
+ ';'
449
+ )}}(${values.join(',')}))`;
450
+ } else {
451
+ return str;
452
+ }
453
+ }
454
+
455
+ /** @param {number} num */
456
+ function get_name(num) {
457
+ let name = '';
458
+
459
+ do {
460
+ name = chars[num % chars.length] + name;
461
+ num = ~~(num / chars.length) - 1;
462
+ } while (num >= 0);
463
+
464
+ return reserved.test(name) ? `${name}0` : name;
465
+ }
466
+
467
+ /** @param {string} c */
468
+ function escape_unsafe_char(c) {
469
+ return escaped[c] || c;
470
+ }
471
+
472
+ /** @param {string} str */
473
+ function escape_unsafe_chars(str) {
474
+ return str.replace(unsafe_chars, escape_unsafe_char);
475
+ }
476
+
477
+ /** @param {string} key */
478
+ function safe_key(key) {
479
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
480
+ ? key
481
+ : escape_unsafe_chars(JSON.stringify(key));
482
+ }
483
+
484
+ /** @param {string} key */
485
+ function safe_prop(key) {
486
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
487
+ ? `.${key}`
488
+ : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
489
+ }
490
+
491
+ /** @param {any} thing */
492
+ function stringify_primitive(thing) {
493
+ if (typeof thing === 'string') return stringify_string(thing);
494
+ if (thing === void 0) return 'void 0';
495
+ if (thing === 0 && 1 / thing < 0) return '-0';
496
+ const str = String(thing);
497
+ if (typeof thing === 'number') return str.replace(/^(-)?0\./, '$1.');
498
+ if (typeof thing === 'bigint') return thing + 'n';
499
+ return str;
500
+ }
501
+
502
+ const text_encoder$1 = new TextEncoder();
503
+ const text_decoder = new TextDecoder();
504
+ function get_relative_path(from, to) {
505
+ const from_parts = from.split(/[/\\]/);
506
+ const to_parts = to.split(/[/\\]/);
507
+ from_parts.pop();
508
+ while (from_parts[0] === to_parts[0]) {
509
+ from_parts.shift();
510
+ to_parts.shift();
511
+ }
512
+ let i = from_parts.length;
513
+ while (i--) from_parts[i] = "..";
514
+ return from_parts.concat(to_parts).join("/");
515
+ }
516
+ function base64_encode$1(bytes) {
517
+ if (globalThis.Buffer) {
518
+ return globalThis.Buffer.from(bytes).toString("base64");
519
+ }
520
+ let binary = "";
521
+ for (let i = 0; i < bytes.length; i++) {
522
+ binary += String.fromCharCode(bytes[i]);
523
+ }
524
+ return btoa(binary);
525
+ }
526
+ function base64_decode(encoded) {
527
+ if (globalThis.Buffer) {
528
+ const buffer = globalThis.Buffer.from(encoded, "base64");
529
+ return new Uint8Array(buffer);
530
+ }
531
+ const binary = atob(encoded);
532
+ const bytes = new Uint8Array(binary.length);
533
+ for (let i = 0; i < binary.length; i++) {
534
+ bytes[i] = binary.charCodeAt(i);
535
+ }
536
+ return bytes;
537
+ }
538
+
539
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx$1(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
540
+
541
+ var is_array = Array.isArray;
542
+ var index_of = Array.prototype.indexOf;
543
+ var includes = Array.prototype.includes;
544
+ var array_from = Array.from;
545
+ var define_property = Object.defineProperty;
546
+ var get_descriptor = Object.getOwnPropertyDescriptor;
547
+ var object_prototype = Object.prototype;
548
+ var array_prototype = Array.prototype;
549
+ var get_prototype_of = Object.getPrototypeOf;
550
+ var is_extensible = Object.isExtensible;
551
+ const noop = () => {
552
+ };
553
+ function run_all(arr) {
554
+ for (var i = 0; i < arr.length; i++) {
555
+ arr[i]();
556
+ }
557
+ }
558
+ function deferred() {
559
+ var resolve;
560
+ var reject;
561
+ var promise = new Promise((res, rej) => {
562
+ resolve = res;
563
+ reject = rej;
564
+ });
565
+ return { promise, resolve, reject };
566
+ }
567
+ function equals(value) {
568
+ return value === this.v;
569
+ }
570
+ function safe_not_equal(a, b) {
571
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
572
+ }
573
+ function safe_equals(value) {
574
+ return !safe_not_equal(value, this.v);
575
+ }
576
+ const DERIVED = 1 << 1;
577
+ const EFFECT = 1 << 2;
578
+ const RENDER_EFFECT = 1 << 3;
579
+ const MANAGED_EFFECT = 1 << 24;
580
+ const BLOCK_EFFECT = 1 << 4;
581
+ const BRANCH_EFFECT = 1 << 5;
582
+ const ROOT_EFFECT = 1 << 6;
583
+ const BOUNDARY_EFFECT = 1 << 7;
584
+ const CONNECTED = 1 << 9;
585
+ const CLEAN = 1 << 10;
586
+ const DIRTY = 1 << 11;
587
+ const MAYBE_DIRTY = 1 << 12;
588
+ const INERT = 1 << 13;
589
+ const DESTROYED = 1 << 14;
590
+ const EFFECT_RAN = 1 << 15;
591
+ const EFFECT_TRANSPARENT = 1 << 16;
592
+ const EAGER_EFFECT = 1 << 17;
593
+ const HEAD_EFFECT = 1 << 18;
594
+ const EFFECT_PRESERVED = 1 << 19;
595
+ const USER_EFFECT = 1 << 20;
596
+ const WAS_MARKED = 1 << 15;
597
+ const REACTION_IS_UPDATING = 1 << 21;
598
+ const ASYNC = 1 << 22;
599
+ const ERROR_VALUE = 1 << 23;
600
+ const STATE_SYMBOL = /* @__PURE__ */ Symbol("$state");
601
+ const LEGACY_PROPS = /* @__PURE__ */ Symbol("legacy props");
602
+ const PROXY_PATH_SYMBOL = /* @__PURE__ */ Symbol("proxy path");
603
+ const STALE_REACTION = new class StaleReactionError extends Error {
604
+ name = "StaleReactionError";
605
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
606
+ }();
607
+ const COMMENT_NODE = 8;
608
+ function invalid_snippet_arguments() {
609
+ {
610
+ const error = new Error(`invalid_snippet_arguments
611
+ A snippet function was passed invalid arguments. Snippets should only be instantiated via \`{@render ...}\`
612
+ https://svelte.dev/e/invalid_snippet_arguments`);
613
+ error.name = "Svelte error";
614
+ throw error;
615
+ }
616
+ }
617
+ function lifecycle_outside_component(name) {
618
+ {
619
+ const error = new Error(`lifecycle_outside_component
620
+ \`${name}(...)\` can only be used during component initialisation
621
+ https://svelte.dev/e/lifecycle_outside_component`);
622
+ error.name = "Svelte error";
623
+ throw error;
624
+ }
625
+ }
626
+ function snippet_without_render_tag() {
627
+ {
628
+ const error = new Error(`snippet_without_render_tag
629
+ Attempted to render a snippet without a \`{@render}\` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change \`{snippet}\` to \`{@render snippet()}\`.
630
+ https://svelte.dev/e/snippet_without_render_tag`);
631
+ error.name = "Svelte error";
632
+ throw error;
633
+ }
634
+ }
635
+ function store_invalid_shape(name) {
636
+ {
637
+ const error = new Error(`store_invalid_shape
638
+ \`${name}\` is not a store with a \`subscribe\` method
639
+ https://svelte.dev/e/store_invalid_shape`);
640
+ error.name = "Svelte error";
641
+ throw error;
642
+ }
643
+ }
644
+ function derived_references_self() {
645
+ {
646
+ const error = new Error(`derived_references_self
647
+ A derived value cannot reference itself recursively
648
+ https://svelte.dev/e/derived_references_self`);
649
+ error.name = "Svelte error";
650
+ throw error;
651
+ }
652
+ }
653
+ function effect_update_depth_exceeded() {
654
+ {
655
+ const error = new Error(`effect_update_depth_exceeded
656
+ Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
657
+ https://svelte.dev/e/effect_update_depth_exceeded`);
658
+ error.name = "Svelte error";
659
+ throw error;
660
+ }
661
+ }
662
+ function hydration_failed() {
663
+ {
664
+ const error = new Error(`hydration_failed
665
+ Failed to hydrate the application
666
+ https://svelte.dev/e/hydration_failed`);
667
+ error.name = "Svelte error";
668
+ throw error;
669
+ }
670
+ }
671
+ function rune_outside_svelte(rune) {
672
+ {
673
+ const error = new Error(`rune_outside_svelte
674
+ The \`${rune}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
675
+ https://svelte.dev/e/rune_outside_svelte`);
676
+ error.name = "Svelte error";
677
+ throw error;
678
+ }
679
+ }
680
+ function state_descriptors_fixed() {
681
+ {
682
+ const error = new Error(`state_descriptors_fixed
683
+ Property descriptors defined on \`$state\` objects must contain \`value\` and always be \`enumerable\`, \`configurable\` and \`writable\`.
684
+ https://svelte.dev/e/state_descriptors_fixed`);
685
+ error.name = "Svelte error";
686
+ throw error;
687
+ }
688
+ }
689
+ function state_prototype_fixed() {
690
+ {
691
+ const error = new Error(`state_prototype_fixed
692
+ Cannot set prototype of \`$state\` object
693
+ https://svelte.dev/e/state_prototype_fixed`);
694
+ error.name = "Svelte error";
695
+ throw error;
696
+ }
697
+ }
698
+ function state_unsafe_mutation() {
699
+ {
700
+ const error = new Error(`state_unsafe_mutation
701
+ Updating state inside \`$derived(...)\`, \`$inspect(...)\` or a template expression is forbidden. If the value should not be reactive, declare it without \`$state\`
702
+ https://svelte.dev/e/state_unsafe_mutation`);
703
+ error.name = "Svelte error";
704
+ throw error;
705
+ }
706
+ }
707
+ function svelte_boundary_reset_onerror() {
708
+ {
709
+ const error = new Error(`svelte_boundary_reset_onerror
710
+ A \`<svelte:boundary>\` \`reset\` function cannot be called while an error is still being handled
711
+ https://svelte.dev/e/svelte_boundary_reset_onerror`);
712
+ error.name = "Svelte error";
713
+ throw error;
714
+ }
715
+ }
716
+ const HYDRATION_START = "[";
717
+ const HYDRATION_START_ELSE = "[!";
718
+ const HYDRATION_END = "]";
719
+ const HYDRATION_ERROR = {};
720
+ const ELEMENT_IS_NAMESPACED = 1;
721
+ const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1;
722
+ const ELEMENT_IS_INPUT = 1 << 2;
723
+ const UNINITIALIZED = /* @__PURE__ */ Symbol();
724
+ const FILENAME = /* @__PURE__ */ Symbol("filename");
725
+ var bold$1 = "font-weight: bold";
726
+ var normal$1 = "font-weight: normal";
727
+ function hydration_mismatch(location) {
728
+ {
729
+ console.warn(
730
+ `%c[svelte] hydration_mismatch
731
+ %c${"Hydration failed because the initial UI does not match what was rendered on the server"}
732
+ https://svelte.dev/e/hydration_mismatch`,
733
+ bold$1,
734
+ normal$1
735
+ );
736
+ }
737
+ }
738
+ function lifecycle_double_unmount() {
739
+ {
740
+ console.warn(`%c[svelte] lifecycle_double_unmount
741
+ %cTried to unmount a component that was not mounted
742
+ https://svelte.dev/e/lifecycle_double_unmount`, bold$1, normal$1);
743
+ }
744
+ }
745
+ function state_proxy_equality_mismatch(operator) {
746
+ {
747
+ console.warn(`%c[svelte] state_proxy_equality_mismatch
748
+ %cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${operator}\` will produce unexpected results
749
+ https://svelte.dev/e/state_proxy_equality_mismatch`, bold$1, normal$1);
750
+ }
751
+ }
752
+ function state_proxy_unmount() {
753
+ {
754
+ console.warn(`%c[svelte] state_proxy_unmount
755
+ %cTried to unmount a state proxy, rather than a component
756
+ https://svelte.dev/e/state_proxy_unmount`, bold$1, normal$1);
757
+ }
758
+ }
759
+ function svelte_boundary_reset_noop() {
760
+ {
761
+ console.warn(`%c[svelte] svelte_boundary_reset_noop
762
+ %cA \`<svelte:boundary>\` \`reset\` function only resets the boundary the first time it is called
763
+ https://svelte.dev/e/svelte_boundary_reset_noop`, bold$1, normal$1);
764
+ }
765
+ }
766
+ let tracing_mode_flag = false;
767
+ function tag(source2, label) {
768
+ source2.label = label;
769
+ tag_proxy(source2.v, label);
770
+ return source2;
771
+ }
772
+ function tag_proxy(value, label) {
773
+ value?.[PROXY_PATH_SYMBOL]?.(label);
774
+ return value;
775
+ }
776
+ function get_error(label) {
777
+ const error = new Error();
778
+ const stack2 = get_stack();
779
+ if (stack2.length === 0) {
780
+ return null;
781
+ }
782
+ stack2.unshift("\n");
783
+ define_property(error, "stack", {
784
+ value: stack2.join("\n")
785
+ });
786
+ define_property(error, "name", {
787
+ value: label
788
+ });
789
+ return (
790
+ /** @type {Error & { stack: string }} */
791
+ error
792
+ );
793
+ }
794
+ function get_stack() {
795
+ const limit = Error.stackTraceLimit;
796
+ Error.stackTraceLimit = Infinity;
797
+ const stack2 = new Error().stack;
798
+ Error.stackTraceLimit = limit;
799
+ if (!stack2) return [];
800
+ const lines = stack2.split("\n");
801
+ const new_lines = [];
802
+ for (let i = 0; i < lines.length; i++) {
803
+ const line = lines[i];
804
+ const posixified = line.replaceAll("\\", "/");
805
+ if (line.trim() === "Error") {
806
+ continue;
807
+ }
808
+ if (line.includes("validate_each_keys")) {
809
+ return [];
810
+ }
811
+ if (posixified.includes("svelte/src/internal") || posixified.includes("node_modules/.vite")) {
812
+ continue;
813
+ }
814
+ new_lines.push(line);
815
+ }
816
+ return new_lines;
817
+ }
818
+ let component_context = null;
819
+ function set_component_context(context) {
820
+ component_context = context;
821
+ }
822
+ let dev_stack = null;
823
+ function set_dev_stack(stack2) {
824
+ dev_stack = stack2;
825
+ }
826
+ let dev_current_component_function = null;
827
+ function set_dev_current_component_function(fn) {
828
+ dev_current_component_function = fn;
829
+ }
830
+ function push$1(props, runes = false, fn) {
831
+ component_context = {
832
+ p: component_context,
833
+ i: false,
834
+ c: null,
835
+ e: null,
836
+ s: props,
837
+ x: null,
838
+ l: null
839
+ };
840
+ {
841
+ component_context.function = fn;
842
+ dev_current_component_function = fn;
843
+ }
844
+ }
845
+ function pop$1(component) {
846
+ var context = (
847
+ /** @type {ComponentContext} */
848
+ component_context
849
+ );
850
+ var effects = context.e;
851
+ if (effects !== null) {
852
+ context.e = null;
853
+ for (var fn of effects) {
854
+ create_user_effect(fn);
855
+ }
856
+ }
857
+ context.i = true;
858
+ component_context = context.p;
859
+ {
860
+ dev_current_component_function = component_context?.function ?? null;
861
+ }
862
+ return (
863
+ /** @type {T} */
864
+ {}
865
+ );
866
+ }
867
+ function is_runes() {
868
+ return true;
869
+ }
870
+ let micro_tasks = [];
871
+ function run_micro_tasks() {
872
+ var tasks = micro_tasks;
873
+ micro_tasks = [];
874
+ run_all(tasks);
875
+ }
876
+ function queue_micro_task(fn) {
877
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
878
+ var tasks = micro_tasks;
879
+ queueMicrotask(() => {
880
+ if (tasks === micro_tasks) run_micro_tasks();
881
+ });
882
+ }
883
+ micro_tasks.push(fn);
884
+ }
885
+ function flush_tasks() {
886
+ while (micro_tasks.length > 0) {
887
+ run_micro_tasks();
888
+ }
889
+ }
890
+ const adjustments = /* @__PURE__ */ new WeakMap();
891
+ function handle_error(error) {
892
+ var effect = active_effect;
893
+ if (effect === null) {
894
+ active_reaction.f |= ERROR_VALUE;
895
+ return error;
896
+ }
897
+ if (error instanceof Error && !adjustments.has(error)) {
898
+ adjustments.set(error, get_adjustments(error, effect));
899
+ }
900
+ if ((effect.f & EFFECT_RAN) === 0) {
901
+ if ((effect.f & BOUNDARY_EFFECT) === 0) {
902
+ if (!effect.parent && error instanceof Error) {
903
+ apply_adjustments(error);
904
+ }
905
+ throw error;
906
+ }
907
+ effect.b.error(error);
908
+ } else {
909
+ invoke_error_boundary(error, effect);
910
+ }
911
+ }
912
+ function invoke_error_boundary(error, effect) {
913
+ while (effect !== null) {
914
+ if ((effect.f & BOUNDARY_EFFECT) !== 0) {
915
+ try {
916
+ effect.b.error(error);
917
+ return;
918
+ } catch (e) {
919
+ error = e;
920
+ }
921
+ }
922
+ effect = effect.parent;
923
+ }
924
+ if (error instanceof Error) {
925
+ apply_adjustments(error);
926
+ }
927
+ throw error;
928
+ }
929
+ function get_adjustments(error, effect) {
930
+ const message_descriptor = get_descriptor(error, "message");
931
+ if (message_descriptor && !message_descriptor.configurable) return;
932
+ var indent = is_firefox ? " " : " ";
933
+ var component_stack = `
934
+ ${indent}in ${effect.fn?.name || "<unknown>"}`;
935
+ var context = effect.ctx;
936
+ while (context !== null) {
937
+ component_stack += `
938
+ ${indent}in ${context.function?.[FILENAME].split("/").pop()}`;
939
+ context = context.p;
940
+ }
941
+ return {
942
+ message: error.message + `
943
+ ${component_stack}
944
+ `,
945
+ stack: error.stack?.split("\n").filter((line) => !line.includes("svelte/src/internal")).join("\n")
946
+ };
947
+ }
948
+ function apply_adjustments(error) {
949
+ const adjusted = adjustments.get(error);
950
+ if (adjusted) {
951
+ define_property(error, "message", {
952
+ value: adjusted.message
953
+ });
954
+ define_property(error, "stack", {
955
+ value: adjusted.stack
956
+ });
957
+ }
958
+ }
959
+ const STATUS_MASK = -7169;
960
+ function set_signal_status(signal, status) {
961
+ signal.f = signal.f & STATUS_MASK | status;
962
+ }
963
+ function update_derived_status(derived) {
964
+ if ((derived.f & CONNECTED) !== 0 || derived.deps === null) {
965
+ set_signal_status(derived, CLEAN);
966
+ } else {
967
+ set_signal_status(derived, MAYBE_DIRTY);
968
+ }
969
+ }
970
+ function clear_marked(deps) {
971
+ if (deps === null) return;
972
+ for (const dep of deps) {
973
+ if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) {
974
+ continue;
975
+ }
976
+ dep.f ^= WAS_MARKED;
977
+ clear_marked(
978
+ /** @type {Derived} */
979
+ dep.deps
980
+ );
981
+ }
982
+ }
983
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
984
+ if ((effect.f & DIRTY) !== 0) {
985
+ dirty_effects.add(effect);
986
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
987
+ maybe_dirty_effects.add(effect);
988
+ }
989
+ clear_marked(effect.deps);
990
+ set_signal_status(effect, CLEAN);
991
+ }
992
+ const batches = /* @__PURE__ */ new Set();
993
+ let current_batch = null;
994
+ let batch_values = null;
995
+ let queued_root_effects = [];
996
+ let last_scheduled_effect = null;
997
+ let is_flushing = false;
998
+ let is_flushing_sync = false;
999
+ class Batch {
1000
+ committed = false;
1001
+ /**
1002
+ * The current values of any sources that are updated in this batch
1003
+ * They keys of this map are identical to `this.#previous`
1004
+ * @type {Map<Source, any>}
1005
+ */
1006
+ current = /* @__PURE__ */ new Map();
1007
+ /**
1008
+ * The values of any sources that are updated in this batch _before_ those updates took place.
1009
+ * They keys of this map are identical to `this.#current`
1010
+ * @type {Map<Source, any>}
1011
+ */
1012
+ previous = /* @__PURE__ */ new Map();
1013
+ /**
1014
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
1015
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
1016
+ * @type {Set<() => void>}
1017
+ */
1018
+ #commit_callbacks = /* @__PURE__ */ new Set();
1019
+ /**
1020
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
1021
+ * @type {Set<(batch: Batch) => void>}
1022
+ */
1023
+ #discard_callbacks = /* @__PURE__ */ new Set();
1024
+ /**
1025
+ * The number of async effects that are currently in flight
1026
+ */
1027
+ #pending = 0;
1028
+ /**
1029
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
1030
+ */
1031
+ #blocking_pending = 0;
1032
+ /**
1033
+ * A deferred that resolves when the batch is committed, used with `settled()`
1034
+ * TODO replace with Promise.withResolvers once supported widely enough
1035
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
1036
+ */
1037
+ #deferred = null;
1038
+ /**
1039
+ * Deferred effects (which run after async work has completed) that are DIRTY
1040
+ * @type {Set<Effect>}
1041
+ */
1042
+ #dirty_effects = /* @__PURE__ */ new Set();
1043
+ /**
1044
+ * Deferred effects that are MAYBE_DIRTY
1045
+ * @type {Set<Effect>}
1046
+ */
1047
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
1048
+ /**
1049
+ * A set of branches that still exist, but will be destroyed when this batch
1050
+ * is committed — we skip over these during `process`
1051
+ * @type {Set<Effect>}
1052
+ */
1053
+ skipped_effects = /* @__PURE__ */ new Set();
1054
+ is_fork = false;
1055
+ #decrement_queued = false;
1056
+ is_deferred() {
1057
+ return this.is_fork || this.#blocking_pending > 0;
1058
+ }
1059
+ /**
1060
+ *
1061
+ * @param {Effect[]} root_effects
1062
+ */
1063
+ process(root_effects) {
1064
+ queued_root_effects = [];
1065
+ this.apply();
1066
+ var effects = [];
1067
+ var render_effects = [];
1068
+ for (const root of root_effects) {
1069
+ this.#traverse_effect_tree(root, effects, render_effects);
1070
+ }
1071
+ if (this.is_deferred()) {
1072
+ this.#defer_effects(render_effects);
1073
+ this.#defer_effects(effects);
1074
+ for (const e of this.skipped_effects) {
1075
+ reset_branch(e);
1076
+ }
1077
+ } else {
1078
+ for (const fn of this.#commit_callbacks) fn();
1079
+ this.#commit_callbacks.clear();
1080
+ if (this.#pending === 0) {
1081
+ this.#commit();
1082
+ }
1083
+ current_batch = null;
1084
+ flush_queued_effects(render_effects);
1085
+ flush_queued_effects(effects);
1086
+ this.#deferred?.resolve();
1087
+ }
1088
+ batch_values = null;
1089
+ }
1090
+ /**
1091
+ * Traverse the effect tree, executing effects or stashing
1092
+ * them for later execution as appropriate
1093
+ * @param {Effect} root
1094
+ * @param {Effect[]} effects
1095
+ * @param {Effect[]} render_effects
1096
+ */
1097
+ #traverse_effect_tree(root, effects, render_effects) {
1098
+ root.f ^= CLEAN;
1099
+ var effect = root.first;
1100
+ var pending_boundary = null;
1101
+ while (effect !== null) {
1102
+ var flags = effect.f;
1103
+ var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
1104
+ var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
1105
+ var skip = is_skippable_branch || (flags & INERT) !== 0 || this.skipped_effects.has(effect);
1106
+ if (!skip && effect.fn !== null) {
1107
+ if (is_branch) {
1108
+ effect.f ^= CLEAN;
1109
+ } else if (pending_boundary !== null && (flags & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0) {
1110
+ pending_boundary.b.defer_effect(effect);
1111
+ } else if ((flags & EFFECT) !== 0) {
1112
+ effects.push(effect);
1113
+ } else if (is_dirty(effect)) {
1114
+ if ((flags & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect);
1115
+ update_effect(effect);
1116
+ }
1117
+ var child = effect.first;
1118
+ if (child !== null) {
1119
+ effect = child;
1120
+ continue;
1121
+ }
1122
+ }
1123
+ var parent = effect.parent;
1124
+ effect = effect.next;
1125
+ while (effect === null && parent !== null) {
1126
+ if (parent === pending_boundary) {
1127
+ pending_boundary = null;
1128
+ }
1129
+ effect = parent.next;
1130
+ parent = parent.parent;
1131
+ }
1132
+ }
1133
+ }
1134
+ /**
1135
+ * @param {Effect[]} effects
1136
+ */
1137
+ #defer_effects(effects) {
1138
+ for (var i = 0; i < effects.length; i += 1) {
1139
+ defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
1140
+ }
1141
+ }
1142
+ /**
1143
+ * Associate a change to a given source with the current
1144
+ * batch, noting its previous and current values
1145
+ * @param {Source} source
1146
+ * @param {any} value
1147
+ */
1148
+ capture(source2, value) {
1149
+ if (value !== UNINITIALIZED && !this.previous.has(source2)) {
1150
+ this.previous.set(source2, value);
1151
+ }
1152
+ if ((source2.f & ERROR_VALUE) === 0) {
1153
+ this.current.set(source2, source2.v);
1154
+ batch_values?.set(source2, source2.v);
1155
+ }
1156
+ }
1157
+ activate() {
1158
+ current_batch = this;
1159
+ this.apply();
1160
+ }
1161
+ deactivate() {
1162
+ if (current_batch !== this) return;
1163
+ current_batch = null;
1164
+ batch_values = null;
1165
+ }
1166
+ flush() {
1167
+ this.activate();
1168
+ if (queued_root_effects.length > 0) {
1169
+ flush_effects();
1170
+ if (current_batch !== null && current_batch !== this) {
1171
+ return;
1172
+ }
1173
+ } else if (this.#pending === 0) {
1174
+ this.process([]);
1175
+ }
1176
+ this.deactivate();
1177
+ }
1178
+ discard() {
1179
+ for (const fn of this.#discard_callbacks) fn(this);
1180
+ this.#discard_callbacks.clear();
1181
+ }
1182
+ #commit() {
1183
+ if (batches.size > 1) {
1184
+ this.previous.clear();
1185
+ var previous_batch_values = batch_values;
1186
+ var is_earlier = true;
1187
+ for (const batch of batches) {
1188
+ if (batch === this) {
1189
+ is_earlier = false;
1190
+ continue;
1191
+ }
1192
+ const sources = [];
1193
+ for (const [source2, value] of this.current) {
1194
+ if (batch.current.has(source2)) {
1195
+ if (is_earlier && value !== batch.current.get(source2)) {
1196
+ batch.current.set(source2, value);
1197
+ } else {
1198
+ continue;
1199
+ }
1200
+ }
1201
+ sources.push(source2);
1202
+ }
1203
+ if (sources.length === 0) {
1204
+ continue;
1205
+ }
1206
+ const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
1207
+ if (others.length > 0) {
1208
+ var prev_queued_root_effects = queued_root_effects;
1209
+ queued_root_effects = [];
1210
+ const marked = /* @__PURE__ */ new Set();
1211
+ const checked = /* @__PURE__ */ new Map();
1212
+ for (const source2 of sources) {
1213
+ mark_effects(source2, others, marked, checked);
1214
+ }
1215
+ if (queued_root_effects.length > 0) {
1216
+ current_batch = batch;
1217
+ batch.apply();
1218
+ for (const root of queued_root_effects) {
1219
+ batch.#traverse_effect_tree(root, [], []);
1220
+ }
1221
+ batch.deactivate();
1222
+ }
1223
+ queued_root_effects = prev_queued_root_effects;
1224
+ }
1225
+ }
1226
+ current_batch = null;
1227
+ batch_values = previous_batch_values;
1228
+ }
1229
+ this.committed = true;
1230
+ batches.delete(this);
1231
+ }
1232
+ /**
1233
+ *
1234
+ * @param {boolean} blocking
1235
+ */
1236
+ increment(blocking) {
1237
+ this.#pending += 1;
1238
+ if (blocking) this.#blocking_pending += 1;
1239
+ }
1240
+ /**
1241
+ *
1242
+ * @param {boolean} blocking
1243
+ */
1244
+ decrement(blocking) {
1245
+ this.#pending -= 1;
1246
+ if (blocking) this.#blocking_pending -= 1;
1247
+ if (this.#decrement_queued) return;
1248
+ this.#decrement_queued = true;
1249
+ queue_micro_task(() => {
1250
+ this.#decrement_queued = false;
1251
+ if (!this.is_deferred()) {
1252
+ this.revive();
1253
+ } else if (queued_root_effects.length > 0) {
1254
+ this.flush();
1255
+ }
1256
+ });
1257
+ }
1258
+ revive() {
1259
+ for (const e of this.#dirty_effects) {
1260
+ this.#maybe_dirty_effects.delete(e);
1261
+ set_signal_status(e, DIRTY);
1262
+ schedule_effect(e);
1263
+ }
1264
+ for (const e of this.#maybe_dirty_effects) {
1265
+ set_signal_status(e, MAYBE_DIRTY);
1266
+ schedule_effect(e);
1267
+ }
1268
+ this.flush();
1269
+ }
1270
+ /** @param {() => void} fn */
1271
+ oncommit(fn) {
1272
+ this.#commit_callbacks.add(fn);
1273
+ }
1274
+ /** @param {(batch: Batch) => void} fn */
1275
+ ondiscard(fn) {
1276
+ this.#discard_callbacks.add(fn);
1277
+ }
1278
+ settled() {
1279
+ return (this.#deferred ??= deferred()).promise;
1280
+ }
1281
+ static ensure() {
1282
+ if (current_batch === null) {
1283
+ const batch = current_batch = new Batch();
1284
+ batches.add(current_batch);
1285
+ if (!is_flushing_sync) {
1286
+ queue_micro_task(() => {
1287
+ if (current_batch !== batch) {
1288
+ return;
1289
+ }
1290
+ batch.flush();
1291
+ });
1292
+ }
1293
+ }
1294
+ return current_batch;
1295
+ }
1296
+ apply() {
1297
+ return;
1298
+ }
1299
+ }
1300
+ function flushSync(fn) {
1301
+ var was_flushing_sync = is_flushing_sync;
1302
+ is_flushing_sync = true;
1303
+ try {
1304
+ var result;
1305
+ if (fn) ;
1306
+ while (true) {
1307
+ flush_tasks();
1308
+ if (queued_root_effects.length === 0) {
1309
+ current_batch?.flush();
1310
+ if (queued_root_effects.length === 0) {
1311
+ last_scheduled_effect = null;
1312
+ return (
1313
+ /** @type {T} */
1314
+ result
1315
+ );
1316
+ }
1317
+ }
1318
+ flush_effects();
1319
+ }
1320
+ } finally {
1321
+ is_flushing_sync = was_flushing_sync;
1322
+ }
1323
+ }
1324
+ function flush_effects() {
1325
+ is_flushing = true;
1326
+ var source_stacks = /* @__PURE__ */ new Set();
1327
+ try {
1328
+ var flush_count = 0;
1329
+ while (queued_root_effects.length > 0) {
1330
+ var batch = Batch.ensure();
1331
+ if (flush_count++ > 1e3) {
1332
+ if (DEV) {
1333
+ var updates = /* @__PURE__ */ new Map();
1334
+ for (const source2 of batch.current.keys()) {
1335
+ for (const [stack2, update] of source2.updated ?? []) {
1336
+ var entry = updates.get(stack2);
1337
+ if (!entry) {
1338
+ entry = { error: update.error, count: 0 };
1339
+ updates.set(stack2, entry);
1340
+ }
1341
+ entry.count += update.count;
1342
+ }
1343
+ }
1344
+ for (const update of updates.values()) {
1345
+ if (update.error) {
1346
+ console.error(update.error);
1347
+ }
1348
+ }
1349
+ }
1350
+ infinite_loop_guard();
1351
+ }
1352
+ batch.process(queued_root_effects);
1353
+ old_values.clear();
1354
+ if (DEV) {
1355
+ for (const source2 of batch.current.keys()) {
1356
+ source_stacks.add(source2);
1357
+ }
1358
+ }
1359
+ }
1360
+ } finally {
1361
+ is_flushing = false;
1362
+ last_scheduled_effect = null;
1363
+ {
1364
+ for (
1365
+ const source2 of
1366
+ /** @type {Set<Source>} */
1367
+ source_stacks
1368
+ ) {
1369
+ source2.updated = null;
1370
+ }
1371
+ }
1372
+ }
1373
+ }
1374
+ function infinite_loop_guard() {
1375
+ try {
1376
+ effect_update_depth_exceeded();
1377
+ } catch (error) {
1378
+ {
1379
+ define_property(error, "stack", { value: "" });
1380
+ }
1381
+ invoke_error_boundary(error, last_scheduled_effect);
1382
+ }
1383
+ }
1384
+ let eager_block_effects = null;
1385
+ function flush_queued_effects(effects) {
1386
+ var length = effects.length;
1387
+ if (length === 0) return;
1388
+ var i = 0;
1389
+ while (i < length) {
1390
+ var effect = effects[i++];
1391
+ if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
1392
+ eager_block_effects = /* @__PURE__ */ new Set();
1393
+ update_effect(effect);
1394
+ if (effect.deps === null && effect.first === null && effect.nodes === null) {
1395
+ if (effect.teardown === null && effect.ac === null) {
1396
+ unlink_effect(effect);
1397
+ } else {
1398
+ effect.fn = null;
1399
+ }
1400
+ }
1401
+ if (eager_block_effects?.size > 0) {
1402
+ old_values.clear();
1403
+ for (const e of eager_block_effects) {
1404
+ if ((e.f & (DESTROYED | INERT)) !== 0) continue;
1405
+ const ordered_effects = [e];
1406
+ let ancestor = e.parent;
1407
+ while (ancestor !== null) {
1408
+ if (eager_block_effects.has(ancestor)) {
1409
+ eager_block_effects.delete(ancestor);
1410
+ ordered_effects.push(ancestor);
1411
+ }
1412
+ ancestor = ancestor.parent;
1413
+ }
1414
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1415
+ const e2 = ordered_effects[j];
1416
+ if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
1417
+ update_effect(e2);
1418
+ }
1419
+ }
1420
+ eager_block_effects.clear();
1421
+ }
1422
+ }
1423
+ }
1424
+ eager_block_effects = null;
1425
+ }
1426
+ function mark_effects(value, sources, marked, checked) {
1427
+ if (marked.has(value)) return;
1428
+ marked.add(value);
1429
+ if (value.reactions !== null) {
1430
+ for (const reaction of value.reactions) {
1431
+ const flags = reaction.f;
1432
+ if ((flags & DERIVED) !== 0) {
1433
+ mark_effects(
1434
+ /** @type {Derived} */
1435
+ reaction,
1436
+ sources,
1437
+ marked,
1438
+ checked
1439
+ );
1440
+ } else if ((flags & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags & DIRTY) === 0 && depends_on(reaction, sources, checked)) {
1441
+ set_signal_status(reaction, DIRTY);
1442
+ schedule_effect(
1443
+ /** @type {Effect} */
1444
+ reaction
1445
+ );
1446
+ }
1447
+ }
1448
+ }
1449
+ }
1450
+ function depends_on(reaction, sources, checked) {
1451
+ const depends = checked.get(reaction);
1452
+ if (depends !== void 0) return depends;
1453
+ if (reaction.deps !== null) {
1454
+ for (const dep of reaction.deps) {
1455
+ if (includes.call(sources, dep)) {
1456
+ return true;
1457
+ }
1458
+ if ((dep.f & DERIVED) !== 0 && depends_on(
1459
+ /** @type {Derived} */
1460
+ dep,
1461
+ sources,
1462
+ checked
1463
+ )) {
1464
+ checked.set(
1465
+ /** @type {Derived} */
1466
+ dep,
1467
+ true
1468
+ );
1469
+ return true;
1470
+ }
1471
+ }
1472
+ }
1473
+ checked.set(reaction, false);
1474
+ return false;
1475
+ }
1476
+ function schedule_effect(signal) {
1477
+ var effect = last_scheduled_effect = signal;
1478
+ while (effect.parent !== null) {
1479
+ effect = effect.parent;
1480
+ var flags = effect.f;
1481
+ if (is_flushing && effect === active_effect && (flags & BLOCK_EFFECT) !== 0 && (flags & HEAD_EFFECT) === 0) {
1482
+ return;
1483
+ }
1484
+ if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
1485
+ if ((flags & CLEAN) === 0) return;
1486
+ effect.f ^= CLEAN;
1487
+ }
1488
+ }
1489
+ queued_root_effects.push(effect);
1490
+ }
1491
+ function reset_branch(effect) {
1492
+ if ((effect.f & BRANCH_EFFECT) !== 0 && (effect.f & CLEAN) !== 0) {
1493
+ return;
1494
+ }
1495
+ set_signal_status(effect, CLEAN);
1496
+ var e = effect.first;
1497
+ while (e !== null) {
1498
+ reset_branch(e);
1499
+ e = e.next;
1500
+ }
1501
+ }
1502
+ const recent_async_deriveds = /* @__PURE__ */ new Set();
1503
+ function destroy_derived_effects(derived) {
1504
+ var effects = derived.effects;
1505
+ if (effects !== null) {
1506
+ derived.effects = null;
1507
+ for (var i = 0; i < effects.length; i += 1) {
1508
+ destroy_effect(
1509
+ /** @type {Effect} */
1510
+ effects[i]
1511
+ );
1512
+ }
1513
+ }
1514
+ }
1515
+ let stack = [];
1516
+ function get_derived_parent_effect(derived) {
1517
+ var parent = derived.parent;
1518
+ while (parent !== null) {
1519
+ if ((parent.f & DERIVED) === 0) {
1520
+ return (parent.f & DESTROYED) === 0 ? (
1521
+ /** @type {Effect} */
1522
+ parent
1523
+ ) : null;
1524
+ }
1525
+ parent = parent.parent;
1526
+ }
1527
+ return null;
1528
+ }
1529
+ function execute_derived(derived) {
1530
+ var value;
1531
+ var prev_active_effect = active_effect;
1532
+ set_active_effect(get_derived_parent_effect(derived));
1533
+ {
1534
+ let prev_eager_effects = eager_effects;
1535
+ set_eager_effects(/* @__PURE__ */ new Set());
1536
+ try {
1537
+ if (includes.call(stack, derived)) {
1538
+ derived_references_self();
1539
+ }
1540
+ stack.push(derived);
1541
+ derived.f &= ~WAS_MARKED;
1542
+ destroy_derived_effects(derived);
1543
+ value = update_reaction(derived);
1544
+ } finally {
1545
+ set_active_effect(prev_active_effect);
1546
+ set_eager_effects(prev_eager_effects);
1547
+ stack.pop();
1548
+ }
1549
+ }
1550
+ return value;
1551
+ }
1552
+ function update_derived(derived) {
1553
+ var value = execute_derived(derived);
1554
+ if (!derived.equals(value)) {
1555
+ derived.wv = increment_write_version();
1556
+ if (!current_batch?.is_fork || derived.deps === null) {
1557
+ derived.v = value;
1558
+ if (derived.deps === null) {
1559
+ set_signal_status(derived, CLEAN);
1560
+ return;
1561
+ }
1562
+ }
1563
+ }
1564
+ if (is_destroying_effect) {
1565
+ return;
1566
+ }
1567
+ if (batch_values !== null) {
1568
+ if (effect_tracking() || current_batch?.is_fork) {
1569
+ batch_values.set(derived, value);
1570
+ }
1571
+ } else {
1572
+ update_derived_status(derived);
1573
+ }
1574
+ }
1575
+ let eager_effects = /* @__PURE__ */ new Set();
1576
+ const old_values = /* @__PURE__ */ new Map();
1577
+ function set_eager_effects(v) {
1578
+ eager_effects = v;
1579
+ }
1580
+ let eager_effects_deferred = false;
1581
+ function set_eager_effects_deferred() {
1582
+ eager_effects_deferred = true;
1583
+ }
1584
+ function source(v, stack2) {
1585
+ var signal = {
1586
+ f: 0,
1587
+ // TODO ideally we could skip this altogether, but it causes type errors
1588
+ v,
1589
+ reactions: null,
1590
+ equals,
1591
+ rv: 0,
1592
+ wv: 0
1593
+ };
1594
+ return signal;
1595
+ }
1596
+ // @__NO_SIDE_EFFECTS__
1597
+ function state(v, stack2) {
1598
+ const s = source(v);
1599
+ push_reaction_value(s);
1600
+ return s;
1601
+ }
1602
+ // @__NO_SIDE_EFFECTS__
1603
+ function mutable_source(initial_value, immutable = false, trackable = true) {
1604
+ const s = source(initial_value);
1605
+ if (!immutable) {
1606
+ s.equals = safe_equals;
1607
+ }
1608
+ return s;
1609
+ }
1610
+ function set(source2, value, should_proxy = false) {
1611
+ if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1612
+ // to ensure we error if state is set inside an inspect effect
1613
+ (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && (current_sources === null || !includes.call(current_sources, source2))) {
1614
+ state_unsafe_mutation();
1615
+ }
1616
+ let new_value = should_proxy ? proxy(value) : value;
1617
+ {
1618
+ tag_proxy(
1619
+ new_value,
1620
+ /** @type {string} */
1621
+ source2.label
1622
+ );
1623
+ }
1624
+ return internal_set(source2, new_value);
1625
+ }
1626
+ function internal_set(source2, value) {
1627
+ if (!source2.equals(value)) {
1628
+ var old_value = source2.v;
1629
+ if (is_destroying_effect) {
1630
+ old_values.set(source2, value);
1631
+ } else {
1632
+ old_values.set(source2, old_value);
1633
+ }
1634
+ source2.v = value;
1635
+ var batch = Batch.ensure();
1636
+ batch.capture(source2, old_value);
1637
+ {
1638
+ if (active_effect !== null) {
1639
+ source2.updated ??= /* @__PURE__ */ new Map();
1640
+ const count = (source2.updated.get("")?.count ?? 0) + 1;
1641
+ source2.updated.set("", { error: (
1642
+ /** @type {any} */
1643
+ null
1644
+ ), count });
1645
+ if (count > 5) {
1646
+ const error = get_error("updated at");
1647
+ if (error !== null) {
1648
+ let entry = source2.updated.get(error.stack);
1649
+ if (!entry) {
1650
+ entry = { error, count: 0 };
1651
+ source2.updated.set(error.stack, entry);
1652
+ }
1653
+ entry.count++;
1654
+ }
1655
+ }
1656
+ }
1657
+ if (active_effect !== null) {
1658
+ source2.set_during_effect = true;
1659
+ }
1660
+ }
1661
+ if ((source2.f & DERIVED) !== 0) {
1662
+ const derived = (
1663
+ /** @type {Derived} */
1664
+ source2
1665
+ );
1666
+ if ((source2.f & DIRTY) !== 0) {
1667
+ execute_derived(derived);
1668
+ }
1669
+ update_derived_status(derived);
1670
+ }
1671
+ source2.wv = increment_write_version();
1672
+ mark_reactions(source2, DIRTY);
1673
+ if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
1674
+ if (untracked_writes === null) {
1675
+ set_untracked_writes([source2]);
1676
+ } else {
1677
+ untracked_writes.push(source2);
1678
+ }
1679
+ }
1680
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
1681
+ flush_eager_effects();
1682
+ }
1683
+ }
1684
+ return value;
1685
+ }
1686
+ function flush_eager_effects() {
1687
+ eager_effects_deferred = false;
1688
+ for (const effect of eager_effects) {
1689
+ if ((effect.f & CLEAN) !== 0) {
1690
+ set_signal_status(effect, MAYBE_DIRTY);
1691
+ }
1692
+ if (is_dirty(effect)) {
1693
+ update_effect(effect);
1694
+ }
1695
+ }
1696
+ eager_effects.clear();
1697
+ }
1698
+ function increment(source2) {
1699
+ set(source2, source2.v + 1);
1700
+ }
1701
+ function mark_reactions(signal, status) {
1702
+ var reactions = signal.reactions;
1703
+ if (reactions === null) return;
1704
+ var length = reactions.length;
1705
+ for (var i = 0; i < length; i++) {
1706
+ var reaction = reactions[i];
1707
+ var flags = reaction.f;
1708
+ if ((flags & EAGER_EFFECT) !== 0) {
1709
+ eager_effects.add(reaction);
1710
+ continue;
1711
+ }
1712
+ var not_dirty = (flags & DIRTY) === 0;
1713
+ if (not_dirty) {
1714
+ set_signal_status(reaction, status);
1715
+ }
1716
+ if ((flags & DERIVED) !== 0) {
1717
+ var derived = (
1718
+ /** @type {Derived} */
1719
+ reaction
1720
+ );
1721
+ batch_values?.delete(derived);
1722
+ if ((flags & WAS_MARKED) === 0) {
1723
+ if (flags & CONNECTED) {
1724
+ reaction.f |= WAS_MARKED;
1725
+ }
1726
+ mark_reactions(derived, MAYBE_DIRTY);
1727
+ }
1728
+ } else if (not_dirty) {
1729
+ if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
1730
+ eager_block_effects.add(
1731
+ /** @type {Effect} */
1732
+ reaction
1733
+ );
1734
+ }
1735
+ schedule_effect(
1736
+ /** @type {Effect} */
1737
+ reaction
1738
+ );
1739
+ }
1740
+ }
1741
+ }
1742
+ const regex_is_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
1743
+ function proxy(value) {
1744
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) {
1745
+ return value;
1746
+ }
1747
+ const prototype = get_prototype_of(value);
1748
+ if (prototype !== object_prototype && prototype !== array_prototype) {
1749
+ return value;
1750
+ }
1751
+ var sources = /* @__PURE__ */ new Map();
1752
+ var is_proxied_array = is_array(value);
1753
+ var version = /* @__PURE__ */ state(0);
1754
+ var parent_version = update_version;
1755
+ var with_parent = (fn) => {
1756
+ if (update_version === parent_version) {
1757
+ return fn();
1758
+ }
1759
+ var reaction = active_reaction;
1760
+ var version2 = update_version;
1761
+ set_active_reaction(null);
1762
+ set_update_version(parent_version);
1763
+ var result = fn();
1764
+ set_active_reaction(reaction);
1765
+ set_update_version(version2);
1766
+ return result;
1767
+ };
1768
+ if (is_proxied_array) {
1769
+ sources.set("length", /* @__PURE__ */ state(
1770
+ /** @type {any[]} */
1771
+ value.length
1772
+ ));
1773
+ {
1774
+ value = /** @type {any} */
1775
+ inspectable_array(
1776
+ /** @type {any[]} */
1777
+ value
1778
+ );
1779
+ }
1780
+ }
1781
+ var path = "";
1782
+ let updating = false;
1783
+ function update_path(new_path) {
1784
+ if (updating) return;
1785
+ updating = true;
1786
+ path = new_path;
1787
+ tag(version, `${path} version`);
1788
+ for (const [prop, source2] of sources) {
1789
+ tag(source2, get_label(path, prop));
1790
+ }
1791
+ updating = false;
1792
+ }
1793
+ return new Proxy(
1794
+ /** @type {any} */
1795
+ value,
1796
+ {
1797
+ defineProperty(_, prop, descriptor) {
1798
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) {
1799
+ state_descriptors_fixed();
1800
+ }
1801
+ var s = sources.get(prop);
1802
+ if (s === void 0) {
1803
+ s = with_parent(() => {
1804
+ var s2 = /* @__PURE__ */ state(descriptor.value);
1805
+ sources.set(prop, s2);
1806
+ if (typeof prop === "string") {
1807
+ tag(s2, get_label(path, prop));
1808
+ }
1809
+ return s2;
1810
+ });
1811
+ } else {
1812
+ set(s, descriptor.value, true);
1813
+ }
1814
+ return true;
1815
+ },
1816
+ deleteProperty(target, prop) {
1817
+ var s = sources.get(prop);
1818
+ if (s === void 0) {
1819
+ if (prop in target) {
1820
+ const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1821
+ sources.set(prop, s2);
1822
+ increment(version);
1823
+ {
1824
+ tag(s2, get_label(path, prop));
1825
+ }
1826
+ }
1827
+ } else {
1828
+ set(s, UNINITIALIZED);
1829
+ increment(version);
1830
+ }
1831
+ return true;
1832
+ },
1833
+ get(target, prop, receiver) {
1834
+ if (prop === STATE_SYMBOL) {
1835
+ return value;
1836
+ }
1837
+ if (prop === PROXY_PATH_SYMBOL) {
1838
+ return update_path;
1839
+ }
1840
+ var s = sources.get(prop);
1841
+ var exists = prop in target;
1842
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1843
+ s = with_parent(() => {
1844
+ var p = proxy(exists ? target[prop] : UNINITIALIZED);
1845
+ var s2 = /* @__PURE__ */ state(p);
1846
+ {
1847
+ tag(s2, get_label(path, prop));
1848
+ }
1849
+ return s2;
1850
+ });
1851
+ sources.set(prop, s);
1852
+ }
1853
+ if (s !== void 0) {
1854
+ var v = get(s);
1855
+ return v === UNINITIALIZED ? void 0 : v;
1856
+ }
1857
+ return Reflect.get(target, prop, receiver);
1858
+ },
1859
+ getOwnPropertyDescriptor(target, prop) {
1860
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1861
+ if (descriptor && "value" in descriptor) {
1862
+ var s = sources.get(prop);
1863
+ if (s) descriptor.value = get(s);
1864
+ } else if (descriptor === void 0) {
1865
+ var source2 = sources.get(prop);
1866
+ var value2 = source2?.v;
1867
+ if (source2 !== void 0 && value2 !== UNINITIALIZED) {
1868
+ return {
1869
+ enumerable: true,
1870
+ configurable: true,
1871
+ value: value2,
1872
+ writable: true
1873
+ };
1874
+ }
1875
+ }
1876
+ return descriptor;
1877
+ },
1878
+ has(target, prop) {
1879
+ if (prop === STATE_SYMBOL) {
1880
+ return true;
1881
+ }
1882
+ var s = sources.get(prop);
1883
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
1884
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
1885
+ if (s === void 0) {
1886
+ s = with_parent(() => {
1887
+ var p = has ? proxy(target[prop]) : UNINITIALIZED;
1888
+ var s2 = /* @__PURE__ */ state(p);
1889
+ {
1890
+ tag(s2, get_label(path, prop));
1891
+ }
1892
+ return s2;
1893
+ });
1894
+ sources.set(prop, s);
1895
+ }
1896
+ var value2 = get(s);
1897
+ if (value2 === UNINITIALIZED) {
1898
+ return false;
1899
+ }
1900
+ }
1901
+ return has;
1902
+ },
1903
+ set(target, prop, value2, receiver) {
1904
+ var s = sources.get(prop);
1905
+ var has = prop in target;
1906
+ if (is_proxied_array && prop === "length") {
1907
+ for (var i = value2; i < /** @type {Source<number>} */
1908
+ s.v; i += 1) {
1909
+ var other_s = sources.get(i + "");
1910
+ if (other_s !== void 0) {
1911
+ set(other_s, UNINITIALIZED);
1912
+ } else if (i in target) {
1913
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1914
+ sources.set(i + "", other_s);
1915
+ {
1916
+ tag(other_s, get_label(path, i));
1917
+ }
1918
+ }
1919
+ }
1920
+ }
1921
+ if (s === void 0) {
1922
+ if (!has || get_descriptor(target, prop)?.writable) {
1923
+ s = with_parent(() => /* @__PURE__ */ state(void 0));
1924
+ {
1925
+ tag(s, get_label(path, prop));
1926
+ }
1927
+ set(s, proxy(value2));
1928
+ sources.set(prop, s);
1929
+ }
1930
+ } else {
1931
+ has = s.v !== UNINITIALIZED;
1932
+ var p = with_parent(() => proxy(value2));
1933
+ set(s, p);
1934
+ }
1935
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1936
+ if (descriptor?.set) {
1937
+ descriptor.set.call(receiver, value2);
1938
+ }
1939
+ if (!has) {
1940
+ if (is_proxied_array && typeof prop === "string") {
1941
+ var ls = (
1942
+ /** @type {Source<number>} */
1943
+ sources.get("length")
1944
+ );
1945
+ var n = Number(prop);
1946
+ if (Number.isInteger(n) && n >= ls.v) {
1947
+ set(ls, n + 1);
1948
+ }
1949
+ }
1950
+ increment(version);
1951
+ }
1952
+ return true;
1953
+ },
1954
+ ownKeys(target) {
1955
+ get(version);
1956
+ var own_keys = Reflect.ownKeys(target).filter((key2) => {
1957
+ var source3 = sources.get(key2);
1958
+ return source3 === void 0 || source3.v !== UNINITIALIZED;
1959
+ });
1960
+ for (var [key, source2] of sources) {
1961
+ if (source2.v !== UNINITIALIZED && !(key in target)) {
1962
+ own_keys.push(key);
1963
+ }
1964
+ }
1965
+ return own_keys;
1966
+ },
1967
+ setPrototypeOf() {
1968
+ state_prototype_fixed();
1969
+ }
1970
+ }
1971
+ );
1972
+ }
1973
+ function get_label(path, prop) {
1974
+ if (typeof prop === "symbol") return `${path}[Symbol(${prop.description ?? ""})]`;
1975
+ if (regex_is_valid_identifier.test(prop)) return `${path}.${prop}`;
1976
+ return /^\d+$/.test(prop) ? `${path}[${prop}]` : `${path}['${prop}']`;
1977
+ }
1978
+ function get_proxied_value(value) {
1979
+ try {
1980
+ if (value !== null && typeof value === "object" && STATE_SYMBOL in value) {
1981
+ return value[STATE_SYMBOL];
1982
+ }
1983
+ } catch {
1984
+ }
1985
+ return value;
1986
+ }
1987
+ const ARRAY_MUTATING_METHODS = /* @__PURE__ */ new Set([
1988
+ "copyWithin",
1989
+ "fill",
1990
+ "pop",
1991
+ "push",
1992
+ "reverse",
1993
+ "shift",
1994
+ "sort",
1995
+ "splice",
1996
+ "unshift"
1997
+ ]);
1998
+ function inspectable_array(array) {
1999
+ return new Proxy(array, {
2000
+ get(target, prop, receiver) {
2001
+ var value = Reflect.get(target, prop, receiver);
2002
+ if (!ARRAY_MUTATING_METHODS.has(
2003
+ /** @type {string} */
2004
+ prop
2005
+ )) {
2006
+ return value;
2007
+ }
2008
+ return function(...args) {
2009
+ set_eager_effects_deferred();
2010
+ var result = value.apply(this, args);
2011
+ flush_eager_effects();
2012
+ return result;
2013
+ };
2014
+ }
2015
+ });
2016
+ }
2017
+ function init_array_prototype_warnings() {
2018
+ const array_prototype2 = Array.prototype;
2019
+ const cleanup = Array.__svelte_cleanup;
2020
+ if (cleanup) {
2021
+ cleanup();
2022
+ }
2023
+ const { indexOf, lastIndexOf, includes: includes2 } = array_prototype2;
2024
+ array_prototype2.indexOf = function(item, from_index) {
2025
+ const index = indexOf.call(this, item, from_index);
2026
+ if (index === -1) {
2027
+ for (let i = from_index ?? 0; i < this.length; i += 1) {
2028
+ if (get_proxied_value(this[i]) === item) {
2029
+ state_proxy_equality_mismatch("array.indexOf(...)");
2030
+ break;
2031
+ }
2032
+ }
2033
+ }
2034
+ return index;
2035
+ };
2036
+ array_prototype2.lastIndexOf = function(item, from_index) {
2037
+ const index = lastIndexOf.call(this, item, from_index ?? this.length - 1);
2038
+ if (index === -1) {
2039
+ for (let i = 0; i <= (from_index ?? this.length - 1); i += 1) {
2040
+ if (get_proxied_value(this[i]) === item) {
2041
+ state_proxy_equality_mismatch("array.lastIndexOf(...)");
2042
+ break;
2043
+ }
2044
+ }
2045
+ }
2046
+ return index;
2047
+ };
2048
+ array_prototype2.includes = function(item, from_index) {
2049
+ const has = includes2.call(this, item, from_index);
2050
+ if (!has) {
2051
+ for (let i = 0; i < this.length; i += 1) {
2052
+ if (get_proxied_value(this[i]) === item) {
2053
+ state_proxy_equality_mismatch("array.includes(...)");
2054
+ break;
2055
+ }
2056
+ }
2057
+ }
2058
+ return has;
2059
+ };
2060
+ Array.__svelte_cleanup = () => {
2061
+ array_prototype2.indexOf = indexOf;
2062
+ array_prototype2.lastIndexOf = lastIndexOf;
2063
+ array_prototype2.includes = includes2;
2064
+ };
2065
+ }
2066
+ var $window;
2067
+ var is_firefox;
2068
+ var first_child_getter;
2069
+ var next_sibling_getter;
2070
+ function init_operations() {
2071
+ if ($window !== void 0) {
2072
+ return;
2073
+ }
2074
+ $window = window;
2075
+ is_firefox = /Firefox/.test(navigator.userAgent);
2076
+ var element_prototype = Element.prototype;
2077
+ var node_prototype = Node.prototype;
2078
+ var text_prototype = Text.prototype;
2079
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
2080
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
2081
+ if (is_extensible(element_prototype)) {
2082
+ element_prototype.__click = void 0;
2083
+ element_prototype.__className = void 0;
2084
+ element_prototype.__attributes = null;
2085
+ element_prototype.__style = void 0;
2086
+ element_prototype.__e = void 0;
2087
+ }
2088
+ if (is_extensible(text_prototype)) {
2089
+ text_prototype.__t = void 0;
2090
+ }
2091
+ {
2092
+ element_prototype.__svelte_meta = null;
2093
+ init_array_prototype_warnings();
2094
+ }
2095
+ }
2096
+ function create_text(value = "") {
2097
+ return document.createTextNode(value);
2098
+ }
2099
+ // @__NO_SIDE_EFFECTS__
2100
+ function get_first_child(node) {
2101
+ return (
2102
+ /** @type {TemplateNode | null} */
2103
+ first_child_getter.call(node)
2104
+ );
2105
+ }
2106
+ // @__NO_SIDE_EFFECTS__
2107
+ function get_next_sibling(node) {
2108
+ return (
2109
+ /** @type {TemplateNode | null} */
2110
+ next_sibling_getter.call(node)
2111
+ );
2112
+ }
2113
+ function clear_text_content(node) {
2114
+ node.textContent = "";
2115
+ }
2116
+ function without_reactive_context(fn) {
2117
+ var previous_reaction = active_reaction;
2118
+ var previous_effect = active_effect;
2119
+ set_active_reaction(null);
2120
+ set_active_effect(null);
2121
+ try {
2122
+ return fn();
2123
+ } finally {
2124
+ set_active_reaction(previous_reaction);
2125
+ set_active_effect(previous_effect);
2126
+ }
2127
+ }
2128
+ function push_effect(effect, parent_effect) {
2129
+ var parent_last = parent_effect.last;
2130
+ if (parent_last === null) {
2131
+ parent_effect.last = parent_effect.first = effect;
2132
+ } else {
2133
+ parent_last.next = effect;
2134
+ effect.prev = parent_last;
2135
+ parent_effect.last = effect;
2136
+ }
2137
+ }
2138
+ function create_effect(type, fn, sync) {
2139
+ var parent = active_effect;
2140
+ {
2141
+ while (parent !== null && (parent.f & EAGER_EFFECT) !== 0) {
2142
+ parent = parent.parent;
2143
+ }
2144
+ }
2145
+ if (parent !== null && (parent.f & INERT) !== 0) {
2146
+ type |= INERT;
2147
+ }
2148
+ var effect = {
2149
+ ctx: component_context,
2150
+ deps: null,
2151
+ nodes: null,
2152
+ f: type | DIRTY | CONNECTED,
2153
+ first: null,
2154
+ fn,
2155
+ last: null,
2156
+ next: null,
2157
+ parent,
2158
+ b: parent && parent.b,
2159
+ prev: null,
2160
+ teardown: null,
2161
+ wv: 0,
2162
+ ac: null
2163
+ };
2164
+ {
2165
+ effect.component_function = dev_current_component_function;
2166
+ }
2167
+ if (sync) {
2168
+ try {
2169
+ update_effect(effect);
2170
+ effect.f |= EFFECT_RAN;
2171
+ } catch (e2) {
2172
+ destroy_effect(effect);
2173
+ throw e2;
2174
+ }
2175
+ } else if (fn !== null) {
2176
+ schedule_effect(effect);
2177
+ }
2178
+ var e = effect;
2179
+ if (sync && e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child
2180
+ (e.f & EFFECT_PRESERVED) === 0) {
2181
+ e = e.first;
2182
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
2183
+ e.f |= EFFECT_TRANSPARENT;
2184
+ }
2185
+ }
2186
+ if (e !== null) {
2187
+ e.parent = parent;
2188
+ if (parent !== null) {
2189
+ push_effect(e, parent);
2190
+ }
2191
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
2192
+ var derived = (
2193
+ /** @type {Derived} */
2194
+ active_reaction
2195
+ );
2196
+ (derived.effects ??= []).push(e);
2197
+ }
2198
+ }
2199
+ return effect;
2200
+ }
2201
+ function effect_tracking() {
2202
+ return active_reaction !== null && !untracking;
2203
+ }
2204
+ function create_user_effect(fn) {
2205
+ return create_effect(EFFECT | USER_EFFECT, fn, false);
2206
+ }
2207
+ function component_root(fn) {
2208
+ Batch.ensure();
2209
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn, true);
2210
+ return (options = {}) => {
2211
+ return new Promise((fulfil) => {
2212
+ if (options.outro) {
2213
+ pause_effect(effect, () => {
2214
+ destroy_effect(effect);
2215
+ fulfil(void 0);
2216
+ });
2217
+ } else {
2218
+ destroy_effect(effect);
2219
+ fulfil(void 0);
2220
+ }
2221
+ });
2222
+ };
2223
+ }
2224
+ function render_effect(fn, flags = 0) {
2225
+ return create_effect(RENDER_EFFECT | flags, fn, true);
2226
+ }
2227
+ function block(fn, flags = 0) {
2228
+ var effect = create_effect(BLOCK_EFFECT | flags, fn, true);
2229
+ {
2230
+ effect.dev_stack = dev_stack;
2231
+ }
2232
+ return effect;
2233
+ }
2234
+ function branch(fn) {
2235
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn, true);
2236
+ }
2237
+ function execute_effect_teardown(effect) {
2238
+ var teardown = effect.teardown;
2239
+ if (teardown !== null) {
2240
+ const previously_destroying_effect = is_destroying_effect;
2241
+ const previous_reaction = active_reaction;
2242
+ set_is_destroying_effect(true);
2243
+ set_active_reaction(null);
2244
+ try {
2245
+ teardown.call(null);
2246
+ } finally {
2247
+ set_is_destroying_effect(previously_destroying_effect);
2248
+ set_active_reaction(previous_reaction);
2249
+ }
2250
+ }
2251
+ }
2252
+ function destroy_effect_children(signal, remove_dom = false) {
2253
+ var effect = signal.first;
2254
+ signal.first = signal.last = null;
2255
+ while (effect !== null) {
2256
+ const controller2 = effect.ac;
2257
+ if (controller2 !== null) {
2258
+ without_reactive_context(() => {
2259
+ controller2.abort(STALE_REACTION);
2260
+ });
2261
+ }
2262
+ var next = effect.next;
2263
+ if ((effect.f & ROOT_EFFECT) !== 0) {
2264
+ effect.parent = null;
2265
+ } else {
2266
+ destroy_effect(effect, remove_dom);
2267
+ }
2268
+ effect = next;
2269
+ }
2270
+ }
2271
+ function destroy_block_effect_children(signal) {
2272
+ var effect = signal.first;
2273
+ while (effect !== null) {
2274
+ var next = effect.next;
2275
+ if ((effect.f & BRANCH_EFFECT) === 0) {
2276
+ destroy_effect(effect);
2277
+ }
2278
+ effect = next;
2279
+ }
2280
+ }
2281
+ function destroy_effect(effect, remove_dom = true) {
2282
+ var removed = false;
2283
+ if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
2284
+ remove_effect_dom(
2285
+ effect.nodes.start,
2286
+ /** @type {TemplateNode} */
2287
+ effect.nodes.end
2288
+ );
2289
+ removed = true;
2290
+ }
2291
+ destroy_effect_children(effect, remove_dom && !removed);
2292
+ remove_reactions(effect, 0);
2293
+ set_signal_status(effect, DESTROYED);
2294
+ var transitions = effect.nodes && effect.nodes.t;
2295
+ if (transitions !== null) {
2296
+ for (const transition of transitions) {
2297
+ transition.stop();
2298
+ }
2299
+ }
2300
+ execute_effect_teardown(effect);
2301
+ var parent = effect.parent;
2302
+ if (parent !== null && parent.first !== null) {
2303
+ unlink_effect(effect);
2304
+ }
2305
+ {
2306
+ effect.component_function = null;
2307
+ }
2308
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = null;
2309
+ }
2310
+ function remove_effect_dom(node, end) {
2311
+ while (node !== null) {
2312
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2313
+ node.remove();
2314
+ node = next;
2315
+ }
2316
+ }
2317
+ function unlink_effect(effect) {
2318
+ var parent = effect.parent;
2319
+ var prev = effect.prev;
2320
+ var next = effect.next;
2321
+ if (prev !== null) prev.next = next;
2322
+ if (next !== null) next.prev = prev;
2323
+ if (parent !== null) {
2324
+ if (parent.first === effect) parent.first = next;
2325
+ if (parent.last === effect) parent.last = prev;
2326
+ }
2327
+ }
2328
+ function pause_effect(effect, callback, destroy = true) {
2329
+ var transitions = [];
2330
+ pause_children(effect, transitions, true);
2331
+ var fn = () => {
2332
+ if (destroy) destroy_effect(effect);
2333
+ if (callback) callback();
2334
+ };
2335
+ var remaining = transitions.length;
2336
+ if (remaining > 0) {
2337
+ var check = () => --remaining || fn();
2338
+ for (var transition of transitions) {
2339
+ transition.out(check);
2340
+ }
2341
+ } else {
2342
+ fn();
2343
+ }
2344
+ }
2345
+ function pause_children(effect, transitions, local) {
2346
+ if ((effect.f & INERT) !== 0) return;
2347
+ effect.f ^= INERT;
2348
+ var t = effect.nodes && effect.nodes.t;
2349
+ if (t !== null) {
2350
+ for (const transition of t) {
2351
+ if (transition.is_global || local) {
2352
+ transitions.push(transition);
2353
+ }
2354
+ }
2355
+ }
2356
+ var child = effect.first;
2357
+ while (child !== null) {
2358
+ var sibling = child.next;
2359
+ var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent,
2360
+ // it means the parent block effect was pruned. In that case,
2361
+ // transparency information was transferred to the branch effect.
2362
+ (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
2363
+ pause_children(child, transitions, transparent ? local : false);
2364
+ child = sibling;
2365
+ }
2366
+ }
2367
+ function move_effect(effect, fragment) {
2368
+ if (!effect.nodes) return;
2369
+ var node = effect.nodes.start;
2370
+ var end = effect.nodes.end;
2371
+ while (node !== null) {
2372
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2373
+ fragment.append(node);
2374
+ node = next;
2375
+ }
2376
+ }
2377
+ let is_updating_effect = false;
2378
+ let is_destroying_effect = false;
2379
+ function set_is_destroying_effect(value) {
2380
+ is_destroying_effect = value;
2381
+ }
2382
+ let active_reaction = null;
2383
+ let untracking = false;
2384
+ function set_active_reaction(reaction) {
2385
+ active_reaction = reaction;
2386
+ }
2387
+ let active_effect = null;
2388
+ function set_active_effect(effect) {
2389
+ active_effect = effect;
2390
+ }
2391
+ let current_sources = null;
2392
+ function push_reaction_value(value) {
2393
+ if (active_reaction !== null && true) {
2394
+ if (current_sources === null) {
2395
+ current_sources = [value];
2396
+ } else {
2397
+ current_sources.push(value);
2398
+ }
2399
+ }
2400
+ }
2401
+ let new_deps = null;
2402
+ let skipped_deps = 0;
2403
+ let untracked_writes = null;
2404
+ function set_untracked_writes(value) {
2405
+ untracked_writes = value;
2406
+ }
2407
+ let write_version = 1;
2408
+ let read_version = 0;
2409
+ let update_version = read_version;
2410
+ function set_update_version(value) {
2411
+ update_version = value;
2412
+ }
2413
+ function increment_write_version() {
2414
+ return ++write_version;
2415
+ }
2416
+ function is_dirty(reaction) {
2417
+ var flags = reaction.f;
2418
+ if ((flags & DIRTY) !== 0) {
2419
+ return true;
2420
+ }
2421
+ if (flags & DERIVED) {
2422
+ reaction.f &= ~WAS_MARKED;
2423
+ }
2424
+ if ((flags & MAYBE_DIRTY) !== 0) {
2425
+ var dependencies = (
2426
+ /** @type {Value[]} */
2427
+ reaction.deps
2428
+ );
2429
+ var length = dependencies.length;
2430
+ for (var i = 0; i < length; i++) {
2431
+ var dependency = dependencies[i];
2432
+ if (is_dirty(
2433
+ /** @type {Derived} */
2434
+ dependency
2435
+ )) {
2436
+ update_derived(
2437
+ /** @type {Derived} */
2438
+ dependency
2439
+ );
2440
+ }
2441
+ if (dependency.wv > reaction.wv) {
2442
+ return true;
2443
+ }
2444
+ }
2445
+ if ((flags & CONNECTED) !== 0 && // During time traveling we don't want to reset the status so that
2446
+ // traversal of the graph in the other batches still happens
2447
+ batch_values === null) {
2448
+ set_signal_status(reaction, CLEAN);
2449
+ }
2450
+ }
2451
+ return false;
2452
+ }
2453
+ function schedule_possible_effect_self_invalidation(signal, effect, root = true) {
2454
+ var reactions = signal.reactions;
2455
+ if (reactions === null) return;
2456
+ if (current_sources !== null && includes.call(current_sources, signal)) {
2457
+ return;
2458
+ }
2459
+ for (var i = 0; i < reactions.length; i++) {
2460
+ var reaction = reactions[i];
2461
+ if ((reaction.f & DERIVED) !== 0) {
2462
+ schedule_possible_effect_self_invalidation(
2463
+ /** @type {Derived} */
2464
+ reaction,
2465
+ effect,
2466
+ false
2467
+ );
2468
+ } else if (effect === reaction) {
2469
+ if (root) {
2470
+ set_signal_status(reaction, DIRTY);
2471
+ } else if ((reaction.f & CLEAN) !== 0) {
2472
+ set_signal_status(reaction, MAYBE_DIRTY);
2473
+ }
2474
+ schedule_effect(
2475
+ /** @type {Effect} */
2476
+ reaction
2477
+ );
2478
+ }
2479
+ }
2480
+ }
2481
+ function update_reaction(reaction) {
2482
+ var previous_deps = new_deps;
2483
+ var previous_skipped_deps = skipped_deps;
2484
+ var previous_untracked_writes = untracked_writes;
2485
+ var previous_reaction = active_reaction;
2486
+ var previous_sources = current_sources;
2487
+ var previous_component_context = component_context;
2488
+ var previous_untracking = untracking;
2489
+ var previous_update_version = update_version;
2490
+ var flags = reaction.f;
2491
+ new_deps = /** @type {null | Value[]} */
2492
+ null;
2493
+ skipped_deps = 0;
2494
+ untracked_writes = null;
2495
+ active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2496
+ current_sources = null;
2497
+ set_component_context(reaction.ctx);
2498
+ untracking = false;
2499
+ update_version = ++read_version;
2500
+ if (reaction.ac !== null) {
2501
+ without_reactive_context(() => {
2502
+ reaction.ac.abort(STALE_REACTION);
2503
+ });
2504
+ reaction.ac = null;
2505
+ }
2506
+ try {
2507
+ reaction.f |= REACTION_IS_UPDATING;
2508
+ var fn = (
2509
+ /** @type {Function} */
2510
+ reaction.fn
2511
+ );
2512
+ var result = fn();
2513
+ var deps = reaction.deps;
2514
+ var is_fork = current_batch?.is_fork;
2515
+ if (new_deps !== null) {
2516
+ var i;
2517
+ if (!is_fork) {
2518
+ remove_reactions(reaction, skipped_deps);
2519
+ }
2520
+ if (deps !== null && skipped_deps > 0) {
2521
+ deps.length = skipped_deps + new_deps.length;
2522
+ for (i = 0; i < new_deps.length; i++) {
2523
+ deps[skipped_deps + i] = new_deps[i];
2524
+ }
2525
+ } else {
2526
+ reaction.deps = deps = new_deps;
2527
+ }
2528
+ if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
2529
+ for (i = skipped_deps; i < deps.length; i++) {
2530
+ (deps[i].reactions ??= []).push(reaction);
2531
+ }
2532
+ }
2533
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2534
+ remove_reactions(reaction, skipped_deps);
2535
+ deps.length = skipped_deps;
2536
+ }
2537
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) {
2538
+ for (i = 0; i < /** @type {Source[]} */
2539
+ untracked_writes.length; i++) {
2540
+ schedule_possible_effect_self_invalidation(
2541
+ untracked_writes[i],
2542
+ /** @type {Effect} */
2543
+ reaction
2544
+ );
2545
+ }
2546
+ }
2547
+ if (previous_reaction !== null && previous_reaction !== reaction) {
2548
+ read_version++;
2549
+ if (previous_reaction.deps !== null) {
2550
+ for (let i2 = 0; i2 < previous_skipped_deps; i2 += 1) {
2551
+ previous_reaction.deps[i2].rv = read_version;
2552
+ }
2553
+ }
2554
+ if (previous_deps !== null) {
2555
+ for (const dep of previous_deps) {
2556
+ dep.rv = read_version;
2557
+ }
2558
+ }
2559
+ if (untracked_writes !== null) {
2560
+ if (previous_untracked_writes === null) {
2561
+ previous_untracked_writes = untracked_writes;
2562
+ } else {
2563
+ previous_untracked_writes.push(.../** @type {Source[]} */
2564
+ untracked_writes);
2565
+ }
2566
+ }
2567
+ }
2568
+ if ((reaction.f & ERROR_VALUE) !== 0) {
2569
+ reaction.f ^= ERROR_VALUE;
2570
+ }
2571
+ return result;
2572
+ } catch (error) {
2573
+ return handle_error(error);
2574
+ } finally {
2575
+ reaction.f ^= REACTION_IS_UPDATING;
2576
+ new_deps = previous_deps;
2577
+ skipped_deps = previous_skipped_deps;
2578
+ untracked_writes = previous_untracked_writes;
2579
+ active_reaction = previous_reaction;
2580
+ current_sources = previous_sources;
2581
+ set_component_context(previous_component_context);
2582
+ untracking = previous_untracking;
2583
+ update_version = previous_update_version;
2584
+ }
2585
+ }
2586
+ function remove_reaction(signal, dependency) {
2587
+ let reactions = dependency.reactions;
2588
+ if (reactions !== null) {
2589
+ var index = index_of.call(reactions, signal);
2590
+ if (index !== -1) {
2591
+ var new_length = reactions.length - 1;
2592
+ if (new_length === 0) {
2593
+ reactions = dependency.reactions = null;
2594
+ } else {
2595
+ reactions[index] = reactions[new_length];
2596
+ reactions.pop();
2597
+ }
2598
+ }
2599
+ }
2600
+ if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
2601
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
2602
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
2603
+ (new_deps === null || !includes.call(new_deps, dependency))) {
2604
+ var derived = (
2605
+ /** @type {Derived} */
2606
+ dependency
2607
+ );
2608
+ if ((derived.f & CONNECTED) !== 0) {
2609
+ derived.f ^= CONNECTED;
2610
+ derived.f &= ~WAS_MARKED;
2611
+ }
2612
+ update_derived_status(derived);
2613
+ destroy_derived_effects(derived);
2614
+ remove_reactions(derived, 0);
2615
+ }
2616
+ }
2617
+ function remove_reactions(signal, start_index) {
2618
+ var dependencies = signal.deps;
2619
+ if (dependencies === null) return;
2620
+ for (var i = start_index; i < dependencies.length; i++) {
2621
+ remove_reaction(signal, dependencies[i]);
2622
+ }
2623
+ }
2624
+ function update_effect(effect) {
2625
+ var flags = effect.f;
2626
+ if ((flags & DESTROYED) !== 0) {
2627
+ return;
2628
+ }
2629
+ set_signal_status(effect, CLEAN);
2630
+ var previous_effect = active_effect;
2631
+ var was_updating_effect = is_updating_effect;
2632
+ active_effect = effect;
2633
+ is_updating_effect = true;
2634
+ {
2635
+ var previous_component_fn = dev_current_component_function;
2636
+ set_dev_current_component_function(effect.component_function);
2637
+ var previous_stack = (
2638
+ /** @type {any} */
2639
+ dev_stack
2640
+ );
2641
+ set_dev_stack(effect.dev_stack ?? dev_stack);
2642
+ }
2643
+ try {
2644
+ if ((flags & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
2645
+ destroy_block_effect_children(effect);
2646
+ } else {
2647
+ destroy_effect_children(effect);
2648
+ }
2649
+ execute_effect_teardown(effect);
2650
+ var teardown = update_reaction(effect);
2651
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2652
+ effect.wv = write_version;
2653
+ var dep;
2654
+ if (DEV && tracing_mode_flag && (effect.f & DIRTY) !== 0 && effect.deps !== null) ;
2655
+ } finally {
2656
+ is_updating_effect = was_updating_effect;
2657
+ active_effect = previous_effect;
2658
+ {
2659
+ set_dev_current_component_function(previous_component_fn);
2660
+ set_dev_stack(previous_stack);
2661
+ }
2662
+ }
2663
+ }
2664
+ function get(signal) {
2665
+ var flags = signal.f;
2666
+ var is_derived = (flags & DERIVED) !== 0;
2667
+ if (active_reaction !== null && !untracking) {
2668
+ var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
2669
+ if (!destroyed && (current_sources === null || !includes.call(current_sources, signal))) {
2670
+ var deps = active_reaction.deps;
2671
+ if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
2672
+ if (signal.rv < read_version) {
2673
+ signal.rv = read_version;
2674
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
2675
+ skipped_deps++;
2676
+ } else if (new_deps === null) {
2677
+ new_deps = [signal];
2678
+ } else {
2679
+ new_deps.push(signal);
2680
+ }
2681
+ }
2682
+ } else {
2683
+ (active_reaction.deps ??= []).push(signal);
2684
+ var reactions = signal.reactions;
2685
+ if (reactions === null) {
2686
+ signal.reactions = [active_reaction];
2687
+ } else if (!includes.call(reactions, active_reaction)) {
2688
+ reactions.push(active_reaction);
2689
+ }
2690
+ }
2691
+ }
2692
+ }
2693
+ {
2694
+ recent_async_deriveds.delete(signal);
2695
+ }
2696
+ if (is_destroying_effect && old_values.has(signal)) {
2697
+ return old_values.get(signal);
2698
+ }
2699
+ if (is_derived) {
2700
+ var derived = (
2701
+ /** @type {Derived} */
2702
+ signal
2703
+ );
2704
+ if (is_destroying_effect) {
2705
+ var value = derived.v;
2706
+ if ((derived.f & CLEAN) === 0 && derived.reactions !== null || depends_on_old_values(derived)) {
2707
+ value = execute_derived(derived);
2708
+ }
2709
+ old_values.set(derived, value);
2710
+ return value;
2711
+ }
2712
+ var should_connect = (derived.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0);
2713
+ var is_new = derived.deps === null;
2714
+ if (is_dirty(derived)) {
2715
+ if (should_connect) {
2716
+ derived.f |= CONNECTED;
2717
+ }
2718
+ update_derived(derived);
2719
+ }
2720
+ if (should_connect && !is_new) {
2721
+ reconnect(derived);
2722
+ }
2723
+ }
2724
+ if (batch_values?.has(signal)) {
2725
+ return batch_values.get(signal);
2726
+ }
2727
+ if ((signal.f & ERROR_VALUE) !== 0) {
2728
+ throw signal.v;
2729
+ }
2730
+ return signal.v;
2731
+ }
2732
+ function reconnect(derived) {
2733
+ if (derived.deps === null) return;
2734
+ derived.f |= CONNECTED;
2735
+ for (const dep of derived.deps) {
2736
+ (dep.reactions ??= []).push(derived);
2737
+ if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) {
2738
+ reconnect(
2739
+ /** @type {Derived} */
2740
+ dep
2741
+ );
2742
+ }
2743
+ }
2744
+ }
2745
+ function depends_on_old_values(derived) {
2746
+ if (derived.v === UNINITIALIZED) return true;
2747
+ if (derived.deps === null) return false;
2748
+ for (const dep of derived.deps) {
2749
+ if (old_values.has(dep)) {
2750
+ return true;
2751
+ }
2752
+ if ((dep.f & DERIVED) !== 0 && depends_on_old_values(
2753
+ /** @type {Derived} */
2754
+ dep
2755
+ )) {
2756
+ return true;
2757
+ }
2758
+ }
2759
+ return false;
2760
+ }
2761
+ function untrack(fn) {
2762
+ var previous_untracking = untracking;
2763
+ try {
2764
+ untracking = true;
2765
+ return fn();
2766
+ } finally {
2767
+ untracking = previous_untracking;
2768
+ }
2769
+ }
2770
+ const regex_return_characters = /\r/g;
2771
+ function hash(str) {
2772
+ str = str.replace(regex_return_characters, "");
2773
+ let hash2 = 5381;
2774
+ let i = str.length;
2775
+ while (i--) hash2 = (hash2 << 5) - hash2 ^ str.charCodeAt(i);
2776
+ return (hash2 >>> 0).toString(36);
2777
+ }
2778
+ const DOM_BOOLEAN_ATTRIBUTES = [
2779
+ "allowfullscreen",
2780
+ "async",
2781
+ "autofocus",
2782
+ "autoplay",
2783
+ "checked",
2784
+ "controls",
2785
+ "default",
2786
+ "disabled",
2787
+ "formnovalidate",
2788
+ "indeterminate",
2789
+ "inert",
2790
+ "ismap",
2791
+ "loop",
2792
+ "multiple",
2793
+ "muted",
2794
+ "nomodule",
2795
+ "novalidate",
2796
+ "open",
2797
+ "playsinline",
2798
+ "readonly",
2799
+ "required",
2800
+ "reversed",
2801
+ "seamless",
2802
+ "selected",
2803
+ "webkitdirectory",
2804
+ "defer",
2805
+ "disablepictureinpicture",
2806
+ "disableremoteplayback"
2807
+ ];
2808
+ function is_boolean_attribute(name) {
2809
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
2810
+ }
2811
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
2812
+ function is_passive_event(name) {
2813
+ return PASSIVE_EVENTS.includes(name);
2814
+ }
2815
+ function validate_store(store, name) {
2816
+ if (store != null && typeof store.subscribe !== "function") {
2817
+ store_invalid_shape(name);
2818
+ }
2819
+ }
2820
+ function prevent_snippet_stringification(fn) {
2821
+ fn.toString = () => {
2822
+ snippet_without_render_tag();
2823
+ return "";
2824
+ };
2825
+ return fn;
2826
+ }
2827
+ const ATTR_REGEX = /[&"<]/g;
2828
+ const CONTENT_REGEX = /[&<]/g;
2829
+ function escape_html(value, is_attr) {
2830
+ const str = String(value ?? "");
2831
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
2832
+ pattern.lastIndex = 0;
2833
+ let escaped = "";
2834
+ let last = 0;
2835
+ while (pattern.test(str)) {
2836
+ const i = pattern.lastIndex - 1;
2837
+ const ch = str[i];
2838
+ escaped += str.substring(last, i) + (ch === "&" ? "&amp;" : ch === '"' ? "&quot;" : "&lt;");
2839
+ last = i + 1;
2840
+ }
2841
+ return escaped + str.substring(last);
2842
+ }
2843
+ const replacements = {
2844
+ translate: /* @__PURE__ */ new Map([
2845
+ [true, "yes"],
2846
+ [false, "no"]
2847
+ ])
2848
+ };
2849
+ function attr(name, value, is_boolean = false) {
2850
+ if (name === "hidden" && value !== "until-found") {
2851
+ is_boolean = true;
2852
+ }
2853
+ if (value == null || !value && is_boolean) return "";
2854
+ const normalized = name in replacements && replacements[name].get(value) || value;
2855
+ const assignment = is_boolean ? "" : `="${escape_html(normalized, true)}"`;
2856
+ return ` ${name}${assignment}`;
2857
+ }
2858
+ function clsx(value) {
2859
+ if (typeof value === "object") {
2860
+ return clsx$1(value);
2861
+ } else {
2862
+ return value ?? "";
2863
+ }
2864
+ }
2865
+ const whitespace = [..." \n\r\f \v\uFEFF"];
2866
+ function to_class(value, hash2, directives) {
2867
+ var classname = value == null ? "" : "" + value;
2868
+ if (hash2) {
2869
+ classname = classname ? classname + " " + hash2 : hash2;
2870
+ }
2871
+ if (directives) {
2872
+ for (var key in directives) {
2873
+ if (directives[key]) {
2874
+ classname = classname ? classname + " " + key : key;
2875
+ } else if (classname.length) {
2876
+ var len = key.length;
2877
+ var a = 0;
2878
+ while ((a = classname.indexOf(key, a)) >= 0) {
2879
+ var b = a + len;
2880
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
2881
+ classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
2882
+ } else {
2883
+ a = b;
2884
+ }
2885
+ }
2886
+ }
2887
+ }
2888
+ }
2889
+ return classname === "" ? null : classname;
2890
+ }
2891
+ function append_styles(styles, important = false) {
2892
+ var separator = important ? " !important;" : ";";
2893
+ var css = "";
2894
+ for (var key in styles) {
2895
+ var value = styles[key];
2896
+ if (value != null && value !== "") {
2897
+ css += " " + key + ": " + value + separator;
2898
+ }
2899
+ }
2900
+ return css;
2901
+ }
2902
+ function to_css_name(name) {
2903
+ if (name[0] !== "-" || name[1] !== "-") {
2904
+ return name.toLowerCase();
2905
+ }
2906
+ return name;
2907
+ }
2908
+ function to_style(value, styles) {
2909
+ if (styles) {
2910
+ var new_style = "";
2911
+ var normal_styles;
2912
+ var important_styles;
2913
+ if (Array.isArray(styles)) {
2914
+ normal_styles = styles[0];
2915
+ important_styles = styles[1];
2916
+ } else {
2917
+ normal_styles = styles;
2918
+ }
2919
+ if (value) {
2920
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
2921
+ var in_str = false;
2922
+ var in_apo = 0;
2923
+ var in_comment = false;
2924
+ var reserved_names = [];
2925
+ if (normal_styles) {
2926
+ reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
2927
+ }
2928
+ if (important_styles) {
2929
+ reserved_names.push(...Object.keys(important_styles).map(to_css_name));
2930
+ }
2931
+ var start_index = 0;
2932
+ var name_index = -1;
2933
+ const len = value.length;
2934
+ for (var i = 0; i < len; i++) {
2935
+ var c = value[i];
2936
+ if (in_comment) {
2937
+ if (c === "/" && value[i - 1] === "*") {
2938
+ in_comment = false;
2939
+ }
2940
+ } else if (in_str) {
2941
+ if (in_str === c) {
2942
+ in_str = false;
2943
+ }
2944
+ } else if (c === "/" && value[i + 1] === "*") {
2945
+ in_comment = true;
2946
+ } else if (c === '"' || c === "'") {
2947
+ in_str = c;
2948
+ } else if (c === "(") {
2949
+ in_apo++;
2950
+ } else if (c === ")") {
2951
+ in_apo--;
2952
+ }
2953
+ if (!in_comment && in_str === false && in_apo === 0) {
2954
+ if (c === ":" && name_index === -1) {
2955
+ name_index = i;
2956
+ } else if (c === ";" || i === len - 1) {
2957
+ if (name_index !== -1) {
2958
+ var name = to_css_name(value.substring(start_index, name_index).trim());
2959
+ if (!reserved_names.includes(name)) {
2960
+ if (c !== ";") {
2961
+ i++;
2962
+ }
2963
+ var property = value.substring(start_index, i).trim();
2964
+ new_style += " " + property + ";";
2965
+ }
2966
+ }
2967
+ start_index = i + 1;
2968
+ name_index = -1;
2969
+ }
2970
+ }
2971
+ }
2972
+ }
2973
+ if (normal_styles) {
2974
+ new_style += append_styles(normal_styles);
2975
+ }
2976
+ if (important_styles) {
2977
+ new_style += append_styles(important_styles, true);
2978
+ }
2979
+ new_style = new_style.trim();
2980
+ return new_style === "" ? null : new_style;
2981
+ }
2982
+ return value == null ? null : String(value);
2983
+ }
2984
+ {
2985
+ let throw_rune_error = function(rune) {
2986
+ if (!(rune in globalThis)) {
2987
+ let value;
2988
+ Object.defineProperty(globalThis, rune, {
2989
+ configurable: true,
2990
+ // eslint-disable-next-line getter-return
2991
+ get: () => {
2992
+ if (value !== void 0) {
2993
+ return value;
2994
+ }
2995
+ rune_outside_svelte(rune);
2996
+ },
2997
+ set: (v) => {
2998
+ value = v;
2999
+ }
3000
+ });
3001
+ }
3002
+ };
3003
+ throw_rune_error("$state");
3004
+ throw_rune_error("$effect");
3005
+ throw_rune_error("$derived");
3006
+ throw_rune_error("$inspect");
3007
+ throw_rune_error("$props");
3008
+ throw_rune_error("$bindable");
3009
+ }
3010
+ function subscribe_to_store(store, run, invalidate) {
3011
+ if (store == null) {
3012
+ run(void 0);
3013
+ return noop;
3014
+ }
3015
+ const unsub = untrack(
3016
+ () => store.subscribe(
3017
+ run,
3018
+ // @ts-expect-error
3019
+ invalidate
3020
+ )
3021
+ );
3022
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
3023
+ }
3024
+ const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
3025
+ const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
3026
+ const EMPTY_COMMENT = `<!---->`;
3027
+ let controller = null;
3028
+ function abort() {
3029
+ controller?.abort(STALE_REACTION);
3030
+ controller = null;
3031
+ }
3032
+ function await_invalid() {
3033
+ const error = new Error(`await_invalid
3034
+ Encountered asynchronous work while rendering synchronously.
3035
+ https://svelte.dev/e/await_invalid`);
3036
+ error.name = "Svelte error";
3037
+ throw error;
3038
+ }
3039
+ function invalid_csp() {
3040
+ const error = new Error(`invalid_csp
3041
+ \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
3042
+ https://svelte.dev/e/invalid_csp`);
3043
+ error.name = "Svelte error";
3044
+ throw error;
3045
+ }
3046
+ function server_context_required() {
3047
+ const error = new Error(`server_context_required
3048
+ Could not resolve \`render\` context.
3049
+ https://svelte.dev/e/server_context_required`);
3050
+ error.name = "Svelte error";
3051
+ throw error;
3052
+ }
3053
+ var ssr_context = null;
3054
+ function set_ssr_context(v) {
3055
+ ssr_context = v;
3056
+ }
3057
+ function getContext(key) {
3058
+ const context_map = get_or_init_context_map("getContext");
3059
+ const result = (
3060
+ /** @type {T} */
3061
+ context_map.get(key)
3062
+ );
3063
+ return result;
3064
+ }
3065
+ function setContext(key, context) {
3066
+ get_or_init_context_map("setContext").set(key, context);
3067
+ return context;
3068
+ }
3069
+ function get_or_init_context_map(name) {
3070
+ if (ssr_context === null) {
3071
+ lifecycle_outside_component(name);
3072
+ }
3073
+ return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0);
3074
+ }
3075
+ function push(fn) {
3076
+ ssr_context = { p: ssr_context, c: null, r: null };
3077
+ {
3078
+ ssr_context.function = fn;
3079
+ ssr_context.element = ssr_context.p?.element;
3080
+ }
3081
+ }
3082
+ function pop() {
3083
+ ssr_context = /** @type {SSRContext} */
3084
+ ssr_context.p;
3085
+ }
3086
+ function get_parent_context(ssr_context2) {
3087
+ let parent = ssr_context2.p;
3088
+ while (parent !== null) {
3089
+ const context_map = parent.c;
3090
+ if (context_map !== null) {
3091
+ return context_map;
3092
+ }
3093
+ parent = parent.p;
3094
+ }
3095
+ return null;
3096
+ }
3097
+ var bold = "font-weight: bold";
3098
+ var normal = "font-weight: normal";
3099
+ function unresolved_hydratable(key, stack2) {
3100
+ {
3101
+ console.warn(
3102
+ `%c[svelte] unresolved_hydratable
3103
+ %cA \`hydratable\` value with key \`${key}\` was created, but at least part of it was not used during the render.
3104
+
3105
+ The \`hydratable\` was initialized in:
3106
+ ${stack2}
3107
+ https://svelte.dev/e/unresolved_hydratable`,
3108
+ bold,
3109
+ normal
3110
+ );
3111
+ }
3112
+ }
3113
+ function get_render_context() {
3114
+ const store = als?.getStore();
3115
+ {
3116
+ server_context_required();
3117
+ }
3118
+ return store;
3119
+ }
3120
+ let als = null;
3121
+ let text_encoder;
3122
+ let crypto;
3123
+ async function sha256(data) {
3124
+ text_encoder ??= new TextEncoder();
3125
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
3126
+ // @ts-ignore - we don't install node types in the prod build
3127
+ (await import('node:crypto')).webcrypto
3128
+ );
3129
+ const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
3130
+ return base64_encode(hash_buffer);
3131
+ }
3132
+ function base64_encode(bytes) {
3133
+ if (globalThis.Buffer) {
3134
+ return globalThis.Buffer.from(bytes).toString("base64");
3135
+ }
3136
+ let binary = "";
3137
+ for (let i = 0; i < bytes.length; i++) {
3138
+ binary += String.fromCharCode(bytes[i]);
3139
+ }
3140
+ return btoa(binary);
3141
+ }
3142
+ class Renderer {
3143
+ /**
3144
+ * The contents of the renderer.
3145
+ * @type {RendererItem[]}
3146
+ */
3147
+ #out = [];
3148
+ /**
3149
+ * Any `onDestroy` callbacks registered during execution of this renderer.
3150
+ * @type {(() => void)[] | undefined}
3151
+ */
3152
+ #on_destroy = void 0;
3153
+ /**
3154
+ * Whether this renderer is a component body.
3155
+ * @type {boolean}
3156
+ */
3157
+ #is_component_body = false;
3158
+ /**
3159
+ * The type of string content that this renderer is accumulating.
3160
+ * @type {RendererType}
3161
+ */
3162
+ type;
3163
+ /** @type {Renderer | undefined} */
3164
+ #parent;
3165
+ /**
3166
+ * Asynchronous work associated with this renderer
3167
+ * @type {Promise<void> | undefined}
3168
+ */
3169
+ promise = void 0;
3170
+ /**
3171
+ * State which is associated with the content tree as a whole.
3172
+ * It will be re-exposed, uncopied, on all children.
3173
+ * @type {SSRState}
3174
+ * @readonly
3175
+ */
3176
+ global;
3177
+ /**
3178
+ * State that is local to the branch it is declared in.
3179
+ * It will be shallow-copied to all children.
3180
+ *
3181
+ * @type {{ select_value: string | undefined }}
3182
+ */
3183
+ local;
3184
+ /**
3185
+ * @param {SSRState} global
3186
+ * @param {Renderer | undefined} [parent]
3187
+ */
3188
+ constructor(global, parent) {
3189
+ this.#parent = parent;
3190
+ this.global = global;
3191
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
3192
+ this.type = parent ? parent.type : "body";
3193
+ }
3194
+ /**
3195
+ * @param {(renderer: Renderer) => void} fn
3196
+ */
3197
+ head(fn) {
3198
+ const head2 = new Renderer(this.global, this);
3199
+ head2.type = "head";
3200
+ this.#out.push(head2);
3201
+ head2.child(fn);
3202
+ }
3203
+ /**
3204
+ * @param {Array<Promise<void>>} blockers
3205
+ * @param {(renderer: Renderer) => void} fn
3206
+ */
3207
+ async_block(blockers, fn) {
3208
+ this.#out.push(BLOCK_OPEN);
3209
+ this.async(blockers, fn);
3210
+ this.#out.push(BLOCK_CLOSE);
3211
+ }
3212
+ /**
3213
+ * @param {Array<Promise<void>>} blockers
3214
+ * @param {(renderer: Renderer) => void} fn
3215
+ */
3216
+ async(blockers, fn) {
3217
+ let callback = fn;
3218
+ if (blockers.length > 0) {
3219
+ const context = ssr_context;
3220
+ callback = (renderer) => {
3221
+ return Promise.all(blockers).then(() => {
3222
+ const previous_context = ssr_context;
3223
+ try {
3224
+ set_ssr_context(context);
3225
+ return fn(renderer);
3226
+ } finally {
3227
+ set_ssr_context(previous_context);
3228
+ }
3229
+ });
3230
+ };
3231
+ }
3232
+ this.child(callback);
3233
+ }
3234
+ /**
3235
+ * @param {Array<() => void>} thunks
3236
+ */
3237
+ run(thunks) {
3238
+ const context = ssr_context;
3239
+ let promise = Promise.resolve(thunks[0]());
3240
+ const promises = [promise];
3241
+ for (const fn of thunks.slice(1)) {
3242
+ promise = promise.then(() => {
3243
+ const previous_context = ssr_context;
3244
+ set_ssr_context(context);
3245
+ try {
3246
+ return fn();
3247
+ } finally {
3248
+ set_ssr_context(previous_context);
3249
+ }
3250
+ });
3251
+ promises.push(promise);
3252
+ }
3253
+ promise.catch(noop);
3254
+ this.promise = promise;
3255
+ return promises;
3256
+ }
3257
+ /**
3258
+ * Create a child renderer. The child renderer inherits the state from the parent,
3259
+ * but has its own content.
3260
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
3261
+ */
3262
+ child(fn) {
3263
+ const child = new Renderer(this.global, this);
3264
+ this.#out.push(child);
3265
+ const parent = ssr_context;
3266
+ set_ssr_context({
3267
+ ...ssr_context,
3268
+ p: parent,
3269
+ c: null,
3270
+ r: child
3271
+ });
3272
+ const result = fn(child);
3273
+ set_ssr_context(parent);
3274
+ if (result instanceof Promise) {
3275
+ if (child.global.mode === "sync") {
3276
+ await_invalid();
3277
+ }
3278
+ result.catch(() => {
3279
+ });
3280
+ child.promise = result;
3281
+ }
3282
+ return child;
3283
+ }
3284
+ /**
3285
+ * Create a component renderer. The component renderer inherits the state from the parent,
3286
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
3287
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
3288
+ * @param {Function} [component_fn]
3289
+ * @returns {void}
3290
+ */
3291
+ component(fn, component_fn) {
3292
+ push(component_fn);
3293
+ const child = this.child(fn);
3294
+ child.#is_component_body = true;
3295
+ pop();
3296
+ }
3297
+ /**
3298
+ * @param {Record<string, any>} attrs
3299
+ * @param {(renderer: Renderer) => void} fn
3300
+ * @param {string | undefined} [css_hash]
3301
+ * @param {Record<string, boolean> | undefined} [classes]
3302
+ * @param {Record<string, string> | undefined} [styles]
3303
+ * @param {number | undefined} [flags]
3304
+ * @param {boolean | undefined} [is_rich]
3305
+ * @returns {void}
3306
+ */
3307
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
3308
+ const { value, ...select_attrs } = attrs;
3309
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
3310
+ this.child((renderer) => {
3311
+ renderer.local.select_value = value;
3312
+ fn(renderer);
3313
+ });
3314
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
3315
+ }
3316
+ /**
3317
+ * @param {Record<string, any>} attrs
3318
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
3319
+ * @param {string | undefined} [css_hash]
3320
+ * @param {Record<string, boolean> | undefined} [classes]
3321
+ * @param {Record<string, string> | undefined} [styles]
3322
+ * @param {number | undefined} [flags]
3323
+ * @param {boolean | undefined} [is_rich]
3324
+ */
3325
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
3326
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
3327
+ const close = (renderer, value, { head: head2, body: body2 }) => {
3328
+ if ("value" in attrs) {
3329
+ value = attrs.value;
3330
+ }
3331
+ if (value === this.local.select_value) {
3332
+ renderer.#out.push(" selected");
3333
+ }
3334
+ renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
3335
+ if (head2) {
3336
+ renderer.head((child) => child.push(head2));
3337
+ }
3338
+ };
3339
+ if (typeof body === "function") {
3340
+ this.child((renderer) => {
3341
+ const r = new Renderer(this.global, this);
3342
+ body(r);
3343
+ if (this.global.mode === "async") {
3344
+ return r.#collect_content_async().then((content) => {
3345
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
3346
+ });
3347
+ } else {
3348
+ const content = r.#collect_content();
3349
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
3350
+ }
3351
+ });
3352
+ } else {
3353
+ close(this, body, { body });
3354
+ }
3355
+ }
3356
+ /**
3357
+ * @param {(renderer: Renderer) => void} fn
3358
+ */
3359
+ title(fn) {
3360
+ const path = this.get_path();
3361
+ const close = (head2) => {
3362
+ this.global.set_title(head2, path);
3363
+ };
3364
+ this.child((renderer) => {
3365
+ const r = new Renderer(renderer.global, renderer);
3366
+ fn(r);
3367
+ if (renderer.global.mode === "async") {
3368
+ return r.#collect_content_async().then((content) => {
3369
+ close(content.head);
3370
+ });
3371
+ } else {
3372
+ const content = r.#collect_content();
3373
+ close(content.head);
3374
+ }
3375
+ });
3376
+ }
3377
+ /**
3378
+ * @param {string | (() => Promise<string>)} content
3379
+ */
3380
+ push(content) {
3381
+ if (typeof content === "function") {
3382
+ this.child(async (renderer) => renderer.push(await content()));
3383
+ } else {
3384
+ this.#out.push(content);
3385
+ }
3386
+ }
3387
+ /**
3388
+ * @param {() => void} fn
3389
+ */
3390
+ on_destroy(fn) {
3391
+ (this.#on_destroy ??= []).push(fn);
3392
+ }
3393
+ /**
3394
+ * @returns {number[]}
3395
+ */
3396
+ get_path() {
3397
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
3398
+ }
3399
+ /**
3400
+ * @deprecated this is needed for legacy component bindings
3401
+ */
3402
+ copy() {
3403
+ const copy = new Renderer(this.global, this.#parent);
3404
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
3405
+ copy.promise = this.promise;
3406
+ return copy;
3407
+ }
3408
+ /**
3409
+ * @param {Renderer} other
3410
+ * @deprecated this is needed for legacy component bindings
3411
+ */
3412
+ subsume(other) {
3413
+ if (this.global.mode !== other.global.mode) {
3414
+ throw new Error(
3415
+ "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
3416
+ );
3417
+ }
3418
+ this.local = other.local;
3419
+ this.#out = other.#out.map((item) => {
3420
+ if (item instanceof Renderer) {
3421
+ item.subsume(item);
3422
+ }
3423
+ return item;
3424
+ });
3425
+ this.promise = other.promise;
3426
+ this.type = other.type;
3427
+ }
3428
+ get length() {
3429
+ return this.#out.length;
3430
+ }
3431
+ /**
3432
+ * Only available on the server and when compiling with the `server` option.
3433
+ * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
3434
+ * @template {Record<string, any>} Props
3435
+ * @param {Component<Props>} component
3436
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
3437
+ * @returns {RenderOutput}
3438
+ */
3439
+ static render(component, options = {}) {
3440
+ let sync;
3441
+ const result = (
3442
+ /** @type {RenderOutput} */
3443
+ {}
3444
+ );
3445
+ Object.defineProperties(result, {
3446
+ html: {
3447
+ get: () => {
3448
+ return (sync ??= Renderer.#render(component, options)).body;
3449
+ }
3450
+ },
3451
+ head: {
3452
+ get: () => {
3453
+ return (sync ??= Renderer.#render(component, options)).head;
3454
+ }
3455
+ },
3456
+ body: {
3457
+ get: () => {
3458
+ return (sync ??= Renderer.#render(component, options)).body;
3459
+ }
3460
+ },
3461
+ hashes: {
3462
+ value: {
3463
+ script: ""
3464
+ }
3465
+ },
3466
+ then: {
3467
+ value: (
3468
+ /**
3469
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
3470
+ *
3471
+ * @template TResult1
3472
+ * @template [TResult2=never]
3473
+ * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
3474
+ * @param { (reason: unknown) => TResult2 } onrejected
3475
+ */
3476
+ (onfulfilled, onrejected) => {
3477
+ {
3478
+ const result2 = sync ??= Renderer.#render(component, options);
3479
+ const user_result = onfulfilled({
3480
+ head: result2.head,
3481
+ body: result2.body,
3482
+ html: result2.body,
3483
+ hashes: { script: [] }
3484
+ });
3485
+ return Promise.resolve(user_result);
3486
+ }
3487
+ }
3488
+ )
3489
+ }
3490
+ });
3491
+ return result;
3492
+ }
3493
+ /**
3494
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
3495
+ * after awaiting `collect_async`.
3496
+ *
3497
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
3498
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
3499
+ * @returns {Iterable<() => void>}
3500
+ */
3501
+ *#collect_on_destroy() {
3502
+ for (const component of this.#traverse_components()) {
3503
+ yield* component.#collect_ondestroy();
3504
+ }
3505
+ }
3506
+ /**
3507
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
3508
+ * @returns {Iterable<Renderer>}
3509
+ */
3510
+ *#traverse_components() {
3511
+ for (const child of this.#out) {
3512
+ if (typeof child !== "string") {
3513
+ yield* child.#traverse_components();
3514
+ }
3515
+ }
3516
+ if (this.#is_component_body) {
3517
+ yield this;
3518
+ }
3519
+ }
3520
+ /**
3521
+ * @returns {Iterable<() => void>}
3522
+ */
3523
+ *#collect_ondestroy() {
3524
+ if (this.#on_destroy) {
3525
+ for (const fn of this.#on_destroy) {
3526
+ yield fn;
3527
+ }
3528
+ }
3529
+ for (const child of this.#out) {
3530
+ if (child instanceof Renderer && !child.#is_component_body) {
3531
+ yield* child.#collect_ondestroy();
3532
+ }
3533
+ }
3534
+ }
3535
+ /**
3536
+ * Render a component. Throws if any of the children are performing asynchronous work.
3537
+ *
3538
+ * @template {Record<string, any>} Props
3539
+ * @param {Component<Props>} component
3540
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
3541
+ * @returns {AccumulatedContent}
3542
+ */
3543
+ static #render(component, options) {
3544
+ var previous_context = ssr_context;
3545
+ try {
3546
+ const renderer = Renderer.#open_render("sync", component, options);
3547
+ const content = renderer.#collect_content();
3548
+ return Renderer.#close_render(content, renderer);
3549
+ } finally {
3550
+ abort();
3551
+ set_ssr_context(previous_context);
3552
+ }
3553
+ }
3554
+ /**
3555
+ * Render a component.
3556
+ *
3557
+ * @template {Record<string, any>} Props
3558
+ * @param {Component<Props>} component
3559
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
3560
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
3561
+ */
3562
+ static async #render_async(component, options) {
3563
+ const previous_context = ssr_context;
3564
+ try {
3565
+ const renderer = Renderer.#open_render("async", component, options);
3566
+ const content = await renderer.#collect_content_async();
3567
+ const hydratables = await renderer.#collect_hydratables();
3568
+ if (hydratables !== null) {
3569
+ content.head = hydratables + content.head;
3570
+ }
3571
+ return Renderer.#close_render(content, renderer);
3572
+ } finally {
3573
+ set_ssr_context(previous_context);
3574
+ abort();
3575
+ }
3576
+ }
3577
+ /**
3578
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
3579
+ * @param {AccumulatedContent} content
3580
+ * @returns {AccumulatedContent}
3581
+ */
3582
+ #collect_content(content = { head: "", body: "" }) {
3583
+ for (const item of this.#out) {
3584
+ if (typeof item === "string") {
3585
+ content[this.type] += item;
3586
+ } else if (item instanceof Renderer) {
3587
+ item.#collect_content(content);
3588
+ }
3589
+ }
3590
+ return content;
3591
+ }
3592
+ /**
3593
+ * Collect all of the code from the `out` array and return it as a string.
3594
+ * @param {AccumulatedContent} content
3595
+ * @returns {Promise<AccumulatedContent>}
3596
+ */
3597
+ async #collect_content_async(content = { head: "", body: "" }) {
3598
+ await this.promise;
3599
+ for (const item of this.#out) {
3600
+ if (typeof item === "string") {
3601
+ content[this.type] += item;
3602
+ } else if (item instanceof Renderer) {
3603
+ await item.#collect_content_async(content);
3604
+ }
3605
+ }
3606
+ return content;
3607
+ }
3608
+ async #collect_hydratables() {
3609
+ const ctx = get_render_context().hydratable;
3610
+ for (const [_, key] of ctx.unresolved_promises) {
3611
+ unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
3612
+ }
3613
+ for (const comparison of ctx.comparisons) {
3614
+ await comparison;
3615
+ }
3616
+ return await this.#hydratable_block(ctx);
3617
+ }
3618
+ /**
3619
+ * @template {Record<string, any>} Props
3620
+ * @param {'sync' | 'async'} mode
3621
+ * @param {import('svelte').Component<Props>} component
3622
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
3623
+ * @returns {Renderer}
3624
+ */
3625
+ static #open_render(mode, component, options) {
3626
+ const renderer = new Renderer(
3627
+ new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp)
3628
+ );
3629
+ renderer.push(BLOCK_OPEN);
3630
+ if (options.context) {
3631
+ push();
3632
+ ssr_context.c = options.context;
3633
+ ssr_context.r = renderer;
3634
+ }
3635
+ component(renderer, options.props ?? {});
3636
+ if (options.context) {
3637
+ pop();
3638
+ }
3639
+ renderer.push(BLOCK_CLOSE);
3640
+ return renderer;
3641
+ }
3642
+ /**
3643
+ * @param {AccumulatedContent} content
3644
+ * @param {Renderer} renderer
3645
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
3646
+ */
3647
+ static #close_render(content, renderer) {
3648
+ for (const cleanup of renderer.#collect_on_destroy()) {
3649
+ cleanup();
3650
+ }
3651
+ let head2 = content.head + renderer.global.get_title();
3652
+ let body = content.body;
3653
+ for (const { hash: hash2, code } of renderer.global.css) {
3654
+ head2 += `<style id="${hash2}">${code}</style>`;
3655
+ }
3656
+ return {
3657
+ head: head2,
3658
+ body,
3659
+ hashes: {
3660
+ script: renderer.global.csp.script_hashes
3661
+ }
3662
+ };
3663
+ }
3664
+ /**
3665
+ * @param {HydratableContext} ctx
3666
+ */
3667
+ async #hydratable_block(ctx) {
3668
+ if (ctx.lookup.size === 0) {
3669
+ return null;
3670
+ }
3671
+ let entries = [];
3672
+ let has_promises = false;
3673
+ for (const [k, v] of ctx.lookup) {
3674
+ if (v.promises) {
3675
+ has_promises = true;
3676
+ for (const p of v.promises) await p;
3677
+ }
3678
+ entries.push(`[${uneval(k)},${v.serialized}]`);
3679
+ }
3680
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
3681
+ if (has_promises) {
3682
+ prelude = `const r = (v) => Promise.resolve(v);
3683
+ ${prelude}`;
3684
+ }
3685
+ const body = `
3686
+ {
3687
+ ${prelude}
3688
+
3689
+ for (const [k, v] of [
3690
+ ${entries.join(",\n ")}
3691
+ ]) {
3692
+ h.set(k, v);
3693
+ }
3694
+ }
3695
+ `;
3696
+ let csp_attr = "";
3697
+ if (this.global.csp.nonce) {
3698
+ csp_attr = ` nonce="${this.global.csp.nonce}"`;
3699
+ } else if (this.global.csp.hash) {
3700
+ const hash2 = await sha256(body);
3701
+ this.global.csp.script_hashes.push(`sha256-${hash2}`);
3702
+ }
3703
+ return `
3704
+ <script${csp_attr}>${body}<\/script>`;
3705
+ }
3706
+ }
3707
+ class SSRState {
3708
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
3709
+ csp;
3710
+ /** @readonly @type {'sync' | 'async'} */
3711
+ mode;
3712
+ /** @readonly @type {() => string} */
3713
+ uid;
3714
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
3715
+ css = /* @__PURE__ */ new Set();
3716
+ /** @type {{ path: number[], value: string }} */
3717
+ #title = { path: [], value: "" };
3718
+ /**
3719
+ * @param {'sync' | 'async'} mode
3720
+ * @param {string} id_prefix
3721
+ * @param {Csp} csp
3722
+ */
3723
+ constructor(mode, id_prefix = "", csp = { hash: false }) {
3724
+ this.mode = mode;
3725
+ this.csp = { ...csp, script_hashes: [] };
3726
+ let uid = 1;
3727
+ this.uid = () => `${id_prefix}s${uid++}`;
3728
+ }
3729
+ get_title() {
3730
+ return this.#title.value;
3731
+ }
3732
+ /**
3733
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
3734
+ * from earlier than or equal to the current value.
3735
+ * @param {string} value
3736
+ * @param {number[]} path
3737
+ */
3738
+ set_title(value, path) {
3739
+ const current = this.#title.path;
3740
+ let i = 0;
3741
+ let l = Math.min(path.length, current.length);
3742
+ while (i < l && path[i] === current[i]) i += 1;
3743
+ if (path[i] === void 0) return;
3744
+ if (current[i] === void 0 || path[i] > current[i]) {
3745
+ this.#title.path = path;
3746
+ this.#title.value = value;
3747
+ }
3748
+ }
3749
+ }
3750
+ const INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
3751
+ function render(component, options = {}) {
3752
+ if (options.csp?.hash && options.csp.nonce) {
3753
+ invalid_csp();
3754
+ }
3755
+ return Renderer.render(
3756
+ /** @type {Component<Props>} */
3757
+ component,
3758
+ options
3759
+ );
3760
+ }
3761
+ function head(hash2, renderer, fn) {
3762
+ renderer.head((renderer2) => {
3763
+ renderer2.push(`<!--${hash2}-->`);
3764
+ renderer2.child(fn);
3765
+ renderer2.push(EMPTY_COMMENT);
3766
+ });
3767
+ }
3768
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
3769
+ if (styles) {
3770
+ attrs.style = to_style(attrs.style, styles);
3771
+ }
3772
+ if (attrs.class) {
3773
+ attrs.class = clsx(attrs.class);
3774
+ }
3775
+ if (css_hash || classes) {
3776
+ attrs.class = to_class(attrs.class, css_hash, classes);
3777
+ }
3778
+ let attr_str = "";
3779
+ let name;
3780
+ const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
3781
+ const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
3782
+ const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
3783
+ for (name in attrs) {
3784
+ if (typeof attrs[name] === "function") continue;
3785
+ if (name[0] === "$" && name[1] === "$") continue;
3786
+ if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
3787
+ var value = attrs[name];
3788
+ if (lowercase) {
3789
+ name = name.toLowerCase();
3790
+ }
3791
+ if (is_input) {
3792
+ if (name === "defaultvalue" || name === "defaultchecked") {
3793
+ name = name === "defaultvalue" ? "value" : "checked";
3794
+ if (attrs[name]) continue;
3795
+ }
3796
+ }
3797
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
3798
+ }
3799
+ return attr_str;
3800
+ }
3801
+ function spread_props(props) {
3802
+ const merged_props = {};
3803
+ let key;
3804
+ for (let i = 0; i < props.length; i++) {
3805
+ const obj = props[i];
3806
+ for (key in obj) {
3807
+ const desc = Object.getOwnPropertyDescriptor(obj, key);
3808
+ if (desc) {
3809
+ Object.defineProperty(merged_props, key, desc);
3810
+ } else {
3811
+ merged_props[key] = obj[key];
3812
+ }
3813
+ }
3814
+ }
3815
+ return merged_props;
3816
+ }
3817
+ function stringify(value) {
3818
+ return typeof value === "string" ? value : value == null ? "" : value + "";
3819
+ }
3820
+ function attr_class(value, hash2, directives) {
3821
+ var result = to_class(value, hash2, directives);
3822
+ return result ? ` class="${escape_html(result, true)}"` : "";
3823
+ }
3824
+ function attr_style(value, directives) {
3825
+ var result = to_style(value, directives);
3826
+ return result ? ` style="${escape_html(result, true)}"` : "";
3827
+ }
3828
+ function store_get(store_values, store_name, store) {
3829
+ {
3830
+ validate_store(store, store_name.slice(1));
3831
+ }
3832
+ if (store_name in store_values && store_values[store_name][0] === store) {
3833
+ return store_values[store_name][2];
3834
+ }
3835
+ store_values[store_name]?.[1]();
3836
+ store_values[store_name] = [store, null, void 0];
3837
+ const unsub = subscribe_to_store(
3838
+ store,
3839
+ /** @param {any} v */
3840
+ (v) => store_values[store_name][2] = v
3841
+ );
3842
+ store_values[store_name][1] = unsub;
3843
+ return store_values[store_name][2];
3844
+ }
3845
+ function unsubscribe_stores(store_values) {
3846
+ for (const store_name in store_values) {
3847
+ store_values[store_name][1]();
3848
+ }
3849
+ }
3850
+ function bind_props(props_parent, props_now) {
3851
+ for (const key in props_now) {
3852
+ const initial_value = props_parent[key];
3853
+ const value = props_now[key];
3854
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) {
3855
+ props_parent[key] = value;
3856
+ }
3857
+ }
3858
+ }
3859
+ function ensure_array_like(array_like_or_iterator) {
3860
+ if (array_like_or_iterator) {
3861
+ return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
3862
+ }
3863
+ return [];
3864
+ }
3865
+
3866
+ const SCHEME = /^[a-z][a-z\d+\-.]+:/i;
3867
+ const internal = new URL("sveltekit-internal://");
3868
+ function resolve(base, path) {
3869
+ if (path[0] === "/" && path[1] === "/") return path;
3870
+ let url = new URL(base, internal);
3871
+ url = new URL(path, url);
3872
+ return url.protocol === internal.protocol ? url.pathname + url.search + url.hash : url.href;
3873
+ }
3874
+ function normalize_path(path, trailing_slash) {
3875
+ if (path === "/" || trailing_slash === "ignore") return path;
3876
+ if (trailing_slash === "never") {
3877
+ return path.endsWith("/") ? path.slice(0, -1) : path;
3878
+ } else if (trailing_slash === "always" && !path.endsWith("/")) {
3879
+ return path + "/";
3880
+ }
3881
+ return path;
3882
+ }
3883
+ function decode_pathname(pathname) {
3884
+ return pathname.split("%25").map(decodeURI).join("%25");
3885
+ }
3886
+ function decode_params(params) {
3887
+ for (const key in params) {
3888
+ params[key] = decodeURIComponent(params[key]);
3889
+ }
3890
+ return params;
3891
+ }
3892
+ function make_trackable(url, callback, search_params_callback, allow_hash = false) {
3893
+ const tracked = new URL(url);
3894
+ Object.defineProperty(tracked, "searchParams", {
3895
+ value: new Proxy(tracked.searchParams, {
3896
+ get(obj, key) {
3897
+ if (key === "get" || key === "getAll" || key === "has") {
3898
+ return (param, ...rest) => {
3899
+ search_params_callback(param);
3900
+ return obj[key](param, ...rest);
3901
+ };
3902
+ }
3903
+ callback();
3904
+ const value = Reflect.get(obj, key);
3905
+ return typeof value === "function" ? value.bind(obj) : value;
3906
+ }
3907
+ }),
3908
+ enumerable: true,
3909
+ configurable: true
3910
+ });
3911
+ const tracked_url_properties = ["href", "pathname", "search", "toString", "toJSON"];
3912
+ if (allow_hash) tracked_url_properties.push("hash");
3913
+ for (const property of tracked_url_properties) {
3914
+ Object.defineProperty(tracked, property, {
3915
+ get() {
3916
+ callback();
3917
+ return url[property];
3918
+ },
3919
+ enumerable: true,
3920
+ configurable: true
3921
+ });
3922
+ }
3923
+ {
3924
+ tracked[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => {
3925
+ return inspect(url, opts);
3926
+ };
3927
+ tracked.searchParams[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => {
3928
+ return inspect(url.searchParams, opts);
3929
+ };
3930
+ }
3931
+ if (!allow_hash) {
3932
+ disable_hash(tracked);
3933
+ }
3934
+ return tracked;
3935
+ }
3936
+ function disable_hash(url) {
3937
+ allow_nodejs_console_log(url);
3938
+ Object.defineProperty(url, "hash", {
3939
+ get() {
3940
+ throw new Error(
3941
+ "Cannot access event.url.hash. Consider using `page.url.hash` inside a component instead"
3942
+ );
3943
+ }
3944
+ });
3945
+ }
3946
+ function disable_search(url) {
3947
+ allow_nodejs_console_log(url);
3948
+ for (const property of ["search", "searchParams"]) {
3949
+ Object.defineProperty(url, property, {
3950
+ get() {
3951
+ throw new Error(`Cannot access url.${property} on a page with prerendering enabled`);
3952
+ }
3953
+ });
3954
+ }
3955
+ }
3956
+ function allow_nodejs_console_log(url) {
3957
+ {
3958
+ url[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => {
3959
+ return inspect(new URL(url), opts);
3960
+ };
3961
+ }
3962
+ }
3963
+ const subscriber_queue = [];
3964
+ function readable(value, start) {
3965
+ return {
3966
+ subscribe: writable(value, start).subscribe
3967
+ };
3968
+ }
3969
+ function writable(value, start = noop) {
3970
+ let stop = null;
3971
+ const subscribers = /* @__PURE__ */ new Set();
3972
+ function set(new_value) {
3973
+ if (safe_not_equal(value, new_value)) {
3974
+ value = new_value;
3975
+ if (stop) {
3976
+ const run_queue = !subscriber_queue.length;
3977
+ for (const subscriber of subscribers) {
3978
+ subscriber[1]();
3979
+ subscriber_queue.push(subscriber, value);
3980
+ }
3981
+ if (run_queue) {
3982
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
3983
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
3984
+ }
3985
+ subscriber_queue.length = 0;
3986
+ }
3987
+ }
3988
+ }
3989
+ }
3990
+ function update(fn) {
3991
+ set(fn(
3992
+ /** @type {T} */
3993
+ value
3994
+ ));
3995
+ }
3996
+ function subscribe(run, invalidate = noop) {
3997
+ const subscriber = [run, invalidate];
3998
+ subscribers.add(subscriber);
3999
+ if (subscribers.size === 1) {
4000
+ stop = start(set, update) || noop;
4001
+ }
4002
+ run(
4003
+ /** @type {T} */
4004
+ value
4005
+ );
4006
+ return () => {
4007
+ subscribers.delete(subscriber);
4008
+ if (subscribers.size === 0 && stop) {
4009
+ stop();
4010
+ stop = null;
4011
+ }
4012
+ };
4013
+ }
4014
+ return { set, update, subscribe };
4015
+ }
4016
+ function validator(expected) {
4017
+ function validate(module, file) {
4018
+ if (!module) return;
4019
+ for (const key in module) {
4020
+ if (key[0] === "_" || expected.has(key)) continue;
4021
+ const values = [...expected.values()];
4022
+ const hint = hint_for_supported_files(key, file?.slice(file.lastIndexOf("."))) ?? `valid exports are ${values.join(", ")}, or anything with a '_' prefix`;
4023
+ throw new Error(`Invalid export '${key}'${file ? ` in ${file}` : ""} (${hint})`);
4024
+ }
4025
+ }
4026
+ return validate;
4027
+ }
4028
+ function hint_for_supported_files(key, ext = ".js") {
4029
+ const supported_files = [];
4030
+ if (valid_layout_exports.has(key)) {
4031
+ supported_files.push(`+layout${ext}`);
4032
+ }
4033
+ if (valid_page_exports.has(key)) {
4034
+ supported_files.push(`+page${ext}`);
4035
+ }
4036
+ if (valid_layout_server_exports.has(key)) {
4037
+ supported_files.push(`+layout.server${ext}`);
4038
+ }
4039
+ if (valid_page_server_exports.has(key)) {
4040
+ supported_files.push(`+page.server${ext}`);
4041
+ }
4042
+ if (valid_server_exports.has(key)) {
4043
+ supported_files.push(`+server${ext}`);
4044
+ }
4045
+ if (supported_files.length > 0) {
4046
+ return `'${key}' is a valid export in ${supported_files.slice(0, -1).join(", ")}${supported_files.length > 1 ? " or " : ""}${supported_files.at(-1)}`;
4047
+ }
4048
+ }
4049
+ const valid_layout_exports = /* @__PURE__ */ new Set([
4050
+ "load",
4051
+ "prerender",
4052
+ "csr",
4053
+ "ssr",
4054
+ "trailingSlash",
4055
+ "config"
4056
+ ]);
4057
+ const valid_page_exports = /* @__PURE__ */ new Set([...valid_layout_exports, "entries"]);
4058
+ const valid_layout_server_exports = /* @__PURE__ */ new Set([...valid_layout_exports]);
4059
+ const valid_page_server_exports = /* @__PURE__ */ new Set([...valid_layout_server_exports, "actions", "entries"]);
4060
+ const valid_server_exports = /* @__PURE__ */ new Set([
4061
+ "GET",
4062
+ "POST",
4063
+ "PATCH",
4064
+ "PUT",
4065
+ "DELETE",
4066
+ "OPTIONS",
4067
+ "HEAD",
4068
+ "fallback",
4069
+ "prerender",
4070
+ "trailingSlash",
4071
+ "config",
4072
+ "entries"
4073
+ ]);
4074
+ const validate_layout_exports = validator(valid_layout_exports);
4075
+ const validate_page_exports = validator(valid_page_exports);
4076
+ const validate_layout_server_exports = validator(valid_layout_server_exports);
4077
+ const validate_page_server_exports = validator(valid_page_server_exports);
4078
+ const validate_server_exports = validator(valid_server_exports);
4079
+
4080
+ export { MAYBE_DIRTY as $, set_active_reaction as A, set_active_effect as B, COMMENT_NODE as C, DevalueError as D, active_effect as E, active_reaction as F, is_passive_event as G, HYDRATION_START as H, create_text as I, FILENAME as J, setContext as K, LEGACY_PROPS as L, prevent_snippet_stringification as M, block as N, branch as O, queue_micro_task as P, Batch as Q, pause_effect as R, STATE_SYMBOL as S, defer_effect as T, set_component_context as U, handle_error as V, component_context as W, move_effect as X, set_signal_status as Y, DIRTY as Z, schedule_effect as _, is_plain_object as a, internal_set as a0, destroy_effect as a1, invoke_error_boundary as a2, svelte_boundary_reset_onerror as a3, tag as a4, effect_tracking as a5, render_effect as a6, HYDRATION_END as a7, svelte_boundary_reset_noop as a8, source as a9, writable as aA, readable as aB, stringify as aC, store_get as aD, attr_class as aE, unsubscribe_stores as aF, escape_html as aG, head as aH, ensure_array_like as aI, attr as aJ, getContext as aK, bind_props as aL, ssr_context as aM, hash as aN, attr_style as aO, spread_props as aP, clsx as aQ, set_ssr_context as aR, Renderer as aS, invalid_snippet_arguments as aT, noop as aU, HYDRATION_START_ELSE as aa, untrack as ab, increment as ac, push$1 as ad, pop$1 as ae, EFFECT_TRANSPARENT as af, EFFECT_PRESERVED as ag, BOUNDARY_EFFECT as ah, decode_pathname as ai, decode_params as aj, DEV as ak, validate_server_exports as al, normalize_path as am, disable_search as an, validate_layout_server_exports as ao, validate_layout_exports as ap, validate_page_server_exports as aq, validate_page_exports as ar, uneval as as, text_encoder$1 as at, resolve as au, make_trackable as av, get_relative_path as aw, base64_encode$1 as ax, SCHEME as ay, try_get_request_store as az, stringify_string as b, base64_decode as c, set as d, enumerable_symbols as e, get as f, get_type as g, flushSync as h, is_primitive as i, define_property as j, init_operations as k, get_first_child as l, mutable_source as m, get_next_sibling as n, HYDRATION_ERROR as o, hydration_failed as p, clear_text_content as q, render as r, stringify_key as s, text_decoder as t, state_proxy_unmount as u, lifecycle_double_unmount as v, with_request_store as w, hydration_mismatch as x, array_from as y, component_root as z };
4081
+ //# sourceMappingURL=exports-CJ0Q5XmL.js.map