---
title: "Documentation Technical · UI SDK — StyleX Blocks"
description: "Sequential technical quickstart guide featuring breadcrumb navigation, an AI setup prompt card, prerequisites and troubleshooting callouts, synced package-manager and runtime code switchers, checkable step completion progress, onward reading cards, and a responsive sticky table-of-contents rail."
url: "https://stylexblocks.com/block/ui-sdk/documentation-technical/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Documentation Technical block

Sequential technical quickstart guide featuring breadcrumb navigation, an AI setup prompt card, prerequisites and troubleshooting callouts, synced package-manager and runtime code switchers, checkable step completion progress, onward reading cards, and a responsive sticky table-of-contents rail.

- Behavior engine: UI SDK
- Category: [Content](https://stylexblocks.com/blocks/content.md)
- Built with: [Alert](https://stylexblocks.com/components/ui-sdk/alert.md), [Badge](https://stylexblocks.com/components/ui-sdk/badge.md), [Breadcrumb](https://stylexblocks.com/components/ui-sdk/breadcrumb.md), [Button](https://stylexblocks.com/components/ui-sdk/button.md), [Card](https://stylexblocks.com/components/ui-sdk/card.md), [Center](https://stylexblocks.com/components/ui-sdk/center.md), [Checkbox](https://stylexblocks.com/components/ui-sdk/checkbox.md), [Code](https://stylexblocks.com/components/ui-sdk/code.md), [Code Block](https://stylexblocks.com/components/ui-sdk/code-block.md), [Grid](https://stylexblocks.com/components/ui-sdk/grid.md), [Heading](https://stylexblocks.com/components/ui-sdk/heading.md), [Icon](https://stylexblocks.com/components/ui-sdk/icon.md), [Icon Badge](https://stylexblocks.com/components/ui-sdk/icon-badge.md), [Icon Button](https://stylexblocks.com/components/ui-sdk/icon-button.md), [Link](https://stylexblocks.com/components/ui-sdk/link.md), [List](https://stylexblocks.com/components/ui-sdk/list.md), [Menu](https://stylexblocks.com/components/ui-sdk/menu.md), [Progress](https://stylexblocks.com/components/ui-sdk/progress.md), [Separator](https://stylexblocks.com/components/ui-sdk/separator.md), [Stack](https://stylexblocks.com/components/ui-sdk/stack.md), [Tabs](https://stylexblocks.com/components/ui-sdk/tabs.md), [Text](https://stylexblocks.com/components/ui-sdk/text.md), [Toast](https://stylexblocks.com/components/ui-sdk/toast.md), [Table of Contents](https://stylexblocks.com/components/ui-sdk/toc.md)
- HTML page: https://stylexblocks.com/block/ui-sdk/documentation-technical/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add documentation-technical
```

Equivalent: `npx shadcn add @stylexblocks/documentation-technical`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/documentation-technical.json

## Usage

```tsx
import { DocumentationTechnical } from "#components/blocks/ui-sdk/documentation-technical.tsx";

export function Example() {
  return (
    <div style={{ minHeight: "100dvh" }}>
      <DocumentationTechnical />
    </div>
  );
}
```

## Source

`components/blocks/ui-sdk/documentation-technical.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { useCallback, useMemo, useState } from "react";
import { Alert } from "#components/ui/ui-sdk/alert.tsx";
import { Badge } from "#components/ui/ui-sdk/badge.tsx";
import { Breadcrumb } from "#components/ui/ui-sdk/breadcrumb.tsx";
import { Button } from "#components/ui/ui-sdk/button.tsx";
import { Card } from "#components/ui/ui-sdk/card.tsx";
import { Circle } from "#components/ui/ui-sdk/center.tsx";
import { Checkbox } from "#components/ui/ui-sdk/checkbox.tsx";
import { Code } from "#components/ui/ui-sdk/code.tsx";
import { CodeBlock } from "#components/ui/ui-sdk/code-block.tsx";
import { Grid } from "#components/ui/ui-sdk/grid.tsx";
import { Heading } from "#components/ui/ui-sdk/heading.tsx";
import { Icon } from "#components/ui/ui-sdk/icon.tsx";
import { IconBadge } from "#components/ui/ui-sdk/icon-badge.tsx";
import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";
import { Link } from "#components/ui/ui-sdk/link.tsx";
import { List } from "#components/ui/ui-sdk/list.tsx";
import { Menu } from "#components/ui/ui-sdk/menu.tsx";
import { Progress } from "#components/ui/ui-sdk/progress.tsx";
import { Separator } from "#components/ui/ui-sdk/separator.tsx";
import { HStack, Stack, VStack } from "#components/ui/ui-sdk/stack.tsx";
import { Tabs } from "#components/ui/ui-sdk/tabs.tsx";
import { Text } from "#components/ui/ui-sdk/text.tsx";
import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";
import { Toc, type TocItemData } from "#components/ui/ui-sdk/toc.tsx";
import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";
import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";
import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";
import {
  accentPalette,
  amberPalette,
  bluePalette,
  emeraldPalette,
} from "@stylexblocks/ui/themes/palettes.ts";
import { durations } from "@stylexblocks/ui/tokens/durations.stylex.ts";
import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";
import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";
import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";
import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";
import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";
import { sizes } from "@stylexblocks/ui/tokens/sizes.stylex.ts";
import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";

// ---------------------------------------------------------------------------
// Container breakpoints
// ---------------------------------------------------------------------------

const NARROW = "@container documentation-technical (max-width: 900px)";
const COMPACT = "@container documentation-technical (max-width: 600px)";

// ---------------------------------------------------------------------------
// Types
// ---------------------------------------------------------------------------

export type PackageManager = "bun" | "pnpm" | "npm";

export type RuntimeTarget = "edge" | "express" | "cli";

export interface GuideNextStep {
  id: string;
  title: string;
  description: string;
  readTime: string;
  href: string;
  icon: "key" | "repeat" | "shield" | "activity";
}

export interface DocumentationTechnicalProps extends StyleOverrideProps {
  /** Guide headline rendered as the page `<h1>`. */
  title?: string;
  /** Introductory summary shown beneath the title. */
  subtitle?: string;
  /** Product / CLI version badge shown in the header metadata. */
  version?: string;
  /** Last updated date label shown in the header metadata. */
  updatedAt?: string;
  /** Initial package manager tab selection. */
  defaultPackageManager?: PackageManager;
  /** Step IDs pre-marked as completed on mount. */
  defaultCompletedSteps?: readonly string[];
  /** Onward reading cards shown in the "Next steps" section. */
  nextSteps?: readonly GuideNextStep[];
  /** Called when a user selects one of the onward next-step cards. */
  onNavigateNextStep?: (step: GuideNextStep) => void;
}

// ---------------------------------------------------------------------------
// Demo data — Deploying Signed Edge Webhooks with Kestrel CLI
// ---------------------------------------------------------------------------

const STEP_IDS = [
  "step-1-install",
  "step-2-secret",
  "step-3-verify",
  "step-4-replay",
  "step-5-promote",
] as const;

type StepId = (typeof STEP_IDS)[number];

interface OutlineEntry {
  id: string;
  label: string;
  depth: number;
}

const OUTLINE_ENTRIES: readonly OutlineEntry[] = [
  { id: "prerequisites", label: "Prerequisites", depth: 2 },
  { id: "step-1-install", label: "1. Install CLI & Authenticate", depth: 2 },
  { id: "step-2-secret", label: "2. Initialize Signing Secret", depth: 2 },
  { id: "step-3-verify", label: "3. Verify Signatures", depth: 2 },
  { id: "step-4-replay", label: "4. Replay Events Locally", depth: 2 },
  { id: "step-5-promote", label: "5. Promote to Production", depth: 2 },
  { id: "troubleshooting", label: "Troubleshooting", depth: 2 },
  { id: "next-steps", label: "Next steps", depth: 2 },
];

const TOC_ITEMS: TocItemData[] = OUTLINE_ENTRIES.map((entry) => ({
  value: entry.id,
  depth: entry.depth,
}));

const AI_SETUP_PROMPT =
  "Help me deploy signed edge webhooks with Kestrel CLI. Based on my repository: 1. Install @kestrel/cli and @kestrel/webhooks. 2. Add a webhook endpoint at /api/webhooks/kestrel that reads raw request bytes and verifies the x-kestrel-signature header with HMAC-SHA256 and a 300-second replay tolerance. 3. Wire KESTREL_WEBHOOK_SECRET from environment variables and add a local test script using `kestrel webhooks listen`.";

const AI_DESTINATIONS = [
  { id: "claude", label: "Open in Claude" },
  { id: "chatgpt", label: "Open in ChatGPT" },
  { id: "cursor", label: "Open in Cursor" },
  { id: "v0", label: "Open in v0" },
] as const;

const INSTALL_SNIPPETS: Record<PackageManager, { filename: string; code: string }> = {
  bun: {
    filename: "terminal · bun",
    code: `# Install the Kestrel CLI and verification helper
bun add -g @kestrel/cli
bun add @kestrel/webhooks

# Authenticate with scoped webhook permissions
kestrel login --scope webhooks:write
kestrel whoami`,
  },
  pnpm: {
    filename: "terminal · pnpm",
    code: `# Install the Kestrel CLI and verification helper
pnpm add -g @kestrel/cli
pnpm add @kestrel/webhooks

# Authenticate with scoped webhook permissions
kestrel login --scope webhooks:write
kestrel whoami`,
  },
  npm: {
    filename: "terminal · npm",
    code: `# Install the Kestrel CLI and verification helper
npm install -g @kestrel/cli
npm install @kestrel/webhooks

# Authenticate with scoped webhook permissions
kestrel login --scope webhooks:write
kestrel whoami`,
  },
};

const SECRET_INIT_SNIPPETS: Record<PackageManager, string> = {
  bun: `# Provision a workspace signing secret and write it to .env.local
bunx kestrel webhooks init \\
  --endpoint /api/webhooks/kestrel \\
  --events invoice.paid,subscription.updated \\
  --env .env.local`,
  pnpm: `# Provision a workspace signing secret and write it to .env.local
pnpm dlx kestrel webhooks init \\
  --endpoint /api/webhooks/kestrel \\
  --events invoice.paid,subscription.updated \\
  --env .env.local`,
  npm: `# Provision a workspace signing secret and write it to .env.local
npx kestrel webhooks init \\
  --endpoint /api/webhooks/kestrel \\
  --events invoice.paid,subscription.updated \\
  --env .env.local`,
};

const ENV_OUTPUT_SNIPPET = `KESTREL_WEBHOOK_ENDPOINT="/api/webhooks/kestrel"
KESTREL_WEBHOOK_SECRET="whsec_dev_7f9a3e2c41b8d60e9c1b54a72e81f0c4"
KESTREL_TOLERANCE_SECONDS="300"`;

const VERIFY_SNIPPETS: Record<
  RuntimeTarget,
  { label: string; filename: string; code: string }
> = {
  edge: {
    label: "TypeScript (Edge)",
    filename: "src/routes/webhooks/kestrel.ts",
    code: `import { verifyWebhookSignature, WebhookError } from "@kestrel/webhooks";

export async function POST(request: Request, env: Env): Promise<Response> {
  // Always read the exact raw bytes before parsing JSON
  const rawBody = await request.text();
  const signature = request.headers.get("x-kestrel-signature");

  try {
    const event = await verifyWebhookSignature({
      payload: rawBody,
      signatureHeader: signature,
      secret: env.KESTREL_WEBHOOK_SECRET,
      toleranceSeconds: 300,
    });

    if (event.type === "invoice.paid") {
      await markInvoiceSettled(event.data.invoiceId, event.id);
    }

    return Response.json({ received: true, eventId: event.id });
  } catch (err) {
    if (err instanceof WebhookError) {
      return new Response(err.message, { status: 401 });
    }
    throw err;
  }
}`,
  },
  express: {
    label: "Node.js (Express)",
    filename: "src/server/webhooks.ts",
    code: `import express from "express";
import { verifyWebhookSignature, WebhookError } from "@kestrel/webhooks";

const router = express.Router();

// Mount express.raw() on this route so the raw Buffer stays intact
router.post(
  "/api/webhooks/kestrel",
  express.raw({ type: "application/json" }),
  async (req, res) => {
    try {
      const event = await verifyWebhookSignature({
        payload: req.body as Buffer,
        signatureHeader: req.header("x-kestrel-signature") ?? null,
        secret: process.env.KESTREL_WEBHOOK_SECRET!,
        toleranceSeconds: 300,
      });

      res.status(200).json({ received: true, eventId: event.id });
    } catch (err) {
      const status = err instanceof WebhookError ? 401 : 500;
      res.status(status).json({ error: (err as Error).message });
    }
  },
);

export default router;`,
  },
  cli: {
    label: "CLI Verify",
    filename: "terminal · ci check",
    code: `# Verify a recorded webhook fixture and header inside CI
kestrel webhooks verify \\
  --payload ./fixtures/invoice.paid.json \\
  --header "t=1764635400,v1=9e82f4a7c1d6b05e..." \\
  --secret "$KESTREL_WEBHOOK_SECRET" \\
  --tolerance 300`,
  },
};

const REPLAY_SNIPPET = `# Terminal 1 — open an authenticated local tunnel to your dev server
kestrel webhooks listen --forward http://localhost:8787/api/webhooks/kestrel

# Terminal 2 — emit a signed test event with a deterministic idempotency key
kestrel webhooks trigger invoice.paid \\
  --idempotency-key evt_test_01 \\
  --data '{"invoiceId":"inv_01j9x7","amountCents":4900}'`;

const PROMOTE_SNIPPET = `# Store the production signing key in the encrypted edge vault
kestrel secret set KESTREL_WEBHOOK_SECRET --stage prod

# Deploy the verified handler and switch the live endpoint pointer
kestrel deploy --stage prod --verify-webhooks

# Confirm live edge delivery health and p99 verification latency
kestrel webhooks status --stage prod`;

const DOCTOR_SNIPPET = `# Inspect raw-body handling, clock skew, and active secret versions
kestrel webhooks doctor --stage prod --trace-last 5`;

const DEFAULT_NEXT_STEPS: readonly GuideNextStep[] = [
  {
    id: "secret-rotation",
    title: "Zero-Downtime Secret Rotation",
    description:
      "Roll signing secrets with overlapping dual-key grace windows so in-flight deliveries never fail verification.",
    readTime: "5 min",
    href: "#next-secret-rotation",
    icon: "key",
  },
  {
    id: "idempotency-queues",
    title: "Idempotency & Replay Queues",
    description:
      "Deduplicate retried deliveries with event IDs and inspect or replay failed payloads from dead-letter storage.",
    readTime: "7 min",
    href: "#next-idempotency-queues",
    icon: "repeat",
  },
  {
    id: "edge-rate-limits",
    title: "Edge Rate Limits & IP Allowlists",
    description:
      "Combine HMAC-SHA256 verification with per-route token buckets and Kestrel egress CIDR pinning.",
    readTime: "6 min",
    href: "#next-edge-rate-limits",
    icon: "shield",
  },
  {
    id: "delivery-telemetry",
    title: "Webhook Delivery Telemetry",
    description:
      "Export OpenTelemetry spans, signature failure alerts, and regional p99 handler latency histograms.",
    readTime: "4 min",
    href: "#next-delivery-telemetry",
    icon: "activity",
  },
];

// ---------------------------------------------------------------------------
// Inline SVG Icons (zero external icon packages)
// ---------------------------------------------------------------------------

function CopyIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.65"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <rect x="7" y="7" width="9" height="9" rx="1.75" />
      <path d="M4 13V5.5A1.5 1.5 0 0 1 5.5 4H13" />
    </Icon>
  );
}

function CheckIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.9"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="m5 10.5 3.2 3.2L15.5 6.5" />
    </Icon>
  );
}

function SparklesIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.65"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="m10 2.75 1.55 4.45 4.45 1.55-4.45 1.55L10 14.75l-1.55-4.45L4 8.75 8.45 7.2 10 2.75Z" />
      <path d="M15.25 13.25v3M13.75 14.75h3" />
    </Icon>
  );
}

function ChevronDownIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.75"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="m5.5 7.75 4.5 4.5 4.5-4.5" />
    </Icon>
  );
}

function ChevronRightIcon() {
  return (
    <Icon
      size="xs"
      viewBox="0 0 16 16"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.75"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="m6 3.75 4.25 4.25L6 12.25" />
    </Icon>
  );
}

function InfoCircleIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.7"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="10" cy="10" r="7.5" />
      <path d="M10 9.25v4.25" />
      <path d="M10 6.5h.01" />
    </Icon>
  );
}

function WarningTriangleIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.7"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M8.85 3.65a1.3 1.3 0 0 1 2.3 0l6.1 11.2A1.3 1.3 0 0 1 16.1 16.75H3.9a1.3 1.3 0 0 1-1.15-1.9l6.1-11.2Z" />
      <path d="M10 8v3.5" />
      <path d="M10 14h.01" />
    </Icon>
  );
}

function ArrowRightIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.75"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M4.5 10h11" />
      <path d="M11 5.5 15.5 10 11 14.5" />
    </Icon>
  );
}

function TerminalIcon() {
  return (
    <Icon
      size="xs"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.7"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <rect x="2.75" y="4" width="14.5" height="12" rx="2" />
      <path d="m6.25 8.25 2.5 2-2.5 2" />
      <path d="M10.5 12.25h3.25" />
    </Icon>
  );
}

function NextStepIcon({ kind }: { kind: GuideNextStep["icon"] }) {
  if (kind === "key") {
    return (
      <Icon
        size="sm"
        viewBox="0 0 20 20"
        fill="none"
        stroke="currentColor"
        strokeWidth="1.65"
        strokeLinecap="round"
        strokeLinejoin="round"
        aria-hidden="true"
      >
        <circle cx="7" cy="10" r="3.25" />
        <path d="M10.25 10H17" />
        <path d="M14.25 10v2.5" />
        <path d="M16.75 10v2" />
      </Icon>
    );
  }
  if (kind === "repeat") {
    return (
      <Icon
        size="sm"
        viewBox="0 0 20 20"
        fill="none"
        stroke="currentColor"
        strokeWidth="1.65"
        strokeLinecap="round"
        strokeLinejoin="round"
        aria-hidden="true"
      >
        <path d="M14.25 3.75 16.75 6.25l-2.5 2.5" />
        <path d="M3.5 9.75V8a1.75 1.75 0 0 1 1.75-1.75h11.5" />
        <path d="M5.75 16.25 3.25 13.75l2.5-2.5" />
        <path d="M16.5 10.25V12a1.75 1.75 0 0 1-1.75 1.75H3.25" />
      </Icon>
    );
  }
  if (kind === "shield") {
    return (
      <Icon
        size="sm"
        viewBox="0 0 20 20"
        fill="none"
        stroke="currentColor"
        strokeWidth="1.65"
        strokeLinecap="round"
        strokeLinejoin="round"
        aria-hidden="true"
      >
        <path d="M10 2.75 16 5.25v4.5c0 3.75-2.55 6.45-6 7.5-3.45-1.05-6-3.75-6-7.5v-4.5l6-2.5Z" />
        <path d="m7.75 10.25 1.6 1.6 3.15-3.35" />
      </Icon>
    );
  }
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.65"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M3 11h3.25l2-5.25 3.25 8.5 2.25-3.25H17" />
    </Icon>
  );
}

// ---------------------------------------------------------------------------
// Styles
// ---------------------------------------------------------------------------

const styles = stylex.create({
  root: {
    backgroundColor: semanticColors.bg,
    color: semanticColors.fg,
    containerName: "documentation-technical",
    containerType: "inline-size",
    fontFamily: fonts.body,
    minHeight: "100%",
    width: "100%",
  },
  pageFrame: {
    marginInline: "auto",
    maxWidth: "74rem",
    paddingBlockEnd: spacing._16,
    paddingBlockStart: {
      default: spacing._8,
      [COMPACT]: spacing._5,
    },
    paddingInline: {
      default: spacing._8,
      [COMPACT]: spacing._4,
    },
  },
  layoutGrid: {
    gap: {
      default: spacing._10,
      [NARROW]: spacing._6,
    },
    gridTemplateColumns: {
      default: "minmax(0, 1fr) 15.5rem",
      [NARROW]: "minmax(0, 1fr)",
    },
  },
  mainColumn: {
    gap: spacing._7,
  },
  headerSection: {
    gap: spacing._3_5,
  },
  updatedText: {
    marginInlineStart: spacing._1,
  },
  pageTitle: {
    marginBlock: 0,
    textWrap: "balance",
  },
  pageSubtitle: {
    maxWidth: "66ch",
  },
  leadingMd: {
    lineHeight: lineHeights.md,
  },
  leadingSm: {
    lineHeight: lineHeights.sm,
  },
  fullWidth: {
    width: "100%",
  },
  inlineTocCard: {
    backgroundColor: semanticColors.bgPanel,
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    display: {
      default: "none",
      [NARROW]: "flex",
    },
    paddingBlock: spacing._3_5,
    paddingInline: spacing._4,
  },
  inlineTocList: {
    listStyleType: "none",
    marginBlock: 0,
    marginInline: 0,
    paddingBlock: 0,
    paddingInline: 0,
  },
  inlineTocButton: {
    appearance: "none",
    backgroundColor: {
      default: semanticColors.bgMuted,
      ":hover": semanticColors.bgSubtle,
    },
    borderColor: semanticColors.borderSubtle,
    borderRadius: semanticRadii.control,
    borderStyle: "solid",
    borderWidth: "1px",
    color: {
      default: semanticColors.fgMuted,
      ":hover": semanticColors.fg,
    },
    cursor: "pointer",
    fontFamily: fonts.body,
    fontSize: fontSizes.xs,
    fontWeight: fontWeights.medium,
    lineHeight: lineHeights.xs,
    outlineColor: {
      default: null,
      ":focus-visible": semanticColors.accentFocusRing,
    },
    outlineOffset: {
      default: null,
      ":focus-visible": "2px",
    },
    outlineStyle: {
      default: "none",
      ":focus-visible": "solid",
    },
    outlineWidth: {
      default: null,
      ":focus-visible": "2px",
    },
    paddingBlock: spacing._1,
    paddingInline: spacing._2_5,
    transitionDuration: durations.fast,
    transitionProperty: "background-color, color, border-color",
  },
  progressCard: {
    borderStyle: "solid",
  },
  progressCardBody: {
    display: "flex",
    flexDirection: "column",
    gap: spacing._2_5,
    paddingBlock: spacing._3_5,
    paddingInline: spacing._4,
  },
  aiCard: {
    borderStyle: "solid",
  },
  aiCardBody: {
    display: "flex",
    flexDirection: "column",
    gap: spacing._3,
    paddingBlock: spacing._4,
    paddingInline: spacing._4,
  },
  anchoredHeading: {
    marginBlock: 0,
    scrollMarginTop: spacing._6,
  },
  alertDescriptionBlock: {
    display: "block",
  },
  prereqList: {
    gap: spacing._1_5,
    marginTop: spacing._1_5,
  },
  stepArticle: {
    gap: spacing._3_5,
    scrollMarginTop: spacing._6,
  },
  stepHeaderRow: {
    alignItems: {
      default: "center",
      [COMPACT]: "flex-start",
    },
    flexDirection: {
      default: "row",
      [COMPACT]: "column",
    },
  },
  stepNumberBadge: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.borderEmphasized,
    borderStyle: "solid",
    borderWidth: "1px",
    color: semanticColors.fg,
    fontSize: fontSizes.xs,
    fontVariantNumeric: "tabular-nums",
    fontWeight: fontWeights.semibold,
    height: sizes._7,
    transitionDuration: durations.fast,
    transitionProperty: "background-color, border-color, color",
    width: sizes._7,
  },
  stepNumberBadgeDone: {
    backgroundColor: semanticColors.successSolid,
    borderColor: semanticColors.successSolid,
    color: semanticColors.successContrast,
  },
  stepTitle: {
    marginBlock: 0,
  },
  stepCheckWrap: {
    flexShrink: 0,
  },
  stepBody: {
    gap: spacing._3_5,
    paddingInlineStart: {
      default: spacing._10,
      [COMPACT]: 0,
    },
  },
  tabsPanelFlush: {
    paddingBlockEnd: 0,
    paddingBlockStart: spacing._3,
    paddingInline: 0,
  },
  codeBlockRoot: {
    borderColor: semanticColors.border,
    borderStyle: "solid",
  },
  codeBlockHeader: {
    borderBottomColor: semanticColors.borderSubtle,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    marginBottom: 0,
  },
  codeBlockContent: {
    backgroundColor: semanticColors.bgMuted,
    borderBottomLeftRadius: radii.md,
    borderBottomRightRadius: radii.md,
    color: semanticColors.fg,
  },
  outputNote: {
    backgroundColor: semanticColors.bgPanel,
    borderColor: semanticColors.borderSubtle,
    borderRadius: semanticRadii.control,
    borderStyle: "solid",
    borderWidth: "1px",
    color: semanticColors.fgMuted,
    fontFamily: fonts.mono,
    fontSize: fontSizes.xs,
    lineHeight: lineHeights.xs,
    paddingBlock: spacing._2,
    paddingInline: spacing._3,
  },
  outputStatusDot: {
    backgroundColor: semanticColors.successSolid,
    height: sizes._2,
    width: sizes._2,
  },
  troubleshootingList: {
    gap: spacing._1_5,
    marginTop: spacing._2,
  },
  nextStepsGrid: {
    gap: spacing._3_5,
    gridTemplateColumns: {
      default: "repeat(2, minmax(0, 1fr))",
      [COMPACT]: "minmax(0, 1fr)",
    },
  },
  nextStepCard: {
    borderColor: {
      default: semanticColors.border,
      ":hover": semanticColors.borderEmphasized,
    },
    borderStyle: "solid",
    boxShadow: {
      default: "none",
      ":hover": semanticShadows.xs,
    },
    transitionDuration: durations.fast,
    transitionProperty: "border-color, box-shadow",
  },
  nextStepButton: {
    appearance: "none",
    backgroundColor: "transparent",
    borderRadius: semanticRadii.panel,
    borderStyle: "none",
    borderWidth: 0,
    color: "inherit",
    cursor: "pointer",
    display: "flex",
    flexDirection: "column",
    gap: spacing._2_5,
    height: "100%",
    outlineColor: {
      default: null,
      ":focus-visible": semanticColors.accentFocusRing,
    },
    outlineOffset: {
      default: null,
      ":focus-visible": "2px",
    },
    outlineStyle: {
      default: "none",
      ":focus-visible": "solid",
    },
    outlineWidth: {
      default: null,
      ":focus-visible": "2px",
    },
    paddingBlock: spacing._4,
    paddingInline: spacing._4,
    textAlign: "start",
    width: "100%",
  },
  nextStepFooter: {
    alignItems: "center",
    color: semanticColors.accentFg,
    display: "inline-flex",
    fontSize: fontSizes.xs,
    fontWeight: fontWeights.medium,
    gap: spacing._1_5,
    marginTop: "auto",
    paddingTop: spacing._1,
  },
  docFooter: {
    paddingTop: spacing._1,
  },
  railColumn: {
    alignSelf: "start",
    display: {
      default: "flex",
      [NARROW]: "none",
    },
    position: "sticky",
    top: spacing._6,
  },
  railCard: {
    backgroundColor: semanticColors.bgPanel,
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    paddingBlock: spacing._3_5,
    paddingInline: spacing._3_5,
  },
});

// ---------------------------------------------------------------------------
// Internal Copyable Code Block helper
// ---------------------------------------------------------------------------

interface GuideCodeBlockProps {
  id: string;
  filename: string;
  code: string;
  copiedId: string | null;
  onCopy: (text: string, label: string, key: string) => void;
}

function GuideCodeBlock({
  id,
  filename,
  code,
  copiedId,
  onCopy,
}: GuideCodeBlockProps) {
  const isCopied = copiedId === id;
  return (
    <CodeBlock.Root size="sm" style={styles.codeBlockRoot}>
      <CodeBlock.Header style={styles.codeBlockHeader}>
        <CodeBlock.Title>
          <TerminalIcon />
          <span>{filename}</span>
        </CodeBlock.Title>
        <CodeBlock.Control>
          <Button
            variant="ghost"
            size="2xs"
            aria-label={`Copy ${filename}`}
            onClick={() => onCopy(code, filename, id)}
          >
            {isCopied ? <CheckIcon /> : <CopyIcon />}
            {isCopied ? "Copied" : "Copy"}
          </Button>
        </CodeBlock.Control>
      </CodeBlock.Header>
      <CodeBlock.Content style={styles.codeBlockContent}>
        <CodeBlock.Code>
          <CodeBlock.CodeText>{code}</CodeBlock.CodeText>
        </CodeBlock.Code>
      </CodeBlock.Content>
    </CodeBlock.Root>
  );
}

// ---------------------------------------------------------------------------
// Main Component
// ---------------------------------------------------------------------------

/**
 * DocumentationTechnical — sequential technical quickstart and walkthrough
 * guide featuring breadcrumb navigation, prerequisites and troubleshooting
 * callouts, synced package-manager and runtime code switchers, checkable step
 * completion progress, AI prompt card, onward next-step cards, and a sticky
 * table-of-contents rail that collapses cleanly on narrow widths.
 */
export function DocumentationTechnical({
  title = "Deploying Signed Edge Webhooks with Kestrel CLI",
  subtitle = "Provision a workspace HMAC-SHA256 signing secret, verify raw webhook payloads in edge middleware, replay signed test events locally, and promote your endpoint to production in five steps.",
  version = "Kestrel CLI v2.8",
  updatedAt = "Updated Nov 28, 2026",
  defaultPackageManager = "bun",
  defaultCompletedSteps = ["step-1-install"],
  nextSteps = DEFAULT_NEXT_STEPS,
  onNavigateNextStep,
  palette,
  style,
}: DocumentationTechnicalProps) {
  const queue = useMemo(() => Toast.createToaster(), []);

  const [packageManager, setPackageManager] = useState<PackageManager>(
    defaultPackageManager,
  );
  const [runtimeTarget, setRuntimeTarget] = useState<RuntimeTarget>("edge");
  const [completedSteps, setCompletedSteps] = useState<ReadonlySet<string>>(
    () => new Set(defaultCompletedSteps),
  );
  const [copiedId, setCopiedId] = useState<string | null>(null);
  const [helpfulVote, setHelpfulVote] = useState<"yes" | "no" | null>(null);

  const completedCount = useMemo(
    () => STEP_IDS.filter((id) => completedSteps.has(id)).length,
    [completedSteps],
  );
  const allStepsComplete = completedCount === STEP_IDS.length;

  const copyText = useCallback(
    (text: string, label: string, key: string) => {
      if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
        void navigator.clipboard.writeText(text).catch(() => {});
      }
      setCopiedId(key);
      window.setTimeout(() => {
        setCopiedId((current) => (current === key ? null : current));
      }, 1600);
      queue.success(`Copied ${label}`, {
        description:
          text.length > 64 ? `${text.split("\n")[0]?.slice(0, 60)}…` : text,
      });
    },
    [queue],
  );

  const toggleStep = useCallback(
    (stepId: StepId, nextDone: boolean, stepLabel: string) => {
      setCompletedSteps((prev) => {
        const next = new Set(prev);
        if (nextDone) {
          next.add(stepId);
        } else {
          next.delete(stepId);
        }
        const nextCount = STEP_IDS.filter((id) => next.has(id)).length;
        if (nextDone && nextCount === STEP_IDS.length) {
          queue.success("All 5 quickstart steps completed", {
            description: "Your signed Kestrel webhook endpoint is production-ready.",
          });
        } else if (nextDone) {
          queue.info(`Marked "${stepLabel}" complete`, {
            description: `${nextCount} of ${STEP_IDS.length} steps finished.`,
          });
        }
        return next;
      });
    },
    [queue],
  );

  const handleMarkAllDone = useCallback(() => {
    setCompletedSteps(new Set(STEP_IDS));
    queue.success("All 5 quickstart steps completed", {
      description: "Every step in this guide has been checked off.",
    });
  }, [queue]);

  const handleResetProgress = useCallback(() => {
    setCompletedSteps(new Set());
    queue.info("Walkthrough progress reset");
  }, [queue]);

  const handleJumpToSection = useCallback((sectionId: string) => {
    const el = document.getElementById(sectionId);
    if (el) {
      el.scrollIntoView({ behavior: "smooth", block: "start" });
    }
  }, []);

  const handleCopyAllCommands = useCallback(() => {
    const combined = [
      INSTALL_SNIPPETS[packageManager].code,
      "",
      SECRET_INIT_SNIPPETS[packageManager],
      "",
      REPLAY_SNIPPET,
      "",
      PROMOTE_SNIPPET,
    ].join("\n");
    copyText(combined, `all ${packageManager} CLI commands`, "copy-all-cli");
  }, [copyText, packageManager]);

  const handleNextStepClick = useCallback(
    (item: GuideNextStep) => {
      onNavigateNextStep?.(item);
      queue.info(`Opening "${item.title}"`, {
        description: `Demo navigation → /docs/webhooks/${item.id} (${item.readTime} read)`,
      });
    },
    [onNavigateNextStep, queue],
  );

  const handleBreadcrumbClick = useCallback(
    (event: React.MouseEvent<HTMLAnchorElement>, label: string, path: string) => {
      event.preventDefault();
      queue.info(`Navigated to ${label}`, {
        description: `Demo breadcrumb link → ${path}`,
      });
    },
    [queue],
  );

  const handleVote = useCallback(
    (vote: "yes" | "no") => {
      setHelpfulVote(vote);
      queue.success(
        vote === "yes"
          ? "Thanks for the feedback"
          : "Feedback noted — we will improve this guide",
        {
          description:
            vote === "yes"
              ? "Glad the Kestrel webhook quickstart helped."
              : "Let us know which step needed more detail via GitHub issues.",
        },
      );
    },
    [queue],
  );

  const isStepDone = (id: StepId) => completedSteps.has(id);

  return (
    <div {...stylex.props(palette, styles.root, style)}>
      <div {...stylex.props(styles.pageFrame)}>
        <Grid align="start" style={styles.layoutGrid}>
          {/* Main technical walkthrough column */}
          <VStack render={<main />} style={styles.mainColumn}>
            {/* Header & Breadcrumb */}
            <VStack render={<header />} style={styles.headerSection}>
              <Breadcrumb.Root aria-label="Documentation breadcrumb" size="sm">
                <Breadcrumb.List>
                  <Breadcrumb.Item>
                    <Breadcrumb.Link
                      href="#docs"
                      onClick={(event) =>
                        handleBreadcrumbClick(event, "Docs", "/docs")
                      }
                    >
                      Docs
                    </Breadcrumb.Link>
                  </Breadcrumb.Item>
                  <Breadcrumb.Separator aria-hidden="true">
                    <ChevronRightIcon />
                  </Breadcrumb.Separator>
                  <Breadcrumb.Item>
                    <Breadcrumb.Link
                      href="#guides"
                      onClick={(event) =>
                        handleBreadcrumbClick(event, "Guides", "/docs/guides")
                      }
                    >
                      Guides
                    </Breadcrumb.Link>
                  </Breadcrumb.Item>
                  <Breadcrumb.Separator aria-hidden="true">
                    <ChevronRightIcon />
                  </Breadcrumb.Separator>
                  <Breadcrumb.Item>
                    <Breadcrumb.Link
                      href="#webhooks"
                      onClick={(event) =>
                        handleBreadcrumbClick(
                          event,
                          "Edge Webhooks",
                          "/docs/guides/edge-webhooks",
                        )
                      }
                    >
                      Edge Webhooks
                    </Breadcrumb.Link>
                  </Breadcrumb.Item>
                  <Breadcrumb.Separator aria-hidden="true">
                    <ChevronRightIcon />
                  </Breadcrumb.Separator>
                  <Breadcrumb.Item>
                    <Breadcrumb.CurrentLink aria-current="page">
                      Signed Edge Webhooks
                    </Breadcrumb.CurrentLink>
                  </Breadcrumb.Item>
                </Breadcrumb.List>
              </Breadcrumb.Root>

              <HStack gap="2" wrap="wrap">
                <Badge variant="surface" size="sm" palette={accentPalette}>
                  Quickstart
                </Badge>
                <Badge variant="outline" size="sm">
                  {version}
                </Badge>
                <Badge variant="subtle" size="sm">
                  12 min · 5 steps
                </Badge>
                <Text render={<span />} variant="muted" size="xs" style={styles.updatedText}>
                  {updatedAt}
                </Text>
              </HStack>

              <Heading render={<h1 />} size="4xl" style={styles.pageTitle}>
                {title}
              </Heading>
              <Text variant="muted" size="md" style={styles.pageSubtitle}>
                {subtitle}
              </Text>

              {/* Inline outline for narrow containers where the sticky rail collapses */}
              <VStack
                render={<nav aria-label="On this page" />}
                gap="2.5"
                style={styles.inlineTocCard}
              >
                <Text variant="overline">On this page</Text>
                <HStack render={<ul />} gap="1.5" wrap="wrap" style={styles.inlineTocList}>
                  {OUTLINE_ENTRIES.map((entry) => (
                    <li key={entry.id}>
                      <button
                        type="button"
                        {...stylex.props(styles.inlineTocButton)}
                        onClick={() => handleJumpToSection(entry.id)}
                      >
                        {entry.label}
                      </button>
                    </li>
                  ))}
                </HStack>
              </VStack>
            </VStack>

            {/* Interactive step completion progress strip */}
            <Card.Root variant="outline" size="sm" style={styles.progressCard}>
              <Card.Body style={styles.progressCardBody}>
                <HStack gap="2" justify="between" wrap="wrap">
                  <HStack gap="2" wrap="wrap">
                    <Text render={<span />} size="sm" weight="semibold">
                      Walkthrough progress
                    </Text>
                    {allStepsComplete ? (
                      <Badge
                        variant="subtle"
                        size="xs"
                        palette={emeraldPalette}
                      >
                        Ready for production
                      </Badge>
                    ) : null}
                    <Text render={<span />} variant="muted" size="xs" tabular="true">
                      {completedCount} of {STEP_IDS.length} steps completed
                    </Text>
                  </HStack>

                  <HStack gap="1.5">
                    {completedCount > 0 ? (
                      <Button
                        variant="ghost"
                        size="2xs"
                        onClick={handleResetProgress}
                      >
                        Reset
                      </Button>
                    ) : null}
                    {!allStepsComplete ? (
                      <Button
                        variant="surface"
                        size="2xs"
                        onClick={handleMarkAllDone}
                      >
                        Mark all done
                      </Button>
                    ) : null}
                  </HStack>
                </HStack>

                <Progress.Root
                  value={completedCount}
                  max={STEP_IDS.length}
                  size="xs"
                  shape="full"
                  palette={allStepsComplete ? emeraldPalette : accentPalette}
                  aria-label="Walkthrough step completion progress"
                >
                  <Progress.Track>
                    <Progress.Range />
                  </Progress.Track>
                </Progress.Root>
              </Card.Body>
            </Card.Root>

            {/* AI Setup Assistant Card */}
            <Card.Root variant="outline" size="md" style={styles.aiCard}>
              <Card.Body style={styles.aiCardBody}>
                <HStack gap="2" justify="between" wrap="wrap">
                  <HStack gap="2">
                    <SparklesIcon />
                    <Text render={<span />} size="sm" weight="semibold">
                      AI Assistance
                    </Text>
                    <Badge variant="subtle" size="xs">
                      Setup prompt
                    </Badge>
                  </HStack>

                  <HStack gap="1">
                    <Button
                      variant="ghost"
                      size="xs"
                      onClick={() =>
                        copyText(AI_SETUP_PROMPT, "AI setup prompt", "ai-prompt")
                      }
                    >
                      {copiedId === "ai-prompt" ? <CheckIcon /> : <CopyIcon />}
                      {copiedId === "ai-prompt" ? "Copied" : "Copy prompt"}
                    </Button>

                    <Menu.Root size="sm">
                      <Menu.Trigger
                        render={
                          <IconButton
                            variant="ghost"
                            size="xs"
                            aria-label="Open setup prompt in AI assistant"
                          />
                        }
                      >
                        <ChevronDownIcon />
                      </Menu.Trigger>
                      <Menu.Content align="end">
                        {AI_DESTINATIONS.map((dest) => (
                          <Menu.Item
                            key={dest.id}
                            onSelect={() =>
                              queue.info(dest.label, {
                                description:
                                  "Demo action: opens this Kestrel webhook setup prompt in your editor or assistant.",
                              })
                            }
                          >
                            <Menu.ItemText>{dest.label}</Menu.ItemText>
                          </Menu.Item>
                        ))}
                      </Menu.Content>
                    </Menu.Root>
                  </HStack>
                </HStack>

                <Text variant="muted" size="sm" style={styles.leadingMd}>
                  {AI_SETUP_PROMPT}
                </Text>
              </Card.Body>
            </Card.Root>

            {/* Prerequisites Callout */}
            <VStack render={<section aria-labelledby="prerequisites" />} gap="4">
              <Heading
                id="prerequisites"
                render={<h2 />}
                size="xl"
                style={styles.anchoredHeading}
              >
                Prerequisites
              </Heading>

              <Alert.Root
                status="info"
                variant="subtle"
                size="md"
                palette={bluePalette}
              >
                <Alert.Indicator>
                  <InfoCircleIcon />
                </Alert.Indicator>
                <Alert.Content>
                  <Alert.Title>Before you begin</Alert.Title>
                  <Alert.Description style={styles.alertDescriptionBlock}>
                    Confirm your local environment meets these requirements so
                    signature verification and local tunnel replay work out of
                    the box.
                    <List.Root variant="marker" style={styles.prereqList}>
                      <List.Item>
                        Node.js 20+ or Bun 1.2+ with Web Crypto (
                        <Code size="xs">crypto.subtle</Code>) enabled
                      </List.Item>
                      <List.Item>
                        A Kestrel workspace with Edge Runtime access and a
                        scoped API token
                      </List.Item>
                      <List.Item>
                        Local port <Code size="xs">8787</Code> free for the
                        authenticated webhook tunnel listener
                      </List.Item>
                    </List.Root>
                  </Alert.Description>
                </Alert.Content>
              </Alert.Root>
            </VStack>

            <Separator />

            {/* Numbered Sequential Walkthrough Steps */}
            <VStack gap="8">
              {/* Step 1 */}
              <VStack
                render={<section id="step-1-install" aria-labelledby="step-1-heading" />}
                style={styles.stepArticle}
              >
                <Stack gap="3" justify="between" style={styles.stepHeaderRow}>
                  <HStack gap="3">
                    <Circle
                      render={<span />}
                      aria-hidden="true"
                      style={[
                        styles.stepNumberBadge,
                        isStepDone("step-1-install") &&
                          styles.stepNumberBadgeDone,
                      ]}
                    >
                      {isStepDone("step-1-install") ? <CheckIcon /> : "1"}
                    </Circle>
                    <Heading
                      id="step-1-heading"
                      render={<h2 />}
                      size="lg"
                      style={styles.stepTitle}
                    >
                      Install CLI &amp; Authenticate
                    </Heading>
                  </HStack>

                  <div {...stylex.props(styles.stepCheckWrap)}>
                    <Checkbox.Root
                      size="sm"
                      variant="solid"
                      palette={emeraldPalette}
                    >
                      <Checkbox.Control
                        checked={isStepDone("step-1-install")}
                        onCheckedChange={(checked) =>
                          toggleStep(
                            "step-1-install",
                            checked === true,
                            "Install CLI & Authenticate",
                          )
                        }
                      />
                      <Checkbox.Label>
                        {isStepDone("step-1-install")
                          ? "Completed"
                          : "Mark complete"}
                      </Checkbox.Label>
                    </Checkbox.Root>
                  </div>
                </Stack>

                <VStack style={styles.stepBody}>
                  <Text variant="muted" size="sm" style={styles.leadingMd}>
                    Install <Code size="xs">@kestrel/cli</Code> globally and add{" "}
                    <Code size="xs">@kestrel/webhooks</Code> to your service.
                    Switching package managers below updates all CLI commands in
                    this guide automatically.
                  </Text>

                  <Tabs.Root
                    value={packageManager}
                    onValueChange={setPackageManager}
                    variant="enclosed"
                    size="xs"
                    palette={accentPalette}
                  >
                    <HStack gap="2.5" justify="between" wrap="wrap">
                      <Tabs.List aria-label="Select package manager">
                        <Tabs.Tab value="bun">bun</Tabs.Tab>
                        <Tabs.Tab value="pnpm">pnpm</Tabs.Tab>
                        <Tabs.Tab value="npm">npm</Tabs.Tab>
                      </Tabs.List>
                      <Text render={<span />} variant="muted" size="xs" weight="medium">
                        Synced across steps 1–2
                      </Text>
                    </HStack>

                    {(["bun", "pnpm", "npm"] as const).map((pm) => (
                      <Tabs.Panel
                        key={pm}
                        value={pm}
                        style={styles.tabsPanelFlush}
                      >
                        <GuideCodeBlock
                          id={`install-${pm}`}
                          filename={INSTALL_SNIPPETS[pm].filename}
                          code={INSTALL_SNIPPETS[pm].code}
                          copiedId={copiedId}
                          onCopy={copyText}
                        />
                      </Tabs.Panel>
                    ))}
                  </Tabs.Root>

                  <HStack gap="2" wrap="wrap" style={styles.outputNote}>
                    <Circle
                      render={<span />}
                      aria-hidden="true"
                      style={styles.outputStatusDot}
                    />
                    <span>
                      Authenticated as <strong>acme-edge</strong> · scopes:
                      webhooks:write · expires in 14d
                    </span>
                  </HStack>
                </VStack>
              </VStack>

              <Separator />

              {/* Step 2 */}
              <VStack
                render={<section id="step-2-secret" aria-labelledby="step-2-heading" />}
                style={styles.stepArticle}
              >
                <Stack gap="3" justify="between" style={styles.stepHeaderRow}>
                  <HStack gap="3">
                    <Circle
                      render={<span />}
                      aria-hidden="true"
                      style={[
                        styles.stepNumberBadge,
                        isStepDone("step-2-secret") &&
                          styles.stepNumberBadgeDone,
                      ]}
                    >
                      {isStepDone("step-2-secret") ? <CheckIcon /> : "2"}
                    </Circle>
                    <Heading
                      id="step-2-heading"
                      render={<h2 />}
                      size="lg"
                      style={styles.stepTitle}
                    >
                      Initialize Signing Secret
                    </Heading>
                  </HStack>

                  <div {...stylex.props(styles.stepCheckWrap)}>
                    <Checkbox.Root
                      size="sm"
                      variant="solid"
                      palette={emeraldPalette}
                    >
                      <Checkbox.Control
                        checked={isStepDone("step-2-secret")}
                        onCheckedChange={(checked) =>
                          toggleStep(
                            "step-2-secret",
                            checked === true,
                            "Initialize Signing Secret",
                          )
                        }
                      />
                      <Checkbox.Label>
                        {isStepDone("step-2-secret")
                          ? "Completed"
                          : "Mark complete"}
                      </Checkbox.Label>
                    </Checkbox.Root>
                  </div>
                </Stack>

                <VStack style={styles.stepBody}>
                  <Text variant="muted" size="sm" style={styles.leadingMd}>
                    Register your webhook route and generate a 256-bit signing
                    secret. Kestrel signs every outgoing delivery with{" "}
                    <Code size="xs">HMAC-SHA256</Code> over{" "}
                    <Code size="xs">{`\${timestamp}.\${rawBody}`}</Code> and
                    attaches the digest in{" "}
                    <Code size="xs">x-kestrel-signature</Code>.
                  </Text>

                  <GuideCodeBlock
                    id={`secret-init-${packageManager}`}
                    filename={`terminal · ${packageManager}`}
                    code={SECRET_INIT_SNIPPETS[packageManager]}
                    copiedId={copiedId}
                    onCopy={copyText}
                  />

                  <GuideCodeBlock
                    id="secret-env-output"
                    filename=".env.local (generated)"
                    code={ENV_OUTPUT_SNIPPET}
                    copiedId={copiedId}
                    onCopy={copyText}
                  />
                </VStack>
              </VStack>

              <Separator />

              {/* Step 3 */}
              <VStack
                render={<section id="step-3-verify" aria-labelledby="step-3-heading" />}
                style={styles.stepArticle}
              >
                <Stack gap="3" justify="between" style={styles.stepHeaderRow}>
                  <HStack gap="3">
                    <Circle
                      render={<span />}
                      aria-hidden="true"
                      style={[
                        styles.stepNumberBadge,
                        isStepDone("step-3-verify") &&
                          styles.stepNumberBadgeDone,
                      ]}
                    >
                      {isStepDone("step-3-verify") ? <CheckIcon /> : "3"}
                    </Circle>
                    <Heading
                      id="step-3-heading"
                      render={<h2 />}
                      size="lg"
                      style={styles.stepTitle}
                    >
                      Verify Signatures in Middleware
                    </Heading>
                  </HStack>

                  <div {...stylex.props(styles.stepCheckWrap)}>
                    <Checkbox.Root
                      size="sm"
                      variant="solid"
                      palette={emeraldPalette}
                    >
                      <Checkbox.Control
                        checked={isStepDone("step-3-verify")}
                        onCheckedChange={(checked) =>
                          toggleStep(
                            "step-3-verify",
                            checked === true,
                            "Verify Signatures in Middleware",
                          )
                        }
                      />
                      <Checkbox.Label>
                        {isStepDone("step-3-verify")
                          ? "Completed"
                          : "Mark complete"}
                      </Checkbox.Label>
                    </Checkbox.Root>
                  </div>
                </Stack>

                <VStack style={styles.stepBody}>
                  <Text variant="muted" size="sm" style={styles.leadingMd}>
                    Validate the raw request payload in constant time before
                    deserializing JSON. Choose the runtime implementation that
                    matches your deployment target:
                  </Text>

                  <Tabs.Root
                    value={runtimeTarget}
                    onValueChange={setRuntimeTarget}
                    variant="line"
                    size="sm"
                    palette={accentPalette}
                  >
                    <Tabs.List aria-label="Select verification runtime">
                      <Tabs.Tab value="edge">
                        {VERIFY_SNIPPETS.edge.label}
                      </Tabs.Tab>
                      <Tabs.Tab value="express">
                        {VERIFY_SNIPPETS.express.label}
                      </Tabs.Tab>
                      <Tabs.Tab value="cli">
                        {VERIFY_SNIPPETS.cli.label}
                      </Tabs.Tab>
                    </Tabs.List>

                    {(["edge", "express", "cli"] as const).map((target) => (
                      <Tabs.Panel
                        key={target}
                        value={target}
                        style={styles.tabsPanelFlush}
                      >
                        <GuideCodeBlock
                          id={`verify-${target}`}
                          filename={VERIFY_SNIPPETS[target].filename}
                          code={VERIFY_SNIPPETS[target].code}
                          copiedId={copiedId}
                          onCopy={copyText}
                        />
                      </Tabs.Panel>
                    ))}
                  </Tabs.Root>
                </VStack>
              </VStack>

              <Separator />

              {/* Step 4 */}
              <VStack
                render={<section id="step-4-replay" aria-labelledby="step-4-heading" />}
                style={styles.stepArticle}
              >
                <Stack gap="3" justify="between" style={styles.stepHeaderRow}>
                  <HStack gap="3">
                    <Circle
                      render={<span />}
                      aria-hidden="true"
                      style={[
                        styles.stepNumberBadge,
                        isStepDone("step-4-replay") &&
                          styles.stepNumberBadgeDone,
                      ]}
                    >
                      {isStepDone("step-4-replay") ? <CheckIcon /> : "4"}
                    </Circle>
                    <Heading
                      id="step-4-heading"
                      render={<h2 />}
                      size="lg"
                      style={styles.stepTitle}
                    >
                      Replay Events Locally
                    </Heading>
                  </HStack>

                  <div {...stylex.props(styles.stepCheckWrap)}>
                    <Checkbox.Root
                      size="sm"
                      variant="solid"
                      palette={emeraldPalette}
                    >
                      <Checkbox.Control
                        checked={isStepDone("step-4-replay")}
                        onCheckedChange={(checked) =>
                          toggleStep(
                            "step-4-replay",
                            checked === true,
                            "Replay Events Locally",
                          )
                        }
                      />
                      <Checkbox.Label>
                        {isStepDone("step-4-replay")
                          ? "Completed"
                          : "Mark complete"}
                      </Checkbox.Label>
                    </Checkbox.Root>
                  </div>
                </Stack>

                <VStack style={styles.stepBody}>
                  <Text variant="muted" size="sm" style={styles.leadingMd}>
                    Stream signed payloads straight to your local handler using{" "}
                    <Code size="xs">kestrel webhooks listen</Code>, then emit a
                    synthetic <Code size="xs">invoice.paid</Code> event from a
                    second terminal to confirm end-to-end HMAC verification.
                  </Text>

                  <GuideCodeBlock
                    id="replay-local"
                    filename="terminal · local tunnel"
                    code={REPLAY_SNIPPET}
                    copiedId={copiedId}
                    onCopy={copyText}
                  />

                  <HStack gap="2" wrap="wrap" style={styles.outputNote}>
                    <Circle
                      render={<span />}
                      aria-hidden="true"
                      style={styles.outputStatusDot}
                    />
                    <span>
                      POST /api/webhooks/kestrel → 200 OK · verified in 1.4 ms ·
                      sig=v1 · evt_test_01
                    </span>
                  </HStack>
                </VStack>
              </VStack>

              <Separator />

              {/* Step 5 */}
              <VStack
                render={<section id="step-5-promote" aria-labelledby="step-5-heading" />}
                style={styles.stepArticle}
              >
                <Stack gap="3" justify="between" style={styles.stepHeaderRow}>
                  <HStack gap="3">
                    <Circle
                      render={<span />}
                      aria-hidden="true"
                      style={[
                        styles.stepNumberBadge,
                        isStepDone("step-5-promote") &&
                          styles.stepNumberBadgeDone,
                      ]}
                    >
                      {isStepDone("step-5-promote") ? <CheckIcon /> : "5"}
                    </Circle>
                    <Heading
                      id="step-5-heading"
                      render={<h2 />}
                      size="lg"
                      style={styles.stepTitle}
                    >
                      Promote to Production
                    </Heading>
                  </HStack>

                  <div {...stylex.props(styles.stepCheckWrap)}>
                    <Checkbox.Root
                      size="sm"
                      variant="solid"
                      palette={emeraldPalette}
                    >
                      <Checkbox.Control
                        checked={isStepDone("step-5-promote")}
                        onCheckedChange={(checked) =>
                          toggleStep(
                            "step-5-promote",
                            checked === true,
                            "Promote to Production",
                          )
                        }
                      />
                      <Checkbox.Label>
                        {isStepDone("step-5-promote")
                          ? "Completed"
                          : "Mark complete"}
                      </Checkbox.Label>
                    </Checkbox.Root>
                  </div>
                </Stack>

                <VStack style={styles.stepBody}>
                  <Text variant="muted" size="sm" style={styles.leadingMd}>
                    Store a dedicated production signing secret in the edge
                    vault, publish your handler across every PoP, and run a
                    live delivery probe before switching customer traffic.
                  </Text>

                  <GuideCodeBlock
                    id="promote-prod"
                    filename="terminal · production deploy"
                    code={PROMOTE_SNIPPET}
                    copiedId={copiedId}
                    onCopy={copyText}
                  />
                </VStack>
              </VStack>
            </VStack>

            <Separator />

            {/* Troubleshooting Callout */}
            <VStack render={<section aria-labelledby="troubleshooting" />} gap="4">
              <Heading
                id="troubleshooting"
                render={<h2 />}
                size="xl"
                style={styles.anchoredHeading}
              >
                Troubleshooting
              </Heading>

              <Alert.Root
                status="warning"
                variant="surface"
                size="md"
                palette={amberPalette}
              >
                <Alert.Indicator>
                  <WarningTriangleIcon />
                </Alert.Indicator>
                <Alert.Content>
                  <Alert.Title>
                    Receiving 401 Invalid Signature in staging or production?
                  </Alert.Title>
                  <Alert.Description style={styles.alertDescriptionBlock}>
                    Most signature mismatches come from subtle body mutations or
                    clock skew between edge PoPs and your origin:
                    <List.Root
                      variant="marker"
                      style={styles.troubleshootingList}
                    >
                      <List.Item>
                        Ensure no upstream JSON body parser runs before{" "}
                        <Code size="xs">request.text()</Code> or{" "}
                        <Code size="xs">express.raw()</Code> — re-serializing
                        JSON alters key spacing and invalidates the HMAC digest.
                      </List.Item>
                      <List.Item>
                        Check host NTP synchronization if errors report{" "}
                        <Code size="xs">ERR_TIMESTAMP_OUTSIDE_TOLERANCE</Code>{" "}
                        (default window is 300 seconds).
                      </List.Item>
                      <List.Item>
                        Verify that your production vault uses a{" "}
                        <Code size="xs">whsec_live_*</Code> secret rather than a
                        local <Code size="xs">whsec_dev_*</Code> key.
                      </List.Item>
                    </List.Root>
                  </Alert.Description>
                </Alert.Content>
              </Alert.Root>

              <GuideCodeBlock
                id="doctor-cmd"
                filename="terminal · diagnostics"
                code={DOCTOR_SNIPPET}
                copiedId={copiedId}
                onCopy={copyText}
              />
            </VStack>

            <Separator />

            {/* Onward Next Steps */}
            <VStack render={<section aria-labelledby="next-steps" />} gap="4">
              <Heading
                id="next-steps"
                render={<h2 />}
                size="xl"
                style={styles.anchoredHeading}
              >
                Next steps
              </Heading>
              <Text variant="muted" size="sm" style={styles.leadingMd}>
                Continue hardening your webhook pipeline with dual-key rotation,
                replay queues, and real-time delivery observability.
              </Text>

              <Grid style={styles.nextStepsGrid}>
                {nextSteps.map((item) => (
                  <Card.Root
                    key={item.id}
                    variant="outline"
                    size="sm"
                    style={styles.nextStepCard}
                  >
                    <button
                      type="button"
                      {...stylex.props(styles.nextStepButton)}
                      onClick={() => handleNextStepClick(item)}
                    >
                      <HStack gap="2" justify="between" style={styles.fullWidth}>
                        <IconBadge
                          variant="subtle"
                          size="sm"
                          palette={accentPalette}
                        >
                          <NextStepIcon kind={item.icon} />
                        </IconBadge>
                        <Badge variant="outline" size="xs">
                          {item.readTime}
                        </Badge>
                      </HStack>
                      <Text render={<h3 />} size="sm" weight="semibold">
                        {item.title}
                      </Text>
                      <Text variant="muted" size="xs" style={styles.leadingSm}>
                        {item.description}
                      </Text>
                      <span {...stylex.props(styles.nextStepFooter)}>
                        Read guide
                        <ArrowRightIcon />
                      </span>
                    </button>
                  </Card.Root>
                ))}
              </Grid>
            </VStack>

            <Separator />

            {/* Documentation Footer */}
            <HStack
              render={<footer />}
              gap="3"
              justify="between"
              wrap="wrap"
              style={styles.docFooter}
            >
              <HStack gap="2" wrap="wrap">
                <Text render={<span />} variant="muted" size="xs">
                  Was this guide helpful?
                </Text>
                <Button
                  variant={helpfulVote === "yes" ? "solid" : "surface"}
                  size="2xs"
                  palette={helpfulVote === "yes" ? accentPalette : undefined}
                  onClick={() => handleVote("yes")}
                >
                  Yes
                </Button>
                <Button
                  variant={helpfulVote === "no" ? "solid" : "surface"}
                  size="2xs"
                  palette={helpfulVote === "no" ? accentPalette : undefined}
                  onClick={() => handleVote("no")}
                >
                  No
                </Button>
              </HStack>

              <Link
                href="#edit-on-github"
                variant="plain"
                onClick={(event) => {
                  event.preventDefault();
                  queue.info("Edit page on GitHub", {
                    description:
                      "Demo link → github.com/kestrel-edge/docs/blob/main/webhooks-quickstart.mdx",
                  });
                }}
              >
                Edit this page on GitHub
              </Link>
            </HStack>
          </VStack>

          {/* Right-hand Sticky Outline Rail */}
          <VStack
            render={<aside aria-label="Guide outline and progress" />}
            gap="5"
            style={styles.railColumn}
          >
            <Toc.Root
              items={TOC_ITEMS}
              variant="line"
              size="sm"
              multiple={false}
              defaultActiveIds={["prerequisites"]}
              palette={accentPalette}
            >
              <Toc.Nav>
                <Toc.Title>On this page</Toc.Title>
                <Toc.List>
                  <Toc.Indicator />
                  {OUTLINE_ENTRIES.map((entry) => (
                    <Toc.Item
                      key={entry.id}
                      item={{ value: entry.id, depth: entry.depth }}
                    >
                      <Toc.Link>{entry.label}</Toc.Link>
                    </Toc.Item>
                  ))}
                </Toc.List>
              </Toc.Nav>
            </Toc.Root>

            <Separator />

            <VStack gap="3" style={styles.railCard}>
              <HStack gap="2" justify="between">
                <Text render={<span />} variant="muted" size="xs" weight="medium">
                  Checklist
                </Text>
                <Text render={<span />} size="xs" weight="semibold" tabular="true">
                  {completedCount}/{STEP_IDS.length}
                </Text>
              </HStack>

              <Progress.Root
                value={completedCount}
                max={STEP_IDS.length}
                size="xs"
                shape="full"
                palette={allStepsComplete ? emeraldPalette : accentPalette}
                aria-label="Sidebar completion summary"
              >
                <Progress.Track>
                  <Progress.Range />
                </Progress.Track>
              </Progress.Root>

              <HStack gap="2" justify="between">
                <Text render={<span />} variant="muted" size="xs" weight="medium">
                  Package manager
                </Text>
                <Code size="xs">{packageManager}</Code>
              </HStack>

              <Button
                variant="surface"
                size="xs"
                onClick={handleCopyAllCommands}
              >
                {copiedId === "copy-all-cli" ? <CheckIcon /> : <CopyIcon />}
                {copiedId === "copy-all-cli"
                  ? "Copied CLI steps"
                  : "Copy all CLI steps"}
              </Button>
            </VStack>
          </VStack>
        </Grid>
      </div>

      <Toaster toaster={queue} />
    </div>
  );
}
```

Credit: Inspired by [Documentation Technical](https://astryx.atmeta.com/playground?template=documentation-technical) from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.)
