From ecf6798141e007f72a14c2323d245d4a558fa22e Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 9 Nov 2026 14:42:37 -0800 Subject: [PATCH 1/3] fix(next): keep route-handler framing for bodies Next did not decode --- apps/docs/scripts/test-header-merge-e2e.ts | 141 ++++++++++++++++++++- patches/README.md | 28 ++++ patches/next@16.4.5.patch | 66 ++++++++++ 3 files changed, 234 insertions(+), 1 deletion(-) diff --git a/apps/docs/scripts/test-header-merge-e2e.ts b/apps/docs/scripts/test-header-merge-e2e.ts index b2c2f37be93..082ad53382c 100644 --- a/apps/docs/scripts/test-header-merge-e2e.ts +++ b/apps/docs/scripts/test-header-merge-e2e.ts @@ -1,13 +1,15 @@ import { mkdir, writeFile } from 'node:fs/promises' -import { createServer, type IncomingMessage, type ServerResponse } from 'node:http' +import { createServer, get, type IncomingMessage, type ServerResponse } from 'node:http' import { createRequire } from 'node:module' import { dirname } from 'node:path' import { pathToFileURL } from 'node:url' import { createLogger } from '@sim/logger' import { getErrorMessage } from '@sim/utils/errors' import { toRecord } from '@sim/utils/object' +import { NodeNextRequest, NodeNextResponse } from 'next/dist/server/base-http/node' import { patchSetHeaderWithCookieSupport } from 'next/dist/server/lib/patch-set-header' import { addRequestMeta } from 'next/dist/server/request-meta' +import { sendResponse } from 'next/dist/server/send-response' const logger = createLogger('DocsHeaderMergeE2E') const reportPath = process.env.DOCS_HEADER_REPORT_PATH @@ -80,11 +82,66 @@ const cases: HeaderCase[] = [ }, ] +interface FramingCase { + name: string + body: string + headers: Record + expected: { 'content-length'?: string; 'content-encoding'?: string } + forbidden?: string[] +} + +const framingBody = 'route handler body' +const framingCases: FramingCase[] = [ + { + name: 'an unencoded body keeps its declared length', + body: framingBody, + headers: { 'Content-Length': String(framingBody.length) }, + expected: { 'content-length': String(framingBody.length) }, + }, + { + name: 'an identity coding keeps its length and coding', + body: framingBody, + headers: { 'Content-Encoding': 'identity', 'Content-Length': String(framingBody.length) }, + expected: { 'content-length': String(framingBody.length), 'content-encoding': 'identity' }, + }, + { + name: 'a streaming response keeps its no-compression marker', + body: framingBody, + headers: { 'Content-Encoding': 'none' }, + expected: { 'content-encoding': 'none' }, + }, + { + name: 'a transparently decoded body drops its stale length and coding', + body: framingBody, + headers: { 'Content-Encoding': 'gzip', 'Content-Length': '7' }, + expected: {}, + forbidden: ['content-length', 'content-encoding'], + }, + { + name: 'a declared transfer coding is never forwarded', + body: framingBody, + headers: { 'Transfer-Encoding': 'gzip, chunked' }, + expected: {}, + }, +] + const require = createRequire(import.meta.url) const esmPath = require.resolve('next/dist/esm/server/lib/patch-set-header.js') const imported: unknown = await import(pathToFileURL(esmPath).href) const esmPatch = toRecord(imported).patchSetHeaderWithCookieSupport if (typeof esmPatch !== 'function') throw new Error('The ESM header merger is unavailable') +const esmSendPath = require.resolve('next/dist/esm/server/send-response.js') +const esmSendResponse = toRecord(await import(pathToFileURL(esmSendPath).href)).sendResponse +if (typeof esmSendResponse !== 'function') throw new Error('The ESM response sender is unavailable') +const senders: Array<{ name: string; send: typeof sendResponse }> = [ + { name: 'CommonJS', send: sendResponse }, + { + name: 'ESM', + send: async (req, res, response) => { + await esmSendResponse(req, res, response) + }, + }, +] const variants: Array<{ name: string @@ -187,6 +244,88 @@ try { ) } } + for (const sender of senders) { + const server = createServer((req, res) => { + const entry = framingCases[Number(req.url?.slice(1))] + if (!entry) { + res.writeHead(404).end() + return + } + sender + .send( + new NodeNextRequest(req), + new NodeNextResponse(res), + new Response(entry.body, { headers: entry.headers }) + ) + .catch((error: unknown) => { + res.statusCode = 500 + res.end(getErrorMessage(error)) + }) + }) + await new Promise((resolve, reject) => { + server.once('error', reject) + server.listen(0, '127.0.0.1', resolve) + }) + try { + const address = server.address() + if (!address || typeof address === 'string') + throw new Error('No loopback listener is available') + for (const [index, entry] of framingCases.entries()) { + const started = performance.now() + let error: string | undefined + try { + const { status, headers, body } = await new Promise<{ + status: number + headers: IncomingMessage['headers'] + body: string + }>((resolve, reject) => { + const request = get( + { host: '127.0.0.1', port: address.port, path: `/${index}`, timeout: 5000 }, + (response) => { + const chunks: Buffer[] = [] + response.on('data', (chunk: Buffer) => chunks.push(chunk)) + response.on('end', () => + resolve({ + status: response.statusCode ?? 0, + headers: response.headers, + body: Buffer.concat(chunks).toString('utf8'), + }) + ) + response.on('error', reject) + } + ) + request.on('timeout', () => request.destroy(new Error('Request timed out'))) + request.on('error', reject) + }) + if (status !== 200 || body !== entry.body) + throw new Error(`Unexpected response: ${status} ${JSON.stringify(body)}`) + for (const [name, value] of Object.entries(entry.expected)) + if (headers[name] !== value) + throw new Error(`Expected ${name} ${value}, got ${String(headers[name])}`) + for (const name of entry.forbidden ?? []) + if (headers[name] !== undefined) + throw new Error(`Stale ${name} was forwarded: ${String(headers[name])}`) + if ( + entry.headers['Transfer-Encoding'] && + headers['transfer-encoding'] === 'gzip, chunked' + ) + throw new Error('The declared transfer coding was forwarded') + } catch (caught) { + error = getErrorMessage(caught) + } + checks.push({ + name: `${sender.name}: ${entry.name}`, + status: error ? 'failed' : 'passed', + durationMs: Math.round(performance.now() - started), + ...(error ? { error } : {}), + }) + } + } finally { + await new Promise((resolve, reject) => + server.close((error) => (error ? reject(error) : resolve())) + ) + } + } } catch (error) { checks.push({ name: 'Header suite lifecycle', diff --git a/patches/README.md b/patches/README.md index b49f6bccdb1..e0360bef6d3 100644 --- a/patches/README.md +++ b/patches/README.md @@ -140,6 +140,34 @@ bun run --cwd apps/docs test:negotiation:e2e Remove the patch when upgrading to a release with equivalent Vary preservation, and retain the HTTP regression check. +# Next.js route-handler response framing + +`next@16.4.5` (GHSA-pc58-hwjq-p385) drops `Content-Length`, `Content-Encoding`, +and `Transfer-Encoding` from every Node route-handler response. The concern is a +fetched upstream response returned unchanged: fetch decodes its body but keeps +the original coding and length, so forwarding them frames a body that was never +sent. Dropping the headers from every response also strips the declared length +from file downloads, which then arrive chunked with no size, and the +`Content-Encoding: none` marker that keeps streaming responses uncompressed. + +The same file's patch narrows that rule in `sendResponse`, in both the CommonJS +and ESM builds. A response whose `Content-Encoding` names a real coding keeps +upstream's behavior: its length and coding are dropped. A response with no coding, +or with `identity`/`none`, was not decoded, so its `Content-Length` and coding are +forwarded. `Transfer-Encoding` is never forwarded; Node frames the response +itself. Route handlers, App Page rendering, and the edge runtime are otherwise +unchanged. + +`test:headers:e2e` sends real responses through both builds of `sendResponse` +over loopback HTTP. The unencoded, `identity`, and `none` checks fail against +unpatched 16.4.5. The decoded-body and transfer-coding checks fail when their +guards are removed; forwarding a decoded body's stale length leaves the client +unable to parse the connection. The project-files E2E's large-download check +asserts the declared length of a 100 MB file served through the running app. + +Remove this part of the patch when upstream forwards framing for undecoded +route-handler bodies, and keep both regression checks. + # Zod collection size bounds `zod@4.3.6` runs an array's `.max()`/`.length()` (and a set's or map's `.max()`/`.size()`) diff --git a/patches/next@16.4.5.patch b/patches/next@16.4.5.patch index 9c4f122d5ce..b3d1f5f5466 100644 --- a/patches/next@16.4.5.patch +++ b/patches/next@16.4.5.patch @@ -34,6 +34,39 @@ index f2236f7ae222afcb8554267ed295ada59dceee6a..3be146fc8fa48196254d93a8a21c2cea if (name.toLowerCase() === 'set-cookie') { const middlewareValue = getRequestMeta(req, 'middlewareCookie'); if (!middlewareValue || !Array.isArray(value) || !value.every((item, idx)=>item === middlewareValue[idx])) { +diff --git a/dist/esm/server/send-response.js b/dist/esm/server/send-response.js +index 080d60cb20a57b7e81411c12ed16e41e1fdbf621..4ee71ca70339473a26366d7ecee0ba6c0b64be92 100644 +--- a/dist/esm/server/send-response.js ++++ b/dist/esm/server/send-response.js +@@ -10,6 +10,12 @@ const FORBIDDEN_HEADERS = [ + 'content-encoding', + 'transfer-encoding' + ]; ++// A body that declares no content coding was not transparently decoded, so its declared length ++// still frames it; only a decoded body's length and coding are stale. ++const IDENTITY_ENCODINGS = [ ++ 'identity', ++ 'none' ++]; + /** + * Sends the response on the underlying next response object. + * +@@ -37,12 +43,14 @@ const FORBIDDEN_HEADERS = [ + 'proxy-authenticate', + 'vary' + ]; ++ const encoding = (_response_headers = response.headers) == null ? void 0 : _response_headers.get('content-encoding'); ++ const bodyEncoded = typeof encoding === 'string' && !IDENTITY_ENCODINGS.includes(encoding.trim().toLowerCase()); + (_response_headers = response.headers) == null ? void 0 : _response_headers.forEach((value, name)=>{ + // `x-middleware-set-cookie` is an internal header not needed for the response + if (name.toLowerCase() === 'x-middleware-set-cookie') { + return; + } +- if (FORBIDDEN_HEADERS.includes(name)) { ++ if (name === 'transfer-encoding' || bodyEncoded && FORBIDDEN_HEADERS.includes(name)) { + return; + } + // The append handling is special cased for `set-cookie`. diff --git a/dist/server/lib/patch-set-header.js b/dist/server/lib/patch-set-header.js index 16cdc4703f3e9957a16c68c962cfaf5ee5d04561..a1c3c7061bc917284e01ed9947cd914818cfd708 100644 --- a/dist/server/lib/patch-set-header.js @@ -73,3 +106,36 @@ index 16cdc4703f3e9957a16c68c962cfaf5ee5d04561..a1c3c7061bc917284e01ed9947cd9148 if (name.toLowerCase() === 'set-cookie') { const middlewareValue = (0, _requestmeta.getRequestMeta)(req, 'middlewareCookie'); if (!middlewareValue || !Array.isArray(value) || !value.every((item, idx)=>item === middlewareValue[idx])) { +diff --git a/dist/server/send-response.js b/dist/server/send-response.js +index 6232e7a729e33f6550e83f8ff7ffe0581c891683..57dc52ecfc58b95e5b433932badd67c2b158450c 100644 +--- a/dist/server/send-response.js ++++ b/dist/server/send-response.js +@@ -20,6 +20,12 @@ const FORBIDDEN_HEADERS = [ + 'content-encoding', + 'transfer-encoding' + ]; ++// A body that declares no content coding was not transparently decoded, so its declared length ++// still frames it; only a decoded body's length and coding are stale. ++const IDENTITY_ENCODINGS = [ ++ 'identity', ++ 'none' ++]; + async function sendResponse(req, res, response, waitUntil) { + if (// The type check here ensures that `req` is correctly typed, and the + // environment variable check provides dead code elimination. +@@ -41,12 +47,14 @@ async function sendResponse(req, res, response, waitUntil) { + 'proxy-authenticate', + 'vary' + ]; ++ const encoding = (_response_headers = response.headers) == null ? void 0 : _response_headers.get('content-encoding'); ++ const bodyEncoded = typeof encoding === 'string' && !IDENTITY_ENCODINGS.includes(encoding.trim().toLowerCase()); + (_response_headers = response.headers) == null ? void 0 : _response_headers.forEach((value, name)=>{ + // `x-middleware-set-cookie` is an internal header not needed for the response + if (name.toLowerCase() === 'x-middleware-set-cookie') { + return; + } +- if (FORBIDDEN_HEADERS.includes(name)) { ++ if (name === 'transfer-encoding' || bodyEncoded && FORBIDDEN_HEADERS.includes(name)) { + return; + } + // The append handling is special cased for `set-cookie`. From 3243c36e93fea6246f2e3bd20cdfe256ae9ec516 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 9 Nov 2026 14:57:50 -0800 Subject: [PATCH 2/3] fix(next): apply the framing rule to the prebundled production server runtime --- patches/README.md | 12 +++++++----- patches/next@16.4.5.patch | 13 +++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/patches/README.md b/patches/README.md index e0360bef6d3..4504483cb6d 100644 --- a/patches/README.md +++ b/patches/README.md @@ -150,20 +150,22 @@ sent. Dropping the headers from every response also strips the declared length from file downloads, which then arrive chunked with no size, and the `Content-Encoding: none` marker that keeps streaming responses uncompressed. -The same file's patch narrows that rule in `sendResponse`, in both the CommonJS -and ESM builds. A response whose `Content-Encoding` names a real coding keeps +The same file's patch narrows that rule in `sendResponse`: the CommonJS and ESM +module builds, and the copy prebundled into +`compiled/next-server/server.runtime.prod.js`, which `next start` runs. A response whose `Content-Encoding` names a real coding keeps upstream's behavior: its length and coding are dropped. A response with no coding, or with `identity`/`none`, was not decoded, so its `Content-Length` and coding are forwarded. `Transfer-Encoding` is never forwarded; Node frames the response itself. Route handlers, App Page rendering, and the edge runtime are otherwise unchanged. -`test:headers:e2e` sends real responses through both builds of `sendResponse` -over loopback HTTP. The unencoded, `identity`, and `none` checks fail against +`test:headers:e2e` sends real responses through both module builds of +`sendResponse` over loopback HTTP. The unencoded, `identity`, and `none` checks fail against unpatched 16.4.5. The decoded-body and transfer-coding checks fail when their guards are removed; forwarding a decoded body's stale length leaves the client unable to parse the connection. The project-files E2E's large-download check -asserts the declared length of a 100 MB file served through the running app. +covers the production runtime: it asserts the declared length of a 100 MB file +served by the built app. Remove this part of the patch when upstream forwards framing for undecoded route-handler bodies, and keep both regression checks. diff --git a/patches/next@16.4.5.patch b/patches/next@16.4.5.patch index b3d1f5f5466..236f11eb0fc 100644 --- a/patches/next@16.4.5.patch +++ b/patches/next@16.4.5.patch @@ -1,3 +1,16 @@ +diff --git a/dist/compiled/next-server/server.runtime.prod.js b/dist/compiled/next-server/server.runtime.prod.js +index 9bfdf0e9bd152d0dea200022a0509b8a45dd87fa..adb1194bfc5790ea481ee68d68876f93c9e46060 100644 +--- a/dist/compiled/next-server/server.runtime.prod.js ++++ b/dist/compiled/next-server/server.runtime.prod.js +@@ -28,7 +28,7 @@ Learn more: ${s}`)),n);break}case"request":{let r=n.stagedRendering;if(r&&r.shou + Read more: https://nextjs.org/docs/messages/middleware-request-page + `)}}class rT extends Error{constructor(){super(`The request.ua has been removed in favour of \`userAgent\` function. + Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent +- `)}}var rA=r("./dist/compiled/@edge-runtime/cookies/index.js");let rk=Symbol("internal request");class r$ extends Request{constructor(e,t={}){const r="string"!=typeof e&&"url"in e?e.url:String(e);rd(r),t.body&&"half"!==t.duplex&&(t.duplex="half"),e instanceof Request?super(e,t):super(r,t);const n=new rR(r,{headers:ru(this.headers),nextConfig:t.nextConfig});this[rk]={cookies:new rA.RequestCookies(this.headers),nextUrl:n,url:process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE?r:n.toString()}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,nextUrl:this.nextUrl,url:this.url,bodyUsed:this.bodyUsed,cache:this.cache,credentials:this.credentials,destination:this.destination,headers:Object.fromEntries(this.headers),integrity:this.integrity,keepalive:this.keepalive,method:this.method,mode:this.mode,redirect:this.redirect,referrer:this.referrer,referrerPolicy:this.referrerPolicy,signal:this.signal}}get cookies(){return this[rk].cookies}get nextUrl(){return this[rk].nextUrl}get page(){throw new r_}get ua(){throw new rT}get url(){return this[rk].url}}let rO="ResponseAborted";class rM extends Error{constructor(...e){super(...e),this.name=rO}}function rI(){let e,t,r=new Promise((r,n)=>{e=r,t=n});return{resolve:e,reject:t,promise:r}}function rN(e){return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.name)===rO}let rj="performance"in globalThis&&process.env.NEXT_OTEL_PERFORMANCE_PREFIX;async function rD(e,t,r,n){try{var i;let s,{errored:a,destroyed:o}=t;if(a||o)return;let l=(i=t,s=new AbortController,i.once("close",()=>{i.writableFinished||s.abort(new rM)}),s),c=function(e,t,r){let n=!1,i=rI();function s(){i.resolve()}e.on("drain",s),e.once("close",()=>{e.off("drain",s),i.resolve()});let a=rI();return e.once("finish",()=>{a.resolve()}),new WritableStream({write:async t=>{if(!n){if(n=!0,rj){let e=null==r?void 0:r.snapshot();e&&performance.measure(`${process.env.NEXT_OTEL_PERFORMANCE_PREFIX}:next-client-component-loading`,{start:e.clientComponentLoadStart,end:e.clientComponentLoadStart+e.clientComponentLoadTimes})}e.flushHeaders(),(0,tn.getTracer)().trace(ta.startResponse,{spanName:"start response"},()=>void 0)}try{let r=e.write(t);"flush"in e&&"function"==typeof e.flush&&e.flush(),r||(await i.promise,i=rI())}catch(t){throw e.end(),Error("failed to write chunk to response",{cause:t})}},abort:t=>{e.writableFinished||e.destroy(t)},close:async()=>{if(t&&await t,!e.writableFinished)return e.end(),a.promise}})}(t,r,n);await e.pipeTo(c,{signal:l.signal})}catch(e){if(rN(e))return;throw Error("failed to pipe response",{cause:e})}}async function rq(e,t,r,n){try{let{errored:i,destroyed:s}=t;if(i||s)return;let a=!1,o=rI(),l=!1,c=()=>{l&&!e.destroyed&&(l=!1,e.resume())};t.on("drain",c),t.once("close",()=>{t.off("drain",c),e.destroy(),o.resolve()}),e.on("data",r=>{if(!a){if(a=!0,"performance"in globalThis&&process.env.NEXT_OTEL_PERFORMANCE_PREFIX){let e=null==n?void 0:n.snapshot();e&&performance.measure(`${process.env.NEXT_OTEL_PERFORMANCE_PREFIX}:next-client-component-loading`,{start:e.clientComponentLoadStart,end:e.clientComponentLoadStart+e.clientComponentLoadTimes})}t.flushHeaders(),(0,tn.getTracer)().trace(ta.startResponse,{spanName:"start response"},()=>void 0)}let i=t.write(r);"flush"in t&&"function"==typeof t.flush&&t.flush(),i||(l=!0,e.pause())}),e.on("end",async()=>{r&&await r,t.writableFinished||t.end(),o.resolve()}),e.on("error",e=>{rN(e)?o.resolve():(t.destroy(e),o.resolve())}),await o.promise}catch(e){if(rN(e))return;throw Error("failed to pipe response",{cause:e})}}function rL(e){return null!==e&&"object"==typeof e&&"function"==typeof e.pipe&&"function"==typeof e.on&&!(e instanceof ReadableStream)}class rF{static #t=this.EMPTY=new rF(null,{metadata:{},contentType:null});static fromStatic(e,t){return new rF(e,{metadata:{},contentType:t})}constructor(e,{contentType:t,waitUntil:r,metadata:n}){this.response=e,this.contentType=t,this.metadata=n,this.waitUntil=r}assignMetadata(e){Object.assign(this.metadata,e)}get isNull(){return null===this.response}get isDynamic(){return"string"!=typeof this.response}toUnchunkedString(e=!1){if(null===this.response)return"";if("string"!=typeof this.response){if(!e)throw new ec("dynamic responses cannot be unchunked. This is a bug in Next.js");return rl(this.readable)}return this.response}get readable(){return null===this.response?new ReadableStream({start(e){e.close()}}):"string"==typeof this.response?ri(this.response):Buffer.isBuffer(this.response)?rs(this.response):Array.isArray(this.response)?function(...e){if(0===e.length)return new ReadableStream({start(e){e.close()}});if(1===e.length)return e[0];let{readable:t,writable:r}=new TransformStream,n=e[0].pipeTo(r,{preventClose:!0}),i=1;for(;it.pipeTo(r,{preventClose:!0}))}let s=e[i];return(n=n.then(()=>s.pipeTo(r))).catch(rr),t}(...this.response):rL(this.response)?require("node:stream").Readable.toWeb(this.response):this.response}coerce(){return null===this.response?[]:"string"==typeof this.response?[ri(this.response)]:Array.isArray(this.response)?this.response:Buffer.isBuffer(this.response)?[rs(this.response)]:rL(this.response)?[require("node:stream").Readable.toWeb(this.response)]:[this.response]}pipeThrough(e){this.response=this.readable.pipeThrough(e)}unshift(e){this.response=this.coerce(),this.response.unshift(e)}push(e){this.response=this.coerce(),this.response.push(e)}async pipeTo(e){try{await this.readable.pipeTo(e,{preventClose:!0}),this.waitUntil&&await this.waitUntil,await e.close()}catch(t){if(rN(t))return void await e.abort(t);throw t}}async pipeToNodeResponse(e){null!==this.response&&"string"!=typeof this.response&&!Buffer.isBuffer(this.response)&&!Array.isArray(this.response)&&rL(this.response)?await rq(this.response,e,this.waitUntil,this.metadata.clientComponentLoadTracker):await rD(this.readable,e,this.waitUntil,this.metadata.clientComponentLoadTracker)}}function rH(e){return e.replace(/\\/g,"/")}function rz(e){let t=rH(e);return t.startsWith("/index/")&&!tQ(t)?t.slice(6):"/index"!==t?t:"/"}function rU(e,t){let r=[],n=(0,ej.pathToRegexp)(e,r,{delimiter:"/",sensitive:"boolean"==typeof t?.sensitive?t.sensitive:!1,strict:t?.strict}),i=(0,ej.regexpToFunction)(t?.regexModifier?new RegExp(t.regexModifier(n.source),n.flags):n,r);return(e,n)=>{if("string"!=typeof e)return!1;let s=i(e);if(!s)return!1;if(t?.removeUnnamedParams)for(let e of r)"number"==typeof e.name&&delete s.params[e.name];return{...n,...s.params}}}function rW(e){return e.replace(/__ESC_COLON_/gi,":")}function rB(e,t,r=[],n=[]){let i={},s=r=>{let n,s=r.key;switch(r.type){case"header":s=s.toLowerCase(),n=e.headers[s];break;case"cookie":n="cookies"in e?e.cookies[r.key]:tc(e.headers)()[r.key];break;case"query":n=t[s];break;case"host":{let{host:t}=e?.headers||{};n=t?.split(":",1)[0].toLowerCase()}}if(!r.value&&n)return i[function(e){let t="";for(let r=0;r64&&n<91||n>96&&n<123)&&(t+=e[r])}return t}(s)]=n,!0;if(n){let e=RegExp(`^${r.value}$`),t=Array.isArray(n)?n.slice(-1)[0].match(e):n.match(e);if(t)return Array.isArray(t)&&(t.groups?Object.keys(t.groups).forEach(e=>{i[e]=t.groups[e]}):"host"===r.type&&t[0]&&(i.host=t[0])),!0}return!1};return r.every(e=>s(e))&&!n.some(e=>s(e))?i:!1}function rG(e,t){if(!e.includes(":"))return e;for(let r of Object.keys(t))e.includes(`:${r}`)&&(e=e.replace(RegExp(`:${r}\\*`,"g"),`:${r}--ESCAPED_PARAM_ASTERISKS`).replace(RegExp(`:${r}\\?`,"g"),`:${r}--ESCAPED_PARAM_QUESTION`).replace(RegExp(`:${r}\\+`,"g"),`:${r}--ESCAPED_PARAM_PLUS`).replace(RegExp(`:${r}(?!\\w)`,"g"),`--ESCAPED_PARAM_COLON${r}`));return e=e.replace(/(:|\*|\?|\+|\(|\)|\{|\})/g,"\\$1").replace(/--ESCAPED_PARAM_PLUS/g,"+").replace(/--ESCAPED_PARAM_COLON/g,":").replace(/--ESCAPED_PARAM_QUESTION/g,"?").replace(/--ESCAPED_PARAM_ASTERISKS/g,"*"),ez(`/${e}`,{validate:!1})(t).slice(1)}function rV(e){try{return decodeURIComponent(e)}catch{return e}}let rX=/https?|ftp|gopher|file/;function rK(e,t){for(let r in delete e.nextInternalLocale,e){let n=r!==e4&&r.startsWith(e4),i=r!==e2&&r.startsWith(e2);(n||i||t.includes(r))&&delete e[r]}}function rJ(e){return e.endsWith("/route")}function rY(e){return"object"==typeof e&&null!==e&&"name"in e&&"message"in e}function rQ(e){let t;return rY(e)?e:Error(!function(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);return null===t||t.hasOwnProperty("isPrototypeOf")}(e)?e+"":(t=new WeakSet,JSON.stringify(e,(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return"[Circular]";t.add(r)}return r})))}let rZ="next-action",r0="next-router-state-tree",r1="next-router-prefetch",r4="next-router-segment-prefetch",r2="next-url",r8=["rsc",r0,r1,"next-hmr-refresh",r4],r3="_rsc",r6="x-nextjs-request-id",r9="x-nextjs-html-request-id";var r5=r("./dist/compiled/nanoid/index.cjs");class r7{constructor(e){this.provider=e}normalize(e){return this.provider.analyze(e).pathname}}var ne=((f={}).PAGES="PAGES",f.PAGES_API="PAGES_API",f.APP_PAGE="APP_PAGE",f.APP_ROUTE="APP_ROUTE",f.IMAGE="IMAGE",f);function nt(e){let t=/^\/index(\/|$)/.test(e)&&!tQ(e)?`/index${e}`:"/"===e?"/index":tU(e);{let{posix:e}=r("path"),n=e.normalize(t);if(n!==t)throw new eA(`Requested and resolved page mismatch: ${t} ${n}`)}return t}class nr{constructor(e=[]){this.normalizers=e}push(e){this.normalizers.push(e)}normalize(e){return this.normalizers.reduce((e,t)=>t.normalize(e),e)}}var nn=r("./dist/esm/shared/lib/isomorphic/path.js"),ni=r.n(nn);class ns{constructor(...e){this.prefix=ni().posix.join(...e)}normalize(e){return ni().posix.join(this.prefix,e)}}function na(e){return{normalize:e}}class no extends nr{constructor(){super([na(nt),new ns("pages")])}normalize(e){return super.normalize(e)}}class nl extends ns{constructor(e){super(e,eX)}normalize(e){return super.normalize(e)}}let nc=["ico","jpg","jpeg","png","svg"],nu=["jpg","jpeg","png"],nd=["jpg","jpeg","png","gif"],nh=["jpg","jpeg","png","gif"],np=(e,t)=>t&&0!==t.length?`(?:\\.(${e.join("|")})|(\\.(${t.join("|")})))`:`(\\.(?:${e.join("|")}))`,nf=/^[\\/]favicon\.ico$/,nm=/^[\\/]robots\.txt$/,ng=/^[\\/]manifest\.json$/,nv=/^[\\/]manifest\.webmanifest$/,ny=/[\\/]sitemap\.xml$/,nx=new Map;class nb{constructor(e){this.filename=new nl(e),this.bundlePath=new no}}class nw{normalize(e){return e.replace(/%5F/g,"_")}}class nE extends ns{constructor(){super("app")}normalize(e){return super.normalize(nt(e))}}class nP extends ns{constructor(e){super(e,eX)}normalize(e){return super.normalize(e)}}class nC extends nr{constructor(){super([na(tW),new nw])}normalize(e){return super.normalize(e)}}class nR{constructor(e){this.filename=new nP(e),this.pathname=new nC,this.bundlePath=new nE}}let nS=Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available");class n_{disable(){throw nS}getStore(){}run(){throw nS}exit(){throw nS}enterWith(){throw nS}static bind(e){return e}}let nT="undefined"!=typeof globalThis&&globalThis.AsyncLocalStorage;var nA=r("./dist/esm/server/lib/trace/span-store.js");class nk{constructor(e){var t;if(this.config=e,!e.locales.length)throw Error("Invariant: No locales provided");this.lowerCaseLocales=e.locales.map(e=>e.toLowerCase()),this.lowerCaseDomains=null==(t=e.domains)?void 0:t.map(e=>{var t;let r=e.domain.toLowerCase();return{defaultLocale:e.defaultLocale.toLowerCase(),hostname:r.split(":",1)[0],domain:r,locales:null==(t=e.locales)?void 0:t.map(e=>e.toLowerCase()),http:e.http}})}detectDomainLocale(e,t){if(e&&this.lowerCaseDomains&&this.config.domains){t&&(t=t.toLowerCase());for(let n=0;ne===t)))return this.config.domains[n]}}}fromRequest(e,t){let r=eM(e,"locale");if(r){let e=this.analyze(t);e.detectedLocale&&(e.detectedLocale!==r&&console.warn(`The detected locale does not match the locale in the query. Expected to find '${r}' in '${t}' but found '${e.detectedLocale}'}`),t=e.pathname)}return{pathname:t,detectedLocale:r,inferredFromDefault:eM(e,"localeInferredFromDefault")??!1}}analyze(e,t={}){let r=t.defaultLocale,n="string"==typeof r,i=e.split("/",2);if(!i[1])return{detectedLocale:r,pathname:e,inferredFromDefault:n};let s=i[1].toLowerCase(),a=this.lowerCaseLocales.indexOf(s);return a<0?{detectedLocale:r,pathname:e,inferredFromDefault:n}:(r=this.config.locales[a],n=!1,e=e.slice(r.length+1)||"/",{detectedLocale:r,pathname:e,inferredFromDefault:n})}}let n$=["content-length","content-encoding","transfer-encoding"];async function nO(e,t,r,n){{var i;t.statusCode=r.status,t.statusMessage=r.statusText;let s=["set-cookie","www-authenticate","proxy-authenticate","vary"];null==(i=r.headers)||i.forEach((e,r)=>{if("x-middleware-set-cookie"!==r.toLowerCase()&&!n$.includes(r))if("set-cookie"===r.toLowerCase())for(let n of rc(e))t.appendHeader(r,n);else{let n=void 0!==t.getHeader(r);(s.includes(r.toLowerCase())||!n)&&t.appendHeader(r,e)}});let{originalResponse:a}=t;r.body&&"HEAD"!==e.method?await rD(r.body,a,n):a.end()}}let nM=rU("/_next/data/:path*",{sensitive:!0});class nI{constructor(e){this.suffix=e}match(e){return!!e.endsWith(this.suffix)}normalize(e,t){return t||this.match(e)?e.substring(0,e.length-this.suffix.length):e}}class nN extends nI{constructor(){super(e9)}}class nj{constructor(e){if(this.prefix=e,e.endsWith("/"))throw Error(`PrefixPathnameNormalizer: prefix "${e}" should not end with a slash`)}match(e){return e===this.prefix||!!e.startsWith(this.prefix+"/")}normalize(e,t){return t||this.match(e)?e.length===this.prefix.length?"/":e.substring(this.prefix.length):e}}class nD{constructor(e){if(this.suffix=new nI(".json"),!e)throw Error("Invariant: buildID is required");this.prefix=new nj(`/_next/data/${e}`)}match(e){return this.prefix.match(e)&&this.suffix.match(e)}normalize(e,t){return t||this.match(e)?(e=this.prefix.normalize(e,!0),rz(e=this.suffix.normalize(e,!0))):e}}let nq=Symbol("next.patchSetHeaderWithCookieSupport"),nL=Symbol.for("@next/request-context");Symbol("response"),Symbol("passThrough"),Symbol("waitUntil");let nF=Symbol("internal response"),nH=new Set([301,302,303,307,308]);function nz(e,t){var r;if(null==e?void 0:null==(r=e.request)?void 0:r.headers){if(!(e.request.headers instanceof Headers))throw Error("request.headers must be an instance of Headers");let r=[];for(let[n,i]of e.request.headers)t.set("x-middleware-request-"+n,i),r.push(n);t.set("x-middleware-override-headers",r.join(","))}}class nU extends Response{constructor(e,t={}){super(e,t);const r=this.headers,n=new Proxy(new rA.ResponseCookies(r),{get(e,n,i){switch(n){case"delete":case"set":return(...i)=>{let s=Reflect.apply(e[n],e,i),a=new Headers(r);return s instanceof rA.ResponseCookies&&r.set("x-middleware-set-cookie",s.getAll().map(e=>(0,rA.stringifyCookie)(e)).join(",")),nz(t,a),s};default:return eQ.get(e,n,i)}}});this[nF]={cookies:n,url:t.url?new rR(t.url,{headers:ru(r),nextConfig:t.nextConfig}):void 0}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,url:this.url,body:this.body,bodyUsed:this.bodyUsed,headers:Object.fromEntries(this.headers),ok:this.ok,redirected:this.redirected,status:this.status,statusText:this.statusText,type:this.type}}get cookies(){return this[nF].cookies}static json(e,t){let r=Response.json(e,t);return new nU(r.body,r)}static redirect(e,t){let r="number"==typeof t?t:(null==t?void 0:t.status)??307;if(!nH.has(r))throw RangeError('Failed to execute "redirect" on "response": Invalid status code');let n="object"==typeof t?t:{},i=new Headers(null==n?void 0:n.headers);return i.set("Location",rd(e)),new nU(null,{...n,headers:i,status:r})}static rewrite(e,t){let r=new Headers(null==t?void 0:t.headers);return r.set("x-middleware-rewrite",rd(e)),nz(t,r),new nU(null,{...t,headers:r})}static next(e){let t=new Headers(null==e?void 0:e.headers);return t.set("x-middleware-next","1"),nz(e,t),new nU(null,{...e,headers:t})}}Symbol.for("next.mutated.cookies"),[...r8,r6,r9].map(e=>e.toLowerCase()),r("./dist/compiled/p-queue/index.js");let nW=require("next/dist/server/lib/incremental-cache/tags-manifest.external.js");function nB(e){if(0===e)return{get:()=>Promise.resolve(void 0),set:()=>Promise.resolve(),refreshTags:()=>Promise.resolve(),getExpiration:()=>Promise.resolve(0),updateTags:()=>Promise.resolve()};let t=new _(e,(e,t)=>e.size+t.length),r=new Map,n=process.env.NEXT_PRIVATE_DEBUG_CACHE?console.debug.bind(console,"DefaultCacheHandler:"):void 0;return{async get(e){let i=r.get(e);i&&(null==n||n("get",e,"pending"),await i);let s=t.get(e);if(!s)return void(null==n||n("get",e,"not found"));let a=s.entry;if(a.expire<0)return void(null==n||n("get",e,"evicted"));let o=a.revalidate;if(performance.timeOrigin+performance.now()>a.timestamp+1e3*o)return void(null==n||n("get",e,"expired"));let l=a.revalidate;return(0,nW.areTagsExpired)(a.tags,a.timestamp)?void(null==n||n("get",e,"had expired tag")):((0,nW.areTagsStale)(a.tags,a.timestamp)&&(null==n||n("get",e,"had stale tag"),l=-1),null==n||n("get",e,"found",{tags:a.tags,timestamp:a.timestamp,expire:a.expire,revalidate:l,stale:a.stale}),{...a,revalidate:l,value:rs(s.value)})},async set(e,i){null==n||n("set",e,"start");let s=()=>{},a=new Promise(e=>{s=e});r.set(e,a);let o=await i;try{if(0===o.expire)return void(null==n||n("set",e,"skipped dynamic entry"));let r=await ro(o.value),{value:i,...s}=o;t.set(e,{entry:s,value:r,isErrored:!1,errorRetryCount:0,size:r.byteLength}),null==n||n("set",e,"done")}catch(t){null==n||n("set",e,"failed",t)}finally{s(),r.delete(e)}},async refreshTags(){},async getExpiration(e){let t=Math.max(...e.map(e=>{let t=nW.tagsManifest.get(e);return t?t.expired||0:0}),0);return null==n||n("getExpiration",{tags:e,expiration:t}),t},async updateTags(e,t){let r=Math.round(performance.timeOrigin+performance.now());for(let i of(null==n||n("updateTags",{tags:e,timestamp:r}),e)){let e=nW.tagsManifest.get(i)||{};if(t){let n={...e};n.stale=r,void 0!==t.expire&&(n.expired=r+1e3*t.expire),nW.tagsManifest.set(i,n)}else nW.tagsManifest.set(i,{...e,expired:r})}}}}let nG=process.env.NEXT_PRIVATE_DEBUG_CACHE?(e,...t)=>{console.log(`use-cache: ${e}`,...t)}:void 0,nV=Symbol.for("@next/cache-handlers"),nX=Symbol.for("@next/cache-handlers-map"),nK=Symbol.for("@next/cache-handlers-set"),nJ=Symbol.for("@next/custom-cache-handlers-registration");Symbol.for("@next/cache-handlers-private");let nY=Symbol.for("@next/cache-handlers-built-in");Symbol.for("@next/cache-handlers-dev-fronts"),Symbol.for("@next/cache-handlers-dev-tiered"),Symbol.for("@next/cache-handlers-memory-disabled");let nQ=globalThis;require("next/dist/server/app-render/after-task-async-storage.external.js");class nZ extends r${constructor(e){super(e.input,e.init),this.sourcePage=e.page}get request(){throw new rS({page:this.sourcePage})}respondWith(){throw new rS({page:this.sourcePage})}waitUntil(){throw new rS({page:this.sourcePage})}}var n0=((m={}).BLOCKING_STATIC_RENDER="BLOCKING_STATIC_RENDER",m.PRERENDER="PRERENDER",m.NOT_FOUND="NOT_FOUND",m);let n1=RegExp(`^(/.*)${t6(e3)}(/.*)${t6(e6)}$`);class n4{match(e){return n1.test(e)}extract(e){let t=e.match(n1);return t?{originalPathname:t[1],segmentPath:t[2]}:null}normalize(e){let t=this.extract(e);return t?t.originalPathname:e}}let n2=require("next/dist/shared/lib/no-fallback-error.external.js");function n8(e){if(0===e.length)return null;let t=Math.random().toString(16).slice(2),r=new Map;for(let{paramName:n}of e)r.set(n,`%%drp:${n}:${t}%%`);return r}async function n3(e,t){let r=[],n=0;for await(let i of e){let e=Buffer.isBuffer(i)?i:Buffer.from(i);if((n+=e.byteLength)>t)return null;r.push(e)}return Buffer.concat(r)}class n6 extends Error{constructor(e){super(),this.innerError=e}}class n9{getServerComponentsHmrCache(){return this.nextConfig.experimental.serverComponentsHmrCache?globalThis.__serverComponentsHmrCache:void 0}getServerComponentsHmrRefreshHash(){}getClientHmrVersion(){}constructor(e){var t,r;this.handleRSCRequest=(e,t,r)=>{var n,i;if(!r.pathname)return!1;if(null==(n=this.normalizers.segmentPrefetchRSC)?void 0:n.match(r.pathname)){let t=this.normalizers.segmentPrefetchRSC.extract(r.pathname);if(!t)return!1;let{originalPathname:n,segmentPath:i}=t;r.pathname=n,e.headers.rsc="1",e.headers[r1]="1",e.headers[r4]=i,eI(e,"isRSCRequest",!0),eI(e,"isPrefetchRSCRequest",!0),eI(e,"segmentPrefetchRSCRequest",i)}else if(null==(i=this.normalizers.rsc)?void 0:i.match(r.pathname))r.pathname=this.normalizers.rsc.normalize(r.pathname,!0),e.headers.rsc="1",eI(e,"isRSCRequest",!0);else if(e.headers["x-now-route-matches"]){var s=e.headers;for(let e of r8)delete s[e];return!1}else if("1"!==e.headers.rsc)return!1;else if(eI(e,"isRSCRequest",!0),"1"===e.headers[r1]){eI(e,"isPrefetchRSCRequest",!0);let t=e.headers[r4];"string"==typeof t&&eI(e,"segmentPrefetchRSCRequest",t)}if(e.url){let t=tx(e.url);t.pathname=r.pathname,e.url=(0,P.format)(t)}return!1},this.handleNextDataRequest=async(e,t,r)=>{var n,i;let s=await this.getMiddleware(),a="string"!=typeof(n=r.pathname)?!1:nM(n);if(!a||!a.path)return!1;if(a.path[0]!==this.buildId)return eM(e,"middlewareInvoke")?!1:(await this.render404(e,t,r),!0);a.path.shift();let o=a.path[a.path.length-1];if("string"!=typeof o||!o.endsWith(".json"))return await this.render404(e,t,r),!0;let l=`/${a.path.join("/")}`;if(l=function(e,t=""){return e=e.replace(/\\/g,"/"),(e=t&&e.endsWith(t)?e.slice(0,-t.length):e).startsWith("/index/")&&!tQ(e)?e=e.slice(6):"/index"===e&&(e="/"),e}(l,".json"),s&&(this.nextConfig.trailingSlash&&!l.endsWith("/")&&(l+="/"),!this.nextConfig.trailingSlash&&l.length>1&&l.endsWith("/")&&(l=l.substring(0,l.length-1))),this.i18nProvider){let n=null==e?void 0:null==(i=e.headers.host)?void 0:i.split(":",1)[0].toLowerCase(),a=this.i18nProvider.detectDomainLocale(n),o=(null==a?void 0:a.defaultLocale)??this.i18nProvider.config.defaultLocale,c=this.i18nProvider.analyze(l);if(c.detectedLocale&&(l=c.pathname),eI(e,"locale",c.detectedLocale),eI(e,"defaultLocale",o),c.detectedLocale||eN(e,"localeInferredFromDefault"),!c.detectedLocale&&!s)return eI(e,"locale",o),await this.render404(e,t,r),!0}return r.pathname=l,eI(e,"isNextDataReq",!0),!1},this.handleNextImageRequest=()=>!1,this.handleCatchallRenderRequest=()=>!1,this.handleCatchallMiddlewareRequest=()=>!1,this.normalize=e=>{let t=[];for(let r of(this.normalizers.data&&t.push(this.normalizers.data),this.normalizers.segmentPrefetchRSC&&t.push(this.normalizers.segmentPrefetchRSC),this.normalizers.rsc&&t.push(this.normalizers.rsc),t))if(r.match(e))return r.normalize(e,!0);return e},this.normalizeAndAttachMetadata=async(e,t,r)=>{let n=await this.handleNextImageRequest(e,t,r);return n?!0:!!(this.enabledDirectories.pages&&(n=await this.handleNextDataRequest(e,t,r)))},this.prepared=!1,this.preparedPromise=null,this.customErrorNo404Warn=function(e){let t,r=!1;return(...n)=>(r||(r=!0,t=e(...n)),t)}(()=>{tS(`You have added a custom /_error page without a custom /404 page. This prevents the 404 page from being auto statically optimized. ++ `)}}var rA=r("./dist/compiled/@edge-runtime/cookies/index.js");let rk=Symbol("internal request");class r$ extends Request{constructor(e,t={}){const r="string"!=typeof e&&"url"in e?e.url:String(e);rd(r),t.body&&"half"!==t.duplex&&(t.duplex="half"),e instanceof Request?super(e,t):super(r,t);const n=new rR(r,{headers:ru(this.headers),nextConfig:t.nextConfig});this[rk]={cookies:new rA.RequestCookies(this.headers),nextUrl:n,url:process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE?r:n.toString()}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,nextUrl:this.nextUrl,url:this.url,bodyUsed:this.bodyUsed,cache:this.cache,credentials:this.credentials,destination:this.destination,headers:Object.fromEntries(this.headers),integrity:this.integrity,keepalive:this.keepalive,method:this.method,mode:this.mode,redirect:this.redirect,referrer:this.referrer,referrerPolicy:this.referrerPolicy,signal:this.signal}}get cookies(){return this[rk].cookies}get nextUrl(){return this[rk].nextUrl}get page(){throw new r_}get ua(){throw new rT}get url(){return this[rk].url}}let rO="ResponseAborted";class rM extends Error{constructor(...e){super(...e),this.name=rO}}function rI(){let e,t,r=new Promise((r,n)=>{e=r,t=n});return{resolve:e,reject:t,promise:r}}function rN(e){return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.name)===rO}let rj="performance"in globalThis&&process.env.NEXT_OTEL_PERFORMANCE_PREFIX;async function rD(e,t,r,n){try{var i;let s,{errored:a,destroyed:o}=t;if(a||o)return;let l=(i=t,s=new AbortController,i.once("close",()=>{i.writableFinished||s.abort(new rM)}),s),c=function(e,t,r){let n=!1,i=rI();function s(){i.resolve()}e.on("drain",s),e.once("close",()=>{e.off("drain",s),i.resolve()});let a=rI();return e.once("finish",()=>{a.resolve()}),new WritableStream({write:async t=>{if(!n){if(n=!0,rj){let e=null==r?void 0:r.snapshot();e&&performance.measure(`${process.env.NEXT_OTEL_PERFORMANCE_PREFIX}:next-client-component-loading`,{start:e.clientComponentLoadStart,end:e.clientComponentLoadStart+e.clientComponentLoadTimes})}e.flushHeaders(),(0,tn.getTracer)().trace(ta.startResponse,{spanName:"start response"},()=>void 0)}try{let r=e.write(t);"flush"in e&&"function"==typeof e.flush&&e.flush(),r||(await i.promise,i=rI())}catch(t){throw e.end(),Error("failed to write chunk to response",{cause:t})}},abort:t=>{e.writableFinished||e.destroy(t)},close:async()=>{if(t&&await t,!e.writableFinished)return e.end(),a.promise}})}(t,r,n);await e.pipeTo(c,{signal:l.signal})}catch(e){if(rN(e))return;throw Error("failed to pipe response",{cause:e})}}async function rq(e,t,r,n){try{let{errored:i,destroyed:s}=t;if(i||s)return;let a=!1,o=rI(),l=!1,c=()=>{l&&!e.destroyed&&(l=!1,e.resume())};t.on("drain",c),t.once("close",()=>{t.off("drain",c),e.destroy(),o.resolve()}),e.on("data",r=>{if(!a){if(a=!0,"performance"in globalThis&&process.env.NEXT_OTEL_PERFORMANCE_PREFIX){let e=null==n?void 0:n.snapshot();e&&performance.measure(`${process.env.NEXT_OTEL_PERFORMANCE_PREFIX}:next-client-component-loading`,{start:e.clientComponentLoadStart,end:e.clientComponentLoadStart+e.clientComponentLoadTimes})}t.flushHeaders(),(0,tn.getTracer)().trace(ta.startResponse,{spanName:"start response"},()=>void 0)}let i=t.write(r);"flush"in t&&"function"==typeof t.flush&&t.flush(),i||(l=!0,e.pause())}),e.on("end",async()=>{r&&await r,t.writableFinished||t.end(),o.resolve()}),e.on("error",e=>{rN(e)?o.resolve():(t.destroy(e),o.resolve())}),await o.promise}catch(e){if(rN(e))return;throw Error("failed to pipe response",{cause:e})}}function rL(e){return null!==e&&"object"==typeof e&&"function"==typeof e.pipe&&"function"==typeof e.on&&!(e instanceof ReadableStream)}class rF{static #t=this.EMPTY=new rF(null,{metadata:{},contentType:null});static fromStatic(e,t){return new rF(e,{metadata:{},contentType:t})}constructor(e,{contentType:t,waitUntil:r,metadata:n}){this.response=e,this.contentType=t,this.metadata=n,this.waitUntil=r}assignMetadata(e){Object.assign(this.metadata,e)}get isNull(){return null===this.response}get isDynamic(){return"string"!=typeof this.response}toUnchunkedString(e=!1){if(null===this.response)return"";if("string"!=typeof this.response){if(!e)throw new ec("dynamic responses cannot be unchunked. This is a bug in Next.js");return rl(this.readable)}return this.response}get readable(){return null===this.response?new ReadableStream({start(e){e.close()}}):"string"==typeof this.response?ri(this.response):Buffer.isBuffer(this.response)?rs(this.response):Array.isArray(this.response)?function(...e){if(0===e.length)return new ReadableStream({start(e){e.close()}});if(1===e.length)return e[0];let{readable:t,writable:r}=new TransformStream,n=e[0].pipeTo(r,{preventClose:!0}),i=1;for(;it.pipeTo(r,{preventClose:!0}))}let s=e[i];return(n=n.then(()=>s.pipeTo(r))).catch(rr),t}(...this.response):rL(this.response)?require("node:stream").Readable.toWeb(this.response):this.response}coerce(){return null===this.response?[]:"string"==typeof this.response?[ri(this.response)]:Array.isArray(this.response)?this.response:Buffer.isBuffer(this.response)?[rs(this.response)]:rL(this.response)?[require("node:stream").Readable.toWeb(this.response)]:[this.response]}pipeThrough(e){this.response=this.readable.pipeThrough(e)}unshift(e){this.response=this.coerce(),this.response.unshift(e)}push(e){this.response=this.coerce(),this.response.push(e)}async pipeTo(e){try{await this.readable.pipeTo(e,{preventClose:!0}),this.waitUntil&&await this.waitUntil,await e.close()}catch(t){if(rN(t))return void await e.abort(t);throw t}}async pipeToNodeResponse(e){null!==this.response&&"string"!=typeof this.response&&!Buffer.isBuffer(this.response)&&!Array.isArray(this.response)&&rL(this.response)?await rq(this.response,e,this.waitUntil,this.metadata.clientComponentLoadTracker):await rD(this.readable,e,this.waitUntil,this.metadata.clientComponentLoadTracker)}}function rH(e){return e.replace(/\\/g,"/")}function rz(e){let t=rH(e);return t.startsWith("/index/")&&!tQ(t)?t.slice(6):"/index"!==t?t:"/"}function rU(e,t){let r=[],n=(0,ej.pathToRegexp)(e,r,{delimiter:"/",sensitive:"boolean"==typeof t?.sensitive?t.sensitive:!1,strict:t?.strict}),i=(0,ej.regexpToFunction)(t?.regexModifier?new RegExp(t.regexModifier(n.source),n.flags):n,r);return(e,n)=>{if("string"!=typeof e)return!1;let s=i(e);if(!s)return!1;if(t?.removeUnnamedParams)for(let e of r)"number"==typeof e.name&&delete s.params[e.name];return{...n,...s.params}}}function rW(e){return e.replace(/__ESC_COLON_/gi,":")}function rB(e,t,r=[],n=[]){let i={},s=r=>{let n,s=r.key;switch(r.type){case"header":s=s.toLowerCase(),n=e.headers[s];break;case"cookie":n="cookies"in e?e.cookies[r.key]:tc(e.headers)()[r.key];break;case"query":n=t[s];break;case"host":{let{host:t}=e?.headers||{};n=t?.split(":",1)[0].toLowerCase()}}if(!r.value&&n)return i[function(e){let t="";for(let r=0;r64&&n<91||n>96&&n<123)&&(t+=e[r])}return t}(s)]=n,!0;if(n){let e=RegExp(`^${r.value}$`),t=Array.isArray(n)?n.slice(-1)[0].match(e):n.match(e);if(t)return Array.isArray(t)&&(t.groups?Object.keys(t.groups).forEach(e=>{i[e]=t.groups[e]}):"host"===r.type&&t[0]&&(i.host=t[0])),!0}return!1};return r.every(e=>s(e))&&!n.some(e=>s(e))?i:!1}function rG(e,t){if(!e.includes(":"))return e;for(let r of Object.keys(t))e.includes(`:${r}`)&&(e=e.replace(RegExp(`:${r}\\*`,"g"),`:${r}--ESCAPED_PARAM_ASTERISKS`).replace(RegExp(`:${r}\\?`,"g"),`:${r}--ESCAPED_PARAM_QUESTION`).replace(RegExp(`:${r}\\+`,"g"),`:${r}--ESCAPED_PARAM_PLUS`).replace(RegExp(`:${r}(?!\\w)`,"g"),`--ESCAPED_PARAM_COLON${r}`));return e=e.replace(/(:|\*|\?|\+|\(|\)|\{|\})/g,"\\$1").replace(/--ESCAPED_PARAM_PLUS/g,"+").replace(/--ESCAPED_PARAM_COLON/g,":").replace(/--ESCAPED_PARAM_QUESTION/g,"?").replace(/--ESCAPED_PARAM_ASTERISKS/g,"*"),ez(`/${e}`,{validate:!1})(t).slice(1)}function rV(e){try{return decodeURIComponent(e)}catch{return e}}let rX=/https?|ftp|gopher|file/;function rK(e,t){for(let r in delete e.nextInternalLocale,e){let n=r!==e4&&r.startsWith(e4),i=r!==e2&&r.startsWith(e2);(n||i||t.includes(r))&&delete e[r]}}function rJ(e){return e.endsWith("/route")}function rY(e){return"object"==typeof e&&null!==e&&"name"in e&&"message"in e}function rQ(e){let t;return rY(e)?e:Error(!function(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);return null===t||t.hasOwnProperty("isPrototypeOf")}(e)?e+"":(t=new WeakSet,JSON.stringify(e,(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return"[Circular]";t.add(r)}return r})))}let rZ="next-action",r0="next-router-state-tree",r1="next-router-prefetch",r4="next-router-segment-prefetch",r2="next-url",r8=["rsc",r0,r1,"next-hmr-refresh",r4],r3="_rsc",r6="x-nextjs-request-id",r9="x-nextjs-html-request-id";var r5=r("./dist/compiled/nanoid/index.cjs");class r7{constructor(e){this.provider=e}normalize(e){return this.provider.analyze(e).pathname}}var ne=((f={}).PAGES="PAGES",f.PAGES_API="PAGES_API",f.APP_PAGE="APP_PAGE",f.APP_ROUTE="APP_ROUTE",f.IMAGE="IMAGE",f);function nt(e){let t=/^\/index(\/|$)/.test(e)&&!tQ(e)?`/index${e}`:"/"===e?"/index":tU(e);{let{posix:e}=r("path"),n=e.normalize(t);if(n!==t)throw new eA(`Requested and resolved page mismatch: ${t} ${n}`)}return t}class nr{constructor(e=[]){this.normalizers=e}push(e){this.normalizers.push(e)}normalize(e){return this.normalizers.reduce((e,t)=>t.normalize(e),e)}}var nn=r("./dist/esm/shared/lib/isomorphic/path.js"),ni=r.n(nn);class ns{constructor(...e){this.prefix=ni().posix.join(...e)}normalize(e){return ni().posix.join(this.prefix,e)}}function na(e){return{normalize:e}}class no extends nr{constructor(){super([na(nt),new ns("pages")])}normalize(e){return super.normalize(e)}}class nl extends ns{constructor(e){super(e,eX)}normalize(e){return super.normalize(e)}}let nc=["ico","jpg","jpeg","png","svg"],nu=["jpg","jpeg","png"],nd=["jpg","jpeg","png","gif"],nh=["jpg","jpeg","png","gif"],np=(e,t)=>t&&0!==t.length?`(?:\\.(${e.join("|")})|(\\.(${t.join("|")})))`:`(\\.(?:${e.join("|")}))`,nf=/^[\\/]favicon\.ico$/,nm=/^[\\/]robots\.txt$/,ng=/^[\\/]manifest\.json$/,nv=/^[\\/]manifest\.webmanifest$/,ny=/[\\/]sitemap\.xml$/,nx=new Map;class nb{constructor(e){this.filename=new nl(e),this.bundlePath=new no}}class nw{normalize(e){return e.replace(/%5F/g,"_")}}class nE extends ns{constructor(){super("app")}normalize(e){return super.normalize(nt(e))}}class nP extends ns{constructor(e){super(e,eX)}normalize(e){return super.normalize(e)}}class nC extends nr{constructor(){super([na(tW),new nw])}normalize(e){return super.normalize(e)}}class nR{constructor(e){this.filename=new nP(e),this.pathname=new nC,this.bundlePath=new nE}}let nS=Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available");class n_{disable(){throw nS}getStore(){}run(){throw nS}exit(){throw nS}enterWith(){throw nS}static bind(e){return e}}let nT="undefined"!=typeof globalThis&&globalThis.AsyncLocalStorage;var nA=r("./dist/esm/server/lib/trace/span-store.js");class nk{constructor(e){var t;if(this.config=e,!e.locales.length)throw Error("Invariant: No locales provided");this.lowerCaseLocales=e.locales.map(e=>e.toLowerCase()),this.lowerCaseDomains=null==(t=e.domains)?void 0:t.map(e=>{var t;let r=e.domain.toLowerCase();return{defaultLocale:e.defaultLocale.toLowerCase(),hostname:r.split(":",1)[0],domain:r,locales:null==(t=e.locales)?void 0:t.map(e=>e.toLowerCase()),http:e.http}})}detectDomainLocale(e,t){if(e&&this.lowerCaseDomains&&this.config.domains){t&&(t=t.toLowerCase());for(let n=0;ne===t)))return this.config.domains[n]}}}fromRequest(e,t){let r=eM(e,"locale");if(r){let e=this.analyze(t);e.detectedLocale&&(e.detectedLocale!==r&&console.warn(`The detected locale does not match the locale in the query. Expected to find '${r}' in '${t}' but found '${e.detectedLocale}'}`),t=e.pathname)}return{pathname:t,detectedLocale:r,inferredFromDefault:eM(e,"localeInferredFromDefault")??!1}}analyze(e,t={}){let r=t.defaultLocale,n="string"==typeof r,i=e.split("/",2);if(!i[1])return{detectedLocale:r,pathname:e,inferredFromDefault:n};let s=i[1].toLowerCase(),a=this.lowerCaseLocales.indexOf(s);return a<0?{detectedLocale:r,pathname:e,inferredFromDefault:n}:(r=this.config.locales[a],n=!1,e=e.slice(r.length+1)||"/",{detectedLocale:r,pathname:e,inferredFromDefault:n})}}let n$=["content-length","content-encoding","transfer-encoding"];async function nO(e,t,r,n){{var i;t.statusCode=r.status,t.statusMessage=r.statusText;let s=["set-cookie","www-authenticate","proxy-authenticate","vary"];let o=null==(i=r.headers)?void 0:i.get("content-encoding"),l="string"==typeof o&&!["identity","none"].includes(o.trim().toLowerCase());null==(i=r.headers)||i.forEach((e,r)=>{if("x-middleware-set-cookie"!==r.toLowerCase()&&"transfer-encoding"!==r&&!(l&&n$.includes(r)))if("set-cookie"===r.toLowerCase())for(let n of rc(e))t.appendHeader(r,n);else{let n=void 0!==t.getHeader(r);(s.includes(r.toLowerCase())||!n)&&t.appendHeader(r,e)}});let{originalResponse:a}=t;r.body&&"HEAD"!==e.method?await rD(r.body,a,n):a.end()}}let nM=rU("/_next/data/:path*",{sensitive:!0});class nI{constructor(e){this.suffix=e}match(e){return!!e.endsWith(this.suffix)}normalize(e,t){return t||this.match(e)?e.substring(0,e.length-this.suffix.length):e}}class nN extends nI{constructor(){super(e9)}}class nj{constructor(e){if(this.prefix=e,e.endsWith("/"))throw Error(`PrefixPathnameNormalizer: prefix "${e}" should not end with a slash`)}match(e){return e===this.prefix||!!e.startsWith(this.prefix+"/")}normalize(e,t){return t||this.match(e)?e.length===this.prefix.length?"/":e.substring(this.prefix.length):e}}class nD{constructor(e){if(this.suffix=new nI(".json"),!e)throw Error("Invariant: buildID is required");this.prefix=new nj(`/_next/data/${e}`)}match(e){return this.prefix.match(e)&&this.suffix.match(e)}normalize(e,t){return t||this.match(e)?(e=this.prefix.normalize(e,!0),rz(e=this.suffix.normalize(e,!0))):e}}let nq=Symbol("next.patchSetHeaderWithCookieSupport"),nL=Symbol.for("@next/request-context");Symbol("response"),Symbol("passThrough"),Symbol("waitUntil");let nF=Symbol("internal response"),nH=new Set([301,302,303,307,308]);function nz(e,t){var r;if(null==e?void 0:null==(r=e.request)?void 0:r.headers){if(!(e.request.headers instanceof Headers))throw Error("request.headers must be an instance of Headers");let r=[];for(let[n,i]of e.request.headers)t.set("x-middleware-request-"+n,i),r.push(n);t.set("x-middleware-override-headers",r.join(","))}}class nU extends Response{constructor(e,t={}){super(e,t);const r=this.headers,n=new Proxy(new rA.ResponseCookies(r),{get(e,n,i){switch(n){case"delete":case"set":return(...i)=>{let s=Reflect.apply(e[n],e,i),a=new Headers(r);return s instanceof rA.ResponseCookies&&r.set("x-middleware-set-cookie",s.getAll().map(e=>(0,rA.stringifyCookie)(e)).join(",")),nz(t,a),s};default:return eQ.get(e,n,i)}}});this[nF]={cookies:n,url:t.url?new rR(t.url,{headers:ru(r),nextConfig:t.nextConfig}):void 0}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,url:this.url,body:this.body,bodyUsed:this.bodyUsed,headers:Object.fromEntries(this.headers),ok:this.ok,redirected:this.redirected,status:this.status,statusText:this.statusText,type:this.type}}get cookies(){return this[nF].cookies}static json(e,t){let r=Response.json(e,t);return new nU(r.body,r)}static redirect(e,t){let r="number"==typeof t?t:(null==t?void 0:t.status)??307;if(!nH.has(r))throw RangeError('Failed to execute "redirect" on "response": Invalid status code');let n="object"==typeof t?t:{},i=new Headers(null==n?void 0:n.headers);return i.set("Location",rd(e)),new nU(null,{...n,headers:i,status:r})}static rewrite(e,t){let r=new Headers(null==t?void 0:t.headers);return r.set("x-middleware-rewrite",rd(e)),nz(t,r),new nU(null,{...t,headers:r})}static next(e){let t=new Headers(null==e?void 0:e.headers);return t.set("x-middleware-next","1"),nz(e,t),new nU(null,{...e,headers:t})}}Symbol.for("next.mutated.cookies"),[...r8,r6,r9].map(e=>e.toLowerCase()),r("./dist/compiled/p-queue/index.js");let nW=require("next/dist/server/lib/incremental-cache/tags-manifest.external.js");function nB(e){if(0===e)return{get:()=>Promise.resolve(void 0),set:()=>Promise.resolve(),refreshTags:()=>Promise.resolve(),getExpiration:()=>Promise.resolve(0),updateTags:()=>Promise.resolve()};let t=new _(e,(e,t)=>e.size+t.length),r=new Map,n=process.env.NEXT_PRIVATE_DEBUG_CACHE?console.debug.bind(console,"DefaultCacheHandler:"):void 0;return{async get(e){let i=r.get(e);i&&(null==n||n("get",e,"pending"),await i);let s=t.get(e);if(!s)return void(null==n||n("get",e,"not found"));let a=s.entry;if(a.expire<0)return void(null==n||n("get",e,"evicted"));let o=a.revalidate;if(performance.timeOrigin+performance.now()>a.timestamp+1e3*o)return void(null==n||n("get",e,"expired"));let l=a.revalidate;return(0,nW.areTagsExpired)(a.tags,a.timestamp)?void(null==n||n("get",e,"had expired tag")):((0,nW.areTagsStale)(a.tags,a.timestamp)&&(null==n||n("get",e,"had stale tag"),l=-1),null==n||n("get",e,"found",{tags:a.tags,timestamp:a.timestamp,expire:a.expire,revalidate:l,stale:a.stale}),{...a,revalidate:l,value:rs(s.value)})},async set(e,i){null==n||n("set",e,"start");let s=()=>{},a=new Promise(e=>{s=e});r.set(e,a);let o=await i;try{if(0===o.expire)return void(null==n||n("set",e,"skipped dynamic entry"));let r=await ro(o.value),{value:i,...s}=o;t.set(e,{entry:s,value:r,isErrored:!1,errorRetryCount:0,size:r.byteLength}),null==n||n("set",e,"done")}catch(t){null==n||n("set",e,"failed",t)}finally{s(),r.delete(e)}},async refreshTags(){},async getExpiration(e){let t=Math.max(...e.map(e=>{let t=nW.tagsManifest.get(e);return t?t.expired||0:0}),0);return null==n||n("getExpiration",{tags:e,expiration:t}),t},async updateTags(e,t){let r=Math.round(performance.timeOrigin+performance.now());for(let i of(null==n||n("updateTags",{tags:e,timestamp:r}),e)){let e=nW.tagsManifest.get(i)||{};if(t){let n={...e};n.stale=r,void 0!==t.expire&&(n.expired=r+1e3*t.expire),nW.tagsManifest.set(i,n)}else nW.tagsManifest.set(i,{...e,expired:r})}}}}let nG=process.env.NEXT_PRIVATE_DEBUG_CACHE?(e,...t)=>{console.log(`use-cache: ${e}`,...t)}:void 0,nV=Symbol.for("@next/cache-handlers"),nX=Symbol.for("@next/cache-handlers-map"),nK=Symbol.for("@next/cache-handlers-set"),nJ=Symbol.for("@next/custom-cache-handlers-registration");Symbol.for("@next/cache-handlers-private");let nY=Symbol.for("@next/cache-handlers-built-in");Symbol.for("@next/cache-handlers-dev-fronts"),Symbol.for("@next/cache-handlers-dev-tiered"),Symbol.for("@next/cache-handlers-memory-disabled");let nQ=globalThis;require("next/dist/server/app-render/after-task-async-storage.external.js");class nZ extends r${constructor(e){super(e.input,e.init),this.sourcePage=e.page}get request(){throw new rS({page:this.sourcePage})}respondWith(){throw new rS({page:this.sourcePage})}waitUntil(){throw new rS({page:this.sourcePage})}}var n0=((m={}).BLOCKING_STATIC_RENDER="BLOCKING_STATIC_RENDER",m.PRERENDER="PRERENDER",m.NOT_FOUND="NOT_FOUND",m);let n1=RegExp(`^(/.*)${t6(e3)}(/.*)${t6(e6)}$`);class n4{match(e){return n1.test(e)}extract(e){let t=e.match(n1);return t?{originalPathname:t[1],segmentPath:t[2]}:null}normalize(e){let t=this.extract(e);return t?t.originalPathname:e}}let n2=require("next/dist/shared/lib/no-fallback-error.external.js");function n8(e){if(0===e.length)return null;let t=Math.random().toString(16).slice(2),r=new Map;for(let{paramName:n}of e)r.set(n,`%%drp:${n}:${t}%%`);return r}async function n3(e,t){let r=[],n=0;for await(let i of e){let e=Buffer.isBuffer(i)?i:Buffer.from(i);if((n+=e.byteLength)>t)return null;r.push(e)}return Buffer.concat(r)}class n6 extends Error{constructor(e){super(),this.innerError=e}}class n9{getServerComponentsHmrCache(){return this.nextConfig.experimental.serverComponentsHmrCache?globalThis.__serverComponentsHmrCache:void 0}getServerComponentsHmrRefreshHash(){}getClientHmrVersion(){}constructor(e){var t,r;this.handleRSCRequest=(e,t,r)=>{var n,i;if(!r.pathname)return!1;if(null==(n=this.normalizers.segmentPrefetchRSC)?void 0:n.match(r.pathname)){let t=this.normalizers.segmentPrefetchRSC.extract(r.pathname);if(!t)return!1;let{originalPathname:n,segmentPath:i}=t;r.pathname=n,e.headers.rsc="1",e.headers[r1]="1",e.headers[r4]=i,eI(e,"isRSCRequest",!0),eI(e,"isPrefetchRSCRequest",!0),eI(e,"segmentPrefetchRSCRequest",i)}else if(null==(i=this.normalizers.rsc)?void 0:i.match(r.pathname))r.pathname=this.normalizers.rsc.normalize(r.pathname,!0),e.headers.rsc="1",eI(e,"isRSCRequest",!0);else if(e.headers["x-now-route-matches"]){var s=e.headers;for(let e of r8)delete s[e];return!1}else if("1"!==e.headers.rsc)return!1;else if(eI(e,"isRSCRequest",!0),"1"===e.headers[r1]){eI(e,"isPrefetchRSCRequest",!0);let t=e.headers[r4];"string"==typeof t&&eI(e,"segmentPrefetchRSCRequest",t)}if(e.url){let t=tx(e.url);t.pathname=r.pathname,e.url=(0,P.format)(t)}return!1},this.handleNextDataRequest=async(e,t,r)=>{var n,i;let s=await this.getMiddleware(),a="string"!=typeof(n=r.pathname)?!1:nM(n);if(!a||!a.path)return!1;if(a.path[0]!==this.buildId)return eM(e,"middlewareInvoke")?!1:(await this.render404(e,t,r),!0);a.path.shift();let o=a.path[a.path.length-1];if("string"!=typeof o||!o.endsWith(".json"))return await this.render404(e,t,r),!0;let l=`/${a.path.join("/")}`;if(l=function(e,t=""){return e=e.replace(/\\/g,"/"),(e=t&&e.endsWith(t)?e.slice(0,-t.length):e).startsWith("/index/")&&!tQ(e)?e=e.slice(6):"/index"===e&&(e="/"),e}(l,".json"),s&&(this.nextConfig.trailingSlash&&!l.endsWith("/")&&(l+="/"),!this.nextConfig.trailingSlash&&l.length>1&&l.endsWith("/")&&(l=l.substring(0,l.length-1))),this.i18nProvider){let n=null==e?void 0:null==(i=e.headers.host)?void 0:i.split(":",1)[0].toLowerCase(),a=this.i18nProvider.detectDomainLocale(n),o=(null==a?void 0:a.defaultLocale)??this.i18nProvider.config.defaultLocale,c=this.i18nProvider.analyze(l);if(c.detectedLocale&&(l=c.pathname),eI(e,"locale",c.detectedLocale),eI(e,"defaultLocale",o),c.detectedLocale||eN(e,"localeInferredFromDefault"),!c.detectedLocale&&!s)return eI(e,"locale",o),await this.render404(e,t,r),!0}return r.pathname=l,eI(e,"isNextDataReq",!0),!1},this.handleNextImageRequest=()=>!1,this.handleCatchallRenderRequest=()=>!1,this.handleCatchallMiddlewareRequest=()=>!1,this.normalize=e=>{let t=[];for(let r of(this.normalizers.data&&t.push(this.normalizers.data),this.normalizers.segmentPrefetchRSC&&t.push(this.normalizers.segmentPrefetchRSC),this.normalizers.rsc&&t.push(this.normalizers.rsc),t))if(r.match(e))return r.normalize(e,!0);return e},this.normalizeAndAttachMetadata=async(e,t,r)=>{let n=await this.handleNextImageRequest(e,t,r);return n?!0:!!(this.enabledDirectories.pages&&(n=await this.handleNextDataRequest(e,t,r)))},this.prepared=!1,this.preparedPromise=null,this.customErrorNo404Warn=function(e){let t,r=!1;return(...n)=>(r||(r=!0,t=e(...n)),t)}(()=>{tS(`You have added a custom /_error page without a custom /404 page. This prevents the 404 page from being auto statically optimized. + See here for info: https://nextjs.org/docs/messages/custom-error-no-custom-404`)});const{dir:n=".",quiet:i=!1,conf:s,dev:a=!1,minimalMode:o=!1,hostname:l,port:c,experimentalTestProxy:u}=e;if(this.dev=a,this.experimentalTestProxy=u,this.serverOptions=e,this.dir=w.resolve(n),this.quiet=i,this.loadEnvConfig({dev:a,forceReload:!1}),this.nextConfig=s,a&&this.nextConfig.experimental.requestInsights&&(process.env.__NEXT_REQUEST_INSIGHTS="true"),this.nextConfig.experimental.runtimeServerDeploymentId){if(!process.env.NEXT_DEPLOYMENT_ID)throw Error("process.env.NEXT_DEPLOYMENT_ID is missing but runtimeServerDeploymentId is enabled");this.deploymentId=process.env.NEXT_DEPLOYMENT_ID}else{let e=this.nextConfig.experimental.useSkewCookie?"":this.nextConfig.deploymentId||"";this.deploymentId=e,process.env.NEXT_DEPLOYMENT_ID=e}globalThis.NEXT_CLIENT_ASSET_SUFFIX=this.nextConfig.supportsImmutableAssets||!this.deploymentId?"":`?dpl=${this.deploymentId}`,this.hostname=l,this.hostname&&(this.fetchHostname=function(e){return tH.test(e)?`[${e}]`:e}(this.hostname)),this.port=c,this.distDir=w.join(this.dir,this.nextConfig.distDir),this.pagesNormalizers=new nb(this.distDir),this.appNormalizers=new nR(this.distDir),this.publicDir=this.getPublicDir(),this.hasStaticDir=!o&&this.getHasStaticDir(),this.i18nProvider=(null==(t=this.nextConfig.i18n)?void 0:t.locales)?new nk(this.nextConfig.i18n):void 0,this.localeNormalizer=this.i18nProvider?new r7(this.i18nProvider):void 0;const{assetPrefix:d,generateEtags:h}=this.nextConfig;this.buildId=this.getBuildId(),this.minimalMode=o||!!process.env.NEXT_PRIVATE_MINIMAL_MODE,this.enabledDirectories=this.getEnabledDirectories(a),this.isAppPPREnabled=this.enabledDirectories.app&&!!this.nextConfig.cacheComponents,this.normalizers={rsc:this.enabledDirectories.app&&1?new nN:void 0,segmentPrefetchRSC:new n4,data:this.enabledDirectories.pages?new nD(this.buildId):void 0},this.nextFontManifest=this.getNextFontManifest(),this.renderOpts={dir:this.dir,supportsDynamicResponse:!0,trailingSlash:this.nextConfig.trailingSlash,poweredByHeader:this.nextConfig.poweredByHeader,generateEtags:h,previewProps:this.getPreviewProps(),basePath:this.nextConfig.basePath,images:this.nextConfig.images,optimizeCss:this.nextConfig.experimental.optimizeCss,nextConfigOutput:this.nextConfig.output,nextScriptWorkers:this.nextConfig.experimental.nextScriptWorkers,disableOptimizedLoading:this.nextConfig.experimental.disableOptimizedLoading,domainLocales:null==(r=this.nextConfig.i18n)?void 0:r.domains,distDir:this.distDir,serverComponents:this.enabledDirectories.app,cacheLifeProfiles:this.nextConfig.cacheLife,staticPageGenerationTimeout:this.nextConfig.staticPageGenerationTimeout,enableTainting:this.nextConfig.experimental.taint,crossOrigin:this.nextConfig.crossOrigin?this.nextConfig.crossOrigin:void 0,largePageDataBytes:this.nextConfig.experimental.largePageDataBytes,isExperimentalCompile:e.compileMode?e.compileMode.isExperimentalCompile:this.nextConfig.experimental.isExperimentalCompile,cacheComponents:this.nextConfig.cacheComponents??!1,partialPrefetching:this.nextConfig.partialPrefetching,validationLevel:this.nextConfig.experimental.instantInsights.validationLevel,experimental:{expireTime:this.nextConfig.expireTime,staleTimes:this.nextConfig.experimental.staleTimes,clientTraceMetadata:this.nextConfig.experimental.clientTraceMetadata,clientParamParsingOrigins:this.nextConfig.experimental.clientParamParsingOrigins,dynamicOnHover:this.nextConfig.experimental.dynamicOnHover??!1,optimisticRouting:this.nextConfig.experimental.optimisticRouting??!1,parallelRouteMetadata:this.nextConfig.experimental.parallelRouteMetadata??!1,inlineCss:this.nextConfig.experimental.inlineCss??!1,prefetchInlining:this.nextConfig.experimental.prefetchInlining??!1,authInterrupts:!!this.nextConfig.experimental.authInterrupts,reactBrowserBailout:this.nextConfig.experimental.reactBrowserBailout??!1,serverComponentsHmrCancellation:this.nextConfig.experimental.serverComponentsHmrCancellation,useCacheTimeout:this.nextConfig.experimental.useCacheTimeout,durableUseCacheEntries:!!this.nextConfig.experimental.durableUseCacheEntries,cachedNavigations:this.nextConfig.experimental.cachedNavigations??!1,maxPostponedStateSizeBytes:tD(this.nextConfig.experimental.maxPostponedStateSize),disableResumeDataCacheCompression:this.nextConfig.experimental.disableResumeDataCacheCompression??!1,exposeTestingApi:!0===this.nextConfig.cacheComponents&&(!0===this.dev||!0===this.nextConfig.experimental.exposeTestingApiInProductionBuild)},prefetchHints:{},reactMaxHeadersLength:this.nextConfig.reactMaxHeadersLength,logServerFunctions:"object"==typeof this.nextConfig.logging&&!!this.nextConfig.logging.serverFunctions},this.pagesManifest=this.getPagesManifest(),this.appPathsManifest=this.getAppPathsManifest(),this.appPathRoutes=this.getAppPathRoutes(),this.interceptionRoutePatterns=this.getinterceptionRoutePatterns(),this.setAssetPrefix(d)}async instrumentationOnRequestError(...e){let[t,r,n]=e;if(this.instrumentation)try{await (null==this.instrumentation.onRequestError?void 0:this.instrumentation.onRequestError.call(this.instrumentation,t,{path:r.url||"",method:r.method||"GET",headers:r instanceof nZ?Object.fromEntries(r.headers.entries()):r.headers},n))}catch(e){console.error("Error in instrumentation.onRequestError:",e)}}logError(e){this.quiet||tR(e)}async handleRequest(e,t,r){var n;let i,s;await this.prepare();let a=e.method.toUpperCase(),o=(0,tn.getTracer)(),l=()=>{let n=!eM(e,"middlewareInvoke")&&void 0!==eM(e,"middlewareInvokeTraceparent"),i=n?o.getActiveScopeSpan():void 0;return o.withPropagatedContext(e.headers,()=>{let s=n?i:o.getActiveScopeSpan();return o.trace(ti.handleRequest,{spanName:`${a}`,kind:tn.SpanKind.SERVER,attributes:{"http.method":a,"http.target":e.url}},async n=>{if(eM(e,"middlewareInvoke")){let t=o.getTraceContextHeaders();t&&(Object.assign(e.headers,t),t.tracestate||delete e.headers.tracestate,eI(e,"middlewareInvokeTraceparent",t.traceparent))}return this.handleRequestImpl(e,t,r).finally(()=>{if(!n)return;let r=eM(e,"isRSCRequest")??!1;n.setAttributes({"http.status_code":t.statusCode,"next.rsc":r}),t.statusCode&&t.statusCode>=500&&(n.setStatus({code:tn.SpanStatusCode.ERROR}),n.setAttribute("error.type",t.statusCode.toString()));let i=o.getRootSpanAttributes();if(!i)return;if(i.get("next.span_type")!==ti.handleRequest)return void console.warn(`Unexpected root span type '${i.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let l=i.get("next.route");if(l){let e=r?`RSC ${a} ${l}`:`${a} ${l}`;n.setAttributes({"next.route":l,"http.route":l,"next.span_name":e}),n.updateName(e),s&&s!==n&&s.setAttribute("http.route",l)}else n.updateName(r?`RSC ${a}`:`${a}`)})})},void 0,n)};if(!(0,nA.io)())return l();let c=e.headers[r6],u="string"==typeof c?c:(0,r5.nanoid)(),d=e.headers[r9];return n={requestId:u,htmlRequestId:"string"==typeof d?d:u,url:e.url},(i=Symbol.for("@next/request-insights-identity-storage@16.4.5"),s=globalThis,s[i]??=nT?new nT:new n_).run(n,l)}async handleRequestImpl(e,t,r){try{var n,i,s,a,o,l,c,u,d;!function(e,t){if(t[nq])return;let r=t.setHeader.bind(t);Object.defineProperty(t,nq,{value:!0}),t.setHeader=(n,i)=>{if("headersSent"in t&&t.headersSent)return t;if("set-cookie"===n.toLowerCase()){let t=eM(e,"middlewareCookie");t&&Array.isArray(i)&&i.every((e,r)=>e===t[r])||(i=[...new Set([...t||[],..."string"==typeof i?[i]:Array.isArray(i)?i:[]])])}return r(n,i)}}(e,t.originalResponse);let h=(e.url||"").split("?",1)[0];if(null==h?void 0:h.match(/(\\|\/\/)/)){let r,n=(r=e.url.split("?"))[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(r[1]?`?${r.slice(1).join("?")}`:"");t.redirect(n,308).body(n).send();return}if(!r||"object"!=typeof r){if(!e.url)throw Error("Invariant: url can not be undefined");r=tx(e.url)}if(!r.pathname)throw Error("Invariant: pathname can't be empty");"string"==typeof r.query&&(r.query=Object.fromEntries(new URLSearchParams(r.query)));let{originalRequest:p=null}=e,f=null==p?void 0:p.headers["x-forwarded-proto"],m=f?"https"===f:!!(null==p?void 0:null==(n=p.socket)?void 0:n.encrypted);e.headers["x-forwarded-host"]??=e.headers.host??this.hostname,e.headers["x-forwarded-port"]??=this.port?this.port.toString():m?"443":"80",e.headers["x-forwarded-proto"]??=m?"https":"http",e.headers["x-forwarded-for"]??=null==p?void 0:null==(i=p.socket)?void 0:i.remoteAddress,this.attachRequestMeta(e,r);let g=await this.handleRSCRequest(e,t,r);if(g)return;let v=null==(s=this.i18nProvider)?void 0:s.detectDomainLocale(rv(r,e.headers)),y=(null==v?void 0:v.defaultLocale)||(null==(a=this.nextConfig.i18n)?void 0:a.defaultLocale);eI(e,"defaultLocale",y);let x=tx(e.url.replace(/^\/+/,"/")),b=rw(x.pathname,{nextConfig:this.nextConfig,i18nProvider:this.i18nProvider});x.pathname=b.pathname,b.basePath&&(e.url=rb(e.url,this.nextConfig.basePath));let w="string"==typeof e.headers[e8];if(w)try{let n;this.enabledDirectories.app&&(e.url.match(/^\/index($|\?)/)&&(e.url=e.url.replace(/^\/index/,"/")),r.pathname="/index"===r.pathname?"/":r.pathname);let{pathname:i}=new URL(function(e){let t=new Uint8Array(e.length);for(let r=0;r{let e="",t=++a;for(;t>0;)e+=String.fromCharCode(97+(t-1)%26),t=Math.floor((t-1)/26);return e}),l={},c=[],u=[];for(let a of(s=structuredClone(s),t9(e).slice(1).split("/"))){let e,d=tX.some(e=>a.startsWith(e)),h=a.match(t5),p=d?h?.[1]:void 0;if(p&&h?.[2]?(e=t?e2:void 0,s.intercepted[h[2]]=p):e=h?.[2]&&s.intercepted[h[2]]?t?e2:void 0:t?e4:void 0,p&&h&&h[2]){let{key:t,pattern:r,cleanedKey:n,repeat:a,optional:d}=rt({getSafeRouteKey:o,interceptionMarker:p,segment:h[2],routeKeys:l,keyPrefix:e,backreferenceDuplicateKeys:i});c.push(r),u.push(`/${h[1]}:${s.names[t]??n}${a?d?"*":"+":""}`),s.names[t]??=n}else if(h&&h[2]){n&&h[1]&&(c.push(`/${t6(h[1])}`),u.push(`/${h[1]}`));let{key:t,pattern:r,cleanedKey:a,repeat:d,optional:p}=rt({getSafeRouteKey:o,segment:h[2],routeKeys:l,keyPrefix:e,backreferenceDuplicateKeys:i}),f=r;n&&h[1]&&(f=f.substring(1)),c.push(f),u.push(`/:${s.names[t]??a}${d?p?"*":"+":""}`),s.names[t]??=a}else c.push(`/${t6(a)}`),u.push(`/${a}`);r&&h&&h[3]&&(c.push(t6(h[3])),u.push(h[3]))}return{namedParameterizedRoute:c.join(""),routeKeys:l,pathToRegexpPattern:u.join(""),reference:s}}(e,u.prefixRouteKeys,u.includeSuffix??!1,u.includePrefix??!1,u.backreferenceDuplicateKeys??!1,u.reference)).namedParameterizedRoute,u.excludeOptionalTrailingSlash||(r+="(?:/)?"),c=(l=eU(o={...re(e,u),namedRegex:`^${r}$`,routeKeys:t.routeKeys,pathToRegexpPattern:t.pathToRegexpPattern,reference:t.reference}))(e)}return{handleRewrites:function(o,c){let u=structuredClone(c),d={},h=u.pathname,p=n=>{let c=rU(n.source+(s?"(/)?":""),{removeUnnamedParams:!0,strict:!0,sensitive:!!a});if(!u.pathname)return!1;let p=c(u.pathname);if((n.has||n.missing)&&p){let e=rB(o,u.query,n.has,n.missing);e?Object.assign(p,e):p=!1}if(p){let{parsedDestination:s,destQuery:a}=function(e){let t,r,n=function(e){let t=e.destination;for(let n of Object.keys({...e.params,...e.query}))if(n){var r;r=t,t=r.replace(RegExp(`:${t6(n)}`,"g"),`__ESC_COLON_${n}`)}let n=tx(t),i=n.pathname;i&&(i=rW(i));let s=n.href;s&&(s=rW(s));let a=n.hostname;a&&(a=rW(a));let o=n.hash;o&&(o=rW(o));let l=n.search;l&&(l=rW(l));let c=n.origin;return c&&(c=rW(c)),{...n,pathname:i,hostname:a,href:s,hash:o,search:l,origin:c}}(e),{hostname:i,query:s,search:a}=n,o=n.pathname;n.hash&&(o=`${o}${n.hash}`);let l=[],c=[];for(let e of(eH(o,c),c))l.push(e.name);if(i){let e=[];for(let t of(eH(i,e),e))l.push(t.name)}let u=ez(o,{validate:!1});for(let[r,n]of(i&&(t=ez(i,{validate:!1,encode:encodeURIComponent})),Object.entries(s)))Array.isArray(n)?s[r]=n.map(t=>rG(rW(t),e.params)):"string"==typeof n&&(s[r]=rG(rW(n),e.params));let d=Object.keys(e.params).filter(e=>"nextInternalLocale"!==e);if(e.appendParamsToQuery&&!d.some(e=>l.includes(e)))for(let t of d)t in s||(s[t]=e.params[t]);if(tK(o))for(let t of o.split("/")){let r=tX.find(e=>t.startsWith(e));if(r){"(..)(..)"===r?(e.params["0"]="(..)",e.params["1"]="(..)"):e.params["0"]=r;break}}try{let[i,s]=(r=u(e.params)).split("#",2);t&&(n.hostname=t(e.params)),n.pathname=i,n.hash=`${s?"#":""}${s||""}`,n.search=a?rG(a,e.params):""}catch(e){if(e.message.match(/Expected .*? to not repeat, but got an array/))throw Error("To use a multi-match in the destination you must add `*` at the end of the param name to signify it should repeat. https://nextjs.org/docs/messages/invalid-multi-match");throw e}return n.query={...e.query,...n.query},{newUrl:r,destQuery:s,parsedDestination:n}}({appendParamsToQuery:!0,destination:n.destination,params:p,query:u.query});if(s.protocol)return!0;if(Object.assign(d,a,p),Object.assign(u.query,s.query),delete s.query,Object.assign(u,s),!(h=u.pathname))return!1;if(r&&(h=h.replace(RegExp(`^${r}`),"")||"/"),t){let e=rx(h,t.locales);h=e.pathname,u.query.nextInternalLocale=e.detectedLocale||p.nextInternalLocale}if(h===e)return!0;if(i&&l){let e=l(h);if(e)return u.query={...u.query,...e},!0}}return!1};for(let e of n.beforeFiles||[])p(e);if(h!==e){let t,r=!1;for(let e of n.afterFiles||[])if(r=p(e))break;if(!r&&!((t=t9(h||""))===t9(e)||(null==l?void 0:l(t)))){for(let e of n.fallback||[])if(r=p(e))break}}return{rewriteParams:d,rewrittenParsedUrl:u}},defaultRouteRegex:o,dynamicRouteMatcher:l,defaultRouteMatches:c,normalizeQueryParams:function(e,t){for(let[r,n]of(delete e.nextInternalLocale,Object.entries(e))){let i=rh(r);i&&(delete e[r],t.add(i),void 0!==n&&(e[i]=Array.isArray(n)?n.map(e=>rV(e)):rV(n)))}},getParamsFromRouteMatches:function(e){if(!o)return null;let{groups:t,routeKeys:r}=o,n=eU({re:{exec:e=>{let n=Object.fromEntries(new URLSearchParams(e));for(let[e,t]of Object.entries(n)){let r=rh(e);r&&(n[r]=t,delete n[e])}let i={};for(let e of Object.keys(r)){let s=r[e];if(!s)continue;let a=t[s],o=n[e];if(!a.optional&&!o)return null;i[a.pos]=o}return i}},groups:t})(e);return n?n:null},normalizeDynamicRouteParams:(e,t)=>o&&c?function(e,t,r,n){let i=(e,t)=>{if(!e)return!1;let r=tV(e);for(let e=0;e<3;e++){if(r===t)return!0;let e=rV(r);if(e===r)break;r=e}return!1},s={};for(let a of Object.keys(t.groups)){let o=e[a];"string"==typeof o?o=tV(o):Array.isArray(o)&&(o=o.map(tV));let l=r[a],c=t.groups[a].optional;if((Array.isArray(l)?l.some(e=>Array.isArray(o)?o.some(t=>i(t,e)):i(o,e)):Array.isArray(o)?o.some(e=>i(e,l)):i(o,l))||void 0===o&&!(c&&n))return{params:{},hasValidParams:!1};c&&(!o||Array.isArray(o)&&1===o.length&&("index"===o[0]||o[0]===`[[...${a}]]`)||"index"===o||o===`[[...${a}]]`)&&(o=void 0,delete e[a]),o&&"string"==typeof o&&t.groups[a].repeat&&(o=o.split("/")),o&&(s[a]=o)}return{params:s,hasValidParams:!0}}(e,o,c,t):{params:{},hasValidParams:!1},normalizeCdnUrl:(e,t)=>(function(e,t){let r=function(e){let t=function(e){let t;try{t=new URL(e,"http://n")}catch{}return t}(e);if(!t)return;let r={};for(let e of t.searchParams.keys()){let n=t.searchParams.getAll(e);r[e]=n.length>1?n:n[0]}return{query:r,hash:t.hash,search:t.search,path:t.pathname,pathname:t.pathname,href:`${t.pathname}${t.search}${t.hash}`,host:"",hostname:"",auth:"",protocol:"",slashes:null,port:""}}(e.url);if(!r)return e.url;delete r.search,rK(r.query,t),e.url=function(e){let{auth:t,hostname:r}=e,n=e.protocol||"",i=e.pathname||"",s=e.hash||"",a=e.query||"",o=!1;(t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host)?o=t+e.host:r&&(o=t+(~r.indexOf(":")?`[${r}]`:r),e.port&&(o+=":"+e.port)),a&&"object"==typeof a&&(a=String(function(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))if(Array.isArray(n))for(let e of n)t.append(r,ty(e));else t.set(r,ty(n));return t}(a)));let l=e.search||a&&`?${a}`||"";return n&&!n.endsWith(":")&&(n+=":"),e.slashes||(!n||rX.test(n))&&!1!==o?(o="//"+(o||""),i&&"/"!==i[0]&&(i="/"+i)):o||(o=""),s&&"#"!==s[0]&&(s="#"+s),l&&"?"!==l[0]&&(l="?"+l),i=i.replace(/[?#]/g,encodeURIComponent),l=l.replace("#","%23"),`${n}${o}${i}${l}${s}`}(r)})(e,t),interpolateDynamicPath:(e,t)=>(function(e,t,r){if(!r)return e;for(let n of Object.keys(r.groups)){let i,{optional:s,repeat:a}=r.groups[n],o=`[${a?"...":""}${n}]`;s&&(o=`[${o}]`);let l=t[n];((i=Array.isArray(l)?l.map(e=>e&&encodeURIComponent(e)).join("/"):l?encodeURIComponent(l):"")||s)&&(e=e.replaceAll(o,i))}return e})(e,t,o),filterInternalQuery:(e,t)=>rK(e,t)}}({pageIsDynamic:p,page:h,i18n:this.nextConfig.i18n,basePath:this.nextConfig.basePath,rewrites:(null==(c=this.getRoutesManifest())?void 0:c.rewrites)||{beforeFiles:[],afterFiles:[],fallback:[]},caseSensitive:!!this.nextConfig.experimental.caseSensitiveRoutes});y&&!b.locale&&(r.pathname=`/${y}${r.pathname}`);let v={...r.query},w=r.pathname,{rewriteParams:E,rewrittenParsedUrl:P}=m.handleRewrites(e,r),C=Object.keys(E),R={...P.query},S=w!==P.pathname;S&&P.pathname&&eI(e,"rewrittenPathname",P.pathname);let _=new Set;for(let[e,t]of Object.entries(r.query)){let n=rh(e);n&&(delete r.query[e],_.add(n),void 0!==t&&(R[n]=Array.isArray(t)?t.map(e=>rV(e)):rV(t)))}if(p){let t={};if(f.hasValidParams||(f=m.normalizeDynamicRouteParams(R,!1)),!f.hasValidParams&&!tQ(a)){let e=null==m.dynamicRouteMatcher?void 0:m.dynamicRouteMatcher.call(m,a);e&&(m.normalizeDynamicRouteParams(e,!1),Object.assign(f.params,e),f.hasValidParams=!0)}if("/index"!==i&&!f.hasValidParams&&!tQ(i)){let e=null==m.dynamicRouteMatcher?void 0:m.dynamicRouteMatcher.call(m,i);if(e){let r=m.normalizeDynamicRouteParams(e,!1);r.hasValidParams&&(Object.assign(t,e),f=r)}}f.hasValidParams&&(t=f.params);let r=e.headers["x-now-route-matches"];if("string"==typeof r&&r&&tQ(i)&&!f.hasValidParams){let e=m.getParamsFromRouteMatches(r);e&&(f=m.normalizeDynamicRouteParams(e,!0)).hasValidParams&&(t=f.params)}if(!f.hasValidParams&&(f=m.normalizeDynamicRouteParams(R,!0)).hasValidParams&&(t=f.params),m.defaultRouteMatches&&a===h&&!f.hasValidParams&&(t=m.defaultRouteMatches,""===r&&eI(e,"renderFallbackShell",!0)),t){i=m.interpolateDynamicPath(h,t),e.url=m.interpolateDynamicPath(e.url,t);let r=eM(e,"segmentPrefetchRSCRequest");r&&tQ(r,!1)&&(r=m.interpolateDynamicPath(r,t),e.headers[r4]=r,eI(e,"segmentPrefetchRSCRequest",r))}}let T=d;if(this.i18nProvider){let t=this.i18nProvider.analyze(i,{defaultLocale:y});i=(T=t.pathname!==i||!d?t:{...d,pathname:i}).pathname,eI(e,"locale",T.detectedLocale),T.inferredFromDefault?eI(e,"localeInferredFromDefault",!0):eN(e,"localeInferredFromDefault")}let A=this.getRouteMatch(i,T);for(let t of(A?eI(e,"match",A):eN(e,"match"),(p||S)&&m.normalizeCdnUrl(e,[...C,...Object.keys((null==(u=m.defaultRouteRegex)?void 0:u.groups)||{})]),_))t in v||delete r.query[t];if(r.pathname=i,x.pathname=r.pathname,((null==n?void 0:n.kind)===ne.PAGES||(null==n?void 0:n.kind)===ne.PAGES_API)&&(r.query=R),g=await this.normalizeAndAttachMetadata(e,t,r))return}catch(r){if(r instanceof eT||r instanceof eA)return t.statusCode=400,this.renderError(null,e,t,"/_error",{});throw r}(eI(e,"isLocaleDomain",!!v),b.locale&&(e.url=(0,P.format)(x),eI(e,"didStripLocale",!0)),!eM(e,"locale"))&&(b.locale?eI(e,"locale",b.locale):y&&(eI(e,"locale",y),eI(e,"localeInferredFromDefault",!0)));if(!this.serverOptions.webServerConfig&&!eM(e,"incrementalCache")){let t=await this.getIncrementalCache({requestHeaders:Object.assign({},e.headers)});t.resetRequestCache(),eI(e,"incrementalCache",t),globalThis.__incrementalCache=t}eM(e,"serverComponentsHmrCache")||eI(e,"serverComponentsHmrCache",this.getServerComponentsHmrCache()),eM(e,"hmrRefreshHash")||eI(e,"hmrRefreshHash",this.getServerComponentsHmrRefreshHash());let E=eM(e,"invokePath");if(!w&&E){let n=eM(e,"invokeStatus");if(n){let i=eM(e,"invokeQuery");i&&Object.assign(r.query,i),t.statusCode=n;let s=eM(e,"invokeError")||null;return this.renderError(s,e,t,"/_error",r.query)}let i=new URL(E||"/","http://n"),s=rw(i.pathname,{nextConfig:this.nextConfig,parseData:!1});s.locale&&eI(e,"locale",s.locale),r.pathname!==i.pathname&&(r.pathname=i.pathname,eI(e,"rewrittenPathname",s.pathname));let a=rx(rb(r.pathname,this.nextConfig.basePath||""),null==(d=this.nextConfig.i18n)?void 0:d.locales);for(let t of(a.detectedLocale&&eI(e,"locale",a.detectedLocale),r.pathname=a.pathname,Object.keys(r.query)))delete r.query[t];let o=eM(e,"invokeQuery");if(o&&Object.assign(r.query,o),g=await this.normalizeAndAttachMetadata(e,t,r))return;await this.handleCatchallRenderRequest(e,t,r);return}if(eM(e,"middlewareInvoke")){if(g=await this.normalizeAndAttachMetadata(e,t,r))return;if(g=await this.handleCatchallMiddlewareRequest(e,t,r))return;let n=Error();throw n.result={response:new Response(null,{headers:{"x-middleware-next":"1"}})},n.bubble=!0,n}return!w&&b.basePath&&(r.pathname=rb(r.pathname,b.basePath)),t.statusCode=200,await this.run(e,t,r)}catch(r){if(r instanceof n2.NoFallbackError)throw r;if(r&&"object"==typeof r&&"ERR_INVALID_URL"===r.code||r instanceof eT||r instanceof eA)return t.statusCode=400,this.renderError(null,e,t,"/_error",{});throw r}}getPagesRouteDefinition(e,t,r,n){var i;let s=null==(i=this.pagesManifest)?void 0:i[e];if(s)return{kind:r,pathname:t,page:e,bundlePath:this.pagesNormalizers.bundlePath.normalize(e),filename:this.pagesNormalizers.filename.normalize(s),...this.i18nProvider?{i18n:{locale:n}}:{}}}getAppPageRouteDefinition(e){var t,r;let n=null==(t=this.appPathRoutes)?void 0:t[e];if(!n)return;let i=tG(e,n);if(!i.endsWith("/page"))return;let s=null==(r=this.appPathsManifest)?void 0:r[i];if(s)return{kind:ne.APP_PAGE,pathname:e,page:i,bundlePath:this.appNormalizers.bundlePath.normalize(i),filename:this.appNormalizers.filename.normalize(s),appPaths:n}}getAppRouteRouteDefinition(e){var t;let r=null==(t=this.appPathsManifest)?void 0:t[e];if(!r)return;let n=this.appNormalizers.pathname.normalize(e);return{kind:ne.APP_ROUTE,pathname:n,page:e,bundlePath:this.appNormalizers.bundlePath.normalize(e),filename:this.appNormalizers.filename.normalize(r)}}getRouteDefinitions(){let e=[];if(this.enabledDirectories.pages)for(let r of Object.keys(this.pagesManifest||{})){var t;let n=null==(t=this.i18nProvider)?void 0:t.analyze(r),i=(null==n?void 0:n.pathname)??r;if(t0(i))continue;let s=this.getPagesRouteDefinition(r,i,"/api"===r||(null==r?void 0:r.startsWith("/api/"))?ne.PAGES_API:ne.PAGES,null==n?void 0:n.detectedLocale);s&&e.push(s)}if(this.enabledDirectories.app){for(let t of Object.keys(this.appPathRoutes||{})){let r=this.getAppPageRouteDefinition(t);r&&e.push(r)}for(let t of Object.keys(this.appPathsManifest||{})){if(!rJ(t))continue;let r=this.getAppRouteRouteDefinition(t);r&&e.push(r)}}return e}getSortedRouteDefinitions(e){let t,r=new Map,n=[];for(let t of e){let e=r.get(t.pathname);e?e.push(t):(r.set(t.pathname,[t]),n.push(t.pathname))}return(t=new tZ,n.forEach(e=>t.insert(e)),t.smoosh()).flatMap(e=>r.get(e))}getRouteMatchPathname(e,t,r){return t.i18n&&r?t.i18n.locale&&r.detectedLocale&&t.i18n.locale!==r.detectedLocale?null:r.pathname:(null==r?void 0:r.inferredFromDefault)?r.pathname:e}testRouteDefinition(e,t,r){let n=this.getRouteMatchPathname(e,t,r);if(!n)return null;if(tQ(t.pathname)){let e=eU(re(t.pathname))(n);return e?{definition:t,params:e}:null}return n===t.pathname?{definition:t,params:void 0}:null}getRoutePatternDefinition(e,t){for(let r of this.getRouteDefinitions())if(this.getRouteMatchPathname(e,r,t)===r.pathname)return r}getRouteMatch(e,t){let r=this.getRouteDefinitions(),n=[];if(tQ(e))for(let e of r)tQ(e.pathname)&&n.push(e);else for(let i of r){if(tQ(i.pathname)){n.push(i);continue}let r=this.testRouteDefinition(e,i,t);if(r)return r}for(let r of this.getSortedRouteDefinitions(n)){let n=this.testRouteDefinition(e,r,t);if(n)return n}return null}getRequestHandlerWithMetadata(e){let t=this.getRequestHandler();return(r,n,i)=>(r[eO]=e,t(r,n,i))}getRequestHandler(){return this.handleRequest.bind(this)}setAssetPrefix(e){this.renderOpts.assetPrefix=e?e.replace(/\/$/,""):""}getAssetPrefix(){return this.renderOpts.assetPrefix||""}async prepare(){if(!this.prepared)return this.instrumentation||(this.instrumentation=await this.loadInstrumentationModule()),null===this.preparedPromise&&(this.preparedPromise=this.prepareImpl().then(()=>{this.prepared=!0,this.preparedPromise=null})),this.preparedPromise}async prepareImpl(){}async loadInstrumentationModule(){}async close(){}getAppPathRoutes(){let e={};return Object.keys(this.appPathsManifest||{}).forEach(t=>{let r=tW(t);e[r]||(e[r]=[]),e[r].push(t)}),e}async run(e,t,r){return(0,tn.getTracer)().trace(ti.run,async()=>this.runImpl(e,t,r))}async runImpl(e,t,r){await this.handleCatchallRenderRequest(e,t,r)}async pipe(e,t){return(0,tn.getTracer)().trace(ti.pipe,async()=>this.pipeImpl(e,t))}async pipeImpl(e,r){var n;let s,a=r.req.headers["user-agent"]||"",o={...r,renderOpts:{...this.renderOpts,supportsDynamicResponse:!this.renderOpts.botType,serveStreamingMetadata:(n=a,s=this.nextConfig.htmlLimitedBots||t2,t!==s&&(t=s,i=RegExp(s,"i")),!(n&&i.test(n)))}},l=await e(o);if(null===l)return;let{req:c,res:u}=o,d=u.statusCode,{body:h}=l,{cacheControl:p}=l;if(!u.sent){let{generateEtags:e,poweredByHeader:t}=this.renderOpts;this.dev&&(u.setHeader("Cache-Control","no-store"),p=void 0),p&&void 0===p.expire&&(p.expire=this.nextConfig.expireTime),await this.sendRenderResult(c,u,{result:h,generateEtags:e,poweredByHeader:t,cacheControl:p}),u.statusCode=d}}async getStaticHTML(e,t){let r={...t,renderOpts:{...this.renderOpts,supportsDynamicResponse:!1}},n=await e(r);return null===n?null:n.body.toUnchunkedString()}async render(e,t,r,n={},i,s=!1){return(0,tn.getTracer)().trace(ti.render,async()=>this.renderImpl(e,t,r,n,i,s))}getWaitUntil(){let e,t=null==(e=globalThis[nL])?void 0:e.get();if(t)return t.waitUntil}getInternalWaitUntil(){}async renderImpl(e,t,r,n={},i,s=!1){r.startsWith("/")||console.warn(`Cannot render page with path "${r}", did you mean "/${r}"?. See more info here: https://nextjs.org/docs/messages/render-no-starting-slash`),this.serverOptions.customServer&&"/index"===r&&!await this.hasPage("/index")&&(r="/");let a=e.headers["user-agent"]||"";return(this.renderOpts.botType=function(e){return t4.test(e)?"dom":t1.test(e)?"html":void 0}(a),t0(r))?this.render404(e,t,i):this.pipe(e=>this.renderToResponse(e),{req:e,res:t,pathname:r,query:n})}async getStaticPaths({pathname:e}){var t;return{staticPaths:void 0,fallbackMode:function(e){if("string"==typeof e)return"PRERENDER";if(null===e)return"BLOCKING_STATIC_RENDER";if(!1===e)return"NOT_FOUND";if(void 0!==e)throw Error(`Invalid fallback option: ${e}. Fallback option must be a string, null, undefined, or false.`)}(null==(t=this.getPrerenderManifest().dynamicRoutes[e])?void 0:t.fallback)}}async renderToResponseWithComponents(e,t){return(0,tn.getTracer)().trace(ti.renderToResponseWithComponents,async()=>this.renderToResponseWithComponentsImpl(e,t))}pathCouldBeIntercepted(e){return tK(e)||this.interceptionRoutePatterns.some(t=>t.test(e))}setVaryHeader(e,t,r,n){let i=`rsc, ${r0}, ${r1}, ${r4}`,s=eM(e,"isRSCRequest")??!1,a=!1;r&&this.pathCouldBeIntercepted(n)?(t.appendHeader("vary",`${i}, ${r2}`),a=!0):(r||s)&&t.appendHeader("vary",i),a||delete e.headers[r2]}async renderToResponseWithComponentsImpl({req:e,res:t,pathname:r,renderOpts:n},{components:i,query:s}){var a,o,l,c,u,d,h,p,f,m,g,v;let y,x,b,w,E,P,C;this.dev&&void 0===eM(e,"initialHmrVersion")&&eI(e,"initialHmrVersion",this.getClientHmrVersion()),r===eW&&(r="/404");let R="/_error"===r,S="/404"===r||R&&404===t.statusCode,_="/500"===r||R&&500===t.statusCode,T=!0===i.isAppPath,A=!!i.getServerSideProps,k=(e.headers instanceof Headers?(b=e.headers.get(rZ)??null,w=e.headers.get("content-type")):(b=e.headers[rZ]??null,w=e.headers["content-type"]??null),E="POST"===e.method&&"application/x-www-form-urlencoded"===w,P=!!("POST"===e.method&&(null==w?void 0:w.startsWith("multipart/form-data"))),C=void 0!==b&&"string"==typeof b&&"POST"===e.method,{actionId:b,isURLEncodedAction:E,isMultipartAction:P,isFetchAction:C,isPossibleServerAction:!!(C||E||P)}).isPossibleServerAction,$=!!i.getStaticProps,O=eM(e,"isRSCRequest")??!1,M=tx(e.url||"").pathname||"/",I=eM(e,"rewrittenPathname")||M;this.setVaryHeader(e,t,T,I);let N=this.getPrerenderManifest();(null==y?void 0:y.includes(I))||e.headers["x-now-route-matches"]?$=!0:this.dev||($||=!!N.routes[r.replace(/(?:\/index)?\/?$/,"")||"/"]);let j=!!(eM(e,"isNextDataReq")||e.headers["x-nextjs-data"]&&this.serverOptions.webServerConfig)&&($||A);if(!$&&e.headers["x-middleware-prefetch"]&&!(S||"/_error"===r))return t.setHeader(e8,r),t.setHeader("x-middleware-skip","1"),t.setHeader("cache-control","private, no-cache, no-store, max-age=0, must-revalidate"),t.body("{}").send(),null;$&&e.headers[e8]&&e.url.startsWith("/_next/data")&&(e.url=this.stripNextDataPath(e.url));let D=eM(e,"locale");e.headers["x-nextjs-data"]&&(!t.statusCode||200===t.statusCode)&&t.setHeader("x-nextjs-matched-path",`${D?`/${D}`:""}${r}`),i.routeModule&&(x=i.routeModule);let q=this.isAppPPREnabled&&void 0!==x&&x.definition.kind===ne.APP_PAGE,L="1"===process.env.__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING&&void 0!==s.__nextppronly&&q,F=!0===this.dev||!0===this.nextConfig.experimental.exposeTestingApiInProductionBuild,H=F&&"1"!==e.headers.rsc&&"string"==typeof e.headers.cookie&&e.headers.cookie.includes("next-instant-navigation-testing=")&&q,z=q&&((null==(a=N.routes[r]??N.dynamicRoutes[r])?void 0:a.renderingMode)==="PARTIALLY_STATIC"||(L||H)&&(F||!0===this.experimentalTestProxy))?eM(e,"postponed"):void 0;if(S&&!j&&!O&&(t.statusCode=404,("GET"===e.method||"HEAD"===e.method)&&"string"==typeof(f=e.headers["sec-fetch-dest"])&&tz.has(f)))return t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),t.setHeader("Content-Type","text/plain; charset=utf-8"),t.body("Not Found").send(),null;if(eJ.includes(r)&&(t.statusCode=parseInt(r.slice(1),10)),!k&&"string"!=typeof z&&!S&&!_&&"/_error"!==r&&"HEAD"!==e.method&&"GET"!==e.method&&("string"==typeof i.Component||$))return t.statusCode=405,t.setHeader("Allow",["GET","HEAD"]),t.body("Method Not Allowed").send(),null;if("string"==typeof i.Component)return{body:rF.fromStatic(i.Component,e1)};if(!0===n.supportsDynamicResponse){let t=(g=m=e.headers["user-agent"]||"",t4.test(g)||t1.test(m)),r="function"!=typeof(null==(o=i.Document)?void 0:o.getInitialProps)||"__NEXT_BUILTIN_DOCUMENT__"in i.Document;n.supportsDynamicResponse=!$&&!t&&r}if(!j&&T&&this.dev&&(n.supportsDynamicResponse=!0),$&&e.headers[e8]&&(I=M),M=t9(M),I=t9(I),this.localeNormalizer&&(I=this.localeNormalizer.normalize(I)),j&&(I=this.stripNextDataPath(I),M=this.stripNextDataPath(M)),(await this.getIncrementalCache({requestHeaders:Object.assign({},e.headers)})).resetRequestCache(),(null==x?void 0:x.isDev)&&tQ(r)&&(i.getStaticPaths||T)){let t;this.dev&&(t=process.hrtime.bigint());let n=await this.getStaticPaths({pathname:r,urlPathname:M,requestHeaders:e.headers,page:i.page,isAppPath:T});if(this.dev&&t&&(null==(l=n.staticPaths)?void 0:l.length)&&eI(e,"devGenerateStaticParamsDuration",process.hrtime.bigint()-t),T&&this.nextConfig.cacheComponents){let t=n.paramMatching;if(void 0!==t&&(eI(e,"devParamMatchingRejected",!1),eI(e,"devNotFoundParams",Object.keys(t).filter(e=>"not-found"===t[e]))),(null==(c=n.prerenderedRoutes)?void 0:c.length)||(null==(u=n.prerenderRouteMatchers)?void 0:u.length)){let r,i=I.split("/").map(e=>{try{var t;t=decodeURIComponent(e),e=t.replace(RegExp("([/#?\\\\]|%(2f|23|3f|5c))","gi"),e=>encodeURIComponent(e))}catch(e){throw new eT("Failed to decode path param(s).")}return e}).join("/");for(let e of n.prerenderedRoutes??[])re(e.pathname).re.test(i)&&(void 0===r||((null==(d=e.fallbackRouteParams)?void 0:d.length)??0)<((null==(h=r.fallbackRouteParams)?void 0:h.length)??0))&&(r=e);for(let e of n.prerenderRouteMatchers??[])re(e.pathname).re.test(i)&&(void 0===r||e.fallbackRouteParams.length<((null==(p=r.fallbackRouteParams)?void 0:p.length)??0))&&(r=e);if(void 0!==t&&(null==r?void 0:r.fallbackMode)===n0.NOT_FOUND&&eI(e,"devParamMatchingRejected",!0),r){eI(e,"fallbackRouteParams",r.fallbackRouteParams?n8(r.fallbackRouteParams):null);let t=function(e){let{fallbackRouteParams:t,remainingPrerenderableParams:r}=e;if(!(null==t?void 0:t.length))return null;if(void 0===e.throwOnEmptyStaticShell)throw new ec("Expected throwOnEmptyStaticShell for a route with fallback params");return!e.throwOnEmptyStaticShell&&(null==r?void 0:r.length)?n8(t.filter(e=>!r.some(t=>t.paramName===e.paramName))):n8(t)}({...r,throwOnEmptyStaticShell:"throwOnEmptyStaticShell"in r?r.throwOnEmptyStaticShell:!1});n.explicitFallbackRouteParams&&(t=new Map([...t??[],...n8(n.explicitFallbackRouteParams)??[]])),eI(e,"stagedFallbackParams",t)}}}}if("OPTIONS"===e.method&&!S&&(!x||x.definition.kind!==ne.APP_ROUTE))return await nO(e,t,new Response(null,{status:400})),null;let U=e.originalRequest,W=t.originalResponse,B=tx(eM(e,"initURL")||e.url),G=B.pathname||"/";for(let e of[this.normalizers.segmentPrefetchRSC,this.normalizers.rsc])(null==e?void 0:e.match(G))&&(G=e.normalize(G));return R||(U.url=`${G}${B.search||""}`),v=eM(e),U[eO]=v,eI(U,"distDir",this.distDir),eI(U,"query",s),eI(U,"params",n.params),eI(U,"minimalMode",!0),n.err&&eI(U,"invokeError",n.err),await i.ComponentMod.handler(U,W,{waitUntil:this.getWaitUntil()}),null}stripNextDataPath(e,t=!0){return e.includes(this.buildId)&&(e=rz(e.substring(e.indexOf(this.buildId)+this.buildId.length).replace(/\.json$/,""))),this.localeNormalizer&&t?this.localeNormalizer.normalize(e):e}getOriginalAppPaths(e){if(this.enabledDirectories.app){var t;let r=null==(t=this.appPathRoutes)?void 0:t[e];return r?r:null}return null}async renderPageComponent(e,t){var r;let{query:n,pathname:i}=e,s=eM(e.req,"match"),a=this.getOriginalAppPaths(i)??(s&&s.definition.kind===ne.APP_PAGE?s.definition.appPaths:null),o=Array.isArray(a),l=i;o?l=tG(i,a):(null==s?void 0:s.definition.kind)===ne.APP_ROUTE&&(l=s.definition.page);let c=await this.findPageComponents({locale:eM(e.req,"locale"),page:l,query:n,params:e.renderOpts.params||{},isAppPath:o,sriEnabled:!!(null==(r=this.nextConfig.experimental.sri)?void 0:r.algorithm),appPaths:a,shouldEnsure:!s,url:i});if(c){(0,tn.getTracer)().setRootSpanAttribute("next.route",i);try{return await this.renderToResponseWithComponents(e,c)}catch(r){let e=r instanceof n2.NoFallbackError;if(!e||e&&t)throw r}}return!1}async renderToResponse(e){return(0,tn.getTracer)().trace(ti.renderToResponse,{spanName:"rendering page",attributes:{"next.route":e.pathname}},async()=>this.renderToResponseImpl(e))}async renderToResponseImpl(e){let{req:t,res:r,query:n,pathname:i}=e,s=eM(e.req,"bubbleNoFallback")??!1;delete n[r3];let a=eM(e.req,"match");eM(e.req,"invokeOutput");try{if(!a){var o;let e=null==(o=this.i18nProvider)?void 0:o.fromRequest(t,i),r=this.getRouteMatch(i,e);r&&(a=r,eI(t,"match",r))}if(a){if(1){let t=await this.renderPageComponent({...e,pathname:a.definition.pathname,renderOpts:{...e.renderOpts,params:a.params}},s);if(!1!==t)return t}}else{let t=await this.renderPageComponent(e,s);if(!1!==t)return t}if(this.serverOptions.webServerConfig){e.pathname=this.serverOptions.webServerConfig.page;let t=await this.renderPageComponent(e,s);if(!1!==t)return t}}catch(a){let t=rQ(a);if(a instanceof e$)throw console.error("Invariant: failed to load static page",JSON.stringify({page:i,url:e.req.url,matchedPath:e.req.headers[e8],initUrl:eM(e.req,"initURL"),didRewrite:!!eM(e.req,"rewrittenPathname"),rewrittenPathname:eM(e.req,"rewrittenPathname")},null,2)),t;if(t instanceof n2.NoFallbackError&&s)throw t;if(t instanceof eT||t instanceof eA)return r.statusCode=400,await this.renderErrorToResponse(e,t);r.statusCode=500,await this.hasPage("/500")&&(eI(e.req,"customErrorRender",!0),await this.renderErrorToResponse(e,t),eN(e.req,"customErrorRender"));let n=t instanceof n6;if(!n)throw rY(t)&&(t.page=i),t;return await this.renderErrorToResponse(e,n?t.innerError:t)}if(await this.getMiddleware()&&e.req.headers["x-nextjs-data"]&&(!r.statusCode||200===r.statusCode||404===r.statusCode)){let e=eM(t,"locale");return r.setHeader("x-nextjs-matched-path",`${e?`/${e}`:""}${i}`),r.statusCode=200,r.setHeader("Content-Type","application/json; charset=utf-8"),r.body("{}"),r.send(),null}return r.statusCode=404,this.renderErrorToResponse(e,null)}async renderToHTML(e,t,r,n={}){return(0,tn.getTracer)().trace(ti.renderToHTML,async()=>this.renderToHTMLImpl(e,t,r,n))}async renderToHTMLImpl(e,t,r,n={}){return this.getStaticHTML(e=>this.renderToResponse(e),{req:e,res:t,pathname:r,query:n})}async renderError(e,t,r,n,i={},s=!0){return(0,tn.getTracer)().trace(ti.renderError,async()=>this.renderErrorImpl(e,t,r,n,i,s))}async renderErrorImpl(e,t,r,n,i={},s=!0){return s&&r.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),this.pipe(async t=>{let n=await this.renderErrorToResponse(t,e);if(500===r.statusCode)throw e;return n},{req:t,res:r,pathname:n,query:i})}async renderErrorToResponse(e,t){return(0,tn.getTracer)().trace(ti.renderErrorToResponse,async()=>this.renderErrorToResponseImpl(e,t))}async renderErrorToResponseImpl(e,t){if(this.dev&&"/favicon.ico"===e.pathname)return{body:rF.EMPTY};let{res:r,query:n}=e;try{let i=null,s=404===r.statusCode,a=this.enabledDirectories.app;s&&(a&&(i=await this.findPageComponents({locale:eM(e.req,"locale"),page:eB,query:n,params:{},isAppPath:!0,shouldEnsure:!0,url:e.req.url})),!i&&await this.hasPage("/404")&&(i=await this.findPageComponents({locale:eM(e.req,"locale"),page:"/404",query:n,params:{},isAppPath:!1,shouldEnsure:!0,url:e.req.url})));let o=`/${r.statusCode}`;if(!eM(e.req,"customErrorRender")&&!i&&eJ.includes(o)&&("/500"!==o||!this.dev)&&(!i&&a&&(i=await this.findPageComponents({locale:eM(e.req,"locale"),page:o,query:n,params:{},isAppPath:!0,shouldEnsure:!0,url:e.req.url})),i=await this.findPageComponents({locale:eM(e.req,"locale"),page:o,query:n,params:{},isAppPath:!1,shouldEnsure:!0,url:e.req.url})),i||(i=await this.findPageComponents({locale:eM(e.req,"locale"),page:"/_error",query:n,params:{},isAppPath:!1,shouldEnsure:!0,url:e.req.url}),o="/_error"),!i){if(this.dev)return{body:rF.fromStatic(` +
missing required error components, refreshing...
+