/**
 * Settings validation schema for PageCaching
 * Auto-generated from baseline.json
 * 
 * @module Performance/PageCaching
 * @since 0.1.0
 */

import { z } from 'zod';

/**
 * Settings schema for PageCaching
 */
export const PageCachingSchema = z.object({
  enable_page_cache: z.boolean().default(false),  // Enable page caching
  cache_expiry_time: z.number().int().min(60).max(604800).default(3600),  // Cache expiry time in seconds
  cache_logged_in_users: z.boolean().default(false),  // Cache pages for logged-in users
  exclude_urls: z.array(z.string()).default(["/cart","/checkout","/my-account"]),  // URLs to exclude from caching
  exclude_cookies: z.array(z.string()).default(["wordpress_logged_in_","woocommerce_cart_hash"]),  // Cookies that prevent caching
  exclude_user_agents: z.array(z.string()).default([]),  // User agents to exclude from cache
  enable_mobile_cache: z.boolean().default(true),  // Separate cache for mobile devices
  preload_cache: z.boolean().default(false),  // Preload cache after purge
  cache_query_strings: z.boolean().default(false),  // Cache pages with query strings
  compression_level: z.enum(['none', 'normal', 'high']).default('normal'),  // GZIP compression level
});

/**
 * TypeScript type for PageCaching settings
 */
export type PageCachingSettings = z.infer<typeof PageCachingSchema>;

/**
 * Default values for PageCaching settings
 */
export const PageCachingDefaults: PageCachingSettings = PageCachingSchema.parse({});

/**
 * Validate PageCaching settings
 */
export function validatePageCachingSettings(data: unknown): PageCachingSettings {
  return PageCachingSchema.parse(data);
}

/**
 * Safely validate PageCaching settings (returns validation result)
 */
export function safeValidatePageCachingSettings(data: unknown) {
  return PageCachingSchema.safeParse(data);
}
