import { z } from "zod";

export const DEFAULT_SLOW_RESPONSE_THRESHOLD_SECONDS = 10;
export const MAX_SLOW_RESPONSE_THRESHOLD_SECONDS = 600;

/**
 * Schema for the runtime proxy config. Shared between server
 * (src/proxy/config.ts) and client (src/lib/useStripConfig.ts) so that
 * the wire format is validated end-to-end with a single source of truth.
 *
 * Keep this file free of side effects and Node-only imports so it is
 * safe to bundle into the client.
 */
export const RuntimeConfigSchema = z.object({
  stripClaudeCodeBillingHeader: z.boolean(),
  hasSeenOnboarding: z.boolean().default(false),
  slowResponseThresholdSeconds: z
    .number()
    .int()
    .min(0)
    .max(MAX_SLOW_RESPONSE_THRESHOLD_SECONDS)
    .default(DEFAULT_SLOW_RESPONSE_THRESHOLD_SECONDS),
});

export type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
