plum-e2e 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/backend/_scaffold/utils/browser.ts +1 -0
  2. package/backend/package-lock.json +2 -2
  3. package/backend/package.json +1 -1
  4. package/bin/plum.js +4 -3
  5. package/frontend/.svelte-kit/adapter-node/.vite/manifest.json +190 -0
  6. package/frontend/.svelte-kit/adapter-node/_app/immutable/assets/Badge.DLLowvEA.css +17 -0
  7. package/frontend/.svelte-kit/adapter-node/_app/immutable/assets/Button.cBruH0aD.css +17 -0
  8. package/frontend/.svelte-kit/adapter-node/_app/immutable/assets/_layout.D7eM-6MV.css +17 -0
  9. package/frontend/.svelte-kit/adapter-node/_app/immutable/assets/_page.BVnUajEa.css +17 -0
  10. package/frontend/.svelte-kit/adapter-node/_app/immutable/assets/_page.CGnCsn5q.css +17 -0
  11. package/frontend/.svelte-kit/adapter-node/_app/immutable/assets/_page.DBhBrHFz.css +17 -0
  12. package/frontend/.svelte-kit/adapter-node/_app/immutable/assets/_page.DOqo0UR4.css +17 -0
  13. package/frontend/.svelte-kit/adapter-node/chunks/Badge.js +30 -0
  14. package/frontend/.svelte-kit/adapter-node/chunks/Button.js +32 -0
  15. package/frontend/.svelte-kit/adapter-node/chunks/attributes.js +34 -0
  16. package/frontend/.svelte-kit/adapter-node/chunks/client.js +59 -0
  17. package/frontend/.svelte-kit/adapter-node/chunks/equality.js +31 -0
  18. package/frontend/.svelte-kit/adapter-node/chunks/escaping.js +36 -0
  19. package/frontend/.svelte-kit/adapter-node/chunks/exports.js +247 -0
  20. package/frontend/.svelte-kit/adapter-node/chunks/index.js +1135 -0
  21. package/frontend/.svelte-kit/adapter-node/chunks/internal.js +695 -0
  22. package/frontend/.svelte-kit/adapter-node/chunks/reports.js +57 -0
  23. package/frontend/.svelte-kit/adapter-node/entries/fallbacks/error.svelte.js +44 -0
  24. package/frontend/.svelte-kit/adapter-node/entries/pages/_layout.svelte.js +181 -0
  25. package/frontend/.svelte-kit/adapter-node/entries/pages/_page.svelte.js +164 -0
  26. package/frontend/.svelte-kit/adapter-node/entries/pages/reports/_page.svelte.js +141 -0
  27. package/frontend/.svelte-kit/adapter-node/entries/pages/reports/_slug_/_page.svelte.js +42 -0
  28. package/frontend/.svelte-kit/adapter-node/entries/pages/scheduled-tests/_page.svelte.js +179 -0
  29. package/frontend/.svelte-kit/adapter-node/index.js +3144 -0
  30. package/frontend/.svelte-kit/adapter-node/internal.js +30 -0
  31. package/frontend/.svelte-kit/adapter-node/manifest-full.js +77 -0
  32. package/frontend/.svelte-kit/adapter-node/manifest.js +81 -0
  33. package/frontend/.svelte-kit/adapter-node/nodes/0.js +25 -0
  34. package/frontend/.svelte-kit/adapter-node/nodes/1.js +25 -0
  35. package/frontend/.svelte-kit/adapter-node/nodes/2.js +25 -0
  36. package/frontend/.svelte-kit/adapter-node/nodes/3.js +25 -0
  37. package/frontend/.svelte-kit/adapter-node/nodes/4.js +25 -0
  38. package/frontend/.svelte-kit/adapter-node/nodes/5.js +25 -0
  39. package/frontend/.svelte-kit/ambient.d.ts +240 -0
  40. package/frontend/.svelte-kit/generated/client/app.js +51 -0
  41. package/frontend/.svelte-kit/generated/client/matchers.js +18 -0
  42. package/frontend/.svelte-kit/generated/client/nodes/0.js +18 -0
  43. package/frontend/.svelte-kit/generated/client/nodes/1.js +18 -0
  44. package/frontend/.svelte-kit/generated/client/nodes/2.js +18 -0
  45. package/frontend/.svelte-kit/generated/client/nodes/3.js +18 -0
  46. package/frontend/.svelte-kit/generated/client/nodes/4.js +18 -0
  47. package/frontend/.svelte-kit/generated/client/nodes/5.js +18 -0
  48. package/frontend/.svelte-kit/generated/client-optimized/app.js +51 -0
  49. package/frontend/.svelte-kit/generated/client-optimized/matchers.js +18 -0
  50. package/frontend/.svelte-kit/generated/client-optimized/nodes/0.js +18 -0
  51. package/frontend/.svelte-kit/generated/client-optimized/nodes/1.js +18 -0
  52. package/frontend/.svelte-kit/generated/client-optimized/nodes/2.js +18 -0
  53. package/frontend/.svelte-kit/generated/client-optimized/nodes/3.js +18 -0
  54. package/frontend/.svelte-kit/generated/client-optimized/nodes/4.js +18 -0
  55. package/frontend/.svelte-kit/generated/client-optimized/nodes/5.js +18 -0
  56. package/frontend/.svelte-kit/generated/root.js +20 -0
  57. package/frontend/.svelte-kit/generated/root.svelte +83 -0
  58. package/frontend/.svelte-kit/generated/server/internal.js +65 -0
  59. package/frontend/.svelte-kit/non-ambient.d.ts +42 -0
  60. package/frontend/.svelte-kit/output/client/.vite/manifest.json +289 -0
  61. package/frontend/.svelte-kit/output/client/_app/immutable/assets/0.CnXRuPt4.css +17 -0
  62. package/frontend/.svelte-kit/output/client/_app/immutable/assets/2.CGnCsn5q.css +17 -0
  63. package/frontend/.svelte-kit/output/client/_app/immutable/assets/3.BVnUajEa.css +17 -0
  64. package/frontend/.svelte-kit/output/client/_app/immutable/assets/4.DBhBrHFz.css +17 -0
  65. package/frontend/.svelte-kit/output/client/_app/immutable/assets/5.D93VAB-w.css +17 -0
  66. package/frontend/.svelte-kit/output/client/_app/immutable/assets/Badge.DLLowvEA.css +17 -0
  67. package/frontend/.svelte-kit/output/client/_app/immutable/assets/Button.cBruH0aD.css +17 -0
  68. package/frontend/.svelte-kit/output/client/_app/immutable/assets/_layout.D7eM-6MV.css +17 -0
  69. package/frontend/.svelte-kit/output/client/_app/immutable/assets/_page.BVnUajEa.css +17 -0
  70. package/frontend/.svelte-kit/output/client/_app/immutable/assets/_page.CGnCsn5q.css +17 -0
  71. package/frontend/.svelte-kit/output/client/_app/immutable/assets/_page.DBhBrHFz.css +17 -0
  72. package/frontend/.svelte-kit/output/client/_app/immutable/assets/_page.DOqo0UR4.css +17 -0
  73. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/B0bn91RF.js +18 -0
  74. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/B1kE5jmt.js +23 -0
  75. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/BKz6FZdB.js +18 -0
  76. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/Be4iUAB0.js +18 -0
  77. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/BpaMqo9O.js +18 -0
  78. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/Bt3-Z7H1.js +18 -0
  79. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/CHV2KnPr.js +18 -0
  80. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/CJ8q7g9Y.js +18 -0
  81. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/Cit9MuSg.js +20 -0
  82. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/CwBTqcbj.js +18 -0
  83. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/DBk3zeq4.js +18 -0
  84. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/DFJLQFic.js +18 -0
  85. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/DTUE7kkY.js +18 -0
  86. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/IYPwzKs_.js +20 -0
  87. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/oc0we5Us.js +18 -0
  88. package/frontend/.svelte-kit/output/client/_app/immutable/chunks/rVEKg0Ak.js +18 -0
  89. package/frontend/.svelte-kit/output/client/_app/immutable/entry/app.C2MbX06K.js +19 -0
  90. package/frontend/.svelte-kit/output/client/_app/immutable/entry/start.GiBry-lw.js +18 -0
  91. package/frontend/.svelte-kit/output/client/_app/immutable/nodes/0.BsCYK-Tn.js +21 -0
  92. package/frontend/.svelte-kit/output/client/_app/immutable/nodes/1.N4gjrCnX.js +18 -0
  93. package/frontend/.svelte-kit/output/client/_app/immutable/nodes/2.D9yQNzK8.js +18 -0
  94. package/frontend/.svelte-kit/output/client/_app/immutable/nodes/3.CBC5WvNb.js +18 -0
  95. package/frontend/.svelte-kit/output/client/_app/immutable/nodes/4.BU6UZHSE.js +19 -0
  96. package/frontend/.svelte-kit/output/client/_app/immutable/nodes/5.Dzzfrntl.js +18 -0
  97. package/frontend/.svelte-kit/output/client/_app/version.json +1 -0
  98. package/frontend/.svelte-kit/output/client/favicon.png +0 -0
  99. package/frontend/.svelte-kit/output/server/.vite/manifest.json +190 -0
  100. package/frontend/.svelte-kit/output/server/_app/immutable/assets/Badge.DLLowvEA.css +17 -0
  101. package/frontend/.svelte-kit/output/server/_app/immutable/assets/Button.cBruH0aD.css +17 -0
  102. package/frontend/.svelte-kit/output/server/_app/immutable/assets/_layout.D7eM-6MV.css +17 -0
  103. package/frontend/.svelte-kit/output/server/_app/immutable/assets/_page.BVnUajEa.css +17 -0
  104. package/frontend/.svelte-kit/output/server/_app/immutable/assets/_page.CGnCsn5q.css +17 -0
  105. package/frontend/.svelte-kit/output/server/_app/immutable/assets/_page.DBhBrHFz.css +17 -0
  106. package/frontend/.svelte-kit/output/server/_app/immutable/assets/_page.DOqo0UR4.css +17 -0
  107. package/frontend/.svelte-kit/output/server/chunks/Badge.js +30 -0
  108. package/frontend/.svelte-kit/output/server/chunks/Button.js +32 -0
  109. package/frontend/.svelte-kit/output/server/chunks/attributes.js +34 -0
  110. package/frontend/.svelte-kit/output/server/chunks/client.js +59 -0
  111. package/frontend/.svelte-kit/output/server/chunks/equality.js +31 -0
  112. package/frontend/.svelte-kit/output/server/chunks/escaping.js +36 -0
  113. package/frontend/.svelte-kit/output/server/chunks/exports.js +247 -0
  114. package/frontend/.svelte-kit/output/server/chunks/index.js +1135 -0
  115. package/frontend/.svelte-kit/output/server/chunks/internal.js +695 -0
  116. package/frontend/.svelte-kit/output/server/chunks/reports.js +57 -0
  117. package/frontend/.svelte-kit/output/server/entries/fallbacks/error.svelte.js +44 -0
  118. package/frontend/.svelte-kit/output/server/entries/pages/_layout.svelte.js +181 -0
  119. package/frontend/.svelte-kit/output/server/entries/pages/_page.svelte.js +164 -0
  120. package/frontend/.svelte-kit/output/server/entries/pages/reports/_page.svelte.js +141 -0
  121. package/frontend/.svelte-kit/output/server/entries/pages/reports/_slug_/_page.svelte.js +42 -0
  122. package/frontend/.svelte-kit/output/server/entries/pages/scheduled-tests/_page.svelte.js +179 -0
  123. package/frontend/.svelte-kit/output/server/index.js +3144 -0
  124. package/frontend/.svelte-kit/output/server/internal.js +30 -0
  125. package/frontend/.svelte-kit/output/server/manifest-full.js +77 -0
  126. package/frontend/.svelte-kit/output/server/manifest.js +77 -0
  127. package/frontend/.svelte-kit/output/server/nodes/0.js +25 -0
  128. package/frontend/.svelte-kit/output/server/nodes/1.js +25 -0
  129. package/frontend/.svelte-kit/output/server/nodes/2.js +25 -0
  130. package/frontend/.svelte-kit/output/server/nodes/3.js +25 -0
  131. package/frontend/.svelte-kit/output/server/nodes/4.js +25 -0
  132. package/frontend/.svelte-kit/output/server/nodes/5.js +25 -0
  133. package/frontend/.svelte-kit/tsconfig.json +49 -0
  134. package/frontend/build/client/_app/immutable/assets/0.CnXRuPt4.css +17 -0
  135. package/frontend/build/client/_app/immutable/assets/0.CnXRuPt4.css.br +0 -0
  136. package/frontend/build/client/_app/immutable/assets/0.CnXRuPt4.css.gz +0 -0
  137. package/frontend/build/client/_app/immutable/assets/2.CGnCsn5q.css +17 -0
  138. package/frontend/build/client/_app/immutable/assets/2.CGnCsn5q.css.br +0 -0
  139. package/frontend/build/client/_app/immutable/assets/2.CGnCsn5q.css.gz +0 -0
  140. package/frontend/build/client/_app/immutable/assets/3.BVnUajEa.css +17 -0
  141. package/frontend/build/client/_app/immutable/assets/3.BVnUajEa.css.br +0 -0
  142. package/frontend/build/client/_app/immutable/assets/3.BVnUajEa.css.gz +0 -0
  143. package/frontend/build/client/_app/immutable/assets/4.DBhBrHFz.css +17 -0
  144. package/frontend/build/client/_app/immutable/assets/4.DBhBrHFz.css.br +0 -0
  145. package/frontend/build/client/_app/immutable/assets/4.DBhBrHFz.css.gz +0 -0
  146. package/frontend/build/client/_app/immutable/assets/5.D93VAB-w.css +17 -0
  147. package/frontend/build/client/_app/immutable/assets/5.D93VAB-w.css.br +0 -0
  148. package/frontend/build/client/_app/immutable/assets/5.D93VAB-w.css.gz +0 -0
  149. package/frontend/build/client/_app/immutable/assets/Badge.DLLowvEA.css +17 -0
  150. package/frontend/build/client/_app/immutable/assets/Badge.DLLowvEA.css.br +0 -0
  151. package/frontend/build/client/_app/immutable/assets/Badge.DLLowvEA.css.gz +0 -0
  152. package/frontend/build/client/_app/immutable/assets/Button.cBruH0aD.css +17 -0
  153. package/frontend/build/client/_app/immutable/assets/Button.cBruH0aD.css.br +0 -0
  154. package/frontend/build/client/_app/immutable/assets/Button.cBruH0aD.css.gz +0 -0
  155. package/frontend/build/client/_app/immutable/assets/_layout.D7eM-6MV.css +17 -0
  156. package/frontend/build/client/_app/immutable/assets/_layout.D7eM-6MV.css.br +0 -0
  157. package/frontend/build/client/_app/immutable/assets/_layout.D7eM-6MV.css.gz +0 -0
  158. package/frontend/build/client/_app/immutable/assets/_page.BVnUajEa.css +17 -0
  159. package/frontend/build/client/_app/immutable/assets/_page.BVnUajEa.css.br +0 -0
  160. package/frontend/build/client/_app/immutable/assets/_page.BVnUajEa.css.gz +0 -0
  161. package/frontend/build/client/_app/immutable/assets/_page.CGnCsn5q.css +17 -0
  162. package/frontend/build/client/_app/immutable/assets/_page.CGnCsn5q.css.br +0 -0
  163. package/frontend/build/client/_app/immutable/assets/_page.CGnCsn5q.css.gz +0 -0
  164. package/frontend/build/client/_app/immutable/assets/_page.DBhBrHFz.css +17 -0
  165. package/frontend/build/client/_app/immutable/assets/_page.DBhBrHFz.css.br +0 -0
  166. package/frontend/build/client/_app/immutable/assets/_page.DBhBrHFz.css.gz +0 -0
  167. package/frontend/build/client/_app/immutable/assets/_page.DOqo0UR4.css +17 -0
  168. package/frontend/build/client/_app/immutable/assets/_page.DOqo0UR4.css.br +0 -0
  169. package/frontend/build/client/_app/immutable/assets/_page.DOqo0UR4.css.gz +0 -0
  170. package/frontend/build/client/_app/immutable/chunks/B0bn91RF.js +18 -0
  171. package/frontend/build/client/_app/immutable/chunks/B0bn91RF.js.br +0 -0
  172. package/frontend/build/client/_app/immutable/chunks/B0bn91RF.js.gz +0 -0
  173. package/frontend/build/client/_app/immutable/chunks/B1kE5jmt.js +23 -0
  174. package/frontend/build/client/_app/immutable/chunks/B1kE5jmt.js.br +0 -0
  175. package/frontend/build/client/_app/immutable/chunks/B1kE5jmt.js.gz +0 -0
  176. package/frontend/build/client/_app/immutable/chunks/BKz6FZdB.js +18 -0
  177. package/frontend/build/client/_app/immutable/chunks/BKz6FZdB.js.br +0 -0
  178. package/frontend/build/client/_app/immutable/chunks/BKz6FZdB.js.gz +0 -0
  179. package/frontend/build/client/_app/immutable/chunks/Be4iUAB0.js +18 -0
  180. package/frontend/build/client/_app/immutable/chunks/Be4iUAB0.js.br +0 -0
  181. package/frontend/build/client/_app/immutable/chunks/Be4iUAB0.js.gz +0 -0
  182. package/frontend/build/client/_app/immutable/chunks/BpaMqo9O.js +18 -0
  183. package/frontend/build/client/_app/immutable/chunks/BpaMqo9O.js.br +0 -0
  184. package/frontend/build/client/_app/immutable/chunks/BpaMqo9O.js.gz +0 -0
  185. package/frontend/build/client/_app/immutable/chunks/Bt3-Z7H1.js +18 -0
  186. package/frontend/build/client/_app/immutable/chunks/Bt3-Z7H1.js.br +0 -0
  187. package/frontend/build/client/_app/immutable/chunks/Bt3-Z7H1.js.gz +0 -0
  188. package/frontend/build/client/_app/immutable/chunks/CHV2KnPr.js +18 -0
  189. package/frontend/build/client/_app/immutable/chunks/CHV2KnPr.js.br +18 -0
  190. package/frontend/build/client/_app/immutable/chunks/CHV2KnPr.js.gz +0 -0
  191. package/frontend/build/client/_app/immutable/chunks/CJ8q7g9Y.js +18 -0
  192. package/{resources/comments-format.text → frontend/build/client/_app/immutable/chunks/CJ8q7g9Y.js.br} +0 -0
  193. package/frontend/build/client/_app/immutable/chunks/CJ8q7g9Y.js.gz +0 -0
  194. package/frontend/build/client/_app/immutable/chunks/Cit9MuSg.js +20 -0
  195. package/frontend/build/client/_app/immutable/chunks/Cit9MuSg.js.br +0 -0
  196. package/frontend/build/client/_app/immutable/chunks/Cit9MuSg.js.gz +0 -0
  197. package/frontend/build/client/_app/immutable/chunks/CwBTqcbj.js +18 -0
  198. package/frontend/build/client/_app/immutable/chunks/CwBTqcbj.js.br +0 -0
  199. package/frontend/build/client/_app/immutable/chunks/CwBTqcbj.js.gz +0 -0
  200. package/frontend/build/client/_app/immutable/chunks/DBk3zeq4.js +18 -0
  201. package/frontend/build/client/_app/immutable/chunks/DBk3zeq4.js.br +0 -0
  202. package/frontend/build/client/_app/immutable/chunks/DBk3zeq4.js.gz +0 -0
  203. package/frontend/build/client/_app/immutable/chunks/DFJLQFic.js +18 -0
  204. package/frontend/build/client/_app/immutable/chunks/DFJLQFic.js.br +0 -0
  205. package/frontend/build/client/_app/immutable/chunks/DFJLQFic.js.gz +0 -0
  206. package/frontend/build/client/_app/immutable/chunks/DTUE7kkY.js +18 -0
  207. package/frontend/build/client/_app/immutable/chunks/DTUE7kkY.js.br +0 -0
  208. package/frontend/build/client/_app/immutable/chunks/DTUE7kkY.js.gz +0 -0
  209. package/frontend/build/client/_app/immutable/chunks/IYPwzKs_.js +20 -0
  210. package/frontend/build/client/_app/immutable/chunks/IYPwzKs_.js.br +0 -0
  211. package/frontend/build/client/_app/immutable/chunks/IYPwzKs_.js.gz +0 -0
  212. package/frontend/build/client/_app/immutable/chunks/oc0we5Us.js +18 -0
  213. package/frontend/build/client/_app/immutable/chunks/oc0we5Us.js.br +0 -0
  214. package/frontend/build/client/_app/immutable/chunks/oc0we5Us.js.gz +0 -0
  215. package/frontend/build/client/_app/immutable/chunks/rVEKg0Ak.js +18 -0
  216. package/frontend/build/client/_app/immutable/chunks/rVEKg0Ak.js.br +0 -0
  217. package/frontend/build/client/_app/immutable/chunks/rVEKg0Ak.js.gz +0 -0
  218. package/frontend/build/client/_app/immutable/entry/app.C2MbX06K.js +19 -0
  219. package/frontend/build/client/_app/immutable/entry/app.C2MbX06K.js.br +0 -0
  220. package/frontend/build/client/_app/immutable/entry/app.C2MbX06K.js.gz +0 -0
  221. package/frontend/build/client/_app/immutable/entry/start.GiBry-lw.js +18 -0
  222. package/frontend/build/client/_app/immutable/entry/start.GiBry-lw.js.br +18 -0
  223. package/frontend/build/client/_app/immutable/entry/start.GiBry-lw.js.gz +0 -0
  224. package/frontend/build/client/_app/immutable/nodes/0.BsCYK-Tn.js +21 -0
  225. package/frontend/build/client/_app/immutable/nodes/0.BsCYK-Tn.js.br +0 -0
  226. package/frontend/build/client/_app/immutable/nodes/0.BsCYK-Tn.js.gz +0 -0
  227. package/frontend/build/client/_app/immutable/nodes/1.N4gjrCnX.js +18 -0
  228. package/frontend/build/client/_app/immutable/nodes/1.N4gjrCnX.js.br +0 -0
  229. package/frontend/build/client/_app/immutable/nodes/1.N4gjrCnX.js.gz +0 -0
  230. package/frontend/build/client/_app/immutable/nodes/2.D9yQNzK8.js +18 -0
  231. package/frontend/build/client/_app/immutable/nodes/2.D9yQNzK8.js.br +0 -0
  232. package/frontend/build/client/_app/immutable/nodes/2.D9yQNzK8.js.gz +0 -0
  233. package/frontend/build/client/_app/immutable/nodes/3.CBC5WvNb.js +18 -0
  234. package/frontend/build/client/_app/immutable/nodes/3.CBC5WvNb.js.br +0 -0
  235. package/frontend/build/client/_app/immutable/nodes/3.CBC5WvNb.js.gz +0 -0
  236. package/frontend/build/client/_app/immutable/nodes/4.BU6UZHSE.js +19 -0
  237. package/frontend/build/client/_app/immutable/nodes/4.BU6UZHSE.js.br +0 -0
  238. package/frontend/build/client/_app/immutable/nodes/4.BU6UZHSE.js.gz +0 -0
  239. package/frontend/build/client/_app/immutable/nodes/5.Dzzfrntl.js +18 -0
  240. package/frontend/build/client/_app/immutable/nodes/5.Dzzfrntl.js.br +0 -0
  241. package/frontend/build/client/_app/immutable/nodes/5.Dzzfrntl.js.gz +0 -0
  242. package/frontend/build/client/_app/version.json +1 -0
  243. package/frontend/build/client/_app/version.json.br +0 -0
  244. package/frontend/build/client/_app/version.json.gz +0 -0
  245. package/frontend/build/client/favicon.png +0 -0
  246. package/frontend/build/env.js +111 -0
  247. package/frontend/build/handler.js +1511 -0
  248. package/frontend/build/index.js +362 -0
  249. package/frontend/build/server/chunks/0-BFfqmlsS.js +26 -0
  250. package/frontend/build/server/chunks/0-BFfqmlsS.js.map +17 -0
  251. package/frontend/build/server/chunks/1-hso3H4Ax.js +26 -0
  252. package/frontend/build/server/chunks/1-hso3H4Ax.js.map +17 -0
  253. package/frontend/build/server/chunks/2-BSZWXCWp.js +26 -0
  254. package/frontend/build/server/chunks/2-BSZWXCWp.js.map +17 -0
  255. package/frontend/build/server/chunks/3-BYumY9dv.js +26 -0
  256. package/frontend/build/server/chunks/3-BYumY9dv.js.map +17 -0
  257. package/frontend/build/server/chunks/4-2UUrCVtM.js +26 -0
  258. package/frontend/build/server/chunks/4-2UUrCVtM.js.map +17 -0
  259. package/frontend/build/server/chunks/5-C2_y_fwT.js +26 -0
  260. package/frontend/build/server/chunks/5-C2_y_fwT.js.map +17 -0
  261. package/frontend/build/server/chunks/Badge-CC4U7C0c.js +30 -0
  262. package/frontend/build/server/chunks/Badge-CC4U7C0c.js.map +17 -0
  263. package/frontend/build/server/chunks/Button-BLkPicwS.js +33 -0
  264. package/frontend/build/server/chunks/Button-BLkPicwS.js.map +17 -0
  265. package/frontend/build/server/chunks/_layout.svelte-Bfxcj9C6.js +183 -0
  266. package/frontend/build/server/chunks/_layout.svelte-Bfxcj9C6.js.map +17 -0
  267. package/frontend/build/server/chunks/_page.svelte-DEK6UvaI.js +45 -0
  268. package/frontend/build/server/chunks/_page.svelte-DEK6UvaI.js.map +17 -0
  269. package/frontend/build/server/chunks/_page.svelte-DScVdHOq.js +142 -0
  270. package/frontend/build/server/chunks/_page.svelte-DScVdHOq.js.map +17 -0
  271. package/frontend/build/server/chunks/_page.svelte-Ns7w2sZt.js +180 -0
  272. package/frontend/build/server/chunks/_page.svelte-Ns7w2sZt.js.map +17 -0
  273. package/frontend/build/server/chunks/_page.svelte-s6ZIOitT.js +165 -0
  274. package/frontend/build/server/chunks/_page.svelte-s6ZIOitT.js.map +17 -0
  275. package/frontend/build/server/chunks/attributes-BeaNKpgU.js +34 -0
  276. package/frontend/build/server/chunks/attributes-BeaNKpgU.js.map +17 -0
  277. package/frontend/build/server/chunks/client-C9IaEwNo.js +52 -0
  278. package/frontend/build/server/chunks/client-C9IaEwNo.js.map +17 -0
  279. package/frontend/build/server/chunks/error.svelte-HKBv5sQT.js +45 -0
  280. package/frontend/build/server/chunks/error.svelte-HKBv5sQT.js.map +17 -0
  281. package/frontend/build/server/chunks/escaping-CqgfEcN3.js +36 -0
  282. package/frontend/build/server/chunks/escaping-CqgfEcN3.js.map +17 -0
  283. package/frontend/build/server/chunks/exports-OxlCJ8yE.js +192 -0
  284. package/frontend/build/server/chunks/exports-OxlCJ8yE.js.map +17 -0
  285. package/frontend/build/server/chunks/index-CjHlq1kt.js +1076 -0
  286. package/frontend/build/server/chunks/index-CjHlq1kt.js.map +17 -0
  287. package/frontend/build/server/chunks/reports-D3ZeYSmi.js +56 -0
  288. package/frontend/build/server/chunks/reports-D3ZeYSmi.js.map +17 -0
  289. package/frontend/build/server/index.js +5015 -0
  290. package/frontend/build/server/index.js.map +17 -0
  291. package/frontend/build/server/manifest.js +84 -0
  292. package/frontend/build/server/manifest.js.map +17 -0
  293. package/frontend/build/shims.js +49 -0
  294. package/frontend/package-lock.json +2 -2
  295. package/frontend/package.json +1 -1
  296. package/package.json +1 -1
  297. package/.claude/settings.local.json +0 -29
  298. package/.husky/pre-commit +0 -2
  299. package/.prettierignore +0 -21
  300. package/.prettierrc +0 -15
  301. package/.vscode/settings.json +0 -10
  302. package/license-config.json +0 -37
@@ -0,0 +1,5015 @@
1
+ /*
2
+ * This file is part of Plum.
3
+ *
4
+ * Plum is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * Plum is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with Plum. If not, see https://www.gnu.org/licenses/.
16
+ */
17
+
18
+ import { r as render, L as LEGACY_PROPS, g as get, f as flush_sync, d as define_property, i as init_operations, a as get_first_child, H as HYDRATION_START, b as get_next_sibling, c as HYDRATION_ERROR, e as HYDRATION_END, h as hydration_failed, j as clear_text_content, k as increment_write_version, l as array_from, m as component_root, D as DIRTY, s as set_signal_status, C as CLEAN, U as UNOWNED, n as DERIVED, o as schedule_effect, p as set_active_reaction, q as set_active_effect, t as is_array, u as active_effect, v as active_reaction, w as untracking, x as is_runes, B as BLOCK_EFFECT, y as derived_sources, z as state_unsafe_mutation, A as BRANCH_EFFECT, R as ROOT_EFFECT, E as untracked_writes, F as set_untracked_writes, M as MAYBE_DIRTY, G as create_text, I as branch, J as push, K as setContext, N as pop, O as push$1, P as component_context, Q as pop$1, S as DEV } from './chunks/index-CjHlq1kt.js';
19
+ import { s as safe_equals, e as equals, d as decode_pathname, a as decode_params, n as normalize_path, b as disable_search, r as resolve, m as make_trackable, w as writable, c as readable } from './chunks/exports-OxlCJ8yE.js';
20
+
21
+ function hydration_mismatch(location) {
22
+ {
23
+ console.warn(`https://svelte.dev/e/hydration_mismatch`);
24
+ }
25
+ }
26
+ function source(v, stack) {
27
+ var signal = {
28
+ f: 0,
29
+ // TODO ideally we could skip this altogether, but it causes type errors
30
+ v,
31
+ reactions: null,
32
+ equals,
33
+ rv: 0,
34
+ wv: 0
35
+ };
36
+ return signal;
37
+ }
38
+ // @__NO_SIDE_EFFECTS__
39
+ function mutable_source(initial_value, immutable = false) {
40
+ const s = source(initial_value);
41
+ if (!immutable) {
42
+ s.equals = safe_equals;
43
+ }
44
+ return s;
45
+ }
46
+ function set(source2, value) {
47
+ if (active_reaction !== null && !untracking && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT)) !== 0 && // If the source was created locally within the current derived, then
48
+ // we allow the mutation.
49
+ (derived_sources === null || !derived_sources.includes(source2))) {
50
+ state_unsafe_mutation();
51
+ }
52
+ return internal_set(source2, value);
53
+ }
54
+ function internal_set(source2, value) {
55
+ if (!source2.equals(value)) {
56
+ source2.v;
57
+ source2.v = value;
58
+ source2.wv = increment_write_version();
59
+ mark_reactions(source2, DIRTY);
60
+ if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
61
+ if (untracked_writes === null) {
62
+ set_untracked_writes([source2]);
63
+ } else {
64
+ untracked_writes.push(source2);
65
+ }
66
+ }
67
+ }
68
+ return value;
69
+ }
70
+ function mark_reactions(signal, status) {
71
+ var reactions = signal.reactions;
72
+ if (reactions === null) return;
73
+ var length = reactions.length;
74
+ for (var i = 0; i < length; i++) {
75
+ var reaction = reactions[i];
76
+ var flags = reaction.f;
77
+ if ((flags & DIRTY) !== 0) continue;
78
+ set_signal_status(reaction, status);
79
+ if ((flags & (CLEAN | UNOWNED)) !== 0) {
80
+ if ((flags & DERIVED) !== 0) {
81
+ mark_reactions(
82
+ /** @type {Derived} */
83
+ reaction,
84
+ MAYBE_DIRTY
85
+ );
86
+ } else {
87
+ schedule_effect(
88
+ /** @type {Effect} */
89
+ reaction
90
+ );
91
+ }
92
+ }
93
+ }
94
+ }
95
+ let hydrating = false;
96
+ function set_hydrating(value) {
97
+ hydrating = value;
98
+ }
99
+ let hydrate_node;
100
+ function set_hydrate_node(node) {
101
+ if (node === null) {
102
+ hydration_mismatch();
103
+ throw HYDRATION_ERROR;
104
+ }
105
+ return hydrate_node = node;
106
+ }
107
+ function hydrate_next() {
108
+ return set_hydrate_node(
109
+ /** @type {TemplateNode} */
110
+ get_next_sibling(hydrate_node)
111
+ );
112
+ }
113
+ const all_registered_events = /* @__PURE__ */ new Set();
114
+ const root_event_handles = /* @__PURE__ */ new Set();
115
+ function handle_event_propagation(event) {
116
+ var handler_element = this;
117
+ var owner_document = (
118
+ /** @type {Node} */
119
+ handler_element.ownerDocument
120
+ );
121
+ var event_name = event.type;
122
+ var path = event.composedPath?.() || [];
123
+ var current_target = (
124
+ /** @type {null | Element} */
125
+ path[0] || event.target
126
+ );
127
+ var path_idx = 0;
128
+ var handled_at = event.__root;
129
+ if (handled_at) {
130
+ var at_idx = path.indexOf(handled_at);
131
+ if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
132
+ window)) {
133
+ event.__root = handler_element;
134
+ return;
135
+ }
136
+ var handler_idx = path.indexOf(handler_element);
137
+ if (handler_idx === -1) {
138
+ return;
139
+ }
140
+ if (at_idx <= handler_idx) {
141
+ path_idx = at_idx;
142
+ }
143
+ }
144
+ current_target = /** @type {Element} */
145
+ path[path_idx] || event.target;
146
+ if (current_target === handler_element) return;
147
+ define_property(event, "currentTarget", {
148
+ configurable: true,
149
+ get() {
150
+ return current_target || owner_document;
151
+ }
152
+ });
153
+ var previous_reaction = active_reaction;
154
+ var previous_effect = active_effect;
155
+ set_active_reaction(null);
156
+ set_active_effect(null);
157
+ try {
158
+ var throw_error;
159
+ var other_errors = [];
160
+ while (current_target !== null) {
161
+ var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */
162
+ current_target.host || null;
163
+ try {
164
+ var delegated = current_target["__" + event_name];
165
+ if (delegated !== void 0 && (!/** @type {any} */
166
+ current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
167
+ // -> the target could not have been disabled because it emits the event in the first place
168
+ event.target === current_target)) {
169
+ if (is_array(delegated)) {
170
+ var [fn, ...data] = delegated;
171
+ fn.apply(current_target, [event, ...data]);
172
+ } else {
173
+ delegated.call(current_target, event);
174
+ }
175
+ }
176
+ } catch (error) {
177
+ if (throw_error) {
178
+ other_errors.push(error);
179
+ } else {
180
+ throw_error = error;
181
+ }
182
+ }
183
+ if (event.cancelBubble || parent_element === handler_element || parent_element === null) {
184
+ break;
185
+ }
186
+ current_target = parent_element;
187
+ }
188
+ if (throw_error) {
189
+ for (let error of other_errors) {
190
+ queueMicrotask(() => {
191
+ throw error;
192
+ });
193
+ }
194
+ throw throw_error;
195
+ }
196
+ } finally {
197
+ event.__root = handler_element;
198
+ delete event.currentTarget;
199
+ set_active_reaction(previous_reaction);
200
+ set_active_effect(previous_effect);
201
+ }
202
+ }
203
+ function assign_nodes(start, end) {
204
+ var effect = (
205
+ /** @type {Effect} */
206
+ active_effect
207
+ );
208
+ if (effect.nodes_start === null) {
209
+ effect.nodes_start = start;
210
+ effect.nodes_end = end;
211
+ }
212
+ }
213
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
214
+ function is_passive_event(name) {
215
+ return PASSIVE_EVENTS.includes(name);
216
+ }
217
+ function mount(component, options2) {
218
+ return _mount(component, options2);
219
+ }
220
+ function hydrate(component, options2) {
221
+ init_operations();
222
+ options2.intro = options2.intro ?? false;
223
+ const target = options2.target;
224
+ const was_hydrating = hydrating;
225
+ const previous_hydrate_node = hydrate_node;
226
+ try {
227
+ var anchor = (
228
+ /** @type {TemplateNode} */
229
+ get_first_child(target)
230
+ );
231
+ while (anchor && (anchor.nodeType !== 8 || /** @type {Comment} */
232
+ anchor.data !== HYDRATION_START)) {
233
+ anchor = /** @type {TemplateNode} */
234
+ get_next_sibling(anchor);
235
+ }
236
+ if (!anchor) {
237
+ throw HYDRATION_ERROR;
238
+ }
239
+ set_hydrating(true);
240
+ set_hydrate_node(
241
+ /** @type {Comment} */
242
+ anchor
243
+ );
244
+ hydrate_next();
245
+ const instance = _mount(component, { ...options2, anchor });
246
+ if (hydrate_node === null || hydrate_node.nodeType !== 8 || /** @type {Comment} */
247
+ hydrate_node.data !== HYDRATION_END) {
248
+ hydration_mismatch();
249
+ throw HYDRATION_ERROR;
250
+ }
251
+ set_hydrating(false);
252
+ return (
253
+ /** @type {Exports} */
254
+ instance
255
+ );
256
+ } catch (error) {
257
+ if (error === HYDRATION_ERROR) {
258
+ if (options2.recover === false) {
259
+ hydration_failed();
260
+ }
261
+ init_operations();
262
+ clear_text_content(target);
263
+ set_hydrating(false);
264
+ return mount(component, options2);
265
+ }
266
+ throw error;
267
+ } finally {
268
+ set_hydrating(was_hydrating);
269
+ set_hydrate_node(previous_hydrate_node);
270
+ }
271
+ }
272
+ const document_listeners = /* @__PURE__ */ new Map();
273
+ function _mount(Component, { target, anchor, props = {}, events, context, intro = true }) {
274
+ init_operations();
275
+ var registered_events = /* @__PURE__ */ new Set();
276
+ var event_handle = (events2) => {
277
+ for (var i = 0; i < events2.length; i++) {
278
+ var event_name = events2[i];
279
+ if (registered_events.has(event_name)) continue;
280
+ registered_events.add(event_name);
281
+ var passive = is_passive_event(event_name);
282
+ target.addEventListener(event_name, handle_event_propagation, { passive });
283
+ var n = document_listeners.get(event_name);
284
+ if (n === void 0) {
285
+ document.addEventListener(event_name, handle_event_propagation, { passive });
286
+ document_listeners.set(event_name, 1);
287
+ } else {
288
+ document_listeners.set(event_name, n + 1);
289
+ }
290
+ }
291
+ };
292
+ event_handle(array_from(all_registered_events));
293
+ root_event_handles.add(event_handle);
294
+ var component = void 0;
295
+ var unmount2 = component_root(() => {
296
+ var anchor_node = anchor ?? target.appendChild(create_text());
297
+ branch(() => {
298
+ if (context) {
299
+ push$1({});
300
+ var ctx = (
301
+ /** @type {ComponentContext} */
302
+ component_context
303
+ );
304
+ ctx.c = context;
305
+ }
306
+ if (events) {
307
+ props.$$events = events;
308
+ }
309
+ if (hydrating) {
310
+ assign_nodes(
311
+ /** @type {TemplateNode} */
312
+ anchor_node,
313
+ null
314
+ );
315
+ }
316
+ component = Component(anchor_node, props) || {};
317
+ if (hydrating) {
318
+ active_effect.nodes_end = hydrate_node;
319
+ }
320
+ if (context) {
321
+ pop$1();
322
+ }
323
+ });
324
+ return () => {
325
+ for (var event_name of registered_events) {
326
+ target.removeEventListener(event_name, handle_event_propagation);
327
+ var n = (
328
+ /** @type {number} */
329
+ document_listeners.get(event_name)
330
+ );
331
+ if (--n === 0) {
332
+ document.removeEventListener(event_name, handle_event_propagation);
333
+ document_listeners.delete(event_name);
334
+ } else {
335
+ document_listeners.set(event_name, n);
336
+ }
337
+ }
338
+ root_event_handles.delete(event_handle);
339
+ if (anchor_node !== anchor) {
340
+ anchor_node.parentNode?.removeChild(anchor_node);
341
+ }
342
+ };
343
+ });
344
+ mounted_components.set(component, unmount2);
345
+ return component;
346
+ }
347
+ let mounted_components = /* @__PURE__ */ new WeakMap();
348
+ function unmount(component, options2) {
349
+ const fn = mounted_components.get(component);
350
+ if (fn) {
351
+ mounted_components.delete(component);
352
+ return fn(options2);
353
+ }
354
+ return Promise.resolve();
355
+ }
356
+ function asClassComponent$1(component) {
357
+ return class extends Svelte4Component {
358
+ /** @param {any} options */
359
+ constructor(options2) {
360
+ super({
361
+ component,
362
+ ...options2
363
+ });
364
+ }
365
+ };
366
+ }
367
+ class Svelte4Component {
368
+ /** @type {any} */
369
+ #events;
370
+ /** @type {Record<string, any>} */
371
+ #instance;
372
+ /**
373
+ * @param {ComponentConstructorOptions & {
374
+ * component: any;
375
+ * }} options
376
+ */
377
+ constructor(options2) {
378
+ var sources = /* @__PURE__ */ new Map();
379
+ var add_source = (key, value) => {
380
+ var s = /* @__PURE__ */ mutable_source(value);
381
+ sources.set(key, s);
382
+ return s;
383
+ };
384
+ const props = new Proxy(
385
+ { ...options2.props || {}, $$events: {} },
386
+ {
387
+ get(target, prop) {
388
+ return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
389
+ },
390
+ has(target, prop) {
391
+ if (prop === LEGACY_PROPS) return true;
392
+ get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
393
+ return Reflect.has(target, prop);
394
+ },
395
+ set(target, prop, value) {
396
+ set(sources.get(prop) ?? add_source(prop, value), value);
397
+ return Reflect.set(target, prop, value);
398
+ }
399
+ }
400
+ );
401
+ this.#instance = (options2.hydrate ? hydrate : mount)(options2.component, {
402
+ target: options2.target,
403
+ anchor: options2.anchor,
404
+ props,
405
+ context: options2.context,
406
+ intro: options2.intro ?? false,
407
+ recover: options2.recover
408
+ });
409
+ if (!options2?.props?.$$host || options2.sync === false) {
410
+ flush_sync();
411
+ }
412
+ this.#events = props.$$events;
413
+ for (const key of Object.keys(this.#instance)) {
414
+ if (key === "$set" || key === "$destroy" || key === "$on") continue;
415
+ define_property(this, key, {
416
+ get() {
417
+ return this.#instance[key];
418
+ },
419
+ /** @param {any} value */
420
+ set(value) {
421
+ this.#instance[key] = value;
422
+ },
423
+ enumerable: true
424
+ });
425
+ }
426
+ this.#instance.$set = /** @param {Record<string, any>} next */
427
+ (next) => {
428
+ Object.assign(props, next);
429
+ };
430
+ this.#instance.$destroy = () => {
431
+ unmount(this.#instance);
432
+ };
433
+ }
434
+ /** @param {Record<string, any>} props */
435
+ $set(props) {
436
+ this.#instance.$set(props);
437
+ }
438
+ /**
439
+ * @param {string} event
440
+ * @param {(...args: any[]) => any} callback
441
+ * @returns {any}
442
+ */
443
+ $on(event, callback) {
444
+ this.#events[event] = this.#events[event] || [];
445
+ const cb = (...args) => callback.call(this, ...args);
446
+ this.#events[event].push(cb);
447
+ return () => {
448
+ this.#events[event] = this.#events[event].filter(
449
+ /** @param {any} fn */
450
+ (fn) => fn !== cb
451
+ );
452
+ };
453
+ }
454
+ $destroy() {
455
+ this.#instance.$destroy();
456
+ }
457
+ }
458
+ function asClassComponent(component) {
459
+ const component_constructor = asClassComponent$1(component);
460
+ const _render = (props, { context } = {}) => {
461
+ const result = render(component, { props, context });
462
+ return {
463
+ css: { code: "", map: null },
464
+ head: result.head,
465
+ html: result.body
466
+ };
467
+ };
468
+ component_constructor.render = _render;
469
+ return component_constructor;
470
+ }
471
+ function Root($$payload, $$props) {
472
+ push();
473
+ let {
474
+ stores,
475
+ page,
476
+ constructors,
477
+ components = [],
478
+ form,
479
+ data_0 = null,
480
+ data_1 = null
481
+ } = $$props;
482
+ {
483
+ setContext("__svelte__", stores);
484
+ }
485
+ {
486
+ stores.page.set(page);
487
+ }
488
+ const Pyramid_1 = constructors[1];
489
+ if (constructors[1]) {
490
+ $$payload.out += "<!--[-->";
491
+ const Pyramid_0 = constructors[0];
492
+ $$payload.out += `<!---->`;
493
+ Pyramid_0($$payload, {
494
+ data: data_0,
495
+ form,
496
+ children: ($$payload2) => {
497
+ $$payload2.out += `<!---->`;
498
+ Pyramid_1($$payload2, { data: data_1, form });
499
+ $$payload2.out += `<!---->`;
500
+ },
501
+ $$slots: { default: true }
502
+ });
503
+ $$payload.out += `<!---->`;
504
+ } else {
505
+ $$payload.out += "<!--[!-->";
506
+ const Pyramid_0 = constructors[0];
507
+ $$payload.out += `<!---->`;
508
+ Pyramid_0($$payload, { data: data_0, form });
509
+ $$payload.out += `<!---->`;
510
+ }
511
+ $$payload.out += `<!--]--> `;
512
+ {
513
+ $$payload.out += "<!--[!-->";
514
+ }
515
+ $$payload.out += `<!--]-->`;
516
+ pop();
517
+ }
518
+ const root = asClassComponent(Root);
519
+ let base = "";
520
+ let assets = base;
521
+ const app_dir = "_app";
522
+ const initial = { base, assets };
523
+ function override(paths) {
524
+ base = paths.base;
525
+ assets = paths.assets;
526
+ }
527
+ function reset() {
528
+ base = initial.base;
529
+ assets = initial.assets;
530
+ }
531
+ let read_implementation = null;
532
+ function set_read_implementation(fn) {
533
+ read_implementation = fn;
534
+ }
535
+ let public_env = {};
536
+ let safe_public_env = {};
537
+ function set_public_env(environment) {
538
+ public_env = environment;
539
+ }
540
+ function set_safe_public_env(environment) {
541
+ safe_public_env = environment;
542
+ }
543
+ const options = {
544
+ app_template_contains_nonce: false,
545
+ csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false }, "reportOnly": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } },
546
+ csrf_check_origin: true,
547
+ embedded: false,
548
+ env_public_prefix: "PUBLIC_",
549
+ env_private_prefix: "",
550
+ hash_routing: false,
551
+ hooks: null,
552
+ // added lazily, via `get_hooks`
553
+ preload_strategy: "modulepreload",
554
+ root,
555
+ service_worker: false,
556
+ templates: {
557
+ app: ({ head, body, assets: assets2, nonce, env }) => '<!--\nThis file is part of Plum.\n\nPlum is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nPlum is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Plum. If not, see https://www.gnu.org/licenses/.\n-->\n<!doctype html>\n<html lang="en" data-theme="light">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" href="' + assets2 + `/favicon.png" />
558
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
559
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
560
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
561
+ <link
562
+ href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500&family=DM+Sans:wght@300;400;500&display=swap"
563
+ rel="stylesheet"
564
+ />
565
+ <!-- Prevent theme flash before Svelte hydrates -->
566
+ <script>
567
+ try {
568
+ const t = localStorage.getItem('plum-theme');
569
+ if (t) document.documentElement.setAttribute('data-theme', t);
570
+ } catch (e) {}
571
+ <\/script>
572
+ ` + head + '\n </head>\n <body data-sveltekit-preload-data="hover">\n <div style="display: contents">' + body + "</div>\n </body>\n</html>\n",
573
+ error: ({ status, message }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>' + message + `</title>
574
+
575
+ <style>
576
+ body {
577
+ --bg: white;
578
+ --fg: #222;
579
+ --divider: #ccc;
580
+ background: var(--bg);
581
+ color: var(--fg);
582
+ font-family:
583
+ system-ui,
584
+ -apple-system,
585
+ BlinkMacSystemFont,
586
+ 'Segoe UI',
587
+ Roboto,
588
+ Oxygen,
589
+ Ubuntu,
590
+ Cantarell,
591
+ 'Open Sans',
592
+ 'Helvetica Neue',
593
+ sans-serif;
594
+ display: flex;
595
+ align-items: center;
596
+ justify-content: center;
597
+ height: 100vh;
598
+ margin: 0;
599
+ }
600
+
601
+ .error {
602
+ display: flex;
603
+ align-items: center;
604
+ max-width: 32rem;
605
+ margin: 0 1rem;
606
+ }
607
+
608
+ .status {
609
+ font-weight: 200;
610
+ font-size: 3rem;
611
+ line-height: 1;
612
+ position: relative;
613
+ top: -0.05rem;
614
+ }
615
+
616
+ .message {
617
+ border-left: 1px solid var(--divider);
618
+ padding: 0 0 0 1rem;
619
+ margin: 0 0 0 1rem;
620
+ min-height: 2.5rem;
621
+ display: flex;
622
+ align-items: center;
623
+ }
624
+
625
+ .message h1 {
626
+ font-weight: 400;
627
+ font-size: 1em;
628
+ margin: 0;
629
+ }
630
+
631
+ @media (prefers-color-scheme: dark) {
632
+ body {
633
+ --bg: #222;
634
+ --fg: #ddd;
635
+ --divider: #666;
636
+ }
637
+ }
638
+ </style>
639
+ </head>
640
+ <body>
641
+ <div class="error">
642
+ <span class="status">` + status + '</span>\n <div class="message">\n <h1>' + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
643
+ },
644
+ version_hash: "kg35is"
645
+ };
646
+ async function get_hooks() {
647
+ let handle;
648
+ let handleFetch;
649
+ let handleError;
650
+ let init;
651
+ let reroute;
652
+ let transport;
653
+ return {
654
+ handle,
655
+ handleFetch,
656
+ handleError,
657
+ init,
658
+ reroute,
659
+ transport
660
+ };
661
+ }
662
+
663
+ /** @type {Record<string, string>} */
664
+ const escaped = {
665
+ '<': '\\u003C',
666
+ '\\': '\\\\',
667
+ '\b': '\\b',
668
+ '\f': '\\f',
669
+ '\n': '\\n',
670
+ '\r': '\\r',
671
+ '\t': '\\t',
672
+ '\u2028': '\\u2028',
673
+ '\u2029': '\\u2029'
674
+ };
675
+
676
+ class DevalueError extends Error {
677
+ /**
678
+ * @param {string} message
679
+ * @param {string[]} keys
680
+ */
681
+ constructor(message, keys) {
682
+ super(message);
683
+ this.name = 'DevalueError';
684
+ this.path = keys.join('');
685
+ }
686
+ }
687
+
688
+ /** @param {any} thing */
689
+ function is_primitive(thing) {
690
+ return Object(thing) !== thing;
691
+ }
692
+
693
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
694
+ Object.prototype
695
+ )
696
+ .sort()
697
+ .join('\0');
698
+
699
+ /** @param {any} thing */
700
+ function is_plain_object(thing) {
701
+ const proto = Object.getPrototypeOf(thing);
702
+
703
+ return (
704
+ proto === Object.prototype ||
705
+ proto === null ||
706
+ Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
707
+ );
708
+ }
709
+
710
+ /** @param {any} thing */
711
+ function get_type(thing) {
712
+ return Object.prototype.toString.call(thing).slice(8, -1);
713
+ }
714
+
715
+ /** @param {string} char */
716
+ function get_escaped_char(char) {
717
+ switch (char) {
718
+ case '"':
719
+ return '\\"';
720
+ case '<':
721
+ return '\\u003C';
722
+ case '\\':
723
+ return '\\\\';
724
+ case '\n':
725
+ return '\\n';
726
+ case '\r':
727
+ return '\\r';
728
+ case '\t':
729
+ return '\\t';
730
+ case '\b':
731
+ return '\\b';
732
+ case '\f':
733
+ return '\\f';
734
+ case '\u2028':
735
+ return '\\u2028';
736
+ case '\u2029':
737
+ return '\\u2029';
738
+ default:
739
+ return char < ' '
740
+ ? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`
741
+ : '';
742
+ }
743
+ }
744
+
745
+ /** @param {string} str */
746
+ function stringify_string(str) {
747
+ let result = '';
748
+ let last_pos = 0;
749
+ const len = str.length;
750
+
751
+ for (let i = 0; i < len; i += 1) {
752
+ const char = str[i];
753
+ const replacement = get_escaped_char(char);
754
+ if (replacement) {
755
+ result += str.slice(last_pos, i) + replacement;
756
+ last_pos = i + 1;
757
+ }
758
+ }
759
+
760
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
761
+ }
762
+
763
+ /** @param {Record<string | symbol, any>} object */
764
+ function enumerable_symbols(object) {
765
+ return Object.getOwnPropertySymbols(object).filter(
766
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
767
+ );
768
+ }
769
+
770
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
771
+
772
+ /** @param {string} key */
773
+ function stringify_key(key) {
774
+ return is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';
775
+ }
776
+
777
+ const chars$1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
778
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
779
+ const reserved =
780
+ /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
781
+
782
+ /**
783
+ * Turn a value into the JavaScript that creates an equivalent value
784
+ * @param {any} value
785
+ * @param {(value: any) => string | void} [replacer]
786
+ */
787
+ function uneval(value, replacer) {
788
+ const counts = new Map();
789
+
790
+ /** @type {string[]} */
791
+ const keys = [];
792
+
793
+ const custom = new Map();
794
+
795
+ /** @param {any} thing */
796
+ function walk(thing) {
797
+ if (typeof thing === 'function') {
798
+ throw new DevalueError(`Cannot stringify a function`, keys);
799
+ }
800
+
801
+ if (!is_primitive(thing)) {
802
+ if (counts.has(thing)) {
803
+ counts.set(thing, counts.get(thing) + 1);
804
+ return;
805
+ }
806
+
807
+ counts.set(thing, 1);
808
+
809
+ if (replacer) {
810
+ const str = replacer(thing);
811
+
812
+ if (typeof str === 'string') {
813
+ custom.set(thing, str);
814
+ return;
815
+ }
816
+ }
817
+
818
+ const type = get_type(thing);
819
+
820
+ switch (type) {
821
+ case 'Number':
822
+ case 'BigInt':
823
+ case 'String':
824
+ case 'Boolean':
825
+ case 'Date':
826
+ case 'RegExp':
827
+ return;
828
+
829
+ case 'Array':
830
+ /** @type {any[]} */ (thing).forEach((value, i) => {
831
+ keys.push(`[${i}]`);
832
+ walk(value);
833
+ keys.pop();
834
+ });
835
+ break;
836
+
837
+ case 'Set':
838
+ Array.from(thing).forEach(walk);
839
+ break;
840
+
841
+ case 'Map':
842
+ for (const [key, value] of thing) {
843
+ keys.push(
844
+ `.get(${is_primitive(key) ? stringify_primitive$1(key) : '...'})`
845
+ );
846
+ walk(value);
847
+ keys.pop();
848
+ }
849
+ break;
850
+
851
+ case "Int8Array":
852
+ case "Uint8Array":
853
+ case "Uint8ClampedArray":
854
+ case "Int16Array":
855
+ case "Uint16Array":
856
+ case "Int32Array":
857
+ case "Uint32Array":
858
+ case "Float32Array":
859
+ case "Float64Array":
860
+ case "BigInt64Array":
861
+ case "BigUint64Array":
862
+ return;
863
+
864
+ case "ArrayBuffer":
865
+ return;
866
+
867
+ default:
868
+ if (!is_plain_object(thing)) {
869
+ throw new DevalueError(
870
+ `Cannot stringify arbitrary non-POJOs`,
871
+ keys
872
+ );
873
+ }
874
+
875
+ if (enumerable_symbols(thing).length > 0) {
876
+ throw new DevalueError(
877
+ `Cannot stringify POJOs with symbolic keys`,
878
+ keys
879
+ );
880
+ }
881
+
882
+ for (const key in thing) {
883
+ keys.push(stringify_key(key));
884
+ walk(thing[key]);
885
+ keys.pop();
886
+ }
887
+ }
888
+ }
889
+ }
890
+
891
+ walk(value);
892
+
893
+ const names = new Map();
894
+
895
+ Array.from(counts)
896
+ .filter((entry) => entry[1] > 1)
897
+ .sort((a, b) => b[1] - a[1])
898
+ .forEach((entry, i) => {
899
+ names.set(entry[0], get_name(i));
900
+ });
901
+
902
+ /**
903
+ * @param {any} thing
904
+ * @returns {string}
905
+ */
906
+ function stringify(thing) {
907
+ if (names.has(thing)) {
908
+ return names.get(thing);
909
+ }
910
+
911
+ if (is_primitive(thing)) {
912
+ return stringify_primitive$1(thing);
913
+ }
914
+
915
+ if (custom.has(thing)) {
916
+ return custom.get(thing);
917
+ }
918
+
919
+ const type = get_type(thing);
920
+
921
+ switch (type) {
922
+ case 'Number':
923
+ case 'String':
924
+ case 'Boolean':
925
+ return `Object(${stringify(thing.valueOf())})`;
926
+
927
+ case 'RegExp':
928
+ return `new RegExp(${stringify_string(thing.source)}, "${
929
+ thing.flags
930
+ }")`;
931
+
932
+ case 'Date':
933
+ return `new Date(${thing.getTime()})`;
934
+
935
+ case 'Array':
936
+ const members = /** @type {any[]} */ (thing).map((v, i) =>
937
+ i in thing ? stringify(v) : ''
938
+ );
939
+ const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
940
+ return `[${members.join(',')}${tail}]`;
941
+
942
+ case 'Set':
943
+ case 'Map':
944
+ return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
945
+
946
+ case "Int8Array":
947
+ case "Uint8Array":
948
+ case "Uint8ClampedArray":
949
+ case "Int16Array":
950
+ case "Uint16Array":
951
+ case "Int32Array":
952
+ case "Uint32Array":
953
+ case "Float32Array":
954
+ case "Float64Array":
955
+ case "BigInt64Array":
956
+ case "BigUint64Array": {
957
+ /** @type {import("./types.js").TypedArray} */
958
+ const typedArray = thing;
959
+ return `new ${type}([${typedArray.toString()}])`;
960
+ }
961
+
962
+ case "ArrayBuffer": {
963
+ const ui8 = new Uint8Array(thing);
964
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
965
+ }
966
+
967
+ default:
968
+ const obj = `{${Object.keys(thing)
969
+ .map((key) => `${safe_key(key)}:${stringify(thing[key])}`)
970
+ .join(',')}}`;
971
+ const proto = Object.getPrototypeOf(thing);
972
+ if (proto === null) {
973
+ return Object.keys(thing).length > 0
974
+ ? `Object.assign(Object.create(null),${obj})`
975
+ : `Object.create(null)`;
976
+ }
977
+
978
+ return obj;
979
+ }
980
+ }
981
+
982
+ const str = stringify(value);
983
+
984
+ if (names.size) {
985
+ /** @type {string[]} */
986
+ const params = [];
987
+
988
+ /** @type {string[]} */
989
+ const statements = [];
990
+
991
+ /** @type {string[]} */
992
+ const values = [];
993
+
994
+ names.forEach((name, thing) => {
995
+ params.push(name);
996
+
997
+ if (custom.has(thing)) {
998
+ values.push(/** @type {string} */ (custom.get(thing)));
999
+ return;
1000
+ }
1001
+
1002
+ if (is_primitive(thing)) {
1003
+ values.push(stringify_primitive$1(thing));
1004
+ return;
1005
+ }
1006
+
1007
+ const type = get_type(thing);
1008
+
1009
+ switch (type) {
1010
+ case 'Number':
1011
+ case 'String':
1012
+ case 'Boolean':
1013
+ values.push(`Object(${stringify(thing.valueOf())})`);
1014
+ break;
1015
+
1016
+ case 'RegExp':
1017
+ values.push(thing.toString());
1018
+ break;
1019
+
1020
+ case 'Date':
1021
+ values.push(`new Date(${thing.getTime()})`);
1022
+ break;
1023
+
1024
+ case 'Array':
1025
+ values.push(`Array(${thing.length})`);
1026
+ /** @type {any[]} */ (thing).forEach((v, i) => {
1027
+ statements.push(`${name}[${i}]=${stringify(v)}`);
1028
+ });
1029
+ break;
1030
+
1031
+ case 'Set':
1032
+ values.push(`new Set`);
1033
+ statements.push(
1034
+ `${name}.${Array.from(thing)
1035
+ .map((v) => `add(${stringify(v)})`)
1036
+ .join('.')}`
1037
+ );
1038
+ break;
1039
+
1040
+ case 'Map':
1041
+ values.push(`new Map`);
1042
+ statements.push(
1043
+ `${name}.${Array.from(thing)
1044
+ .map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)
1045
+ .join('.')}`
1046
+ );
1047
+ break;
1048
+
1049
+ default:
1050
+ values.push(
1051
+ Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'
1052
+ );
1053
+ Object.keys(thing).forEach((key) => {
1054
+ statements.push(
1055
+ `${name}${safe_prop(key)}=${stringify(thing[key])}`
1056
+ );
1057
+ });
1058
+ }
1059
+ });
1060
+
1061
+ statements.push(`return ${str}`);
1062
+
1063
+ return `(function(${params.join(',')}){${statements.join(
1064
+ ';'
1065
+ )}}(${values.join(',')}))`;
1066
+ } else {
1067
+ return str;
1068
+ }
1069
+ }
1070
+
1071
+ /** @param {number} num */
1072
+ function get_name(num) {
1073
+ let name = '';
1074
+
1075
+ do {
1076
+ name = chars$1[num % chars$1.length] + name;
1077
+ num = ~~(num / chars$1.length) - 1;
1078
+ } while (num >= 0);
1079
+
1080
+ return reserved.test(name) ? `${name}0` : name;
1081
+ }
1082
+
1083
+ /** @param {string} c */
1084
+ function escape_unsafe_char(c) {
1085
+ return escaped[c] || c;
1086
+ }
1087
+
1088
+ /** @param {string} str */
1089
+ function escape_unsafe_chars(str) {
1090
+ return str.replace(unsafe_chars, escape_unsafe_char);
1091
+ }
1092
+
1093
+ /** @param {string} key */
1094
+ function safe_key(key) {
1095
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
1096
+ ? key
1097
+ : escape_unsafe_chars(JSON.stringify(key));
1098
+ }
1099
+
1100
+ /** @param {string} key */
1101
+ function safe_prop(key) {
1102
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
1103
+ ? `.${key}`
1104
+ : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
1105
+ }
1106
+
1107
+ /** @param {any} thing */
1108
+ function stringify_primitive$1(thing) {
1109
+ if (typeof thing === 'string') return stringify_string(thing);
1110
+ if (thing === void 0) return 'void 0';
1111
+ if (thing === 0 && 1 / thing < 0) return '-0';
1112
+ const str = String(thing);
1113
+ if (typeof thing === 'number') return str.replace(/^(-)?0\./, '$1.');
1114
+ if (typeof thing === 'bigint') return thing + 'n';
1115
+ return str;
1116
+ }
1117
+
1118
+ /**
1119
+ * Base64 Encodes an arraybuffer
1120
+ * @param {ArrayBuffer} arraybuffer
1121
+ * @returns {string}
1122
+ */
1123
+ function encode64(arraybuffer) {
1124
+ const dv = new DataView(arraybuffer);
1125
+ let binaryString = "";
1126
+
1127
+ for (let i = 0; i < arraybuffer.byteLength; i++) {
1128
+ binaryString += String.fromCharCode(dv.getUint8(i));
1129
+ }
1130
+
1131
+ return binaryToAscii(binaryString);
1132
+ }
1133
+
1134
+ const KEY_STRING =
1135
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1136
+
1137
+ /**
1138
+ * Substitute for btoa since it's deprecated in node.
1139
+ * Does not do any input validation.
1140
+ *
1141
+ * @see https://github.com/jsdom/abab/blob/master/lib/btoa.js
1142
+ *
1143
+ * @param {string} str
1144
+ * @returns {string}
1145
+ */
1146
+ function binaryToAscii(str) {
1147
+ let out = "";
1148
+ for (let i = 0; i < str.length; i += 3) {
1149
+ /** @type {[number, number, number, number]} */
1150
+ const groupsOfSix = [undefined, undefined, undefined, undefined];
1151
+ groupsOfSix[0] = str.charCodeAt(i) >> 2;
1152
+ groupsOfSix[1] = (str.charCodeAt(i) & 0x03) << 4;
1153
+ if (str.length > i + 1) {
1154
+ groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
1155
+ groupsOfSix[2] = (str.charCodeAt(i + 1) & 0x0f) << 2;
1156
+ }
1157
+ if (str.length > i + 2) {
1158
+ groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
1159
+ groupsOfSix[3] = str.charCodeAt(i + 2) & 0x3f;
1160
+ }
1161
+ for (let j = 0; j < groupsOfSix.length; j++) {
1162
+ if (typeof groupsOfSix[j] === "undefined") {
1163
+ out += "=";
1164
+ } else {
1165
+ out += KEY_STRING[groupsOfSix[j]];
1166
+ }
1167
+ }
1168
+ }
1169
+ return out;
1170
+ }
1171
+
1172
+ const UNDEFINED = -1;
1173
+ const HOLE = -2;
1174
+ const NAN = -3;
1175
+ const POSITIVE_INFINITY = -4;
1176
+ const NEGATIVE_INFINITY = -5;
1177
+ const NEGATIVE_ZERO = -6;
1178
+
1179
+ /**
1180
+ * Turn a value into a JSON string that can be parsed with `devalue.parse`
1181
+ * @param {any} value
1182
+ * @param {Record<string, (value: any) => any>} [reducers]
1183
+ */
1184
+ function stringify(value, reducers) {
1185
+ /** @type {any[]} */
1186
+ const stringified = [];
1187
+
1188
+ /** @type {Map<any, number>} */
1189
+ const indexes = new Map();
1190
+
1191
+ /** @type {Array<{ key: string, fn: (value: any) => any }>} */
1192
+ const custom = [];
1193
+ if (reducers) {
1194
+ for (const key of Object.getOwnPropertyNames(reducers)) {
1195
+ custom.push({ key, fn: reducers[key] });
1196
+ }
1197
+ }
1198
+
1199
+ /** @type {string[]} */
1200
+ const keys = [];
1201
+
1202
+ let p = 0;
1203
+
1204
+ /** @param {any} thing */
1205
+ function flatten(thing) {
1206
+ if (typeof thing === 'function') {
1207
+ throw new DevalueError(`Cannot stringify a function`, keys);
1208
+ }
1209
+
1210
+ if (indexes.has(thing)) return indexes.get(thing);
1211
+
1212
+ if (thing === undefined) return UNDEFINED;
1213
+ if (Number.isNaN(thing)) return NAN;
1214
+ if (thing === Infinity) return POSITIVE_INFINITY;
1215
+ if (thing === -Infinity) return NEGATIVE_INFINITY;
1216
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
1217
+
1218
+ const index = p++;
1219
+ indexes.set(thing, index);
1220
+
1221
+ for (const { key, fn } of custom) {
1222
+ const value = fn(thing);
1223
+ if (value) {
1224
+ stringified[index] = `["${key}",${flatten(value)}]`;
1225
+ return index;
1226
+ }
1227
+ }
1228
+
1229
+ let str = '';
1230
+
1231
+ if (is_primitive(thing)) {
1232
+ str = stringify_primitive(thing);
1233
+ } else {
1234
+ const type = get_type(thing);
1235
+
1236
+ switch (type) {
1237
+ case 'Number':
1238
+ case 'String':
1239
+ case 'Boolean':
1240
+ str = `["Object",${stringify_primitive(thing)}]`;
1241
+ break;
1242
+
1243
+ case 'BigInt':
1244
+ str = `["BigInt",${thing}]`;
1245
+ break;
1246
+
1247
+ case 'Date':
1248
+ const valid = !isNaN(thing.getDate());
1249
+ str = `["Date","${valid ? thing.toISOString() : ''}"]`;
1250
+ break;
1251
+
1252
+ case 'RegExp':
1253
+ const { source, flags } = thing;
1254
+ str = flags
1255
+ ? `["RegExp",${stringify_string(source)},"${flags}"]`
1256
+ : `["RegExp",${stringify_string(source)}]`;
1257
+ break;
1258
+
1259
+ case 'Array':
1260
+ str = '[';
1261
+
1262
+ for (let i = 0; i < thing.length; i += 1) {
1263
+ if (i > 0) str += ',';
1264
+
1265
+ if (i in thing) {
1266
+ keys.push(`[${i}]`);
1267
+ str += flatten(thing[i]);
1268
+ keys.pop();
1269
+ } else {
1270
+ str += HOLE;
1271
+ }
1272
+ }
1273
+
1274
+ str += ']';
1275
+
1276
+ break;
1277
+
1278
+ case 'Set':
1279
+ str = '["Set"';
1280
+
1281
+ for (const value of thing) {
1282
+ str += `,${flatten(value)}`;
1283
+ }
1284
+
1285
+ str += ']';
1286
+ break;
1287
+
1288
+ case 'Map':
1289
+ str = '["Map"';
1290
+
1291
+ for (const [key, value] of thing) {
1292
+ keys.push(
1293
+ `.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`
1294
+ );
1295
+ str += `,${flatten(key)},${flatten(value)}`;
1296
+ keys.pop();
1297
+ }
1298
+
1299
+ str += ']';
1300
+ break;
1301
+
1302
+ case "Int8Array":
1303
+ case "Uint8Array":
1304
+ case "Uint8ClampedArray":
1305
+ case "Int16Array":
1306
+ case "Uint16Array":
1307
+ case "Int32Array":
1308
+ case "Uint32Array":
1309
+ case "Float32Array":
1310
+ case "Float64Array":
1311
+ case "BigInt64Array":
1312
+ case "BigUint64Array": {
1313
+ /** @type {import("./types.js").TypedArray} */
1314
+ const typedArray = thing;
1315
+ const base64 = encode64(typedArray.buffer);
1316
+ str = '["' + type + '","' + base64 + '"]';
1317
+ break;
1318
+ }
1319
+
1320
+ case "ArrayBuffer": {
1321
+ /** @type {ArrayBuffer} */
1322
+ const arraybuffer = thing;
1323
+ const base64 = encode64(arraybuffer);
1324
+
1325
+ str = `["ArrayBuffer","${base64}"]`;
1326
+ break;
1327
+ }
1328
+
1329
+ default:
1330
+ if (!is_plain_object(thing)) {
1331
+ throw new DevalueError(
1332
+ `Cannot stringify arbitrary non-POJOs`,
1333
+ keys
1334
+ );
1335
+ }
1336
+
1337
+ if (enumerable_symbols(thing).length > 0) {
1338
+ throw new DevalueError(
1339
+ `Cannot stringify POJOs with symbolic keys`,
1340
+ keys
1341
+ );
1342
+ }
1343
+
1344
+ if (Object.getPrototypeOf(thing) === null) {
1345
+ str = '["null"';
1346
+ for (const key in thing) {
1347
+ keys.push(stringify_key(key));
1348
+ str += `,${stringify_string(key)},${flatten(thing[key])}`;
1349
+ keys.pop();
1350
+ }
1351
+ str += ']';
1352
+ } else {
1353
+ str = '{';
1354
+ let started = false;
1355
+ for (const key in thing) {
1356
+ if (started) str += ',';
1357
+ started = true;
1358
+ keys.push(stringify_key(key));
1359
+ str += `${stringify_string(key)}:${flatten(thing[key])}`;
1360
+ keys.pop();
1361
+ }
1362
+ str += '}';
1363
+ }
1364
+ }
1365
+ }
1366
+
1367
+ stringified[index] = str;
1368
+ return index;
1369
+ }
1370
+
1371
+ const index = flatten(value);
1372
+
1373
+ // special case — value is represented as a negative index
1374
+ if (index < 0) return `${index}`;
1375
+
1376
+ return `[${stringified.join(',')}]`;
1377
+ }
1378
+
1379
+ /**
1380
+ * @param {any} thing
1381
+ * @returns {string}
1382
+ */
1383
+ function stringify_primitive(thing) {
1384
+ const type = typeof thing;
1385
+ if (type === 'string') return stringify_string(thing);
1386
+ if (thing instanceof String) return stringify_string(thing.toString());
1387
+ if (thing === void 0) return UNDEFINED.toString();
1388
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
1389
+ if (type === 'bigint') return `["BigInt","${thing}"]`;
1390
+ return String(thing);
1391
+ }
1392
+
1393
+ var cookie = {};
1394
+
1395
+ /*!
1396
+ * cookie
1397
+ * Copyright(c) 2012-2014 Roman Shtylman
1398
+ * Copyright(c) 2015 Douglas Christopher Wilson
1399
+ * MIT Licensed
1400
+ */
1401
+
1402
+ var hasRequiredCookie;
1403
+
1404
+ function requireCookie () {
1405
+ if (hasRequiredCookie) return cookie;
1406
+ hasRequiredCookie = 1;
1407
+
1408
+ /**
1409
+ * Module exports.
1410
+ * @public
1411
+ */
1412
+
1413
+ cookie.parse = parse;
1414
+ cookie.serialize = serialize;
1415
+
1416
+ /**
1417
+ * Module variables.
1418
+ * @private
1419
+ */
1420
+
1421
+ var __toString = Object.prototype.toString;
1422
+
1423
+ /**
1424
+ * RegExp to match field-content in RFC 7230 sec 3.2
1425
+ *
1426
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
1427
+ * field-vchar = VCHAR / obs-text
1428
+ * obs-text = %x80-FF
1429
+ */
1430
+
1431
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
1432
+
1433
+ /**
1434
+ * Parse a cookie header.
1435
+ *
1436
+ * Parse the given cookie header string into an object
1437
+ * The object has the various cookies as keys(names) => values
1438
+ *
1439
+ * @param {string} str
1440
+ * @param {object} [options]
1441
+ * @return {object}
1442
+ * @public
1443
+ */
1444
+
1445
+ function parse(str, options) {
1446
+ if (typeof str !== 'string') {
1447
+ throw new TypeError('argument str must be a string');
1448
+ }
1449
+
1450
+ var obj = {};
1451
+ var opt = options || {};
1452
+ var dec = opt.decode || decode;
1453
+
1454
+ var index = 0;
1455
+ while (index < str.length) {
1456
+ var eqIdx = str.indexOf('=', index);
1457
+
1458
+ // no more cookie pairs
1459
+ if (eqIdx === -1) {
1460
+ break
1461
+ }
1462
+
1463
+ var endIdx = str.indexOf(';', index);
1464
+
1465
+ if (endIdx === -1) {
1466
+ endIdx = str.length;
1467
+ } else if (endIdx < eqIdx) {
1468
+ // backtrack on prior semicolon
1469
+ index = str.lastIndexOf(';', eqIdx - 1) + 1;
1470
+ continue
1471
+ }
1472
+
1473
+ var key = str.slice(index, eqIdx).trim();
1474
+
1475
+ // only assign once
1476
+ if (undefined === obj[key]) {
1477
+ var val = str.slice(eqIdx + 1, endIdx).trim();
1478
+
1479
+ // quoted values
1480
+ if (val.charCodeAt(0) === 0x22) {
1481
+ val = val.slice(1, -1);
1482
+ }
1483
+
1484
+ obj[key] = tryDecode(val, dec);
1485
+ }
1486
+
1487
+ index = endIdx + 1;
1488
+ }
1489
+
1490
+ return obj;
1491
+ }
1492
+
1493
+ /**
1494
+ * Serialize data into a cookie header.
1495
+ *
1496
+ * Serialize the a name value pair into a cookie string suitable for
1497
+ * http headers. An optional options object specified cookie parameters.
1498
+ *
1499
+ * serialize('foo', 'bar', { httpOnly: true })
1500
+ * => "foo=bar; httpOnly"
1501
+ *
1502
+ * @param {string} name
1503
+ * @param {string} val
1504
+ * @param {object} [options]
1505
+ * @return {string}
1506
+ * @public
1507
+ */
1508
+
1509
+ function serialize(name, val, options) {
1510
+ var opt = options || {};
1511
+ var enc = opt.encode || encode;
1512
+
1513
+ if (typeof enc !== 'function') {
1514
+ throw new TypeError('option encode is invalid');
1515
+ }
1516
+
1517
+ if (!fieldContentRegExp.test(name)) {
1518
+ throw new TypeError('argument name is invalid');
1519
+ }
1520
+
1521
+ var value = enc(val);
1522
+
1523
+ if (value && !fieldContentRegExp.test(value)) {
1524
+ throw new TypeError('argument val is invalid');
1525
+ }
1526
+
1527
+ var str = name + '=' + value;
1528
+
1529
+ if (null != opt.maxAge) {
1530
+ var maxAge = opt.maxAge - 0;
1531
+
1532
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
1533
+ throw new TypeError('option maxAge is invalid')
1534
+ }
1535
+
1536
+ str += '; Max-Age=' + Math.floor(maxAge);
1537
+ }
1538
+
1539
+ if (opt.domain) {
1540
+ if (!fieldContentRegExp.test(opt.domain)) {
1541
+ throw new TypeError('option domain is invalid');
1542
+ }
1543
+
1544
+ str += '; Domain=' + opt.domain;
1545
+ }
1546
+
1547
+ if (opt.path) {
1548
+ if (!fieldContentRegExp.test(opt.path)) {
1549
+ throw new TypeError('option path is invalid');
1550
+ }
1551
+
1552
+ str += '; Path=' + opt.path;
1553
+ }
1554
+
1555
+ if (opt.expires) {
1556
+ var expires = opt.expires;
1557
+
1558
+ if (!isDate(expires) || isNaN(expires.valueOf())) {
1559
+ throw new TypeError('option expires is invalid');
1560
+ }
1561
+
1562
+ str += '; Expires=' + expires.toUTCString();
1563
+ }
1564
+
1565
+ if (opt.httpOnly) {
1566
+ str += '; HttpOnly';
1567
+ }
1568
+
1569
+ if (opt.secure) {
1570
+ str += '; Secure';
1571
+ }
1572
+
1573
+ if (opt.partitioned) {
1574
+ str += '; Partitioned';
1575
+ }
1576
+
1577
+ if (opt.priority) {
1578
+ var priority = typeof opt.priority === 'string'
1579
+ ? opt.priority.toLowerCase()
1580
+ : opt.priority;
1581
+
1582
+ switch (priority) {
1583
+ case 'low':
1584
+ str += '; Priority=Low';
1585
+ break
1586
+ case 'medium':
1587
+ str += '; Priority=Medium';
1588
+ break
1589
+ case 'high':
1590
+ str += '; Priority=High';
1591
+ break
1592
+ default:
1593
+ throw new TypeError('option priority is invalid')
1594
+ }
1595
+ }
1596
+
1597
+ if (opt.sameSite) {
1598
+ var sameSite = typeof opt.sameSite === 'string'
1599
+ ? opt.sameSite.toLowerCase() : opt.sameSite;
1600
+
1601
+ switch (sameSite) {
1602
+ case true:
1603
+ str += '; SameSite=Strict';
1604
+ break;
1605
+ case 'lax':
1606
+ str += '; SameSite=Lax';
1607
+ break;
1608
+ case 'strict':
1609
+ str += '; SameSite=Strict';
1610
+ break;
1611
+ case 'none':
1612
+ str += '; SameSite=None';
1613
+ break;
1614
+ default:
1615
+ throw new TypeError('option sameSite is invalid');
1616
+ }
1617
+ }
1618
+
1619
+ return str;
1620
+ }
1621
+
1622
+ /**
1623
+ * URL-decode string value. Optimized to skip native call when no %.
1624
+ *
1625
+ * @param {string} str
1626
+ * @returns {string}
1627
+ */
1628
+
1629
+ function decode (str) {
1630
+ return str.indexOf('%') !== -1
1631
+ ? decodeURIComponent(str)
1632
+ : str
1633
+ }
1634
+
1635
+ /**
1636
+ * URL-encode value.
1637
+ *
1638
+ * @param {string} val
1639
+ * @returns {string}
1640
+ */
1641
+
1642
+ function encode (val) {
1643
+ return encodeURIComponent(val)
1644
+ }
1645
+
1646
+ /**
1647
+ * Determine if value is a Date.
1648
+ *
1649
+ * @param {*} val
1650
+ * @private
1651
+ */
1652
+
1653
+ function isDate (val) {
1654
+ return __toString.call(val) === '[object Date]' ||
1655
+ val instanceof Date
1656
+ }
1657
+
1658
+ /**
1659
+ * Try decoding a string using a decoding function.
1660
+ *
1661
+ * @param {string} str
1662
+ * @param {function} decode
1663
+ * @private
1664
+ */
1665
+
1666
+ function tryDecode(str, decode) {
1667
+ try {
1668
+ return decode(str);
1669
+ } catch (e) {
1670
+ return str;
1671
+ }
1672
+ }
1673
+ return cookie;
1674
+ }
1675
+
1676
+ var cookieExports = requireCookie();
1677
+
1678
+ var setCookie = {exports: {}};
1679
+
1680
+ var hasRequiredSetCookie;
1681
+
1682
+ function requireSetCookie () {
1683
+ if (hasRequiredSetCookie) return setCookie.exports;
1684
+ hasRequiredSetCookie = 1;
1685
+
1686
+ var defaultParseOptions = {
1687
+ decodeValues: true,
1688
+ map: false,
1689
+ silent: false,
1690
+ };
1691
+
1692
+ function isNonEmptyString(str) {
1693
+ return typeof str === "string" && !!str.trim();
1694
+ }
1695
+
1696
+ function parseString(setCookieValue, options) {
1697
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
1698
+
1699
+ var nameValuePairStr = parts.shift();
1700
+ var parsed = parseNameValuePair(nameValuePairStr);
1701
+ var name = parsed.name;
1702
+ var value = parsed.value;
1703
+
1704
+ options = options
1705
+ ? Object.assign({}, defaultParseOptions, options)
1706
+ : defaultParseOptions;
1707
+
1708
+ try {
1709
+ value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
1710
+ } catch (e) {
1711
+ console.error(
1712
+ "set-cookie-parser encountered an error while decoding a cookie with value '" +
1713
+ value +
1714
+ "'. Set options.decodeValues to false to disable this feature.",
1715
+ e
1716
+ );
1717
+ }
1718
+
1719
+ var cookie = {
1720
+ name: name,
1721
+ value: value,
1722
+ };
1723
+
1724
+ parts.forEach(function (part) {
1725
+ var sides = part.split("=");
1726
+ var key = sides.shift().trimLeft().toLowerCase();
1727
+ var value = sides.join("=");
1728
+ if (key === "expires") {
1729
+ cookie.expires = new Date(value);
1730
+ } else if (key === "max-age") {
1731
+ cookie.maxAge = parseInt(value, 10);
1732
+ } else if (key === "secure") {
1733
+ cookie.secure = true;
1734
+ } else if (key === "httponly") {
1735
+ cookie.httpOnly = true;
1736
+ } else if (key === "samesite") {
1737
+ cookie.sameSite = value;
1738
+ } else if (key === "partitioned") {
1739
+ cookie.partitioned = true;
1740
+ } else {
1741
+ cookie[key] = value;
1742
+ }
1743
+ });
1744
+
1745
+ return cookie;
1746
+ }
1747
+
1748
+ function parseNameValuePair(nameValuePairStr) {
1749
+ // Parses name-value-pair according to rfc6265bis draft
1750
+
1751
+ var name = "";
1752
+ var value = "";
1753
+ var nameValueArr = nameValuePairStr.split("=");
1754
+ if (nameValueArr.length > 1) {
1755
+ name = nameValueArr.shift();
1756
+ value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
1757
+ } else {
1758
+ value = nameValuePairStr;
1759
+ }
1760
+
1761
+ return { name: name, value: value };
1762
+ }
1763
+
1764
+ function parse(input, options) {
1765
+ options = options
1766
+ ? Object.assign({}, defaultParseOptions, options)
1767
+ : defaultParseOptions;
1768
+
1769
+ if (!input) {
1770
+ if (!options.map) {
1771
+ return [];
1772
+ } else {
1773
+ return {};
1774
+ }
1775
+ }
1776
+
1777
+ if (input.headers) {
1778
+ if (typeof input.headers.getSetCookie === "function") {
1779
+ // for fetch responses - they combine headers of the same type in the headers array,
1780
+ // but getSetCookie returns an uncombined array
1781
+ input = input.headers.getSetCookie();
1782
+ } else if (input.headers["set-cookie"]) {
1783
+ // fast-path for node.js (which automatically normalizes header names to lower-case
1784
+ input = input.headers["set-cookie"];
1785
+ } else {
1786
+ // slow-path for other environments - see #25
1787
+ var sch =
1788
+ input.headers[
1789
+ Object.keys(input.headers).find(function (key) {
1790
+ return key.toLowerCase() === "set-cookie";
1791
+ })
1792
+ ];
1793
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
1794
+ if (!sch && input.headers.cookie && !options.silent) {
1795
+ console.warn(
1796
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
1797
+ );
1798
+ }
1799
+ input = sch;
1800
+ }
1801
+ }
1802
+ if (!Array.isArray(input)) {
1803
+ input = [input];
1804
+ }
1805
+
1806
+ if (!options.map) {
1807
+ return input.filter(isNonEmptyString).map(function (str) {
1808
+ return parseString(str, options);
1809
+ });
1810
+ } else {
1811
+ var cookies = {};
1812
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
1813
+ var cookie = parseString(str, options);
1814
+ cookies[cookie.name] = cookie;
1815
+ return cookies;
1816
+ }, cookies);
1817
+ }
1818
+ }
1819
+
1820
+ /*
1821
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
1822
+ that are within a single set-cookie field-value, such as in the Expires portion.
1823
+
1824
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
1825
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
1826
+ React Native's fetch does this for *every* header, including set-cookie.
1827
+
1828
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
1829
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
1830
+ */
1831
+ function splitCookiesString(cookiesString) {
1832
+ if (Array.isArray(cookiesString)) {
1833
+ return cookiesString;
1834
+ }
1835
+ if (typeof cookiesString !== "string") {
1836
+ return [];
1837
+ }
1838
+
1839
+ var cookiesStrings = [];
1840
+ var pos = 0;
1841
+ var start;
1842
+ var ch;
1843
+ var lastComma;
1844
+ var nextStart;
1845
+ var cookiesSeparatorFound;
1846
+
1847
+ function skipWhitespace() {
1848
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
1849
+ pos += 1;
1850
+ }
1851
+ return pos < cookiesString.length;
1852
+ }
1853
+
1854
+ function notSpecialChar() {
1855
+ ch = cookiesString.charAt(pos);
1856
+
1857
+ return ch !== "=" && ch !== ";" && ch !== ",";
1858
+ }
1859
+
1860
+ while (pos < cookiesString.length) {
1861
+ start = pos;
1862
+ cookiesSeparatorFound = false;
1863
+
1864
+ while (skipWhitespace()) {
1865
+ ch = cookiesString.charAt(pos);
1866
+ if (ch === ",") {
1867
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
1868
+ lastComma = pos;
1869
+ pos += 1;
1870
+
1871
+ skipWhitespace();
1872
+ nextStart = pos;
1873
+
1874
+ while (pos < cookiesString.length && notSpecialChar()) {
1875
+ pos += 1;
1876
+ }
1877
+
1878
+ // currently special character
1879
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
1880
+ // we found cookies separator
1881
+ cookiesSeparatorFound = true;
1882
+ // pos is inside the next cookie, so back up and return it.
1883
+ pos = nextStart;
1884
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
1885
+ start = pos;
1886
+ } else {
1887
+ // in param ',' or param separator ';',
1888
+ // we continue from that comma
1889
+ pos = lastComma + 1;
1890
+ }
1891
+ } else {
1892
+ pos += 1;
1893
+ }
1894
+ }
1895
+
1896
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
1897
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
1898
+ }
1899
+ }
1900
+
1901
+ return cookiesStrings;
1902
+ }
1903
+
1904
+ setCookie.exports = parse;
1905
+ setCookie.exports.parse = parse;
1906
+ setCookie.exports.parseString = parseString;
1907
+ setCookie.exports.splitCookiesString = splitCookiesString;
1908
+ return setCookie.exports;
1909
+ }
1910
+
1911
+ var setCookieExports = /*@__PURE__*/ requireSetCookie();
1912
+
1913
+ function hash(...values) {
1914
+ let hash2 = 5381;
1915
+ for (const value of values) {
1916
+ if (typeof value === "string") {
1917
+ let i = value.length;
1918
+ while (i) hash2 = hash2 * 33 ^ value.charCodeAt(--i);
1919
+ } else if (ArrayBuffer.isView(value)) {
1920
+ const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
1921
+ let i = buffer.length;
1922
+ while (i) hash2 = hash2 * 33 ^ buffer[--i];
1923
+ } else {
1924
+ throw new TypeError("value must be a string or TypedArray");
1925
+ }
1926
+ }
1927
+ return (hash2 >>> 0).toString(36);
1928
+ }
1929
+ function b64_encode(buffer) {
1930
+ if (globalThis.Buffer) {
1931
+ return Buffer.from(buffer).toString("base64");
1932
+ }
1933
+ const little_endian = new Uint8Array(new Uint16Array([1]).buffer)[0] > 0;
1934
+ return btoa(
1935
+ new TextDecoder(little_endian ? "utf-16le" : "utf-16be").decode(
1936
+ new Uint16Array(new Uint8Array(buffer))
1937
+ )
1938
+ );
1939
+ }
1940
+ function get_relative_path(from, to) {
1941
+ const from_parts = from.split(/[/\\]/);
1942
+ const to_parts = to.split(/[/\\]/);
1943
+ from_parts.pop();
1944
+ while (from_parts[0] === to_parts[0]) {
1945
+ from_parts.shift();
1946
+ to_parts.shift();
1947
+ }
1948
+ let i = from_parts.length;
1949
+ while (i--) from_parts[i] = "..";
1950
+ return from_parts.concat(to_parts).join("/");
1951
+ }
1952
+ function exec(match, params, matchers) {
1953
+ const result = {};
1954
+ const values = match.slice(1);
1955
+ const values_needing_match = values.filter((value) => value !== void 0);
1956
+ let buffered = 0;
1957
+ for (let i = 0; i < params.length; i += 1) {
1958
+ const param = params[i];
1959
+ let value = values[i - buffered];
1960
+ if (param.chained && param.rest && buffered) {
1961
+ value = values.slice(i - buffered, i + 1).filter((s2) => s2).join("/");
1962
+ buffered = 0;
1963
+ }
1964
+ if (value === void 0) {
1965
+ if (param.rest) result[param.name] = "";
1966
+ continue;
1967
+ }
1968
+ if (!param.matcher || matchers[param.matcher](value)) {
1969
+ result[param.name] = value;
1970
+ const next_param = params[i + 1];
1971
+ const next_value = values[i + 1];
1972
+ if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) {
1973
+ buffered = 0;
1974
+ }
1975
+ if (!next_param && !next_value && Object.keys(result).length === values_needing_match.length) {
1976
+ buffered = 0;
1977
+ }
1978
+ continue;
1979
+ }
1980
+ if (param.optional && param.chained) {
1981
+ buffered++;
1982
+ continue;
1983
+ }
1984
+ return;
1985
+ }
1986
+ if (buffered) return;
1987
+ return result;
1988
+ }
1989
+ function compact(arr) {
1990
+ return arr.filter(
1991
+ /** @returns {val is NonNullable<T>} */
1992
+ (val) => val != null
1993
+ );
1994
+ }
1995
+ class HttpError {
1996
+ /**
1997
+ * @param {number} status
1998
+ * @param {{message: string} extends App.Error ? (App.Error | string | undefined) : App.Error} body
1999
+ */
2000
+ constructor(status, body2) {
2001
+ this.status = status;
2002
+ if (typeof body2 === "string") {
2003
+ this.body = { message: body2 };
2004
+ } else if (body2) {
2005
+ this.body = body2;
2006
+ } else {
2007
+ this.body = { message: `Error: ${status}` };
2008
+ }
2009
+ }
2010
+ toString() {
2011
+ return JSON.stringify(this.body);
2012
+ }
2013
+ }
2014
+ class Redirect {
2015
+ /**
2016
+ * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308} status
2017
+ * @param {string} location
2018
+ */
2019
+ constructor(status, location) {
2020
+ this.status = status;
2021
+ this.location = location;
2022
+ }
2023
+ }
2024
+ class SvelteKitError extends Error {
2025
+ /**
2026
+ * @param {number} status
2027
+ * @param {string} text
2028
+ * @param {string} message
2029
+ */
2030
+ constructor(status, text2, message) {
2031
+ super(message);
2032
+ this.status = status;
2033
+ this.text = text2;
2034
+ }
2035
+ }
2036
+ class ActionFailure {
2037
+ /**
2038
+ * @param {number} status
2039
+ * @param {T} data
2040
+ */
2041
+ constructor(status, data) {
2042
+ this.status = status;
2043
+ this.data = data;
2044
+ }
2045
+ }
2046
+ const INVALIDATED_PARAM = "x-sveltekit-invalidated";
2047
+ const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
2048
+ function coalesce_to_error(err) {
2049
+ return err instanceof Error || err && /** @type {any} */
2050
+ err.name && /** @type {any} */
2051
+ err.message ? (
2052
+ /** @type {Error} */
2053
+ err
2054
+ ) : new Error(JSON.stringify(err));
2055
+ }
2056
+ function normalize_error(error) {
2057
+ return (
2058
+ /** @type {import('../runtime/control.js').Redirect | HttpError | SvelteKitError | Error} */
2059
+ error
2060
+ );
2061
+ }
2062
+ function get_status(error) {
2063
+ return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
2064
+ }
2065
+ function get_message(error) {
2066
+ return error instanceof SvelteKitError ? error.text : "Internal Error";
2067
+ }
2068
+ const DATA_SUFFIX = "/__data.json";
2069
+ const HTML_DATA_SUFFIX = ".html__data.json";
2070
+ function has_data_suffix(pathname) {
2071
+ return pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX);
2072
+ }
2073
+ function add_data_suffix(pathname) {
2074
+ if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_DATA_SUFFIX);
2075
+ return pathname.replace(/\/$/, "") + DATA_SUFFIX;
2076
+ }
2077
+ function strip_data_suffix(pathname) {
2078
+ if (pathname.endsWith(HTML_DATA_SUFFIX)) {
2079
+ return pathname.slice(0, -HTML_DATA_SUFFIX.length) + ".html";
2080
+ }
2081
+ return pathname.slice(0, -DATA_SUFFIX.length);
2082
+ }
2083
+ const ROUTE_SUFFIX = "/__route.js";
2084
+ function has_resolution_suffix(pathname) {
2085
+ return pathname.endsWith(ROUTE_SUFFIX);
2086
+ }
2087
+ function add_resolution_suffix(pathname) {
2088
+ return pathname.replace(/\/$/, "") + ROUTE_SUFFIX;
2089
+ }
2090
+ function strip_resolution_suffix(pathname) {
2091
+ return pathname.slice(0, -ROUTE_SUFFIX.length);
2092
+ }
2093
+ const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
2094
+ const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
2095
+ const PAGE_METHODS = ["GET", "POST", "HEAD"];
2096
+ function negotiate(accept, types) {
2097
+ const parts = [];
2098
+ accept.split(",").forEach((str, i) => {
2099
+ const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
2100
+ if (match) {
2101
+ const [, type, subtype, q = "1"] = match;
2102
+ parts.push({ type, subtype, q: +q, i });
2103
+ }
2104
+ });
2105
+ parts.sort((a, b) => {
2106
+ if (a.q !== b.q) {
2107
+ return b.q - a.q;
2108
+ }
2109
+ if (a.subtype === "*" !== (b.subtype === "*")) {
2110
+ return a.subtype === "*" ? 1 : -1;
2111
+ }
2112
+ if (a.type === "*" !== (b.type === "*")) {
2113
+ return a.type === "*" ? 1 : -1;
2114
+ }
2115
+ return a.i - b.i;
2116
+ });
2117
+ let accepted;
2118
+ let min_priority = Infinity;
2119
+ for (const mimetype of types) {
2120
+ const [type, subtype] = mimetype.split("/");
2121
+ const priority = parts.findIndex(
2122
+ (part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*")
2123
+ );
2124
+ if (priority !== -1 && priority < min_priority) {
2125
+ accepted = mimetype;
2126
+ min_priority = priority;
2127
+ }
2128
+ }
2129
+ return accepted;
2130
+ }
2131
+ function is_content_type(request, ...types) {
2132
+ const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
2133
+ return types.includes(type.toLowerCase());
2134
+ }
2135
+ function is_form_content_type(request) {
2136
+ return is_content_type(
2137
+ request,
2138
+ "application/x-www-form-urlencoded",
2139
+ "multipart/form-data",
2140
+ "text/plain"
2141
+ );
2142
+ }
2143
+ function json(data, init2) {
2144
+ const body2 = JSON.stringify(data);
2145
+ const headers2 = new Headers(init2?.headers);
2146
+ if (!headers2.has("content-length")) {
2147
+ headers2.set("content-length", encoder$3.encode(body2).byteLength.toString());
2148
+ }
2149
+ if (!headers2.has("content-type")) {
2150
+ headers2.set("content-type", "application/json");
2151
+ }
2152
+ return new Response(body2, {
2153
+ ...init2,
2154
+ headers: headers2
2155
+ });
2156
+ }
2157
+ const encoder$3 = new TextEncoder();
2158
+ function text(body2, init2) {
2159
+ const headers2 = new Headers(init2?.headers);
2160
+ if (!headers2.has("content-length")) {
2161
+ const encoded = encoder$3.encode(body2);
2162
+ headers2.set("content-length", encoded.byteLength.toString());
2163
+ return new Response(encoded, {
2164
+ ...init2,
2165
+ headers: headers2
2166
+ });
2167
+ }
2168
+ return new Response(body2, {
2169
+ ...init2,
2170
+ headers: headers2
2171
+ });
2172
+ }
2173
+ const escape_html_attr_dict = {
2174
+ "&": "&amp;",
2175
+ '"': "&quot;"
2176
+ // Svelte also escapes < because the escape function could be called inside a `noscript` there
2177
+ // https://github.com/sveltejs/svelte/security/advisories/GHSA-8266-84wp-wv5c
2178
+ // However, that doesn't apply in SvelteKit
2179
+ };
2180
+ const escape_html_dict = {
2181
+ "&": "&amp;",
2182
+ "<": "&lt;"
2183
+ };
2184
+ const surrogates = (
2185
+ // high surrogate without paired low surrogate
2186
+ "[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]"
2187
+ );
2188
+ const escape_html_attr_regex = new RegExp(
2189
+ `[${Object.keys(escape_html_attr_dict).join("")}]|` + surrogates,
2190
+ "g"
2191
+ );
2192
+ const escape_html_regex = new RegExp(
2193
+ `[${Object.keys(escape_html_dict).join("")}]|` + surrogates,
2194
+ "g"
2195
+ );
2196
+ function escape_html(str, is_attr) {
2197
+ const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
2198
+ const escaped_str = str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {
2199
+ if (match.length === 2) {
2200
+ return match;
2201
+ }
2202
+ return dict[match] ?? `&#${match.charCodeAt(0)};`;
2203
+ });
2204
+ return escaped_str;
2205
+ }
2206
+ function method_not_allowed(mod, method) {
2207
+ return text(`${method} method not allowed`, {
2208
+ status: 405,
2209
+ headers: {
2210
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
2211
+ // "The server must generate an Allow header field in a 405 status code response"
2212
+ allow: allowed_methods(mod).join(", ")
2213
+ }
2214
+ });
2215
+ }
2216
+ function allowed_methods(mod) {
2217
+ const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
2218
+ if ("GET" in mod || "HEAD" in mod) allowed.push("HEAD");
2219
+ return allowed;
2220
+ }
2221
+ function static_error_page(options2, status, message) {
2222
+ let page = options2.templates.error({ status, message: escape_html(message) });
2223
+ return text(page, {
2224
+ headers: { "content-type": "text/html; charset=utf-8" },
2225
+ status
2226
+ });
2227
+ }
2228
+ async function handle_fatal_error(event, options2, error) {
2229
+ error = error instanceof HttpError ? error : coalesce_to_error(error);
2230
+ const status = get_status(error);
2231
+ const body2 = await handle_error_and_jsonify(event, options2, error);
2232
+ const type = negotiate(event.request.headers.get("accept") || "text/html", [
2233
+ "application/json",
2234
+ "text/html"
2235
+ ]);
2236
+ if (event.isDataRequest || type === "application/json") {
2237
+ return json(body2, {
2238
+ status
2239
+ });
2240
+ }
2241
+ return static_error_page(options2, status, body2.message);
2242
+ }
2243
+ async function handle_error_and_jsonify(event, options2, error) {
2244
+ if (error instanceof HttpError) {
2245
+ return error.body;
2246
+ }
2247
+ const status = get_status(error);
2248
+ const message = get_message(error);
2249
+ return await options2.hooks.handleError({ error, event, status, message }) ?? { message };
2250
+ }
2251
+ function redirect_response(status, location) {
2252
+ const response = new Response(void 0, {
2253
+ status,
2254
+ headers: { location }
2255
+ });
2256
+ return response;
2257
+ }
2258
+ function clarify_devalue_error(event, error) {
2259
+ if (error.path) {
2260
+ return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (data${error.path})`;
2261
+ }
2262
+ if (error.path === "") {
2263
+ return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
2264
+ }
2265
+ return error.message;
2266
+ }
2267
+ function stringify_uses(node) {
2268
+ const uses = [];
2269
+ if (node.uses && node.uses.dependencies.size > 0) {
2270
+ uses.push(`"dependencies":${JSON.stringify(Array.from(node.uses.dependencies))}`);
2271
+ }
2272
+ if (node.uses && node.uses.search_params.size > 0) {
2273
+ uses.push(`"search_params":${JSON.stringify(Array.from(node.uses.search_params))}`);
2274
+ }
2275
+ if (node.uses && node.uses.params.size > 0) {
2276
+ uses.push(`"params":${JSON.stringify(Array.from(node.uses.params))}`);
2277
+ }
2278
+ if (node.uses?.parent) uses.push('"parent":1');
2279
+ if (node.uses?.route) uses.push('"route":1');
2280
+ if (node.uses?.url) uses.push('"url":1');
2281
+ return `"uses":{${uses.join(",")}}`;
2282
+ }
2283
+ async function render_endpoint(event, mod, state) {
2284
+ const method = (
2285
+ /** @type {import('types').HttpMethod} */
2286
+ event.request.method
2287
+ );
2288
+ let handler = mod[method] || mod.fallback;
2289
+ if (method === "HEAD" && mod.GET && !mod.HEAD) {
2290
+ handler = mod.GET;
2291
+ }
2292
+ if (!handler) {
2293
+ return method_not_allowed(mod, method);
2294
+ }
2295
+ const prerender = mod.prerender ?? state.prerender_default;
2296
+ if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) {
2297
+ throw new Error("Cannot prerender endpoints that have mutative methods");
2298
+ }
2299
+ if (state.prerendering && !prerender) {
2300
+ if (state.depth > 0) {
2301
+ throw new Error(`${event.route.id} is not prerenderable`);
2302
+ } else {
2303
+ return new Response(void 0, { status: 204 });
2304
+ }
2305
+ }
2306
+ try {
2307
+ let response = await handler(
2308
+ /** @type {import('@sveltejs/kit').RequestEvent<Record<string, any>>} */
2309
+ event
2310
+ );
2311
+ if (!(response instanceof Response)) {
2312
+ throw new Error(
2313
+ `Invalid response from route ${event.url.pathname}: handler should return a Response object`
2314
+ );
2315
+ }
2316
+ if (state.prerendering) {
2317
+ response = new Response(response.body, {
2318
+ status: response.status,
2319
+ statusText: response.statusText,
2320
+ headers: new Headers(response.headers)
2321
+ });
2322
+ response.headers.set("x-sveltekit-prerender", String(prerender));
2323
+ }
2324
+ return response;
2325
+ } catch (e) {
2326
+ if (e instanceof Redirect) {
2327
+ return new Response(void 0, {
2328
+ status: e.status,
2329
+ headers: { location: e.location }
2330
+ });
2331
+ }
2332
+ throw e;
2333
+ }
2334
+ }
2335
+ function is_endpoint_request(event) {
2336
+ const { method, headers: headers2 } = event.request;
2337
+ if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) {
2338
+ return true;
2339
+ }
2340
+ if (method === "POST" && headers2.get("x-sveltekit-action") === "true") return false;
2341
+ const accept = event.request.headers.get("accept") ?? "*/*";
2342
+ return negotiate(accept, ["*", "text/html"]) !== "text/html";
2343
+ }
2344
+ function is_action_json_request(event) {
2345
+ const accept = negotiate(event.request.headers.get("accept") ?? "*/*", [
2346
+ "application/json",
2347
+ "text/html"
2348
+ ]);
2349
+ return accept === "application/json" && event.request.method === "POST";
2350
+ }
2351
+ async function handle_action_json_request(event, options2, server) {
2352
+ const actions = server?.actions;
2353
+ if (!actions) {
2354
+ const no_actions_error = new SvelteKitError(
2355
+ 405,
2356
+ "Method Not Allowed",
2357
+ `POST method not allowed. No form actions exist for ${"this page"}`
2358
+ );
2359
+ return action_json(
2360
+ {
2361
+ type: "error",
2362
+ error: await handle_error_and_jsonify(event, options2, no_actions_error)
2363
+ },
2364
+ {
2365
+ status: no_actions_error.status,
2366
+ headers: {
2367
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
2368
+ // "The server must generate an Allow header field in a 405 status code response"
2369
+ allow: "GET"
2370
+ }
2371
+ }
2372
+ );
2373
+ }
2374
+ check_named_default_separate(actions);
2375
+ try {
2376
+ const data = await call_action(event, actions);
2377
+ if (false) ;
2378
+ if (data instanceof ActionFailure) {
2379
+ return action_json({
2380
+ type: "failure",
2381
+ status: data.status,
2382
+ // @ts-expect-error we assign a string to what is supposed to be an object. That's ok
2383
+ // because we don't use the object outside, and this way we have better code navigation
2384
+ // through knowing where the related interface is used.
2385
+ data: stringify_action_response(
2386
+ data.data,
2387
+ /** @type {string} */
2388
+ event.route.id,
2389
+ options2.hooks.transport
2390
+ )
2391
+ });
2392
+ } else {
2393
+ return action_json({
2394
+ type: "success",
2395
+ status: data ? 200 : 204,
2396
+ // @ts-expect-error see comment above
2397
+ data: stringify_action_response(
2398
+ data,
2399
+ /** @type {string} */
2400
+ event.route.id,
2401
+ options2.hooks.transport
2402
+ )
2403
+ });
2404
+ }
2405
+ } catch (e) {
2406
+ const err = normalize_error(e);
2407
+ if (err instanceof Redirect) {
2408
+ return action_json_redirect(err);
2409
+ }
2410
+ return action_json(
2411
+ {
2412
+ type: "error",
2413
+ error: await handle_error_and_jsonify(event, options2, check_incorrect_fail_use(err))
2414
+ },
2415
+ {
2416
+ status: get_status(err)
2417
+ }
2418
+ );
2419
+ }
2420
+ }
2421
+ function check_incorrect_fail_use(error) {
2422
+ return error instanceof ActionFailure ? new Error('Cannot "throw fail()". Use "return fail()"') : error;
2423
+ }
2424
+ function action_json_redirect(redirect) {
2425
+ return action_json({
2426
+ type: "redirect",
2427
+ status: redirect.status,
2428
+ location: redirect.location
2429
+ });
2430
+ }
2431
+ function action_json(data, init2) {
2432
+ return json(data, init2);
2433
+ }
2434
+ function is_action_request(event) {
2435
+ return event.request.method === "POST";
2436
+ }
2437
+ async function handle_action_request(event, server) {
2438
+ const actions = server?.actions;
2439
+ if (!actions) {
2440
+ event.setHeaders({
2441
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
2442
+ // "The server must generate an Allow header field in a 405 status code response"
2443
+ allow: "GET"
2444
+ });
2445
+ return {
2446
+ type: "error",
2447
+ error: new SvelteKitError(
2448
+ 405,
2449
+ "Method Not Allowed",
2450
+ `POST method not allowed. No form actions exist for ${"this page"}`
2451
+ )
2452
+ };
2453
+ }
2454
+ check_named_default_separate(actions);
2455
+ try {
2456
+ const data = await call_action(event, actions);
2457
+ if (false) ;
2458
+ if (data instanceof ActionFailure) {
2459
+ return {
2460
+ type: "failure",
2461
+ status: data.status,
2462
+ data: data.data
2463
+ };
2464
+ } else {
2465
+ return {
2466
+ type: "success",
2467
+ status: 200,
2468
+ // @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission
2469
+ data
2470
+ };
2471
+ }
2472
+ } catch (e) {
2473
+ const err = normalize_error(e);
2474
+ if (err instanceof Redirect) {
2475
+ return {
2476
+ type: "redirect",
2477
+ status: err.status,
2478
+ location: err.location
2479
+ };
2480
+ }
2481
+ return {
2482
+ type: "error",
2483
+ error: check_incorrect_fail_use(err)
2484
+ };
2485
+ }
2486
+ }
2487
+ function check_named_default_separate(actions) {
2488
+ if (actions.default && Object.keys(actions).length > 1) {
2489
+ throw new Error(
2490
+ "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"
2491
+ );
2492
+ }
2493
+ }
2494
+ async function call_action(event, actions) {
2495
+ const url = new URL(event.request.url);
2496
+ let name = "default";
2497
+ for (const param of url.searchParams) {
2498
+ if (param[0].startsWith("/")) {
2499
+ name = param[0].slice(1);
2500
+ if (name === "default") {
2501
+ throw new Error('Cannot use reserved action name "default"');
2502
+ }
2503
+ break;
2504
+ }
2505
+ }
2506
+ const action = actions[name];
2507
+ if (!action) {
2508
+ throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
2509
+ }
2510
+ if (!is_form_content_type(event.request)) {
2511
+ throw new SvelteKitError(
2512
+ 415,
2513
+ "Unsupported Media Type",
2514
+ `Form actions expect form-encoded data — received ${event.request.headers.get(
2515
+ "content-type"
2516
+ )}`
2517
+ );
2518
+ }
2519
+ return action(event);
2520
+ }
2521
+ function uneval_action_response(data, route_id, transport) {
2522
+ const replacer = (thing) => {
2523
+ for (const key2 in transport) {
2524
+ const encoded = transport[key2].encode(thing);
2525
+ if (encoded) {
2526
+ return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
2527
+ }
2528
+ }
2529
+ };
2530
+ return try_serialize(data, (value) => uneval(value, replacer), route_id);
2531
+ }
2532
+ function stringify_action_response(data, route_id, transport) {
2533
+ const encoders = Object.fromEntries(
2534
+ Object.entries(transport).map(([key2, value]) => [key2, value.encode])
2535
+ );
2536
+ return try_serialize(data, (value) => stringify(value, encoders), route_id);
2537
+ }
2538
+ function try_serialize(data, fn, route_id) {
2539
+ try {
2540
+ return fn(data);
2541
+ } catch (e) {
2542
+ const error = (
2543
+ /** @type {any} */
2544
+ e
2545
+ );
2546
+ if (data instanceof Response) {
2547
+ throw new Error(
2548
+ `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" });`
2549
+ );
2550
+ }
2551
+ if ("path" in error) {
2552
+ let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
2553
+ if (error.path !== "") message += ` (data.${error.path})`;
2554
+ throw new Error(message);
2555
+ }
2556
+ throw error;
2557
+ }
2558
+ }
2559
+ async function load_server_data({ event, state, node, parent }) {
2560
+ if (!node?.server) return null;
2561
+ let is_tracking = true;
2562
+ const uses = {
2563
+ dependencies: /* @__PURE__ */ new Set(),
2564
+ params: /* @__PURE__ */ new Set(),
2565
+ parent: false,
2566
+ route: false,
2567
+ url: false,
2568
+ search_params: /* @__PURE__ */ new Set()
2569
+ };
2570
+ const url = make_trackable(
2571
+ event.url,
2572
+ () => {
2573
+ if (is_tracking) {
2574
+ uses.url = true;
2575
+ }
2576
+ },
2577
+ (param) => {
2578
+ if (is_tracking) {
2579
+ uses.search_params.add(param);
2580
+ }
2581
+ }
2582
+ );
2583
+ if (state.prerendering) {
2584
+ disable_search(url);
2585
+ }
2586
+ const result = await node.server.load?.call(null, {
2587
+ ...event,
2588
+ fetch: (info, init2) => {
2589
+ new URL(info instanceof Request ? info.url : info, event.url);
2590
+ return event.fetch(info, init2);
2591
+ },
2592
+ /** @param {string[]} deps */
2593
+ depends: (...deps) => {
2594
+ for (const dep of deps) {
2595
+ const { href } = new URL(dep, event.url);
2596
+ uses.dependencies.add(href);
2597
+ }
2598
+ },
2599
+ params: new Proxy(event.params, {
2600
+ get: (target, key2) => {
2601
+ if (is_tracking) {
2602
+ uses.params.add(key2);
2603
+ }
2604
+ return target[
2605
+ /** @type {string} */
2606
+ key2
2607
+ ];
2608
+ }
2609
+ }),
2610
+ parent: async () => {
2611
+ if (is_tracking) {
2612
+ uses.parent = true;
2613
+ }
2614
+ return parent();
2615
+ },
2616
+ route: new Proxy(event.route, {
2617
+ get: (target, key2) => {
2618
+ if (is_tracking) {
2619
+ uses.route = true;
2620
+ }
2621
+ return target[
2622
+ /** @type {'id'} */
2623
+ key2
2624
+ ];
2625
+ }
2626
+ }),
2627
+ url,
2628
+ untrack(fn) {
2629
+ is_tracking = false;
2630
+ try {
2631
+ return fn();
2632
+ } finally {
2633
+ is_tracking = true;
2634
+ }
2635
+ }
2636
+ });
2637
+ return {
2638
+ type: "data",
2639
+ data: result ?? null,
2640
+ uses,
2641
+ slash: node.server.trailingSlash
2642
+ };
2643
+ }
2644
+ async function load_data({
2645
+ event,
2646
+ fetched,
2647
+ node,
2648
+ parent,
2649
+ server_data_promise,
2650
+ state,
2651
+ resolve_opts,
2652
+ csr
2653
+ }) {
2654
+ const server_data_node = await server_data_promise;
2655
+ if (!node?.universal?.load) {
2656
+ return server_data_node?.data ?? null;
2657
+ }
2658
+ const result = await node.universal.load.call(null, {
2659
+ url: event.url,
2660
+ params: event.params,
2661
+ data: server_data_node?.data ?? null,
2662
+ route: event.route,
2663
+ fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),
2664
+ setHeaders: event.setHeaders,
2665
+ depends: () => {
2666
+ },
2667
+ parent,
2668
+ untrack: (fn) => fn()
2669
+ });
2670
+ return result ?? null;
2671
+ }
2672
+ function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
2673
+ const universal_fetch = async (input, init2) => {
2674
+ const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
2675
+ const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init2?.headers;
2676
+ let response = await event.fetch(input, init2);
2677
+ const url = new URL(input instanceof Request ? input.url : input, event.url);
2678
+ const same_origin = url.origin === event.url.origin;
2679
+ let dependency;
2680
+ if (same_origin) {
2681
+ if (state.prerendering) {
2682
+ dependency = { response, body: null };
2683
+ state.prerendering.dependencies.set(url.pathname, dependency);
2684
+ }
2685
+ } else {
2686
+ const mode = input instanceof Request ? input.mode : init2?.mode ?? "cors";
2687
+ if (mode === "no-cors") {
2688
+ response = new Response("", {
2689
+ status: response.status,
2690
+ statusText: response.statusText,
2691
+ headers: response.headers
2692
+ });
2693
+ } else {
2694
+ const acao = response.headers.get("access-control-allow-origin");
2695
+ if (!acao || acao !== event.url.origin && acao !== "*") {
2696
+ throw new Error(
2697
+ `CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource`
2698
+ );
2699
+ }
2700
+ }
2701
+ }
2702
+ const proxy = new Proxy(response, {
2703
+ get(response2, key2, _receiver) {
2704
+ async function push_fetched(body2, is_b64) {
2705
+ const status_number = Number(response2.status);
2706
+ if (isNaN(status_number)) {
2707
+ throw new Error(
2708
+ `response.status is not a number. value: "${response2.status}" type: ${typeof response2.status}`
2709
+ );
2710
+ }
2711
+ fetched.push({
2712
+ url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
2713
+ method: event.request.method,
2714
+ request_body: (
2715
+ /** @type {string | ArrayBufferView | undefined} */
2716
+ input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init2?.body
2717
+ ),
2718
+ request_headers: cloned_headers,
2719
+ response_body: body2,
2720
+ response: response2,
2721
+ is_b64
2722
+ });
2723
+ }
2724
+ if (key2 === "arrayBuffer") {
2725
+ return async () => {
2726
+ const buffer = await response2.arrayBuffer();
2727
+ if (dependency) {
2728
+ dependency.body = new Uint8Array(buffer);
2729
+ }
2730
+ if (buffer instanceof ArrayBuffer) {
2731
+ await push_fetched(b64_encode(buffer), true);
2732
+ }
2733
+ return buffer;
2734
+ };
2735
+ }
2736
+ async function text2() {
2737
+ const body2 = await response2.text();
2738
+ if (!body2 || typeof body2 === "string") {
2739
+ await push_fetched(body2, false);
2740
+ }
2741
+ if (dependency) {
2742
+ dependency.body = body2;
2743
+ }
2744
+ return body2;
2745
+ }
2746
+ if (key2 === "text") {
2747
+ return text2;
2748
+ }
2749
+ if (key2 === "json") {
2750
+ return async () => {
2751
+ return JSON.parse(await text2());
2752
+ };
2753
+ }
2754
+ return Reflect.get(response2, key2, response2);
2755
+ }
2756
+ });
2757
+ if (csr) {
2758
+ const get = response.headers.get;
2759
+ response.headers.get = (key2) => {
2760
+ const lower = key2.toLowerCase();
2761
+ const value = get.call(response.headers, lower);
2762
+ if (value && !lower.startsWith("x-sveltekit-")) {
2763
+ const included = resolve_opts.filterSerializedResponseHeaders(lower, value);
2764
+ if (!included) {
2765
+ throw new Error(
2766
+ `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})`
2767
+ );
2768
+ }
2769
+ }
2770
+ return value;
2771
+ };
2772
+ }
2773
+ return proxy;
2774
+ };
2775
+ return (input, init2) => {
2776
+ const response = universal_fetch(input, init2);
2777
+ response.catch(() => {
2778
+ });
2779
+ return response;
2780
+ };
2781
+ }
2782
+ async function stream_to_string(stream) {
2783
+ let result = "";
2784
+ const reader = stream.getReader();
2785
+ const decoder = new TextDecoder();
2786
+ while (true) {
2787
+ const { done, value } = await reader.read();
2788
+ if (done) {
2789
+ break;
2790
+ }
2791
+ result += decoder.decode(value);
2792
+ }
2793
+ return result;
2794
+ }
2795
+ const replacements = {
2796
+ "<": "\\u003C",
2797
+ "\u2028": "\\u2028",
2798
+ "\u2029": "\\u2029"
2799
+ };
2800
+ const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
2801
+ function serialize_data(fetched, filter, prerendering2 = false) {
2802
+ const headers2 = {};
2803
+ let cache_control = null;
2804
+ let age = null;
2805
+ let varyAny = false;
2806
+ for (const [key2, value] of fetched.response.headers) {
2807
+ if (filter(key2, value)) {
2808
+ headers2[key2] = value;
2809
+ }
2810
+ if (key2 === "cache-control") cache_control = value;
2811
+ else if (key2 === "age") age = value;
2812
+ else if (key2 === "vary" && value.trim() === "*") varyAny = true;
2813
+ }
2814
+ const payload = {
2815
+ status: fetched.response.status,
2816
+ statusText: fetched.response.statusText,
2817
+ headers: headers2,
2818
+ body: fetched.response_body
2819
+ };
2820
+ const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);
2821
+ const attrs = [
2822
+ 'type="application/json"',
2823
+ "data-sveltekit-fetched",
2824
+ `data-url="${escape_html(fetched.url, true)}"`
2825
+ ];
2826
+ if (fetched.is_b64) {
2827
+ attrs.push("data-b64");
2828
+ }
2829
+ if (fetched.request_headers || fetched.request_body) {
2830
+ const values = [];
2831
+ if (fetched.request_headers) {
2832
+ values.push([...new Headers(fetched.request_headers)].join(","));
2833
+ }
2834
+ if (fetched.request_body) {
2835
+ values.push(fetched.request_body);
2836
+ }
2837
+ attrs.push(`data-hash="${hash(...values)}"`);
2838
+ }
2839
+ if (!prerendering2 && fetched.method === "GET" && cache_control && !varyAny) {
2840
+ const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
2841
+ if (match) {
2842
+ const ttl = +match[1] - +(age ?? "0");
2843
+ attrs.push(`data-ttl="${ttl}"`);
2844
+ }
2845
+ }
2846
+ return `<script ${attrs.join(" ")}>${safe_payload}<\/script>`;
2847
+ }
2848
+ const s = JSON.stringify;
2849
+ const encoder$2 = new TextEncoder();
2850
+ function sha256(data) {
2851
+ if (!key[0]) precompute();
2852
+ const out = init.slice(0);
2853
+ const array2 = encode(data);
2854
+ for (let i = 0; i < array2.length; i += 16) {
2855
+ const w = array2.subarray(i, i + 16);
2856
+ let tmp;
2857
+ let a;
2858
+ let b;
2859
+ let out0 = out[0];
2860
+ let out1 = out[1];
2861
+ let out2 = out[2];
2862
+ let out3 = out[3];
2863
+ let out4 = out[4];
2864
+ let out5 = out[5];
2865
+ let out6 = out[6];
2866
+ let out7 = out[7];
2867
+ for (let i2 = 0; i2 < 64; i2++) {
2868
+ if (i2 < 16) {
2869
+ tmp = w[i2];
2870
+ } else {
2871
+ a = w[i2 + 1 & 15];
2872
+ b = w[i2 + 14 & 15];
2873
+ tmp = w[i2 & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i2 & 15] + w[i2 + 9 & 15] | 0;
2874
+ }
2875
+ tmp = tmp + out7 + (out4 >>> 6 ^ out4 >>> 11 ^ out4 >>> 25 ^ out4 << 26 ^ out4 << 21 ^ out4 << 7) + (out6 ^ out4 & (out5 ^ out6)) + key[i2];
2876
+ out7 = out6;
2877
+ out6 = out5;
2878
+ out5 = out4;
2879
+ out4 = out3 + tmp | 0;
2880
+ out3 = out2;
2881
+ out2 = out1;
2882
+ out1 = out0;
2883
+ out0 = tmp + (out1 & out2 ^ out3 & (out1 ^ out2)) + (out1 >>> 2 ^ out1 >>> 13 ^ out1 >>> 22 ^ out1 << 30 ^ out1 << 19 ^ out1 << 10) | 0;
2884
+ }
2885
+ out[0] = out[0] + out0 | 0;
2886
+ out[1] = out[1] + out1 | 0;
2887
+ out[2] = out[2] + out2 | 0;
2888
+ out[3] = out[3] + out3 | 0;
2889
+ out[4] = out[4] + out4 | 0;
2890
+ out[5] = out[5] + out5 | 0;
2891
+ out[6] = out[6] + out6 | 0;
2892
+ out[7] = out[7] + out7 | 0;
2893
+ }
2894
+ const bytes = new Uint8Array(out.buffer);
2895
+ reverse_endianness(bytes);
2896
+ return base64(bytes);
2897
+ }
2898
+ const init = new Uint32Array(8);
2899
+ const key = new Uint32Array(64);
2900
+ function precompute() {
2901
+ function frac(x) {
2902
+ return (x - Math.floor(x)) * 4294967296;
2903
+ }
2904
+ let prime = 2;
2905
+ for (let i = 0; i < 64; prime++) {
2906
+ let is_prime = true;
2907
+ for (let factor = 2; factor * factor <= prime; factor++) {
2908
+ if (prime % factor === 0) {
2909
+ is_prime = false;
2910
+ break;
2911
+ }
2912
+ }
2913
+ if (is_prime) {
2914
+ if (i < 8) {
2915
+ init[i] = frac(prime ** (1 / 2));
2916
+ }
2917
+ key[i] = frac(prime ** (1 / 3));
2918
+ i++;
2919
+ }
2920
+ }
2921
+ }
2922
+ function reverse_endianness(bytes) {
2923
+ for (let i = 0; i < bytes.length; i += 4) {
2924
+ const a = bytes[i + 0];
2925
+ const b = bytes[i + 1];
2926
+ const c = bytes[i + 2];
2927
+ const d = bytes[i + 3];
2928
+ bytes[i + 0] = d;
2929
+ bytes[i + 1] = c;
2930
+ bytes[i + 2] = b;
2931
+ bytes[i + 3] = a;
2932
+ }
2933
+ }
2934
+ function encode(str) {
2935
+ const encoded = encoder$2.encode(str);
2936
+ const length = encoded.length * 8;
2937
+ const size = 512 * Math.ceil((length + 65) / 512);
2938
+ const bytes = new Uint8Array(size / 8);
2939
+ bytes.set(encoded);
2940
+ bytes[encoded.length] = 128;
2941
+ reverse_endianness(bytes);
2942
+ const words = new Uint32Array(bytes.buffer);
2943
+ words[words.length - 2] = Math.floor(length / 4294967296);
2944
+ words[words.length - 1] = length;
2945
+ return words;
2946
+ }
2947
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
2948
+ function base64(bytes) {
2949
+ const l = bytes.length;
2950
+ let result = "";
2951
+ let i;
2952
+ for (i = 2; i < l; i += 3) {
2953
+ result += chars[bytes[i - 2] >> 2];
2954
+ result += chars[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
2955
+ result += chars[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
2956
+ result += chars[bytes[i] & 63];
2957
+ }
2958
+ if (i === l + 1) {
2959
+ result += chars[bytes[i - 2] >> 2];
2960
+ result += chars[(bytes[i - 2] & 3) << 4];
2961
+ result += "==";
2962
+ }
2963
+ if (i === l) {
2964
+ result += chars[bytes[i - 2] >> 2];
2965
+ result += chars[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
2966
+ result += chars[(bytes[i - 1] & 15) << 2];
2967
+ result += "=";
2968
+ }
2969
+ return result;
2970
+ }
2971
+ const array = new Uint8Array(16);
2972
+ function generate_nonce() {
2973
+ crypto.getRandomValues(array);
2974
+ return base64(array);
2975
+ }
2976
+ const quoted = /* @__PURE__ */ new Set([
2977
+ "self",
2978
+ "unsafe-eval",
2979
+ "unsafe-hashes",
2980
+ "unsafe-inline",
2981
+ "none",
2982
+ "strict-dynamic",
2983
+ "report-sample",
2984
+ "wasm-unsafe-eval",
2985
+ "script"
2986
+ ]);
2987
+ const crypto_pattern = /^(nonce|sha\d\d\d)-/;
2988
+ class BaseProvider {
2989
+ /** @type {boolean} */
2990
+ #use_hashes;
2991
+ /** @type {boolean} */
2992
+ #script_needs_csp;
2993
+ /** @type {boolean} */
2994
+ #script_src_needs_csp;
2995
+ /** @type {boolean} */
2996
+ #script_src_elem_needs_csp;
2997
+ /** @type {boolean} */
2998
+ #style_needs_csp;
2999
+ /** @type {boolean} */
3000
+ #style_src_needs_csp;
3001
+ /** @type {boolean} */
3002
+ #style_src_attr_needs_csp;
3003
+ /** @type {boolean} */
3004
+ #style_src_elem_needs_csp;
3005
+ /** @type {import('types').CspDirectives} */
3006
+ #directives;
3007
+ /** @type {import('types').Csp.Source[]} */
3008
+ #script_src;
3009
+ /** @type {import('types').Csp.Source[]} */
3010
+ #script_src_elem;
3011
+ /** @type {import('types').Csp.Source[]} */
3012
+ #style_src;
3013
+ /** @type {import('types').Csp.Source[]} */
3014
+ #style_src_attr;
3015
+ /** @type {import('types').Csp.Source[]} */
3016
+ #style_src_elem;
3017
+ /** @type {string} */
3018
+ #nonce;
3019
+ /**
3020
+ * @param {boolean} use_hashes
3021
+ * @param {import('types').CspDirectives} directives
3022
+ * @param {string} nonce
3023
+ */
3024
+ constructor(use_hashes, directives, nonce) {
3025
+ this.#use_hashes = use_hashes;
3026
+ this.#directives = directives;
3027
+ const d = this.#directives;
3028
+ this.#script_src = [];
3029
+ this.#script_src_elem = [];
3030
+ this.#style_src = [];
3031
+ this.#style_src_attr = [];
3032
+ this.#style_src_elem = [];
3033
+ const effective_script_src = d["script-src"] || d["default-src"];
3034
+ const script_src_elem = d["script-src-elem"];
3035
+ const effective_style_src = d["style-src"] || d["default-src"];
3036
+ const style_src_attr = d["style-src-attr"];
3037
+ const style_src_elem = d["style-src-elem"];
3038
+ const needs_csp = (directive) => !!directive && !directive.some((value) => value === "unsafe-inline");
3039
+ this.#script_src_needs_csp = needs_csp(effective_script_src);
3040
+ this.#script_src_elem_needs_csp = needs_csp(script_src_elem);
3041
+ this.#style_src_needs_csp = needs_csp(effective_style_src);
3042
+ this.#style_src_attr_needs_csp = needs_csp(style_src_attr);
3043
+ this.#style_src_elem_needs_csp = needs_csp(style_src_elem);
3044
+ this.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;
3045
+ this.#style_needs_csp = this.#style_src_needs_csp || this.#style_src_attr_needs_csp || this.#style_src_elem_needs_csp;
3046
+ this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
3047
+ this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
3048
+ this.#nonce = nonce;
3049
+ }
3050
+ /** @param {string} content */
3051
+ add_script(content) {
3052
+ if (!this.#script_needs_csp) return;
3053
+ const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
3054
+ if (this.#script_src_needs_csp) {
3055
+ this.#script_src.push(source);
3056
+ }
3057
+ if (this.#script_src_elem_needs_csp) {
3058
+ this.#script_src_elem.push(source);
3059
+ }
3060
+ }
3061
+ /** @param {string} content */
3062
+ add_style(content) {
3063
+ if (!this.#style_needs_csp) return;
3064
+ const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
3065
+ if (this.#style_src_needs_csp) {
3066
+ this.#style_src.push(source);
3067
+ }
3068
+ if (this.#style_src_attr_needs_csp) {
3069
+ this.#style_src_attr.push(source);
3070
+ }
3071
+ if (this.#style_src_elem_needs_csp) {
3072
+ const sha256_empty_comment_hash = "sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=";
3073
+ const d = this.#directives;
3074
+ if (d["style-src-elem"] && !d["style-src-elem"].includes(sha256_empty_comment_hash) && !this.#style_src_elem.includes(sha256_empty_comment_hash)) {
3075
+ this.#style_src_elem.push(sha256_empty_comment_hash);
3076
+ }
3077
+ if (source !== sha256_empty_comment_hash) {
3078
+ this.#style_src_elem.push(source);
3079
+ }
3080
+ }
3081
+ }
3082
+ /**
3083
+ * @param {boolean} [is_meta]
3084
+ */
3085
+ get_header(is_meta = false) {
3086
+ const header = [];
3087
+ const directives = { ...this.#directives };
3088
+ if (this.#style_src.length > 0) {
3089
+ directives["style-src"] = [
3090
+ ...directives["style-src"] || directives["default-src"] || [],
3091
+ ...this.#style_src
3092
+ ];
3093
+ }
3094
+ if (this.#style_src_attr.length > 0) {
3095
+ directives["style-src-attr"] = [
3096
+ ...directives["style-src-attr"] || [],
3097
+ ...this.#style_src_attr
3098
+ ];
3099
+ }
3100
+ if (this.#style_src_elem.length > 0) {
3101
+ directives["style-src-elem"] = [
3102
+ ...directives["style-src-elem"] || [],
3103
+ ...this.#style_src_elem
3104
+ ];
3105
+ }
3106
+ if (this.#script_src.length > 0) {
3107
+ directives["script-src"] = [
3108
+ ...directives["script-src"] || directives["default-src"] || [],
3109
+ ...this.#script_src
3110
+ ];
3111
+ }
3112
+ if (this.#script_src_elem.length > 0) {
3113
+ directives["script-src-elem"] = [
3114
+ ...directives["script-src-elem"] || [],
3115
+ ...this.#script_src_elem
3116
+ ];
3117
+ }
3118
+ for (const key2 in directives) {
3119
+ if (is_meta && (key2 === "frame-ancestors" || key2 === "report-uri" || key2 === "sandbox")) {
3120
+ continue;
3121
+ }
3122
+ const value = (
3123
+ /** @type {string[] | true} */
3124
+ directives[key2]
3125
+ );
3126
+ if (!value) continue;
3127
+ const directive = [key2];
3128
+ if (Array.isArray(value)) {
3129
+ value.forEach((value2) => {
3130
+ if (quoted.has(value2) || crypto_pattern.test(value2)) {
3131
+ directive.push(`'${value2}'`);
3132
+ } else {
3133
+ directive.push(value2);
3134
+ }
3135
+ });
3136
+ }
3137
+ header.push(directive.join(" "));
3138
+ }
3139
+ return header.join("; ");
3140
+ }
3141
+ }
3142
+ class CspProvider extends BaseProvider {
3143
+ get_meta() {
3144
+ const content = this.get_header(true);
3145
+ if (!content) {
3146
+ return;
3147
+ }
3148
+ return `<meta http-equiv="content-security-policy" content="${escape_html(content, true)}">`;
3149
+ }
3150
+ }
3151
+ class CspReportOnlyProvider extends BaseProvider {
3152
+ /**
3153
+ * @param {boolean} use_hashes
3154
+ * @param {import('types').CspDirectives} directives
3155
+ * @param {string} nonce
3156
+ */
3157
+ constructor(use_hashes, directives, nonce) {
3158
+ super(use_hashes, directives, nonce);
3159
+ if (Object.values(directives).filter((v) => !!v).length > 0) {
3160
+ const has_report_to = directives["report-to"]?.length ?? 0 > 0;
3161
+ const has_report_uri = directives["report-uri"]?.length ?? 0 > 0;
3162
+ if (!has_report_to && !has_report_uri) {
3163
+ throw Error(
3164
+ "`content-security-policy-report-only` must be specified with either the `report-to` or `report-uri` directives, or both"
3165
+ );
3166
+ }
3167
+ }
3168
+ }
3169
+ }
3170
+ class Csp {
3171
+ /** @readonly */
3172
+ nonce = generate_nonce();
3173
+ /** @type {CspProvider} */
3174
+ csp_provider;
3175
+ /** @type {CspReportOnlyProvider} */
3176
+ report_only_provider;
3177
+ /**
3178
+ * @param {import('./types.js').CspConfig} config
3179
+ * @param {import('./types.js').CspOpts} opts
3180
+ */
3181
+ constructor({ mode, directives, reportOnly }, { prerender }) {
3182
+ const use_hashes = mode === "hash" || mode === "auto" && prerender;
3183
+ this.csp_provider = new CspProvider(use_hashes, directives, this.nonce);
3184
+ this.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);
3185
+ }
3186
+ get script_needs_nonce() {
3187
+ return this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;
3188
+ }
3189
+ get style_needs_nonce() {
3190
+ return this.csp_provider.style_needs_nonce || this.report_only_provider.style_needs_nonce;
3191
+ }
3192
+ /** @param {string} content */
3193
+ add_script(content) {
3194
+ this.csp_provider.add_script(content);
3195
+ this.report_only_provider.add_script(content);
3196
+ }
3197
+ /** @param {string} content */
3198
+ add_style(content) {
3199
+ this.csp_provider.add_style(content);
3200
+ this.report_only_provider.add_style(content);
3201
+ }
3202
+ }
3203
+ function defer() {
3204
+ let fulfil;
3205
+ let reject;
3206
+ const promise = new Promise((f, r) => {
3207
+ fulfil = f;
3208
+ reject = r;
3209
+ });
3210
+ return { promise, fulfil, reject };
3211
+ }
3212
+ function create_async_iterator() {
3213
+ const deferred = [defer()];
3214
+ return {
3215
+ iterator: {
3216
+ [Symbol.asyncIterator]() {
3217
+ return {
3218
+ next: async () => {
3219
+ const next = await deferred[0].promise;
3220
+ if (!next.done) deferred.shift();
3221
+ return next;
3222
+ }
3223
+ };
3224
+ }
3225
+ },
3226
+ push: (value) => {
3227
+ deferred[deferred.length - 1].fulfil({
3228
+ value,
3229
+ done: false
3230
+ });
3231
+ deferred.push(defer());
3232
+ },
3233
+ done: () => {
3234
+ deferred[deferred.length - 1].fulfil({ done: true });
3235
+ }
3236
+ };
3237
+ }
3238
+ function generate_route_object(route, url, manifest) {
3239
+ const { errors, layouts, leaf } = route;
3240
+ const nodes = [...errors, ...layouts.map((l) => l?.[1]), leaf[1]].filter((n) => typeof n === "number").map((n) => `'${n}': () => ${create_client_import(manifest._.client.nodes?.[n], url)}`).join(",\n ");
3241
+ return [
3242
+ `{
3243
+ id: ${s(route.id)}`,
3244
+ `errors: ${s(route.errors)}`,
3245
+ `layouts: ${s(route.layouts)}`,
3246
+ `leaf: ${s(route.leaf)}`,
3247
+ `nodes: {
3248
+ ${nodes}
3249
+ }
3250
+ }`
3251
+ ].join(",\n ");
3252
+ }
3253
+ function create_client_import(import_path, url) {
3254
+ if (!import_path) return "Promise.resolve({})";
3255
+ if (import_path[0] === "/") {
3256
+ return `import('${import_path}')`;
3257
+ }
3258
+ if (assets !== "") {
3259
+ return `import('${assets}/${import_path}')`;
3260
+ }
3261
+ let path = get_relative_path(url.pathname, `${base}/${import_path}`);
3262
+ if (path[0] !== ".") path = `./${path}`;
3263
+ return `import('${path}')`;
3264
+ }
3265
+ async function resolve_route(resolved_path, url, manifest) {
3266
+ if (!manifest._.client.routes) {
3267
+ return text("Server-side route resolution disabled", { status: 400 });
3268
+ }
3269
+ let route = null;
3270
+ let params = {};
3271
+ const matchers = await manifest._.matchers();
3272
+ for (const candidate of manifest._.client.routes) {
3273
+ const match = candidate.pattern.exec(resolved_path);
3274
+ if (!match) continue;
3275
+ const matched = exec(match, candidate.params, matchers);
3276
+ if (matched) {
3277
+ route = candidate;
3278
+ params = decode_params(matched);
3279
+ break;
3280
+ }
3281
+ }
3282
+ return create_server_routing_response(route, params, url, manifest).response;
3283
+ }
3284
+ function create_server_routing_response(route, params, url, manifest) {
3285
+ const headers2 = new Headers({
3286
+ "content-type": "application/javascript; charset=utf-8"
3287
+ });
3288
+ if (route) {
3289
+ const csr_route = generate_route_object(route, url, manifest);
3290
+ const body2 = `export const route = ${csr_route}; export const params = ${JSON.stringify(params)};`;
3291
+ return { response: text(body2, { headers: headers2 }), body: body2 };
3292
+ } else {
3293
+ return { response: text("", { headers: headers2 }), body: "" };
3294
+ }
3295
+ }
3296
+ const updated = {
3297
+ ...readable(false),
3298
+ check: () => false
3299
+ };
3300
+ const encoder$1 = new TextEncoder();
3301
+ async function render_response({
3302
+ branch,
3303
+ fetched,
3304
+ options: options2,
3305
+ manifest,
3306
+ state,
3307
+ page_config,
3308
+ status,
3309
+ error = null,
3310
+ event,
3311
+ resolve_opts,
3312
+ action_result
3313
+ }) {
3314
+ if (state.prerendering) {
3315
+ if (options2.csp.mode === "nonce") {
3316
+ throw new Error('Cannot use prerendering if config.kit.csp.mode === "nonce"');
3317
+ }
3318
+ if (options2.app_template_contains_nonce) {
3319
+ throw new Error("Cannot use prerendering if page template contains %sveltekit.nonce%");
3320
+ }
3321
+ }
3322
+ const { client } = manifest._;
3323
+ const modulepreloads = new Set(client.imports);
3324
+ const stylesheets = new Set(client.stylesheets);
3325
+ const fonts = new Set(client.fonts);
3326
+ const link_header_preloads = /* @__PURE__ */ new Set();
3327
+ const inline_styles = /* @__PURE__ */ new Map();
3328
+ let rendered;
3329
+ const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
3330
+ let base$1 = base;
3331
+ let assets$1 = assets;
3332
+ let base_expression = s(base);
3333
+ {
3334
+ if (!state.prerendering?.fallback) {
3335
+ const segments = event.url.pathname.slice(base.length).split("/").slice(2);
3336
+ base$1 = segments.map(() => "..").join("/") || ".";
3337
+ base_expression = `new URL(${s(base$1)}, location).pathname.slice(0, -1)`;
3338
+ if (!assets || assets[0] === "/" && assets !== SVELTE_KIT_ASSETS) {
3339
+ assets$1 = base$1;
3340
+ }
3341
+ } else if (options2.hash_routing) {
3342
+ base_expression = "new URL('.', location).pathname.slice(0, -1)";
3343
+ }
3344
+ }
3345
+ if (page_config.ssr) {
3346
+ const props = {
3347
+ stores: {
3348
+ page: writable(null),
3349
+ navigating: writable(null),
3350
+ updated
3351
+ },
3352
+ constructors: await Promise.all(branch.map(({ node }) => node.component())),
3353
+ form: form_value
3354
+ };
3355
+ let data2 = {};
3356
+ for (let i = 0; i < branch.length; i += 1) {
3357
+ data2 = { ...data2, ...branch[i].data };
3358
+ props[`data_${i}`] = data2;
3359
+ }
3360
+ props.page = {
3361
+ error,
3362
+ params: (
3363
+ /** @type {Record<string, any>} */
3364
+ event.params
3365
+ ),
3366
+ route: event.route,
3367
+ status,
3368
+ url: event.url,
3369
+ data: data2,
3370
+ form: form_value,
3371
+ state: {}
3372
+ };
3373
+ override({ base: base$1, assets: assets$1 });
3374
+ const render_opts = {
3375
+ context: /* @__PURE__ */ new Map([
3376
+ [
3377
+ "__request__",
3378
+ {
3379
+ page: props.page
3380
+ }
3381
+ ]
3382
+ ])
3383
+ };
3384
+ {
3385
+ try {
3386
+ rendered = options2.root.render(props, render_opts);
3387
+ } finally {
3388
+ reset();
3389
+ }
3390
+ }
3391
+ for (const { node } of branch) {
3392
+ for (const url of node.imports) modulepreloads.add(url);
3393
+ for (const url of node.stylesheets) stylesheets.add(url);
3394
+ for (const url of node.fonts) fonts.add(url);
3395
+ if (node.inline_styles && !client.inline) {
3396
+ Object.entries(await node.inline_styles()).forEach(([k, v]) => inline_styles.set(k, v));
3397
+ }
3398
+ }
3399
+ } else {
3400
+ rendered = { head: "", html: "", css: { code: "", map: null } };
3401
+ }
3402
+ let head = "";
3403
+ let body2 = rendered.html;
3404
+ const csp = new Csp(options2.csp, {
3405
+ prerender: !!state.prerendering
3406
+ });
3407
+ const prefixed = (path) => {
3408
+ if (path.startsWith("/")) {
3409
+ return base + path;
3410
+ }
3411
+ return `${assets$1}/${path}`;
3412
+ };
3413
+ const style = client.inline ? client.inline?.style : Array.from(inline_styles.values()).join("\n");
3414
+ if (style) {
3415
+ const attributes = [];
3416
+ if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
3417
+ csp.add_style(style);
3418
+ head += `
3419
+ <style${attributes.join("")}>${style}</style>`;
3420
+ }
3421
+ for (const dep of stylesheets) {
3422
+ const path = prefixed(dep);
3423
+ const attributes = ['rel="stylesheet"'];
3424
+ if (inline_styles.has(dep)) {
3425
+ attributes.push("disabled", 'media="(max-width: 0)"');
3426
+ } else {
3427
+ if (resolve_opts.preload({ type: "css", path })) {
3428
+ const preload_atts = ['rel="preload"', 'as="style"'];
3429
+ link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(";")}; nopush`);
3430
+ }
3431
+ }
3432
+ head += `
3433
+ <link href="${path}" ${attributes.join(" ")}>`;
3434
+ }
3435
+ for (const dep of fonts) {
3436
+ const path = prefixed(dep);
3437
+ if (resolve_opts.preload({ type: "font", path })) {
3438
+ const ext = dep.slice(dep.lastIndexOf(".") + 1);
3439
+ const attributes = [
3440
+ 'rel="preload"',
3441
+ 'as="font"',
3442
+ `type="font/${ext}"`,
3443
+ `href="${path}"`,
3444
+ "crossorigin"
3445
+ ];
3446
+ head += `
3447
+ <link ${attributes.join(" ")}>`;
3448
+ }
3449
+ }
3450
+ const global = `__sveltekit_${options2.version_hash}`;
3451
+ const { data, chunks } = get_data(
3452
+ event,
3453
+ options2,
3454
+ branch.map((b) => b.server_data),
3455
+ csp,
3456
+ global
3457
+ );
3458
+ if (page_config.ssr && page_config.csr) {
3459
+ body2 += `
3460
+ ${fetched.map(
3461
+ (item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering)
3462
+ ).join("\n ")}`;
3463
+ }
3464
+ if (page_config.csr) {
3465
+ const route = manifest._.client.routes?.find((r) => r.id === event.route.id) ?? null;
3466
+ if (client.uses_env_dynamic_public && state.prerendering) {
3467
+ modulepreloads.add(`${app_dir}/env.js`);
3468
+ }
3469
+ if (!client.inline) {
3470
+ const included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter(
3471
+ (path) => resolve_opts.preload({ type: "js", path })
3472
+ );
3473
+ for (const path of included_modulepreloads) {
3474
+ link_header_preloads.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
3475
+ if (options2.preload_strategy !== "modulepreload") {
3476
+ head += `
3477
+ <link rel="preload" as="script" crossorigin="anonymous" href="${path}">`;
3478
+ } else if (state.prerendering) {
3479
+ head += `
3480
+ <link rel="modulepreload" href="${path}">`;
3481
+ }
3482
+ }
3483
+ }
3484
+ if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
3485
+ const pathname = add_resolution_suffix(event.url.pathname);
3486
+ state.prerendering.dependencies.set(
3487
+ pathname,
3488
+ create_server_routing_response(route, event.params, new URL(pathname, event.url), manifest)
3489
+ );
3490
+ }
3491
+ const blocks = [];
3492
+ const load_env_eagerly = client.uses_env_dynamic_public && state.prerendering;
3493
+ const properties = [`base: ${base_expression}`];
3494
+ if (assets) {
3495
+ properties.push(`assets: ${s(assets)}`);
3496
+ }
3497
+ if (client.uses_env_dynamic_public) {
3498
+ properties.push(`env: ${load_env_eagerly ? "null" : s(public_env)}`);
3499
+ }
3500
+ if (chunks) {
3501
+ blocks.push("const deferred = new Map();");
3502
+ properties.push(`defer: (id) => new Promise((fulfil, reject) => {
3503
+ deferred.set(id, { fulfil, reject });
3504
+ })`);
3505
+ properties.push(`resolve: ({ id, data, error }) => {
3506
+ const try_to_resolve = () => {
3507
+ if (!deferred.has(id)) {
3508
+ setTimeout(try_to_resolve, 0);
3509
+ return;
3510
+ }
3511
+ const { fulfil, reject } = deferred.get(id);
3512
+ deferred.delete(id);
3513
+ if (error) reject(error);
3514
+ else fulfil(data);
3515
+ }
3516
+ try_to_resolve();
3517
+ }`);
3518
+ }
3519
+ blocks.push(`${global} = {
3520
+ ${properties.join(",\n ")}
3521
+ };`);
3522
+ const args = ["element"];
3523
+ blocks.push("const element = document.currentScript.parentElement;");
3524
+ if (page_config.ssr) {
3525
+ const serialized = { form: "null", error: "null" };
3526
+ if (form_value) {
3527
+ serialized.form = uneval_action_response(
3528
+ form_value,
3529
+ /** @type {string} */
3530
+ event.route.id,
3531
+ options2.hooks.transport
3532
+ );
3533
+ }
3534
+ if (error) {
3535
+ serialized.error = uneval(error);
3536
+ }
3537
+ const hydrate = [
3538
+ `node_ids: [${branch.map(({ node }) => node.index).join(", ")}]`,
3539
+ `data: ${data}`,
3540
+ `form: ${serialized.form}`,
3541
+ `error: ${serialized.error}`
3542
+ ];
3543
+ if (status !== 200) {
3544
+ hydrate.push(`status: ${status}`);
3545
+ }
3546
+ if (manifest._.client.routes) {
3547
+ if (route) {
3548
+ const stringified = generate_route_object(route, event.url, manifest).replaceAll(
3549
+ "\n",
3550
+ "\n "
3551
+ );
3552
+ hydrate.push(`params: ${uneval(event.params)}`, `server_route: ${stringified}`);
3553
+ }
3554
+ } else if (options2.embedded) {
3555
+ hydrate.push(`params: ${uneval(event.params)}`, `route: ${s(event.route)}`);
3556
+ }
3557
+ const indent = " ".repeat(load_env_eagerly ? 7 : 6);
3558
+ args.push(`{
3559
+ ${indent} ${hydrate.join(`,
3560
+ ${indent} `)}
3561
+ ${indent}}`);
3562
+ }
3563
+ const boot = client.inline ? `${client.inline.script}
3564
+
3565
+ __sveltekit_${options2.version_hash}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
3566
+ import(${s(prefixed(client.start))}),
3567
+ import(${s(prefixed(client.app))})
3568
+ ]).then(([kit, app]) => {
3569
+ kit.start(app, ${args.join(", ")});
3570
+ });` : `import(${s(prefixed(client.start))}).then((app) => {
3571
+ app.start(${args.join(", ")})
3572
+ });`;
3573
+ if (load_env_eagerly) {
3574
+ blocks.push(`import(${s(`${base$1}/${app_dir}/env.js`)}).then(({ env }) => {
3575
+ ${global}.env = env;
3576
+
3577
+ ${boot.replace(/\n/g, "\n ")}
3578
+ });`);
3579
+ } else {
3580
+ blocks.push(boot);
3581
+ }
3582
+ if (options2.service_worker) {
3583
+ const opts = "";
3584
+ blocks.push(`if ('serviceWorker' in navigator) {
3585
+ addEventListener('load', function () {
3586
+ navigator.serviceWorker.register('${prefixed("service-worker.js")}'${opts});
3587
+ });
3588
+ }`);
3589
+ }
3590
+ const init_app = `
3591
+ {
3592
+ ${blocks.join("\n\n ")}
3593
+ }
3594
+ `;
3595
+ csp.add_script(init_app);
3596
+ body2 += `
3597
+ <script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>${init_app}<\/script>
3598
+ `;
3599
+ }
3600
+ const headers2 = new Headers({
3601
+ "x-sveltekit-page": "true",
3602
+ "content-type": "text/html"
3603
+ });
3604
+ if (state.prerendering) {
3605
+ const http_equiv = [];
3606
+ const csp_headers = csp.csp_provider.get_meta();
3607
+ if (csp_headers) {
3608
+ http_equiv.push(csp_headers);
3609
+ }
3610
+ if (state.prerendering.cache) {
3611
+ http_equiv.push(`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`);
3612
+ }
3613
+ if (http_equiv.length > 0) {
3614
+ head = http_equiv.join("\n") + head;
3615
+ }
3616
+ } else {
3617
+ const csp_header = csp.csp_provider.get_header();
3618
+ if (csp_header) {
3619
+ headers2.set("content-security-policy", csp_header);
3620
+ }
3621
+ const report_only_header = csp.report_only_provider.get_header();
3622
+ if (report_only_header) {
3623
+ headers2.set("content-security-policy-report-only", report_only_header);
3624
+ }
3625
+ if (link_header_preloads.size) {
3626
+ headers2.set("link", Array.from(link_header_preloads).join(", "));
3627
+ }
3628
+ }
3629
+ head += rendered.head;
3630
+ const html = options2.templates.app({
3631
+ head,
3632
+ body: body2,
3633
+ assets: assets$1,
3634
+ nonce: (
3635
+ /** @type {string} */
3636
+ csp.nonce
3637
+ ),
3638
+ env: safe_public_env
3639
+ });
3640
+ const transformed = await resolve_opts.transformPageChunk({
3641
+ html,
3642
+ done: true
3643
+ }) || "";
3644
+ if (!chunks) {
3645
+ headers2.set("etag", `"${hash(transformed)}"`);
3646
+ }
3647
+ return !chunks ? text(transformed, {
3648
+ status,
3649
+ headers: headers2
3650
+ }) : new Response(
3651
+ new ReadableStream({
3652
+ async start(controller) {
3653
+ controller.enqueue(encoder$1.encode(transformed + "\n"));
3654
+ for await (const chunk of chunks) {
3655
+ controller.enqueue(encoder$1.encode(chunk));
3656
+ }
3657
+ controller.close();
3658
+ },
3659
+ type: "bytes"
3660
+ }),
3661
+ {
3662
+ headers: headers2
3663
+ }
3664
+ );
3665
+ }
3666
+ function get_data(event, options2, nodes, csp, global) {
3667
+ let promise_id = 1;
3668
+ let count = 0;
3669
+ const { iterator, push, done } = create_async_iterator();
3670
+ function replacer(thing) {
3671
+ if (typeof thing?.then === "function") {
3672
+ const id = promise_id++;
3673
+ count += 1;
3674
+ thing.then(
3675
+ /** @param {any} data */
3676
+ (data) => ({ data })
3677
+ ).catch(
3678
+ /** @param {any} error */
3679
+ async (error) => ({
3680
+ error: await handle_error_and_jsonify(event, options2, error)
3681
+ })
3682
+ ).then(
3683
+ /**
3684
+ * @param {{data: any; error: any}} result
3685
+ */
3686
+ async ({ data, error }) => {
3687
+ count -= 1;
3688
+ let str;
3689
+ try {
3690
+ str = uneval({ id, data, error }, replacer);
3691
+ } catch {
3692
+ error = await handle_error_and_jsonify(
3693
+ event,
3694
+ options2,
3695
+ new Error(`Failed to serialize promise while rendering ${event.route.id}`)
3696
+ );
3697
+ data = void 0;
3698
+ str = uneval({ id, data, error }, replacer);
3699
+ }
3700
+ const nonce = csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : "";
3701
+ push(`<script${nonce}>${global}.resolve(${str})<\/script>
3702
+ `);
3703
+ if (count === 0) done();
3704
+ }
3705
+ );
3706
+ return `${global}.defer(${id})`;
3707
+ } else {
3708
+ for (const key2 in options2.hooks.transport) {
3709
+ const encoded = options2.hooks.transport[key2].encode(thing);
3710
+ if (encoded) {
3711
+ return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
3712
+ }
3713
+ }
3714
+ }
3715
+ }
3716
+ try {
3717
+ const strings = nodes.map((node) => {
3718
+ if (!node) return "null";
3719
+ return `{"type":"data","data":${uneval(node.data, replacer)},${stringify_uses(node)}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
3720
+ });
3721
+ return {
3722
+ data: `[${strings.join(",")}]`,
3723
+ chunks: count > 0 ? iterator : null
3724
+ };
3725
+ } catch (e) {
3726
+ throw new Error(clarify_devalue_error(
3727
+ event,
3728
+ /** @type {any} */
3729
+ e
3730
+ ));
3731
+ }
3732
+ }
3733
+ function get_option(nodes, option) {
3734
+ return nodes.reduce(
3735
+ (value, node) => {
3736
+ return (
3737
+ /** @type {Value} TypeScript's too dumb to understand this */
3738
+ node?.universal?.[option] ?? node?.server?.[option] ?? value
3739
+ );
3740
+ },
3741
+ /** @type {Value | undefined} */
3742
+ void 0
3743
+ );
3744
+ }
3745
+ async function respond_with_error({
3746
+ event,
3747
+ options: options2,
3748
+ manifest,
3749
+ state,
3750
+ status,
3751
+ error,
3752
+ resolve_opts
3753
+ }) {
3754
+ if (event.request.headers.get("x-sveltekit-error")) {
3755
+ return static_error_page(
3756
+ options2,
3757
+ status,
3758
+ /** @type {Error} */
3759
+ error.message
3760
+ );
3761
+ }
3762
+ const fetched = [];
3763
+ try {
3764
+ const branch = [];
3765
+ const default_layout = await manifest._.nodes[0]();
3766
+ const ssr = get_option([default_layout], "ssr") ?? true;
3767
+ const csr = get_option([default_layout], "csr") ?? true;
3768
+ if (ssr) {
3769
+ state.error = true;
3770
+ const server_data_promise = load_server_data({
3771
+ event,
3772
+ state,
3773
+ node: default_layout,
3774
+ // eslint-disable-next-line @typescript-eslint/require-await
3775
+ parent: async () => ({})
3776
+ });
3777
+ const server_data = await server_data_promise;
3778
+ const data = await load_data({
3779
+ event,
3780
+ fetched,
3781
+ node: default_layout,
3782
+ // eslint-disable-next-line @typescript-eslint/require-await
3783
+ parent: async () => ({}),
3784
+ resolve_opts,
3785
+ server_data_promise,
3786
+ state,
3787
+ csr
3788
+ });
3789
+ branch.push(
3790
+ {
3791
+ node: default_layout,
3792
+ server_data,
3793
+ data
3794
+ },
3795
+ {
3796
+ node: await manifest._.nodes[1](),
3797
+ // 1 is always the root error
3798
+ data: null,
3799
+ server_data: null
3800
+ }
3801
+ );
3802
+ }
3803
+ return await render_response({
3804
+ options: options2,
3805
+ manifest,
3806
+ state,
3807
+ page_config: {
3808
+ ssr,
3809
+ csr
3810
+ },
3811
+ status,
3812
+ error: await handle_error_and_jsonify(event, options2, error),
3813
+ branch,
3814
+ fetched,
3815
+ event,
3816
+ resolve_opts
3817
+ });
3818
+ } catch (e) {
3819
+ if (e instanceof Redirect) {
3820
+ return redirect_response(e.status, e.location);
3821
+ }
3822
+ return static_error_page(
3823
+ options2,
3824
+ get_status(e),
3825
+ (await handle_error_and_jsonify(event, options2, e)).message
3826
+ );
3827
+ }
3828
+ }
3829
+ function once(fn) {
3830
+ let done = false;
3831
+ let result;
3832
+ return () => {
3833
+ if (done) return result;
3834
+ done = true;
3835
+ return result = fn();
3836
+ };
3837
+ }
3838
+ const encoder = new TextEncoder();
3839
+ async function render_data(event, route, options2, manifest, state, invalidated_data_nodes, trailing_slash) {
3840
+ if (!route.page) {
3841
+ return new Response(void 0, {
3842
+ status: 404
3843
+ });
3844
+ }
3845
+ try {
3846
+ const node_ids = [...route.page.layouts, route.page.leaf];
3847
+ const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
3848
+ let aborted = false;
3849
+ const url = new URL(event.url);
3850
+ url.pathname = normalize_path(url.pathname, trailing_slash);
3851
+ const new_event = { ...event, url };
3852
+ const functions = node_ids.map((n, i) => {
3853
+ return once(async () => {
3854
+ try {
3855
+ if (aborted) {
3856
+ return (
3857
+ /** @type {import('types').ServerDataSkippedNode} */
3858
+ {
3859
+ type: "skip"
3860
+ }
3861
+ );
3862
+ }
3863
+ const node = n == void 0 ? n : await manifest._.nodes[n]();
3864
+ return load_server_data({
3865
+ event: new_event,
3866
+ state,
3867
+ node,
3868
+ parent: async () => {
3869
+ const data2 = {};
3870
+ for (let j = 0; j < i; j += 1) {
3871
+ const parent = (
3872
+ /** @type {import('types').ServerDataNode | null} */
3873
+ await functions[j]()
3874
+ );
3875
+ if (parent) {
3876
+ Object.assign(data2, parent.data);
3877
+ }
3878
+ }
3879
+ return data2;
3880
+ }
3881
+ });
3882
+ } catch (e) {
3883
+ aborted = true;
3884
+ throw e;
3885
+ }
3886
+ });
3887
+ });
3888
+ const promises = functions.map(async (fn, i) => {
3889
+ if (!invalidated[i]) {
3890
+ return (
3891
+ /** @type {import('types').ServerDataSkippedNode} */
3892
+ {
3893
+ type: "skip"
3894
+ }
3895
+ );
3896
+ }
3897
+ return fn();
3898
+ });
3899
+ let length = promises.length;
3900
+ const nodes = await Promise.all(
3901
+ promises.map(
3902
+ (p, i) => p.catch(async (error) => {
3903
+ if (error instanceof Redirect) {
3904
+ throw error;
3905
+ }
3906
+ length = Math.min(length, i + 1);
3907
+ return (
3908
+ /** @type {import('types').ServerErrorNode} */
3909
+ {
3910
+ type: "error",
3911
+ error: await handle_error_and_jsonify(event, options2, error),
3912
+ status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : void 0
3913
+ }
3914
+ );
3915
+ })
3916
+ )
3917
+ );
3918
+ const { data, chunks } = get_data_json(event, options2, nodes);
3919
+ if (!chunks) {
3920
+ return json_response(data);
3921
+ }
3922
+ return new Response(
3923
+ new ReadableStream({
3924
+ async start(controller) {
3925
+ controller.enqueue(encoder.encode(data));
3926
+ for await (const chunk of chunks) {
3927
+ controller.enqueue(encoder.encode(chunk));
3928
+ }
3929
+ controller.close();
3930
+ },
3931
+ type: "bytes"
3932
+ }),
3933
+ {
3934
+ headers: {
3935
+ // we use a proprietary content type to prevent buffering.
3936
+ // the `text` prefix makes it inspectable
3937
+ "content-type": "text/sveltekit-data",
3938
+ "cache-control": "private, no-store"
3939
+ }
3940
+ }
3941
+ );
3942
+ } catch (e) {
3943
+ const error = normalize_error(e);
3944
+ if (error instanceof Redirect) {
3945
+ return redirect_json_response(error);
3946
+ } else {
3947
+ return json_response(await handle_error_and_jsonify(event, options2, error), 500);
3948
+ }
3949
+ }
3950
+ }
3951
+ function json_response(json2, status = 200) {
3952
+ return text(typeof json2 === "string" ? json2 : JSON.stringify(json2), {
3953
+ status,
3954
+ headers: {
3955
+ "content-type": "application/json",
3956
+ "cache-control": "private, no-store"
3957
+ }
3958
+ });
3959
+ }
3960
+ function redirect_json_response(redirect) {
3961
+ return json_response({
3962
+ type: "redirect",
3963
+ location: redirect.location
3964
+ });
3965
+ }
3966
+ function get_data_json(event, options2, nodes) {
3967
+ let promise_id = 1;
3968
+ let count = 0;
3969
+ const { iterator, push, done } = create_async_iterator();
3970
+ const reducers = {
3971
+ ...Object.fromEntries(
3972
+ Object.entries(options2.hooks.transport).map(([key2, value]) => [key2, value.encode])
3973
+ ),
3974
+ /** @param {any} thing */
3975
+ Promise: (thing) => {
3976
+ if (typeof thing?.then === "function") {
3977
+ const id = promise_id++;
3978
+ count += 1;
3979
+ let key2 = "data";
3980
+ thing.catch(
3981
+ /** @param {any} e */
3982
+ async (e) => {
3983
+ key2 = "error";
3984
+ return handle_error_and_jsonify(
3985
+ event,
3986
+ options2,
3987
+ /** @type {any} */
3988
+ e
3989
+ );
3990
+ }
3991
+ ).then(
3992
+ /** @param {any} value */
3993
+ async (value) => {
3994
+ let str;
3995
+ try {
3996
+ str = stringify(value, reducers);
3997
+ } catch {
3998
+ const error = await handle_error_and_jsonify(
3999
+ event,
4000
+ options2,
4001
+ new Error(`Failed to serialize promise while rendering ${event.route.id}`)
4002
+ );
4003
+ key2 = "error";
4004
+ str = stringify(error, reducers);
4005
+ }
4006
+ count -= 1;
4007
+ push(`{"type":"chunk","id":${id},"${key2}":${str}}
4008
+ `);
4009
+ if (count === 0) done();
4010
+ }
4011
+ );
4012
+ return id;
4013
+ }
4014
+ }
4015
+ };
4016
+ try {
4017
+ const strings = nodes.map((node) => {
4018
+ if (!node) return "null";
4019
+ if (node.type === "error" || node.type === "skip") {
4020
+ return JSON.stringify(node);
4021
+ }
4022
+ return `{"type":"data","data":${stringify(node.data, reducers)},${stringify_uses(
4023
+ node
4024
+ )}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
4025
+ });
4026
+ return {
4027
+ data: `{"type":"data","nodes":[${strings.join(",")}]}
4028
+ `,
4029
+ chunks: count > 0 ? iterator : null
4030
+ };
4031
+ } catch (e) {
4032
+ throw new Error(clarify_devalue_error(
4033
+ event,
4034
+ /** @type {any} */
4035
+ e
4036
+ ));
4037
+ }
4038
+ }
4039
+ function load_page_nodes(page, manifest) {
4040
+ return Promise.all([
4041
+ // we use == here rather than === because [undefined] serializes as "[null]"
4042
+ ...page.layouts.map((n) => n == void 0 ? n : manifest._.nodes[n]()),
4043
+ manifest._.nodes[page.leaf]()
4044
+ ]);
4045
+ }
4046
+ const MAX_DEPTH = 10;
4047
+ async function render_page(event, page, options2, manifest, state, resolve_opts) {
4048
+ if (state.depth > MAX_DEPTH) {
4049
+ return text(`Not found: ${event.url.pathname}`, {
4050
+ status: 404
4051
+ // TODO in some cases this should be 500. not sure how to differentiate
4052
+ });
4053
+ }
4054
+ if (is_action_json_request(event)) {
4055
+ const node = await manifest._.nodes[page.leaf]();
4056
+ return handle_action_json_request(event, options2, node?.server);
4057
+ }
4058
+ try {
4059
+ const nodes = await load_page_nodes(page, manifest);
4060
+ const leaf_node = (
4061
+ /** @type {import('types').SSRNode} */
4062
+ nodes.at(-1)
4063
+ );
4064
+ let status = 200;
4065
+ let action_result = void 0;
4066
+ if (is_action_request(event)) {
4067
+ action_result = await handle_action_request(event, leaf_node.server);
4068
+ if (action_result?.type === "redirect") {
4069
+ return redirect_response(action_result.status, action_result.location);
4070
+ }
4071
+ if (action_result?.type === "error") {
4072
+ status = get_status(action_result.error);
4073
+ }
4074
+ if (action_result?.type === "failure") {
4075
+ status = action_result.status;
4076
+ }
4077
+ }
4078
+ const should_prerender_data = nodes.some(
4079
+ // prerender in case of trailingSlash because the client retrieves that value from the server
4080
+ (node) => node?.server?.load || node?.server?.trailingSlash !== void 0
4081
+ );
4082
+ const data_pathname = add_data_suffix(event.url.pathname);
4083
+ const should_prerender = get_option(nodes, "prerender") ?? false;
4084
+ if (should_prerender) {
4085
+ const mod = leaf_node.server;
4086
+ if (mod?.actions) {
4087
+ throw new Error("Cannot prerender pages with actions");
4088
+ }
4089
+ } else if (state.prerendering) {
4090
+ return new Response(void 0, {
4091
+ status: 204
4092
+ });
4093
+ }
4094
+ state.prerender_default = should_prerender;
4095
+ const fetched = [];
4096
+ if (get_option(nodes, "ssr") === false && !(state.prerendering && should_prerender_data)) {
4097
+ if (DEV && action_result && !event.request.headers.has("x-sveltekit-action")) ;
4098
+ return await render_response({
4099
+ branch: [],
4100
+ fetched,
4101
+ page_config: {
4102
+ ssr: false,
4103
+ csr: get_option(nodes, "csr") ?? true
4104
+ },
4105
+ status,
4106
+ error: null,
4107
+ event,
4108
+ options: options2,
4109
+ manifest,
4110
+ state,
4111
+ resolve_opts
4112
+ });
4113
+ }
4114
+ const branch = [];
4115
+ let load_error = null;
4116
+ const server_promises = nodes.map((node, i) => {
4117
+ if (load_error) {
4118
+ throw load_error;
4119
+ }
4120
+ return Promise.resolve().then(async () => {
4121
+ try {
4122
+ if (node === leaf_node && action_result?.type === "error") {
4123
+ throw action_result.error;
4124
+ }
4125
+ return await load_server_data({
4126
+ event,
4127
+ state,
4128
+ node,
4129
+ parent: async () => {
4130
+ const data = {};
4131
+ for (let j = 0; j < i; j += 1) {
4132
+ const parent = await server_promises[j];
4133
+ if (parent) Object.assign(data, parent.data);
4134
+ }
4135
+ return data;
4136
+ }
4137
+ });
4138
+ } catch (e) {
4139
+ load_error = /** @type {Error} */
4140
+ e;
4141
+ throw load_error;
4142
+ }
4143
+ });
4144
+ });
4145
+ const csr = get_option(nodes, "csr") ?? true;
4146
+ const load_promises = nodes.map((node, i) => {
4147
+ if (load_error) throw load_error;
4148
+ return Promise.resolve().then(async () => {
4149
+ try {
4150
+ return await load_data({
4151
+ event,
4152
+ fetched,
4153
+ node,
4154
+ parent: async () => {
4155
+ const data = {};
4156
+ for (let j = 0; j < i; j += 1) {
4157
+ Object.assign(data, await load_promises[j]);
4158
+ }
4159
+ return data;
4160
+ },
4161
+ resolve_opts,
4162
+ server_data_promise: server_promises[i],
4163
+ state,
4164
+ csr
4165
+ });
4166
+ } catch (e) {
4167
+ load_error = /** @type {Error} */
4168
+ e;
4169
+ throw load_error;
4170
+ }
4171
+ });
4172
+ });
4173
+ for (const p of server_promises) p.catch(() => {
4174
+ });
4175
+ for (const p of load_promises) p.catch(() => {
4176
+ });
4177
+ for (let i = 0; i < nodes.length; i += 1) {
4178
+ const node = nodes[i];
4179
+ if (node) {
4180
+ try {
4181
+ const server_data = await server_promises[i];
4182
+ const data = await load_promises[i];
4183
+ branch.push({ node, server_data, data });
4184
+ } catch (e) {
4185
+ const err = normalize_error(e);
4186
+ if (err instanceof Redirect) {
4187
+ if (state.prerendering && should_prerender_data) {
4188
+ const body2 = JSON.stringify({
4189
+ type: "redirect",
4190
+ location: err.location
4191
+ });
4192
+ state.prerendering.dependencies.set(data_pathname, {
4193
+ response: text(body2),
4194
+ body: body2
4195
+ });
4196
+ }
4197
+ return redirect_response(err.status, err.location);
4198
+ }
4199
+ const status2 = get_status(err);
4200
+ const error = await handle_error_and_jsonify(event, options2, err);
4201
+ while (i--) {
4202
+ if (page.errors[i]) {
4203
+ const index = (
4204
+ /** @type {number} */
4205
+ page.errors[i]
4206
+ );
4207
+ const node2 = await manifest._.nodes[index]();
4208
+ let j = i;
4209
+ while (!branch[j]) j -= 1;
4210
+ return await render_response({
4211
+ event,
4212
+ options: options2,
4213
+ manifest,
4214
+ state,
4215
+ resolve_opts,
4216
+ page_config: { ssr: true, csr: true },
4217
+ status: status2,
4218
+ error,
4219
+ branch: compact(branch.slice(0, j + 1)).concat({
4220
+ node: node2,
4221
+ data: null,
4222
+ server_data: null
4223
+ }),
4224
+ fetched
4225
+ });
4226
+ }
4227
+ }
4228
+ return static_error_page(options2, status2, error.message);
4229
+ }
4230
+ } else {
4231
+ branch.push(null);
4232
+ }
4233
+ }
4234
+ if (state.prerendering && should_prerender_data) {
4235
+ let { data, chunks } = get_data_json(
4236
+ event,
4237
+ options2,
4238
+ branch.map((node) => node?.server_data)
4239
+ );
4240
+ if (chunks) {
4241
+ for await (const chunk of chunks) {
4242
+ data += chunk;
4243
+ }
4244
+ }
4245
+ state.prerendering.dependencies.set(data_pathname, {
4246
+ response: text(data),
4247
+ body: data
4248
+ });
4249
+ }
4250
+ const ssr = get_option(nodes, "ssr") ?? true;
4251
+ return await render_response({
4252
+ event,
4253
+ options: options2,
4254
+ manifest,
4255
+ state,
4256
+ resolve_opts,
4257
+ page_config: {
4258
+ csr: get_option(nodes, "csr") ?? true,
4259
+ ssr
4260
+ },
4261
+ status,
4262
+ error: null,
4263
+ branch: ssr === false ? [] : compact(branch),
4264
+ action_result,
4265
+ fetched
4266
+ });
4267
+ } catch (e) {
4268
+ return await respond_with_error({
4269
+ event,
4270
+ options: options2,
4271
+ manifest,
4272
+ state,
4273
+ status: 500,
4274
+ error: e,
4275
+ resolve_opts
4276
+ });
4277
+ }
4278
+ }
4279
+ const INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
4280
+ function validate_options(options2) {
4281
+ if (options2?.path === void 0) {
4282
+ throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
4283
+ }
4284
+ }
4285
+ function get_cookies(request, url, trailing_slash) {
4286
+ const header = request.headers.get("cookie") ?? "";
4287
+ const initial_cookies = cookieExports.parse(header, { decode: (value) => value });
4288
+ const normalized_url = normalize_path(url.pathname, trailing_slash);
4289
+ const new_cookies = {};
4290
+ const defaults = {
4291
+ httpOnly: true,
4292
+ sameSite: "lax",
4293
+ secure: url.hostname === "localhost" && url.protocol === "http:" ? false : true
4294
+ };
4295
+ const cookies = {
4296
+ // The JSDoc param annotations appearing below for get, set and delete
4297
+ // are necessary to expose the `cookie` library types to
4298
+ // typescript users. `@type {import('@sveltejs/kit').Cookies}` above is not
4299
+ // sufficient to do so.
4300
+ /**
4301
+ * @param {string} name
4302
+ * @param {import('cookie').CookieParseOptions} [opts]
4303
+ */
4304
+ get(name, opts) {
4305
+ const c = new_cookies[name];
4306
+ if (c && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
4307
+ return c.value;
4308
+ }
4309
+ const req_cookies = cookieExports.parse(header, { decode: opts?.decode });
4310
+ const cookie = req_cookies[name];
4311
+ return cookie;
4312
+ },
4313
+ /**
4314
+ * @param {import('cookie').CookieParseOptions} [opts]
4315
+ */
4316
+ getAll(opts) {
4317
+ const cookies2 = cookieExports.parse(header, { decode: opts?.decode });
4318
+ for (const c of Object.values(new_cookies)) {
4319
+ if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
4320
+ cookies2[c.name] = c.value;
4321
+ }
4322
+ }
4323
+ return Object.entries(cookies2).map(([name, value]) => ({ name, value }));
4324
+ },
4325
+ /**
4326
+ * @param {string} name
4327
+ * @param {string} value
4328
+ * @param {import('./page/types.js').Cookie['options']} options
4329
+ */
4330
+ set(name, value, options2) {
4331
+ const illegal_characters = name.match(INVALID_COOKIE_CHARACTER_REGEX);
4332
+ if (illegal_characters) {
4333
+ console.warn(
4334
+ `The cookie name "${name}" will be invalid in SvelteKit 3.0 as it contains ${illegal_characters.join(
4335
+ " and "
4336
+ )}. See RFC 2616 for more details https://datatracker.ietf.org/doc/html/rfc2616#section-2.2`
4337
+ );
4338
+ }
4339
+ validate_options(options2);
4340
+ set_internal(name, value, { ...defaults, ...options2 });
4341
+ },
4342
+ /**
4343
+ * @param {string} name
4344
+ * @param {import('./page/types.js').Cookie['options']} options
4345
+ */
4346
+ delete(name, options2) {
4347
+ validate_options(options2);
4348
+ cookies.set(name, "", { ...options2, maxAge: 0 });
4349
+ },
4350
+ /**
4351
+ * @param {string} name
4352
+ * @param {string} value
4353
+ * @param {import('./page/types.js').Cookie['options']} options
4354
+ */
4355
+ serialize(name, value, options2) {
4356
+ validate_options(options2);
4357
+ let path = options2.path;
4358
+ if (!options2.domain || options2.domain === url.hostname) {
4359
+ path = resolve(normalized_url, path);
4360
+ }
4361
+ return cookieExports.serialize(name, value, { ...defaults, ...options2, path });
4362
+ }
4363
+ };
4364
+ function get_cookie_header(destination, header2) {
4365
+ const combined_cookies = {
4366
+ // cookies sent by the user agent have lowest precedence
4367
+ ...initial_cookies
4368
+ };
4369
+ for (const key2 in new_cookies) {
4370
+ const cookie = new_cookies[key2];
4371
+ if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
4372
+ if (!path_matches(destination.pathname, cookie.options.path)) continue;
4373
+ const encoder2 = cookie.options.encode || encodeURIComponent;
4374
+ combined_cookies[cookie.name] = encoder2(cookie.value);
4375
+ }
4376
+ if (header2) {
4377
+ const parsed = cookieExports.parse(header2, { decode: (value) => value });
4378
+ for (const name in parsed) {
4379
+ combined_cookies[name] = parsed[name];
4380
+ }
4381
+ }
4382
+ return Object.entries(combined_cookies).map(([name, value]) => `${name}=${value}`).join("; ");
4383
+ }
4384
+ function set_internal(name, value, options2) {
4385
+ let path = options2.path;
4386
+ if (!options2.domain || options2.domain === url.hostname) {
4387
+ path = resolve(normalized_url, path);
4388
+ }
4389
+ new_cookies[name] = { name, value, options: { ...options2, path } };
4390
+ }
4391
+ return { cookies, new_cookies, get_cookie_header, set_internal };
4392
+ }
4393
+ function domain_matches(hostname, constraint) {
4394
+ if (!constraint) return true;
4395
+ const normalized = constraint[0] === "." ? constraint.slice(1) : constraint;
4396
+ if (hostname === normalized) return true;
4397
+ return hostname.endsWith("." + normalized);
4398
+ }
4399
+ function path_matches(path, constraint) {
4400
+ if (!constraint) return true;
4401
+ const normalized = constraint.endsWith("/") ? constraint.slice(0, -1) : constraint;
4402
+ if (path === normalized) return true;
4403
+ return path.startsWith(normalized + "/");
4404
+ }
4405
+ function add_cookies_to_headers(headers2, cookies) {
4406
+ for (const new_cookie of cookies) {
4407
+ const { name, value, options: options2 } = new_cookie;
4408
+ headers2.append("set-cookie", cookieExports.serialize(name, value, options2));
4409
+ if (options2.path.endsWith(".html")) {
4410
+ const path = add_data_suffix(options2.path);
4411
+ headers2.append("set-cookie", cookieExports.serialize(name, value, { ...options2, path }));
4412
+ }
4413
+ }
4414
+ }
4415
+ function create_fetch({ event, options: options2, manifest, state, get_cookie_header, set_internal }) {
4416
+ const server_fetch = async (info, init2) => {
4417
+ const original_request = normalize_fetch_input(info, init2, event.url);
4418
+ let mode = (info instanceof Request ? info.mode : init2?.mode) ?? "cors";
4419
+ let credentials = (info instanceof Request ? info.credentials : init2?.credentials) ?? "same-origin";
4420
+ return options2.hooks.handleFetch({
4421
+ event,
4422
+ request: original_request,
4423
+ fetch: async (info2, init3) => {
4424
+ const request = normalize_fetch_input(info2, init3, event.url);
4425
+ const url = new URL(request.url);
4426
+ if (!request.headers.has("origin")) {
4427
+ request.headers.set("origin", event.url.origin);
4428
+ }
4429
+ if (info2 !== original_request) {
4430
+ mode = (info2 instanceof Request ? info2.mode : init3?.mode) ?? "cors";
4431
+ credentials = (info2 instanceof Request ? info2.credentials : init3?.credentials) ?? "same-origin";
4432
+ }
4433
+ if ((request.method === "GET" || request.method === "HEAD") && (mode === "no-cors" && url.origin !== event.url.origin || url.origin === event.url.origin)) {
4434
+ request.headers.delete("origin");
4435
+ }
4436
+ if (url.origin !== event.url.origin) {
4437
+ if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
4438
+ const cookie = get_cookie_header(url, request.headers.get("cookie"));
4439
+ if (cookie) request.headers.set("cookie", cookie);
4440
+ }
4441
+ return fetch(request);
4442
+ }
4443
+ const prefix = assets || base;
4444
+ const decoded = decodeURIComponent(url.pathname);
4445
+ const filename = (decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded).slice(1);
4446
+ const filename_html = `${filename}/index.html`;
4447
+ const is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;
4448
+ const is_asset_html = manifest.assets.has(filename_html) || filename_html in manifest._.server_assets;
4449
+ if (is_asset || is_asset_html) {
4450
+ const file = is_asset ? filename : filename_html;
4451
+ if (state.read) {
4452
+ const type = is_asset ? manifest.mimeTypes[filename.slice(filename.lastIndexOf("."))] : "text/html";
4453
+ return new Response(state.read(file), {
4454
+ headers: type ? { "content-type": type } : {}
4455
+ });
4456
+ } else if (read_implementation && file in manifest._.server_assets) {
4457
+ const length = manifest._.server_assets[file];
4458
+ const type = manifest.mimeTypes[file.slice(file.lastIndexOf("."))];
4459
+ return new Response(read_implementation(file), {
4460
+ headers: {
4461
+ "Content-Length": "" + length,
4462
+ "Content-Type": type
4463
+ }
4464
+ });
4465
+ }
4466
+ return await fetch(request);
4467
+ }
4468
+ if (manifest._.prerendered_routes.has(decoded) || decoded.at(-1) === "/" && manifest._.prerendered_routes.has(decoded.slice(0, -1))) {
4469
+ return await fetch(request);
4470
+ }
4471
+ if (credentials !== "omit") {
4472
+ const cookie = get_cookie_header(url, request.headers.get("cookie"));
4473
+ if (cookie) {
4474
+ request.headers.set("cookie", cookie);
4475
+ }
4476
+ const authorization = event.request.headers.get("authorization");
4477
+ if (authorization && !request.headers.has("authorization")) {
4478
+ request.headers.set("authorization", authorization);
4479
+ }
4480
+ }
4481
+ if (!request.headers.has("accept")) {
4482
+ request.headers.set("accept", "*/*");
4483
+ }
4484
+ if (!request.headers.has("accept-language")) {
4485
+ request.headers.set(
4486
+ "accept-language",
4487
+ /** @type {string} */
4488
+ event.request.headers.get("accept-language")
4489
+ );
4490
+ }
4491
+ const response = await respond(request, options2, manifest, {
4492
+ ...state,
4493
+ depth: state.depth + 1
4494
+ });
4495
+ const set_cookie = response.headers.get("set-cookie");
4496
+ if (set_cookie) {
4497
+ for (const str of setCookieExports.splitCookiesString(set_cookie)) {
4498
+ const { name, value, ...options3 } = setCookieExports.parseString(str, {
4499
+ decodeValues: false
4500
+ });
4501
+ const path = options3.path ?? (url.pathname.split("/").slice(0, -1).join("/") || "/");
4502
+ set_internal(name, value, {
4503
+ path,
4504
+ encode: (value2) => value2,
4505
+ .../** @type {import('cookie').CookieSerializeOptions} */
4506
+ options3
4507
+ });
4508
+ }
4509
+ }
4510
+ return response;
4511
+ }
4512
+ });
4513
+ };
4514
+ return (input, init2) => {
4515
+ const response = server_fetch(input, init2);
4516
+ response.catch(() => {
4517
+ });
4518
+ return response;
4519
+ };
4520
+ }
4521
+ function normalize_fetch_input(info, init2, url) {
4522
+ if (info instanceof Request) {
4523
+ return info;
4524
+ }
4525
+ return new Request(typeof info === "string" ? new URL(info, url) : info, init2);
4526
+ }
4527
+ let body;
4528
+ let etag;
4529
+ let headers;
4530
+ function get_public_env(request) {
4531
+ body ??= `export const env=${JSON.stringify(public_env)}`;
4532
+ etag ??= `W/${Date.now()}`;
4533
+ headers ??= new Headers({
4534
+ "content-type": "application/javascript; charset=utf-8",
4535
+ etag
4536
+ });
4537
+ if (request.headers.get("if-none-match") === etag) {
4538
+ return new Response(void 0, { status: 304, headers });
4539
+ }
4540
+ return new Response(body, { headers });
4541
+ }
4542
+ function get_page_config(nodes) {
4543
+ let current = {};
4544
+ for (const node of nodes) {
4545
+ if (!node?.universal?.config && !node?.server?.config) continue;
4546
+ current = {
4547
+ ...current,
4548
+ ...node?.universal?.config,
4549
+ ...node?.server?.config
4550
+ };
4551
+ }
4552
+ return Object.keys(current).length ? current : void 0;
4553
+ }
4554
+ const default_transform = ({ html }) => html;
4555
+ const default_filter = () => false;
4556
+ const default_preload = ({ type }) => type === "js" || type === "css";
4557
+ const page_methods = /* @__PURE__ */ new Set(["GET", "HEAD", "POST"]);
4558
+ const allowed_page_methods = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
4559
+ async function respond(request, options2, manifest, state) {
4560
+ const url = new URL(request.url);
4561
+ if (options2.csrf_check_origin) {
4562
+ const forbidden = is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request.headers.get("origin") !== url.origin;
4563
+ if (forbidden) {
4564
+ const csrf_error = new HttpError(
4565
+ 403,
4566
+ `Cross-site ${request.method} form submissions are forbidden`
4567
+ );
4568
+ if (request.headers.get("accept") === "application/json") {
4569
+ return json(csrf_error.body, { status: csrf_error.status });
4570
+ }
4571
+ return text(csrf_error.body.message, { status: csrf_error.status });
4572
+ }
4573
+ }
4574
+ if (options2.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") {
4575
+ return text("Not found", { status: 404 });
4576
+ }
4577
+ let invalidated_data_nodes;
4578
+ const is_route_resolution_request = has_resolution_suffix(url.pathname);
4579
+ const is_data_request = has_data_suffix(url.pathname);
4580
+ if (is_route_resolution_request) {
4581
+ url.pathname = strip_resolution_suffix(url.pathname);
4582
+ } else if (is_data_request) {
4583
+ url.pathname = strip_data_suffix(url.pathname) + (url.searchParams.get(TRAILING_SLASH_PARAM) === "1" ? "/" : "") || "/";
4584
+ url.searchParams.delete(TRAILING_SLASH_PARAM);
4585
+ invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
4586
+ url.searchParams.delete(INVALIDATED_PARAM);
4587
+ }
4588
+ let resolved_path;
4589
+ try {
4590
+ resolved_path = options2.hooks.reroute({ url: new URL(url) }) ?? url.pathname;
4591
+ } catch {
4592
+ return text("Internal Server Error", {
4593
+ status: 500
4594
+ });
4595
+ }
4596
+ try {
4597
+ resolved_path = decode_pathname(resolved_path);
4598
+ } catch {
4599
+ return text("Malformed URI", { status: 400 });
4600
+ }
4601
+ let route = null;
4602
+ let params = {};
4603
+ if (base && !state.prerendering?.fallback) {
4604
+ if (!resolved_path.startsWith(base)) {
4605
+ return text("Not found", { status: 404 });
4606
+ }
4607
+ resolved_path = resolved_path.slice(base.length) || "/";
4608
+ }
4609
+ if (is_route_resolution_request) {
4610
+ return resolve_route(resolved_path, new URL(request.url), manifest);
4611
+ }
4612
+ if (resolved_path === `/${app_dir}/env.js`) {
4613
+ return get_public_env(request);
4614
+ }
4615
+ if (resolved_path.startsWith(`/${app_dir}`)) {
4616
+ const headers22 = new Headers();
4617
+ headers22.set("cache-control", "public, max-age=0, must-revalidate");
4618
+ return text("Not found", { status: 404, headers: headers22 });
4619
+ }
4620
+ if (!state.prerendering?.fallback) {
4621
+ const matchers = await manifest._.matchers();
4622
+ for (const candidate of manifest._.routes) {
4623
+ const match = candidate.pattern.exec(resolved_path);
4624
+ if (!match) continue;
4625
+ const matched = exec(match, candidate.params, matchers);
4626
+ if (matched) {
4627
+ route = candidate;
4628
+ params = decode_params(matched);
4629
+ break;
4630
+ }
4631
+ }
4632
+ }
4633
+ let trailing_slash = void 0;
4634
+ const headers2 = {};
4635
+ let cookies_to_add = {};
4636
+ const event = {
4637
+ // @ts-expect-error `cookies` and `fetch` need to be created after the `event` itself
4638
+ cookies: null,
4639
+ // @ts-expect-error
4640
+ fetch: null,
4641
+ getClientAddress: state.getClientAddress || (() => {
4642
+ throw new Error(
4643
+ `${"@sveltejs/adapter-node"} does not specify getClientAddress. Please raise an issue`
4644
+ );
4645
+ }),
4646
+ locals: {},
4647
+ params,
4648
+ platform: state.platform,
4649
+ request,
4650
+ route: { id: route?.id ?? null },
4651
+ setHeaders: (new_headers) => {
4652
+ for (const key2 in new_headers) {
4653
+ const lower = key2.toLowerCase();
4654
+ const value = new_headers[key2];
4655
+ if (lower === "set-cookie") {
4656
+ throw new Error(
4657
+ "Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies"
4658
+ );
4659
+ } else if (lower in headers2) {
4660
+ throw new Error(`"${key2}" header is already set`);
4661
+ } else {
4662
+ headers2[lower] = value;
4663
+ if (state.prerendering && lower === "cache-control") {
4664
+ state.prerendering.cache = /** @type {string} */
4665
+ value;
4666
+ }
4667
+ }
4668
+ }
4669
+ },
4670
+ url,
4671
+ isDataRequest: is_data_request,
4672
+ isSubRequest: state.depth > 0
4673
+ };
4674
+ let resolve_opts = {
4675
+ transformPageChunk: default_transform,
4676
+ filterSerializedResponseHeaders: default_filter,
4677
+ preload: default_preload
4678
+ };
4679
+ try {
4680
+ if (route) {
4681
+ if (url.pathname === base || url.pathname === base + "/") {
4682
+ trailing_slash = "always";
4683
+ } else if (route.page) {
4684
+ const nodes = await load_page_nodes(route.page, manifest);
4685
+ if (DEV) ;
4686
+ trailing_slash = get_option(nodes, "trailingSlash");
4687
+ } else if (route.endpoint) {
4688
+ const node = await route.endpoint();
4689
+ trailing_slash = node.trailingSlash;
4690
+ if (DEV) ;
4691
+ }
4692
+ if (!is_data_request) {
4693
+ const normalized = normalize_path(url.pathname, trailing_slash ?? "never");
4694
+ if (normalized !== url.pathname && !state.prerendering?.fallback) {
4695
+ return new Response(void 0, {
4696
+ status: 308,
4697
+ headers: {
4698
+ "x-sveltekit-normalize": "1",
4699
+ location: (
4700
+ // ensure paths starting with '//' are not treated as protocol-relative
4701
+ (normalized.startsWith("//") ? url.origin + normalized : normalized) + (url.search === "?" ? "" : url.search)
4702
+ )
4703
+ }
4704
+ });
4705
+ }
4706
+ }
4707
+ if (state.before_handle || state.emulator?.platform) {
4708
+ let config = {};
4709
+ let prerender = false;
4710
+ if (route.endpoint) {
4711
+ const node = await route.endpoint();
4712
+ config = node.config ?? config;
4713
+ prerender = node.prerender ?? prerender;
4714
+ } else if (route.page) {
4715
+ const nodes = await load_page_nodes(route.page, manifest);
4716
+ config = get_page_config(nodes) ?? config;
4717
+ prerender = get_option(nodes, "prerender") ?? false;
4718
+ }
4719
+ if (state.before_handle) {
4720
+ state.before_handle(event, config, prerender);
4721
+ }
4722
+ if (state.emulator?.platform) {
4723
+ event.platform = await state.emulator.platform({ config, prerender });
4724
+ }
4725
+ }
4726
+ } else if (state.emulator?.platform) {
4727
+ event.platform = await state.emulator.platform({
4728
+ config: {},
4729
+ prerender: !!state.prerendering?.fallback
4730
+ });
4731
+ }
4732
+ const { cookies, new_cookies, get_cookie_header, set_internal } = get_cookies(
4733
+ request,
4734
+ url,
4735
+ trailing_slash ?? "never"
4736
+ );
4737
+ cookies_to_add = new_cookies;
4738
+ event.cookies = cookies;
4739
+ event.fetch = create_fetch({
4740
+ event,
4741
+ options: options2,
4742
+ manifest,
4743
+ state,
4744
+ get_cookie_header,
4745
+ set_internal
4746
+ });
4747
+ if (state.prerendering && !state.prerendering.fallback) disable_search(url);
4748
+ const response = await options2.hooks.handle({
4749
+ event,
4750
+ resolve: (event2, opts) => resolve2(event2, opts).then((response2) => {
4751
+ for (const key2 in headers2) {
4752
+ const value = headers2[key2];
4753
+ response2.headers.set(
4754
+ key2,
4755
+ /** @type {string} */
4756
+ value
4757
+ );
4758
+ }
4759
+ add_cookies_to_headers(response2.headers, Object.values(cookies_to_add));
4760
+ if (state.prerendering && event2.route.id !== null) {
4761
+ response2.headers.set("x-sveltekit-routeid", encodeURI(event2.route.id));
4762
+ }
4763
+ return response2;
4764
+ })
4765
+ });
4766
+ if (response.status === 200 && response.headers.has("etag")) {
4767
+ let if_none_match_value = request.headers.get("if-none-match");
4768
+ if (if_none_match_value?.startsWith('W/"')) {
4769
+ if_none_match_value = if_none_match_value.substring(2);
4770
+ }
4771
+ const etag2 = (
4772
+ /** @type {string} */
4773
+ response.headers.get("etag")
4774
+ );
4775
+ if (if_none_match_value === etag2) {
4776
+ const headers22 = new Headers({ etag: etag2 });
4777
+ for (const key2 of [
4778
+ "cache-control",
4779
+ "content-location",
4780
+ "date",
4781
+ "expires",
4782
+ "vary",
4783
+ "set-cookie"
4784
+ ]) {
4785
+ const value = response.headers.get(key2);
4786
+ if (value) headers22.set(key2, value);
4787
+ }
4788
+ return new Response(void 0, {
4789
+ status: 304,
4790
+ headers: headers22
4791
+ });
4792
+ }
4793
+ }
4794
+ if (is_data_request && response.status >= 300 && response.status <= 308) {
4795
+ const location = response.headers.get("location");
4796
+ if (location) {
4797
+ return redirect_json_response(new Redirect(
4798
+ /** @type {any} */
4799
+ response.status,
4800
+ location
4801
+ ));
4802
+ }
4803
+ }
4804
+ return response;
4805
+ } catch (e) {
4806
+ if (e instanceof Redirect) {
4807
+ const response = is_data_request ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
4808
+ add_cookies_to_headers(response.headers, Object.values(cookies_to_add));
4809
+ return response;
4810
+ }
4811
+ return await handle_fatal_error(event, options2, e);
4812
+ }
4813
+ async function resolve2(event2, opts) {
4814
+ try {
4815
+ if (opts) {
4816
+ resolve_opts = {
4817
+ transformPageChunk: opts.transformPageChunk || default_transform,
4818
+ filterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter,
4819
+ preload: opts.preload || default_preload
4820
+ };
4821
+ }
4822
+ if (options2.hash_routing || state.prerendering?.fallback) {
4823
+ return await render_response({
4824
+ event: event2,
4825
+ options: options2,
4826
+ manifest,
4827
+ state,
4828
+ page_config: { ssr: false, csr: true },
4829
+ status: 200,
4830
+ error: null,
4831
+ branch: [],
4832
+ fetched: [],
4833
+ resolve_opts
4834
+ });
4835
+ }
4836
+ if (route) {
4837
+ const method = (
4838
+ /** @type {import('types').HttpMethod} */
4839
+ event2.request.method
4840
+ );
4841
+ let response;
4842
+ if (is_data_request) {
4843
+ response = await render_data(
4844
+ event2,
4845
+ route,
4846
+ options2,
4847
+ manifest,
4848
+ state,
4849
+ invalidated_data_nodes,
4850
+ trailing_slash ?? "never"
4851
+ );
4852
+ } else if (route.endpoint && (!route.page || is_endpoint_request(event2))) {
4853
+ response = await render_endpoint(event2, await route.endpoint(), state);
4854
+ } else if (route.page) {
4855
+ if (page_methods.has(method)) {
4856
+ response = await render_page(event2, route.page, options2, manifest, state, resolve_opts);
4857
+ } else {
4858
+ const allowed_methods2 = new Set(allowed_page_methods);
4859
+ const node = await manifest._.nodes[route.page.leaf]();
4860
+ if (node?.server?.actions) {
4861
+ allowed_methods2.add("POST");
4862
+ }
4863
+ if (method === "OPTIONS") {
4864
+ response = new Response(null, {
4865
+ status: 204,
4866
+ headers: {
4867
+ allow: Array.from(allowed_methods2.values()).join(", ")
4868
+ }
4869
+ });
4870
+ } else {
4871
+ const mod = [...allowed_methods2].reduce(
4872
+ (acc, curr) => {
4873
+ acc[curr] = true;
4874
+ return acc;
4875
+ },
4876
+ /** @type {Record<string, any>} */
4877
+ {}
4878
+ );
4879
+ response = method_not_allowed(mod, method);
4880
+ }
4881
+ }
4882
+ } else {
4883
+ throw new Error("This should never happen");
4884
+ }
4885
+ if (request.method === "GET" && route.page && route.endpoint) {
4886
+ const vary = response.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
4887
+ if (!(vary?.includes("accept") || vary?.includes("*"))) {
4888
+ response = new Response(response.body, {
4889
+ status: response.status,
4890
+ statusText: response.statusText,
4891
+ headers: new Headers(response.headers)
4892
+ });
4893
+ response.headers.append("Vary", "Accept");
4894
+ }
4895
+ }
4896
+ return response;
4897
+ }
4898
+ if (state.error && event2.isSubRequest) {
4899
+ const headers22 = new Headers(request.headers);
4900
+ headers22.set("x-sveltekit-error", "true");
4901
+ return await fetch(request, { headers: headers22 });
4902
+ }
4903
+ if (state.error) {
4904
+ return text("Internal Server Error", {
4905
+ status: 500
4906
+ });
4907
+ }
4908
+ if (state.depth === 0) {
4909
+ return await respond_with_error({
4910
+ event: event2,
4911
+ options: options2,
4912
+ manifest,
4913
+ state,
4914
+ status: 404,
4915
+ error: new SvelteKitError(404, "Not Found", `Not found: ${event2.url.pathname}`),
4916
+ resolve_opts
4917
+ });
4918
+ }
4919
+ if (state.prerendering) {
4920
+ return text("not found", { status: 404 });
4921
+ }
4922
+ return await fetch(request);
4923
+ } catch (e) {
4924
+ return await handle_fatal_error(event2, options2, e);
4925
+ } finally {
4926
+ event2.cookies.set = () => {
4927
+ throw new Error("Cannot use `cookies.set(...)` after the response has been generated");
4928
+ };
4929
+ event2.setHeaders = () => {
4930
+ throw new Error("Cannot use `setHeaders(...)` after the response has been generated");
4931
+ };
4932
+ }
4933
+ }
4934
+ }
4935
+ function filter_private_env(env, { public_prefix, private_prefix }) {
4936
+ return Object.fromEntries(
4937
+ Object.entries(env).filter(
4938
+ ([k]) => k.startsWith(private_prefix) && (public_prefix === "" || !k.startsWith(public_prefix))
4939
+ )
4940
+ );
4941
+ }
4942
+ function filter_public_env(env, { public_prefix, private_prefix }) {
4943
+ return Object.fromEntries(
4944
+ Object.entries(env).filter(
4945
+ ([k]) => k.startsWith(public_prefix) && (private_prefix === "" || !k.startsWith(private_prefix))
4946
+ )
4947
+ );
4948
+ }
4949
+ let init_promise;
4950
+ class Server {
4951
+ /** @type {import('types').SSROptions} */
4952
+ #options;
4953
+ /** @type {import('@sveltejs/kit').SSRManifest} */
4954
+ #manifest;
4955
+ /** @param {import('@sveltejs/kit').SSRManifest} manifest */
4956
+ constructor(manifest) {
4957
+ this.#options = options;
4958
+ this.#manifest = manifest;
4959
+ }
4960
+ /**
4961
+ * @param {{
4962
+ * env: Record<string, string>;
4963
+ * read?: (file: string) => ReadableStream;
4964
+ * }} opts
4965
+ */
4966
+ async init({ env, read }) {
4967
+ const prefixes = {
4968
+ public_prefix: this.#options.env_public_prefix,
4969
+ private_prefix: this.#options.env_private_prefix
4970
+ };
4971
+ filter_private_env(env, prefixes);
4972
+ const public_env2 = filter_public_env(env, prefixes);
4973
+ set_public_env(
4974
+ public_env2
4975
+ );
4976
+ set_safe_public_env(public_env2);
4977
+ if (read) {
4978
+ set_read_implementation(read);
4979
+ }
4980
+ await (init_promise ??= (async () => {
4981
+ try {
4982
+ const module = await get_hooks();
4983
+ this.#options.hooks = {
4984
+ handle: module.handle || (({ event, resolve: resolve2 }) => resolve2(event)),
4985
+ handleError: module.handleError || (({ error }) => console.error(error)),
4986
+ handleFetch: module.handleFetch || (({ request, fetch: fetch2 }) => fetch2(request)),
4987
+ reroute: module.reroute || (() => {
4988
+ }),
4989
+ transport: module.transport || {}
4990
+ };
4991
+ if (module.init) {
4992
+ await module.init();
4993
+ }
4994
+ } catch (error) {
4995
+ {
4996
+ throw error;
4997
+ }
4998
+ }
4999
+ })());
5000
+ }
5001
+ /**
5002
+ * @param {Request} request
5003
+ * @param {import('types').RequestOptions} options
5004
+ */
5005
+ async respond(request, options2) {
5006
+ return respond(request, this.#options, this.#manifest, {
5007
+ ...options2,
5008
+ error: false,
5009
+ depth: 0
5010
+ });
5011
+ }
5012
+ }
5013
+
5014
+ export { Server };
5015
+ //# sourceMappingURL=index.js.map