import{__exports as t}from"../../../../../_virtual/entry.mjs";import{__require as e}from"../../utils/index.mjs";var i;function r(){if(i)return t;i=1,Object.defineProperty(t,"__esModule",{value:!0});const r=e();return t.default=class{constructor(t,e){this._settings=t,this._micromatchOptions=e,this.index=new Map}getFilter(t,e){const[i,s]=r.pattern.partitionAbsoluteAndRelative(e),n={positive:{all:r.pattern.convertPatternsToRe(t,this._micromatchOptions)},negative:{absolute:r.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:r.pattern.convertPatternsToRe(s,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return t=>this._filter(t,n)}_filter(t,e){const i=r.path.removeLeadingDotSegment(t.path);if(this._settings.unique&&this._isDuplicateEntry(i))return!1;if(this._onlyFileFilter(t)||this._onlyDirectoryFilter(t))return!1;const s=this._isMatchToPatternsSet(i,e,t.dirent.isDirectory());return this._settings.unique&&s&&this._createIndexRecord(i),s}_isDuplicateEntry(t){return this.index.has(t)}_createIndexRecord(t){this.index.set(t,void 0)}_onlyFileFilter(t){return this._settings.onlyFiles&&!t.dirent.isFile()}_onlyDirectoryFilter(t){return this._settings.onlyDirectories&&!t.dirent.isDirectory()}_isMatchToPatternsSet(t,e,i){if(!this._isMatchToPatterns(t,e.positive.all,i))return!1;if(this._isMatchToPatterns(t,e.negative.relative,i))return!1;return!this._isMatchToAbsoluteNegative(t,e.negative.absolute,i)}_isMatchToAbsoluteNegative(t,e,i){if(0===e.length)return!1;const s=r.path.makeAbsolute(this._settings.cwd,t);return this._isMatchToPatterns(s,e,i)}_isMatchToPatterns(t,e,i){if(0===e.length)return!1;const s=r.pattern.matchAny(t,e);return!s&&i?r.pattern.matchAny(t+"/",e):s}},t}export{r as __require};