@syntrologie/adapt-chatbot 2.8.0-canary.317 → 2.8.0-canary.319

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"AdaptiveChatBar.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatBar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAGhD,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;MAOxB;IAEF,QAAQ,EAAE,YAAY,EAAE,CAAM;IAE9B;;;uDAGmD;IACnD,aAAa,UAAS;IACtB,WAAW,SAAuB;IAClC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAa;IACzC;;;;;;OAMG;IACH,QAAQ,UAAS;IACjB,MAAM,SAAM;IAEH,gBAAgB,IAAI,WAAW;IAUxC,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,UAAU,CAShB;IAKF,OAAO,CAAC,kBAAkB,CAMxB;IAEF,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,KAAK;IAoBJ,MAAM;CAyChB;AAmPD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
1
+ {"version":3,"file":"AdaptiveChatBar.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatBar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAGhD,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;MAOxB;IAEF,QAAQ,EAAE,YAAY,EAAE,CAAM;IAE9B;;;uDAGmD;IACnD,aAAa,UAAS;IACtB,WAAW,SAAuB;IAClC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAa;IACzC;;;;;;OAMG;IACH,QAAQ,UAAS;IACjB,MAAM,SAAM;IAEH,gBAAgB,IAAI,WAAW;IAUxC,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,UAAU,CAShB;IAKF,OAAO,CAAC,kBAAkB,CAMxB;IAEF,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,KAAK;IAoBJ,MAAM;CA0ChB;AAmPD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AdaptiveChatBar
3
- } from "./chunk-SCVTTLFJ.js";
4
- import "./chunk-BNN5YLN3.js";
3
+ } from "./chunk-OCDIFF6G.js";
4
+ import "./chunk-VHMHUS45.js";
5
5
  import "./chunk-ONGGPQER.js";
6
6
  import "./chunk-UVKRO5ER.js";
7
7
  export {
@@ -51,11 +51,23 @@ export declare class AdaptiveChatTrail extends LitElement {
51
51
  forceExpanded: {
52
52
  type: BooleanConstructor;
53
53
  };
54
+ /**
55
+ * Mirrors `chatSession.inFlight` — true between `send()` and the
56
+ * assistant's first `receiveStart`/`receiveDelta`, OR while a
57
+ * stream is in progress. Drives the "thinking" indicator that
58
+ * fills the gap between the user's just-sent message and the
59
+ * first assistant token. Wired through AdaptiveChatBar (it owns
60
+ * the chatSession subscription and forwards inFlight as a prop).
61
+ */
62
+ inFlight: {
63
+ type: BooleanConstructor;
64
+ };
54
65
  };
55
66
  messages: TrailMessage[];
56
67
  visibleCount: number;
57
68
  expanded: boolean;
58
69
  forceExpanded: boolean;
70
+ inFlight: boolean;
59
71
  /**
60
72
  * Pre-conversation phantom assistant message. Rendered only when
61
73
  * `messages` is empty. NOT injected into chatSession state — the
@@ -74,6 +86,16 @@ export declare class AdaptiveChatTrail extends LitElement {
74
86
  */
75
87
  private _onToolCallClick;
76
88
  private _onCollapse;
89
+ /**
90
+ * Whether to render the thinking-dots chip after the last message.
91
+ * True iff a request is in flight AND the assistant hasn't started
92
+ * streaming a reply yet — once the first delta lands, the streaming
93
+ * chip's caret takes over and the thinking indicator hides so the
94
+ * visitor isn't shown both at once. Also hidden when the last
95
+ * message is an error/system message, because the request that
96
+ * "errored" is already over from the user's perspective.
97
+ */
98
+ private _shouldShowThinking;
77
99
  updated(changed: Map<string, unknown>): void;
78
100
  render(): typeof nothing | import("lit-html").TemplateResult<1>;
79
101
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AdaptiveChatTrail.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatTrail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAQ,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAIhD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;CACrE;AAED,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,6GAA6G;IAC7G,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;IAC5C,+EAA+E;IAC/E,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7B;AAqBD,qBAAa,iBAAkB,SAA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a,EAAE,CAAC;CAC7B;AAqBD,qBAAa,iBAAkB,SAAQ,UAAU;IAC/C,OAAgB,UAAU;;;;;;;;;;;;;QAKxB;;;0EAGkE;;;;QAElE;;;;;;;WAOG;;;;MAEH;IAEF,QAAQ,EAAE,YAAY,EAAE,CAAM;IAC9B,YAAY,SAAmB;IAC/B,QAAQ,UAAS;IACjB,aAAa,UAAS;IACtB,QAAQ,UAAS;IACjB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAa;IAEhC,gBAAgB,IAAI,WAAW;IAK/B,iBAAiB,IAAI,IAAI;IAKlC,OAAO,CAAC,SAAS,CAMf;IAEF;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB,CAStB;IAEF,OAAO,CAAC,WAAW,CAMjB;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IASlB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAyB5C,MAAM;CAgQhB;AAqSD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qBAAqB,EAAE,iBAAiB,CAAC;KAC1C;CACF"}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AdaptiveChatTrail
3
- } from "./chunk-BNN5YLN3.js";
3
+ } from "./chunk-VHMHUS45.js";
4
4
  import "./chunk-ONGGPQER.js";
5
5
  import "./chunk-UVKRO5ER.js";
6
6
  export {
@@ -82,6 +82,7 @@ var AdaptiveChatBar = class extends LitElement {
82
82
  .messages=${this.messages}
83
83
  .greeting=${this.greeting}
84
84
  .forceExpanded=${this.forceExpanded}
85
+ .inFlight=${this.inFlight}
85
86
  ></adaptive-chat-trail>
86
87
  <div style=${styleMap(rowStyles(this.forceExpanded))} data-chat-row>
87
88
  <span style=${styleMap(avatarStyles())} aria-hidden="true">✦</span>
@@ -331,4 +332,4 @@ if (!customElements.get("adaptive-chat-bar")) {
331
332
  export {
332
333
  AdaptiveChatBar
333
334
  };
334
- //# sourceMappingURL=chunk-SCVTTLFJ.js.map
335
+ //# sourceMappingURL=chunk-OCDIFF6G.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/AdaptiveChatBar.ts"],
4
+ "sourcesContent": ["/**\n * AdaptiveChatBar \u2014 the canvas lid composition for the chat-canvas\n * experience. Renders the bubble-up trail on top and an always-visible\n * input row below.\n *\n * Wiring contract (events out):\n * - `chat-message-sent` ({ text }): the user submitted text via Enter\n * or the send button. The owning code is responsible for pushing\n * this into the conversation history and producing a reply.\n * - `canvas-close`: the user clicked the close \u2715 button. Propagated\n * to the canvas overlay so the underlying drawer is dismissed.\n *\n * Wiring contract (props in):\n * - `messages`: the conversation trail, passed straight through to\n * `<adaptive-chat-trail>`.\n * - `placeholder`: input placeholder copy. Defaults to a generic\n * \"Ask, find, or navigate\u2026\" \u2014 the host (typically the slot's lid\n * widget mount) can override to a context-specific string.\n *\n * Light DOM. Glassmorphism is applied at the input-row level so the\n * trail above floats over the host page without chrome. See PRD \u00A74.4.\n */\n\nimport { html, LitElement, nothing } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nimport './AdaptiveChatTrail.js';\nimport type { TrailMessage } from './AdaptiveChatTrail.js';\n\nconst DEFAULT_PLACEHOLDER = 'Ask, find, or navigate\u2026';\n\nexport class AdaptiveChatBar extends LitElement {\n static override properties = {\n messages: { attribute: false },\n placeholder: { type: String },\n greeting: { type: String },\n inFlight: { type: Boolean, reflect: true },\n forceExpanded: { type: Boolean, reflect: true },\n _input: { state: true },\n };\n\n messages: TrailMessage[] = [];\n\n /** Pass-through to {@link AdaptiveChatTrail}'s ``forceExpanded`` prop.\n * Hosts that mount the chat-bar in a full-screen surface (mobile\n * panel, agent app, etc.) set this to skip the collapse affordance\n * \u2014 there is no smaller state to fall back to. */\n forceExpanded = false;\n placeholder = DEFAULT_PLACEHOLDER;\n /**\n * Initial assistant message shown before any real conversation\n * starts. Renders inside the trail as a phantom assistant chip\n * when messages.length === 0; auto-disappears as soon as the\n * first user message lands. Mirrors ChatAssistantLit's greeting.\n */\n greeting: string | undefined = undefined;\n /**\n * Whether a chat round-trip is in flight (request sent, awaiting\n * reply). The single send/stop button morphs accordingly: \u2191 when\n * ready, \u23F9 when in-flight. Parent owns this state \u2014 set true after\n * `chat-message-sent` fires, false when the reply lands or the\n * request is aborted. Enter is inert while in-flight.\n */\n inFlight = false;\n _input = '';\n\n override createRenderRoot(): HTMLElement {\n return this;\n }\n\n // Host-level styling (display, width, height, flex, etc.) is owned\n // by the container \u2014 SDK shadow root provides default rules, panel\n // overrides via design tokens (--sc-chat-bar-host-*). This adaptive\n // never sets inline styles on itself. See SmartCanvasElementLit's\n // static styles for the rule.\n\n private _onInput = (e: Event): void => {\n this._input = (e.target as HTMLInputElement).value;\n };\n\n private _onKeyDown = (e: KeyboardEvent): void => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n // Enter is the send affordance \u2014 while in-flight there's nothing\n // to send, so it's a no-op. Interrupt requires the explicit\n // \u23F9 click to avoid surprise-aborting on a stray keystroke.\n if (this.inFlight) return;\n this._send();\n }\n };\n\n // Single button. Click delegates to send-or-interrupt based on\n // current state. Same DOM node, different behavior \u2014 discoverability\n // wins from the user not having to scan for which control is active.\n private _onSendOrInterrupt = (): void => {\n if (this.inFlight) {\n this.dispatchEvent(new CustomEvent('chat-interrupt', { bubbles: true, composed: true }));\n return;\n }\n this._send();\n };\n\n private _onClose = (): void => {\n this.dispatchEvent(new CustomEvent('canvas-close', { bubbles: true, composed: true }));\n };\n\n private _send(): void {\n const text = this._input.trim();\n if (!text) return;\n this.dispatchEvent(\n new CustomEvent<{ text: string }>('chat-message-sent', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n this._input = '';\n // Drop the input value too \u2014 the input's bound value is `this._input`\n // via the render, but jsdom's two-way binding via property only takes\n // effect after the next render, so set it imperatively for the test\n // and for browser symmetry (most browsers do the right thing here\n // anyway because Lit re-renders on the state change).\n const input = this.querySelector<HTMLInputElement>('input[data-chat-input]');\n if (input) input.value = '';\n }\n\n override render() {\n return html`\n <div style=${styleMap(rootStyles(this.forceExpanded))}>\n ${this.forceExpanded ? renderHeader() : nothing}\n <adaptive-chat-trail\n .messages=${this.messages}\n .greeting=${this.greeting}\n .forceExpanded=${this.forceExpanded}\n .inFlight=${this.inFlight}\n ></adaptive-chat-trail>\n <div style=${styleMap(rowStyles(this.forceExpanded))} data-chat-row>\n <span style=${styleMap(avatarStyles())} aria-hidden=\"true\">\u2726</span>\n <input\n data-chat-input\n type=\"text\"\n placeholder=${this.placeholder}\n .value=${this._input}\n @input=${this._onInput}\n @keydown=${this._onKeyDown}\n style=${styleMap(inputStyles())}\n aria-label=\"Chat input\"\n />\n <button\n type=\"button\"\n data-chat-send\n data-state=${this.inFlight ? 'in-flight' : 'ready'}\n @click=${this._onSendOrInterrupt}\n aria-label=${this.inFlight ? 'Stop' : 'Send message'}\n title=${this.inFlight ? 'Interrupt' : 'Send'}\n style=${styleMap(sendStyles(this.inFlight))}\n >${this.inFlight ? '\u25A0' : '\u2191'}</button>\n <button\n type=\"button\"\n data-chat-close\n @click=${this._onClose}\n aria-label=\"Hide chat\"\n style=${styleMap(closeStyles())}\n >\u2715</button>\n </div>\n </div>\n `;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Styles \u2014 kept inline (Lit styleMap) so they participate in light-DOM\n// rendering and pick up host CSS variables (e.g. --sc-tile-background).\n// ---------------------------------------------------------------------------\n\nfunction rootStyles(forceExpanded: boolean): Record<string, string> {\n // When the host expects the chat to fill its container (full-screen\n // panel, agent app), we grow vertically AND wrap the whole widget in\n // its own chrome card \u2014 trail + input read as one cohesive surface\n // instead of a naked trail above a chrome'd input. Floating mounts\n // (bottom-right pinned, etc.) stay chrome-less here because their\n // chrome is owned by the host's positioned wrapper.\n if (!forceExpanded) {\n return {\n display: 'flex',\n flexDirection: 'column',\n gap: '6px',\n width: '100%',\n pointerEvents: 'auto',\n };\n }\n // Input is ABSOLUTELY positioned at the bottom of this chrome card\n // (see rowStyles forceExpanded mode). That guarantees the input is\n // always visible \u2014 even when the lid region is tighter than the\n // chat-bar would naturally want. The flex column above holds\n // header + trail; padding-bottom reserves the input's footprint so\n // trail content can never overlap.\n //\n // Priority of \"what disappears when space is tight\":\n // Trail (shrinks to 0 first via flex: 1 1 0)\n // Header (can shrink via default flex: 0 1 auto)\n // Input (NEVER \u2014 it's positioned absolute, always at the bottom)\n return {\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '8px',\n width: '100%',\n height: '100%',\n boxSizing: 'border-box',\n flex: '1 1 auto',\n minHeight: '0',\n overflow: 'hidden',\n pointerEvents: 'auto',\n background: 'var(--sc-tile-background, rgba(255, 255, 255, 0.92))',\n border: 'var(--sc-tile-border, 1px solid rgba(0, 0, 0, 0.06))',\n borderRadius: 'var(--sc-tile-border-radius, 14px)',\n boxShadow: 'var(--sc-tile-shadow, 0 12px 32px -16px rgba(0, 0, 0, 0.18))',\n // Reserves room for the absolute-positioned input pill (36px high\n // + 12px from bottom) plus a 16px visual gap above the input.\n padding: '0.75rem 0.75rem calc(36px + 1.75rem)',\n color: 'var(--sc-tile-title-color, inherit)',\n fontFamily: 'var(--sc-font-family, inherit)',\n // Override the trail's host-layout tokens so the trail (a flex item\n // of this column) shrinks to 0 first when space is tight \u2014 letting\n // the header and absolute-positioned input pill stay pinned. The\n // SDK-level rule in SmartCanvasElementLit consumes these tokens on\n // adaptive-chat-trail's host element. Containers OWN host styling\n // via tokens; the adaptive never sets inline styles on its host.\n ['--sc-chat-trail-host-display']: 'flex',\n ['--sc-chat-trail-host-flex-direction']: 'column',\n ['--sc-chat-trail-host-flex']: '1 1 0',\n ['--sc-chat-trail-host-min-height']: '0',\n ['--sc-chat-trail-host-overflow']: 'hidden',\n };\n}\n\nfunction rowStyles(forceExpanded: boolean): Record<string, string> {\n // forceExpanded \u2014 root container already carries the chrome; row\n // becomes a flat input-pill inside that chrome (subtle border + soft\n // background, no shadow/blur).\n if (forceExpanded) {\n // Absolute-pinned to the chrome card's bottom edge so it never\n // disappears under any container size. The chrome reserves\n // padding-bottom equal to this row's footprint so flex content\n // above (header + trail) can't overlap.\n return {\n position: 'absolute',\n left: '0.75rem',\n right: '0.75rem',\n bottom: '0.75rem',\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n padding: '6px 14px',\n borderRadius: '9999px',\n background: 'rgba(0, 0, 0, 0.04)',\n border: '1px solid rgba(0, 0, 0, 0.10)',\n color: 'var(--sc-content-text-color, inherit)',\n fontFamily: 'var(--sc-font-family, inherit)',\n minHeight: '36px',\n };\n }\n // Floating mount \u2014 keeps the original tile-chrome look.\n return {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n padding: '10px 12px',\n borderRadius: 'var(--sc-tile-border-radius, 14px)',\n background: 'var(--sc-tile-background, rgba(15, 19, 24, 0.6))',\n backdropFilter: 'var(--sc-chat-bar-blur, blur(24px) saturate(140%))',\n WebkitBackdropFilter: 'var(--sc-chat-bar-blur, blur(24px) saturate(140%))',\n border: 'var(--sc-tile-border, 1px solid rgba(255, 255, 255, 0.08))',\n boxShadow: 'var(--sc-tile-shadow, 0 2px 12px rgba(0, 0, 0, 0.3))',\n color: 'var(--sc-tile-title-color, #fafafa)',\n fontFamily: 'var(--sc-font-family, inherit)',\n };\n}\n\nfunction avatarStyles(): Record<string, string> {\n return {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '24px',\n height: '24px',\n borderRadius: '9999px',\n background: 'hsl(var(--sc-accent-color) / 0.15)',\n border: '1px solid hsl(var(--sc-accent-color) / 0.30)',\n color: 'hsl(var(--sc-accent-color) / 0.95)',\n flexShrink: '0',\n fontSize: '11px',\n };\n}\n\nfunction inputStyles(): Record<string, string> {\n return {\n flex: '1',\n minWidth: '0',\n background: 'transparent',\n border: 'none',\n outline: 'none',\n color: 'inherit',\n fontSize: '13px',\n };\n}\n\nfunction sendStyles(inFlight: boolean): Record<string, string> {\n return {\n width: '28px',\n height: '28px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '9999px',\n // Ready: filled accent (send is the affordance). In-flight: hollow\n // ring + accent ring (stop is a one-of-a-kind disruptive action,\n // styled differently so the user reads \"this isn't just send\").\n background: inFlight ? 'transparent' : 'hsl(var(--sc-accent-color) / 0.85)',\n color: inFlight ? 'hsl(var(--sc-accent-color) / 0.95)' : 'var(--sc-accent-foreground, #fff)',\n border: inFlight ? '1px solid hsl(var(--sc-accent-color) / 0.55)' : 'none',\n cursor: 'pointer',\n flexShrink: '0',\n transition: 'background 150ms ease, color 150ms ease, border-color 150ms ease',\n };\n}\n\nfunction closeStyles(): Record<string, string> {\n return {\n width: '28px',\n height: '28px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '9999px',\n background: 'transparent',\n color: 'inherit',\n border: 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n cursor: 'pointer',\n flexShrink: '0',\n opacity: '0.7',\n };\n}\n\nfunction renderHeader() {\n const headerStyles: Record<string, string> = {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n padding: '4px 4px 12px',\n borderBottom: '1px solid var(--sc-content-divider-color, rgba(0, 0, 0, 0.08))',\n flex: '0 0 auto',\n };\n const avatar: Record<string, string> = {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '28px',\n height: '28px',\n borderRadius: '9999px',\n background: 'var(--sc-tile-icon-background, linear-gradient(135deg, #5faf7d 0%, #3d8a5e 100%))',\n color: '#fff',\n flexShrink: '0',\n fontSize: '14px',\n };\n const nameWrap: Record<string, string> = {\n display: 'flex',\n flexDirection: 'column',\n minWidth: '0',\n flex: '1 1 auto',\n };\n const name: Record<string, string> = {\n fontSize: '0.85rem',\n fontWeight: '600',\n color: 'var(--sc-content-text-color, inherit)',\n lineHeight: '1.2',\n };\n const status: Record<string, string> = {\n fontSize: '0.7rem',\n color: 'var(--sc-tile-title-color, #3d8275)',\n display: 'flex',\n alignItems: 'center',\n gap: '4px',\n lineHeight: '1.2',\n };\n const statusDot: Record<string, string> = {\n width: '6px',\n height: '6px',\n borderRadius: '9999px',\n background: 'var(--sc-tile-title-color, #3d8275)',\n display: 'inline-block',\n };\n return html`\n <div style=${styleMap(headerStyles)} data-chat-header>\n <span style=${styleMap(avatar)} aria-hidden=\"true\">\u2726</span>\n <div style=${styleMap(nameWrap)}>\n <span style=${styleMap(name)}>Assistant</span>\n <span style=${styleMap(status)}>\n <span style=${styleMap(statusDot)}></span>\n Online \u00B7 understands your session\n </span>\n </div>\n </div>\n `;\n}\n\nif (!customElements.get('adaptive-chat-bar')) {\n customElements.define('adaptive-chat-bar', AdaptiveChatBar);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'adaptive-chat-bar': AdaptiveChatBar;\n }\n}\n"],
5
+ "mappings": ";AAuBA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,gBAAgB;AAKzB,IAAM,sBAAsB;AAErB,IAAM,kBAAN,cAA8B,WAAW;AAAA,EAAzC;AAAA;AAUL,oBAA2B,CAAC;AAM5B;AAAA;AAAA;AAAA;AAAA,yBAAgB;AAChB,uBAAc;AAOd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAQ/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAW;AACX,kBAAS;AAYT;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,WAAW,CAAC,MAAmB;AACrC,WAAK,SAAU,EAAE,OAA4B;AAAA,IAC/C;AAEA,SAAQ,aAAa,CAAC,MAA2B;AAC/C,UAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;AACpC,UAAE,eAAe;AAIjB,YAAI,KAAK,SAAU;AACnB,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAKA;AAAA;AAAA;AAAA,SAAQ,qBAAqB,MAAY;AACvC,UAAI,KAAK,UAAU;A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AAA,mBACjB,SAAS,QAAQ,CAAC;AAAA,sBACf,SAAS,IAAI,CAAC;AAAA,sBACd,SAAS,MAAM,CAAC;AAAA,wBACd,SAAS,SAAS,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAM3C;AAEA,IAAI,CAAC,eAAe,IAAI,mBAAmB,GAAG;AAC5C,iBAAe,OAAO,qBAAqB,eAAe;AAC5D;",
6
+ "names": []
7
+ }
@@ -19,6 +19,7 @@ var AdaptiveChatTrail = class extends LitElement {
19
19
  this.visibleCount = DEFAULT_VISIBLE;
20
20
  this.expanded = false;
21
21
  this.forceExpanded = false;
22
+ this.inFlight = false;
22
23
  /**
23
24
  * Pre-conversation phantom assistant message. Rendered only when
24
25
  * `messages` is empty. NOT injected into chatSession state — the
@@ -58,6 +59,23 @@ var AdaptiveChatTrail = class extends LitElement {
58
59
  super.connectedCallback();
59
60
  ensureStreamingKeyframes();
60
61
  }
62
+ /**
63
+ * Whether to render the thinking-dots chip after the last message.
64
+ * True iff a request is in flight AND the assistant hasn't started
65
+ * streaming a reply yet — once the first delta lands, the streaming
66
+ * chip's caret takes over and the thinking indicator hides so the
67
+ * visitor isn't shown both at once. Also hidden when the last
68
+ * message is an error/system message, because the request that
69
+ * "errored" is already over from the user's perspective.
70
+ */
71
+ _shouldShowThinking() {
72
+ if (!this.inFlight) return false;
73
+ const last = this.messages[this.messages.length - 1];
74
+ if (!last) return true;
75
+ if (last.role === "assistant" && last.status === "streaming") return false;
76
+ if (last.role === "system" || last.status === "error") return false;
77
+ return true;
78
+ }
61
79
  updated(changed) {
62
80
  if (changed.has("expanded") || changed.has("messages")) {
63
81
  requestAnimationFrame(() => {
@@ -214,6 +232,28 @@ var AdaptiveChatTrail = class extends LitElement {
214
232
  )}
215
233
  </div>` : nothing}</div>`;
216
234
  })}
235
+ ${// Thinking indicator — fills the gap between the user's
236
+ // most recent message and the assistant's first token.
237
+ // Shows when chatSession.inFlight is true AND the last
238
+ // message is NOT a streaming assistant message (the
239
+ // assistant's own caret takes over once tokens arrive).
240
+ // Styled as an assistant chip with three bouncing dots
241
+ // instead of text, so the thread reads naturally — the
242
+ // visitor sees an "assistant" bubble that's clearly busy.
243
+ this._shouldShowThinking() ? html`<div
244
+ data-trail-chip
245
+ data-trail-thinking
246
+ data-role="assistant"
247
+ data-status="thinking"
248
+ aria-label="Assistant is thinking"
249
+ style=${styleMap(chipStyles("assistant", 0, { isStreaming: true, isError: false }))}
250
+ >
251
+ <span data-trail-thinking-dots style=${styleMap(thinkingDotsStyles())}>
252
+ <span style=${styleMap(thinkingDotStyles(0))}></span>
253
+ <span style=${styleMap(thinkingDotStyles(1))}></span>
254
+ <span style=${styleMap(thinkingDotStyles(2))}></span>
255
+ </span>
256
+ </div>` : nothing}
217
257
  </div>
218
258
  ${// The blur veil only fires in collapsed (ambient) mode.
219
259
  // Expanded = the user explicitly asked for history; blurring
@@ -238,7 +278,16 @@ AdaptiveChatTrail.properties = {
238
278
  * expand/collapse affordance is hidden. Used by hosts that mount
239
279
  * the chat in a full-screen surface (the mobile panel) where
240
280
  * collapse makes no sense — there's nothing to collapse INTO. */
241
- forceExpanded: { type: Boolean }
281
+ forceExpanded: { type: Boolean },
282
+ /**
283
+ * Mirrors `chatSession.inFlight` — true between `send()` and the
284
+ * assistant's first `receiveStart`/`receiveDelta`, OR while a
285
+ * stream is in progress. Drives the "thinking" indicator that
286
+ * fills the gap between the user's just-sent message and the
287
+ * first assistant token. Wired through AdaptiveChatBar (it owns
288
+ * the chatSession subscription and forwards inFlight as a prop).
289
+ */
290
+ inFlight: { type: Boolean }
242
291
  };
243
292
  function blurVeilStyles() {
244
293
  const mask = "linear-gradient(to bottom, black 0%, black 40%, transparent 100%)";
@@ -343,6 +392,31 @@ function caretStyles() {
343
392
  animation: "syntro-trail-caret 1s steps(2, end) infinite"
344
393
  };
345
394
  }
395
+ function thinkingDotsStyles() {
396
+ return {
397
+ display: "inline-flex",
398
+ alignItems: "center",
399
+ gap: "4px",
400
+ padding: "2px 0",
401
+ // Match chip line height so the dots sit in the same vertical
402
+ // rhythm as a text chip — no jump when the assistant token
403
+ // arrives and the chip flips from dots to text.
404
+ lineHeight: "11px"
405
+ };
406
+ }
407
+ function thinkingDotStyles(index) {
408
+ return {
409
+ display: "inline-block",
410
+ width: "5px",
411
+ height: "5px",
412
+ borderRadius: "50%",
413
+ background: "currentColor",
414
+ // 160ms stagger between dots — same rhythm as the platform chat
415
+ // (packages/chat/src/styles.ts:297) so the brand identity reads
416
+ // consistent across surfaces.
417
+ animation: `syntro-trail-thinking-bounce 1.4s ease-in-out ${index * 0.16}s infinite`
418
+ };
419
+ }
346
420
  function moreStyles() {
347
421
  return {
348
422
  // Center horizontally regardless of the parent's display model.
@@ -396,7 +470,12 @@ function ensureStreamingKeyframes() {
396
470
  "[data-trail-chip] code { font-family: ui-monospace, SF Mono, Menlo, monospace; font-size: 10px; background: var(--sc-content-code-background, rgba(0, 0, 0, 0.25)); padding: 1px 4px; border-radius: 3px }",
397
471
  "[data-trail-chip] pre code { background: transparent; padding: 0 }",
398
472
  "[data-trail-chip] a { color: var(--sc-content-link-color, var(--sc-color-primary, #b72e2a)); text-decoration: underline }",
399
- "[data-trail-chip] strong { font-weight: 600 }"
473
+ "[data-trail-chip] strong { font-weight: 600 }",
474
+ // Thinking-dot animation. Three vertically-bouncing pills with
475
+ // staggered delays read as the canonical "AI is composing"
476
+ // indicator. translateY rather than scale keeps the dots from
477
+ // ballooning past the chip's padding.
478
+ "@keyframes syntro-trail-thinking-bounce { 0%,80%,100% { transform: translateY(0); opacity: 0.45 } 40% { transform: translateY(-3px); opacity: 1 } }"
400
479
  ].join(" ");
401
480
  document.head.appendChild(style);
402
481
  }
@@ -414,4 +493,4 @@ if (!customElements.get("adaptive-chat-trail")) {
414
493
  export {
415
494
  AdaptiveChatTrail
416
495
  };
417
- //# sourceMappingURL=chunk-BNN5YLN3.js.map
496
+ //# sourceMappingURL=chunk-VHMHUS45.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/AdaptiveChatTrail.ts"],
4
+ "sourcesContent": ["/**\n * AdaptiveChatTrail \u2014 the \"bubble-up\" message column that sits above the\n * chat bar in the canvas lid.\n *\n * Messages appear immediately above the chat bar and drift upward as\n * newer ones arrive. Each stack position carries an opacity + blur\n * falloff so older messages read as fading from the page. Beyond a\n * `visibleCount` cap (default 3) the trail collapses into an \"N more \u00B7\n * expand\" affordance \u2014 clicking emits `trail-expand`.\n *\n * Light DOM (no shadow root) so the host page's CSS variables and the\n * surrounding canvas tokens flow through without a nested shadow\n * boundary.\n *\n * See PRD \u00A74.3 (chat trail) for the canonical motion + falloff spec.\n */\n\nimport { renderMarkdown } from '@syntrologie/chat';\nimport { html, LitElement, nothing } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport interface TrailToolCall {\n id: string;\n name: string;\n status: 'args-streaming' | 'pending' | 'running' | 'done' | 'error';\n}\n\nexport interface TrailMessage {\n /** Stable identity for keyed rendering (must be unique within the trail). */\n id: number | string;\n role: 'user' | 'assistant' | 'system';\n text: string;\n /** Streaming \u2192 assistant text still arriving from backend. Complete \u2192 final. Error \u2192 fatal during stream. */\n status?: 'streaming' | 'complete' | 'error';\n /** Tool calls attached to an assistant message (rendered as compact chips). */\n toolCalls?: TrailToolCall[];\n}\n\n/** PRD \u00A74.3 constants. */\nconst DEFAULT_VISIBLE = 3;\nconst OPACITY_STEP = 0.22;\nconst OPACITY_FLOOR = 0.18;\nconst Y_DRIFT_PX = -2;\n/**\n * Height of the absolute blur veil at the top of the trail's scroll\n * area. Pixel-based, NOT message-count-based: with the old per-chip\n * `filter: blur(pos * step)` model, a single long markdown response\n * at pos=1 would have its entire body uniformly blurred \u2014 including\n * the chunk visually adjacent to the crisp newest message \u2014 because\n * blur is a property of the chip element, not of pixels. Switching\n * to a fixed-height backdrop-blur veil keeps the bottom of the\n * visible area (newest content) crisp regardless of message length.\n */\nconst TRAIL_BLUR_VEIL_PX = 72;\n/** Max blur applied at the very top of the veil; tapers to 0 at the bottom edge. */\nconst TRAIL_BLUR_MAX_PX = 5;\n\nexport class AdaptiveChatTrail extends LitElement {\n static override properties = {\n messages: { attribute: false },\n visibleCount: { type: Number },\n expanded: { type: Boolean },\n greeting: { type: String },\n /** When true: trail renders fully expanded AND the\n * expand/collapse affordance is hidden. Used by hosts that mount\n * the chat in a full-screen surface (the mobile panel) where\n * collapse makes no sense \u2014 there's nothing to collapse INTO. */\n forceExpanded: { type: Boolean },\n /**\n * Mirrors `chatSession.inFlight` \u2014 true between `send()` and the\n * assistant's first `receiveStart`/`receiveDelta`, OR while a\n * stream is in progress. Drives the \"thinking\" indicator that\n * fills the gap between the user's just-sent message and the\n * first assistant token. Wired through AdaptiveChatBar (it owns\n * the chatSession subscription and forwards inFlight as a prop).\n */\n inFlight: { type: Boolean },\n };\n\n messages: TrailMessage[] = [];\n visibleCount = DEFAULT_VISIBLE;\n expanded = false;\n forceExpanded = false;\n inFlight = false;\n /**\n * Pre-conversation phantom assistant message. Rendered only when\n * `messages` is empty. NOT injected into chatSession state \u2014 the\n * greeting is configuration, not conversation, so it disappears\n * automatically when the first real message arrives.\n */\n greeting: string | undefined = undefined;\n\n override createRenderRoot(): HTMLElement {\n // Light DOM \u2014 canvas-level CSS vars reach the chips directly.\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n ensureStreamingKeyframes();\n }\n\n private _onExpand = (): void => {\n // Self-manage: clicking the inline link expands the trail in place.\n // We still dispatch the event so any parent that wants to react\n // (telemetry, mirror state to a side panel, etc.) can listen.\n this.expanded = true;\n this.dispatchEvent(new CustomEvent('trail-expand', { bubbles: true, composed: true }));\n };\n\n /**\n * Approve a pending client tool call. The trail emits a generic\n * event so the host can decide whether to forward to chatSession\n * (the common path) or override. Keeps the trail itself free of\n * direct chatSession coupling \u2014 it's a pure view component.\n */\n private _onToolCallClick = (tc: TrailToolCall): void => {\n if (tc.status !== 'pending') return;\n this.dispatchEvent(\n new CustomEvent<{ toolCallId: string; approved: boolean }>('trail-toolcall-approved', {\n detail: { toolCallId: tc.id, approved: true },\n bubbles: true,\n composed: true,\n })\n );\n };\n\n private _onCollapse = (): void => {\n // Mirror of _onExpand for the minimize affordance shown while\n // expanded. Self-manages + dispatches `trail-collapse` for parent\n // observers (telemetry, side-panel mirrors).\n this.expanded = false;\n this.dispatchEvent(new CustomEvent('trail-collapse', { bubbles: true, composed: true }));\n };\n\n /**\n * Whether to render the thinking-dots chip after the last message.\n * True iff a request is in flight AND the assistant hasn't started\n * streaming a reply yet \u2014 once the first delta lands, the streaming\n * chip's caret takes over and the thinking indicator hides so the\n * visitor isn't shown both at once. Also hidden when the last\n * message is an error/system message, because the request that\n * \"errored\" is already over from the user's perspective.\n */\n private _shouldShowThinking(): boolean {\n if (!this.inFlight) return false;\n const last = this.messages[this.messages.length - 1];\n if (!last) return true;\n if (last.role === 'assistant' && last.status === 'streaming') return false;\n if (last.role === 'system' || last.status === 'error') return false;\n return true;\n }\n\n override updated(changed: Map<string, unknown>): void {\n // Anchor the scroll to the bottom whenever:\n // - the trail flips into expanded mode (UX continuity), OR\n // - new messages or text deltas arrive (so a long streaming chip\n // stays pinned to the latest line, not the start of the chip).\n // Skip when the user has manually scrolled UP into history \u2014 we'd\n // rather lose pinning than yank them out of what they're reading.\n if (changed.has('expanded') || changed.has('messages')) {\n requestAnimationFrame(() => {\n const container = this.querySelector<HTMLElement>('[data-syntro-chat-trail]');\n if (!container) return;\n const distanceFromBottom =\n container.scrollHeight - container.scrollTop - container.clientHeight;\n // 200px tolerance \u2014 streaming deltas can append a paragraph in\n // one update, easily 80-150px. A tighter window would strand\n // the viewer at the top of the chip mid-stream because the\n // first delta blew past the threshold. User-driven scroll-up\n // of >200px disables auto-pin until they scroll back down.\n if (distanceFromBottom < 200 || changed.has('expanded')) {\n container.scrollTop = container.scrollHeight;\n }\n });\n }\n }\n\n override render() {\n if (this.messages.length === 0 && !this.greeting) return nothing;\n if (this.messages.length === 0 && this.greeting) {\n // Render the greeting as a pure-display assistant chip. No\n // tool-calls, no streaming caret, single chip at pos=0.\n return html`<div data-syntro-chat-trail style=${styleMap({\n display: 'flex',\n flexDirection: 'column',\n gap: '6px',\n justifyContent: 'flex-end',\n width: '100%',\n padding: '0',\n pointerEvents: 'auto',\n })}>\n <div\n data-trail-chip\n data-role=\"assistant\"\n data-status=\"greeting\"\n style=${styleMap(chipStyles('assistant', 0, { isStreaming: false, isError: false }))}\n >${unsafeHTML(renderMarkdown(stripTrailingWhitespace(this.greeting)))}</div>\n </div>`;\n }\n\n // Choose the slice we actually paint. Newest are at the END of the\n // array (closest to the chat bar). When not expanded, take the last\n // `visibleCount`; when expanded, take all.\n const visible =\n this.expanded || this.forceExpanded ? this.messages : this.messages.slice(-this.visibleCount);\n const hidden = this.messages.length - visible.length;\n\n const baseStyles: Record<string, string> = {\n display: 'flex',\n flexDirection: 'column',\n gap: '6px',\n // NO `justifyContent: flex-end` here \u2014 combined with `overflow: auto`\n // it's a known cross-browser bug: oversized flex children get\n // pushed ABOVE the container without contributing to scrollHeight,\n // so the scrollbar never appears. We rely on `:first-child {\n // margin-top: auto }` (injected as global CSS) to push short\n // content to the bottom of the box while leaving overflow handling\n // to the native scroll container.\n width: '100%',\n // The trail itself has no chrome \u2014 chips sit on the host page bg.\n padding: '0',\n pointerEvents: 'auto',\n };\n\n // Expanded mode: cap height, scroll, and add a visible top border so\n // the panel reads as a bounded region. NO background tint or shadow\n // \u2014 the ambient (collapsed) treatment is fine and we don't want to\n // suddenly introduce panel chrome that wasn't there before. The\n // border alone marks the panel's top edge.\n // Falloff is turned off per-chip below \u2014 readability wins once the\n // user has explicitly asked for history. See PRD \u00A74.3.\n // Collapsed mode also gets a (looser) cap + scroll so a single long\n // markdown chip doesn't blow the chat-bar off-screen with no\n // scroll affordance. Tighter than expanded so the bubble-up trail\n // doesn't dominate the surface visually.\n const modeStyles: Record<string, string> = this.forceExpanded\n ? {\n // Full-screen host: fill all available vertical space and\n // scroll the overflow. ``flex: 1 1 0`` (basis 0, not auto)\n // makes the trail shrink to 0 first when the parent runs\n // out of space \u2014 so the header above and the input row\n // below stay pinned at their natural sizes instead of one\n // of them being pushed off-screen.\n flex: '1 1 0',\n minHeight: '0',\n overflowY: 'auto',\n // ``contain`` prevents scroll from bubbling out to the host\n // page when the trail hits top or bottom. Required for the\n // panel-scroll-leak regression test in\n // SyntroBottomSheet.test.ts.\n overscrollBehavior: 'contain',\n paddingTop: '8px',\n borderTop: 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n scrollBehavior: 'smooth',\n scrollbarWidth: 'thin',\n }\n : this.expanded\n ? {\n maxHeight: 'min(320px, 40vh)',\n overflowY: 'auto',\n paddingTop: '8px',\n borderTop: 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n scrollBehavior: 'smooth',\n scrollbarWidth: 'thin',\n }\n : {\n // Collapsed mode = ambient peek surface. Never a scrollbar:\n // long messages slide up behind the blur veil instead of\n // exposing a scrollbar. The \"\u2191 N more \u00B7 expand\" affordance\n // is the only entry into history; clicking it switches to\n // expanded mode where scroll IS allowed.\n // Height kept short so the trail reads as a peek strip above\n // the chat bar, not a panel \u2014 long single replies fade into\n // the blur veil at the top, user expands to read the rest.\n maxHeight: 'min(140px, 22vh)',\n overflow: 'hidden',\n };\n\n const containerStyles = { ...baseStyles, ...modeStyles };\n\n // Wrap the scroll container in a positioning frame so the absolute\n // blur veil (rendered at the top) anchors to the scroll viewport's\n // top edge \u2014 NOT to a chip that scrolls under it. Pixel-anchored\n // blur means: the top TRAIL_BLUR_VEIL_PX of the visible area is\n // veiled regardless of how many messages occupy those pixels.\n // The frame wraps the scroll container so the absolute blur veil\n // anchors to the scroll viewport's top edge. In ``forceExpanded``\n // mode it ALSO has to participate in the flex column laid out by\n // the trail host \u2014 otherwise the scroll container's ``flex: 1 1\n // 0`` has no flex context, falls back to content height, and the\n // trail's overflow:hidden clips at the TOP of the scroll\n // (showing oldest messages, hiding the newest at the bottom).\n const frameStyles: Record<string, string> = this.forceExpanded\n ? {\n position: 'relative',\n width: '100%',\n display: 'flex',\n flexDirection: 'column',\n flex: '1 1 0',\n minHeight: '0',\n }\n : {\n position: 'relative',\n width: '100%',\n };\n\n return html`\n ${\n // Single toggle button above the frame. Same DOM node morphs:\n // collapsed \u2192 \"\u2191 N more \u00B7 expand\" / \"\u2191 expand\" (calls _onExpand)\n // expanded \u2192 \"\u2304 minimize\" (calls _onCollapse)\n // Lives OUTSIDE the frame so the absolute blur veil (top:0,\n // z-index:2 inside the frame) doesn't cover it. Shown whenever\n // there's anything in the trail \u2014 the user expects this affordance\n // available regardless of how many chips are on screen.\n // When ``forceExpanded`` is set by the host (full-screen panel,\n // etc.), there's nowhere to collapse INTO and the affordance\n // would just confuse the user \u2014 suppress it entirely.\n this.messages.length === 0 || this.forceExpanded\n ? nothing\n : this.expanded\n ? html`<button\n type=\"button\"\n data-trail-toggle\n data-trail-collapse\n @click=${this._onCollapse}\n style=${styleMap(moreStyles())}\n >\u2304 minimize</button>`\n : html`<button\n type=\"button\"\n data-trail-toggle\n data-trail-more\n @click=${this._onExpand}\n style=${styleMap(moreStyles())}\n >${hidden > 0 ? html`\u2191 ${hidden} more \u00B7 expand` : html`\u2191 expand`}</button>`\n }\n <div data-syntro-chat-trail-frame style=${styleMap(frameStyles)}>\n <div data-syntro-chat-trail style=${styleMap(containerStyles)}>\n ${visible.map((m, i) => {\n // Stack position from the bar: 0 = closest, N-1 = oldest.\n // visible[last] is closest, so reverse the index from the\n // tail of the visible slice. When expanded, the ambient\n // falloff is suppressed (pos = 0) so every chip reads at\n // full opacity \u2014 explicit history view, not ambient trail.\n const pos = this.expanded || this.forceExpanded ? 0 : visible.length - 1 - i;\n const isStreaming = m.status === 'streaming';\n const isError = m.status === 'error' || m.role === 'system';\n const toolCalls = m.toolCalls ?? [];\n // Assistant text is markdown-formatted by the agent (lists,\n // code, bold, links). renderMarkdown sanitizes via DOMPurify,\n // then unsafeHTML injects the safe HTML. User + system chips\n // stay plain text \u2014 no markdown risk + no expansion attack\n // surface on user-typed input.\n const renderedText =\n m.role === 'assistant'\n ? html`${unsafeHTML(renderMarkdown(stripTrailingWhitespace(m.text)))}`\n : html`${m.text}`;\n return html`<div\n data-trail-chip\n data-role=${m.role}\n data-status=${m.status ?? 'complete'}\n style=${styleMap(chipStyles(m.role, pos, { isStreaming, isError }))}\n >${renderedText}${\n isStreaming\n ? html`<span\n data-trail-caret\n aria-hidden=\"true\"\n style=${styleMap(caretStyles())}\n ></span>`\n : nothing\n }${\n toolCalls.length > 0\n ? html`<div data-trail-toolcalls style=${styleMap(toolCallStripStyles())}>\n ${toolCalls.map(\n (tc) => html`<button\n type=\"button\"\n data-trail-toolcall\n data-tool-id=${tc.id}\n data-tool-status=${tc.status}\n @click=${() => this._onToolCallClick(tc)}\n ?disabled=${tc.status !== 'pending'}\n style=${styleMap(toolCallChipStyles(tc.status))}\n title=\"${tc.name} \u00B7 ${tc.status}\"\n >${toolCallIcon(tc.status)} ${tc.name}</button>`\n )}\n </div>`\n : nothing\n }</div>`;\n })}\n ${\n // Thinking indicator \u2014 fills the gap between the user's\n // most recent message and the assistant's first token.\n // Shows when chatSession.inFlight is true AND the last\n // message is NOT a streaming assistant message (the\n // assistant's own caret takes over once tokens arrive).\n // Styled as an assistant chip with three bouncing dots\n // instead of text, so the thread reads naturally \u2014 the\n // visitor sees an \"assistant\" bubble that's clearly busy.\n this._shouldShowThinking()\n ? html`<div\n data-trail-chip\n data-trail-thinking\n data-role=\"assistant\"\n data-status=\"thinking\"\n aria-label=\"Assistant is thinking\"\n style=${styleMap(chipStyles('assistant', 0, { isStreaming: true, isError: false }))}\n >\n <span data-trail-thinking-dots style=${styleMap(thinkingDotsStyles())}>\n <span style=${styleMap(thinkingDotStyles(0))}></span>\n <span style=${styleMap(thinkingDotStyles(1))}></span>\n <span style=${styleMap(thinkingDotStyles(2))}></span>\n </span>\n </div>`\n : nothing\n }\n </div>\n ${\n // The blur veil only fires in collapsed (ambient) mode.\n // Expanded = the user explicitly asked for history; blurring\n // the top of the panel would hide content (including the\n // minimize button just above the trail's top edge) the user\n // came here to see.\n this.expanded || this.forceExpanded\n ? nothing\n : html`<div\n data-trail-blur-veil\n aria-hidden=\"true\"\n style=${styleMap(blurVeilStyles())}\n ></div>`\n }\n </div>\n `;\n }\n}\n\n/**\n * Absolute blur veil at the top of the scroll viewport. Uses\n * `backdrop-filter: blur(...)` so whatever pixels sit beneath the veil\n * (top of the scroll content) become blurred, regardless of which chip\n * those pixels belong to. A linear mask fades the blur effect from full\n * at the top to zero at the bottom of the veil \u2014 newest content stays\n * crisp because it lives below the veil's height.\n *\n * Note: `mask-image` controls where the BACKDROP-FILTER applies (via\n * masking the veil element), so the bottom edge of the veil naturally\n * dissolves into the unblurred scroll area below.\n */\nfunction blurVeilStyles(): Record<string, string> {\n const mask = 'linear-gradient(to bottom, black 0%, black 40%, transparent 100%)';\n return {\n position: 'absolute',\n top: '0',\n left: '0',\n right: '0',\n height: `${TRAIL_BLUR_VEIL_PX}px`,\n pointerEvents: 'none',\n backdropFilter: `blur(${TRAIL_BLUR_MAX_PX}px)`,\n WebkitBackdropFilter: `blur(${TRAIL_BLUR_MAX_PX}px)`,\n maskImage: mask,\n WebkitMaskImage: mask,\n zIndex: '2',\n };\n}\n\nfunction chipStyles(\n role: TrailMessage['role'],\n pos: number,\n state: { isStreaming: boolean; isError: boolean } = { isStreaming: false, isError: false }\n): Record<string, string> {\n const opacity = Math.max(OPACITY_FLOOR, 1 - pos * OPACITY_STEP);\n const yPx = pos * Y_DRIFT_PX;\n\n // Error chips override role-specific styling \u2014 they shouldn't read\n // as \"an assistant reply.\" Streaming chips get a subtle accent ring\n // so the in-progress state is visually distinct from a settled reply.\n // All four states resolve to design-system tokens via the theme; the\n // fallbacks here are conservative neutrals so the widget still renders\n // sensibly on a host page that hasn't set tokens yet.\n const border = state.isError\n ? 'var(--sc-content-bubble-border-error, 1px solid rgba(220, 80, 80, 0.55))'\n : state.isStreaming\n ? 'var(--sc-content-bubble-border-user, 1px solid rgba(255, 255, 255, 0.28))'\n : role === 'user'\n ? 'var(--sc-content-bubble-border-user, 1px solid rgba(255, 255, 255, 0.28))'\n : 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))';\n const background = state.isError\n ? 'var(--sc-content-bubble-background-error, rgba(140, 40, 40, 0.42))'\n : role === 'user'\n ? 'var(--sc-content-bubble-background-user, rgba(255, 255, 255, 0.10))'\n : 'var(--sc-content-bubble-background, rgba(20, 22, 24, 0.35))';\n\n const base: Record<string, string> = {\n alignSelf: role === 'user' ? 'flex-end' : 'flex-start',\n maxWidth: '85%',\n fontSize: '11px',\n lineHeight: '1.45',\n padding: '4px 10px',\n borderRadius: '10px',\n border,\n background,\n backdropFilter: 'blur(8px)',\n WebkitBackdropFilter: 'blur(8px)',\n color: state.isError\n ? 'var(--sc-content-bubble-text-error, rgba(255, 220, 220, 0.95))'\n : 'var(--sc-tile-title-color, inherit)',\n transition:\n 'opacity 240ms cubic-bezier(0.22, 1, 0.36, 1), transform 240ms cubic-bezier(0.22, 1, 0.36, 1)',\n // Per-position opacity + y-drift falloff is still per-chip \u2014 those\n // operate naturally per element. Blur is NOT per-chip anymore: it's\n // applied via an absolute-positioned veil at the top of the scroll\n // viewport (TRAIL_BLUR_VEIL_PX above), so a single long message\n // doesn't get uniformly blurred across its full body.\n opacity: String(toFixedTrim(opacity)),\n transform: `translateY(${yPx}px)`,\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n };\n return base;\n}\n\nfunction toolCallStripStyles(): Record<string, string> {\n return {\n display: 'flex',\n flexWrap: 'wrap',\n gap: '4px',\n marginTop: '4px',\n paddingTop: '4px',\n borderTop: '1px dashed var(--sc-content-divider-color, rgba(255, 255, 255, 0.12))',\n };\n}\n\nfunction toolCallChipStyles(status: TrailToolCall['status']): Record<string, string> {\n const isPending = status === 'pending';\n const isError = status === 'error';\n const isDone = status === 'done';\n return {\n display: 'inline-flex',\n alignItems: 'center',\n gap: '4px',\n padding: '2px 7px',\n border: isError\n ? 'var(--sc-content-bubble-border-error, 1px solid rgba(220, 80, 80, 0.45))'\n : isPending\n ? 'var(--sc-content-bubble-border-user, 1px solid rgba(255, 255, 255, 0.28))'\n : 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n background: isError\n ? 'var(--sc-content-bubble-background-error, rgba(140, 40, 40, 0.35))'\n : isPending\n ? 'var(--sc-content-bubble-background-user, rgba(255, 255, 255, 0.10))'\n : isDone\n ? 'var(--sc-content-bubble-background-idle, rgba(40, 44, 50, 0.4))'\n : 'var(--sc-content-bubble-background, rgba(20, 22, 24, 0.35))',\n color: 'var(--sc-tile-text-color, inherit)',\n borderRadius: '999px',\n fontSize: '10px',\n fontWeight: '500',\n fontFamily: 'ui-monospace, SF Mono, Menlo, monospace',\n cursor: isPending ? 'pointer' : 'default',\n opacity: isDone ? '0.7' : '1',\n };\n}\n\nfunction toolCallIcon(status: TrailToolCall['status']): string {\n switch (status) {\n case 'args-streaming':\n case 'running':\n return '\u22EF';\n case 'pending':\n return '?';\n case 'done':\n return '\u2713';\n case 'error':\n return '\u2717';\n default:\n return '\u00B7';\n }\n}\n\nfunction caretStyles(): Record<string, string> {\n return {\n display: 'inline-block',\n width: '6px',\n height: '12px',\n marginLeft: '3px',\n verticalAlign: '-1px',\n background: 'hsl(var(--sc-accent-color) / 0.85)',\n borderRadius: '1px',\n animation: 'syntro-trail-caret 1s steps(2, end) infinite',\n };\n}\n\nfunction thinkingDotsStyles(): Record<string, string> {\n return {\n display: 'inline-flex',\n alignItems: 'center',\n gap: '4px',\n padding: '2px 0',\n // Match chip line height so the dots sit in the same vertical\n // rhythm as a text chip \u2014 no jump when the assistant token\n // arrives and the chip flips from dots to text.\n lineHeight: '11px',\n };\n}\n\nfunction thinkingDotStyles(index: number): Record<string, string> {\n return {\n display: 'inline-block',\n width: '5px',\n height: '5px',\n borderRadius: '50%',\n background: 'currentColor',\n // 160ms stagger between dots \u2014 same rhythm as the platform chat\n // (packages/chat/src/styles.ts:297) so the brand identity reads\n // consistent across surfaces.\n animation: `syntro-trail-thinking-bounce 1.4s ease-in-out ${index * 0.16}s infinite`,\n };\n}\n\nfunction moreStyles(): Record<string, string> {\n return {\n // Center horizontally regardless of the parent's display model.\n // ``alignSelf: center`` only works when the parent is a flex/grid\n // container with cross-axis alignment; the chat-bar's flex column\n // stretches us full-width instead. ``display: block`` + auto inline\n // margins centers the auto-sized button without needing the parent\n // to opt in.\n display: 'block',\n marginLeft: 'auto',\n marginRight: 'auto',\n marginBottom: '6px',\n fontSize: '10px',\n fontWeight: '500',\n letterSpacing: '0.06em',\n padding: '4px 10px',\n border: '1px solid hsl(var(--sc-accent-color) / 0.32)',\n borderRadius: '999px',\n background: 'hsl(var(--sc-accent-color) / 0.10)',\n color: 'var(--sc-tile-text-color, currentColor)',\n cursor: 'pointer',\n opacity: '0.85',\n backdropFilter: 'blur(8px)',\n WebkitBackdropFilter: 'blur(8px)',\n transition: 'opacity 150ms ease, background 150ms ease',\n };\n}\n\n/**\n * Inject the streaming-caret keyframes once per document. Light-DOM\n * components can't ship CSS via Lit's `styles` static \u2014 the rules\n * need to be present in the document's stylesheet. Idempotent via\n * a data attribute on the injected style tag.\n */\nfunction ensureStreamingKeyframes(): void {\n if (typeof document === 'undefined') return;\n if (document.head.querySelector('style[data-syntro-trail-caret-keyframes]')) return;\n const style = document.createElement('style');\n style.setAttribute('data-syntro-trail-caret-keyframes', 'true');\n // Caret animation + markdown reset for assistant chips. The trail\n // chips are tiny (11px line-height); default <p>/<ul>/<pre> margins\n // would push the chip vertically and break the falloff layout.\n style.textContent = [\n '@keyframes syntro-trail-caret { 0%{opacity:1} 50%{opacity:0} 100%{opacity:1} }',\n // Anchor short content to the bottom of the scrollable trail \u2014\n // see baseStyles comment for why we can't use justify-content.\n '[data-syntro-chat-trail] > :first-child { margin-top: auto }',\n // Tight spacing \u2014 trail chips are an 11px-line-height pill. Default\n // browser <p>/<ul> margins (1em \u2248 11px each side) would dominate the\n // chip. Keep paragraph + list separators minimal (4px) so multi-\n // paragraph replies read as one continuous flow, not a vertical\n // stack of fragments.\n '[data-trail-chip] > p:first-child { margin-top: 0 }',\n '[data-trail-chip] > p:last-child { margin-bottom: 0 }',\n '[data-trail-chip] p { margin: 4px 0 }',\n '[data-trail-chip] br + br { display: none }',\n '[data-trail-chip] ul, [data-trail-chip] ol { margin: 4px 0; padding-left: 1.1em }',\n '[data-trail-chip] li { margin: 0 }',\n '[data-trail-chip] li + li { margin-top: 1px }',\n '[data-trail-chip] pre { margin: 6px 0; padding: 6px 8px; background: var(--sc-content-code-background-block, rgba(0, 0, 0, 0.35)); border-radius: 6px; overflow-x: auto; font-size: 10px }',\n '[data-trail-chip] code { font-family: ui-monospace, SF Mono, Menlo, monospace; font-size: 10px; background: var(--sc-content-code-background, rgba(0, 0, 0, 0.25)); padding: 1px 4px; border-radius: 3px }',\n '[data-trail-chip] pre code { background: transparent; padding: 0 }',\n '[data-trail-chip] a { color: var(--sc-content-link-color, var(--sc-color-primary, #b72e2a)); text-decoration: underline }',\n '[data-trail-chip] strong { font-weight: 600 }',\n // Thinking-dot animation. Three vertically-bouncing pills with\n // staggered delays read as the canonical \"AI is composing\"\n // indicator. translateY rather than scale keeps the dots from\n // ballooning past the chip's padding.\n '@keyframes syntro-trail-thinking-bounce { 0%,80%,100% { transform: translateY(0); opacity: 0.45 } 40% { transform: translateY(-3px); opacity: 1 } }',\n ].join(' ');\n document.head.appendChild(style);\n}\n\n/**\n * Pre-process LLM markdown before rendering. Three common artifacts:\n *\n * 1. Trailing \" \" (two spaces = markdown hard-break) sprinkled at\n * end-of-line, even inside list items where it just leaks\n * invisible whitespace into the DOM.\n * 2. Runs of 3+ blank lines used as visual separators. Markdown\n * treats any number of blank lines as a single paragraph break,\n * so the extras add nothing semantically \u2014 but combined with\n * paragraph margins they create huge gaps in the tiny chip layout.\n * 3. Leading / trailing newlines on the whole message. Trailing\n * `\\n\\n` is the common one \u2014 marked turns it into a final empty\n * <p> that still occupies a full line-height of vertical space,\n * leaving a visible gap between the last text and the chat bar.\n *\n * Collapsing all three keeps the rendered HTML tight without changing\n * the agent's semantic intent.\n */\nfunction stripTrailingWhitespace(text: string): string {\n return text\n .replace(/[ \\t]+$/gm, '') // trailing whitespace per line\n .replace(/\\n{3,}/g, '\\n\\n') // collapse runs of blank lines\n .trim(); // drop leading/trailing whitespace+newlines on the whole message\n}\n\n/** Two-decimal trim that avoids trailing zeros (\".50\" \u2192 \".5\"). */\nfunction toFixedTrim(n: number): string {\n const s = n.toFixed(2);\n return s.replace(/\\.?0+$/, '') || '0';\n}\n\nif (!customElements.get('adaptive-chat-trail')) {\n customElements.define('adaptive-chat-trail', AdaptiveChatTrail);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'adaptive-chat-trail': AdaptiveChatTrail;\n }\n}\n"],
5
+ "mappings": ";;;;;AAkBA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAoB3B,IAAM,kBAAkB;AACxB,IAAM,eAAe;AACrB,IAAM,gBAAgB;AACtB,IAAM,aAAa;AAWnB,IAAM,qBAAqB;AAE3B,IAAM,oBAAoB;AAEnB,IAAM,oBAAN,cAAgC,WAAW;AAAA,EAA3C;AAAA;AAsBL,oBAA2B,CAAC;AAC5B,wBAAe;AACf,oBAAW;AACX,yBAAgB;AAChB,oBAAW;AAOX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAY/B,SAAQ,YAAY,MAAY;AAI9B,WAAK,WAAW;AAChB,WAAK,cAAc,IAAI,YAAY,gBAAgB,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AAAA,IACvF;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,mBAAmB,CAAC,OAA4B;AACtD,UAAI,GAAG,WAAW,UAAW;AAC7B,WAAK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,8 +10,8 @@ import {
10
10
  fetchMountedElements,
11
11
  renderFallbackHtml
12
12
  } from "./chunk-DG63RLZZ.js";
13
- import "./chunk-SCVTTLFJ.js";
14
- import "./chunk-BNN5YLN3.js";
13
+ import "./chunk-OCDIFF6G.js";
14
+ import "./chunk-VHMHUS45.js";
15
15
  import "./chunk-ONGGPQER.js";
16
16
  import "./chunk-FVNSOP7B.js";
17
17
  import "./chunk-VLJ3WOEX.js";
package/dist/schema.d.ts CHANGED
@@ -144,8 +144,8 @@ export declare const chatBarPropsSchema: z.ZodObject<{
144
144
  }[] | undefined;
145
145
  greeting?: string | undefined;
146
146
  forceExpanded?: boolean | undefined;
147
- placeholder?: string | undefined;
148
147
  inFlight?: boolean | undefined;
148
+ placeholder?: string | undefined;
149
149
  backendUrl?: string | undefined;
150
150
  fallback?: z.objectOutputType<{
151
151
  title: z.ZodOptional<z.ZodString>;
@@ -162,8 +162,8 @@ export declare const chatBarPropsSchema: z.ZodObject<{
162
162
  }[] | undefined;
163
163
  greeting?: string | undefined;
164
164
  forceExpanded?: boolean | undefined;
165
- placeholder?: string | undefined;
166
165
  inFlight?: boolean | undefined;
166
+ placeholder?: string | undefined;
167
167
  backendUrl?: string | undefined;
168
168
  fallback?: z.objectInputType<{
169
169
  title: z.ZodOptional<z.ZodString>;
@@ -1434,8 +1434,8 @@ export declare const tileWidgets: ({
1434
1434
  }[] | undefined;
1435
1435
  greeting?: string | undefined;
1436
1436
  forceExpanded?: boolean | undefined;
1437
- placeholder?: string | undefined;
1438
1437
  inFlight?: boolean | undefined;
1438
+ placeholder?: string | undefined;
1439
1439
  backendUrl?: string | undefined;
1440
1440
  fallback?: z.objectOutputType<{
1441
1441
  title: z.ZodOptional<z.ZodString>;
@@ -1452,8 +1452,8 @@ export declare const tileWidgets: ({
1452
1452
  }[] | undefined;
1453
1453
  greeting?: string | undefined;
1454
1454
  forceExpanded?: boolean | undefined;
1455
- placeholder?: string | undefined;
1456
1455
  inFlight?: boolean | undefined;
1456
+ placeholder?: string | undefined;
1457
1457
  backendUrl?: string | undefined;
1458
1458
  fallback?: z.objectInputType<{
1459
1459
  title: z.ZodOptional<z.ZodString>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syntrologie/adapt-chatbot",
3
- "version": "2.8.0-canary.317",
3
+ "version": "2.8.0-canary.319",
4
4
  "description": "Adaptive Chatbot - AI chat assistant widget with action execution",
5
5
  "license": "Proprietary",
6
6
  "private": false,
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/AdaptiveChatTrail.ts"],
4
- "sourcesContent": ["/**\n * AdaptiveChatTrail \u2014 the \"bubble-up\" message column that sits above the\n * chat bar in the canvas lid.\n *\n * Messages appear immediately above the chat bar and drift upward as\n * newer ones arrive. Each stack position carries an opacity + blur\n * falloff so older messages read as fading from the page. Beyond a\n * `visibleCount` cap (default 3) the trail collapses into an \"N more \u00B7\n * expand\" affordance \u2014 clicking emits `trail-expand`.\n *\n * Light DOM (no shadow root) so the host page's CSS variables and the\n * surrounding canvas tokens flow through without a nested shadow\n * boundary.\n *\n * See PRD \u00A74.3 (chat trail) for the canonical motion + falloff spec.\n */\n\nimport { renderMarkdown } from '@syntrologie/chat';\nimport { html, LitElement, nothing } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport interface TrailToolCall {\n id: string;\n name: string;\n status: 'args-streaming' | 'pending' | 'running' | 'done' | 'error';\n}\n\nexport interface TrailMessage {\n /** Stable identity for keyed rendering (must be unique within the trail). */\n id: number | string;\n role: 'user' | 'assistant' | 'system';\n text: string;\n /** Streaming \u2192 assistant text still arriving from backend. Complete \u2192 final. Error \u2192 fatal during stream. */\n status?: 'streaming' | 'complete' | 'error';\n /** Tool calls attached to an assistant message (rendered as compact chips). */\n toolCalls?: TrailToolCall[];\n}\n\n/** PRD \u00A74.3 constants. */\nconst DEFAULT_VISIBLE = 3;\nconst OPACITY_STEP = 0.22;\nconst OPACITY_FLOOR = 0.18;\nconst Y_DRIFT_PX = -2;\n/**\n * Height of the absolute blur veil at the top of the trail's scroll\n * area. Pixel-based, NOT message-count-based: with the old per-chip\n * `filter: blur(pos * step)` model, a single long markdown response\n * at pos=1 would have its entire body uniformly blurred \u2014 including\n * the chunk visually adjacent to the crisp newest message \u2014 because\n * blur is a property of the chip element, not of pixels. Switching\n * to a fixed-height backdrop-blur veil keeps the bottom of the\n * visible area (newest content) crisp regardless of message length.\n */\nconst TRAIL_BLUR_VEIL_PX = 72;\n/** Max blur applied at the very top of the veil; tapers to 0 at the bottom edge. */\nconst TRAIL_BLUR_MAX_PX = 5;\n\nexport class AdaptiveChatTrail extends LitElement {\n static override properties = {\n messages: { attribute: false },\n visibleCount: { type: Number },\n expanded: { type: Boolean },\n greeting: { type: String },\n /** When true: trail renders fully expanded AND the\n * expand/collapse affordance is hidden. Used by hosts that mount\n * the chat in a full-screen surface (the mobile panel) where\n * collapse makes no sense \u2014 there's nothing to collapse INTO. */\n forceExpanded: { type: Boolean },\n };\n\n messages: TrailMessage[] = [];\n visibleCount = DEFAULT_VISIBLE;\n expanded = false;\n forceExpanded = false;\n /**\n * Pre-conversation phantom assistant message. Rendered only when\n * `messages` is empty. NOT injected into chatSession state \u2014 the\n * greeting is configuration, not conversation, so it disappears\n * automatically when the first real message arrives.\n */\n greeting: string | undefined = undefined;\n\n override createRenderRoot(): HTMLElement {\n // Light DOM \u2014 canvas-level CSS vars reach the chips directly.\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n ensureStreamingKeyframes();\n }\n\n private _onExpand = (): void => {\n // Self-manage: clicking the inline link expands the trail in place.\n // We still dispatch the event so any parent that wants to react\n // (telemetry, mirror state to a side panel, etc.) can listen.\n this.expanded = true;\n this.dispatchEvent(new CustomEvent('trail-expand', { bubbles: true, composed: true }));\n };\n\n /**\n * Approve a pending client tool call. The trail emits a generic\n * event so the host can decide whether to forward to chatSession\n * (the common path) or override. Keeps the trail itself free of\n * direct chatSession coupling \u2014 it's a pure view component.\n */\n private _onToolCallClick = (tc: TrailToolCall): void => {\n if (tc.status !== 'pending') return;\n this.dispatchEvent(\n new CustomEvent<{ toolCallId: string; approved: boolean }>('trail-toolcall-approved', {\n detail: { toolCallId: tc.id, approved: true },\n bubbles: true,\n composed: true,\n })\n );\n };\n\n private _onCollapse = (): void => {\n // Mirror of _onExpand for the minimize affordance shown while\n // expanded. Self-manages + dispatches `trail-collapse` for parent\n // observers (telemetry, side-panel mirrors).\n this.expanded = false;\n this.dispatchEvent(new CustomEvent('trail-collapse', { bubbles: true, composed: true }));\n };\n\n override updated(changed: Map<string, unknown>): void {\n // Anchor the scroll to the bottom whenever:\n // - the trail flips into expanded mode (UX continuity), OR\n // - new messages or text deltas arrive (so a long streaming chip\n // stays pinned to the latest line, not the start of the chip).\n // Skip when the user has manually scrolled UP into history \u2014 we'd\n // rather lose pinning than yank them out of what they're reading.\n if (changed.has('expanded') || changed.has('messages')) {\n requestAnimationFrame(() => {\n const container = this.querySelector<HTMLElement>('[data-syntro-chat-trail]');\n if (!container) return;\n const distanceFromBottom =\n container.scrollHeight - container.scrollTop - container.clientHeight;\n // 200px tolerance \u2014 streaming deltas can append a paragraph in\n // one update, easily 80-150px. A tighter window would strand\n // the viewer at the top of the chip mid-stream because the\n // first delta blew past the threshold. User-driven scroll-up\n // of >200px disables auto-pin until they scroll back down.\n if (distanceFromBottom < 200 || changed.has('expanded')) {\n container.scrollTop = container.scrollHeight;\n }\n });\n }\n }\n\n override render() {\n if (this.messages.length === 0 && !this.greeting) return nothing;\n if (this.messages.length === 0 && this.greeting) {\n // Render the greeting as a pure-display assistant chip. No\n // tool-calls, no streaming caret, single chip at pos=0.\n return html`<div data-syntro-chat-trail style=${styleMap({\n display: 'flex',\n flexDirection: 'column',\n gap: '6px',\n justifyContent: 'flex-end',\n width: '100%',\n padding: '0',\n pointerEvents: 'auto',\n })}>\n <div\n data-trail-chip\n data-role=\"assistant\"\n data-status=\"greeting\"\n style=${styleMap(chipStyles('assistant', 0, { isStreaming: false, isError: false }))}\n >${unsafeHTML(renderMarkdown(stripTrailingWhitespace(this.greeting)))}</div>\n </div>`;\n }\n\n // Choose the slice we actually paint. Newest are at the END of the\n // array (closest to the chat bar). When not expanded, take the last\n // `visibleCount`; when expanded, take all.\n const visible =\n this.expanded || this.forceExpanded ? this.messages : this.messages.slice(-this.visibleCount);\n const hidden = this.messages.length - visible.length;\n\n const baseStyles: Record<string, string> = {\n display: 'flex',\n flexDirection: 'column',\n gap: '6px',\n // NO `justifyContent: flex-end` here \u2014 combined with `overflow: auto`\n // it's a known cross-browser bug: oversized flex children get\n // pushed ABOVE the container without contributing to scrollHeight,\n // so the scrollbar never appears. We rely on `:first-child {\n // margin-top: auto }` (injected as global CSS) to push short\n // content to the bottom of the box while leaving overflow handling\n // to the native scroll container.\n width: '100%',\n // The trail itself has no chrome \u2014 chips sit on the host page bg.\n padding: '0',\n pointerEvents: 'auto',\n };\n\n // Expanded mode: cap height, scroll, and add a visible top border so\n // the panel reads as a bounded region. NO background tint or shadow\n // \u2014 the ambient (collapsed) treatment is fine and we don't want to\n // suddenly introduce panel chrome that wasn't there before. The\n // border alone marks the panel's top edge.\n // Falloff is turned off per-chip below \u2014 readability wins once the\n // user has explicitly asked for history. See PRD \u00A74.3.\n // Collapsed mode also gets a (looser) cap + scroll so a single long\n // markdown chip doesn't blow the chat-bar off-screen with no\n // scroll affordance. Tighter than expanded so the bubble-up trail\n // doesn't dominate the surface visually.\n const modeStyles: Record<string, string> = this.forceExpanded\n ? {\n // Full-screen host: fill all available vertical space and\n // scroll the overflow. ``flex: 1 1 0`` (basis 0, not auto)\n // makes the trail shrink to 0 first when the parent runs\n // out of space \u2014 so the header above and the input row\n // below stay pinned at their natural sizes instead of one\n // of them being pushed off-screen.\n flex: '1 1 0',\n minHeight: '0',\n overflowY: 'auto',\n // ``contain`` prevents scroll from bubbling out to the host\n // page when the trail hits top or bottom. Required for the\n // panel-scroll-leak regression test in\n // SyntroBottomSheet.test.ts.\n overscrollBehavior: 'contain',\n paddingTop: '8px',\n borderTop: 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n scrollBehavior: 'smooth',\n scrollbarWidth: 'thin',\n }\n : this.expanded\n ? {\n maxHeight: 'min(320px, 40vh)',\n overflowY: 'auto',\n paddingTop: '8px',\n borderTop: 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n scrollBehavior: 'smooth',\n scrollbarWidth: 'thin',\n }\n : {\n // Collapsed mode = ambient peek surface. Never a scrollbar:\n // long messages slide up behind the blur veil instead of\n // exposing a scrollbar. The \"\u2191 N more \u00B7 expand\" affordance\n // is the only entry into history; clicking it switches to\n // expanded mode where scroll IS allowed.\n // Height kept short so the trail reads as a peek strip above\n // the chat bar, not a panel \u2014 long single replies fade into\n // the blur veil at the top, user expands to read the rest.\n maxHeight: 'min(140px, 22vh)',\n overflow: 'hidden',\n };\n\n const containerStyles = { ...baseStyles, ...modeStyles };\n\n // Wrap the scroll container in a positioning frame so the absolute\n // blur veil (rendered at the top) anchors to the scroll viewport's\n // top edge \u2014 NOT to a chip that scrolls under it. Pixel-anchored\n // blur means: the top TRAIL_BLUR_VEIL_PX of the visible area is\n // veiled regardless of how many messages occupy those pixels.\n // The frame wraps the scroll container so the absolute blur veil\n // anchors to the scroll viewport's top edge. In ``forceExpanded``\n // mode it ALSO has to participate in the flex column laid out by\n // the trail host \u2014 otherwise the scroll container's ``flex: 1 1\n // 0`` has no flex context, falls back to content height, and the\n // trail's overflow:hidden clips at the TOP of the scroll\n // (showing oldest messages, hiding the newest at the bottom).\n const frameStyles: Record<string, string> = this.forceExpanded\n ? {\n position: 'relative',\n width: '100%',\n display: 'flex',\n flexDirection: 'column',\n flex: '1 1 0',\n minHeight: '0',\n }\n : {\n position: 'relative',\n width: '100%',\n };\n\n return html`\n ${\n // Single toggle button above the frame. Same DOM node morphs:\n // collapsed \u2192 \"\u2191 N more \u00B7 expand\" / \"\u2191 expand\" (calls _onExpand)\n // expanded \u2192 \"\u2304 minimize\" (calls _onCollapse)\n // Lives OUTSIDE the frame so the absolute blur veil (top:0,\n // z-index:2 inside the frame) doesn't cover it. Shown whenever\n // there's anything in the trail \u2014 the user expects this affordance\n // available regardless of how many chips are on screen.\n // When ``forceExpanded`` is set by the host (full-screen panel,\n // etc.), there's nowhere to collapse INTO and the affordance\n // would just confuse the user \u2014 suppress it entirely.\n this.messages.length === 0 || this.forceExpanded\n ? nothing\n : this.expanded\n ? html`<button\n type=\"button\"\n data-trail-toggle\n data-trail-collapse\n @click=${this._onCollapse}\n style=${styleMap(moreStyles())}\n >\u2304 minimize</button>`\n : html`<button\n type=\"button\"\n data-trail-toggle\n data-trail-more\n @click=${this._onExpand}\n style=${styleMap(moreStyles())}\n >${hidden > 0 ? html`\u2191 ${hidden} more \u00B7 expand` : html`\u2191 expand`}</button>`\n }\n <div data-syntro-chat-trail-frame style=${styleMap(frameStyles)}>\n <div data-syntro-chat-trail style=${styleMap(containerStyles)}>\n ${visible.map((m, i) => {\n // Stack position from the bar: 0 = closest, N-1 = oldest.\n // visible[last] is closest, so reverse the index from the\n // tail of the visible slice. When expanded, the ambient\n // falloff is suppressed (pos = 0) so every chip reads at\n // full opacity \u2014 explicit history view, not ambient trail.\n const pos = this.expanded || this.forceExpanded ? 0 : visible.length - 1 - i;\n const isStreaming = m.status === 'streaming';\n const isError = m.status === 'error' || m.role === 'system';\n const toolCalls = m.toolCalls ?? [];\n // Assistant text is markdown-formatted by the agent (lists,\n // code, bold, links). renderMarkdown sanitizes via DOMPurify,\n // then unsafeHTML injects the safe HTML. User + system chips\n // stay plain text \u2014 no markdown risk + no expansion attack\n // surface on user-typed input.\n const renderedText =\n m.role === 'assistant'\n ? html`${unsafeHTML(renderMarkdown(stripTrailingWhitespace(m.text)))}`\n : html`${m.text}`;\n return html`<div\n data-trail-chip\n data-role=${m.role}\n data-status=${m.status ?? 'complete'}\n style=${styleMap(chipStyles(m.role, pos, { isStreaming, isError }))}\n >${renderedText}${\n isStreaming\n ? html`<span\n data-trail-caret\n aria-hidden=\"true\"\n style=${styleMap(caretStyles())}\n ></span>`\n : nothing\n }${\n toolCalls.length > 0\n ? html`<div data-trail-toolcalls style=${styleMap(toolCallStripStyles())}>\n ${toolCalls.map(\n (tc) => html`<button\n type=\"button\"\n data-trail-toolcall\n data-tool-id=${tc.id}\n data-tool-status=${tc.status}\n @click=${() => this._onToolCallClick(tc)}\n ?disabled=${tc.status !== 'pending'}\n style=${styleMap(toolCallChipStyles(tc.status))}\n title=\"${tc.name} \u00B7 ${tc.status}\"\n >${toolCallIcon(tc.status)} ${tc.name}</button>`\n )}\n </div>`\n : nothing\n }</div>`;\n })}\n </div>\n ${\n // The blur veil only fires in collapsed (ambient) mode.\n // Expanded = the user explicitly asked for history; blurring\n // the top of the panel would hide content (including the\n // minimize button just above the trail's top edge) the user\n // came here to see.\n this.expanded || this.forceExpanded\n ? nothing\n : html`<div\n data-trail-blur-veil\n aria-hidden=\"true\"\n style=${styleMap(blurVeilStyles())}\n ></div>`\n }\n </div>\n `;\n }\n}\n\n/**\n * Absolute blur veil at the top of the scroll viewport. Uses\n * `backdrop-filter: blur(...)` so whatever pixels sit beneath the veil\n * (top of the scroll content) become blurred, regardless of which chip\n * those pixels belong to. A linear mask fades the blur effect from full\n * at the top to zero at the bottom of the veil \u2014 newest content stays\n * crisp because it lives below the veil's height.\n *\n * Note: `mask-image` controls where the BACKDROP-FILTER applies (via\n * masking the veil element), so the bottom edge of the veil naturally\n * dissolves into the unblurred scroll area below.\n */\nfunction blurVeilStyles(): Record<string, string> {\n const mask = 'linear-gradient(to bottom, black 0%, black 40%, transparent 100%)';\n return {\n position: 'absolute',\n top: '0',\n left: '0',\n right: '0',\n height: `${TRAIL_BLUR_VEIL_PX}px`,\n pointerEvents: 'none',\n backdropFilter: `blur(${TRAIL_BLUR_MAX_PX}px)`,\n WebkitBackdropFilter: `blur(${TRAIL_BLUR_MAX_PX}px)`,\n maskImage: mask,\n WebkitMaskImage: mask,\n zIndex: '2',\n };\n}\n\nfunction chipStyles(\n role: TrailMessage['role'],\n pos: number,\n state: { isStreaming: boolean; isError: boolean } = { isStreaming: false, isError: false }\n): Record<string, string> {\n const opacity = Math.max(OPACITY_FLOOR, 1 - pos * OPACITY_STEP);\n const yPx = pos * Y_DRIFT_PX;\n\n // Error chips override role-specific styling \u2014 they shouldn't read\n // as \"an assistant reply.\" Streaming chips get a subtle accent ring\n // so the in-progress state is visually distinct from a settled reply.\n // All four states resolve to design-system tokens via the theme; the\n // fallbacks here are conservative neutrals so the widget still renders\n // sensibly on a host page that hasn't set tokens yet.\n const border = state.isError\n ? 'var(--sc-content-bubble-border-error, 1px solid rgba(220, 80, 80, 0.55))'\n : state.isStreaming\n ? 'var(--sc-content-bubble-border-user, 1px solid rgba(255, 255, 255, 0.28))'\n : role === 'user'\n ? 'var(--sc-content-bubble-border-user, 1px solid rgba(255, 255, 255, 0.28))'\n : 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))';\n const background = state.isError\n ? 'var(--sc-content-bubble-background-error, rgba(140, 40, 40, 0.42))'\n : role === 'user'\n ? 'var(--sc-content-bubble-background-user, rgba(255, 255, 255, 0.10))'\n : 'var(--sc-content-bubble-background, rgba(20, 22, 24, 0.35))';\n\n const base: Record<string, string> = {\n alignSelf: role === 'user' ? 'flex-end' : 'flex-start',\n maxWidth: '85%',\n fontSize: '11px',\n lineHeight: '1.45',\n padding: '4px 10px',\n borderRadius: '10px',\n border,\n background,\n backdropFilter: 'blur(8px)',\n WebkitBackdropFilter: 'blur(8px)',\n color: state.isError\n ? 'var(--sc-content-bubble-text-error, rgba(255, 220, 220, 0.95))'\n : 'var(--sc-tile-title-color, inherit)',\n transition:\n 'opacity 240ms cubic-bezier(0.22, 1, 0.36, 1), transform 240ms cubic-bezier(0.22, 1, 0.36, 1)',\n // Per-position opacity + y-drift falloff is still per-chip \u2014 those\n // operate naturally per element. Blur is NOT per-chip anymore: it's\n // applied via an absolute-positioned veil at the top of the scroll\n // viewport (TRAIL_BLUR_VEIL_PX above), so a single long message\n // doesn't get uniformly blurred across its full body.\n opacity: String(toFixedTrim(opacity)),\n transform: `translateY(${yPx}px)`,\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n };\n return base;\n}\n\nfunction toolCallStripStyles(): Record<string, string> {\n return {\n display: 'flex',\n flexWrap: 'wrap',\n gap: '4px',\n marginTop: '4px',\n paddingTop: '4px',\n borderTop: '1px dashed var(--sc-content-divider-color, rgba(255, 255, 255, 0.12))',\n };\n}\n\nfunction toolCallChipStyles(status: TrailToolCall['status']): Record<string, string> {\n const isPending = status === 'pending';\n const isError = status === 'error';\n const isDone = status === 'done';\n return {\n display: 'inline-flex',\n alignItems: 'center',\n gap: '4px',\n padding: '2px 7px',\n border: isError\n ? 'var(--sc-content-bubble-border-error, 1px solid rgba(220, 80, 80, 0.45))'\n : isPending\n ? 'var(--sc-content-bubble-border-user, 1px solid rgba(255, 255, 255, 0.28))'\n : 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n background: isError\n ? 'var(--sc-content-bubble-background-error, rgba(140, 40, 40, 0.35))'\n : isPending\n ? 'var(--sc-content-bubble-background-user, rgba(255, 255, 255, 0.10))'\n : isDone\n ? 'var(--sc-content-bubble-background-idle, rgba(40, 44, 50, 0.4))'\n : 'var(--sc-content-bubble-background, rgba(20, 22, 24, 0.35))',\n color: 'var(--sc-tile-text-color, inherit)',\n borderRadius: '999px',\n fontSize: '10px',\n fontWeight: '500',\n fontFamily: 'ui-monospace, SF Mono, Menlo, monospace',\n cursor: isPending ? 'pointer' : 'default',\n opacity: isDone ? '0.7' : '1',\n };\n}\n\nfunction toolCallIcon(status: TrailToolCall['status']): string {\n switch (status) {\n case 'args-streaming':\n case 'running':\n return '\u22EF';\n case 'pending':\n return '?';\n case 'done':\n return '\u2713';\n case 'error':\n return '\u2717';\n default:\n return '\u00B7';\n }\n}\n\nfunction caretStyles(): Record<string, string> {\n return {\n display: 'inline-block',\n width: '6px',\n height: '12px',\n marginLeft: '3px',\n verticalAlign: '-1px',\n background: 'hsl(var(--sc-accent-color) / 0.85)',\n borderRadius: '1px',\n animation: 'syntro-trail-caret 1s steps(2, end) infinite',\n };\n}\n\nfunction moreStyles(): Record<string, string> {\n return {\n // Center horizontally regardless of the parent's display model.\n // ``alignSelf: center`` only works when the parent is a flex/grid\n // container with cross-axis alignment; the chat-bar's flex column\n // stretches us full-width instead. ``display: block`` + auto inline\n // margins centers the auto-sized button without needing the parent\n // to opt in.\n display: 'block',\n marginLeft: 'auto',\n marginRight: 'auto',\n marginBottom: '6px',\n fontSize: '10px',\n fontWeight: '500',\n letterSpacing: '0.06em',\n padding: '4px 10px',\n border: '1px solid hsl(var(--sc-accent-color) / 0.32)',\n borderRadius: '999px',\n background: 'hsl(var(--sc-accent-color) / 0.10)',\n color: 'var(--sc-tile-text-color, currentColor)',\n cursor: 'pointer',\n opacity: '0.85',\n backdropFilter: 'blur(8px)',\n WebkitBackdropFilter: 'blur(8px)',\n transition: 'opacity 150ms ease, background 150ms ease',\n };\n}\n\n/**\n * Inject the streaming-caret keyframes once per document. Light-DOM\n * components can't ship CSS via Lit's `styles` static \u2014 the rules\n * need to be present in the document's stylesheet. Idempotent via\n * a data attribute on the injected style tag.\n */\nfunction ensureStreamingKeyframes(): void {\n if (typeof document === 'undefined') return;\n if (document.head.querySelector('style[data-syntro-trail-caret-keyframes]')) return;\n const style = document.createElement('style');\n style.setAttribute('data-syntro-trail-caret-keyframes', 'true');\n // Caret animation + markdown reset for assistant chips. The trail\n // chips are tiny (11px line-height); default <p>/<ul>/<pre> margins\n // would push the chip vertically and break the falloff layout.\n style.textContent = [\n '@keyframes syntro-trail-caret { 0%{opacity:1} 50%{opacity:0} 100%{opacity:1} }',\n // Anchor short content to the bottom of the scrollable trail \u2014\n // see baseStyles comment for why we can't use justify-content.\n '[data-syntro-chat-trail] > :first-child { margin-top: auto }',\n // Tight spacing \u2014 trail chips are an 11px-line-height pill. Default\n // browser <p>/<ul> margins (1em \u2248 11px each side) would dominate the\n // chip. Keep paragraph + list separators minimal (4px) so multi-\n // paragraph replies read as one continuous flow, not a vertical\n // stack of fragments.\n '[data-trail-chip] > p:first-child { margin-top: 0 }',\n '[data-trail-chip] > p:last-child { margin-bottom: 0 }',\n '[data-trail-chip] p { margin: 4px 0 }',\n '[data-trail-chip] br + br { display: none }',\n '[data-trail-chip] ul, [data-trail-chip] ol { margin: 4px 0; padding-left: 1.1em }',\n '[data-trail-chip] li { margin: 0 }',\n '[data-trail-chip] li + li { margin-top: 1px }',\n '[data-trail-chip] pre { margin: 6px 0; padding: 6px 8px; background: var(--sc-content-code-background-block, rgba(0, 0, 0, 0.35)); border-radius: 6px; overflow-x: auto; font-size: 10px }',\n '[data-trail-chip] code { font-family: ui-monospace, SF Mono, Menlo, monospace; font-size: 10px; background: var(--sc-content-code-background, rgba(0, 0, 0, 0.25)); padding: 1px 4px; border-radius: 3px }',\n '[data-trail-chip] pre code { background: transparent; padding: 0 }',\n '[data-trail-chip] a { color: var(--sc-content-link-color, var(--sc-color-primary, #b72e2a)); text-decoration: underline }',\n '[data-trail-chip] strong { font-weight: 600 }',\n ].join(' ');\n document.head.appendChild(style);\n}\n\n/**\n * Pre-process LLM markdown before rendering. Three common artifacts:\n *\n * 1. Trailing \" \" (two spaces = markdown hard-break) sprinkled at\n * end-of-line, even inside list items where it just leaks\n * invisible whitespace into the DOM.\n * 2. Runs of 3+ blank lines used as visual separators. Markdown\n * treats any number of blank lines as a single paragraph break,\n * so the extras add nothing semantically \u2014 but combined with\n * paragraph margins they create huge gaps in the tiny chip layout.\n * 3. Leading / trailing newlines on the whole message. Trailing\n * `\\n\\n` is the common one \u2014 marked turns it into a final empty\n * <p> that still occupies a full line-height of vertical space,\n * leaving a visible gap between the last text and the chat bar.\n *\n * Collapsing all three keeps the rendered HTML tight without changing\n * the agent's semantic intent.\n */\nfunction stripTrailingWhitespace(text: string): string {\n return text\n .replace(/[ \\t]+$/gm, '') // trailing whitespace per line\n .replace(/\\n{3,}/g, '\\n\\n') // collapse runs of blank lines\n .trim(); // drop leading/trailing whitespace+newlines on the whole message\n}\n\n/** Two-decimal trim that avoids trailing zeros (\".50\" \u2192 \".5\"). */\nfunction toFixedTrim(n: number): string {\n const s = n.toFixed(2);\n return s.replace(/\\.?0+$/, '') || '0';\n}\n\nif (!customElements.get('adaptive-chat-trail')) {\n customElements.define('adaptive-chat-trail', AdaptiveChatTrail);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'adaptive-chat-trail': AdaptiveChatTrail;\n }\n}\n"],
5
- "mappings": ";;;;;AAkBA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAoB3B,IAAM,kBAAkB;AACxB,IAAM,eAAe;AACrB,IAAM,gBAAgB;AACtB,IAAM,aAAa;AAWnB,IAAM,qBAAqB;AAE3B,IAAM,oBAAoB;AAEnB,IAAM,oBAAN,cAAgC,WAAW;AAAA,EAA3C;AAAA;AAaL,oBAA2B,CAAC;AAC5B,wBAAe;AACf,oBAAW;AACX,yBAAgB;AAOhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAY/B,SAAQ,YAAY,MAAY;AAI9B,WAAK,WAAW;AAChB,WAAK,cAAc,IAAI,YAAY,gBAAgB,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AAAA,IACvF;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,mBAAmB,CAAC,OAA4B;AACtD,UAAI,GAAG,WAAW,UAAW;AAC7B,WAAK;AAAA,QACH,IAAI,YAAuD,2BAA2B;AAAA,UACpF,QAAQ,EAAE,YAAY,GAAG,IAAI,UAAU,KAAK;AAAA,UAC5C,SAAS;AAAA,UACT,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAEA,SAAQ,cAAc,MAAY;AAI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,cAAc;AAAA,IACd,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,IACtB,YAAY;AAAA,EACd;AACF;AAQA,SAAS,2BAAiC;AACxC,MAAI,OAAO,aAAa,YAAa;AACrC,MAAI,SAAS,KAAK,cAAc,0CAA0C,EAAG;AAC7E,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,qCAAqC,MAAM;AAI9D,QAAM,cAAc;AAAA,IAClB;AAAA;AAAA;AAAA,IAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,KAAK,GAAG;AACV,WAAS,KAAK,YAAY,KAAK;AACjC;AAoBA,SAAS,wBAAwB,MAAsB;AACrD,SAAO,KACJ,QAAQ,aAAa,EAAE,EACvB,QAAQ,WAAW,MAAM,EACzB,KAAK;AACV;AAGA,SAAS,YAAY,GAAmB;AACtC,QAAM,IAAI,EAAE,QAAQ,CAAC;AACrB,SAAO,EAAE,QAAQ,UAAU,EAAE,KAAK;AACpC;AAEA,IAAI,CAAC,eAAe,IAAI,qBAAqB,GAAG;AAC9C,iBAAe,OAAO,uBAAuB,iBAAiB;AAChE;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/AdaptiveChatBar.ts"],
4
- "sourcesContent": ["/**\n * AdaptiveChatBar \u2014 the canvas lid composition for the chat-canvas\n * experience. Renders the bubble-up trail on top and an always-visible\n * input row below.\n *\n * Wiring contract (events out):\n * - `chat-message-sent` ({ text }): the user submitted text via Enter\n * or the send button. The owning code is responsible for pushing\n * this into the conversation history and producing a reply.\n * - `canvas-close`: the user clicked the close \u2715 button. Propagated\n * to the canvas overlay so the underlying drawer is dismissed.\n *\n * Wiring contract (props in):\n * - `messages`: the conversation trail, passed straight through to\n * `<adaptive-chat-trail>`.\n * - `placeholder`: input placeholder copy. Defaults to a generic\n * \"Ask, find, or navigate\u2026\" \u2014 the host (typically the slot's lid\n * widget mount) can override to a context-specific string.\n *\n * Light DOM. Glassmorphism is applied at the input-row level so the\n * trail above floats over the host page without chrome. See PRD \u00A74.4.\n */\n\nimport { html, LitElement, nothing } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nimport './AdaptiveChatTrail.js';\nimport type { TrailMessage } from './AdaptiveChatTrail.js';\n\nconst DEFAULT_PLACEHOLDER = 'Ask, find, or navigate\u2026';\n\nexport class AdaptiveChatBar extends LitElement {\n static override properties = {\n messages: { attribute: false },\n placeholder: { type: String },\n greeting: { type: String },\n inFlight: { type: Boolean, reflect: true },\n forceExpanded: { type: Boolean, reflect: true },\n _input: { state: true },\n };\n\n messages: TrailMessage[] = [];\n\n /** Pass-through to {@link AdaptiveChatTrail}'s ``forceExpanded`` prop.\n * Hosts that mount the chat-bar in a full-screen surface (mobile\n * panel, agent app, etc.) set this to skip the collapse affordance\n * \u2014 there is no smaller state to fall back to. */\n forceExpanded = false;\n placeholder = DEFAULT_PLACEHOLDER;\n /**\n * Initial assistant message shown before any real conversation\n * starts. Renders inside the trail as a phantom assistant chip\n * when messages.length === 0; auto-disappears as soon as the\n * first user message lands. Mirrors ChatAssistantLit's greeting.\n */\n greeting: string | undefined = undefined;\n /**\n * Whether a chat round-trip is in flight (request sent, awaiting\n * reply). The single send/stop button morphs accordingly: \u2191 when\n * ready, \u23F9 when in-flight. Parent owns this state \u2014 set true after\n * `chat-message-sent` fires, false when the reply lands or the\n * request is aborted. Enter is inert while in-flight.\n */\n inFlight = false;\n _input = '';\n\n override createRenderRoot(): HTMLElement {\n return this;\n }\n\n // Host-level styling (display, width, height, flex, etc.) is owned\n // by the container \u2014 SDK shadow root provides default rules, panel\n // overrides via design tokens (--sc-chat-bar-host-*). This adaptive\n // never sets inline styles on itself. See SmartCanvasElementLit's\n // static styles for the rule.\n\n private _onInput = (e: Event): void => {\n this._input = (e.target as HTMLInputElement).value;\n };\n\n private _onKeyDown = (e: KeyboardEvent): void => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n // Enter is the send affordance \u2014 while in-flight there's nothing\n // to send, so it's a no-op. Interrupt requires the explicit\n // \u23F9 click to avoid surprise-aborting on a stray keystroke.\n if (this.inFlight) return;\n this._send();\n }\n };\n\n // Single button. Click delegates to send-or-interrupt based on\n // current state. Same DOM node, different behavior \u2014 discoverability\n // wins from the user not having to scan for which control is active.\n private _onSendOrInterrupt = (): void => {\n if (this.inFlight) {\n this.dispatchEvent(new CustomEvent('chat-interrupt', { bubbles: true, composed: true }));\n return;\n }\n this._send();\n };\n\n private _onClose = (): void => {\n this.dispatchEvent(new CustomEvent('canvas-close', { bubbles: true, composed: true }));\n };\n\n private _send(): void {\n const text = this._input.trim();\n if (!text) return;\n this.dispatchEvent(\n new CustomEvent<{ text: string }>('chat-message-sent', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n this._input = '';\n // Drop the input value too \u2014 the input's bound value is `this._input`\n // via the render, but jsdom's two-way binding via property only takes\n // effect after the next render, so set it imperatively for the test\n // and for browser symmetry (most browsers do the right thing here\n // anyway because Lit re-renders on the state change).\n const input = this.querySelector<HTMLInputElement>('input[data-chat-input]');\n if (input) input.value = '';\n }\n\n override render() {\n return html`\n <div style=${styleMap(rootStyles(this.forceExpanded))}>\n ${this.forceExpanded ? renderHeader() : nothing}\n <adaptive-chat-trail\n .messages=${this.messages}\n .greeting=${this.greeting}\n .forceExpanded=${this.forceExpanded}\n ></adaptive-chat-trail>\n <div style=${styleMap(rowStyles(this.forceExpanded))} data-chat-row>\n <span style=${styleMap(avatarStyles())} aria-hidden=\"true\">\u2726</span>\n <input\n data-chat-input\n type=\"text\"\n placeholder=${this.placeholder}\n .value=${this._input}\n @input=${this._onInput}\n @keydown=${this._onKeyDown}\n style=${styleMap(inputStyles())}\n aria-label=\"Chat input\"\n />\n <button\n type=\"button\"\n data-chat-send\n data-state=${this.inFlight ? 'in-flight' : 'ready'}\n @click=${this._onSendOrInterrupt}\n aria-label=${this.inFlight ? 'Stop' : 'Send message'}\n title=${this.inFlight ? 'Interrupt' : 'Send'}\n style=${styleMap(sendStyles(this.inFlight))}\n >${this.inFlight ? '\u25A0' : '\u2191'}</button>\n <button\n type=\"button\"\n data-chat-close\n @click=${this._onClose}\n aria-label=\"Hide chat\"\n style=${styleMap(closeStyles())}\n >\u2715</button>\n </div>\n </div>\n `;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Styles \u2014 kept inline (Lit styleMap) so they participate in light-DOM\n// rendering and pick up host CSS variables (e.g. --sc-tile-background).\n// ---------------------------------------------------------------------------\n\nfunction rootStyles(forceExpanded: boolean): Record<string, string> {\n // When the host expects the chat to fill its container (full-screen\n // panel, agent app), we grow vertically AND wrap the whole widget in\n // its own chrome card \u2014 trail + input read as one cohesive surface\n // instead of a naked trail above a chrome'd input. Floating mounts\n // (bottom-right pinned, etc.) stay chrome-less here because their\n // chrome is owned by the host's positioned wrapper.\n if (!forceExpanded) {\n return {\n display: 'flex',\n flexDirection: 'column',\n gap: '6px',\n width: '100%',\n pointerEvents: 'auto',\n };\n }\n // Input is ABSOLUTELY positioned at the bottom of this chrome card\n // (see rowStyles forceExpanded mode). That guarantees the input is\n // always visible \u2014 even when the lid region is tighter than the\n // chat-bar would naturally want. The flex column above holds\n // header + trail; padding-bottom reserves the input's footprint so\n // trail content can never overlap.\n //\n // Priority of \"what disappears when space is tight\":\n // Trail (shrinks to 0 first via flex: 1 1 0)\n // Header (can shrink via default flex: 0 1 auto)\n // Input (NEVER \u2014 it's positioned absolute, always at the bottom)\n return {\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '8px',\n width: '100%',\n height: '100%',\n boxSizing: 'border-box',\n flex: '1 1 auto',\n minHeight: '0',\n overflow: 'hidden',\n pointerEvents: 'auto',\n background: 'var(--sc-tile-background, rgba(255, 255, 255, 0.92))',\n border: 'var(--sc-tile-border, 1px solid rgba(0, 0, 0, 0.06))',\n borderRadius: 'var(--sc-tile-border-radius, 14px)',\n boxShadow: 'var(--sc-tile-shadow, 0 12px 32px -16px rgba(0, 0, 0, 0.18))',\n // Reserves room for the absolute-positioned input pill (36px high\n // + 12px from bottom) plus a 16px visual gap above the input.\n padding: '0.75rem 0.75rem calc(36px + 1.75rem)',\n color: 'var(--sc-tile-title-color, inherit)',\n fontFamily: 'var(--sc-font-family, inherit)',\n // Override the trail's host-layout tokens so the trail (a flex item\n // of this column) shrinks to 0 first when space is tight \u2014 letting\n // the header and absolute-positioned input pill stay pinned. The\n // SDK-level rule in SmartCanvasElementLit consumes these tokens on\n // adaptive-chat-trail's host element. Containers OWN host styling\n // via tokens; the adaptive never sets inline styles on its host.\n ['--sc-chat-trail-host-display']: 'flex',\n ['--sc-chat-trail-host-flex-direction']: 'column',\n ['--sc-chat-trail-host-flex']: '1 1 0',\n ['--sc-chat-trail-host-min-height']: '0',\n ['--sc-chat-trail-host-overflow']: 'hidden',\n };\n}\n\nfunction rowStyles(forceExpanded: boolean): Record<string, string> {\n // forceExpanded \u2014 root container already carries the chrome; row\n // becomes a flat input-pill inside that chrome (subtle border + soft\n // background, no shadow/blur).\n if (forceExpanded) {\n // Absolute-pinned to the chrome card's bottom edge so it never\n // disappears under any container size. The chrome reserves\n // padding-bottom equal to this row's footprint so flex content\n // above (header + trail) can't overlap.\n return {\n position: 'absolute',\n left: '0.75rem',\n right: '0.75rem',\n bottom: '0.75rem',\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n padding: '6px 14px',\n borderRadius: '9999px',\n background: 'rgba(0, 0, 0, 0.04)',\n border: '1px solid rgba(0, 0, 0, 0.10)',\n color: 'var(--sc-content-text-color, inherit)',\n fontFamily: 'var(--sc-font-family, inherit)',\n minHeight: '36px',\n };\n }\n // Floating mount \u2014 keeps the original tile-chrome look.\n return {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n padding: '10px 12px',\n borderRadius: 'var(--sc-tile-border-radius, 14px)',\n background: 'var(--sc-tile-background, rgba(15, 19, 24, 0.6))',\n backdropFilter: 'var(--sc-chat-bar-blur, blur(24px) saturate(140%))',\n WebkitBackdropFilter: 'var(--sc-chat-bar-blur, blur(24px) saturate(140%))',\n border: 'var(--sc-tile-border, 1px solid rgba(255, 255, 255, 0.08))',\n boxShadow: 'var(--sc-tile-shadow, 0 2px 12px rgba(0, 0, 0, 0.3))',\n color: 'var(--sc-tile-title-color, #fafafa)',\n fontFamily: 'var(--sc-font-family, inherit)',\n };\n}\n\nfunction avatarStyles(): Record<string, string> {\n return {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '24px',\n height: '24px',\n borderRadius: '9999px',\n background: 'hsl(var(--sc-accent-color) / 0.15)',\n border: '1px solid hsl(var(--sc-accent-color) / 0.30)',\n color: 'hsl(var(--sc-accent-color) / 0.95)',\n flexShrink: '0',\n fontSize: '11px',\n };\n}\n\nfunction inputStyles(): Record<string, string> {\n return {\n flex: '1',\n minWidth: '0',\n background: 'transparent',\n border: 'none',\n outline: 'none',\n color: 'inherit',\n fontSize: '13px',\n };\n}\n\nfunction sendStyles(inFlight: boolean): Record<string, string> {\n return {\n width: '28px',\n height: '28px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '9999px',\n // Ready: filled accent (send is the affordance). In-flight: hollow\n // ring + accent ring (stop is a one-of-a-kind disruptive action,\n // styled differently so the user reads \"this isn't just send\").\n background: inFlight ? 'transparent' : 'hsl(var(--sc-accent-color) / 0.85)',\n color: inFlight ? 'hsl(var(--sc-accent-color) / 0.95)' : 'var(--sc-accent-foreground, #fff)',\n border: inFlight ? '1px solid hsl(var(--sc-accent-color) / 0.55)' : 'none',\n cursor: 'pointer',\n flexShrink: '0',\n transition: 'background 150ms ease, color 150ms ease, border-color 150ms ease',\n };\n}\n\nfunction closeStyles(): Record<string, string> {\n return {\n width: '28px',\n height: '28px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '9999px',\n background: 'transparent',\n color: 'inherit',\n border: 'var(--sc-content-bubble-border, 1px solid rgba(255, 255, 255, 0.18))',\n cursor: 'pointer',\n flexShrink: '0',\n opacity: '0.7',\n };\n}\n\nfunction renderHeader() {\n const headerStyles: Record<string, string> = {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n padding: '4px 4px 12px',\n borderBottom: '1px solid var(--sc-content-divider-color, rgba(0, 0, 0, 0.08))',\n flex: '0 0 auto',\n };\n const avatar: Record<string, string> = {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '28px',\n height: '28px',\n borderRadius: '9999px',\n background: 'var(--sc-tile-icon-background, linear-gradient(135deg, #5faf7d 0%, #3d8a5e 100%))',\n color: '#fff',\n flexShrink: '0',\n fontSize: '14px',\n };\n const nameWrap: Record<string, string> = {\n display: 'flex',\n flexDirection: 'column',\n minWidth: '0',\n flex: '1 1 auto',\n };\n const name: Record<string, string> = {\n fontSize: '0.85rem',\n fontWeight: '600',\n color: 'var(--sc-content-text-color, inherit)',\n lineHeight: '1.2',\n };\n const status: Record<string, string> = {\n fontSize: '0.7rem',\n color: 'var(--sc-tile-title-color, #3d8275)',\n display: 'flex',\n alignItems: 'center',\n gap: '4px',\n lineHeight: '1.2',\n };\n const statusDot: Record<string, string> = {\n width: '6px',\n height: '6px',\n borderRadius: '9999px',\n background: 'var(--sc-tile-title-color, #3d8275)',\n display: 'inline-block',\n };\n return html`\n <div style=${styleMap(headerStyles)} data-chat-header>\n <span style=${styleMap(avatar)} aria-hidden=\"true\">\u2726</span>\n <div style=${styleMap(nameWrap)}>\n <span style=${styleMap(name)}>Assistant</span>\n <span style=${styleMap(status)}>\n <span style=${styleMap(statusDot)}></span>\n Online \u00B7 understands your session\n </span>\n </div>\n </div>\n `;\n}\n\nif (!customElements.get('adaptive-chat-bar')) {\n customElements.define('adaptive-chat-bar', AdaptiveChatBar);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'adaptive-chat-bar': AdaptiveChatBar;\n }\n}\n"],
5
- "mappings": ";AAuBA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,gBAAgB;AAKzB,IAAM,sBAAsB;AAErB,IAAM,kBAAN,cAA8B,WAAW;AAAA,EAAzC;AAAA;AAUL,oBAA2B,CAAC;AAM5B;AAAA;AAAA;AAAA;AAAA,yBAAgB;AAChB,uBAAc;AAOd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAQ/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAW;AACX,kBAAS;AAYT;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,WAAW,CAAC,MAAmB;AACrC,WAAK,SAAU,EAAE,OAA4B;AAAA,IAC/C;AAEA,SAAQ,aAAa,CAAC,MAA2B;AAC/C,UAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;AACpC,UAAE,eAAe;AAIjB,YAAI,KAAK,SAAU;AACnB,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAKA;AAAA;AAAA;AAAA,SAAQ,qBAAqB,MAAY;AACvC,UAAI,KAAK,UAAU;AACjB,aAAK,cAAc,IAAI,YAAY,kBAAkB,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AACvF;AAAA,MACF;AACA,WAAK,MAAM;AAAA,IACb;AAEA,SAAQ,WAAW,MAAY;AAC7B,WAAK,cAAc,IAAI,YAAY,gBAAgB,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AAAA,IACvF;AAAA;AAAA,EAtCS,mBAAgC;AACvC,WAAO;AAAA,EACT;AAAA,EAsCQ,QAAc;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