/**
 * Obscured admin UI path for hardened admin-only builds.
 * Keep in sync with `deploy/nginx-admin-host-8080.conf` on ark-library-backend-admin-1.
 */
export const ADMIN_UI_SECRET_PREFIX =
  "/2d7ccf8f4c9af0aaf5c0ef72ddc3f7dca90f44b53df9fd73d7f3ddf82d8b6d3d";

export const adminOnlyBuild = import.meta.env.VITE_ADMIN_ONLY === "true";

/** Base path for admin UI (no trailing slash). */
function resolveAdminUiPrefix(): string {
  const raw = import.meta.env.VITE_ADMIN_UI_PREFIX;
  if (typeof raw === "string" && raw.trim() !== "") {
    const v = raw.replace(/\/+$/, "");
    return v.startsWith("/") ? v : `/${v}`;
  }
  if (adminOnlyBuild) return ADMIN_UI_SECRET_PREFIX;
  return "/admin";
}

export const adminUiPrefix = resolveAdminUiPrefix();
