import f from"node:path";import{bundle as m,createConfig as d,Source as l}from"@redocly/openapi-core";import{ExternalResolver as u}from"../../../../fs/utils/external-ref-resolver.js";async function h({schemaOrRef:e,filePath:n,fs:c}){if(typeof e!="object"||!e)return;const a={config:await d({}),base:f.dirname(n),doc:{source:new l(n,""),parsed:JSON.parse(JSON.stringify({openapi:"3.1.0",components:{schemas:{__root:e}}}))},externalRefResolver:new u(c)},{bundle:{parsed:p},problems:i}=await m(a),s=p,o=s?.components?.schemas,r=o?.__root?.$ref,t=typeof r=="string"?r.split("/").at(-1):void 0;return{schema:t?o?.[t]:o?.__root,problems:i,oas:s}}export{h as dereferenceJsonSchemaRefs};
