/**
 * Server-rendered HTML pages for the OAuth tier (key-binding, consent,
 * approval flows). Extracted from {@link ../../actions.ts} so the design-system
 * validator can scope `<!doctype html>` rendering to one well-known module.
 *
 * The OAuth pages share the canonical bundled-page palette ({@link
 * ../bundled_pages/tokens.ts}) and shell ({@link
 * ../bundled_pages/html_shell.ts}) — code coupling, not comment coupling.
 *
 * The amber `.notice` callout (sandbox advisories, developer warnings) is now
 * sourced from the canonical `notice_*` token family in `BUNDLED_PAGE_PALETTE`.
 * It mirrors the React `Banner` component's `warning` variant so server-rendered
 * and client-rendered surfaces stay visually aligned.
 */
import { BUNDLED_PAGE_PALETTE as P } from "../bundled_pages/tokens.js";
import { renderBundledPageShell } from "../bundled_pages/html_shell.js";
function escapeHtml(value) {
    return value
        .replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&#39;");
}
const OAUTH_EXTRA_HEAD = [
    `<link rel="preconnect" href="https://fonts.googleapis.com">`,
    `<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>`,
    `<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400&display=swap" rel="stylesheet">`,
].join("\n    ");
const OAUTH_EXTRA_STYLES = `
:root {
  color-scheme: light dark;
  --background: ${P.background.light.hsl};
  --foreground: ${P.foreground.light.hsl};
  --card: ${P.card.light.hsl};
  --card-foreground: ${P.card_foreground.light.hsl};
  --primary: ${P.primary.light.hsl};
  --primary-foreground: ${P.primary_foreground.light.hsl};
  --muted: ${P.muted.light.hsl};
  --muted-foreground: ${P.muted_foreground.light.hsl};
  --border: ${P.border.light.hsl};
  --input: ${P.input.light.hsl};
  --ring: ${P.ring.light.hsl};
  --radius: 0.5rem;
}
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  line-height: 1.6;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}
.wrap {
  max-width: 860px;
  margin: 48px auto;
  padding: 0 16px;
}
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(52, 35, 26, 0.08);
  padding: 24px;
}
h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 0 0 20px;
  color: hsl(var(--muted-foreground));
  font-size: 15px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tab-btn {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.tab-btn.active {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
.row {
  margin-bottom: 12px;
}
label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}
input, textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
textarea {
  min-height: 96px;
  resize: vertical;
}
input:focus-visible, textarea:focus-visible, .tab-btn:focus-visible, button:focus-visible, .btn-link:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 1px;
}
.help {
  margin: 6px 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}
/* Amber notice - sourced from the canonical notice_* token family.
 * Mirrors the React Banner component warning variant. */
.notice {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid hsl(${P.notice_border.light.hsl});
  background: hsl(${P.notice_background.light.hsl});
  color: hsl(${P.notice_foreground.light.hsl});
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
}
.actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
button, .btn-link {
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  text-decoration: none;
}
.btn-link.secondary {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
code {
  font-family: "JetBrains Mono", "Fira Code", "Roboto Mono", "Courier New", monospace;
  font-size: 0.8125rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: ${P.background.dark.hsl};
    --foreground: ${P.foreground.dark.hsl};
    --card: ${P.card.dark.hsl};
    --card-foreground: ${P.card_foreground.dark.hsl};
    --primary: ${P.primary.dark.hsl};
    --primary-foreground: ${P.primary_foreground.dark.hsl};
    --muted: ${P.muted.dark.hsl};
    --muted-foreground: ${P.muted_foreground.dark.hsl};
    --border: ${P.border.dark.hsl};
    --input: ${P.input.dark.hsl};
    --ring: ${P.ring.dark.hsl};
  }
  body {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
  }
  .card {
    background: hsl(var(--card));
    border-color: hsl(var(--border));
    box-shadow: none;
  }
  /* Dark-mode amber notice — sourced from canonical notice_* tokens. */
  .notice {
    border-color: hsl(${P.notice_border.dark.hsl});
    background: hsl(${P.notice_background.dark.hsl});
    color: hsl(${P.notice_foreground.dark.hsl});
  }
}
`;
/**
 * Render a complete OAuth-tier HTML page (key-binding, consent, approval).
 * Body is wrapped in `<div class="wrap"><div class="card">…</div></div>`; the
 * `<head>` and base styles come from {@link renderBundledPageShell}.
 */
export function renderOauthPage(params) {
    const subtitle = params.subtitle
        ? `<p class="subtitle">${escapeHtml(params.subtitle)}</p>`
        : "";
    const body = `<div class="wrap">
  <div class="card">
    <h1>${escapeHtml(params.title)}</h1>
    ${subtitle}
    ${params.contentHtml}
  </div>
</div>`;
    return renderBundledPageShell({
        title: params.title,
        // OAuth flows are user-private surfaces — never index.
        robots: "noindex, nofollow",
        extraHead: OAUTH_EXTRA_HEAD,
        extraStyles: OAUTH_EXTRA_STYLES,
        // The OAuth styles install their own scoped CSS variables (`--background`,
        // `--foreground`, `--card`, etc.); skip the shell's canonical-token expose
        // to keep the inlined CSS minimal and avoid double-defining variables.
        tokensToExpose: [],
    }, body);
}
//# sourceMappingURL=render.js.map