{
  "$schema": "../../schema.json",
  "id": "flash",
  "type": "transition",
  "title": "Flash",
  "summary": "An overexposed white flash hides the cut from A to B.",
  "tags": [
    "transition",
    "energetic",
    "impact"
  ],
  "version": "1.0.0",
  "license": "MIT",
  "export": "flash",
  "signature": "flash(a, b, p, { color, bloom, peak })",
  "params": [
    {
      "name": "color",
      "type": "color",
      "default": "#fff",
      "description": "color (CSS)",
      "control": "color",
      "group": "main"
    },
    {
      "name": "bloom",
      "type": "number",
      "default": 18,
      "description": "blur at the peak in px",
      "min": 0,
      "max": 60,
      "step": 1,
      "group": "main"
    },
    {
      "name": "peak",
      "type": "number",
      "default": 0.4,
      "description": "where the flash peaks (0–1)",
      "min": 0.1,
      "max": 0.9,
      "step": 0.01,
      "group": "main"
    }
  ],
  "install": {
    "kind": "code"
  },
  "files": [
    {
      "path": "moves/flash.js",
      "content": "import { ease, clamp } from 'paper-motion';\n\n/** An overexposed white flash: A burns out, the cut happens at the peak, B comes back from the white. */\nexport function flash(a, b, p, { color = '#fff', bloom = 18, peak = 0.4 } = {}) {\n  const parent = a.parentElement;\n  let o = parent.querySelector(':scope > .lab-flash');\n  if (!o) { o = document.createElement('div'); o.className = 'lab-flash'; Object.assign(o.style, { position: 'absolute', inset: 0, background: color, pointerEvents: 'none', zIndex: 50 }); parent.append(o); }\n  const up = ease.inCubic(clamp(p / peak)), down = 1 - ease.outCubic(clamp((p - peak) / (1 - peak)));\n  const k = p < peak ? up : down;\n  o.style.opacity = p <= 0 || p >= 1 ? 0 : k;\n  const cur = p < peak ? a : b;\n  a.style.opacity = p < peak ? 1 : 0; b.style.opacity = p < peak ? 0 : 1;\n  cur.style.filter = k > 0.02 ? `blur(${bloom * k}px) brightness(${1 + 1.5 * k})` : 'none';\n  cur.style.transform = `scale(${1 + 0.04 * k})`;\n}\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.0"
  },
  "usage": "import { flash } from './moves/flash.js';\n\n// two stacked layers, B above A; in s.update(t), from 2.0 s to 2.6 s:\nflash(a, b, progress(t, 2.0, 2.6));",
  "notes": [
    "An overexposed white flash: A burns out, the cut happens at the peak, B comes back from the white.",
    "At p = 0 only A shows, at p = 1 only B; keep B above A (z-index)."
  ],
  "preview": {
    "video": "previews/flash.webm",
    "poster": "previews/flash.jpg"
  },
  "mood": [
    "bold",
    "raw"
  ],
  "energy": 5,
  "role": "swap",
  "when": [
    "hiding a cut with an impact",
    "a drop, a reveal, a shout"
  ]
}