{# Ops Console semantic chip macros (V3 #208).
Canonical label-to-semantic mapping for the Ops Console chip system.
Import: {% from "fragments/_chips.html" import chip %}
Usage: {{ chip("done") }} {{ chip("2 voices need you") }}
The mapping is the single source; R1-R6 consume it via the macro.
Extending: add a row to CHIP_MAP below and the CSS class if needed. #}
{# Map: label → (css_class, display_text). Labels are the canonical
user-facing strings from the design spec (#208). #}
{% set CHIP_MAP = {
"verified": ("chip-ok", "✓ verified"),
"verified by you": ("chip-ok", "✓ verified by you"),
"reviewed": ("chip-ok", "✓ reviewed"),
"all reviewed": ("chip-ok", "✓ all reviewed"),
"done": ("chip-ok", "done"),
"transcribing": ("chip-info", none),
"needs you": ("chip-warn", "needs you"),
"need you": ("chip-warn", none),
"failed": ("chip-danger", "failed"),
"active": ("chip-ok", "active"),
"watched": ("chip-accent", "watched"),
"learned": ("chip-info", none),
"unknown": ("chip-neutral", "unknown"),
} %}
{# Count-inflected "needs you" chip. Owns BOTH the inflection ("1 voice needs
you" / "2 voices need you") and the warn class, so call sites cannot drift
into subject-verb disagreement or fall through the exact-key chip() lookup
to chip-neutral (which "2 voices need you" did on the jobs page). #}
{% macro needs_you_chip(count) -%}
{{ count }} voice{{ "s" if count != 1 else "" }} need{{ "s" if count == 1 else "" }} you
{%- endmacro %}
{% macro chip(label, extra_class="") -%}
{%- set key = label.split()[0] if label.split()[0] in ["transcribing", "learned"] else label.lower().rstrip("s") if label.lower().rstrip("s") in CHIP_MAP else label.lower() -%}
{%- set entry = CHIP_MAP.get(key, ("chip-neutral", none)) -%}
{%- endmacro %}