import{deterministicCodegenBrief as A}from"@contractspec/bundle.library/components/docs/intent/intent-pages.docblocks";import{SeoOptimizer as H}from"@contractspec/lib.content-gen/seo";import{CodeBlock as F}from"@contractspec/lib.design-system";import G from"@contractspec/lib.ui-link";import{ChevronRight as I}from"lucide-react";import{jsx as q,jsxs as w}from"react/jsx-runtime";var M=new H().optimize(A);function T(){return w("div",{className:"space-y-8",children:[w("div",{className:"space-y-3",children:[q("h1",{className:"font-bold text-4xl",children:A.title}),q("p",{className:"text-lg text-muted-foreground",children:A.summary})]}),w("div",{className:"card-subtle space-y-4 p-6",children:[q("h2",{className:"font-bold text-2xl",children:"Regeneration Challenges"}),q("ul",{className:"space-y-2 text-muted-foreground text-sm",children:A.problems.map((D,E)=>q("li",{children:D},E))})]}),w("div",{className:"card-subtle space-y-4 p-6",children:[q("h2",{className:"font-bold text-2xl",children:"Deterministic Solutions"}),q("ul",{className:"space-y-2 text-muted-foreground text-sm",children:A.solutions.map((D,E)=>q("li",{children:D},E))})]}),w("div",{className:"space-y-6",children:[w("div",{className:"space-y-3",children:[q("h2",{className:"font-bold text-2xl",children:"Protected Zones"}),q("p",{className:"text-muted-foreground text-sm",children:"Separate generated code from hand-written business logic with clear boundaries."}),q(F,{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,
  }
);`})]}),w("div",{className:"space-y-3",children:[q("h2",{className:"font-bold text-2xl",children:"Incremental Regeneration"}),q("p",{className:"text-muted-foreground text-sm",children:"Regenerate only what changed while preserving custom logic."}),q(F,{language:"bash",filename:"incremental-regen",code:"contractspec generate \\\n  --incremental \\\n  --preserve-zones ./src/handlers/*.ts \\\n  --input ./src/contracts/ \\\n  --output ./generated/"})]}),w("div",{className:"space-y-3",children:[q("h2",{className:"font-bold text-2xl",children:"Conflict Detection"}),q("p",{className:"text-muted-foreground text-sm",children:"Automatically detect and report conflicts during regeneration."}),q(F,{language:"bash",filename:"check-conflicts",code:"contractspec generate \\\n  --check-conflicts \\\n  --report-conflicts ./conflicts.json"})]})]}),w("div",{className:"flex items-center gap-4 pt-4",children:[w(G,{href:"/docs/guides/generate-docs-clients-schemas",className:"btn-primary",children:["Client Generation ",q(I,{size:16})]}),q(G,{href:"/docs/intent/schema-validation-typescript",className:"btn-ghost",children:"Type Safety"})]})]})}export{M as metadata,T as DeterministicCodegenPage};
