fundus 0.0.2 → 0.0.3

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 (300) hide show
  1. package/README.md +58 -0
  2. package/build/client/_app/immutable/assets/0.DLhIsYA_.css.br +0 -0
  3. package/build/client/_app/immutable/assets/0.DLhIsYA_.css.gz +0 -0
  4. package/build/client/_app/immutable/assets/2.wavcNhPC.css +1 -0
  5. package/build/client/_app/immutable/assets/2.wavcNhPC.css.br +0 -0
  6. package/build/client/_app/immutable/assets/2.wavcNhPC.css.gz +0 -0
  7. package/build/client/_app/immutable/assets/3.Cjh_fXPY.css +1 -0
  8. package/build/client/_app/immutable/assets/3.Cjh_fXPY.css.br +0 -0
  9. package/build/client/_app/immutable/assets/3.Cjh_fXPY.css.gz +0 -0
  10. package/build/client/_app/immutable/assets/4.p004hmEN.css +1 -0
  11. package/build/client/_app/immutable/assets/4.p004hmEN.css.br +0 -0
  12. package/build/client/_app/immutable/assets/4.p004hmEN.css.gz +0 -0
  13. package/build/client/_app/immutable/assets/ConfirmDialog.BdKlitwi.css +1 -0
  14. package/build/client/_app/immutable/assets/ConfirmDialog.BdKlitwi.css.br +0 -0
  15. package/build/client/_app/immutable/assets/ConfirmDialog.BdKlitwi.css.gz +0 -0
  16. package/build/client/_app/immutable/assets/LibraryContextMenu.zyZtpKzC.css +1 -0
  17. package/build/client/_app/immutable/assets/LibraryContextMenu.zyZtpKzC.css.br +0 -0
  18. package/build/client/_app/immutable/assets/LibraryContextMenu.zyZtpKzC.css.gz +0 -0
  19. package/build/client/_app/immutable/chunks/BiIto6ft.js +1 -0
  20. package/build/client/_app/immutable/chunks/BiIto6ft.js.br +0 -0
  21. package/build/client/_app/immutable/chunks/BiIto6ft.js.gz +0 -0
  22. package/build/client/_app/immutable/chunks/Bjy-W4x2.js.br +0 -0
  23. package/build/client/_app/immutable/chunks/Bjy-W4x2.js.gz +0 -0
  24. package/build/client/_app/immutable/chunks/CNRz3sSw.js.br +0 -0
  25. package/build/client/_app/immutable/chunks/CNRz3sSw.js.gz +0 -0
  26. package/build/client/_app/immutable/chunks/CO4RBJfa.js.br +0 -0
  27. package/build/client/_app/immutable/chunks/CO4RBJfa.js.gz +0 -0
  28. package/{dist/editor/_app/immutable/chunks/DjvOiDmq.js → build/client/_app/immutable/chunks/CvY6YsFE.js} +1 -1
  29. package/build/client/_app/immutable/chunks/CvY6YsFE.js.br +0 -0
  30. package/build/client/_app/immutable/chunks/CvY6YsFE.js.gz +0 -0
  31. package/build/client/_app/immutable/chunks/DL0_39Ys.js +5 -0
  32. package/build/client/_app/immutable/chunks/DL0_39Ys.js.br +0 -0
  33. package/build/client/_app/immutable/chunks/DL0_39Ys.js.gz +0 -0
  34. package/{dist/editor/_app/immutable/chunks/BfPE5wdt.js → build/client/_app/immutable/chunks/DQ8SXFaX.js} +1 -1
  35. package/build/client/_app/immutable/chunks/DQ8SXFaX.js.br +0 -0
  36. package/build/client/_app/immutable/chunks/DQ8SXFaX.js.gz +0 -0
  37. package/build/client/_app/immutable/chunks/DjdrdRzT.js.br +0 -0
  38. package/build/client/_app/immutable/chunks/DjdrdRzT.js.gz +0 -0
  39. package/build/client/_app/immutable/chunks/xihTtKlq.js.br +1 -0
  40. package/build/client/_app/immutable/chunks/xihTtKlq.js.gz +0 -0
  41. package/{dist/editor/_app/immutable/entry/app.BkqbfI8n.js → build/client/_app/immutable/entry/app.ubN0v9bN.js} +2 -2
  42. package/build/client/_app/immutable/entry/app.ubN0v9bN.js.br +0 -0
  43. package/build/client/_app/immutable/entry/app.ubN0v9bN.js.gz +0 -0
  44. package/build/client/_app/immutable/entry/start.BW8dBDh6.js +1 -0
  45. package/build/client/_app/immutable/entry/start.BW8dBDh6.js.br +0 -0
  46. package/build/client/_app/immutable/entry/start.BW8dBDh6.js.gz +0 -0
  47. package/{dist/editor/_app/immutable/nodes/0.xdMI5GEU.js → build/client/_app/immutable/nodes/0.Dr5ijCIl.js} +1 -1
  48. package/build/client/_app/immutable/nodes/0.Dr5ijCIl.js.br +0 -0
  49. package/build/client/_app/immutable/nodes/0.Dr5ijCIl.js.gz +0 -0
  50. package/{dist/editor/_app/immutable/nodes/1.D9p2tfoJ.js → build/client/_app/immutable/nodes/1.DiIGIRAb.js} +1 -1
  51. package/build/client/_app/immutable/nodes/1.DiIGIRAb.js.br +3 -0
  52. package/build/client/_app/immutable/nodes/1.DiIGIRAb.js.gz +0 -0
  53. package/{dist/editor/_app/immutable/nodes/2.BrA0Hyzu.js → build/client/_app/immutable/nodes/2.B8KYmQcV.js} +3 -3
  54. package/build/client/_app/immutable/nodes/2.B8KYmQcV.js.br +0 -0
  55. package/build/client/_app/immutable/nodes/2.B8KYmQcV.js.gz +0 -0
  56. package/build/client/_app/immutable/nodes/3.B1jc7arT.js +104 -0
  57. package/build/client/_app/immutable/nodes/3.B1jc7arT.js.br +0 -0
  58. package/build/client/_app/immutable/nodes/3.B1jc7arT.js.gz +0 -0
  59. package/build/client/_app/immutable/nodes/4.BPK9n1mH.js +2 -0
  60. package/build/client/_app/immutable/nodes/4.BPK9n1mH.js.br +0 -0
  61. package/build/client/_app/immutable/nodes/4.BPK9n1mH.js.gz +0 -0
  62. package/build/client/_app/version.json +1 -0
  63. package/build/client/_app/version.json.br +0 -0
  64. package/build/client/_app/version.json.gz +0 -0
  65. package/build/env.js +100 -0
  66. package/build/env.js.map +1 -0
  67. package/build/handler.js +22 -0
  68. package/build/handler.js.map +1 -0
  69. package/build/index.js +145 -0
  70. package/build/index.js.map +1 -0
  71. package/build/server/chunks/chunks/context.js-Bw4WWLhG.js +443 -0
  72. package/build/server/chunks/chunks/context.js-Bw4WWLhG.js.map +1 -0
  73. package/build/server/chunks/chunks/core.js-DDntpb72.js +409 -0
  74. package/build/server/chunks/chunks/core.js-DDntpb72.js.map +1 -0
  75. package/build/server/chunks/chunks/env.js-l0sNRNKZ.js +2 -0
  76. package/build/server/chunks/chunks/env.js-l0sNRNKZ.js.map +1 -0
  77. package/build/server/chunks/chunks/exports.js-CLTzaOxn.js +152 -0
  78. package/build/server/chunks/chunks/exports.js-CLTzaOxn.js.map +1 -0
  79. package/build/server/chunks/chunks/folder-path.js-ytx9ucgg.js +64 -0
  80. package/build/server/chunks/chunks/folder-path.js-ytx9ucgg.js.map +1 -0
  81. package/build/server/chunks/chunks/http.js-Dxoa-jtP.js +100 -0
  82. package/build/server/chunks/chunks/http.js-Dxoa-jtP.js.map +1 -0
  83. package/build/server/chunks/chunks/internal.js-BDBSzJId.js +5753 -0
  84. package/build/server/chunks/chunks/internal.js-BDBSzJId.js.map +1 -0
  85. package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js +22 -0
  86. package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js.map +1 -0
  87. package/{dist/operations-DYM-5KVl.js → build/server/chunks/chunks/library-store.js-BP8cL-qD.js} +344 -444
  88. package/build/server/chunks/chunks/library-store.js-BP8cL-qD.js.map +1 -0
  89. package/build/server/chunks/chunks/manifest-appearance.js-DTk355LQ.js +146 -0
  90. package/build/server/chunks/chunks/manifest-appearance.js-DTk355LQ.js.map +1 -0
  91. package/build/server/chunks/chunks/routing.js-y-tryuip.js +213 -0
  92. package/build/server/chunks/chunks/routing.js-y-tryuip.js.map +1 -0
  93. package/build/server/chunks/chunks/shared.js-BWXgl1Xf.js +255 -0
  94. package/build/server/chunks/chunks/shared.js-BWXgl1Xf.js.map +1 -0
  95. package/build/server/chunks/chunks/utils.js-9oI5Oz0w.js +1048 -0
  96. package/build/server/chunks/chunks/utils.js-9oI5Oz0w.js.map +1 -0
  97. package/build/server/chunks/entries/endpoints/api/_...path_/_server.ts.js-WknZVW_S.js +27 -0
  98. package/build/server/chunks/entries/endpoints/api/_...path_/_server.ts.js-WknZVW_S.js.map +1 -0
  99. package/build/server/chunks/entries/endpoints/api/assets/_id_/_server.ts.js-BrZ__-HZ.js +24 -0
  100. package/build/server/chunks/entries/endpoints/api/assets/_id_/_server.ts.js-BrZ__-HZ.js.map +1 -0
  101. package/build/server/chunks/entries/endpoints/api/assets/_server.ts.js-PqADGPXc.js +45 -0
  102. package/build/server/chunks/entries/endpoints/api/assets/_server.ts.js-PqADGPXc.js.map +1 -0
  103. package/build/server/chunks/entries/endpoints/api/assets/delete/_server.ts.js-OqoE5PN-.js +31 -0
  104. package/build/server/chunks/entries/endpoints/api/assets/delete/_server.ts.js-OqoE5PN-.js.map +1 -0
  105. package/build/server/chunks/entries/endpoints/api/assets/move/_server.ts.js-CJ08e1ho.js +31 -0
  106. package/build/server/chunks/entries/endpoints/api/assets/move/_server.ts.js-CJ08e1ho.js.map +1 -0
  107. package/build/server/chunks/entries/endpoints/api/folders/_path_/_server.ts.js-DdF3eK2I.js +38 -0
  108. package/build/server/chunks/entries/endpoints/api/folders/_path_/_server.ts.js-DdF3eK2I.js.map +1 -0
  109. package/build/server/chunks/entries/endpoints/api/folders/_server.ts.js-Cxt6jsJ5.js +31 -0
  110. package/build/server/chunks/entries/endpoints/api/folders/_server.ts.js-Cxt6jsJ5.js.map +1 -0
  111. package/build/server/chunks/entries/endpoints/api/manifests/_name_/_server.ts.js-BWVM2Ntl.js +24 -0
  112. package/build/server/chunks/entries/endpoints/api/manifests/_name_/_server.ts.js-BWVM2Ntl.js.map +1 -0
  113. package/build/server/chunks/entries/endpoints/api/manifests/_server.ts.js-Z2bM-qHM.js +31 -0
  114. package/build/server/chunks/entries/endpoints/api/manifests/_server.ts.js-Z2bM-qHM.js.map +1 -0
  115. package/build/server/chunks/entries/endpoints/api/state/_server.ts.js-BX9H2Z34.js +24 -0
  116. package/build/server/chunks/entries/endpoints/api/state/_server.ts.js-BX9H2Z34.js.map +1 -0
  117. package/build/server/chunks/entries/endpoints/files/_...path_/_server.ts.js-BWHDZ8mz.js +27 -0
  118. package/build/server/chunks/entries/endpoints/files/_...path_/_server.ts.js-BWHDZ8mz.js.map +1 -0
  119. package/build/server/chunks/entries/endpoints/files/proxy/_...path_/_server.ts.js-CR_7mndO.js +24 -0
  120. package/build/server/chunks/entries/endpoints/files/proxy/_...path_/_server.ts.js-CR_7mndO.js.map +1 -0
  121. package/build/server/chunks/entries/endpoints/files/raw/_...path_/_server.ts.js-Cw1PDBvb.js +24 -0
  122. package/build/server/chunks/entries/endpoints/files/raw/_...path_/_server.ts.js-Cw1PDBvb.js.map +1 -0
  123. package/build/server/chunks/entries/hooks.server.js-BHoE0yBi.js +23 -0
  124. package/build/server/chunks/entries/hooks.server.js-BHoE0yBi.js.map +1 -0
  125. package/build/server/chunks/handler-10cx4zHn.js +1475 -0
  126. package/build/server/chunks/handler-10cx4zHn.js.map +1 -0
  127. package/build/server/chunks/index.js-DvPfiC00.js +3789 -0
  128. package/build/server/chunks/index.js-DvPfiC00.js.map +1 -0
  129. package/build/server/chunks/manifest.js-DoPjUnzD.js +149 -0
  130. package/build/server/chunks/manifest.js-DoPjUnzD.js.map +1 -0
  131. package/build/server/chunks/nodes/0.js-Di3qgAtW.js +11 -0
  132. package/build/server/chunks/nodes/0.js-Di3qgAtW.js.map +1 -0
  133. package/build/server/chunks/nodes/1.js-BlWSFIA8.js +7 -0
  134. package/build/server/chunks/nodes/1.js-BlWSFIA8.js.map +1 -0
  135. package/build/server/chunks/nodes/2.js-CO9nSPUN.js +7 -0
  136. package/build/server/chunks/nodes/2.js-CO9nSPUN.js.map +1 -0
  137. package/build/server/chunks/nodes/3.js-C2D6xpEO.js +7 -0
  138. package/build/server/chunks/nodes/3.js-C2D6xpEO.js.map +1 -0
  139. package/build/server/chunks/nodes/4.js-B3IuagJW.js +7 -0
  140. package/build/server/chunks/nodes/4.js-B3IuagJW.js.map +1 -0
  141. package/build/shims.js +33 -0
  142. package/build/shims.js.map +1 -0
  143. package/dist/cli.d.ts +2 -1
  144. package/dist/cli.js +109 -1332
  145. package/dist/config.d.ts +3 -2
  146. package/dist/config.js +2 -2
  147. package/dist/core/api-types.d.ts +141 -0
  148. package/dist/core/api-types.js +1 -0
  149. package/dist/core/asset-id.d.ts +28 -0
  150. package/dist/core/asset-id.js +59 -0
  151. package/dist/core/asset-reference.d.ts +23 -0
  152. package/dist/core/asset-reference.js +15 -0
  153. package/dist/core/canonicalize.d.ts +9 -0
  154. package/dist/core/canonicalize.js +36 -0
  155. package/dist/core/chroma-key.d.ts +30 -0
  156. package/dist/core/chroma-key.js +55 -0
  157. package/dist/core/config.d.ts +35 -0
  158. package/dist/core/config.js +4 -0
  159. package/dist/core/folder-path.d.ts +19 -0
  160. package/dist/core/folder-path.js +86 -0
  161. package/dist/core/index.d.ts +33 -499
  162. package/dist/core/index.js +17 -962
  163. package/dist/core/ingest.d.ts +18 -0
  164. package/dist/core/ingest.js +58 -0
  165. package/dist/core/library.d.ts +54 -0
  166. package/dist/core/library.js +138 -0
  167. package/dist/core/manifest-appearance.d.ts +35 -0
  168. package/dist/core/manifest-appearance.js +123 -0
  169. package/dist/core/manifest-entry.d.ts +104 -0
  170. package/dist/core/manifest-entry.js +1 -0
  171. package/dist/core/manifest-membership.d.ts +56 -0
  172. package/dist/core/manifest-membership.js +54 -0
  173. package/dist/core/plugins/audio.d.ts +26 -0
  174. package/dist/core/plugins/audio.js +44 -0
  175. package/dist/core/plugins/chroma-key-video.d.ts +29 -0
  176. package/dist/core/plugins/chroma-key-video.js +69 -0
  177. package/dist/core/plugins/contract.d.ts +35 -0
  178. package/dist/core/plugins/contract.js +1 -0
  179. package/dist/core/plugins/image.d.ts +30 -0
  180. package/dist/core/plugins/image.js +45 -0
  181. package/dist/core/plugins/slice.d.ts +22 -0
  182. package/dist/core/plugins/slice.js +60 -0
  183. package/dist/core/plugins/video.d.ts +45 -0
  184. package/dist/core/plugins/video.js +77 -0
  185. package/dist/core/reference-graph.d.ts +41 -0
  186. package/dist/core/reference-graph.js +138 -0
  187. package/dist/core/slice-data.d.ts +61 -0
  188. package/dist/core/slice-data.js +49 -0
  189. package/dist/runtime/chroma-key-gl.d.ts +40 -22
  190. package/dist/runtime/chroma-key-gl.js +189 -183
  191. package/dist/runtime/components/ChromaKeyVideo.svelte +3 -3
  192. package/dist/runtime/components/ChromaKeyVideo.svelte.d.ts +21 -0
  193. package/dist/runtime/components/Image.svelte +1 -1
  194. package/dist/runtime/components/Image.svelte.d.ts +9 -0
  195. package/dist/runtime/components/Slice.svelte +1 -1
  196. package/dist/runtime/components/Slice.svelte.d.ts +19 -0
  197. package/dist/runtime/components/SliceCanvas.svelte +3 -3
  198. package/dist/runtime/components/SliceCanvas.svelte.d.ts +10 -0
  199. package/dist/runtime/components/SliceDom.svelte +3 -3
  200. package/dist/runtime/components/SliceDom.svelte.d.ts +10 -0
  201. package/dist/runtime/components/Video.svelte +2 -2
  202. package/dist/runtime/components/Video.svelte.d.ts +18 -0
  203. package/dist/runtime/geometry.d.ts +55 -35
  204. package/dist/runtime/geometry.js +186 -191
  205. package/dist/runtime/index.d.ts +9 -9
  206. package/dist/runtime/index.js +9 -9
  207. package/dist/runtime/kind-handlers.d.ts +33 -24
  208. package/dist/runtime/kind-handlers.js +74 -65
  209. package/dist/runtime/manifest.d.ts +53 -47
  210. package/dist/runtime/manifest.js +133 -113
  211. package/dist/runtime/observe-border-box-size.d.ts +1 -4
  212. package/dist/runtime/observe-border-box-size.js +9 -10
  213. package/dist/runtime/preload-registry.d.ts +22 -8
  214. package/dist/runtime/preload-registry.js +65 -62
  215. package/dist/server/build.d.ts +8 -0
  216. package/dist/server/build.js +25 -0
  217. package/dist/server/check.d.ts +24 -0
  218. package/dist/server/check.js +199 -0
  219. package/dist/server/cli-commands.d.ts +25 -0
  220. package/dist/server/cli-commands.js +1178 -0
  221. package/dist/server/cli-init.d.ts +3 -0
  222. package/dist/server/cli-init.js +53 -0
  223. package/dist/server/cli-io.d.ts +46 -0
  224. package/dist/server/cli-io.js +105 -0
  225. package/dist/server/codegen.d.ts +58 -0
  226. package/dist/server/codegen.js +185 -0
  227. package/dist/server/config-loader.d.ts +34 -0
  228. package/dist/server/config-loader.js +103 -0
  229. package/dist/server/context.d.ts +8 -0
  230. package/dist/server/context.js +19 -0
  231. package/dist/server/folder-filesystem.d.ts +7 -0
  232. package/dist/server/folder-filesystem.js +39 -0
  233. package/dist/server/http.d.ts +12 -0
  234. package/dist/server/http.js +100 -0
  235. package/dist/server/index.d.ts +16 -0
  236. package/dist/server/index.js +9 -0
  237. package/dist/server/job-hash.d.ts +10 -0
  238. package/dist/server/job-hash.js +23 -0
  239. package/dist/server/library-store.d.ts +82 -0
  240. package/dist/server/library-store.js +763 -0
  241. package/dist/server/operations.d.ts +87 -0
  242. package/dist/server/operations.js +427 -0
  243. package/dist/server/plugins/audio.d.ts +7 -0
  244. package/dist/server/plugins/audio.js +27 -0
  245. package/dist/server/plugins/chroma-key-video.d.ts +9 -0
  246. package/dist/server/plugins/chroma-key-video.js +38 -0
  247. package/dist/server/plugins/contract.d.ts +100 -0
  248. package/dist/server/plugins/contract.js +16 -0
  249. package/dist/server/plugins/image.d.ts +8 -0
  250. package/dist/server/plugins/image.js +30 -0
  251. package/dist/server/plugins/slice.d.ts +14 -0
  252. package/dist/server/plugins/slice.js +63 -0
  253. package/dist/server/plugins/video.d.ts +6 -0
  254. package/dist/server/plugins/video.js +29 -0
  255. package/dist/server/plugins.d.ts +23 -0
  256. package/dist/server/plugins.js +33 -0
  257. package/dist/server/processing/audio-processing.d.ts +17 -0
  258. package/dist/server/processing/audio-processing.js +46 -0
  259. package/dist/server/processing/ffmpeg.d.ts +9 -0
  260. package/dist/server/processing/ffmpeg.js +50 -0
  261. package/dist/server/processing/image-processing.d.ts +16 -0
  262. package/dist/server/processing/image-processing.js +26 -0
  263. package/dist/server/processing/media-probe.d.ts +15 -0
  264. package/dist/server/processing/media-probe.js +27 -0
  265. package/dist/server/processing/processor.d.ts +50 -0
  266. package/dist/server/processing/processor.js +158 -0
  267. package/dist/server/processing/video-processing.d.ts +35 -0
  268. package/dist/server/processing/video-processing.js +87 -0
  269. package/dist/server/server.d.ts +13 -0
  270. package/dist/server/server.js +57 -0
  271. package/dist/server/start.d.ts +1 -0
  272. package/dist/server/start.js +33 -0
  273. package/package.json +29 -16
  274. package/dist/build-CZYFLLvl.js +0 -191
  275. package/dist/core/image-Dqmz8FXS.js +0 -54
  276. package/dist/core/reference-graph-CjuHbLDw.d.ts +0 -280
  277. package/dist/core/testing.d.ts +0 -27
  278. package/dist/core/testing.js +0 -80
  279. package/dist/editor/200.html +0 -37
  280. package/dist/editor/_app/immutable/assets/2.DIbbW7U1.css +0 -1
  281. package/dist/editor/_app/immutable/assets/3.C-9vFQ9A.css +0 -1
  282. package/dist/editor/_app/immutable/assets/4.BS8ElpOV.css +0 -1
  283. package/dist/editor/_app/immutable/assets/ConfirmDialog.CHEISE-L.css +0 -1
  284. package/dist/editor/_app/immutable/assets/LibraryContextMenu.CDjCmdV-.css +0 -1
  285. package/dist/editor/_app/immutable/chunks/Cx6qtxJg.js +0 -1
  286. package/dist/editor/_app/immutable/chunks/n7mvYc42.js +0 -5
  287. package/dist/editor/_app/immutable/entry/start.C8HHOLly.js +0 -1
  288. package/dist/editor/_app/immutable/nodes/3.WO7tZH_d.js +0 -104
  289. package/dist/editor/_app/immutable/nodes/4.DQtx17aW.js +0 -2
  290. package/dist/editor/_app/version.json +0 -1
  291. package/dist/index.d.ts +0 -370
  292. package/dist/index.js +0 -4
  293. package/dist/start-Bhnqt9Dc.js +0 -279
  294. package/dist/start-D2IXOrni.js +0 -2
  295. /package/{dist/editor → build/client}/_app/immutable/assets/0.DLhIsYA_.css +0 -0
  296. /package/{dist/editor → build/client}/_app/immutable/chunks/Bjy-W4x2.js +0 -0
  297. /package/{dist/editor → build/client}/_app/immutable/chunks/CNRz3sSw.js +0 -0
  298. /package/{dist/editor → build/client}/_app/immutable/chunks/CO4RBJfa.js +0 -0
  299. /package/{dist/editor → build/client}/_app/immutable/chunks/DjdrdRzT.js +0 -0
  300. /package/{dist/editor → build/client}/_app/immutable/chunks/xihTtKlq.js +0 -0
@@ -0,0 +1,3789 @@
1
+ import { o as options, a as set_private_env, b as set_public_env, g as get_hooks, u as uneval, c as public_env, r as read_implementation, d as set_read_implementation, w as writable, e as readable, s as stringify$1 } from './chunks/internal.js-BDBSzJId.js';
2
+ import { n as noop, T as TRAILING_SLASH_PARAM, I as INVALIDATED_PARAM, R as Redirect, b as get_relative_path, S as SvelteKitError, g as get_status, t as text_encoder, o as once, H as HttpError, d as normalize_error, e as create_remote_key, p as parse_remote_arg, s as stringify, A as ActionFailure, f as split_remote_key, h as base64_encode } from './chunks/shared.js-BWXgl1Xf.js';
3
+ import { b as base, o as override, a as assets, r as reset, c as app_dir } from './chunks/internal2.js-BlXt2rfE.js';
4
+ import { f as format_server_error, j as json, i as is_form_content_type, t as text, h as has_prerendered_path, a as handle_fatal_error, r as redirect_response, g as get_set_cookies, n as negotiate, w as with_request_store, p as parseString, m as merge_tracing, b as method_not_allowed, s as static_error_page, c as handle_error_and_jsonify, d as get_global_name, e as create_replacer, k as serialize_uses, l as clarify_devalue_error, E as ENDPOINT_METHODS, P as PAGE_METHODS, o as get_node_type, q as isRedirect, u as escape_html, v as error, x as deserialize_binary_form } from './chunks/utils.js-9oI5Oz0w.js';
5
+ import { v as validate_layout_server_exports, a as validate_layout_exports, b as validate_page_server_exports, c as validate_page_exports, n as noop_span, h as hash, d as compact } from './chunks/exports.js-CLTzaOxn.js';
6
+ import { h as has_resolution_suffix, a as has_data_suffix, s as strip_resolution_suffix, b as strip_data_suffix, d as decode_pathname, c as add_data_suffix, e as add_resolution_suffix, f as find_route, n as normalize_path, g as disable_search, r as resolve, m as make_trackable } from './chunks/routing.js-y-tryuip.js';
7
+
8
+ var cookie = {};
9
+
10
+ /*!
11
+ * cookie
12
+ * Copyright(c) 2012-2014 Roman Shtylman
13
+ * Copyright(c) 2015 Douglas Christopher Wilson
14
+ * MIT Licensed
15
+ */
16
+
17
+ var hasRequiredCookie;
18
+
19
+ function requireCookie () {
20
+ if (hasRequiredCookie) return cookie;
21
+ hasRequiredCookie = 1;
22
+
23
+ /**
24
+ * Module exports.
25
+ * @public
26
+ */
27
+
28
+ cookie.parse = parse;
29
+ cookie.serialize = serialize;
30
+
31
+ /**
32
+ * Module variables.
33
+ * @private
34
+ */
35
+
36
+ var __toString = Object.prototype.toString;
37
+
38
+ /**
39
+ * RegExp to match field-content in RFC 7230 sec 3.2
40
+ *
41
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
42
+ * field-vchar = VCHAR / obs-text
43
+ * obs-text = %x80-FF
44
+ */
45
+
46
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
47
+
48
+ /**
49
+ * Parse a cookie header.
50
+ *
51
+ * Parse the given cookie header string into an object
52
+ * The object has the various cookies as keys(names) => values
53
+ *
54
+ * @param {string} str
55
+ * @param {object} [options]
56
+ * @return {object}
57
+ * @public
58
+ */
59
+
60
+ function parse(str, options) {
61
+ if (typeof str !== 'string') {
62
+ throw new TypeError('argument str must be a string');
63
+ }
64
+
65
+ var obj = {};
66
+ var opt = options || {};
67
+ var dec = opt.decode || decode;
68
+
69
+ var index = 0;
70
+ while (index < str.length) {
71
+ var eqIdx = str.indexOf('=', index);
72
+
73
+ // no more cookie pairs
74
+ if (eqIdx === -1) {
75
+ break
76
+ }
77
+
78
+ var endIdx = str.indexOf(';', index);
79
+
80
+ if (endIdx === -1) {
81
+ endIdx = str.length;
82
+ } else if (endIdx < eqIdx) {
83
+ // backtrack on prior semicolon
84
+ index = str.lastIndexOf(';', eqIdx - 1) + 1;
85
+ continue
86
+ }
87
+
88
+ var key = str.slice(index, eqIdx).trim();
89
+
90
+ // only assign once
91
+ if (undefined === obj[key]) {
92
+ var val = str.slice(eqIdx + 1, endIdx).trim();
93
+
94
+ // quoted values
95
+ if (val.charCodeAt(0) === 0x22) {
96
+ val = val.slice(1, -1);
97
+ }
98
+
99
+ obj[key] = tryDecode(val, dec);
100
+ }
101
+
102
+ index = endIdx + 1;
103
+ }
104
+
105
+ return obj;
106
+ }
107
+
108
+ /**
109
+ * Serialize data into a cookie header.
110
+ *
111
+ * Serialize the a name value pair into a cookie string suitable for
112
+ * http headers. An optional options object specified cookie parameters.
113
+ *
114
+ * serialize('foo', 'bar', { httpOnly: true })
115
+ * => "foo=bar; httpOnly"
116
+ *
117
+ * @param {string} name
118
+ * @param {string} val
119
+ * @param {object} [options]
120
+ * @return {string}
121
+ * @public
122
+ */
123
+
124
+ function serialize(name, val, options) {
125
+ var opt = options || {};
126
+ var enc = opt.encode || encode;
127
+
128
+ if (typeof enc !== 'function') {
129
+ throw new TypeError('option encode is invalid');
130
+ }
131
+
132
+ if (!fieldContentRegExp.test(name)) {
133
+ throw new TypeError('argument name is invalid');
134
+ }
135
+
136
+ var value = enc(val);
137
+
138
+ if (value && !fieldContentRegExp.test(value)) {
139
+ throw new TypeError('argument val is invalid');
140
+ }
141
+
142
+ var str = name + '=' + value;
143
+
144
+ if (null != opt.maxAge) {
145
+ var maxAge = opt.maxAge - 0;
146
+
147
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
148
+ throw new TypeError('option maxAge is invalid')
149
+ }
150
+
151
+ str += '; Max-Age=' + Math.floor(maxAge);
152
+ }
153
+
154
+ if (opt.domain) {
155
+ if (!fieldContentRegExp.test(opt.domain)) {
156
+ throw new TypeError('option domain is invalid');
157
+ }
158
+
159
+ str += '; Domain=' + opt.domain;
160
+ }
161
+
162
+ if (opt.path) {
163
+ if (!fieldContentRegExp.test(opt.path)) {
164
+ throw new TypeError('option path is invalid');
165
+ }
166
+
167
+ str += '; Path=' + opt.path;
168
+ }
169
+
170
+ if (opt.expires) {
171
+ var expires = opt.expires;
172
+
173
+ if (!isDate(expires) || isNaN(expires.valueOf())) {
174
+ throw new TypeError('option expires is invalid');
175
+ }
176
+
177
+ str += '; Expires=' + expires.toUTCString();
178
+ }
179
+
180
+ if (opt.httpOnly) {
181
+ str += '; HttpOnly';
182
+ }
183
+
184
+ if (opt.secure) {
185
+ str += '; Secure';
186
+ }
187
+
188
+ if (opt.partitioned) {
189
+ str += '; Partitioned';
190
+ }
191
+
192
+ if (opt.priority) {
193
+ var priority = typeof opt.priority === 'string'
194
+ ? opt.priority.toLowerCase()
195
+ : opt.priority;
196
+
197
+ switch (priority) {
198
+ case 'low':
199
+ str += '; Priority=Low';
200
+ break
201
+ case 'medium':
202
+ str += '; Priority=Medium';
203
+ break
204
+ case 'high':
205
+ str += '; Priority=High';
206
+ break
207
+ default:
208
+ throw new TypeError('option priority is invalid')
209
+ }
210
+ }
211
+
212
+ if (opt.sameSite) {
213
+ var sameSite = typeof opt.sameSite === 'string'
214
+ ? opt.sameSite.toLowerCase() : opt.sameSite;
215
+
216
+ switch (sameSite) {
217
+ case true:
218
+ str += '; SameSite=Strict';
219
+ break;
220
+ case 'lax':
221
+ str += '; SameSite=Lax';
222
+ break;
223
+ case 'strict':
224
+ str += '; SameSite=Strict';
225
+ break;
226
+ case 'none':
227
+ str += '; SameSite=None';
228
+ break;
229
+ default:
230
+ throw new TypeError('option sameSite is invalid');
231
+ }
232
+ }
233
+
234
+ return str;
235
+ }
236
+
237
+ /**
238
+ * URL-decode string value. Optimized to skip native call when no %.
239
+ *
240
+ * @param {string} str
241
+ * @returns {string}
242
+ */
243
+
244
+ function decode (str) {
245
+ return str.indexOf('%') !== -1
246
+ ? decodeURIComponent(str)
247
+ : str
248
+ }
249
+
250
+ /**
251
+ * URL-encode value.
252
+ *
253
+ * @param {string} val
254
+ * @returns {string}
255
+ */
256
+
257
+ function encode (val) {
258
+ return encodeURIComponent(val)
259
+ }
260
+
261
+ /**
262
+ * Determine if value is a Date.
263
+ *
264
+ * @param {*} val
265
+ * @private
266
+ */
267
+
268
+ function isDate (val) {
269
+ return __toString.call(val) === '[object Date]' ||
270
+ val instanceof Date
271
+ }
272
+
273
+ /**
274
+ * Try decoding a string using a decoding function.
275
+ *
276
+ * @param {string} str
277
+ * @param {function} decode
278
+ * @private
279
+ */
280
+
281
+ function tryDecode(str, decode) {
282
+ try {
283
+ return decode(str);
284
+ } catch (e) {
285
+ return str;
286
+ }
287
+ }
288
+ return cookie;
289
+ }
290
+
291
+ var cookieExports = requireCookie();
292
+
293
+ //#region node_modules/@sveltejs/kit/src/utils/promise.js
294
+ /** @see https://github.com/microsoft/TypeScript/blob/904e7dd97dc8da1352c8e05d70829dff17c73214/src/lib/es2024.promise.d.ts */
295
+ /**
296
+ * @template T
297
+ * @typedef {{
298
+ * promise: Promise<T>;
299
+ * resolve: (value: T | PromiseLike<T>) => void;
300
+ * reject: (reason?: any) => void;
301
+ * }} PromiseWithResolvers<T>
302
+ */
303
+ /**
304
+ * TODO: Whenever Node >21 is minimum supported version, we can use `Promise.withResolvers` to avoid this ceremony
305
+ *
306
+ * @template T
307
+ * @returns {PromiseWithResolvers<T>}
308
+ */
309
+ function with_resolvers() {
310
+ let resolve;
311
+ let reject;
312
+ return {
313
+ promise: new Promise((res, rej) => {
314
+ resolve = res;
315
+ reject = rej;
316
+ }),
317
+ resolve,
318
+ reject
319
+ };
320
+ }
321
+ //#endregion
322
+ //#region node_modules/@sveltejs/kit/src/runtime/server/constants.js
323
+ var NULL_BODY_STATUS = [
324
+ 101,
325
+ 103,
326
+ 204,
327
+ 205,
328
+ 304
329
+ ];
330
+ var IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
331
+ //#endregion
332
+ //#region node_modules/@sveltejs/kit/src/utils/misc.js
333
+ var s = JSON.stringify;
334
+ //#endregion
335
+ //#region node_modules/@sveltejs/kit/src/runtime/server/endpoint.js
336
+ /**
337
+ * @param {import('@sveltejs/kit').RequestEvent} event
338
+ * @param {import('types').RequestState} event_state
339
+ * @param {import('types').SSREndpoint} mod
340
+ * @param {import('types').SSRState} state
341
+ * @returns {Promise<Response>}
342
+ */
343
+ async function render_endpoint(event, event_state, mod, state) {
344
+ const method = event.request.method;
345
+ let handler = mod[method] || mod.fallback;
346
+ if (method === "HEAD" && !mod.HEAD && mod.GET) handler = mod.GET;
347
+ if (!handler) return method_not_allowed(mod, method);
348
+ const prerender = mod.prerender ?? state.prerender_default;
349
+ if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) throw new Error("Cannot prerender endpoints that have mutative methods");
350
+ if (state.prerendering && !state.prerendering.inside_reroute && !prerender) if (state.depth > 0) throw new Error(`${event.route.id} is not prerenderable`);
351
+ else return new Response(void 0, { status: 204 });
352
+ try {
353
+ const response = await with_request_store({
354
+ event,
355
+ state: event_state
356
+ }, () => handler(event));
357
+ if (!(response instanceof Response)) throw new Error(`Invalid response from route ${event.url.pathname}: handler should return a Response object`);
358
+ if (state.prerendering && (!state.prerendering.inside_reroute || prerender)) {
359
+ const cloned = new Response(response.clone().body, {
360
+ status: response.status,
361
+ statusText: response.statusText,
362
+ headers: new Headers(response.headers)
363
+ });
364
+ cloned.headers.set("x-sveltekit-prerender", String(prerender));
365
+ if (state.prerendering.inside_reroute && prerender) {
366
+ cloned.headers.set("x-sveltekit-routeid", encodeURI(event.route.id));
367
+ state.prerendering.dependencies.set(event.url.pathname, {
368
+ response: cloned,
369
+ body: null
370
+ });
371
+ } else return cloned;
372
+ }
373
+ return response;
374
+ } catch (e) {
375
+ if (e instanceof Redirect) return new Response(void 0, {
376
+ status: e.status,
377
+ headers: { location: e.location }
378
+ });
379
+ throw e;
380
+ }
381
+ }
382
+ /**
383
+ * @param {import('@sveltejs/kit').RequestEvent} event
384
+ */
385
+ function is_endpoint_request(event) {
386
+ const { method, headers } = event.request;
387
+ if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) return true;
388
+ if (method === "POST" && headers.get("x-sveltekit-action") === "true") return false;
389
+ return negotiate(event.request.headers.get("accept") ?? "*/*", ["*", "text/html"]) !== "text/html";
390
+ }
391
+ //#endregion
392
+ //#region node_modules/@sveltejs/kit/src/runtime/telemetry/record_span.js
393
+ /** @import { RecordSpan } from 'types' */
394
+ /** @type {RecordSpan} */
395
+ async function record_span({ name, attributes, fn }) {
396
+ return fn(noop_span);
397
+ }
398
+ //#endregion
399
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/actions.js
400
+ /** @import { RequestEvent, ActionResult, Actions } from '@sveltejs/kit' */
401
+ /** @import { SSROptions, SSRNode, ServerNode, ServerHooks } from 'types' */
402
+ /** @param {RequestEvent} event */
403
+ function is_action_json_request(event) {
404
+ return negotiate(event.request.headers.get("accept") ?? "*/*", ["application/json", "text/html"]) === "application/json" && event.request.method === "POST";
405
+ }
406
+ /**
407
+ * @param {RequestEvent} event
408
+ * @param {import('types').RequestState} event_state
409
+ * @param {SSROptions} options
410
+ * @param {SSRNode['server'] | undefined} server
411
+ */
412
+ async function handle_action_json_request(event, event_state, options, server) {
413
+ const actions = server?.actions;
414
+ if (!actions) {
415
+ const no_actions_error = new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`);
416
+ return action_json({
417
+ type: "error",
418
+ error: await handle_error_and_jsonify(event, event_state, options, no_actions_error)
419
+ }, {
420
+ status: no_actions_error.status,
421
+ headers: { allow: "GET" }
422
+ });
423
+ }
424
+ check_named_default_separate(actions);
425
+ try {
426
+ const data = await call_action(event, event_state, actions);
427
+ if (data instanceof ActionFailure) return action_json({
428
+ type: "failure",
429
+ status: data.status,
430
+ data: stringify_action_response(data.data, event.route.id, options.hooks.transport)
431
+ });
432
+ else return action_json({
433
+ type: "success",
434
+ status: data ? 200 : 204,
435
+ data: stringify_action_response(data, event.route.id, options.hooks.transport)
436
+ });
437
+ } catch (e) {
438
+ const err = normalize_error(e);
439
+ if (err instanceof Redirect) return action_json_redirect(err);
440
+ return action_json({
441
+ type: "error",
442
+ error: await handle_error_and_jsonify(event, event_state, options, check_incorrect_fail_use(err))
443
+ }, { status: get_status(err) });
444
+ }
445
+ }
446
+ /**
447
+ * @param {HttpError | Error} error
448
+ */
449
+ function check_incorrect_fail_use(error) {
450
+ return error instanceof ActionFailure ? /* @__PURE__ */ new Error("Cannot \"throw fail()\". Use \"return fail()\"") : error;
451
+ }
452
+ /**
453
+ * @param {Redirect} redirect
454
+ */
455
+ function action_json_redirect(redirect) {
456
+ return action_json({
457
+ type: "redirect",
458
+ status: redirect.status,
459
+ location: redirect.location
460
+ });
461
+ }
462
+ /**
463
+ * @param {ActionResult} data
464
+ * @param {ResponseInit} [init]
465
+ */
466
+ function action_json(data, init) {
467
+ return json(data, init);
468
+ }
469
+ /**
470
+ * @param {RequestEvent} event
471
+ */
472
+ function is_action_request(event) {
473
+ return event.request.method === "POST";
474
+ }
475
+ /**
476
+ * @param {RequestEvent} event
477
+ * @param {import('types').RequestState} event_state
478
+ * @param {SSRNode['server'] | undefined} server
479
+ * @returns {Promise<ActionResult>}
480
+ */
481
+ async function handle_action_request(event, event_state, server) {
482
+ const actions = server?.actions;
483
+ if (!actions) {
484
+ event.setHeaders({ allow: "GET" });
485
+ return {
486
+ type: "error",
487
+ error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
488
+ };
489
+ }
490
+ check_named_default_separate(actions);
491
+ try {
492
+ const data = await call_action(event, event_state, actions);
493
+ if (data instanceof ActionFailure) return {
494
+ type: "failure",
495
+ status: data.status,
496
+ data: data.data
497
+ };
498
+ else return {
499
+ type: "success",
500
+ status: 200,
501
+ data
502
+ };
503
+ } catch (e) {
504
+ const err = normalize_error(e);
505
+ if (err instanceof Redirect) return {
506
+ type: "redirect",
507
+ status: err.status,
508
+ location: err.location
509
+ };
510
+ return {
511
+ type: "error",
512
+ error: check_incorrect_fail_use(err)
513
+ };
514
+ }
515
+ }
516
+ /**
517
+ * @param {Actions} actions
518
+ */
519
+ function check_named_default_separate(actions) {
520
+ if (actions.default && Object.keys(actions).length > 1) throw new Error("When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions");
521
+ }
522
+ /**
523
+ * @param {RequestEvent} event
524
+ * @param {import('types').RequestState} event_state
525
+ * @param {NonNullable<ServerNode['actions']>} actions
526
+ * @throws {Redirect | HttpError | SvelteKitError | Error}
527
+ */
528
+ async function call_action(event, event_state, actions) {
529
+ const url = new URL(event.request.url);
530
+ let name = "default";
531
+ for (const param of url.searchParams) if (param[0].startsWith("/")) {
532
+ name = param[0].slice(1);
533
+ if (name === "default") throw new Error("Cannot use reserved action name \"default\"");
534
+ break;
535
+ }
536
+ const action = actions[name];
537
+ if (!action) throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
538
+ if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `Form actions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
539
+ return record_span({
540
+ name: "sveltekit.form_action",
541
+ attributes: {
542
+ "http.route": event.route.id || "unknown"
543
+ },
544
+ fn: async (current) => {
545
+ const traced_event = merge_tracing(event, current);
546
+ const result = await with_request_store({
547
+ event: traced_event,
548
+ state: event_state
549
+ }, () => action(traced_event));
550
+ if (result instanceof ActionFailure) current.setAttributes({
551
+ "sveltekit.form_action.result.type": "failure",
552
+ "sveltekit.form_action.result.status": result.status
553
+ });
554
+ return result;
555
+ }
556
+ });
557
+ }
558
+ /**
559
+ * Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context
560
+ * @param {any} data
561
+ * @param {string} route_id
562
+ * @param {ServerHooks['transport']} transport
563
+ */
564
+ function uneval_action_response(data, route_id, transport) {
565
+ const replacer = create_replacer(transport);
566
+ return try_serialize(data, (value) => uneval(value, replacer), route_id);
567
+ }
568
+ /**
569
+ * Try to `devalue.stringify` the data object, and if it fails, return a proper Error with context
570
+ * @param {any} data
571
+ * @param {string} route_id
572
+ * @param {ServerHooks['transport']} transport
573
+ */
574
+ function stringify_action_response(data, route_id, transport) {
575
+ const encoders = Object.fromEntries(Object.entries(transport).map(([key, value]) => [key, value.encode]));
576
+ return try_serialize(data, (value) => stringify$1(value, encoders), route_id);
577
+ }
578
+ /**
579
+ * @param {any} data
580
+ * @param {(data: any) => string} fn
581
+ * @param {string} route_id
582
+ */
583
+ function try_serialize(data, fn, route_id) {
584
+ try {
585
+ return fn(data);
586
+ } catch (e) {
587
+ const error = e;
588
+ if (data instanceof Response) throw new Error(`Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`, { cause: e });
589
+ if ("path" in error) {
590
+ let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
591
+ if (error.path !== "") message += ` (data.${error.path})`;
592
+ throw new Error(message, { cause: e });
593
+ }
594
+ throw error;
595
+ }
596
+ }
597
+ //#endregion
598
+ //#region node_modules/@sveltejs/kit/src/utils/streaming.js
599
+ /**
600
+ * Create an async iterator and a function to push values into it
601
+ * @template T
602
+ * @returns {{
603
+ * iterate: (transform?: (input: T) => T) => AsyncIterable<T>;
604
+ * add: (promise: Promise<T>) => void;
605
+ * }}
606
+ */
607
+ function create_async_iterator() {
608
+ let resolved = -1;
609
+ let returned = -1;
610
+ /** @type {import('./promise.js').PromiseWithResolvers<T>[]} */
611
+ const deferred = [];
612
+ return {
613
+ iterate: (transform = (x) => x) => {
614
+ return { [Symbol.asyncIterator]() {
615
+ return { next: async () => {
616
+ const next = deferred[++returned];
617
+ if (!next) return {
618
+ value: null,
619
+ done: true
620
+ };
621
+ return {
622
+ value: transform(await next.promise),
623
+ done: false
624
+ };
625
+ } };
626
+ } };
627
+ },
628
+ add: (promise) => {
629
+ /** @type {import('./promise.js').PromiseWithResolvers<T>} */
630
+ const next = with_resolvers();
631
+ next.promise.catch(noop);
632
+ deferred.push(next);
633
+ promise.then((value) => {
634
+ deferred[++resolved].resolve(value);
635
+ }, (error) => {
636
+ deferred[++resolved].reject(error);
637
+ });
638
+ }
639
+ };
640
+ }
641
+ //#endregion
642
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/data_serializer.js
643
+ /**
644
+ * If the serialized data contains promises, `chunks` will be an
645
+ * async iterable containing their resolutions
646
+ * @param {import('@sveltejs/kit').RequestEvent} event
647
+ * @param {import('types').RequestState} event_state
648
+ * @param {import('types').SSROptions} options
649
+ * @returns {import('./types.js').ServerDataSerializer}
650
+ */
651
+ function server_data_serializer(event, event_state, options) {
652
+ let promise_id = 1;
653
+ let max_nodes = -1;
654
+ const iterator = create_async_iterator();
655
+ const global = get_global_name(options);
656
+ /** @param {number} index */
657
+ function get_replacer(index) {
658
+ /** @param {any} thing */
659
+ return function replacer(thing) {
660
+ if (typeof thing?.then === "function") {
661
+ const id = promise_id++;
662
+ const promise = thing.then(
663
+ /** @param {any} data */
664
+ (data) => ({ data })
665
+ ).catch(
666
+ /** @param {any} error */
667
+ async (error) => ({ error: await handle_error_and_jsonify(event, event_state, options, error) })
668
+ ).then(
669
+ /**
670
+ * @param {{data: any; error: any}} result
671
+ */
672
+ async ({ data, error }) => {
673
+ let str;
674
+ try {
675
+ str = uneval(error ? [, error] : [data], replacer);
676
+ } catch {
677
+ error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
678
+ str = uneval([, error], replacer);
679
+ }
680
+ return {
681
+ index,
682
+ str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})`
683
+ };
684
+ }
685
+ );
686
+ iterator.add(promise);
687
+ return `${global}.defer(${id})`;
688
+ } else for (const key in options.hooks.transport) {
689
+ const encoded = options.hooks.transport[key].encode(thing);
690
+ if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`;
691
+ }
692
+ };
693
+ }
694
+ const strings = [];
695
+ return {
696
+ set_max_nodes(i) {
697
+ max_nodes = i;
698
+ },
699
+ add_node(i, node) {
700
+ try {
701
+ if (!node) {
702
+ strings[i] = "null";
703
+ return;
704
+ }
705
+ /** @type {any} */
706
+ const payload = {
707
+ type: "data",
708
+ data: node.data,
709
+ uses: serialize_uses(node)
710
+ };
711
+ if (node.slash) payload.slash = node.slash;
712
+ strings[i] = uneval(payload, get_replacer(i));
713
+ } catch (e) {
714
+ e.path = e.path.slice(1);
715
+ throw new Error(clarify_devalue_error(event, e), { cause: e });
716
+ }
717
+ },
718
+ get_data(csp) {
719
+ const open = `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>`;
720
+ const close = `<\/script>\n`;
721
+ return {
722
+ data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`,
723
+ chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => {
724
+ if (max_nodes > -1 && index >= max_nodes) return "";
725
+ return open + str + close;
726
+ }) : null
727
+ };
728
+ }
729
+ };
730
+ }
731
+ /**
732
+ * If the serialized data contains promises, `chunks` will be an
733
+ * async iterable containing their resolutions
734
+ * @param {import('@sveltejs/kit').RequestEvent} event
735
+ * @param {import('types').RequestState} event_state
736
+ * @param {import('types').SSROptions} options
737
+ * @returns {import('./types.js').ServerDataSerializerJson}
738
+ */
739
+ function server_data_serializer_json(event, event_state, options) {
740
+ let promise_id = 1;
741
+ const iterator = create_async_iterator();
742
+ const reducers = {
743
+ ...Object.fromEntries(Object.entries(options.hooks.transport).map(([key, value]) => [key, value.encode])),
744
+ /** @param {any} thing */
745
+ Promise: (thing) => {
746
+ if (typeof thing?.then !== "function") return;
747
+ const id = promise_id++;
748
+ /** @type {'data' | 'error'} */
749
+ let key = "data";
750
+ const promise = thing.catch(
751
+ /** @param {any} e */
752
+ async (e) => {
753
+ key = "error";
754
+ return handle_error_and_jsonify(event, event_state, options, e);
755
+ }
756
+ ).then(
757
+ /** @param {any} value */
758
+ async (value) => {
759
+ let str;
760
+ try {
761
+ str = stringify$1(value, reducers);
762
+ } catch {
763
+ const error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
764
+ key = "error";
765
+ str = stringify$1(error, reducers);
766
+ }
767
+ return `{"type":"chunk","id":${id},"${key}":${str}}\n`;
768
+ }
769
+ );
770
+ iterator.add(promise);
771
+ return id;
772
+ }
773
+ };
774
+ const strings = [];
775
+ return {
776
+ add_node(i, node) {
777
+ try {
778
+ if (!node) {
779
+ strings[i] = "null";
780
+ return;
781
+ }
782
+ if (node.type === "error" || node.type === "skip") {
783
+ strings[i] = JSON.stringify(node);
784
+ return;
785
+ }
786
+ strings[i] = `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(serialize_uses(node))}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
787
+ } catch (e) {
788
+ e.path = "data" + e.path;
789
+ throw new Error(clarify_devalue_error(event, e), { cause: e });
790
+ }
791
+ },
792
+ get_data() {
793
+ return {
794
+ data: `{"type":"data","nodes":[${strings.join(",")}]}\n`,
795
+ chunks: promise_id > 1 ? iterator.iterate() : null
796
+ };
797
+ }
798
+ };
799
+ }
800
+ //#endregion
801
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js
802
+ /**
803
+ * Calls the user's server `load` function.
804
+ * @param {{
805
+ * event: import('@sveltejs/kit').RequestEvent;
806
+ * event_state: import('types').RequestState;
807
+ * state: import('types').SSRState;
808
+ * node: import('types').SSRNode | undefined;
809
+ * parent: () => Promise<Record<string, any>>;
810
+ * }} opts
811
+ * @returns {Promise<import('types').ServerDataNode | null>}
812
+ */
813
+ async function load_server_data({ event, event_state, state, node, parent }) {
814
+ if (!node?.server) return null;
815
+ let is_tracking = true;
816
+ const uses = {
817
+ dependencies: /* @__PURE__ */ new Set(),
818
+ params: /* @__PURE__ */ new Set(),
819
+ parent: false,
820
+ route: false,
821
+ url: false,
822
+ search_params: /* @__PURE__ */ new Set()
823
+ };
824
+ const load = node.server.load;
825
+ const slash = node.server.trailingSlash;
826
+ if (!load) return {
827
+ type: "data",
828
+ data: null,
829
+ uses,
830
+ slash
831
+ };
832
+ const url = make_trackable(event.url, () => {
833
+ if (is_tracking) uses.url = true;
834
+ }, (param) => {
835
+ if (is_tracking) uses.search_params.add(param);
836
+ });
837
+ if (state.prerendering) disable_search(url);
838
+ return {
839
+ type: "data",
840
+ data: await record_span({
841
+ name: "sveltekit.load",
842
+ attributes: {
843
+ "sveltekit.load.node_id": node.server_id || "unknown",
844
+ "sveltekit.load.node_type": get_node_type(node.server_id),
845
+ "http.route": event.route.id || "unknown"
846
+ },
847
+ fn: async (current) => {
848
+ const traced_event = merge_tracing(event, current);
849
+ return await with_request_store({
850
+ event: traced_event,
851
+ state: event_state
852
+ }, () => load.call(null, {
853
+ ...traced_event,
854
+ fetch: (info, init) => {
855
+ new URL(info instanceof Request ? info.url : info, event.url);
856
+ return event.fetch(info, init);
857
+ },
858
+ /** @param {string[]} deps */
859
+ depends: (...deps) => {
860
+ for (const dep of deps) {
861
+ const { href } = new URL(dep, event.url);
862
+ uses.dependencies.add(href);
863
+ }
864
+ },
865
+ params: new Proxy(event.params, { get: (target, key) => {
866
+ if (is_tracking) uses.params.add(key);
867
+ return target[key];
868
+ } }),
869
+ parent: async () => {
870
+ if (is_tracking) uses.parent = true;
871
+ return parent();
872
+ },
873
+ route: new Proxy(event.route, { get: (target, key) => {
874
+ if (is_tracking) uses.route = true;
875
+ return target[key];
876
+ } }),
877
+ url,
878
+ untrack(fn) {
879
+ is_tracking = false;
880
+ try {
881
+ return fn();
882
+ } finally {
883
+ is_tracking = true;
884
+ }
885
+ }
886
+ }));
887
+ }
888
+ }) ?? null,
889
+ uses,
890
+ slash
891
+ };
892
+ }
893
+ /**
894
+ * Calls the user's `load` function.
895
+ * @param {{
896
+ * event: import('@sveltejs/kit').RequestEvent;
897
+ * event_state: import('types').RequestState;
898
+ * fetched: import('./types.js').Fetched[];
899
+ * node: import('types').SSRNode | undefined;
900
+ * parent: () => Promise<Record<string, any>>;
901
+ * resolve_opts: import('types').RequiredResolveOptions;
902
+ * server_data_promise: Promise<import('types').ServerDataNode | null>;
903
+ * state: import('types').SSRState;
904
+ * csr: boolean;
905
+ * }} opts
906
+ * @returns {Promise<Record<string, any | Promise<any>> | null>}
907
+ */
908
+ async function load_data({ event, event_state, fetched, node, parent, server_data_promise, state, resolve_opts, csr }) {
909
+ const server_data_node = await server_data_promise;
910
+ const load = node?.universal?.load;
911
+ if (!load) return server_data_node?.data ?? null;
912
+ return await record_span({
913
+ name: "sveltekit.load",
914
+ attributes: {
915
+ "sveltekit.load.node_id": node.universal_id || "unknown",
916
+ "sveltekit.load.node_type": get_node_type(node.universal_id),
917
+ "http.route": event.route.id || "unknown"
918
+ },
919
+ fn: async (current) => {
920
+ const traced_event = merge_tracing(event, current);
921
+ return await with_request_store({
922
+ event: traced_event,
923
+ state: {
924
+ ...event_state,
925
+ is_in_universal_load: true
926
+ }
927
+ }, () => load.call(null, {
928
+ url: event.url,
929
+ params: event.params,
930
+ data: server_data_node?.data ?? null,
931
+ route: event.route,
932
+ fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),
933
+ setHeaders: event.setHeaders,
934
+ depends: noop,
935
+ parent,
936
+ untrack: (fn) => fn(),
937
+ tracing: traced_event.tracing
938
+ }));
939
+ }
940
+ }) ?? null;
941
+ }
942
+ /**
943
+ * @param {Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>} event
944
+ * @param {import('types').SSRState} state
945
+ * @param {import('./types.js').Fetched[]} fetched
946
+ * @param {boolean} csr
947
+ * @param {Pick<Required<import('@sveltejs/kit').ResolveOptions>, 'filterSerializedResponseHeaders'>} resolve_opts
948
+ * @returns {typeof fetch}
949
+ */
950
+ function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
951
+ /**
952
+ * @param {URL | RequestInfo} input
953
+ * @param {RequestInit} [init]
954
+ */
955
+ const universal_fetch = async (input, init) => {
956
+ const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
957
+ const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init?.headers;
958
+ let response = await event.fetch(input, init);
959
+ const url = new URL(input instanceof Request ? input.url : input, event.url);
960
+ const same_origin = url.origin === event.url.origin;
961
+ /** @type {import('types').PrerenderDependency} */
962
+ let dependency;
963
+ if (same_origin) {
964
+ if (state.prerendering) {
965
+ dependency = {
966
+ response,
967
+ body: null
968
+ };
969
+ state.prerendering.dependencies.set(url.pathname, dependency);
970
+ }
971
+ } else if (url.protocol === "https:" || url.protocol === "http:") if ((input instanceof Request ? input.mode : init?.mode ?? "cors") === "no-cors") response = new Response("", {
972
+ status: response.status,
973
+ statusText: response.statusText,
974
+ headers: response.headers
975
+ });
976
+ else {
977
+ const acao = response.headers.get("access-control-allow-origin");
978
+ if (!acao || acao !== event.url.origin && acao !== "*") throw new Error(`CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource`);
979
+ }
980
+ /** @type {ReadableStream<Uint8Array>} */
981
+ let teed_body;
982
+ const proxy = new Proxy(response, { get(response, key, receiver) {
983
+ /**
984
+ * @param {string | undefined} body
985
+ * @param {boolean} is_b64
986
+ */
987
+ async function push_fetched(body, is_b64) {
988
+ const status_number = Number(response.status);
989
+ if (isNaN(status_number)) throw new Error(`response.status is not a number. value: "${response.status}" type: ${typeof response.status}`);
990
+ fetched.push({
991
+ url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
992
+ method: event.request.method,
993
+ request_body: input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init?.body,
994
+ request_headers: cloned_headers,
995
+ response_body: body,
996
+ response,
997
+ is_b64
998
+ });
999
+ }
1000
+ if (key === "body") {
1001
+ if (response.body === null) return null;
1002
+ if (teed_body) return teed_body;
1003
+ const [a, b] = response.body.tee();
1004
+ (async () => {
1005
+ let result = /* @__PURE__ */ new Uint8Array();
1006
+ for await (const chunk of a) {
1007
+ const combined = new Uint8Array(result.length + chunk.length);
1008
+ combined.set(result, 0);
1009
+ combined.set(chunk, result.length);
1010
+ result = combined;
1011
+ }
1012
+ if (dependency) dependency.body = new Uint8Array(result);
1013
+ push_fetched(base64_encode(result), true);
1014
+ })().catch(noop);
1015
+ return teed_body = b;
1016
+ }
1017
+ if (key === "arrayBuffer") return async () => {
1018
+ const buffer = await response.arrayBuffer();
1019
+ const bytes = new Uint8Array(buffer);
1020
+ if (dependency) dependency.body = bytes;
1021
+ if (buffer instanceof ArrayBuffer) await push_fetched(base64_encode(bytes), true);
1022
+ return buffer;
1023
+ };
1024
+ async function text() {
1025
+ const body = await response.text();
1026
+ if (body === "" && NULL_BODY_STATUS.includes(response.status)) {
1027
+ await push_fetched(void 0, false);
1028
+ return;
1029
+ }
1030
+ if (!body || typeof body === "string") await push_fetched(body, false);
1031
+ if (dependency) dependency.body = body;
1032
+ return body;
1033
+ }
1034
+ if (key === "text") return text;
1035
+ if (key === "json") return async () => {
1036
+ const body = await text();
1037
+ return body ? JSON.parse(body) : void 0;
1038
+ };
1039
+ const value = Reflect.get(response, key, response);
1040
+ if (value instanceof Function) return Object.defineProperties(
1041
+ /**
1042
+ * @this {any}
1043
+ */
1044
+ function() {
1045
+ return Reflect.apply(value, this === receiver ? response : this, arguments);
1046
+ },
1047
+ {
1048
+ name: { value: value.name },
1049
+ length: { value: value.length }
1050
+ }
1051
+ );
1052
+ return value;
1053
+ } });
1054
+ if (csr) {
1055
+ const get = response.headers.get;
1056
+ response.headers.get = (key) => {
1057
+ const lower = key.toLowerCase();
1058
+ const value = get.call(response.headers, lower);
1059
+ if (value && !lower.startsWith("x-sveltekit-")) {
1060
+ if (!resolve_opts.filterSerializedResponseHeaders(lower, value)) throw new Error(`Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`);
1061
+ }
1062
+ return value;
1063
+ };
1064
+ }
1065
+ return proxy;
1066
+ };
1067
+ return (input, init) => {
1068
+ const response = universal_fetch(input, init);
1069
+ response.catch(noop);
1070
+ return response;
1071
+ };
1072
+ }
1073
+ /**
1074
+ * @param {ReadableStream<Uint8Array>} stream
1075
+ */
1076
+ async function stream_to_string(stream) {
1077
+ let result = "";
1078
+ const reader = stream.getReader();
1079
+ const decoder = new TextDecoder();
1080
+ while (true) {
1081
+ const { done, value } = await reader.read();
1082
+ if (done) {
1083
+ result += decoder.decode();
1084
+ break;
1085
+ }
1086
+ result += decoder.decode(value, { stream: true });
1087
+ }
1088
+ return result;
1089
+ }
1090
+ //#endregion
1091
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/serialize_data.js
1092
+ /**
1093
+ * Inside a script element, only `<\/script` and `<!--` hold special meaning to the HTML parser.
1094
+ *
1095
+ * The first closes the script element, so everything after is treated as raw HTML.
1096
+ * The second disables further parsing until `-->`, so the script element might be unexpectedly
1097
+ * kept open up until an unrelated HTML comment in the page.
1098
+ *
1099
+ * U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are escaped for the sake of pre-2018
1100
+ * browsers.
1101
+ *
1102
+ * @see tests for unsafe parsing examples.
1103
+ * @see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
1104
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
1105
+ * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-state
1106
+ * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escaped-state
1107
+ * @see https://github.com/tc39/proposal-json-superset
1108
+ * @type {Record<string, string>}
1109
+ */
1110
+ var replacements = {
1111
+ "<": "\\u003C",
1112
+ "\u2028": "\\u2028",
1113
+ "\u2029": "\\u2029"
1114
+ };
1115
+ var pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
1116
+ /**
1117
+ * Generates a raw HTML string containing a safe script element carrying data and associated attributes.
1118
+ *
1119
+ * It escapes all the special characters needed to guarantee the element is unbroken, but care must
1120
+ * be taken to ensure it is inserted in the document at an acceptable position for a script element,
1121
+ * and that the resulting string isn't further modified.
1122
+ *
1123
+ * @param {import('./types.js').Fetched} fetched
1124
+ * @param {(name: string, value: string) => boolean} filter
1125
+ * @param {boolean} [prerendering]
1126
+ * @returns {string} The raw HTML of a script element carrying the JSON payload.
1127
+ * @example const html = serialize_data('/data.json', null, { foo: 'bar' });
1128
+ */
1129
+ function serialize_data(fetched, filter, prerendering = false) {
1130
+ /** @type {Record<string, string>} */
1131
+ const headers = {};
1132
+ let cache_control = null;
1133
+ let age = null;
1134
+ let varyAny = false;
1135
+ for (const [key, value] of fetched.response.headers) {
1136
+ if (filter(key, value)) headers[key] = value;
1137
+ if (key === "cache-control") cache_control = value;
1138
+ else if (key === "age") age = value;
1139
+ else if (key === "vary" && value.trim() === "*") varyAny = true;
1140
+ }
1141
+ const payload = {
1142
+ status: fetched.response.status,
1143
+ statusText: fetched.response.statusText,
1144
+ headers,
1145
+ body: fetched.response_body
1146
+ };
1147
+ const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);
1148
+ const attrs = [
1149
+ "type=\"application/json\"",
1150
+ "data-sveltekit-fetched",
1151
+ `data-url="${escape_html(fetched.url, true)}"`
1152
+ ];
1153
+ if (fetched.is_b64) attrs.push("data-b64");
1154
+ if (fetched.request_headers || fetched.request_body) {
1155
+ /** @type {import('types').StrictBody[]} */
1156
+ const values = [];
1157
+ if (fetched.request_headers) values.push([...new Headers(fetched.request_headers)].join(","));
1158
+ if (fetched.request_body) values.push(fetched.request_body);
1159
+ attrs.push(`data-hash="${hash(...values)}"`);
1160
+ }
1161
+ if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) {
1162
+ const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
1163
+ if (match) {
1164
+ const ttl = +match[1] - +(age ?? "0");
1165
+ attrs.push(`data-ttl="${ttl}"`);
1166
+ }
1167
+ }
1168
+ return `<script ${attrs.join(" ")}>${safe_payload}<\/script>`;
1169
+ }
1170
+ //#endregion
1171
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/crypto.js
1172
+ /**
1173
+ * SHA-256 hashing function adapted from https://bitwiseshiftleft.github.io/sjcl
1174
+ * modified and redistributed under BSD license
1175
+ * @param {string} data
1176
+ */
1177
+ function sha256(data) {
1178
+ if (!key[0]) precompute();
1179
+ const out = init.slice(0);
1180
+ const array = encode(data);
1181
+ for (let i = 0; i < array.length; i += 16) {
1182
+ const w = array.subarray(i, i + 16);
1183
+ let tmp;
1184
+ let a;
1185
+ let b;
1186
+ let out0 = out[0];
1187
+ let out1 = out[1];
1188
+ let out2 = out[2];
1189
+ let out3 = out[3];
1190
+ let out4 = out[4];
1191
+ let out5 = out[5];
1192
+ let out6 = out[6];
1193
+ let out7 = out[7];
1194
+ for (let i = 0; i < 64; i++) {
1195
+ if (i < 16) tmp = w[i];
1196
+ else {
1197
+ a = w[i + 1 & 15];
1198
+ b = w[i + 14 & 15];
1199
+ tmp = w[i & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i & 15] + w[i + 9 & 15] | 0;
1200
+ }
1201
+ tmp = tmp + out7 + (out4 >>> 6 ^ out4 >>> 11 ^ out4 >>> 25 ^ out4 << 26 ^ out4 << 21 ^ out4 << 7) + (out6 ^ out4 & (out5 ^ out6)) + key[i];
1202
+ out7 = out6;
1203
+ out6 = out5;
1204
+ out5 = out4;
1205
+ out4 = out3 + tmp | 0;
1206
+ out3 = out2;
1207
+ out2 = out1;
1208
+ out1 = out0;
1209
+ out0 = tmp + (out1 & out2 ^ out3 & (out1 ^ out2)) + (out1 >>> 2 ^ out1 >>> 13 ^ out1 >>> 22 ^ out1 << 30 ^ out1 << 19 ^ out1 << 10) | 0;
1210
+ }
1211
+ out[0] = out[0] + out0 | 0;
1212
+ out[1] = out[1] + out1 | 0;
1213
+ out[2] = out[2] + out2 | 0;
1214
+ out[3] = out[3] + out3 | 0;
1215
+ out[4] = out[4] + out4 | 0;
1216
+ out[5] = out[5] + out5 | 0;
1217
+ out[6] = out[6] + out6 | 0;
1218
+ out[7] = out[7] + out7 | 0;
1219
+ }
1220
+ const bytes = new Uint8Array(out.buffer);
1221
+ reverse_endianness(bytes);
1222
+ return btoa(String.fromCharCode(...bytes));
1223
+ }
1224
+ /** The SHA-256 initialization vector */
1225
+ var init = /* @__PURE__ */ new Uint32Array(8);
1226
+ /** The SHA-256 hash key */
1227
+ var key = /* @__PURE__ */ new Uint32Array(64);
1228
+ /** Function to precompute init and key. */
1229
+ function precompute() {
1230
+ /** @param {number} x */
1231
+ function frac(x) {
1232
+ return (x - Math.floor(x)) * 4294967296;
1233
+ }
1234
+ let prime = 2;
1235
+ for (let i = 0; i < 64; prime++) {
1236
+ let is_prime = true;
1237
+ for (let factor = 2; factor * factor <= prime; factor++) if (prime % factor === 0) {
1238
+ is_prime = false;
1239
+ break;
1240
+ }
1241
+ if (is_prime) {
1242
+ if (i < 8) init[i] = frac(prime ** (1 / 2));
1243
+ key[i] = frac(prime ** (1 / 3));
1244
+ i++;
1245
+ }
1246
+ }
1247
+ }
1248
+ /** @param {Uint8Array} bytes */
1249
+ function reverse_endianness(bytes) {
1250
+ for (let i = 0; i < bytes.length; i += 4) {
1251
+ const a = bytes[i + 0];
1252
+ const b = bytes[i + 1];
1253
+ const c = bytes[i + 2];
1254
+ const d = bytes[i + 3];
1255
+ bytes[i + 0] = d;
1256
+ bytes[i + 1] = c;
1257
+ bytes[i + 2] = b;
1258
+ bytes[i + 3] = a;
1259
+ }
1260
+ }
1261
+ /** @param {string} str */
1262
+ function encode(str) {
1263
+ const encoded = text_encoder.encode(str);
1264
+ const length = encoded.length * 8;
1265
+ const size = 512 * Math.ceil((length + 65) / 512);
1266
+ const bytes = new Uint8Array(size / 8);
1267
+ bytes.set(encoded);
1268
+ bytes[encoded.length] = 128;
1269
+ reverse_endianness(bytes);
1270
+ const words = new Uint32Array(bytes.buffer);
1271
+ words[words.length - 2] = Math.floor(length / 4294967296);
1272
+ words[words.length - 1] = length;
1273
+ return words;
1274
+ }
1275
+ //#endregion
1276
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/csp.js
1277
+ var array = /* @__PURE__ */ new Uint8Array(16);
1278
+ function generate_nonce() {
1279
+ crypto.getRandomValues(array);
1280
+ return btoa(String.fromCharCode(...array));
1281
+ }
1282
+ var quoted = /* @__PURE__ */ new Set([
1283
+ "self",
1284
+ "unsafe-eval",
1285
+ "unsafe-hashes",
1286
+ "unsafe-inline",
1287
+ "none",
1288
+ "strict-dynamic",
1289
+ "report-sample",
1290
+ "wasm-unsafe-eval",
1291
+ "script"
1292
+ ]);
1293
+ var crypto_pattern = /^(nonce|sha\d\d\d)-/;
1294
+ var BaseProvider = class {
1295
+ /** @type {boolean} */
1296
+ #use_hashes;
1297
+ /** @type {boolean} */
1298
+ #script_needs_csp;
1299
+ /** @type {boolean} */
1300
+ #script_src_needs_csp;
1301
+ /** @type {boolean} */
1302
+ #script_src_elem_needs_csp;
1303
+ /** @type {boolean} */
1304
+ #style_needs_csp;
1305
+ /** @type {boolean} */
1306
+ #style_src_needs_csp;
1307
+ /** @type {boolean} */
1308
+ #style_src_attr_needs_csp;
1309
+ /** @type {boolean} */
1310
+ #style_src_elem_needs_csp;
1311
+ /** @type {import('types').CspDirectives} */
1312
+ #directives;
1313
+ /** @type {Set<import('types').Csp.Source>} */
1314
+ #script_src;
1315
+ /** @type {Set<import('types').Csp.Source>} */
1316
+ #script_src_elem;
1317
+ /** @type {Set<import('types').Csp.Source>} */
1318
+ #style_src;
1319
+ /** @type {Set<import('types').Csp.Source>} */
1320
+ #style_src_attr;
1321
+ /** @type {Set<import('types').Csp.Source>} */
1322
+ #style_src_elem;
1323
+ /** @type {boolean} */
1324
+ script_needs_nonce;
1325
+ /** @type {boolean} */
1326
+ style_needs_nonce;
1327
+ /** @type {boolean} */
1328
+ script_needs_hash;
1329
+ /** @type {string} */
1330
+ #nonce;
1331
+ /**
1332
+ * @param {boolean} use_hashes
1333
+ * @param {import('types').CspDirectives} directives
1334
+ * @param {string} nonce
1335
+ */
1336
+ constructor(use_hashes, directives, nonce) {
1337
+ this.#use_hashes = use_hashes;
1338
+ this.#directives = directives;
1339
+ const d = this.#directives;
1340
+ this.#script_src = /* @__PURE__ */ new Set();
1341
+ this.#script_src_elem = /* @__PURE__ */ new Set();
1342
+ this.#style_src = /* @__PURE__ */ new Set();
1343
+ this.#style_src_attr = /* @__PURE__ */ new Set();
1344
+ this.#style_src_elem = /* @__PURE__ */ new Set();
1345
+ const effective_script_src = d["script-src"] || d["default-src"];
1346
+ const script_src_elem = d["script-src-elem"];
1347
+ const effective_style_src = d["style-src"] || d["default-src"];
1348
+ const style_src_attr = d["style-src-attr"];
1349
+ const style_src_elem = d["style-src-elem"];
1350
+ /** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */
1351
+ const style_needs_csp = (directive) => !!directive && !directive.some((value) => value === "unsafe-inline");
1352
+ /** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */
1353
+ const script_needs_csp = (directive) => !!directive && (!directive.some((value) => value === "unsafe-inline") || directive.some((value) => value === "strict-dynamic"));
1354
+ this.#script_src_needs_csp = script_needs_csp(effective_script_src);
1355
+ this.#script_src_elem_needs_csp = script_needs_csp(script_src_elem);
1356
+ this.#style_src_needs_csp = style_needs_csp(effective_style_src);
1357
+ this.#style_src_attr_needs_csp = style_needs_csp(style_src_attr);
1358
+ this.#style_src_elem_needs_csp = style_needs_csp(style_src_elem);
1359
+ this.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;
1360
+ this.#style_needs_csp = this.#style_src_needs_csp || this.#style_src_attr_needs_csp || this.#style_src_elem_needs_csp;
1361
+ this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
1362
+ this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
1363
+ this.script_needs_hash = this.#script_needs_csp && this.#use_hashes;
1364
+ this.#nonce = nonce;
1365
+ }
1366
+ /** @param {string} content */
1367
+ add_script(content) {
1368
+ if (!this.#script_needs_csp) return;
1369
+ /** @type {`nonce-${string}` | `sha256-${string}`} */
1370
+ const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
1371
+ if (this.#script_src_needs_csp) this.#script_src.add(source);
1372
+ if (this.#script_src_elem_needs_csp) this.#script_src_elem.add(source);
1373
+ }
1374
+ /** @param {`sha256-${string}`[]} hashes */
1375
+ add_script_hashes(hashes) {
1376
+ for (const hash of hashes) {
1377
+ if (this.#script_src_needs_csp) this.#script_src.add(hash);
1378
+ if (this.#script_src_elem_needs_csp) this.#script_src_elem.add(hash);
1379
+ }
1380
+ }
1381
+ /** @param {string} content */
1382
+ add_style(content) {
1383
+ if (!this.#style_needs_csp) return;
1384
+ /** @type {`nonce-${string}` | `sha256-${string}`} */
1385
+ const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
1386
+ if (this.#style_src_needs_csp) this.#style_src.add(source);
1387
+ if (this.#style_src_attr_needs_csp) this.#style_src_attr.add(source);
1388
+ if (this.#style_src_elem_needs_csp) {
1389
+ const sha256_empty_comment_hash = "sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=";
1390
+ const d = this.#directives;
1391
+ if (d["style-src-elem"] && !d["style-src-elem"].includes(sha256_empty_comment_hash) && !this.#style_src_elem.has(sha256_empty_comment_hash)) this.#style_src_elem.add(sha256_empty_comment_hash);
1392
+ if (source !== sha256_empty_comment_hash) this.#style_src_elem.add(source);
1393
+ }
1394
+ }
1395
+ /**
1396
+ * @param {boolean} [is_meta]
1397
+ */
1398
+ get_header(is_meta = false) {
1399
+ const header = [];
1400
+ const directives = { ...this.#directives };
1401
+ if (this.#style_src.size > 0) directives["style-src"] = [...directives["style-src"] || directives["default-src"] || [], ...this.#style_src];
1402
+ if (this.#style_src_attr.size > 0) directives["style-src-attr"] = [...directives["style-src-attr"] || [], ...this.#style_src_attr];
1403
+ if (this.#style_src_elem.size > 0) directives["style-src-elem"] = [...directives["style-src-elem"] || [], ...this.#style_src_elem];
1404
+ if (this.#script_src.size > 0) directives["script-src"] = [...directives["script-src"] || directives["default-src"] || [], ...this.#script_src];
1405
+ if (this.#script_src_elem.size > 0) directives["script-src-elem"] = [...directives["script-src-elem"] || [], ...this.#script_src_elem];
1406
+ for (const key in directives) {
1407
+ if (is_meta && (key === "frame-ancestors" || key === "report-uri" || key === "sandbox")) continue;
1408
+ const value = directives[key];
1409
+ if (!value) continue;
1410
+ const directive = [key];
1411
+ if (Array.isArray(value)) value.forEach((value) => {
1412
+ if (quoted.has(value) || crypto_pattern.test(value)) directive.push(`'${value}'`);
1413
+ else directive.push(value);
1414
+ });
1415
+ header.push(directive.join(" "));
1416
+ }
1417
+ return header.join("; ");
1418
+ }
1419
+ };
1420
+ var CspProvider = class extends BaseProvider {
1421
+ get_meta() {
1422
+ const content = this.get_header(true);
1423
+ if (!content) return;
1424
+ return `<meta http-equiv="content-security-policy" content="${escape_html(content, true)}">`;
1425
+ }
1426
+ };
1427
+ var CspReportOnlyProvider = class extends BaseProvider {
1428
+ /**
1429
+ * @param {boolean} use_hashes
1430
+ * @param {import('types').CspDirectives} directives
1431
+ * @param {string} nonce
1432
+ */
1433
+ constructor(use_hashes, directives, nonce) {
1434
+ super(use_hashes, directives, nonce);
1435
+ if (Object.values(directives).filter((v) => !!v).length > 0) {
1436
+ const has_report_to = directives["report-to"]?.length ?? false;
1437
+ const has_report_uri = directives["report-uri"]?.length ?? false;
1438
+ if (!has_report_to && !has_report_uri) throw Error("`content-security-policy-report-only` must be specified with either the `report-to` or `report-uri` directives, or both");
1439
+ }
1440
+ }
1441
+ };
1442
+ var Csp = class {
1443
+ /** @readonly */
1444
+ nonce = generate_nonce();
1445
+ /** @type {CspProvider} */
1446
+ csp_provider;
1447
+ /** @type {CspReportOnlyProvider} */
1448
+ report_only_provider;
1449
+ /**
1450
+ * @param {import('./types.js').CspConfig} config
1451
+ * @param {import('./types.js').CspOpts} opts
1452
+ */
1453
+ constructor({ mode, directives, reportOnly }, { prerender }) {
1454
+ const use_hashes = mode === "hash" || mode === "auto" && prerender;
1455
+ this.csp_provider = new CspProvider(use_hashes, directives, this.nonce);
1456
+ this.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);
1457
+ }
1458
+ get script_needs_hash() {
1459
+ return this.csp_provider.script_needs_hash || this.report_only_provider.script_needs_hash;
1460
+ }
1461
+ get script_needs_nonce() {
1462
+ return this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;
1463
+ }
1464
+ get style_needs_nonce() {
1465
+ return this.csp_provider.style_needs_nonce || this.report_only_provider.style_needs_nonce;
1466
+ }
1467
+ /** @param {string} content */
1468
+ add_script(content) {
1469
+ this.csp_provider.add_script(content);
1470
+ this.report_only_provider.add_script(content);
1471
+ }
1472
+ /** @param {`sha256-${string}`[]} hashes */
1473
+ add_script_hashes(hashes) {
1474
+ this.csp_provider.add_script_hashes(hashes);
1475
+ this.report_only_provider.add_script_hashes(hashes);
1476
+ }
1477
+ /** @param {string} content */
1478
+ add_style(content) {
1479
+ this.csp_provider.add_style(content);
1480
+ this.report_only_provider.add_style(content);
1481
+ }
1482
+ };
1483
+ //#endregion
1484
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/server_routing.js
1485
+ /** @import { SSRManifest } from '@sveltejs/kit' */
1486
+ /**
1487
+ * @param {import('types').SSRClientRoute} route
1488
+ * @param {URL} url
1489
+ * @param {NonNullable<SSRManifest['_']['client']>} client
1490
+ * @returns {string}
1491
+ */
1492
+ function generate_route_object(route, url, client) {
1493
+ const { errors, layouts, leaf } = route;
1494
+ const nodes = [
1495
+ ...errors,
1496
+ ...layouts.map((l) => l?.[1]),
1497
+ leaf[1]
1498
+ ].filter((n) => typeof n === "number").map((n) => `'${n}': () => ${create_client_import(client.nodes?.[n], url)}`).join(",\n ");
1499
+ /** @type {import('types').CSRRouteServer} */
1500
+ return [
1501
+ `{\n\tid: ${s(route.id)}`,
1502
+ `errors: ${s(route.errors)}`,
1503
+ `layouts: ${s(route.layouts)}`,
1504
+ `leaf: ${s(route.leaf)}`,
1505
+ `nodes: {\n\t\t${nodes}\n\t}\n}`
1506
+ ].join(",\n ");
1507
+ }
1508
+ /**
1509
+ * @param {string | undefined} import_path
1510
+ * @param {URL} url
1511
+ */
1512
+ function create_client_import(import_path, url) {
1513
+ if (!import_path) return "Promise.resolve({})";
1514
+ if (import_path[0] === "/") return `import('${import_path}')`;
1515
+ if (assets !== "") return `import('${assets}/${import_path}')`;
1516
+ let path = get_relative_path(url.pathname, `${base}/${import_path}`);
1517
+ if (path[0] !== ".") path = `./${path}`;
1518
+ return `import('${path}')`;
1519
+ }
1520
+ /**
1521
+ * @param {string} resolved_path
1522
+ * @param {URL} url
1523
+ * @param {SSRManifest} manifest
1524
+ * @returns {Promise<Response>}
1525
+ */
1526
+ async function resolve_route(resolved_path, url, manifest) {
1527
+ if (!manifest._.client?.routes) return text("Server-side route resolution disabled", { status: 400 });
1528
+ const matchers = await manifest._.matchers();
1529
+ const result = find_route(resolved_path, manifest._.client.routes, matchers);
1530
+ return create_server_routing_response(result?.route ?? null, result?.params ?? {}, url, manifest._.client).response;
1531
+ }
1532
+ /**
1533
+ * @param {import('types').SSRClientRoute | null} route
1534
+ * @param {Partial<Record<string, string>>} params
1535
+ * @param {URL} url
1536
+ * @param {NonNullable<SSRManifest['_']['client']>} client
1537
+ * @returns {{response: Response, body: string}}
1538
+ */
1539
+ function create_server_routing_response(route, params, url, client) {
1540
+ const headers = new Headers({ "content-type": "application/javascript; charset=utf-8" });
1541
+ if (route) {
1542
+ const csr_route = generate_route_object(route, url, client);
1543
+ const body = `${create_css_import(route, url, client)}\nexport const route = ${csr_route}; export const params = ${JSON.stringify(params)};`;
1544
+ return {
1545
+ response: text(body, { headers }),
1546
+ body
1547
+ };
1548
+ } else return {
1549
+ response: text("", { headers }),
1550
+ body: ""
1551
+ };
1552
+ }
1553
+ /**
1554
+ * This function generates the client-side import for the CSS files that are
1555
+ * associated with the current route. Vite takes care of that when using
1556
+ * client-side route resolution, but for server-side resolution it does
1557
+ * not know about the CSS files automatically.
1558
+ *
1559
+ * @param {import('types').SSRClientRoute} route
1560
+ * @param {URL} url
1561
+ * @param {NonNullable<SSRManifest['_']['client']>} client
1562
+ * @returns {string}
1563
+ */
1564
+ function create_css_import(route, url, client) {
1565
+ const { errors, layouts, leaf } = route;
1566
+ let css = "";
1567
+ for (const node of [
1568
+ ...errors,
1569
+ ...layouts.map((l) => l?.[1]),
1570
+ leaf[1]
1571
+ ]) {
1572
+ if (typeof node !== "number") continue;
1573
+ const node_css = client.css?.[node];
1574
+ for (const css_path of node_css ?? []) css += `'${assets || base}/${css_path}',`;
1575
+ }
1576
+ if (!css) return "";
1577
+ return `${create_client_import(client.start, url)}.then(x => x.load_css([${css}]));`;
1578
+ }
1579
+ //#endregion
1580
+ //#region node_modules/@sveltejs/kit/src/runtime/server/remote.js
1581
+ /** @import { ActionResult, RemoteForm, RequestEvent, SSRManifest } from '@sveltejs/kit' */
1582
+ /** @import { RemoteFormInternals, RemoteFunctionData, RemoteFunctionResponse, RemoteInternals, RequestState, SSROptions } from 'types' */
1583
+ /** @type {typeof handle_remote_call_internal} */
1584
+ async function handle_remote_call(event, state, options, manifest, id) {
1585
+ return record_span({
1586
+ name: "sveltekit.remote.call",
1587
+ attributes: { },
1588
+ fn: (current) => {
1589
+ const traced_event = merge_tracing(event, current);
1590
+ return with_request_store({
1591
+ event: traced_event,
1592
+ state
1593
+ }, () => handle_remote_call_internal(traced_event, state, options, manifest, id));
1594
+ }
1595
+ });
1596
+ }
1597
+ /**
1598
+ * @param {RequestEvent} event
1599
+ * @param {RequestState} state
1600
+ * @param {SSROptions} options
1601
+ * @param {SSRManifest} manifest
1602
+ * @param {string} id
1603
+ */
1604
+ async function handle_remote_call_internal(event, state, options, manifest, id) {
1605
+ const [hash, name, additional_args] = id.split("/");
1606
+ const remotes = manifest._.remotes;
1607
+ if (!remotes[hash]) error(404);
1608
+ const fn = (await remotes[hash]()).default[name];
1609
+ if (!fn) error(404);
1610
+ /** @type {RemoteInternals} */
1611
+ const internals = fn.__;
1612
+ const transport = options.hooks.transport;
1613
+ event.tracing.current.setAttributes({
1614
+ "sveltekit.remote.call.type": internals.type,
1615
+ "sveltekit.remote.call.name": internals.name
1616
+ });
1617
+ /** @type {HeadersInit | undefined} */
1618
+ const headers = state.prerendering ? void 0 : { "cache-control": "private, no-store" };
1619
+ try {
1620
+ /** @type {RemoteFunctionData} */
1621
+ const data = {};
1622
+ switch (internals.type) {
1623
+ case "query_live": {
1624
+ if (event.request.method !== "GET") throw new SvelteKitError(405, "Method Not Allowed", `\`query.live\` functions must be invoked via GET request, not ${event.request.method}`);
1625
+ const payload = new URL(event.request.url).searchParams.get("payload");
1626
+ const generator = internals.run(event, state, parse_remote_arg(payload, transport));
1627
+ const encoder = new TextEncoder();
1628
+ /**
1629
+ * @param {ReadableStreamDefaultController} controller
1630
+ * @param {any} payload
1631
+ */
1632
+ function send(controller, payload) {
1633
+ controller.enqueue(encoder.encode("data: " + JSON.stringify(payload) + "\n\n"));
1634
+ }
1635
+ let closed = false;
1636
+ /** @type {string | undefined} */
1637
+ let result = void 0;
1638
+ async function cancel() {
1639
+ if (closed) return;
1640
+ closed = true;
1641
+ await generator.return(void 0);
1642
+ }
1643
+ event.request.signal.addEventListener("abort", cancel, { once: true });
1644
+ return new Response(new ReadableStream({
1645
+ async pull(controller) {
1646
+ if (event.request.signal.aborted) {
1647
+ await cancel();
1648
+ controller.close();
1649
+ return;
1650
+ }
1651
+ try {
1652
+ while (true) {
1653
+ const { value, done } = await generator.next();
1654
+ if (done) {
1655
+ await cancel();
1656
+ controller.close();
1657
+ return;
1658
+ }
1659
+ if (result !== (result = stringify(value, transport))) {
1660
+ send(controller, {
1661
+ type: "result",
1662
+ result
1663
+ });
1664
+ return;
1665
+ }
1666
+ }
1667
+ } catch (error) {
1668
+ if (!event.request.signal.aborted) if (error instanceof Redirect) send(controller, {
1669
+ type: "redirect",
1670
+ location: error.location
1671
+ });
1672
+ else {
1673
+ const status = error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
1674
+ send(controller, {
1675
+ type: "error",
1676
+ error: await handle_error_and_jsonify(event, state, options, error),
1677
+ status
1678
+ });
1679
+ }
1680
+ await cancel();
1681
+ controller.close();
1682
+ }
1683
+ },
1684
+ cancel
1685
+ }), { headers: {
1686
+ "cache-control": "private, no-store",
1687
+ "content-type": "text/event-stream"
1688
+ } });
1689
+ }
1690
+ case "query_batch": {
1691
+ if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`query.batch\` functions must be invoked via POST request, not ${event.request.method}`);
1692
+ /** @type {{ payloads: string[] }} */
1693
+ const { payloads } = await event.request.json();
1694
+ const args = await Promise.all(payloads.map((payload) => parse_remote_arg(payload, transport)));
1695
+ data._ = await with_request_store({
1696
+ event,
1697
+ state
1698
+ }, () => internals.run(args, options));
1699
+ break;
1700
+ }
1701
+ case "form": {
1702
+ if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`form\` functions must be invoked via POST request, not ${event.request.method}`);
1703
+ if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `\`form\` functions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
1704
+ const { data: input, meta, form_data } = await deserialize_binary_form(event.request);
1705
+ state.remote.requested = create_requested_map(meta.remote_refreshes);
1706
+ if (additional_args && !("id" in input)) input.id = JSON.parse(decodeURIComponent(additional_args));
1707
+ const fn = internals.fn;
1708
+ data._ = await with_request_store({
1709
+ event,
1710
+ state: {
1711
+ ...state,
1712
+ is_in_remote_form_or_command: true
1713
+ }
1714
+ }, () => fn(input, meta, form_data));
1715
+ if (data._.issues) return json({
1716
+ type: "result",
1717
+ data: stringify(data, transport)
1718
+ }, { headers });
1719
+ break;
1720
+ }
1721
+ case "command": {
1722
+ /** @type {{ payload: string, refreshes?: string[] }} */
1723
+ const { payload, refreshes } = await event.request.json();
1724
+ state.remote.requested = create_requested_map(refreshes);
1725
+ const arg = parse_remote_arg(payload, transport);
1726
+ data._ = await with_request_store({
1727
+ event,
1728
+ state: {
1729
+ ...state,
1730
+ is_in_remote_form_or_command: true
1731
+ }
1732
+ }, () => fn(arg));
1733
+ break;
1734
+ }
1735
+ case "prerender":
1736
+ data._ = await with_request_store({
1737
+ event,
1738
+ state
1739
+ }, () => fn(parse_remote_arg(additional_args, transport)));
1740
+ break;
1741
+ case "query": {
1742
+ const payload = new URL(event.request.url).searchParams.get("payload");
1743
+ data._ = await with_request_store({
1744
+ event,
1745
+ state
1746
+ }, () => fn(parse_remote_arg(payload, transport)));
1747
+ break;
1748
+ }
1749
+ }
1750
+ await collect_remote_data(data, event, state, options);
1751
+ return json({
1752
+ type: "result",
1753
+ data: stringify(data, transport)
1754
+ }, { headers });
1755
+ } catch (error) {
1756
+ if (error instanceof Redirect) return json({
1757
+ type: "result",
1758
+ data: stringify(await collect_remote_data({ redirect: error.location }, event, state, options), transport)
1759
+ }, { headers });
1760
+ const status = error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
1761
+ return json({
1762
+ type: "error",
1763
+ error: await handle_error_and_jsonify(event, state, options, error),
1764
+ status
1765
+ }, {
1766
+ status: state.prerendering ? status : void 0,
1767
+ headers: { "cache-control": "private, no-store" }
1768
+ });
1769
+ }
1770
+ }
1771
+ /**
1772
+ * Collects all the query/prerender data that was retrieved
1773
+ * during the request and adds it to `data`
1774
+ * @param {RemoteFunctionData} data
1775
+ * @param {RequestEvent} event
1776
+ * @param {RequestState} state
1777
+ * @param {SSROptions} options
1778
+ */
1779
+ async function collect_remote_data(data, event, state, options) {
1780
+ /**
1781
+ *
1782
+ * @param {unknown} error
1783
+ * @returns {Promise<[status: number, error: App.Error]>}
1784
+ */
1785
+ async function convert_error(error) {
1786
+ return [error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500, await handle_error_and_jsonify(event, state, options, error)];
1787
+ }
1788
+ /** @type {Promise<any>[]} */
1789
+ const promises = [];
1790
+ if (state.remote.explicit) for (const [remote_key, { internals, promise }] of state.remote.explicit) {
1791
+ data.r = true;
1792
+ const type = internals.type === "query_live" ? "l" : internals.type[0];
1793
+ await promise.then((v) => {
1794
+ ((data[type] ??= {})[remote_key] ??= {}).v = v;
1795
+ }, async (e) => {
1796
+ if (e instanceof Redirect) return;
1797
+ ((data[type] ??= {})[remote_key] ??= {}).e = await convert_error(e);
1798
+ });
1799
+ }
1800
+ await Promise.all(promises);
1801
+ if (state.remote.implicit) for (const [internals, record] of state.remote.implicit) {
1802
+ if (!internals.id) continue;
1803
+ for (const key in record) {
1804
+ const remote_key = internals.type === "form" ? key : create_remote_key(internals.id, key);
1805
+ const type = internals.type === "query_live" ? "l" : internals.type[0];
1806
+ const promise = state.remote.data?.get(internals)?.[key] ?? record[key]();
1807
+ let resolved = true;
1808
+ await Promise.race([Promise.resolve(promise).then((v) => {
1809
+ if (resolved) ((data[type] ??= {})[remote_key] ??= {}).v = v;
1810
+ }, (e) => {
1811
+ if (e instanceof Redirect) return;
1812
+ if (resolved) promises.push(convert_error(e).then((e) => {
1813
+ ((data[type] ??= {})[remote_key] ??= {}).e = e;
1814
+ }));
1815
+ }), Promise.resolve().then(() => resolved = false)]);
1816
+ }
1817
+ }
1818
+ await Promise.all(promises);
1819
+ return data;
1820
+ }
1821
+ /**
1822
+ * @param {string[] | undefined} refreshes
1823
+ */
1824
+ function create_requested_map(refreshes) {
1825
+ /** @type {Map<string, string[]>} */
1826
+ const requested = /* @__PURE__ */ new Map();
1827
+ for (const key of refreshes ?? []) {
1828
+ const parts = split_remote_key(key);
1829
+ const existing = requested.get(parts.id);
1830
+ if (existing) existing.push(parts.payload);
1831
+ else requested.set(parts.id, [parts.payload]);
1832
+ }
1833
+ return requested;
1834
+ }
1835
+ /** @type {typeof handle_remote_form_post_internal} */
1836
+ async function handle_remote_form_post(event, state, manifest, id) {
1837
+ return record_span({
1838
+ name: "sveltekit.remote.form.post",
1839
+ attributes: { },
1840
+ fn: (current) => {
1841
+ const traced_event = merge_tracing(event, current);
1842
+ return with_request_store({
1843
+ event: traced_event,
1844
+ state
1845
+ }, () => handle_remote_form_post_internal(traced_event, state, manifest, id));
1846
+ }
1847
+ });
1848
+ }
1849
+ /**
1850
+ * @param {RequestEvent} event
1851
+ * @param {RequestState} state
1852
+ * @param {SSRManifest} manifest
1853
+ * @param {string} id
1854
+ * @returns {Promise<ActionResult>}
1855
+ */
1856
+ async function handle_remote_form_post_internal(event, state, manifest, id) {
1857
+ const [hash, name, ...rest] = id.split("/");
1858
+ const action_id = rest.join("/");
1859
+ let form = (await manifest._.remotes[hash]?.())?.default[name];
1860
+ if (!form) {
1861
+ event.setHeaders({ allow: "GET" });
1862
+ return {
1863
+ type: "error",
1864
+ error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
1865
+ };
1866
+ }
1867
+ if (action_id) form = with_request_store({
1868
+ event,
1869
+ state
1870
+ }, () => form.for(JSON.parse(action_id)));
1871
+ try {
1872
+ const fn = form.__.fn;
1873
+ const { data, meta, form_data } = await deserialize_binary_form(event.request);
1874
+ if (action_id && !("id" in data)) data.id = JSON.parse(decodeURIComponent(action_id));
1875
+ await with_request_store({
1876
+ event,
1877
+ state: {
1878
+ ...state,
1879
+ is_in_remote_form_or_command: true
1880
+ }
1881
+ }, () => fn(data, meta, form_data));
1882
+ return {
1883
+ type: "success",
1884
+ status: 200
1885
+ };
1886
+ } catch (e) {
1887
+ const err = normalize_error(e);
1888
+ if (err instanceof Redirect) return {
1889
+ type: "redirect",
1890
+ status: err.status,
1891
+ location: err.location
1892
+ };
1893
+ return {
1894
+ type: "error",
1895
+ error: check_incorrect_fail_use(err)
1896
+ };
1897
+ }
1898
+ }
1899
+ /**
1900
+ * @param {URL} url
1901
+ */
1902
+ function get_remote_id(url) {
1903
+ return url.pathname.startsWith(`${base}/_app/remote/`) && url.pathname.replace(`${base}/_app/remote/`, "");
1904
+ }
1905
+ /**
1906
+ * @param {URL} url
1907
+ */
1908
+ function get_remote_action(url) {
1909
+ return url.searchParams.get("/remote");
1910
+ }
1911
+ //#endregion
1912
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/render.js
1913
+ var updated = {
1914
+ ...readable(false),
1915
+ check: () => false
1916
+ };
1917
+ /**
1918
+ * Creates the HTML response.
1919
+ * @param {{
1920
+ * branch: Array<import('./types.js').Loaded>;
1921
+ * fetched: Array<import('./types.js').Fetched>;
1922
+ * options: import('types').SSROptions;
1923
+ * manifest: import('@sveltejs/kit').SSRManifest;
1924
+ * state: import('types').SSRState;
1925
+ * page_config: { ssr: boolean; csr: boolean };
1926
+ * status: number;
1927
+ * error: App.Error | null;
1928
+ * event: import('@sveltejs/kit').RequestEvent;
1929
+ * event_state: import('types').RequestState;
1930
+ * resolve_opts: import('types').RequiredResolveOptions;
1931
+ * action_result?: import('@sveltejs/kit').ActionResult;
1932
+ * data_serializer: import('./types.js').ServerDataSerializer;
1933
+ * error_components?: Array<import('types').SSRComponent | undefined>
1934
+ * }} opts
1935
+ */
1936
+ async function render_response({ branch, fetched, options, manifest, state, page_config, status, error = null, event, event_state, resolve_opts, action_result, data_serializer, error_components }) {
1937
+ if (state.prerendering) {
1938
+ if (options.csp.mode === "nonce") throw new Error("Cannot use prerendering if config.kit.csp.mode === \"nonce\"");
1939
+ if (options.app_template_contains_nonce) throw new Error("Cannot use prerendering if page template contains %sveltekit.nonce%");
1940
+ }
1941
+ const { client } = manifest._;
1942
+ const modulepreloads = new Set(client?.imports);
1943
+ const stylesheets = new Set(client?.stylesheets);
1944
+ const fonts = new Set(client?.fonts);
1945
+ /**
1946
+ * The value of the Link header that is added to the response when not prerendering
1947
+ * @type {Set<string>}
1948
+ */
1949
+ const link_headers = /* @__PURE__ */ new Set();
1950
+ /** @type {Map<string, string>} */
1951
+ const inline_styles = /* @__PURE__ */ new Map();
1952
+ /** @type {ReturnType<typeof options.root.render>} */
1953
+ let rendered;
1954
+ const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
1955
+ /** @type {string} */
1956
+ let base$1 = base;
1957
+ /** @type {string} */
1958
+ let assets$1 = assets;
1959
+ /**
1960
+ * An expression that will evaluate in the client to determine the resolved base path.
1961
+ * We use a relative path when possible to support IPFS, the internet archive, etc.
1962
+ */
1963
+ let base_expression = s(base);
1964
+ const csp = new Csp(options.csp, { prerender: !!state.prerendering });
1965
+ if (!state.prerendering?.fallback) {
1966
+ base$1 = (event.isDataRequest ? add_data_suffix(event.url.pathname) : event.url.pathname).slice(base.length).split("/").slice(2).map(() => "..").join("/") || ".";
1967
+ base_expression = `new URL(${s(base$1)}, location).pathname.slice(0, -1)`;
1968
+ if (!assets || assets[0] === "/" && assets !== "/_svelte_kit_assets") assets$1 = base$1;
1969
+ } else if (options.hash_routing) base_expression = "new URL('.', location).pathname.slice(0, -1)";
1970
+ if (page_config.ssr) {
1971
+ /** @type {Record<string, any>} */
1972
+ const props = {
1973
+ stores: {
1974
+ page: writable(null),
1975
+ navigating: writable(null),
1976
+ updated
1977
+ },
1978
+ constructors: await Promise.all(branch.map(({ node }) => {
1979
+ if (!node.component) throw new Error(`Missing +page.svelte component for route ${event.route.id}`);
1980
+ return node.component();
1981
+ })),
1982
+ form: form_value
1983
+ };
1984
+ if (error_components) {
1985
+ if (error) props.error = error;
1986
+ props.errors = error_components;
1987
+ }
1988
+ let data = {};
1989
+ for (let i = 0; i < branch.length; i += 1) {
1990
+ data = {
1991
+ ...data,
1992
+ ...branch[i].data
1993
+ };
1994
+ props[`data_${i}`] = data;
1995
+ }
1996
+ props.page = {
1997
+ error,
1998
+ params: event.params,
1999
+ route: event.route,
2000
+ status,
2001
+ url: event.url,
2002
+ data,
2003
+ form: form_value,
2004
+ state: {}
2005
+ };
2006
+ const render_opts = {
2007
+ context: /* @__PURE__ */ new Map([["__request__", { page: props.page }]]),
2008
+ csp: csp.script_needs_nonce ? { nonce: csp.nonce } : { hash: csp.script_needs_hash },
2009
+ transformError: error_components ? async (e) => {
2010
+ if (isRedirect(e)) throw e;
2011
+ const transformed = await handle_error_and_jsonify(event, event_state, options, e);
2012
+ props.page.error = props.error = error = transformed;
2013
+ props.page.status = status = get_status(e);
2014
+ return transformed;
2015
+ } : void 0
2016
+ };
2017
+ try {
2018
+ rendered = await with_request_store({
2019
+ event,
2020
+ state: {
2021
+ ...event_state,
2022
+ is_in_render: true
2023
+ }
2024
+ }, async () => {
2025
+ override({
2026
+ base: base$1,
2027
+ assets: assets$1
2028
+ });
2029
+ const maybe_promise = options.root.render(props, render_opts);
2030
+ const rendered = options.async && "then" in maybe_promise ? maybe_promise.then((r) => r) : maybe_promise;
2031
+ if (options.async) reset();
2032
+ const { head, html, css, hashes } = options.async ? await rendered : rendered;
2033
+ if (hashes) csp.add_script_hashes(hashes.script);
2034
+ return {
2035
+ head,
2036
+ html,
2037
+ css,
2038
+ hashes
2039
+ };
2040
+ });
2041
+ } finally {
2042
+ reset();
2043
+ }
2044
+ } else rendered = {
2045
+ head: "",
2046
+ html: "",
2047
+ css: {
2048
+ code: "",
2049
+ map: null
2050
+ },
2051
+ hashes: { script: [] }
2052
+ };
2053
+ for (const { node } of branch) {
2054
+ for (const url of node.imports) modulepreloads.add(url);
2055
+ for (const url of node.stylesheets) stylesheets.add(url);
2056
+ for (const url of node.fonts) fonts.add(url);
2057
+ if (node.inline_styles && !client?.inline) Object.entries(await node.inline_styles()).forEach(([filename, css]) => {
2058
+ if (typeof css === "string") {
2059
+ inline_styles.set(filename, css);
2060
+ return;
2061
+ }
2062
+ inline_styles.set(filename, css(`${assets$1}/${app_dir}/immutable/assets`, assets$1));
2063
+ });
2064
+ }
2065
+ const head = new Head(rendered.head, !!state.prerendering);
2066
+ let body = rendered.html;
2067
+ /** @param {string} path */
2068
+ const prefixed = (path) => {
2069
+ if (path.startsWith("/")) return base + path;
2070
+ return `${assets$1}/${path}`;
2071
+ };
2072
+ const style = client?.inline ? client.inline?.style : Array.from(inline_styles.values()).join("\n");
2073
+ if (style) {
2074
+ const attributes = [];
2075
+ if (csp.style_needs_nonce) attributes.push(`nonce="${csp.nonce}"`);
2076
+ csp.add_style(style);
2077
+ head.add_style(style, attributes);
2078
+ }
2079
+ for (const dep of stylesheets) {
2080
+ const path = prefixed(dep);
2081
+ const attributes = ["rel=\"stylesheet\""];
2082
+ if (inline_styles.has(dep)) attributes.push("disabled", "media=\"(max-width: 0)\"");
2083
+ else if (resolve_opts.preload({
2084
+ type: "css",
2085
+ path
2086
+ })) link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="style"; nopush`);
2087
+ head.add_stylesheet(path, attributes);
2088
+ }
2089
+ for (const dep of fonts) {
2090
+ const path = prefixed(dep);
2091
+ if (resolve_opts.preload({
2092
+ type: "font",
2093
+ path
2094
+ })) {
2095
+ const ext = dep.slice(dep.lastIndexOf(".") + 1);
2096
+ head.add_link_tag(path, [
2097
+ "rel=\"preload\"",
2098
+ "as=\"font\"",
2099
+ `type="font/${ext}"`,
2100
+ "crossorigin"
2101
+ ]);
2102
+ link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`);
2103
+ }
2104
+ }
2105
+ const global = get_global_name(options);
2106
+ const { data, chunks } = data_serializer.get_data(csp);
2107
+ if (page_config.ssr && page_config.csr) body += `\n\t\t\t${fetched.map((item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering)).join("\n ")}`;
2108
+ if (page_config.csr && client) {
2109
+ const route = client.routes?.find((r) => r.id === event.route.id) ?? null;
2110
+ const load_env_eagerly = client.uses_env_dynamic_public && !!state.prerendering;
2111
+ if (load_env_eagerly) modulepreloads.add(`${app_dir}/env.js`);
2112
+ if (!client.inline) {
2113
+ const included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter((path) => resolve_opts.preload({
2114
+ type: "js",
2115
+ path
2116
+ }));
2117
+ for (const path of included_modulepreloads) {
2118
+ link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
2119
+ if (options.preload_strategy !== "modulepreload") head.add_script_preload(path);
2120
+ else head.add_link_tag(path, ["rel=\"modulepreload\""]);
2121
+ }
2122
+ }
2123
+ if (client.routes && state.prerendering && !state.prerendering.fallback) {
2124
+ const pathname = add_resolution_suffix(event.url.pathname);
2125
+ state.prerendering.dependencies.set(pathname, create_server_routing_response(route, event.params, new URL(pathname, event.url), client));
2126
+ }
2127
+ const blocks = [];
2128
+ const properties = [`base: ${base_expression}`];
2129
+ if (assets) properties.push(`assets: ${s(assets)}`);
2130
+ if (client.uses_env_dynamic_public) properties.push(`env: ${load_env_eagerly ? "null" : s(public_env)}`);
2131
+ if (chunks) {
2132
+ blocks.push("const deferred = new Map();");
2133
+ properties.push(`defer: (id) => new Promise((fulfil, reject) => {
2134
+ deferred.set(id, { fulfil, reject });
2135
+ })`);
2136
+ let app_declaration = "";
2137
+ if (Object.keys(options.hooks.transport).length > 0) if (client.inline) app_declaration = `const app = ${global}.app.app;`;
2138
+ else if (client.app) app_declaration = `const app = await import(${s(prefixed(client.app))});`;
2139
+ else app_declaration = `const { app } = await import(${s(prefixed(client.start))});`;
2140
+ const prelude = app_declaration ? `${app_declaration}
2141
+ const [data, error] = fn(app);` : `const [data, error] = fn();`;
2142
+ properties.push(`resolve: async (id, fn) => {
2143
+ ${prelude}
2144
+
2145
+ const try_to_resolve = () => {
2146
+ if (!deferred.has(id)) {
2147
+ setTimeout(try_to_resolve, 0);
2148
+ return;
2149
+ }
2150
+ const { fulfil, reject } = deferred.get(id);
2151
+ deferred.delete(id);
2152
+ if (error) reject(error);
2153
+ else fulfil(data);
2154
+ }
2155
+ try_to_resolve();
2156
+ }`);
2157
+ }
2158
+ blocks.push(`${global} = {
2159
+ ${properties.join(",\n ")}
2160
+ };`);
2161
+ const args = ["element"];
2162
+ blocks.push("const element = document.currentScript.parentElement;");
2163
+ if (page_config.ssr) {
2164
+ const serialized = {
2165
+ form: "null",
2166
+ error: "null"
2167
+ };
2168
+ if (form_value) serialized.form = uneval_action_response(form_value, event.route.id, options.hooks.transport);
2169
+ if (error) serialized.error = uneval(error);
2170
+ const hydrate = [
2171
+ `node_ids: [${branch.map(({ node }) => node.index).join(", ")}]`,
2172
+ `data: ${data}`,
2173
+ `form: ${serialized.form}`,
2174
+ `error: ${serialized.error}`
2175
+ ];
2176
+ if (status !== 200) hydrate.push(`status: ${status}`);
2177
+ if (client.routes) {
2178
+ if (route) {
2179
+ const stringified = generate_route_object(route, event.url, client).replaceAll("\n", "\n ");
2180
+ hydrate.push(`params: ${uneval(event.params)}`, `server_route: ${stringified}`);
2181
+ }
2182
+ } else if (options.embedded) hydrate.push(`params: ${uneval(event.params)}`, `route: ${s(event.route)}`);
2183
+ const indent = " ".repeat(load_env_eagerly ? 7 : 6);
2184
+ args.push(`{\n${indent}\t${hydrate.join(`,\n${indent}\t`)}\n${indent}}`);
2185
+ }
2186
+ const remote_data = await collect_remote_data({}, event, event_state, options);
2187
+ const serialized_data = Object.keys(remote_data).length > 0 ? `${global}.data = ${uneval(remote_data, create_replacer(options.hooks.transport))};\n\n\t\t\t\t\t\t` : "";
2188
+ const boot = client.inline ? `${client.inline.script}
2189
+
2190
+ ${serialized_data}${global}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
2191
+ import(${s(prefixed(client.start))}),
2192
+ import(${s(prefixed(client.app))})
2193
+ ]).then(([kit, app]) => {
2194
+ ${serialized_data}kit.start(app, ${args.join(", ")});
2195
+ });` : `import(${s(prefixed(client.start))}).then((app) => {
2196
+ ${serialized_data}app.start(${args.join(", ")})
2197
+ });`;
2198
+ if (load_env_eagerly) blocks.push(`import(${s(`${base$1}/${app_dir}/env.js`)}).then(({ env }) => {
2199
+ ${global}.env = env;
2200
+
2201
+ ${boot.replace(/\n/g, "\n ")}
2202
+ });`);
2203
+ else blocks.push(boot);
2204
+ if (options.service_worker) {
2205
+ let opts = "";
2206
+ if (options.service_worker_options != null) opts = `, ${s({ ...options.service_worker_options })}`;
2207
+ blocks.push(`if ('serviceWorker' in navigator) {
2208
+ const script_url = '${prefixed("service-worker.js")}';
2209
+ const policy = globalThis?.window?.trustedTypes?.createPolicy(
2210
+ 'sveltekit-trusted-url',
2211
+ { createScriptURL(url) { return url; } }
2212
+ );
2213
+ const sanitised = policy?.createScriptURL(script_url) ?? script_url;
2214
+ addEventListener('load', function () {
2215
+ navigator.serviceWorker.register(sanitised${opts});
2216
+ });
2217
+ }`);
2218
+ }
2219
+ const init_app = `
2220
+ {
2221
+ ${blocks.join("\n\n ")}
2222
+ }
2223
+ `;
2224
+ csp.add_script(init_app);
2225
+ body += `\n\t\t\t<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>${init_app}<\/script>\n\t\t`;
2226
+ }
2227
+ const headers = new Headers({
2228
+ "x-sveltekit-page": "true",
2229
+ "content-type": "text/html"
2230
+ });
2231
+ if (state.prerendering) {
2232
+ const csp_headers = csp.csp_provider.get_meta();
2233
+ if (csp_headers) head.add_http_equiv(csp_headers);
2234
+ if (state.prerendering.cache) head.add_http_equiv(`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`);
2235
+ } else {
2236
+ const csp_header = csp.csp_provider.get_header();
2237
+ if (csp_header) headers.set("content-security-policy", csp_header);
2238
+ const report_only_header = csp.report_only_provider.get_header();
2239
+ if (report_only_header) headers.set("content-security-policy-report-only", report_only_header);
2240
+ if (link_headers.size) headers.set("link", Array.from(link_headers).join(", "));
2241
+ }
2242
+ const html = options.templates.app({
2243
+ head: head.build(),
2244
+ body,
2245
+ assets: assets$1,
2246
+ nonce: csp.nonce,
2247
+ env: public_env
2248
+ });
2249
+ const transformed = await resolve_opts.transformPageChunk({
2250
+ html,
2251
+ done: true
2252
+ }) || "";
2253
+ if (!chunks) headers.set("etag", `"${hash(transformed)}"`);
2254
+ return !chunks ? text(transformed, {
2255
+ status,
2256
+ headers
2257
+ }) : new Response(new ReadableStream({
2258
+ async start(controller) {
2259
+ controller.enqueue(text_encoder.encode(transformed + "\n"));
2260
+ for await (const chunk of chunks) if (chunk.length) controller.enqueue(text_encoder.encode(chunk));
2261
+ controller.close();
2262
+ },
2263
+ type: "bytes"
2264
+ }), { headers });
2265
+ }
2266
+ var Head = class {
2267
+ #rendered;
2268
+ #prerendering;
2269
+ /** @type {string[]} */
2270
+ #http_equiv = [];
2271
+ /** @type {string[]} */
2272
+ #link_tags = [];
2273
+ /** @type {string[]} */
2274
+ #script_preloads = [];
2275
+ /** @type {string[]} */
2276
+ #style_tags = [];
2277
+ /** @type {string[]} */
2278
+ #stylesheet_links = [];
2279
+ /**
2280
+ * @param {string} rendered
2281
+ * @param {boolean} prerendering
2282
+ */
2283
+ constructor(rendered, prerendering) {
2284
+ this.#rendered = rendered;
2285
+ this.#prerendering = prerendering;
2286
+ }
2287
+ build() {
2288
+ return [
2289
+ ...this.#http_equiv,
2290
+ ...this.#link_tags,
2291
+ ...this.#script_preloads,
2292
+ this.#rendered,
2293
+ ...this.#style_tags,
2294
+ ...this.#stylesheet_links
2295
+ ].join("\n ");
2296
+ }
2297
+ /**
2298
+ * @param {string} style
2299
+ * @param {string[]} attributes
2300
+ */
2301
+ add_style(style, attributes) {
2302
+ this.#style_tags.push(`<style${attributes.length ? " " + attributes.join(" ") : ""}>${style}</style>`);
2303
+ }
2304
+ /**
2305
+ * @param {string} href
2306
+ * @param {string[]} attributes
2307
+ */
2308
+ add_stylesheet(href, attributes) {
2309
+ this.#stylesheet_links.push(`<link href="${href}" ${attributes.join(" ")}>`);
2310
+ }
2311
+ /** @param {string} href */
2312
+ add_script_preload(href) {
2313
+ this.#script_preloads.push(`<link rel="preload" as="script" crossorigin="anonymous" href="${href}">`);
2314
+ }
2315
+ /**
2316
+ * @param {string} href
2317
+ * @param {string[]} attributes
2318
+ */
2319
+ add_link_tag(href, attributes) {
2320
+ if (!this.#prerendering) return;
2321
+ this.#link_tags.push(`<link href="${href}" ${attributes.join(" ")}>`);
2322
+ }
2323
+ /** @param {string} tag */
2324
+ add_http_equiv(tag) {
2325
+ if (!this.#prerendering) return;
2326
+ this.#http_equiv.push(tag);
2327
+ }
2328
+ };
2329
+ //#endregion
2330
+ //#region node_modules/@sveltejs/kit/src/utils/page_nodes.js
2331
+ var PageNodes = class {
2332
+ /** All layout nodes and the page node, if any */
2333
+ data;
2334
+ /**
2335
+ * @param {Array<import('types').SSRNode | undefined>} nodes
2336
+ */
2337
+ constructor(nodes) {
2338
+ this.data = nodes;
2339
+ }
2340
+ layouts() {
2341
+ return this.data.slice(0, -1);
2342
+ }
2343
+ page() {
2344
+ return this.data.at(-1);
2345
+ }
2346
+ validate() {
2347
+ for (const layout of this.layouts()) if (layout) {
2348
+ validate_layout_server_exports(layout.server, layout.server_id);
2349
+ validate_layout_exports(layout.universal, layout.universal_id);
2350
+ }
2351
+ const page = this.page();
2352
+ if (page) {
2353
+ validate_page_server_exports(page.server, page.server_id);
2354
+ validate_page_exports(page.universal, page.universal_id);
2355
+ }
2356
+ }
2357
+ /**
2358
+ * @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash'} Option
2359
+ * @param {Option} option
2360
+ * @returns {Value | undefined}
2361
+ */
2362
+ #get_option(option) {
2363
+ /** @typedef {(import('types').UniversalNode | import('types').ServerNode)[Option]} Value */
2364
+ return this.data.reduce((value, node) => {
2365
+ return node?.universal?.[option] ?? node?.server?.[option] ?? value;
2366
+ }, void 0);
2367
+ }
2368
+ csr() {
2369
+ return this.#get_option("csr") ?? true;
2370
+ }
2371
+ ssr() {
2372
+ return this.#get_option("ssr") ?? true;
2373
+ }
2374
+ prerender() {
2375
+ return this.#get_option("prerender") ?? false;
2376
+ }
2377
+ trailing_slash() {
2378
+ return this.#get_option("trailingSlash") ?? "never";
2379
+ }
2380
+ get_config() {
2381
+ /** @type {any} */
2382
+ let current = {};
2383
+ for (const node of this.data) {
2384
+ if (!node?.universal?.config && !node?.server?.config) continue;
2385
+ current = {
2386
+ ...current,
2387
+ ...node?.universal?.config,
2388
+ ...node?.server?.config
2389
+ };
2390
+ }
2391
+ return Object.keys(current).length ? current : void 0;
2392
+ }
2393
+ should_prerender_data() {
2394
+ return this.data.some((node) => node?.server?.load || node?.server?.trailingSlash !== void 0);
2395
+ }
2396
+ };
2397
+ //#endregion
2398
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/respond_with_error.js
2399
+ /**
2400
+ * @typedef {import('./types.js').Loaded} Loaded
2401
+ */
2402
+ /**
2403
+ * @param {{
2404
+ * event: import('@sveltejs/kit').RequestEvent;
2405
+ * event_state: import('types').RequestState;
2406
+ * options: import('types').SSROptions;
2407
+ * manifest: import('@sveltejs/kit').SSRManifest;
2408
+ * state: import('types').SSRState;
2409
+ * status: number;
2410
+ * error: unknown;
2411
+ * resolve_opts: import('types').RequiredResolveOptions;
2412
+ * }} opts
2413
+ */
2414
+ async function respond_with_error({ event, event_state, options, manifest, state, status, error, resolve_opts }) {
2415
+ if (event.request.headers.get("x-sveltekit-error")) return static_error_page(
2416
+ options,
2417
+ status,
2418
+ /** @type {Error} */
2419
+ error.message
2420
+ );
2421
+ /** @type {import('./types.js').Fetched[]} */
2422
+ const fetched = [];
2423
+ try {
2424
+ const branch = [];
2425
+ const default_layout = await manifest._.nodes[0]();
2426
+ const nodes = new PageNodes([default_layout]);
2427
+ const ssr = nodes.ssr();
2428
+ const csr = nodes.csr();
2429
+ const data_serializer = server_data_serializer(event, event_state, options);
2430
+ if (ssr) {
2431
+ state.error = true;
2432
+ const server_data_promise = load_server_data({
2433
+ event,
2434
+ event_state,
2435
+ state,
2436
+ node: default_layout,
2437
+ parent: async () => ({})
2438
+ });
2439
+ const server_data = await server_data_promise;
2440
+ data_serializer.add_node(0, server_data);
2441
+ const data = await load_data({
2442
+ event,
2443
+ event_state,
2444
+ fetched,
2445
+ node: default_layout,
2446
+ parent: async () => ({}),
2447
+ resolve_opts,
2448
+ server_data_promise,
2449
+ state,
2450
+ csr
2451
+ });
2452
+ branch.push({
2453
+ node: default_layout,
2454
+ server_data,
2455
+ data
2456
+ }, {
2457
+ node: await manifest._.nodes[1](),
2458
+ data: null,
2459
+ server_data: null
2460
+ });
2461
+ }
2462
+ return await render_response({
2463
+ options,
2464
+ manifest,
2465
+ state,
2466
+ page_config: {
2467
+ ssr,
2468
+ csr
2469
+ },
2470
+ status,
2471
+ error: await handle_error_and_jsonify(event, event_state, options, error),
2472
+ branch,
2473
+ error_components: [],
2474
+ fetched,
2475
+ event,
2476
+ event_state,
2477
+ resolve_opts,
2478
+ data_serializer
2479
+ });
2480
+ } catch (e) {
2481
+ if (e instanceof Redirect) return redirect_response(e.status, e.location);
2482
+ return static_error_page(options, get_status(e), (await handle_error_and_jsonify(event, event_state, options, e)).message);
2483
+ }
2484
+ }
2485
+ //#endregion
2486
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/index.js
2487
+ /** @import { ActionResult, RequestEvent, SSRManifest } from '@sveltejs/kit' */
2488
+ /** @import { PageNodeIndexes, RequestState, RequiredResolveOptions, ServerDataNode, SSRComponent, SSRNode, SSROptions, SSRState } from 'types' */
2489
+ /**
2490
+ * The maximum request depth permitted before assuming we're stuck in an infinite loop
2491
+ */
2492
+ var MAX_DEPTH = 10;
2493
+ /**
2494
+ * @param {RequestEvent} event
2495
+ * @param {RequestState} event_state
2496
+ * @param {PageNodeIndexes} page
2497
+ * @param {SSROptions} options
2498
+ * @param {SSRManifest} manifest
2499
+ * @param {SSRState} state
2500
+ * @param {import('../../../utils/page_nodes.js').PageNodes} nodes
2501
+ * @param {RequiredResolveOptions} resolve_opts
2502
+ * @returns {Promise<Response>}
2503
+ */
2504
+ async function render_page(event, event_state, page, options, manifest, state, nodes, resolve_opts) {
2505
+ if (state.depth > MAX_DEPTH) return text(`Not found: ${event.url.pathname}`, { status: 404 });
2506
+ if (is_action_json_request(event)) return handle_action_json_request(event, event_state, options, (await manifest._.nodes[page.leaf]())?.server);
2507
+ try {
2508
+ const leaf_node = nodes.page();
2509
+ let status = 200;
2510
+ /** @type {ActionResult | undefined} */
2511
+ let action_result = void 0;
2512
+ if (is_action_request(event)) {
2513
+ const remote_id = get_remote_action(event.url);
2514
+ if (remote_id) action_result = await handle_remote_form_post(event, event_state, manifest, remote_id);
2515
+ else action_result = await handle_action_request(event, event_state, leaf_node.server);
2516
+ if (action_result?.type === "redirect") return redirect_response(action_result.status, action_result.location);
2517
+ if (action_result?.type === "error") status = get_status(action_result.error);
2518
+ if (action_result?.type === "failure") status = action_result.status;
2519
+ }
2520
+ const should_prerender = nodes.prerender();
2521
+ if (should_prerender) {
2522
+ if (leaf_node.server?.actions) throw new Error("Cannot prerender pages with actions");
2523
+ } else if (state.prerendering) return new Response(void 0, { status: 204 });
2524
+ state.prerender_default = should_prerender;
2525
+ const should_prerender_data = nodes.should_prerender_data();
2526
+ const data_pathname = add_data_suffix(event.url.pathname);
2527
+ /** @type {import('./types.js').Fetched[]} */
2528
+ const fetched = [];
2529
+ const ssr = nodes.ssr();
2530
+ const csr = nodes.csr();
2531
+ if (ssr === false && !(state.prerendering && should_prerender_data)) return await render_response({
2532
+ branch: compact(nodes.data).map((node) => {
2533
+ return {
2534
+ node,
2535
+ data: null,
2536
+ server_data: null
2537
+ };
2538
+ }),
2539
+ fetched,
2540
+ page_config: {
2541
+ ssr: false,
2542
+ csr
2543
+ },
2544
+ status,
2545
+ error: null,
2546
+ event,
2547
+ event_state,
2548
+ options,
2549
+ manifest,
2550
+ state,
2551
+ resolve_opts,
2552
+ data_serializer: server_data_serializer(event, event_state, options)
2553
+ });
2554
+ /** @type {Array<import('./types.js').Loaded | null>} */
2555
+ const branch = [];
2556
+ /** @type {Error | null} */
2557
+ let load_error = null;
2558
+ const data_serializer = server_data_serializer(event, event_state, options);
2559
+ const data_serializer_json = state.prerendering && should_prerender_data ? server_data_serializer_json(event, event_state, options) : null;
2560
+ /** @type {Array<Promise<ServerDataNode | null>>} */
2561
+ const server_promises = nodes.data.map((node, i) => {
2562
+ if (load_error) throw load_error;
2563
+ return Promise.resolve().then(async () => {
2564
+ try {
2565
+ if (node === leaf_node && action_result?.type === "error") throw action_result.error;
2566
+ const server_data = await load_server_data({
2567
+ event,
2568
+ event_state,
2569
+ state,
2570
+ node,
2571
+ parent: async () => {
2572
+ /** @type {Record<string, any>} */
2573
+ const data = {};
2574
+ for (let j = 0; j < i; j += 1) {
2575
+ const parent = await server_promises[j];
2576
+ if (parent) Object.assign(data, parent.data);
2577
+ }
2578
+ return data;
2579
+ }
2580
+ });
2581
+ if (node) data_serializer.add_node(i, server_data);
2582
+ data_serializer_json?.add_node(i, server_data);
2583
+ return server_data;
2584
+ } catch (e) {
2585
+ load_error = e;
2586
+ throw load_error;
2587
+ }
2588
+ });
2589
+ });
2590
+ /** @type {Array<Promise<Record<string, any> | null>>} */
2591
+ const load_promises = nodes.data.map((node, i) => {
2592
+ if (load_error) throw load_error;
2593
+ return Promise.resolve().then(async () => {
2594
+ try {
2595
+ return await load_data({
2596
+ event,
2597
+ event_state,
2598
+ fetched,
2599
+ node,
2600
+ parent: async () => {
2601
+ const data = {};
2602
+ for (let j = 0; j < i; j += 1) Object.assign(data, await load_promises[j]);
2603
+ return data;
2604
+ },
2605
+ resolve_opts,
2606
+ server_data_promise: server_promises[i],
2607
+ state,
2608
+ csr
2609
+ });
2610
+ } catch (e) {
2611
+ load_error = e;
2612
+ throw load_error;
2613
+ }
2614
+ });
2615
+ });
2616
+ for (const p of server_promises) p.catch(noop);
2617
+ for (const p of load_promises) p.catch(noop);
2618
+ for (let i = 0; i < nodes.data.length; i += 1) {
2619
+ const node = nodes.data[i];
2620
+ if (node) try {
2621
+ const server_data = await server_promises[i];
2622
+ const data = await load_promises[i];
2623
+ branch.push({
2624
+ node,
2625
+ server_data,
2626
+ data
2627
+ });
2628
+ } catch (e) {
2629
+ const err = normalize_error(e);
2630
+ if (err instanceof Redirect) {
2631
+ if (state.prerendering && should_prerender_data) {
2632
+ const body = JSON.stringify({
2633
+ type: "redirect",
2634
+ location: err.location
2635
+ });
2636
+ state.prerendering.dependencies.set(data_pathname, {
2637
+ response: text(body),
2638
+ body
2639
+ });
2640
+ }
2641
+ return redirect_response(err.status, err.location);
2642
+ }
2643
+ const status = get_status(err);
2644
+ const error = await handle_error_and_jsonify(event, event_state, options, err);
2645
+ while (i--) if (page.errors[i]) {
2646
+ const index = page.errors[i];
2647
+ const node = await manifest._.nodes[index]();
2648
+ let j = i;
2649
+ while (!branch[j]) j -= 1;
2650
+ data_serializer.set_max_nodes(j + 1);
2651
+ const layouts = compact(branch.slice(0, j + 1));
2652
+ const nodes = new PageNodes(layouts.map((layout) => layout.node));
2653
+ const error_branch = layouts.concat({
2654
+ node,
2655
+ data: null,
2656
+ server_data: null
2657
+ });
2658
+ return await render_response({
2659
+ event,
2660
+ event_state,
2661
+ options,
2662
+ manifest,
2663
+ state,
2664
+ resolve_opts,
2665
+ page_config: {
2666
+ ssr: nodes.ssr(),
2667
+ csr: nodes.csr()
2668
+ },
2669
+ status,
2670
+ error,
2671
+ error_components: await load_error_components(options, ssr, error_branch, page, manifest),
2672
+ branch: error_branch,
2673
+ fetched,
2674
+ data_serializer
2675
+ });
2676
+ }
2677
+ return static_error_page(options, status, error.message);
2678
+ }
2679
+ else branch.push(null);
2680
+ }
2681
+ if (state.prerendering && data_serializer_json) {
2682
+ let { data, chunks } = data_serializer_json.get_data();
2683
+ if (chunks) for await (const chunk of chunks) data += chunk;
2684
+ state.prerendering.dependencies.set(data_pathname, {
2685
+ response: text(data),
2686
+ body: data
2687
+ });
2688
+ }
2689
+ return await render_response({
2690
+ event,
2691
+ event_state,
2692
+ options,
2693
+ manifest,
2694
+ state,
2695
+ resolve_opts,
2696
+ page_config: {
2697
+ csr,
2698
+ ssr
2699
+ },
2700
+ status,
2701
+ error: null,
2702
+ branch: compact(branch),
2703
+ action_result,
2704
+ fetched,
2705
+ data_serializer: !ssr ? server_data_serializer(event, event_state, options) : data_serializer,
2706
+ error_components: await load_error_components(options, ssr, branch, page, manifest)
2707
+ });
2708
+ } catch (e) {
2709
+ if (e instanceof Redirect) return redirect_response(e.status, e.location);
2710
+ return await respond_with_error({
2711
+ event,
2712
+ event_state,
2713
+ options,
2714
+ manifest,
2715
+ state,
2716
+ status: e instanceof HttpError ? e.status : 500,
2717
+ error: e,
2718
+ resolve_opts
2719
+ });
2720
+ }
2721
+ }
2722
+ /**
2723
+ *
2724
+ * @param {SSROptions} options
2725
+ * @param {boolean} ssr
2726
+ * @param {Array<import('./types.js').Loaded | null>} branch
2727
+ * @param {PageNodeIndexes} page
2728
+ * @param {SSRManifest} manifest
2729
+ */
2730
+ async function load_error_components(options, ssr, branch, page, manifest) {
2731
+ /** @type {Array<SSRComponent | undefined> | undefined} */
2732
+ let error_components;
2733
+ if (options.server_error_boundaries && ssr) {
2734
+ let last_idx = -1;
2735
+ error_components = await Promise.all(branch.map((b, i) => {
2736
+ if (i === 0) return void 0;
2737
+ if (!b) return null;
2738
+ i--;
2739
+ while (i > last_idx + 1 && page.errors[i] === void 0) i -= 1;
2740
+ last_idx = i;
2741
+ const idx = page.errors[i];
2742
+ if (idx == null) return void 0;
2743
+ return manifest._.nodes[idx]?.().then((e) => e.component?.()).catch(() => void 0);
2744
+ }).filter((e) => e !== null));
2745
+ }
2746
+ return error_components;
2747
+ }
2748
+ //#endregion
2749
+ //#region node_modules/@sveltejs/kit/src/runtime/server/data/index.js
2750
+ /**
2751
+ * @param {import('@sveltejs/kit').RequestEvent} event
2752
+ * @param {import('types').RequestState} event_state
2753
+ * @param {import('types').SSRRoute} route
2754
+ * @param {import('types').SSROptions} options
2755
+ * @param {import('@sveltejs/kit').SSRManifest} manifest
2756
+ * @param {import('types').SSRState} state
2757
+ * @param {boolean[] | undefined} invalidated_data_nodes
2758
+ * @param {import('types').TrailingSlash} trailing_slash
2759
+ * @returns {Promise<Response>}
2760
+ */
2761
+ async function render_data(event, event_state, route, options, manifest, state, invalidated_data_nodes, trailing_slash) {
2762
+ if (!route.page) return new Response(void 0, { status: 404 });
2763
+ try {
2764
+ const node_ids = [...route.page.layouts, route.page.leaf];
2765
+ const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
2766
+ let aborted = false;
2767
+ const url = new URL(event.url);
2768
+ url.pathname = normalize_path(url.pathname, trailing_slash);
2769
+ const new_event = {
2770
+ ...event,
2771
+ url
2772
+ };
2773
+ const functions = node_ids.map((n, i) => {
2774
+ return once(async () => {
2775
+ try {
2776
+ if (aborted) return { type: "skip" };
2777
+ const node = n == void 0 ? n : await manifest._.nodes[n]();
2778
+ return load_server_data({
2779
+ event: new_event,
2780
+ event_state,
2781
+ state,
2782
+ node,
2783
+ parent: async () => {
2784
+ /** @type {Record<string, any>} */
2785
+ const data = {};
2786
+ for (let j = 0; j < i; j += 1) {
2787
+ const parent = await functions[j]();
2788
+ if (parent) Object.assign(data, parent.data);
2789
+ }
2790
+ return data;
2791
+ }
2792
+ });
2793
+ } catch (e) {
2794
+ aborted = true;
2795
+ throw e;
2796
+ }
2797
+ });
2798
+ });
2799
+ const promises = functions.map(async (fn, i) => {
2800
+ if (!invalidated[i]) return { type: "skip" };
2801
+ return fn();
2802
+ });
2803
+ let length = promises.length;
2804
+ const nodes = await Promise.all(promises.map((p, i) => p.catch(async (error) => {
2805
+ if (error instanceof Redirect) throw error;
2806
+ length = Math.min(length, i + 1);
2807
+ return {
2808
+ type: "error",
2809
+ error: await handle_error_and_jsonify(event, event_state, options, error),
2810
+ status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : void 0
2811
+ };
2812
+ })));
2813
+ const data_serializer = server_data_serializer_json(event, event_state, options);
2814
+ for (let i = 0; i < nodes.length; i++) data_serializer.add_node(i, nodes[i]);
2815
+ const { data, chunks } = data_serializer.get_data();
2816
+ if (!chunks) return json_response(data);
2817
+ return new Response(new ReadableStream({
2818
+ async start(controller) {
2819
+ controller.enqueue(text_encoder.encode(data));
2820
+ for await (const chunk of chunks) controller.enqueue(text_encoder.encode(chunk));
2821
+ controller.close();
2822
+ },
2823
+ type: "bytes"
2824
+ }), { headers: {
2825
+ "content-type": "text/sveltekit-data",
2826
+ "cache-control": "private, no-store"
2827
+ } });
2828
+ } catch (e) {
2829
+ const error = normalize_error(e);
2830
+ if (error instanceof Redirect) return redirect_json_response(error);
2831
+ else return json_response(await handle_error_and_jsonify(event, event_state, options, error), 500);
2832
+ }
2833
+ }
2834
+ /**
2835
+ * @param {Record<string, any> | string} json
2836
+ * @param {number} [status]
2837
+ */
2838
+ function json_response(json, status = 200) {
2839
+ return text(typeof json === "string" ? json : JSON.stringify(json), {
2840
+ status,
2841
+ headers: {
2842
+ "content-type": "application/json",
2843
+ "cache-control": "private, no-store"
2844
+ }
2845
+ });
2846
+ }
2847
+ /**
2848
+ * @param {Redirect} redirect
2849
+ */
2850
+ function redirect_json_response(redirect) {
2851
+ return json_response({
2852
+ type: "redirect",
2853
+ location: redirect.location
2854
+ });
2855
+ }
2856
+ //#endregion
2857
+ //#region node_modules/@sveltejs/kit/src/runtime/server/cookie.js
2858
+ var INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
2859
+ /** @param {import('./page/types.js').Cookie['options']} options */
2860
+ function validate_options(options) {
2861
+ if (options?.path === void 0) throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
2862
+ }
2863
+ /**
2864
+ * Generates a unique key for a cookie based on its domain, path, and name in
2865
+ * the format: `<domain>/<path>?<name>`.
2866
+ * If domain is undefined, it will be omitted.
2867
+ * For example: `/?name`, `example.com/foo?name`.
2868
+ *
2869
+ * @param {string | undefined} domain
2870
+ * @param {string} path
2871
+ * @param {string} name
2872
+ * @returns {string}
2873
+ */
2874
+ function generate_cookie_key(domain, path, name) {
2875
+ return `${domain || ""}${path}?${encodeURIComponent(name)}`;
2876
+ }
2877
+ /**
2878
+ * @param {Request} request
2879
+ * @param {URL} url
2880
+ */
2881
+ function get_cookies(request, url) {
2882
+ const header = request.headers.get("cookie") ?? "";
2883
+ const initial_cookies = cookieExports.parse(header, { decode: (value) => value });
2884
+ /** @type {string | undefined} */
2885
+ let normalized_url;
2886
+ /** @type {Map<string, import('./page/types.js').Cookie>} */
2887
+ const new_cookies = /* @__PURE__ */ new Map();
2888
+ /** @type {import('cookie').CookieSerializeOptions} */
2889
+ const defaults = {
2890
+ httpOnly: true,
2891
+ sameSite: "lax",
2892
+ secure: url.hostname === "localhost" && url.protocol === "http:" ? false : true
2893
+ };
2894
+ /** @type {import('@sveltejs/kit').Cookies} */
2895
+ const cookies = {
2896
+ /**
2897
+ * @param {string} name
2898
+ * @param {import('cookie').CookieParseOptions} [opts]
2899
+ */
2900
+ get(name, opts) {
2901
+ const best_match = Array.from(new_cookies.values()).filter((c) => {
2902
+ return c.name === name && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path);
2903
+ }).sort((a, b) => b.options.path.length - a.options.path.length)[0];
2904
+ if (best_match) return best_match.options.maxAge === 0 ? void 0 : best_match.value;
2905
+ return cookieExports.parse(header, { decode: opts?.decode })[name];
2906
+ },
2907
+ /**
2908
+ * @param {import('cookie').CookieParseOptions} [opts]
2909
+ */
2910
+ getAll(opts) {
2911
+ const cookies = cookieExports.parse(header, { decode: opts?.decode });
2912
+ const lookup = /* @__PURE__ */ new Map();
2913
+ for (const c of new_cookies.values()) if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
2914
+ const existing = lookup.get(c.name);
2915
+ if (!existing || c.options.path.length > existing.options.path.length) lookup.set(c.name, c);
2916
+ }
2917
+ for (const c of lookup.values()) cookies[c.name] = c.value;
2918
+ return Object.entries(cookies).map(([name, value]) => ({
2919
+ name,
2920
+ value
2921
+ }));
2922
+ },
2923
+ /**
2924
+ * @param {string} name
2925
+ * @param {string} value
2926
+ * @param {import('./page/types.js').Cookie['options']} options
2927
+ */
2928
+ set(name, value, options) {
2929
+ const illegal_characters = name.match(INVALID_COOKIE_CHARACTER_REGEX);
2930
+ if (illegal_characters) console.warn(`The cookie name "${name}" will be invalid in SvelteKit 3.0 as it contains ${illegal_characters.join(" and ")}. See RFC 2616 for more details https://datatracker.ietf.org/doc/html/rfc2616#section-2.2`);
2931
+ validate_options(options);
2932
+ set_internal(name, value, {
2933
+ ...defaults,
2934
+ ...options
2935
+ });
2936
+ },
2937
+ /**
2938
+ * @param {string} name
2939
+ * @param {import('./page/types.js').Cookie['options']} options
2940
+ */
2941
+ delete(name, options) {
2942
+ validate_options(options);
2943
+ cookies.set(name, "", {
2944
+ ...options,
2945
+ maxAge: 0
2946
+ });
2947
+ },
2948
+ /**
2949
+ * @param {string} name
2950
+ * @param {string} value
2951
+ * @param {import('./page/types.js').Cookie['options']} options
2952
+ */
2953
+ serialize(name, value, options) {
2954
+ validate_options(options);
2955
+ let path = options.path;
2956
+ if (!options.domain || options.domain === url.hostname) {
2957
+ if (!normalized_url) throw new Error("Cannot serialize cookies until after the route is determined");
2958
+ path = resolve(normalized_url, path);
2959
+ }
2960
+ return cookieExports.serialize(name, value, {
2961
+ ...defaults,
2962
+ ...options,
2963
+ path
2964
+ });
2965
+ }
2966
+ };
2967
+ /**
2968
+ * @param {URL} destination
2969
+ * @param {string | null} header
2970
+ */
2971
+ function get_cookie_header(destination, header) {
2972
+ /** @type {Record<string, string>} */
2973
+ const combined_cookies = { ...initial_cookies };
2974
+ for (const cookie of new_cookies.values()) {
2975
+ if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
2976
+ if (!path_matches(destination.pathname, cookie.options.path)) continue;
2977
+ const encoder = cookie.options.encode || encodeURIComponent;
2978
+ combined_cookies[cookie.name] = encoder(cookie.value);
2979
+ }
2980
+ if (header) {
2981
+ const parsed = cookieExports.parse(header, { decode: (value) => value });
2982
+ for (const name in parsed) combined_cookies[name] = parsed[name];
2983
+ }
2984
+ return Object.entries(combined_cookies).map(([name, value]) => `${name}=${value}`).join("; ");
2985
+ }
2986
+ /** @type {Array<() => void>} */
2987
+ const internal_queue = [];
2988
+ /**
2989
+ * @param {string} name
2990
+ * @param {string} value
2991
+ * @param {import('./page/types.js').Cookie['options']} options
2992
+ */
2993
+ function set_internal(name, value, options) {
2994
+ if (!normalized_url) {
2995
+ internal_queue.push(() => set_internal(name, value, options));
2996
+ return;
2997
+ }
2998
+ let path = options.path;
2999
+ if (!options.domain || options.domain === url.hostname) path = resolve(normalized_url, path);
3000
+ const cookie_key = generate_cookie_key(options.domain, path, name);
3001
+ const cookie = {
3002
+ name,
3003
+ value,
3004
+ options: {
3005
+ ...options,
3006
+ path
3007
+ }
3008
+ };
3009
+ new_cookies.set(cookie_key, cookie);
3010
+ }
3011
+ /**
3012
+ * @param {import('types').TrailingSlash} trailing_slash
3013
+ */
3014
+ function set_trailing_slash(trailing_slash) {
3015
+ normalized_url = normalize_path(url.pathname, trailing_slash);
3016
+ internal_queue.forEach((fn) => fn());
3017
+ }
3018
+ return {
3019
+ cookies,
3020
+ new_cookies,
3021
+ get_cookie_header,
3022
+ set_internal,
3023
+ set_trailing_slash
3024
+ };
3025
+ }
3026
+ /**
3027
+ * @param {string} hostname
3028
+ * @param {string} [constraint]
3029
+ */
3030
+ function domain_matches(hostname, constraint) {
3031
+ if (!constraint) return true;
3032
+ const normalized = constraint[0] === "." ? constraint.slice(1) : constraint;
3033
+ if (hostname === normalized) return true;
3034
+ return hostname.endsWith("." + normalized);
3035
+ }
3036
+ /**
3037
+ * @param {string} path
3038
+ * @param {string} [constraint]
3039
+ */
3040
+ function path_matches(path, constraint) {
3041
+ if (!constraint) return true;
3042
+ const normalized = constraint.endsWith("/") ? constraint.slice(0, -1) : constraint;
3043
+ if (path === normalized) return true;
3044
+ return path.startsWith(normalized + "/");
3045
+ }
3046
+ /**
3047
+ * @param {Headers} headers
3048
+ * @param {MapIterator<import('./page/types.js').Cookie>} cookies
3049
+ */
3050
+ function add_cookies_to_headers(headers, cookies) {
3051
+ for (const new_cookie of cookies) {
3052
+ const { name, value, options } = new_cookie;
3053
+ headers.append("set-cookie", cookieExports.serialize(name, value, options));
3054
+ if (options.path.endsWith(".html")) {
3055
+ const path = add_data_suffix(options.path);
3056
+ headers.append("set-cookie", cookieExports.serialize(name, value, {
3057
+ ...options,
3058
+ path
3059
+ }));
3060
+ }
3061
+ }
3062
+ }
3063
+ //#endregion
3064
+ //#region node_modules/@sveltejs/kit/src/runtime/server/fetch.js
3065
+ /**
3066
+ * @param {{
3067
+ * event: import('@sveltejs/kit').RequestEvent;
3068
+ * options: import('types').SSROptions;
3069
+ * manifest: import('@sveltejs/kit').SSRManifest;
3070
+ * state: import('types').SSRState;
3071
+ * get_cookie_header: (url: URL, header: string | null) => string;
3072
+ * set_internal: (name: string, value: string, opts: import('./page/types.js').Cookie['options']) => void;
3073
+ * }} opts
3074
+ * @returns {typeof fetch}
3075
+ */
3076
+ function create_fetch({ event, options, manifest, state, get_cookie_header, set_internal }) {
3077
+ /**
3078
+ * @type {typeof fetch}
3079
+ */
3080
+ const server_fetch = async (info, init) => {
3081
+ const original_request = normalize_fetch_input(info, init, event.url);
3082
+ let mode = (info instanceof Request ? info.mode : init?.mode) ?? "cors";
3083
+ let credentials = (info instanceof Request ? info.credentials : init?.credentials) ?? "same-origin";
3084
+ return options.hooks.handleFetch({
3085
+ event,
3086
+ request: original_request,
3087
+ fetch: async (info, init) => {
3088
+ const request = normalize_fetch_input(info, init, event.url);
3089
+ const url = new URL(request.url);
3090
+ if (!request.headers.has("origin")) request.headers.set("origin", event.url.origin);
3091
+ if (info !== original_request) {
3092
+ mode = (info instanceof Request ? info.mode : init?.mode) ?? "cors";
3093
+ credentials = (info instanceof Request ? info.credentials : init?.credentials) ?? "same-origin";
3094
+ }
3095
+ if ((request.method === "GET" || request.method === "HEAD") && (mode === "no-cors" && url.origin !== event.url.origin || url.origin === event.url.origin)) request.headers.delete("origin");
3096
+ const decoded = decodeURIComponent(url.pathname);
3097
+ if (url.origin !== event.url.origin || base && decoded !== base && !decoded.startsWith(`${base}/`)) {
3098
+ if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
3099
+ const cookie = get_cookie_header(url, request.headers.get("cookie"));
3100
+ if (cookie) request.headers.set("cookie", cookie);
3101
+ }
3102
+ return fetch(request);
3103
+ }
3104
+ const prefix = assets || base;
3105
+ const filename = (decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded).slice(1);
3106
+ const filename_html = `${filename}/index.html`;
3107
+ const is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;
3108
+ const is_asset_html = manifest.assets.has(filename_html) || filename_html in manifest._.server_assets;
3109
+ if (is_asset || is_asset_html) {
3110
+ const file = is_asset ? filename : filename_html;
3111
+ if (state.read) {
3112
+ const type = is_asset ? manifest.mimeTypes[filename.slice(filename.lastIndexOf("."))] : "text/html";
3113
+ return new Response(state.read(file), { headers: type ? { "content-type": type } : {} });
3114
+ } else if (read_implementation && file in manifest._.server_assets) {
3115
+ const length = manifest._.server_assets[file];
3116
+ const type = manifest.mimeTypes[file.slice(file.lastIndexOf("."))];
3117
+ return new Response(read_implementation(file), { headers: {
3118
+ "Content-Length": "" + length,
3119
+ "Content-Type": type
3120
+ } });
3121
+ }
3122
+ return await fetch(request);
3123
+ }
3124
+ if (has_prerendered_path(manifest, base + decoded)) return await fetch(request);
3125
+ if (credentials !== "omit") {
3126
+ const cookie = get_cookie_header(url, request.headers.get("cookie"));
3127
+ if (cookie) request.headers.set("cookie", cookie);
3128
+ const authorization = event.request.headers.get("authorization");
3129
+ if (authorization && !request.headers.has("authorization")) request.headers.set("authorization", authorization);
3130
+ }
3131
+ if (!request.headers.has("accept")) request.headers.set("accept", "*/*");
3132
+ if (!request.headers.has("accept-language")) request.headers.set("accept-language", event.request.headers.get("accept-language"));
3133
+ const response = await internal_fetch(request, options, manifest, state);
3134
+ for (const str of get_set_cookies(response.headers)) {
3135
+ const { name, value, ...options } = parseString(str, { decodeValues: false });
3136
+ set_internal(name, value, {
3137
+ path: options.path ?? (url.pathname.split("/").slice(0, -1).join("/") || "/"),
3138
+ encode: (value) => value,
3139
+ ...options
3140
+ });
3141
+ }
3142
+ return response;
3143
+ }
3144
+ });
3145
+ };
3146
+ return (input, init) => {
3147
+ const response = server_fetch(input, init);
3148
+ response.catch(noop);
3149
+ return response;
3150
+ };
3151
+ }
3152
+ /**
3153
+ * @param {RequestInfo | URL} info
3154
+ * @param {RequestInit | undefined} init
3155
+ * @param {URL} url
3156
+ */
3157
+ function normalize_fetch_input(info, init, url) {
3158
+ if (info instanceof Request) return info;
3159
+ return new Request(typeof info === "string" ? new URL(info, url) : info, init);
3160
+ }
3161
+ /**
3162
+ * @param {Request} request
3163
+ * @param {import('types').SSROptions} options
3164
+ * @param {import('@sveltejs/kit').SSRManifest} manifest
3165
+ * @param {import('types').SSRState} state
3166
+ * @returns {Promise<Response>}
3167
+ */
3168
+ async function internal_fetch(request, options, manifest, state) {
3169
+ if (request.signal) {
3170
+ if (request.signal.aborted) throw new DOMException("The operation was aborted.", "AbortError");
3171
+ let remove_abort_listener = noop;
3172
+ /** @type {Promise<never>} */
3173
+ const abort_promise = new Promise((_, reject) => {
3174
+ const on_abort = () => {
3175
+ reject(new DOMException("The operation was aborted.", "AbortError"));
3176
+ };
3177
+ request.signal.addEventListener("abort", on_abort, { once: true });
3178
+ remove_abort_listener = () => request.signal.removeEventListener("abort", on_abort);
3179
+ });
3180
+ const result = await Promise.race([respond(request, options, manifest, {
3181
+ ...state,
3182
+ depth: state.depth + 1
3183
+ }), abort_promise]);
3184
+ remove_abort_listener();
3185
+ return result;
3186
+ } else return await respond(request, options, manifest, {
3187
+ ...state,
3188
+ depth: state.depth + 1
3189
+ });
3190
+ }
3191
+ //#endregion
3192
+ //#region node_modules/@sveltejs/kit/src/runtime/server/env_module.js
3193
+ /** @type {string} */
3194
+ var payload;
3195
+ /** @type {string} */
3196
+ var etag;
3197
+ /** @type {Headers} */
3198
+ var headers;
3199
+ /**
3200
+ * @param {Request} request
3201
+ * @returns {Response}
3202
+ */
3203
+ function get_public_env(request) {
3204
+ const script = request.url.endsWith(".script.js");
3205
+ const env = public_env;
3206
+ payload ??= uneval(env);
3207
+ etag ??= `W/${Date.now()}`;
3208
+ headers ??= new Headers({
3209
+ "content-type": "application/javascript; charset=utf-8",
3210
+ etag
3211
+ });
3212
+ if (request.headers.get("if-none-match") === etag) return new Response(void 0, {
3213
+ status: 304,
3214
+ headers
3215
+ });
3216
+ if (script) return new Response(`globalThis.__sveltekit_sw={env:${payload}}`, { headers });
3217
+ return new Response(`export const env=${payload}`, { headers });
3218
+ }
3219
+ //#endregion
3220
+ //#region node_modules/@sveltejs/kit/src/runtime/server/respond.js
3221
+ /** @import { RequestState, SSRNode } from 'types' */
3222
+ /** @type {import('types').RequiredResolveOptions['transformPageChunk']} */
3223
+ var default_transform = ({ html }) => html;
3224
+ /** @type {import('types').RequiredResolveOptions['filterSerializedResponseHeaders']} */
3225
+ var default_filter = () => false;
3226
+ /** @type {import('types').RequiredResolveOptions['preload']} */
3227
+ var default_preload = ({ type }) => type === "js" || type === "css";
3228
+ var page_methods = /* @__PURE__ */ new Set([
3229
+ "GET",
3230
+ "HEAD",
3231
+ "POST"
3232
+ ]);
3233
+ var allowed_page_methods = /* @__PURE__ */ new Set([
3234
+ "GET",
3235
+ "HEAD",
3236
+ "OPTIONS"
3237
+ ]);
3238
+ var respond = propagate_context(internal_respond);
3239
+ /**
3240
+ * @param {Request} request
3241
+ * @param {import('types').SSROptions} options
3242
+ * @param {import('@sveltejs/kit').SSRManifest} manifest
3243
+ * @param {import('types').SSRState} state
3244
+ * @returns {Promise<Response>}
3245
+ */
3246
+ async function internal_respond(request, options, manifest, state) {
3247
+ /** URL but stripped from the potential `/__data.json` suffix and its search param */
3248
+ const url = new URL(request.url);
3249
+ const is_route_resolution_request = has_resolution_suffix(url.pathname);
3250
+ const is_data_request = has_data_suffix(url.pathname);
3251
+ const remote_id = get_remote_id(url);
3252
+ {
3253
+ const request_origin = request.headers.get("origin");
3254
+ if (remote_id) {
3255
+ if (request.method !== "GET" && request_origin !== url.origin) return json({ message: "Cross-site remote requests are forbidden" }, { status: 403 });
3256
+ } else if (options.csrf_check_origin) {
3257
+ if (is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request_origin !== url.origin && (!request_origin || !options.csrf_trusted_origins.includes(request_origin))) {
3258
+ const message = `Cross-site ${request.method} form submissions are forbidden`;
3259
+ const opts = { status: 403 };
3260
+ if (request.headers.get("accept") === "application/json") return json({ message }, opts);
3261
+ return text(message, opts);
3262
+ }
3263
+ }
3264
+ }
3265
+ if (options.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") return text("Not found", { status: 404 });
3266
+ /** @type {boolean[] | undefined} */
3267
+ let invalidated_data_nodes;
3268
+ if (is_route_resolution_request)
3269
+ /**
3270
+ * If the request is for a route resolution, first modify the URL, then continue as normal
3271
+ * for path resolution, then return the route object as a JS file.
3272
+ */
3273
+ url.pathname = strip_resolution_suffix(url.pathname);
3274
+ else if (is_data_request) {
3275
+ url.pathname = strip_data_suffix(url.pathname) + (url.searchParams.get("x-sveltekit-trailing-slash") === "1" ? "/" : "") || "/";
3276
+ url.searchParams.delete(TRAILING_SLASH_PARAM);
3277
+ invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
3278
+ url.searchParams.delete(INVALIDATED_PARAM);
3279
+ } else if (remote_id) {
3280
+ url.pathname = request.headers.get("x-sveltekit-pathname") ?? base;
3281
+ url.search = request.headers.get("x-sveltekit-search") ?? "";
3282
+ }
3283
+ /** @type {Record<string, string>} */
3284
+ const headers = {};
3285
+ const { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(request, url);
3286
+ /** @type {RequestState} */
3287
+ const event_state = {
3288
+ prerendering: state.prerendering,
3289
+ transport: options.hooks.transport,
3290
+ handleValidationError: options.hooks.handleValidationError,
3291
+ tracing: { record_span },
3292
+ remote: {
3293
+ data: null,
3294
+ explicit: null,
3295
+ implicit: null,
3296
+ forms: null,
3297
+ requested: null,
3298
+ batches: null,
3299
+ live_iterators: null
3300
+ },
3301
+ is_in_remote_function: false,
3302
+ is_in_remote_form_or_command: false,
3303
+ is_in_remote_query: false,
3304
+ is_in_render: false,
3305
+ is_in_universal_load: false
3306
+ };
3307
+ /** @type {import('@sveltejs/kit').RequestEvent} */
3308
+ const event = {
3309
+ cookies,
3310
+ fetch: null,
3311
+ getClientAddress: state.getClientAddress || (() => {
3312
+ throw new Error(`@sveltejs/adapter-node does not specify getClientAddress. Please raise an issue`);
3313
+ }),
3314
+ locals: {},
3315
+ params: {},
3316
+ platform: state.platform,
3317
+ request,
3318
+ route: { id: null },
3319
+ setHeaders: (new_headers) => {
3320
+ for (const key in new_headers) {
3321
+ const lower = key.toLowerCase();
3322
+ const value = new_headers[key];
3323
+ if (lower === "set-cookie") throw new Error("Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies");
3324
+ else if (lower in headers) if (lower === "server-timing") headers[lower] += ", " + value;
3325
+ else throw new Error(`"${key}" header is already set`);
3326
+ else {
3327
+ headers[lower] = value;
3328
+ if (state.prerendering && lower === "cache-control") state.prerendering.cache = value;
3329
+ }
3330
+ }
3331
+ },
3332
+ url,
3333
+ isDataRequest: is_data_request,
3334
+ isSubRequest: state.depth > 0,
3335
+ isRemoteRequest: !!remote_id
3336
+ };
3337
+ event.fetch = create_fetch({
3338
+ event,
3339
+ options,
3340
+ manifest,
3341
+ state,
3342
+ get_cookie_header,
3343
+ set_internal
3344
+ });
3345
+ if (state.emulator?.platform) event.platform = await state.emulator.platform({
3346
+ config: {},
3347
+ prerender: !!state.prerendering?.fallback
3348
+ });
3349
+ /** @type {string | null} */
3350
+ let resolved_path = url.pathname;
3351
+ if (!remote_id) {
3352
+ const prerendering_reroute_state = state.prerendering?.inside_reroute;
3353
+ try {
3354
+ if (state.prerendering) state.prerendering.inside_reroute = true;
3355
+ resolved_path = await options.hooks.reroute({
3356
+ url: new URL(url),
3357
+ fetch: event.fetch
3358
+ }) ?? url.pathname;
3359
+ } catch {
3360
+ return text("Internal Server Error", { status: 500 });
3361
+ } finally {
3362
+ if (state.prerendering) state.prerendering.inside_reroute = prerendering_reroute_state;
3363
+ }
3364
+ }
3365
+ /** @type {import('types').RequiredResolveOptions} */
3366
+ let resolve_opts = {
3367
+ transformPageChunk: default_transform,
3368
+ filterSerializedResponseHeaders: default_filter,
3369
+ preload: default_preload
3370
+ };
3371
+ /** @type {import('types').TrailingSlash} */
3372
+ let trailing_slash = "never";
3373
+ /** @type {PageNodes | undefined} */
3374
+ let page_nodes;
3375
+ try {
3376
+ resolved_path = decode_pathname(resolved_path);
3377
+ } catch {
3378
+ resolved_path = null;
3379
+ return await handle();
3380
+ }
3381
+ if (resolved_path !== decode_pathname(url.pathname) && !state.prerendering?.fallback && has_prerendered_path(manifest, resolved_path)) {
3382
+ const url = new URL(request.url);
3383
+ url.pathname = is_data_request ? add_data_suffix(resolved_path) : is_route_resolution_request ? add_resolution_suffix(resolved_path) : resolved_path;
3384
+ try {
3385
+ const response = await fetch(url, request);
3386
+ const headers = new Headers(response.headers);
3387
+ if (headers.has("content-encoding")) {
3388
+ headers.delete("content-encoding");
3389
+ headers.delete("content-length");
3390
+ }
3391
+ return new Response(response.body, {
3392
+ headers,
3393
+ status: response.status,
3394
+ statusText: response.statusText
3395
+ });
3396
+ } catch (error) {
3397
+ return await handle_fatal_error(event, event_state, options, error);
3398
+ }
3399
+ }
3400
+ /** @type {import('types').SSRRoute | null} */
3401
+ let route = null;
3402
+ if (base && !state.prerendering?.fallback) {
3403
+ if (!resolved_path.startsWith(base)) return text("Not found", { status: 404 });
3404
+ resolved_path = resolved_path.slice(base.length) || "/";
3405
+ }
3406
+ if (is_route_resolution_request) return resolve_route(resolved_path, new URL(request.url), manifest);
3407
+ if (resolved_path === `/_app/env.js` || resolved_path === `/_app/env.script.js`) return get_public_env(request);
3408
+ if (!remote_id && resolved_path.startsWith(`/_app`)) {
3409
+ const headers = new Headers();
3410
+ headers.set("cache-control", "public, max-age=0, must-revalidate");
3411
+ return text("Not found", {
3412
+ status: 404,
3413
+ headers
3414
+ });
3415
+ }
3416
+ if (!state.prerendering?.fallback) {
3417
+ const matchers = await manifest._.matchers();
3418
+ const result = find_route(resolved_path, manifest._.routes, matchers);
3419
+ if (result) {
3420
+ route = result.route;
3421
+ event.route = { id: route.id };
3422
+ event.params = result.params;
3423
+ }
3424
+ }
3425
+ try {
3426
+ page_nodes = route?.page ? new PageNodes(await load_page_nodes(route.page, manifest)) : void 0;
3427
+ if (route && !remote_id) {
3428
+ if (url.pathname === base || url.pathname === base + "/") trailing_slash = "always";
3429
+ else if (page_nodes) trailing_slash = page_nodes.trailing_slash();
3430
+ else if (route.endpoint) trailing_slash = (await route.endpoint()).trailingSlash ?? "never";
3431
+ if (!is_data_request) {
3432
+ const normalized = normalize_path(url.pathname, trailing_slash);
3433
+ if (normalized !== url.pathname && !state.prerendering?.fallback) return new Response(void 0, {
3434
+ status: 308,
3435
+ headers: {
3436
+ "x-sveltekit-normalize": "1",
3437
+ location: (normalized.startsWith("//") ? url.origin + normalized : normalized) + (url.search === "?" ? "" : url.search)
3438
+ }
3439
+ });
3440
+ }
3441
+ if (state.before_handle || state.emulator?.platform) {
3442
+ let config = {};
3443
+ /** @type {import('types').PrerenderOption} */
3444
+ let prerender = false;
3445
+ if (route.endpoint) {
3446
+ const node = await route.endpoint();
3447
+ config = node.config ?? config;
3448
+ prerender = node.prerender ?? prerender;
3449
+ } else if (page_nodes) {
3450
+ config = page_nodes.get_config() ?? config;
3451
+ prerender = page_nodes.prerender();
3452
+ }
3453
+ if (state.emulator?.platform) event.platform = await state.emulator.platform({
3454
+ config,
3455
+ prerender
3456
+ });
3457
+ if (state.before_handle) return await state.before_handle(event, config, prerender, handle);
3458
+ }
3459
+ }
3460
+ return await handle();
3461
+ } catch (e) {
3462
+ if (e instanceof Redirect) try {
3463
+ 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);
3464
+ add_cookies_to_headers(response.headers, new_cookies.values());
3465
+ return response;
3466
+ } catch (err) {
3467
+ return await handle_fatal_error(event, event_state, options, err);
3468
+ }
3469
+ return await handle_fatal_error(event, event_state, options, e);
3470
+ }
3471
+ async function handle() {
3472
+ set_trailing_slash(trailing_slash);
3473
+ if (state.prerendering && !state.prerendering.fallback && !state.prerendering.inside_reroute) disable_search(url);
3474
+ const response = await record_span({
3475
+ name: "sveltekit.handle.root",
3476
+ attributes: {
3477
+ "http.route": event.route.id || "unknown",
3478
+ "http.method": event.request.method,
3479
+ "http.url": event.url.href,
3480
+ "sveltekit.is_sub_request": event.isSubRequest
3481
+ },
3482
+ fn: async (root_span) => {
3483
+ const traced_event = {
3484
+ ...event,
3485
+ tracing: {
3486
+ enabled: false,
3487
+ root: root_span,
3488
+ current: root_span
3489
+ }
3490
+ };
3491
+ return await with_request_store({
3492
+ event: traced_event,
3493
+ state: event_state
3494
+ }, () => options.hooks.handle({
3495
+ event: traced_event,
3496
+ resolve: (event, opts) => {
3497
+ return record_span({
3498
+ name: "sveltekit.resolve",
3499
+ attributes: { "http.route": event.route.id || "unknown" },
3500
+ fn: (resolve_span) => {
3501
+ return with_request_store(null, () => resolve(merge_tracing(event, resolve_span), page_nodes, opts).then((response) => {
3502
+ for (const key in headers) {
3503
+ const value = headers[key];
3504
+ response.headers.set(key, value);
3505
+ }
3506
+ add_cookies_to_headers(response.headers, new_cookies.values());
3507
+ if (state.prerendering && event.route.id !== null) response.headers.set("x-sveltekit-routeid", encodeURI(event.route.id));
3508
+ resolve_span.setAttributes({
3509
+ "http.response.status_code": response.status,
3510
+ "http.response.body.size": response.headers.get("content-length") || "unknown"
3511
+ });
3512
+ return response;
3513
+ }));
3514
+ }
3515
+ });
3516
+ }
3517
+ }));
3518
+ }
3519
+ });
3520
+ if (response.status === 200 && response.headers.has("etag")) {
3521
+ let if_none_match_value = request.headers.get("if-none-match");
3522
+ if (if_none_match_value?.startsWith("W/\"")) if_none_match_value = if_none_match_value.substring(2);
3523
+ const etag = response.headers.get("etag");
3524
+ if (if_none_match_value === etag) {
3525
+ const headers = new Headers({ etag });
3526
+ for (const key of [
3527
+ "cache-control",
3528
+ "content-location",
3529
+ "date",
3530
+ "expires",
3531
+ "vary"
3532
+ ]) {
3533
+ const value = response.headers.get(key);
3534
+ if (value) headers.set(key, value);
3535
+ }
3536
+ for (const cookie of get_set_cookies(response.headers)) headers.append("set-cookie", cookie);
3537
+ return new Response(void 0, {
3538
+ status: 304,
3539
+ headers
3540
+ });
3541
+ }
3542
+ }
3543
+ if (is_data_request && response.status >= 300 && response.status <= 308) {
3544
+ const location = response.headers.get("location");
3545
+ if (location) return redirect_json_response(new Redirect(response.status, location));
3546
+ }
3547
+ return response;
3548
+ }
3549
+ /**
3550
+ * @param {import('@sveltejs/kit').RequestEvent} event
3551
+ * @param {PageNodes | undefined} page_nodes
3552
+ * @param {import('@sveltejs/kit').ResolveOptions} [opts]
3553
+ */
3554
+ async function resolve(event, page_nodes, opts) {
3555
+ try {
3556
+ if (opts) resolve_opts = {
3557
+ transformPageChunk: opts.transformPageChunk || default_transform,
3558
+ filterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter,
3559
+ preload: opts.preload || default_preload
3560
+ };
3561
+ if (resolved_path === null) return await respond_with_error({
3562
+ event,
3563
+ event_state,
3564
+ options,
3565
+ manifest,
3566
+ state,
3567
+ status: 400,
3568
+ error: new SvelteKitError(400, "Malformed URI", `Failed to decode URI: ${event.url.pathname}`),
3569
+ resolve_opts
3570
+ });
3571
+ if (options.hash_routing || state.prerendering?.fallback) return await render_response({
3572
+ event,
3573
+ event_state,
3574
+ options,
3575
+ manifest,
3576
+ state,
3577
+ page_config: {
3578
+ ssr: false,
3579
+ csr: true
3580
+ },
3581
+ status: 200,
3582
+ error: null,
3583
+ branch: [{
3584
+ node: await manifest._.nodes[0](),
3585
+ data: null,
3586
+ server_data: null
3587
+ }],
3588
+ fetched: [],
3589
+ resolve_opts,
3590
+ data_serializer: server_data_serializer(event, event_state, options)
3591
+ });
3592
+ if (remote_id) return await handle_remote_call(event, event_state, options, manifest, remote_id);
3593
+ if (route) {
3594
+ const method = event.request.method;
3595
+ /** @type {Response} */
3596
+ let response;
3597
+ if (is_data_request) response = await render_data(event, event_state, route, options, manifest, state, invalidated_data_nodes, trailing_slash);
3598
+ else if (route.endpoint && (!route.page || !state.prerendering && is_endpoint_request(event))) response = await render_endpoint(event, event_state, await route.endpoint(), state);
3599
+ else if (route.page) if (!page_nodes) throw new Error("page_nodes not found. This should never happen");
3600
+ else if (page_methods.has(method)) response = await render_page(event, event_state, route.page, options, manifest, state, page_nodes, resolve_opts);
3601
+ else {
3602
+ const allowed_methods = new Set(allowed_page_methods);
3603
+ if ((await manifest._.nodes[route.page.leaf]())?.server?.actions) allowed_methods.add("POST");
3604
+ if (method === "OPTIONS") response = new Response(null, {
3605
+ status: 204,
3606
+ headers: { allow: Array.from(allowed_methods.values()).join(", ") }
3607
+ });
3608
+ else response = method_not_allowed([...allowed_methods].reduce((acc, curr) => {
3609
+ acc[curr] = true;
3610
+ return acc;
3611
+ }, {}), method);
3612
+ }
3613
+ else throw new Error("Route is neither page nor endpoint. This should never happen");
3614
+ if (request.method === "GET" && route.page && route.endpoint) {
3615
+ const vary = response.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
3616
+ if (!(vary?.includes("accept") || vary?.includes("*"))) {
3617
+ response = new Response(response.body, {
3618
+ status: response.status,
3619
+ statusText: response.statusText,
3620
+ headers: new Headers(response.headers)
3621
+ });
3622
+ response.headers.append("Vary", "Accept");
3623
+ }
3624
+ }
3625
+ return response;
3626
+ }
3627
+ if (state.error && event.isSubRequest) {
3628
+ const headers = new Headers(request.headers);
3629
+ headers.set("x-sveltekit-error", "true");
3630
+ return await fetch(request, { headers });
3631
+ }
3632
+ if (state.error) return text("Internal Server Error", { status: 500 });
3633
+ if (state.depth === 0) return await respond_with_error({
3634
+ event,
3635
+ event_state,
3636
+ options,
3637
+ manifest,
3638
+ state,
3639
+ status: 404,
3640
+ error: new SvelteKitError(404, "Not Found", `Not found: ${event.url.pathname}`),
3641
+ resolve_opts
3642
+ });
3643
+ if (state.prerendering) return text("not found", { status: 404 });
3644
+ const response = await fetch(request);
3645
+ return new Response(response.body, response);
3646
+ } catch (e) {
3647
+ return await handle_fatal_error(event, event_state, options, e);
3648
+ } finally {
3649
+ event.cookies.set = () => {
3650
+ throw new Error("Cannot use `cookies.set(...)` after the response has been generated");
3651
+ };
3652
+ event.setHeaders = () => {
3653
+ throw new Error("Cannot use `setHeaders(...)` after the response has been generated");
3654
+ };
3655
+ }
3656
+ }
3657
+ }
3658
+ /**
3659
+ * @param {import('types').PageNodeIndexes} page
3660
+ * @param {import('@sveltejs/kit').SSRManifest} manifest
3661
+ */
3662
+ function load_page_nodes(page, manifest) {
3663
+ return Promise.all([...page.layouts.map((n) => n == void 0 ? n : manifest._.nodes[n]()), manifest._.nodes[page.leaf]()]);
3664
+ }
3665
+ /**
3666
+ * It's likely that, in a distributed system, there are spans starting outside the SvelteKit server -- eg.
3667
+ * started on the frontend client, or in a service that calls the SvelteKit server. There are standardized
3668
+ * ways to represent this context in HTTP headers, so we can extract that context and run our tracing inside of it
3669
+ * so that when our traces are exported, they are associated with the correct parent context.
3670
+ * @param {typeof internal_respond} fn
3671
+ * @returns {typeof internal_respond}
3672
+ */
3673
+ function propagate_context(fn) {
3674
+ return async (req, ...rest) => {
3675
+ return fn(req, ...rest);
3676
+ };
3677
+ }
3678
+ //#endregion
3679
+ //#region node_modules/@sveltejs/kit/src/utils/env.js
3680
+ /**
3681
+ * @param {Record<string, string>} env
3682
+ * @param {string} allowed
3683
+ * @param {string} disallowed
3684
+ * @returns {Record<string, string>}
3685
+ */
3686
+ function filter_env(env, allowed, disallowed) {
3687
+ return Object.fromEntries(Object.entries(env).filter(([k]) => k.startsWith(allowed) && (disallowed === "" || !k.startsWith(disallowed))));
3688
+ }
3689
+ //#endregion
3690
+ //#region node_modules/@sveltejs/kit/src/runtime/server/index.js
3691
+ /** @import { PromiseWithResolvers } from '../../utils/promise.js' */
3692
+ /** @type {Promise<any>} */
3693
+ var init_promise;
3694
+ /** @type {Promise<void> | null} */
3695
+ var current = null;
3696
+ var Server = class {
3697
+ /** @type {import('types').SSROptions} */
3698
+ #options;
3699
+ /** @type {import('@sveltejs/kit').SSRManifest} */
3700
+ #manifest;
3701
+ /** @param {import('@sveltejs/kit').SSRManifest} manifest */
3702
+ constructor(manifest) {
3703
+ /** @type {import('types').SSROptions} */
3704
+ this.#options = options;
3705
+ this.#manifest = manifest;
3706
+ if (IN_WEBCONTAINER) {
3707
+ const respond = this.respond.bind(this);
3708
+ /** @type {typeof respond} */
3709
+ this.respond = async (...args) => {
3710
+ const { promise, resolve } = with_resolvers();
3711
+ const previous = current;
3712
+ current = promise;
3713
+ await previous;
3714
+ return respond(...args).finally(resolve);
3715
+ };
3716
+ }
3717
+ }
3718
+ /**
3719
+ * @param {import('@sveltejs/kit').ServerInitOptions} opts
3720
+ */
3721
+ async init({ env, read }) {
3722
+ const { env_public_prefix, env_private_prefix } = this.#options;
3723
+ set_private_env(filter_env(env, env_private_prefix, env_public_prefix));
3724
+ set_public_env(filter_env(env, env_public_prefix, env_private_prefix));
3725
+ if (read) {
3726
+ /** @param {string} file */
3727
+ const wrapped_read = (file) => {
3728
+ const result = read(file);
3729
+ if (result instanceof ReadableStream) return result;
3730
+ else return new ReadableStream({ async start(controller) {
3731
+ try {
3732
+ const stream = await Promise.resolve(result);
3733
+ if (!stream) {
3734
+ controller.close();
3735
+ return;
3736
+ }
3737
+ const reader = stream.getReader();
3738
+ while (true) {
3739
+ const { done, value } = await reader.read();
3740
+ if (done) break;
3741
+ controller.enqueue(value);
3742
+ }
3743
+ controller.close();
3744
+ } catch (error) {
3745
+ controller.error(error);
3746
+ }
3747
+ } });
3748
+ };
3749
+ set_read_implementation(wrapped_read);
3750
+ }
3751
+ await (init_promise ??= (async () => {
3752
+ try {
3753
+ const module = await get_hooks();
3754
+ this.#options.hooks = {
3755
+ handle: module.handle || (({ event, resolve }) => resolve(event)),
3756
+ handleError: module.handleError || (({ status, error, event }) => {
3757
+ const error_message = format_server_error(status, error, event);
3758
+ console.error(error_message);
3759
+ }),
3760
+ handleFetch: module.handleFetch || (({ request, fetch }) => fetch(request)),
3761
+ handleValidationError: module.handleValidationError || (({ issues }) => {
3762
+ console.error("Remote function schema validation failed:", issues);
3763
+ return { message: "Bad Request" };
3764
+ }),
3765
+ reroute: module.reroute || noop,
3766
+ transport: module.transport || {}
3767
+ };
3768
+ module.transport && Object.fromEntries(Object.entries(module.transport).map(([k, v]) => [k, v.decode]));
3769
+ if (module.init) await module.init();
3770
+ } catch (e) {
3771
+ throw e;
3772
+ }
3773
+ })());
3774
+ }
3775
+ /**
3776
+ * @param {Request} request
3777
+ * @param {import('types').RequestOptions} options
3778
+ */
3779
+ async respond(request, options) {
3780
+ return respond(request, this.#options, this.#manifest, {
3781
+ ...options,
3782
+ error: false,
3783
+ depth: 0
3784
+ });
3785
+ }
3786
+ };
3787
+
3788
+ export { Server as S };
3789
+ //# sourceMappingURL=index.js-DvPfiC00.js.map