import a from"node:path";import{createConfig as g}from"@redocly/openapi-core";import{ruleTypes as l}from"@redocly/config";import{deepMerge as u}from"../../../../utils/object/deep-merge.js";import{CONFIG_FILE_NAME as m}from"../../../../constants/common.js";import{getScorecardConfig as p}from"../get-scorecard-config.js";async function E(t,n){const o=await n.getConfig(),e=p(o),r=e.levels??[],i=a.join(n.fs.cwd,m),s=await c(r,o.plugins,i),f=await d(e.targets,r,o.plugins,i);return{levelsConfig:r,configs:s,targets:f}}async function c(t,n=[],o){const e={};for(const r of t)e[r.name]=await g({...r,plugins:n},{configPath:o});return e}async function d(t,n,o=[],e){return t?Promise.all(t?.filter(r=>!!r.rules).map(async r=>{const i=n.map(s=>({...s,...C(s,r.rules)}));return{...r,configs:await c(i,o,e)}})||[]):[]}function C(t,n){return l.reduce((o,e)=>(o[e]=u(t[e]??{},n??{}),o),{})}export{E as scorecardConfigLoader};
