// src/components/docs/libraries/LibrariesProgressiveDeliveryPage.tsx
import { CodeBlock, InstallCommand } from "@contractspec/lib.design-system";
import Link from "@contractspec/lib.ui-link";
import { ChevronRight } from "lucide-react";
import { jsx, jsxs } from "react/jsx-runtime";
function LibrariesProgressiveDeliveryPage() {
  return /* @__PURE__ */ jsxs("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h1", {
            className: "text-4xl font-bold",
            children: "Progressive Delivery Library"
          }),
          /* @__PURE__ */ jsxs("p", {
            className: "text-muted-foreground text-lg",
            children: [
              "The ",
              /* @__PURE__ */ jsx("code", {
                children: "@contractspec/lib.progressive-delivery"
              }),
              " package helps you ship new specs with confidence: canary + blue-green strategies, metric guardrails, and rollback hooks in one place."
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Installation"
          }),
          /* @__PURE__ */ jsx(InstallCommand, {
            package: "@contractspec/lib.progressive-delivery"
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Define a Strategy"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `import { DeploymentCoordinator, createDefaultCanaryController, TrafficShifter, RollbackManager } from '@contractspec/lib.progressive-delivery';

const strategy = {
  target: { name: 'billing.createInvoice', version: 7 },
  mode: 'canary',
  thresholds: {
    errorRate: 0.01,
    latencyP99: 500,
    latencyP95: 250,
  },
};`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Run the Coordinator"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `const eventBus = new DeploymentEventBus();
const controller = createDefaultCanaryController(strategy, fetchMetrics, eventBus);
const coordinator = new DeploymentCoordinator({
  strategy,
  controller,
  trafficShifter: new TrafficShifter(strategy.mode),
  rollbackManager: new RollbackManager({ rollback: revertSpec }),
  applyTrafficSplit: updateFeatureFlag,
  eventBus,
});

const result = await coordinator.run();`
          }),
          /* @__PURE__ */ jsxs("p", {
            className: "text-muted-foreground text-sm",
            children: [
              "The coordinator emits ",
              /* @__PURE__ */ jsx("code", {
                children: "stage_started"
              }),
              ",",
              " ",
              /* @__PURE__ */ jsx("code", {
                children: "stage_failed"
              }),
              ", and ",
              /* @__PURE__ */ jsx("code", {
                children: "rolled_back"
              }),
              " events, making it easy to power dashboards or alerting workflows."
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Blue-Green Swap"
          }),
          /* @__PURE__ */ jsxs("p", {
            className: "text-muted-foreground text-sm",
            children: [
              "Switch to ",
              /* @__PURE__ */ jsx("code", {
                children: "mode: 'blue-green'"
              }),
              " to warm up the new stack in parallel and cut over once smoke tests pass. The same guardrails apply before the final swap."
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx(Link, {
            href: "/docs/libraries",
            className: "btn-ghost",
            children: "Back to Libraries"
          }),
          /* @__PURE__ */ jsxs(Link, {
            href: "/docs/libraries/resilience",
            className: "btn-primary",
            children: [
              "Next: Resilience ",
              /* @__PURE__ */ jsx(ChevronRight, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}
export {
  LibrariesProgressiveDeliveryPage
};
