import{_ as e,k as t}from"./cookie-serialize-CgV1qMZJ.js";import{o as n}from"./request-pipeline-C54Q0Rq0.js";import{$ as r,a as i,c as a,s as o}from"./implicit-tags-BJP8ZwY0.js";import{n as s,t as c}from"./isr-decision-Ur15yHLm.js";function l(e){let t=e.indexOf(`=`);if(t<=0)return null;let n=e.indexOf(`;`),r=n===-1?t:Math.min(t,n);return e.slice(0,r)}var u=`NextResponse.rewrite() was used in a app route handler, this is not currently supported. Please remove the invocation to continue.`,d=`NextResponse.next() was used in a app route handler, this is not supported. See here for more info: https://nextjs.org/docs/messages/next-response-next-in-app-route-handler`;function f(e){for(let t of e.keys())if(t.startsWith(`x-middleware-`))return!0;return!1}function p(e,t,n={}){let r=n.appendResponseLink?e.headers.get(`link`):null;if(!t.headers&&t.status==null)return i(e.headers,r),e;let o=new Headers(e.headers);a(o,t.headers),r&&t.headers?.get(`link`)&&o.append(`link`,r);let s=new Response(e.body,{status:t.status??e.status,statusText:e.statusText,headers:o});return i(s.headers,r),s}function m(e){if(e.headers.has(`x-middleware-rewrite`))throw Error(u);if(e.headers.get(`x-middleware-next`)===`1`)throw Error(d)}function h(n,i){let a=new Headers;for(let[e,t]of Object.entries(n.headers))if(Array.isArray(t))for(let n of t)a.append(e,n);else a.set(e,t);a.delete(e),a.delete(t),o(a,i.cacheState);let{cacheControl:c}=s({cacheState:i.cacheState,kind:`app-route`,revalidateSeconds:i.revalidateSeconds,expireSeconds:i.expireSeconds,cacheControlMeta:i.cacheControl});return r(a,{cacheControl:c}),new Response(i.isHead?null:n.body,{status:n.status,headers:a})}function g(e,t,n,i){r(e.headers,{cacheControl:c(t,n),tags:i})}function _(e){o(e.headers,`MISS`)}function v(e,t){let n=t.toLowerCase(),r=e.indexOf(`;`);for(;r!==-1;){let t=r+1;for(;t<e.length&&e[t]===` `;)t++;let i=e.indexOf(`;`,t),a=i===-1?e.length:i,o=e.indexOf(`=`,t),s=o===-1||o>a?a:o;if(e.slice(t,s).trim().toLowerCase()===n)return!0;r=i}return!1}function y(e){return v(e,`Path`)?e:`${e.replace(/;\s*$/,``)}; Path=/`}function b(e,t){if(t.length===0)return;let n=e.getSetCookie(),r=new Set;for(let e of n){let t=l(e);t&&r.add(t)}let i=new Map,a=[];for(let e of t){let t=l(e);if(!t){a.push(e);continue}r.has(t)||i.set(t,e)}e.delete(`Set-Cookie`);for(let t of a)e.append(`Set-Cookie`,t);for(let t of i.values())e.append(`Set-Cookie`,t);for(let t of n)e.append(`Set-Cookie`,y(t))}async function x(e){let t=await e.arrayBuffer(),n={};e.headers.forEach((e,t)=>{t===`set-cookie`||t===`connection`||t===`content-length`||t===`date`||t===`keep-alive`||t===`transfer-encoding`||t===`x-next-cache-tags`||t===`x-vinext-metadata-route-cache`||t===`x-vinext-prerender-cache-life`||t===`x-vinext-cache`||t===`x-nextjs-cache`||t===`cache-control`||t.startsWith(`x-middleware-`)||(n[t]=e)});let r=e.headers.getSetCookie?.()??[];return r.length>0&&(n[`set-cookie`]=r),{kind:`APP_ROUTE`,body:t,status:e.status,headers:n}}function S(e,t){let{pendingCookies:r,draftCookie:i,isHead:a}=t;if(r.length===0&&!i&&!a&&!f(e.headers))return e;let o=new Headers(e.headers);return n(o),b(o,r),i&&o.append(`Set-Cookie`,i),new Response(a?null:e.body,{status:e.status,statusText:e.statusText,headers:o})}export{h as a,x as i,g as n,S as o,m as r,_ as s,p as t};