@gulbanana/jagman 0.0.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 (220) hide show
  1. package/LICENSE +663 -0
  2. package/README.md +40 -0
  3. package/bin/jagman.js +35 -0
  4. package/build/client/_app/immutable/assets/0.B3c8us65.css +1 -0
  5. package/build/client/_app/immutable/assets/0.B3c8us65.css.br +0 -0
  6. package/build/client/_app/immutable/assets/0.B3c8us65.css.gz +0 -0
  7. package/build/client/_app/immutable/assets/2.QhF3SmLf.css +1 -0
  8. package/build/client/_app/immutable/assets/2.QhF3SmLf.css.br +0 -0
  9. package/build/client/_app/immutable/assets/2.QhF3SmLf.css.gz +0 -0
  10. package/build/client/_app/immutable/assets/4.BoAskxZr.css +1 -0
  11. package/build/client/_app/immutable/assets/4.BoAskxZr.css.br +0 -0
  12. package/build/client/_app/immutable/assets/4.BoAskxZr.css.gz +0 -0
  13. package/build/client/_app/immutable/assets/5.DYpN9IwI.css +1 -0
  14. package/build/client/_app/immutable/assets/5.DYpN9IwI.css.br +0 -0
  15. package/build/client/_app/immutable/assets/5.DYpN9IwI.css.gz +0 -0
  16. package/build/client/_app/immutable/assets/7.BBPBRqyF.css +1 -0
  17. package/build/client/_app/immutable/assets/7.BBPBRqyF.css.br +0 -0
  18. package/build/client/_app/immutable/assets/7.BBPBRqyF.css.gz +0 -0
  19. package/build/client/_app/immutable/assets/8.WP6ZlE0M.css +1 -0
  20. package/build/client/_app/immutable/assets/8.WP6ZlE0M.css.br +0 -0
  21. package/build/client/_app/immutable/assets/8.WP6ZlE0M.css.gz +0 -0
  22. package/build/client/_app/immutable/assets/9.DH8YZ1_b.css +1 -0
  23. package/build/client/_app/immutable/assets/9.DH8YZ1_b.css.br +0 -0
  24. package/build/client/_app/immutable/assets/9.DH8YZ1_b.css.gz +0 -0
  25. package/build/client/_app/immutable/assets/ErrorSpan.BarpW_JY.css +1 -0
  26. package/build/client/_app/immutable/assets/ErrorSpan.BarpW_JY.css.br +0 -0
  27. package/build/client/_app/immutable/assets/ErrorSpan.BarpW_JY.css.gz +0 -0
  28. package/build/client/_app/immutable/assets/Icon.Di_GsCEs.css +1 -0
  29. package/build/client/_app/immutable/assets/Icon.Di_GsCEs.css.br +0 -0
  30. package/build/client/_app/immutable/assets/Icon.Di_GsCEs.css.gz +0 -0
  31. package/build/client/_app/immutable/assets/Pane.LvSW-vL-.css +1 -0
  32. package/build/client/_app/immutable/assets/Pane.LvSW-vL-.css.br +0 -0
  33. package/build/client/_app/immutable/assets/Pane.LvSW-vL-.css.gz +0 -0
  34. package/build/client/_app/immutable/assets/favicon.DGDeBov5.svg +191 -0
  35. package/build/client/_app/immutable/assets/favicon.DGDeBov5.svg.br +0 -0
  36. package/build/client/_app/immutable/assets/favicon.DGDeBov5.svg.gz +0 -0
  37. package/build/client/_app/immutable/assets/feather-sprite.BfIm3Xr9.svg +1 -0
  38. package/build/client/_app/immutable/assets/feather-sprite.BfIm3Xr9.svg.br +0 -0
  39. package/build/client/_app/immutable/assets/feather-sprite.BfIm3Xr9.svg.gz +0 -0
  40. package/build/client/_app/immutable/assets/gc-dark.DHisUerN.svg +101 -0
  41. package/build/client/_app/immutable/assets/gc-dark.DHisUerN.svg.br +0 -0
  42. package/build/client/_app/immutable/assets/gc-dark.DHisUerN.svg.gz +0 -0
  43. package/build/client/_app/immutable/assets/gc-light.C55NzigM.svg +100 -0
  44. package/build/client/_app/immutable/assets/gc-light.C55NzigM.svg.br +0 -0
  45. package/build/client/_app/immutable/assets/gc-light.C55NzigM.svg.gz +0 -0
  46. package/build/client/_app/immutable/chunks/B3ZkAhB4.js +1 -0
  47. package/build/client/_app/immutable/chunks/B3ZkAhB4.js.br +0 -0
  48. package/build/client/_app/immutable/chunks/B3ZkAhB4.js.gz +0 -0
  49. package/build/client/_app/immutable/chunks/B9tazVuH.js +2 -0
  50. package/build/client/_app/immutable/chunks/B9tazVuH.js.br +0 -0
  51. package/build/client/_app/immutable/chunks/B9tazVuH.js.gz +0 -0
  52. package/build/client/_app/immutable/chunks/BdkrN5mN.js +1 -0
  53. package/build/client/_app/immutable/chunks/BdkrN5mN.js.br +0 -0
  54. package/build/client/_app/immutable/chunks/BdkrN5mN.js.gz +0 -0
  55. package/build/client/_app/immutable/chunks/ByNAvWKi.js +1 -0
  56. package/build/client/_app/immutable/chunks/ByNAvWKi.js.br +0 -0
  57. package/build/client/_app/immutable/chunks/ByNAvWKi.js.gz +0 -0
  58. package/build/client/_app/immutable/chunks/C8oOvULD.js +1 -0
  59. package/build/client/_app/immutable/chunks/C8oOvULD.js.br +0 -0
  60. package/build/client/_app/immutable/chunks/C8oOvULD.js.gz +0 -0
  61. package/build/client/_app/immutable/chunks/CCH3sm1V.js +1 -0
  62. package/build/client/_app/immutable/chunks/CCH3sm1V.js.br +0 -0
  63. package/build/client/_app/immutable/chunks/CCH3sm1V.js.gz +0 -0
  64. package/build/client/_app/immutable/chunks/CDD8JGhu.js +1 -0
  65. package/build/client/_app/immutable/chunks/CDD8JGhu.js.br +0 -0
  66. package/build/client/_app/immutable/chunks/CDD8JGhu.js.gz +0 -0
  67. package/build/client/_app/immutable/chunks/CKIpFoVh.js +1 -0
  68. package/build/client/_app/immutable/chunks/CKIpFoVh.js.br +0 -0
  69. package/build/client/_app/immutable/chunks/CKIpFoVh.js.gz +0 -0
  70. package/build/client/_app/immutable/chunks/CMyhPqp1.js +1 -0
  71. package/build/client/_app/immutable/chunks/CMyhPqp1.js.br +0 -0
  72. package/build/client/_app/immutable/chunks/CMyhPqp1.js.gz +0 -0
  73. package/build/client/_app/immutable/chunks/COe4_SPO.js +1 -0
  74. package/build/client/_app/immutable/chunks/COe4_SPO.js.br +0 -0
  75. package/build/client/_app/immutable/chunks/COe4_SPO.js.gz +0 -0
  76. package/build/client/_app/immutable/chunks/CaZKc3PV.js +2 -0
  77. package/build/client/_app/immutable/chunks/CaZKc3PV.js.br +0 -0
  78. package/build/client/_app/immutable/chunks/CaZKc3PV.js.gz +0 -0
  79. package/build/client/_app/immutable/chunks/Cj8zunyE.js +1 -0
  80. package/build/client/_app/immutable/chunks/Cj8zunyE.js.br +2 -0
  81. package/build/client/_app/immutable/chunks/Cj8zunyE.js.gz +0 -0
  82. package/build/client/_app/immutable/chunks/CvfIoSRb.js +1 -0
  83. package/build/client/_app/immutable/chunks/CvfIoSRb.js.br +0 -0
  84. package/build/client/_app/immutable/chunks/CvfIoSRb.js.gz +0 -0
  85. package/build/client/_app/immutable/chunks/DhBP0au1.js +1 -0
  86. package/build/client/_app/immutable/chunks/DhBP0au1.js.br +0 -0
  87. package/build/client/_app/immutable/chunks/DhBP0au1.js.gz +0 -0
  88. package/build/client/_app/immutable/chunks/F2VqmO6x.js +1 -0
  89. package/build/client/_app/immutable/chunks/F2VqmO6x.js.br +0 -0
  90. package/build/client/_app/immutable/chunks/F2VqmO6x.js.gz +0 -0
  91. package/build/client/_app/immutable/chunks/hlNgmD7C.js +1 -0
  92. package/build/client/_app/immutable/chunks/hlNgmD7C.js.br +0 -0
  93. package/build/client/_app/immutable/chunks/hlNgmD7C.js.gz +0 -0
  94. package/build/client/_app/immutable/chunks/tW0gGpbB.js +2 -0
  95. package/build/client/_app/immutable/chunks/tW0gGpbB.js.br +0 -0
  96. package/build/client/_app/immutable/chunks/tW0gGpbB.js.gz +0 -0
  97. package/build/client/_app/immutable/entry/app.BJglbmCx.js +2 -0
  98. package/build/client/_app/immutable/entry/app.BJglbmCx.js.br +0 -0
  99. package/build/client/_app/immutable/entry/app.BJglbmCx.js.gz +0 -0
  100. package/build/client/_app/immutable/entry/start.f6OGjaz6.js +1 -0
  101. package/build/client/_app/immutable/entry/start.f6OGjaz6.js.br +2 -0
  102. package/build/client/_app/immutable/entry/start.f6OGjaz6.js.gz +0 -0
  103. package/build/client/_app/immutable/nodes/0.BcUb2smo.js +1 -0
  104. package/build/client/_app/immutable/nodes/0.BcUb2smo.js.br +0 -0
  105. package/build/client/_app/immutable/nodes/0.BcUb2smo.js.gz +0 -0
  106. package/build/client/_app/immutable/nodes/1.xem2AZVD.js +1 -0
  107. package/build/client/_app/immutable/nodes/1.xem2AZVD.js.br +0 -0
  108. package/build/client/_app/immutable/nodes/1.xem2AZVD.js.gz +0 -0
  109. package/build/client/_app/immutable/nodes/2.CDTJMs0M.js +1 -0
  110. package/build/client/_app/immutable/nodes/2.CDTJMs0M.js.br +1 -0
  111. package/build/client/_app/immutable/nodes/2.CDTJMs0M.js.gz +0 -0
  112. package/build/client/_app/immutable/nodes/3.Kr4ly1KY.js +1 -0
  113. package/build/client/_app/immutable/nodes/3.Kr4ly1KY.js.br +0 -0
  114. package/build/client/_app/immutable/nodes/3.Kr4ly1KY.js.gz +0 -0
  115. package/build/client/_app/immutable/nodes/4.CkrrNwwZ.js +1 -0
  116. package/build/client/_app/immutable/nodes/4.CkrrNwwZ.js.br +0 -0
  117. package/build/client/_app/immutable/nodes/4.CkrrNwwZ.js.gz +0 -0
  118. package/build/client/_app/immutable/nodes/5.Ck9pAYWh.js +3 -0
  119. package/build/client/_app/immutable/nodes/5.Ck9pAYWh.js.br +0 -0
  120. package/build/client/_app/immutable/nodes/5.Ck9pAYWh.js.gz +0 -0
  121. package/build/client/_app/immutable/nodes/6.BZru-VFo.js +1 -0
  122. package/build/client/_app/immutable/nodes/6.BZru-VFo.js.br +0 -0
  123. package/build/client/_app/immutable/nodes/6.BZru-VFo.js.gz +0 -0
  124. package/build/client/_app/immutable/nodes/7.DQKVlDfB.js +1 -0
  125. package/build/client/_app/immutable/nodes/7.DQKVlDfB.js.br +0 -0
  126. package/build/client/_app/immutable/nodes/7.DQKVlDfB.js.gz +0 -0
  127. package/build/client/_app/immutable/nodes/8.CRaTbcsI.js +1 -0
  128. package/build/client/_app/immutable/nodes/8.CRaTbcsI.js.br +0 -0
  129. package/build/client/_app/immutable/nodes/8.CRaTbcsI.js.gz +0 -0
  130. package/build/client/_app/immutable/nodes/9.ZY9fPTpH.js +1 -0
  131. package/build/client/_app/immutable/nodes/9.ZY9fPTpH.js.br +0 -0
  132. package/build/client/_app/immutable/nodes/9.ZY9fPTpH.js.gz +0 -0
  133. package/build/client/_app/version.json +1 -0
  134. package/build/client/_app/version.json.br +0 -0
  135. package/build/client/_app/version.json.gz +0 -0
  136. package/build/env.js +94 -0
  137. package/build/handler.js +1494 -0
  138. package/build/index.js +345 -0
  139. package/build/server/chunks/0-DFKHNL47.js +9 -0
  140. package/build/server/chunks/0-DFKHNL47.js.map +1 -0
  141. package/build/server/chunks/1-rBV5UzK8.js +9 -0
  142. package/build/server/chunks/1-rBV5UzK8.js.map +1 -0
  143. package/build/server/chunks/2-DNhpm2f0.js +9 -0
  144. package/build/server/chunks/2-DNhpm2f0.js.map +1 -0
  145. package/build/server/chunks/3-BriZP-4z.js +9 -0
  146. package/build/server/chunks/3-BriZP-4z.js.map +1 -0
  147. package/build/server/chunks/4-BRqbjiow.js +9 -0
  148. package/build/server/chunks/4-BRqbjiow.js.map +1 -0
  149. package/build/server/chunks/5-DxPUkn7K.js +9 -0
  150. package/build/server/chunks/5-DxPUkn7K.js.map +1 -0
  151. package/build/server/chunks/6-OQ8ks1e7.js +19 -0
  152. package/build/server/chunks/6-OQ8ks1e7.js.map +1 -0
  153. package/build/server/chunks/7-wbR5qPH1.js +9 -0
  154. package/build/server/chunks/7-wbR5qPH1.js.map +1 -0
  155. package/build/server/chunks/8-BL7_9qSi.js +9 -0
  156. package/build/server/chunks/8-BL7_9qSi.js.map +1 -0
  157. package/build/server/chunks/9-DC9G3Slz.js +9 -0
  158. package/build/server/chunks/9-DC9G3Slz.js.map +1 -0
  159. package/build/server/chunks/ErrorSpan-BSqKaGqG.js +9 -0
  160. package/build/server/chunks/ErrorSpan-BSqKaGqG.js.map +1 -0
  161. package/build/server/chunks/Icon-Dr5EwAkb.js +10 -0
  162. package/build/server/chunks/Icon-Dr5EwAkb.js.map +1 -0
  163. package/build/server/chunks/Pane-DcSwhEiL.js +41 -0
  164. package/build/server/chunks/Pane-DcSwhEiL.js.map +1 -0
  165. package/build/server/chunks/_error.svelte-Cw0MGN-r.js +18 -0
  166. package/build/server/chunks/_error.svelte-Cw0MGN-r.js.map +1 -0
  167. package/build/server/chunks/_layout.svelte-CFeu3znf.js +14 -0
  168. package/build/server/chunks/_layout.svelte-CFeu3znf.js.map +1 -0
  169. package/build/server/chunks/_layout.svelte-CQ3MtcgC.js +33 -0
  170. package/build/server/chunks/_layout.svelte-CQ3MtcgC.js.map +1 -0
  171. package/build/server/chunks/_layout.svelte-D_GQeKpE.js +9 -0
  172. package/build/server/chunks/_layout.svelte-D_GQeKpE.js.map +1 -0
  173. package/build/server/chunks/_page.svelte-C8O6i1zq.js +282 -0
  174. package/build/server/chunks/_page.svelte-C8O6i1zq.js.map +1 -0
  175. package/build/server/chunks/_page.svelte-CfJpXtNh.js +104 -0
  176. package/build/server/chunks/_page.svelte-CfJpXtNh.js.map +1 -0
  177. package/build/server/chunks/_page.svelte-CkpYjdBP.js +68 -0
  178. package/build/server/chunks/_page.svelte-CkpYjdBP.js.map +1 -0
  179. package/build/server/chunks/_page.svelte-DbAHpdpc.js +6 -0
  180. package/build/server/chunks/_page.svelte-DbAHpdpc.js.map +1 -0
  181. package/build/server/chunks/agent-C7A3zEr3.js +708 -0
  182. package/build/server/chunks/agent-C7A3zEr3.js.map +1 -0
  183. package/build/server/chunks/data.remote-3GWudL8p.js +28 -0
  184. package/build/server/chunks/data.remote-3GWudL8p.js.map +1 -0
  185. package/build/server/chunks/data.remote2-DPGOveFg.js +23 -0
  186. package/build/server/chunks/data.remote2-DPGOveFg.js.map +1 -0
  187. package/build/server/chunks/data.remote3-CDhxyD61.js +25 -0
  188. package/build/server/chunks/data.remote3-CDhxyD61.js.map +1 -0
  189. package/build/server/chunks/error.svelte-D0cH8izO.js +13 -0
  190. package/build/server/chunks/error.svelte-D0cH8izO.js.map +1 -0
  191. package/build/server/chunks/exports-DsGzTZ0S.js +121 -0
  192. package/build/server/chunks/exports-DsGzTZ0S.js.map +1 -0
  193. package/build/server/chunks/hooks.server-Cke-TrVc.js +14 -0
  194. package/build/server/chunks/hooks.server-Cke-TrVc.js.map +1 -0
  195. package/build/server/chunks/index-CoD1IJuy.js +190 -0
  196. package/build/server/chunks/index-CoD1IJuy.js.map +1 -0
  197. package/build/server/chunks/index-DwoWbz0A.js +1819 -0
  198. package/build/server/chunks/index-DwoWbz0A.js.map +1 -0
  199. package/build/server/chunks/index2-Ej5CkWKF.js +44 -0
  200. package/build/server/chunks/index2-Ej5CkWKF.js.map +1 -0
  201. package/build/server/chunks/mock-data-D8qN6SIX.js +18 -0
  202. package/build/server/chunks/mock-data-D8qN6SIX.js.map +1 -0
  203. package/build/server/chunks/opencode-vgZ5DMQ2.js +452 -0
  204. package/build/server/chunks/opencode-vgZ5DMQ2.js.map +1 -0
  205. package/build/server/chunks/remote-1jrju9-CYV2OBS9.js +16 -0
  206. package/build/server/chunks/remote-1jrju9-CYV2OBS9.js.map +1 -0
  207. package/build/server/chunks/remote-1t3e9fx-Bq2E-Huu.js +16 -0
  208. package/build/server/chunks/remote-1t3e9fx-Bq2E-Huu.js.map +1 -0
  209. package/build/server/chunks/remote-dsfuc2-DwI4AU9q.js +15 -0
  210. package/build/server/chunks/remote-dsfuc2-DwI4AU9q.js.map +1 -0
  211. package/build/server/chunks/root-C5lyo0VT.js +2906 -0
  212. package/build/server/chunks/root-C5lyo0VT.js.map +1 -0
  213. package/build/server/chunks/shared-bytReIJX.js +1236 -0
  214. package/build/server/chunks/shared-bytReIJX.js.map +1 -0
  215. package/build/server/index.js +4422 -0
  216. package/build/server/index.js.map +1 -0
  217. package/build/server/manifest.js +83 -0
  218. package/build/server/manifest.js.map +1 -0
  219. package/build/shims.js +32 -0
  220. package/package.json +70 -0
@@ -0,0 +1,1236 @@
1
+ import { H as HttpError, j as json, t as text, S as SvelteKitError } from './index-CoD1IJuy.js';
2
+ import { w as with_request_store, t as text_decoder, b as base64_decode, a as base64_encode } from './root-C5lyo0VT.js';
3
+ import { D as DevalueError, i as is_primitive, j as get_type, k as is_plain_object, l as enumerable_symbols, m as stringify_key, o as stringify_string, v as valid_array_indices } from './index-DwoWbz0A.js';
4
+
5
+ /**
6
+ * Base64 Encodes an arraybuffer
7
+ * @param {ArrayBuffer} arraybuffer
8
+ * @returns {string}
9
+ */
10
+ function encode64(arraybuffer) {
11
+ const dv = new DataView(arraybuffer);
12
+ let binaryString = "";
13
+
14
+ for (let i = 0; i < arraybuffer.byteLength; i++) {
15
+ binaryString += String.fromCharCode(dv.getUint8(i));
16
+ }
17
+
18
+ return binaryToAscii(binaryString);
19
+ }
20
+
21
+ /**
22
+ * Decodes a base64 string into an arraybuffer
23
+ * @param {string} string
24
+ * @returns {ArrayBuffer}
25
+ */
26
+ function decode64(string) {
27
+ const binaryString = asciiToBinary(string);
28
+ const arraybuffer = new ArrayBuffer(binaryString.length);
29
+ const dv = new DataView(arraybuffer);
30
+
31
+ for (let i = 0; i < arraybuffer.byteLength; i++) {
32
+ dv.setUint8(i, binaryString.charCodeAt(i));
33
+ }
34
+
35
+ return arraybuffer;
36
+ }
37
+
38
+ const KEY_STRING =
39
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
40
+
41
+ /**
42
+ * Substitute for atob since it's deprecated in node.
43
+ * Does not do any input validation.
44
+ *
45
+ * @see https://github.com/jsdom/abab/blob/master/lib/atob.js
46
+ *
47
+ * @param {string} data
48
+ * @returns {string}
49
+ */
50
+ function asciiToBinary(data) {
51
+ if (data.length % 4 === 0) {
52
+ data = data.replace(/==?$/, "");
53
+ }
54
+
55
+ let output = "";
56
+ let buffer = 0;
57
+ let accumulatedBits = 0;
58
+
59
+ for (let i = 0; i < data.length; i++) {
60
+ buffer <<= 6;
61
+ buffer |= KEY_STRING.indexOf(data[i]);
62
+ accumulatedBits += 6;
63
+ if (accumulatedBits === 24) {
64
+ output += String.fromCharCode((buffer & 0xff0000) >> 16);
65
+ output += String.fromCharCode((buffer & 0xff00) >> 8);
66
+ output += String.fromCharCode(buffer & 0xff);
67
+ buffer = accumulatedBits = 0;
68
+ }
69
+ }
70
+ if (accumulatedBits === 12) {
71
+ buffer >>= 4;
72
+ output += String.fromCharCode(buffer);
73
+ } else if (accumulatedBits === 18) {
74
+ buffer >>= 2;
75
+ output += String.fromCharCode((buffer & 0xff00) >> 8);
76
+ output += String.fromCharCode(buffer & 0xff);
77
+ }
78
+ return output;
79
+ }
80
+
81
+ /**
82
+ * Substitute for btoa since it's deprecated in node.
83
+ * Does not do any input validation.
84
+ *
85
+ * @see https://github.com/jsdom/abab/blob/master/lib/btoa.js
86
+ *
87
+ * @param {string} str
88
+ * @returns {string}
89
+ */
90
+ function binaryToAscii(str) {
91
+ let out = "";
92
+ for (let i = 0; i < str.length; i += 3) {
93
+ /** @type {[number, number, number, number]} */
94
+ const groupsOfSix = [undefined, undefined, undefined, undefined];
95
+ groupsOfSix[0] = str.charCodeAt(i) >> 2;
96
+ groupsOfSix[1] = (str.charCodeAt(i) & 0x03) << 4;
97
+ if (str.length > i + 1) {
98
+ groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
99
+ groupsOfSix[2] = (str.charCodeAt(i + 1) & 0x0f) << 2;
100
+ }
101
+ if (str.length > i + 2) {
102
+ groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
103
+ groupsOfSix[3] = str.charCodeAt(i + 2) & 0x3f;
104
+ }
105
+ for (let j = 0; j < groupsOfSix.length; j++) {
106
+ if (typeof groupsOfSix[j] === "undefined") {
107
+ out += "=";
108
+ } else {
109
+ out += KEY_STRING[groupsOfSix[j]];
110
+ }
111
+ }
112
+ }
113
+ return out;
114
+ }
115
+
116
+ const UNDEFINED = -1;
117
+ const HOLE = -2;
118
+ const NAN = -3;
119
+ const POSITIVE_INFINITY = -4;
120
+ const NEGATIVE_INFINITY = -5;
121
+ const NEGATIVE_ZERO = -6;
122
+ const SPARSE = -7;
123
+
124
+ /**
125
+ * Revive a value serialized with `devalue.stringify`
126
+ * @param {string} serialized
127
+ * @param {Record<string, (value: any) => any>} [revivers]
128
+ */
129
+ function parse(serialized, revivers) {
130
+ return unflatten(JSON.parse(serialized), revivers);
131
+ }
132
+
133
+ /**
134
+ * Revive a value flattened with `devalue.stringify`
135
+ * @param {number | any[]} parsed
136
+ * @param {Record<string, (value: any) => any>} [revivers]
137
+ */
138
+ function unflatten(parsed, revivers) {
139
+ if (typeof parsed === 'number') return hydrate(parsed, true);
140
+
141
+ if (!Array.isArray(parsed) || parsed.length === 0) {
142
+ throw new Error('Invalid input');
143
+ }
144
+
145
+ const values = /** @type {any[]} */ (parsed);
146
+
147
+ const hydrated = Array(values.length);
148
+
149
+ /**
150
+ * A set of values currently being hydrated with custom revivers,
151
+ * used to detect invalid cyclical dependencies
152
+ * @type {Set<number> | null}
153
+ */
154
+ let hydrating = null;
155
+
156
+ /**
157
+ * @param {number} index
158
+ * @returns {any}
159
+ */
160
+ function hydrate(index, standalone = false) {
161
+ if (index === UNDEFINED) return undefined;
162
+ if (index === NAN) return NaN;
163
+ if (index === POSITIVE_INFINITY) return Infinity;
164
+ if (index === NEGATIVE_INFINITY) return -Infinity;
165
+ if (index === NEGATIVE_ZERO) return -0;
166
+
167
+ if (standalone || typeof index !== 'number') {
168
+ throw new Error(`Invalid input`);
169
+ }
170
+
171
+ if (index in hydrated) return hydrated[index];
172
+
173
+ const value = values[index];
174
+
175
+ if (!value || typeof value !== 'object') {
176
+ hydrated[index] = value;
177
+ } else if (Array.isArray(value)) {
178
+ if (typeof value[0] === 'string') {
179
+ const type = value[0];
180
+
181
+ const reviver =
182
+ revivers && Object.hasOwn(revivers, type)
183
+ ? revivers[type]
184
+ : undefined;
185
+
186
+ if (reviver) {
187
+ let i = value[1];
188
+ if (typeof i !== 'number') {
189
+ // if it's not a number, it was serialized by a builtin reviver
190
+ // so we need to munge it into the format expected by a custom reviver
191
+ i = values.push(value[1]) - 1;
192
+ }
193
+
194
+ hydrating ??= new Set();
195
+
196
+ if (hydrating.has(i)) {
197
+ throw new Error('Invalid circular reference');
198
+ }
199
+
200
+ hydrating.add(i);
201
+ hydrated[index] = reviver(hydrate(i));
202
+ hydrating.delete(i);
203
+
204
+ return hydrated[index];
205
+ }
206
+
207
+ switch (type) {
208
+ case 'Date':
209
+ hydrated[index] = new Date(value[1]);
210
+ break;
211
+
212
+ case 'Set':
213
+ const set = new Set();
214
+ hydrated[index] = set;
215
+ for (let i = 1; i < value.length; i += 1) {
216
+ set.add(hydrate(value[i]));
217
+ }
218
+ break;
219
+
220
+ case 'Map':
221
+ const map = new Map();
222
+ hydrated[index] = map;
223
+ for (let i = 1; i < value.length; i += 2) {
224
+ map.set(hydrate(value[i]), hydrate(value[i + 1]));
225
+ }
226
+ break;
227
+
228
+ case 'RegExp':
229
+ hydrated[index] = new RegExp(value[1], value[2]);
230
+ break;
231
+
232
+ case 'Object':
233
+ hydrated[index] = Object(value[1]);
234
+ break;
235
+
236
+ case 'BigInt':
237
+ hydrated[index] = BigInt(value[1]);
238
+ break;
239
+
240
+ case 'null':
241
+ const obj = Object.create(null);
242
+ hydrated[index] = obj;
243
+ for (let i = 1; i < value.length; i += 2) {
244
+ obj[value[i]] = hydrate(value[i + 1]);
245
+ }
246
+ break;
247
+
248
+ case 'Int8Array':
249
+ case 'Uint8Array':
250
+ case 'Uint8ClampedArray':
251
+ case 'Int16Array':
252
+ case 'Uint16Array':
253
+ case 'Int32Array':
254
+ case 'Uint32Array':
255
+ case 'Float32Array':
256
+ case 'Float64Array':
257
+ case 'BigInt64Array':
258
+ case 'BigUint64Array': {
259
+ if (values[value[1]][0] !== 'ArrayBuffer') {
260
+ // without this, if we receive malformed input we could
261
+ // end up trying to hydrate in a circle or allocate
262
+ // huge amounts of memory when we call `new TypedArrayConstructor(buffer)`
263
+ throw new Error('Invalid data');
264
+ }
265
+
266
+ const TypedArrayConstructor = globalThis[type];
267
+ const buffer = hydrate(value[1]);
268
+ const typedArray = new TypedArrayConstructor(buffer);
269
+
270
+ hydrated[index] =
271
+ value[2] !== undefined
272
+ ? typedArray.subarray(value[2], value[3])
273
+ : typedArray;
274
+
275
+ break;
276
+ }
277
+
278
+ case 'ArrayBuffer': {
279
+ const base64 = value[1];
280
+ if (typeof base64 !== 'string') {
281
+ throw new Error('Invalid ArrayBuffer encoding');
282
+ }
283
+ const arraybuffer = decode64(base64);
284
+ hydrated[index] = arraybuffer;
285
+ break;
286
+ }
287
+
288
+ case 'Temporal.Duration':
289
+ case 'Temporal.Instant':
290
+ case 'Temporal.PlainDate':
291
+ case 'Temporal.PlainTime':
292
+ case 'Temporal.PlainDateTime':
293
+ case 'Temporal.PlainMonthDay':
294
+ case 'Temporal.PlainYearMonth':
295
+ case 'Temporal.ZonedDateTime': {
296
+ const temporalName = type.slice(9);
297
+ // @ts-expect-error TS doesn't know about Temporal yet
298
+ hydrated[index] = Temporal[temporalName].from(value[1]);
299
+ break;
300
+ }
301
+
302
+ case 'URL': {
303
+ const url = new URL(value[1]);
304
+ hydrated[index] = url;
305
+ break;
306
+ }
307
+
308
+ case 'URLSearchParams': {
309
+ const url = new URLSearchParams(value[1]);
310
+ hydrated[index] = url;
311
+ break;
312
+ }
313
+
314
+ default:
315
+ throw new Error(`Unknown type ${type}`);
316
+ }
317
+ } else if (value[0] === SPARSE) {
318
+ // Sparse array encoding: [SPARSE, length, idx, val, idx, val, ...]
319
+ const len = value[1];
320
+
321
+ const array = new Array(len);
322
+ hydrated[index] = array;
323
+
324
+ for (let i = 2; i < value.length; i += 2) {
325
+ const idx = value[i];
326
+ array[idx] = hydrate(value[i + 1]);
327
+ }
328
+ } else {
329
+ const array = new Array(value.length);
330
+ hydrated[index] = array;
331
+
332
+ for (let i = 0; i < value.length; i += 1) {
333
+ const n = value[i];
334
+ if (n === HOLE) continue;
335
+
336
+ array[i] = hydrate(n);
337
+ }
338
+ }
339
+ } else {
340
+ /** @type {Record<string, any>} */
341
+ const object = {};
342
+ hydrated[index] = object;
343
+
344
+ for (const key of Object.keys(value)) {
345
+ if (key === '__proto__') {
346
+ throw new Error('Cannot parse an object with a `__proto__` property');
347
+ }
348
+
349
+ const n = value[key];
350
+ object[key] = hydrate(n);
351
+ }
352
+ }
353
+
354
+ return hydrated[index];
355
+ }
356
+
357
+ return hydrate(0);
358
+ }
359
+
360
+ /**
361
+ * Turn a value into a JSON string that can be parsed with `devalue.parse`
362
+ * @param {any} value
363
+ * @param {Record<string, (value: any) => any>} [reducers]
364
+ */
365
+ function stringify$1(value, reducers) {
366
+ /** @type {any[]} */
367
+ const stringified = [];
368
+
369
+ /** @type {Map<any, number>} */
370
+ const indexes = new Map();
371
+
372
+ /** @type {Array<{ key: string, fn: (value: any) => any }>} */
373
+ const custom = [];
374
+ if (reducers) {
375
+ for (const key of Object.getOwnPropertyNames(reducers)) {
376
+ custom.push({ key, fn: reducers[key] });
377
+ }
378
+ }
379
+
380
+ /** @type {string[]} */
381
+ const keys = [];
382
+
383
+ let p = 0;
384
+
385
+ /** @param {any} thing */
386
+ function flatten(thing) {
387
+ if (thing === undefined) return UNDEFINED;
388
+ if (Number.isNaN(thing)) return NAN;
389
+ if (thing === Infinity) return POSITIVE_INFINITY;
390
+ if (thing === -Infinity) return NEGATIVE_INFINITY;
391
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
392
+
393
+ if (indexes.has(thing)) return indexes.get(thing);
394
+
395
+ const index = p++;
396
+ indexes.set(thing, index);
397
+
398
+ for (const { key, fn } of custom) {
399
+ const value = fn(thing);
400
+ if (value) {
401
+ stringified[index] = `["${key}",${flatten(value)}]`;
402
+ return index;
403
+ }
404
+ }
405
+
406
+ if (typeof thing === 'function') {
407
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
408
+ }
409
+
410
+ let str = '';
411
+
412
+ if (is_primitive(thing)) {
413
+ str = stringify_primitive(thing);
414
+ } else {
415
+ const type = get_type(thing);
416
+
417
+ switch (type) {
418
+ case 'Number':
419
+ case 'String':
420
+ case 'Boolean':
421
+ str = `["Object",${stringify_primitive(thing)}]`;
422
+ break;
423
+
424
+ case 'BigInt':
425
+ str = `["BigInt",${thing}]`;
426
+ break;
427
+
428
+ case 'Date':
429
+ const valid = !isNaN(thing.getDate());
430
+ str = `["Date","${valid ? thing.toISOString() : ''}"]`;
431
+ break;
432
+
433
+ case 'URL':
434
+ str = `["URL",${stringify_string(thing.toString())}]`;
435
+ break;
436
+
437
+ case 'URLSearchParams':
438
+ str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
439
+ break;
440
+
441
+ case 'RegExp':
442
+ const { source, flags } = thing;
443
+ str = flags
444
+ ? `["RegExp",${stringify_string(source)},"${flags}"]`
445
+ : `["RegExp",${stringify_string(source)}]`;
446
+ break;
447
+
448
+ case 'Array': {
449
+ // For dense arrays (no holes), we iterate normally.
450
+ // When we encounter the first hole, we call Object.keys
451
+ // to determine the sparseness, then decide between:
452
+ // - HOLE encoding: [-2, val, -2, ...] (default)
453
+ // - Sparse encoding: [-7, length, idx, val, ...] (for very sparse arrays)
454
+ // Only the sparse path avoids iterating every slot, which
455
+ // is what protects against the DoS of e.g. `arr[1000000] = 1`.
456
+ let mostly_dense = false;
457
+
458
+ str = '[';
459
+
460
+ for (let i = 0; i < thing.length; i += 1) {
461
+ if (i > 0) str += ',';
462
+
463
+ if (Object.hasOwn(thing, i)) {
464
+ keys.push(`[${i}]`);
465
+ str += flatten(thing[i]);
466
+ keys.pop();
467
+ } else if (mostly_dense) {
468
+ // Use dense encoding. The heuristic guarantees the
469
+ // array is only mildly sparse, so iterating over every
470
+ // slot is fine.
471
+ str += HOLE;
472
+ } else {
473
+ // Decide between HOLE encoding and sparse encoding.
474
+ //
475
+ // HOLE encoding: each hole is serialized as the HOLE
476
+ // sentinel (-2). For example, [, "a", ,] becomes
477
+ // [-2, 0, -2]. Each hole costs 3 chars ("-2" + comma).
478
+ //
479
+ // Sparse encoding: lists only populated indices.
480
+ // For example, [, "a", ,] becomes [-7, 3, 1, 0] — the
481
+ // -7 sentinel, the array length (3), then index-value
482
+ // pairs. This avoids paying per-hole, but each element
483
+ // costs extra chars to write its index.
484
+ //
485
+ // The values are the same size either way, so the
486
+ // choice comes down to structural overhead:
487
+ //
488
+ // HOLE overhead:
489
+ // 3 chars per hole ("-2" + comma)
490
+ // = (L - P) * 3
491
+ //
492
+ // Sparse overhead:
493
+ // "-7," — 3 chars (sparse sentinel + comma)
494
+ // + length + "," — (d + 1) chars (array length + comma)
495
+ // + per element: index + "," — (d + 1) chars
496
+ // = (4 + d) + P * (d + 1)
497
+ //
498
+ // where L is the array length, P is the number of
499
+ // populated elements, and d is the number of digits
500
+ // in L (an upper bound on the digits in any index).
501
+ //
502
+ // Sparse encoding is cheaper when:
503
+ // (4 + d) + P * (d + 1) < (L - P) * 3
504
+ const populated_keys = valid_array_indices(/** @type {any[]} */ (thing));
505
+ const population = populated_keys.length;
506
+ const d = String(thing.length).length;
507
+
508
+ const hole_cost = (thing.length - population) * 3;
509
+ const sparse_cost = 4 + d + population * (d + 1);
510
+
511
+ if (hole_cost > sparse_cost) {
512
+ str = '[' + SPARSE + ',' + thing.length;
513
+ for (let j = 0; j < populated_keys.length; j++) {
514
+ const key = populated_keys[j];
515
+ keys.push(`[${key}]`);
516
+ str += ',' + key + ',' + flatten(thing[key]);
517
+ keys.pop();
518
+ }
519
+ break;
520
+ } else {
521
+ mostly_dense = true;
522
+ str += HOLE;
523
+ }
524
+ }
525
+ }
526
+
527
+ str += ']';
528
+
529
+ break;
530
+ }
531
+
532
+ case 'Set':
533
+ str = '["Set"';
534
+
535
+ for (const value of thing) {
536
+ str += `,${flatten(value)}`;
537
+ }
538
+
539
+ str += ']';
540
+ break;
541
+
542
+ case 'Map':
543
+ str = '["Map"';
544
+
545
+ for (const [key, value] of thing) {
546
+ keys.push(
547
+ `.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`
548
+ );
549
+ str += `,${flatten(key)},${flatten(value)}`;
550
+ keys.pop();
551
+ }
552
+
553
+ str += ']';
554
+ break;
555
+
556
+ case 'Int8Array':
557
+ case 'Uint8Array':
558
+ case 'Uint8ClampedArray':
559
+ case 'Int16Array':
560
+ case 'Uint16Array':
561
+ case 'Int32Array':
562
+ case 'Uint32Array':
563
+ case 'Float32Array':
564
+ case 'Float64Array':
565
+ case 'BigInt64Array':
566
+ case 'BigUint64Array': {
567
+ /** @type {import("./types.js").TypedArray} */
568
+ const typedArray = thing;
569
+ str = '["' + type + '",' + flatten(typedArray.buffer);
570
+
571
+ const a = thing.byteOffset;
572
+ const b = a + thing.byteLength;
573
+
574
+ // handle subarrays
575
+ if (a > 0 || b !== typedArray.buffer.byteLength) {
576
+ const m = +/(\d+)/.exec(type)[1] / 8;
577
+ str += `,${a / m},${b / m}`;
578
+ }
579
+
580
+ str += ']';
581
+ break;
582
+ }
583
+
584
+ case 'ArrayBuffer': {
585
+ /** @type {ArrayBuffer} */
586
+ const arraybuffer = thing;
587
+ const base64 = encode64(arraybuffer);
588
+
589
+ str = `["ArrayBuffer","${base64}"]`;
590
+ break;
591
+ }
592
+
593
+ case 'Temporal.Duration':
594
+ case 'Temporal.Instant':
595
+ case 'Temporal.PlainDate':
596
+ case 'Temporal.PlainTime':
597
+ case 'Temporal.PlainDateTime':
598
+ case 'Temporal.PlainMonthDay':
599
+ case 'Temporal.PlainYearMonth':
600
+ case 'Temporal.ZonedDateTime':
601
+ str = `["${type}",${stringify_string(thing.toString())}]`;
602
+ break;
603
+
604
+ default:
605
+ if (!is_plain_object(thing)) {
606
+ throw new DevalueError(
607
+ `Cannot stringify arbitrary non-POJOs`,
608
+ keys,
609
+ thing,
610
+ value
611
+ );
612
+ }
613
+
614
+ if (enumerable_symbols(thing).length > 0) {
615
+ throw new DevalueError(
616
+ `Cannot stringify POJOs with symbolic keys`,
617
+ keys,
618
+ thing,
619
+ value
620
+ );
621
+ }
622
+
623
+ if (Object.getPrototypeOf(thing) === null) {
624
+ str = '["null"';
625
+ for (const key of Object.keys(thing)) {
626
+ if (key === '__proto__') {
627
+ throw new DevalueError(
628
+ `Cannot stringify objects with __proto__ keys`,
629
+ keys,
630
+ thing,
631
+ value
632
+ );
633
+ }
634
+
635
+ keys.push(stringify_key(key));
636
+ str += `,${stringify_string(key)},${flatten(thing[key])}`;
637
+ keys.pop();
638
+ }
639
+ str += ']';
640
+ } else {
641
+ str = '{';
642
+ let started = false;
643
+ for (const key of Object.keys(thing)) {
644
+ if (key === '__proto__') {
645
+ throw new DevalueError(
646
+ `Cannot stringify objects with __proto__ keys`,
647
+ keys,
648
+ thing,
649
+ value
650
+ );
651
+ }
652
+
653
+ if (started) str += ',';
654
+ started = true;
655
+ keys.push(stringify_key(key));
656
+ str += `${stringify_string(key)}:${flatten(thing[key])}`;
657
+ keys.pop();
658
+ }
659
+ str += '}';
660
+ }
661
+ }
662
+ }
663
+
664
+ stringified[index] = str;
665
+ return index;
666
+ }
667
+
668
+ const index = flatten(value);
669
+
670
+ // special case — value is represented as a negative index
671
+ if (index < 0) return `${index}`;
672
+
673
+ return `[${stringified.join(',')}]`;
674
+ }
675
+
676
+ /**
677
+ * @param {any} thing
678
+ * @returns {string}
679
+ */
680
+ function stringify_primitive(thing) {
681
+ const type = typeof thing;
682
+ if (type === 'string') return stringify_string(thing);
683
+ if (thing instanceof String) return stringify_string(thing.toString());
684
+ if (thing === void 0) return UNDEFINED.toString();
685
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
686
+ if (type === 'bigint') return `["BigInt","${thing}"]`;
687
+ return String(thing);
688
+ }
689
+
690
+ const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
691
+ const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
692
+ const PAGE_METHODS = ["GET", "POST", "HEAD"];
693
+ function set_nested_value(object, path_string, value) {
694
+ if (path_string.startsWith("n:")) {
695
+ path_string = path_string.slice(2);
696
+ value = value === "" ? void 0 : parseFloat(value);
697
+ } else if (path_string.startsWith("b:")) {
698
+ path_string = path_string.slice(2);
699
+ value = value === "on";
700
+ }
701
+ deep_set(object, split_path(path_string), value);
702
+ }
703
+ function convert_formdata(data) {
704
+ const result = {};
705
+ for (let key of data.keys()) {
706
+ const is_array = key.endsWith("[]");
707
+ let values = data.getAll(key);
708
+ if (is_array) key = key.slice(0, -2);
709
+ if (values.length > 1 && !is_array) {
710
+ throw new Error(`Form cannot contain duplicated keys — "${key}" has ${values.length} values`);
711
+ }
712
+ values = values.filter(
713
+ (entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0
714
+ );
715
+ if (key.startsWith("n:")) {
716
+ key = key.slice(2);
717
+ values = values.map((v) => v === "" ? void 0 : parseFloat(
718
+ /** @type {string} */
719
+ v
720
+ ));
721
+ } else if (key.startsWith("b:")) {
722
+ key = key.slice(2);
723
+ values = values.map((v) => v === "on");
724
+ }
725
+ set_nested_value(result, key, is_array ? values : values[0]);
726
+ }
727
+ return result;
728
+ }
729
+ const BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata";
730
+ const BINARY_FORM_VERSION = 0;
731
+ const HEADER_BYTES = 1 + 4 + 2;
732
+ async function deserialize_binary_form(request) {
733
+ if (request.headers.get("content-type") !== BINARY_FORM_CONTENT_TYPE) {
734
+ const form_data = await request.formData();
735
+ return { data: convert_formdata(form_data), meta: {}, form_data };
736
+ }
737
+ if (!request.body) {
738
+ throw deserialize_error("no body");
739
+ }
740
+ const content_length = parseInt(request.headers.get("content-length") ?? "");
741
+ if (Number.isNaN(content_length)) {
742
+ throw deserialize_error("invalid Content-Length header");
743
+ }
744
+ const reader = request.body.getReader();
745
+ const chunks = [];
746
+ function get_chunk(index) {
747
+ if (index in chunks) return chunks[index];
748
+ let i = chunks.length;
749
+ while (i <= index) {
750
+ chunks[i] = reader.read().then((chunk) => chunk.value);
751
+ i++;
752
+ }
753
+ return chunks[index];
754
+ }
755
+ async function get_buffer(offset, length) {
756
+ let start_chunk;
757
+ let chunk_start = 0;
758
+ let chunk_index;
759
+ for (chunk_index = 0; ; chunk_index++) {
760
+ const chunk = await get_chunk(chunk_index);
761
+ if (!chunk) return null;
762
+ const chunk_end = chunk_start + chunk.byteLength;
763
+ if (offset >= chunk_start && offset < chunk_end) {
764
+ start_chunk = chunk;
765
+ break;
766
+ }
767
+ chunk_start = chunk_end;
768
+ }
769
+ if (offset + length <= chunk_start + start_chunk.byteLength) {
770
+ return start_chunk.subarray(offset - chunk_start, offset + length - chunk_start);
771
+ }
772
+ const chunks2 = [start_chunk.subarray(offset - chunk_start)];
773
+ let cursor = start_chunk.byteLength - offset + chunk_start;
774
+ while (cursor < length) {
775
+ chunk_index++;
776
+ let chunk = await get_chunk(chunk_index);
777
+ if (!chunk) return null;
778
+ if (chunk.byteLength > length - cursor) {
779
+ chunk = chunk.subarray(0, length - cursor);
780
+ }
781
+ chunks2.push(chunk);
782
+ cursor += chunk.byteLength;
783
+ }
784
+ const buffer = new Uint8Array(length);
785
+ cursor = 0;
786
+ for (const chunk of chunks2) {
787
+ buffer.set(chunk, cursor);
788
+ cursor += chunk.byteLength;
789
+ }
790
+ return buffer;
791
+ }
792
+ const header = await get_buffer(0, HEADER_BYTES);
793
+ if (!header) throw deserialize_error("too short");
794
+ if (header[0] !== BINARY_FORM_VERSION) {
795
+ throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
796
+ }
797
+ const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
798
+ const data_length = header_view.getUint32(1, true);
799
+ if (HEADER_BYTES + data_length > content_length) {
800
+ throw deserialize_error("data overflow");
801
+ }
802
+ const file_offsets_length = header_view.getUint16(5, true);
803
+ if (HEADER_BYTES + data_length + file_offsets_length > content_length) {
804
+ throw deserialize_error("file offset table overflow");
805
+ }
806
+ const data_buffer = await get_buffer(HEADER_BYTES, data_length);
807
+ if (!data_buffer) throw deserialize_error("data too short");
808
+ let file_offsets;
809
+ let files_start_offset;
810
+ if (file_offsets_length > 0) {
811
+ const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
812
+ if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
813
+ const parsed_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));
814
+ if (!Array.isArray(parsed_offsets) || parsed_offsets.some((n) => typeof n !== "number" || !Number.isInteger(n) || n < 0)) {
815
+ throw deserialize_error("invalid file offset table");
816
+ }
817
+ file_offsets = /** @type {Array<number>} */
818
+ parsed_offsets;
819
+ files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
820
+ }
821
+ const [data, meta] = parse(text_decoder.decode(data_buffer), {
822
+ File: ([name, type, size, last_modified, index]) => {
823
+ if (typeof name !== "string" || typeof type !== "string" || typeof size !== "number" || typeof last_modified !== "number" || typeof index !== "number") {
824
+ throw deserialize_error("invalid file metadata");
825
+ }
826
+ if (files_start_offset + file_offsets[index] + size > content_length) {
827
+ throw deserialize_error("file data overflow");
828
+ }
829
+ return new Proxy(
830
+ new LazyFile(
831
+ name,
832
+ type,
833
+ size,
834
+ last_modified,
835
+ get_chunk,
836
+ files_start_offset + file_offsets[index]
837
+ ),
838
+ {
839
+ getPrototypeOf() {
840
+ return File.prototype;
841
+ }
842
+ }
843
+ );
844
+ }
845
+ });
846
+ void (async () => {
847
+ let has_more = true;
848
+ while (has_more) {
849
+ const chunk = await get_chunk(chunks.length);
850
+ has_more = !!chunk;
851
+ }
852
+ })();
853
+ return { data, meta, form_data: null };
854
+ }
855
+ function deserialize_error(message) {
856
+ return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`);
857
+ }
858
+ class LazyFile {
859
+ /** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */
860
+ #get_chunk;
861
+ /** @type {number} */
862
+ #offset;
863
+ /**
864
+ * @param {string} name
865
+ * @param {string} type
866
+ * @param {number} size
867
+ * @param {number} last_modified
868
+ * @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
869
+ * @param {number} offset
870
+ */
871
+ constructor(name, type, size, last_modified, get_chunk, offset) {
872
+ this.name = name;
873
+ this.type = type;
874
+ this.size = size;
875
+ this.lastModified = last_modified;
876
+ this.webkitRelativePath = "";
877
+ this.#get_chunk = get_chunk;
878
+ this.#offset = offset;
879
+ this.arrayBuffer = this.arrayBuffer.bind(this);
880
+ this.bytes = this.bytes.bind(this);
881
+ this.slice = this.slice.bind(this);
882
+ this.stream = this.stream.bind(this);
883
+ this.text = this.text.bind(this);
884
+ }
885
+ /** @type {ArrayBuffer | undefined} */
886
+ #buffer;
887
+ async arrayBuffer() {
888
+ this.#buffer ??= await new Response(this.stream()).arrayBuffer();
889
+ return this.#buffer;
890
+ }
891
+ async bytes() {
892
+ return new Uint8Array(await this.arrayBuffer());
893
+ }
894
+ /**
895
+ * @param {number=} start
896
+ * @param {number=} end
897
+ * @param {string=} contentType
898
+ */
899
+ slice(start = 0, end = this.size, contentType = this.type) {
900
+ if (start < 0) {
901
+ start = Math.max(this.size + start, 0);
902
+ } else {
903
+ start = Math.min(start, this.size);
904
+ }
905
+ if (end < 0) {
906
+ end = Math.max(this.size + end, 0);
907
+ } else {
908
+ end = Math.min(end, this.size);
909
+ }
910
+ const size = Math.max(end - start, 0);
911
+ const file = new LazyFile(
912
+ this.name,
913
+ contentType,
914
+ size,
915
+ this.lastModified,
916
+ this.#get_chunk,
917
+ this.#offset + start
918
+ );
919
+ return file;
920
+ }
921
+ stream() {
922
+ let cursor = 0;
923
+ let chunk_index = 0;
924
+ return new ReadableStream({
925
+ start: async (controller) => {
926
+ let chunk_start = 0;
927
+ let start_chunk;
928
+ for (chunk_index = 0; ; chunk_index++) {
929
+ const chunk = await this.#get_chunk(chunk_index);
930
+ if (!chunk) return null;
931
+ const chunk_end = chunk_start + chunk.byteLength;
932
+ if (this.#offset >= chunk_start && this.#offset < chunk_end) {
933
+ start_chunk = chunk;
934
+ break;
935
+ }
936
+ chunk_start = chunk_end;
937
+ }
938
+ if (this.#offset + this.size <= chunk_start + start_chunk.byteLength) {
939
+ controller.enqueue(
940
+ start_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start)
941
+ );
942
+ controller.close();
943
+ } else {
944
+ controller.enqueue(start_chunk.subarray(this.#offset - chunk_start));
945
+ cursor = start_chunk.byteLength - this.#offset + chunk_start;
946
+ }
947
+ },
948
+ pull: async (controller) => {
949
+ chunk_index++;
950
+ let chunk = await this.#get_chunk(chunk_index);
951
+ if (!chunk) {
952
+ controller.error("incomplete file data");
953
+ controller.close();
954
+ return;
955
+ }
956
+ if (chunk.byteLength > this.size - cursor) {
957
+ chunk = chunk.subarray(0, this.size - cursor);
958
+ }
959
+ controller.enqueue(chunk);
960
+ cursor += chunk.byteLength;
961
+ if (cursor >= this.size) {
962
+ controller.close();
963
+ }
964
+ }
965
+ });
966
+ }
967
+ async text() {
968
+ return text_decoder.decode(await this.arrayBuffer());
969
+ }
970
+ }
971
+ const path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/;
972
+ function split_path(path) {
973
+ if (!path_regex.test(path)) {
974
+ throw new Error(`Invalid path ${path}`);
975
+ }
976
+ return path.split(/\.|\[|\]/).filter(Boolean);
977
+ }
978
+ function check_prototype_pollution(key) {
979
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
980
+ throw new Error(
981
+ `Invalid key "${key}"`
982
+ );
983
+ }
984
+ }
985
+ function deep_set(object, keys, value) {
986
+ let current = object;
987
+ for (let i = 0; i < keys.length - 1; i += 1) {
988
+ const key = keys[i];
989
+ check_prototype_pollution(key);
990
+ const is_array = /^\d+$/.test(keys[i + 1]);
991
+ const exists = Object.hasOwn(current, key);
992
+ const inner = current[key];
993
+ if (exists && is_array !== Array.isArray(inner)) {
994
+ throw new Error(`Invalid array key ${keys[i + 1]}`);
995
+ }
996
+ if (!exists) {
997
+ current[key] = is_array ? [] : {};
998
+ }
999
+ current = current[key];
1000
+ }
1001
+ const final_key = keys[keys.length - 1];
1002
+ check_prototype_pollution(final_key);
1003
+ current[final_key] = value;
1004
+ }
1005
+ function negotiate(accept, types) {
1006
+ const parts = [];
1007
+ accept.split(",").forEach((str, i) => {
1008
+ const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
1009
+ if (match) {
1010
+ const [, type, subtype, q = "1"] = match;
1011
+ parts.push({ type, subtype, q: +q, i });
1012
+ }
1013
+ });
1014
+ parts.sort((a, b) => {
1015
+ if (a.q !== b.q) {
1016
+ return b.q - a.q;
1017
+ }
1018
+ if (a.subtype === "*" !== (b.subtype === "*")) {
1019
+ return a.subtype === "*" ? 1 : -1;
1020
+ }
1021
+ if (a.type === "*" !== (b.type === "*")) {
1022
+ return a.type === "*" ? 1 : -1;
1023
+ }
1024
+ return a.i - b.i;
1025
+ });
1026
+ let accepted;
1027
+ let min_priority = Infinity;
1028
+ for (const mimetype of types) {
1029
+ const [type, subtype] = mimetype.split("/");
1030
+ const priority = parts.findIndex(
1031
+ (part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*")
1032
+ );
1033
+ if (priority !== -1 && priority < min_priority) {
1034
+ accepted = mimetype;
1035
+ min_priority = priority;
1036
+ }
1037
+ }
1038
+ return accepted;
1039
+ }
1040
+ function is_content_type(request, ...types) {
1041
+ const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
1042
+ return types.includes(type.toLowerCase());
1043
+ }
1044
+ function is_form_content_type(request) {
1045
+ return is_content_type(
1046
+ request,
1047
+ "application/x-www-form-urlencoded",
1048
+ "multipart/form-data",
1049
+ "text/plain",
1050
+ BINARY_FORM_CONTENT_TYPE
1051
+ );
1052
+ }
1053
+ function coalesce_to_error(err) {
1054
+ return err instanceof Error || err && /** @type {any} */
1055
+ err.name && /** @type {any} */
1056
+ err.message ? (
1057
+ /** @type {Error} */
1058
+ err
1059
+ ) : new Error(JSON.stringify(err));
1060
+ }
1061
+ function normalize_error(error) {
1062
+ return (
1063
+ /** @type {import('../exports/internal/index.js').Redirect | HttpError | SvelteKitError | Error} */
1064
+ error
1065
+ );
1066
+ }
1067
+ function get_status(error) {
1068
+ return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
1069
+ }
1070
+ function get_message(error) {
1071
+ return error instanceof SvelteKitError ? error.text : "Internal Error";
1072
+ }
1073
+ const escape_html_attr_dict = {
1074
+ "&": "&amp;",
1075
+ '"': "&quot;"
1076
+ // Svelte also escapes < because the escape function could be called inside a `noscript` there
1077
+ // https://github.com/sveltejs/svelte/security/advisories/GHSA-8266-84wp-wv5c
1078
+ // However, that doesn't apply in SvelteKit
1079
+ };
1080
+ const escape_html_dict = {
1081
+ "&": "&amp;",
1082
+ "<": "&lt;"
1083
+ };
1084
+ const surrogates = (
1085
+ // high surrogate without paired low surrogate
1086
+ "[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]"
1087
+ );
1088
+ const escape_html_attr_regex = new RegExp(
1089
+ `[${Object.keys(escape_html_attr_dict).join("")}]|` + surrogates,
1090
+ "g"
1091
+ );
1092
+ const escape_html_regex = new RegExp(
1093
+ `[${Object.keys(escape_html_dict).join("")}]|` + surrogates,
1094
+ "g"
1095
+ );
1096
+ function escape_html(str, is_attr) {
1097
+ const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
1098
+ const escaped_str = str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {
1099
+ if (match.length === 2) {
1100
+ return match;
1101
+ }
1102
+ return dict[match] ?? `&#${match.charCodeAt(0)};`;
1103
+ });
1104
+ return escaped_str;
1105
+ }
1106
+ function method_not_allowed(mod, method) {
1107
+ return text(`${method} method not allowed`, {
1108
+ status: 405,
1109
+ headers: {
1110
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
1111
+ // "The server must generate an Allow header field in a 405 status code response"
1112
+ allow: allowed_methods(mod).join(", ")
1113
+ }
1114
+ });
1115
+ }
1116
+ function allowed_methods(mod) {
1117
+ const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
1118
+ if ("GET" in mod && !("HEAD" in mod)) {
1119
+ allowed.push("HEAD");
1120
+ }
1121
+ return allowed;
1122
+ }
1123
+ function get_global_name(options) {
1124
+ return `__sveltekit_${options.version_hash}`;
1125
+ }
1126
+ function static_error_page(options, status, message) {
1127
+ let page = options.templates.error({ status, message: escape_html(message) });
1128
+ return text(page, {
1129
+ headers: { "content-type": "text/html; charset=utf-8" },
1130
+ status
1131
+ });
1132
+ }
1133
+ async function handle_fatal_error(event, state, options, error) {
1134
+ error = error instanceof HttpError ? error : coalesce_to_error(error);
1135
+ const status = get_status(error);
1136
+ const body = await handle_error_and_jsonify(event, state, options, error);
1137
+ const type = negotiate(event.request.headers.get("accept") || "text/html", [
1138
+ "application/json",
1139
+ "text/html"
1140
+ ]);
1141
+ if (event.isDataRequest || type === "application/json") {
1142
+ return json(body, {
1143
+ status
1144
+ });
1145
+ }
1146
+ return static_error_page(options, status, body.message);
1147
+ }
1148
+ async function handle_error_and_jsonify(event, state, options, error) {
1149
+ if (error instanceof HttpError) {
1150
+ return { message: "Unknown Error", ...error.body };
1151
+ }
1152
+ const status = get_status(error);
1153
+ const message = get_message(error);
1154
+ return await with_request_store(
1155
+ { event, state },
1156
+ () => options.hooks.handleError({ error, event, status, message })
1157
+ ) ?? { message };
1158
+ }
1159
+ function redirect_response(status, location) {
1160
+ const response = new Response(void 0, {
1161
+ status,
1162
+ headers: { location }
1163
+ });
1164
+ return response;
1165
+ }
1166
+ function clarify_devalue_error(event, error) {
1167
+ if (error.path) {
1168
+ return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path}). If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`;
1169
+ }
1170
+ if (error.path === "") {
1171
+ return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
1172
+ }
1173
+ return error.message;
1174
+ }
1175
+ function serialize_uses(node) {
1176
+ const uses = {};
1177
+ if (node.uses && node.uses.dependencies.size > 0) {
1178
+ uses.dependencies = Array.from(node.uses.dependencies);
1179
+ }
1180
+ if (node.uses && node.uses.search_params.size > 0) {
1181
+ uses.search_params = Array.from(node.uses.search_params);
1182
+ }
1183
+ if (node.uses && node.uses.params.size > 0) {
1184
+ uses.params = Array.from(node.uses.params);
1185
+ }
1186
+ if (node.uses?.parent) uses.parent = 1;
1187
+ if (node.uses?.route) uses.route = 1;
1188
+ if (node.uses?.url) uses.url = 1;
1189
+ return uses;
1190
+ }
1191
+ function has_prerendered_path(manifest, pathname) {
1192
+ return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
1193
+ }
1194
+ function format_server_error(status, error, event) {
1195
+ const formatted_text = `
1196
+ \x1B[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1B[0m`;
1197
+ if (status === 404) {
1198
+ return formatted_text;
1199
+ }
1200
+ return `${formatted_text}
1201
+ ${error.stack}`;
1202
+ }
1203
+ function get_node_type(node_id) {
1204
+ const parts = node_id?.split("/");
1205
+ const filename = parts?.at(-1);
1206
+ if (!filename) return "unknown";
1207
+ const dot_parts = filename.split(".");
1208
+ return dot_parts.slice(0, -1).join(".");
1209
+ }
1210
+ const INVALIDATED_PARAM = "x-sveltekit-invalidated";
1211
+ const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
1212
+ function stringify(data, transport) {
1213
+ const encoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.encode]));
1214
+ return stringify$1(data, encoders);
1215
+ }
1216
+ function stringify_remote_arg(value, transport) {
1217
+ if (value === void 0) return "";
1218
+ const json_string = stringify(value, transport);
1219
+ const bytes = new TextEncoder().encode(json_string);
1220
+ return base64_encode(bytes).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
1221
+ }
1222
+ function parse_remote_arg(string, transport) {
1223
+ if (!string) return void 0;
1224
+ const json_string = text_decoder.decode(
1225
+ // no need to add back `=` characters, atob can handle it
1226
+ base64_decode(string.replaceAll("-", "+").replaceAll("_", "/"))
1227
+ );
1228
+ const decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode]));
1229
+ return parse(json_string, decoders);
1230
+ }
1231
+ function create_remote_key(id, payload) {
1232
+ return id + "/" + payload;
1233
+ }
1234
+
1235
+ export { ENDPOINT_METHODS as E, INVALIDATED_PARAM as I, PAGE_METHODS as P, SVELTE_KIT_ASSETS as S, TRAILING_SLASH_PARAM as T, has_prerendered_path as a, handle_fatal_error as b, create_remote_key as c, serialize_uses as d, clarify_devalue_error as e, format_server_error as f, get_global_name as g, handle_error_and_jsonify as h, is_form_content_type as i, get_status as j, normalize_error as k, static_error_page as l, method_not_allowed as m, negotiate as n, stringify as o, parse_remote_arg as p, deserialize_binary_form as q, redirect_response as r, stringify_remote_arg as s, get_node_type as t, stringify$1 as u, escape_html as v };
1236
+ //# sourceMappingURL=shared-bytReIJX.js.map