{"version":3,"file":"index.c4ca6160.js","sources":["../../../../../../node_modules/@sveltejs/kit/src/exports/index.js"],"sourcesContent":["import { HttpError, Redirect, ActionFailure } from '../runtime/control.js';\nimport { BROWSER, DEV } from 'esm-env';\nimport { get_route_segments } from '../utils/routing.js';\n\nexport { VERSION } from '../version.js';\n\n/**\n * @overload\n * @param {number} status\n * @param {App.Error} body\n * @return {HttpError}\n */\n\n/**\n * @overload\n * @param {number} status\n * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body]\n * @return {HttpError}\n */\n\n/**\n * Creates an `HttpError` object with an HTTP status code and an optional message.\n * This object, if thrown during request handling, will cause SvelteKit to\n * return an error response without invoking `handleError`.\n * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.\n * @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.\n * @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.\n */\nexport function error(status, body) {\n\tif ((!BROWSER || DEV) && (isNaN(status) || status < 400 || status > 599)) {\n\t\tthrow new Error(`HTTP error status codes must be between 400 and 599 — ${status} is invalid`);\n\t}\n\n\treturn new HttpError(status, body);\n}\n\n/**\n * Create a `Redirect` object. If thrown during request handling, SvelteKit will return a redirect response.\n * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it.\n * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.\n * @param {string | URL} location The location to redirect to.\n */\nexport function redirect(status, location) {\n\tif ((!BROWSER || DEV) && (isNaN(status) || status < 300 || status > 308)) {\n\t\tthrow new Error('Invalid status code');\n\t}\n\n\treturn new Redirect(status, location.toString());\n}\n\n/**\n * Create a JSON `Response` object from the supplied data.\n * @param {any} data The value that will be serialized as JSON.\n * @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.\n */\nexport function json(data, init) {\n\t// TODO deprecate this in favour of `Response.json` when it's\n\t// more widely supported\n\tconst body = JSON.stringify(data);\n\n\t// we can't just do `text(JSON.stringify(data), init)` because\n\t// it will set a default `content-type` header. duplicated code\n\t// means less duplicated work\n\tconst headers = new Headers(init?.headers);\n\tif (!headers.has('content-length')) {\n\t\theaders.set('content-length', encoder.encode(body).byteLength.toString());\n\t}\n\n\tif (!headers.has('content-type')) {\n\t\theaders.set('content-type', 'application/json');\n\t}\n\n\treturn new Response(body, {\n\t\t...init,\n\t\theaders\n\t});\n}\n\nconst encoder = new TextEncoder();\n\n/**\n * Create a `Response` object from the supplied body.\n * @param {string} body The value that will be used as-is.\n * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically.\n */\nexport function text(body, init) {\n\tconst headers = new Headers(init?.headers);\n\tif (!headers.has('content-length')) {\n\t\tconst encoded = encoder.encode(body);\n\t\theaders.set('content-length', encoded.byteLength.toString());\n\t\treturn new Response(encoded, {\n\t\t\t...init,\n\t\t\theaders\n\t\t});\n\t}\n\n\treturn new Response(body, {\n\t\t...init,\n\t\theaders\n\t});\n}\n\n/**\n * Create an `ActionFailure` object.\n * @template {Record | undefined} [T=undefined]\n * @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.\n * @param {T} [data] Data associated with the failure (e.g. validation errors)\n * @returns {ActionFailure}\n */\nexport function fail(status, data) {\n\treturn new ActionFailure(status, data);\n}\n\nconst basic_param_pattern = /\\[(\\[)?(\\.\\.\\.)?(\\w+?)(?:=(\\w+))?\\]\\]?/g;\n\nlet warned = false;\n\n/**\n * @deprecated Use `resolveRoute` from `$app/paths` instead.\n *\n * Populate a route ID with params to resolve a pathname.\n * @example\n * ```js\n * resolvePath(\n * `/blog/[slug]/[...somethingElse]`,\n * {\n * slug: 'hello-world',\n * somethingElse: 'something/else'\n * }\n * ); // `/blog/hello-world/something/else`\n * ```\n * @param {string} id\n * @param {Record} params\n * @returns {string}\n */\nexport function resolvePath(id, params) {\n\tif (!warned) {\n\t\tconsole.warn('`resolvePath` is deprecated. Use `resolveRoute` from `$app/paths` instead.');\n\t\twarned = true;\n\t}\n\n\tconst segments = get_route_segments(id);\n\treturn (\n\t\t'/' +\n\t\tsegments\n\t\t\t.map((segment) =>\n\t\t\t\tsegment.replace(basic_param_pattern, (_, optional, rest, name) => {\n\t\t\t\t\tconst param_value = params[name];\n\n\t\t\t\t\t// This is nested so TS correctly narrows the type\n\t\t\t\t\tif (!param_value) {\n\t\t\t\t\t\tif (optional) return '';\n\t\t\t\t\t\tif (rest && param_value !== undefined) return '';\n\t\t\t\t\t\tthrow new Error(`Missing parameter '${name}' in route ${id}`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (param_value.startsWith('/') || param_value.endsWith('/'))\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`\n\t\t\t\t\t\t);\n\t\t\t\t\treturn param_value;\n\t\t\t\t})\n\t\t\t)\n\t\t\t.filter(Boolean)\n\t\t\t.join('/')\n\t);\n}\n"],"names":[],"mappings":"AA8EgB,IAAI","x_google_ignoreList":[0]}