/**
 * Image filter presets for photo elements.
 *
 * Each preset can specify ONE of two ways to identify its filter:
 *   - `konva`: a string name looked up on `Konva.Filters` at apply time.
 *     Used for built-in Konva filters (Grayscale, Sepia, etc.). We avoid
 *     importing Konva here so consumers (e.g. ElementToolbar) that only
 *     iterate the list for UI don't pay the bundle cost.
 *   - `customFn`: a direct function reference (a Konva-compatible filter
 *     that mutates ImageData in place). Used for filters that don't ship
 *     with Konva — e.g. the `warm` preset uses Filerobot's Kelvin filter.
 *
 * Lookup order in ImageElement: `customFn ?? Konva.Filters[konva] ?? null`.
 *
 * Each preset can also carry default attribute values that Konva reads
 * during filter application — `Brighten` reads `brightness`, `Contrast`
 * reads `contrast`, etc. Presets currently only use the basic toggle-style
 * filters; the schema supports parameter passing for future presets.
 *
 * Server-side note
 * ────────────────
 * The print export pipeline (server.js → applyFilterToSharp) currently
 * mirrors grayscale, sepia, and invert via sharp. The `warm`/Kelvin preset
 * is editor-only — exports silently skip it — so the printed shirt won't
 * match the on-screen preview for warm-filtered photos until a sharp
 * implementation is added.
 */

import KelvinFilter from 'react-filerobot-image-editor/lib/custom/filters/Kelvin';

export const IMAGE_FILTERS = [
  {
    id: 'none',
    label: 'Original',
    konva: null,
    icon: '◯',
  },
  {
    id: 'grayscale',
    label: 'B&W',
    konva: 'Grayscale',
    icon: '◐',
  },
  {
    id: 'sepia',
    label: 'Sepia',
    konva: 'Sepia',
    icon: '◑',
  },
  {
    id: 'warm',
    label: 'Warm',
    customFn: KelvinFilter,
    icon: '◓',
  },
];

export function getFilterPreset(id) {
  return IMAGE_FILTERS.find((f) => f.id === id) || IMAGE_FILTERS[0];
}
