"use strict";exports.__esModule=true;exports.pathToRegexp=exports.default=exports.customRouteMatcherOptions=exports.matcherOptions=void 0;var pathToRegexp=_interopRequireWildcard(require("next/dist/compiled/path-to-regexp"));exports.pathToRegexp=pathToRegexp;function _getRequireWildcardCache(){if(typeof WeakMap!=="function")return null;var cache=new WeakMap();_getRequireWildcardCache=function(){return cache;};return cache;}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache();if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}const matcherOptions={sensitive:false,delimiter:'/'};exports.matcherOptions=matcherOptions;const customRouteMatcherOptions={...matcherOptions,strict:true};exports.customRouteMatcherOptions=customRouteMatcherOptions;var _default=(customRoute=false)=>{return path=>{const keys=[];const matcherRegex=pathToRegexp.pathToRegexp(path,keys,customRoute?customRouteMatcherOptions:matcherOptions);const matcher=pathToRegexp.regexpToFunction(matcherRegex,keys);return(pathname,params)=>{const res=pathname==null?false:matcher(pathname);if(!res){return false;}if(customRoute){for(const key of keys){// unnamed params should be removed as they
// are not allowed to be used in the destination
if(typeof key.name==='number'){delete res.params[key.name];}}}return{...params,...res.params};};};};exports.default=_default;
//# sourceMappingURL=path-match.js.map