import { _ as __commonJSMin } from './chunks/index-server-C6vKN1Ke.js'; import { R as Redirect, H as HttpError, d as coalesce_to_error, m as get_status, k as get_message, P as with_request_store, x as parse, S as SvelteKitError, w as options, j as get_hooks, r as noop, o as has_resolution_suffix, n as has_data_suffix, J as strip_resolution_suffix, G as strip_data_suffix, T as TRAILING_SLASH_PARAM, I as INVALIDATED_PARAM, g as decode_pathname, a as add_data_suffix, b as add_resolution_suffix, i as find_route, u as normalize_path, h as disable_search, M as validate_layout_server_exports, L as validate_layout_exports, O as validate_page_server_exports, N as validate_page_exports, s as noop_span, B as resolve, z as read_implementation, l as get_relative_path, C as set_read_implementation, f as create_remote_key, p as hash, K as text_encoder$1, e as compact, v as once, t as normalize_error, q as make_trackable, y as parse_remote_arg, E as stringify, F as stringify$1, A as ActionFailure, D as split_remote_key, c as base64_encode } from './chunks/internal-BncRdZO5.js'; import { af as uneval, ah as writable, a2 as readable } from './chunks/dev-B3xIfLjQ.js'; //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/app/paths/internal/server.js var base = ""; var assets = base; var app_dir = "_app"; var initial = { base, assets }; /** * @param {{ base: string, assets: string }} paths */ function override(paths) { base = paths.base; assets = paths.assets; } function reset() { base = initial.base; assets = initial.assets; } /** * `$env/dynamic/public` * @type {Record} */ var public_env = {}; /** @type {(environment: Record) => void} */ function set_private_env(environment) {} /** @type {(environment: Record) => void} */ function set_public_env(environment) { public_env = environment; } const text_encoder = new TextEncoder(); /** @import { StandardSchemaV1 } from '@standard-schema/spec' */ // TODO 3.0: remove these types as they are not used anymore (we can't remove them yet because that would be a breaking change) /** * @template {number} TNumber * @template {any[]} [TArray=[]] * @typedef {TNumber extends TArray['length'] ? TArray[number] : LessThan} LessThan */ /** * @template {number} TStart * @template {number} TEnd * @typedef {Exclude, LessThan>} NumericRange */ // Keep the status codes as `number` because restricting to certain numbers makes it unnecessarily hard to use compared to the benefits // (we have runtime errors already to check for invalid codes). Also see https://github.com/sveltejs/kit/issues/11780 // we have to repeat the JSDoc because the display for function overloads is broken // see https://github.com/microsoft/TypeScript/issues/55056 /** * Throws an error with a HTTP status code and an optional message. * When called during request handling, this will cause SvelteKit to * return an error response without invoking `handleError`. * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. * @param {App.Error} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. * @overload * @param {number} status * @param {App.Error} body * @return {never} * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. * @throws {Error} If the provided status is invalid (not between 400 and 599). */ /** * Throws an error with a HTTP status code and an optional message. * When called during request handling, this will cause SvelteKit to * return an error response without invoking `handleError`. * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body] An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. * @overload * @param {number} status * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body] * @return {never} * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. * @throws {Error} If the provided status is invalid (not between 400 and 599). */ /** * Throws an error with a HTTP status code and an optional message. * When called during request handling, this will cause SvelteKit to * return an error response without invoking `handleError`. * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. * @return {never} * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. * @throws {Error} If the provided status is invalid (not between 400 and 599). */ function error(status, body) { if ((isNaN(status) || status < 400 || status > 599)) { throw new Error(`HTTP error status codes must be between 400 and 599 — ${status} is invalid`); } throw new HttpError(status, body); } /** * Checks whether this is a redirect thrown by {@link redirect}. * @param {unknown} e The object to check. * @return {e is Redirect} */ function isRedirect(e) { return e instanceof Redirect; } /** * Create a JSON `Response` object from the supplied data. * @param {any} data The value that will be serialized as JSON. * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. `Content-Type: application/json` and `Content-Length` headers will be added automatically. */ function json(data, init) { // TODO deprecate this in favour of `Response.json` when it's // more widely supported const body = JSON.stringify(data); // we can't just do `text(JSON.stringify(data), init)` because // it will set a default `content-type` header. duplicated code // means less duplicated work const headers = new Headers(init?.headers); if (!headers.has('content-length')) { headers.set('content-length', text_encoder.encode(body).byteLength.toString()); } if (!headers.has('content-type')) { headers.set('content-type', 'application/json'); } return new Response(body, { ...init, headers }); } /** * Create a `Response` object from the supplied body. * @param {string} body The value that will be used as-is. * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically. */ function text(body, init) { const headers = new Headers(init?.headers); if (!headers.has('content-length')) { const encoded = text_encoder.encode(body); headers.set('content-length', encoded.byteLength.toString()); return new Response(encoded, { ...init, headers }); } return new Response(body, { ...init, headers }); } /** * @template {{ tracing: { enabled: boolean, root: import('@opentelemetry/api').Span, current: import('@opentelemetry/api').Span } }} T * @param {T} event_like * @param {import('@opentelemetry/api').Span} current * @returns {T} */ function merge_tracing(event_like, current) { return { ...event_like, tracing: { ...event_like.tracing, current } }; } var ENDPOINT_METHODS = [ "GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD" ]; var PAGE_METHODS = [ "GET", "POST", "HEAD" ]; //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/form-utils.js /** @import { RemoteForm } from '@sveltejs/kit' */ /** @import { BinaryFormMeta, InternalRemoteFormIssue } from 'types' */ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */ var decoder = new TextDecoder(); /** * Sets a value in a nested object using a path string, mutating the original object * @param {Record} object * @param {string} path_string * @param {any} value */ function set_nested_value(object, path_string, value) { if (path_string.startsWith("n:")) { path_string = path_string.slice(2); value = value === "" ? void 0 : parseFloat(value); } else if (path_string.startsWith("b:")) { path_string = path_string.slice(2); value = value === "on"; } deep_set(object, split_path(path_string), value); } /** * Convert `FormData` into a POJO * @param {FormData} data */ function convert_formdata(data) { /** @type {Record} */ const result = {}; for (let key of data.keys()) { const is_array = key.endsWith("[]"); /** @type {any[]} */ let values = data.getAll(key); if (is_array) key = key.slice(0, -2); if (values.length > 1 && !is_array) throw new Error(`Form cannot contain duplicated keys — "${key}" has ${values.length} values`); values = values.filter((entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0); if (key.startsWith("n:")) { key = key.slice(2); values = values.map((v) => v === "" ? void 0 : parseFloat(v)); } else if (key.startsWith("b:")) { key = key.slice(2); values = values.map((v) => v === "on"); } set_nested_value(result, key, is_array ? values : values[0]); } return result; } var BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata"; var BINARY_FORM_VERSION = 0; var HEADER_BYTES = 7; /** * @param {Request} request * @returns {Promise<{ data: Record; meta: BinaryFormMeta; form_data: FormData | null }>} */ async function deserialize_binary_form(request) { if (request.headers.get("content-type") !== "application/x-sveltekit-formdata") { const form_data = await request.formData(); return { data: convert_formdata(form_data), meta: {}, form_data }; } if (!request.body) throw deserialize_error("no body"); const reader = request.body.getReader(); /** @type {Array | undefined>>} */ const chunks = []; /** * @param {number} index * @returns {Promise | undefined>} */ function get_chunk(index) { if (index in chunks) return chunks[index]; let i = chunks.length; while (i <= index) { chunks[i] = reader.read().then((chunk) => chunk.value); i++; } return chunks[index]; } /** * @param {number} offset * @param {number} length * @returns {Promise} */ async function get_buffer(offset, length) { /** @type {Uint8Array} */ let start_chunk; let chunk_start = 0; /** @type {number} */ let chunk_index; for (chunk_index = 0;; chunk_index++) { const chunk = await get_chunk(chunk_index); if (!chunk) return null; const chunk_end = chunk_start + chunk.byteLength; if (offset >= chunk_start && offset < chunk_end) { start_chunk = chunk; break; } chunk_start = chunk_end; } if (offset + length <= chunk_start + start_chunk.byteLength) return start_chunk.subarray(offset - chunk_start, offset + length - chunk_start); const chunks = [start_chunk.subarray(offset - chunk_start)]; let cursor = start_chunk.byteLength - offset + chunk_start; while (cursor < length) { chunk_index++; let chunk = await get_chunk(chunk_index); if (!chunk) return null; if (chunk.byteLength > length - cursor) chunk = chunk.subarray(0, length - cursor); chunks.push(chunk); cursor += chunk.byteLength; } const buffer = new Uint8Array(length); cursor = 0; for (const chunk of chunks) { buffer.set(chunk, cursor); cursor += chunk.byteLength; } return buffer; } const header = await get_buffer(0, HEADER_BYTES); if (!header) throw deserialize_error("too short"); if (header[0] !== BINARY_FORM_VERSION) throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`); const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength); const data_length = header_view.getUint32(1, true); const file_offsets_length = header_view.getUint16(5, true); const data_buffer = await get_buffer(HEADER_BYTES, data_length); if (!data_buffer) throw deserialize_error("data too short"); /** @type {Array} */ let file_offsets; /** @type {number} */ let files_start_offset; if (file_offsets_length > 0) { const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length); if (!file_offsets_buffer) throw deserialize_error("file offset table too short"); const parsed_offsets = JSON.parse(decoder.decode(file_offsets_buffer)); if (!Array.isArray(parsed_offsets) || parsed_offsets.some((n) => typeof n !== "number" || !Number.isInteger(n) || n < 0)) throw deserialize_error("invalid file offset table"); file_offsets = parsed_offsets; files_start_offset = HEADER_BYTES + data_length + file_offsets_length; } /** @type {Array<{ offset: number, size: number }>} */ const file_spans = []; const [data, meta] = parse(decoder.decode(data_buffer), { File: ([name, type, size, last_modified, index]) => { if (typeof name !== "string" || typeof type !== "string" || typeof size !== "number" || typeof last_modified !== "number" || typeof index !== "number") throw deserialize_error("invalid file metadata"); let offset = file_offsets[index]; if (offset === void 0) throw deserialize_error("duplicate file offset table index"); file_offsets[index] = void 0; offset += files_start_offset; file_spans.push({ offset, size }); return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), { getPrototypeOf() { return File.prototype; } }); } }); file_spans.sort((a, b) => a.offset - b.offset || a.size - b.size); for (let i = 1; i < file_spans.length; i++) { const previous = file_spans[i - 1]; const current = file_spans[i]; const previous_end = previous.offset + previous.size; if (previous_end < current.offset) throw deserialize_error("gaps in file data"); if (previous_end > current.offset) throw deserialize_error("overlapping file data"); } (async () => { let has_more = true; while (has_more) has_more = !!await get_chunk(chunks.length); })(); return { data, meta, form_data: null }; } /** * @param {string} message */ function deserialize_error(message) { return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`); } /** @implements {File} */ var LazyFile = class LazyFile { /** @type {(index: number) => Promise | undefined>} */ #get_chunk; /** @type {number} */ #offset; /** * @param {string} name * @param {string} type * @param {number} size * @param {number} last_modified * @param {(index: number) => Promise | undefined>} get_chunk * @param {number} offset */ constructor(name, type, size, last_modified, get_chunk, offset) { this.name = name; this.type = type; this.size = size; this.lastModified = last_modified; this.webkitRelativePath = ""; this.#get_chunk = get_chunk; this.#offset = offset; this.arrayBuffer = this.arrayBuffer.bind(this); this.bytes = this.bytes.bind(this); this.slice = this.slice.bind(this); this.stream = this.stream.bind(this); this.text = this.text.bind(this); } /** @type {ArrayBuffer | undefined} */ #buffer; async arrayBuffer() { this.#buffer ??= await new Response(this.stream()).arrayBuffer(); return this.#buffer; } async bytes() { return new Uint8Array(await this.arrayBuffer()); } /** * @param {number=} start * @param {number=} end * @param {string=} contentType */ slice(start = 0, end = this.size, contentType = this.type) { if (start < 0) start = Math.max(this.size + start, 0); else start = Math.min(start, this.size); if (end < 0) end = Math.max(this.size + end, 0); else end = Math.min(end, this.size); const size = Math.max(end - start, 0); return new LazyFile(this.name, contentType, size, this.lastModified, this.#get_chunk, this.#offset + start); } stream() { let cursor = 0; let chunk_index = 0; return new ReadableStream({ start: async (controller) => { let chunk_start = 0; /** @type {Uint8Array} */ let start_chunk; for (chunk_index = 0;; chunk_index++) { const chunk = await this.#get_chunk(chunk_index); if (!chunk) return null; const chunk_end = chunk_start + chunk.byteLength; if (this.#offset >= chunk_start && this.#offset < chunk_end) { start_chunk = chunk; break; } chunk_start = chunk_end; } if (this.#offset + this.size <= chunk_start + start_chunk.byteLength) { controller.enqueue(start_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start)); controller.close(); } else { controller.enqueue(start_chunk.subarray(this.#offset - chunk_start)); cursor = start_chunk.byteLength - this.#offset + chunk_start; } }, pull: async (controller) => { chunk_index++; let chunk = await this.#get_chunk(chunk_index); if (!chunk) { controller.error("incomplete file data"); controller.close(); return; } if (chunk.byteLength > this.size - cursor) chunk = chunk.subarray(0, this.size - cursor); controller.enqueue(chunk); cursor += chunk.byteLength; if (cursor >= this.size) controller.close(); } }); } async text() { return decoder.decode(await this.arrayBuffer()); } }; var path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/; /** * @param {string} path */ function split_path(path) { if (!path_regex.test(path)) throw new Error(`Invalid path ${path}`); return path.split(/\.|\[|\]/).filter(Boolean); } /** * Check if a property key is dangerous and could lead to prototype pollution * @param {string} key */ function check_prototype_pollution(key) { if (key === "__proto__" || key === "constructor" || key === "prototype") throw new Error(`Invalid key "${key}"`); } /** * Sets a value in a nested object using an array of keys, mutating the original object. * @param {Record} object * @param {string[]} keys * @param {any} value */ function deep_set(object, keys, value) { let current = object; for (let i = 0; i < keys.length - 1; i += 1) { const key = keys[i]; check_prototype_pollution(key); const is_array = /^\d+$/.test(keys[i + 1]); const inner = Object.hasOwn(current, key) ? current[key] : void 0; const exists = inner != null; if (exists && is_array !== Array.isArray(inner)) throw new Error(`Invalid array key ${keys[i + 1]}`); if (!exists) current[key] = is_array ? [] : {}; current = current[key]; } const final_key = keys[keys.length - 1]; check_prototype_pollution(final_key); current[final_key] = value; } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/utils/http.js /** * Given an Accept header and a list of possible content types, pick * the most suitable one to respond with * @param {string} accept * @param {string[]} types */ function negotiate(accept, types) { /** @type {Array<{ type: string, subtype: string, q: number, i: number }>} */ const parts = []; accept.split(",").forEach((str, i) => { const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str); if (match) { const [, type, subtype, q = "1"] = match; parts.push({ type, subtype, q: +q, i }); } }); parts.sort((a, b) => { if (a.q !== b.q) return b.q - a.q; if (a.subtype === "*" !== (b.subtype === "*")) return a.subtype === "*" ? 1 : -1; if (a.type === "*" !== (b.type === "*")) return a.type === "*" ? 1 : -1; return a.i - b.i; }); let accepted; let min_priority = Infinity; for (const mimetype of types) { const [type, subtype] = mimetype.split("/"); const priority = parts.findIndex((part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*")); if (priority !== -1 && priority < min_priority) { accepted = mimetype; min_priority = priority; } } return accepted; } /** * Returns `true` if the request contains a `content-type` header with the given type * @param {Request} request * @param {...string} types */ function is_content_type(request, ...types) { const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? ""; return types.includes(type.toLowerCase()); } /** * @param {Request} request */ function is_form_content_type(request) { return is_content_type(request, "application/x-www-form-urlencoded", "multipart/form-data", "text/plain", BINARY_FORM_CONTENT_TYPE); } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/utils/misc.js var s = JSON.stringify; //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/utils/escape.js /** * When inside a double-quoted attribute value, only `&` and `"` hold special meaning. * @see https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state * @type {Record} */ var escape_html_attr_dict = { "&": "&", "\"": """ }; /** * @type {Record} */ var escape_html_dict = { "&": "&", "<": "<" }; var escape_html_attr_regex = new RegExp(`[${Object.keys(escape_html_attr_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g"); var escape_html_regex = new RegExp(`[${Object.keys(escape_html_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g"); /** * Escapes unpaired surrogates (which are allowed in js strings but invalid in HTML) and * escapes characters that are special. * * @param {string} str * @param {boolean} [is_attr] * @returns {string} escaped string * @example const html = `...`; */ function escape_html(str, is_attr) { const dict = is_attr ? escape_html_attr_dict : escape_html_dict; return str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => { if (match.length === 2) return match; return dict[match] ?? `&#${match.charCodeAt(0)};`; }); } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/server/utils.js /** @import { ServerHooks } from 'types' */ /** * @param {Partial>} mod * @param {import('types').HttpMethod} method */ function method_not_allowed(mod, method) { return text(`${method} method not allowed`, { status: 405, headers: { allow: allowed_methods(mod).join(", ") } }); } /** @param {Partial>} mod */ function allowed_methods(mod) { const allowed = ENDPOINT_METHODS.filter((method) => method in mod); if ("GET" in mod && !("HEAD" in mod)) allowed.push("HEAD"); return allowed; } /** * @param {import('types').SSROptions} options */ function get_global_name(options) { return `__sveltekit_${options.version_hash}`; } /** * Return as a response that renders the error.html * * @param {import('types').SSROptions} options * @param {number} status * @param {string} message */ function static_error_page(options, status, message) { return text(options.templates.error({ status, message: escape_html(message) }), { headers: { "content-type": "text/html; charset=utf-8" }, status }); } /** * @param {import('@sveltejs/kit').RequestEvent} event * @param {import('types').RequestState} state * @param {import('types').SSROptions} options * @param {unknown} error */ async function handle_fatal_error(event, state, options, error) { error = error instanceof HttpError ? error : coalesce_to_error(error); const status = get_status(error); const body = await handle_error_and_jsonify(event, state, options, error); const type = negotiate(event.request.headers.get("accept") || "text/html", ["application/json", "text/html"]); if (event.isDataRequest || type === "application/json") return json(body, { status }); return static_error_page(options, status, body.message); } /** * @param {import('@sveltejs/kit').RequestEvent} event * @param {import('types').RequestState} state * @param {import('types').SSROptions} options * @param {any} error * @returns {Promise} */ async function handle_error_and_jsonify(event, state, options, error) { if (error instanceof HttpError) return { message: "Unknown Error", ...error.body }; const status = get_status(error); const message = get_message(error); return await with_request_store({ event, state }, () => options.hooks.handleError({ error, event, status, message })) ?? { message }; } /** * @param {number} status * @param {string} location */ function redirect_response(status, location) { return new Response(void 0, { status, headers: { location } }); } /** * @param {import('@sveltejs/kit').RequestEvent} event * @param {Error & { path: string }} error */ function clarify_devalue_error(event, error) { if (error.path) return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path}). If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`; if (error.path === "") return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`; return error.message; } /** * @param {import('types').ServerDataNode} node */ function serialize_uses(node) { const uses = {}; if (node.uses && node.uses.dependencies.size > 0) uses.dependencies = Array.from(node.uses.dependencies); if (node.uses && node.uses.search_params.size > 0) uses.search_params = Array.from(node.uses.search_params); if (node.uses && node.uses.params.size > 0) uses.params = Array.from(node.uses.params); if (node.uses?.parent) uses.parent = 1; if (node.uses?.route) uses.route = 1; if (node.uses?.url) uses.url = 1; return uses; } /** * Returns `true` if the given path was prerendered * @param {import('@sveltejs/kit').SSRManifest} manifest * @param {string} pathname Should include the base and be decoded */ function has_prerendered_path(manifest, pathname) { return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1)); } /** * Formats the error into a nice message with sanitized stack trace * @param {number} status * @param {Error} error * @param {import('@sveltejs/kit').RequestEvent} event */ function format_server_error(status, error, event) { const formatted_text = `\n\x1b[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1b[0m`; if (status === 404) return formatted_text; return `${formatted_text}\n${error.stack}`; } /** * Returns the filename without the extension. e.g., `+page.server`, `+page`, etc. * @param {string | undefined} node_id * @returns {string} */ function get_node_type(node_id) { const filename = (node_id?.split("/"))?.at(-1); if (!filename) return "unknown"; return filename.split(".").slice(0, -1).join("."); } /** * Creates a serialiser for non-arbitrary POJOs using the app's transport hook * @param {ServerHooks['transport']} transport * @returns {(thing: unknown) => string | undefined} */ function create_replacer(transport) { /** @param {unknown} thing */ const replacer = (thing) => { for (const key in transport) { const encoded = transport[key].encode(thing); if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`; } }; return replacer; } //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/utils/promise.js /** @see https://github.com/microsoft/TypeScript/blob/904e7dd97dc8da1352c8e05d70829dff17c73214/src/lib/es2024.promise.d.ts */ /** * @template T * @typedef {{ * promise: Promise; * resolve: (value: T | PromiseLike) => void; * reject: (reason?: any) => void; * }} PromiseWithResolvers */ /** * TODO: Whenever Node >21 is minimum supported version, we can use `Promise.withResolvers` to avoid this ceremony * * @template T * @returns {PromiseWithResolvers} */ function with_resolvers() { let resolve; let reject; return { promise: new Promise((res, rej) => { resolve = res; reject = rej; }), resolve, reject }; } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/server/constants.js var NULL_BODY_STATUS = [ 101, 103, 204, 205, 304 ]; var IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer; //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js /** * @param {import('@sveltejs/kit').RequestEvent} event * @param {import('types').RequestState} event_state * @param {import('types').SSREndpoint} mod * @param {import('types').SSRState} state * @returns {Promise} */ async function render_endpoint(event, event_state, mod, state) { const method = event.request.method; let handler = mod[method] || mod.fallback; if (method === "HEAD" && !mod.HEAD && mod.GET) handler = mod.GET; if (!handler) return method_not_allowed(mod, method); const prerender = mod.prerender ?? state.prerender_default; if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) throw new Error("Cannot prerender endpoints that have mutative methods"); if (state.prerendering && !state.prerendering.inside_reroute && !prerender) if (state.depth > 0) throw new Error(`${event.route.id} is not prerenderable`); else return new Response(void 0, { status: 204 }); try { const response = await with_request_store({ event, state: event_state }, () => handler(event)); if (!(response instanceof Response)) throw new Error(`Invalid response from route ${event.url.pathname}: handler should return a Response object`); if (state.prerendering && (!state.prerendering.inside_reroute || prerender)) { const cloned = new Response(response.clone().body, { status: response.status, statusText: response.statusText, headers: new Headers(response.headers) }); cloned.headers.set("x-sveltekit-prerender", String(prerender)); if (state.prerendering.inside_reroute && prerender) { cloned.headers.set("x-sveltekit-routeid", encodeURI(event.route.id)); state.prerendering.dependencies.set(event.url.pathname, { response: cloned, body: null }); } else return cloned; } return response; } catch (e) { if (e instanceof Redirect) return new Response(void 0, { status: e.status, headers: { location: e.location } }); throw e; } } /** * @param {import('@sveltejs/kit').RequestEvent} event */ function is_endpoint_request(event) { const { method, headers } = event.request; if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) return true; if (method === "POST" && headers.get("x-sveltekit-action") === "true") return false; return negotiate(event.request.headers.get("accept") ?? "*/*", ["*", "text/html"]) !== "text/html"; } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/telemetry/record_span.js /** @import { RecordSpan } from 'types' */ /** @type {RecordSpan} */ async function record_span({ name, attributes, fn }) { return fn(noop_span); } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js /** @import { RequestEvent, ActionResult, Actions } from '@sveltejs/kit' */ /** @import { SSROptions, SSRNode, ServerNode, ServerHooks } from 'types' */ /** @param {RequestEvent} event */ function is_action_json_request(event) { return negotiate(event.request.headers.get("accept") ?? "*/*", ["application/json", "text/html"]) === "application/json" && event.request.method === "POST"; } /** * @param {RequestEvent} event * @param {import('types').RequestState} event_state * @param {SSROptions} options * @param {SSRNode['server'] | undefined} server */ async function handle_action_json_request(event, event_state, options, server) { const actions = server?.actions; if (!actions) { const no_actions_error = new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`); return action_json({ type: "error", error: await handle_error_and_jsonify(event, event_state, options, no_actions_error) }, { status: no_actions_error.status, headers: { allow: "GET" } }); } check_named_default_separate(actions); try { const data = await call_action(event, event_state, actions); if (data instanceof ActionFailure) return action_json({ type: "failure", status: data.status, data: stringify_action_response(data.data, event.route.id, options.hooks.transport) }); else return action_json({ type: "success", status: data ? 200 : 204, data: stringify_action_response(data, event.route.id, options.hooks.transport) }); } catch (e) { const err = normalize_error(e); if (err instanceof Redirect) return action_json_redirect(err); return action_json({ type: "error", error: await handle_error_and_jsonify(event, event_state, options, check_incorrect_fail_use(err)) }, { status: get_status(err) }); } } /** * @param {HttpError | Error} error */ function check_incorrect_fail_use(error) { return error instanceof ActionFailure ? /* @__PURE__ */ new Error("Cannot \"throw fail()\". Use \"return fail()\"") : error; } /** * @param {Redirect} redirect */ function action_json_redirect(redirect) { return action_json({ type: "redirect", status: redirect.status, location: redirect.location }); } /** * @param {ActionResult} data * @param {ResponseInit} [init] */ function action_json(data, init) { return json(data, init); } /** * @param {RequestEvent} event */ function is_action_request(event) { return event.request.method === "POST"; } /** * @param {RequestEvent} event * @param {import('types').RequestState} event_state * @param {SSRNode['server'] | undefined} server * @returns {Promise} */ async function handle_action_request(event, event_state, server) { const actions = server?.actions; if (!actions) { event.setHeaders({ allow: "GET" }); return { type: "error", error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`) }; } check_named_default_separate(actions); try { const data = await call_action(event, event_state, actions); if (data instanceof ActionFailure) return { type: "failure", status: data.status, data: data.data }; else return { type: "success", status: 200, data }; } catch (e) { const err = normalize_error(e); if (err instanceof Redirect) return { type: "redirect", status: err.status, location: err.location }; return { type: "error", error: check_incorrect_fail_use(err) }; } } /** * @param {Actions} actions */ function check_named_default_separate(actions) { if (actions.default && Object.keys(actions).length > 1) throw new Error("When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions"); } /** * @param {RequestEvent} event * @param {import('types').RequestState} event_state * @param {NonNullable} actions * @throws {Redirect | HttpError | SvelteKitError | Error} */ async function call_action(event, event_state, actions) { const url = new URL(event.request.url); let name = "default"; for (const param of url.searchParams) if (param[0].startsWith("/")) { name = param[0].slice(1); if (name === "default") throw new Error("Cannot use reserved action name \"default\""); break; } const action = actions[name]; if (!action) throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`); 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")}`); return record_span({ name: "sveltekit.form_action", attributes: { "http.route": event.route.id || "unknown" }, fn: async (current) => { const traced_event = merge_tracing(event, current); const result = await with_request_store({ event: traced_event, state: event_state }, () => action(traced_event)); if (result instanceof ActionFailure) current.setAttributes({ "sveltekit.form_action.result.type": "failure", "sveltekit.form_action.result.status": result.status }); return result; } }); } /** * Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context * @param {any} data * @param {string} route_id * @param {ServerHooks['transport']} transport */ function uneval_action_response(data, route_id, transport) { const replacer = create_replacer(transport); return try_serialize(data, (value) => uneval(value, replacer), route_id); } /** * Try to `devalue.stringify` the data object, and if it fails, return a proper Error with context * @param {any} data * @param {string} route_id * @param {ServerHooks['transport']} transport */ function stringify_action_response(data, route_id, transport) { const encoders = Object.fromEntries(Object.entries(transport).map(([key, value]) => [key, value.encode])); return try_serialize(data, (value) => stringify$1(value, encoders), route_id); } /** * @param {any} data * @param {(data: any) => string} fn * @param {string} route_id */ function try_serialize(data, fn, route_id) { try { return fn(data); } catch (e) { const error = e; if (data instanceof Response) throw new Error(`Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`, { cause: e }); if ("path" in error) { let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`; if (error.path !== "") message += ` (data.${error.path})`; throw new Error(message, { cause: e }); } throw error; } } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/utils/streaming.js /** * Create an async iterator and a function to push values into it * @template T * @returns {{ * iterate: (transform?: (input: T) => T) => AsyncIterable; * add: (promise: Promise) => void; * }} */ function create_async_iterator() { let resolved = -1; let returned = -1; /** @type {import('./promise.js').PromiseWithResolvers[]} */ const deferred = []; return { iterate: (transform = (x) => x) => { return { [Symbol.asyncIterator]() { return { next: async () => { const next = deferred[++returned]; if (!next) return { value: null, done: true }; return { value: transform(await next.promise), done: false }; } }; } }; }, add: (promise) => { deferred.push(with_resolvers()); promise.then((value) => { deferred[++resolved].resolve(value); }); } }; } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/server/page/data_serializer.js /** * If the serialized data contains promises, `chunks` will be an * async iterable containing their resolutions * @param {import('@sveltejs/kit').RequestEvent} event * @param {import('types').RequestState} event_state * @param {import('types').SSROptions} options * @returns {import('./types.js').ServerDataSerializer} */ function server_data_serializer(event, event_state, options) { let promise_id = 1; let max_nodes = -1; const iterator = create_async_iterator(); const global = get_global_name(options); /** @param {number} index */ function get_replacer(index) { /** @param {any} thing */ return function replacer(thing) { if (typeof thing?.then === "function") { const id = promise_id++; const promise = thing.then( /** @param {any} data */ (data) => ({ data }) ).catch( /** @param {any} error */ async (error) => ({ error: await handle_error_and_jsonify(event, event_state, options, error) }) ).then( /** * @param {{data: any; error: any}} result */ async ({ data, error }) => { let str; try { str = uneval(error ? [, error] : [data], replacer); } catch { error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`)); str = uneval([, error], replacer); } return { index, str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})` }; } ); iterator.add(promise); return `${global}.defer(${id})`; } else for (const key in options.hooks.transport) { const encoded = options.hooks.transport[key].encode(thing); if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`; } }; } const strings = []; return { set_max_nodes(i) { max_nodes = i; }, add_node(i, node) { try { if (!node) { strings[i] = "null"; return; } /** @type {any} */ const payload = { type: "data", data: node.data, uses: serialize_uses(node) }; if (node.slash) payload.slash = node.slash; strings[i] = uneval(payload, get_replacer(i)); } catch (e) { e.path = e.path.slice(1); throw new Error(clarify_devalue_error(event, e), { cause: e }); } }, get_data(csp) { const open = ``; const close = `<\/script>\n`; return { data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`, chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => { if (max_nodes > -1 && index >= max_nodes) return ""; return open + str + close; }) : null }; } }; } /** * If the serialized data contains promises, `chunks` will be an * async iterable containing their resolutions * @param {import('@sveltejs/kit').RequestEvent} event * @param {import('types').RequestState} event_state * @param {import('types').SSROptions} options * @returns {import('./types.js').ServerDataSerializerJson} */ function server_data_serializer_json(event, event_state, options) { let promise_id = 1; const iterator = create_async_iterator(); const reducers = { ...Object.fromEntries(Object.entries(options.hooks.transport).map(([key, value]) => [key, value.encode])), /** @param {any} thing */ Promise: (thing) => { if (typeof thing?.then !== "function") return; const id = promise_id++; /** @type {'data' | 'error'} */ let key = "data"; const promise = thing.catch( /** @param {any} e */ async (e) => { key = "error"; return handle_error_and_jsonify(event, event_state, options, e); } ).then( /** @param {any} value */ async (value) => { let str; try { str = stringify$1(value, reducers); } catch { const error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`)); key = "error"; str = stringify$1(error, reducers); } return `{"type":"chunk","id":${id},"${key}":${str}}\n`; } ); iterator.add(promise); return id; } }; const strings = []; return { add_node(i, node) { try { if (!node) { strings[i] = "null"; return; } if (node.type === "error" || node.type === "skip") { strings[i] = JSON.stringify(node); return; } strings[i] = `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(serialize_uses(node))}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`; } catch (e) { e.path = "data" + e.path; throw new Error(clarify_devalue_error(event, e), { cause: e }); } }, get_data() { return { data: `{"type":"data","nodes":[${strings.join(",")}]}\n`, chunks: promise_id > 1 ? iterator.iterate() : null }; } }; } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js /** * Calls the user's server `load` function. * @param {{ * event: import('@sveltejs/kit').RequestEvent; * event_state: import('types').RequestState; * state: import('types').SSRState; * node: import('types').SSRNode | undefined; * parent: () => Promise>; * }} opts * @returns {Promise} */ async function load_server_data({ event, event_state, state, node, parent }) { if (!node?.server) return null; let is_tracking = true; const uses = { dependencies: /* @__PURE__ */ new Set(), params: /* @__PURE__ */ new Set(), parent: false, route: false, url: false, search_params: /* @__PURE__ */ new Set() }; const load = node.server.load; const slash = node.server.trailingSlash; if (!load) return { type: "data", data: null, uses, slash }; const url = make_trackable(event.url, () => { if (is_tracking) uses.url = true; }, (param) => { if (is_tracking) uses.search_params.add(param); }); if (state.prerendering) disable_search(url); return { type: "data", data: await record_span({ name: "sveltekit.load", attributes: { "sveltekit.load.node_id": node.server_id || "unknown", "sveltekit.load.node_type": get_node_type(node.server_id), "http.route": event.route.id || "unknown" }, fn: async (current) => { const traced_event = merge_tracing(event, current); return await with_request_store({ event: traced_event, state: event_state }, () => load.call(null, { ...traced_event, fetch: (info, init) => { new URL(info instanceof Request ? info.url : info, event.url); return event.fetch(info, init); }, /** @param {string[]} deps */ depends: (...deps) => { for (const dep of deps) { const { href } = new URL(dep, event.url); uses.dependencies.add(href); } }, params: new Proxy(event.params, { get: (target, key) => { if (is_tracking) uses.params.add(key); return target[key]; } }), parent: async () => { if (is_tracking) uses.parent = true; return parent(); }, route: new Proxy(event.route, { get: (target, key) => { if (is_tracking) uses.route = true; return target[key]; } }), url, untrack(fn) { is_tracking = false; try { return fn(); } finally { is_tracking = true; } } })); } }) ?? null, uses, slash }; } /** * Calls the user's `load` function. * @param {{ * event: import('@sveltejs/kit').RequestEvent; * event_state: import('types').RequestState; * fetched: import('./types.js').Fetched[]; * node: import('types').SSRNode | undefined; * parent: () => Promise>; * resolve_opts: import('types').RequiredResolveOptions; * server_data_promise: Promise; * state: import('types').SSRState; * csr: boolean; * }} opts * @returns {Promise> | null>} */ async function load_data({ event, event_state, fetched, node, parent, server_data_promise, state, resolve_opts, csr }) { const server_data_node = await server_data_promise; const load = node?.universal?.load; if (!load) return server_data_node?.data ?? null; return await record_span({ name: "sveltekit.load", attributes: { "sveltekit.load.node_id": node.universal_id || "unknown", "sveltekit.load.node_type": get_node_type(node.universal_id), "http.route": event.route.id || "unknown" }, fn: async (current) => { const traced_event = merge_tracing(event, current); return await with_request_store({ event: traced_event, state: { ...event_state, is_in_universal_load: true } }, () => load.call(null, { url: event.url, params: event.params, data: server_data_node?.data ?? null, route: event.route, fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts), setHeaders: event.setHeaders, depends: noop, parent, untrack: (fn) => fn(), tracing: traced_event.tracing })); } }) ?? null; } /** * @param {Pick} event * @param {import('types').SSRState} state * @param {import('./types.js').Fetched[]} fetched * @param {boolean} csr * @param {Pick, 'filterSerializedResponseHeaders'>} resolve_opts * @returns {typeof fetch} */ function create_universal_fetch(event, state, fetched, csr, resolve_opts) { /** * @param {URL | RequestInfo} input * @param {RequestInit} [init] */ const universal_fetch = async (input, init) => { const cloned_body = input instanceof Request && input.body ? input.clone().body : null; const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init?.headers; let response = await event.fetch(input, init); const url = new URL(input instanceof Request ? input.url : input, event.url); const same_origin = url.origin === event.url.origin; /** @type {import('types').PrerenderDependency} */ let dependency; if (same_origin) { if (state.prerendering) { dependency = { response, body: null }; state.prerendering.dependencies.set(url.pathname, dependency); } } else if (url.protocol === "https:" || url.protocol === "http:") if ((input instanceof Request ? input.mode : init?.mode ?? "cors") === "no-cors") response = new Response("", { status: response.status, statusText: response.statusText, headers: response.headers }); else { const acao = response.headers.get("access-control-allow-origin"); if (!acao || acao !== event.url.origin && acao !== "*") throw new Error(`CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource`); } /** @type {ReadableStream} */ let teed_body; const proxy = new Proxy(response, { get(response, key, receiver) { /** * @param {string | undefined} body * @param {boolean} is_b64 */ async function push_fetched(body, is_b64) { const status_number = Number(response.status); if (isNaN(status_number)) throw new Error(`response.status is not a number. value: "${response.status}" type: ${typeof response.status}`); fetched.push({ url: same_origin ? url.href.slice(event.url.origin.length) : url.href, method: event.request.method, request_body: input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init?.body, request_headers: cloned_headers, response_body: body, response, is_b64 }); } if (key === "body") { if (response.body === null) return null; if (teed_body) return teed_body; const [a, b] = response.body.tee(); (async () => { let result = new Uint8Array(); for await (const chunk of a) { const combined = new Uint8Array(result.length + chunk.length); combined.set(result, 0); combined.set(chunk, result.length); result = combined; } if (dependency) dependency.body = new Uint8Array(result); push_fetched(base64_encode(result), true); })(); return teed_body = b; } if (key === "arrayBuffer") return async () => { const buffer = await response.arrayBuffer(); const bytes = new Uint8Array(buffer); if (dependency) dependency.body = bytes; if (buffer instanceof ArrayBuffer) await push_fetched(base64_encode(bytes), true); return buffer; }; async function text() { const body = await response.text(); if (body === "" && NULL_BODY_STATUS.includes(response.status)) { await push_fetched(void 0, false); return; } if (!body || typeof body === "string") await push_fetched(body, false); if (dependency) dependency.body = body; return body; } if (key === "text") return text; if (key === "json") return async () => { const body = await text(); return body ? JSON.parse(body) : void 0; }; const value = Reflect.get(response, key, response); if (value instanceof Function) return Object.defineProperties( /** * @this {any} */ function() { return Reflect.apply(value, this === receiver ? response : this, arguments); }, { name: { value: value.name }, length: { value: value.length } } ); return value; } }); if (csr) { const get = response.headers.get; response.headers.get = (key) => { const lower = key.toLowerCase(); const value = get.call(response.headers, lower); if (value && !lower.startsWith("x-sveltekit-")) { if (!resolve_opts.filterSerializedResponseHeaders(lower, value)) throw new Error(`Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`); } return value; }; } return proxy; }; return (input, init) => { const response = universal_fetch(input, init); response.catch(noop); return response; }; } /** * @param {ReadableStream} stream */ async function stream_to_string(stream) { let result = ""; const reader = stream.getReader(); const decoder = new TextDecoder(); while (true) { const { done, value } = await reader.read(); if (done) { result += decoder.decode(); break; } result += decoder.decode(value, { stream: true }); } return result; } //#endregion //#region node_modules/.pnpm/@sveltejs+kit@2.61.1_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.55.9_@typescript-eslin_1eb4acd89e2a6645581271b871efb1f8/node_modules/@sveltejs/kit/src/runtime/server/page/serialize_data.js /** * Inside a script element, only `<\/script` and ``, so the script element might be unexpectedly * kept open up until an unrelated HTML comment in the page. * * U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are escaped for the sake of pre-2018 * browsers. * * @see tests for unsafe parsing examples. * @see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements * @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-state * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escaped-state * @see https://github.com/tc39/proposal-json-superset * @type {Record} */ var replacements = { "<": "\\u003C", "\u2028": "\\u2028", "\u2029": "\\u2029" }; var pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g"); /** * Generates a raw HTML string containing a safe script element carrying data and associated attributes. * * It escapes all the special characters needed to guarantee the element is unbroken, but care must * be taken to ensure it is inserted in the document at an acceptable position for a script element, * and that the resulting string isn't further modified. * * @param {import('./types.js').Fetched} fetched * @param {(name: string, value: string) => boolean} filter * @param {boolean} [prerendering] * @returns {string} The raw HTML of a script element carrying the JSON payload. * @example const html = serialize_data('/data.json', null, { foo: 'bar' }); */ function serialize_data(fetched, filter, prerendering = false) { /** @type {Record} */ const headers = {}; let cache_control = null; let age = null; let varyAny = false; for (const [key, value] of fetched.response.headers) { if (filter(key, value)) headers[key] = value; if (key === "cache-control") cache_control = value; else if (key === "age") age = value; else if (key === "vary" && value.trim() === "*") varyAny = true; } const payload = { status: fetched.response.status, statusText: fetched.response.statusText, headers, body: fetched.response_body }; const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]); const attrs = [ "type=\"application/json\"", "data-sveltekit-fetched", `data-url="${escape_html(fetched.url, true)}"` ]; if (fetched.is_b64) attrs.push("data-b64"); if (fetched.request_headers || fetched.request_body) { /** @type {import('types').StrictBody[]} */ const values = []; if (fetched.request_headers) values.push([...new Headers(fetched.request_headers)].join(",")); if (fetched.request_body) values.push(fetched.request_body); attrs.push(`data-hash="${hash(...values)}"`); } if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) { const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control); if (match) { const ttl = +match[1] - +(age ?? "0"); attrs.push(`data-ttl="${ttl}"`); } } return `