"""One-shot fix: friendlier Step-12 review labels for auto-convert attach modes."""
from pathlib import Path

p = Path("static/js/pages/campaigns.js")
lines = p.read_text(encoding="utf-8").split("\n")

idx = next(i for i, l in enumerate(lines) if "<dt>Attachments</dt>" in l)
assert "attach_mode" in lines[idx], lines[idx]

new = """            <dt>Attachments</dt><dd>${(() => { const m = C.attach_mode;
              if (m === "none") return "none";
              const lbl = { body_pdf: "Auto-convert body \u2192 PDF", body_image: "Auto-convert body \u2192 PNG image", body_word: "Auto-convert body \u2192 Word (.docx)" };
              if (lbl[m]) return lbl[m];
              return esc(m) + (m === "pdf" && C.attach_pdf_template_id ? ` \u2014 template #${C.attach_pdf_template_id}` : "") +
                (m !== "pdf" && m !== "none" && C.attachment_id ? ` \u2014 attachment #${C.attachment_id}` : ""); })()}</dd>"""

# The old block spans 3 lines (idx..idx+2); replace them.
assert lines[idx + 2].rstrip().endswith("</dd>"), lines[idx + 2]
lines[idx:idx + 3] = new.split("\n")
p.write_text("\n".join(lines), encoding="utf-8")
print("Review labels updated at line", idx + 1)
