@axium/server 0.24.0 → 0.25.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 (353) hide show
  1. package/axiumd.service +1 -1
  2. package/build/client/_app/immutable/assets/account.dAAx7bby.css +1 -0
  3. package/build/client/_app/immutable/assets/account.dAAx7bby.css.br +0 -0
  4. package/build/client/_app/immutable/assets/account.dAAx7bby.css.gz +0 -0
  5. package/build/client/_app/immutable/assets/list.DVGH0BeP.css +1 -0
  6. package/build/client/_app/immutable/assets/list.DVGH0BeP.css.br +0 -0
  7. package/build/client/_app/immutable/assets/list.DVGH0BeP.css.gz +0 -0
  8. package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css +1 -0
  9. package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css.br +2 -0
  10. package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css.gz +0 -0
  11. package/build/client/_app/immutable/chunks/1taVrT-y.js +1 -0
  12. package/build/client/_app/immutable/chunks/1taVrT-y.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/1taVrT-y.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/BSFUgC2l.js +23 -0
  15. package/build/client/_app/immutable/chunks/BSFUgC2l.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/BSFUgC2l.js.gz +0 -0
  17. package/build/client/_app/immutable/chunks/Bbzjahjl.js +2 -0
  18. package/build/client/_app/immutable/chunks/Bbzjahjl.js.br +0 -0
  19. package/build/client/_app/immutable/chunks/Bbzjahjl.js.gz +0 -0
  20. package/build/client/_app/immutable/chunks/BxjargW5.js +1 -0
  21. package/build/client/_app/immutable/chunks/BxjargW5.js.br +0 -0
  22. package/build/client/_app/immutable/chunks/BxjargW5.js.gz +0 -0
  23. package/build/client/_app/immutable/chunks/C2ewTgu8.js +1 -0
  24. package/build/client/_app/immutable/chunks/C2ewTgu8.js.br +0 -0
  25. package/build/client/_app/immutable/chunks/C2ewTgu8.js.gz +0 -0
  26. package/build/client/_app/immutable/chunks/CFWAHLsq.js +1 -0
  27. package/build/client/_app/immutable/chunks/CFWAHLsq.js.br +0 -0
  28. package/build/client/_app/immutable/chunks/CFWAHLsq.js.gz +0 -0
  29. package/build/client/_app/immutable/chunks/CPL43v-I.js +1 -0
  30. package/build/client/_app/immutable/chunks/CPL43v-I.js.br +0 -0
  31. package/build/client/_app/immutable/chunks/CPL43v-I.js.gz +0 -0
  32. package/build/client/_app/immutable/chunks/CTKC36WM.js +1 -0
  33. package/build/client/_app/immutable/chunks/CTKC36WM.js.br +0 -0
  34. package/build/client/_app/immutable/chunks/CTKC36WM.js.gz +0 -0
  35. package/build/client/_app/immutable/chunks/CekH6JMP.js +1 -0
  36. package/build/client/_app/immutable/chunks/CekH6JMP.js.br +0 -0
  37. package/build/client/_app/immutable/chunks/CekH6JMP.js.gz +0 -0
  38. package/build/client/_app/immutable/chunks/Ch16TNvP.js +1 -0
  39. package/build/client/_app/immutable/chunks/Ch16TNvP.js.br +0 -0
  40. package/build/client/_app/immutable/chunks/Ch16TNvP.js.gz +0 -0
  41. package/build/client/_app/immutable/chunks/CqfYW08-.js +1 -0
  42. package/build/client/_app/immutable/chunks/CqfYW08-.js.br +0 -0
  43. package/build/client/_app/immutable/chunks/CqfYW08-.js.gz +0 -0
  44. package/build/client/_app/immutable/chunks/D1v6O410.js +1 -0
  45. package/build/client/_app/immutable/chunks/D1v6O410.js.br +0 -0
  46. package/build/client/_app/immutable/chunks/D1v6O410.js.gz +0 -0
  47. package/build/client/_app/immutable/chunks/DY4fWHx_.js +1 -0
  48. package/build/client/_app/immutable/chunks/DY4fWHx_.js.br +0 -0
  49. package/build/client/_app/immutable/chunks/DY4fWHx_.js.gz +0 -0
  50. package/build/client/_app/immutable/chunks/DdnE6dyJ.js +2 -0
  51. package/build/client/_app/immutable/chunks/DdnE6dyJ.js.br +0 -0
  52. package/build/client/_app/immutable/chunks/DdnE6dyJ.js.gz +0 -0
  53. package/build/client/_app/immutable/chunks/DeieCYM0.js +22 -0
  54. package/build/client/_app/immutable/chunks/DeieCYM0.js.br +0 -0
  55. package/build/client/_app/immutable/chunks/DeieCYM0.js.gz +0 -0
  56. package/build/client/_app/immutable/chunks/DfUzlYF5.js +1 -0
  57. package/build/client/_app/immutable/chunks/DfUzlYF5.js.br +0 -0
  58. package/build/client/_app/immutable/chunks/DfUzlYF5.js.gz +0 -0
  59. package/build/client/_app/immutable/chunks/Dnk28BpG.js +1 -0
  60. package/build/client/_app/immutable/chunks/Dnk28BpG.js.br +0 -0
  61. package/build/client/_app/immutable/chunks/Dnk28BpG.js.gz +0 -0
  62. package/build/client/_app/immutable/chunks/KNAS5R2A.js +3 -0
  63. package/build/client/_app/immutable/chunks/KNAS5R2A.js.br +0 -0
  64. package/build/client/_app/immutable/chunks/KNAS5R2A.js.gz +0 -0
  65. package/build/client/_app/immutable/chunks/eyJgPND9.js +1 -0
  66. package/build/client/_app/immutable/chunks/eyJgPND9.js.br +1 -0
  67. package/build/client/_app/immutable/chunks/eyJgPND9.js.gz +0 -0
  68. package/build/client/_app/immutable/entry/app.CPF6A_DV.js +2 -0
  69. package/build/client/_app/immutable/entry/app.CPF6A_DV.js.br +0 -0
  70. package/build/client/_app/immutable/entry/app.CPF6A_DV.js.gz +0 -0
  71. package/build/client/_app/immutable/entry/start.Dos_Ttds.js +1 -0
  72. package/build/client/_app/immutable/entry/start.Dos_Ttds.js.br +2 -0
  73. package/build/client/_app/immutable/entry/start.Dos_Ttds.js.gz +0 -0
  74. package/build/client/_app/immutable/nodes/{0.DlE8ZTIF.js → 0.C5HgTRfT.js} +1 -1
  75. package/build/client/_app/immutable/nodes/0.C5HgTRfT.js.br +0 -0
  76. package/build/client/_app/immutable/nodes/0.C5HgTRfT.js.gz +0 -0
  77. package/build/client/_app/immutable/nodes/1.CGcgSoA9.js +1 -0
  78. package/build/client/_app/immutable/nodes/1.CGcgSoA9.js.br +0 -0
  79. package/build/client/_app/immutable/nodes/1.CGcgSoA9.js.gz +0 -0
  80. package/build/client/_app/immutable/nodes/10.ukScuXwz.js +1 -0
  81. package/build/client/_app/immutable/nodes/10.ukScuXwz.js.br +5 -0
  82. package/build/client/_app/immutable/nodes/10.ukScuXwz.js.gz +0 -0
  83. package/build/client/_app/immutable/nodes/11.D3RDNx7M.js +1 -0
  84. package/build/client/_app/immutable/nodes/11.D3RDNx7M.js.br +0 -0
  85. package/build/client/_app/immutable/nodes/11.D3RDNx7M.js.gz +0 -0
  86. package/build/client/_app/immutable/nodes/12._vvpCcSG.js +1 -0
  87. package/build/client/_app/immutable/nodes/12._vvpCcSG.js.br +0 -0
  88. package/build/client/_app/immutable/nodes/12._vvpCcSG.js.gz +0 -0
  89. package/build/client/_app/immutable/nodes/13.BWPzZMQ5.js +1 -0
  90. package/build/client/_app/immutable/nodes/13.BWPzZMQ5.js.br +0 -0
  91. package/build/client/_app/immutable/nodes/13.BWPzZMQ5.js.gz +0 -0
  92. package/build/client/_app/immutable/nodes/14.Cr843Lep.js +1 -0
  93. package/build/client/_app/immutable/nodes/14.Cr843Lep.js.br +0 -0
  94. package/build/client/_app/immutable/nodes/14.Cr843Lep.js.gz +0 -0
  95. package/build/client/_app/immutable/nodes/2.DUpwDjw8.js +1 -0
  96. package/build/client/_app/immutable/nodes/2.DUpwDjw8.js.br +0 -0
  97. package/build/client/_app/immutable/nodes/2.DUpwDjw8.js.gz +0 -0
  98. package/build/client/_app/immutable/nodes/{2.CvEpuMc7.js → 3.DPH7xl7M.js} +1 -1
  99. package/build/client/_app/immutable/nodes/3.DPH7xl7M.js.br +0 -0
  100. package/build/client/_app/immutable/nodes/3.DPH7xl7M.js.gz +0 -0
  101. package/build/client/_app/immutable/nodes/4.Bk0knTIK.js +1 -0
  102. package/build/client/_app/immutable/nodes/4.Bk0knTIK.js.br +0 -0
  103. package/build/client/_app/immutable/nodes/4.Bk0knTIK.js.gz +0 -0
  104. package/build/client/_app/immutable/nodes/5.DwnZ1Bh8.js +1 -0
  105. package/build/client/_app/immutable/nodes/5.DwnZ1Bh8.js.br +0 -0
  106. package/build/client/_app/immutable/nodes/5.DwnZ1Bh8.js.gz +0 -0
  107. package/build/client/_app/immutable/nodes/6.5U-KxFgt.js +2 -0
  108. package/build/client/_app/immutable/nodes/6.5U-KxFgt.js.br +0 -0
  109. package/build/client/_app/immutable/nodes/6.5U-KxFgt.js.gz +0 -0
  110. package/build/client/_app/immutable/nodes/7.DFc4sJix.js +1 -0
  111. package/build/client/_app/immutable/nodes/7.DFc4sJix.js.br +0 -0
  112. package/build/client/_app/immutable/nodes/7.DFc4sJix.js.gz +0 -0
  113. package/build/client/_app/immutable/nodes/8.BG4bv5P5.js +1 -0
  114. package/build/client/_app/immutable/nodes/8.BG4bv5P5.js.br +0 -0
  115. package/build/client/_app/immutable/nodes/8.BG4bv5P5.js.gz +0 -0
  116. package/build/client/_app/immutable/nodes/9.BKljyhOi.js +1 -0
  117. package/build/client/_app/immutable/nodes/9.BKljyhOi.js.br +0 -0
  118. package/build/client/_app/immutable/nodes/9.BKljyhOi.js.gz +0 -0
  119. package/build/client/_app/version.json +1 -1
  120. package/build/client/_app/version.json.br +0 -0
  121. package/build/client/_app/version.json.gz +0 -0
  122. package/build/client/styles.css +7 -0
  123. package/build/client/styles.css.br +0 -0
  124. package/build/client/styles.css.gz +0 -0
  125. package/build/handler.js +20 -3
  126. package/build/server/chunks/0-CZBaNtSI.js +9 -0
  127. package/build/server/chunks/{0-DgHTujtC.js.map → 0-CZBaNtSI.js.map} +1 -1
  128. package/build/server/chunks/1-D_3BtEbe.js +9 -0
  129. package/build/server/chunks/{1-k30i-hic.js.map → 1-D_3BtEbe.js.map} +1 -1
  130. package/build/server/chunks/10-CLkNMKHU.js +13 -0
  131. package/build/server/chunks/10-CLkNMKHU.js.map +1 -0
  132. package/build/server/chunks/11-5xPYR_1w.js +13 -0
  133. package/build/server/chunks/11-5xPYR_1w.js.map +1 -0
  134. package/build/server/chunks/12-N7UaQj7u.js +9 -0
  135. package/build/server/chunks/12-N7UaQj7u.js.map +1 -0
  136. package/build/server/chunks/13-QYVLpXli.js +9 -0
  137. package/build/server/chunks/13-QYVLpXli.js.map +1 -0
  138. package/build/server/chunks/14-CPY578rT.js +9 -0
  139. package/build/server/chunks/14-CPY578rT.js.map +1 -0
  140. package/build/server/chunks/2-_1jFrcvz.js +13 -0
  141. package/build/server/chunks/2-_1jFrcvz.js.map +1 -0
  142. package/build/server/chunks/3-B1CwnVF_.js +9 -0
  143. package/build/server/chunks/{2-CXlrhpR6.js.map → 3-B1CwnVF_.js.map} +1 -1
  144. package/build/server/chunks/4-CcxCcH4F.js +13 -0
  145. package/build/server/chunks/4-CcxCcH4F.js.map +1 -0
  146. package/build/server/chunks/5-CrlH6VoB.js +13 -0
  147. package/build/server/chunks/5-CrlH6VoB.js.map +1 -0
  148. package/build/server/chunks/6-FkP678Uz.js +13 -0
  149. package/build/server/chunks/6-FkP678Uz.js.map +1 -0
  150. package/build/server/chunks/7-B1iCe7VA.js +13 -0
  151. package/build/server/chunks/7-B1iCe7VA.js.map +1 -0
  152. package/build/server/chunks/8-p6n9G-P_.js +13 -0
  153. package/build/server/chunks/8-p6n9G-P_.js.map +1 -0
  154. package/build/server/chunks/9-fc3lKB7X.js +13 -0
  155. package/build/server/chunks/9-fc3lKB7X.js.map +1 -0
  156. package/build/server/chunks/Icon-CG7XnWX5.js +30 -0
  157. package/build/server/chunks/Icon-CG7XnWX5.js.map +1 -0
  158. package/build/server/chunks/Logout-BwzK1P29.js +45 -0
  159. package/build/server/chunks/Logout-BwzK1P29.js.map +1 -0
  160. package/build/server/chunks/_layout.svelte-9KMUotip.js +31 -0
  161. package/build/server/chunks/_layout.svelte-9KMUotip.js.map +1 -0
  162. package/build/server/chunks/_page.svelte-BD3HmLo_.js +28 -0
  163. package/build/server/chunks/_page.svelte-BD3HmLo_.js.map +1 -0
  164. package/build/server/chunks/_page.svelte-BFzPdJ6z.js +105 -0
  165. package/build/server/chunks/_page.svelte-BFzPdJ6z.js.map +1 -0
  166. package/build/server/chunks/_page.svelte-BIxxuzff.js +64 -0
  167. package/build/server/chunks/_page.svelte-BIxxuzff.js.map +1 -0
  168. package/build/server/chunks/_page.svelte-Bou2_u6i.js +13 -0
  169. package/build/server/chunks/_page.svelte-Bou2_u6i.js.map +1 -0
  170. package/build/server/chunks/_page.svelte-C25oQ2NT.js +80 -0
  171. package/build/server/chunks/_page.svelte-C25oQ2NT.js.map +1 -0
  172. package/build/server/chunks/_page.svelte-CAzWL4aq.js +66 -0
  173. package/build/server/chunks/_page.svelte-CAzWL4aq.js.map +1 -0
  174. package/build/server/chunks/_page.svelte-Ci5V-DhL.js +72 -0
  175. package/build/server/chunks/_page.svelte-Ci5V-DhL.js.map +1 -0
  176. package/build/server/chunks/_page.svelte-CnfRSJsl.js +37 -0
  177. package/build/server/chunks/_page.svelte-CnfRSJsl.js.map +1 -0
  178. package/build/server/chunks/_page.svelte-DgyZKeaF.js +231 -0
  179. package/build/server/chunks/_page.svelte-DgyZKeaF.js.map +1 -0
  180. package/build/server/chunks/_page.svelte-VDBvShZ8.js +6 -0
  181. package/build/server/chunks/_page.svelte-VDBvShZ8.js.map +1 -0
  182. package/build/server/chunks/_page.svelte-cAsZlwLs.js +24 -0
  183. package/build/server/chunks/_page.svelte-cAsZlwLs.js.map +1 -0
  184. package/build/server/chunks/_page.svelte-rrN2zFNa.js +66 -0
  185. package/build/server/chunks/_page.svelte-rrN2zFNa.js.map +1 -0
  186. package/build/server/chunks/account-BZSP6KBP.js +445 -0
  187. package/build/server/chunks/account-BZSP6KBP.js.map +1 -0
  188. package/build/server/chunks/color-K_MR7m8s.js +14 -0
  189. package/build/server/chunks/color-K_MR7m8s.js.map +1 -0
  190. package/build/server/chunks/context-R2425nfV.js +64 -0
  191. package/build/server/chunks/context-R2425nfV.js.map +1 -0
  192. package/build/server/chunks/{error.svelte-DNQXZmIO.js → error.svelte-DTrQqomO.js} +8 -7
  193. package/build/server/chunks/error.svelte-DTrQqomO.js.map +1 -0
  194. package/build/server/chunks/index-DJrm8BZm.js +844 -0
  195. package/build/server/chunks/index-DJrm8BZm.js.map +1 -0
  196. package/build/server/chunks/{index-CvHf_GW2.js → index-eKiDBuyI.js} +826 -438
  197. package/build/server/chunks/index-eKiDBuyI.js.map +1 -0
  198. package/build/server/chunks/layout.svelte-UxsTmhKc.js +8 -0
  199. package/build/server/chunks/layout.svelte-UxsTmhKc.js.map +1 -0
  200. package/build/server/chunks/{string-DLbvtT1R.js → numbers-DL8C9q4W.js} +1 -71
  201. package/build/server/chunks/numbers-DL8C9q4W.js.map +1 -0
  202. package/build/server/chunks/{FormDialog-CB-2YGWi.js → user2-Coq3Frtw.js} +102 -203
  203. package/build/server/chunks/user2-Coq3Frtw.js.map +1 -0
  204. package/build/server/chunks/{utils-h74ns7K6.js → utils-DlBYhQz7.js} +2 -1
  205. package/build/server/chunks/utils-DlBYhQz7.js.map +1 -0
  206. package/build/server/index.js +1787 -994
  207. package/build/server/index.js.map +1 -1
  208. package/build/server/manifest.js +70 -13
  209. package/build/server/manifest.js.map +1 -1
  210. package/dist/acl.d.ts +1 -2
  211. package/dist/api/acl.js +4 -4
  212. package/dist/api/admin.d.ts +1 -0
  213. package/dist/api/admin.js +135 -0
  214. package/dist/api/index.d.ts +2 -0
  215. package/dist/api/index.js +2 -0
  216. package/dist/api/metadata.js +3 -3
  217. package/dist/api/passkeys.js +10 -10
  218. package/dist/api/register.js +4 -4
  219. package/dist/api/session.js +5 -5
  220. package/dist/api/users.js +48 -48
  221. package/dist/audit.d.ts +7 -39
  222. package/dist/audit.js +10 -13
  223. package/dist/auth.d.ts +4 -11
  224. package/dist/auth.js +4 -4
  225. package/dist/cli.js +40 -54
  226. package/dist/config.d.ts +24 -14
  227. package/dist/config.js +42 -25
  228. package/dist/database.d.ts +3 -4
  229. package/dist/database.js +12 -12
  230. package/dist/internal_requests.d.ts +3 -0
  231. package/dist/internal_requests.js +119 -0
  232. package/dist/io.d.ts +1 -1
  233. package/dist/io.js +2 -5
  234. package/dist/linking.d.ts +0 -1
  235. package/dist/linking.js +2 -5
  236. package/dist/plugins.d.ts +4 -39
  237. package/dist/plugins.js +35 -51
  238. package/dist/requests.d.ts +5 -5
  239. package/dist/requests.js +14 -14
  240. package/dist/routes.d.ts +6 -10
  241. package/dist/routes.js +4 -5
  242. package/dist/serve.d.ts +3 -2
  243. package/dist/serve.js +165 -13
  244. package/dist/state.js +2 -1
  245. package/package.json +6 -5
  246. package/routes/account/+page.svelte +5 -109
  247. package/routes/admin/+layout.svelte +56 -0
  248. package/routes/admin/+layout.ts +29 -0
  249. package/routes/admin/+page.svelte +39 -0
  250. package/routes/admin/+page.ts +7 -0
  251. package/routes/admin/audit/+page.svelte +137 -0
  252. package/routes/admin/audit/+page.ts +20 -0
  253. package/routes/admin/audit/[id]/+page.svelte +43 -0
  254. package/routes/admin/audit/[id]/+page.ts +9 -0
  255. package/routes/admin/audit/styles.css +31 -0
  256. package/routes/admin/config/+page.svelte +28 -0
  257. package/routes/admin/config/+page.ts +9 -0
  258. package/routes/admin/plugins/+page.svelte +23 -0
  259. package/routes/admin/plugins/+page.ts +7 -0
  260. package/routes/admin/users/+page.svelte +60 -0
  261. package/routes/admin/users/+page.ts +9 -0
  262. package/routes/admin/users/[id]/+page.svelte +108 -0
  263. package/routes/admin/users/[id]/+page.ts +17 -0
  264. package/routes/tsconfig.json +1 -1
  265. package/svelte.config.js +4 -10
  266. package/{web/template.html → template.html} +1 -1
  267. package/{web/tsconfig.json → web.tsconfig.json} +2 -2
  268. package/build/client/_app/immutable/chunks/B1E1cVbi.js +0 -1
  269. package/build/client/_app/immutable/chunks/B1E1cVbi.js.br +0 -0
  270. package/build/client/_app/immutable/chunks/B1E1cVbi.js.gz +0 -0
  271. package/build/client/_app/immutable/chunks/D3hk2v8y.js +0 -1
  272. package/build/client/_app/immutable/chunks/D3hk2v8y.js.br +0 -2
  273. package/build/client/_app/immutable/chunks/D3hk2v8y.js.gz +0 -0
  274. package/build/client/_app/immutable/chunks/D4Bce_hb.js +0 -1
  275. package/build/client/_app/immutable/chunks/D4Bce_hb.js.br +0 -0
  276. package/build/client/_app/immutable/chunks/D4Bce_hb.js.gz +0 -0
  277. package/build/client/_app/immutable/chunks/D9TfJrfD.js +0 -1
  278. package/build/client/_app/immutable/chunks/D9TfJrfD.js.br +0 -0
  279. package/build/client/_app/immutable/chunks/D9TfJrfD.js.gz +0 -0
  280. package/build/client/_app/immutable/chunks/DJeR1n-B.js +0 -51
  281. package/build/client/_app/immutable/chunks/DJeR1n-B.js.br +0 -0
  282. package/build/client/_app/immutable/chunks/DJeR1n-B.js.gz +0 -0
  283. package/build/client/_app/immutable/chunks/Dy1O3iBu.js +0 -2
  284. package/build/client/_app/immutable/chunks/Dy1O3iBu.js.br +0 -0
  285. package/build/client/_app/immutable/chunks/Dy1O3iBu.js.gz +0 -0
  286. package/build/client/_app/immutable/chunks/NhZR8nmR.js +0 -3
  287. package/build/client/_app/immutable/chunks/NhZR8nmR.js.br +0 -0
  288. package/build/client/_app/immutable/chunks/NhZR8nmR.js.gz +0 -0
  289. package/build/client/_app/immutable/chunks/pba7IodQ.js +0 -1
  290. package/build/client/_app/immutable/chunks/pba7IodQ.js.br +0 -0
  291. package/build/client/_app/immutable/chunks/pba7IodQ.js.gz +0 -0
  292. package/build/client/_app/immutable/entry/app.DJWgFLyv.js +0 -2
  293. package/build/client/_app/immutable/entry/app.DJWgFLyv.js.br +0 -0
  294. package/build/client/_app/immutable/entry/app.DJWgFLyv.js.gz +0 -0
  295. package/build/client/_app/immutable/entry/start.CM7y0WAo.js +0 -1
  296. package/build/client/_app/immutable/entry/start.CM7y0WAo.js.br +0 -2
  297. package/build/client/_app/immutable/entry/start.CM7y0WAo.js.gz +0 -0
  298. package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.br +0 -0
  299. package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.gz +0 -0
  300. package/build/client/_app/immutable/nodes/1.BER4lkmI.js +0 -1
  301. package/build/client/_app/immutable/nodes/1.BER4lkmI.js.br +0 -0
  302. package/build/client/_app/immutable/nodes/1.BER4lkmI.js.gz +0 -0
  303. package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.br +0 -0
  304. package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.gz +0 -0
  305. package/build/client/_app/immutable/nodes/3.CVudd8x2.js +0 -7
  306. package/build/client/_app/immutable/nodes/3.CVudd8x2.js.br +0 -0
  307. package/build/client/_app/immutable/nodes/3.CVudd8x2.js.gz +0 -0
  308. package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js +0 -1
  309. package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js.br +0 -0
  310. package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js.gz +0 -0
  311. package/build/client/_app/immutable/nodes/5.CGoBaVII.js +0 -1
  312. package/build/client/_app/immutable/nodes/5.CGoBaVII.js.br +0 -0
  313. package/build/client/_app/immutable/nodes/5.CGoBaVII.js.gz +0 -0
  314. package/build/client/_app/immutable/nodes/6.BtB2uWXy.js +0 -1
  315. package/build/client/_app/immutable/nodes/6.BtB2uWXy.js.br +0 -0
  316. package/build/client/_app/immutable/nodes/6.BtB2uWXy.js.gz +0 -0
  317. package/build/server/chunks/0-DgHTujtC.js +0 -9
  318. package/build/server/chunks/1-k30i-hic.js +0 -9
  319. package/build/server/chunks/2-CXlrhpR6.js +0 -9
  320. package/build/server/chunks/3-CGT4Ugys.js +0 -13
  321. package/build/server/chunks/3-CGT4Ugys.js.map +0 -1
  322. package/build/server/chunks/4-BscEiwUk.js +0 -9
  323. package/build/server/chunks/4-BscEiwUk.js.map +0 -1
  324. package/build/server/chunks/5-H0ePIJBE.js +0 -9
  325. package/build/server/chunks/5-H0ePIJBE.js.map +0 -1
  326. package/build/server/chunks/6-BrPpcagX.js +0 -9
  327. package/build/server/chunks/6-BrPpcagX.js.map +0 -1
  328. package/build/server/chunks/FormDialog-CB-2YGWi.js.map +0 -1
  329. package/build/server/chunks/Logout-LKOt-AST.js +0 -45
  330. package/build/server/chunks/Logout-LKOt-AST.js.map +0 -1
  331. package/build/server/chunks/_page.svelte-B1LK5J87.js +0 -11
  332. package/build/server/chunks/_page.svelte-B1LK5J87.js.map +0 -1
  333. package/build/server/chunks/_page.svelte-CMtkwvbP.js +0 -68
  334. package/build/server/chunks/_page.svelte-CMtkwvbP.js.map +0 -1
  335. package/build/server/chunks/_page.svelte-CbI2KxeA.js +0 -62
  336. package/build/server/chunks/_page.svelte-CbI2KxeA.js.map +0 -1
  337. package/build/server/chunks/_page.svelte-D1_WJoyP.js +0 -6
  338. package/build/server/chunks/_page.svelte-D1_WJoyP.js.map +0 -1
  339. package/build/server/chunks/_page.svelte-d01Hl2Ia.js +0 -639
  340. package/build/server/chunks/_page.svelte-d01Hl2Ia.js.map +0 -1
  341. package/build/server/chunks/error.svelte-DNQXZmIO.js.map +0 -1
  342. package/build/server/chunks/hooks.server-BQqilaHv.js +0 -17301
  343. package/build/server/chunks/hooks.server-BQqilaHv.js.map +0 -1
  344. package/build/server/chunks/index-CvHf_GW2.js.map +0 -1
  345. package/build/server/chunks/index-RTKpMYZ1.js +0 -397
  346. package/build/server/chunks/index-RTKpMYZ1.js.map +0 -1
  347. package/build/server/chunks/layout.svelte-BSvrn-4a.js +0 -8
  348. package/build/server/chunks/layout.svelte-BSvrn-4a.js.map +0 -1
  349. package/build/server/chunks/string-DLbvtT1R.js.map +0 -1
  350. package/build/server/chunks/utils-h74ns7K6.js.map +0 -1
  351. package/dist/sveltekit.d.ts +0 -8
  352. package/dist/sveltekit.js +0 -60
  353. package/web/hooks.server.ts +0 -4
@@ -1,13 +1,16 @@
1
- import { r as render, L as LEGACY_PROPS, U as UNOWNED, E as ERROR_VALUE, C as COMMENT_NODE, H as HYDRATION_START, a as HYDRATION_ERROR, b as HYDRATION_END, S as STATE_SYMBOL, c as UNINITIALIZED, D as DERIVED, d as DIRTY, e as CLEAN, M as MAYBE_DIRTY, f as DISCONNECTED, g as DEV, I as INERT, h as EFFECT, A as ASYNC, B as BLOCK_EFFECT, i as is_passive_event, j as BRANCH_EFFECT, R as ROOT_EFFECT, k as DESTROYED, l as REACTION_IS_UPDATING, m as EFFECT_RAN, n as EFFECT_PRESERVED, o as HEAD_EFFECT, p as BOUNDARY_EFFECT, q as EFFECT_TRANSPARENT, s as INSPECT_EFFECT, t as STALE_REACTION, u as push$1, v as setContext, w as pop$1, x as USER_EFFECT } from './chunks/index-RTKpMYZ1.js';
2
1
  import { json, text, error } from '@sveltejs/kit';
3
2
  import { Redirect, SvelteKitError, HttpError, ActionFailure } from '@sveltejs/kit/internal';
4
3
  import { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';
5
- import { d as define_property, s as safe_equals, o as object_prototype, a as array_prototype, g as get_descriptor, i as is_extensible, b as array_from, e as equals, c as get_prototype_of, f as is_array, h as deferred, r as run_all, j as index_of, t as text_decoder, k as base64_decode, l as decode_pathname, m as decode_params, n as normalize_path, p as disable_search, v as validate_layout_server_exports, q as validate_layout_exports, u as validate_page_server_exports, w as validate_page_exports, x as text_encoder, y as resolve, z as make_trackable, A as get_relative_path, B as base64_encode, C as readable, D as writable } from './chunks/utils-h74ns7K6.js';
4
+ import { d as define_property, s as safe_equals, o as object_prototype, a as array_prototype, g as get_descriptor, i as is_extensible, b as array_from, e as equals, c as get_prototype_of, f as is_array, h as deferred, r as run_all, j as index_of, t as text_decoder, k as base64_decode, l as decode_pathname, m as decode_params, n as normalize_path, p as disable_search, v as validate_layout_server_exports, q as validate_layout_exports, u as validate_page_server_exports, w as validate_page_exports, x as text_encoder, y as resolve, z as make_trackable, A as get_relative_path, B as base64_encode, C as readable, D as writable } from './chunks/utils-DlBYhQz7.js';
5
+ import { r as render, L as LEGACY_PROPS, U as UNOWNED, E as ERROR_VALUE, C as COMMENT_NODE, H as HYDRATION_START, a as HYDRATION_ERROR, S as STATE_SYMBOL, b as UNINITIALIZED, D as DERIVED, c as DIRTY, d as CLEAN, M as MAYBE_DIRTY, e as DISCONNECTED, I as INERT, f as EFFECT, A as ASYNC, B as BLOCK_EFFECT, i as is_passive_event, g as BRANCH_EFFECT, R as ROOT_EFFECT, h as DESTROYED, j as REACTION_IS_UPDATING, k as EFFECT_RAN, l as EFFECT_PRESERVED, m as HEAD_EFFECT, n as BOUNDARY_EFFECT, o as EFFECT_TRANSPARENT, p as INSPECT_EFFECT, q as STALE_REACTION, s as HYDRATION_END, t as RENDER_EFFECT, u as HYDRATION_START_ELSE, v as USER_EFFECT } from './chunks/index-DJrm8BZm.js';
6
+ import { s as setContext } from './chunks/context-R2425nfV.js';
6
7
  import { parse as parse$1, serialize } from 'cookie';
7
8
 
9
+ const DEV = false;
8
10
  let base = "";
9
11
  let assets = base;
10
12
  const app_dir = "_app";
13
+ const relative = true;
11
14
  const initial = { base, assets };
12
15
  function override(paths) {
13
16
  base = paths.base;
@@ -61,6 +64,7 @@ function is_plain_object(thing) {
61
64
  return (
62
65
  proto === Object.prototype ||
63
66
  proto === null ||
67
+ Object.getPrototypeOf(proto) === null ||
64
68
  Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
65
69
  );
66
70
  }
@@ -140,7 +144,7 @@ const reserved =
140
144
  /**
141
145
  * Turn a value into the JavaScript that creates an equivalent value
142
146
  * @param {any} value
143
- * @param {(value: any) => string | void} [replacer]
147
+ * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
144
148
  */
145
149
  function uneval(value, replacer) {
146
150
  const counts = new Map();
@@ -165,7 +169,7 @@ function uneval(value, replacer) {
165
169
  counts.set(thing, 1);
166
170
 
167
171
  if (replacer) {
168
- const str = replacer(thing);
172
+ const str = replacer(thing, (value) => uneval(value, replacer));
169
173
 
170
174
  if (typeof str === 'string') {
171
175
  custom.set(thing, str);
@@ -182,6 +186,8 @@ function uneval(value, replacer) {
182
186
  case 'Boolean':
183
187
  case 'Date':
184
188
  case 'RegExp':
189
+ case 'URL':
190
+ case 'URLSearchParams':
185
191
  return;
186
192
 
187
193
  case 'Array':
@@ -205,21 +211,32 @@ function uneval(value, replacer) {
205
211
  keys.pop();
206
212
  }
207
213
  break;
208
-
209
- case "Int8Array":
210
- case "Uint8Array":
211
- case "Uint8ClampedArray":
212
- case "Int16Array":
213
- case "Uint16Array":
214
- case "Int32Array":
215
- case "Uint32Array":
216
- case "Float32Array":
217
- case "Float64Array":
218
- case "BigInt64Array":
219
- case "BigUint64Array":
214
+
215
+ case 'Int8Array':
216
+ case 'Uint8Array':
217
+ case 'Uint8ClampedArray':
218
+ case 'Int16Array':
219
+ case 'Uint16Array':
220
+ case 'Int32Array':
221
+ case 'Uint32Array':
222
+ case 'Float32Array':
223
+ case 'Float64Array':
224
+ case 'BigInt64Array':
225
+ case 'BigUint64Array':
226
+ walk(thing.buffer);
227
+ return;
228
+
229
+ case 'ArrayBuffer':
220
230
  return;
221
-
222
- case "ArrayBuffer":
231
+
232
+ case 'Temporal.Duration':
233
+ case 'Temporal.Instant':
234
+ case 'Temporal.PlainDate':
235
+ case 'Temporal.PlainTime':
236
+ case 'Temporal.PlainDateTime':
237
+ case 'Temporal.PlainMonthDay':
238
+ case 'Temporal.PlainYearMonth':
239
+ case 'Temporal.ZonedDateTime':
223
240
  return;
224
241
 
225
242
  default:
@@ -290,6 +307,12 @@ function uneval(value, replacer) {
290
307
  case 'Date':
291
308
  return `new Date(${thing.getTime()})`;
292
309
 
310
+ case 'URL':
311
+ return `new URL(${stringify_string(thing.toString())})`;
312
+
313
+ case 'URLSearchParams':
314
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
315
+
293
316
  case 'Array':
294
317
  const members = /** @type {any[]} */ (thing).map((v, i) =>
295
318
  i in thing ? stringify(v) : ''
@@ -300,40 +323,67 @@ function uneval(value, replacer) {
300
323
  case 'Set':
301
324
  case 'Map':
302
325
  return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
303
-
304
- case "Int8Array":
305
- case "Uint8Array":
306
- case "Uint8ClampedArray":
307
- case "Int16Array":
308
- case "Uint16Array":
309
- case "Int32Array":
310
- case "Uint32Array":
311
- case "Float32Array":
312
- case "Float64Array":
313
- case "BigInt64Array":
314
- case "BigUint64Array": {
315
- /** @type {import("./types.js").TypedArray} */
316
- const typedArray = thing;
317
- return `new ${type}([${typedArray.toString()}])`;
326
+
327
+ case 'Int8Array':
328
+ case 'Uint8Array':
329
+ case 'Uint8ClampedArray':
330
+ case 'Int16Array':
331
+ case 'Uint16Array':
332
+ case 'Int32Array':
333
+ case 'Uint32Array':
334
+ case 'Float32Array':
335
+ case 'Float64Array':
336
+ case 'BigInt64Array':
337
+ case 'BigUint64Array': {
338
+ let str = `new ${type}`;
339
+
340
+ if (counts.get(thing.buffer) === 1) {
341
+ const array = new thing.constructor(thing.buffer);
342
+ str += `([${array}])`;
343
+ } else {
344
+ str += `([${stringify(thing.buffer)}])`;
345
+ }
346
+
347
+ const a = thing.byteOffset;
348
+ const b = a + thing.byteLength;
349
+
350
+ // handle subarrays
351
+ if (a > 0 || b !== thing.buffer.byteLength) {
352
+ const m = +/(\d+)/.exec(type)[1] / 8;
353
+ str += `.subarray(${a / m},${b / m})`;
354
+ }
355
+
356
+ return str;
318
357
  }
319
-
320
- case "ArrayBuffer": {
358
+
359
+ case 'ArrayBuffer': {
321
360
  const ui8 = new Uint8Array(thing);
322
361
  return `new Uint8Array([${ui8.toString()}]).buffer`;
323
362
  }
324
363
 
364
+ case 'Temporal.Duration':
365
+ case 'Temporal.Instant':
366
+ case 'Temporal.PlainDate':
367
+ case 'Temporal.PlainTime':
368
+ case 'Temporal.PlainDateTime':
369
+ case 'Temporal.PlainMonthDay':
370
+ case 'Temporal.PlainYearMonth':
371
+ case 'Temporal.ZonedDateTime':
372
+ return `${type}.from(${stringify_string(thing.toString())})`;
373
+
325
374
  default:
326
- const obj = `{${Object.keys(thing)
375
+ const keys = Object.keys(thing);
376
+ const obj = keys
327
377
  .map((key) => `${safe_key(key)}:${stringify(thing[key])}`)
328
- .join(',')}}`;
378
+ .join(',');
329
379
  const proto = Object.getPrototypeOf(thing);
330
380
  if (proto === null) {
331
- return Object.keys(thing).length > 0
332
- ? `Object.assign(Object.create(null),${obj})`
333
- : `Object.create(null)`;
381
+ return keys.length > 0
382
+ ? `{${obj},__proto__:null}`
383
+ : `{__proto__:null}`;
334
384
  }
335
385
 
336
- return obj;
386
+ return `{${obj}}`;
337
387
  }
338
388
  }
339
389
 
@@ -404,6 +454,12 @@ function uneval(value, replacer) {
404
454
  );
405
455
  break;
406
456
 
457
+ case 'ArrayBuffer':
458
+ values.push(
459
+ `new Uint8Array([${new Uint8Array(thing).join(',')}]).buffer`
460
+ );
461
+ break;
462
+
407
463
  default:
408
464
  values.push(
409
465
  Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'
@@ -627,7 +683,9 @@ function unflatten(parsed, revivers) {
627
683
  if (index === NEGATIVE_INFINITY) return -Infinity;
628
684
  if (index === NEGATIVE_ZERO) return -0;
629
685
 
630
- if (standalone) throw new Error(`Invalid input`);
686
+ if (standalone || typeof index !== 'number') {
687
+ throw new Error(`Invalid input`);
688
+ }
631
689
 
632
690
  if (index in hydrated) return hydrated[index];
633
691
 
@@ -685,31 +743,60 @@ function unflatten(parsed, revivers) {
685
743
  }
686
744
  break;
687
745
 
688
- case "Int8Array":
689
- case "Uint8Array":
690
- case "Uint8ClampedArray":
691
- case "Int16Array":
692
- case "Uint16Array":
693
- case "Int32Array":
694
- case "Uint32Array":
695
- case "Float32Array":
696
- case "Float64Array":
697
- case "BigInt64Array":
698
- case "BigUint64Array": {
699
- const TypedArrayConstructor = globalThis[type];
700
- const base64 = value[1];
701
- const arraybuffer = decode64(base64);
702
- const typedArray = new TypedArrayConstructor(arraybuffer);
703
- hydrated[index] = typedArray;
704
- break;
705
- }
746
+ case 'Int8Array':
747
+ case 'Uint8Array':
748
+ case 'Uint8ClampedArray':
749
+ case 'Int16Array':
750
+ case 'Uint16Array':
751
+ case 'Int32Array':
752
+ case 'Uint32Array':
753
+ case 'Float32Array':
754
+ case 'Float64Array':
755
+ case 'BigInt64Array':
756
+ case 'BigUint64Array': {
757
+ const TypedArrayConstructor = globalThis[type];
758
+ const typedArray = new TypedArrayConstructor(hydrate(value[1]));
759
+
760
+ hydrated[index] =
761
+ value[2] !== undefined
762
+ ? typedArray.subarray(value[2], value[3])
763
+ : typedArray;
706
764
 
707
- case "ArrayBuffer": {
708
- const base64 = value[1];
709
- const arraybuffer = decode64(base64);
710
- hydrated[index] = arraybuffer;
711
- break;
712
- }
765
+ break;
766
+ }
767
+
768
+ case 'ArrayBuffer': {
769
+ const base64 = value[1];
770
+ const arraybuffer = decode64(base64);
771
+ hydrated[index] = arraybuffer;
772
+ break;
773
+ }
774
+
775
+ case 'Temporal.Duration':
776
+ case 'Temporal.Instant':
777
+ case 'Temporal.PlainDate':
778
+ case 'Temporal.PlainTime':
779
+ case 'Temporal.PlainDateTime':
780
+ case 'Temporal.PlainMonthDay':
781
+ case 'Temporal.PlainYearMonth':
782
+ case 'Temporal.ZonedDateTime': {
783
+ const temporalName = type.slice(9);
784
+ // @ts-expect-error TS doesn't know about Temporal yet
785
+ hydrated[index] = Temporal[temporalName].from(value[1]);
786
+ break;
787
+ }
788
+
789
+ case 'URL': {
790
+ const url = new URL(value[1]);
791
+ hydrated[index] = url;
792
+ break;
793
+ }
794
+
795
+ case 'URLSearchParams': {
796
+ const url = new URLSearchParams(value[1]);
797
+ hydrated[index] = url;
798
+ break;
799
+ }
713
800
 
714
801
  default:
715
802
  throw new Error(`Unknown type ${type}`);
@@ -731,6 +818,10 @@ function unflatten(parsed, revivers) {
731
818
  hydrated[index] = object;
732
819
 
733
820
  for (const key in value) {
821
+ if (key === '__proto__') {
822
+ throw new Error('Cannot parse an object with a `__proto__` property');
823
+ }
824
+
734
825
  const n = value[key];
735
826
  object[key] = hydrate(n);
736
827
  }
@@ -773,14 +864,14 @@ function stringify$1(value, reducers) {
773
864
  throw new DevalueError(`Cannot stringify a function`, keys);
774
865
  }
775
866
 
776
- if (indexes.has(thing)) return indexes.get(thing);
777
-
778
867
  if (thing === undefined) return UNDEFINED;
779
868
  if (Number.isNaN(thing)) return NAN;
780
869
  if (thing === Infinity) return POSITIVE_INFINITY;
781
870
  if (thing === -Infinity) return NEGATIVE_INFINITY;
782
871
  if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
783
872
 
873
+ if (indexes.has(thing)) return indexes.get(thing);
874
+
784
875
  const index = p++;
785
876
  indexes.set(thing, index);
786
877
 
@@ -815,6 +906,14 @@ function stringify$1(value, reducers) {
815
906
  str = `["Date","${valid ? thing.toISOString() : ''}"]`;
816
907
  break;
817
908
 
909
+ case 'URL':
910
+ str = `["URL",${stringify_string(thing.toString())}]`;
911
+ break;
912
+
913
+ case 'URLSearchParams':
914
+ str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
915
+ break;
916
+
818
917
  case 'RegExp':
819
918
  const { source, flags } = thing;
820
919
  str = flags
@@ -865,33 +964,54 @@ function stringify$1(value, reducers) {
865
964
  str += ']';
866
965
  break;
867
966
 
868
- case "Int8Array":
869
- case "Uint8Array":
870
- case "Uint8ClampedArray":
871
- case "Int16Array":
872
- case "Uint16Array":
873
- case "Int32Array":
874
- case "Uint32Array":
875
- case "Float32Array":
876
- case "Float64Array":
877
- case "BigInt64Array":
878
- case "BigUint64Array": {
967
+ case 'Int8Array':
968
+ case 'Uint8Array':
969
+ case 'Uint8ClampedArray':
970
+ case 'Int16Array':
971
+ case 'Uint16Array':
972
+ case 'Int32Array':
973
+ case 'Uint32Array':
974
+ case 'Float32Array':
975
+ case 'Float64Array':
976
+ case 'BigInt64Array':
977
+ case 'BigUint64Array': {
879
978
  /** @type {import("./types.js").TypedArray} */
880
979
  const typedArray = thing;
881
- const base64 = encode64(typedArray.buffer);
882
- str = '["' + type + '","' + base64 + '"]';
980
+ str = '["' + type + '",' + flatten(typedArray.buffer);
981
+
982
+ const a = thing.byteOffset;
983
+ const b = a + thing.byteLength;
984
+
985
+ // handle subarrays
986
+ if (a > 0 || b !== typedArray.buffer.byteLength) {
987
+ const m = +/(\d+)/.exec(type)[1] / 8;
988
+ str += `,${a / m},${b / m}`;
989
+ }
990
+
991
+ str += ']';
883
992
  break;
884
993
  }
885
-
886
- case "ArrayBuffer": {
994
+
995
+ case 'ArrayBuffer': {
887
996
  /** @type {ArrayBuffer} */
888
997
  const arraybuffer = thing;
889
998
  const base64 = encode64(arraybuffer);
890
-
999
+
891
1000
  str = `["ArrayBuffer","${base64}"]`;
892
1001
  break;
893
1002
  }
894
-
1003
+
1004
+ case 'Temporal.Duration':
1005
+ case 'Temporal.Instant':
1006
+ case 'Temporal.PlainDate':
1007
+ case 'Temporal.PlainTime':
1008
+ case 'Temporal.PlainDateTime':
1009
+ case 'Temporal.PlainMonthDay':
1010
+ case 'Temporal.PlainYearMonth':
1011
+ case 'Temporal.ZonedDateTime':
1012
+ str = `["${type}",${stringify_string(thing.toString())}]`;
1013
+ break;
1014
+
895
1015
  default:
896
1016
  if (!is_plain_object(thing)) {
897
1017
  throw new DevalueError(
@@ -957,13 +1077,11 @@ function stringify_primitive(thing) {
957
1077
  }
958
1078
 
959
1079
  let public_env = {};
960
- let safe_public_env = {};
1080
+ function set_private_env(environment) {
1081
+ }
961
1082
  function set_public_env(environment) {
962
1083
  public_env = environment;
963
1084
  }
964
- function set_safe_public_env(environment) {
965
- safe_public_env = environment;
966
- }
967
1085
  function effect_update_depth_exceeded() {
968
1086
  {
969
1087
  throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
@@ -989,11 +1107,21 @@ function state_unsafe_mutation() {
989
1107
  throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
990
1108
  }
991
1109
  }
1110
+ function svelte_boundary_reset_onerror() {
1111
+ {
1112
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
1113
+ }
1114
+ }
992
1115
  function hydration_mismatch(location) {
993
1116
  {
994
1117
  console.warn(`https://svelte.dev/e/hydration_mismatch`);
995
1118
  }
996
1119
  }
1120
+ function svelte_boundary_reset_noop() {
1121
+ {
1122
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
1123
+ }
1124
+ }
997
1125
  let hydrating = false;
998
1126
  function set_hydrating(value) {
999
1127
  hydrating = value;
@@ -1012,6 +1140,41 @@ function hydrate_next() {
1012
1140
  /* @__PURE__ */ get_next_sibling(hydrate_node)
1013
1141
  );
1014
1142
  }
1143
+ function next(count = 1) {
1144
+ if (hydrating) {
1145
+ var i = count;
1146
+ var node = hydrate_node;
1147
+ while (i--) {
1148
+ node = /** @type {TemplateNode} */
1149
+ /* @__PURE__ */ get_next_sibling(node);
1150
+ }
1151
+ hydrate_node = node;
1152
+ }
1153
+ }
1154
+ function skip_nodes(remove = true) {
1155
+ var depth = 0;
1156
+ var node = hydrate_node;
1157
+ while (true) {
1158
+ if (node.nodeType === COMMENT_NODE) {
1159
+ var data = (
1160
+ /** @type {Comment} */
1161
+ node.data
1162
+ );
1163
+ if (data === HYDRATION_END) {
1164
+ if (depth === 0) return node;
1165
+ depth -= 1;
1166
+ } else if (data === HYDRATION_START || data === HYDRATION_START_ELSE) {
1167
+ depth += 1;
1168
+ }
1169
+ }
1170
+ var next2 = (
1171
+ /** @type {TemplateNode} */
1172
+ /* @__PURE__ */ get_next_sibling(node)
1173
+ );
1174
+ if (remove) node.remove();
1175
+ node = next2;
1176
+ }
1177
+ }
1015
1178
  let tracing_mode_flag = false;
1016
1179
  let component_context = null;
1017
1180
  function set_component_context(context) {
@@ -1048,6 +1211,26 @@ function pop(component) {
1048
1211
  function is_runes() {
1049
1212
  return true;
1050
1213
  }
1214
+ let micro_tasks = [];
1215
+ function run_micro_tasks() {
1216
+ var tasks = micro_tasks;
1217
+ micro_tasks = [];
1218
+ run_all(tasks);
1219
+ }
1220
+ function queue_micro_task(fn) {
1221
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
1222
+ var tasks = micro_tasks;
1223
+ queueMicrotask(() => {
1224
+ if (tasks === micro_tasks) run_micro_tasks();
1225
+ });
1226
+ }
1227
+ micro_tasks.push(fn);
1228
+ }
1229
+ function flush_tasks() {
1230
+ while (micro_tasks.length > 0) {
1231
+ run_micro_tasks();
1232
+ }
1233
+ }
1051
1234
  const adjustments = /* @__PURE__ */ new WeakMap();
1052
1235
  function handle_error(error) {
1053
1236
  var effect = active_effect;
@@ -1095,96 +1278,10 @@ function apply_adjustments(error) {
1095
1278
  });
1096
1279
  }
1097
1280
  }
1098
- let micro_tasks = [];
1099
- let idle_tasks = [];
1100
- function run_micro_tasks() {
1101
- var tasks2 = micro_tasks;
1102
- micro_tasks = [];
1103
- run_all(tasks2);
1104
- }
1105
- function run_idle_tasks() {
1106
- var tasks2 = idle_tasks;
1107
- idle_tasks = [];
1108
- run_all(tasks2);
1109
- }
1110
- function flush_tasks() {
1111
- if (micro_tasks.length > 0) {
1112
- run_micro_tasks();
1113
- }
1114
- if (idle_tasks.length > 0) {
1115
- run_idle_tasks();
1116
- }
1117
- }
1118
- function destroy_derived_effects(derived) {
1119
- var effects = derived.effects;
1120
- if (effects !== null) {
1121
- derived.effects = null;
1122
- for (var i = 0; i < effects.length; i += 1) {
1123
- destroy_effect(
1124
- /** @type {Effect} */
1125
- effects[i]
1126
- );
1127
- }
1128
- }
1129
- }
1130
- function get_derived_parent_effect(derived) {
1131
- var parent = derived.parent;
1132
- while (parent !== null) {
1133
- if ((parent.f & DERIVED) === 0) {
1134
- return (
1135
- /** @type {Effect} */
1136
- parent
1137
- );
1138
- }
1139
- parent = parent.parent;
1140
- }
1141
- return null;
1142
- }
1143
- function execute_derived(derived) {
1144
- var value;
1145
- var prev_active_effect = active_effect;
1146
- set_active_effect(get_derived_parent_effect(derived));
1147
- {
1148
- try {
1149
- destroy_derived_effects(derived);
1150
- value = update_reaction(derived);
1151
- } finally {
1152
- set_active_effect(prev_active_effect);
1153
- }
1154
- }
1155
- return value;
1156
- }
1157
- function update_derived(derived) {
1158
- var value = execute_derived(derived);
1159
- if (!derived.equals(value)) {
1160
- derived.v = value;
1161
- derived.wv = increment_write_version();
1162
- }
1163
- if (is_destroying_effect) {
1164
- return;
1165
- }
1166
- if (batch_deriveds !== null) {
1167
- batch_deriveds.set(derived, derived.v);
1168
- } else {
1169
- var status = (skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN;
1170
- set_signal_status(derived, status);
1171
- }
1172
- }
1173
1281
  const batches = /* @__PURE__ */ new Set();
1174
1282
  let current_batch = null;
1175
- let batch_deriveds = null;
1283
+ let batch_values = null;
1176
1284
  let effect_pending_updates = /* @__PURE__ */ new Set();
1177
- let tasks = [];
1178
- function dequeue() {
1179
- const task = (
1180
- /** @type {() => void} */
1181
- tasks.shift()
1182
- );
1183
- if (tasks.length > 0) {
1184
- queueMicrotask(dequeue);
1185
- }
1186
- task();
1187
- }
1188
1285
  let queued_root_effects = [];
1189
1286
  let last_scheduled_effect = null;
1190
1287
  let is_flushing = false;
@@ -1219,20 +1316,8 @@ class Batch {
1219
1316
  */
1220
1317
  #deferred = null;
1221
1318
  /**
1222
- * True if an async effect inside this batch resolved and
1223
- * its parent branch was already deleted
1224
- */
1225
- #neutered = false;
1226
- /**
1227
- * Async effects (created inside `async_derived`) encountered during processing.
1228
- * These run after the rest of the batch has updated, since they should
1229
- * always have the latest values
1230
- * @type {Effect[]}
1231
- */
1232
- #async_effects = [];
1233
- /**
1234
- * The same as `#async_effects`, but for effects inside a newly-created
1235
- * `<svelte:boundary>` — these do not prevent the batch from committing
1319
+ * Async effects inside a newly-created `<svelte:boundary>`
1320
+ * these do not prevent the batch from committing
1236
1321
  * @type {Effect[]}
1237
1322
  */
1238
1323
  #boundary_async_effects = [];
@@ -1275,28 +1360,12 @@ class Batch {
1275
1360
  */
1276
1361
  process(root_effects) {
1277
1362
  queued_root_effects = [];
1278
- var current_values = null;
1279
- if (batches.size > 1) {
1280
- current_values = /* @__PURE__ */ new Map();
1281
- batch_deriveds = /* @__PURE__ */ new Map();
1282
- for (const [source2, current] of this.current) {
1283
- current_values.set(source2, { v: source2.v, wv: source2.wv });
1284
- source2.v = current;
1285
- }
1286
- for (const batch of batches) {
1287
- if (batch === this) continue;
1288
- for (const [source2, previous] of batch.#previous) {
1289
- if (!current_values.has(source2)) {
1290
- current_values.set(source2, { v: source2.v, wv: source2.wv });
1291
- source2.v = previous;
1292
- }
1293
- }
1294
- }
1295
- }
1363
+ this.apply();
1296
1364
  for (const root2 of root_effects) {
1297
1365
  this.#traverse_effect_tree(root2);
1298
1366
  }
1299
- if (this.#async_effects.length === 0 && this.#pending === 0) {
1367
+ if (this.#pending === 0) {
1368
+ var previous_batch_sources = batch_values;
1300
1369
  this.#commit();
1301
1370
  var render_effects = this.#render_effects;
1302
1371
  var effects = this.#effects;
@@ -1304,34 +1373,19 @@ class Batch {
1304
1373
  this.#effects = [];
1305
1374
  this.#block_effects = [];
1306
1375
  current_batch = null;
1376
+ batch_values = previous_batch_sources;
1307
1377
  flush_queued_effects(render_effects);
1308
1378
  flush_queued_effects(effects);
1309
- if (current_batch === null) {
1310
- current_batch = this;
1311
- } else {
1312
- batches.delete(this);
1313
- }
1314
1379
  this.#deferred?.resolve();
1315
1380
  } else {
1316
1381
  this.#defer_effects(this.#render_effects);
1317
1382
  this.#defer_effects(this.#effects);
1318
1383
  this.#defer_effects(this.#block_effects);
1319
1384
  }
1320
- if (current_values) {
1321
- for (const [source2, { v, wv }] of current_values) {
1322
- if (source2.wv <= wv) {
1323
- source2.v = v;
1324
- }
1325
- }
1326
- batch_deriveds = null;
1327
- }
1328
- for (const effect of this.#async_effects) {
1329
- update_effect(effect);
1330
- }
1385
+ batch_values = null;
1331
1386
  for (const effect of this.#boundary_async_effects) {
1332
1387
  update_effect(effect);
1333
1388
  }
1334
- this.#async_effects = [];
1335
1389
  this.#boundary_async_effects = [];
1336
1390
  }
1337
1391
  /**
@@ -1343,19 +1397,18 @@ class Batch {
1343
1397
  root2.f ^= CLEAN;
1344
1398
  var effect = root2.first;
1345
1399
  while (effect !== null) {
1346
- var flags = effect.f;
1347
- var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
1348
- var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
1349
- var skip = is_skippable_branch || (flags & INERT) !== 0 || this.skipped_effects.has(effect);
1400
+ var flags2 = effect.f;
1401
+ var is_branch = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
1402
+ var is_skippable_branch = is_branch && (flags2 & CLEAN) !== 0;
1403
+ var skip = is_skippable_branch || (flags2 & INERT) !== 0 || this.skipped_effects.has(effect);
1350
1404
  if (!skip && effect.fn !== null) {
1351
1405
  if (is_branch) {
1352
1406
  effect.f ^= CLEAN;
1353
- } else if ((flags & EFFECT) !== 0) {
1407
+ } else if ((flags2 & EFFECT) !== 0) {
1354
1408
  this.#effects.push(effect);
1355
- } else if ((flags & CLEAN) === 0) {
1356
- if ((flags & ASYNC) !== 0) {
1357
- var effects = effect.b?.pending ? this.#boundary_async_effects : this.#async_effects;
1358
- effects.push(effect);
1409
+ } else if ((flags2 & CLEAN) === 0) {
1410
+ if ((flags2 & ASYNC) !== 0 && effect.b?.is_pending()) {
1411
+ this.#boundary_async_effects.push(effect);
1359
1412
  } else if (is_dirty(effect)) {
1360
1413
  if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
1361
1414
  update_effect(effect);
@@ -1397,68 +1450,98 @@ class Batch {
1397
1450
  this.#previous.set(source2, value);
1398
1451
  }
1399
1452
  this.current.set(source2, source2.v);
1453
+ batch_values?.set(source2, source2.v);
1400
1454
  }
1401
1455
  activate() {
1402
1456
  current_batch = this;
1403
1457
  }
1404
1458
  deactivate() {
1405
1459
  current_batch = null;
1406
- for (const update of effect_pending_updates) {
1407
- effect_pending_updates.delete(update);
1408
- update();
1409
- if (current_batch !== null) {
1410
- break;
1411
- }
1412
- }
1413
- }
1414
- neuter() {
1415
- this.#neutered = true;
1460
+ batch_values = null;
1416
1461
  }
1417
1462
  flush() {
1418
1463
  if (queued_root_effects.length > 0) {
1464
+ this.activate();
1419
1465
  flush_effects();
1420
- } else {
1466
+ if (current_batch !== null && current_batch !== this) {
1467
+ return;
1468
+ }
1469
+ } else if (this.#pending === 0) {
1421
1470
  this.#commit();
1422
1471
  }
1423
- if (current_batch !== this) {
1424
- return;
1425
- }
1426
- if (this.#pending === 0) {
1427
- batches.delete(this);
1428
- }
1429
1472
  this.deactivate();
1473
+ for (const update of effect_pending_updates) {
1474
+ effect_pending_updates.delete(update);
1475
+ update();
1476
+ if (current_batch !== null) {
1477
+ break;
1478
+ }
1479
+ }
1430
1480
  }
1431
1481
  /**
1432
1482
  * Append and remove branches to/from the DOM
1433
1483
  */
1434
1484
  #commit() {
1435
- if (!this.#neutered) {
1436
- for (const fn of this.#callbacks) {
1437
- fn();
1438
- }
1485
+ for (const fn of this.#callbacks) {
1486
+ fn();
1439
1487
  }
1440
1488
  this.#callbacks.clear();
1489
+ if (batches.size > 1) {
1490
+ this.#previous.clear();
1491
+ let is_earlier = true;
1492
+ for (const batch of batches) {
1493
+ if (batch === this) {
1494
+ is_earlier = false;
1495
+ continue;
1496
+ }
1497
+ const sources = [];
1498
+ for (const [source2, value] of this.current) {
1499
+ if (batch.current.has(source2)) {
1500
+ if (is_earlier && value !== batch.current.get(source2)) {
1501
+ batch.current.set(source2, value);
1502
+ } else {
1503
+ continue;
1504
+ }
1505
+ }
1506
+ sources.push(source2);
1507
+ }
1508
+ if (sources.length === 0) {
1509
+ continue;
1510
+ }
1511
+ const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
1512
+ if (others.length > 0) {
1513
+ for (const source2 of sources) {
1514
+ mark_effects(source2, others);
1515
+ }
1516
+ if (queued_root_effects.length > 0) {
1517
+ current_batch = batch;
1518
+ batch.apply();
1519
+ for (const root2 of queued_root_effects) {
1520
+ batch.#traverse_effect_tree(root2);
1521
+ }
1522
+ queued_root_effects = [];
1523
+ batch.deactivate();
1524
+ }
1525
+ }
1526
+ }
1527
+ current_batch = null;
1528
+ }
1529
+ batches.delete(this);
1441
1530
  }
1442
1531
  increment() {
1443
1532
  this.#pending += 1;
1444
1533
  }
1445
1534
  decrement() {
1446
1535
  this.#pending -= 1;
1447
- if (this.#pending === 0) {
1448
- for (const e of this.#dirty_effects) {
1449
- set_signal_status(e, DIRTY);
1450
- schedule_effect(e);
1451
- }
1452
- for (const e of this.#maybe_dirty_effects) {
1453
- set_signal_status(e, MAYBE_DIRTY);
1454
- schedule_effect(e);
1455
- }
1456
- this.#render_effects = [];
1457
- this.#effects = [];
1458
- this.flush();
1459
- } else {
1460
- this.deactivate();
1536
+ for (const e of this.#dirty_effects) {
1537
+ set_signal_status(e, DIRTY);
1538
+ schedule_effect(e);
1461
1539
  }
1540
+ for (const e of this.#maybe_dirty_effects) {
1541
+ set_signal_status(e, MAYBE_DIRTY);
1542
+ schedule_effect(e);
1543
+ }
1544
+ this.flush();
1462
1545
  }
1463
1546
  /** @param {() => void} fn */
1464
1547
  add_callback(fn) {
@@ -1484,10 +1567,10 @@ class Batch {
1484
1567
  }
1485
1568
  /** @param {() => void} task */
1486
1569
  static enqueue(task) {
1487
- if (tasks.length === 0) {
1488
- queueMicrotask(dequeue);
1489
- }
1490
- tasks.unshift(task);
1570
+ queue_micro_task(task);
1571
+ }
1572
+ apply() {
1573
+ return;
1491
1574
  }
1492
1575
  }
1493
1576
  function flushSync(fn) {
@@ -1560,7 +1643,7 @@ function flush_queued_effects(effects) {
1560
1643
  effect.fn = null;
1561
1644
  }
1562
1645
  }
1563
- if (eager_block_effects.length > 0) {
1646
+ if (eager_block_effects?.length > 0) {
1564
1647
  old_values.clear();
1565
1648
  for (const e of eager_block_effects) {
1566
1649
  update_effect(e);
@@ -1571,36 +1654,476 @@ function flush_queued_effects(effects) {
1571
1654
  }
1572
1655
  eager_block_effects = null;
1573
1656
  }
1657
+ function mark_effects(value, sources) {
1658
+ if (value.reactions !== null) {
1659
+ for (const reaction of value.reactions) {
1660
+ const flags2 = reaction.f;
1661
+ if ((flags2 & DERIVED) !== 0) {
1662
+ mark_effects(
1663
+ /** @type {Derived} */
1664
+ reaction,
1665
+ sources
1666
+ );
1667
+ } else if ((flags2 & (ASYNC | BLOCK_EFFECT)) !== 0 && depends_on(reaction, sources)) {
1668
+ set_signal_status(reaction, DIRTY);
1669
+ schedule_effect(
1670
+ /** @type {Effect} */
1671
+ reaction
1672
+ );
1673
+ }
1674
+ }
1675
+ }
1676
+ }
1677
+ function depends_on(reaction, sources) {
1678
+ if (reaction.deps !== null) {
1679
+ for (const dep of reaction.deps) {
1680
+ if (sources.includes(dep)) {
1681
+ return true;
1682
+ }
1683
+ if ((dep.f & DERIVED) !== 0 && depends_on(
1684
+ /** @type {Derived} */
1685
+ dep,
1686
+ sources
1687
+ )) {
1688
+ return true;
1689
+ }
1690
+ }
1691
+ }
1692
+ return false;
1693
+ }
1574
1694
  function schedule_effect(signal) {
1575
1695
  var effect = last_scheduled_effect = signal;
1576
1696
  while (effect.parent !== null) {
1577
1697
  effect = effect.parent;
1578
- var flags = effect.f;
1579
- if (is_flushing && effect === active_effect && (flags & BLOCK_EFFECT) !== 0) {
1698
+ var flags2 = effect.f;
1699
+ if (is_flushing && effect === active_effect && (flags2 & BLOCK_EFFECT) !== 0) {
1580
1700
  return;
1581
1701
  }
1582
- if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
1583
- if ((flags & CLEAN) === 0) return;
1702
+ if ((flags2 & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
1703
+ if ((flags2 & CLEAN) === 0) return;
1584
1704
  effect.f ^= CLEAN;
1585
1705
  }
1586
1706
  }
1587
1707
  queued_root_effects.push(effect);
1588
1708
  }
1589
- const old_values = /* @__PURE__ */ new Map();
1590
- function source(v, stack) {
1591
- var signal = {
1592
- f: 0,
1593
- // TODO ideally we could skip this altogether, but it causes type errors
1594
- v,
1595
- reactions: null,
1596
- equals,
1597
- rv: 0,
1598
- wv: 0
1599
- };
1600
- return signal;
1601
- }
1602
- // @__NO_SIDE_EFFECTS__
1603
- function state(v, stack) {
1709
+ function createSubscriber(start) {
1710
+ let subscribers = 0;
1711
+ let version = source(0);
1712
+ let stop;
1713
+ return () => {
1714
+ if (effect_tracking()) {
1715
+ get(version);
1716
+ render_effect(() => {
1717
+ if (subscribers === 0) {
1718
+ stop = untrack(() => start(() => increment(version)));
1719
+ }
1720
+ subscribers += 1;
1721
+ return () => {
1722
+ queue_micro_task(() => {
1723
+ subscribers -= 1;
1724
+ if (subscribers === 0) {
1725
+ stop?.();
1726
+ stop = void 0;
1727
+ increment(version);
1728
+ }
1729
+ });
1730
+ };
1731
+ });
1732
+ }
1733
+ };
1734
+ }
1735
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT;
1736
+ function boundary(node, props, children) {
1737
+ new Boundary(node, props, children);
1738
+ }
1739
+ class Boundary {
1740
+ /** @type {Boundary | null} */
1741
+ parent;
1742
+ #pending = false;
1743
+ /** @type {TemplateNode} */
1744
+ #anchor;
1745
+ /** @type {TemplateNode | null} */
1746
+ #hydrate_open = hydrating ? hydrate_node : null;
1747
+ /** @type {BoundaryProps} */
1748
+ #props;
1749
+ /** @type {((anchor: Node) => void)} */
1750
+ #children;
1751
+ /** @type {Effect} */
1752
+ #effect;
1753
+ /** @type {Effect | null} */
1754
+ #main_effect = null;
1755
+ /** @type {Effect | null} */
1756
+ #pending_effect = null;
1757
+ /** @type {Effect | null} */
1758
+ #failed_effect = null;
1759
+ /** @type {DocumentFragment | null} */
1760
+ #offscreen_fragment = null;
1761
+ #local_pending_count = 0;
1762
+ #pending_count = 0;
1763
+ #is_creating_fallback = false;
1764
+ /**
1765
+ * A source containing the number of pending async deriveds/expressions.
1766
+ * Only created if `$effect.pending()` is used inside the boundary,
1767
+ * otherwise updating the source results in needless `Batch.ensure()`
1768
+ * calls followed by no-op flushes
1769
+ * @type {Source<number> | null}
1770
+ */
1771
+ #effect_pending = null;
1772
+ #effect_pending_update = () => {
1773
+ if (this.#effect_pending) {
1774
+ internal_set(this.#effect_pending, this.#local_pending_count);
1775
+ }
1776
+ };
1777
+ #effect_pending_subscriber = createSubscriber(() => {
1778
+ this.#effect_pending = source(this.#local_pending_count);
1779
+ return () => {
1780
+ this.#effect_pending = null;
1781
+ };
1782
+ });
1783
+ /**
1784
+ * @param {TemplateNode} node
1785
+ * @param {BoundaryProps} props
1786
+ * @param {((anchor: Node) => void)} children
1787
+ */
1788
+ constructor(node, props, children) {
1789
+ this.#anchor = node;
1790
+ this.#props = props;
1791
+ this.#children = children;
1792
+ this.parent = /** @type {Effect} */
1793
+ active_effect.b;
1794
+ this.#pending = !!this.#props.pending;
1795
+ this.#effect = block(() => {
1796
+ active_effect.b = this;
1797
+ if (hydrating) {
1798
+ const comment = this.#hydrate_open;
1799
+ hydrate_next();
1800
+ const server_rendered_pending = (
1801
+ /** @type {Comment} */
1802
+ comment.nodeType === COMMENT_NODE && /** @type {Comment} */
1803
+ comment.data === HYDRATION_START_ELSE
1804
+ );
1805
+ if (server_rendered_pending) {
1806
+ this.#hydrate_pending_content();
1807
+ } else {
1808
+ this.#hydrate_resolved_content();
1809
+ }
1810
+ } else {
1811
+ try {
1812
+ this.#main_effect = branch(() => children(this.#anchor));
1813
+ } catch (error) {
1814
+ this.error(error);
1815
+ }
1816
+ if (this.#pending_count > 0) {
1817
+ this.#show_pending_snippet();
1818
+ } else {
1819
+ this.#pending = false;
1820
+ }
1821
+ }
1822
+ }, flags);
1823
+ if (hydrating) {
1824
+ this.#anchor = hydrate_node;
1825
+ }
1826
+ }
1827
+ #hydrate_resolved_content() {
1828
+ try {
1829
+ this.#main_effect = branch(() => this.#children(this.#anchor));
1830
+ } catch (error) {
1831
+ this.error(error);
1832
+ }
1833
+ this.#pending = false;
1834
+ }
1835
+ #hydrate_pending_content() {
1836
+ const pending = this.#props.pending;
1837
+ if (!pending) {
1838
+ return;
1839
+ }
1840
+ this.#pending_effect = branch(() => pending(this.#anchor));
1841
+ Batch.enqueue(() => {
1842
+ this.#main_effect = this.#run(() => {
1843
+ Batch.ensure();
1844
+ return branch(() => this.#children(this.#anchor));
1845
+ });
1846
+ if (this.#pending_count > 0) {
1847
+ this.#show_pending_snippet();
1848
+ } else {
1849
+ pause_effect(
1850
+ /** @type {Effect} */
1851
+ this.#pending_effect,
1852
+ () => {
1853
+ this.#pending_effect = null;
1854
+ }
1855
+ );
1856
+ this.#pending = false;
1857
+ }
1858
+ });
1859
+ }
1860
+ /**
1861
+ * Returns `true` if the effect exists inside a boundary whose pending snippet is shown
1862
+ * @returns {boolean}
1863
+ */
1864
+ is_pending() {
1865
+ return this.#pending || !!this.parent && this.parent.is_pending();
1866
+ }
1867
+ has_pending_snippet() {
1868
+ return !!this.#props.pending;
1869
+ }
1870
+ /**
1871
+ * @param {() => Effect | null} fn
1872
+ */
1873
+ #run(fn) {
1874
+ var previous_effect = active_effect;
1875
+ var previous_reaction = active_reaction;
1876
+ var previous_ctx = component_context;
1877
+ set_active_effect(this.#effect);
1878
+ set_active_reaction(this.#effect);
1879
+ set_component_context(this.#effect.ctx);
1880
+ try {
1881
+ return fn();
1882
+ } catch (e) {
1883
+ handle_error(e);
1884
+ return null;
1885
+ } finally {
1886
+ set_active_effect(previous_effect);
1887
+ set_active_reaction(previous_reaction);
1888
+ set_component_context(previous_ctx);
1889
+ }
1890
+ }
1891
+ #show_pending_snippet() {
1892
+ const pending = (
1893
+ /** @type {(anchor: Node) => void} */
1894
+ this.#props.pending
1895
+ );
1896
+ if (this.#main_effect !== null) {
1897
+ this.#offscreen_fragment = document.createDocumentFragment();
1898
+ move_effect(this.#main_effect, this.#offscreen_fragment);
1899
+ }
1900
+ if (this.#pending_effect === null) {
1901
+ this.#pending_effect = branch(() => pending(this.#anchor));
1902
+ }
1903
+ }
1904
+ /**
1905
+ * Updates the pending count associated with the currently visible pending snippet,
1906
+ * if any, such that we can replace the snippet with content once work is done
1907
+ * @param {1 | -1} d
1908
+ */
1909
+ #update_pending_count(d) {
1910
+ if (!this.has_pending_snippet()) {
1911
+ if (this.parent) {
1912
+ this.parent.#update_pending_count(d);
1913
+ }
1914
+ return;
1915
+ }
1916
+ this.#pending_count += d;
1917
+ if (this.#pending_count === 0) {
1918
+ this.#pending = false;
1919
+ if (this.#pending_effect) {
1920
+ pause_effect(this.#pending_effect, () => {
1921
+ this.#pending_effect = null;
1922
+ });
1923
+ }
1924
+ if (this.#offscreen_fragment) {
1925
+ this.#anchor.before(this.#offscreen_fragment);
1926
+ this.#offscreen_fragment = null;
1927
+ }
1928
+ queue_micro_task(() => {
1929
+ Batch.ensure().flush();
1930
+ });
1931
+ }
1932
+ }
1933
+ /**
1934
+ * Update the source that powers `$effect.pending()` inside this boundary,
1935
+ * and controls when the current `pending` snippet (if any) is removed.
1936
+ * Do not call from inside the class
1937
+ * @param {1 | -1} d
1938
+ */
1939
+ update_pending_count(d) {
1940
+ this.#update_pending_count(d);
1941
+ this.#local_pending_count += d;
1942
+ effect_pending_updates.add(this.#effect_pending_update);
1943
+ }
1944
+ get_effect_pending() {
1945
+ this.#effect_pending_subscriber();
1946
+ return get(
1947
+ /** @type {Source<number>} */
1948
+ this.#effect_pending
1949
+ );
1950
+ }
1951
+ /** @param {unknown} error */
1952
+ error(error) {
1953
+ var onerror = this.#props.onerror;
1954
+ let failed = this.#props.failed;
1955
+ if (this.#is_creating_fallback || !onerror && !failed) {
1956
+ throw error;
1957
+ }
1958
+ if (this.#main_effect) {
1959
+ destroy_effect(this.#main_effect);
1960
+ this.#main_effect = null;
1961
+ }
1962
+ if (this.#pending_effect) {
1963
+ destroy_effect(this.#pending_effect);
1964
+ this.#pending_effect = null;
1965
+ }
1966
+ if (this.#failed_effect) {
1967
+ destroy_effect(this.#failed_effect);
1968
+ this.#failed_effect = null;
1969
+ }
1970
+ if (hydrating) {
1971
+ set_hydrate_node(
1972
+ /** @type {TemplateNode} */
1973
+ this.#hydrate_open
1974
+ );
1975
+ next();
1976
+ set_hydrate_node(skip_nodes());
1977
+ }
1978
+ var did_reset = false;
1979
+ var calling_on_error = false;
1980
+ const reset = () => {
1981
+ if (did_reset) {
1982
+ svelte_boundary_reset_noop();
1983
+ return;
1984
+ }
1985
+ did_reset = true;
1986
+ if (calling_on_error) {
1987
+ svelte_boundary_reset_onerror();
1988
+ }
1989
+ Batch.ensure();
1990
+ this.#local_pending_count = 0;
1991
+ if (this.#failed_effect !== null) {
1992
+ pause_effect(this.#failed_effect, () => {
1993
+ this.#failed_effect = null;
1994
+ });
1995
+ }
1996
+ this.#pending = this.has_pending_snippet();
1997
+ this.#main_effect = this.#run(() => {
1998
+ this.#is_creating_fallback = false;
1999
+ return branch(() => this.#children(this.#anchor));
2000
+ });
2001
+ if (this.#pending_count > 0) {
2002
+ this.#show_pending_snippet();
2003
+ } else {
2004
+ this.#pending = false;
2005
+ }
2006
+ };
2007
+ var previous_reaction = active_reaction;
2008
+ try {
2009
+ set_active_reaction(null);
2010
+ calling_on_error = true;
2011
+ onerror?.(error, reset);
2012
+ calling_on_error = false;
2013
+ } catch (error2) {
2014
+ invoke_error_boundary(error2, this.#effect && this.#effect.parent);
2015
+ } finally {
2016
+ set_active_reaction(previous_reaction);
2017
+ }
2018
+ if (failed) {
2019
+ queue_micro_task(() => {
2020
+ this.#failed_effect = this.#run(() => {
2021
+ this.#is_creating_fallback = true;
2022
+ try {
2023
+ return branch(() => {
2024
+ failed(
2025
+ this.#anchor,
2026
+ () => error,
2027
+ () => reset
2028
+ );
2029
+ });
2030
+ } catch (error2) {
2031
+ invoke_error_boundary(
2032
+ error2,
2033
+ /** @type {Effect} */
2034
+ this.#effect.parent
2035
+ );
2036
+ return null;
2037
+ } finally {
2038
+ this.#is_creating_fallback = false;
2039
+ }
2040
+ });
2041
+ });
2042
+ }
2043
+ }
2044
+ }
2045
+ function move_effect(effect, fragment) {
2046
+ var node = effect.nodes_start;
2047
+ var end = effect.nodes_end;
2048
+ while (node !== null) {
2049
+ var next2 = node === end ? null : (
2050
+ /** @type {TemplateNode} */
2051
+ /* @__PURE__ */ get_next_sibling(node)
2052
+ );
2053
+ fragment.append(node);
2054
+ node = next2;
2055
+ }
2056
+ }
2057
+ function destroy_derived_effects(derived) {
2058
+ var effects = derived.effects;
2059
+ if (effects !== null) {
2060
+ derived.effects = null;
2061
+ for (var i = 0; i < effects.length; i += 1) {
2062
+ destroy_effect(
2063
+ /** @type {Effect} */
2064
+ effects[i]
2065
+ );
2066
+ }
2067
+ }
2068
+ }
2069
+ function get_derived_parent_effect(derived) {
2070
+ var parent = derived.parent;
2071
+ while (parent !== null) {
2072
+ if ((parent.f & DERIVED) === 0) {
2073
+ return (
2074
+ /** @type {Effect} */
2075
+ parent
2076
+ );
2077
+ }
2078
+ parent = parent.parent;
2079
+ }
2080
+ return null;
2081
+ }
2082
+ function execute_derived(derived) {
2083
+ var value;
2084
+ var prev_active_effect = active_effect;
2085
+ set_active_effect(get_derived_parent_effect(derived));
2086
+ {
2087
+ try {
2088
+ destroy_derived_effects(derived);
2089
+ value = update_reaction(derived);
2090
+ } finally {
2091
+ set_active_effect(prev_active_effect);
2092
+ }
2093
+ }
2094
+ return value;
2095
+ }
2096
+ function update_derived(derived) {
2097
+ var value = execute_derived(derived);
2098
+ if (!derived.equals(value)) {
2099
+ derived.v = value;
2100
+ derived.wv = increment_write_version();
2101
+ }
2102
+ if (is_destroying_effect) {
2103
+ return;
2104
+ }
2105
+ if (batch_values !== null) {
2106
+ batch_values.set(derived, derived.v);
2107
+ } else {
2108
+ var status = (skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN;
2109
+ set_signal_status(derived, status);
2110
+ }
2111
+ }
2112
+ const old_values = /* @__PURE__ */ new Map();
2113
+ function source(v, stack) {
2114
+ var signal = {
2115
+ f: 0,
2116
+ // TODO ideally we could skip this altogether, but it causes type errors
2117
+ v,
2118
+ reactions: null,
2119
+ equals,
2120
+ rv: 0,
2121
+ wv: 0
2122
+ };
2123
+ return signal;
2124
+ }
2125
+ // @__NO_SIDE_EFFECTS__
2126
+ function state(v, stack) {
1604
2127
  const s = source(v);
1605
2128
  push_reaction_value(s);
1606
2129
  return s;
@@ -1663,19 +2186,19 @@ function mark_reactions(signal, status) {
1663
2186
  var length = reactions.length;
1664
2187
  for (var i = 0; i < length; i++) {
1665
2188
  var reaction = reactions[i];
1666
- var flags = reaction.f;
1667
- var not_dirty = (flags & DIRTY) === 0;
2189
+ var flags2 = reaction.f;
2190
+ var not_dirty = (flags2 & DIRTY) === 0;
1668
2191
  if (not_dirty) {
1669
2192
  set_signal_status(reaction, status);
1670
2193
  }
1671
- if ((flags & DERIVED) !== 0) {
2194
+ if ((flags2 & DERIVED) !== 0) {
1672
2195
  mark_reactions(
1673
2196
  /** @type {Derived} */
1674
2197
  reaction,
1675
2198
  MAYBE_DIRTY
1676
2199
  );
1677
2200
  } else if (not_dirty) {
1678
- if ((flags & BLOCK_EFFECT) !== 0) {
2201
+ if ((flags2 & BLOCK_EFFECT) !== 0) {
1679
2202
  if (eager_block_effects !== null) {
1680
2203
  eager_block_effects.push(
1681
2204
  /** @type {Effect} */
@@ -1967,34 +2490,44 @@ function create_effect(type, fn, sync, push2 = true) {
1967
2490
  try {
1968
2491
  update_effect(effect);
1969
2492
  effect.f |= EFFECT_RAN;
1970
- } catch (e) {
2493
+ } catch (e2) {
1971
2494
  destroy_effect(effect);
1972
- throw e;
2495
+ throw e2;
1973
2496
  }
1974
2497
  } else if (fn !== null) {
1975
2498
  schedule_effect(effect);
1976
2499
  }
1977
- var inert = sync && effect.deps === null && effect.first === null && effect.nodes_start === null && effect.teardown === null && (effect.f & EFFECT_PRESERVED) === 0;
1978
- if (!inert && push2) {
1979
- if (parent !== null) {
1980
- push_effect(effect, parent);
2500
+ if (push2) {
2501
+ var e = effect;
2502
+ if (sync && e.deps === null && e.teardown === null && e.nodes_start === null && e.first === e.last && // either `null`, or a singular child
2503
+ (e.f & EFFECT_PRESERVED) === 0) {
2504
+ e = e.first;
1981
2505
  }
1982
- if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
1983
- var derived = (
1984
- /** @type {Derived} */
1985
- active_reaction
1986
- );
1987
- (derived.effects ??= []).push(effect);
2506
+ if (e !== null) {
2507
+ e.parent = parent;
2508
+ if (parent !== null) {
2509
+ push_effect(e, parent);
2510
+ }
2511
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
2512
+ var derived = (
2513
+ /** @type {Derived} */
2514
+ active_reaction
2515
+ );
2516
+ (derived.effects ??= []).push(e);
2517
+ }
1988
2518
  }
1989
2519
  }
1990
2520
  return effect;
1991
2521
  }
2522
+ function effect_tracking() {
2523
+ return active_reaction !== null && !untracking;
2524
+ }
1992
2525
  function create_user_effect(fn) {
1993
2526
  return create_effect(EFFECT | USER_EFFECT, fn, false);
1994
2527
  }
1995
2528
  function component_root(fn) {
1996
2529
  Batch.ensure();
1997
- const effect = create_effect(ROOT_EFFECT, fn, true);
2530
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn, true);
1998
2531
  return (options2 = {}) => {
1999
2532
  return new Promise((fulfil) => {
2000
2533
  if (options2.outro) {
@@ -2009,8 +2542,15 @@ function component_root(fn) {
2009
2542
  });
2010
2543
  };
2011
2544
  }
2545
+ function render_effect(fn, flags2 = 0) {
2546
+ return create_effect(RENDER_EFFECT | flags2, fn, true);
2547
+ }
2548
+ function block(fn, flags2 = 0) {
2549
+ var effect = create_effect(BLOCK_EFFECT | flags2, fn, true);
2550
+ return effect;
2551
+ }
2012
2552
  function branch(fn, push2 = true) {
2013
- return create_effect(BRANCH_EFFECT, fn, true, push2);
2553
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn, true, push2);
2014
2554
  }
2015
2555
  function execute_effect_teardown(effect) {
2016
2556
  var teardown = effect.teardown;
@@ -2037,23 +2577,23 @@ function destroy_effect_children(signal, remove_dom = false) {
2037
2577
  controller.abort(STALE_REACTION);
2038
2578
  });
2039
2579
  }
2040
- var next = effect.next;
2580
+ var next2 = effect.next;
2041
2581
  if ((effect.f & ROOT_EFFECT) !== 0) {
2042
2582
  effect.parent = null;
2043
2583
  } else {
2044
2584
  destroy_effect(effect, remove_dom);
2045
2585
  }
2046
- effect = next;
2586
+ effect = next2;
2047
2587
  }
2048
2588
  }
2049
2589
  function destroy_block_effect_children(signal) {
2050
2590
  var effect = signal.first;
2051
2591
  while (effect !== null) {
2052
- var next = effect.next;
2592
+ var next2 = effect.next;
2053
2593
  if ((effect.f & BRANCH_EFFECT) === 0) {
2054
2594
  destroy_effect(effect);
2055
2595
  }
2056
- effect = next;
2596
+ effect = next2;
2057
2597
  }
2058
2598
  }
2059
2599
  function destroy_effect(effect, remove_dom = true) {
@@ -2084,22 +2624,22 @@ function destroy_effect(effect, remove_dom = true) {
2084
2624
  }
2085
2625
  function remove_effect_dom(node, end) {
2086
2626
  while (node !== null) {
2087
- var next = node === end ? null : (
2627
+ var next2 = node === end ? null : (
2088
2628
  /** @type {TemplateNode} */
2089
2629
  /* @__PURE__ */ get_next_sibling(node)
2090
2630
  );
2091
2631
  node.remove();
2092
- node = next;
2632
+ node = next2;
2093
2633
  }
2094
2634
  }
2095
2635
  function unlink_effect(effect) {
2096
2636
  var parent = effect.parent;
2097
2637
  var prev = effect.prev;
2098
- var next = effect.next;
2099
- if (prev !== null) prev.next = next;
2100
- if (next !== null) next.prev = prev;
2638
+ var next2 = effect.next;
2639
+ if (prev !== null) prev.next = next2;
2640
+ if (next2 !== null) next2.prev = prev;
2101
2641
  if (parent !== null) {
2102
- if (parent.first === effect) parent.first = next;
2642
+ if (parent.first === effect) parent.first = next2;
2103
2643
  if (parent.last === effect) parent.last = prev;
2104
2644
  }
2105
2645
  }
@@ -2184,17 +2724,17 @@ function increment_write_version() {
2184
2724
  return ++write_version;
2185
2725
  }
2186
2726
  function is_dirty(reaction) {
2187
- var flags = reaction.f;
2188
- if ((flags & DIRTY) !== 0) {
2727
+ var flags2 = reaction.f;
2728
+ if ((flags2 & DIRTY) !== 0) {
2189
2729
  return true;
2190
2730
  }
2191
- if ((flags & MAYBE_DIRTY) !== 0) {
2731
+ if ((flags2 & MAYBE_DIRTY) !== 0) {
2192
2732
  var dependencies = reaction.deps;
2193
- var is_unowned = (flags & UNOWNED) !== 0;
2733
+ var is_unowned = (flags2 & UNOWNED) !== 0;
2194
2734
  if (dependencies !== null) {
2195
2735
  var i;
2196
2736
  var dependency;
2197
- var is_disconnected = (flags & DISCONNECTED) !== 0;
2737
+ var is_disconnected = (flags2 & DISCONNECTED) !== 0;
2198
2738
  var is_unowned_connected = is_unowned && active_effect !== null && !skip_reaction;
2199
2739
  var length = dependencies.length;
2200
2740
  if ((is_disconnected || is_unowned_connected) && (active_effect === null || (active_effect.f & DESTROYED) === 0)) {
@@ -2276,13 +2816,13 @@ function update_reaction(reaction) {
2276
2816
  var previous_component_context = component_context;
2277
2817
  var previous_untracking = untracking;
2278
2818
  var previous_update_version = update_version;
2279
- var flags = reaction.f;
2819
+ var flags2 = reaction.f;
2280
2820
  new_deps = /** @type {null | Value[]} */
2281
2821
  null;
2282
2822
  skipped_deps = 0;
2283
2823
  untracked_writes = null;
2284
- skip_reaction = (flags & UNOWNED) !== 0 && (untracking || !is_updating_effect || active_reaction === null);
2285
- active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2824
+ skip_reaction = (flags2 & UNOWNED) !== 0 && (untracking || !is_updating_effect || active_reaction === null);
2825
+ active_reaction = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2286
2826
  current_sources = null;
2287
2827
  set_component_context(reaction.ctx);
2288
2828
  untracking = false;
@@ -2313,7 +2853,7 @@ function update_reaction(reaction) {
2313
2853
  reaction.deps = deps = new_deps;
2314
2854
  }
2315
2855
  if (!skip_reaction || // Deriveds that already have reactions can cleanup, so we still add them as reactions
2316
- (flags & DERIVED) !== 0 && /** @type {import('#client').Derived} */
2856
+ (flags2 & DERIVED) !== 0 && /** @type {import('#client').Derived} */
2317
2857
  reaction.reactions !== null) {
2318
2858
  for (i = skipped_deps; i < deps.length; i++) {
2319
2859
  (deps[i].reactions ??= []).push(reaction);
@@ -2404,8 +2944,8 @@ function remove_reactions(signal, start_index) {
2404
2944
  }
2405
2945
  }
2406
2946
  function update_effect(effect) {
2407
- var flags = effect.f;
2408
- if ((flags & DESTROYED) !== 0) {
2947
+ var flags2 = effect.f;
2948
+ if ((flags2 & DESTROYED) !== 0) {
2409
2949
  return;
2410
2950
  }
2411
2951
  set_signal_status(effect, CLEAN);
@@ -2414,7 +2954,7 @@ function update_effect(effect) {
2414
2954
  active_effect = effect;
2415
2955
  is_updating_effect = true;
2416
2956
  try {
2417
- if ((flags & BLOCK_EFFECT) !== 0) {
2957
+ if ((flags2 & BLOCK_EFFECT) !== 0) {
2418
2958
  destroy_block_effect_children(effect);
2419
2959
  } else {
2420
2960
  destroy_effect_children(effect);
@@ -2431,8 +2971,8 @@ function update_effect(effect) {
2431
2971
  }
2432
2972
  }
2433
2973
  function get(signal) {
2434
- var flags = signal.f;
2435
- var is_derived = (flags & DERIVED) !== 0;
2974
+ var flags2 = signal.f;
2975
+ var is_derived = (flags2 & DERIVED) !== 0;
2436
2976
  if (active_reaction !== null && !untracking) {
2437
2977
  var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
2438
2978
  if (!destroyed && !current_sources?.includes(signal)) {
@@ -2487,13 +3027,16 @@ function get(signal) {
2487
3027
  } else if (is_derived) {
2488
3028
  derived = /** @type {Derived} */
2489
3029
  signal;
2490
- if (batch_deriveds?.has(derived)) {
2491
- return batch_deriveds.get(derived);
3030
+ if (batch_values?.has(derived)) {
3031
+ return batch_values.get(derived);
2492
3032
  }
2493
3033
  if (is_dirty(derived)) {
2494
3034
  update_derived(derived);
2495
3035
  }
2496
3036
  }
3037
+ if (batch_values?.has(signal)) {
3038
+ return batch_values.get(signal);
3039
+ }
2497
3040
  if ((signal.f & ERROR_VALUE) !== 0) {
2498
3041
  throw signal.v;
2499
3042
  }
@@ -2515,6 +3058,15 @@ function depends_on_old_values(derived) {
2515
3058
  }
2516
3059
  return false;
2517
3060
  }
3061
+ function untrack(fn) {
3062
+ var previous_untracking = untracking;
3063
+ try {
3064
+ untracking = true;
3065
+ return fn();
3066
+ } finally {
3067
+ untracking = previous_untracking;
3068
+ }
3069
+ }
2518
3070
  const STATUS_MASK = -7169;
2519
3071
  function set_signal_status(signal, status) {
2520
3072
  signal.f = signal.f & STATUS_MASK | status;
@@ -2648,13 +3200,7 @@ function hydrate(component, options2) {
2648
3200
  /** @type {Comment} */
2649
3201
  anchor
2650
3202
  );
2651
- hydrate_next();
2652
3203
  const instance = _mount(component, { ...options2, anchor });
2653
- if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
2654
- hydrate_node.data !== HYDRATION_END) {
2655
- hydration_mismatch();
2656
- throw HYDRATION_ERROR;
2657
- }
2658
3204
  set_hydrating(false);
2659
3205
  return (
2660
3206
  /** @type {Exports} */
@@ -2704,33 +3250,46 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
2704
3250
  var component = void 0;
2705
3251
  var unmount2 = component_root(() => {
2706
3252
  var anchor_node = anchor ?? target.appendChild(create_text());
2707
- branch(() => {
2708
- if (context) {
2709
- push({});
2710
- var ctx = (
2711
- /** @type {ComponentContext} */
2712
- component_context
2713
- );
2714
- ctx.c = context;
2715
- }
2716
- if (events) {
2717
- props.$$events = events;
2718
- }
2719
- if (hydrating) {
2720
- assign_nodes(
2721
- /** @type {TemplateNode} */
2722
- anchor_node,
2723
- null
2724
- );
2725
- }
2726
- component = Component(anchor_node, props) || {};
2727
- if (hydrating) {
2728
- active_effect.nodes_end = hydrate_node;
2729
- }
2730
- if (context) {
2731
- pop();
3253
+ boundary(
3254
+ /** @type {TemplateNode} */
3255
+ anchor_node,
3256
+ {
3257
+ pending: () => {
3258
+ }
3259
+ },
3260
+ (anchor_node2) => {
3261
+ if (context) {
3262
+ push({});
3263
+ var ctx = (
3264
+ /** @type {ComponentContext} */
3265
+ component_context
3266
+ );
3267
+ ctx.c = context;
3268
+ }
3269
+ if (events) {
3270
+ props.$$events = events;
3271
+ }
3272
+ if (hydrating) {
3273
+ assign_nodes(
3274
+ /** @type {TemplateNode} */
3275
+ anchor_node2,
3276
+ null
3277
+ );
3278
+ }
3279
+ component = Component(anchor_node2, props) || {};
3280
+ if (hydrating) {
3281
+ active_effect.nodes_end = hydrate_node;
3282
+ if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
3283
+ hydrate_node.data !== HYDRATION_END) {
3284
+ hydration_mismatch();
3285
+ throw HYDRATION_ERROR;
3286
+ }
3287
+ }
3288
+ if (context) {
3289
+ pop();
3290
+ }
2732
3291
  }
2733
- });
3292
+ );
2734
3293
  return () => {
2735
3294
  for (var event_name of registered_events) {
2736
3295
  target.removeEventListener(event_name, handle_event_propagation);
@@ -2834,8 +3393,8 @@ class Svelte4Component {
2834
3393
  });
2835
3394
  }
2836
3395
  this.#instance.$set = /** @param {Record<string, any>} next */
2837
- (next) => {
2838
- Object.assign(props, next);
3396
+ (next2) => {
3397
+ Object.assign(props, next2);
2839
3398
  };
2840
3399
  this.#instance.$destroy = () => {
2841
3400
  unmount(this.#instance);
@@ -2873,80 +3432,135 @@ function asClassComponent(component) {
2873
3432
  const component_constructor = asClassComponent$1(component);
2874
3433
  const _render = (props, { context } = {}) => {
2875
3434
  const result = render(component, { props, context });
2876
- return {
2877
- css: { code: "", map: null },
2878
- head: result.head,
2879
- html: result.body
2880
- };
3435
+ const munged = Object.defineProperties(
3436
+ /** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
3437
+ {},
3438
+ {
3439
+ css: {
3440
+ value: { code: "", map: null }
3441
+ },
3442
+ head: {
3443
+ get: () => result.head
3444
+ },
3445
+ html: {
3446
+ get: () => result.body
3447
+ },
3448
+ then: {
3449
+ /**
3450
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
3451
+ *
3452
+ * @template TResult1
3453
+ * @template [TResult2=never]
3454
+ * @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
3455
+ * @param { (reason: unknown) => TResult2 } onrejected
3456
+ */
3457
+ value: (onfulfilled, onrejected) => {
3458
+ {
3459
+ const user_result = onfulfilled({
3460
+ css: munged.css,
3461
+ head: munged.head,
3462
+ html: munged.html
3463
+ });
3464
+ return Promise.resolve(user_result);
3465
+ }
3466
+ }
3467
+ }
3468
+ }
3469
+ );
3470
+ return munged;
2881
3471
  };
2882
3472
  component_constructor.render = _render;
2883
3473
  return component_constructor;
2884
3474
  }
2885
- function Root($$payload, $$props) {
2886
- push$1();
2887
- let {
2888
- stores,
2889
- page,
2890
- constructors,
2891
- components = [],
2892
- form,
2893
- data_0 = null,
2894
- data_1 = null
2895
- } = $$props;
2896
- {
2897
- setContext("__svelte__", stores);
2898
- }
2899
- {
2900
- stores.page.set(page);
2901
- }
2902
- const Pyramid_1 = constructors[1];
2903
- if (constructors[1]) {
2904
- $$payload.out.push("<!--[-->");
2905
- const Pyramid_0 = constructors[0];
2906
- $$payload.out.push(`<!---->`);
2907
- Pyramid_0($$payload, {
2908
- data: data_0,
3475
+ function Root($$renderer, $$props) {
3476
+ $$renderer.component(($$renderer2) => {
3477
+ let {
3478
+ stores,
3479
+ page,
3480
+ constructors,
3481
+ components = [],
2909
3482
  form,
2910
- params: page.params,
2911
- children: ($$payload2) => {
2912
- $$payload2.out.push(`<!---->`);
2913
- Pyramid_1($$payload2, { data: data_1, form, params: page.params });
2914
- $$payload2.out.push(`<!---->`);
2915
- },
2916
- $$slots: { default: true }
2917
- });
2918
- $$payload.out.push(`<!---->`);
2919
- } else {
2920
- $$payload.out.push("<!--[!-->");
2921
- const Pyramid_0 = constructors[0];
2922
- $$payload.out.push(`<!---->`);
2923
- Pyramid_0($$payload, { data: data_0, form, params: page.params });
2924
- $$payload.out.push(`<!---->`);
2925
- }
2926
- $$payload.out.push(`<!--]--> `);
2927
- {
2928
- $$payload.out.push("<!--[!-->");
2929
- }
2930
- $$payload.out.push(`<!--]-->`);
2931
- pop$1();
2932
- }
2933
- const root = asClassComponent(Root);
2934
- const options = {
2935
- app_template_contains_nonce: false,
2936
- csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false }, "reportOnly": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } },
2937
- csrf_check_origin: true,
2938
- embedded: false,
2939
- env_public_prefix: "PUBLIC_",
2940
- env_private_prefix: "",
2941
- hash_routing: false,
2942
- hooks: null,
3483
+ data_0 = null,
3484
+ data_1 = null,
3485
+ data_2 = null
3486
+ } = $$props;
3487
+ {
3488
+ setContext("__svelte__", stores);
3489
+ }
3490
+ {
3491
+ stores.page.set(page);
3492
+ }
3493
+ const Pyramid_2 = constructors[2];
3494
+ if (constructors[1]) {
3495
+ $$renderer2.push("<!--[-->");
3496
+ const Pyramid_0 = constructors[0];
3497
+ $$renderer2.push(`<!---->`);
3498
+ Pyramid_0($$renderer2, {
3499
+ data: data_0,
3500
+ form,
3501
+ params: page.params,
3502
+ children: ($$renderer3) => {
3503
+ if (constructors[2]) {
3504
+ $$renderer3.push("<!--[-->");
3505
+ const Pyramid_1 = constructors[1];
3506
+ $$renderer3.push(`<!---->`);
3507
+ Pyramid_1($$renderer3, {
3508
+ data: data_1,
3509
+ form,
3510
+ params: page.params,
3511
+ children: ($$renderer4) => {
3512
+ $$renderer4.push(`<!---->`);
3513
+ Pyramid_2($$renderer4, { data: data_2, form, params: page.params });
3514
+ $$renderer4.push(`<!---->`);
3515
+ },
3516
+ $$slots: { default: true }
3517
+ });
3518
+ $$renderer3.push(`<!---->`);
3519
+ } else {
3520
+ $$renderer3.push("<!--[!-->");
3521
+ const Pyramid_1 = constructors[1];
3522
+ $$renderer3.push(`<!---->`);
3523
+ Pyramid_1($$renderer3, { data: data_1, form, params: page.params });
3524
+ $$renderer3.push(`<!---->`);
3525
+ }
3526
+ $$renderer3.push(`<!--]-->`);
3527
+ },
3528
+ $$slots: { default: true }
3529
+ });
3530
+ $$renderer2.push(`<!---->`);
3531
+ } else {
3532
+ $$renderer2.push("<!--[!-->");
3533
+ const Pyramid_0 = constructors[0];
3534
+ $$renderer2.push(`<!---->`);
3535
+ Pyramid_0($$renderer2, { data: data_0, form, params: page.params });
3536
+ $$renderer2.push(`<!---->`);
3537
+ }
3538
+ $$renderer2.push(`<!--]--> `);
3539
+ {
3540
+ $$renderer2.push("<!--[!-->");
3541
+ }
3542
+ $$renderer2.push(`<!--]-->`);
3543
+ });
3544
+ }
3545
+ const root = asClassComponent(Root);
3546
+ const options = {
3547
+ app_template_contains_nonce: false,
3548
+ async: false,
3549
+ csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false }, "reportOnly": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } },
3550
+ csrf_check_origin: true,
3551
+ csrf_trusted_origins: [],
3552
+ embedded: false,
3553
+ env_public_prefix: "PUBLIC_",
3554
+ env_private_prefix: "",
3555
+ hash_routing: false,
3556
+ hooks: null,
2943
3557
  // added lazily, via `get_hooks`
2944
3558
  preload_strategy: "modulepreload",
2945
3559
  root,
2946
3560
  service_worker: false,
2947
3561
  service_worker_options: void 0,
2948
3562
  templates: {
2949
- app: ({ head, body, assets, nonce, env }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" href="' + assets + '/favicon.svg" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <meta name="color-scheme" content="dark light" />\n <link rel="stylesheet" href="' + assets + '/theme.css" />\n <link rel="stylesheet" href="' + assets + '/styles.css" />\n ' + head + '\n </head>\n\n <body>\n <div style="display: contents">' + body + "</div>\n </body>\n</html>\n",
3563
+ app: ({ head, body, assets, nonce, env }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" href="' + assets + '/favicon.svg" type="image/svg" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <meta name="color-scheme" content="dark light" />\n <link rel="stylesheet" href="' + assets + '/theme.css" />\n <link rel="stylesheet" href="' + assets + '/styles.css" />\n ' + head + '\n </head>\n\n <body>\n <div style="display: contents">' + body + "</div>\n </body>\n</html>\n",
2950
3564
  error: ({ status, message }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>' + message + `</title>
2951
3565
 
2952
3566
  <style>
@@ -3018,7 +3632,7 @@ const options = {
3018
3632
  <div class="error">
3019
3633
  <span class="status">` + status + '</span>\n <div class="message">\n <h1>' + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
3020
3634
  },
3021
- version_hash: "lx8w8t"
3635
+ version_hash: "1qcsm56"
3022
3636
  };
3023
3637
  async function get_hooks() {
3024
3638
  let handle;
@@ -3026,7 +3640,6 @@ async function get_hooks() {
3026
3640
  let handleError;
3027
3641
  let handleValidationError;
3028
3642
  let init;
3029
- ({ handle, handleFetch, handleError, handleValidationError, init } = await import('./chunks/hooks.server-BQqilaHv.js'));
3030
3643
  let reroute;
3031
3644
  let transport;
3032
3645
  return {
@@ -3055,6 +3668,9 @@ function parse_remote_arg(string, transport) {
3055
3668
  const decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode]));
3056
3669
  return parse(json_string, decoders);
3057
3670
  }
3671
+ function create_remote_cache_key(id, payload) {
3672
+ return id + "/" + payload;
3673
+ }
3058
3674
 
3059
3675
  var setCookie = {exports: {}};
3060
3676
 
@@ -3291,6 +3907,17 @@ function requireSetCookie () {
3291
3907
 
3292
3908
  var setCookieExports = /*@__PURE__*/ requireSetCookie();
3293
3909
 
3910
+ function with_resolvers() {
3911
+ let resolve2;
3912
+ let reject;
3913
+ const promise = new Promise((res, rej) => {
3914
+ resolve2 = res;
3915
+ reject = rej;
3916
+ });
3917
+ return { promise, resolve: resolve2, reject };
3918
+ }
3919
+ const NULL_BODY_STATUS = [101, 103, 204, 205, 304];
3920
+ const IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
3294
3921
  const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
3295
3922
  const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
3296
3923
  const PAGE_METHODS = ["GET", "POST", "HEAD"];
@@ -3406,9 +4033,14 @@ function method_not_allowed(mod, method) {
3406
4033
  }
3407
4034
  function allowed_methods(mod) {
3408
4035
  const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
3409
- if ("GET" in mod || "HEAD" in mod) allowed.push("HEAD");
4036
+ if ("GET" in mod && !("HEAD" in mod)) {
4037
+ allowed.push("HEAD");
4038
+ }
3410
4039
  return allowed;
3411
4040
  }
4041
+ function get_global_name(options2) {
4042
+ return `__sveltekit_${options2.version_hash}`;
4043
+ }
3412
4044
  function static_error_page(options2, status, message) {
3413
4045
  let page = options2.templates.error({ status, message: escape_html(message) });
3414
4046
  return text(page, {
@@ -3433,7 +4065,7 @@ async function handle_fatal_error(event, state, options2, error2) {
3433
4065
  }
3434
4066
  async function handle_error_and_jsonify(event, state, options2, error2) {
3435
4067
  if (error2 instanceof HttpError) {
3436
- return error2.body;
4068
+ return { message: "Unknown Error", ...error2.body };
3437
4069
  }
3438
4070
  const status = get_status(error2);
3439
4071
  const message = get_message(error2);
@@ -3477,6 +4109,15 @@ function serialize_uses(node) {
3477
4109
  function has_prerendered_path(manifest, pathname) {
3478
4110
  return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
3479
4111
  }
4112
+ function format_server_error(status, error2, event) {
4113
+ const formatted_text = `
4114
+ \x1B[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1B[0m`;
4115
+ if (status === 404) {
4116
+ return formatted_text;
4117
+ }
4118
+ return `${formatted_text}
4119
+ ${error2.stack}`;
4120
+ }
3480
4121
  function get_node_type(node_id) {
3481
4122
  const parts = node_id?.split("/");
3482
4123
  const filename = parts?.at(-1);
@@ -3507,6 +4148,7 @@ async function render_endpoint(event, event_state, mod, state) {
3507
4148
  return new Response(void 0, { status: 204 });
3508
4149
  }
3509
4150
  }
4151
+ event_state.is_endpoint_request = true;
3510
4152
  try {
3511
4153
  const response = await with_request_store(
3512
4154
  { event, state: event_state },
@@ -3669,7 +4311,7 @@ async function handle_action_json_request(event, event_state, options2, server)
3669
4311
  check_named_default_separate(actions);
3670
4312
  try {
3671
4313
  const data = await call_action(event, event_state, actions);
3672
- if (false) ;
4314
+ if (DEV) ;
3673
4315
  if (data instanceof ActionFailure) {
3674
4316
  return action_json({
3675
4317
  type: "failure",
@@ -3754,7 +4396,7 @@ async function handle_action_request(event, event_state, server) {
3754
4396
  check_named_default_separate(actions);
3755
4397
  try {
3756
4398
  const data = await call_action(event, event_state, actions);
3757
- if (false) ;
4399
+ if (DEV) ;
3758
4400
  if (data instanceof ActionFailure) {
3759
4401
  return {
3760
4402
  type: "failure",
@@ -3821,14 +4463,14 @@ async function call_action(event, event_state, actions) {
3821
4463
  attributes: {
3822
4464
  "http.route": event.route.id || "unknown"
3823
4465
  },
3824
- fn: async (current) => {
3825
- const traced_event = merge_tracing(event, current);
4466
+ fn: async (current2) => {
4467
+ const traced_event = merge_tracing(event, current2);
3826
4468
  const result = await with_request_store(
3827
4469
  { event: traced_event, state: event_state },
3828
4470
  () => action(traced_event)
3829
4471
  );
3830
4472
  if (result instanceof ActionFailure) {
3831
- current.setAttributes({
4473
+ current2.setAttributes({
3832
4474
  "sveltekit.form_action.result.type": "failure",
3833
4475
  "sveltekit.form_action.result.status": result.status
3834
4476
  });
@@ -3875,6 +4517,231 @@ function try_serialize(data, fn, route_id) {
3875
4517
  throw error2;
3876
4518
  }
3877
4519
  }
4520
+ function defer() {
4521
+ let fulfil;
4522
+ let reject;
4523
+ const promise = new Promise((f, r) => {
4524
+ fulfil = f;
4525
+ reject = r;
4526
+ });
4527
+ return { promise, fulfil, reject };
4528
+ }
4529
+ function create_async_iterator() {
4530
+ let count = 0;
4531
+ const deferred = [defer()];
4532
+ return {
4533
+ iterate: (transform = (x) => x) => {
4534
+ return {
4535
+ [Symbol.asyncIterator]() {
4536
+ return {
4537
+ next: async () => {
4538
+ const next = await deferred[0].promise;
4539
+ if (!next.done) {
4540
+ deferred.shift();
4541
+ return { value: transform(next.value), done: false };
4542
+ }
4543
+ return next;
4544
+ }
4545
+ };
4546
+ }
4547
+ };
4548
+ },
4549
+ add: (promise) => {
4550
+ count += 1;
4551
+ void promise.then((value) => {
4552
+ deferred[deferred.length - 1].fulfil({
4553
+ value,
4554
+ done: false
4555
+ });
4556
+ deferred.push(defer());
4557
+ if (--count === 0) {
4558
+ deferred[deferred.length - 1].fulfil({ done: true });
4559
+ }
4560
+ });
4561
+ }
4562
+ };
4563
+ }
4564
+ function server_data_serializer(event, event_state, options2) {
4565
+ let promise_id = 1;
4566
+ let max_nodes = -1;
4567
+ const iterator = create_async_iterator();
4568
+ const global = get_global_name(options2);
4569
+ function get_replacer(index) {
4570
+ return function replacer(thing) {
4571
+ if (typeof thing?.then === "function") {
4572
+ const id = promise_id++;
4573
+ const promise = thing.then(
4574
+ /** @param {any} data */
4575
+ (data) => ({ data })
4576
+ ).catch(
4577
+ /** @param {any} error */
4578
+ async (error2) => ({
4579
+ error: await handle_error_and_jsonify(event, event_state, options2, error2)
4580
+ })
4581
+ ).then(
4582
+ /**
4583
+ * @param {{data: any; error: any}} result
4584
+ */
4585
+ async ({ data, error: error2 }) => {
4586
+ let str;
4587
+ try {
4588
+ str = uneval(error2 ? [, error2] : [data], replacer);
4589
+ } catch {
4590
+ error2 = await handle_error_and_jsonify(
4591
+ event,
4592
+ event_state,
4593
+ options2,
4594
+ new Error(`Failed to serialize promise while rendering ${event.route.id}`)
4595
+ );
4596
+ data = void 0;
4597
+ str = uneval([, error2], replacer);
4598
+ }
4599
+ return {
4600
+ index,
4601
+ str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})`
4602
+ };
4603
+ }
4604
+ );
4605
+ iterator.add(promise);
4606
+ return `${global}.defer(${id})`;
4607
+ } else {
4608
+ for (const key2 in options2.hooks.transport) {
4609
+ const encoded = options2.hooks.transport[key2].encode(thing);
4610
+ if (encoded) {
4611
+ return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
4612
+ }
4613
+ }
4614
+ }
4615
+ };
4616
+ }
4617
+ const strings = (
4618
+ /** @type {string[]} */
4619
+ []
4620
+ );
4621
+ return {
4622
+ set_max_nodes(i) {
4623
+ max_nodes = i;
4624
+ },
4625
+ add_node(i, node) {
4626
+ try {
4627
+ if (!node) {
4628
+ strings[i] = "null";
4629
+ return;
4630
+ }
4631
+ const payload = { type: "data", data: node.data, uses: serialize_uses(node) };
4632
+ if (node.slash) payload.slash = node.slash;
4633
+ strings[i] = uneval(payload, get_replacer(i));
4634
+ } catch (e) {
4635
+ e.path = e.path.slice(1);
4636
+ throw new Error(clarify_devalue_error(
4637
+ event,
4638
+ /** @type {any} */
4639
+ e
4640
+ ));
4641
+ }
4642
+ },
4643
+ get_data(csp) {
4644
+ const open = `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>`;
4645
+ const close = `<\/script>
4646
+ `;
4647
+ return {
4648
+ data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`,
4649
+ chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => {
4650
+ if (max_nodes > -1 && index >= max_nodes) {
4651
+ return "";
4652
+ }
4653
+ return open + str + close;
4654
+ }) : null
4655
+ };
4656
+ }
4657
+ };
4658
+ }
4659
+ function server_data_serializer_json(event, event_state, options2) {
4660
+ let promise_id = 1;
4661
+ const iterator = create_async_iterator();
4662
+ const reducers = {
4663
+ ...Object.fromEntries(
4664
+ Object.entries(options2.hooks.transport).map(([key2, value]) => [key2, value.encode])
4665
+ ),
4666
+ /** @param {any} thing */
4667
+ Promise: (thing) => {
4668
+ if (typeof thing?.then !== "function") {
4669
+ return;
4670
+ }
4671
+ const id = promise_id++;
4672
+ let key2 = "data";
4673
+ const promise = thing.catch(
4674
+ /** @param {any} e */
4675
+ async (e) => {
4676
+ key2 = "error";
4677
+ return handle_error_and_jsonify(
4678
+ event,
4679
+ event_state,
4680
+ options2,
4681
+ /** @type {any} */
4682
+ e
4683
+ );
4684
+ }
4685
+ ).then(
4686
+ /** @param {any} value */
4687
+ async (value) => {
4688
+ let str;
4689
+ try {
4690
+ str = stringify$1(value, reducers);
4691
+ } catch {
4692
+ const error2 = await handle_error_and_jsonify(
4693
+ event,
4694
+ event_state,
4695
+ options2,
4696
+ new Error(`Failed to serialize promise while rendering ${event.route.id}`)
4697
+ );
4698
+ key2 = "error";
4699
+ str = stringify$1(error2, reducers);
4700
+ }
4701
+ return `{"type":"chunk","id":${id},"${key2}":${str}}
4702
+ `;
4703
+ }
4704
+ );
4705
+ iterator.add(promise);
4706
+ return id;
4707
+ }
4708
+ };
4709
+ const strings = (
4710
+ /** @type {string[]} */
4711
+ []
4712
+ );
4713
+ return {
4714
+ add_node(i, node) {
4715
+ try {
4716
+ if (!node) {
4717
+ strings[i] = "null";
4718
+ return;
4719
+ }
4720
+ if (node.type === "error" || node.type === "skip") {
4721
+ strings[i] = JSON.stringify(node);
4722
+ return;
4723
+ }
4724
+ strings[i] = `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(
4725
+ serialize_uses(node)
4726
+ )}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
4727
+ } catch (e) {
4728
+ e.path = "data" + e.path;
4729
+ throw new Error(clarify_devalue_error(
4730
+ event,
4731
+ /** @type {any} */
4732
+ e
4733
+ ));
4734
+ }
4735
+ },
4736
+ get_data() {
4737
+ return {
4738
+ data: `{"type":"data","nodes":[${strings.join(",")}]}
4739
+ `,
4740
+ chunks: promise_id > 1 ? iterator.iterate() : null
4741
+ };
4742
+ }
4743
+ };
4744
+ }
3878
4745
  async function load_server_data({ event, event_state, state, node, parent }) {
3879
4746
  if (!node?.server) return null;
3880
4747
  let is_tracking = true;
@@ -3914,8 +4781,8 @@ async function load_server_data({ event, event_state, state, node, parent }) {
3914
4781
  "sveltekit.load.node_type": get_node_type(node.server_id),
3915
4782
  "http.route": event.route.id || "unknown"
3916
4783
  },
3917
- fn: async (current) => {
3918
- const traced_event = merge_tracing(event, current);
4784
+ fn: async (current2) => {
4785
+ const traced_event = merge_tracing(event, current2);
3919
4786
  const result2 = await with_request_store(
3920
4787
  { event: traced_event, state: event_state },
3921
4788
  () => load.call(null, {
@@ -4003,8 +4870,8 @@ async function load_data({
4003
4870
  "sveltekit.load.node_type": get_node_type(node.universal_id),
4004
4871
  "http.route": event.route.id || "unknown"
4005
4872
  },
4006
- fn: async (current) => {
4007
- const traced_event = merge_tracing(event, current);
4873
+ fn: async (current2) => {
4874
+ const traced_event = merge_tracing(event, current2);
4008
4875
  return await with_request_store(
4009
4876
  { event: traced_event, state: event_state },
4010
4877
  () => load.call(null, {
@@ -4116,6 +4983,10 @@ function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
4116
4983
  }
4117
4984
  async function text2() {
4118
4985
  const body2 = await response2.text();
4986
+ if (body2 === "" && NULL_BODY_STATUS.includes(response2.status)) {
4987
+ await push_fetched(void 0, false);
4988
+ return void 0;
4989
+ }
4119
4990
  if (!body2 || typeof body2 === "string") {
4120
4991
  await push_fetched(body2, false);
4121
4992
  }
@@ -4129,7 +5000,8 @@ function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
4129
5000
  }
4130
5001
  if (key2 === "json") {
4131
5002
  return async () => {
4132
- return JSON.parse(await text2());
5003
+ const body2 = await text2();
5004
+ return body2 ? JSON.parse(body2) : void 0;
4133
5005
  };
4134
5006
  }
4135
5007
  return Reflect.get(response2, key2, response2);
@@ -4194,7 +5066,7 @@ const replacements = {
4194
5066
  "\u2029": "\\u2029"
4195
5067
  };
4196
5068
  const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
4197
- function serialize_data(fetched, filter, prerendering2 = false) {
5069
+ function serialize_data(fetched, filter, prerendering = false) {
4198
5070
  const headers2 = {};
4199
5071
  let cache_control = null;
4200
5072
  let age = null;
@@ -4232,7 +5104,7 @@ function serialize_data(fetched, filter, prerendering2 = false) {
4232
5104
  }
4233
5105
  attrs.push(`data-hash="${hash(...values)}"`);
4234
5106
  }
4235
- if (!prerendering2 && fetched.method === "GET" && cache_control && !varyAny) {
5107
+ if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) {
4236
5108
  const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
4237
5109
  if (match) {
4238
5110
  const ttl = +match[1] - +(age ?? "0");
@@ -4571,41 +5443,6 @@ class Csp {
4571
5443
  this.report_only_provider.add_style(content);
4572
5444
  }
4573
5445
  }
4574
- function defer() {
4575
- let fulfil;
4576
- let reject;
4577
- const promise = new Promise((f, r) => {
4578
- fulfil = f;
4579
- reject = r;
4580
- });
4581
- return { promise, fulfil, reject };
4582
- }
4583
- function create_async_iterator() {
4584
- const deferred = [defer()];
4585
- return {
4586
- iterator: {
4587
- [Symbol.asyncIterator]() {
4588
- return {
4589
- next: async () => {
4590
- const next = await deferred[0].promise;
4591
- if (!next.done) deferred.shift();
4592
- return next;
4593
- }
4594
- };
4595
- }
4596
- },
4597
- push: (value) => {
4598
- deferred[deferred.length - 1].fulfil({
4599
- value,
4600
- done: false
4601
- });
4602
- deferred.push(defer());
4603
- },
4604
- done: () => {
4605
- deferred[deferred.length - 1].fulfil({ done: true });
4606
- }
4607
- };
4608
- }
4609
5446
  function exec(match, params, matchers) {
4610
5447
  const result = {};
4611
5448
  const values = match.slice(1);
@@ -4735,7 +5572,8 @@ async function render_response({
4735
5572
  event,
4736
5573
  event_state,
4737
5574
  resolve_opts,
4738
- action_result
5575
+ action_result,
5576
+ data_serializer
4739
5577
  }) {
4740
5578
  if (state.prerendering) {
4741
5579
  if (options2.csp.mode === "nonce") {
@@ -4749,7 +5587,8 @@ async function render_response({
4749
5587
  const modulepreloads = new Set(client.imports);
4750
5588
  const stylesheets = new Set(client.stylesheets);
4751
5589
  const fonts = new Set(client.fonts);
4752
- const link_header_preloads = /* @__PURE__ */ new Set();
5590
+ const link_headers = /* @__PURE__ */ new Set();
5591
+ const link_tags = /* @__PURE__ */ new Set();
4753
5592
  const inline_styles = /* @__PURE__ */ new Map();
4754
5593
  let rendered;
4755
5594
  const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
@@ -4803,7 +5642,6 @@ async function render_response({
4803
5642
  form: form_value,
4804
5643
  state: {}
4805
5644
  };
4806
- override({ base: base$1, assets: assets$1 });
4807
5645
  const render_opts = {
4808
5646
  context: /* @__PURE__ */ new Map([
4809
5647
  [
@@ -4814,15 +5652,23 @@ async function render_response({
4814
5652
  ]
4815
5653
  ])
4816
5654
  };
4817
- {
4818
- try {
4819
- rendered = with_request_store(
4820
- { event, state: event_state },
4821
- () => options2.root.render(props, render_opts)
4822
- );
4823
- } finally {
4824
- reset();
4825
- }
5655
+ try {
5656
+ if (DEV) ;
5657
+ rendered = await with_request_store({ event, state: event_state }, async () => {
5658
+ if (relative) override({ base: base$1, assets: assets$1 });
5659
+ const maybe_promise = options2.root.render(props, render_opts);
5660
+ const rendered2 = options2.async && "then" in maybe_promise ? (
5661
+ /** @type {ReturnType<typeof options.root.render> & Promise<any>} */
5662
+ maybe_promise.then((r) => r)
5663
+ ) : maybe_promise;
5664
+ if (options2.async) {
5665
+ reset();
5666
+ }
5667
+ const { head: head2, html: html2, css } = options2.async ? await rendered2 : rendered2;
5668
+ return { head: head2, html: html2, css };
5669
+ });
5670
+ } finally {
5671
+ reset();
4826
5672
  }
4827
5673
  for (const { node } of branch) {
4828
5674
  for (const url of node.imports) modulepreloads.add(url);
@@ -4861,8 +5707,7 @@ async function render_response({
4861
5707
  attributes.push("disabled", 'media="(max-width: 0)"');
4862
5708
  } else {
4863
5709
  if (resolve_opts.preload({ type: "css", path })) {
4864
- const preload_atts = ['rel="preload"', 'as="style"'];
4865
- link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(";")}; nopush`);
5710
+ link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="style"; nopush`);
4866
5711
  }
4867
5712
  }
4868
5713
  head += `
@@ -4872,26 +5717,14 @@ async function render_response({
4872
5717
  const path = prefixed(dep);
4873
5718
  if (resolve_opts.preload({ type: "font", path })) {
4874
5719
  const ext = dep.slice(dep.lastIndexOf(".") + 1);
4875
- const attributes = [
4876
- 'rel="preload"',
4877
- 'as="font"',
4878
- `type="font/${ext}"`,
4879
- `href="${path}"`,
4880
- "crossorigin"
4881
- ];
4882
- head += `
4883
- <link ${attributes.join(" ")}>`;
5720
+ link_tags.add(`<link rel="preload" as="font" type="font/${ext}" href="${path}" crossorigin>`);
5721
+ link_headers.add(
5722
+ `<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`
5723
+ );
4884
5724
  }
4885
5725
  }
4886
- const global = `__sveltekit_${options2.version_hash}`;
4887
- const { data, chunks } = get_data(
4888
- event,
4889
- event_state,
4890
- options2,
4891
- branch.map((b) => b.server_data),
4892
- csp,
4893
- global
4894
- );
5726
+ const global = get_global_name(options2);
5727
+ const { data, chunks } = data_serializer.get_data(csp);
4895
5728
  if (page_config.ssr && page_config.csr) {
4896
5729
  body2 += `
4897
5730
  ${fetched.map(
@@ -4908,16 +5741,19 @@ async function render_response({
4908
5741
  (path) => resolve_opts.preload({ type: "js", path })
4909
5742
  );
4910
5743
  for (const path of included_modulepreloads) {
4911
- link_header_preloads.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
5744
+ link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
4912
5745
  if (options2.preload_strategy !== "modulepreload") {
4913
5746
  head += `
4914
5747
  <link rel="preload" as="script" crossorigin="anonymous" href="${path}">`;
4915
- } else if (state.prerendering) {
4916
- head += `
4917
- <link rel="modulepreload" href="${path}">`;
5748
+ } else {
5749
+ link_tags.add(`<link rel="modulepreload" href="${path}">`);
4918
5750
  }
4919
5751
  }
4920
5752
  }
5753
+ if (state.prerendering && link_tags.size > 0) {
5754
+ head += Array.from(link_tags).map((tag) => `
5755
+ ${tag}`).join("");
5756
+ }
4921
5757
  if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
4922
5758
  const pathname = add_resolution_suffix(event.url.pathname);
4923
5759
  state.prerendering.dependencies.set(
@@ -4939,7 +5775,21 @@ async function render_response({
4939
5775
  properties.push(`defer: (id) => new Promise((fulfil, reject) => {
4940
5776
  deferred.set(id, { fulfil, reject });
4941
5777
  })`);
4942
- properties.push(`resolve: ({ id, data, error }) => {
5778
+ let app_declaration = "";
5779
+ if (Object.keys(options2.hooks.transport).length > 0) {
5780
+ if (client.inline) {
5781
+ app_declaration = `const app = __sveltekit_${options2.version_hash}.app.app;`;
5782
+ } else if (client.app) {
5783
+ app_declaration = `const app = await import(${s(prefixed(client.app))});`;
5784
+ } else {
5785
+ app_declaration = `const { app } = await import(${s(prefixed(client.start))});`;
5786
+ }
5787
+ }
5788
+ const prelude = app_declaration ? `${app_declaration}
5789
+ const [data, error] = fn(app);` : `const [data, error] = fn();`;
5790
+ properties.push(`resolve: async (id, fn) => {
5791
+ ${prelude}
5792
+
4943
5793
  const try_to_resolve = () => {
4944
5794
  if (!deferred.has(id)) {
4945
5795
  setTimeout(try_to_resolve, 0);
@@ -4953,22 +5803,6 @@ async function render_response({
4953
5803
  try_to_resolve();
4954
5804
  }`);
4955
5805
  }
4956
- const { remote_data } = event_state;
4957
- if (remote_data) {
4958
- const remote = {};
4959
- for (const key2 in remote_data) {
4960
- remote[key2] = await remote_data[key2];
4961
- }
4962
- const replacer = (thing) => {
4963
- for (const key2 in options2.hooks.transport) {
4964
- const encoded = options2.hooks.transport[key2].encode(thing);
4965
- if (encoded) {
4966
- return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
4967
- }
4968
- }
4969
- };
4970
- properties.push(`data: ${uneval(remote, replacer)}`);
4971
- }
4972
5806
  blocks.push(`${global} = {
4973
5807
  ${properties.join(",\n ")}
4974
5808
  };`);
@@ -5013,15 +5847,37 @@ ${indent} ${hydrate.join(`,
5013
5847
  ${indent} `)}
5014
5848
  ${indent}}`);
5015
5849
  }
5850
+ const { remote_data: remote_cache } = event_state;
5851
+ let serialized_remote_data = "";
5852
+ if (remote_cache) {
5853
+ const remote = {};
5854
+ for (const [info, cache] of remote_cache) {
5855
+ if (!info.id) continue;
5856
+ for (const key2 in cache) {
5857
+ remote[create_remote_cache_key(info.id, key2)] = await cache[key2];
5858
+ }
5859
+ }
5860
+ const replacer = (thing) => {
5861
+ for (const key2 in options2.hooks.transport) {
5862
+ const encoded = options2.hooks.transport[key2].encode(thing);
5863
+ if (encoded) {
5864
+ return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
5865
+ }
5866
+ }
5867
+ };
5868
+ serialized_remote_data = `${global}.data = ${uneval(remote, replacer)};
5869
+
5870
+ `;
5871
+ }
5016
5872
  const boot = client.inline ? `${client.inline.script}
5017
5873
 
5018
- __sveltekit_${options2.version_hash}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
5874
+ ${serialized_remote_data}${global}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
5019
5875
  import(${s(prefixed(client.start))}),
5020
5876
  import(${s(prefixed(client.app))})
5021
5877
  ]).then(([kit, app]) => {
5022
- kit.start(app, ${args.join(", ")});
5878
+ ${serialized_remote_data}kit.start(app, ${args.join(", ")});
5023
5879
  });` : `import(${s(prefixed(client.start))}).then((app) => {
5024
- app.start(${args.join(", ")})
5880
+ ${serialized_remote_data}app.start(${args.join(", ")})
5025
5881
  });`;
5026
5882
  if (load_env_eagerly) {
5027
5883
  blocks.push(`import(${s(`${base$1}/${app_dir}/env.js`)}).then(({ env }) => {
@@ -5079,8 +5935,8 @@ ${indent}}`);
5079
5935
  if (report_only_header) {
5080
5936
  headers2.set("content-security-policy-report-only", report_only_header);
5081
5937
  }
5082
- if (link_header_preloads.size) {
5083
- headers2.set("link", Array.from(link_header_preloads).join(", "));
5938
+ if (link_headers.size) {
5939
+ headers2.set("link", Array.from(link_headers).join(", "));
5084
5940
  }
5085
5941
  }
5086
5942
  head += rendered.head;
@@ -5092,7 +5948,7 @@ ${indent}}`);
5092
5948
  /** @type {string} */
5093
5949
  csp.nonce
5094
5950
  ),
5095
- env: safe_public_env
5951
+ env: public_env
5096
5952
  });
5097
5953
  const transformed = await resolve_opts.transformPageChunk({
5098
5954
  html,
@@ -5120,77 +5976,6 @@ ${indent}}`);
5120
5976
  }
5121
5977
  );
5122
5978
  }
5123
- function get_data(event, event_state, options2, nodes, csp, global) {
5124
- let promise_id = 1;
5125
- let count = 0;
5126
- const { iterator, push, done } = create_async_iterator();
5127
- function replacer(thing) {
5128
- if (typeof thing?.then === "function") {
5129
- const id = promise_id++;
5130
- count += 1;
5131
- thing.then(
5132
- /** @param {any} data */
5133
- (data) => ({ data })
5134
- ).catch(
5135
- /** @param {any} error */
5136
- async (error2) => ({
5137
- error: await handle_error_and_jsonify(event, event_state, options2, error2)
5138
- })
5139
- ).then(
5140
- /**
5141
- * @param {{data: any; error: any}} result
5142
- */
5143
- async ({ data, error: error2 }) => {
5144
- count -= 1;
5145
- let str;
5146
- try {
5147
- str = uneval({ id, data, error: error2 }, replacer);
5148
- } catch {
5149
- error2 = await handle_error_and_jsonify(
5150
- event,
5151
- event_state,
5152
- options2,
5153
- new Error(`Failed to serialize promise while rendering ${event.route.id}`)
5154
- );
5155
- data = void 0;
5156
- str = uneval({ id, data, error: error2 }, replacer);
5157
- }
5158
- const nonce = csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : "";
5159
- push(`<script${nonce}>${global}.resolve(${str})<\/script>
5160
- `);
5161
- if (count === 0) done();
5162
- }
5163
- );
5164
- return `${global}.defer(${id})`;
5165
- } else {
5166
- for (const key2 in options2.hooks.transport) {
5167
- const encoded = options2.hooks.transport[key2].encode(thing);
5168
- if (encoded) {
5169
- return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
5170
- }
5171
- }
5172
- }
5173
- }
5174
- try {
5175
- const strings = nodes.map((node) => {
5176
- if (!node) return "null";
5177
- const payload = { type: "data", data: node.data, uses: serialize_uses(node) };
5178
- if (node.slash) payload.slash = node.slash;
5179
- return uneval(payload, replacer);
5180
- });
5181
- return {
5182
- data: `[${strings.join(",")}]`,
5183
- chunks: count > 0 ? iterator : null
5184
- };
5185
- } catch (e) {
5186
- e.path = e.path.slice(1);
5187
- throw new Error(clarify_devalue_error(
5188
- event,
5189
- /** @type {any} */
5190
- e
5191
- ));
5192
- }
5193
- }
5194
5979
  class PageNodes {
5195
5980
  data;
5196
5981
  /**
@@ -5261,17 +6046,17 @@ class PageNodes {
5261
6046
  return this.#get_option("trailingSlash") ?? "never";
5262
6047
  }
5263
6048
  get_config() {
5264
- let current = {};
6049
+ let current2 = {};
5265
6050
  for (const node of this.data) {
5266
6051
  if (!node?.universal?.config && !node?.server?.config) continue;
5267
- current = {
5268
- ...current,
6052
+ current2 = {
6053
+ ...current2,
5269
6054
  // TODO: should we override the server config value with the universal value similar to other page options?
5270
6055
  ...node?.universal?.config,
5271
6056
  ...node?.server?.config
5272
6057
  };
5273
6058
  }
5274
- return Object.keys(current).length ? current : void 0;
6059
+ return Object.keys(current2).length ? current2 : void 0;
5275
6060
  }
5276
6061
  should_prerender_data() {
5277
6062
  return this.data.some(
@@ -5305,6 +6090,7 @@ async function respond_with_error({
5305
6090
  const nodes = new PageNodes([default_layout]);
5306
6091
  const ssr = nodes.ssr();
5307
6092
  const csr = nodes.csr();
6093
+ const data_serializer = server_data_serializer(event, event_state, options2);
5308
6094
  if (ssr) {
5309
6095
  state.error = true;
5310
6096
  const server_data_promise = load_server_data({
@@ -5316,6 +6102,7 @@ async function respond_with_error({
5316
6102
  parent: async () => ({})
5317
6103
  });
5318
6104
  const server_data = await server_data_promise;
6105
+ data_serializer.add_node(0, server_data);
5319
6106
  const data = await load_data({
5320
6107
  event,
5321
6108
  event_state,
@@ -5328,269 +6115,54 @@ async function respond_with_error({
5328
6115
  state,
5329
6116
  csr
5330
6117
  });
5331
- branch.push(
5332
- {
5333
- node: default_layout,
5334
- server_data,
5335
- data
5336
- },
5337
- {
5338
- node: await manifest._.nodes[1](),
5339
- // 1 is always the root error
5340
- data: null,
5341
- server_data: null
5342
- }
5343
- );
5344
- }
5345
- return await render_response({
5346
- options: options2,
5347
- manifest,
5348
- state,
5349
- page_config: {
5350
- ssr,
5351
- csr
5352
- },
5353
- status,
5354
- error: await handle_error_and_jsonify(event, event_state, options2, error2),
5355
- branch,
5356
- fetched,
5357
- event,
5358
- event_state,
5359
- resolve_opts
5360
- });
5361
- } catch (e) {
5362
- if (e instanceof Redirect) {
5363
- return redirect_response(e.status, e.location);
5364
- }
5365
- return static_error_page(
5366
- options2,
5367
- get_status(e),
5368
- (await handle_error_and_jsonify(event, event_state, options2, e)).message
5369
- );
5370
- }
5371
- }
5372
- function once(fn) {
5373
- let done = false;
5374
- let result;
5375
- return () => {
5376
- if (done) return result;
5377
- done = true;
5378
- return result = fn();
5379
- };
5380
- }
5381
- async function render_data(event, event_state, route, options2, manifest, state, invalidated_data_nodes, trailing_slash) {
5382
- if (!route.page) {
5383
- return new Response(void 0, {
5384
- status: 404
5385
- });
5386
- }
5387
- try {
5388
- const node_ids = [...route.page.layouts, route.page.leaf];
5389
- const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
5390
- let aborted = false;
5391
- const url = new URL(event.url);
5392
- url.pathname = normalize_path(url.pathname, trailing_slash);
5393
- const new_event = { ...event, url };
5394
- const functions = node_ids.map((n, i) => {
5395
- return once(async () => {
5396
- try {
5397
- if (aborted) {
5398
- return (
5399
- /** @type {import('types').ServerDataSkippedNode} */
5400
- {
5401
- type: "skip"
5402
- }
5403
- );
5404
- }
5405
- const node = n == void 0 ? n : await manifest._.nodes[n]();
5406
- return load_server_data({
5407
- event: new_event,
5408
- event_state,
5409
- state,
5410
- node,
5411
- parent: async () => {
5412
- const data2 = {};
5413
- for (let j = 0; j < i; j += 1) {
5414
- const parent = (
5415
- /** @type {import('types').ServerDataNode | null} */
5416
- await functions[j]()
5417
- );
5418
- if (parent) {
5419
- Object.assign(data2, parent.data);
5420
- }
5421
- }
5422
- return data2;
5423
- }
5424
- });
5425
- } catch (e) {
5426
- aborted = true;
5427
- throw e;
5428
- }
5429
- });
5430
- });
5431
- const promises = functions.map(async (fn, i) => {
5432
- if (!invalidated[i]) {
5433
- return (
5434
- /** @type {import('types').ServerDataSkippedNode} */
5435
- {
5436
- type: "skip"
5437
- }
5438
- );
5439
- }
5440
- return fn();
5441
- });
5442
- let length = promises.length;
5443
- const nodes = await Promise.all(
5444
- promises.map(
5445
- (p, i) => p.catch(async (error2) => {
5446
- if (error2 instanceof Redirect) {
5447
- throw error2;
5448
- }
5449
- length = Math.min(length, i + 1);
5450
- return (
5451
- /** @type {import('types').ServerErrorNode} */
5452
- {
5453
- type: "error",
5454
- error: await handle_error_and_jsonify(event, event_state, options2, error2),
5455
- status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : void 0
5456
- }
5457
- );
5458
- })
5459
- )
5460
- );
5461
- const { data, chunks } = get_data_json(event, event_state, options2, nodes);
5462
- if (!chunks) {
5463
- return json_response(data);
5464
- }
5465
- return new Response(
5466
- new ReadableStream({
5467
- async start(controller) {
5468
- controller.enqueue(text_encoder.encode(data));
5469
- for await (const chunk of chunks) {
5470
- controller.enqueue(text_encoder.encode(chunk));
5471
- }
5472
- controller.close();
5473
- },
5474
- type: "bytes"
5475
- }),
5476
- {
5477
- headers: {
5478
- // we use a proprietary content type to prevent buffering.
5479
- // the `text` prefix makes it inspectable
5480
- "content-type": "text/sveltekit-data",
5481
- "cache-control": "private, no-store"
5482
- }
5483
- }
5484
- );
5485
- } catch (e) {
5486
- const error2 = normalize_error(e);
5487
- if (error2 instanceof Redirect) {
5488
- return redirect_json_response(error2);
5489
- } else {
5490
- return json_response(await handle_error_and_jsonify(event, event_state, options2, error2), 500);
5491
- }
5492
- }
5493
- }
5494
- function json_response(json2, status = 200) {
5495
- return text(typeof json2 === "string" ? json2 : JSON.stringify(json2), {
5496
- status,
5497
- headers: {
5498
- "content-type": "application/json",
5499
- "cache-control": "private, no-store"
5500
- }
5501
- });
5502
- }
5503
- function redirect_json_response(redirect) {
5504
- return json_response(
5505
- /** @type {import('types').ServerRedirectNode} */
5506
- {
5507
- type: "redirect",
5508
- location: redirect.location
5509
- }
5510
- );
5511
- }
5512
- function get_data_json(event, event_state, options2, nodes) {
5513
- let promise_id = 1;
5514
- let count = 0;
5515
- const { iterator, push, done } = create_async_iterator();
5516
- const reducers = {
5517
- ...Object.fromEntries(
5518
- Object.entries(options2.hooks.transport).map(([key2, value]) => [key2, value.encode])
5519
- ),
5520
- /** @param {any} thing */
5521
- Promise: (thing) => {
5522
- if (typeof thing?.then === "function") {
5523
- const id = promise_id++;
5524
- count += 1;
5525
- let key2 = "data";
5526
- thing.catch(
5527
- /** @param {any} e */
5528
- async (e) => {
5529
- key2 = "error";
5530
- return handle_error_and_jsonify(
5531
- event,
5532
- event_state,
5533
- options2,
5534
- /** @type {any} */
5535
- e
5536
- );
5537
- }
5538
- ).then(
5539
- /** @param {any} value */
5540
- async (value) => {
5541
- let str;
5542
- try {
5543
- str = stringify$1(value, reducers);
5544
- } catch {
5545
- const error2 = await handle_error_and_jsonify(
5546
- event,
5547
- event_state,
5548
- options2,
5549
- new Error(`Failed to serialize promise while rendering ${event.route.id}`)
5550
- );
5551
- key2 = "error";
5552
- str = stringify$1(error2, reducers);
5553
- }
5554
- count -= 1;
5555
- push(`{"type":"chunk","id":${id},"${key2}":${str}}
5556
- `);
5557
- if (count === 0) done();
5558
- }
5559
- );
5560
- return id;
5561
- }
6118
+ branch.push(
6119
+ {
6120
+ node: default_layout,
6121
+ server_data,
6122
+ data
6123
+ },
6124
+ {
6125
+ node: await manifest._.nodes[1](),
6126
+ // 1 is always the root error
6127
+ data: null,
6128
+ server_data: null
6129
+ }
6130
+ );
5562
6131
  }
5563
- };
5564
- try {
5565
- const strings = nodes.map((node) => {
5566
- if (!node) return "null";
5567
- if (node.type === "error" || node.type === "skip") {
5568
- return JSON.stringify(node);
5569
- }
5570
- return `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(
5571
- serialize_uses(node)
5572
- )}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
6132
+ return await render_response({
6133
+ options: options2,
6134
+ manifest,
6135
+ state,
6136
+ page_config: {
6137
+ ssr,
6138
+ csr
6139
+ },
6140
+ status,
6141
+ error: await handle_error_and_jsonify(event, event_state, options2, error2),
6142
+ branch,
6143
+ fetched,
6144
+ event,
6145
+ event_state,
6146
+ resolve_opts,
6147
+ data_serializer
5573
6148
  });
5574
- return {
5575
- data: `{"type":"data","nodes":[${strings.join(",")}]}
5576
- `,
5577
- chunks: count > 0 ? iterator : null
5578
- };
5579
6149
  } catch (e) {
5580
- e.path = "data" + e.path;
5581
- throw new Error(clarify_devalue_error(
5582
- event,
5583
- /** @type {any} */
5584
- e
5585
- ));
6150
+ if (e instanceof Redirect) {
6151
+ return redirect_response(e.status, e.location);
6152
+ }
6153
+ return static_error_page(
6154
+ options2,
6155
+ get_status(e),
6156
+ (await handle_error_and_jsonify(event, event_state, options2, e)).message
6157
+ );
5586
6158
  }
5587
6159
  }
5588
6160
  async function handle_remote_call(event, state, options2, manifest, id) {
5589
6161
  return record_span({
5590
6162
  name: "sveltekit.remote.call",
5591
6163
  attributes: {},
5592
- fn: (current) => {
5593
- const traced_event = merge_tracing(event, current);
6164
+ fn: (current2) => {
6165
+ const traced_event = merge_tracing(event, current2);
5594
6166
  return with_request_store(
5595
6167
  { event: traced_event, state },
5596
6168
  () => handle_remote_call_internal(traced_event, state, options2, manifest, id)
@@ -5599,11 +6171,11 @@ async function handle_remote_call(event, state, options2, manifest, id) {
5599
6171
  });
5600
6172
  }
5601
6173
  async function handle_remote_call_internal(event, state, options2, manifest, id) {
5602
- const [hash2, name, prerender_args] = id.split("/");
6174
+ const [hash2, name, additional_args] = id.split("/");
5603
6175
  const remotes = manifest._.remotes;
5604
6176
  if (!remotes[hash2]) error(404);
5605
6177
  const module = await remotes[hash2]();
5606
- const fn = module[name];
6178
+ const fn = module.default[name];
5607
6179
  if (!fn) error(404);
5608
6180
  const info = fn.__;
5609
6181
  const transport = options2.hooks.transport;
@@ -5613,22 +6185,65 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5613
6185
  });
5614
6186
  let form_client_refreshes;
5615
6187
  try {
6188
+ if (info.type === "query_batch") {
6189
+ if (event.request.method !== "POST") {
6190
+ throw new SvelteKitError(
6191
+ 405,
6192
+ "Method Not Allowed",
6193
+ `\`query.batch\` functions must be invoked via POST request, not ${event.request.method}`
6194
+ );
6195
+ }
6196
+ const { payloads } = await event.request.json();
6197
+ const args = payloads.map((payload2) => parse_remote_arg(payload2, transport));
6198
+ const get_result = await with_request_store({ event, state }, () => info.run(args));
6199
+ const results = await Promise.all(
6200
+ args.map(async (arg, i) => {
6201
+ try {
6202
+ return { type: "result", data: get_result(arg, i) };
6203
+ } catch (error2) {
6204
+ return {
6205
+ type: "error",
6206
+ error: await handle_error_and_jsonify(event, state, options2, error2),
6207
+ status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500
6208
+ };
6209
+ }
6210
+ })
6211
+ );
6212
+ return json(
6213
+ /** @type {RemoteFunctionResponse} */
6214
+ {
6215
+ type: "result",
6216
+ result: stringify(results, transport)
6217
+ }
6218
+ );
6219
+ }
5616
6220
  if (info.type === "form") {
6221
+ if (event.request.method !== "POST") {
6222
+ throw new SvelteKitError(
6223
+ 405,
6224
+ "Method Not Allowed",
6225
+ `\`form\` functions must be invoked via POST request, not ${event.request.method}`
6226
+ );
6227
+ }
5617
6228
  if (!is_form_content_type(event.request)) {
5618
6229
  throw new SvelteKitError(
5619
6230
  415,
5620
6231
  "Unsupported Media Type",
5621
- `Form actions expect form-encoded data — received ${event.request.headers.get(
6232
+ `\`form\` functions expect form-encoded data — received ${event.request.headers.get(
5622
6233
  "content-type"
5623
6234
  )}`
5624
6235
  );
5625
6236
  }
5626
6237
  const form_data = await event.request.formData();
5627
- form_client_refreshes = JSON.parse(
6238
+ form_client_refreshes = /** @type {string[]} */
6239
+ JSON.parse(
5628
6240
  /** @type {string} */
5629
6241
  form_data.get("sveltekit:remote_refreshes") ?? "[]"
5630
6242
  );
5631
6243
  form_data.delete("sveltekit:remote_refreshes");
6244
+ if (additional_args) {
6245
+ form_data.set("sveltekit:id", decodeURIComponent(additional_args));
6246
+ }
5632
6247
  const fn2 = info.fn;
5633
6248
  const data2 = await with_request_store({ event, state }, () => fn2(form_data));
5634
6249
  return json(
@@ -5636,10 +6251,7 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5636
6251
  {
5637
6252
  type: "result",
5638
6253
  result: stringify(data2, transport),
5639
- refreshes: await serialize_refreshes(
5640
- /** @type {string[]} */
5641
- form_client_refreshes
5642
- )
6254
+ refreshes: data2.issues ? {} : await serialize_refreshes(form_client_refreshes)
5643
6255
  }
5644
6256
  );
5645
6257
  }
@@ -5656,7 +6268,7 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5656
6268
  }
5657
6269
  );
5658
6270
  }
5659
- const payload = info.type === "prerender" ? prerender_args : (
6271
+ const payload = info.type === "prerender" ? additional_args : (
5660
6272
  /** @type {string} */
5661
6273
  // new URL(...) necessary because we're hiding the URL from the user in the event object
5662
6274
  new URL(event.request.url).searchParams.get("payload")
@@ -5674,20 +6286,27 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5674
6286
  );
5675
6287
  } catch (error2) {
5676
6288
  if (error2 instanceof Redirect) {
5677
- return json({
5678
- type: "redirect",
5679
- location: error2.location,
5680
- refreshes: await serialize_refreshes(form_client_refreshes ?? [])
5681
- });
6289
+ return json(
6290
+ /** @type {RemoteFunctionResponse} */
6291
+ {
6292
+ type: "redirect",
6293
+ location: error2.location,
6294
+ refreshes: await serialize_refreshes(form_client_refreshes ?? [])
6295
+ }
6296
+ );
5682
6297
  }
6298
+ const status = error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500;
5683
6299
  return json(
5684
6300
  /** @type {RemoteFunctionResponse} */
5685
6301
  {
5686
6302
  type: "error",
5687
6303
  error: await handle_error_and_jsonify(event, state, options2, error2),
5688
- status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500
6304
+ status
5689
6305
  },
5690
6306
  {
6307
+ // By setting a non-200 during prerendering we fail the prerender process (unless handleHttpError handles it).
6308
+ // Errors at runtime will be passed to the client and are handled there
6309
+ status: state.prerendering ? status : void 0,
5691
6310
  headers: {
5692
6311
  "cache-control": "private, no-store"
5693
6312
  }
@@ -5695,37 +6314,37 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5695
6314
  );
5696
6315
  }
5697
6316
  async function serialize_refreshes(client_refreshes) {
5698
- const refreshes = {
5699
- ...state.refreshes,
5700
- ...Object.fromEntries(
6317
+ const refreshes = state.refreshes ?? {};
6318
+ for (const key2 of client_refreshes) {
6319
+ if (refreshes[key2] !== void 0) continue;
6320
+ const [hash3, name2, payload] = key2.split("/");
6321
+ const loader = manifest._.remotes[hash3];
6322
+ const fn2 = (await loader?.())?.default?.[name2];
6323
+ if (!fn2) error(400, "Bad Request");
6324
+ refreshes[key2] = with_request_store(
6325
+ { event, state },
6326
+ () => fn2(parse_remote_arg(payload, transport))
6327
+ );
6328
+ }
6329
+ if (Object.keys(refreshes).length === 0) {
6330
+ return void 0;
6331
+ }
6332
+ return stringify(
6333
+ Object.fromEntries(
5701
6334
  await Promise.all(
5702
- client_refreshes.map(async (key2) => {
5703
- const [hash3, name2, payload] = key2.split("/");
5704
- const loader = manifest._.remotes[hash3];
5705
- if (!loader) error(400, "Bad Request");
5706
- const module2 = await loader();
5707
- const fn2 = module2[name2];
5708
- if (!fn2) error(400, "Bad Request");
5709
- return [
5710
- key2,
5711
- await with_request_store(
5712
- { event, state },
5713
- () => fn2(parse_remote_arg(payload, transport))
5714
- )
5715
- ];
5716
- })
6335
+ Object.entries(refreshes).map(async ([key2, promise]) => [key2, await promise])
5717
6336
  )
5718
- )
5719
- };
5720
- return Object.keys(refreshes).length > 0 ? stringify(refreshes, transport) : void 0;
6337
+ ),
6338
+ transport
6339
+ );
5721
6340
  }
5722
6341
  }
5723
6342
  async function handle_remote_form_post(event, state, manifest, id) {
5724
6343
  return record_span({
5725
6344
  name: "sveltekit.remote.form.post",
5726
6345
  attributes: {},
5727
- fn: (current) => {
5728
- const traced_event = merge_tracing(event, current);
6346
+ fn: (current2) => {
6347
+ const traced_event = merge_tracing(event, current2);
5729
6348
  return with_request_store(
5730
6349
  { event: traced_event, state },
5731
6350
  () => handle_remote_form_post_internal(traced_event, state, manifest, id)
@@ -5738,8 +6357,8 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
5738
6357
  const remotes = manifest._.remotes;
5739
6358
  const module = await remotes[hash2]?.();
5740
6359
  let form = (
5741
- /** @type {RemoteForm<any>} */
5742
- module?.[name]
6360
+ /** @type {RemoteForm<any, any>} */
6361
+ module?.default[name]
5743
6362
  );
5744
6363
  if (!form) {
5745
6364
  event.setHeaders({
@@ -5766,6 +6385,9 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
5766
6385
  /** @type {any} */
5767
6386
  form.__.fn
5768
6387
  );
6388
+ if (action_id && !form_data.has("id")) {
6389
+ form_data.set("sveltekit:id", decodeURIComponent(action_id));
6390
+ }
5769
6391
  await with_request_store({ event, state }, () => fn(form_data));
5770
6392
  return {
5771
6393
  type: "success",
@@ -5861,11 +6483,14 @@ async function render_page(event, event_state, page, options2, manifest, state,
5861
6483
  options: options2,
5862
6484
  manifest,
5863
6485
  state,
5864
- resolve_opts
6486
+ resolve_opts,
6487
+ data_serializer: server_data_serializer(event, event_state, options2)
5865
6488
  });
5866
6489
  }
5867
6490
  const branch = [];
5868
6491
  let load_error = null;
6492
+ const data_serializer = server_data_serializer(event, event_state, options2);
6493
+ const data_serializer_json = state.prerendering && should_prerender_data ? server_data_serializer_json(event, event_state, options2) : null;
5869
6494
  const server_promises = nodes.data.map((node, i) => {
5870
6495
  if (load_error) {
5871
6496
  throw load_error;
@@ -5875,7 +6500,7 @@ async function render_page(event, event_state, page, options2, manifest, state,
5875
6500
  if (node === leaf_node && action_result?.type === "error") {
5876
6501
  throw action_result.error;
5877
6502
  }
5878
- return await load_server_data({
6503
+ const server_data = await load_server_data({
5879
6504
  event,
5880
6505
  event_state,
5881
6506
  state,
@@ -5889,6 +6514,11 @@ async function render_page(event, event_state, page, options2, manifest, state,
5889
6514
  return data;
5890
6515
  }
5891
6516
  });
6517
+ if (node) {
6518
+ data_serializer.add_node(i, server_data);
6519
+ }
6520
+ data_serializer_json?.add_node(i, server_data);
6521
+ return server_data;
5892
6522
  } catch (e) {
5893
6523
  load_error = /** @type {Error} */
5894
6524
  e;
@@ -5961,6 +6591,7 @@ async function render_page(event, event_state, page, options2, manifest, state,
5961
6591
  const node2 = await manifest._.nodes[index]();
5962
6592
  let j = i;
5963
6593
  while (!branch[j]) j -= 1;
6594
+ data_serializer.set_max_nodes(j + 1);
5964
6595
  const layouts = compact(branch.slice(0, j + 1));
5965
6596
  const nodes2 = new PageNodes(layouts.map((layout) => layout.node));
5966
6597
  return await render_response({
@@ -5981,7 +6612,8 @@ async function render_page(event, event_state, page, options2, manifest, state,
5981
6612
  data: null,
5982
6613
  server_data: null
5983
6614
  }),
5984
- fetched
6615
+ fetched,
6616
+ data_serializer
5985
6617
  });
5986
6618
  }
5987
6619
  }
@@ -5991,13 +6623,8 @@ async function render_page(event, event_state, page, options2, manifest, state,
5991
6623
  branch.push(null);
5992
6624
  }
5993
6625
  }
5994
- if (state.prerendering && should_prerender_data) {
5995
- let { data, chunks } = get_data_json(
5996
- event,
5997
- event_state,
5998
- options2,
5999
- branch.map((node) => node?.server_data)
6000
- );
6626
+ if (state.prerendering && data_serializer_json) {
6627
+ let { data, chunks } = data_serializer_json.get_data();
6001
6628
  if (chunks) {
6002
6629
  for await (const chunk of chunks) {
6003
6630
  data += chunk;
@@ -6023,7 +6650,8 @@ async function render_page(event, event_state, page, options2, manifest, state,
6023
6650
  error: null,
6024
6651
  branch: ssr === false ? [] : compact(branch),
6025
6652
  action_result,
6026
- fetched
6653
+ fetched,
6654
+ data_serializer: ssr === false ? server_data_serializer(event, event_state, options2) : data_serializer
6027
6655
  });
6028
6656
  } catch (e) {
6029
6657
  return await respond_with_error({
@@ -6038,17 +6666,162 @@ async function render_page(event, event_state, page, options2, manifest, state,
6038
6666
  });
6039
6667
  }
6040
6668
  }
6669
+ function once(fn) {
6670
+ let done = false;
6671
+ let result;
6672
+ return () => {
6673
+ if (done) return result;
6674
+ done = true;
6675
+ return result = fn();
6676
+ };
6677
+ }
6678
+ async function render_data(event, event_state, route, options2, manifest, state, invalidated_data_nodes, trailing_slash) {
6679
+ if (!route.page) {
6680
+ return new Response(void 0, {
6681
+ status: 404
6682
+ });
6683
+ }
6684
+ try {
6685
+ const node_ids = [...route.page.layouts, route.page.leaf];
6686
+ const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
6687
+ let aborted = false;
6688
+ const url = new URL(event.url);
6689
+ url.pathname = normalize_path(url.pathname, trailing_slash);
6690
+ const new_event = { ...event, url };
6691
+ const functions = node_ids.map((n, i) => {
6692
+ return once(async () => {
6693
+ try {
6694
+ if (aborted) {
6695
+ return (
6696
+ /** @type {import('types').ServerDataSkippedNode} */
6697
+ {
6698
+ type: "skip"
6699
+ }
6700
+ );
6701
+ }
6702
+ const node = n == void 0 ? n : await manifest._.nodes[n]();
6703
+ return load_server_data({
6704
+ event: new_event,
6705
+ event_state,
6706
+ state,
6707
+ node,
6708
+ parent: async () => {
6709
+ const data2 = {};
6710
+ for (let j = 0; j < i; j += 1) {
6711
+ const parent = (
6712
+ /** @type {import('types').ServerDataNode | null} */
6713
+ await functions[j]()
6714
+ );
6715
+ if (parent) {
6716
+ Object.assign(data2, parent.data);
6717
+ }
6718
+ }
6719
+ return data2;
6720
+ }
6721
+ });
6722
+ } catch (e) {
6723
+ aborted = true;
6724
+ throw e;
6725
+ }
6726
+ });
6727
+ });
6728
+ const promises = functions.map(async (fn, i) => {
6729
+ if (!invalidated[i]) {
6730
+ return (
6731
+ /** @type {import('types').ServerDataSkippedNode} */
6732
+ {
6733
+ type: "skip"
6734
+ }
6735
+ );
6736
+ }
6737
+ return fn();
6738
+ });
6739
+ let length = promises.length;
6740
+ const nodes = await Promise.all(
6741
+ promises.map(
6742
+ (p, i) => p.catch(async (error2) => {
6743
+ if (error2 instanceof Redirect) {
6744
+ throw error2;
6745
+ }
6746
+ length = Math.min(length, i + 1);
6747
+ return (
6748
+ /** @type {import('types').ServerErrorNode} */
6749
+ {
6750
+ type: "error",
6751
+ error: await handle_error_and_jsonify(event, event_state, options2, error2),
6752
+ status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : void 0
6753
+ }
6754
+ );
6755
+ })
6756
+ )
6757
+ );
6758
+ const data_serializer = server_data_serializer_json(event, event_state, options2);
6759
+ for (let i = 0; i < nodes.length; i++) data_serializer.add_node(i, nodes[i]);
6760
+ const { data, chunks } = data_serializer.get_data();
6761
+ if (!chunks) {
6762
+ return json_response(data);
6763
+ }
6764
+ return new Response(
6765
+ new ReadableStream({
6766
+ async start(controller) {
6767
+ controller.enqueue(text_encoder.encode(data));
6768
+ for await (const chunk of chunks) {
6769
+ controller.enqueue(text_encoder.encode(chunk));
6770
+ }
6771
+ controller.close();
6772
+ },
6773
+ type: "bytes"
6774
+ }),
6775
+ {
6776
+ headers: {
6777
+ // we use a proprietary content type to prevent buffering.
6778
+ // the `text` prefix makes it inspectable
6779
+ "content-type": "text/sveltekit-data",
6780
+ "cache-control": "private, no-store"
6781
+ }
6782
+ }
6783
+ );
6784
+ } catch (e) {
6785
+ const error2 = normalize_error(e);
6786
+ if (error2 instanceof Redirect) {
6787
+ return redirect_json_response(error2);
6788
+ } else {
6789
+ return json_response(await handle_error_and_jsonify(event, event_state, options2, error2), 500);
6790
+ }
6791
+ }
6792
+ }
6793
+ function json_response(json2, status = 200) {
6794
+ return text(typeof json2 === "string" ? json2 : JSON.stringify(json2), {
6795
+ status,
6796
+ headers: {
6797
+ "content-type": "application/json",
6798
+ "cache-control": "private, no-store"
6799
+ }
6800
+ });
6801
+ }
6802
+ function redirect_json_response(redirect) {
6803
+ return json_response(
6804
+ /** @type {import('types').ServerRedirectNode} */
6805
+ {
6806
+ type: "redirect",
6807
+ location: redirect.location
6808
+ }
6809
+ );
6810
+ }
6041
6811
  const INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
6042
6812
  function validate_options(options2) {
6043
6813
  if (options2?.path === void 0) {
6044
6814
  throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
6045
6815
  }
6046
6816
  }
6817
+ function generate_cookie_key(domain, path, name) {
6818
+ return `${domain || ""}${path}?${encodeURIComponent(name)}`;
6819
+ }
6047
6820
  function get_cookies(request, url) {
6048
6821
  const header = request.headers.get("cookie") ?? "";
6049
6822
  const initial_cookies = parse$1(header, { decode: (value) => value });
6050
6823
  let normalized_url;
6051
- const new_cookies = {};
6824
+ const new_cookies = /* @__PURE__ */ new Map();
6052
6825
  const defaults = {
6053
6826
  httpOnly: true,
6054
6827
  sameSite: "lax",
@@ -6064,9 +6837,11 @@ function get_cookies(request, url) {
6064
6837
  * @param {import('cookie').CookieParseOptions} [opts]
6065
6838
  */
6066
6839
  get(name, opts) {
6067
- const c = new_cookies[name];
6068
- if (c && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
6069
- return c.value;
6840
+ const best_match = Array.from(new_cookies.values()).filter((c) => {
6841
+ return c.name === name && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path);
6842
+ }).sort((a, b) => b.options.path.length - a.options.path.length)[0];
6843
+ if (best_match) {
6844
+ return best_match.options.maxAge === 0 ? void 0 : best_match.value;
6070
6845
  }
6071
6846
  const req_cookies = parse$1(header, { decode: opts?.decode });
6072
6847
  const cookie = req_cookies[name];
@@ -6077,11 +6852,18 @@ function get_cookies(request, url) {
6077
6852
  */
6078
6853
  getAll(opts) {
6079
6854
  const cookies2 = parse$1(header, { decode: opts?.decode });
6080
- for (const c of Object.values(new_cookies)) {
6855
+ const lookup = /* @__PURE__ */ new Map();
6856
+ for (const c of new_cookies.values()) {
6081
6857
  if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
6082
- cookies2[c.name] = c.value;
6858
+ const existing = lookup.get(c.name);
6859
+ if (!existing || c.options.path.length > existing.options.path.length) {
6860
+ lookup.set(c.name, c);
6861
+ }
6083
6862
  }
6084
6863
  }
6864
+ for (const c of lookup.values()) {
6865
+ cookies2[c.name] = c.value;
6866
+ }
6085
6867
  return Object.entries(cookies2).map(([name, value]) => ({ name, value }));
6086
6868
  },
6087
6869
  /**
@@ -6131,8 +6913,7 @@ function get_cookies(request, url) {
6131
6913
  // cookies sent by the user agent have lowest precedence
6132
6914
  ...initial_cookies
6133
6915
  };
6134
- for (const key2 in new_cookies) {
6135
- const cookie = new_cookies[key2];
6916
+ for (const cookie of new_cookies.values()) {
6136
6917
  if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
6137
6918
  if (!path_matches(destination.pathname, cookie.options.path)) continue;
6138
6919
  const encoder = cookie.options.encode || encodeURIComponent;
@@ -6156,7 +6937,9 @@ function get_cookies(request, url) {
6156
6937
  if (!options2.domain || options2.domain === url.hostname) {
6157
6938
  path = resolve(normalized_url, path);
6158
6939
  }
6159
- new_cookies[name] = { name, value, options: { ...options2, path } };
6940
+ const cookie_key = generate_cookie_key(options2.domain, path, name);
6941
+ const cookie = { name, value, options: { ...options2, path } };
6942
+ new_cookies.set(cookie_key, cookie);
6160
6943
  }
6161
6944
  function set_trailing_slash(trailing_slash) {
6162
6945
  normalized_url = normalize_path(url.pathname, trailing_slash);
@@ -6351,23 +7134,23 @@ async function internal_respond(request, options2, manifest, state) {
6351
7134
  const is_route_resolution_request = has_resolution_suffix(url.pathname);
6352
7135
  const is_data_request = has_data_suffix(url.pathname);
6353
7136
  const remote_id = get_remote_id(url);
6354
- if (options2.csrf_check_origin && request.headers.get("origin") !== url.origin) {
6355
- const opts = { status: 403 };
6356
- if (remote_id && request.method !== "GET") {
6357
- return json(
6358
- {
6359
- message: "Cross-site remote requests are forbidden"
6360
- },
6361
- opts
6362
- );
6363
- }
6364
- const forbidden = is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE");
6365
- if (forbidden) {
6366
- const message = `Cross-site ${request.method} form submissions are forbidden`;
6367
- if (request.headers.get("accept") === "application/json") {
6368
- return json({ message }, opts);
7137
+ {
7138
+ const request_origin = request.headers.get("origin");
7139
+ if (remote_id) {
7140
+ if (request.method !== "GET" && request_origin !== url.origin) {
7141
+ const message = "Cross-site remote requests are forbidden";
7142
+ return json({ message }, { status: 403 });
7143
+ }
7144
+ } else if (options2.csrf_check_origin) {
7145
+ const forbidden = is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request_origin !== url.origin && (!request_origin || !options2.csrf_trusted_origins.includes(request_origin));
7146
+ if (forbidden) {
7147
+ const message = `Cross-site ${request.method} form submissions are forbidden`;
7148
+ const opts = { status: 403 };
7149
+ if (request.headers.get("accept") === "application/json") {
7150
+ return json({ message }, opts);
7151
+ }
7152
+ return text(message, opts);
6369
7153
  }
6370
- return text(message, opts);
6371
7154
  }
6372
7155
  }
6373
7156
  if (options2.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") {
@@ -6382,8 +7165,8 @@ async function internal_respond(request, options2, manifest, state) {
6382
7165
  invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
6383
7166
  url.searchParams.delete(INVALIDATED_PARAM);
6384
7167
  } else if (remote_id) {
6385
- url.pathname = base;
6386
- url.search = "";
7168
+ url.pathname = request.headers.get("x-sveltekit-pathname") ?? base;
7169
+ url.search = request.headers.get("x-sveltekit-search") ?? "";
6387
7170
  }
6388
7171
  const headers2 = {};
6389
7172
  const { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(
@@ -6396,7 +7179,8 @@ async function internal_respond(request, options2, manifest, state) {
6396
7179
  handleValidationError: options2.hooks.handleValidationError,
6397
7180
  tracing: {
6398
7181
  record_span
6399
- }
7182
+ },
7183
+ is_in_remote_function: false
6400
7184
  };
6401
7185
  const event = {
6402
7186
  cookies,
@@ -6502,7 +7286,7 @@ async function internal_respond(request, options2, manifest, state) {
6502
7286
  headers22.set("cache-control", "public, max-age=0, must-revalidate");
6503
7287
  return text("Not found", { status: 404, headers: headers22 });
6504
7288
  }
6505
- if (!state.prerendering?.fallback && !remote_id) {
7289
+ if (!state.prerendering?.fallback) {
6506
7290
  const matchers = await manifest._.matchers();
6507
7291
  for (const candidate of manifest._.routes) {
6508
7292
  const match = candidate.pattern.exec(resolved_path);
@@ -6524,7 +7308,7 @@ async function internal_respond(request, options2, manifest, state) {
6524
7308
  let trailing_slash = "never";
6525
7309
  try {
6526
7310
  const page_nodes = route?.page ? new PageNodes(await load_page_nodes(route.page, manifest)) : void 0;
6527
- if (route) {
7311
+ if (route && !remote_id) {
6528
7312
  if (url.pathname === base || url.pathname === base + "/") {
6529
7313
  trailing_slash = "always";
6530
7314
  } else if (page_nodes) {
@@ -6614,7 +7398,7 @@ async function internal_respond(request, options2, manifest, state) {
6614
7398
  value
6615
7399
  );
6616
7400
  }
6617
- add_cookies_to_headers(response2.headers, Object.values(new_cookies));
7401
+ add_cookies_to_headers(response2.headers, new_cookies.values());
6618
7402
  if (state.prerendering && event2.route.id !== null) {
6619
7403
  response2.headers.set("x-sveltekit-routeid", encodeURI(event2.route.id));
6620
7404
  }
@@ -6674,8 +7458,8 @@ async function internal_respond(request, options2, manifest, state) {
6674
7458
  return response;
6675
7459
  } catch (e) {
6676
7460
  if (e instanceof Redirect) {
6677
- const response = is_data_request ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
6678
- add_cookies_to_headers(response.headers, Object.values(new_cookies));
7461
+ const response = is_data_request || remote_id ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
7462
+ add_cookies_to_headers(response.headers, new_cookies.values());
6679
7463
  return response;
6680
7464
  }
6681
7465
  return await handle_fatal_error(event, event_state, options2, e);
@@ -6701,7 +7485,8 @@ async function internal_respond(request, options2, manifest, state) {
6701
7485
  error: null,
6702
7486
  branch: [],
6703
7487
  fetched: [],
6704
- resolve_opts
7488
+ resolve_opts,
7489
+ data_serializer: server_data_serializer(event2, event_state, options2)
6705
7490
  });
6706
7491
  }
6707
7492
  if (remote_id) {
@@ -6712,9 +7497,9 @@ async function internal_respond(request, options2, manifest, state) {
6712
7497
  /** @type {import('types').HttpMethod} */
6713
7498
  event2.request.method
6714
7499
  );
6715
- let response;
7500
+ let response2;
6716
7501
  if (is_data_request) {
6717
- response = await render_data(
7502
+ response2 = await render_data(
6718
7503
  event2,
6719
7504
  event_state,
6720
7505
  route,
@@ -6725,12 +7510,12 @@ async function internal_respond(request, options2, manifest, state) {
6725
7510
  trailing_slash
6726
7511
  );
6727
7512
  } else if (route.endpoint && (!route.page || is_endpoint_request(event2))) {
6728
- response = await render_endpoint(event2, event_state, await route.endpoint(), state);
7513
+ response2 = await render_endpoint(event2, event_state, await route.endpoint(), state);
6729
7514
  } else if (route.page) {
6730
7515
  if (!page_nodes) {
6731
7516
  throw new Error("page_nodes not found. This should never happen");
6732
7517
  } else if (page_methods.has(method)) {
6733
- response = await render_page(
7518
+ response2 = await render_page(
6734
7519
  event2,
6735
7520
  event_state,
6736
7521
  route.page,
@@ -6747,7 +7532,7 @@ async function internal_respond(request, options2, manifest, state) {
6747
7532
  allowed_methods2.add("POST");
6748
7533
  }
6749
7534
  if (method === "OPTIONS") {
6750
- response = new Response(null, {
7535
+ response2 = new Response(null, {
6751
7536
  status: 204,
6752
7537
  headers: {
6753
7538
  allow: Array.from(allowed_methods2.values()).join(", ")
@@ -6762,24 +7547,24 @@ async function internal_respond(request, options2, manifest, state) {
6762
7547
  /** @type {Record<string, any>} */
6763
7548
  {}
6764
7549
  );
6765
- response = method_not_allowed(mod, method);
7550
+ response2 = method_not_allowed(mod, method);
6766
7551
  }
6767
7552
  }
6768
7553
  } else {
6769
7554
  throw new Error("Route is neither page nor endpoint. This should never happen");
6770
7555
  }
6771
7556
  if (request.method === "GET" && route.page && route.endpoint) {
6772
- const vary = response.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
7557
+ const vary = response2.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
6773
7558
  if (!(vary?.includes("accept") || vary?.includes("*"))) {
6774
- response = new Response(response.body, {
6775
- status: response.status,
6776
- statusText: response.statusText,
6777
- headers: new Headers(response.headers)
7559
+ response2 = new Response(response2.body, {
7560
+ status: response2.status,
7561
+ statusText: response2.statusText,
7562
+ headers: new Headers(response2.headers)
6778
7563
  });
6779
- response.headers.append("Vary", "Accept");
7564
+ response2.headers.append("Vary", "Accept");
6780
7565
  }
6781
7566
  }
6782
- return response;
7567
+ return response2;
6783
7568
  }
6784
7569
  if (state.error && event2.isSubRequest) {
6785
7570
  const headers22 = new Headers(request.headers);
@@ -6807,7 +7592,8 @@ async function internal_respond(request, options2, manifest, state) {
6807
7592
  if (state.prerendering) {
6808
7593
  return text("not found", { status: 404 });
6809
7594
  }
6810
- return await fetch(request);
7595
+ const response = await fetch(request);
7596
+ return new Response(response.body, response);
6811
7597
  } catch (e) {
6812
7598
  return await handle_fatal_error(event2, event_state, options2, e);
6813
7599
  } finally {
@@ -6834,23 +7620,17 @@ function propagate_context(fn) {
6834
7620
  }
6835
7621
  };
6836
7622
  }
6837
- function filter_private_env(env, { public_prefix, private_prefix }) {
6838
- return Object.fromEntries(
6839
- Object.entries(env).filter(
6840
- ([k]) => k.startsWith(private_prefix) && (public_prefix === "" || !k.startsWith(public_prefix))
6841
- )
6842
- );
6843
- }
6844
- function filter_public_env(env, { public_prefix, private_prefix }) {
7623
+ function filter_env(env, allowed, disallowed) {
6845
7624
  return Object.fromEntries(
6846
7625
  Object.entries(env).filter(
6847
- ([k]) => k.startsWith(public_prefix) && (private_prefix === "" || !k.startsWith(private_prefix))
7626
+ ([k]) => k.startsWith(allowed) && (disallowed === "" || !k.startsWith(disallowed))
6848
7627
  )
6849
7628
  );
6850
7629
  }
6851
7630
  function set_app(value) {
6852
7631
  }
6853
7632
  let init_promise;
7633
+ let current = null;
6854
7634
  class Server {
6855
7635
  /** @type {import('types').SSROptions} */
6856
7636
  #options;
@@ -6860,21 +7640,27 @@ class Server {
6860
7640
  constructor(manifest) {
6861
7641
  this.#options = options;
6862
7642
  this.#manifest = manifest;
7643
+ if (IN_WEBCONTAINER) {
7644
+ const respond2 = this.respond.bind(this);
7645
+ this.respond = async (...args) => {
7646
+ const { promise, resolve: resolve2 } = (
7647
+ /** @type {PromiseWithResolvers<void>} */
7648
+ with_resolvers()
7649
+ );
7650
+ const previous = current;
7651
+ current = promise;
7652
+ await previous;
7653
+ return respond2(...args).finally(resolve2);
7654
+ };
7655
+ }
6863
7656
  }
6864
7657
  /**
6865
7658
  * @param {import('@sveltejs/kit').ServerInitOptions} opts
6866
7659
  */
6867
7660
  async init({ env, read }) {
6868
- const prefixes = {
6869
- public_prefix: this.#options.env_public_prefix,
6870
- private_prefix: this.#options.env_private_prefix
6871
- };
6872
- filter_private_env(env, prefixes);
6873
- const public_env2 = filter_public_env(env, prefixes);
6874
- set_public_env(
6875
- public_env2
6876
- );
6877
- set_safe_public_env(public_env2);
7661
+ const { env_public_prefix, env_private_prefix } = this.#options;
7662
+ set_private_env(filter_env(env, env_private_prefix, env_public_prefix));
7663
+ set_public_env(filter_env(env, env_public_prefix, env_private_prefix));
6878
7664
  if (read) {
6879
7665
  const wrapped_read = (file) => {
6880
7666
  const result = read(file);
@@ -6910,8 +7696,15 @@ class Server {
6910
7696
  const module = await get_hooks();
6911
7697
  this.#options.hooks = {
6912
7698
  handle: module.handle || (({ event, resolve: resolve2 }) => resolve2(event)),
6913
- handleError: module.handleError || (({ status, error: error2 }) => console.error(status === 404 && /** @type {Error} */
6914
- error2?.message || error2)),
7699
+ handleError: module.handleError || (({ status, error: error2, event }) => {
7700
+ const error_message = format_server_error(
7701
+ status,
7702
+ /** @type {Error} */
7703
+ error2,
7704
+ event
7705
+ );
7706
+ console.error(error_message);
7707
+ }),
6915
7708
  handleFetch: module.handleFetch || (({ request, fetch: fetch2 }) => fetch2(request)),
6916
7709
  handleValidationError: module.handleValidationError || (({ issues }) => {
6917
7710
  console.error("Remote function schema validation failed:", issues);