import s from"picomatch";import{minimatch as f}from"minimatch";import u from"is-glob";import c from"path";import{removeTrailingSlash as a}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as m}from"../../utils/url/remove-leading-slash.js";const p=(t,r)=>{const n=t.tokens??[],o=r.tokens??[];if(t.isGlob!==r.isGlob)return t.isGlob?r:t;if(n.length!==o.length)return n.length>o.length?t:r;for(let e=0;e<n.length;e++){if(n[e].isGlob!==o[e].isGlob)return n[e].isGlob?r:t;if(n[e].value!==o[e].value)return n[e].value.length>o[e].value.length?t:r}return t};function h(t,r){if(u(r)){if(f(t,r))return!0}else{const n=a(m(c.posix.normalize(r))),o=t.startsWith(n+"/");if(t===n||o)return!0}return!1}function x(t,r){let n={},o={};if(!r)return n;for(const[e,i]of Object.entries(r))h(t,e)&&(o[e]=i);if(Object.keys(o).length){const e=Object.keys(o).map(i=>s.scan(i,{tokens:!0,parts:!0}));if(e.length){let i=e[0];for(const l of e)i=p(i,l);n=o[i.input]}}return n}function P(t){const r=s.makeRe(t);return r||void 0}export{P as convertGlobToRegex,p as getDeeperGlobPattern,h as pathMatchesGlobPattern,x as resolveMetadataGlobs};
