"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getExamples=exports.getExternalExampleValue=void 0;const url_1=require("url"),utils_1=require("../utils"),ExternalExamplesCache={};function getExternalExampleValue(e,r){return r?(r in ExternalExamplesCache||(ExternalExamplesCache[r]=fetch(r).then((r=>r.text().then((t=>{if(!r.ok)return Promise.reject(new Error(t));if(!(0,utils_1.isJsonLike)(e))return t;try{return JSON.parse(t)}catch(e){return t}}))))),ExternalExamplesCache[r]):Promise.resolve(void 0)}function getExamples({parser:e,infoOrRef:r,mime:t,encoding:l}){let a;const{resolved:n}=e.deref(r),s=n.value,u=n.value,i=(0,utils_1.getValueFromMdParsedExtension)(n,"summary"),o=(0,utils_1.getValueFromMdParsedExtension)(n,"description");return n.externalValue&&(a=(0,url_1.resolve)(e.definitionUrl||"",n.externalValue)),{value:u,rawValue:s,externalValueUrl:a,summary:i,description:o,mime:t,encoding:l}}exports.getExternalExampleValue=getExternalExampleValue,exports.getExamples=getExamples;
//# sourceMappingURL=example.js.map