// @bun
var I=Object.defineProperty;var J=(w)=>w;function K(w,A){this[w]=J.bind(null,A)}var P=(w,A)=>{for(var F in A)I(w,F,{get:A[F],enumerable:!0,configurable:!0,set:K.bind(A,F)})};var Q=(w,A)=>()=>(w&&(A=w(w=0)),A);import{deterministicCodegenBrief as E}from"@contractspec/bundle.library/components/docs/intent/intent-pages.docblocks";import{SeoOptimizer as M}from"@contractspec/lib.content-gen/seo";import{CodeBlock as G}from"@contractspec/lib.design-system";import H from"@contractspec/lib.ui-link";import{ChevronRight as N}from"lucide-react";import{jsx as q,jsxs as D}from"react/jsx-runtime";var W=new M().optimize(E);function _(){return D("div",{className:"space-y-8",children:[D("div",{className:"space-y-3",children:[q("h1",{className:"font-bold text-4xl",children:E.title}),q("p",{className:"text-lg text-muted-foreground",children:E.summary})]}),D("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:E.problems.map((w,A)=>q("li",{children:w},A))})]}),D("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:E.solutions.map((w,A)=>q("li",{children:w},A))})]}),D("div",{className:"space-y-6",children:[D("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(G,{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,
  }
);`})]}),D("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(G,{language:"bash",filename:"incremental-regen",code:"contractspec generate \\\n  --incremental \\\n  --preserve-zones ./src/handlers/*.ts \\\n  --input ./src/contracts/ \\\n  --output ./generated/"})]}),D("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(G,{language:"bash",filename:"check-conflicts",code:"contractspec generate \\\n  --check-conflicts \\\n  --report-conflicts ./conflicts.json"})]})]}),D("div",{className:"flex items-center gap-4 pt-4",children:[D(H,{href:"/docs/guides/generate-docs-clients-schemas",className:"btn-primary",children:["Client Generation ",q(N,{size:16})]}),q(H,{href:"/docs/intent/schema-validation-typescript",className:"btn-ghost",children:"Type Safety"})]})]})}export{W as metadata,_ as DeterministicCodegenPage};
