/** * — escalation-only async human handoff * (spec: docs/superpowers/specs/2026-08-13-async-handoff-crisp-design.md). * Five states: form (compose only) → email (optional, fallback framing) → * sent → mail ("You got mail!") → flipped (reply + inline follow-up). All * delivery through an injected SupportChatBridge; fail closed when the * bridge is absent or the vendor SDK undetected. * * REDESIGN (owner brief, 2026-08-13): the compose step used to bundle an * email input + message textarea + one Send button into a single * "required everything up front" form. That's backwards — the message is * the thing that matters (it's already drafted for the visitor); email is * a nice-to-have fallback for if they leave the page before a reply * arrives. So: send the message FIRST (compose step, message box only), * THEN ask for email as a distinct, skippable second step. Every visitor- * facing string moved to `copy` (workspace configuration) — the bundle * ships no English fallback text anywhere; absent copy means that piece * does not render (mirrors the pre-existing `replyToast` precedent). * * FINAL LAYOUT CORRECTION (owner, same day): the send/submit control lives * INSIDE the field's own border — bottom-right, exactly like * ``'s composer — never below the field, never beside it as a * sibling button. And nothing renders below the field's box at all: one * line of framing/prompt copy above it, then the box, full stop (the card * is clamped to ~276px by the deck it lives in). See `fieldWrapStyles` / * `embeddedIconButtonStyles` below for the mechanics, and `srOnlyStyles` * for how a field still gets a REAL accessible label without spending any * of that vertical budget. * * SECOND CORRECTION (owner, same day): "why is it reinventing the wheel" * — the live-chat face mounts the REAL `` transcript * renderer (`./AdaptiveChatTrail.ts`) instead of hand-rolled bubble * markup. It is explicitly NOT bound to the concierge's shared * `chatSession` singleton (`./ChatSession.ts`) — this file never imports * that module, directly or transitively (the trail's own import graph is * `@syntrologie/chat` + `lit` only). Each card owns its own * `_transcript` instance field and feeds it to its own * `` element; see `LeaveAMessageLit.test.ts`'s * singleton-isolation suite for the mutation-proven guarantee. */ import { LitElement, nothing } from 'lit'; import './AdaptiveChatTrail.js'; import type { SupportChatBridge } from './support-chat/types'; /** One line of the visitor↔operator conversation, persisted so a page * remount can rebuild the exact transcript in order. */ export interface TranscriptEntry { role: 'visitor' | 'operator'; text: string; } /** Namespace + key the widget persists {state, transcript, email} under * via `runtime.state.ns()` (I2, final-review fixes 2026-08-13) — * see `LeaveAMessageLit#_loadPersisted` / `#_persist`. The page-level * inbox (support-chat/inbox.ts) writes the same record when a team * message arrives with no card mounted, so the next card picks it up. */ export declare const LEAVE_A_MESSAGE_PERSIST_NAMESPACE = "supportchat"; export declare const LEAVE_A_MESSAGE_PERSIST_KEY = "leave-a-message"; export type LeaveAMessageState = 'form' | 'email' | 'sent' | 'mail' | 'flipped'; export declare function liveLeaveAMessageCards(): ReadonlySet; /** * Every visitor-facing string on this card — authored entirely by the * workspace (`default_widget_props.copy`), same pattern as `replyToast`. * The bundle ships NO English fallback for any of these: absent copy means * that piece of UI does not render. For the icon-only send/submit * controls this isn't just a style choice — an icon button with no * accessible name is a real usability defect, so `sendLabel` / * `emailSubmitLabel` / `replySendLabel` double as BOTH the control's * aria-label AND the gate on whether the control renders at all. */ export interface LeaveAMessageCopy { /** Framing line above the message box (form step) — explains the * message was drafted from the conversation and remains editable. */ framing?: string; /** Accessible (visually-hidden) label for the message textarea. */ messageLabel?: string; /** Accessible name for the compose step's embedded send control. * Absence removes the control (see interface doc above). */ sendLabel?: string; /** Prompt shown on the email step — frames the address as optional, a * fallback for a reply if the visitor leaves the page. */ emailPrompt?: string; /** Accessible (visually-hidden) label for the email input. */ emailLabel?: string; /** Placeholder for the email input — distinct copy from the label, never * doubling as it. */ emailPlaceholder?: string; /** Accessible name for the email step's embedded submit control. * Absence removes the control. */ emailSubmitLabel?: string; /** Quiet inline decline text, beside the email field. Absence removes * the control — the visitor can still get the same effect by * submitting a blank field. */ emailSkipLabel?: string; /** Confirmation paragraph shown in the 'sent' state. */ sentBody?: string; /** Button text for the 'mail' state ("You got mail!" tap target). */ mailLabel?: string; /** Accessible (visually-hidden) label for the reply input. */ replyLabel?: string; /** Placeholder for the reply input (flipped state). */ replyPlaceholder?: string; /** Accessible name for the flipped state's embedded send control. * Absence removes the control. */ replySendLabel?: string; } /** * Minimal runtime slice the widget needs to raise the "You got mail!" * toast — mirrors adaptive-nav's `NavWidgetRuntime.events` shape (see * `NavWidgetLit#publishEvent`) so tile `notifications` rules (which * subscribe to the runtime EventBus, not DOM CustomEvents) can match * on `supportchat:reply_received`. */ export interface LeaveAMessageRuntime { events: { publish: (name: string, props?: Record) => void; }; /** * Optional persistence seam (I2, final-review fixes 2026-08-13) — mirrors * adaptive-overlays' `WorkflowWidgetLit.runtimeRef?.state?.ns?.(...)` * pattern exactly. On an MPA the tile unmounts and remounts fresh per * page; without this, a visitor who already sent a message and is * waiting on a reply loses that thread on their very next click (state * resets to 'form', the operator's reply becomes invisible). Optional * because older host bundles / the playground don't inject it — the * widget still works, it just can't survive navigation. */ state?: { ns?: (namespace: string) => { get: (key: string) => unknown; set: (key: string, value: unknown) => void; }; }; } /** Shape persisted under `runtime.state.ns('supportchat')`. */ export interface PersistedLeaveAMessage { state?: LeaveAMessageState; transcript?: TranscriptEntry[]; email?: string; } export declare class LeaveAMessageLit extends LitElement { static properties: { bridge: { attribute: boolean; }; message: { type: StringConstructor; }; contextSummary: { attribute: boolean; }; state: { type: StringConstructor; }; runtime: { attribute: boolean; }; replyToast: { attribute: boolean; }; copy: { attribute: boolean; }; }; bridge: SupportChatBridge | undefined; message: string; contextSummary: string; state: LeaveAMessageState; /** Runtime plumbing injected by the mountable — undefined outside a live SDK mount. */ runtime: LeaveAMessageRuntime | undefined; /** * Visitor-facing toast copy, authored by the WORKSPACE CONFIG * (`default_widget_props.replyToast`) — presentation belongs to * configuration, not to this bundle: every workspace has its own voice * and language. The built-in fallback below exists only so an * unconfigured mount still says something truthful. */ replyToast: { title?: string; body?: string; } | undefined; /** Every OTHER visitor-facing string on this card — see * `LeaveAMessageCopy` doc. */ copy: LeaveAMessageCopy | undefined; /** Unique per-instance id prefix so `