// V23.5 — 3D LUT Preset Library
//
// Built-in colour-grading .cube presets. Each LUT is a 17×17×17 RGB
// remapping table stored in /public/luts/{name}.cube.
//
// FFmpeg filter: `lut3d=file=/path/to.cube`. We use Next.js public
// asset path so the file is fetched from the same origin and FFmpeg.wasm
// can `readFile` it from the wasm filesystem after we copy it in.

export interface LutPreset {
  /** Internal id (also the file basename without extension). */
  id: string;
  /** Display label (Thai). */
  label: string;
  /** English subtitle for the picker. */
  subtitle: string;
  /** Hue swatch emoji or hex used for the picker preview. */
  swatch: string;
  /** Public asset URL (relative to /). */
  url: string;
}

export const LUT_PRESETS: LutPreset[] = [
  {
    id: 'teal-orange',
    label: 'ทีล & ออเรนจ์',
    subtitle: 'Teal & Orange',
    swatch: 'linear-gradient(135deg, #1a5d7a 0%, #ff6b35 100%)',
    url: '/luts/teal-orange.cube',
  },
  {
    id: 'cinematic',
    label: 'Cinematic F35',
    subtitle: 'Hollywood film look',
    swatch: 'linear-gradient(135deg, #0f3a5f 0%, #d4a574 100%)',
    url: '/luts/cinematic.cube',
  },
  {
    id: 'vintage',
    label: 'วินเทจ',
    subtitle: 'Vintage Film',
    swatch: 'linear-gradient(135deg, #c9a96e 0%, #6b4423 100%)',
    url: '/luts/vintage.cube',
  },
  {
    id: 'bw',
    label: 'ขาว-ดำ',
    subtitle: 'Black & White',
    swatch: 'linear-gradient(135deg, #404040 0%, #d0d0d0 100%)',
    url: '/luts/bw.cube',
  },
  {
    id: 'noir',
    label: 'ฟิล์มนัวร์',
    subtitle: 'Film Noir',
    swatch: 'linear-gradient(135deg, #0a0a0a 0%, #555 100%)',
    url: '/luts/noir.cube',
  },
  {
    id: 'warm',
    label: 'โทนอุ่น',
    subtitle: 'Warm Instagram',
    swatch: 'linear-gradient(135deg, #ffb37a 0%, #ff6b6b 100%)',
    url: '/luts/warm.cube',
  },
];

/** Lookup by preset id; returns undefined if not found. */
export function getLutPreset(id: string | undefined): LutPreset | undefined {
  if (!id) return undefined;
  return LUT_PRESETS.find((p) => p.id === id);
}