import{__exports as e}from"../../../../../../../_virtual/prepare-destination.js_commonjs-exports";import"./querystring.js";import"./parse-relative-url.js";import"../../../../compiled/path-to-regexp/index.js";import{__exports as t}from"../../../../../../../_virtual/index2.js_commonjs-exports";import{__exports as r}from"../../../../../../../_virtual/querystring.js_commonjs-exports";import{__exports as a}from"../../../../../../../_virtual/parse-relative-url.js_commonjs-exports";e.__esModule=!0,e.matchHas=function(e,t,r){const a={};if(t.every((t=>{let o,s=t.key;switch(t.type){case"header":s=s.toLowerCase(),o=e.headers[s];break;case"cookie":o=e.cookies[t.key];break;case"query":o=r[s];break;case"host":{const{host:t}=(null==e?void 0:e.headers)||{};o=null==t?void 0:t.split(":")[0].toLowerCase();break}}if(!t.value&&o)return a[i(s)]=o,!0;if(o){const e=new RegExp(`^${t.value}$`),r=o.match(e);if(r)return r.groups?Object.keys(r.groups).forEach((e=>{a[e]=r.groups[e]})):"host"===t.type&&r[0]&&(a.host=r[0]),!0}return!1})))return a;return!1},e.compileNonPath=p,e.default=function(e,t,r,a){let c={};const i=(r=Object.assign({},r)).__nextLocale;if(delete r.__nextLocale,delete r.__nextDefaultLocale,e.startsWith("/"))c=(0,s.parseRelativeUrl)(e);else{const{pathname:t,searchParams:r,hash:a,hostname:s,port:n,protocol:i,search:p,href:l}=new URL(e);c={pathname:t,query:(0,o.searchParamsToUrlQuery)(r),hash:a,protocol:i,hostname:s,port:n,search:p,href:l}}const l=c.query,u=`${c.pathname}${c.hash||""}`,h=[];n.pathToRegexp(u,h);const f=h.map((e=>e.name));let m,_=n.compile(u,{validate:!1});for(const[e,r]of Object.entries(l)){let a=Array.isArray(r)?r[0]:r;a&&(a=p(a,t)),l[e]=a}let d=Object.keys(t);i&&(d=d.filter((e=>"nextInternalLocale"!==e)));if(a&&!d.some((e=>f.includes(e))))for(const e of d)e in l||(l[e]=t[e]);try{m=_(t);const[e,r]=m.split("#");c.pathname=e,c.hash=`${r?"#":""}${r||""}`,delete c.search}catch(e){if(e.message.match(/Expected .*? to not repeat, but got an array/))throw new 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 c.query={...r,...c.query},{newUrl:m,parsedDestination:c}},e.getSafeParamName=void 0;var o=r,s=a,n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var s=a?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(t);function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}const i=e=>{let t="";for(let r=0;r<e.length;r++){const a=e.charCodeAt(r);(a>64&&a<91||a>96&&a<123)&&(t+=e[r])}return t};function p(e,t){if(!e.includes(":"))return e;for(const r of Object.keys(t))e.includes(`:${r}`)&&(e=e.replace(new RegExp(`:${r}\\*`,"g"),`:${r}--ESCAPED_PARAM_ASTERISKS`).replace(new RegExp(`:${r}\\?`,"g"),`:${r}--ESCAPED_PARAM_QUESTION`).replace(new RegExp(`:${r}\\+`,"g"),`:${r}--ESCAPED_PARAM_PLUS`).replace(new 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,"*"),n.compile(`/${e}`,{validate:!1})(t).substr(1)}e.getSafeParamName=i;
//# sourceMappingURL=prepare-destination.js.map
