import{join as o}from"node:path";import t from"node:process";import{d as i}from"../../../_virtual/index6.mjs";import{ConfigurationError as e}from"./utils/errors.mjs";import{augmentConfigFull as n}from"./augmentConfig.mjs";const r="test"===t.env.NODE_ENV?t.cwd():void 0;async function s({stylelint:t,searchPath:s=t._options.cwd,filePath:a,failIfNoConfig:f=!0}){const c=t._options.config,p=t._options.cwd;if(c){const i=a??"",e=t._specifiedConfigCache.get(c)??new Map,r=e.get(i);if(r)return r;const s=await n(t,a,{config:c,filepath:o(p,"argument-config")});return e.set(i,s),t._specifiedConfigCache.set(c,e),s}const m=i.cosmiconfig("stylelint",{transform:o=>n(t,a,o),stopDir:r,searchStrategy:"global"}),g=t._options.configFile;let l=g?await m.load(g):await m.search(s);if(l||(l=await m.search(p)),!l&&f)throw new e("No configuration provided"+(s?` for ${s}`:""));return l}export{s as default};