"use strict";
(() => {
const container = document.getElementById("redoc-container");
if (!container) return;
function fail(error) {
const message = document.createElement("p");
message.setAttribute("role", "alert");
message.textContent = "Unable to load API documentation.";
container.replaceChildren(message);
container.setAttribute("aria-busy", "false");
console.error("ReDoc initialization failed", error);
}
async function initialize() {
const response = await fetch(new URL(container.dataset.optionsUrl, document.baseURI), {
credentials: "same-origin",
});
if (!response.ok) throw new Error(`Options request failed: ${response.status}`);
const options = await response.json();
if (typeof window.Redoc?.init !== "function") throw new Error("ReDoc bundle is unavailable");
const specUrl = new URL(container.dataset.specUrl, document.baseURI).href;
window.Redoc.init(specUrl, options, container, (error) => {
if (error) fail(error);
else container.setAttribute("aria-busy", "false");
});
}
initialize().catch(fail);
})();