#!/usr/bin/env python3
"""Monster High picker v5 — Style A "Editorial Light" + dark mode.
- light theme default (auto follows system), manual toggle in header
- bursts collapsed to one motion cell; tap opens group with RANGE + copy button
- lightbox: arrows/swipe, favorite, counter
- live sync: every selection POSTs to /picks on the mini (no download needed)
Usage: python3 build_picker_v5.py bursts.json
"""
import json, sys
from pathlib import Path
SHOOT = Path("/Volumes/Sam Storage/YellowMellow/2026/Monster High Theme (10:01:2026)")
PRE = SHOOT / "ClientPicker" / "Previews"
OUT = SHOOT / "Monster High - Photo Picker.html"
ids = sorted(p.stem for p in PRE.glob("*.jpg") if not p.name.startswith("._"))
assert ids, "no previews"
idset = set(ids)
bursts = json.load(open(sys.argv[1]))
burst_frames, frame_burst = {}, {}
for k, v in bursts.items():
a, b = int(v["first"][4:]), int(v["last"][4:])
fr = ["7O9A%04d" % n for n in range(a, b + 1) if "7O9A%04d" % n in idset]
if not fr:
continue
burst_frames[k] = fr
for f in fr:
frame_burst[f] = k
def pretty(i): return i[:4] + "-" + i[4:]
cells, n_singles = [], 0
for i in ids:
chip, attrs, cls = "", "", ""
if i in frame_burst:
k = frame_burst[i]
if burst_frames[k][0] == i:
chip = 'MOTION ×%d' % len(burst_frames[k])
attrs = ' data-burst="%s"' % k
cls = " motion"
else:
attrs = ' data-burstframe="%s"' % k
else:
n_singles += 1
src = ("ClientPicker/Bursts/%s.webp" % k) if "data-burst=" in attrs else ("ClientPicker/Thumbs/%s.jpg" % i)
cells.append(
'%s