screenreader-speech-capture 0.0.1-preview.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +20 -0
  2. package/dist/cli.mjs +3876 -939
  3. package/dist/ui/adapter-node.js +11 -0
  4. package/dist/ui/client/_app/immutable/chunks/BMrJcSB7.js +3 -0
  5. package/dist/ui/client/_app/immutable/chunks/BMrJcSB7.js.br +0 -0
  6. package/dist/ui/client/_app/immutable/chunks/BMrJcSB7.js.gz +0 -0
  7. package/dist/ui/client/_app/immutable/chunks/Bjy-W4x2.js +81 -0
  8. package/dist/ui/client/_app/immutable/chunks/Bjy-W4x2.js.br +0 -0
  9. package/dist/ui/client/_app/immutable/chunks/Bjy-W4x2.js.gz +0 -0
  10. package/dist/ui/client/_app/immutable/chunks/BueZJg5y.js +2 -0
  11. package/dist/ui/client/_app/immutable/chunks/BueZJg5y.js.br +0 -0
  12. package/dist/ui/client/_app/immutable/chunks/BueZJg5y.js.gz +0 -0
  13. package/dist/ui/client/_app/immutable/chunks/DclECHGd.js +1 -0
  14. package/dist/ui/client/_app/immutable/chunks/DclECHGd.js.br +0 -0
  15. package/dist/ui/client/_app/immutable/chunks/DclECHGd.js.gz +0 -0
  16. package/dist/ui/client/_app/immutable/chunks/ZzrMKdp0.js +1 -0
  17. package/dist/ui/client/_app/immutable/chunks/ZzrMKdp0.js.br +0 -0
  18. package/dist/ui/client/_app/immutable/chunks/ZzrMKdp0.js.gz +0 -0
  19. package/dist/ui/client/_app/immutable/entry/app.BGREpuCm.js +2 -0
  20. package/dist/ui/client/_app/immutable/entry/app.BGREpuCm.js.br +0 -0
  21. package/dist/ui/client/_app/immutable/entry/app.BGREpuCm.js.gz +0 -0
  22. package/dist/ui/client/_app/immutable/entry/payload.DSmR2FwN.js +1 -0
  23. package/dist/ui/client/_app/immutable/entry/payload.DSmR2FwN.js.br +0 -0
  24. package/dist/ui/client/_app/immutable/entry/payload.DSmR2FwN.js.gz +0 -0
  25. package/dist/ui/client/_app/immutable/entry/start.Bj3y6VYi.js +2 -0
  26. package/dist/ui/client/_app/immutable/entry/start.Bj3y6VYi.js.br +0 -0
  27. package/dist/ui/client/_app/immutable/entry/start.Bj3y6VYi.js.gz +0 -0
  28. package/dist/ui/client/_app/immutable/nodes/0.BdmtdjrF.js +1 -0
  29. package/dist/ui/client/_app/immutable/nodes/0.BdmtdjrF.js.br +0 -0
  30. package/dist/ui/client/_app/immutable/nodes/0.BdmtdjrF.js.gz +0 -0
  31. package/dist/ui/client/_app/immutable/nodes/1.B76I_t5U.js +1 -0
  32. package/dist/ui/client/_app/immutable/nodes/1.B76I_t5U.js.br +0 -0
  33. package/dist/ui/client/_app/immutable/nodes/1.B76I_t5U.js.gz +0 -0
  34. package/dist/ui/client/_app/immutable/nodes/2.CpNTEXmI.js +1 -0
  35. package/dist/ui/client/_app/immutable/nodes/2.CpNTEXmI.js.br +0 -0
  36. package/dist/ui/client/_app/immutable/nodes/2.CpNTEXmI.js.gz +0 -0
  37. package/dist/ui/client/_app/version.json +1 -0
  38. package/dist/ui/client/_app/version.json.br +0 -0
  39. package/dist/ui/client/_app/version.json.gz +0 -0
  40. package/dist/ui/client/robots.txt +3 -0
  41. package/dist/ui/client/robots.txt.br +0 -0
  42. package/dist/ui/client/robots.txt.gz +0 -0
  43. package/dist/ui/handler.js +1 -0
  44. package/dist/ui/index.js +1 -0
  45. package/dist/ui/server/.vite/manifest.json +186 -0
  46. package/dist/ui/server/adapter-env.js +1 -0
  47. package/dist/ui/server/adapter-index.js +73 -0
  48. package/dist/ui/server/adapter-index.js.map +1 -0
  49. package/dist/ui/server/adapter-node-env.js +63 -0
  50. package/dist/ui/server/adapter-node-env.js.map +1 -0
  51. package/dist/ui/server/adapter-node-handler.js +616 -0
  52. package/dist/ui/server/adapter-node-handler.js.map +1 -0
  53. package/dist/ui/server/chunks/config.js +9 -0
  54. package/dist/ui/server/chunks/config.js.map +1 -0
  55. package/dist/ui/server/chunks/exports.js +484 -0
  56. package/dist/ui/server/chunks/exports.js.map +1 -0
  57. package/dist/ui/server/chunks/functions.js +29 -0
  58. package/dist/ui/server/chunks/functions.js.map +1 -0
  59. package/dist/ui/server/chunks/instance.js +3568 -0
  60. package/dist/ui/server/chunks/instance.js.map +1 -0
  61. package/dist/ui/server/chunks/internal.js +2900 -0
  62. package/dist/ui/server/chunks/internal.js.map +1 -0
  63. package/dist/ui/server/chunks/server-errors.js +487 -0
  64. package/dist/ui/server/chunks/server-errors.js.map +1 -0
  65. package/dist/ui/server/chunks/server.js +8 -0
  66. package/dist/ui/server/chunks/server.js.map +1 -0
  67. package/dist/ui/server/chunks/server2.js +1368 -0
  68. package/dist/ui/server/chunks/server2.js.map +1 -0
  69. package/dist/ui/server/chunks/shared.js +85 -0
  70. package/dist/ui/server/chunks/shared.js.map +1 -0
  71. package/dist/ui/server/chunks/uneval.js +534 -0
  72. package/dist/ui/server/chunks/uneval.js.map +1 -0
  73. package/dist/ui/server/entries/fallbacks/error.svelte.js +44 -0
  74. package/dist/ui/server/entries/fallbacks/error.svelte.js.map +1 -0
  75. package/dist/ui/server/entries/pages/_layout.server.ts.js +987 -0
  76. package/dist/ui/server/entries/pages/_layout.server.ts.js.map +1 -0
  77. package/dist/ui/server/entries/pages/_layout.svelte.js +15 -0
  78. package/dist/ui/server/entries/pages/_layout.svelte.js.map +1 -0
  79. package/dist/ui/server/entries/pages/_page.svelte.js +11 -0
  80. package/dist/ui/server/entries/pages/_page.svelte.js.map +1 -0
  81. package/dist/ui/server/env.js +1 -0
  82. package/dist/ui/server/handler.js +1 -0
  83. package/dist/ui/server/index.js +67 -0
  84. package/dist/ui/server/index.js.map +1 -0
  85. package/dist/ui/server/manifest-full.js +37 -0
  86. package/dist/ui/server/manifest.js +37 -0
  87. package/dist/ui/server/nodes/0.js +10 -0
  88. package/dist/ui/server/nodes/1.js +8 -0
  89. package/dist/ui/server/nodes/2.js +8 -0
  90. package/dist/ui/server/remote-entry.js +1565 -0
  91. package/dist/ui/server/remote-entry.js.map +1 -0
  92. package/dist/ui/server/server.js +39 -0
  93. package/package.json +18 -2
@@ -0,0 +1,2900 @@
1
+ import { A as ENDPOINT_METHODS, C as param_matcher_result_invalid, O as with_request_store, S as param_matcher_async, T as merge_tracing, _ as form_field_unbound, g as form_field_invalid_name, h as form_field_forbidden_key, i as depends_special_scheme, m as form_field_duplicate, p as form_field_array_conflict, r as text, t as error, w as remote_argument_unsupported, x as load_invalid_response } from "./exports.js";
2
+ import { a as SvelteKitError, i as Redirect, n as HandledHttpError, o as ValidationError, r as HttpError, t as ActionFailure } from "./shared.js";
3
+ import { Z as capture_error, h as handle_error_hook_failed, i as action_response_not_serializable, n as action_default_with_named, r as action_name_reserved, s as action_throw_fail, t as action_data_not_serializable, v as load_not_plain_object, y as load_not_serializable } from "./server-errors.js";
4
+ import { a as is_buffer, c as is_valid_array_len, d as valid_array_indices, f as MAX_ARRAY_INDEX, i as get_type, l as stringify_key, n as DevalueError, o as is_plain_object$1, r as enumerable_symbols, s as is_valid_array_index, t as uneval$1, u as stringify_string } from "./uneval.js";
5
+ import { n as noop } from "./functions.js";
6
+ var assets = "";
7
+ var app_dir = "_app";
8
+ /** @param {string} path */
9
+ function set_assets(path) {
10
+ assets = path;
11
+ }
12
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/server/dev.js
13
+ var symbol = Symbol.for("sveltekit.global_state");
14
+ var state = globalThis[symbol] ??= {};
15
+ /**
16
+ * Persist a value across dev server reloads, in case a freshly-invalidated module
17
+ * reads global state that is not set until a request is handled
18
+ * @param {symbol} key
19
+ * @param {any} value
20
+ */
21
+ function save(key, value) {
22
+ state[key] = value;
23
+ }
24
+ /**
25
+ * Restore a value after a dev server reload
26
+ * @param {symbol} key
27
+ */
28
+ function restore(key) {
29
+ return state[key];
30
+ }
31
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/utils.js
32
+ var text_encoder = new TextEncoder();
33
+ /**
34
+ * `ReadableStream.from`, for runtimes that don't support it (as of writing, every Bun release)
35
+ * @template T
36
+ * @param {AsyncIterable<T>} iterable
37
+ * @returns {ReadableStream<T>}
38
+ */
39
+ function stream_from_iterable(iterable) {
40
+ if (ReadableStream.from) return ReadableStream.from(iterable);
41
+ const iterator = iterable[Symbol.asyncIterator]();
42
+ return new ReadableStream({
43
+ async pull(controller) {
44
+ const { value, done } = await iterator.next();
45
+ if (done) controller.close();
46
+ else controller.enqueue(value);
47
+ },
48
+ async cancel(reason) {
49
+ await iterator.return?.(reason);
50
+ }
51
+ });
52
+ }
53
+ /**
54
+ * @param {string} head
55
+ * @param {AsyncIterable<string>} chunks
56
+ * @returns {ReadableStream<Uint8Array>} `head` followed by each non-empty chunk, encoded
57
+ */
58
+ function stream_text(head, chunks) {
59
+ return stream_from_iterable((async function* () {
60
+ yield text_encoder.encode(head);
61
+ for await (const chunk of chunks) if (chunk) yield text_encoder.encode(chunk);
62
+ })());
63
+ }
64
+ var text_decoder = new TextDecoder();
65
+ /**
66
+ * @param {Uint8Array} bytes
67
+ * @returns {string}
68
+ */
69
+ function base64_encode(bytes) {
70
+ if (globalThis.Buffer) return globalThis.Buffer.from(bytes).toString("base64");
71
+ let binary = "";
72
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
73
+ return btoa(binary);
74
+ }
75
+ /**
76
+ * @param {string} encoded
77
+ * @returns {Uint8Array}
78
+ */
79
+ function base64_decode(encoded) {
80
+ if (globalThis.Buffer) {
81
+ const buffer = globalThis.Buffer.from(encoded, "base64");
82
+ return new Uint8Array(buffer);
83
+ }
84
+ const binary = atob(encoded);
85
+ const bytes = new Uint8Array(binary.length);
86
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
87
+ return bytes;
88
+ }
89
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/pathname.js
90
+ var DATA_SUFFIX = "/__data.json";
91
+ var HTML_DATA_SUFFIX = ".html__data.json";
92
+ /** @param {string} pathname */
93
+ function has_data_suffix(pathname) {
94
+ return pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX);
95
+ }
96
+ /** @param {string} pathname */
97
+ function add_data_suffix(pathname) {
98
+ if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_DATA_SUFFIX);
99
+ return pathname.replace(/\/$/, "") + DATA_SUFFIX;
100
+ }
101
+ /** @param {string} pathname */
102
+ function strip_data_suffix(pathname) {
103
+ if (pathname.endsWith(HTML_DATA_SUFFIX)) return pathname.slice(0, -16) + ".html";
104
+ return pathname.slice(0, -12);
105
+ }
106
+ var ROUTE_SUFFIX = "/__route.js";
107
+ var HTML_ROUTE_SUFFIX = ".html__route.js";
108
+ /**
109
+ * @param {string} pathname
110
+ * @returns {boolean}
111
+ */
112
+ function has_resolution_suffix(pathname) {
113
+ return pathname.endsWith(ROUTE_SUFFIX) || pathname.endsWith(HTML_ROUTE_SUFFIX);
114
+ }
115
+ /**
116
+ * Convert a regular URL to a route to send to SvelteKit's server-side route resolution endpoint
117
+ * @param {string} pathname
118
+ * @returns {string}
119
+ */
120
+ function add_resolution_suffix(pathname) {
121
+ if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_ROUTE_SUFFIX);
122
+ return pathname.replace(/\/$/, "") + ROUTE_SUFFIX;
123
+ }
124
+ /**
125
+ * @param {string} pathname
126
+ * @returns {string}
127
+ */
128
+ function strip_resolution_suffix(pathname) {
129
+ if (pathname.endsWith(HTML_ROUTE_SUFFIX)) return pathname.slice(0, -15) + ".html";
130
+ return pathname.slice(0, -11);
131
+ }
132
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/telemetry.js
133
+ /** @import { Span, SpanContext } from '@opentelemetry/api' */
134
+ /**
135
+ * @type {Span}
136
+ */
137
+ var noop_span = {
138
+ spanContext() {
139
+ return noop_span_context;
140
+ },
141
+ setAttribute() {
142
+ return this;
143
+ },
144
+ setAttributes() {
145
+ return this;
146
+ },
147
+ addEvent() {
148
+ return this;
149
+ },
150
+ setStatus() {
151
+ return this;
152
+ },
153
+ updateName() {
154
+ return this;
155
+ },
156
+ end() {
157
+ return this;
158
+ },
159
+ isRecording() {
160
+ return false;
161
+ },
162
+ recordException() {
163
+ return this;
164
+ },
165
+ addLink() {
166
+ return this;
167
+ },
168
+ addLinks() {
169
+ return this;
170
+ }
171
+ };
172
+ /**
173
+ * @type {SpanContext}
174
+ */
175
+ var noop_span_context = {
176
+ traceId: "",
177
+ spanId: "",
178
+ traceFlags: 0
179
+ };
180
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/exports/internal/server/telemetry.js
181
+ /** @import { Tracer, SpanStatusCode, PropagationAPI, ContextAPI } from '@opentelemetry/api' */
182
+ /** @import { RecordSpan } from 'types' */
183
+ /** @type {Promise<{ tracer: Tracer, SpanStatusCode: typeof SpanStatusCode, propagation: PropagationAPI, context: ContextAPI }> | null} */
184
+ var otel = null;
185
+ /** @type {RecordSpan} */
186
+ async function record_span({ name, attributes, fn }) {
187
+ if (otel === null) return fn(noop_span);
188
+ const { SpanStatusCode, tracer } = await otel;
189
+ return tracer.startActiveSpan(name, { attributes }, async (span) => {
190
+ try {
191
+ return await fn(span);
192
+ } catch (error) {
193
+ if (error instanceof HttpError) {
194
+ span.setAttributes({
195
+ [`${name}.result.type`]: "known_error",
196
+ [`${name}.result.status`]: error.status,
197
+ [`${name}.result.message`]: error.body.message
198
+ });
199
+ if (error.status >= 500) {
200
+ span.recordException({
201
+ name: "HttpError",
202
+ message: error.body.message
203
+ });
204
+ span.setStatus({
205
+ code: SpanStatusCode.ERROR,
206
+ message: error.body.message
207
+ });
208
+ }
209
+ } else if (error instanceof Redirect) span.setAttributes({
210
+ [`${name}.result.type`]: "redirect",
211
+ [`${name}.result.status`]: error.status,
212
+ [`${name}.result.location`]: error.location
213
+ });
214
+ else if (error instanceof Error) {
215
+ span.setAttributes({ [`${name}.result.type`]: "unknown_error" });
216
+ span.recordException({
217
+ name: error.name,
218
+ message: error.message,
219
+ ...error.stack !== void 0 && { stack: error.stack }
220
+ });
221
+ span.setStatus({
222
+ code: SpanStatusCode.ERROR,
223
+ message: error.message
224
+ });
225
+ } else {
226
+ span.setAttributes({ [`${name}.result.type`]: "unknown_error" });
227
+ span.setStatus({ code: SpanStatusCode.ERROR });
228
+ }
229
+ throw error;
230
+ } finally {
231
+ span.end();
232
+ }
233
+ });
234
+ }
235
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/utils/routing.js
236
+ /** @import { ParamMatcher, ParamValue } from '@sveltejs/kit/params' */
237
+ var escape_sequence_pattern = /\[([ux])\+([^\]]+)\]/;
238
+ /**
239
+ * @param {ParamMatcher} matcher
240
+ * @param {string} value
241
+ * @returns {{ success: true, value: any } | { success: false }}
242
+ */
243
+ function run_matcher(matcher, value) {
244
+ const result = matcher["~standard"].validate(value);
245
+ if (result instanceof Promise) param_matcher_async();
246
+ if (result.issues) return { success: false };
247
+ const parsed = result.value;
248
+ if (typeof parsed !== "string" && typeof parsed !== "number" && typeof parsed !== "boolean" && typeof parsed !== "bigint") param_matcher_result_invalid();
249
+ return {
250
+ success: true,
251
+ value: parsed
252
+ };
253
+ }
254
+ /**
255
+ * @param {RegExpMatchArray} match
256
+ * @param {import('types').RouteParam[]} params
257
+ * @param {Record<string, ParamMatcher>} matchers
258
+ */
259
+ function exec(match, params, matchers) {
260
+ /** @type {Record<string, any>} */
261
+ const result = {};
262
+ const values = match.slice(1);
263
+ const values_needing_match = values.filter((value) => value !== void 0);
264
+ let buffered = 0;
265
+ for (let i = 0; i < params.length; i += 1) {
266
+ const param = params[i];
267
+ let value = values[i - buffered];
268
+ if (param.chained && param.rest && buffered) {
269
+ value = values.slice(i - buffered, i + 1).filter((s) => s).join("/");
270
+ buffered = 0;
271
+ }
272
+ if (value === void 0) {
273
+ if (param.rest) value = "";
274
+ else continue;
275
+ }
276
+ const decoded = decodeURIComponent(value);
277
+ if (param.matcher) {
278
+ const outcome = run_matcher(matchers[param.matcher], decoded);
279
+ if (!outcome.success) {
280
+ if (param.optional && param.chained) {
281
+ buffered++;
282
+ continue;
283
+ }
284
+ return;
285
+ }
286
+ result[param.name] = outcome.value;
287
+ } else result[param.name] = decoded;
288
+ const next_param = params[i + 1];
289
+ const next_value = values[i + 1];
290
+ if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) buffered = 0;
291
+ if (!next_param && !next_value && Object.keys(result).length === values_needing_match.length) buffered = 0;
292
+ }
293
+ if (buffered) return;
294
+ return result;
295
+ }
296
+ new RegExp(`${escape_sequence_pattern.source}|${/\[(\[)?(\.\.\.)?([\w-]+?)(?:=([\w-]+))?\]\]?/g.source}`, "g");
297
+ /**
298
+ * Find the first route that matches the given path
299
+ * @template {{pattern: RegExp, params: import('types').RouteParam[]}} Route
300
+ * @param {string} path - The decoded pathname to match
301
+ * @param {Route[]} routes
302
+ * @param {Record<string, ParamMatcher>} matchers
303
+ * @returns {{ route: Route, params: Record<string, any> } | null}
304
+ */
305
+ function find_route(path, routes, matchers) {
306
+ for (const route of routes) {
307
+ const match = route.pattern.exec(path);
308
+ if (!match) continue;
309
+ const matched = exec(match, route.params, matchers);
310
+ if (matched) return {
311
+ route,
312
+ params: matched
313
+ };
314
+ }
315
+ return null;
316
+ }
317
+ // ../../node_modules/.pnpm/devalue@5.9.4/node_modules/devalue/src/base64.js
318
+ /** @type {(array_buffer: ArrayBuffer) => string} */
319
+ function encode_native(array_buffer) {
320
+ return new Uint8Array(array_buffer).toBase64();
321
+ }
322
+ /** @type {(base64: string) => ArrayBuffer} */
323
+ function decode_native(base64) {
324
+ return Uint8Array.fromBase64(base64).buffer;
325
+ }
326
+ /** @type {(array_buffer: ArrayBuffer) => string} */
327
+ function encode_buffer(array_buffer) {
328
+ return Buffer.from(array_buffer).toString("base64");
329
+ }
330
+ /** @type {(base64: string) => ArrayBuffer} */
331
+ function decode_buffer(base64) {
332
+ return Uint8Array.from(Buffer.from(base64, "base64")).buffer;
333
+ }
334
+ /** @type {(array_buffer: ArrayBuffer) => string} */
335
+ function encode_legacy(array_buffer) {
336
+ const array = new Uint8Array(array_buffer);
337
+ let binary = "";
338
+ const chunk_size = 32768;
339
+ for (let i = 0; i < array.length; i += chunk_size) {
340
+ const chunk = array.subarray(i, i + chunk_size);
341
+ binary += String.fromCharCode.apply(null, chunk);
342
+ }
343
+ return btoa(binary);
344
+ }
345
+ /** @type {(base64: string) => ArrayBuffer} */
346
+ function decode_legacy(base64) {
347
+ const binary_string = atob(base64);
348
+ const len = binary_string.length;
349
+ const array = new Uint8Array(len);
350
+ for (let i = 0; i < len; i++) array[i] = binary_string.charCodeAt(i);
351
+ return array.buffer;
352
+ }
353
+ var native = typeof Uint8Array.fromBase64 === "function";
354
+ var buffer = typeof process === "object" && process.versions?.node !== void 0;
355
+ var encode64 = native ? encode_native : buffer ? encode_buffer : encode_legacy;
356
+ var decode64 = native ? decode_native : buffer ? decode_buffer : decode_legacy;
357
+ // ../../node_modules/.pnpm/devalue@5.9.4/node_modules/devalue/src/operations.js
358
+ /**
359
+ * Merges caller-provided operation overrides over the defaults. Iterating the
360
+ * default keys (rather than the override's own keys) means nullish members
361
+ * fall back to the default, and inherited members — e.g. from a class
362
+ * instance — are picked up.
363
+ *
364
+ * @template {Record<string, any>} T
365
+ * @param {T} defaults
366
+ * @param {Partial<T> | undefined} overrides
367
+ * @returns {T}
368
+ */
369
+ function merge_operations(defaults, overrides) {
370
+ if (!overrides) return defaults;
371
+ const merged = {};
372
+ for (const key of Object.keys(defaults)) merged[key] = overrides[key] ?? defaults[key];
373
+ return merged;
374
+ }
375
+ /** @type {{ kind: 'not-plain' }} */
376
+ var NOT_PLAIN = /* @__PURE__ */ Object.freeze({ kind: "not-plain" });
377
+ /** @type {{ kind: 'symbol-keys' }} */
378
+ var SYMBOL_KEYS = /* @__PURE__ */ Object.freeze({ kind: "symbol-keys" });
379
+ var default_stringify_operations = /* @__PURE__ */ Object.freeze({
380
+ identify: (value) => value,
381
+ typeOf: (value) => value === null ? "null" : typeof value,
382
+ toPrimitive: (value) => value,
383
+ tagOf: (value) => get_type(value),
384
+ isThenable: (value) => typeof value.then === "function",
385
+ toPromise: (thenable) => Promise.resolve(thenable),
386
+ unbox: (boxed) => boxed.valueOf(),
387
+ toISOString: (date) => isNaN(date.getDate()) ? "" : date.toISOString(),
388
+ toStringValue: (value) => value.toString(),
389
+ regExpInfo: (regexp) => ({
390
+ source: regexp.source,
391
+ flags: regexp.flags
392
+ }),
393
+ valuesOf: (set) => set,
394
+ entriesOf: (map) => map,
395
+ viewInfo: (view) => {
396
+ if (is_buffer(view)) view = new Uint8Array(view);
397
+ return {
398
+ buffer: view.buffer,
399
+ byteOffset: view.byteOffset,
400
+ byteLength: view.byteLength,
401
+ length: view.length,
402
+ bufferByteLength: view.buffer.byteLength
403
+ };
404
+ },
405
+ toArrayBuffer: (buffer) => buffer,
406
+ lengthOf: (array) => array.length,
407
+ hasOwn: (value, key) => Object.hasOwn(value, key),
408
+ indicesOf: (array) => valid_array_indices(array),
409
+ shapeOf: (value) => {
410
+ if (!is_plain_object$1(value)) return NOT_PLAIN;
411
+ if (enumerable_symbols(value).length > 0) return SYMBOL_KEYS;
412
+ return {
413
+ kind: Object.getPrototypeOf(value) === null ? "null-proto" : "plain",
414
+ keys: Object.keys(value)
415
+ };
416
+ },
417
+ get: (value, key) => value[key]
418
+ });
419
+ var array_buffer_byte_length = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
420
+ var shared_array_buffer_byte_length = typeof SharedArrayBuffer === "undefined" ? void 0 : Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
421
+ var default_parse_operations = /* @__PURE__ */ Object.freeze({
422
+ fromPrimitive: (primitive) => primitive,
423
+ fromISOString: (iso) => new Date(iso),
424
+ fromStringValue: (tag, text) => {
425
+ if (tag === "URL") return new URL(text);
426
+ if (tag === "URLSearchParams") return new URLSearchParams(text);
427
+ return Temporal[tag.slice(9)].from(text);
428
+ },
429
+ fromArrayBuffer: (buffer) => buffer,
430
+ fromRegExpInfo: (source, flags) => new RegExp(source, flags),
431
+ fromViewInfo: (tag, buffer, byteOffset, length) => {
432
+ try {
433
+ array_buffer_byte_length.call(buffer);
434
+ } catch (error) {
435
+ if (!shared_array_buffer_byte_length) throw error;
436
+ shared_array_buffer_byte_length.call(buffer);
437
+ }
438
+ const Constructor = globalThis[tag];
439
+ return byteOffset !== void 0 ? new Constructor(buffer, byteOffset, length) : new Constructor(buffer);
440
+ },
441
+ box: (value) => Object(value),
442
+ createArray: (length) => new Array(length),
443
+ createSparseArray: (length) => {
444
+ /** @type {any[]} */
445
+ const array = [];
446
+ array[MAX_ARRAY_INDEX] = void 0;
447
+ delete array[MAX_ARRAY_INDEX];
448
+ array.length = length;
449
+ return array;
450
+ },
451
+ createObject: () => ({}),
452
+ createNullPrototypeObject: () => Object.create(null),
453
+ createSet: () => /* @__PURE__ */ new Set(),
454
+ createMap: () => /* @__PURE__ */ new Map(),
455
+ set: (target, key, value) => {
456
+ target[key] = value;
457
+ },
458
+ addValue: (set, value) => {
459
+ set.add(value);
460
+ },
461
+ addEntry: (map, key, value) => {
462
+ map.set(key, value);
463
+ }
464
+ });
465
+ // ../../node_modules/.pnpm/devalue@5.9.4/node_modules/devalue/src/parse.js
466
+ /**
467
+ * Revive a value serialized with `devalue.stringify`
468
+ * @param {string} serialized
469
+ * @param {Record<string, (value: any) => any>} [revivers]
470
+ * @param {import('./types.js').ParseOptions} [options]
471
+ */
472
+ function parse$1(serialized, revivers, options) {
473
+ return unflatten(JSON.parse(serialized), revivers, options);
474
+ }
475
+ /**
476
+ * Revive a value flattened with `devalue.stringify`
477
+ * @param {number | any[]} parsed
478
+ * @param {Record<string, (value: any) => any>} [revivers]
479
+ * @param {import('./types.js').ParseOptions} [options]
480
+ */
481
+ function unflatten(parsed, revivers, options) {
482
+ /** @type {import('./types.js').ParseOperations} */
483
+ const ops = merge_operations(default_parse_operations, options?.operations);
484
+ if (typeof parsed === "number") return hydrate(parsed, true);
485
+ if (!Array.isArray(parsed) || parsed.length === 0) throw new Error("Invalid input");
486
+ const values = parsed;
487
+ const hydrated = Array(values.length);
488
+ /**
489
+ * A set of values currently being hydrated with custom revivers,
490
+ * used to detect invalid cyclical dependencies
491
+ * @type {Set<number> | null}
492
+ */
493
+ let hydrating = null;
494
+ /**
495
+ * @param {number} index
496
+ * @returns {any}
497
+ */
498
+ function hydrate(index, standalone = false) {
499
+ if (index === -1) return ops.fromPrimitive(void 0);
500
+ if (index === -3) return ops.fromPrimitive(NaN);
501
+ if (index === -4) return ops.fromPrimitive(Infinity);
502
+ if (index === -5) return ops.fromPrimitive(-Infinity);
503
+ if (index === -6) return ops.fromPrimitive(-0);
504
+ if (standalone || typeof index !== "number") throw new Error(`Invalid input`);
505
+ if (index in hydrated) return hydrated[index];
506
+ if (index >= values.length) throw new Error(`Invalid input`);
507
+ const value = values[index];
508
+ if (!value || typeof value !== "object") hydrated[index] = ops.fromPrimitive(value);
509
+ else if (Array.isArray(value)) {
510
+ if (typeof value[0] === "string") {
511
+ const type = value[0];
512
+ const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
513
+ if (reviver) {
514
+ let i = value[1];
515
+ if (typeof i !== "number") i = values.push(value[1]) - 1;
516
+ if (Object.hasOwn(hydrated, i)) return hydrated[index] = reviver(hydrated[i]);
517
+ hydrating ??= /* @__PURE__ */ new Set();
518
+ if (hydrating.has(i)) throw new Error("Invalid circular reference");
519
+ hydrating.add(i);
520
+ hydrated[index] = reviver(hydrate(i));
521
+ hydrating.delete(i);
522
+ return hydrated[index];
523
+ }
524
+ switch (type) {
525
+ case "Date":
526
+ hydrated[index] = ops.fromISOString(value[1]);
527
+ break;
528
+ case "Set":
529
+ const set = ops.createSet();
530
+ hydrated[index] = set;
531
+ for (let i = 1; i < value.length; i += 1) ops.addValue(set, hydrate(value[i]));
532
+ break;
533
+ case "Map":
534
+ const map = ops.createMap();
535
+ hydrated[index] = map;
536
+ for (let i = 1; i < value.length; i += 2) ops.addEntry(map, hydrate(value[i]), hydrate(value[i + 1]));
537
+ break;
538
+ case "RegExp":
539
+ hydrated[index] = ops.fromRegExpInfo(value[1], value[2]);
540
+ break;
541
+ case "Object": {
542
+ const wrapped_index = value[1];
543
+ if (typeof values[wrapped_index] === "object" && values[wrapped_index][0] !== "BigInt") throw new Error("Invalid input");
544
+ hydrated[index] = ops.box(hydrate(wrapped_index));
545
+ break;
546
+ }
547
+ case "BigInt":
548
+ hydrated[index] = ops.fromPrimitive(BigInt(value[1]));
549
+ break;
550
+ case "null":
551
+ const obj = ops.createNullPrototypeObject();
552
+ hydrated[index] = obj;
553
+ for (let i = 1; i < value.length; i += 2) {
554
+ const key = value[i];
555
+ if (typeof key !== "string") throw new Error("Cannot parse an object with a non-string key");
556
+ if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
557
+ ops.set(obj, key, hydrate(value[i + 1]));
558
+ }
559
+ break;
560
+ case "Int8Array":
561
+ case "Uint8Array":
562
+ case "Uint8ClampedArray":
563
+ case "Int16Array":
564
+ case "Uint16Array":
565
+ case "Float16Array":
566
+ case "Int32Array":
567
+ case "Uint32Array":
568
+ case "Float32Array":
569
+ case "Float64Array":
570
+ case "BigInt64Array":
571
+ case "BigUint64Array":
572
+ case "DataView": {
573
+ if (values[value[1]][0] !== "ArrayBuffer") throw new Error("Invalid data");
574
+ const buffer = hydrate(value[1]);
575
+ hydrated[index] = ops.fromViewInfo(type, buffer, value[2], value[3]);
576
+ break;
577
+ }
578
+ case "ArrayBuffer": {
579
+ const base64 = value[1];
580
+ if (typeof base64 !== "string") throw new Error("Invalid ArrayBuffer encoding");
581
+ hydrated[index] = ops.fromArrayBuffer(decode64(base64));
582
+ break;
583
+ }
584
+ case "URL":
585
+ case "URLSearchParams":
586
+ case "Temporal.Duration":
587
+ case "Temporal.Instant":
588
+ case "Temporal.PlainDate":
589
+ case "Temporal.PlainTime":
590
+ case "Temporal.PlainDateTime":
591
+ case "Temporal.PlainMonthDay":
592
+ case "Temporal.PlainYearMonth":
593
+ case "Temporal.ZonedDateTime":
594
+ hydrated[index] = ops.fromStringValue(type, value[1]);
595
+ break;
596
+ default: throw new Error(`Unknown type ${type}`);
597
+ }
598
+ } else if (value[0] === -7) {
599
+ const len = value[1];
600
+ if (!is_valid_array_len(len)) throw new Error("Invalid input");
601
+ const array = ops.createSparseArray(len);
602
+ hydrated[index] = array;
603
+ for (let i = 2; i < value.length; i += 2) {
604
+ const idx = value[i];
605
+ if (!is_valid_array_index(idx) || idx >= len) throw new Error("Invalid input");
606
+ ops.set(array, idx, hydrate(value[i + 1]));
607
+ }
608
+ } else {
609
+ const array = ops.createArray(value.length);
610
+ hydrated[index] = array;
611
+ for (let i = 0; i < value.length; i += 1) {
612
+ const n = value[i];
613
+ if (n === -2) continue;
614
+ ops.set(array, i, hydrate(n));
615
+ }
616
+ }
617
+ } else {
618
+ const object = ops.createObject();
619
+ hydrated[index] = object;
620
+ for (const key of Object.keys(value)) {
621
+ if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
622
+ ops.set(object, key, hydrate(value[key]));
623
+ }
624
+ }
625
+ return hydrated[index];
626
+ }
627
+ return hydrate(0);
628
+ }
629
+ // ../../node_modules/.pnpm/devalue@5.9.4/node_modules/devalue/src/stringify.js
630
+ /**
631
+ * Turn a value into a JSON string that can be parsed with `devalue.parse`
632
+ * @param {any} value
633
+ * @param {Record<string, (value: any) => any>} [reducers]
634
+ * @param {import('./types.js').StringifyOptions} [options]
635
+ */
636
+ function stringify$1(value, reducers, options) {
637
+ const stringified = run(false, value, reducers, options);
638
+ return typeof stringified === "string" ? stringified : `[${stringified.join(",")}]`;
639
+ }
640
+ /**
641
+ * @param {boolean} async
642
+ * @param {any} value
643
+ * @param {Record<string, (value: any) => any>} [reducers]
644
+ * @param {import('./types.js').StringifyOptions} [options]
645
+ */
646
+ function run(async, value, reducers, options) {
647
+ const ops = merge_operations(default_stringify_operations, options?.operations);
648
+ /** @type {any[]} */
649
+ const stringified = [];
650
+ /** @type {Map<any, number>} */
651
+ const indexes = /* @__PURE__ */ new Map();
652
+ /** @type {Array<{ key: string, fn: (value: any) => any }>} */
653
+ const custom = [];
654
+ if (reducers) for (const key of Object.getOwnPropertyNames(reducers)) custom.push({
655
+ key,
656
+ fn: reducers[key]
657
+ });
658
+ /** @type {string[]} */
659
+ const keys = [];
660
+ let p = 0;
661
+ /**
662
+ * @param {any} thing
663
+ * @param {number} [index]
664
+ */
665
+ function flatten(thing, index) {
666
+ const type = ops.typeOf(thing);
667
+ if (type === "undefined") return -1;
668
+ /** @type {number | undefined} */
669
+ let number;
670
+ if (type === "number") {
671
+ number = ops.toPrimitive(thing);
672
+ if (Number.isNaN(number)) return -3;
673
+ if (number === Infinity) return -4;
674
+ if (number === -Infinity) return -5;
675
+ if (number === 0 && 1 / number < 0) return -6;
676
+ }
677
+ const id = ops.identify(thing);
678
+ if (indexes.has(id)) return indexes.get(id);
679
+ index ??= p++;
680
+ indexes.set(id, index);
681
+ for (const { key, fn } of custom) {
682
+ const value = fn(thing);
683
+ if (value) {
684
+ stringified[index] = `["${key}",${flatten(value)}]`;
685
+ return index;
686
+ }
687
+ }
688
+ if (type === "function") throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
689
+ else if (type === "symbol") throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
690
+ /** @type {string | Promise<any>} */
691
+ let str = "";
692
+ if (type !== "object") str = stringify_primitive(type === "number" ? number : ops.toPrimitive(thing));
693
+ else if (ops.isThenable(thing)) {
694
+ if (!async) throw new DevalueError(`Cannot stringify a Promise or thenable — use stringifyAsync instead`, keys, thing, value);
695
+ str = ops.toPromise(thing).then((value) => {
696
+ const i = flatten(value, index);
697
+ if (i < 0) stringified[index] = i;
698
+ });
699
+ str.catch(() => {});
700
+ } else {
701
+ const tag = ops.tagOf(thing);
702
+ switch (tag) {
703
+ case "Number":
704
+ case "String":
705
+ case "Boolean":
706
+ case "BigInt":
707
+ str = `["Object",${flatten(ops.unbox(thing))}]`;
708
+ break;
709
+ case "Date":
710
+ str = `["Date","${ops.toISOString(thing)}"]`;
711
+ break;
712
+ case "URL":
713
+ str = `["URL",${stringify_string(ops.toStringValue(thing))}]`;
714
+ break;
715
+ case "URLSearchParams":
716
+ str = `["URLSearchParams",${stringify_string(ops.toStringValue(thing))}]`;
717
+ break;
718
+ case "RegExp":
719
+ const { source, flags } = ops.regExpInfo(thing);
720
+ str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
721
+ break;
722
+ case "Array": {
723
+ let mostly_dense = false;
724
+ const length = ops.lengthOf(thing);
725
+ str = "[";
726
+ for (let i = 0; i < length; i += 1) {
727
+ if (i > 0) str += ",";
728
+ if (ops.hasOwn(thing, i)) {
729
+ keys.push(`[${i}]`);
730
+ str += flatten(ops.get(thing, i));
731
+ keys.pop();
732
+ } else if (mostly_dense) str += -2;
733
+ else {
734
+ const populated_keys = ops.indicesOf(thing);
735
+ const population = populated_keys.length;
736
+ const d = String(length).length;
737
+ if ((length - population) * 3 > 4 + d + population * (d + 1)) {
738
+ str = "[-7," + length;
739
+ for (let j = 0; j < populated_keys.length; j++) {
740
+ const key = populated_keys[j];
741
+ keys.push(`[${key}]`);
742
+ str += "," + key + "," + flatten(ops.get(thing, key));
743
+ keys.pop();
744
+ }
745
+ break;
746
+ } else {
747
+ mostly_dense = true;
748
+ str += -2;
749
+ }
750
+ }
751
+ }
752
+ str += "]";
753
+ break;
754
+ }
755
+ case "Set":
756
+ str = "[\"Set\"";
757
+ for (const value of ops.valuesOf(thing)) str += `,${flatten(value)}`;
758
+ str += "]";
759
+ break;
760
+ case "Map":
761
+ str = "[\"Map\"";
762
+ for (const [key, value] of ops.entriesOf(thing)) {
763
+ const key_type = ops.typeOf(key);
764
+ const key_is_primitive = key_type !== "object" && key_type !== "function" && key_type !== "symbol";
765
+ keys.push(`.get(${key_is_primitive ? stringify_primitive(ops.toPrimitive(key)) : "..."})`);
766
+ str += `,${flatten(key)},${flatten(value)}`;
767
+ keys.pop();
768
+ }
769
+ str += "]";
770
+ break;
771
+ case "Int8Array":
772
+ case "Uint8Array":
773
+ case "Uint8ClampedArray":
774
+ case "Int16Array":
775
+ case "Uint16Array":
776
+ case "Float16Array":
777
+ case "Int32Array":
778
+ case "Uint32Array":
779
+ case "Float32Array":
780
+ case "Float64Array":
781
+ case "BigInt64Array":
782
+ case "BigUint64Array": {
783
+ const info = ops.viewInfo(thing);
784
+ str = "[\"" + tag + "\"," + flatten(info.buffer);
785
+ if (info.byteLength !== info.bufferByteLength) str += `,${info.byteOffset},${info.length}`;
786
+ str += "]";
787
+ break;
788
+ }
789
+ case "DataView": {
790
+ const info = ops.viewInfo(thing);
791
+ str = "[\"" + tag + "\"," + flatten(info.buffer);
792
+ if (info.byteLength !== info.bufferByteLength) str += `,${info.byteOffset},${info.byteLength}`;
793
+ str += "]";
794
+ break;
795
+ }
796
+ case "ArrayBuffer":
797
+ str = `["ArrayBuffer","${encode64(ops.toArrayBuffer(thing))}"]`;
798
+ break;
799
+ case "Temporal.Duration":
800
+ case "Temporal.Instant":
801
+ case "Temporal.PlainDate":
802
+ case "Temporal.PlainTime":
803
+ case "Temporal.PlainDateTime":
804
+ case "Temporal.PlainMonthDay":
805
+ case "Temporal.PlainYearMonth":
806
+ case "Temporal.ZonedDateTime":
807
+ str = `["${tag}",${stringify_string(ops.toStringValue(thing))}]`;
808
+ break;
809
+ default: {
810
+ const shape = ops.shapeOf(thing);
811
+ if (shape.kind === "not-plain") throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
812
+ if (shape.kind === "symbol-keys") throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
813
+ if (shape.kind === "null-proto") {
814
+ str = "[\"null\"";
815
+ for (const key of shape.keys) {
816
+ if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
817
+ keys.push(stringify_key(key));
818
+ str += `,${stringify_string(key)},${flatten(ops.get(thing, key))}`;
819
+ keys.pop();
820
+ }
821
+ str += "]";
822
+ } else {
823
+ str = "{";
824
+ let started = false;
825
+ for (const key of shape.keys) {
826
+ if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
827
+ if (started) str += ",";
828
+ started = true;
829
+ keys.push(stringify_key(key));
830
+ str += `${stringify_string(key)}:${flatten(ops.get(thing, key))}`;
831
+ keys.pop();
832
+ }
833
+ str += "}";
834
+ }
835
+ }
836
+ }
837
+ }
838
+ stringified[index] = str;
839
+ return index;
840
+ }
841
+ const index = flatten(value);
842
+ if (index < 0) return `${index}`;
843
+ return stringified;
844
+ }
845
+ /**
846
+ * @param {any} thing
847
+ * @returns {string}
848
+ */
849
+ function stringify_primitive(thing) {
850
+ const type = typeof thing;
851
+ if (type === "string") return stringify_string(thing);
852
+ if (thing === void 0) return (-1).toString();
853
+ if (thing === 0 && 1 / thing < 0) return (-6).toString();
854
+ if (type === "bigint") return `["BigInt","${thing}"]`;
855
+ return String(thing);
856
+ }
857
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/form-utils.js
858
+ /** @import { BinaryFormMeta, InternalRemoteFormIssue } from 'types' */
859
+ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
860
+ /**
861
+ * Sets a parsed form field value in a nested object, mutating the original object.
862
+ * @param {Record<string, any>} object
863
+ * @param {{ name: string; type: 'number' | 'boolean' | null }} field
864
+ * @param {any} value
865
+ */
866
+ function set_nested_value(object, field, value) {
867
+ deep_set(object, split_path(field.name), value);
868
+ }
869
+ /**
870
+ * Separates a form field's path from the metadata encoded in its name.
871
+ * @param {string} form_id
872
+ * @param {string} key
873
+ * @returns {{ name: string; type: 'number' | 'boolean' | null; is_array: boolean }}
874
+ */
875
+ function parse_form_key(form_id, key) {
876
+ const suffix = "/" + form_id;
877
+ let name = key;
878
+ let image_coordinate = "";
879
+ if (name.startsWith("i:") && (name.endsWith(suffix + ".x") || name.endsWith(suffix + ".y"))) {
880
+ image_coordinate = name[name.length - 1];
881
+ name = name.slice(0, -2);
882
+ }
883
+ if (!name.endsWith(suffix)) form_field_unbound({ name });
884
+ name = name.slice(0, -suffix.length);
885
+ /** @type {'number' | 'boolean' | null} */
886
+ let type = null;
887
+ if (name.startsWith("n:")) {
888
+ name = name.slice(2);
889
+ type = "number";
890
+ } else if (name.startsWith("b:")) {
891
+ name = name.slice(2);
892
+ type = "boolean";
893
+ } else if (name.startsWith("i:")) {
894
+ name = name.slice(2);
895
+ type = "number";
896
+ }
897
+ const is_array = name.endsWith("[]");
898
+ if (is_array) name = name.slice(0, -2);
899
+ if (image_coordinate) name += "." + image_coordinate;
900
+ return {
901
+ name,
902
+ type,
903
+ is_array
904
+ };
905
+ }
906
+ /**
907
+ * @param {'number' | 'boolean' | null} type
908
+ * @param {any} value
909
+ * @returns {any}
910
+ */
911
+ function coerce_form_value(type, value) {
912
+ if (Array.isArray(value)) return value.map((value) => coerce_form_value(type, value));
913
+ if (type === "number") return value === "" ? void 0 : parseFloat(value);
914
+ if (type === "boolean") return value === "on";
915
+ return value;
916
+ }
917
+ /** Pass this to set_nested_value to delete the last part of the given path */
918
+ var DELETE_KEY = {};
919
+ /**
920
+ * Groups `FormData` entries by name in a single pass. Calling `data.getAll(name)`
921
+ * for each name is O(n²) in the number of entries, which is a DoS vector.
922
+ * @param {FormData} data
923
+ * @returns {Map<string, FormDataEntryValue[]>}
924
+ */
925
+ function group_formdata(data) {
926
+ /** @type {Map<string, FormDataEntryValue[]>} */
927
+ const grouped = /* @__PURE__ */ new Map();
928
+ for (const [name, value] of data) {
929
+ const values = grouped.get(name);
930
+ if (values) values.push(value);
931
+ else grouped.set(name, [value]);
932
+ }
933
+ return grouped;
934
+ }
935
+ /**
936
+ * Convert `FormData` into a POJO
937
+ * @param {string} form_id
938
+ * @param {FormData} data
939
+ */
940
+ function convert_formdata(form_id, data) {
941
+ /** @type {Record<string, any>} */
942
+ const result = {};
943
+ for (const [field_name, values] of group_formdata(data)) {
944
+ const field = parse_form_key(form_id, field_name);
945
+ const entries = values.filter((entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0);
946
+ if (entries.length === 0 && !field.is_array) continue;
947
+ if (entries.length > 1 && !field.is_array) form_field_duplicate({
948
+ name: field.name,
949
+ count: String(entries.length)
950
+ });
951
+ set_nested_value(result, field, coerce_form_value(field.type, field.is_array ? entries : entries[0]));
952
+ }
953
+ return result;
954
+ }
955
+ var BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata";
956
+ var BINARY_FORM_VERSION = 0;
957
+ var HEADER_BYTES = 7;
958
+ /**
959
+ * @param {Request} request
960
+ * @param {string} form_id
961
+ * @returns {Promise<{ data: Record<string, any>; meta: BinaryFormMeta; form_data: FormData | null }>}
962
+ */
963
+ async function deserialize_binary_form(request, form_id) {
964
+ if (request.headers.get("content-type") !== "application/x-sveltekit-formdata") {
965
+ const form_data = await request.formData();
966
+ return {
967
+ data: convert_formdata(form_id, form_data),
968
+ meta: {},
969
+ form_data
970
+ };
971
+ }
972
+ if (!request.body) throw deserialize_error("no body");
973
+ const reader = request.body.getReader();
974
+ /** @type {Array<Promise<Uint8Array<ArrayBuffer> | undefined>>} */
975
+ const chunks = [];
976
+ /**
977
+ * @param {number} index
978
+ * @returns {Promise<Uint8Array<ArrayBuffer> | undefined>}
979
+ */
980
+ function get_chunk(index) {
981
+ if (index in chunks) return chunks[index];
982
+ let i = chunks.length;
983
+ while (i <= index) {
984
+ const previous = chunks[i - 1] ?? Promise.resolve(void 0);
985
+ chunks[i] = previous.then(() => reader.read()).then((chunk) => chunk.value);
986
+ i++;
987
+ }
988
+ return chunks[index];
989
+ }
990
+ /**
991
+ * @param {number} offset
992
+ * @param {number} length
993
+ * @returns {Promise<Uint8Array | null>}
994
+ */
995
+ async function get_buffer(offset, length) {
996
+ /** @type {Uint8Array<ArrayBuffer>[]} */
997
+ const parts = [];
998
+ let total = 0;
999
+ for await (const part of read_range(get_chunk, offset, length)) {
1000
+ parts.push(part);
1001
+ total += part.byteLength;
1002
+ }
1003
+ if (total < length || parts.length === 0) return null;
1004
+ if (parts.length === 1) return parts[0];
1005
+ const buffer = new Uint8Array(length);
1006
+ let cursor = 0;
1007
+ for (const part of parts) {
1008
+ buffer.set(part, cursor);
1009
+ cursor += part.byteLength;
1010
+ }
1011
+ return buffer;
1012
+ }
1013
+ const header = await get_buffer(0, HEADER_BYTES);
1014
+ if (!header) throw deserialize_error("too short");
1015
+ if (header[0] !== BINARY_FORM_VERSION) throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
1016
+ const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
1017
+ const data_length = header_view.getUint32(1, true);
1018
+ const file_offsets_length = header_view.getUint16(5, true);
1019
+ const data_buffer = await get_buffer(HEADER_BYTES, data_length);
1020
+ if (!data_buffer) throw deserialize_error("data too short");
1021
+ /** @type {Array<number | undefined>} */
1022
+ let file_offsets;
1023
+ /** @type {number} */
1024
+ let files_start_offset;
1025
+ if (file_offsets_length > 0) {
1026
+ const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
1027
+ if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
1028
+ const parsed_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));
1029
+ if (!Array.isArray(parsed_offsets) || parsed_offsets.some((n) => typeof n !== "number" || !Number.isInteger(n) || n < 0)) throw deserialize_error("invalid file offset table");
1030
+ file_offsets = parsed_offsets;
1031
+ files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
1032
+ }
1033
+ /** @type {Array<{ offset: number, size: number }>} */
1034
+ const file_spans = [];
1035
+ const [data, meta] = parse$1(text_decoder.decode(data_buffer), { File: ([name, type, size, last_modified, index]) => {
1036
+ if (typeof name !== "string" || typeof type !== "string" || !Number.isSafeInteger(size) || size < 0 || !Number.isSafeInteger(last_modified) || !Number.isSafeInteger(index) || index < 0 || file_offsets === void 0) throw deserialize_error("invalid file metadata");
1037
+ let offset = file_offsets[index];
1038
+ if (offset === void 0) throw deserialize_error("duplicate file offset table index");
1039
+ file_offsets[index] = void 0;
1040
+ offset += files_start_offset;
1041
+ file_spans.push({
1042
+ offset,
1043
+ size
1044
+ });
1045
+ return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), { getPrototypeOf() {
1046
+ return File.prototype;
1047
+ } });
1048
+ } });
1049
+ file_spans.sort((a, b) => a.offset - b.offset || a.size - b.size);
1050
+ for (let i = 1; i < file_spans.length; i++) {
1051
+ const previous = file_spans[i - 1];
1052
+ const current = file_spans[i];
1053
+ const previous_end = previous.offset + previous.size;
1054
+ if (previous_end < current.offset) throw deserialize_error("gaps in file data");
1055
+ if (previous_end > current.offset) throw deserialize_error("overlapping file data");
1056
+ }
1057
+ (async () => {
1058
+ let has_more = true;
1059
+ while (has_more) has_more = !!await get_chunk(chunks.length);
1060
+ })().catch(noop);
1061
+ return {
1062
+ data,
1063
+ meta,
1064
+ form_data: null
1065
+ };
1066
+ }
1067
+ /**
1068
+ * @param {string} message
1069
+ */
1070
+ function deserialize_error(message) {
1071
+ return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`);
1072
+ }
1073
+ /**
1074
+ * Yields the chunks that make up the byte range `[offset, offset + length)`,
1075
+ * trimmed to its boundaries. Ends early if the underlying data runs out.
1076
+ * @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
1077
+ * @param {number} offset
1078
+ * @param {number} length
1079
+ * @returns {AsyncGenerator<Uint8Array<ArrayBuffer>, void, void>}
1080
+ */
1081
+ async function* read_range(get_chunk, offset, length) {
1082
+ let chunk_start = 0;
1083
+ for (let index = 0;; index++) {
1084
+ const chunk = await get_chunk(index);
1085
+ if (!chunk) return;
1086
+ const chunk_end = chunk_start + chunk.byteLength;
1087
+ if (chunk_end > offset) {
1088
+ yield chunk.subarray(Math.max(0, offset - chunk_start), Math.min(chunk.byteLength, offset + length - chunk_start));
1089
+ if (offset + length <= chunk_end) return;
1090
+ }
1091
+ chunk_start = chunk_end;
1092
+ }
1093
+ }
1094
+ /** @implements {File} */
1095
+ var LazyFile = class LazyFile {
1096
+ /** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */
1097
+ #get_chunk;
1098
+ /** @type {number} */
1099
+ #offset;
1100
+ /**
1101
+ * @param {string} name
1102
+ * @param {string} type
1103
+ * @param {number} size
1104
+ * @param {number} last_modified
1105
+ * @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
1106
+ * @param {number} offset
1107
+ */
1108
+ constructor(name, type, size, last_modified, get_chunk, offset) {
1109
+ this.name = name;
1110
+ this.type = type;
1111
+ this.size = size;
1112
+ this.lastModified = last_modified;
1113
+ this.webkitRelativePath = "";
1114
+ this.#get_chunk = get_chunk;
1115
+ this.#offset = offset;
1116
+ this.arrayBuffer = this.arrayBuffer.bind(this);
1117
+ this.bytes = this.bytes.bind(this);
1118
+ this.slice = this.slice.bind(this);
1119
+ this.stream = this.stream.bind(this);
1120
+ this.text = this.text.bind(this);
1121
+ }
1122
+ /** @type {ArrayBuffer | undefined} */
1123
+ #buffer;
1124
+ async arrayBuffer() {
1125
+ this.#buffer ??= await new Response(this.stream()).arrayBuffer();
1126
+ return this.#buffer;
1127
+ }
1128
+ async bytes() {
1129
+ return new Uint8Array(await this.arrayBuffer());
1130
+ }
1131
+ /**
1132
+ * @param {number=} start
1133
+ * @param {number=} end
1134
+ * @param {string=} contentType
1135
+ */
1136
+ slice(start = 0, end = this.size, contentType = this.type) {
1137
+ if (start < 0) start = Math.max(this.size + start, 0);
1138
+ else start = Math.min(start, this.size);
1139
+ if (end < 0) end = Math.max(this.size + end, 0);
1140
+ else end = Math.min(end, this.size);
1141
+ const size = Math.max(end - start, 0);
1142
+ return new LazyFile(this.name, contentType, size, this.lastModified, this.#get_chunk, this.#offset + start);
1143
+ }
1144
+ stream() {
1145
+ const range = read_range(this.#get_chunk, this.#offset, this.size);
1146
+ const size = this.size;
1147
+ return stream_from_iterable((async function* () {
1148
+ let cursor = 0;
1149
+ for await (const chunk of range) {
1150
+ cursor += chunk.byteLength;
1151
+ yield chunk;
1152
+ }
1153
+ if (cursor < size) throw new Error("incomplete file data");
1154
+ })());
1155
+ }
1156
+ async text() {
1157
+ return text_decoder.decode(await this.arrayBuffer());
1158
+ }
1159
+ };
1160
+ var path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/;
1161
+ /**
1162
+ * @param {string} path
1163
+ */
1164
+ function split_path(path) {
1165
+ if (!path_regex.test(path)) form_field_invalid_name({ name: path });
1166
+ return path.split(/\.|\[|\]/).filter(Boolean);
1167
+ }
1168
+ /**
1169
+ * Check if a property key is dangerous and could lead to prototype pollution
1170
+ * @param {string} key
1171
+ */
1172
+ function check_prototype_pollution(key) {
1173
+ if (key === "__proto__" || key === "constructor" || key === "prototype") form_field_forbidden_key({ key });
1174
+ }
1175
+ /**
1176
+ * Sets a value in a nested object using an array of keys, mutating the original object.
1177
+ * @param {Record<string, any>} object
1178
+ * @param {string[]} keys
1179
+ * @param {any} value
1180
+ */
1181
+ function deep_set(object, keys, value) {
1182
+ let current = object;
1183
+ for (let i = 0; i < keys.length - 1; i += 1) {
1184
+ const key = keys[i];
1185
+ check_prototype_pollution(key);
1186
+ const is_array = /^\d+$/.test(keys[i + 1]);
1187
+ const inner = Object.hasOwn(current, key) ? current[key] : void 0;
1188
+ const exists = inner != null;
1189
+ if (exists && is_array !== Array.isArray(inner)) form_field_array_conflict({ key: keys[i + 1] });
1190
+ if (!exists) {
1191
+ if (value === DELETE_KEY) return;
1192
+ current[key] = is_array ? [] : {};
1193
+ }
1194
+ current = current[key];
1195
+ }
1196
+ const final_key = keys[keys.length - 1];
1197
+ check_prototype_pollution(final_key);
1198
+ if (value === DELETE_KEY) delete current[final_key];
1199
+ else current[final_key] = value;
1200
+ }
1201
+ /**
1202
+ * @param {StandardSchemaV1.Issue} issue
1203
+ * @param {boolean} server Whether this issue came from server validation
1204
+ */
1205
+ function normalize_issue(issue, server = false) {
1206
+ /** @type {InternalRemoteFormIssue} */
1207
+ const normalized = {
1208
+ name: "",
1209
+ path: [],
1210
+ message: issue.message,
1211
+ server
1212
+ };
1213
+ if (issue.path !== void 0) {
1214
+ let name = "";
1215
+ for (const segment of issue.path) {
1216
+ const key = typeof segment === "object" ? segment.key : segment;
1217
+ normalized.path.push(key);
1218
+ if (typeof key === "number") name += `[${key}]`;
1219
+ else if (typeof key === "string") name += name === "" ? key : "." + key;
1220
+ }
1221
+ normalized.name = name;
1222
+ }
1223
+ return normalized;
1224
+ }
1225
+ /**
1226
+ * @param {InternalRemoteFormIssue[]} issues
1227
+ */
1228
+ function flatten_issues(issues) {
1229
+ /** @type {Record<string, InternalRemoteFormIssue[]>} */
1230
+ const result = Object.create(null);
1231
+ for (const issue of issues) {
1232
+ (result.$ ??= []).push(issue);
1233
+ let name = "";
1234
+ if (issue.path !== void 0) for (const key of issue.path) {
1235
+ if (typeof key === "number") name += `[${key}]`;
1236
+ else if (typeof key === "string") name += name === "" ? key : "." + key;
1237
+ (result[name] ??= []).push(issue);
1238
+ }
1239
+ }
1240
+ return result;
1241
+ }
1242
+ /**
1243
+ * Gets a nested value from an object using a path array
1244
+ * @param {Record<string, any>} object
1245
+ * @param {(string | number)[]} path
1246
+ * @returns {any}
1247
+ */
1248
+ function deep_get(object, path) {
1249
+ let current = object;
1250
+ for (const key of path) {
1251
+ if (current === null || typeof current !== "object" || !Object.hasOwn(current, key)) return;
1252
+ current = current[key];
1253
+ }
1254
+ return current;
1255
+ }
1256
+ /** name prefixes that tell the server which type to coerce a submitted string to */
1257
+ var type_prefixes = {
1258
+ number: "n:",
1259
+ boolean: "b:"
1260
+ };
1261
+ /**
1262
+ * adds props; a function becomes a getter that is computed each time it is read
1263
+ * @param {Record<string, any>} base_props
1264
+ * @param {Record<string, unknown>} props
1265
+ */
1266
+ function add_props(base_props, props) {
1267
+ for (const prop in props) {
1268
+ const value = props[prop];
1269
+ if (typeof value === "function") Object.defineProperty(base_props, prop, {
1270
+ enumerable: true,
1271
+ get: value
1272
+ });
1273
+ else base_props[prop] = value;
1274
+ }
1275
+ return base_props;
1276
+ }
1277
+ /**
1278
+ * @param {string} type
1279
+ * @param {boolean} is_array
1280
+ * @param {unknown} input_value
1281
+ */
1282
+ function get_type_prefix(type, is_array, input_value) {
1283
+ if (type === "number" || type === "range") return "n:";
1284
+ if (type === "image") return "i:";
1285
+ if (type === "checkbox" && !is_array) return "b:";
1286
+ if (type === "hidden" || type === "submit") return type_prefixes[typeof input_value] ?? "";
1287
+ return "";
1288
+ }
1289
+ /**
1290
+ * A deep-clone implementation specifically for form data, where
1291
+ * we don't need to worry about cycles and whatnot
1292
+ * @param {any} value
1293
+ * @returns {any}
1294
+ */
1295
+ function deep_clone(value) {
1296
+ if (value !== null && typeof value === "object") {
1297
+ if (value instanceof Date) return new Date(value.getTime());
1298
+ if (value instanceof File) return value;
1299
+ if (Array.isArray(value)) return value.map(deep_clone);
1300
+ /** @type {Record<string, any>} */
1301
+ const clone = {};
1302
+ for (const key of Object.keys(value)) clone[key] = deep_clone(value[key]);
1303
+ return clone;
1304
+ }
1305
+ return value;
1306
+ }
1307
+ /** @type {ProxyHandler<object> | null} */
1308
+ var dev_traps = null;
1309
+ /** @param {InternalRemoteFormIssue} issue */
1310
+ var public_issue = (issue) => ({
1311
+ path: issue.path,
1312
+ message: issue.message
1313
+ });
1314
+ /** @typedef {{
1315
+ * form_id: string,
1316
+ * get: () => Record<string, any>,
1317
+ * set: (path: (string | number)[], value: any) => void,
1318
+ * get_issues: (path?: (string | number)[], all?: boolean) => Record<string, InternalRemoteFormIssue[]>,
1319
+ * get_touched: () => Record<string, boolean>,
1320
+ * get_dirty: () => Record<string, boolean>
1321
+ * }} FieldContext */
1322
+ /**
1323
+ * @param {FieldContext} context
1324
+ * @param {(string | number)[]} path
1325
+ * @param {string} prop
1326
+ * @returns {any} a method of the field at `path`, or undefined for a nested field
1327
+ */
1328
+ function create_field_method(context, path, prop) {
1329
+ switch (prop) {
1330
+ case "set": return (value) => {
1331
+ context.set(path, value);
1332
+ return value;
1333
+ };
1334
+ case "value": return () => deep_clone(deep_get(context.get(), path));
1335
+ case "issues":
1336
+ case "allIssues": {
1337
+ const key = build_path_string(path);
1338
+ const all = prop === "allIssues";
1339
+ return () => {
1340
+ const issues = context.get_issues(path, all)[key === "" ? "$" : key];
1341
+ if (all) return issues?.map(public_issue);
1342
+ const own = issues?.filter((issue) => issue.name === key).map(public_issue);
1343
+ return own?.length ? own : void 0;
1344
+ };
1345
+ }
1346
+ case "touched":
1347
+ case "dirty": {
1348
+ const key = build_path_string(path);
1349
+ return () => {
1350
+ const object = prop === "dirty" ? context.get_dirty() : context.get_touched();
1351
+ if (Object.hasOwn(object, key)) return true;
1352
+ for (const candidate in object) {
1353
+ if (!Object.hasOwn(object, candidate)) continue;
1354
+ if (key === "") return true;
1355
+ if (!candidate.startsWith(key)) continue;
1356
+ const next = candidate[key.length];
1357
+ if (next === "." || next === "[") return true;
1358
+ }
1359
+ return false;
1360
+ };
1361
+ }
1362
+ case "as": {
1363
+ const key = build_path_string(path);
1364
+ /**
1365
+ * the field's value, or `fallback` until the field has been edited
1366
+ * (without a fallback there is nothing to suppress, so `dirty` is not read)
1367
+ * @param {unknown} [fallback]
1368
+ */
1369
+ const read = (fallback) => deep_get(context.get(), path) ?? (fallback !== void 0 && Object.hasOwn(context.get_dirty(), key) ? void 0 : fallback);
1370
+ /**
1371
+ * @param {string} type
1372
+ * @param {unknown} [input_value]
1373
+ * @param {boolean} [checked]
1374
+ */
1375
+ return (type, input_value, checked) => {
1376
+ const is_array = type === "file multiple" || type === "select multiple" || type === "checkbox" && typeof input_value === "string";
1377
+ /** @type {Record<string, any>} */
1378
+ const base_props = {
1379
+ name: get_type_prefix(type, is_array, input_value) + key + (is_array ? "[]" : "") + "/" + context.form_id,
1380
+ get "aria-invalid"() {
1381
+ const issues = context.get_issues();
1382
+ return key in issues ? "true" : void 0;
1383
+ }
1384
+ };
1385
+ if (type !== "text" && type !== "select" && type !== "select multiple") base_props.type = type === "file multiple" ? "file" : type;
1386
+ if (type === "submit" || type === "hidden") return add_props(base_props, { value: typeof input_value === "boolean" ? input_value ? "on" : "off" : input_value });
1387
+ if (type === "select" || type === "select multiple") return add_props(base_props, {
1388
+ multiple: is_array,
1389
+ value: () => {
1390
+ const value = read(input_value);
1391
+ return Array.isArray(value) ? [...value] : value;
1392
+ }
1393
+ });
1394
+ if (type === "checkbox" || type === "radio") {
1395
+ if (type === "radio" || is_array) base_props.value = input_value ?? "on";
1396
+ else checked = input_value;
1397
+ return add_props(base_props, {
1398
+ defaultChecked: checked,
1399
+ checked: () => {
1400
+ const value = read();
1401
+ if (value == null) return read(checked);
1402
+ if (type === "radio") return value === input_value;
1403
+ if (is_array) return value.includes(input_value);
1404
+ return value;
1405
+ }
1406
+ });
1407
+ }
1408
+ if (type === "file" || type === "file multiple") return add_props(base_props, {
1409
+ multiple: is_array,
1410
+ files: () => {
1411
+ const value = read();
1412
+ const files = value instanceof File ? [value] : value;
1413
+ if (!Array.isArray(files) || !files.every((f) => f instanceof File)) return null;
1414
+ if (typeof DataTransfer === "undefined") return Object.assign({ length: files.length }, files);
1415
+ const transfer = new DataTransfer();
1416
+ for (const file of files) transfer.items.add(file);
1417
+ return transfer.files;
1418
+ }
1419
+ });
1420
+ if (type === "image") return base_props;
1421
+ return add_props(base_props, {
1422
+ defaultValue: input_value,
1423
+ value: () => String(read(input_value) ?? "")
1424
+ });
1425
+ };
1426
+ }
1427
+ }
1428
+ }
1429
+ /**
1430
+ * Creates a proxy-based field accessor for form data
1431
+ * @param {FieldContext} context
1432
+ * @param {any} target - Function or empty POJO
1433
+ * @param {(string | number)[]} path - Current access path
1434
+ * @returns {any} Proxy object with name(), value(), and issues() methods
1435
+ */
1436
+ function create_field_proxy(context, target = {}, path = []) {
1437
+ return new Proxy(target, {
1438
+ ...dev_traps,
1439
+ get(target, prop) {
1440
+ if (typeof prop === "symbol") return target[prop];
1441
+ const next = [...path, /^\d+$/.test(prop) ? parseInt(prop, 10) : prop];
1442
+ return create_field_proxy(context, create_field_method(context, path, prop), next);
1443
+ }
1444
+ });
1445
+ }
1446
+ /**
1447
+ * Builds a path string from an array of path segments
1448
+ * @param {(string | number)[]} path
1449
+ * @returns {string}
1450
+ */
1451
+ function build_path_string(path) {
1452
+ let result = "";
1453
+ for (const segment of path) if (typeof segment === "number") result += `[${segment}]`;
1454
+ else result += result === "" ? segment : "." + segment;
1455
+ return result;
1456
+ }
1457
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/utils/http.js
1458
+ /**
1459
+ * Given an Accept header and a list of possible content types, pick
1460
+ * the most suitable one to respond with
1461
+ * @param {string} accept
1462
+ * @param {string[]} types
1463
+ */
1464
+ function negotiate(accept, types) {
1465
+ /** @type {Array<{ type: string, subtype: string, q: number, i: number }>} */
1466
+ const parts = [];
1467
+ accept.split(",").forEach((str, i) => {
1468
+ const match = /^[ \t]*([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
1469
+ if (match) {
1470
+ const [, type, subtype, q = "1"] = match;
1471
+ parts.push({
1472
+ type,
1473
+ subtype,
1474
+ q: +q,
1475
+ i
1476
+ });
1477
+ }
1478
+ });
1479
+ parts.sort((a, b) => {
1480
+ if (a.q !== b.q) return b.q - a.q;
1481
+ if (a.subtype === "*" !== (b.subtype === "*")) return a.subtype === "*" ? 1 : -1;
1482
+ if (a.type === "*" !== (b.type === "*")) return a.type === "*" ? 1 : -1;
1483
+ return a.i - b.i;
1484
+ });
1485
+ let accepted;
1486
+ let min_priority = Infinity;
1487
+ for (const mimetype of types) {
1488
+ const [type, subtype] = mimetype.split("/");
1489
+ const priority = parts.findIndex((part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*"));
1490
+ if (priority !== -1 && priority < min_priority) {
1491
+ accepted = mimetype;
1492
+ min_priority = priority;
1493
+ }
1494
+ }
1495
+ return accepted;
1496
+ }
1497
+ /**
1498
+ * Returns `true` if a `content-type` header value is one of the given types, ignoring
1499
+ * parameters such as `charset` and comparing case-insensitively
1500
+ * @param {string | null | undefined} header
1501
+ * @param {...string} types
1502
+ */
1503
+ function matches_content_type(header, ...types) {
1504
+ const type = header?.split(";", 1)[0].trim() ?? "";
1505
+ return types.includes(type.toLowerCase());
1506
+ }
1507
+ /**
1508
+ * @param {Request} request
1509
+ */
1510
+ function is_form_content_type(request) {
1511
+ return matches_content_type(request.headers.get("content-type"), "application/x-www-form-urlencoded", "multipart/form-data", "text/plain", BINARY_FORM_CONTENT_TYPE);
1512
+ }
1513
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/app/internal/transport.js
1514
+ /** @import { Transport } from '@sveltejs/kit/hooks' */
1515
+ /** @type {(thing: any) => string} */
1516
+ var uneval = () => {
1517
+ throw new Error("");
1518
+ };
1519
+ /** @type {(data: any) => string} */
1520
+ var stringify = () => {
1521
+ throw new Error("");
1522
+ };
1523
+ /** @type {(data: string) => any} */
1524
+ var parse = () => {
1525
+ throw new Error("");
1526
+ };
1527
+ /** @type {Record<string, (data: any) => any>} */
1528
+ var encoders = {};
1529
+ /** @type {Record<string, (data: any) => any>} */
1530
+ var decoders = {};
1531
+ var has_custom_transporters = false;
1532
+ /**
1533
+ *
1534
+ * @param {Transport} transport
1535
+ */
1536
+ function init_transport(transport) {
1537
+ const transporters = Object.entries(transport);
1538
+ has_custom_transporters = transporters.length > 0;
1539
+ /** @param {unknown} thing */
1540
+ const replacer = (thing) => {
1541
+ for (const key of Object.keys(transport)) {
1542
+ const encoded = transport[key].encode(thing);
1543
+ if (encoded) return `app.decode('${key}', ${uneval$1(encoded, replacer)})`;
1544
+ }
1545
+ };
1546
+ encoders = Object.fromEntries(transporters.map(([k, v]) => [k, v.encode]));
1547
+ decoders = Object.fromEntries(transporters.map(([k, v]) => [k, v.decode]));
1548
+ uneval = (data) => uneval$1(data, replacer);
1549
+ stringify = (data) => stringify$1(data, encoders);
1550
+ parse = (data) => parse$1(data, decoders);
1551
+ }
1552
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/shared.js
1553
+ /**
1554
+ * @param {string} route_id
1555
+ * @param {string} dep
1556
+ */
1557
+ function validate_depends(route_id, dep) {
1558
+ const match = /^(moz-icon|view-source|jar):/.exec(dep);
1559
+ if (match) depends_special_scheme({
1560
+ route: route_id,
1561
+ dependency: dep,
1562
+ scheme: match[1]
1563
+ });
1564
+ }
1565
+ /**
1566
+ * Same-origin urls are keyed by path, so prerendered pages can be served from any origin
1567
+ * @param {URL} url
1568
+ * @param {{ origin: string }} page
1569
+ */
1570
+ function fetch_cache_url(url, page) {
1571
+ return url.origin === page.origin ? url.href.slice(page.origin.length) : url.href;
1572
+ }
1573
+ var INVALIDATED_PARAM = "x-sveltekit-invalidated";
1574
+ var TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
1575
+ /**
1576
+ * @param {any} data
1577
+ * @param {string} [location_description]
1578
+ */
1579
+ function validate_load_response(data, location_description) {
1580
+ if (data != null && Object.getPrototypeOf(data) !== Object.prototype) load_invalid_response({
1581
+ location: String(location_description),
1582
+ type: typeof data !== "object" ? `a ${typeof data}` : data instanceof Response ? "a Response object" : Array.isArray(data) ? "an array" : "a non-plain object"
1583
+ });
1584
+ }
1585
+ var object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
1586
+ /**
1587
+ * @param {unknown} thing
1588
+ * @returns {thing is Record<PropertyKey, unknown>}
1589
+ */
1590
+ function is_plain_object(thing) {
1591
+ if (typeof thing !== "object" || thing === null) return false;
1592
+ const proto = Object.getPrototypeOf(thing);
1593
+ return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
1594
+ }
1595
+ /**
1596
+ * @param {Record<string, any>} value
1597
+ * @param {Map<object, any>} clones
1598
+ */
1599
+ function to_sorted(value, clones) {
1600
+ const clone = Object.getPrototypeOf(value) === null ? Object.create(null) : {};
1601
+ clones.set(value, clone);
1602
+ Object.defineProperty(clone, remote_arg_marker, { value: true });
1603
+ for (const key of Object.keys(value).sort()) {
1604
+ const property = value[key];
1605
+ Object.defineProperty(clone, key, {
1606
+ value: clones.get(property) ?? property,
1607
+ enumerable: true,
1608
+ configurable: true,
1609
+ writable: true
1610
+ });
1611
+ }
1612
+ return clone;
1613
+ }
1614
+ var remote_object = "__skrao";
1615
+ var remote_map = "__skram";
1616
+ var remote_set = "__skras";
1617
+ var remote_file = "__skraf";
1618
+ var remote_regex_guard = "__skrag";
1619
+ var remote_arg_marker = Symbol(remote_object);
1620
+ /**
1621
+ * @param {boolean} sort
1622
+ */
1623
+ function create_remote_arg_reducers(sort) {
1624
+ /** @type {Record<string, (value: unknown) => unknown>} */
1625
+ const remote_fns_reducers = {
1626
+ /** @param {unknown} value */
1627
+ [remote_regex_guard]: (value) => {
1628
+ if (value instanceof RegExp) remote_argument_unsupported({ type: "Regular expressions" });
1629
+ } };
1630
+ if (sort) {
1631
+ const clones = /* @__PURE__ */ new Map();
1632
+ /** @type {(value: unknown) => Array<[unknown, unknown]> | undefined} */
1633
+ remote_fns_reducers[remote_map] = (value) => {
1634
+ if (!(value instanceof Map)) return;
1635
+ /** @type {Array<[string, string]>} */
1636
+ const entries = [];
1637
+ for (const [key, val] of value) entries.push([stringify(key), stringify(val)]);
1638
+ return entries.sort(([a1, a2], [b1, b2]) => {
1639
+ if (a1 < b1) return -1;
1640
+ if (a1 > b1) return 1;
1641
+ if (a2 < b2) return -1;
1642
+ if (a2 > b2) return 1;
1643
+ return 0;
1644
+ });
1645
+ };
1646
+ /** @type {(value: unknown) => unknown[] | undefined} */
1647
+ remote_fns_reducers[remote_set] = (value) => {
1648
+ if (!(value instanceof Set)) return;
1649
+ /** @type {string[]} */
1650
+ const items = [];
1651
+ for (const item of value) items.push(stringify(item));
1652
+ items.sort();
1653
+ return items;
1654
+ };
1655
+ /** @type {(value: unknown) => Record<PropertyKey, unknown> | undefined} */
1656
+ remote_fns_reducers[remote_object] = (value) => {
1657
+ if (!is_plain_object(value)) return;
1658
+ if (Object.hasOwn(value, remote_arg_marker)) return;
1659
+ if (clones.has(value)) return clones.get(value);
1660
+ return to_sorted(value, clones);
1661
+ };
1662
+ }
1663
+ const all_reducers = {
1664
+ ...encoders,
1665
+ ...remote_fns_reducers
1666
+ };
1667
+ /** @type {(value: unknown) => string} */
1668
+ const stringify = (value) => stringify$1(value, all_reducers);
1669
+ return all_reducers;
1670
+ }
1671
+ function create_remote_arg_revivers() {
1672
+ const remote_fns_revivers = {
1673
+ /** @type {(value: unknown) => unknown} */
1674
+ [remote_object]: (value) => value,
1675
+ /** @type {(value: unknown) => Map<unknown, unknown>} */
1676
+ [remote_map]: (value) => {
1677
+ if (!Array.isArray(value)) throw new Error("Invalid data for Map reviver");
1678
+ const map = /* @__PURE__ */ new Map();
1679
+ for (const item of value) {
1680
+ if (!Array.isArray(item) || item.length !== 2 || typeof item[0] !== "string" || typeof item[1] !== "string") throw new Error("Invalid data for Map reviver");
1681
+ const [key, val] = item;
1682
+ map.set(parse(key), parse(val));
1683
+ }
1684
+ return map;
1685
+ },
1686
+ /** @type {(value: unknown) => Set<unknown>} */
1687
+ [remote_set]: (value) => {
1688
+ if (!Array.isArray(value)) throw new Error("Invalid data for Set reviver");
1689
+ const set = /* @__PURE__ */ new Set();
1690
+ for (const item of value) {
1691
+ if (typeof item !== "string") throw new Error("Invalid data for Set reviver");
1692
+ set.add(parse(item));
1693
+ }
1694
+ return set;
1695
+ },
1696
+ /** @type {(value: any) => File} */
1697
+ [remote_file]: (value) => {
1698
+ if (!value || typeof value !== "object" || typeof value.name !== "string" || typeof value.type !== "string" || typeof value.size !== "number" || typeof value.lastModified !== "number" || !(value.data instanceof ArrayBuffer)) throw new Error("Invalid data for File reviver");
1699
+ const { data, name, ...meta } = value;
1700
+ return new File([data], name, meta);
1701
+ }
1702
+ };
1703
+ const all_revivers = {
1704
+ ...decoders,
1705
+ ...remote_fns_revivers
1706
+ };
1707
+ /** @type {(data: string) => unknown} */
1708
+ const parse = (data) => parse$1(data, all_revivers);
1709
+ return all_revivers;
1710
+ }
1711
+ /**
1712
+ * Stringifies the argument (if any) for a remote function in such a way that
1713
+ * it is both a valid URL and a valid file name (necessary for prerendering).
1714
+ * @param {any} value
1715
+ */
1716
+ function stringify_remote_arg(value) {
1717
+ if (value === void 0) return "";
1718
+ return url_friendly_base64_encode(stringify$1(value, create_remote_arg_reducers(true)));
1719
+ }
1720
+ /**
1721
+ * Base64-encodes `string` in such a way that the result is safe to use
1722
+ * as both a URI component and a filename
1723
+ * @param {string} string
1724
+ */
1725
+ function url_friendly_base64_encode(string) {
1726
+ return base64_encode(text_encoder.encode(string)).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
1727
+ }
1728
+ /**
1729
+ * Parses the argument (if any) for a remote function
1730
+ * @param {string} string
1731
+ */
1732
+ function parse_remote_arg(string) {
1733
+ if (!string) return void 0;
1734
+ return parse$1(text_decoder.decode(base64_decode(string.replaceAll("-", "+").replaceAll("_", "/"))), create_remote_arg_revivers());
1735
+ }
1736
+ /**
1737
+ * @param {string} id
1738
+ * @param {string} payload
1739
+ */
1740
+ function create_remote_key(id, payload) {
1741
+ return id + "/" + payload;
1742
+ }
1743
+ /**
1744
+ * @param {string} key
1745
+ * @returns {{ id: string; payload: string }}
1746
+ */
1747
+ function split_remote_key(key) {
1748
+ const i = key.lastIndexOf("/");
1749
+ if (i === -1) throw new Error(`Invalid remote key: ${key}`);
1750
+ return {
1751
+ id: key.slice(0, i),
1752
+ payload: key.slice(i + 1)
1753
+ };
1754
+ }
1755
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/utils/error.js
1756
+ /**
1757
+ * @param {Error} error
1758
+ * @param {string} stack
1759
+ * @returns {string | undefined}
1760
+ */
1761
+ function set_error_stack(error, stack) {
1762
+ try {
1763
+ Reflect.set(error, "stack", stack);
1764
+ } catch {}
1765
+ return error.stack;
1766
+ }
1767
+ /**
1768
+ * @param {unknown} err
1769
+ * @return {Error}
1770
+ */
1771
+ function coalesce_to_error(err) {
1772
+ return err instanceof Error || err && err.name && err.message ? err : new Error(JSON.stringify(err));
1773
+ }
1774
+ /**
1775
+ * This is an identity function that exists to make TypeScript less
1776
+ * paranoid about people throwing things that aren't errors, which
1777
+ * frankly is not something we should care about
1778
+ * @param {unknown} error
1779
+ */
1780
+ function normalize_error(error) {
1781
+ return error;
1782
+ }
1783
+ /**
1784
+ * @param {unknown} error
1785
+ */
1786
+ function get_status(error) {
1787
+ return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
1788
+ }
1789
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/messages/server-warnings.js
1790
+ /**
1791
+ * `cache-control` header contains empty directives. (While parsing `%value%`.)
1792
+ * @param {{ "value": string }} _values
1793
+ */
1794
+ function cache_control_empty_directive(_values) {
1795
+ console.warn("https://svelte.dev/e/kit/cache_control_empty_directive");
1796
+ }
1797
+ /**
1798
+ * Invalid `cache-control` directive `%directive%`. Did you mean one of: %directives%? (While parsing `%value%`.)
1799
+ * @param {{ "directive": string; "directives": string; "value": string }} _values
1800
+ */
1801
+ function cache_control_invalid_directive(_values) {
1802
+ console.warn("https://svelte.dev/e/kit/cache_control_invalid_directive");
1803
+ }
1804
+ /**
1805
+ * Invalid `content-type` value `%type%`. (While parsing `%value%`.)
1806
+ * @param {{ "type": string; "value": string }} _values
1807
+ */
1808
+ function content_type_invalid(_values) {
1809
+ console.warn("https://svelte.dev/e/kit/content_type_invalid");
1810
+ }
1811
+ /**
1812
+ * `%name%` cookie does not exist for `%pathname%`, but was previously set at %paths%. Did you mean to set its `path` to `'/'` instead?
1813
+ * @param {{ "name": string; "pathname": string; "paths": string }} _values
1814
+ */
1815
+ function cookie_path_mismatch(_values) {
1816
+ console.warn("https://svelte.dev/e/kit/cookie_path_mismatch");
1817
+ }
1818
+ /**
1819
+ * The form action returned a value, but it isn't available in `page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#Progressive-enhancement-use:enhance
1820
+ * @param {void} _values
1821
+ */
1822
+ function form_action_data_without_ssr(_values) {
1823
+ console.warn("https://svelte.dev/e/kit/form_action_data_without_ssr");
1824
+ }
1825
+ /**
1826
+ * The form action returned an error, but `+error.svelte` wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#Progressive-enhancement-use:enhance
1827
+ * @param {void} _values
1828
+ */
1829
+ function form_action_error_without_ssr(_values) {
1830
+ console.warn("https://svelte.dev/e/kit/form_action_error_without_ssr");
1831
+ }
1832
+ /**
1833
+ * To use an async `handleError` hook to handle errors that occur during rendering, you must enable `compilerOptions.experimental.async` in the SvelteKit plugin of your Vite config. The returned error has been replaced with a generic object
1834
+ * @param {void} _values
1835
+ */
1836
+ function handle_error_async_without_async_svelte(_values) {
1837
+ console.warn("https://svelte.dev/e/kit/handle_error_async_without_async_svelte");
1838
+ }
1839
+ /**
1840
+ * `%id%`: %usage% in a promise handler after `load(...)` has returned will not cause the function to re-run when %change%
1841
+ * @param {{ "id": string; "usage": string; "change": string }} _values
1842
+ */
1843
+ function load_tracking_after_return(_values) {
1844
+ console.warn("https://svelte.dev/e/kit/load_tracking_after_return");
1845
+ }
1846
+ /**
1847
+ * Avoid calling `fetch` eagerly during server-side rendering — put your `fetch` calls inside `onMount` or a `load` function instead
1848
+ * @param {void} _values
1849
+ */
1850
+ function ssr_fetch_eager(_values) {
1851
+ console.warn("https://svelte.dev/e/kit/ssr_fetch_eager");
1852
+ }
1853
+ /**
1854
+ * Returning promises from server `load` functions will only work if `csr === true`
1855
+ * @param {void} _values
1856
+ */
1857
+ function streaming_without_csr(_values) {
1858
+ console.warn("https://svelte.dev/e/kit/streaming_without_csr");
1859
+ }
1860
+ /**
1861
+ * Removing comments in `transformPageChunk` can break Svelte's hydration
1862
+ * @param {void} _values
1863
+ */
1864
+ function transform_page_chunk_comments(_values) {
1865
+ console.warn("https://svelte.dev/e/kit/transform_page_chunk_comments");
1866
+ }
1867
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/server/errors.js
1868
+ /**
1869
+ * @param {import('@sveltejs/kit').RequestEvent} event
1870
+ * @param {import('types').RequestState} state
1871
+ * @param {any} error
1872
+ * @returns {App.Error | Promise<App.Error>}
1873
+ */
1874
+ function handle_error_and_jsonify(event, state, error) {
1875
+ if (error instanceof HandledHttpError) return error.body;
1876
+ /** @type {import('@sveltejs/kit/hooks').CaughtError} */
1877
+ let caught;
1878
+ if (error instanceof HttpError) caught = {
1879
+ kind: "app",
1880
+ error: error.body
1881
+ };
1882
+ else if (error instanceof SvelteKitError) caught = {
1883
+ kind: "framework",
1884
+ error: {
1885
+ status: error.status,
1886
+ message: error.text
1887
+ }
1888
+ };
1889
+ else if (error instanceof ValidationError) caught = {
1890
+ kind: "validation",
1891
+ error: {
1892
+ status: 400,
1893
+ message: "Bad Request"
1894
+ },
1895
+ issues: error.issues,
1896
+ remote: error.remote
1897
+ };
1898
+ else {
1899
+ caught = {
1900
+ kind: "unknown",
1901
+ error
1902
+ };
1903
+ let e = error;
1904
+ while (e instanceof Error) {
1905
+ fix_stack_trace(e);
1906
+ e = e.cause;
1907
+ }
1908
+ }
1909
+ const fallback = caught.kind === "unknown" ? {
1910
+ status: 500,
1911
+ message: "Internal Error"
1912
+ } : caught.error;
1913
+ /**
1914
+ * The hook returns only the properties it wants to override; anything it omits
1915
+ * (including by returning nothing at all) is inherited from the caught error.
1916
+ * @param {Awaited<ReturnType<import('@sveltejs/kit/hooks').HandleServerError>>} body
1917
+ * @returns {App.Error}
1918
+ */
1919
+ function merge(body) {
1920
+ return {
1921
+ ...fallback,
1922
+ ...body
1923
+ };
1924
+ }
1925
+ let result;
1926
+ try {
1927
+ const input = {
1928
+ ...caught,
1929
+ event
1930
+ };
1931
+ result = with_request_store({
1932
+ event,
1933
+ state
1934
+ }, () => hooks.handleError(input));
1935
+ } catch (hook_error) {
1936
+ log_handle_error_hook_failure(error, hook_error);
1937
+ return {
1938
+ status: fallback.status,
1939
+ message: "Internal Error"
1940
+ };
1941
+ }
1942
+ if (result instanceof Promise) {
1943
+ if (state.is_in_render) {
1944
+ handle_error_async_without_async_svelte();
1945
+ result.catch((hook_error) => log_handle_error_hook_failure(error, hook_error));
1946
+ return {
1947
+ status: fallback.status,
1948
+ message: "Internal Error"
1949
+ };
1950
+ }
1951
+ return result.then(merge, (hook_error) => {
1952
+ log_handle_error_hook_failure(error, hook_error);
1953
+ return {
1954
+ status: fallback.status,
1955
+ message: "Internal Error"
1956
+ };
1957
+ });
1958
+ }
1959
+ return merge(result);
1960
+ }
1961
+ /**
1962
+ * @param {unknown} error
1963
+ * @param {unknown} hook_error
1964
+ */
1965
+ function log_handle_error_hook_failure(error, hook_error) {
1966
+ const failure = capture_error(() => handle_error_hook_failed(void 0, { cause: coalesce_to_error(hook_error) }));
1967
+ failure.stack = `${failure.name}: ${failure.message}`;
1968
+ console.error(failure);
1969
+ if (error instanceof SvelteKitError) console.error(`Original error: ${error.status} ${error.text}: ${error.message}`);
1970
+ else console.error("Original error:", error);
1971
+ }
1972
+ /**
1973
+ * @param {import('@sveltejs/kit/hooks').CaughtError & { event: import('@sveltejs/kit').RequestEvent }} input
1974
+ */
1975
+ function default_handle_error({ kind, error, issues, remote }) {
1976
+ if (kind === "validation") {
1977
+ let fn;
1978
+ if (remote?.name && remote.file) fn = `${remote.name} (${remote.file})`;
1979
+ else if (remote?.name) fn = remote.name;
1980
+ console.error(`Remote function ${fn ? fn + " " : ""}schema validation failed:`, issues);
1981
+ return;
1982
+ }
1983
+ if (kind !== "unknown") return;
1984
+ let e = error;
1985
+ while (e instanceof Error) {
1986
+ if (e.stack) console.error(e.stack);
1987
+ e = e.cause;
1988
+ }
1989
+ if (e) console.error(String(e));
1990
+ }
1991
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/server/utils.js
1992
+ /**
1993
+ * @param {Partial<Record<import('types').HttpMethod, any>>} mod
1994
+ * @param {import('types').HttpMethod} method
1995
+ */
1996
+ function method_not_allowed(mod, method) {
1997
+ return text(`${method} method not allowed`, {
1998
+ status: 405,
1999
+ headers: { allow: allowed_methods(mod).join(", ") }
2000
+ });
2001
+ }
2002
+ /** @param {Partial<Record<import('types').HttpMethod, any>>} mod */
2003
+ function allowed_methods(mod) {
2004
+ const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
2005
+ if ("GET" in mod && !("HEAD" in mod)) allowed.push("HEAD");
2006
+ return allowed;
2007
+ }
2008
+ /**
2009
+ * @param {number} status
2010
+ * @param {string} location
2011
+ */
2012
+ function redirect_response(status, location) {
2013
+ return new Response(void 0, {
2014
+ status,
2015
+ headers: { location }
2016
+ });
2017
+ }
2018
+ /**
2019
+ * Whether the response is being prerendered, either because we're running the prerenderer
2020
+ * or because a `+server.js` endpoint inherits the prerender option of the page fetching it
2021
+ * @param {import('types').RequestState} state
2022
+ */
2023
+ function is_prerendering(state) {
2024
+ return !!state.prerendering || state.prerender_default === true;
2025
+ }
2026
+ /**
2027
+ * @param {Response} response
2028
+ */
2029
+ function with_version_header(response) {
2030
+ response.headers.set("x-sveltekit-version", "1794756716856");
2031
+ return response;
2032
+ }
2033
+ /**
2034
+ * Throws an error explaining why data returned from `load` couldn't be serialized by devalue,
2035
+ * whose error becomes the cause
2036
+ * @param {import('@sveltejs/kit').RequestEvent} event
2037
+ * @param {Error & { path: string }} error
2038
+ * @returns {never}
2039
+ */
2040
+ function throw_devalue_error(event, error) {
2041
+ const id = event.route.id;
2042
+ if (error.path) load_not_serializable({
2043
+ id,
2044
+ message: error.message,
2045
+ path: error.path
2046
+ }, { cause: error });
2047
+ if (error.path === "") load_not_plain_object({ id }, { cause: error });
2048
+ throw new Error(error.message, { cause: error });
2049
+ }
2050
+ /**
2051
+ * @param {import('types').ServerDataNode} node
2052
+ */
2053
+ function serialize_uses(node) {
2054
+ const uses = {};
2055
+ if (node.uses && node.uses.dependencies.size > 0) uses.dependencies = Array.from(node.uses.dependencies);
2056
+ if (node.uses && node.uses.search_params.size > 0) uses.search_params = Array.from(node.uses.search_params);
2057
+ if (node.uses && node.uses.params.size > 0) uses.params = Array.from(node.uses.params);
2058
+ if (node.uses?.parent) uses.parent = 1;
2059
+ if (node.uses?.route) uses.route = 1;
2060
+ if (node.uses?.url) uses.url = 1;
2061
+ return uses;
2062
+ }
2063
+ /**
2064
+ * Returns `true` if the given path was prerendered
2065
+ * @param {string} pathname Should include the base and be decoded
2066
+ */
2067
+ function has_prerendered_path(pathname) {
2068
+ return manifest.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest.prerendered_routes.has(pathname.slice(0, -1));
2069
+ }
2070
+ /**
2071
+ * Returns the filename without the extension. e.g., `+page.server`, `+page`, etc.
2072
+ * @param {string | undefined} node_id
2073
+ * @returns {string}
2074
+ */
2075
+ function get_node_type(node_id) {
2076
+ const filename = (node_id?.split("/"))?.at(-1);
2077
+ if (!filename) return "unknown";
2078
+ return filename.split(".").slice(0, -1).join(".");
2079
+ }
2080
+ /**
2081
+ * Counts HTML comments that are not SSI directives (which start with `<!--#`).
2082
+ * Used to detect when `transformPageChunk` removes comments that Svelte needs for hydration.
2083
+ * @param {string} str
2084
+ * @returns {number}
2085
+ */
2086
+ function count_non_ssi_comments(str) {
2087
+ return (str.match(/<!--(?!#)/g) ?? []).length;
2088
+ }
2089
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js
2090
+ /** @import { RequestEvent, Actions } from '@sveltejs/kit' */
2091
+ /** @import { ActionResult } from '$app/forms' */
2092
+ /** @import { SSRNode, ServerNode, ServerActionResult } from 'types' */
2093
+ /** @param {RequestEvent} event */
2094
+ function is_action_json_request(event) {
2095
+ return negotiate(event.request.headers.get("accept") ?? "*/*", ["application/json", "text/html"]) === "application/json" && event.request.method === "POST";
2096
+ }
2097
+ /**
2098
+ * @param {RequestEvent} event
2099
+ * @param {import('types').RequestState} state
2100
+ * @param {SSRNode['server'] | undefined} server
2101
+ */
2102
+ async function handle_action_json_request(event, state, server) {
2103
+ return action_result_json(event, state, await handle_action_request(event, state, server));
2104
+ }
2105
+ /**
2106
+ * @param {RequestEvent} event
2107
+ * @param {import('types').RequestState} state
2108
+ * @param {ServerActionResult} result
2109
+ * @returns {Promise<Response>}
2110
+ */
2111
+ async function action_result_json(event, state, result) {
2112
+ if (result.type === "redirect") return action_json(result);
2113
+ if (result.type === "error") {
2114
+ const error = await handle_error_and_jsonify(event, state, result.error);
2115
+ return action_json({
2116
+ ...result,
2117
+ error
2118
+ }, { status: error.status });
2119
+ }
2120
+ if (result.type === "success" && !result.data) return action_json({
2121
+ ...result,
2122
+ status: 204,
2123
+ data: void 0
2124
+ });
2125
+ try {
2126
+ return action_json({
2127
+ ...result,
2128
+ data: try_serialize(result.data, stringify, event.route.id)
2129
+ }, { status: result.status });
2130
+ } catch (error) {
2131
+ return action_result_json(event, state, action_error_result(error, result.location));
2132
+ }
2133
+ }
2134
+ /**
2135
+ * @param {URL} url
2136
+ */
2137
+ function get_action_location(url) {
2138
+ const location = new URL(url);
2139
+ for (const key of location.searchParams.keys()) if (key.startsWith("/")) {
2140
+ location.searchParams.delete(key);
2141
+ break;
2142
+ }
2143
+ return (location.pathname.startsWith("//") ? "/." + location.pathname : location.pathname) + location.search;
2144
+ }
2145
+ /**
2146
+ * @param {RequestEvent} event
2147
+ * @param {string} location
2148
+ * @returns {Extract<ServerActionResult, { type: 'error' }>}
2149
+ */
2150
+ function method_not_allowed_result(event, location) {
2151
+ event.setHeaders({ allow: "GET" });
2152
+ return {
2153
+ type: "error",
2154
+ location,
2155
+ error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
2156
+ };
2157
+ }
2158
+ /**
2159
+ * @param {unknown} error
2160
+ * @param {string} location
2161
+ * @returns {Extract<ServerActionResult, { type: 'redirect' | 'error' }>}
2162
+ */
2163
+ function action_error_result(error, location) {
2164
+ const err = normalize_error(error);
2165
+ if (err instanceof Redirect) return {
2166
+ type: "redirect",
2167
+ status: err.status,
2168
+ location: err.location
2169
+ };
2170
+ return {
2171
+ type: "error",
2172
+ location,
2173
+ error: err
2174
+ };
2175
+ }
2176
+ /**
2177
+ * @param {Redirect} redirect
2178
+ */
2179
+ function action_json_redirect(redirect) {
2180
+ return action_json({
2181
+ type: "redirect",
2182
+ status: redirect.status,
2183
+ location: redirect.location
2184
+ });
2185
+ }
2186
+ /**
2187
+ * @param {ActionResult} data
2188
+ * @param {ResponseInit} [init]
2189
+ */
2190
+ function action_json(data, init) {
2191
+ return with_version_header(Response.json(data, init));
2192
+ }
2193
+ /**
2194
+ * @param {RequestEvent} event
2195
+ */
2196
+ function is_action_request(event) {
2197
+ return event.request.method === "POST";
2198
+ }
2199
+ /**
2200
+ * @param {RequestEvent} event
2201
+ * @param {import('types').RequestState} state
2202
+ * @param {SSRNode['server'] | undefined} server
2203
+ * @returns {Promise<ServerActionResult>}
2204
+ */
2205
+ async function handle_action_request(event, state, server) {
2206
+ const actions = server?.actions;
2207
+ const location = get_action_location(event.url);
2208
+ if (!actions) return method_not_allowed_result(event, location);
2209
+ check_named_default_separate(actions);
2210
+ try {
2211
+ const data = await call_action(event, state, actions);
2212
+ if (data instanceof ActionFailure) return {
2213
+ type: "failure",
2214
+ status: data.status,
2215
+ location,
2216
+ data: data.data
2217
+ };
2218
+ else return {
2219
+ type: "success",
2220
+ status: 200,
2221
+ location,
2222
+ data
2223
+ };
2224
+ } catch (error) {
2225
+ return action_error_result(error instanceof ActionFailure ? capture_error(() => action_throw_fail()) : error, location);
2226
+ }
2227
+ }
2228
+ /**
2229
+ * @param {Actions} actions
2230
+ */
2231
+ function check_named_default_separate(actions) {
2232
+ if (actions.default && Object.keys(actions).length > 1) action_default_with_named();
2233
+ }
2234
+ /**
2235
+ * @param {RequestEvent} event
2236
+ * @param {import('types').RequestState} state
2237
+ * @param {NonNullable<ServerNode['actions']>} actions
2238
+ * @throws {Redirect | HttpError | SvelteKitError | Error}
2239
+ */
2240
+ async function call_action(event, state, actions) {
2241
+ const url = new URL(event.request.url);
2242
+ let name = "default";
2243
+ for (const param of url.searchParams) if (param[0].startsWith("/")) {
2244
+ name = param[0].slice(1);
2245
+ if (name === "default") action_name_reserved();
2246
+ break;
2247
+ }
2248
+ if (!Object.hasOwn(actions, name)) throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
2249
+ const action = actions[name];
2250
+ if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `Form actions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
2251
+ return record_span({
2252
+ name: "sveltekit.form_action",
2253
+ attributes: {
2254
+ "sveltekit.form_action.name": name,
2255
+ "http.route": event.route.id || "unknown"
2256
+ },
2257
+ fn: async (current) => {
2258
+ const traced_event = merge_tracing(event, current);
2259
+ const result = await with_request_store({
2260
+ event: traced_event,
2261
+ state
2262
+ }, () => action(traced_event));
2263
+ if (result instanceof ActionFailure) current.setAttributes({
2264
+ "sveltekit.form_action.result.type": "failure",
2265
+ "sveltekit.form_action.result.status": result.status
2266
+ });
2267
+ return result;
2268
+ }
2269
+ });
2270
+ }
2271
+ /**
2272
+ * Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context
2273
+ * @param {any} data
2274
+ * @param {string} route_id
2275
+ */
2276
+ function uneval_action_response(data, route_id) {
2277
+ return try_serialize(data, uneval, route_id);
2278
+ }
2279
+ /**
2280
+ * @param {any} data
2281
+ * @param {(data: any) => string} fn
2282
+ * @param {string} route_id
2283
+ */
2284
+ function try_serialize(data, fn, route_id) {
2285
+ try {
2286
+ return fn(data);
2287
+ } catch (error) {
2288
+ if (data instanceof Response) action_response_not_serializable({ id: route_id }, { cause: error });
2289
+ if ("path" in error) {
2290
+ const values = {
2291
+ id: route_id,
2292
+ message: error.message
2293
+ };
2294
+ action_data_not_serializable(error.path === "" ? values : {
2295
+ ...values,
2296
+ path: `data${error.path}`
2297
+ }, { cause: error });
2298
+ }
2299
+ throw error;
2300
+ }
2301
+ }
2302
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/server/remote-functions.js
2303
+ /** @import { RequestEvent } from '@sveltejs/kit' */
2304
+ /** @import { RemoteFormInternals, RemoteFunctionData, RemoteFunctionResponse, RemoteInternals, RequestState, ServerActionResult, SSRManifest } from 'types' */
2305
+ /**
2306
+ * How long (in milliseconds) to wait after the last message was sent before
2307
+ * sending a `: keep-alive` SSE comment, to prevent proxies/load balancers with
2308
+ * an idle timeout from closing an otherwise-quiet `query.live` connection.
2309
+ */
2310
+ var KEEP_ALIVE_INTERVAL = 3e4;
2311
+ /**
2312
+ * @param {RequestEvent} event
2313
+ * @param {RequestState} state
2314
+ * @param {import('types').RemoteQueryLiveInternals} internals
2315
+ * @param {any} arg
2316
+ */
2317
+ function create_live_query_response(event, state, internals, arg) {
2318
+ const cancellation = new AbortController();
2319
+ const live_event = {
2320
+ ...event,
2321
+ request: new Request(event.request, { signal: AbortSignal.any([event.request.signal, cancellation.signal]) })
2322
+ };
2323
+ const generator = internals.run(live_event, state, arg);
2324
+ let open = true;
2325
+ let pulling = false;
2326
+ /** @type {ReadableStreamDefaultController<Uint8Array>} */
2327
+ let stream_controller;
2328
+ /** @type {ReturnType<typeof setTimeout> | undefined} */
2329
+ let keep_alive;
2330
+ /** @type {string | undefined} */
2331
+ let result;
2332
+ function schedule_keep_alive() {
2333
+ clearTimeout(keep_alive);
2334
+ keep_alive = setTimeout(() => {
2335
+ if (!open) return;
2336
+ if ((stream_controller.desiredSize ?? 0) > 0) stream_controller.enqueue(text_encoder.encode(": keep-alive\n\n"));
2337
+ schedule_keep_alive();
2338
+ }, KEEP_ALIVE_INTERVAL);
2339
+ }
2340
+ /** @param {any} data */
2341
+ function send(data) {
2342
+ if (!open) return;
2343
+ stream_controller.enqueue(text_encoder.encode("data: " + JSON.stringify(data) + "\n\n"));
2344
+ schedule_keep_alive();
2345
+ }
2346
+ /** @param {boolean} cancelled */
2347
+ function teardown(cancelled) {
2348
+ if (!open) return;
2349
+ open = false;
2350
+ clearTimeout(keep_alive);
2351
+ cancellation.abort();
2352
+ if (!cancelled) stream_controller.close();
2353
+ generator.return(void 0).catch(() => {});
2354
+ }
2355
+ event.request.signal.addEventListener("abort", () => teardown(true), { once: true });
2356
+ return new Response(new ReadableStream({
2357
+ start(controller) {
2358
+ stream_controller = controller;
2359
+ schedule_keep_alive();
2360
+ },
2361
+ async pull() {
2362
+ if (!open || pulling) return;
2363
+ pulling = true;
2364
+ try {
2365
+ while (open) {
2366
+ const { value, done } = await generator.next();
2367
+ if (!open) return;
2368
+ if (done) {
2369
+ teardown(false);
2370
+ return;
2371
+ }
2372
+ if (result !== (result = stringify(value))) {
2373
+ send({
2374
+ type: "result",
2375
+ result
2376
+ });
2377
+ return;
2378
+ }
2379
+ }
2380
+ } catch (error) {
2381
+ if (!open) return;
2382
+ if (error instanceof Redirect) send({
2383
+ type: "redirect",
2384
+ location: error.location
2385
+ });
2386
+ else send({
2387
+ type: "error",
2388
+ error: await handle_error_and_jsonify(event, state, error)
2389
+ });
2390
+ teardown(false);
2391
+ } finally {
2392
+ pulling = false;
2393
+ }
2394
+ },
2395
+ cancel() {
2396
+ teardown(true);
2397
+ }
2398
+ }), { headers: {
2399
+ "cache-control": "private, no-store",
2400
+ "content-type": "text/event-stream"
2401
+ } });
2402
+ }
2403
+ /** @type {typeof handle_remote_call_internal} */
2404
+ async function handle_remote_call(event, state, id) {
2405
+ return record_span({
2406
+ name: "sveltekit.remote.call",
2407
+ attributes: { "sveltekit.remote.call.id": id },
2408
+ fn: async (current) => {
2409
+ const traced_event = merge_tracing(event, current);
2410
+ return with_version_header(await with_request_store({
2411
+ event: traced_event,
2412
+ state
2413
+ }, () => handle_remote_call_internal(traced_event, state, id)));
2414
+ }
2415
+ });
2416
+ }
2417
+ /**
2418
+ *
2419
+ * @param {string} id
2420
+ * @param {SSRManifest} manifest
2421
+ * @returns {Promise<{ fn: ((...args: any[]) => any) & { __: RemoteInternals }, name: string, additional_args: string } | undefined>}
2422
+ */
2423
+ async function get_remote_function(id, manifest) {
2424
+ const first_slash = id.indexOf("/");
2425
+ if (first_slash === -1) return;
2426
+ const second_slash = id.indexOf("/", first_slash + 1);
2427
+ const hash = id.substring(0, first_slash);
2428
+ /** @type {string} */
2429
+ let name;
2430
+ let additional_args = "";
2431
+ if (second_slash === -1) name = id.substring(first_slash + 1);
2432
+ else {
2433
+ name = id.substring(first_slash + 1, second_slash);
2434
+ additional_args = id.substring(second_slash + 1);
2435
+ }
2436
+ const remotes = manifest.remotes;
2437
+ if (!Object.hasOwn(remotes, hash)) return;
2438
+ const module = await remotes[hash]();
2439
+ if (!Object.hasOwn(module.default, name)) return;
2440
+ return {
2441
+ fn: module.default[name],
2442
+ name,
2443
+ additional_args
2444
+ };
2445
+ }
2446
+ /**
2447
+ * @param {RequestEvent} event
2448
+ * @param {RequestState} state
2449
+ * @param {string} id
2450
+ */
2451
+ async function handle_remote_call_internal(event, state, id) {
2452
+ const remote = await get_remote_function(id, manifest);
2453
+ if (!remote) error(404);
2454
+ const { fn, additional_args } = remote;
2455
+ /** @type {RemoteInternals} */
2456
+ const internals = fn.__;
2457
+ event.tracing.current.setAttributes({
2458
+ "sveltekit.remote.call.type": internals.type,
2459
+ "sveltekit.remote.call.name": internals.name
2460
+ });
2461
+ /** @type {HeadersInit | undefined} */
2462
+ const headers = state.prerendering ? void 0 : { "cache-control": "private, no-store" };
2463
+ try {
2464
+ /** @type {RemoteFunctionData} */
2465
+ const data = {};
2466
+ switch (internals.type) {
2467
+ case "query_live":
2468
+ if (event.request.method !== "GET") throw new SvelteKitError(405, "Method Not Allowed", `\`query.live\` functions must be invoked via GET request, not ${event.request.method}`);
2469
+ return create_live_query_response(event, state, internals, parse_remote_arg(new URL(event.request.url).searchParams.get("payload")));
2470
+ case "query_batch": {
2471
+ if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`query.batch\` functions must be invoked via POST request, not ${event.request.method}`);
2472
+ /** @type {{ payloads: string[] }} */
2473
+ const { payloads } = await event.request.json();
2474
+ const args = await Promise.all(payloads.map((payload) => parse_remote_arg(payload)));
2475
+ data._ = await with_request_store({
2476
+ event,
2477
+ state
2478
+ }, () => internals.run(args));
2479
+ break;
2480
+ }
2481
+ case "form": {
2482
+ if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`form\` functions must be invoked via POST request, not ${event.request.method}`);
2483
+ if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `\`form\` functions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
2484
+ const { data: input, meta, form_data } = await deserialize_binary_form(event.request, internals.id);
2485
+ state.remote.requested = create_requested_map(meta.remote_refreshes);
2486
+ if (additional_args && !("id" in input)) input.id = JSON.parse(decodeURIComponent(additional_args));
2487
+ const fn = internals.fn;
2488
+ data._ = await with_request_store({
2489
+ event,
2490
+ state: {
2491
+ ...state,
2492
+ is_in_remote_form_or_command: true
2493
+ }
2494
+ }, () => fn(input, meta, form_data));
2495
+ if (data._.issues) return Response.json({
2496
+ type: "result",
2497
+ data: stringify(data)
2498
+ }, { headers });
2499
+ break;
2500
+ }
2501
+ case "command": {
2502
+ /** @type {{ payload: string, refreshes?: string[] }} */
2503
+ const { payload, refreshes } = await event.request.json();
2504
+ state.remote.requested = create_requested_map(refreshes);
2505
+ const arg = parse_remote_arg(payload);
2506
+ data._ = await with_request_store({
2507
+ event,
2508
+ state: {
2509
+ ...state,
2510
+ is_in_remote_form_or_command: true
2511
+ }
2512
+ }, () => fn(arg));
2513
+ break;
2514
+ }
2515
+ case "prerender":
2516
+ data._ = await with_request_store({
2517
+ event,
2518
+ state
2519
+ }, () => fn(parse_remote_arg(additional_args)));
2520
+ break;
2521
+ case "query": {
2522
+ const payload = new URL(event.request.url).searchParams.get("payload");
2523
+ data._ = await with_request_store({
2524
+ event,
2525
+ state
2526
+ }, () => fn(parse_remote_arg(payload)));
2527
+ break;
2528
+ }
2529
+ }
2530
+ await collect_remote_data(data, event, state);
2531
+ if (state.remote.ignored?.size) data.i = Array.from(state.remote.ignored);
2532
+ return Response.json({
2533
+ type: "result",
2534
+ data: stringify(data)
2535
+ }, { headers });
2536
+ } catch (error) {
2537
+ if (error instanceof Redirect) {
2538
+ const data = await collect_remote_data({ redirect: error.location }, event, state);
2539
+ return Response.json({
2540
+ type: "result",
2541
+ data: stringify(data)
2542
+ }, { headers });
2543
+ }
2544
+ const transformed = await handle_error_and_jsonify(event, state, error);
2545
+ return Response.json({
2546
+ type: "error",
2547
+ error: transformed
2548
+ }, {
2549
+ status: state.prerendering ? transformed.status : void 0,
2550
+ headers: { "cache-control": "private, no-store" }
2551
+ });
2552
+ }
2553
+ }
2554
+ /**
2555
+ * Collects all the query/prerender data that was retrieved
2556
+ * during the request and adds it to `data`
2557
+ * @param {RemoteFunctionData} data
2558
+ * @param {RequestEvent} event
2559
+ * @param {RequestState} state
2560
+ */
2561
+ async function collect_remote_data(data, event, state) {
2562
+ /**
2563
+ *
2564
+ * @param {unknown} error
2565
+ * @returns {Promise<App.Error>}
2566
+ */
2567
+ function convert_error(error) {
2568
+ return Promise.resolve(handle_error_and_jsonify(event, state, error));
2569
+ }
2570
+ /** @type {Promise<any>[]} */
2571
+ const promises = [];
2572
+ /** @type {Set<string>} */
2573
+ const processed = /* @__PURE__ */ new Set();
2574
+ if (state.remote.explicit) {
2575
+ const { explicit } = state.remote;
2576
+ /** @type {Promise<void>[]} */
2577
+ const inflight = [];
2578
+ const drain = () => {
2579
+ for (const [remote_key, { internals, fn }] of explicit) {
2580
+ explicit.delete(remote_key);
2581
+ if (processed.has(remote_key)) continue;
2582
+ processed.add(remote_key);
2583
+ data.r = true;
2584
+ const type = internals.type === "query_live" ? "l" : internals.type[0];
2585
+ inflight.push(fn().then((v) => {
2586
+ (data[type] ??= {})[remote_key] = { v };
2587
+ drain();
2588
+ }, async (e) => {
2589
+ if (!(e instanceof Redirect)) (data[type] ??= {})[remote_key] = { e: await convert_error(e) };
2590
+ drain();
2591
+ }));
2592
+ }
2593
+ };
2594
+ drain();
2595
+ for (const promise of inflight) await promise;
2596
+ }
2597
+ if (state.remote.implicit) for (const [internals, record] of state.remote.implicit) {
2598
+ if (!internals.id) continue;
2599
+ for (const key in record) {
2600
+ const remote_key = internals.type === "form" ? key : create_remote_key(internals.id, key);
2601
+ if (processed.has(remote_key)) continue;
2602
+ const type = internals.type === "query_live" ? "l" : internals.type[0];
2603
+ const promise = state.remote.data?.get(internals)?.[key] ?? record[key]();
2604
+ let resolved = true;
2605
+ await Promise.race([Promise.resolve(promise).then((v) => {
2606
+ if (resolved) ((data[type] ??= {})[remote_key] ??= {}).v = v;
2607
+ }, (e) => {
2608
+ if (e instanceof Redirect) return;
2609
+ if (resolved) promises.push(convert_error(e).then((e) => {
2610
+ ((data[type] ??= {})[remote_key] ??= {}).e = e;
2611
+ }));
2612
+ }), Promise.resolve().then(() => resolved = false)]);
2613
+ }
2614
+ }
2615
+ await Promise.all(promises);
2616
+ return data;
2617
+ }
2618
+ /**
2619
+ * @param {string[] | undefined} refreshes
2620
+ */
2621
+ function create_requested_map(refreshes) {
2622
+ /** @type {Map<string, Set<string>>} */
2623
+ const requested = /* @__PURE__ */ new Map();
2624
+ for (const key of refreshes ?? []) {
2625
+ const parts = split_remote_key(key);
2626
+ const existing = requested.get(parts.id);
2627
+ if (existing) existing.add(parts.payload);
2628
+ else requested.set(parts.id, /* @__PURE__ */ new Set([parts.payload]));
2629
+ }
2630
+ return requested;
2631
+ }
2632
+ /** @type {typeof handle_remote_form_post_internal} */
2633
+ async function handle_remote_form_post(event, state, id) {
2634
+ return record_span({
2635
+ name: "sveltekit.remote.form.post",
2636
+ attributes: { "sveltekit.remote.form.post.id": id },
2637
+ fn: (current) => {
2638
+ const traced_event = merge_tracing(event, current);
2639
+ return with_request_store({
2640
+ event: traced_event,
2641
+ state
2642
+ }, () => handle_remote_form_post_internal(traced_event, state, id));
2643
+ }
2644
+ });
2645
+ }
2646
+ /**
2647
+ * @param {RequestEvent} event
2648
+ * @param {RequestState} state
2649
+ * @param {string} id
2650
+ * @returns {Promise<ServerActionResult>}
2651
+ */
2652
+ async function handle_remote_form_post_internal(event, state, id) {
2653
+ const location = get_action_location(event.url);
2654
+ const remote = await get_remote_function(id, manifest);
2655
+ if (!remote) return method_not_allowed_result(event, location);
2656
+ let form = remote.fn;
2657
+ const action_id = remote.additional_args;
2658
+ if (action_id) form = with_request_store({
2659
+ event,
2660
+ state
2661
+ }, () => form.for(JSON.parse(action_id)));
2662
+ try {
2663
+ const __ = form.__;
2664
+ const { data, meta, form_data } = await deserialize_binary_form(event.request, __.id);
2665
+ if (action_id && !("id" in data)) data.id = JSON.parse(decodeURIComponent(action_id));
2666
+ await with_request_store({
2667
+ event,
2668
+ state: {
2669
+ ...state,
2670
+ is_in_remote_form_or_command: true
2671
+ }
2672
+ }, () => __.fn(data, meta, form_data));
2673
+ return {
2674
+ type: "success",
2675
+ status: 200,
2676
+ location
2677
+ };
2678
+ } catch (e) {
2679
+ return action_error_result(e, location);
2680
+ }
2681
+ }
2682
+ /**
2683
+ * @param {URL} url
2684
+ */
2685
+ function has_remote_prefix(url) {
2686
+ return url.pathname.startsWith(`/${app_dir}/remote/`);
2687
+ }
2688
+ /**
2689
+ * @param {URL} url
2690
+ */
2691
+ function strip_remote_prefix(url) {
2692
+ return url.pathname.replace(`/${app_dir}/remote/`, "");
2693
+ }
2694
+ /**
2695
+ * @param {URL} url
2696
+ */
2697
+ function get_remote_id(url) {
2698
+ return has_remote_prefix(url) && strip_remote_prefix(url);
2699
+ }
2700
+ /**
2701
+ * @param {URL} url
2702
+ */
2703
+ function get_remote_action(url) {
2704
+ return url.searchParams.get("/remote");
2705
+ }
2706
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/server/sourcemaps.js
2707
+ var fs = globalThis.process?.getBuiltinModule?.("node:fs");
2708
+ var url = globalThis.process?.getBuiltinModule?.("node:url");
2709
+ var path = globalThis.process?.getBuiltinModule?.("node:path");
2710
+ var module = globalThis.process?.getBuiltinModule?.("node:module");
2711
+ var cwd = globalThis.process?.cwd?.();
2712
+ /** @type {(file: string) => string} */
2713
+ var relative = cwd ? (file) => path.relative(cwd, file) : (file) => file;
2714
+ /**
2715
+ * Applies sourcemaps, makes paths relative to the cwd, and truncates
2716
+ * non-user code from the bottom of the stack
2717
+ * @param {Error} error
2718
+ * @returns void
2719
+ */
2720
+ var fix_stack_trace = (error) => {
2721
+ if (!error.stack || !fs) return;
2722
+ let end = 0;
2723
+ set_error_stack(error, error.stack.split("\n").map((line, i) => {
2724
+ const match = line.match(/^ {4}at.+(file:\/\/\/.*):(\d+):(\d+)(\)?)$/);
2725
+ if (!match) {
2726
+ if (!line.includes("node:internal/")) end = i + 1;
2727
+ return line;
2728
+ }
2729
+ const file = url.fileURLToPath(match[1]);
2730
+ const traced = trace(file, Number(match[2]) - 1, Number(match[3]) - 1);
2731
+ if (!/[\\/]node_modules[\\/]/.test(traced?.file ?? file)) end = i + 1;
2732
+ if (traced?.line) {
2733
+ const location = `${match[1]}:${match[2]}:${match[3]}`;
2734
+ const original = `${relative(traced.file)}:${traced.line}:${traced.column}`;
2735
+ return line.replace(location, original);
2736
+ }
2737
+ if (traced) return `${line.replace(match[1], relative(file))} [${traced.file}]`;
2738
+ return line;
2739
+ }).slice(0, end).join("\n"));
2740
+ };
2741
+ /**
2742
+ * Override the implementation of fix_stack_trace (for using during dev)
2743
+ * @param {(error: Error) => void} fn
2744
+ */
2745
+ function set_fix_stack_trace(fn) {
2746
+ fix_stack_trace = fn;
2747
+ }
2748
+ /** @type {Map<string, { map: import('node:module').SourceMap; directory: string } | null>} */
2749
+ var source_maps = /* @__PURE__ */ new Map();
2750
+ /** @type {Map<string, Array<string | undefined>>} */
2751
+ var source_regions = /* @__PURE__ */ new Map();
2752
+ /** @param {string} file */
2753
+ function get_source_map(file) {
2754
+ if (source_maps.has(file)) return source_maps.get(file);
2755
+ try {
2756
+ let source;
2757
+ let directory = path.dirname(file);
2758
+ const code = fs.readFileSync(file, "utf8");
2759
+ const url = Array.from(code.matchAll(/\/\/[#@]\s*sourceMappingURL=(\S+)/g)).at(-1)?.[1];
2760
+ if (url?.startsWith("data:")) {
2761
+ const comma = url.indexOf(",");
2762
+ const metadata = url.slice(5, comma);
2763
+ const data = url.slice(comma + 1);
2764
+ source = metadata.endsWith(";base64") ? Buffer.from(data, "base64").toString() : decodeURIComponent(data);
2765
+ } else {
2766
+ const map_file = url ? path.resolve(path.dirname(file), decodeURIComponent(url)) : `${file}.map`;
2767
+ if (fs.existsSync(map_file)) {
2768
+ directory = path.dirname(map_file);
2769
+ source = fs.readFileSync(map_file, "utf8");
2770
+ }
2771
+ }
2772
+ if (source) {
2773
+ const source_map = {
2774
+ map: new module.SourceMap(JSON.parse(source)),
2775
+ directory
2776
+ };
2777
+ source_maps.set(file, source_map);
2778
+ return source_map;
2779
+ }
2780
+ } catch {}
2781
+ source_maps.set(file, null);
2782
+ return null;
2783
+ }
2784
+ /**
2785
+ *
2786
+ * @param {string} file
2787
+ * @param {number} line
2788
+ * @param {number} column
2789
+ * @returns {null | { file: string, line?: number, column?: number }}
2790
+ */
2791
+ function trace(file, line, column) {
2792
+ const source_map = get_source_map(file);
2793
+ if (!source_map) return null;
2794
+ const entry = source_map.map.findEntry(line, column);
2795
+ if (entry && "originalSource" in entry && entry.originalSource && typeof entry.originalLine === "number" && typeof entry.originalColumn === "number") {
2796
+ const traced = {
2797
+ file: entry.originalSource.startsWith("file:") ? url.fileURLToPath(entry.originalSource) : path.resolve(source_map.directory, entry.originalSource),
2798
+ line: entry.originalLine + 1,
2799
+ column: entry.originalColumn + 1
2800
+ };
2801
+ return trace(traced.file, traced.line - 1, traced.column - 1) ?? traced;
2802
+ }
2803
+ let regions = source_regions.get(file);
2804
+ if (!regions) {
2805
+ /** @type {string | undefined} */
2806
+ let source;
2807
+ regions = fs.readFileSync(file, "utf8").split("\n").map((line) => {
2808
+ const start = line.match(/^\/\/#region (.+)$/);
2809
+ if (start) source = start[1];
2810
+ if (line === "//#endregion") source = void 0;
2811
+ return source;
2812
+ });
2813
+ source_regions.set(file, regions);
2814
+ }
2815
+ const source = regions[line];
2816
+ if (source) return { file: source };
2817
+ return null;
2818
+ }
2819
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/server/internal.js
2820
+ var styleText = globalThis.process?.getBuiltinModule?.("node:util")?.styleText ?? ((_format, text) => text);
2821
+ var read_implementation = false;
2822
+ var manifest = false;
2823
+ var hooks = false;
2824
+ /**
2825
+ * The public `read` may return a promise, the runtime expects a stream
2826
+ * @param {NonNullable<import('@sveltejs/kit').ServerInitOptions['read']>} read
2827
+ */
2828
+ function set_read_implementation(read) {
2829
+ read_implementation = (file) => {
2830
+ const result = read(file);
2831
+ if (result instanceof ReadableStream) return result;
2832
+ return stream_from_iterable((async function* () {
2833
+ const stream = await result;
2834
+ if (stream) yield* stream;
2835
+ })());
2836
+ };
2837
+ }
2838
+ /**
2839
+ *
2840
+ * @param {SSRManifest} value
2841
+ */
2842
+ function set_manifest(value) {
2843
+ manifest = value;
2844
+ }
2845
+ /**
2846
+ * @param {ServerHooks} value
2847
+ */
2848
+ function set_hooks(value) {
2849
+ hooks = value;
2850
+ }
2851
+ /**
2852
+ * @param {number} status
2853
+ * @param {Request} request
2854
+ * @param {SSRManifest} manifest
2855
+ * @returns {Promise<string>}
2856
+ */
2857
+ async function format_response(status, request, manifest) {
2858
+ const url = new URL(request.url);
2859
+ const requested = url.href.replace(url.origin, "");
2860
+ let log = `${styleText(status < 400 ? ["cyan"] : ["bold", "red"], `${status}`)} `;
2861
+ if (has_data_suffix(url.pathname)) {
2862
+ log += `${request.method} `;
2863
+ const pathname = strip_data_suffix(url.pathname) || "/";
2864
+ log += pathname + styleText("dim", requested.slice(pathname.length));
2865
+ } else if (has_resolution_suffix(url.pathname)) {
2866
+ log += `${request.method} `;
2867
+ const pathname = strip_resolution_suffix(url.pathname) || "/";
2868
+ log += pathname + styleText("dim", requested.slice(pathname.length));
2869
+ } else if (has_remote_prefix(url)) {
2870
+ const id = strip_remote_prefix(url);
2871
+ /** @type {Awaited<ReturnType<typeof get_remote_function>>} */
2872
+ let remote;
2873
+ try {
2874
+ remote = await get_remote_function(id, manifest);
2875
+ } catch {}
2876
+ if (remote) {
2877
+ const internals = remote.fn.__;
2878
+ log += styleText(["bold", "magenta"], "ƒ ");
2879
+ log += styleText("magenta", `${internals.type.replace("_", ".")} `);
2880
+ if (internals.dev_loc) {
2881
+ let file_link = internals.dev_loc.file;
2882
+ if (internals.dev_loc.line != null) file_link += `#${internals.dev_loc.line}`;
2883
+ log += `\u001B]8;;${file_link}\u0007`;
2884
+ }
2885
+ log += styleText(["bold"], `${remote.name}()`);
2886
+ if (internals.dev_loc) log += "\x1B]8;;\x07";
2887
+ if (url.search) log += " " + styleText("dim", url.search);
2888
+ } else {
2889
+ log += `${request.method} `;
2890
+ const [file_hash, name, arg_hash] = id.split("/");
2891
+ log += styleText("dim", `${url.pathname.slice(0, -id.length)}${file_hash}/`) + name;
2892
+ if (arg_hash) log += styleText("dim", `/${arg_hash}`);
2893
+ if (url.search) log += styleText("dim", url.search);
2894
+ }
2895
+ } else log += `${request.method} ${requested}`;
2896
+ return log;
2897
+ }
2898
+ export { has_custom_transporters as $, default_handle_error as A, set_assets as At, streaming_without_csr as B, has_prerendered_path as C, base64_encode as Ct, serialize_uses as D, save as Dt, redirect_response as E, restore as Et, cookie_path_mismatch as F, TRAILING_SLASH_PARAM as G, get_status as H, form_action_data_without_ssr as I, parse_remote_arg as J, create_remote_key as K, form_action_error_without_ssr as L, cache_control_empty_directive as M, cache_control_invalid_directive as N, throw_devalue_error as O, app_dir as Ot, content_type_invalid as P, encoders as Q, load_tracking_after_return as R, get_node_type as S, strip_resolution_suffix as St, method_not_allowed as T, text_encoder as Tt, normalize_error as U, transform_page_chunk_comments as V, INVALIDATED_PARAM as W, validate_depends as X, stringify_remote_arg as Y, validate_load_response as Z, handle_action_request as _, add_data_suffix as _t, set_hooks as a, negotiate as at, uneval_action_response as b, has_resolution_suffix as bt, fix_stack_trace as c, flatten_issues as ct, get_remote_action as d, parse_form_key as dt, init_transport as et, get_remote_id as f, split_path as ft, handle_action_json_request as g, record_span as gt, action_json_redirect as h, otel as ht, read_implementation as i, is_form_content_type as it, handle_error_and_jsonify as j, with_version_header as k, assets as kt, set_fix_stack_trace as l, group_formdata as lt, handle_remote_form_post as m, find_route as mt, hooks as n, stringify as nt, set_manifest as o, create_field_proxy as ot, handle_remote_call as p, stringify$1 as pt, fetch_cache_url as q, manifest as r, uneval as rt, set_read_implementation as s, deep_set as st, format_response as t, parse as tt, collect_remote_data as u, normalize_issue as ut, is_action_json_request as v, add_resolution_suffix as vt, is_prerendering as w, stream_text as wt, count_non_ssi_comments as x, strip_data_suffix as xt, is_action_request as y, has_data_suffix as yt, ssr_fetch_eager as z };
2899
+
2900
+ //# sourceMappingURL=internal.js.map