claude-mux 0.7.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 (636) hide show
  1. package/.beads/README.md +81 -0
  2. package/.beads/config.yaml +62 -0
  3. package/.beads/interactions.jsonl +0 -0
  4. package/.beads/issues.jsonl +5 -0
  5. package/.beads/metadata.json +4 -0
  6. package/.eslintrc.json +25 -0
  7. package/.gitattributes +3 -0
  8. package/.prettierrc +7 -0
  9. package/CLAUDE.md +123 -0
  10. package/LICENSE +21 -0
  11. package/PLAN-beads-integration.md +250 -0
  12. package/README.md +366 -0
  13. package/dist/app.d.ts +2 -0
  14. package/dist/app.d.ts.map +1 -0
  15. package/dist/app.js +147 -0
  16. package/dist/app.js.map +1 -0
  17. package/dist/cli.d.ts +3 -0
  18. package/dist/cli.d.ts.map +1 -0
  19. package/dist/cli.js +65 -0
  20. package/dist/cli.js.map +1 -0
  21. package/dist/commands/index.d.ts +5 -0
  22. package/dist/commands/index.d.ts.map +1 -0
  23. package/dist/commands/index.js +5 -0
  24. package/dist/commands/index.js.map +1 -0
  25. package/dist/commands/serve.d.ts +8 -0
  26. package/dist/commands/serve.d.ts.map +1 -0
  27. package/dist/commands/serve.js +59 -0
  28. package/dist/commands/serve.js.map +1 -0
  29. package/dist/commands/setup.d.ts +4 -0
  30. package/dist/commands/setup.d.ts.map +1 -0
  31. package/dist/commands/setup.js +12 -0
  32. package/dist/commands/setup.js.map +1 -0
  33. package/dist/commands/tui.d.ts +9 -0
  34. package/dist/commands/tui.d.ts.map +1 -0
  35. package/dist/commands/tui.js +234 -0
  36. package/dist/commands/tui.js.map +1 -0
  37. package/dist/commands/uninstall.d.ts +4 -0
  38. package/dist/commands/uninstall.d.ts.map +1 -0
  39. package/dist/commands/uninstall.js +12 -0
  40. package/dist/commands/uninstall.js.map +1 -0
  41. package/dist/components/Header.d.ts +7 -0
  42. package/dist/components/Header.d.ts.map +1 -0
  43. package/dist/components/Header.js +14 -0
  44. package/dist/components/Header.js.map +1 -0
  45. package/dist/components/HelpDialog.d.ts +6 -0
  46. package/dist/components/HelpDialog.d.ts.map +1 -0
  47. package/dist/components/HelpDialog.js +14 -0
  48. package/dist/components/HelpDialog.js.map +1 -0
  49. package/dist/components/SessionEntry.d.ts +17 -0
  50. package/dist/components/SessionEntry.d.ts.map +1 -0
  51. package/dist/components/SessionEntry.js +102 -0
  52. package/dist/components/SessionEntry.js.map +1 -0
  53. package/dist/components/SessionList.d.ts +14 -0
  54. package/dist/components/SessionList.d.ts.map +1 -0
  55. package/dist/components/SessionList.js +57 -0
  56. package/dist/components/SessionList.js.map +1 -0
  57. package/dist/components/StatusBar.d.ts +6 -0
  58. package/dist/components/StatusBar.d.ts.map +1 -0
  59. package/dist/components/StatusBar.js +7 -0
  60. package/dist/components/StatusBar.js.map +1 -0
  61. package/dist/components/index.d.ts +6 -0
  62. package/dist/components/index.d.ts.map +1 -0
  63. package/dist/components/index.js +6 -0
  64. package/dist/components/index.js.map +1 -0
  65. package/dist/db/index.d.ts +2 -0
  66. package/dist/db/index.d.ts.map +1 -0
  67. package/dist/db/index.js +3 -0
  68. package/dist/db/index.js.map +1 -0
  69. package/dist/db/schema.d.ts +4 -0
  70. package/dist/db/schema.d.ts.map +1 -0
  71. package/dist/db/schema.js +23 -0
  72. package/dist/db/schema.js.map +1 -0
  73. package/dist/db/sessions-json.d.ts +85 -0
  74. package/dist/db/sessions-json.d.ts.map +1 -0
  75. package/dist/db/sessions-json.js +242 -0
  76. package/dist/db/sessions-json.js.map +1 -0
  77. package/dist/db/sessions.d.ts +38 -0
  78. package/dist/db/sessions.d.ts.map +1 -0
  79. package/dist/db/sessions.js +87 -0
  80. package/dist/db/sessions.js.map +1 -0
  81. package/dist/hooks/claude-mux-hook.d.ts +15 -0
  82. package/dist/hooks/claude-mux-hook.d.ts.map +1 -0
  83. package/dist/hooks/claude-mux-hook.js +396 -0
  84. package/dist/hooks/claude-mux-hook.js.map +1 -0
  85. package/dist/hooks/claude-watch-hook.d.ts +15 -0
  86. package/dist/hooks/claude-watch-hook.d.ts.map +1 -0
  87. package/dist/hooks/claude-watch-hook.js +396 -0
  88. package/dist/hooks/claude-watch-hook.js.map +1 -0
  89. package/dist/server/custom-server.d.ts +13 -0
  90. package/dist/server/custom-server.d.ts.map +1 -0
  91. package/dist/server/custom-server.js +63 -0
  92. package/dist/server/custom-server.js.map +1 -0
  93. package/dist/server/index.d.ts +9 -0
  94. package/dist/server/index.d.ts.map +1 -0
  95. package/dist/server/index.js +1143 -0
  96. package/dist/server/index.js.map +1 -0
  97. package/dist/server/middleware/cors.d.ts +2 -0
  98. package/dist/server/middleware/cors.d.ts.map +1 -0
  99. package/dist/server/middleware/cors.js +11 -0
  100. package/dist/server/middleware/cors.js.map +1 -0
  101. package/dist/server/routes/sessions.d.ts +3 -0
  102. package/dist/server/routes/sessions.d.ts.map +1 -0
  103. package/dist/server/routes/sessions.js +78 -0
  104. package/dist/server/routes/sessions.js.map +1 -0
  105. package/dist/server/routes/stream.d.ts +3 -0
  106. package/dist/server/routes/stream.d.ts.map +1 -0
  107. package/dist/server/routes/stream.js +45 -0
  108. package/dist/server/routes/stream.js.map +1 -0
  109. package/dist/server/types.d.ts +28 -0
  110. package/dist/server/types.d.ts.map +1 -0
  111. package/dist/server/types.js +2 -0
  112. package/dist/server/types.js.map +1 -0
  113. package/dist/server/watcher.d.ts +22 -0
  114. package/dist/server/watcher.d.ts.map +1 -0
  115. package/dist/server/watcher.js +119 -0
  116. package/dist/server/watcher.js.map +1 -0
  117. package/dist/server/websocket.d.ts +51 -0
  118. package/dist/server/websocket.d.ts.map +1 -0
  119. package/dist/server/websocket.js +156 -0
  120. package/dist/server/websocket.js.map +1 -0
  121. package/dist/server/ws-handlers.d.ts +174 -0
  122. package/dist/server/ws-handlers.d.ts.map +1 -0
  123. package/dist/server/ws-handlers.js +695 -0
  124. package/dist/server/ws-handlers.js.map +1 -0
  125. package/dist/setup/hooks.d.ts +44 -0
  126. package/dist/setup/hooks.d.ts.map +1 -0
  127. package/dist/setup/hooks.js +267 -0
  128. package/dist/setup/hooks.js.map +1 -0
  129. package/dist/setup/index.d.ts +3 -0
  130. package/dist/setup/index.d.ts.map +1 -0
  131. package/dist/setup/index.js +3 -0
  132. package/dist/setup/index.js.map +1 -0
  133. package/dist/setup/wizard.d.ts +4 -0
  134. package/dist/setup/wizard.d.ts.map +1 -0
  135. package/dist/setup/wizard.js +72 -0
  136. package/dist/setup/wizard.js.map +1 -0
  137. package/dist/tmux/detect.d.ts +25 -0
  138. package/dist/tmux/detect.d.ts.map +1 -0
  139. package/dist/tmux/detect.js +71 -0
  140. package/dist/tmux/detect.js.map +1 -0
  141. package/dist/tmux/navigate.d.ts +13 -0
  142. package/dist/tmux/navigate.d.ts.map +1 -0
  143. package/dist/tmux/navigate.js +41 -0
  144. package/dist/tmux/navigate.js.map +1 -0
  145. package/dist/tmux/pane.d.ts +57 -0
  146. package/dist/tmux/pane.d.ts.map +1 -0
  147. package/dist/tmux/pane.js +156 -0
  148. package/dist/tmux/pane.js.map +1 -0
  149. package/dist/tmux/resize.d.ts +10 -0
  150. package/dist/tmux/resize.d.ts.map +1 -0
  151. package/dist/tmux/resize.js +25 -0
  152. package/dist/tmux/resize.js.map +1 -0
  153. package/dist/utils/paths.d.ts +7 -0
  154. package/dist/utils/paths.d.ts.map +1 -0
  155. package/dist/utils/paths.js +9 -0
  156. package/dist/utils/paths.js.map +1 -0
  157. package/dist/utils/pid.d.ts +5 -0
  158. package/dist/utils/pid.d.ts.map +1 -0
  159. package/dist/utils/pid.js +14 -0
  160. package/dist/utils/pid.js.map +1 -0
  161. package/dist/utils/version.d.ts +6 -0
  162. package/dist/utils/version.d.ts.map +1 -0
  163. package/dist/utils/version.js +6 -0
  164. package/dist/utils/version.js.map +1 -0
  165. package/dist/web/client/_app/immutable/assets/0.WptSHSUl.css +1 -0
  166. package/dist/web/client/_app/immutable/assets/2.s6Kx4oz1.css +1 -0
  167. package/dist/web/client/_app/immutable/assets/4.DoNWy7tW.css +1 -0
  168. package/dist/web/client/_app/immutable/assets/AllSessionsPanel.CGHY3HLy.css +1 -0
  169. package/dist/web/client/_app/immutable/chunks/-3mUPuLP.js +1 -0
  170. package/dist/web/client/_app/immutable/chunks/B5U4_V3d.js +1 -0
  171. package/dist/web/client/_app/immutable/chunks/BHwiZXRv.js +1 -0
  172. package/dist/web/client/_app/immutable/chunks/C9P-coqM.js +1 -0
  173. package/dist/web/client/_app/immutable/chunks/Cegv0r8x.js +1 -0
  174. package/dist/web/client/_app/immutable/chunks/DU91Ml7U.js +3 -0
  175. package/dist/web/client/_app/immutable/chunks/DmdO6ygw.js +1 -0
  176. package/dist/web/client/_app/immutable/chunks/HKNo9LID.js +5 -0
  177. package/dist/web/client/_app/immutable/chunks/U4ip-C0d.js +2 -0
  178. package/dist/web/client/_app/immutable/chunks/cgUjKIhX.js +2 -0
  179. package/dist/web/client/_app/immutable/entry/app.CGIBnoln.js +2 -0
  180. package/dist/web/client/_app/immutable/entry/start.CJk8zB1j.js +1 -0
  181. package/dist/web/client/_app/immutable/nodes/0.CqlJ9a31.js +1 -0
  182. package/dist/web/client/_app/immutable/nodes/1.BQUZh2-w.js +1 -0
  183. package/dist/web/client/_app/immutable/nodes/2.CCV1YdgF.js +1 -0
  184. package/dist/web/client/_app/immutable/nodes/3.D9tDCdq8.js +1 -0
  185. package/dist/web/client/_app/immutable/nodes/4.BqPyNkFA.js +6 -0
  186. package/dist/web/client/_app/version.json +1 -0
  187. package/dist/web/client/robots.txt +3 -0
  188. package/dist/web/env.js +32 -0
  189. package/dist/web/handler.js +744 -0
  190. package/dist/web/index.js +49 -0
  191. package/dist/web/server/chunks/0-BHWsmCJv.js +23 -0
  192. package/dist/web/server/chunks/0-BHWsmCJv.js.map +1 -0
  193. package/dist/web/server/chunks/1-YRx6A8Tm.js +17 -0
  194. package/dist/web/server/chunks/1-YRx6A8Tm.js.map +1 -0
  195. package/dist/web/server/chunks/2-eC6JuGAo.js +22 -0
  196. package/dist/web/server/chunks/2-eC6JuGAo.js.map +1 -0
  197. package/dist/web/server/chunks/3-Bk-wV20p.js +32 -0
  198. package/dist/web/server/chunks/3-Bk-wV20p.js.map +1 -0
  199. package/dist/web/server/chunks/4-nteBgDrW.js +21 -0
  200. package/dist/web/server/chunks/4-nteBgDrW.js.map +1 -0
  201. package/dist/web/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang-Bt4B0-oi.js +35 -0
  202. package/dist/web/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang-Bt4B0-oi.js.map +1 -0
  203. package/dist/web/server/chunks/_layout.svelte-BIF9eZCY.js +453 -0
  204. package/dist/web/server/chunks/_layout.svelte-BIF9eZCY.js.map +1 -0
  205. package/dist/web/server/chunks/_page.svelte-Be6iabRn.js +34 -0
  206. package/dist/web/server/chunks/_page.svelte-Be6iabRn.js.map +1 -0
  207. package/dist/web/server/chunks/_page.svelte-C_fGJVSE.js +576 -0
  208. package/dist/web/server/chunks/_page.svelte-C_fGJVSE.js.map +1 -0
  209. package/dist/web/server/chunks/_page.svelte-CnfJk6cu.js +2722 -0
  210. package/dist/web/server/chunks/_page.svelte-CnfJk6cu.js.map +1 -0
  211. package/dist/web/server/chunks/_server.ts-3WAmKvn2.js +34 -0
  212. package/dist/web/server/chunks/_server.ts-3WAmKvn2.js.map +1 -0
  213. package/dist/web/server/chunks/_server.ts-BAWJCSFb.js +29 -0
  214. package/dist/web/server/chunks/_server.ts-BAWJCSFb.js.map +1 -0
  215. package/dist/web/server/chunks/_server.ts-BPpMOZCm.js +24 -0
  216. package/dist/web/server/chunks/_server.ts-BPpMOZCm.js.map +1 -0
  217. package/dist/web/server/chunks/_server.ts-BUKgRb6U.js +13 -0
  218. package/dist/web/server/chunks/_server.ts-BUKgRb6U.js.map +1 -0
  219. package/dist/web/server/chunks/_server.ts-BVHUS8fm.js +41 -0
  220. package/dist/web/server/chunks/_server.ts-BVHUS8fm.js.map +1 -0
  221. package/dist/web/server/chunks/_server.ts-BrF3od0O.js +45 -0
  222. package/dist/web/server/chunks/_server.ts-BrF3od0O.js.map +1 -0
  223. package/dist/web/server/chunks/_server.ts-C4oPmOJR.js +38 -0
  224. package/dist/web/server/chunks/_server.ts-C4oPmOJR.js.map +1 -0
  225. package/dist/web/server/chunks/_server.ts-CDAUUmG_.js +21 -0
  226. package/dist/web/server/chunks/_server.ts-CDAUUmG_.js.map +1 -0
  227. package/dist/web/server/chunks/_server.ts-CR0uWvpz.js +24 -0
  228. package/dist/web/server/chunks/_server.ts-CR0uWvpz.js.map +1 -0
  229. package/dist/web/server/chunks/_server.ts-CSqdCNGi.js +21 -0
  230. package/dist/web/server/chunks/_server.ts-CSqdCNGi.js.map +1 -0
  231. package/dist/web/server/chunks/_server.ts-DI9fzUo9.js +52 -0
  232. package/dist/web/server/chunks/_server.ts-DI9fzUo9.js.map +1 -0
  233. package/dist/web/server/chunks/_server.ts-DNjJTClI.js +46 -0
  234. package/dist/web/server/chunks/_server.ts-DNjJTClI.js.map +1 -0
  235. package/dist/web/server/chunks/_server.ts-DdbOAkOj.js +22 -0
  236. package/dist/web/server/chunks/_server.ts-DdbOAkOj.js.map +1 -0
  237. package/dist/web/server/chunks/_server.ts-Df2isGQc.js +41 -0
  238. package/dist/web/server/chunks/_server.ts-Df2isGQc.js.map +1 -0
  239. package/dist/web/server/chunks/_server.ts-Vpw25_-3.js +12 -0
  240. package/dist/web/server/chunks/_server.ts-Vpw25_-3.js.map +1 -0
  241. package/dist/web/server/chunks/_server.ts-WldRpSRi.js +26 -0
  242. package/dist/web/server/chunks/_server.ts-WldRpSRi.js.map +1 -0
  243. package/dist/web/server/chunks/alert-dialog-description-DDA6u-nS.js +2890 -0
  244. package/dist/web/server/chunks/alert-dialog-description-DDA6u-nS.js.map +1 -0
  245. package/dist/web/server/chunks/auth-DrUf-v4J.js +51 -0
  246. package/dist/web/server/chunks/auth-DrUf-v4J.js.map +1 -0
  247. package/dist/web/server/chunks/button-D6xS9rHt.js +2335 -0
  248. package/dist/web/server/chunks/button-D6xS9rHt.js.map +1 -0
  249. package/dist/web/server/chunks/chunk-EKzHsMy_.js +42 -0
  250. package/dist/web/server/chunks/chunks-DmdqVYC7.js +58 -0
  251. package/dist/web/server/chunks/chunks-DmdqVYC7.js.map +1 -0
  252. package/dist/web/server/chunks/client-CUrSQijh.js +18 -0
  253. package/dist/web/server/chunks/client-CUrSQijh.js.map +1 -0
  254. package/dist/web/server/chunks/clsx-FzI4_gi0.js +332 -0
  255. package/dist/web/server/chunks/clsx-FzI4_gi0.js.map +1 -0
  256. package/dist/web/server/chunks/error.svelte-D-c-9pTE.js +27 -0
  257. package/dist/web/server/chunks/error.svelte-D-c-9pTE.js.map +1 -0
  258. package/dist/web/server/chunks/events-BDBlYddw.js +89 -0
  259. package/dist/web/server/chunks/events-BDBlYddw.js.map +1 -0
  260. package/dist/web/server/chunks/exports-CCurQ-Tl.js +131 -0
  261. package/dist/web/server/chunks/exports-CCurQ-Tl.js.map +1 -0
  262. package/dist/web/server/chunks/hooks.server-BK1bopsh.js +86 -0
  263. package/dist/web/server/chunks/hooks.server-BK1bopsh.js.map +1 -0
  264. package/dist/web/server/chunks/index2-BQnysSj-.js +2588 -0
  265. package/dist/web/server/chunks/index2-BQnysSj-.js.map +1 -0
  266. package/dist/web/server/chunks/internal-DLENj6YI.js +61 -0
  267. package/dist/web/server/chunks/internal-DLENj6YI.js.map +1 -0
  268. package/dist/web/server/chunks/pane-Dg3pKvsm.js +94 -0
  269. package/dist/web/server/chunks/pane-Dg3pKvsm.js.map +1 -0
  270. package/dist/web/server/chunks/sessions-json-DgfkCLO7.js +107 -0
  271. package/dist/web/server/chunks/sessions-json-DgfkCLO7.js.map +1 -0
  272. package/dist/web/server/chunks/sessions.svelte-Ds82MvkB.js +178 -0
  273. package/dist/web/server/chunks/sessions.svelte-Ds82MvkB.js.map +1 -0
  274. package/dist/web/server/chunks/state.svelte-xeAZvWZ6.js +7 -0
  275. package/dist/web/server/chunks/state.svelte-xeAZvWZ6.js.map +1 -0
  276. package/dist/web/server/chunks/ws-handlers-B4r5eSP2.js +733 -0
  277. package/dist/web/server/chunks/ws-handlers-B4r5eSP2.js.map +1 -0
  278. package/dist/web/server/index.js +4907 -0
  279. package/dist/web/server/index.js.map +1 -0
  280. package/dist/web/server/manifest.js +233 -0
  281. package/dist/web/server/manifest.js.map +1 -0
  282. package/docs/images/desktop-dashboard.png +0 -0
  283. package/docs/images/desktop-session.png +0 -0
  284. package/docs/images/mobile-dashboard.png +0 -0
  285. package/docs/images/mobile-session.png +0 -0
  286. package/docs/release-checklist.md +228 -0
  287. package/docs/removing-hooks.md +135 -0
  288. package/docs/state-transitions.md +109 -0
  289. package/package.json +71 -0
  290. package/src/app.tsx +188 -0
  291. package/src/cli.ts +83 -0
  292. package/src/commands/index.ts +4 -0
  293. package/src/commands/serve.ts +75 -0
  294. package/src/commands/setup.ts +13 -0
  295. package/src/commands/tui.ts +255 -0
  296. package/src/commands/uninstall.ts +13 -0
  297. package/src/components/Header.tsx +32 -0
  298. package/src/components/HelpDialog.tsx +45 -0
  299. package/src/components/SessionEntry.tsx +202 -0
  300. package/src/components/SessionList.tsx +98 -0
  301. package/src/components/StatusBar.tsx +26 -0
  302. package/src/components/index.ts +5 -0
  303. package/src/db/index.ts +20 -0
  304. package/src/db/sessions-json.ts +314 -0
  305. package/src/hooks/claude-mux-hook.ts +498 -0
  306. package/src/server/watcher.ts +128 -0
  307. package/src/server/ws-handlers.ts +922 -0
  308. package/src/setup/hooks.ts +333 -0
  309. package/src/setup/index.ts +2 -0
  310. package/src/setup/wizard.ts +81 -0
  311. package/src/tmux/detect.ts +87 -0
  312. package/src/tmux/navigate.ts +42 -0
  313. package/src/tmux/pane.ts +167 -0
  314. package/src/tmux/resize.ts +28 -0
  315. package/src/utils/paths.ts +11 -0
  316. package/src/utils/pid.ts +12 -0
  317. package/src/utils/version.ts +5 -0
  318. package/tests/components/Header.test.tsx +42 -0
  319. package/tests/components/SessionEntry-extended.test.tsx +165 -0
  320. package/tests/components/SessionEntry.test.tsx +138 -0
  321. package/tests/components/SessionList.test.tsx +110 -0
  322. package/tests/components/StatusBar.test.tsx +31 -0
  323. package/tests/db/index.test.ts +78 -0
  324. package/tests/db/sessions.test.ts +230 -0
  325. package/tests/server/integration.test.ts +319 -0
  326. package/tests/server/sessions.test.ts +114 -0
  327. package/tests/setup/hooks-integration.test.ts +148 -0
  328. package/tests/setup/hooks.test.ts +123 -0
  329. package/tests/tmux/detect.test.ts +54 -0
  330. package/tests/tmux/navigate.test.ts +30 -0
  331. package/tests/utils/pid.test.ts +17 -0
  332. package/tsconfig.cli.json +9 -0
  333. package/tsconfig.json +22 -0
  334. package/vitest.config.ts +29 -0
  335. package/web/.svelte-kit/adapter-bun/.vite/manifest.json +408 -0
  336. package/web/.svelte-kit/adapter-bun/_app/immutable/assets/AllSessionsPanel.BKhqOrbV.css +1 -0
  337. package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_layout.WptSHSUl.css +1 -0
  338. package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_page.DldLgTc-.css +1 -0
  339. package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_page.DoNWy7tW.css +1 -0
  340. package/web/.svelte-kit/adapter-bun/chunks/AllSessionsPanel.svelte_svelte_type_style_lang.js +49 -0
  341. package/web/.svelte-kit/adapter-bun/chunks/alert-dialog-description.js +2670 -0
  342. package/web/.svelte-kit/adapter-bun/chunks/auth.js +59 -0
  343. package/web/.svelte-kit/adapter-bun/chunks/button.js +82 -0
  344. package/web/.svelte-kit/adapter-bun/chunks/client.js +29 -0
  345. package/web/.svelte-kit/adapter-bun/chunks/context.js +133 -0
  346. package/web/.svelte-kit/adapter-bun/chunks/environment.js +34 -0
  347. package/web/.svelte-kit/adapter-bun/chunks/events.js +121 -0
  348. package/web/.svelte-kit/adapter-bun/chunks/exports.js +174 -0
  349. package/web/.svelte-kit/adapter-bun/chunks/false.js +4 -0
  350. package/web/.svelte-kit/adapter-bun/chunks/index.js +59 -0
  351. package/web/.svelte-kit/adapter-bun/chunks/index2.js +2828 -0
  352. package/web/.svelte-kit/adapter-bun/chunks/internal.js +920 -0
  353. package/web/.svelte-kit/adapter-bun/chunks/pane.js +82 -0
  354. package/web/.svelte-kit/adapter-bun/chunks/sessions-json.js +124 -0
  355. package/web/.svelte-kit/adapter-bun/chunks/sessions.svelte.js +229 -0
  356. package/web/.svelte-kit/adapter-bun/chunks/shared.js +542 -0
  357. package/web/.svelte-kit/adapter-bun/chunks/state.svelte.js +16 -0
  358. package/web/.svelte-kit/adapter-bun/chunks/utils.js +43 -0
  359. package/web/.svelte-kit/adapter-bun/chunks/ws-handlers.js +782 -0
  360. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/auth/login/_server.ts.js +22 -0
  361. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/auth/logout/_server.ts.js +9 -0
  362. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/beads/_server.ts.js +22 -0
  363. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/browse/_server.ts.js +50 -0
  364. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/chrome/_server.ts.js +30 -0
  365. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/files/image/_server.ts.js +53 -0
  366. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/health/_server.ts.js +7 -0
  367. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
  368. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
  369. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +36 -0
  370. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/restart/_server.ts.js +40 -0
  371. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/screenshots/_server.ts.js +28 -0
  372. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/send/_server.ts.js +29 -0
  373. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_server.ts.js +49 -0
  374. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
  375. package/web/.svelte-kit/adapter-bun/entries/endpoints/api/tmux/panes/_server.ts.js +21 -0
  376. package/web/.svelte-kit/adapter-bun/entries/fallbacks/error.svelte.js +27 -0
  377. package/web/.svelte-kit/adapter-bun/entries/hooks.server.js +105 -0
  378. package/web/.svelte-kit/adapter-bun/entries/pages/_layout.svelte.js +499 -0
  379. package/web/.svelte-kit/adapter-bun/entries/pages/_page.svelte.js +3057 -0
  380. package/web/.svelte-kit/adapter-bun/entries/pages/login/_page.server.ts.js +15 -0
  381. package/web/.svelte-kit/adapter-bun/entries/pages/login/_page.svelte.js +37 -0
  382. package/web/.svelte-kit/adapter-bun/entries/pages/session/_target_/_page.svelte.js +653 -0
  383. package/web/.svelte-kit/adapter-bun/index.js +3864 -0
  384. package/web/.svelte-kit/adapter-bun/internal.js +13 -0
  385. package/web/.svelte-kit/adapter-bun/manifest-full.js +167 -0
  386. package/web/.svelte-kit/adapter-bun/manifest.js +171 -0
  387. package/web/.svelte-kit/adapter-bun/nodes/0.js +8 -0
  388. package/web/.svelte-kit/adapter-bun/nodes/1.js +8 -0
  389. package/web/.svelte-kit/adapter-bun/nodes/2.js +8 -0
  390. package/web/.svelte-kit/adapter-bun/nodes/3.js +10 -0
  391. package/web/.svelte-kit/adapter-bun/nodes/4.js +8 -0
  392. package/web/.svelte-kit/adapter-bun/remote-entry.js +541 -0
  393. package/web/.svelte-kit/adapter-node/.vite/manifest.json +223 -0
  394. package/web/.svelte-kit/adapter-node/_app/immutable/assets/_layout.4NiX29PU.css +1 -0
  395. package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.BEMzYUGV.css +1 -0
  396. package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.DOJn7TG7.css +1 -0
  397. package/web/.svelte-kit/adapter-node/chunks/context.js +121 -0
  398. package/web/.svelte-kit/adapter-node/chunks/environment.js +34 -0
  399. package/web/.svelte-kit/adapter-node/chunks/exports.js +174 -0
  400. package/web/.svelte-kit/adapter-node/chunks/false.js +4 -0
  401. package/web/.svelte-kit/adapter-node/chunks/index.js +59 -0
  402. package/web/.svelte-kit/adapter-node/chunks/index2.js +2710 -0
  403. package/web/.svelte-kit/adapter-node/chunks/internal.js +1005 -0
  404. package/web/.svelte-kit/adapter-node/chunks/sessions-json.js +109 -0
  405. package/web/.svelte-kit/adapter-node/chunks/sessions.svelte.js +67 -0
  406. package/web/.svelte-kit/adapter-node/chunks/shared.js +542 -0
  407. package/web/.svelte-kit/adapter-node/chunks/state.svelte.js +16 -0
  408. package/web/.svelte-kit/adapter-node/chunks/utils.js +43 -0
  409. package/web/.svelte-kit/adapter-node/entries/endpoints/api/browse/_server.ts.js +50 -0
  410. package/web/.svelte-kit/adapter-node/entries/endpoints/api/health/_server.ts.js +7 -0
  411. package/web/.svelte-kit/adapter-node/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
  412. package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
  413. package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +30 -0
  414. package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/send/_server.ts.js +22 -0
  415. package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_server.ts.js +126 -0
  416. package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
  417. package/web/.svelte-kit/adapter-node/entries/fallbacks/error.svelte.js +44 -0
  418. package/web/.svelte-kit/adapter-node/entries/pages/_layout.svelte.js +12 -0
  419. package/web/.svelte-kit/adapter-node/entries/pages/_page.svelte.js +87 -0
  420. package/web/.svelte-kit/adapter-node/entries/pages/session/_target_/_page.svelte.js +76 -0
  421. package/web/.svelte-kit/adapter-node/index.js +3864 -0
  422. package/web/.svelte-kit/adapter-node/internal.js +13 -0
  423. package/web/.svelte-kit/adapter-node/manifest-full.js +103 -0
  424. package/web/.svelte-kit/adapter-node/manifest.js +107 -0
  425. package/web/.svelte-kit/adapter-node/nodes/0.js +8 -0
  426. package/web/.svelte-kit/adapter-node/nodes/1.js +8 -0
  427. package/web/.svelte-kit/adapter-node/nodes/2.js +8 -0
  428. package/web/.svelte-kit/adapter-node/nodes/3.js +8 -0
  429. package/web/.svelte-kit/adapter-node/remote-entry.js +541 -0
  430. package/web/.svelte-kit/ambient.d.ts +187 -0
  431. package/web/.svelte-kit/generated/client/app.js +33 -0
  432. package/web/.svelte-kit/generated/client/matchers.js +1 -0
  433. package/web/.svelte-kit/generated/client/nodes/0.js +1 -0
  434. package/web/.svelte-kit/generated/client/nodes/1.js +1 -0
  435. package/web/.svelte-kit/generated/client/nodes/2.js +1 -0
  436. package/web/.svelte-kit/generated/client/nodes/3.js +1 -0
  437. package/web/.svelte-kit/generated/client/nodes/4.js +1 -0
  438. package/web/.svelte-kit/generated/client-optimized/app.js +33 -0
  439. package/web/.svelte-kit/generated/client-optimized/matchers.js +1 -0
  440. package/web/.svelte-kit/generated/client-optimized/nodes/0.js +1 -0
  441. package/web/.svelte-kit/generated/client-optimized/nodes/1.js +1 -0
  442. package/web/.svelte-kit/generated/client-optimized/nodes/2.js +1 -0
  443. package/web/.svelte-kit/generated/client-optimized/nodes/3.js +1 -0
  444. package/web/.svelte-kit/generated/client-optimized/nodes/4.js +1 -0
  445. package/web/.svelte-kit/generated/root.js +3 -0
  446. package/web/.svelte-kit/generated/root.svelte +68 -0
  447. package/web/.svelte-kit/generated/server/internal.js +53 -0
  448. package/web/.svelte-kit/non-ambient.d.ts +73 -0
  449. package/web/.svelte-kit/output/client/.vite/manifest.json +203 -0
  450. package/web/.svelte-kit/output/client/_app/immutable/assets/0.WptSHSUl.css +1 -0
  451. package/web/.svelte-kit/output/client/_app/immutable/assets/2.s6Kx4oz1.css +1 -0
  452. package/web/.svelte-kit/output/client/_app/immutable/assets/4.DoNWy7tW.css +1 -0
  453. package/web/.svelte-kit/output/client/_app/immutable/assets/AllSessionsPanel.CGHY3HLy.css +1 -0
  454. package/web/.svelte-kit/output/client/_app/immutable/chunks/-3mUPuLP.js +1 -0
  455. package/web/.svelte-kit/output/client/_app/immutable/chunks/B5U4_V3d.js +1 -0
  456. package/web/.svelte-kit/output/client/_app/immutable/chunks/BHwiZXRv.js +1 -0
  457. package/web/.svelte-kit/output/client/_app/immutable/chunks/C9P-coqM.js +1 -0
  458. package/web/.svelte-kit/output/client/_app/immutable/chunks/Cegv0r8x.js +1 -0
  459. package/web/.svelte-kit/output/client/_app/immutable/chunks/DU91Ml7U.js +3 -0
  460. package/web/.svelte-kit/output/client/_app/immutable/chunks/DmdO6ygw.js +1 -0
  461. package/web/.svelte-kit/output/client/_app/immutable/chunks/HKNo9LID.js +5 -0
  462. package/web/.svelte-kit/output/client/_app/immutable/chunks/U4ip-C0d.js +2 -0
  463. package/web/.svelte-kit/output/client/_app/immutable/chunks/cgUjKIhX.js +2 -0
  464. package/web/.svelte-kit/output/client/_app/immutable/entry/app.CGIBnoln.js +2 -0
  465. package/web/.svelte-kit/output/client/_app/immutable/entry/start.CJk8zB1j.js +1 -0
  466. package/web/.svelte-kit/output/client/_app/immutable/nodes/0.CqlJ9a31.js +1 -0
  467. package/web/.svelte-kit/output/client/_app/immutable/nodes/1.BQUZh2-w.js +1 -0
  468. package/web/.svelte-kit/output/client/_app/immutable/nodes/2.CCV1YdgF.js +1 -0
  469. package/web/.svelte-kit/output/client/_app/immutable/nodes/3.D9tDCdq8.js +1 -0
  470. package/web/.svelte-kit/output/client/_app/immutable/nodes/4.BqPyNkFA.js +6 -0
  471. package/web/.svelte-kit/output/client/_app/version.json +1 -0
  472. package/web/.svelte-kit/output/client/robots.txt +3 -0
  473. package/web/.svelte-kit/output/server/.vite/manifest.json +408 -0
  474. package/web/.svelte-kit/output/server/_app/immutable/assets/AllSessionsPanel.BKhqOrbV.css +1 -0
  475. package/web/.svelte-kit/output/server/_app/immutable/assets/_layout.WptSHSUl.css +1 -0
  476. package/web/.svelte-kit/output/server/_app/immutable/assets/_page.DldLgTc-.css +1 -0
  477. package/web/.svelte-kit/output/server/_app/immutable/assets/_page.DoNWy7tW.css +1 -0
  478. package/web/.svelte-kit/output/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang.js +49 -0
  479. package/web/.svelte-kit/output/server/chunks/alert-dialog-description.js +2670 -0
  480. package/web/.svelte-kit/output/server/chunks/auth.js +59 -0
  481. package/web/.svelte-kit/output/server/chunks/button.js +82 -0
  482. package/web/.svelte-kit/output/server/chunks/client.js +29 -0
  483. package/web/.svelte-kit/output/server/chunks/context.js +133 -0
  484. package/web/.svelte-kit/output/server/chunks/environment.js +34 -0
  485. package/web/.svelte-kit/output/server/chunks/events.js +121 -0
  486. package/web/.svelte-kit/output/server/chunks/exports.js +174 -0
  487. package/web/.svelte-kit/output/server/chunks/false.js +4 -0
  488. package/web/.svelte-kit/output/server/chunks/index.js +59 -0
  489. package/web/.svelte-kit/output/server/chunks/index2.js +2828 -0
  490. package/web/.svelte-kit/output/server/chunks/internal.js +920 -0
  491. package/web/.svelte-kit/output/server/chunks/pane.js +82 -0
  492. package/web/.svelte-kit/output/server/chunks/sessions-json.js +124 -0
  493. package/web/.svelte-kit/output/server/chunks/sessions.svelte.js +229 -0
  494. package/web/.svelte-kit/output/server/chunks/shared.js +542 -0
  495. package/web/.svelte-kit/output/server/chunks/state.svelte.js +16 -0
  496. package/web/.svelte-kit/output/server/chunks/utils.js +43 -0
  497. package/web/.svelte-kit/output/server/chunks/ws-handlers.js +782 -0
  498. package/web/.svelte-kit/output/server/entries/endpoints/api/auth/login/_server.ts.js +22 -0
  499. package/web/.svelte-kit/output/server/entries/endpoints/api/auth/logout/_server.ts.js +9 -0
  500. package/web/.svelte-kit/output/server/entries/endpoints/api/beads/_server.ts.js +22 -0
  501. package/web/.svelte-kit/output/server/entries/endpoints/api/browse/_server.ts.js +50 -0
  502. package/web/.svelte-kit/output/server/entries/endpoints/api/chrome/_server.ts.js +30 -0
  503. package/web/.svelte-kit/output/server/entries/endpoints/api/files/image/_server.ts.js +53 -0
  504. package/web/.svelte-kit/output/server/entries/endpoints/api/health/_server.ts.js +7 -0
  505. package/web/.svelte-kit/output/server/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
  506. package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
  507. package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +36 -0
  508. package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/restart/_server.ts.js +40 -0
  509. package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/screenshots/_server.ts.js +28 -0
  510. package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/send/_server.ts.js +29 -0
  511. package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_server.ts.js +49 -0
  512. package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
  513. package/web/.svelte-kit/output/server/entries/endpoints/api/tmux/panes/_server.ts.js +21 -0
  514. package/web/.svelte-kit/output/server/entries/fallbacks/error.svelte.js +27 -0
  515. package/web/.svelte-kit/output/server/entries/hooks.server.js +105 -0
  516. package/web/.svelte-kit/output/server/entries/pages/_layout.svelte.js +499 -0
  517. package/web/.svelte-kit/output/server/entries/pages/_page.svelte.js +3057 -0
  518. package/web/.svelte-kit/output/server/entries/pages/login/_page.server.ts.js +15 -0
  519. package/web/.svelte-kit/output/server/entries/pages/login/_page.svelte.js +37 -0
  520. package/web/.svelte-kit/output/server/entries/pages/session/_target_/_page.svelte.js +653 -0
  521. package/web/.svelte-kit/output/server/index.js +3864 -0
  522. package/web/.svelte-kit/output/server/internal.js +13 -0
  523. package/web/.svelte-kit/output/server/manifest-full.js +167 -0
  524. package/web/.svelte-kit/output/server/manifest.js +167 -0
  525. package/web/.svelte-kit/output/server/nodes/0.js +8 -0
  526. package/web/.svelte-kit/output/server/nodes/1.js +8 -0
  527. package/web/.svelte-kit/output/server/nodes/2.js +8 -0
  528. package/web/.svelte-kit/output/server/nodes/3.js +10 -0
  529. package/web/.svelte-kit/output/server/nodes/4.js +8 -0
  530. package/web/.svelte-kit/output/server/remote-entry.js +541 -0
  531. package/web/.svelte-kit/tsconfig.json +58 -0
  532. package/web/.svelte-kit/types/route_meta_data.json +55 -0
  533. package/web/.svelte-kit/types/src/routes/$types.d.ts +24 -0
  534. package/web/.svelte-kit/types/src/routes/api/auth/login/$types.d.ts +10 -0
  535. package/web/.svelte-kit/types/src/routes/api/auth/logout/$types.d.ts +10 -0
  536. package/web/.svelte-kit/types/src/routes/api/beads/$types.d.ts +10 -0
  537. package/web/.svelte-kit/types/src/routes/api/browse/$types.d.ts +10 -0
  538. package/web/.svelte-kit/types/src/routes/api/chrome/$types.d.ts +10 -0
  539. package/web/.svelte-kit/types/src/routes/api/files/image/$types.d.ts +10 -0
  540. package/web/.svelte-kit/types/src/routes/api/health/$types.d.ts +10 -0
  541. package/web/.svelte-kit/types/src/routes/api/projects/new-session/$types.d.ts +10 -0
  542. package/web/.svelte-kit/types/src/routes/api/sessions/$types.d.ts +10 -0
  543. package/web/.svelte-kit/types/src/routes/api/sessions/[id]/$types.d.ts +11 -0
  544. package/web/.svelte-kit/types/src/routes/api/sessions/[id]/kill/$types.d.ts +11 -0
  545. package/web/.svelte-kit/types/src/routes/api/sessions/[id]/restart/$types.d.ts +11 -0
  546. package/web/.svelte-kit/types/src/routes/api/sessions/[id]/screenshots/$types.d.ts +11 -0
  547. package/web/.svelte-kit/types/src/routes/api/sessions/[id]/send/$types.d.ts +11 -0
  548. package/web/.svelte-kit/types/src/routes/api/sessions/[target]/output/$types.d.ts +11 -0
  549. package/web/.svelte-kit/types/src/routes/api/tmux/panes/$types.d.ts +10 -0
  550. package/web/.svelte-kit/types/src/routes/login/$types.d.ts +25 -0
  551. package/web/.svelte-kit/types/src/routes/login/proxy+page.server.ts +19 -0
  552. package/web/.svelte-kit/types/src/routes/session/[target]/$types.d.ts +19 -0
  553. package/web/README.md +42 -0
  554. package/web/components.json +16 -0
  555. package/web/package.json +35 -0
  556. package/web/src/app.css +128 -0
  557. package/web/src/app.d.ts +13 -0
  558. package/web/src/app.html +11 -0
  559. package/web/src/hooks.server.ts +156 -0
  560. package/web/src/lib/assets/favicon.svg +1 -0
  561. package/web/src/lib/components/AllSessionsPanel.svelte +789 -0
  562. package/web/src/lib/components/BeadsPanel.svelte +146 -0
  563. package/web/src/lib/components/IssueItem.svelte +287 -0
  564. package/web/src/lib/components/ScreenshotsPanel.svelte +336 -0
  565. package/web/src/lib/components/SessionsSidebar.svelte +312 -0
  566. package/web/src/lib/components/TerminalRenderer.svelte +189 -0
  567. package/web/src/lib/components/ui/alert-dialog/alert-dialog-action.svelte +18 -0
  568. package/web/src/lib/components/ui/alert-dialog/alert-dialog-cancel.svelte +18 -0
  569. package/web/src/lib/components/ui/alert-dialog/alert-dialog-content.svelte +29 -0
  570. package/web/src/lib/components/ui/alert-dialog/alert-dialog-description.svelte +17 -0
  571. package/web/src/lib/components/ui/alert-dialog/alert-dialog-footer.svelte +20 -0
  572. package/web/src/lib/components/ui/alert-dialog/alert-dialog-header.svelte +20 -0
  573. package/web/src/lib/components/ui/alert-dialog/alert-dialog-overlay.svelte +20 -0
  574. package/web/src/lib/components/ui/alert-dialog/alert-dialog-portal.svelte +7 -0
  575. package/web/src/lib/components/ui/alert-dialog/alert-dialog-title.svelte +17 -0
  576. package/web/src/lib/components/ui/alert-dialog/alert-dialog-trigger.svelte +7 -0
  577. package/web/src/lib/components/ui/alert-dialog/alert-dialog.svelte +7 -0
  578. package/web/src/lib/components/ui/alert-dialog/index.ts +37 -0
  579. package/web/src/lib/components/ui/badge/badge.svelte +50 -0
  580. package/web/src/lib/components/ui/badge/index.ts +2 -0
  581. package/web/src/lib/components/ui/button/button.svelte +86 -0
  582. package/web/src/lib/components/ui/button/index.ts +17 -0
  583. package/web/src/lib/components/ui/checkbox/checkbox.svelte +36 -0
  584. package/web/src/lib/components/ui/checkbox/index.ts +6 -0
  585. package/web/src/lib/components/ui/dialog/dialog-close.svelte +7 -0
  586. package/web/src/lib/components/ui/dialog/dialog-content.svelte +45 -0
  587. package/web/src/lib/components/ui/dialog/dialog-description.svelte +17 -0
  588. package/web/src/lib/components/ui/dialog/dialog-footer.svelte +20 -0
  589. package/web/src/lib/components/ui/dialog/dialog-header.svelte +20 -0
  590. package/web/src/lib/components/ui/dialog/dialog-overlay.svelte +20 -0
  591. package/web/src/lib/components/ui/dialog/dialog-portal.svelte +7 -0
  592. package/web/src/lib/components/ui/dialog/dialog-title.svelte +17 -0
  593. package/web/src/lib/components/ui/dialog/dialog-trigger.svelte +7 -0
  594. package/web/src/lib/components/ui/dialog/dialog.svelte +7 -0
  595. package/web/src/lib/components/ui/dialog/index.ts +34 -0
  596. package/web/src/lib/components/ui/scroll-area/index.ts +10 -0
  597. package/web/src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte +31 -0
  598. package/web/src/lib/components/ui/scroll-area/scroll-area.svelte +43 -0
  599. package/web/src/lib/components/ui/textarea/index.ts +7 -0
  600. package/web/src/lib/components/ui/textarea/textarea.svelte +23 -0
  601. package/web/src/lib/index.ts +1 -0
  602. package/web/src/lib/server/auth.ts +90 -0
  603. package/web/src/lib/stores/beads.svelte.ts +163 -0
  604. package/web/src/lib/stores/input-injection.svelte.ts +39 -0
  605. package/web/src/lib/stores/preferences.svelte.ts +55 -0
  606. package/web/src/lib/stores/sessions.svelte.ts +108 -0
  607. package/web/src/lib/stores/terminal.svelte.ts +96 -0
  608. package/web/src/lib/stores/websocket-base.svelte.ts +209 -0
  609. package/web/src/lib/types/terminal.ts +31 -0
  610. package/web/src/lib/utils/terminal-parser.ts +239 -0
  611. package/web/src/lib/utils.ts +13 -0
  612. package/web/src/routes/+layout.svelte +450 -0
  613. package/web/src/routes/+page.svelte +19 -0
  614. package/web/src/routes/api/auth/login/+server.ts +34 -0
  615. package/web/src/routes/api/auth/logout/+server.ts +10 -0
  616. package/web/src/routes/api/beads/+server.ts +28 -0
  617. package/web/src/routes/api/browse/+server.ts +59 -0
  618. package/web/src/routes/api/chrome/+server.ts +35 -0
  619. package/web/src/routes/api/files/image/+server.ts +64 -0
  620. package/web/src/routes/api/health/+server.ts +6 -0
  621. package/web/src/routes/api/projects/new-session/+server.ts +50 -0
  622. package/web/src/routes/api/sessions/+server.ts +62 -0
  623. package/web/src/routes/api/sessions/[id]/+server.ts +19 -0
  624. package/web/src/routes/api/sessions/[id]/kill/+server.ts +46 -0
  625. package/web/src/routes/api/sessions/[id]/restart/+server.ts +59 -0
  626. package/web/src/routes/api/sessions/[id]/screenshots/+server.ts +32 -0
  627. package/web/src/routes/api/sessions/[id]/send/+server.ts +31 -0
  628. package/web/src/routes/api/sessions/[target]/output/+server.ts +13 -0
  629. package/web/src/routes/api/tmux/panes/+server.ts +32 -0
  630. package/web/src/routes/login/+page.server.ts +18 -0
  631. package/web/src/routes/login/+page.svelte +69 -0
  632. package/web/src/routes/session/[target]/+page.svelte +450 -0
  633. package/web/static/robots.txt +3 -0
  634. package/web/svelte.config.js +20 -0
  635. package/web/tsconfig.json +20 -0
  636. package/web/vite.config.ts +154 -0
@@ -0,0 +1,2588 @@
1
+ import { C as safe_equals, D as ssr_context, E as set_ssr_context, S as run_all, _ as noop, b as push$1, d as get_prototype_of, g as is_extensible, h as is_array, i as deferred, m as index_of, o as equals, p as includes, r as array_prototype, s as escape_html, t as clsx$1, u as get_descriptor, v as object_prototype, y as pop$1 } from "./clsx-FzI4_gi0.js";
2
+
3
+ //#region .svelte-kit/adapter-bun/chunks/false.js
4
+ const BROWSER = false;
5
+
6
+ //#endregion
7
+ //#region ../node_modules/devalue/src/utils.js
8
+ /** @type {Record<string, string>} */
9
+ const escaped = {
10
+ "<": "\\u003C",
11
+ "\\": "\\\\",
12
+ "\b": "\\b",
13
+ "\f": "\\f",
14
+ "\n": "\\n",
15
+ "\r": "\\r",
16
+ " ": "\\t",
17
+ "\u2028": "\\u2028",
18
+ "\u2029": "\\u2029"
19
+ };
20
+ var DevalueError = class extends Error {
21
+ /**
22
+ * @param {string} message
23
+ * @param {string[]} keys
24
+ * @param {any} [value] - The value that failed to be serialized
25
+ * @param {any} [root] - The root value being serialized
26
+ */
27
+ constructor(message, keys, value, root) {
28
+ super(message);
29
+ this.name = "DevalueError";
30
+ this.path = keys.join("");
31
+ this.value = value;
32
+ this.root = root;
33
+ }
34
+ };
35
+ /** @param {any} thing */
36
+ function is_primitive(thing) {
37
+ return Object(thing) !== thing;
38
+ }
39
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
40
+ /** @param {any} thing */
41
+ function is_plain_object(thing) {
42
+ const proto = Object.getPrototypeOf(thing);
43
+ return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
44
+ }
45
+ /** @param {any} thing */
46
+ function get_type(thing) {
47
+ return Object.prototype.toString.call(thing).slice(8, -1);
48
+ }
49
+ /** @param {string} char */
50
+ function get_escaped_char(char) {
51
+ switch (char) {
52
+ case "\"": return "\\\"";
53
+ case "<": return "\\u003C";
54
+ case "\\": return "\\\\";
55
+ case "\n": return "\\n";
56
+ case "\r": return "\\r";
57
+ case " ": return "\\t";
58
+ case "\b": return "\\b";
59
+ case "\f": return "\\f";
60
+ case "\u2028": return "\\u2028";
61
+ case "\u2029": return "\\u2029";
62
+ default: return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
63
+ }
64
+ }
65
+ /** @param {string} str */
66
+ function stringify_string(str) {
67
+ let result = "";
68
+ let last_pos = 0;
69
+ const len = str.length;
70
+ for (let i = 0; i < len; i += 1) {
71
+ const char = str[i];
72
+ const replacement = get_escaped_char(char);
73
+ if (replacement) {
74
+ result += str.slice(last_pos, i) + replacement;
75
+ last_pos = i + 1;
76
+ }
77
+ }
78
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
79
+ }
80
+ /** @param {Record<string | symbol, any>} object */
81
+ function enumerable_symbols(object) {
82
+ return Object.getOwnPropertySymbols(object).filter((symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable);
83
+ }
84
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
85
+ /** @param {string} key */
86
+ function stringify_key(key) {
87
+ return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
88
+ }
89
+
90
+ //#endregion
91
+ //#region ../node_modules/devalue/src/uneval.js
92
+ const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
93
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
94
+ const reserved = /^(?: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)$/;
95
+ /**
96
+ * Turn a value into the JavaScript that creates an equivalent value
97
+ * @param {any} value
98
+ * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
99
+ */
100
+ function uneval(value, replacer) {
101
+ const counts = /* @__PURE__ */ new Map();
102
+ /** @type {string[]} */
103
+ const keys = [];
104
+ const custom = /* @__PURE__ */ new Map();
105
+ /** @param {any} thing */
106
+ function walk(thing) {
107
+ if (!is_primitive(thing)) {
108
+ if (counts.has(thing)) {
109
+ counts.set(thing, counts.get(thing) + 1);
110
+ return;
111
+ }
112
+ counts.set(thing, 1);
113
+ if (replacer) {
114
+ const str = replacer(thing, (value) => uneval(value, replacer));
115
+ if (typeof str === "string") {
116
+ custom.set(thing, str);
117
+ return;
118
+ }
119
+ }
120
+ if (typeof thing === "function") throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
121
+ switch (get_type(thing)) {
122
+ case "Number":
123
+ case "BigInt":
124
+ case "String":
125
+ case "Boolean":
126
+ case "Date":
127
+ case "RegExp":
128
+ case "URL":
129
+ case "URLSearchParams": return;
130
+ case "Array":
131
+ /** @type {any[]} */ thing.forEach((value, i) => {
132
+ keys.push(`[${i}]`);
133
+ walk(value);
134
+ keys.pop();
135
+ });
136
+ break;
137
+ case "Set":
138
+ Array.from(thing).forEach(walk);
139
+ break;
140
+ case "Map":
141
+ for (const [key, value] of thing) {
142
+ keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`);
143
+ walk(value);
144
+ keys.pop();
145
+ }
146
+ break;
147
+ case "Int8Array":
148
+ case "Uint8Array":
149
+ case "Uint8ClampedArray":
150
+ case "Int16Array":
151
+ case "Uint16Array":
152
+ case "Int32Array":
153
+ case "Uint32Array":
154
+ case "Float32Array":
155
+ case "Float64Array":
156
+ case "BigInt64Array":
157
+ case "BigUint64Array":
158
+ walk(thing.buffer);
159
+ return;
160
+ case "ArrayBuffer": return;
161
+ case "Temporal.Duration":
162
+ case "Temporal.Instant":
163
+ case "Temporal.PlainDate":
164
+ case "Temporal.PlainTime":
165
+ case "Temporal.PlainDateTime":
166
+ case "Temporal.PlainMonthDay":
167
+ case "Temporal.PlainYearMonth":
168
+ case "Temporal.ZonedDateTime": return;
169
+ default:
170
+ if (!is_plain_object(thing)) throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
171
+ if (enumerable_symbols(thing).length > 0) throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
172
+ for (const key in thing) {
173
+ keys.push(stringify_key(key));
174
+ walk(thing[key]);
175
+ keys.pop();
176
+ }
177
+ }
178
+ }
179
+ }
180
+ walk(value);
181
+ const names = /* @__PURE__ */ new Map();
182
+ Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => {
183
+ names.set(entry[0], get_name(i));
184
+ });
185
+ /**
186
+ * @param {any} thing
187
+ * @returns {string}
188
+ */
189
+ function stringify(thing) {
190
+ if (names.has(thing)) return names.get(thing);
191
+ if (is_primitive(thing)) return stringify_primitive(thing);
192
+ if (custom.has(thing)) return custom.get(thing);
193
+ const type = get_type(thing);
194
+ switch (type) {
195
+ case "Number":
196
+ case "String":
197
+ case "Boolean": return `Object(${stringify(thing.valueOf())})`;
198
+ case "RegExp": return `new RegExp(${stringify_string(thing.source)}, "${thing.flags}")`;
199
+ case "Date": return `new Date(${thing.getTime()})`;
200
+ case "URL": return `new URL(${stringify_string(thing.toString())})`;
201
+ case "URLSearchParams": return `new URLSearchParams(${stringify_string(thing.toString())})`;
202
+ case "Array":
203
+ const members = thing.map((v, i) => i in thing ? stringify(v) : "");
204
+ const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
205
+ return `[${members.join(",")}${tail}]`;
206
+ case "Set":
207
+ case "Map": return `new ${type}([${Array.from(thing).map(stringify).join(",")}])`;
208
+ case "Int8Array":
209
+ case "Uint8Array":
210
+ case "Uint8ClampedArray":
211
+ case "Int16Array":
212
+ case "Uint16Array":
213
+ case "Int32Array":
214
+ case "Uint32Array":
215
+ case "Float32Array":
216
+ case "Float64Array":
217
+ case "BigInt64Array":
218
+ case "BigUint64Array": {
219
+ let str = `new ${type}`;
220
+ if (counts.get(thing.buffer) === 1) {
221
+ const array = new thing.constructor(thing.buffer);
222
+ str += `([${array}])`;
223
+ } else str += `([${stringify(thing.buffer)}])`;
224
+ const a = thing.byteOffset;
225
+ const b = a + thing.byteLength;
226
+ if (a > 0 || b !== thing.buffer.byteLength) {
227
+ const m = +/(\d+)/.exec(type)[1] / 8;
228
+ str += `.subarray(${a / m},${b / m})`;
229
+ }
230
+ return str;
231
+ }
232
+ case "ArrayBuffer": return `new Uint8Array([${new Uint8Array(thing).toString()}]).buffer`;
233
+ case "Temporal.Duration":
234
+ case "Temporal.Instant":
235
+ case "Temporal.PlainDate":
236
+ case "Temporal.PlainTime":
237
+ case "Temporal.PlainDateTime":
238
+ case "Temporal.PlainMonthDay":
239
+ case "Temporal.PlainYearMonth":
240
+ case "Temporal.ZonedDateTime": return `${type}.from(${stringify_string(thing.toString())})`;
241
+ default:
242
+ const keys = Object.keys(thing);
243
+ const obj = keys.map((key) => `${safe_key(key)}:${stringify(thing[key])}`).join(",");
244
+ if (Object.getPrototypeOf(thing) === null) return keys.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
245
+ return `{${obj}}`;
246
+ }
247
+ }
248
+ const str = stringify(value);
249
+ if (names.size) {
250
+ /** @type {string[]} */
251
+ const params = [];
252
+ /** @type {string[]} */
253
+ const statements = [];
254
+ /** @type {string[]} */
255
+ const values = [];
256
+ names.forEach((name, thing) => {
257
+ params.push(name);
258
+ if (custom.has(thing)) {
259
+ values.push(custom.get(thing));
260
+ return;
261
+ }
262
+ if (is_primitive(thing)) {
263
+ values.push(stringify_primitive(thing));
264
+ return;
265
+ }
266
+ switch (get_type(thing)) {
267
+ case "Number":
268
+ case "String":
269
+ case "Boolean":
270
+ values.push(`Object(${stringify(thing.valueOf())})`);
271
+ break;
272
+ case "RegExp":
273
+ values.push(thing.toString());
274
+ break;
275
+ case "Date":
276
+ values.push(`new Date(${thing.getTime()})`);
277
+ break;
278
+ case "Array":
279
+ values.push(`Array(${thing.length})`);
280
+ /** @type {any[]} */ thing.forEach((v, i) => {
281
+ statements.push(`${name}[${i}]=${stringify(v)}`);
282
+ });
283
+ break;
284
+ case "Set":
285
+ values.push(`new Set`);
286
+ statements.push(`${name}.${Array.from(thing).map((v) => `add(${stringify(v)})`).join(".")}`);
287
+ break;
288
+ case "Map":
289
+ values.push(`new Map`);
290
+ statements.push(`${name}.${Array.from(thing).map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`).join(".")}`);
291
+ break;
292
+ case "ArrayBuffer":
293
+ values.push(`new Uint8Array([${new Uint8Array(thing).join(",")}]).buffer`);
294
+ break;
295
+ default:
296
+ values.push(Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}");
297
+ Object.keys(thing).forEach((key) => {
298
+ statements.push(`${name}${safe_prop(key)}=${stringify(thing[key])}`);
299
+ });
300
+ }
301
+ });
302
+ statements.push(`return ${str}`);
303
+ return `(function(${params.join(",")}){${statements.join(";")}}(${values.join(",")}))`;
304
+ } else return str;
305
+ }
306
+ /** @param {number} num */
307
+ function get_name(num) {
308
+ let name = "";
309
+ do {
310
+ name = chars[num % 54] + name;
311
+ num = ~~(num / 54) - 1;
312
+ } while (num >= 0);
313
+ return reserved.test(name) ? `${name}0` : name;
314
+ }
315
+ /** @param {string} c */
316
+ function escape_unsafe_char(c) {
317
+ return escaped[c] || c;
318
+ }
319
+ /** @param {string} str */
320
+ function escape_unsafe_chars(str) {
321
+ return str.replace(unsafe_chars, escape_unsafe_char);
322
+ }
323
+ /** @param {string} key */
324
+ function safe_key(key) {
325
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
326
+ }
327
+ /** @param {string} key */
328
+ function safe_prop(key) {
329
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
330
+ }
331
+ /** @param {any} thing */
332
+ function stringify_primitive(thing) {
333
+ if (typeof thing === "string") return stringify_string(thing);
334
+ if (thing === void 0) return "void 0";
335
+ if (thing === 0 && 1 / thing < 0) return "-0";
336
+ const str = String(thing);
337
+ if (typeof thing === "number") return str.replace(/^(-)?0\./, "$1.");
338
+ if (typeof thing === "bigint") return thing + "n";
339
+ return str;
340
+ }
341
+
342
+ //#endregion
343
+ //#region .svelte-kit/adapter-bun/chunks/index2.js
344
+ const DERIVED = 2;
345
+ const EFFECT = 4;
346
+ const RENDER_EFFECT = 8;
347
+ const MANAGED_EFFECT = 1 << 24;
348
+ const BLOCK_EFFECT = 16;
349
+ const BRANCH_EFFECT = 32;
350
+ const ROOT_EFFECT = 64;
351
+ const BOUNDARY_EFFECT = 128;
352
+ const CONNECTED = 512;
353
+ const CLEAN = 1024;
354
+ const DIRTY = 2048;
355
+ const MAYBE_DIRTY = 4096;
356
+ const INERT = 8192;
357
+ const DESTROYED = 16384;
358
+ const EFFECT_RAN = 32768;
359
+ const EFFECT_TRANSPARENT = 65536;
360
+ const EAGER_EFFECT = 1 << 17;
361
+ const HEAD_EFFECT = 1 << 18;
362
+ const EFFECT_PRESERVED = 1 << 19;
363
+ const USER_EFFECT = 1 << 20;
364
+ const WAS_MARKED = 32768;
365
+ const REACTION_IS_UPDATING = 1 << 21;
366
+ const ASYNC = 1 << 22;
367
+ const ERROR_VALUE = 1 << 23;
368
+ const STATE_SYMBOL = /* @__PURE__ */ Symbol("$state");
369
+ const LEGACY_PROPS = /* @__PURE__ */ Symbol("legacy props");
370
+ const STALE_REACTION = new class StaleReactionError extends Error {
371
+ name = "StaleReactionError";
372
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
373
+ }();
374
+ const COMMENT_NODE = 8;
375
+ function effect_update_depth_exceeded() {
376
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
377
+ }
378
+ function hydration_failed() {
379
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
380
+ }
381
+ function state_descriptors_fixed() {
382
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
383
+ }
384
+ function state_prototype_fixed() {
385
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
386
+ }
387
+ function state_unsafe_mutation() {
388
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
389
+ }
390
+ function svelte_boundary_reset_onerror() {
391
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
392
+ }
393
+ const HYDRATION_START = "[";
394
+ const HYDRATION_START_ELSE = "[!";
395
+ const HYDRATION_END = "]";
396
+ const HYDRATION_ERROR = {};
397
+ const ELEMENT_IS_NAMESPACED = 1;
398
+ const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 2;
399
+ const ELEMENT_IS_INPUT = 4;
400
+ const UNINITIALIZED = /* @__PURE__ */ Symbol();
401
+ const ATTACHMENT_KEY = "@attach";
402
+ let component_context = null;
403
+ function set_component_context(context) {
404
+ component_context = context;
405
+ }
406
+ function push(props, runes = false, fn) {
407
+ component_context = {
408
+ p: component_context,
409
+ i: false,
410
+ c: null,
411
+ e: null,
412
+ s: props,
413
+ x: null,
414
+ l: null
415
+ };
416
+ }
417
+ function pop(component) {
418
+ var context = component_context;
419
+ var effects = context.e;
420
+ if (effects !== null) {
421
+ context.e = null;
422
+ for (var fn of effects) create_user_effect(fn);
423
+ }
424
+ context.i = true;
425
+ component_context = context.p;
426
+ return (
427
+ /** @type {T} */
428
+ {});
429
+ }
430
+ function is_runes() {
431
+ return true;
432
+ }
433
+ let micro_tasks = [];
434
+ function run_micro_tasks() {
435
+ var tasks = micro_tasks;
436
+ micro_tasks = [];
437
+ run_all(tasks);
438
+ }
439
+ function queue_micro_task(fn) {
440
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
441
+ var tasks = micro_tasks;
442
+ queueMicrotask(() => {
443
+ if (tasks === micro_tasks) run_micro_tasks();
444
+ });
445
+ }
446
+ micro_tasks.push(fn);
447
+ }
448
+ function flush_tasks() {
449
+ while (micro_tasks.length > 0) run_micro_tasks();
450
+ }
451
+ function handle_error(error) {
452
+ var effect = active_effect;
453
+ if (effect === null) {
454
+ active_reaction.f |= ERROR_VALUE;
455
+ return error;
456
+ }
457
+ if ((effect.f & EFFECT_RAN) === 0) {
458
+ if ((effect.f & BOUNDARY_EFFECT) === 0) throw error;
459
+ effect.b.error(error);
460
+ } else invoke_error_boundary(error, effect);
461
+ }
462
+ function invoke_error_boundary(error, effect) {
463
+ while (effect !== null) {
464
+ if ((effect.f & BOUNDARY_EFFECT) !== 0) try {
465
+ effect.b.error(error);
466
+ return;
467
+ } catch (e) {
468
+ error = e;
469
+ }
470
+ effect = effect.parent;
471
+ }
472
+ throw error;
473
+ }
474
+ const STATUS_MASK = -7169;
475
+ function set_signal_status(signal, status) {
476
+ signal.f = signal.f & STATUS_MASK | status;
477
+ }
478
+ function update_derived_status(derived2) {
479
+ if ((derived2.f & CONNECTED) !== 0 || derived2.deps === null) set_signal_status(derived2, CLEAN);
480
+ else set_signal_status(derived2, MAYBE_DIRTY);
481
+ }
482
+ function clear_marked(deps) {
483
+ if (deps === null) return;
484
+ for (const dep of deps) {
485
+ if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) continue;
486
+ dep.f ^= WAS_MARKED;
487
+ clear_marked(
488
+ /** @type {Derived} */
489
+ dep.deps
490
+ );
491
+ }
492
+ }
493
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
494
+ if ((effect.f & DIRTY) !== 0) dirty_effects.add(effect);
495
+ else if ((effect.f & MAYBE_DIRTY) !== 0) maybe_dirty_effects.add(effect);
496
+ clear_marked(effect.deps);
497
+ set_signal_status(effect, CLEAN);
498
+ }
499
+ const batches = /* @__PURE__ */ new Set();
500
+ let current_batch = null;
501
+ let batch_values = null;
502
+ let queued_root_effects = [];
503
+ let last_scheduled_effect = null;
504
+ let is_flushing = false;
505
+ let is_flushing_sync = false;
506
+ var Batch = class Batch {
507
+ committed = false;
508
+ /**
509
+ * The current values of any sources that are updated in this batch
510
+ * They keys of this map are identical to `this.#previous`
511
+ * @type {Map<Source, any>}
512
+ */
513
+ current = /* @__PURE__ */ new Map();
514
+ /**
515
+ * The values of any sources that are updated in this batch _before_ those updates took place.
516
+ * They keys of this map are identical to `this.#current`
517
+ * @type {Map<Source, any>}
518
+ */
519
+ previous = /* @__PURE__ */ new Map();
520
+ /**
521
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
522
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
523
+ * @type {Set<() => void>}
524
+ */
525
+ #commit_callbacks = /* @__PURE__ */ new Set();
526
+ /**
527
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
528
+ * @type {Set<(batch: Batch) => void>}
529
+ */
530
+ #discard_callbacks = /* @__PURE__ */ new Set();
531
+ /**
532
+ * The number of async effects that are currently in flight
533
+ */
534
+ #pending = 0;
535
+ /**
536
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
537
+ */
538
+ #blocking_pending = 0;
539
+ /**
540
+ * A deferred that resolves when the batch is committed, used with `settled()`
541
+ * TODO replace with Promise.withResolvers once supported widely enough
542
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
543
+ */
544
+ #deferred = null;
545
+ /**
546
+ * Deferred effects (which run after async work has completed) that are DIRTY
547
+ * @type {Set<Effect>}
548
+ */
549
+ #dirty_effects = /* @__PURE__ */ new Set();
550
+ /**
551
+ * Deferred effects that are MAYBE_DIRTY
552
+ * @type {Set<Effect>}
553
+ */
554
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
555
+ /**
556
+ * A set of branches that still exist, but will be destroyed when this batch
557
+ * is committed — we skip over these during `process`
558
+ * @type {Set<Effect>}
559
+ */
560
+ skipped_effects = /* @__PURE__ */ new Set();
561
+ is_fork = false;
562
+ #decrement_queued = false;
563
+ is_deferred() {
564
+ return this.is_fork || this.#blocking_pending > 0;
565
+ }
566
+ /**
567
+ *
568
+ * @param {Effect[]} root_effects
569
+ */
570
+ process(root_effects) {
571
+ queued_root_effects = [];
572
+ this.apply();
573
+ var effects = [];
574
+ var render_effects = [];
575
+ for (const root of root_effects) this.#traverse_effect_tree(root, effects, render_effects);
576
+ if (this.is_deferred()) {
577
+ this.#defer_effects(render_effects);
578
+ this.#defer_effects(effects);
579
+ } else {
580
+ for (const fn of this.#commit_callbacks) fn();
581
+ this.#commit_callbacks.clear();
582
+ if (this.#pending === 0) this.#commit();
583
+ current_batch = null;
584
+ flush_queued_effects(render_effects);
585
+ flush_queued_effects(effects);
586
+ this.#deferred?.resolve();
587
+ }
588
+ batch_values = null;
589
+ }
590
+ /**
591
+ * Traverse the effect tree, executing effects or stashing
592
+ * them for later execution as appropriate
593
+ * @param {Effect} root
594
+ * @param {Effect[]} effects
595
+ * @param {Effect[]} render_effects
596
+ */
597
+ #traverse_effect_tree(root, effects, render_effects) {
598
+ root.f ^= CLEAN;
599
+ var effect = root.first;
600
+ var pending_boundary = null;
601
+ while (effect !== null) {
602
+ var flags = effect.f;
603
+ var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
604
+ if (!(is_branch && (flags & CLEAN) !== 0 || (flags & INERT) !== 0 || this.skipped_effects.has(effect)) && effect.fn !== null) {
605
+ if (is_branch) effect.f ^= CLEAN;
606
+ else if (pending_boundary !== null && (flags & (RENDER_EFFECT | 16777220)) !== 0) pending_boundary.b.defer_effect(effect);
607
+ else if ((flags & EFFECT) !== 0) effects.push(effect);
608
+ else if (is_dirty(effect)) {
609
+ if ((flags & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect);
610
+ update_effect(effect);
611
+ }
612
+ var child = effect.first;
613
+ if (child !== null) {
614
+ effect = child;
615
+ continue;
616
+ }
617
+ }
618
+ var parent = effect.parent;
619
+ effect = effect.next;
620
+ while (effect === null && parent !== null) {
621
+ if (parent === pending_boundary) pending_boundary = null;
622
+ effect = parent.next;
623
+ parent = parent.parent;
624
+ }
625
+ }
626
+ }
627
+ /**
628
+ * @param {Effect[]} effects
629
+ */
630
+ #defer_effects(effects) {
631
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
632
+ }
633
+ /**
634
+ * Associate a change to a given source with the current
635
+ * batch, noting its previous and current values
636
+ * @param {Source} source
637
+ * @param {any} value
638
+ */
639
+ capture(source2, value) {
640
+ if (value !== UNINITIALIZED && !this.previous.has(source2)) this.previous.set(source2, value);
641
+ if ((source2.f & ERROR_VALUE) === 0) {
642
+ this.current.set(source2, source2.v);
643
+ batch_values?.set(source2, source2.v);
644
+ }
645
+ }
646
+ activate() {
647
+ current_batch = this;
648
+ this.apply();
649
+ }
650
+ deactivate() {
651
+ if (current_batch !== this) return;
652
+ current_batch = null;
653
+ batch_values = null;
654
+ }
655
+ flush() {
656
+ this.activate();
657
+ if (queued_root_effects.length > 0) {
658
+ flush_effects();
659
+ if (current_batch !== null && current_batch !== this) return;
660
+ } else if (this.#pending === 0) this.process([]);
661
+ this.deactivate();
662
+ }
663
+ discard() {
664
+ for (const fn of this.#discard_callbacks) fn(this);
665
+ this.#discard_callbacks.clear();
666
+ }
667
+ #commit() {
668
+ if (batches.size > 1) {
669
+ this.previous.clear();
670
+ var previous_batch_values = batch_values;
671
+ var is_earlier = true;
672
+ for (const batch of batches) {
673
+ if (batch === this) {
674
+ is_earlier = false;
675
+ continue;
676
+ }
677
+ const sources = [];
678
+ for (const [source2, value] of this.current) {
679
+ if (batch.current.has(source2)) if (is_earlier && value !== batch.current.get(source2)) batch.current.set(source2, value);
680
+ else continue;
681
+ sources.push(source2);
682
+ }
683
+ if (sources.length === 0) continue;
684
+ const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
685
+ if (others.length > 0) {
686
+ var prev_queued_root_effects = queued_root_effects;
687
+ queued_root_effects = [];
688
+ const marked = /* @__PURE__ */ new Set();
689
+ const checked = /* @__PURE__ */ new Map();
690
+ for (const source2 of sources) mark_effects(source2, others, marked, checked);
691
+ if (queued_root_effects.length > 0) {
692
+ current_batch = batch;
693
+ batch.apply();
694
+ for (const root of queued_root_effects) batch.#traverse_effect_tree(root, [], []);
695
+ batch.deactivate();
696
+ }
697
+ queued_root_effects = prev_queued_root_effects;
698
+ }
699
+ }
700
+ current_batch = null;
701
+ batch_values = previous_batch_values;
702
+ }
703
+ this.committed = true;
704
+ batches.delete(this);
705
+ }
706
+ /**
707
+ *
708
+ * @param {boolean} blocking
709
+ */
710
+ increment(blocking) {
711
+ this.#pending += 1;
712
+ if (blocking) this.#blocking_pending += 1;
713
+ }
714
+ /**
715
+ *
716
+ * @param {boolean} blocking
717
+ */
718
+ decrement(blocking) {
719
+ this.#pending -= 1;
720
+ if (blocking) this.#blocking_pending -= 1;
721
+ if (this.#decrement_queued) return;
722
+ this.#decrement_queued = true;
723
+ queue_micro_task(() => {
724
+ this.#decrement_queued = false;
725
+ if (!this.is_deferred()) this.revive();
726
+ else if (queued_root_effects.length > 0) this.flush();
727
+ });
728
+ }
729
+ revive() {
730
+ for (const e of this.#dirty_effects) {
731
+ this.#maybe_dirty_effects.delete(e);
732
+ set_signal_status(e, DIRTY);
733
+ schedule_effect(e);
734
+ }
735
+ for (const e of this.#maybe_dirty_effects) {
736
+ set_signal_status(e, MAYBE_DIRTY);
737
+ schedule_effect(e);
738
+ }
739
+ this.flush();
740
+ }
741
+ /** @param {() => void} fn */
742
+ oncommit(fn) {
743
+ this.#commit_callbacks.add(fn);
744
+ }
745
+ /** @param {(batch: Batch) => void} fn */
746
+ ondiscard(fn) {
747
+ this.#discard_callbacks.add(fn);
748
+ }
749
+ settled() {
750
+ return (this.#deferred ??= deferred()).promise;
751
+ }
752
+ static ensure() {
753
+ if (current_batch === null) {
754
+ const batch = current_batch = new Batch();
755
+ batches.add(current_batch);
756
+ if (!is_flushing_sync) queue_micro_task(() => {
757
+ if (current_batch !== batch) return;
758
+ batch.flush();
759
+ });
760
+ }
761
+ return current_batch;
762
+ }
763
+ apply() {}
764
+ };
765
+ function flushSync(fn) {
766
+ var was_flushing_sync = is_flushing_sync;
767
+ is_flushing_sync = true;
768
+ try {
769
+ var result;
770
+ if (fn);
771
+ while (true) {
772
+ flush_tasks();
773
+ if (queued_root_effects.length === 0) {
774
+ current_batch?.flush();
775
+ if (queued_root_effects.length === 0) {
776
+ last_scheduled_effect = null;
777
+ return result;
778
+ }
779
+ }
780
+ flush_effects();
781
+ }
782
+ } finally {
783
+ is_flushing_sync = was_flushing_sync;
784
+ }
785
+ }
786
+ function flush_effects() {
787
+ is_flushing = true;
788
+ try {
789
+ var flush_count = 0;
790
+ while (queued_root_effects.length > 0) {
791
+ var batch = Batch.ensure();
792
+ if (flush_count++ > 1e3) {
793
+ if (BROWSER);
794
+ infinite_loop_guard();
795
+ }
796
+ batch.process(queued_root_effects);
797
+ old_values.clear();
798
+ if (BROWSER);
799
+ }
800
+ } finally {
801
+ is_flushing = false;
802
+ last_scheduled_effect = null;
803
+ }
804
+ }
805
+ function infinite_loop_guard() {
806
+ try {
807
+ effect_update_depth_exceeded();
808
+ } catch (error) {
809
+ invoke_error_boundary(error, last_scheduled_effect);
810
+ }
811
+ }
812
+ let eager_block_effects = null;
813
+ function flush_queued_effects(effects) {
814
+ var length = effects.length;
815
+ if (length === 0) return;
816
+ var i = 0;
817
+ while (i < length) {
818
+ var effect = effects[i++];
819
+ if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
820
+ eager_block_effects = /* @__PURE__ */ new Set();
821
+ update_effect(effect);
822
+ if (effect.deps === null && effect.first === null && effect.nodes === null) if (effect.teardown === null && effect.ac === null) unlink_effect(effect);
823
+ else effect.fn = null;
824
+ if (eager_block_effects?.size > 0) {
825
+ old_values.clear();
826
+ for (const e of eager_block_effects) {
827
+ if ((e.f & (DESTROYED | INERT)) !== 0) continue;
828
+ const ordered_effects = [e];
829
+ let ancestor = e.parent;
830
+ while (ancestor !== null) {
831
+ if (eager_block_effects.has(ancestor)) {
832
+ eager_block_effects.delete(ancestor);
833
+ ordered_effects.push(ancestor);
834
+ }
835
+ ancestor = ancestor.parent;
836
+ }
837
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
838
+ const e2 = ordered_effects[j];
839
+ if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
840
+ update_effect(e2);
841
+ }
842
+ }
843
+ eager_block_effects.clear();
844
+ }
845
+ }
846
+ }
847
+ eager_block_effects = null;
848
+ }
849
+ function mark_effects(value, sources, marked, checked) {
850
+ if (marked.has(value)) return;
851
+ marked.add(value);
852
+ if (value.reactions !== null) for (const reaction of value.reactions) {
853
+ const flags = reaction.f;
854
+ if ((flags & DERIVED) !== 0) mark_effects(
855
+ /** @type {Derived} */
856
+ reaction,
857
+ sources,
858
+ marked,
859
+ checked
860
+ );
861
+ else if ((flags & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags & DIRTY) === 0 && depends_on(reaction, sources, checked)) {
862
+ set_signal_status(reaction, DIRTY);
863
+ schedule_effect(
864
+ /** @type {Effect} */
865
+ reaction
866
+ );
867
+ }
868
+ }
869
+ }
870
+ function depends_on(reaction, sources, checked) {
871
+ const depends = checked.get(reaction);
872
+ if (depends !== void 0) return depends;
873
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
874
+ if (includes.call(sources, dep)) return true;
875
+ if ((dep.f & DERIVED) !== 0 && depends_on(
876
+ /** @type {Derived} */
877
+ dep,
878
+ sources,
879
+ checked
880
+ )) {
881
+ checked.set(
882
+ /** @type {Derived} */
883
+ dep,
884
+ true
885
+ );
886
+ return true;
887
+ }
888
+ }
889
+ checked.set(reaction, false);
890
+ return false;
891
+ }
892
+ function schedule_effect(signal) {
893
+ var effect = last_scheduled_effect = signal;
894
+ while (effect.parent !== null) {
895
+ effect = effect.parent;
896
+ var flags = effect.f;
897
+ if (is_flushing && effect === active_effect && (flags & BLOCK_EFFECT) !== 0 && (flags & HEAD_EFFECT) === 0) return;
898
+ if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
899
+ if ((flags & CLEAN) === 0) return;
900
+ effect.f ^= CLEAN;
901
+ }
902
+ }
903
+ queued_root_effects.push(effect);
904
+ }
905
+ function destroy_derived_effects(derived2) {
906
+ var effects = derived2.effects;
907
+ if (effects !== null) {
908
+ derived2.effects = null;
909
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(
910
+ /** @type {Effect} */
911
+ effects[i]
912
+ );
913
+ }
914
+ }
915
+ function get_derived_parent_effect(derived2) {
916
+ var parent = derived2.parent;
917
+ while (parent !== null) {
918
+ if ((parent.f & DERIVED) === 0) return (parent.f & DESTROYED) === 0 ? parent : null;
919
+ parent = parent.parent;
920
+ }
921
+ return null;
922
+ }
923
+ function execute_derived(derived2) {
924
+ var value;
925
+ var prev_active_effect = active_effect;
926
+ set_active_effect(get_derived_parent_effect(derived2));
927
+ try {
928
+ derived2.f &= ~WAS_MARKED;
929
+ destroy_derived_effects(derived2);
930
+ value = update_reaction(derived2);
931
+ } finally {
932
+ set_active_effect(prev_active_effect);
933
+ }
934
+ return value;
935
+ }
936
+ function update_derived(derived2) {
937
+ var value = execute_derived(derived2);
938
+ if (!derived2.equals(value)) {
939
+ derived2.wv = increment_write_version();
940
+ if (!current_batch?.is_fork || derived2.deps === null) {
941
+ derived2.v = value;
942
+ if (derived2.deps === null) {
943
+ set_signal_status(derived2, CLEAN);
944
+ return;
945
+ }
946
+ }
947
+ }
948
+ if (is_destroying_effect) return;
949
+ if (batch_values !== null) {
950
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived2, value);
951
+ } else update_derived_status(derived2);
952
+ }
953
+ let eager_effects = /* @__PURE__ */ new Set();
954
+ const old_values = /* @__PURE__ */ new Map();
955
+ let eager_effects_deferred = false;
956
+ function source(v, stack) {
957
+ return {
958
+ f: 0,
959
+ v,
960
+ reactions: null,
961
+ equals,
962
+ rv: 0,
963
+ wv: 0
964
+ };
965
+ }
966
+ /* @__NO_SIDE_EFFECTS__ */
967
+ function state(v, stack) {
968
+ const s = source(v);
969
+ push_reaction_value(s);
970
+ return s;
971
+ }
972
+ /* @__NO_SIDE_EFFECTS__ */
973
+ function mutable_source(initial_value, immutable = false, trackable = true) {
974
+ const s = source(initial_value);
975
+ if (!immutable) s.equals = safe_equals;
976
+ return s;
977
+ }
978
+ function set(source2, value, should_proxy = false) {
979
+ if (active_reaction !== null && (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & 4325394) !== 0 && (current_sources === null || !includes.call(current_sources, source2))) state_unsafe_mutation();
980
+ return internal_set(source2, should_proxy ? proxy(value) : value);
981
+ }
982
+ function internal_set(source2, value) {
983
+ if (!source2.equals(value)) {
984
+ var old_value = source2.v;
985
+ if (is_destroying_effect) old_values.set(source2, value);
986
+ else old_values.set(source2, old_value);
987
+ source2.v = value;
988
+ var batch = Batch.ensure();
989
+ batch.capture(source2, old_value);
990
+ if ((source2.f & DERIVED) !== 0) {
991
+ const derived2 = source2;
992
+ if ((source2.f & DIRTY) !== 0) execute_derived(derived2);
993
+ update_derived_status(derived2);
994
+ }
995
+ source2.wv = increment_write_version();
996
+ mark_reactions(source2, DIRTY);
997
+ if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) if (untracked_writes === null) set_untracked_writes([source2]);
998
+ else untracked_writes.push(source2);
999
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) flush_eager_effects();
1000
+ }
1001
+ return value;
1002
+ }
1003
+ function flush_eager_effects() {
1004
+ eager_effects_deferred = false;
1005
+ for (const effect of eager_effects) {
1006
+ if ((effect.f & CLEAN) !== 0) set_signal_status(effect, MAYBE_DIRTY);
1007
+ if (is_dirty(effect)) update_effect(effect);
1008
+ }
1009
+ eager_effects.clear();
1010
+ }
1011
+ function increment(source2) {
1012
+ set(source2, source2.v + 1);
1013
+ }
1014
+ function mark_reactions(signal, status) {
1015
+ var reactions = signal.reactions;
1016
+ if (reactions === null) return;
1017
+ var length = reactions.length;
1018
+ for (var i = 0; i < length; i++) {
1019
+ var reaction = reactions[i];
1020
+ var flags = reaction.f;
1021
+ var not_dirty = (flags & DIRTY) === 0;
1022
+ if (not_dirty) set_signal_status(reaction, status);
1023
+ if ((flags & DERIVED) !== 0) {
1024
+ var derived2 = reaction;
1025
+ batch_values?.delete(derived2);
1026
+ if ((flags & WAS_MARKED) === 0) {
1027
+ if (flags & CONNECTED) reaction.f |= WAS_MARKED;
1028
+ mark_reactions(derived2, MAYBE_DIRTY);
1029
+ }
1030
+ } else if (not_dirty) {
1031
+ if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) eager_block_effects.add(
1032
+ /** @type {Effect} */
1033
+ reaction
1034
+ );
1035
+ schedule_effect(
1036
+ /** @type {Effect} */
1037
+ reaction
1038
+ );
1039
+ }
1040
+ }
1041
+ }
1042
+ function proxy(value) {
1043
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) return value;
1044
+ const prototype = get_prototype_of(value);
1045
+ if (prototype !== object_prototype && prototype !== array_prototype) return value;
1046
+ var sources = /* @__PURE__ */ new Map();
1047
+ var is_proxied_array = is_array(value);
1048
+ var version = /* @__PURE__ */ state(0);
1049
+ var parent_version = update_version;
1050
+ var with_parent = (fn) => {
1051
+ if (update_version === parent_version) return fn();
1052
+ var reaction = active_reaction;
1053
+ var version2 = update_version;
1054
+ set_active_reaction(null);
1055
+ set_update_version(parent_version);
1056
+ var result = fn();
1057
+ set_active_reaction(reaction);
1058
+ set_update_version(version2);
1059
+ return result;
1060
+ };
1061
+ if (is_proxied_array) sources.set("length", /* @__PURE__ */ state(
1062
+ /** @type {any[]} */
1063
+ value.length
1064
+ ));
1065
+ return new Proxy(
1066
+ /** @type {any} */
1067
+ value,
1068
+ {
1069
+ defineProperty(_, prop, descriptor) {
1070
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) state_descriptors_fixed();
1071
+ var s = sources.get(prop);
1072
+ if (s === void 0) s = with_parent(() => {
1073
+ var s2 = /* @__PURE__ */ state(descriptor.value);
1074
+ sources.set(prop, s2);
1075
+ return s2;
1076
+ });
1077
+ else set(s, descriptor.value, true);
1078
+ return true;
1079
+ },
1080
+ deleteProperty(target, prop) {
1081
+ var s = sources.get(prop);
1082
+ if (s === void 0) {
1083
+ if (prop in target) {
1084
+ const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1085
+ sources.set(prop, s2);
1086
+ increment(version);
1087
+ }
1088
+ } else {
1089
+ set(s, UNINITIALIZED);
1090
+ increment(version);
1091
+ }
1092
+ return true;
1093
+ },
1094
+ get(target, prop, receiver) {
1095
+ if (prop === STATE_SYMBOL) return value;
1096
+ var s = sources.get(prop);
1097
+ var exists = prop in target;
1098
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1099
+ s = with_parent(() => {
1100
+ return /* @__PURE__ */ state(proxy(exists ? target[prop] : UNINITIALIZED));
1101
+ });
1102
+ sources.set(prop, s);
1103
+ }
1104
+ if (s !== void 0) {
1105
+ var v = get(s);
1106
+ return v === UNINITIALIZED ? void 0 : v;
1107
+ }
1108
+ return Reflect.get(target, prop, receiver);
1109
+ },
1110
+ getOwnPropertyDescriptor(target, prop) {
1111
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1112
+ if (descriptor && "value" in descriptor) {
1113
+ var s = sources.get(prop);
1114
+ if (s) descriptor.value = get(s);
1115
+ } else if (descriptor === void 0) {
1116
+ var source2 = sources.get(prop);
1117
+ var value2 = source2?.v;
1118
+ if (source2 !== void 0 && value2 !== UNINITIALIZED) return {
1119
+ enumerable: true,
1120
+ configurable: true,
1121
+ value: value2,
1122
+ writable: true
1123
+ };
1124
+ }
1125
+ return descriptor;
1126
+ },
1127
+ has(target, prop) {
1128
+ if (prop === STATE_SYMBOL) return true;
1129
+ var s = sources.get(prop);
1130
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
1131
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
1132
+ if (s === void 0) {
1133
+ s = with_parent(() => {
1134
+ return /* @__PURE__ */ state(has ? proxy(target[prop]) : UNINITIALIZED);
1135
+ });
1136
+ sources.set(prop, s);
1137
+ }
1138
+ if (get(s) === UNINITIALIZED) return false;
1139
+ }
1140
+ return has;
1141
+ },
1142
+ set(target, prop, value2, receiver) {
1143
+ var s = sources.get(prop);
1144
+ var has = prop in target;
1145
+ if (is_proxied_array && prop === "length") for (var i = value2; i < s.v; i += 1) {
1146
+ var other_s = sources.get(i + "");
1147
+ if (other_s !== void 0) set(other_s, UNINITIALIZED);
1148
+ else if (i in target) {
1149
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1150
+ sources.set(i + "", other_s);
1151
+ }
1152
+ }
1153
+ if (s === void 0) {
1154
+ if (!has || get_descriptor(target, prop)?.writable) {
1155
+ s = with_parent(() => /* @__PURE__ */ state(void 0));
1156
+ set(s, proxy(value2));
1157
+ sources.set(prop, s);
1158
+ }
1159
+ } else {
1160
+ has = s.v !== UNINITIALIZED;
1161
+ var p = with_parent(() => proxy(value2));
1162
+ set(s, p);
1163
+ }
1164
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1165
+ if (descriptor?.set) descriptor.set.call(receiver, value2);
1166
+ if (!has) {
1167
+ if (is_proxied_array && typeof prop === "string") {
1168
+ var ls = sources.get("length");
1169
+ var n = Number(prop);
1170
+ if (Number.isInteger(n) && n >= ls.v) set(ls, n + 1);
1171
+ }
1172
+ increment(version);
1173
+ }
1174
+ return true;
1175
+ },
1176
+ ownKeys(target) {
1177
+ get(version);
1178
+ var own_keys = Reflect.ownKeys(target).filter((key2) => {
1179
+ var source3 = sources.get(key2);
1180
+ return source3 === void 0 || source3.v !== UNINITIALIZED;
1181
+ });
1182
+ for (var [key, source2] of sources) if (source2.v !== UNINITIALIZED && !(key in target)) own_keys.push(key);
1183
+ return own_keys;
1184
+ },
1185
+ setPrototypeOf() {
1186
+ state_prototype_fixed();
1187
+ }
1188
+ }
1189
+ );
1190
+ }
1191
+ var $window;
1192
+ var first_child_getter;
1193
+ var next_sibling_getter;
1194
+ function init_operations() {
1195
+ if ($window !== void 0) return;
1196
+ $window = window;
1197
+ var element_prototype = Element.prototype;
1198
+ var node_prototype = Node.prototype;
1199
+ var text_prototype = Text.prototype;
1200
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
1201
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
1202
+ if (is_extensible(element_prototype)) {
1203
+ element_prototype.__click = void 0;
1204
+ element_prototype.__className = void 0;
1205
+ element_prototype.__attributes = null;
1206
+ element_prototype.__style = void 0;
1207
+ element_prototype.__e = void 0;
1208
+ }
1209
+ if (is_extensible(text_prototype)) text_prototype.__t = void 0;
1210
+ }
1211
+ function create_text(value = "") {
1212
+ return document.createTextNode(value);
1213
+ }
1214
+ /* @__NO_SIDE_EFFECTS__ */
1215
+ function get_first_child(node) {
1216
+ return first_child_getter.call(node);
1217
+ }
1218
+ /* @__NO_SIDE_EFFECTS__ */
1219
+ function get_next_sibling(node) {
1220
+ return next_sibling_getter.call(node);
1221
+ }
1222
+ function clear_text_content(node) {
1223
+ node.textContent = "";
1224
+ }
1225
+ function without_reactive_context(fn) {
1226
+ var previous_reaction = active_reaction;
1227
+ var previous_effect = active_effect;
1228
+ set_active_reaction(null);
1229
+ set_active_effect(null);
1230
+ try {
1231
+ return fn();
1232
+ } finally {
1233
+ set_active_reaction(previous_reaction);
1234
+ set_active_effect(previous_effect);
1235
+ }
1236
+ }
1237
+ function push_effect(effect, parent_effect) {
1238
+ var parent_last = parent_effect.last;
1239
+ if (parent_last === null) parent_effect.last = parent_effect.first = effect;
1240
+ else {
1241
+ parent_last.next = effect;
1242
+ effect.prev = parent_last;
1243
+ parent_effect.last = effect;
1244
+ }
1245
+ }
1246
+ function create_effect(type, fn, sync) {
1247
+ var parent = active_effect;
1248
+ if (parent !== null && (parent.f & INERT) !== 0) type |= INERT;
1249
+ var effect = {
1250
+ ctx: component_context,
1251
+ deps: null,
1252
+ nodes: null,
1253
+ f: type | 2560,
1254
+ first: null,
1255
+ fn,
1256
+ last: null,
1257
+ next: null,
1258
+ parent,
1259
+ b: parent && parent.b,
1260
+ prev: null,
1261
+ teardown: null,
1262
+ wv: 0,
1263
+ ac: null
1264
+ };
1265
+ if (sync) try {
1266
+ update_effect(effect);
1267
+ effect.f |= EFFECT_RAN;
1268
+ } catch (e2) {
1269
+ destroy_effect(effect);
1270
+ throw e2;
1271
+ }
1272
+ else if (fn !== null) schedule_effect(effect);
1273
+ var e = effect;
1274
+ if (sync && e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && (e.f & EFFECT_PRESERVED) === 0) {
1275
+ e = e.first;
1276
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) e.f |= EFFECT_TRANSPARENT;
1277
+ }
1278
+ if (e !== null) {
1279
+ e.parent = parent;
1280
+ if (parent !== null) push_effect(e, parent);
1281
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
1282
+ var derived2 = active_reaction;
1283
+ (derived2.effects ??= []).push(e);
1284
+ }
1285
+ }
1286
+ return effect;
1287
+ }
1288
+ function effect_tracking() {
1289
+ return active_reaction !== null && !untracking;
1290
+ }
1291
+ function create_user_effect(fn) {
1292
+ return create_effect(EFFECT | USER_EFFECT, fn, false);
1293
+ }
1294
+ function component_root(fn) {
1295
+ Batch.ensure();
1296
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn, true);
1297
+ return (options = {}) => {
1298
+ return new Promise((fulfil) => {
1299
+ if (options.outro) pause_effect(effect, () => {
1300
+ destroy_effect(effect);
1301
+ fulfil(void 0);
1302
+ });
1303
+ else {
1304
+ destroy_effect(effect);
1305
+ fulfil(void 0);
1306
+ }
1307
+ });
1308
+ };
1309
+ }
1310
+ function render_effect(fn, flags = 0) {
1311
+ return create_effect(RENDER_EFFECT | flags, fn, true);
1312
+ }
1313
+ function block(fn, flags = 0) {
1314
+ return create_effect(BLOCK_EFFECT | flags, fn, true);
1315
+ }
1316
+ function branch(fn) {
1317
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn, true);
1318
+ }
1319
+ function execute_effect_teardown(effect) {
1320
+ var teardown = effect.teardown;
1321
+ if (teardown !== null) {
1322
+ const previously_destroying_effect = is_destroying_effect;
1323
+ const previous_reaction = active_reaction;
1324
+ set_is_destroying_effect(true);
1325
+ set_active_reaction(null);
1326
+ try {
1327
+ teardown.call(null);
1328
+ } finally {
1329
+ set_is_destroying_effect(previously_destroying_effect);
1330
+ set_active_reaction(previous_reaction);
1331
+ }
1332
+ }
1333
+ }
1334
+ function destroy_effect_children(signal, remove_dom = false) {
1335
+ var effect = signal.first;
1336
+ signal.first = signal.last = null;
1337
+ while (effect !== null) {
1338
+ const controller2 = effect.ac;
1339
+ if (controller2 !== null) without_reactive_context(() => {
1340
+ controller2.abort(STALE_REACTION);
1341
+ });
1342
+ var next = effect.next;
1343
+ if ((effect.f & ROOT_EFFECT) !== 0) effect.parent = null;
1344
+ else destroy_effect(effect, remove_dom);
1345
+ effect = next;
1346
+ }
1347
+ }
1348
+ function destroy_block_effect_children(signal) {
1349
+ var effect = signal.first;
1350
+ while (effect !== null) {
1351
+ var next = effect.next;
1352
+ if ((effect.f & BRANCH_EFFECT) === 0) destroy_effect(effect);
1353
+ effect = next;
1354
+ }
1355
+ }
1356
+ function destroy_effect(effect, remove_dom = true) {
1357
+ var removed = false;
1358
+ if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
1359
+ remove_effect_dom(
1360
+ effect.nodes.start,
1361
+ /** @type {TemplateNode} */
1362
+ effect.nodes.end
1363
+ );
1364
+ removed = true;
1365
+ }
1366
+ destroy_effect_children(effect, remove_dom && !removed);
1367
+ remove_reactions(effect, 0);
1368
+ set_signal_status(effect, DESTROYED);
1369
+ var transitions = effect.nodes && effect.nodes.t;
1370
+ if (transitions !== null) for (const transition of transitions) transition.stop();
1371
+ execute_effect_teardown(effect);
1372
+ var parent = effect.parent;
1373
+ if (parent !== null && parent.first !== null) unlink_effect(effect);
1374
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = null;
1375
+ }
1376
+ function remove_effect_dom(node, end) {
1377
+ while (node !== null) {
1378
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1379
+ node.remove();
1380
+ node = next;
1381
+ }
1382
+ }
1383
+ function unlink_effect(effect) {
1384
+ var parent = effect.parent;
1385
+ var prev = effect.prev;
1386
+ var next = effect.next;
1387
+ if (prev !== null) prev.next = next;
1388
+ if (next !== null) next.prev = prev;
1389
+ if (parent !== null) {
1390
+ if (parent.first === effect) parent.first = next;
1391
+ if (parent.last === effect) parent.last = prev;
1392
+ }
1393
+ }
1394
+ function pause_effect(effect, callback, destroy = true) {
1395
+ var transitions = [];
1396
+ pause_children(effect, transitions, true);
1397
+ var fn = () => {
1398
+ if (destroy) destroy_effect(effect);
1399
+ if (callback) callback();
1400
+ };
1401
+ var remaining = transitions.length;
1402
+ if (remaining > 0) {
1403
+ var check = () => --remaining || fn();
1404
+ for (var transition of transitions) transition.out(check);
1405
+ } else fn();
1406
+ }
1407
+ function pause_children(effect, transitions, local) {
1408
+ if ((effect.f & INERT) !== 0) return;
1409
+ effect.f ^= INERT;
1410
+ var t = effect.nodes && effect.nodes.t;
1411
+ if (t !== null) {
1412
+ for (const transition of t) if (transition.is_global || local) transitions.push(transition);
1413
+ }
1414
+ var child = effect.first;
1415
+ while (child !== null) {
1416
+ var sibling = child.next;
1417
+ var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
1418
+ pause_children(child, transitions, transparent ? local : false);
1419
+ child = sibling;
1420
+ }
1421
+ }
1422
+ function move_effect(effect, fragment) {
1423
+ if (!effect.nodes) return;
1424
+ var node = effect.nodes.start;
1425
+ var end = effect.nodes.end;
1426
+ while (node !== null) {
1427
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1428
+ fragment.append(node);
1429
+ node = next;
1430
+ }
1431
+ }
1432
+ let is_updating_effect = false;
1433
+ let is_destroying_effect = false;
1434
+ function set_is_destroying_effect(value) {
1435
+ is_destroying_effect = value;
1436
+ }
1437
+ let active_reaction = null;
1438
+ let untracking = false;
1439
+ function set_active_reaction(reaction) {
1440
+ active_reaction = reaction;
1441
+ }
1442
+ let active_effect = null;
1443
+ function set_active_effect(effect) {
1444
+ active_effect = effect;
1445
+ }
1446
+ let current_sources = null;
1447
+ function push_reaction_value(value) {
1448
+ if (active_reaction !== null && true) if (current_sources === null) current_sources = [value];
1449
+ else current_sources.push(value);
1450
+ }
1451
+ let new_deps = null;
1452
+ let skipped_deps = 0;
1453
+ let untracked_writes = null;
1454
+ function set_untracked_writes(value) {
1455
+ untracked_writes = value;
1456
+ }
1457
+ let write_version = 1;
1458
+ let read_version = 0;
1459
+ let update_version = read_version;
1460
+ function set_update_version(value) {
1461
+ update_version = value;
1462
+ }
1463
+ function increment_write_version() {
1464
+ return ++write_version;
1465
+ }
1466
+ function is_dirty(reaction) {
1467
+ var flags = reaction.f;
1468
+ if ((flags & DIRTY) !== 0) return true;
1469
+ if (flags & DERIVED) reaction.f &= ~WAS_MARKED;
1470
+ if ((flags & MAYBE_DIRTY) !== 0) {
1471
+ var dependencies = reaction.deps;
1472
+ var length = dependencies.length;
1473
+ for (var i = 0; i < length; i++) {
1474
+ var dependency = dependencies[i];
1475
+ if (is_dirty(
1476
+ /** @type {Derived} */
1477
+ dependency
1478
+ )) update_derived(
1479
+ /** @type {Derived} */
1480
+ dependency
1481
+ );
1482
+ if (dependency.wv > reaction.wv) return true;
1483
+ }
1484
+ if ((flags & CONNECTED) !== 0 && batch_values === null) set_signal_status(reaction, CLEAN);
1485
+ }
1486
+ return false;
1487
+ }
1488
+ function schedule_possible_effect_self_invalidation(signal, effect, root = true) {
1489
+ var reactions = signal.reactions;
1490
+ if (reactions === null) return;
1491
+ if (current_sources !== null && includes.call(current_sources, signal)) return;
1492
+ for (var i = 0; i < reactions.length; i++) {
1493
+ var reaction = reactions[i];
1494
+ if ((reaction.f & DERIVED) !== 0) schedule_possible_effect_self_invalidation(
1495
+ /** @type {Derived} */
1496
+ reaction,
1497
+ effect,
1498
+ false
1499
+ );
1500
+ else if (effect === reaction) {
1501
+ if (root) set_signal_status(reaction, DIRTY);
1502
+ else if ((reaction.f & CLEAN) !== 0) set_signal_status(reaction, MAYBE_DIRTY);
1503
+ schedule_effect(
1504
+ /** @type {Effect} */
1505
+ reaction
1506
+ );
1507
+ }
1508
+ }
1509
+ }
1510
+ function update_reaction(reaction) {
1511
+ var previous_deps = new_deps;
1512
+ var previous_skipped_deps = skipped_deps;
1513
+ var previous_untracked_writes = untracked_writes;
1514
+ var previous_reaction = active_reaction;
1515
+ var previous_sources = current_sources;
1516
+ var previous_component_context = component_context;
1517
+ var previous_untracking = untracking;
1518
+ var previous_update_version = update_version;
1519
+ var flags = reaction.f;
1520
+ new_deps = null;
1521
+ skipped_deps = 0;
1522
+ untracked_writes = null;
1523
+ active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
1524
+ current_sources = null;
1525
+ set_component_context(reaction.ctx);
1526
+ untracking = false;
1527
+ update_version = ++read_version;
1528
+ if (reaction.ac !== null) {
1529
+ without_reactive_context(() => {
1530
+ reaction.ac.abort(STALE_REACTION);
1531
+ });
1532
+ reaction.ac = null;
1533
+ }
1534
+ try {
1535
+ reaction.f |= REACTION_IS_UPDATING;
1536
+ var fn = reaction.fn;
1537
+ var result = fn();
1538
+ var deps = reaction.deps;
1539
+ if (new_deps !== null) {
1540
+ var i;
1541
+ remove_reactions(reaction, skipped_deps);
1542
+ if (deps !== null && skipped_deps > 0) {
1543
+ deps.length = skipped_deps + new_deps.length;
1544
+ for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
1545
+ } else reaction.deps = deps = new_deps;
1546
+ if (effect_tracking() && (reaction.f & CONNECTED) !== 0) for (i = skipped_deps; i < deps.length; i++) (deps[i].reactions ??= []).push(reaction);
1547
+ } else if (deps !== null && skipped_deps < deps.length) {
1548
+ remove_reactions(reaction, skipped_deps);
1549
+ deps.length = skipped_deps;
1550
+ }
1551
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (MAYBE_DIRTY | 2050)) === 0) for (i = 0; i < untracked_writes.length; i++) schedule_possible_effect_self_invalidation(
1552
+ untracked_writes[i],
1553
+ /** @type {Effect} */
1554
+ reaction
1555
+ );
1556
+ if (previous_reaction !== null && previous_reaction !== reaction) {
1557
+ read_version++;
1558
+ if (previous_reaction.deps !== null) for (let i2 = 0; i2 < previous_skipped_deps; i2 += 1) previous_reaction.deps[i2].rv = read_version;
1559
+ if (previous_deps !== null) for (const dep of previous_deps) dep.rv = read_version;
1560
+ if (untracked_writes !== null) if (previous_untracked_writes === null) previous_untracked_writes = untracked_writes;
1561
+ else previous_untracked_writes.push(...untracked_writes);
1562
+ }
1563
+ if ((reaction.f & ERROR_VALUE) !== 0) reaction.f ^= ERROR_VALUE;
1564
+ return result;
1565
+ } catch (error) {
1566
+ return handle_error(error);
1567
+ } finally {
1568
+ reaction.f ^= REACTION_IS_UPDATING;
1569
+ new_deps = previous_deps;
1570
+ skipped_deps = previous_skipped_deps;
1571
+ untracked_writes = previous_untracked_writes;
1572
+ active_reaction = previous_reaction;
1573
+ current_sources = previous_sources;
1574
+ set_component_context(previous_component_context);
1575
+ untracking = previous_untracking;
1576
+ update_version = previous_update_version;
1577
+ }
1578
+ }
1579
+ function remove_reaction(signal, dependency) {
1580
+ let reactions = dependency.reactions;
1581
+ if (reactions !== null) {
1582
+ var index = index_of.call(reactions, signal);
1583
+ if (index !== -1) {
1584
+ var new_length = reactions.length - 1;
1585
+ if (new_length === 0) reactions = dependency.reactions = null;
1586
+ else {
1587
+ reactions[index] = reactions[new_length];
1588
+ reactions.pop();
1589
+ }
1590
+ }
1591
+ }
1592
+ if (reactions === null && (dependency.f & DERIVED) !== 0 && (new_deps === null || !includes.call(new_deps, dependency))) {
1593
+ var derived2 = dependency;
1594
+ if ((derived2.f & CONNECTED) !== 0) {
1595
+ derived2.f ^= CONNECTED;
1596
+ derived2.f &= ~WAS_MARKED;
1597
+ }
1598
+ update_derived_status(derived2);
1599
+ destroy_derived_effects(derived2);
1600
+ remove_reactions(derived2, 0);
1601
+ }
1602
+ }
1603
+ function remove_reactions(signal, start_index) {
1604
+ var dependencies = signal.deps;
1605
+ if (dependencies === null) return;
1606
+ for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
1607
+ }
1608
+ function update_effect(effect) {
1609
+ var flags = effect.f;
1610
+ if ((flags & DESTROYED) !== 0) return;
1611
+ set_signal_status(effect, CLEAN);
1612
+ var previous_effect = active_effect;
1613
+ var was_updating_effect = is_updating_effect;
1614
+ active_effect = effect;
1615
+ is_updating_effect = true;
1616
+ try {
1617
+ if ((flags & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) destroy_block_effect_children(effect);
1618
+ else destroy_effect_children(effect);
1619
+ execute_effect_teardown(effect);
1620
+ var teardown = update_reaction(effect);
1621
+ effect.teardown = typeof teardown === "function" ? teardown : null;
1622
+ effect.wv = write_version;
1623
+ } finally {
1624
+ is_updating_effect = was_updating_effect;
1625
+ active_effect = previous_effect;
1626
+ }
1627
+ }
1628
+ function get(signal) {
1629
+ var is_derived = (signal.f & DERIVED) !== 0;
1630
+ if (active_reaction !== null && !untracking) {
1631
+ if (!(active_effect !== null && (active_effect.f & DESTROYED) !== 0) && (current_sources === null || !includes.call(current_sources, signal))) {
1632
+ var deps = active_reaction.deps;
1633
+ if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
1634
+ if (signal.rv < read_version) {
1635
+ signal.rv = read_version;
1636
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
1637
+ else if (new_deps === null) new_deps = [signal];
1638
+ else new_deps.push(signal);
1639
+ }
1640
+ } else {
1641
+ (active_reaction.deps ??= []).push(signal);
1642
+ var reactions = signal.reactions;
1643
+ if (reactions === null) signal.reactions = [active_reaction];
1644
+ else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
1645
+ }
1646
+ }
1647
+ }
1648
+ if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
1649
+ if (is_derived) {
1650
+ var derived2 = signal;
1651
+ if (is_destroying_effect) {
1652
+ var value = derived2.v;
1653
+ if ((derived2.f & CLEAN) === 0 && derived2.reactions !== null || depends_on_old_values(derived2)) value = execute_derived(derived2);
1654
+ old_values.set(derived2, value);
1655
+ return value;
1656
+ }
1657
+ var should_connect = (derived2.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0);
1658
+ var is_new = derived2.deps === null;
1659
+ if (is_dirty(derived2)) {
1660
+ if (should_connect) derived2.f |= CONNECTED;
1661
+ update_derived(derived2);
1662
+ }
1663
+ if (should_connect && !is_new) reconnect(derived2);
1664
+ }
1665
+ if (batch_values?.has(signal)) return batch_values.get(signal);
1666
+ if ((signal.f & ERROR_VALUE) !== 0) throw signal.v;
1667
+ return signal.v;
1668
+ }
1669
+ function reconnect(derived2) {
1670
+ if (derived2.deps === null) return;
1671
+ derived2.f |= CONNECTED;
1672
+ for (const dep of derived2.deps) {
1673
+ (dep.reactions ??= []).push(derived2);
1674
+ if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) reconnect(
1675
+ /** @type {Derived} */
1676
+ dep
1677
+ );
1678
+ }
1679
+ }
1680
+ function depends_on_old_values(derived2) {
1681
+ if (derived2.v === UNINITIALIZED) return true;
1682
+ if (derived2.deps === null) return false;
1683
+ for (const dep of derived2.deps) {
1684
+ if (old_values.has(dep)) return true;
1685
+ if ((dep.f & DERIVED) !== 0 && depends_on_old_values(
1686
+ /** @type {Derived} */
1687
+ dep
1688
+ )) return true;
1689
+ }
1690
+ return false;
1691
+ }
1692
+ function untrack(fn) {
1693
+ var previous_untracking = untracking;
1694
+ try {
1695
+ untracking = true;
1696
+ return fn();
1697
+ } finally {
1698
+ untracking = previous_untracking;
1699
+ }
1700
+ }
1701
+ const VOID_ELEMENT_NAMES = [
1702
+ "area",
1703
+ "base",
1704
+ "br",
1705
+ "col",
1706
+ "command",
1707
+ "embed",
1708
+ "hr",
1709
+ "img",
1710
+ "input",
1711
+ "keygen",
1712
+ "link",
1713
+ "meta",
1714
+ "param",
1715
+ "source",
1716
+ "track",
1717
+ "wbr"
1718
+ ];
1719
+ function is_void(name) {
1720
+ return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === "!doctype";
1721
+ }
1722
+ const DOM_BOOLEAN_ATTRIBUTES = [
1723
+ "allowfullscreen",
1724
+ "async",
1725
+ "autofocus",
1726
+ "autoplay",
1727
+ "checked",
1728
+ "controls",
1729
+ "default",
1730
+ "disabled",
1731
+ "formnovalidate",
1732
+ "indeterminate",
1733
+ "inert",
1734
+ "ismap",
1735
+ "loop",
1736
+ "multiple",
1737
+ "muted",
1738
+ "nomodule",
1739
+ "novalidate",
1740
+ "open",
1741
+ "playsinline",
1742
+ "readonly",
1743
+ "required",
1744
+ "reversed",
1745
+ "seamless",
1746
+ "selected",
1747
+ "webkitdirectory",
1748
+ "defer",
1749
+ "disablepictureinpicture",
1750
+ "disableremoteplayback"
1751
+ ];
1752
+ function is_boolean_attribute(name) {
1753
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
1754
+ }
1755
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
1756
+ function is_passive_event(name) {
1757
+ return PASSIVE_EVENTS.includes(name);
1758
+ }
1759
+ const RAW_TEXT_ELEMENTS = [
1760
+ "textarea",
1761
+ "script",
1762
+ "style",
1763
+ "title"
1764
+ ];
1765
+ function is_raw_text_element(name) {
1766
+ return RAW_TEXT_ELEMENTS.includes(
1767
+ /** @type {typeof RAW_TEXT_ELEMENTS[number]} */
1768
+ name
1769
+ );
1770
+ }
1771
+ const replacements = { translate: /* @__PURE__ */ new Map([[true, "yes"], [false, "no"]]) };
1772
+ function attr(name, value, is_boolean = false) {
1773
+ if (name === "hidden" && value !== "until-found") is_boolean = true;
1774
+ if (value == null || !value && is_boolean) return "";
1775
+ const normalized = name in replacements && replacements[name].get(value) || value;
1776
+ return ` ${name}${is_boolean ? "" : `="${escape_html(normalized, true)}"`}`;
1777
+ }
1778
+ function clsx(value) {
1779
+ if (typeof value === "object") return clsx$1(value);
1780
+ else return value ?? "";
1781
+ }
1782
+ const whitespace = [..." \n\r\f\xA0\v"];
1783
+ function to_class(value, hash, directives) {
1784
+ var classname = value == null ? "" : "" + value;
1785
+ if (hash) classname = classname ? classname + " " + hash : hash;
1786
+ if (directives) {
1787
+ for (var key in directives) if (directives[key]) classname = classname ? classname + " " + key : key;
1788
+ else if (classname.length) {
1789
+ var len = key.length;
1790
+ var a = 0;
1791
+ while ((a = classname.indexOf(key, a)) >= 0) {
1792
+ var b = a + len;
1793
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
1794
+ else a = b;
1795
+ }
1796
+ }
1797
+ }
1798
+ return classname === "" ? null : classname;
1799
+ }
1800
+ function append_styles(styles, important = false) {
1801
+ var separator = important ? " !important;" : ";";
1802
+ var css = "";
1803
+ for (var key in styles) {
1804
+ var value = styles[key];
1805
+ if (value != null && value !== "") css += " " + key + ": " + value + separator;
1806
+ }
1807
+ return css;
1808
+ }
1809
+ function to_css_name(name) {
1810
+ if (name[0] !== "-" || name[1] !== "-") return name.toLowerCase();
1811
+ return name;
1812
+ }
1813
+ function to_style(value, styles) {
1814
+ if (styles) {
1815
+ var new_style = "";
1816
+ var normal_styles;
1817
+ var important_styles;
1818
+ if (Array.isArray(styles)) {
1819
+ normal_styles = styles[0];
1820
+ important_styles = styles[1];
1821
+ } else normal_styles = styles;
1822
+ if (value) {
1823
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
1824
+ var in_str = false;
1825
+ var in_apo = 0;
1826
+ var in_comment = false;
1827
+ var reserved_names = [];
1828
+ if (normal_styles) reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
1829
+ if (important_styles) reserved_names.push(...Object.keys(important_styles).map(to_css_name));
1830
+ var start_index = 0;
1831
+ var name_index = -1;
1832
+ const len = value.length;
1833
+ for (var i = 0; i < len; i++) {
1834
+ var c = value[i];
1835
+ if (in_comment) {
1836
+ if (c === "/" && value[i - 1] === "*") in_comment = false;
1837
+ } else if (in_str) {
1838
+ if (in_str === c) in_str = false;
1839
+ } else if (c === "/" && value[i + 1] === "*") in_comment = true;
1840
+ else if (c === "\"" || c === "'") in_str = c;
1841
+ else if (c === "(") in_apo++;
1842
+ else if (c === ")") in_apo--;
1843
+ if (!in_comment && in_str === false && in_apo === 0) {
1844
+ if (c === ":" && name_index === -1) name_index = i;
1845
+ else if (c === ";" || i === len - 1) {
1846
+ if (name_index !== -1) {
1847
+ var name = to_css_name(value.substring(start_index, name_index).trim());
1848
+ if (!reserved_names.includes(name)) {
1849
+ if (c !== ";") i++;
1850
+ var property = value.substring(start_index, i).trim();
1851
+ new_style += " " + property + ";";
1852
+ }
1853
+ }
1854
+ start_index = i + 1;
1855
+ name_index = -1;
1856
+ }
1857
+ }
1858
+ }
1859
+ }
1860
+ if (normal_styles) new_style += append_styles(normal_styles);
1861
+ if (important_styles) new_style += append_styles(important_styles, true);
1862
+ new_style = new_style.trim();
1863
+ return new_style === "" ? null : new_style;
1864
+ }
1865
+ return value == null ? null : String(value);
1866
+ }
1867
+ function subscribe_to_store(store, run, invalidate) {
1868
+ if (store == null) {
1869
+ run(void 0);
1870
+ return noop;
1871
+ }
1872
+ const unsub = untrack(() => store.subscribe(run, invalidate));
1873
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
1874
+ }
1875
+ const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
1876
+ const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
1877
+ const EMPTY_COMMENT = `<!---->`;
1878
+ let controller = null;
1879
+ function abort() {
1880
+ controller?.abort(STALE_REACTION);
1881
+ controller = null;
1882
+ }
1883
+ function await_invalid() {
1884
+ const error = /* @__PURE__ */ new Error(`await_invalid
1885
+ Encountered asynchronous work while rendering synchronously.
1886
+ https://svelte.dev/e/await_invalid`);
1887
+ error.name = "Svelte error";
1888
+ throw error;
1889
+ }
1890
+ function invalid_csp() {
1891
+ const error = /* @__PURE__ */ new Error(`invalid_csp
1892
+ \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
1893
+ https://svelte.dev/e/invalid_csp`);
1894
+ error.name = "Svelte error";
1895
+ throw error;
1896
+ }
1897
+ function lifecycle_function_unavailable(name) {
1898
+ const error = /* @__PURE__ */ new Error(`lifecycle_function_unavailable
1899
+ \`${name}(...)\` is not available on the server
1900
+ https://svelte.dev/e/lifecycle_function_unavailable`);
1901
+ error.name = "Svelte error";
1902
+ throw error;
1903
+ }
1904
+ function server_context_required() {
1905
+ const error = /* @__PURE__ */ new Error(`server_context_required
1906
+ Could not resolve \`render\` context.
1907
+ https://svelte.dev/e/server_context_required`);
1908
+ error.name = "Svelte error";
1909
+ throw error;
1910
+ }
1911
+ function unresolved_hydratable(key, stack) {
1912
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
1913
+ }
1914
+ function get_render_context() {
1915
+ const store = als?.getStore();
1916
+ server_context_required();
1917
+ return store;
1918
+ }
1919
+ let als = null;
1920
+ let text_encoder;
1921
+ let crypto;
1922
+ async function sha256(data) {
1923
+ text_encoder ??= new TextEncoder();
1924
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (await import("node:crypto")).webcrypto;
1925
+ return base64_encode(await crypto.subtle.digest("SHA-256", text_encoder.encode(data)));
1926
+ }
1927
+ function base64_encode(bytes) {
1928
+ if (globalThis.Buffer) return globalThis.Buffer.from(bytes).toString("base64");
1929
+ let binary = "";
1930
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
1931
+ return btoa(binary);
1932
+ }
1933
+ var Renderer = class Renderer {
1934
+ /**
1935
+ * The contents of the renderer.
1936
+ * @type {RendererItem[]}
1937
+ */
1938
+ #out = [];
1939
+ /**
1940
+ * Any `onDestroy` callbacks registered during execution of this renderer.
1941
+ * @type {(() => void)[] | undefined}
1942
+ */
1943
+ #on_destroy = void 0;
1944
+ /**
1945
+ * Whether this renderer is a component body.
1946
+ * @type {boolean}
1947
+ */
1948
+ #is_component_body = false;
1949
+ /**
1950
+ * The type of string content that this renderer is accumulating.
1951
+ * @type {RendererType}
1952
+ */
1953
+ type;
1954
+ /** @type {Renderer | undefined} */
1955
+ #parent;
1956
+ /**
1957
+ * Asynchronous work associated with this renderer
1958
+ * @type {Promise<void> | undefined}
1959
+ */
1960
+ promise = void 0;
1961
+ /**
1962
+ * State which is associated with the content tree as a whole.
1963
+ * It will be re-exposed, uncopied, on all children.
1964
+ * @type {SSRState}
1965
+ * @readonly
1966
+ */
1967
+ global;
1968
+ /**
1969
+ * State that is local to the branch it is declared in.
1970
+ * It will be shallow-copied to all children.
1971
+ *
1972
+ * @type {{ select_value: string | undefined }}
1973
+ */
1974
+ local;
1975
+ /**
1976
+ * @param {SSRState} global
1977
+ * @param {Renderer | undefined} [parent]
1978
+ */
1979
+ constructor(global, parent) {
1980
+ this.#parent = parent;
1981
+ this.global = global;
1982
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
1983
+ this.type = parent ? parent.type : "body";
1984
+ }
1985
+ /**
1986
+ * @param {(renderer: Renderer) => void} fn
1987
+ */
1988
+ head(fn) {
1989
+ const head2 = new Renderer(this.global, this);
1990
+ head2.type = "head";
1991
+ this.#out.push(head2);
1992
+ head2.child(fn);
1993
+ }
1994
+ /**
1995
+ * @param {Array<Promise<void>>} blockers
1996
+ * @param {(renderer: Renderer) => void} fn
1997
+ */
1998
+ async_block(blockers, fn) {
1999
+ this.#out.push(BLOCK_OPEN);
2000
+ this.async(blockers, fn);
2001
+ this.#out.push(BLOCK_CLOSE);
2002
+ }
2003
+ /**
2004
+ * @param {Array<Promise<void>>} blockers
2005
+ * @param {(renderer: Renderer) => void} fn
2006
+ */
2007
+ async(blockers, fn) {
2008
+ let callback = fn;
2009
+ if (blockers.length > 0) {
2010
+ const context = ssr_context;
2011
+ callback = (renderer) => {
2012
+ return Promise.all(blockers).then(() => {
2013
+ const previous_context = ssr_context;
2014
+ try {
2015
+ set_ssr_context(context);
2016
+ return fn(renderer);
2017
+ } finally {
2018
+ set_ssr_context(previous_context);
2019
+ }
2020
+ });
2021
+ };
2022
+ }
2023
+ this.child(callback);
2024
+ }
2025
+ /**
2026
+ * @param {Array<() => void>} thunks
2027
+ */
2028
+ run(thunks) {
2029
+ const context = ssr_context;
2030
+ let promise = Promise.resolve(thunks[0]());
2031
+ const promises = [promise];
2032
+ for (const fn of thunks.slice(1)) {
2033
+ promise = promise.then(() => {
2034
+ const previous_context = ssr_context;
2035
+ set_ssr_context(context);
2036
+ try {
2037
+ return fn();
2038
+ } finally {
2039
+ set_ssr_context(previous_context);
2040
+ }
2041
+ });
2042
+ promises.push(promise);
2043
+ }
2044
+ return promises;
2045
+ }
2046
+ /**
2047
+ * Create a child renderer. The child renderer inherits the state from the parent,
2048
+ * but has its own content.
2049
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
2050
+ */
2051
+ child(fn) {
2052
+ const child = new Renderer(this.global, this);
2053
+ this.#out.push(child);
2054
+ const parent = ssr_context;
2055
+ set_ssr_context({
2056
+ ...ssr_context,
2057
+ p: parent,
2058
+ c: null,
2059
+ r: child
2060
+ });
2061
+ const result = fn(child);
2062
+ set_ssr_context(parent);
2063
+ if (result instanceof Promise) {
2064
+ if (child.global.mode === "sync") await_invalid();
2065
+ result.catch(() => {});
2066
+ child.promise = result;
2067
+ }
2068
+ return child;
2069
+ }
2070
+ /**
2071
+ * Create a component renderer. The component renderer inherits the state from the parent,
2072
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
2073
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
2074
+ * @param {Function} [component_fn]
2075
+ * @returns {void}
2076
+ */
2077
+ component(fn, component_fn) {
2078
+ push$1();
2079
+ const child = this.child(fn);
2080
+ child.#is_component_body = true;
2081
+ pop$1();
2082
+ }
2083
+ /**
2084
+ * @param {Record<string, any>} attrs
2085
+ * @param {(renderer: Renderer) => void} fn
2086
+ * @param {string | undefined} [css_hash]
2087
+ * @param {Record<string, boolean> | undefined} [classes]
2088
+ * @param {Record<string, string> | undefined} [styles]
2089
+ * @param {number | undefined} [flags]
2090
+ * @param {boolean | undefined} [is_rich]
2091
+ * @returns {void}
2092
+ */
2093
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
2094
+ const { value, ...select_attrs } = attrs;
2095
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
2096
+ this.child((renderer) => {
2097
+ renderer.local.select_value = value;
2098
+ fn(renderer);
2099
+ });
2100
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
2101
+ }
2102
+ /**
2103
+ * @param {Record<string, any>} attrs
2104
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
2105
+ * @param {string | undefined} [css_hash]
2106
+ * @param {Record<string, boolean> | undefined} [classes]
2107
+ * @param {Record<string, string> | undefined} [styles]
2108
+ * @param {number | undefined} [flags]
2109
+ * @param {boolean | undefined} [is_rich]
2110
+ */
2111
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
2112
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
2113
+ const close = (renderer, value, { head: head2, body: body2 }) => {
2114
+ if ("value" in attrs) value = attrs.value;
2115
+ if (value === this.local.select_value) renderer.#out.push(" selected");
2116
+ renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
2117
+ if (head2) renderer.head((child) => child.push(head2));
2118
+ };
2119
+ if (typeof body === "function") this.child((renderer) => {
2120
+ const r = new Renderer(this.global, this);
2121
+ body(r);
2122
+ if (this.global.mode === "async") return r.#collect_content_async().then((content) => {
2123
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
2124
+ });
2125
+ else {
2126
+ const content = r.#collect_content();
2127
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
2128
+ }
2129
+ });
2130
+ else close(this, body, { body });
2131
+ }
2132
+ /**
2133
+ * @param {(renderer: Renderer) => void} fn
2134
+ */
2135
+ title(fn) {
2136
+ const path = this.get_path();
2137
+ const close = (head2) => {
2138
+ this.global.set_title(head2, path);
2139
+ };
2140
+ this.child((renderer) => {
2141
+ const r = new Renderer(renderer.global, renderer);
2142
+ fn(r);
2143
+ if (renderer.global.mode === "async") return r.#collect_content_async().then((content) => {
2144
+ close(content.head);
2145
+ });
2146
+ else close(r.#collect_content().head);
2147
+ });
2148
+ }
2149
+ /**
2150
+ * @param {string | (() => Promise<string>)} content
2151
+ */
2152
+ push(content) {
2153
+ if (typeof content === "function") this.child(async (renderer) => renderer.push(await content()));
2154
+ else this.#out.push(content);
2155
+ }
2156
+ /**
2157
+ * @param {() => void} fn
2158
+ */
2159
+ on_destroy(fn) {
2160
+ (this.#on_destroy ??= []).push(fn);
2161
+ }
2162
+ /**
2163
+ * @returns {number[]}
2164
+ */
2165
+ get_path() {
2166
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
2167
+ }
2168
+ /**
2169
+ * @deprecated this is needed for legacy component bindings
2170
+ */
2171
+ copy() {
2172
+ const copy = new Renderer(this.global, this.#parent);
2173
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
2174
+ copy.promise = this.promise;
2175
+ return copy;
2176
+ }
2177
+ /**
2178
+ * @param {Renderer} other
2179
+ * @deprecated this is needed for legacy component bindings
2180
+ */
2181
+ subsume(other) {
2182
+ if (this.global.mode !== other.global.mode) throw new Error("invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!");
2183
+ this.local = other.local;
2184
+ this.#out = other.#out.map((item) => {
2185
+ if (item instanceof Renderer) item.subsume(item);
2186
+ return item;
2187
+ });
2188
+ this.promise = other.promise;
2189
+ this.type = other.type;
2190
+ }
2191
+ get length() {
2192
+ return this.#out.length;
2193
+ }
2194
+ /**
2195
+ * Only available on the server and when compiling with the `server` option.
2196
+ * 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.
2197
+ * @template {Record<string, any>} Props
2198
+ * @param {Component<Props>} component
2199
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
2200
+ * @returns {RenderOutput}
2201
+ */
2202
+ static render(component, options = {}) {
2203
+ let sync;
2204
+ const result = (
2205
+ /** @type {RenderOutput} */
2206
+ {});
2207
+ Object.defineProperties(result, {
2208
+ html: { get: () => {
2209
+ return (sync ??= Renderer.#render(component, options)).body;
2210
+ } },
2211
+ head: { get: () => {
2212
+ return (sync ??= Renderer.#render(component, options)).head;
2213
+ } },
2214
+ body: { get: () => {
2215
+ return (sync ??= Renderer.#render(component, options)).body;
2216
+ } },
2217
+ hashes: { value: { script: "" } },
2218
+ then: { value: ((onfulfilled, onrejected) => {
2219
+ {
2220
+ const result2 = sync ??= Renderer.#render(component, options);
2221
+ const user_result = onfulfilled({
2222
+ head: result2.head,
2223
+ body: result2.body,
2224
+ html: result2.body,
2225
+ hashes: { script: [] }
2226
+ });
2227
+ return Promise.resolve(user_result);
2228
+ }
2229
+ }) }
2230
+ });
2231
+ return result;
2232
+ }
2233
+ /**
2234
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
2235
+ * after awaiting `collect_async`.
2236
+ *
2237
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
2238
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
2239
+ * @returns {Iterable<() => void>}
2240
+ */
2241
+ *#collect_on_destroy() {
2242
+ for (const component of this.#traverse_components()) yield* component.#collect_ondestroy();
2243
+ }
2244
+ /**
2245
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
2246
+ * @returns {Iterable<Renderer>}
2247
+ */
2248
+ *#traverse_components() {
2249
+ for (const child of this.#out) if (typeof child !== "string") yield* child.#traverse_components();
2250
+ if (this.#is_component_body) yield this;
2251
+ }
2252
+ /**
2253
+ * @returns {Iterable<() => void>}
2254
+ */
2255
+ *#collect_ondestroy() {
2256
+ if (this.#on_destroy) for (const fn of this.#on_destroy) yield fn;
2257
+ for (const child of this.#out) if (child instanceof Renderer && !child.#is_component_body) yield* child.#collect_ondestroy();
2258
+ }
2259
+ /**
2260
+ * Render a component. Throws if any of the children are performing asynchronous work.
2261
+ *
2262
+ * @template {Record<string, any>} Props
2263
+ * @param {Component<Props>} component
2264
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
2265
+ * @returns {AccumulatedContent}
2266
+ */
2267
+ static #render(component, options) {
2268
+ var previous_context = ssr_context;
2269
+ try {
2270
+ const renderer = Renderer.#open_render("sync", component, options);
2271
+ const content = renderer.#collect_content();
2272
+ return Renderer.#close_render(content, renderer);
2273
+ } finally {
2274
+ abort();
2275
+ set_ssr_context(previous_context);
2276
+ }
2277
+ }
2278
+ /**
2279
+ * Render a component.
2280
+ *
2281
+ * @template {Record<string, any>} Props
2282
+ * @param {Component<Props>} component
2283
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
2284
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
2285
+ */
2286
+ static async #render_async(component, options) {
2287
+ const previous_context = ssr_context;
2288
+ try {
2289
+ const renderer = Renderer.#open_render("async", component, options);
2290
+ const content = await renderer.#collect_content_async();
2291
+ const hydratables = await renderer.#collect_hydratables();
2292
+ if (hydratables !== null) content.head = hydratables + content.head;
2293
+ return Renderer.#close_render(content, renderer);
2294
+ } finally {
2295
+ set_ssr_context(previous_context);
2296
+ abort();
2297
+ }
2298
+ }
2299
+ /**
2300
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
2301
+ * @param {AccumulatedContent} content
2302
+ * @returns {AccumulatedContent}
2303
+ */
2304
+ #collect_content(content = {
2305
+ head: "",
2306
+ body: ""
2307
+ }) {
2308
+ for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
2309
+ else if (item instanceof Renderer) item.#collect_content(content);
2310
+ return content;
2311
+ }
2312
+ /**
2313
+ * Collect all of the code from the `out` array and return it as a string.
2314
+ * @param {AccumulatedContent} content
2315
+ * @returns {Promise<AccumulatedContent>}
2316
+ */
2317
+ async #collect_content_async(content = {
2318
+ head: "",
2319
+ body: ""
2320
+ }) {
2321
+ await this.promise;
2322
+ for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
2323
+ else if (item instanceof Renderer) await item.#collect_content_async(content);
2324
+ return content;
2325
+ }
2326
+ async #collect_hydratables() {
2327
+ const ctx = get_render_context().hydratable;
2328
+ for (const [_, key] of ctx.unresolved_promises) unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
2329
+ for (const comparison of ctx.comparisons) await comparison;
2330
+ return await this.#hydratable_block(ctx);
2331
+ }
2332
+ /**
2333
+ * @template {Record<string, any>} Props
2334
+ * @param {'sync' | 'async'} mode
2335
+ * @param {import('svelte').Component<Props>} component
2336
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
2337
+ * @returns {Renderer}
2338
+ */
2339
+ static #open_render(mode, component, options) {
2340
+ const renderer = new Renderer(new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp));
2341
+ renderer.push(BLOCK_OPEN);
2342
+ if (options.context) {
2343
+ push$1();
2344
+ ssr_context.c = options.context;
2345
+ ssr_context.r = renderer;
2346
+ }
2347
+ component(renderer, options.props ?? {});
2348
+ if (options.context) pop$1();
2349
+ renderer.push(BLOCK_CLOSE);
2350
+ return renderer;
2351
+ }
2352
+ /**
2353
+ * @param {AccumulatedContent} content
2354
+ * @param {Renderer} renderer
2355
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
2356
+ */
2357
+ static #close_render(content, renderer) {
2358
+ for (const cleanup of renderer.#collect_on_destroy()) cleanup();
2359
+ let head2 = content.head + renderer.global.get_title();
2360
+ let body = content.body;
2361
+ for (const { hash, code } of renderer.global.css) head2 += `<style id="${hash}">${code}</style>`;
2362
+ return {
2363
+ head: head2,
2364
+ body,
2365
+ hashes: { script: renderer.global.csp.script_hashes }
2366
+ };
2367
+ }
2368
+ /**
2369
+ * @param {HydratableContext} ctx
2370
+ */
2371
+ async #hydratable_block(ctx) {
2372
+ if (ctx.lookup.size === 0) return null;
2373
+ let entries = [];
2374
+ let has_promises = false;
2375
+ for (const [k, v] of ctx.lookup) {
2376
+ if (v.promises) {
2377
+ has_promises = true;
2378
+ for (const p of v.promises) await p;
2379
+ }
2380
+ entries.push(`[${uneval(k)},${v.serialized}]`);
2381
+ }
2382
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
2383
+ if (has_promises) prelude = `const r = (v) => Promise.resolve(v);
2384
+ ${prelude}`;
2385
+ const body = `
2386
+ {
2387
+ ${prelude}
2388
+
2389
+ for (const [k, v] of [
2390
+ ${entries.join(",\n ")}
2391
+ ]) {
2392
+ h.set(k, v);
2393
+ }
2394
+ }
2395
+ `;
2396
+ let csp_attr = "";
2397
+ if (this.global.csp.nonce) csp_attr = ` nonce="${this.global.csp.nonce}"`;
2398
+ else if (this.global.csp.hash) {
2399
+ const hash = await sha256(body);
2400
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
2401
+ }
2402
+ return `
2403
+ <script${csp_attr}>${body}<\/script>`;
2404
+ }
2405
+ };
2406
+ var SSRState = class {
2407
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
2408
+ csp;
2409
+ /** @readonly @type {'sync' | 'async'} */
2410
+ mode;
2411
+ /** @readonly @type {() => string} */
2412
+ uid;
2413
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
2414
+ css = /* @__PURE__ */ new Set();
2415
+ /** @type {{ path: number[], value: string }} */
2416
+ #title = {
2417
+ path: [],
2418
+ value: ""
2419
+ };
2420
+ /**
2421
+ * @param {'sync' | 'async'} mode
2422
+ * @param {string} id_prefix
2423
+ * @param {Csp} csp
2424
+ */
2425
+ constructor(mode, id_prefix = "", csp = { hash: false }) {
2426
+ this.mode = mode;
2427
+ this.csp = {
2428
+ ...csp,
2429
+ script_hashes: []
2430
+ };
2431
+ let uid = 1;
2432
+ this.uid = () => `${id_prefix}s${uid++}`;
2433
+ }
2434
+ get_title() {
2435
+ return this.#title.value;
2436
+ }
2437
+ /**
2438
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
2439
+ * from earlier than or equal to the current value.
2440
+ * @param {string} value
2441
+ * @param {number[]} path
2442
+ */
2443
+ set_title(value, path) {
2444
+ const current = this.#title.path;
2445
+ let i = 0;
2446
+ let l = Math.min(path.length, current.length);
2447
+ while (i < l && path[i] === current[i]) i += 1;
2448
+ if (path[i] === void 0) return;
2449
+ if (current[i] === void 0 || path[i] > current[i]) {
2450
+ this.#title.path = path;
2451
+ this.#title.value = value;
2452
+ }
2453
+ }
2454
+ };
2455
+ 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;
2456
+ function element(renderer, tag, attributes_fn = noop, children_fn = noop) {
2457
+ renderer.push("<!---->");
2458
+ if (tag) {
2459
+ renderer.push(`<${tag}`);
2460
+ attributes_fn();
2461
+ renderer.push(`>`);
2462
+ if (!is_void(tag)) {
2463
+ children_fn();
2464
+ if (!is_raw_text_element(tag)) renderer.push(EMPTY_COMMENT);
2465
+ renderer.push(`</${tag}>`);
2466
+ }
2467
+ }
2468
+ renderer.push("<!---->");
2469
+ }
2470
+ function render(component, options = {}) {
2471
+ if (options.csp?.hash && options.csp.nonce) invalid_csp();
2472
+ return Renderer.render(
2473
+ /** @type {Component<Props>} */
2474
+ component,
2475
+ options
2476
+ );
2477
+ }
2478
+ function head(hash, renderer, fn) {
2479
+ renderer.head((renderer2) => {
2480
+ renderer2.push(`<!--${hash}-->`);
2481
+ renderer2.child(fn);
2482
+ renderer2.push(EMPTY_COMMENT);
2483
+ });
2484
+ }
2485
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
2486
+ if (styles) attrs.style = to_style(attrs.style, styles);
2487
+ if (attrs.class) attrs.class = clsx(attrs.class);
2488
+ if (css_hash || classes) attrs.class = to_class(attrs.class, css_hash, classes);
2489
+ let attr_str = "";
2490
+ let name;
2491
+ const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
2492
+ const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
2493
+ const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
2494
+ for (name in attrs) {
2495
+ if (typeof attrs[name] === "function") continue;
2496
+ if (name[0] === "$" && name[1] === "$") continue;
2497
+ if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
2498
+ var value = attrs[name];
2499
+ if (lowercase) name = name.toLowerCase();
2500
+ if (is_input) {
2501
+ if (name === "defaultvalue" || name === "defaultchecked") {
2502
+ name = name === "defaultvalue" ? "value" : "checked";
2503
+ if (attrs[name]) continue;
2504
+ }
2505
+ }
2506
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
2507
+ }
2508
+ return attr_str;
2509
+ }
2510
+ function spread_props(props) {
2511
+ const merged_props = {};
2512
+ let key;
2513
+ for (let i = 0; i < props.length; i++) {
2514
+ const obj = props[i];
2515
+ for (key in obj) {
2516
+ const desc = Object.getOwnPropertyDescriptor(obj, key);
2517
+ if (desc) Object.defineProperty(merged_props, key, desc);
2518
+ else merged_props[key] = obj[key];
2519
+ }
2520
+ }
2521
+ return merged_props;
2522
+ }
2523
+ function stringify(value) {
2524
+ return typeof value === "string" ? value : value == null ? "" : value + "";
2525
+ }
2526
+ function attr_class(value, hash, directives) {
2527
+ var result = to_class(value, hash, directives);
2528
+ return result ? ` class="${escape_html(result, true)}"` : "";
2529
+ }
2530
+ function attr_style(value, directives) {
2531
+ var result = to_style(value, directives);
2532
+ return result ? ` style="${escape_html(result, true)}"` : "";
2533
+ }
2534
+ function store_get(store_values, store_name, store) {
2535
+ if (store_name in store_values && store_values[store_name][0] === store) return store_values[store_name][2];
2536
+ store_values[store_name]?.[1]();
2537
+ store_values[store_name] = [
2538
+ store,
2539
+ null,
2540
+ void 0
2541
+ ];
2542
+ const unsub = subscribe_to_store(
2543
+ store,
2544
+ /** @param {any} v */
2545
+ (v) => store_values[store_name][2] = v
2546
+ );
2547
+ store_values[store_name][1] = unsub;
2548
+ return store_values[store_name][2];
2549
+ }
2550
+ function unsubscribe_stores(store_values) {
2551
+ for (const store_name in store_values) store_values[store_name][1]();
2552
+ }
2553
+ function bind_props(props_parent, props_now) {
2554
+ for (const key in props_now) {
2555
+ const initial_value = props_parent[key];
2556
+ const value = props_now[key];
2557
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) props_parent[key] = value;
2558
+ }
2559
+ }
2560
+ function ensure_array_like(array_like_or_iterator) {
2561
+ if (array_like_or_iterator) return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
2562
+ return [];
2563
+ }
2564
+ function once(get_value) {
2565
+ let value = UNINITIALIZED;
2566
+ return () => {
2567
+ if (value === UNINITIALIZED) value = get_value();
2568
+ return value;
2569
+ };
2570
+ }
2571
+ function props_id(renderer) {
2572
+ const uid = renderer.global.uid();
2573
+ renderer.push("<!--$" + uid + "-->");
2574
+ return uid;
2575
+ }
2576
+ function derived(fn) {
2577
+ const get_value = once(fn);
2578
+ let updated_value;
2579
+ return function(new_value) {
2580
+ if (arguments.length === 0) return updated_value ?? get_value();
2581
+ updated_value = new_value;
2582
+ return updated_value;
2583
+ };
2584
+ }
2585
+
2586
+ //#endregion
2587
+ export { queue_micro_task as $, destroy_effect as A, hydration_failed as B, clear_text_content as C, stringify_string as Ct, create_text as D, component_root as E, get as F, is_passive_event as G, init_operations as H, get_first_child as I, mutable_source as J, lifecycle_function_unavailable as K, get_next_sibling as L, element as M, ensure_array_like as N, defer_effect as O, flushSync as P, push as Q, handle_error as R, branch as S, stringify_key as St, component_context as T, internal_set as U, increment as V, invoke_error_boundary as W, pop as X, pause_effect as Y, props_id as Z, attr_class as _, DevalueError as _t, DIRTY as a, set_active_reaction as at, bind_props as b, is_plain_object as bt, HYDRATION_END as c, source as ct, HYDRATION_START_ELSE as d, stringify as dt, render as et, LEGACY_PROPS as f, svelte_boundary_reset_onerror as ft, attr as g, uneval as gt, active_reaction as h, without_reactive_context as ht, COMMENT_NODE as i, set_active_effect as it, effect_tracking as j, derived as k, HYDRATION_ERROR as l, spread_props as lt, active_effect as m, untrack as mt, BOUNDARY_EFFECT as n, schedule_effect as nt, EFFECT_PRESERVED as o, set_component_context as ot, MAYBE_DIRTY as p, unsubscribe_stores as pt, move_effect as q, Batch as r, set as rt, EFFECT_TRANSPARENT as s, set_signal_status as st, ATTACHMENT_KEY as t, render_effect as tt, HYDRATION_START as u, store_get as ut, attr_style as v, enumerable_symbols as vt, clsx as w, BROWSER as wt, block as x, is_primitive as xt, attributes as y, get_type as yt, head as z };
2588
+ //# sourceMappingURL=index2-BQnysSj-.js.map