import type { DrizzleClient } from '../client';
import { insertSystemConfigIfMissing, setSystemConfig } from '../queries/system-config';

export async function seedSupportSystemConfig(
  db: DrizzleClient,
  adminId: string | null = null,
): Promise<void> {
  // Model resolver keys — not in SystemConfigKey union, inserted directly.
  await insertSystemConfigIfMissing(db, 'model:IMAGE_APPROVAL', 'gemini-3.1-flash-lite');

  const defaults: Array<[string, string]> = [
    ['support_vendor_window_hours', '48'],
    ['support_sla_ai_hours', '2'],
    ['support_sla_human_hours', '24'],
    ['support_autoclose_days', '7'],
    ['support_auto_refund_cap_cents', '5000'],
    ['support_ai_confidence_threshold', '0.8'],
    ['support_ai_max_tool_calls', '12'],
    ['support_ai_max_cost_cents', '50'],
    ['support_notification_emails', '[]'],
    ['support_media_max_images', '10'],
    ['support_media_max_mb', '10'],
    ['support_return_window_days', '30'],
    ['support_reopen_limit', '2'],
  ];
  for (const [k, v] of defaults) {
    await setSystemConfig(db, k as Parameters<typeof setSystemConfig>[1], v, adminId ?? undefined);
  }
}
