@paramms/chat-widget 1.0.35 → 1.0.36

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.
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","sources":["../src/react.tsx"],"sourcesContent":["// react.tsx — React wrapper around mount().\n//\n// Next.js App Router: add 'use client' to whichever file imports these.\n// The widget needs WebSocket + DOM — it cannot render on the server.\n//\n// Import path: '@paramms/chat-widget/react'\n//\n// Two components:\n// ChatWidget — general support chat (hotel, SaaS, helpdesk, etc.)\n// MarketplaceChat — one thread per listing (used cars, rentals, etc.)\n//\n// Both: only url + profileId are required. userId is always optional —\n// anonymous guests are handled automatically via localStorage.\n\nimport { useEffect, useRef, useState } from 'react'\nimport { mount, type MountOptions, type WidgetHandle } from './index.js'\n\n// ── Shared base props ─────────────────────────────────────────────────────────\n\ninterface BaseProps {\n /** Relay URL — set as NEXT_PUBLIC_RELAY_URL in .env. Any scheme works:\n * `https://api.example.com` is fine. The WebSocket URL and REST base are\n * derived automatically — you do NOT need to pass `wss://` or `/ws`. */\n url: string\n /** HTTP(S) base for REST calls — only when the REST API is on a different\n * origin than the socket. Normally omit. */\n apiUrl?: string\n /** Your Relay profile ID — set as NEXT_PUBLIC_RELAY_PROFILE_ID in .env — required */\n profileId: string\n\n /** A signed identity token — an ES256 JWT `{sub,iat,exp}` minted by YOUR\n * backend for chatrooms with signed identity (guestPublicKey) enabled.\n * This is the production identity tier; wins over `userId`. */\n token?: string\n /** Called when a signed token expires: return a fresh token from your\n * backend to renew the session without a reload. */\n refreshToken?: () => Promise<string | null>\n /** Your logged-in user's stable ID. When omitted the widget automatically\n * assigns a persistent anonymous ID from localStorage — no login required. */\n userId?: string\n /** Shown to agents instead of the raw user ID */\n userName?: string\n /** Shown to agents so they can follow up by email */\n userEmail?: string\n /** Avatar URL shown in the widget header and dashboard */\n userAvatar?: string\n\n /** Brand colour hex, e.g. \"#1a56db\". Defaults to the profile theme colour. */\n accent?: string\n /** Render as a floating launcher button instead of inline */\n launcher?: boolean\n /** Launcher position — default 'bottom-right' */\n position?: 'bottom-right' | 'bottom-left'\n /** Pre-set reply chips shown above the input */\n quickReplies?: string[]\n /** Container height when rendered inline. Default: '100%' */\n height?: string\n /** i18n string overrides for non-English sites */\n i18n?: MountOptions['i18n']\n /** ISO language code for auto-translating incoming messages */\n translateLang?: string\n}\n\n// ── ChatWidget ────────────────────────────────────────────────────────────────\n\nexport interface ChatWidgetProps extends BaseProps {\n /** Optional context card shown at the top of the chat\n * (e.g. the support ticket, booking, or order being discussed) */\n contextTitle?: string\n contextSubtitle?: string\n contextStatus?: string\n\n /** Stable item ID — pins this conversation to a specific item/thread. */\n subjectId?: string\n}\n\n/**\n * General-purpose support chat widget. Only `url` and `profileId` are required.\n * All other props are optional — anonymous guests work without any configuration.\n *\n * @example Basic support chat\n * ```tsx\n * <ChatWidget\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * userName={session?.user.name}\n * userEmail={session?.user.email}\n * />\n * ```\n *\n * @example Multi-thread (tickets, bookings, orders) — one thread per subjectId\n * ```tsx\n * <ChatWidget\n * url={...} profileId={...}\n * subjectId={`ticket_${ticket.id}`}\n * contextTitle={ticket.title}\n * contextStatus={ticket.status}\n * userId={session?.user.id}\n * />\n * ```\n *\n * Need a list of the user's threads with tap-to-open? That's `<ChatApp />`\n * (inline) or `<ChatAppLauncher />` (floating bubble) — this component renders\n * a single conversation.\n */\nexport function ChatWidget({\n url, apiUrl, profileId,\n token, refreshToken,\n userId, userName, userEmail, userAvatar,\n contextTitle, contextSubtitle, contextStatus,\n subjectId,\n accent, launcher, position, quickReplies, height = '100%',\n i18n, translateLang,\n}: ChatWidgetProps): JSX.Element {\n const ref = useRef<HTMLDivElement>(null)\n const handleRef = useRef<WidgetHandle | null>(null)\n\n useEffect(() => {\n if (!ref.current) return\n handleRef.current?.close()\n handleRef.current = mount({\n el: ref.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n profileId,\n ...(subjectId ? { subjectId } : {}),\n ...(token ? { token } : {}),\n ...(refreshToken ? { refreshToken } : {}),\n ...(userId ? { userId } : {}),\n ...(userId || userName || userEmail || userAvatar ? {\n user: {\n ...(userName ? { name: userName } : {}),\n ...(userEmail ? { email: userEmail } : {}),\n ...(userAvatar ? { avatar: userAvatar } : {}),\n },\n } : {}),\n ...(contextTitle ? {\n subject: {\n title: contextTitle,\n ...(contextSubtitle ? { subtitle: contextSubtitle } : {}),\n ...(contextStatus ? { status: contextStatus } : {}),\n },\n } : {}),\n ...(quickReplies ? { quickReplies } : {}),\n ...(accent ? { accent } : {}),\n ...(translateLang ? { translateLang } : {}),\n ...(i18n ? { i18n } : {}),\n ...(launcher ? { launcher, position: position ?? 'bottom-right' } : {}),\n })\n return () => { handleRef.current?.close(); handleRef.current = null }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, apiUrl, profileId, subjectId, token, userId, userName, userEmail, accent, launcher, position, translateLang])\n\n // When launcher=true, still render the div — mount() moves it inside the\n // fixed panel above the bubble. Zero size so it doesn't affect page layout.\n return (\n <div\n ref={ref}\n style={launcher ? { width: 0, height: 0, overflow: 'hidden' } : { width: '100%', height, minHeight: height === '100%' ? '480px' : undefined }}\n />\n )\n}\n\n// ── MarketplaceChat ───────────────────────────────────────────────────────────\n\nexport interface MarketplaceChatProps extends BaseProps {\n /** Unique ID for this listing — each listing gets its own thread.\n * Omit for a general (non-item-specific) conversation. */\n listingId?: string\n /** Shown at the top of the chat — e.g. \"2019 Toyota Camry SE\" */\n listingTitle?: string\n /** One-line detail — e.g. \"45,000 km · Automatic\" */\n listingMeta?: string\n /** Price shown as a tag — e.g. 12500 → \"$12,500\" */\n listingPrice?: number\n /** Status badge — e.g. \"Available\", \"Sold\", \"Pending\" */\n listingStatus?: string\n}\n\nconst DEFAULT_MARKETPLACE_REPLIES = [\n 'Is this still available?',\n 'Can I schedule a viewing?',\n 'What is your best price?',\n]\n\n/**\n * Marketplace chat widget. Two modes depending on whether `listingId` is provided:\n *\n * **With `listingId` (listing page)** — opens that listing's chat immediately.\n * No list screen. The buyer is already looking at the item so context is clear.\n * ```tsx\n * // On your listing detail page:\n * <MarketplaceChat\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * listingId={car.id}\n * listingTitle={car.title}\n * listingPrice={car.price}\n * listingMeta={`${car.mileage.toLocaleString()} km · ${car.gearbox}`}\n * listingStatus=\"Available\"\n * userId={session?.user.id}\n * userName={session?.user.name}\n * userEmail={session?.user.email}\n * />\n * ```\n *\n * **Without `listingId`** — opens the buyer's single general (non-listing)\n * thread with this chatroom. For a \"My Messages\" / inbox page with the\n * WhatsApp-style thread list and tap-to-open, use `<ChatApp />` (or\n * `<ChatAppLauncher />` for a floating bubble):\n * ```tsx\n * // On your /messages page:\n * <ChatApp\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * />\n * ```\n *\n * Only `url` and `profileId` are required. All other props are optional.\n */\nexport function MarketplaceChat({\n url, apiUrl, profileId,\n token, refreshToken,\n listingId, listingTitle, listingMeta, listingPrice, listingStatus,\n userId, userName, userEmail, userAvatar,\n accent, launcher, position, quickReplies, height = '100%',\n i18n, translateLang,\n}: MarketplaceChatProps): JSX.Element {\n const ref = useRef<HTMLDivElement>(null)\n const handleRef = useRef<WidgetHandle | null>(null)\n\n useEffect(() => {\n if (!ref.current) return\n // Coalesce rapid identity changes into a SINGLE mount. NextAuth's\n // `session?.user.id` is undefined on first render and resolves a tick later,\n // which would otherwise open an anonymous conversation and immediately\n // orphan it when the real id arrives — surfacing as \"a new chat every time\".\n // Deferring the mount lets a same-tick id change settle first. For a slower\n // (network) session fetch, gate rendering on the session status host-side\n // (e.g. NextAuth: don't render until `status !== 'loading'`).\n let cancelled = false\n const timer = setTimeout(() => {\n if (cancelled || !ref.current) return\n handleRef.current?.close()\n handleRef.current = mount({\n el: ref.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n profileId,\n ...(listingId ? { subjectId: `listing_${listingId}` } : {}),\n ...(token ? { token } : {}),\n ...(refreshToken ? { refreshToken } : {}),\n ...(userId ? { userId } : {}),\n ...(userId || userName || userEmail || userAvatar ? {\n user: {\n ...(userName ? { name: userName } : {}),\n ...(userEmail ? { email: userEmail } : {}),\n ...(userAvatar ? { avatar: userAvatar } : {}),\n ...(listingId ? { meta: { listingId } } : {}),\n },\n } : {}),\n ...(listingTitle ? {\n subject: {\n title: listingTitle,\n ...(listingMeta ? { subtitle: listingMeta } : {}),\n ...(listingPrice ? { tags: [`$${listingPrice.toLocaleString()}`] } : {}),\n ...(listingStatus ? { status: listingStatus } : {}),\n },\n } : {}),\n quickReplies: quickReplies ?? DEFAULT_MARKETPLACE_REPLIES,\n ...(accent ? { accent } : {}),\n ...(translateLang ? { translateLang } : {}),\n ...(i18n ? { i18n } : {}),\n ...(launcher ? { launcher, position: position ?? 'bottom-right' } : {}),\n })\n }, 0)\n return () => { cancelled = true; clearTimeout(timer); handleRef.current?.close(); handleRef.current = null }\n // Only identity/target-affecting props trigger a remount — metadata like\n // userName/userEmail is sent once at mount and must NOT churn the connection.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, apiUrl, profileId, listingId, token, userId, accent, launcher, position, translateLang])\n\n // When launcher=true, still render the div — mount() moves it inside the\n // fixed panel above the bubble. Zero size so it doesn't affect page layout.\n return (\n <div\n ref={ref}\n style={launcher ? { width: 0, height: 0, overflow: 'hidden' } : { width: '100%', height, minHeight: height === '100%' ? '480px' : undefined }}\n />\n )\n}\n\n// ── ChatList ──────────────────────────────────────────────────────────────────\n\n/** Live viewport breakpoint — updates on resize/rotation via matchMedia,\n * never a one-shot read (a one-shot read leaves layouts stuck after the\n * user rotates their phone or resizes across the breakpoint). SSR-safe. */\nfunction useIsMobile(maxWidthPx: number): boolean {\n const [mobile, setMobile] = useState(\n typeof window !== 'undefined' && window.innerWidth <= maxWidthPx,\n )\n useEffect(() => {\n if (typeof window === 'undefined' || !window.matchMedia) return\n const mq = window.matchMedia(`(max-width: ${maxWidthPx}px)`)\n const onChange = (e: MediaQueryListEvent): void => setMobile(e.matches)\n setMobile(mq.matches)\n mq.addEventListener('change', onChange)\n return () => mq.removeEventListener('change', onChange)\n }, [maxWidthPx])\n return mobile\n}\n\nexport interface ChatAppProps {\n /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the\n * recommended form. The WebSocket URL and REST base are derived from it —\n * you do NOT need to pass `wss://` or `/ws`. */\n url: string\n /** HTTP(S) base for REST calls — only when the REST API is on a different\n * origin than the socket. Normally omit.\n * @deprecated pass a single `url`; kept for back-compat. */\n apiUrl?: string\n /** A chatroom id. Provide `profileId` OR `tenantId` (see below). When both\n * are given, profileId also fixes where the ✎ \"new conversation\" opens. */\n profileId?: string\n /** Tenant-level identification — the natural fit for a chat app: lists\n * EVERY conversation this user has with your business across ALL of its\n * chatrooms, without naming one. Use this when the platform runs several\n * chatrooms under one tenant (e.g. a marketplace chatroom for\n * `<MarketplaceChat/>` pages PLUS a general-support chatroom) — the inbox\n * shows both, and each row opens against its own chatroom. The ✎ compose\n * button opens the tenant's default chatroom (its oldest, as reported by\n * the server). */\n tenantId?: string\n /** A signed identity token (ES256 JWT) for chatrooms with signed identity\n * enabled — the production tier. Wins over `userId`. */\n token?: string\n /** Return a fresh token when a signed token expires. */\n refreshToken?: () => Promise<string | null>\n /** Your logged-in user's stable ID. Omit for anonymous (uses localStorage UID) */\n userId?: string\n /** Optional: shown to agents in the dashboard */\n userName?: string\n /** Optional: shown to agents in the dashboard */\n userEmail?: string\n /** Which conversations the list shows when configured with a profileId\n * (default 'tenant'; irrelevant with `tenantId`, which is always\n * tenant-wide):\n * 'tenant' — every conversation this user has with the business that\n * owns `profileId`, across ALL of its chatrooms — like a real\n * messaging app. Each row opens against its own chatroom.\n * 'profile' — only this chatroom's threads (the pre-1.0.30 behaviour).\n * Tenancy note: guests never see or send tenant ids — the server resolves\n * the tenant FROM the profileId, so `profileId` stays the only id you\n * configure. */\n scope?: 'profile' | 'tenant'\n /** Brand colour hex — default '#4F63F5' */\n accent?: string\n /** Container height. Default: '100%' */\n height?: string\n /** When provided, ChatApp renders an always-visible close (✕) control in the\n * top-right corner of its container. Pass this whenever ChatApp is shown in\n * an overlay/panel or as a mobile-fullscreen surface (ChatAppLauncher wires\n * it automatically) so there is a reliable way OUT — without it, an inline\n * fullscreen panel on a phone (no Escape key, no reachable backdrop) traps\n * the user. Omit for a bare inline embed the host chromes itself. */\n onClose?: () => void\n /** i18n overrides */\n i18n?: import('./chatlist.js').ChatListOptions['i18n']\n}\n\n/**\n * Full chat-app component: conversation list on the left (or full screen on\n * mobile), chat room on the right when a thread is selected — like a\n * standalone messaging app. Tapping a thread opens the chat inline; the ✎\n * button starts a new conversation with the business.\n *\n * By default (`scope=\"tenant\"`) the list shows EVERY conversation this user\n * has with the business that owns `profileId` — across all of its chatrooms —\n * and each row opens against its own chatroom. Pass `scope=\"profile\"` to\n * limit it to one chatroom's threads.\n *\n * Identify at either level:\n * • `tenantId` — the natural fit for a chat app. A platform often runs\n * SEVERAL chatrooms under one business (a marketplace chatroom for\n * `<MarketplaceChat/>` pages plus a general-support chatroom, …); with\n * `tenantId` the inbox shows the user's chats with all of them, no\n * profileId needed. Compose opens the tenant's default chatroom.\n * • `profileId` — any one of the business's chatrooms; still lists\n * tenant-wide by default (`scope=\"tenant\"`), and fixes where compose\n * opens.\n *\n * @example\n * ```tsx\n * 'use client'\n * import { ChatApp } from '@paramms/chat-widget/react'\n *\n * export default function MessagesPage({ session }) {\n * return (\n * <div style={{ height: '100vh' }}>\n * <ChatApp\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * tenantId={process.env.NEXT_PUBLIC_RELAY_TENANT_ID} // or profileId={…}\n * userId={session?.user.id}\n * userName={session?.user.name}\n * userEmail={session?.user.email}\n * />\n * </div>\n * )\n * }\n * ```\n */\nexport function ChatApp({\n url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail,\n accent, height = '100%', i18n, onClose,\n scope = 'tenant',\n}: ChatAppProps): JSX.Element {\n const misconfigured = !profileId && !tenantId\n type Entry = import('./chatlist.js').ChatListEntry\n const [selected, setSelected] = useState<Entry | null>(null)\n const listRef = useRef<HTMLDivElement>(null)\n const chatRef = useRef<HTMLDivElement>(null)\n const handleRef = useRef<import('./chatlist.js').ChatListHandle | null>(null)\n const chatHandle = useRef<WidgetHandle | null>(null)\n\n // Build the chat list\n useEffect(() => {\n if (!listRef.current) return\n let cancelled = false\n import('./chatlist.js').then(({ mountChatList }) => {\n // The dynamic import is async: if the effect was cleaned up (unmount,\n // dep change, or StrictMode's double-invoke) before it resolved, or the\n // ref is gone, don't mount a phantom list that never gets closed.\n if (cancelled || !listRef.current) return\n handleRef.current = mountChatList({\n el: listRef.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n ...(profileId ? { profileId } : {}),\n ...(tenantId ? { tenantId } : {}),\n scope,\n onSelect: (entry) => setSelected(entry),\n // Compose (✎) opens the chatroom's general support thread — without\n // this a user with no conversations yet had an empty list and no way\n // to ever start one, which is what made ChatApp feel broken.\n // Compose target: the configured chatroom, else the tenant's default\n // (oldest chatroom, reported by the server on the first list fetch).\n onNewChat: () => {\n const target = handleRef.current?.defaultProfileId()\n if (!target) return // list hasn't loaded yet — nothing sane to open\n setSelected({ id: '__new__', profileId: target, state: 'open', updatedAt: Date.now() })\n },\n ...(token ? { token } : {}),\n ...(userId ? { userId } : {}),\n ...(accent ? { accent } : {}),\n ...(i18n ? { i18n } : {}),\n })\n })\n return () => { cancelled = true; handleRef.current?.close(); handleRef.current = null }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, apiUrl, profileId, tenantId, token, userId, scope])\n\n // Open a ChatWidget when a thread is selected.\n //\n // Two correctness details here:\n // • identity: `userId` goes through as userId (the host-vouched tier) and\n // signed JWTs as `token` — the same tiers as every other component. It\n // used to conflate them (`token: userId`), which worked only by the\n // accident that mount() folds userId into the token, and left no way to\n // pass a REAL signed token at all.\n // • chatroom: the row's OWN profileId wins. With scope='tenant' the list\n // spans every chatroom of the business, so opening against the mounted\n // profileId would find-or-create a DIFFERENT conversation.\n useEffect(() => {\n if (!chatRef.current || !selected) return\n chatHandle.current?.close()\n chatHandle.current = mount({\n el: chatRef.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n profileId: (selected.profileId ?? profileId)!, // rows always carry theirs; compose sets one explicitly\n // DM rows open as direct conversations (kind + peer). Opening them via\n // their dm:… subjectId only works for the participant that OWNS the\n // thread key — the other side would silently fork a duplicate.\n ...(selected.kind === 'direct' && selected.peerId\n ? { kind: 'direct' as const, peerId: selected.peerId }\n : selected.subjectId ? { subjectId: selected.subjectId } : {}),\n ...(token ? { token } : {}),\n ...(refreshToken ? { refreshToken } : {}),\n ...(userId ? { userId } : {}),\n ...(userId || userName || userEmail ? {\n user: {\n ...(userName ? { name: userName } : {}),\n ...(userEmail ? { email: userEmail } : {}),\n },\n } : {}),\n ...(selected.subjectTitle ? {\n subject: {\n title: selected.subjectTitle,\n ...(selected.subjectMeta ? { subtitle: selected.subjectMeta } : {}),\n },\n } : {}),\n ...(accent ? { accent } : {}),\n })\n // Keep the list fresh: opening a chat marks it read, and replies received\n // while a chat is open should update its row's preview/ordering.\n const listTimer = setInterval(() => handleRef.current?.refresh(), 20_000)\n return () => {\n clearInterval(listTimer)\n chatHandle.current?.close(); chatHandle.current = null\n // Refresh once on the way out so the row reflects what just happened.\n handleRef.current?.refresh()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selected?.id])\n\n // Responsive: live breakpoint (list/chat panes swap below 768px).\n const isMobile = useIsMobile(767)\n\n // (After all hooks — React requires unconditional hook order.)\n if (misconfigured) {\n return (\n <div style={{ padding: 16, font: '13px system-ui', color: '#b91c1c', background: '#fef2f2', borderRadius: 8 }}>\n [relay] &lt;ChatApp/&gt; needs a <code>profileId</code> or a <code>tenantId</code>.\n </div>\n )\n }\n\n return (\n <div style={{ display: 'flex', width: '100%', height, minHeight: '400px', overflow: 'hidden', position: 'relative' }}>\n {/* Reliable close control. Sits above both panes (list AND chat) at the\n top-right, so there is always a way out — this is the fix for an\n overlay/mobile-fullscreen panel having no reachable close (the ← back\n button only returns list↔chat; it does not dismiss the whole surface).\n Only rendered when the host asked for it via onClose. */}\n {onClose && (\n <button\n onClick={onClose}\n aria-label={i18n?.close ?? 'Close'}\n style={{\n position: 'absolute', top: 8, right: 8, zIndex: 20,\n width: 32, height: 32, borderRadius: '50%',\n display: 'flex', alignItems: 'center', justifyContent: 'center',\n background: 'rgba(0,0,0,.05)', border: 'none', color: '#1c1b1a',\n fontSize: 18, lineHeight: 1, cursor: 'pointer',\n }}\n >\n ✕\n </button>\n )}\n {/* List panel — hidden on mobile when a chat is open */}\n <div style={{\n width: isMobile ? '100%' : '360px',\n flex: isMobile && selected ? 'none' : undefined,\n display: isMobile && selected ? 'none' : 'flex',\n flexDirection: 'column',\n borderRight: isMobile ? 'none' : '1px solid #e8eaed',\n minWidth: 0,\n }}>\n <div ref={listRef} style={{ width: '100%', height: '100%' }} />\n </div>\n\n {/* Chat panel — shows when a thread is selected */}\n {selected ? (\n <div style={{ flex: 1, display: 'flex', flexDirection: 'column', minWidth: 0, position: 'relative' }}>\n {/* Back button on mobile */}\n {isMobile && (\n <button\n onClick={() => setSelected(null)}\n style={{ position: 'absolute', top: 12, left: 12, zIndex: 10, background: 'none', border: 'none', fontSize: 22, cursor: 'pointer', color: '#1c1b1a' }}\n >\n ←\n </button>\n )}\n <div ref={chatRef} style={{ width: '100%', height: '100%' }} />\n </div>\n ) : (\n <div style={{ flex: 1, display: isMobile ? 'none' : 'flex', alignItems: 'center', justifyContent: 'center', color: '#9b9690', fontSize: 14 }}>\n Select a conversation\n </div>\n )}\n </div>\n )\n}\n\n// ── ChatAppLauncher ───────────────────────────────────────────────────────────\n\nexport interface ChatAppLauncherProps {\n /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the\n * recommended form. The WebSocket URL and REST base are derived from it. */\n url: string\n /** HTTP(S) base for REST calls — only when REST is on a different origin.\n * @deprecated pass a single `url`; kept for back-compat. */\n apiUrl?: string\n /** A chatroom id. Provide `profileId` OR `tenantId`. */\n profileId?: string\n /** Tenant-level identification — the panel lists EVERY conversation this\n * user has with your business across ALL of its chatrooms (see\n * ChatAppProps.tenantId). The ✎ compose opens the tenant's default\n * chatroom. */\n tenantId?: string\n /** A signed identity token (ES256 JWT) for chatrooms with signed identity\n * enabled — the production tier. Wins over `userId`. */\n token?: string\n /** Return a fresh token when a signed token expires. */\n refreshToken?: () => Promise<string | null>\n /** Your logged-in user's stable ID */\n userId?: string\n userName?: string\n userEmail?: string\n /** Which conversations the panel's list shows — see ChatAppProps.scope.\n * Default 'tenant': every conversation this user has with the business. */\n scope?: 'profile' | 'tenant'\n /** Brand colour hex — default '#4F63F5' */\n accent?: string\n\n /** true → floating bubble fixed to the corner of the screen (like Intercom)\n * false → an inline \"Messages\" button that expands a panel below it\n * Default: true */\n floating?: boolean\n /** Only used when floating=true. Default: 'bottom-right' */\n position?: 'bottom-right' | 'bottom-left'\n /** Label shown on the button. Default: '💬' for floating, 'Messages' for inline */\n label?: string\n /** Width of the chat panel. Default: '420px' (floating) or '100%' (inline) */\n panelWidth?: string\n /** Height of the chat panel. Default: '600px' */\n panelHeight?: string\n}\n\n/**\n * A button that opens the full ChatApp (list → chat) in a panel.\n *\n * floating=true → fixed bubble in the corner of the screen, like WhatsApp Web's\n * chat button or Intercom.\n * floating=false → an inline button (e.g. in your nav bar) that expands a panel\n * below it.\n *\n * @example Floating bubble (bottom-right)\n * ```tsx\n * <ChatAppLauncher\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * floating\n * position=\"bottom-right\"\n * />\n * ```\n *\n * @example Inline nav button\n * ```tsx\n * <ChatAppLauncher\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * floating={false}\n * label=\"Messages\"\n * />\n * ```\n */\nexport function ChatAppLauncher({\n url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail,\n scope,\n accent = '#4F63F5',\n floating = true,\n position = 'bottom-right',\n label,\n panelWidth,\n panelHeight = '600px',\n}: ChatAppLauncherProps): JSX.Element {\n const [open, setOpen] = useState(false)\n const btnRef = useRef<HTMLButtonElement>(null)\n\n const isRight = position === 'bottom-right'\n const defaultLabel = floating ? '💬' : 'Messages'\n const btnLabel = label ?? defaultLabel\n const isMobile = useIsMobile(479)\n\n // Close on Escape\n useEffect(() => {\n const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') setOpen(false) }\n document.addEventListener('keydown', handler)\n return () => document.removeEventListener('keydown', handler)\n }, [])\n\n // ── Floating mode ──────────────────────────────────────────────────────────\n if (floating) {\n // Mobile (<480px): the panel must be its OWN fixed fullscreen layer\n // (inset:0). Sizing it 100vw INSIDE the bottom-right wrapper — as it used\n // to — anchored its right edge 20px in from the viewport, pushing the\n // whole app 20px off-screen. The bubble wrapper stays above it (z 9999\n // vs 9998) so the ✕ keeps working as the close control. Live breakpoint:\n // rotating the phone re-lays-out.\n return (\n <div style={{\n position: 'fixed',\n [isRight ? 'right' : 'left']: '20px',\n bottom: '20px',\n zIndex: 9999,\n display: 'flex',\n flexDirection: 'column',\n alignItems: isRight ? 'flex-end' : 'flex-start',\n gap: '12px',\n }}>\n {/* Panel */}\n <div style={{\n ...(isMobile ? {\n position: 'fixed' as const, inset: 0,\n width: '100%', height: '100dvh', borderRadius: '0', zIndex: 9998,\n } : {\n width: `min(${panelWidth ?? '420px'}, calc(100vw - 40px))`,\n height: `min(${panelHeight}, calc(100dvh - 108px))`,\n borderRadius: '16px',\n }),\n overflow: 'hidden',\n boxShadow: isMobile ? 'none' : '0 8px 40px rgba(0,0,0,.18)',\n background: '#fff',\n display: open ? 'flex' : 'none',\n flexDirection: 'column',\n transformOrigin: `bottom ${isRight ? 'right' : 'left'}`,\n animation: open ? 'ocl-pop-in .18s ease' : 'none',\n }}>\n <ChatApp\n url={url} {...(apiUrl ? { apiUrl } : {})}\n {...(profileId ? { profileId } : {})}\n {...(tenantId ? { tenantId } : {})}\n {...(token ? { token } : {})}\n {...(refreshToken ? { refreshToken } : {})}\n {...(userId ? { userId } : {})}\n {...(userName ? { userName } : {})}\n {...(userEmail ? { userEmail } : {})}\n {...(scope ? { scope } : {})}\n accent={accent} height=\"100%\"\n onClose={() => setOpen(false)}\n />\n </div>\n\n {/* Bubble button. On a fullscreen mobile panel the bubble sits at\n bottom-right ON TOP of the message composer/send button, so hide it\n while open on mobile — the in-panel top-right ✕ is the close there. */}\n <button\n ref={btnRef}\n onClick={() => setOpen(o => !o)}\n style={{\n width: '56px', height: '56px', borderRadius: '50%',\n background: accent, color: '#fff', border: 'none',\n fontSize: '24px', cursor: 'pointer', flexShrink: 0,\n boxShadow: '0 4px 16px rgba(0,0,0,.25)',\n transition: 'transform .15s',\n display: (open && isMobile) ? 'none' : 'block',\n }}\n onMouseEnter={e => { (e.target as HTMLElement).style.transform = 'scale(1.08)' }}\n onMouseLeave={e => { (e.target as HTMLElement).style.transform = 'scale(1)' }}\n >\n {open ? '✕' : btnLabel}\n </button>\n\n <style>{`@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }`}</style>\n </div>\n )\n }\n\n // ── Inline mode ────────────────────────────────────────────────────────────\n // The panel is rendered via a fixed overlay anchored to the button position.\n // This prevents clipping from parent overflow:hidden containers (e.g. nav bars).\n // On mobile the anchored popover can't fit — it goes fullscreen instead\n // (the backdrop still closes it).\n const pWidth = `min(${panelWidth ?? '420px'}, calc(100vw - 16px))`\n\n // Track button position for panel anchor\n const [btnRect, setBtnRect] = useState<DOMRect | null>(null)\n\n const handleBtnClick = () => {\n if (!open && btnRef.current) setBtnRect(btnRef.current.getBoundingClientRect())\n setOpen(o => !o)\n }\n\n const panelTop = btnRect ? btnRect.bottom + 8 : 0\n // Clamp so a button near the left edge can't push the panel off-screen.\n const panelRight = btnRect ? Math.max(8, window.innerWidth - btnRect.right) : 0\n\n return (\n <>\n {/* Trigger button */}\n <button\n ref={btnRef}\n onClick={handleBtnClick}\n style={{\n display: 'inline-flex', alignItems: 'center', gap: '6px',\n padding: '8px 16px', borderRadius: '8px',\n background: open ? accent : 'transparent',\n color: open ? '#fff' : accent,\n border: `2px solid ${accent}`,\n fontSize: '14px', fontWeight: 600, cursor: 'pointer',\n transition: 'background .15s, color .15s',\n }}\n >\n 💬 {btnLabel}\n </button>\n\n {/* Fixed panel — rendered at document root level via CSS fixed positioning */}\n {open && btnRect && (\n <>\n {/* Backdrop */}\n <div\n onClick={() => setOpen(false)}\n style={{ position: 'fixed', inset: 0, zIndex: 9998 }}\n />\n <div style={{\n position: 'fixed',\n ...(isMobile ? {\n inset: 0, width: '100%', height: '100dvh', borderRadius: '0',\n } : {\n top: panelTop,\n right: panelRight,\n width: pWidth,\n height: `min(${panelHeight}, calc(100dvh - ${panelTop}px - 12px))`,\n borderRadius: '16px',\n }),\n overflow: 'hidden',\n boxShadow: isMobile ? 'none' : '0 8px 40px rgba(0,0,0,.2)',\n background: '#fff',\n zIndex: 9999,\n animation: 'ocl-slide-in .18s ease',\n }}>\n <ChatApp\n url={url} {...(apiUrl ? { apiUrl } : {})}\n {...(profileId ? { profileId } : {})}\n {...(tenantId ? { tenantId } : {})}\n {...(token ? { token } : {})}\n {...(refreshToken ? { refreshToken } : {})}\n {...(userId ? { userId } : {})}\n {...(userName ? { userName } : {})}\n {...(userEmail ? { userEmail } : {})}\n {...(scope ? { scope } : {})}\n accent={accent} height=\"100%\"\n onClose={() => setOpen(false)}\n />\n </div>\n <style>{`@keyframes ocl-slide-in { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }`}</style>\n </>\n )}\n </>\n )\n}\n"],"names":["ChatWidget","url","apiUrl","profileId","token","refreshToken","userId","userName","userEmail","userAvatar","contextTitle","contextSubtitle","contextStatus","subjectId","accent","launcher","position","quickReplies","height","i18n","translateLang","ref","useRef","handleRef","useEffect","_a","mount","jsx","DEFAULT_MARKETPLACE_REPLIES","MarketplaceChat","listingId","listingTitle","listingMeta","listingPrice","listingStatus","cancelled","timer","useIsMobile","maxWidthPx","mobile","setMobile","useState","mq","onChange","e","ChatApp","tenantId","onClose","scope","misconfigured","selected","setSelected","listRef","chatRef","chatHandle","mountChatList","entry","target","listTimer","_b","isMobile","jsxs","ChatAppLauncher","floating","label","panelWidth","panelHeight","open","setOpen","btnRef","isRight","btnLabel","handler","o","pWidth","btnRect","setBtnRect","handleBtnClick","panelTop","panelRight","Fragment"],"mappings":";;;AA0GO,SAASA,EAAW;AAAA,EACzB,KAAAC;AAAA,EAAK,QAAAC;AAAA,EAAQ,WAAAC;AAAA,EACb,OAAAC;AAAA,EAAO,cAAAC;AAAA,EACP,QAAAC;AAAA,EAAQ,UAAAC;AAAA,EAAU,WAAAC;AAAA,EAAW,YAAAC;AAAA,EAC7B,cAAAC;AAAA,EAAc,iBAAAC;AAAA,EAAiB,eAAAC;AAAA,EAC/B,WAAAC;AAAA,EACA,QAAAC;AAAA,EAAQ,UAAAC;AAAA,EAAU,UAAAC;AAAA,EAAU,cAAAC;AAAA,EAAc,QAAAC,IAAS;AAAA,EACnD,MAAAC;AAAA,EAAM,eAAAC;AACR,GAAiC;AAC/B,QAAMC,IAAYC,EAAuB,IAAI,GACvCC,IAAYD,EAA4B,IAAI;AAElD,SAAAE,EAAU,MAAM;;AACd,QAAKH,EAAI;AACT,cAAAI,IAAAF,EAAU,YAAV,QAAAE,EAAmB,SACnBF,EAAU,UAAUG,EAAM;AAAA,QACxB,IAAIL,EAAI;AAAA,QACR,KAA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WAAO,UAAA,uHAAA,CAAuH;AAAA,IAAA,EAAA,CACjI;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"react.js","sources":["../src/react.tsx"],"sourcesContent":["// react.tsx — React wrapper around mount().\n//\n// Next.js App Router: add 'use client' to whichever file imports these.\n// The widget needs WebSocket + DOM — it cannot render on the server.\n//\n// Import path: '@paramms/chat-widget/react'\n//\n// Two components:\n// ChatWidget — general support chat (hotel, SaaS, helpdesk, etc.)\n// MarketplaceChat — one thread per listing (used cars, rentals, etc.)\n//\n// Both: only url + profileId are required. userId is always optional —\n// anonymous guests are handled automatically via localStorage.\n\nimport { useEffect, useRef, useState } from 'react'\nimport { mount, type MountOptions, type WidgetHandle } from './index.js'\n\n// ── Shared base props ─────────────────────────────────────────────────────────\n\ninterface BaseProps {\n /** Relay URL — set as NEXT_PUBLIC_RELAY_URL in .env. Any scheme works:\n * `https://api.example.com` is fine. The WebSocket URL and REST base are\n * derived automatically — you do NOT need to pass `wss://` or `/ws`. */\n url: string\n /** HTTP(S) base for REST calls — only when the REST API is on a different\n * origin than the socket. Normally omit. */\n apiUrl?: string\n /** Your Relay profile ID — set as NEXT_PUBLIC_RELAY_PROFILE_ID in .env — required */\n profileId: string\n\n /** A signed identity token — an ES256 JWT `{sub,iat,exp}` minted by YOUR\n * backend for chatrooms with signed identity (guestPublicKey) enabled.\n * This is the production identity tier; wins over `userId`. */\n token?: string\n /** Called when a signed token expires: return a fresh token from your\n * backend to renew the session without a reload. */\n refreshToken?: () => Promise<string | null>\n /** Your logged-in user's stable ID. When omitted the widget automatically\n * assigns a persistent anonymous ID from localStorage — no login required. */\n userId?: string\n /** Shown to agents instead of the raw user ID */\n userName?: string\n /** Shown to agents so they can follow up by email */\n userEmail?: string\n /** Avatar URL shown in the widget header and dashboard */\n userAvatar?: string\n\n /** Brand colour hex, e.g. \"#1a56db\". Defaults to the profile theme colour. */\n accent?: string\n /** Render as a floating launcher button instead of inline */\n launcher?: boolean\n /** Launcher position — default 'bottom-right' */\n position?: 'bottom-right' | 'bottom-left'\n /** Pre-set reply chips shown above the input */\n quickReplies?: string[]\n /** Container height when rendered inline. Default: '100%' */\n height?: string\n /** i18n string overrides for non-English sites */\n i18n?: MountOptions['i18n']\n /** ISO language code for auto-translating incoming messages */\n translateLang?: string\n}\n\n// ── ChatWidget ────────────────────────────────────────────────────────────────\n\nexport interface ChatWidgetProps extends BaseProps {\n /** Optional context card shown at the top of the chat\n * (e.g. the support ticket, booking, or order being discussed) */\n contextTitle?: string\n contextSubtitle?: string\n contextStatus?: string\n\n /** Stable item ID — pins this conversation to a specific item/thread. */\n subjectId?: string\n}\n\n/**\n * General-purpose support chat widget. Only `url` and `profileId` are required.\n * All other props are optional — anonymous guests work without any configuration.\n *\n * @example Basic support chat\n * ```tsx\n * <ChatWidget\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * userName={session?.user.name}\n * userEmail={session?.user.email}\n * />\n * ```\n *\n * @example Multi-thread (tickets, bookings, orders) — one thread per subjectId\n * ```tsx\n * <ChatWidget\n * url={...} profileId={...}\n * subjectId={`ticket_${ticket.id}`}\n * contextTitle={ticket.title}\n * contextStatus={ticket.status}\n * userId={session?.user.id}\n * />\n * ```\n *\n * Need a list of the user's threads with tap-to-open? That's `<ChatApp />`\n * (inline) or `<ChatAppLauncher />` (floating bubble) — this component renders\n * a single conversation.\n */\nexport function ChatWidget({\n url, apiUrl, profileId,\n token, refreshToken,\n userId, userName, userEmail, userAvatar,\n contextTitle, contextSubtitle, contextStatus,\n subjectId,\n accent, launcher, position, quickReplies, height = '100%',\n i18n, translateLang,\n}: ChatWidgetProps): JSX.Element {\n const ref = useRef<HTMLDivElement>(null)\n const handleRef = useRef<WidgetHandle | null>(null)\n\n useEffect(() => {\n if (!ref.current) return\n handleRef.current?.close()\n handleRef.current = mount({\n el: ref.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n profileId,\n ...(subjectId ? { subjectId } : {}),\n ...(token ? { token } : {}),\n ...(refreshToken ? { refreshToken } : {}),\n ...(userId ? { userId } : {}),\n ...(userId || userName || userEmail || userAvatar ? {\n user: {\n ...(userName ? { name: userName } : {}),\n ...(userEmail ? { email: userEmail } : {}),\n ...(userAvatar ? { avatar: userAvatar } : {}),\n },\n } : {}),\n ...(contextTitle ? {\n subject: {\n title: contextTitle,\n ...(contextSubtitle ? { subtitle: contextSubtitle } : {}),\n ...(contextStatus ? { status: contextStatus } : {}),\n },\n } : {}),\n ...(quickReplies ? { quickReplies } : {}),\n ...(accent ? { accent } : {}),\n ...(translateLang ? { translateLang } : {}),\n ...(i18n ? { i18n } : {}),\n ...(launcher ? { launcher, position: position ?? 'bottom-right' } : {}),\n })\n return () => { handleRef.current?.close(); handleRef.current = null }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, apiUrl, profileId, subjectId, token, userId, userName, userEmail, accent, launcher, position, translateLang])\n\n // When launcher=true, still render the div — mount() moves it inside the\n // fixed panel above the bubble. Zero size so it doesn't affect page layout.\n return (\n <div\n ref={ref}\n style={launcher ? { width: 0, height: 0, overflow: 'hidden' } : { width: '100%', height, minHeight: height === '100%' ? '480px' : undefined }}\n />\n )\n}\n\n// ── MarketplaceChat ───────────────────────────────────────────────────────────\n\nexport interface MarketplaceChatProps extends BaseProps {\n /** Unique ID for this listing — each listing gets its own thread.\n * Omit for a general (non-item-specific) conversation. */\n listingId?: string\n /** Shown at the top of the chat — e.g. \"2019 Toyota Camry SE\" */\n listingTitle?: string\n /** One-line detail — e.g. \"45,000 km · Automatic\" */\n listingMeta?: string\n /** Price shown as a tag — e.g. 12500 → \"$12,500\" */\n listingPrice?: number\n /** Status badge — e.g. \"Available\", \"Sold\", \"Pending\" */\n listingStatus?: string\n}\n\nconst DEFAULT_MARKETPLACE_REPLIES = [\n 'Is this still available?',\n 'Can I schedule a viewing?',\n 'What is your best price?',\n]\n\n/**\n * Marketplace chat widget. Two modes depending on whether `listingId` is provided:\n *\n * **With `listingId` (listing page)** — opens that listing's chat immediately.\n * No list screen. The buyer is already looking at the item so context is clear.\n * ```tsx\n * // On your listing detail page:\n * <MarketplaceChat\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * listingId={car.id}\n * listingTitle={car.title}\n * listingPrice={car.price}\n * listingMeta={`${car.mileage.toLocaleString()} km · ${car.gearbox}`}\n * listingStatus=\"Available\"\n * userId={session?.user.id}\n * userName={session?.user.name}\n * userEmail={session?.user.email}\n * />\n * ```\n *\n * **Without `listingId`** — opens the buyer's single general (non-listing)\n * thread with this chatroom. For a \"My Messages\" / inbox page with the\n * WhatsApp-style thread list and tap-to-open, use `<ChatApp />` (or\n * `<ChatAppLauncher />` for a floating bubble):\n * ```tsx\n * // On your /messages page:\n * <ChatApp\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * />\n * ```\n *\n * Only `url` and `profileId` are required. All other props are optional.\n */\nexport function MarketplaceChat({\n url, apiUrl, profileId,\n token, refreshToken,\n listingId, listingTitle, listingMeta, listingPrice, listingStatus,\n userId, userName, userEmail, userAvatar,\n accent, launcher, position, quickReplies, height = '100%',\n i18n, translateLang,\n}: MarketplaceChatProps): JSX.Element {\n const ref = useRef<HTMLDivElement>(null)\n const handleRef = useRef<WidgetHandle | null>(null)\n\n useEffect(() => {\n if (!ref.current) return\n // Coalesce rapid identity changes into a SINGLE mount. NextAuth's\n // `session?.user.id` is undefined on first render and resolves a tick later,\n // which would otherwise open an anonymous conversation and immediately\n // orphan it when the real id arrives — surfacing as \"a new chat every time\".\n // Deferring the mount lets a same-tick id change settle first. For a slower\n // (network) session fetch, gate rendering on the session status host-side\n // (e.g. NextAuth: don't render until `status !== 'loading'`).\n let cancelled = false\n const timer = setTimeout(() => {\n if (cancelled || !ref.current) return\n handleRef.current?.close()\n handleRef.current = mount({\n el: ref.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n profileId,\n ...(listingId ? { subjectId: `listing_${listingId}` } : {}),\n ...(token ? { token } : {}),\n ...(refreshToken ? { refreshToken } : {}),\n ...(userId ? { userId } : {}),\n ...(userId || userName || userEmail || userAvatar ? {\n user: {\n ...(userName ? { name: userName } : {}),\n ...(userEmail ? { email: userEmail } : {}),\n ...(userAvatar ? { avatar: userAvatar } : {}),\n ...(listingId ? { meta: { listingId } } : {}),\n },\n } : {}),\n ...(listingTitle ? {\n subject: {\n title: listingTitle,\n ...(listingMeta ? { subtitle: listingMeta } : {}),\n ...(listingPrice ? { tags: [`$${listingPrice.toLocaleString()}`] } : {}),\n ...(listingStatus ? { status: listingStatus } : {}),\n },\n } : {}),\n quickReplies: quickReplies ?? DEFAULT_MARKETPLACE_REPLIES,\n ...(accent ? { accent } : {}),\n ...(translateLang ? { translateLang } : {}),\n ...(i18n ? { i18n } : {}),\n ...(launcher ? { launcher, position: position ?? 'bottom-right' } : {}),\n })\n }, 0)\n return () => { cancelled = true; clearTimeout(timer); handleRef.current?.close(); handleRef.current = null }\n // Only identity/target-affecting props trigger a remount — metadata like\n // userName/userEmail is sent once at mount and must NOT churn the connection.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, apiUrl, profileId, listingId, token, userId, accent, launcher, position, translateLang])\n\n // When launcher=true, still render the div — mount() moves it inside the\n // fixed panel above the bubble. Zero size so it doesn't affect page layout.\n return (\n <div\n ref={ref}\n style={launcher ? { width: 0, height: 0, overflow: 'hidden' } : { width: '100%', height, minHeight: height === '100%' ? '480px' : undefined }}\n />\n )\n}\n\n// ── ChatList ──────────────────────────────────────────────────────────────────\n\n/** Live viewport breakpoint — updates on resize/rotation via matchMedia,\n * never a one-shot read (a one-shot read leaves layouts stuck after the\n * user rotates their phone or resizes across the breakpoint). SSR-safe. */\nfunction useIsMobile(maxWidthPx: number): boolean {\n const [mobile, setMobile] = useState(\n typeof window !== 'undefined' && window.innerWidth <= maxWidthPx,\n )\n useEffect(() => {\n if (typeof window === 'undefined' || !window.matchMedia) return\n const mq = window.matchMedia(`(max-width: ${maxWidthPx}px)`)\n const onChange = (e: MediaQueryListEvent): void => setMobile(e.matches)\n setMobile(mq.matches)\n mq.addEventListener('change', onChange)\n return () => mq.removeEventListener('change', onChange)\n }, [maxWidthPx])\n return mobile\n}\n\nexport interface ChatAppProps {\n /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the\n * recommended form. The WebSocket URL and REST base are derived from it —\n * you do NOT need to pass `wss://` or `/ws`. */\n url: string\n /** HTTP(S) base for REST calls — only when the REST API is on a different\n * origin than the socket. Normally omit.\n * @deprecated pass a single `url`; kept for back-compat. */\n apiUrl?: string\n /** A chatroom id. Provide `profileId` OR `tenantId` (see below). When both\n * are given, profileId also fixes where the ✎ \"new conversation\" opens. */\n profileId?: string\n /** Tenant-level identification — the natural fit for a chat app: lists\n * EVERY conversation this user has with your business across ALL of its\n * chatrooms, without naming one. Use this when the platform runs several\n * chatrooms under one tenant (e.g. a marketplace chatroom for\n * `<MarketplaceChat/>` pages PLUS a general-support chatroom) — the inbox\n * shows both, and each row opens against its own chatroom. The ✎ compose\n * button opens the tenant's default chatroom (its oldest, as reported by\n * the server). */\n tenantId?: string\n /** A signed identity token (ES256 JWT) for chatrooms with signed identity\n * enabled — the production tier. Wins over `userId`. */\n token?: string\n /** Return a fresh token when a signed token expires. */\n refreshToken?: () => Promise<string | null>\n /** Your logged-in user's stable ID. Omit for anonymous (uses localStorage UID) */\n userId?: string\n /** Optional: shown to agents in the dashboard */\n userName?: string\n /** Optional: shown to agents in the dashboard */\n userEmail?: string\n /** Which conversations the list shows when configured with a profileId\n * (default 'tenant'; irrelevant with `tenantId`, which is always\n * tenant-wide):\n * 'tenant' — every conversation this user has with the business that\n * owns `profileId`, across ALL of its chatrooms — like a real\n * messaging app. Each row opens against its own chatroom.\n * 'profile' — only this chatroom's threads (the pre-1.0.30 behaviour).\n * Tenancy note: guests never see or send tenant ids — the server resolves\n * the tenant FROM the profileId, so `profileId` stays the only id you\n * configure. */\n scope?: 'profile' | 'tenant'\n /** Brand colour hex — default '#4F63F5' */\n accent?: string\n /** Container height. Default: '100%' */\n height?: string\n /** When provided, ChatApp renders an always-visible close (✕) control in the\n * top-right corner of its container. Pass this whenever ChatApp is shown in\n * an overlay/panel or as a mobile-fullscreen surface (ChatAppLauncher wires\n * it automatically) so there is a reliable way OUT — without it, an inline\n * fullscreen panel on a phone (no Escape key, no reachable backdrop) traps\n * the user. Omit for a bare inline embed the host chromes itself. */\n onClose?: () => void\n /** i18n overrides */\n i18n?: import('./chatlist.js').ChatListOptions['i18n']\n}\n\n/**\n * Full chat-app component: conversation list on the left (or full screen on\n * mobile), chat room on the right when a thread is selected — like a\n * standalone messaging app. Tapping a thread opens the chat inline; the ✎\n * button starts a new conversation with the business.\n *\n * By default (`scope=\"tenant\"`) the list shows EVERY conversation this user\n * has with the business that owns `profileId` — across all of its chatrooms —\n * and each row opens against its own chatroom. Pass `scope=\"profile\"` to\n * limit it to one chatroom's threads.\n *\n * Identify at either level:\n * • `tenantId` — the natural fit for a chat app. A platform often runs\n * SEVERAL chatrooms under one business (a marketplace chatroom for\n * `<MarketplaceChat/>` pages plus a general-support chatroom, …); with\n * `tenantId` the inbox shows the user's chats with all of them, no\n * profileId needed. Compose opens the tenant's default chatroom.\n * • `profileId` — any one of the business's chatrooms; still lists\n * tenant-wide by default (`scope=\"tenant\"`), and fixes where compose\n * opens.\n *\n * @example\n * ```tsx\n * 'use client'\n * import { ChatApp } from '@paramms/chat-widget/react'\n *\n * export default function MessagesPage({ session }) {\n * return (\n * <div style={{ height: '100vh' }}>\n * <ChatApp\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * tenantId={process.env.NEXT_PUBLIC_RELAY_TENANT_ID} // or profileId={…}\n * userId={session?.user.id}\n * userName={session?.user.name}\n * userEmail={session?.user.email}\n * />\n * </div>\n * )\n * }\n * ```\n */\nexport function ChatApp({\n url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail,\n accent, height = '100%', i18n, onClose,\n scope = 'tenant',\n}: ChatAppProps): JSX.Element {\n const misconfigured = !profileId && !tenantId\n type Entry = import('./chatlist.js').ChatListEntry\n const [selected, setSelected] = useState<Entry | null>(null)\n const listRef = useRef<HTMLDivElement>(null)\n const chatRef = useRef<HTMLDivElement>(null)\n const handleRef = useRef<import('./chatlist.js').ChatListHandle | null>(null)\n const chatHandle = useRef<WidgetHandle | null>(null)\n\n // Build the chat list\n useEffect(() => {\n if (!listRef.current) return\n let cancelled = false\n import('./chatlist.js').then(({ mountChatList }) => {\n // The dynamic import is async: if the effect was cleaned up (unmount,\n // dep change, or StrictMode's double-invoke) before it resolved, or the\n // ref is gone, don't mount a phantom list that never gets closed.\n if (cancelled || !listRef.current) return\n handleRef.current = mountChatList({\n el: listRef.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n ...(profileId ? { profileId } : {}),\n ...(tenantId ? { tenantId } : {}),\n scope,\n onSelect: (entry) => setSelected(entry),\n // Compose (✎) opens the chatroom's general support thread — without\n // this a user with no conversations yet had an empty list and no way\n // to ever start one, which is what made ChatApp feel broken.\n // Compose target: the configured chatroom, else the tenant's default\n // (oldest chatroom, reported by the server on the first list fetch).\n onNewChat: () => {\n const target = handleRef.current?.defaultProfileId()\n if (!target) return // list hasn't loaded yet — nothing sane to open\n setSelected({ id: '__new__', profileId: target, state: 'open', updatedAt: Date.now() })\n },\n ...(token ? { token } : {}),\n ...(userId ? { userId } : {}),\n ...(accent ? { accent } : {}),\n ...(i18n ? { i18n } : {}),\n })\n })\n return () => { cancelled = true; handleRef.current?.close(); handleRef.current = null }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, apiUrl, profileId, tenantId, token, userId, scope])\n\n // Open a ChatWidget when a thread is selected.\n //\n // Two correctness details here:\n // • identity: `userId` goes through as userId (the host-vouched tier) and\n // signed JWTs as `token` — the same tiers as every other component. It\n // used to conflate them (`token: userId`), which worked only by the\n // accident that mount() folds userId into the token, and left no way to\n // pass a REAL signed token at all.\n // • chatroom: the row's OWN profileId wins. With scope='tenant' the list\n // spans every chatroom of the business, so opening against the mounted\n // profileId would find-or-create a DIFFERENT conversation.\n useEffect(() => {\n if (!chatRef.current || !selected) return\n chatHandle.current?.close()\n chatHandle.current = mount({\n el: chatRef.current,\n url,\n ...(apiUrl ? { apiUrl } : {}),\n profileId: (selected.profileId ?? profileId)!, // rows always carry theirs; compose sets one explicitly\n // DM rows open as direct conversations (kind + peer). Opening them via\n // their dm:… subjectId only works for the participant that OWNS the\n // thread key — the other side would silently fork a duplicate.\n ...(selected.kind === 'direct' && selected.peerId\n ? { kind: 'direct' as const, peerId: selected.peerId }\n : selected.subjectId ? { subjectId: selected.subjectId } : {}),\n ...(token ? { token } : {}),\n ...(refreshToken ? { refreshToken } : {}),\n ...(userId ? { userId } : {}),\n ...(userId || userName || userEmail ? {\n user: {\n ...(userName ? { name: userName } : {}),\n ...(userEmail ? { email: userEmail } : {}),\n },\n } : {}),\n ...(selected.subjectTitle ? {\n subject: {\n title: selected.subjectTitle,\n ...(selected.subjectMeta ? { subtitle: selected.subjectMeta } : {}),\n },\n } : {}),\n ...(accent ? { accent } : {}),\n // Stack navigation: the chatroom's back chevron returns to the list.\n onBack: () => setSelected(null),\n })\n // Keep the list fresh: opening a chat marks it read, and replies received\n // while a chat is open should update its row's preview/ordering.\n const listTimer = setInterval(() => handleRef.current?.refresh(), 20_000)\n return () => {\n clearInterval(listTimer)\n chatHandle.current?.close(); chatHandle.current = null\n // Refresh once on the way out so the row reflects what just happened.\n handleRef.current?.refresh()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selected?.id])\n\n // (After all hooks — React requires unconditional hook order.)\n if (misconfigured) {\n return (\n <div style={{ padding: 16, font: '13px system-ui', color: '#b91c1c', background: '#fef2f2', borderRadius: 8 }}>\n [relay] &lt;ChatApp/&gt; needs a <code>profileId</code> or a <code>tenantId</code>.\n </div>\n )\n }\n\n // Stack navigation, like a native messaging app: show the LIST, and when a\n // conversation is tapped, push the CHATROOM over it (full surface); the\n // chatroom's own header carries the back chevron (wired via mount's onBack)\n // that pops back to the list. No two-pane \"select a conversation\" dead space —\n // that only ever made sense on a very wide desktop inbox, and read as broken\n // in the launcher panel / on mobile, which is how this is actually used.\n return (\n <div style={{ position: 'relative', width: '100%', height, minHeight: '400px', overflow: 'hidden', background: '#fff' }}>\n {onClose && !selected && (\n <button\n onClick={onClose}\n aria-label={i18n?.close ?? 'Close'}\n style={{\n position: 'absolute', top: 8, right: 8, zIndex: 20,\n width: 32, height: 32, borderRadius: '50%',\n display: 'flex', alignItems: 'center', justifyContent: 'center',\n background: 'rgba(0,0,0,.05)', border: 'none', color: '#1c1b1a',\n fontSize: 18, lineHeight: 1, cursor: 'pointer',\n }}\n >\n ✕\n </button>\n )}\n\n {/* List — kept mounted (just hidden) so its scroll position, search text\n and live unread counts survive a round-trip into a chatroom. */}\n <div style={{\n position: 'absolute', inset: 0,\n display: selected ? 'none' : 'flex', flexDirection: 'column',\n }}>\n <div ref={listRef} style={{ width: '100%', height: '100%' }} />\n </div>\n\n {/* Chatroom — only present while a conversation is selected. */}\n {selected && (\n <div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column' }}>\n <div ref={chatRef} style={{ width: '100%', height: '100%' }} />\n </div>\n )}\n </div>\n )\n}\n\n// ── ChatAppLauncher ───────────────────────────────────────────────────────────\n\nexport interface ChatAppLauncherProps {\n /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the\n * recommended form. The WebSocket URL and REST base are derived from it. */\n url: string\n /** HTTP(S) base for REST calls — only when REST is on a different origin.\n * @deprecated pass a single `url`; kept for back-compat. */\n apiUrl?: string\n /** A chatroom id. Provide `profileId` OR `tenantId`. */\n profileId?: string\n /** Tenant-level identification — the panel lists EVERY conversation this\n * user has with your business across ALL of its chatrooms (see\n * ChatAppProps.tenantId). The ✎ compose opens the tenant's default\n * chatroom. */\n tenantId?: string\n /** A signed identity token (ES256 JWT) for chatrooms with signed identity\n * enabled — the production tier. Wins over `userId`. */\n token?: string\n /** Return a fresh token when a signed token expires. */\n refreshToken?: () => Promise<string | null>\n /** Your logged-in user's stable ID */\n userId?: string\n userName?: string\n userEmail?: string\n /** Which conversations the panel's list shows — see ChatAppProps.scope.\n * Default 'tenant': every conversation this user has with the business. */\n scope?: 'profile' | 'tenant'\n /** Brand colour hex — default '#4F63F5' */\n accent?: string\n\n /** true → floating bubble fixed to the corner of the screen (like Intercom)\n * false → an inline \"Messages\" button that expands a panel below it\n * Default: true */\n floating?: boolean\n /** Only used when floating=true. Default: 'bottom-right' */\n position?: 'bottom-right' | 'bottom-left'\n /** Label shown on the button. Default: '💬' for floating, 'Messages' for inline */\n label?: string\n /** Width of the chat panel. Default: '420px' (floating) or '100%' (inline) */\n panelWidth?: string\n /** Height of the chat panel. Default: '600px' */\n panelHeight?: string\n}\n\n/**\n * A button that opens the full ChatApp (list → chat) in a panel.\n *\n * floating=true → fixed bubble in the corner of the screen, like WhatsApp Web's\n * chat button or Intercom.\n * floating=false → an inline button (e.g. in your nav bar) that expands a panel\n * below it.\n *\n * @example Floating bubble (bottom-right)\n * ```tsx\n * <ChatAppLauncher\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * floating\n * position=\"bottom-right\"\n * />\n * ```\n *\n * @example Inline nav button\n * ```tsx\n * <ChatAppLauncher\n * url={process.env.NEXT_PUBLIC_RELAY_URL}\n * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}\n * userId={session?.user.id}\n * floating={false}\n * label=\"Messages\"\n * />\n * ```\n */\nexport function ChatAppLauncher({\n url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail,\n scope,\n accent = '#4F63F5',\n floating = true,\n position = 'bottom-right',\n label,\n panelWidth,\n panelHeight = '600px',\n}: ChatAppLauncherProps): JSX.Element {\n const [open, setOpen] = useState(false)\n const btnRef = useRef<HTMLButtonElement>(null)\n\n const isRight = position === 'bottom-right'\n const defaultLabel = floating ? '💬' : 'Messages'\n const btnLabel = label ?? defaultLabel\n const isMobile = useIsMobile(479)\n\n // Close on Escape\n useEffect(() => {\n const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') setOpen(false) }\n document.addEventListener('keydown', handler)\n return () => document.removeEventListener('keydown', handler)\n }, [])\n\n // ── Floating mode ──────────────────────────────────────────────────────────\n if (floating) {\n // Mobile (<480px): the panel must be its OWN fixed fullscreen layer\n // (inset:0). Sizing it 100vw INSIDE the bottom-right wrapper — as it used\n // to — anchored its right edge 20px in from the viewport, pushing the\n // whole app 20px off-screen. The bubble wrapper stays above it (z 9999\n // vs 9998) so the ✕ keeps working as the close control. Live breakpoint:\n // rotating the phone re-lays-out.\n return (\n <div style={{\n position: 'fixed',\n [isRight ? 'right' : 'left']: '20px',\n bottom: '20px',\n zIndex: 9999,\n display: 'flex',\n flexDirection: 'column',\n alignItems: isRight ? 'flex-end' : 'flex-start',\n gap: '12px',\n }}>\n {/* Panel */}\n <div style={{\n ...(isMobile ? {\n position: 'fixed' as const, inset: 0,\n width: '100%', height: '100dvh', borderRadius: '0', zIndex: 9998,\n } : {\n width: `min(${panelWidth ?? '420px'}, calc(100vw - 40px))`,\n height: `min(${panelHeight}, calc(100dvh - 108px))`,\n borderRadius: '16px',\n }),\n overflow: 'hidden',\n boxShadow: isMobile ? 'none' : '0 8px 40px rgba(0,0,0,.18)',\n background: '#fff',\n display: open ? 'flex' : 'none',\n flexDirection: 'column',\n transformOrigin: `bottom ${isRight ? 'right' : 'left'}`,\n animation: open ? 'ocl-pop-in .18s ease' : 'none',\n }}>\n <ChatApp\n url={url} {...(apiUrl ? { apiUrl } : {})}\n {...(profileId ? { profileId } : {})}\n {...(tenantId ? { tenantId } : {})}\n {...(token ? { token } : {})}\n {...(refreshToken ? { refreshToken } : {})}\n {...(userId ? { userId } : {})}\n {...(userName ? { userName } : {})}\n {...(userEmail ? { userEmail } : {})}\n {...(scope ? { scope } : {})}\n accent={accent} height=\"100%\"\n onClose={() => setOpen(false)}\n />\n </div>\n\n {/* Bubble button. On a fullscreen mobile panel the bubble sits at\n bottom-right ON TOP of the message composer/send button, so hide it\n while open on mobile — the in-panel top-right ✕ is the close there. */}\n <button\n ref={btnRef}\n onClick={() => setOpen(o => !o)}\n style={{\n width: '56px', height: '56px', borderRadius: '50%',\n background: accent, color: '#fff', border: 'none',\n fontSize: '24px', cursor: 'pointer', flexShrink: 0,\n boxShadow: '0 4px 16px rgba(0,0,0,.25)',\n transition: 'transform .15s',\n display: (open && isMobile) ? 'none' : 'block',\n }}\n onMouseEnter={e => { (e.target as HTMLElement).style.transform = 'scale(1.08)' }}\n onMouseLeave={e => { (e.target as HTMLElement).style.transform = 'scale(1)' }}\n >\n {open ? '✕' : btnLabel}\n </button>\n\n <style>{`@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }`}</style>\n </div>\n )\n }\n\n // ── Inline mode ────────────────────────────────────────────────────────────\n // The panel is rendered via a fixed overlay anchored to the button position.\n // This prevents clipping from parent overflow:hidden containers (e.g. nav bars).\n // On mobile the anchored popover can't fit — it goes fullscreen instead\n // (the backdrop still closes it).\n const pWidth = `min(${panelWidth ?? '420px'}, calc(100vw - 16px))`\n\n // Track button position for panel anchor\n const [btnRect, setBtnRect] = useState<DOMRect | null>(null)\n\n const handleBtnClick = () => {\n if (!open && btnRef.current) setBtnRect(btnRef.current.getBoundingClientRect())\n setOpen(o => !o)\n }\n\n const panelTop = btnRect ? btnRect.bottom + 8 : 0\n // Clamp so a button near the left edge can't push the panel off-screen.\n const panelRight = btnRect ? Math.max(8, window.innerWidth - btnRect.right) : 0\n\n return (\n <>\n {/* Trigger button */}\n <button\n ref={btnRef}\n onClick={handleBtnClick}\n style={{\n display: 'inline-flex', alignItems: 'center', gap: '6px',\n padding: '8px 16px', borderRadius: '8px',\n background: open ? accent : 'transparent',\n color: open ? '#fff' : accent,\n border: `2px solid ${accent}`,\n fontSize: '14px', fontWeight: 600, cursor: 'pointer',\n transition: 'background .15s, color .15s',\n }}\n >\n 💬 {btnLabel}\n </button>\n\n {/* Fixed panel — rendered at document root level via CSS fixed positioning */}\n {open && btnRect && (\n <>\n {/* Backdrop */}\n <div\n onClick={() => setOpen(false)}\n style={{ position: 'fixed', inset: 0, zIndex: 9998 }}\n />\n <div style={{\n position: 'fixed',\n ...(isMobile ? {\n inset: 0, width: '100%', height: '100dvh', borderRadius: '0',\n } : {\n top: panelTop,\n right: panelRight,\n width: pWidth,\n height: `min(${panelHeight}, calc(100dvh - ${panelTop}px - 12px))`,\n borderRadius: '16px',\n }),\n overflow: 'hidden',\n boxShadow: isMobile ? 'none' : '0 8px 40px rgba(0,0,0,.2)',\n background: '#fff',\n zIndex: 9999,\n animation: 'ocl-slide-in .18s ease',\n }}>\n <ChatApp\n url={url} {...(apiUrl ? { apiUrl } : {})}\n {...(profileId ? { profileId } : {})}\n {...(tenantId ? { tenantId } : {})}\n {...(token ? { token } : {})}\n {...(refreshToken ? { refreshToken } : {})}\n {...(userId ? { userId } : {})}\n {...(userName ? { userName } : {})}\n {...(userEmail ? { userEmail } : {})}\n {...(scope ? { scope } : {})}\n accent={accent} height=\"100%\"\n onClose={() => setOpen(false)}\n />\n </div>\n <style>{`@keyframes ocl-slide-in { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }`}</style>\n </>\n )}\n </>\n )\n}\n"],"names":["ChatWidget","url","apiUrl","profileId","token","refreshToken","userId","userName","userEmail","userAvatar","contextTitle","contextSubtitle","contextStatus","subjectId","accent","launcher","position","quickReplies","height","i18n","translateLang","ref","useRef","handleRef","useEffect","_a","mount","jsx","DEFAULT_MARKETPLACE_REPLIES","MarketplaceChat","listingId","listingTitle","listingMeta","listingPrice","listingStatus","cancelled","timer","useIsMobile","maxWidthPx","mobile","setMobile","useState","mq","onChange","e","ChatApp","tenantId","onClose","scope","misconfigured","selected","setSelected","listRef","chatRef","chatHandle","mountChatList","entry","target","listTimer","_b","jsxs","ChatAppLauncher","floating","label","panelWidth","panelHeight","open","setOpen","btnRef","isRight","btnLabel","isMobile","handler","o","pWidth","btnRect","setBtnRect","handleBtnClick","panelTop","panelRight","Fragment"],"mappings":";;;AA0GO,SAASA,EAAW;AAAA,EACzB,KAAAC;AAAA,EAAK,QAAAC;AAAA,EAAQ,WAAAC;AAAA,EACb,OAAAC;AAAA,EAAO,cAAAC;AAAA,EACP,QAAAC;AAAA,EAAQ,UAAAC;AAAA,EAAU,WAAAC;AAAA,EAAW,YAAAC;AAAA,EAC7B,cAAAC;AAAA,EAAc,iBAAAC;AAAA,EAAiB,eAAAC;AAAA,EAC/B,WAAAC;AAAA,EACA,QAAAC;AAAA,EAAQ,UAAAC;AAAA,EAAU,UAAAC;AAAA,EAAU,cAAAC;AAAA,EAAc,QAAAC,IAAS;AAAA,EACnD,MAAAC;AAAA,EAAM,eAAAC;AACR,GAAiC;AAC/B,QAAMC,IAAYC,EAAuB,IAAI,GACvCC,IAAYD,EAA4B,IAAI;AAElD,SAAAE,EAAU,MAAM;;AACd,QAAKH,EAAI;AACT,cAAAI,IAAAF,EAAU,YAAV,QAAAE,EAAmB,SACnBF,EAAU,UAAUG,EAAM;AAAA,QACxB,IAAIL,EAAI;AAAA,QACR,KAAApB;AAAA,QACA,GAAIC,IAAS,EAAE,QAAAA,EAAA,IAAW,CAAA;AAAA,QAC1B,WAAAC;AAAA,QACA,GAAIU,IAAY,EAAE,WAAAA,EAAA,IAAiB,CAAA;AAAA,QACnC,GAAIT,IAAe,EAAE,OAAAA,EAAA,IAAiB,CAAA;AAAA,QACtC,GAAIC,IAAe,EAAE,cAAAA,EAAA,IAAiB,CAAA;AAAA,QACtC,GAAIC,IAAY,EAAE,QAAAA,EAAA,IAAW,CAAA;AAAA,QAC7B,GAAIA,KAAUC,KAAYC,KAAaC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AiB,CAAA;AAAA,UACtC,GAAIC,IAAY,EAAE,QAAAA,EAAA,IAAc,CAAA;AAAA,UAChC,GAAIC,IAAY,EAAE,UAAAA,EAAA,IAAc,CAAA;AAAA,UAChC,GAAIC,IAAY,EAAE,WAAAA,EAAA,IAAc,CAAA;AAAA,UAChC,GAAIwC,IAAY,EAAE,OAAAA,EAAA,IAAc,CAAA;AAAA,UACjC,QAAAlC;AAAA,UAAgB,QAAO;AAAA,UACvB,SAAS,MAAMqD,EAAQ,EAAK;AAAA,QAAA;AAAA,MAAA,GAEhC;AAAA,MACA,gBAAAxC,EAAC,WAAO,UAAA,uHAAA,CAAuH;AAAA,IAAA,EAAA,CACjI;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -51,6 +51,11 @@ export interface RendererHandlers {
51
51
  /** Translate a message's text for display. Return null if unavailable —
52
52
  * the renderer shows a brief "unavailable" hint and leaves the original. */
53
53
  onTranslate?(text: string): Promise<string | null>;
54
+ /** Stack navigation (chat-app surfaces): when set, the header shows a back
55
+ * chevron on the left that calls this — tap a conversation → chatroom →
56
+ * back → list, like a native messaging app. Omit for a standalone widget,
57
+ * which has nothing to go "back" to. */
58
+ onBack?(): void;
54
59
  }
55
60
  /** Renders a ChatStore into a host element in the Image-1 layout: header →
56
61
  * subject card → action chips → chat → quick replies → input. Self-injects its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paramms/chat-widget",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "Embeddable real-time chat widget for the Relay platform",
5
5
  "license": "MIT",
6
6
  "repository": {