import{B as e,O as t,c as n,d as r}from"./cookie-serialize-CgV1qMZJ.js";import{n as i,r as a}from"./http-error-responses-DkXnydOV.js";import{r as o}from"./base-path-7wmUKVfF.js";function s(e){if(!e.startsWith(`/`))return!1;let t=e.slice(1);if(t.startsWith(`/`)||t.startsWith(`\\`))return!0;if(t.length>=3&&t[0]===`%`){let e=t.slice(0,3).toLowerCase();if(e===`%5c`||e===`%2f`)return!0}return!1}new URL(`http://vinext.invalid/`);function c(e){return s(e)?a():null}var l=/\.[^/]+\/?$/;function u(e){return e===`/.well-known`||e.startsWith(`/.well-known/`)}function d(t,n){let r=new Headers({[e]:encodeURIComponent(t)});if(n.headers)for(let[e,t]of n.headers)r.append(e,t);return new Response(null,{status:n.status??200,headers:r})}function f(e){return e.pathname.endsWith(`.rsc`)||!e.publicFiles.has(e.cleanPathname)?null:e.request.method!==`GET`&&e.request.method!==`HEAD`?i(`GET, HEAD`,{headers:e.middlewareContext.headers??void 0}):d(e.cleanPathname,e.middlewareContext)}function p(e,t){if(e===`/`||e===`/api`||e.startsWith(`/api/`))return null;let n=e.endsWith(`/`);if(t){if(u(e))return null;if(l.test(e)){let t=o(e);return t===e?null:t}return!n&&!e.endsWith(`.rsc`)?`${e}/`:null}return n?o(e):null}function m(e,t,n,r){if(e===`/`||e===`/api`||e.startsWith(`/api/`))return null;if(s(e))return a();let i=p(e,n);if(i===null)return null;let o=i.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@/%]/gu,encodeURIComponent);return new Response(null,{status:308,headers:{Location:t+o+r}})}function h(e){let t=[],r=n(e);for(let n of e.keys())n.startsWith(`x-middleware-`)&&n!==`x-middleware-cache`&&!r.has(n)&&t.push(n);for(let n of t)e.delete(n)}var g=new Set([...r,...t]);function _(e){let t=new Headers;for(let[n,r]of e)g.has(n.toLowerCase())||t.append(n,r);return t}function v(e){let t=Reflect.get(e,`cf`);return t===void 0?void 0:t}function y(e,t){let n=v(t);return n!==void 0&&Object.defineProperty(e,`cf`,{value:n,enumerable:!0,configurable:!0}),e}function b(e,t){let n;try{n=new Request(e,{headers:t})}catch{let r={method:e.method,headers:t,body:e.body??void 0,redirect:e.redirect,signal:e.signal,integrity:e.integrity,cache:e.cache,mode:e.mode,credentials:e.credentials,keepalive:e.body===null&&e.keepalive,referrer:e.referrer,referrerPolicy:e.referrerPolicy};e.body&&(r.duplex=`half`),n=new Request(e.url,r)}return y(n,e)}function x(e,t){let n;try{n=new Request(t,e)}catch{let r={method:e.method,headers:e.headers,body:e.body??void 0,redirect:e.redirect,signal:e.signal,integrity:e.integrity,cache:e.cache,mode:e.mode,credentials:e.credentials,keepalive:e.body===null&&e.keepalive,referrer:e.referrer,referrerPolicy:e.referrerPolicy};e.body&&(r.duplex=`half`),n=new Request(t,r)}return y(n,e)}export{m as a,s as c,c as i,x as n,h as o,_ as r,f as s,b as t};