import{existsSync as t}from"node:fs";import{resolve as o}from"node:path";import r from"./dynamicImport.mjs";import e from"../formatters/index.mjs";import m from"./getFormatterOptionsText.mjs";import i from"./resolveOptionValue.mjs";async function n(n){let a=await i({stylelint:n,name:"formatter"});if("string"==typeof a){let i=e[a];if(void 0===i){if(!t(a)){const t=m(", ",'"');throw new Error(`You must use a valid formatter option: ${t} or a function`)}i=await r(o(a)).then(t=>t.default)}return i}return"function"==typeof a||a?Promise.resolve(a):(a??=n._options._defaultFormatter??"json",e[a])}export{n as default};