globalThis.process ??= {}; globalThis.process.env ??= {};
import { f as fetchApiIndex } from '../../../../../chunks/fetch_CoXtH9RF.mjs';
import { c as createJsonResponse, a as createIndexKey } from '../../../../../chunks/apiHelpers_CD8DANYs.mjs';
export { r as renderers } from '../../../../../chunks/_@astro-renderers_DcHY5gmj.mjs';

const prerender = false;
const GET = async ({ params, redirect, url }) => {
  const { version, section, page, tab } = params;
  if (!version || !section || !page || !tab) {
    return createJsonResponse(
      { error: "Version, section, page, and tab parameters are required" },
      400
    );
  }
  const index = await fetchApiIndex(url);
  if (!index.versions.includes(version)) {
    return createJsonResponse({ error: `Version '${version}' not found` }, 404);
  }
  const sections = index.sections[version] || [];
  if (!sections.includes(section)) {
    return createJsonResponse(
      { error: `Section '${section}' not found for version '${version}'` },
      404
    );
  }
  const sectionKey = createIndexKey(version, section);
  const pageKey = createIndexKey(version, section, page);
  if (!index.pages[sectionKey]?.includes(page)) {
    return createJsonResponse(
      {
        error: `Page '${page}' not found in section '${section}' for version '${version}'`
      },
      404
    );
  }
  if (!index.tabs[pageKey]?.includes(tab)) {
    return createJsonResponse(
      {
        error: `Tab '${tab}' not found for page '${page}' in section '${section}' for version '${version}'`
      },
      404
    );
  }
  return redirect(`${url.pathname}/text`);
};

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  GET,
  prerender
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
