"use strict";var __awaiter=this&&this.__awaiter||function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function d(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(d,u)}c((r=r.apply(e,n||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.fixSpec=fixSpec,exports.loadSingle=loadSingle,exports.loadAndBundleSpecOrMd=loadAndBundleSpecOrMd,exports.useDeepCompareMemoize=useDeepCompareMemoize,exports.getMarkdownHeaderId=getMarkdownHeaderId;const react_1=require("react"),fast_deep_equal_1=__importDefault(require("fast-deep-equal")),loadAndBundleSpec_1=require("../../utils/loadAndBundleSpec"),string_1=require("../../utils/string");function fixSpec(e){const n=e.components&&e.components.securitySchemes||{};for(const e of Object.keys(n)){const t=n[e];t["x-type"]&&(t.type=t["x-type"]),t["x-scheme"]&&(t.scheme=t["x-scheme"])}}function loadSingle(e,n,t){return __awaiter(this,void 0,void 0,(function*(){let r;if(null==t?void 0:t.skipBundle){if(!e)throw new Error('spec must be specified when using "skipBundleAndConvert"');r=e}else r=yield(0,loadAndBundleSpec_1.loadAndBundleDefinition)(e||n);try{fixSpec(r)}catch(e){}return r}))}function loadAndBundleSpecOrMd(e,n){return e.endsWith(".md")?(0,loadAndBundleSpec_1.loadAndBundleDefinition)({openapi:"3.0.0",info:{title:n||"",version:"1.0",description:{$ref:e}},paths:{}}):(0,loadAndBundleSpec_1.loadAndBundleDefinition)(e)}function useDeepCompareMemoize(e){const n=(0,react_1.useRef)(null),t=(0,react_1.useRef)(0);return(0,fast_deep_equal_1.default)(e,n.current)||(n.current=e,t.current+=1),[t.current]}function getMarkdownHeaderId(e){return"string"==typeof e[0]?`section/${(0,string_1.safeSlugify)(e[0])}`:e.children?getMarkdownHeaderId(e[0]):void 0}
//# sourceMappingURL=utils.js.map