// src/components/docs/intent/DeterministicCodegenPage.tsx
import { deterministicCodegenBrief } from "@contractspec/bundle.library/components/docs/intent/intent-pages.docblocks";
import { SeoOptimizer } from "@contractspec/lib.content-gen/seo";
import { CodeBlock } from "@contractspec/lib.design-system";
import Link from "@contractspec/lib.ui-link";
import { ChevronRight } from "lucide-react";
import { jsx, jsxs } from "react/jsx-runtime";
var metadata = new SeoOptimizer().optimize(deterministicCodegenBrief);
function DeterministicCodegenPage() {
  return /* @__PURE__ */ jsxs("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx("h1", {
            className: "text-4xl font-bold",
            children: deterministicCodegenBrief.title
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground text-lg",
            children: deterministicCodegenBrief.summary
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "card-subtle space-y-4 p-6",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Regeneration Challenges"
          }),
          /* @__PURE__ */ jsx("ul", {
            className: "text-muted-foreground space-y-2 text-sm",
            children: deterministicCodegenBrief.problems.map((problem, index) => /* @__PURE__ */ jsx("li", {
              children: problem
            }, index))
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "card-subtle space-y-4 p-6",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Deterministic Solutions"
          }),
          /* @__PURE__ */ jsx("ul", {
            className: "text-muted-foreground space-y-2 text-sm",
            children: deterministicCodegenBrief.solutions.map((solution, index) => /* @__PURE__ */ jsx("li", {
              children: solution
            }, index))
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-6",
        children: [
          /* @__PURE__ */ jsxs("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx("h2", {
                className: "text-2xl font-bold",
                children: "Protected Zones"
              }),
              /* @__PURE__ */ jsx("p", {
                className: "text-muted-foreground text-sm",
                children: "Separate generated code from hand-written business logic with clear boundaries."
              }),
              /* @__PURE__ */ jsx(CodeBlock, {
                language: "typescript",
                filename: "src/handlers/user-handlers.ts",
                code: `// Hand-written business logic (protected from regeneration)
export class UserService {
  async createUser(input: CreateUserInput): Promise<CreateUserOutput> {
    // Custom validation and business rules
    if (await this.emailExists(input.email)) {
      throw new Error('Email already exists');
    }
    
    // Persistence logic
    const user = await this.repository.create({
      email: input.email,
      name: input.name,
      password: await this.hashPassword(input.password),
    });
    
    return {
      id: user.id,
      email: user.email,
      name: user.name,
      createdAt: user.createdAt.toISOString(),
    };
  }
  
  private async emailExists(email: string): Promise<boolean> {
    // Custom business validation
    return !!(await this.repository.findByEmail(email));
  }
}

// Generated handler wrapper (can be regenerated safely)
export const createUserHandler = wrapOperationHandler(
  UserService.prototype.createUser,
  {
    serviceName: 'UserService',
    operationName: 'createUser',
    errorMapper: mapToStandardErrors,
  }
);`
              })
            ]
          }),
          /* @__PURE__ */ jsxs("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx("h2", {
                className: "text-2xl font-bold",
                children: "Incremental Regeneration"
              }),
              /* @__PURE__ */ jsx("p", {
                className: "text-muted-foreground text-sm",
                children: "Regenerate only what changed while preserving custom logic."
              }),
              /* @__PURE__ */ jsx(CodeBlock, {
                language: "bash",
                filename: "incremental-regen",
                code: `contractspec generate \\
  --incremental \\
  --preserve-zones ./src/handlers/*.ts \\
  --input ./src/contracts/ \\
  --output ./generated/`
              })
            ]
          }),
          /* @__PURE__ */ jsxs("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx("h2", {
                className: "text-2xl font-bold",
                children: "Conflict Detection"
              }),
              /* @__PURE__ */ jsx("p", {
                className: "text-muted-foreground text-sm",
                children: "Automatically detect and report conflicts during regeneration."
              }),
              /* @__PURE__ */ jsx(CodeBlock, {
                language: "bash",
                filename: "check-conflicts",
                code: `contractspec generate \\
  --check-conflicts \\
  --report-conflicts ./conflicts.json`
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsxs(Link, {
            href: "/docs/guides/generate-docs-clients-schemas",
            className: "btn-primary",
            children: [
              "Client Generation ",
              /* @__PURE__ */ jsx(ChevronRight, {
                size: 16
              })
            ]
          }),
          /* @__PURE__ */ jsx(Link, {
            href: "/docs/intent/schema-validation-typescript",
            className: "btn-ghost",
            children: "Type Safety"
          })
        ]
      })
    ]
  });
}
export {
  metadata,
  DeterministicCodegenPage
};
