/**
 * pres/backgrounds — dispatch for the six background styles.
 *
 * Every style is a function `(slide, resolved, opts)` that mutates the
 * pptxgenjs slide in-place, adding a background colour + any decorative
 * shapes that sit behind content. Archetypes can call this once per
 * slide; the global theme picks the default style, per-slide overrides
 * win.
 */
import solid from './solid.js';
import gradient from './gradient.js';
import mesh from './mesh.js';
import noise from './noise.js';
import geometric from './geometric.js';
import grid from './grid.js';
import voidBg from './void.js';
import orb from './orb.js';

const BACKGROUNDS = {
  solid, gradient, mesh, noise, geometric, grid, void: voidBg, orb,
};

export function listBackgrounds() {
  return Object.keys(BACKGROUNDS);
}

/**
 * Apply a background style to a slide.
 *   - `style`: one of solid | gradient | mesh | noise | geometric | grid
 *   - `resolved`: full resolved theme (palette + decoration config)
 *   - `opts.seed`: optional integer for deterministic randomisation
 *
 * Unknown styles fall back to solid — never errors.
 */
export function applyBackground(slide, resolved, style, opts = {}) {
  const fn = BACKGROUNDS[style] || BACKGROUNDS.solid;
  fn(slide, resolved, opts);
}
