"""Server-rendered review; no scripts, telemetry or browser-held bearer token.""" from html import escape from urllib.parse import quote import uuid from .disposition import Verb, legal_verbs STYLES = """ :root{color-scheme:light;font-family:system-ui,sans-serif;color:#172d35;background:#f4f5ef} *{box-sizing:border-box}body{margin:0}a{color:#145c65}header{background:#173d43;color:white;padding:1.25rem max(1.25rem,calc((100vw - 1080px)/2));display:flex;justify-content:space-between;align-items:center;gap:1rem}header a{color:inherit;text-decoration:none;font-weight:700}header small{color:#d2e8df}main{max-width:1080px;margin:2.5rem auto;padding:0 1.25rem}h1{font-size:clamp(1.7rem,3vw,2.6rem);line-height:1.2;max-width:850px}h2{font-size:1.2rem;margin-top:0}h3{font-size:1rem}p,li{line-height:1.6}.eyebrow{font-size:.75rem;letter-spacing:.1em;text-transform:uppercase;color:#486a6f}.grid{display:grid;grid-template-columns:minmax(0,2fr) minmax(230px,1fr);gap:1.25rem;align-items:start}.card{background:white;border:1px solid #d9dfd7;border-radius:12px;padding:1.5rem;margin-bottom:1.25rem}.notice{padding:1rem 1.25rem;border-left:4px solid #356f63;background:#e3eee7;margin:1.25rem 0}.warning{border-color:#a26814;background:#fff1d6}dl{margin:0}dt{font-size:.8rem;color:#5e7375;margin-top:1rem}dt:first-child{margin-top:0}dd{margin:.3rem 0;overflow-wrap:anywhere}pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:.88rem;line-height:1.5;background:#f3f5f0;padding:1rem;border-radius:6px}button{font:inherit;font-weight:600;border:1px solid #1f6460;border-radius:7px;padding:.7rem 1.1rem;background:#23665d;color:white;cursor:pointer}button.secondary{background:white;color:#244d50}button:disabled{opacity:.45;cursor:not-allowed}input,select,textarea{font:inherit;max-width:100%;padding:.65rem;border:1px solid #9badaa;border-radius:5px}input[type=checkbox]{width:1.2rem;height:1.2rem;vertical-align:middle;margin-right:.6rem}label{display:block;line-height:1.5;margin:.7rem 0}textarea{display:block;width:100%;min-height:90px}.muted{font-size:.9rem;color:#567074}.brief{white-space:pre-wrap}.actions{display:flex;flex-wrap:wrap;gap:.7rem}.highlight{padding:.9rem 0;border-bottom:1px solid #e3e8df}.highlight:last-of-type{border-bottom:0}details{margin:1rem 0}summary{cursor:pointer;font-weight:600}.hash{overflow-wrap:anywhere;font-family:monospace;font-size:.8rem}.record{padding:.7rem 0;border-bottom:1px solid #e3e8df}:focus-visible{outline:3px solid #b67e19;outline-offset:3px}footer{padding:1.5rem 0;color:#567074;font-size:.85rem}@media(max-width:740px){.grid{grid-template-columns:1fr}main{margin:1.5rem auto}header{align-items:start;flex-direction:column}} """ def text(value): return escape(str(value), quote=True) def document(title, content, subject=None): return ('
' '' f''+text(message) +'
', subject) def review_page(page, session): memo, p = page.memo, page.presentation base = "/presentations/" + quote(p.id, safe="") csrf = hidden("csrf", session.csrf) missing = memo.required_ack_ids - p.acked_highlight_ids legal = legal_verbs(memo.step_kind) intent = page.intent blocked = page.stale or page.engine_status not in ("requested", "approved") accepted = intent and intent["state"] == "confirmed" uncertain = intent and intent["state"] in ("in_flight", "unresolved") if accepted: notice = '{text(h.note)}
' f'Document: {text(h.item_id)} · {"Required acknowledgment" if h.required_ack else "Optional acknowledgment"}
' + (control if not blocked and not accepted and not uncertain else ('Acknowledged
' if acked else 'Not acknowledged
')) + '{text(preview)}' if preview is not None else 'Open the complete attachment to review this document.
') + f'Download complete document{text(item.hash)}
No attachments.
') + '{text(value)}
' for label, value in (("Terms", memo.binding.terms), ("Justification", memo.binding.justification)) if value) forms = '' if not blocked and not accepted and not uncertain: for verb, label in ((Verb.ACCEPT, "Accept the complete request"), (Verb.RETURN, "Return for improvement"), (Verb.DISCUSS, "Request discussion"), (Verb.DECLINE, "Decline")): if verb not in legal: continue operation = intent["operation_id"] if intent and verb is Verb.ACCEPT else str(uuid.uuid4()) fields = csrf + hidden("verb", verb.value) + hidden("operation_id", operation) if verb is Verb.RETURN: fields += '' if verb in (Verb.RETURN, Verb.DISCUSS): fields += '' disabled = ' disabled' if missing and verb in (Verb.ACCEPT, Verb.DECLINE) else '' forms += (f'Record all required acknowledgments before accepting or declining.
' + forms records = ''.join(f'{text(d.note)}
' if d.note else '') + 'Memo {text(memo.id)} · version {memo.version}
' f'Presentation {text(p.id)}
View: {text(p.view_hash)}
' f'Act: {text(memo.approval_binding_digest)}
' f'Account zone: {text(session.tenant.value)} ({text(session.tenant.route.value)}). This is separate from the act scope.
Decision review · version {memo.version}
{text(memo.requested_act)}
{text(memo.brief)}
{terms}No new approval submission is available from this record.
') + (f'