@burdenoff/website-sdk 2026.1029.1 → 2026.1031.2

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,"sources":["../../src/components/explore-avatar-live-config.ts","../../src/components/explore-avatar-api.ts","../../src/components/explore-avatar-i18n.ts","../../src/components/explore-avatar-turnstile.ts","../../src/components/explore-fill.ts","../../src/utils/cn.ts","../../src/components/explore-avatar-live-view.tsx"],"names":["twMerge","clsx","INERT","useId","useState","useRef","useCallback","live","locale","base","headers","off","body","useEffect","jsx","jsxs","Fragment"],"mappings":";;;;;;;;AA0CA,IAAM,IAAA,GAAO,wBAAA;AACb,IAAM,OAAA,GAAU,wBAAA;AAKT,SAAS,aAAa,KAAA,EAAwB;AACnD,EAAA,OAAO,IAAA,CAAK,KAAK,KAAK,CAAA;AACxB;AAGO,SAAS,gBAAgB,KAAA,EAAwB;AACtD,EAAA,OAAO,OAAA,CAAQ,KAAK,KAAK,CAAA;AAC3B;AAsCA,IAAM,QAAA,mBAAuC,IAAI,GAAA,CAAmB,CAAC,IAAI,CAAC,CAAA;AAGnE,SAAS,2BAA2B,MAAA,EAAgC;AACzE,EAAA,OAAO,QAAA,CAAS,IAAI,MAAM,CAAA;AAC5B;;;AC7DA,IAAM,uBAAA,GAA0B,GAAA;AAEhC,IAAM,iBAAA,GAAoB,GAAA;AAiE1B,IAAM,UAAA,GAAa,uBAAA;AACnB,IAAM,kBAAA,GAAqB,8BAAA;AAC3B,IAAM,MAAA,GAAS,sBAAA;AACf,IAAM,UAAA,GAAa,oBAAA;AACnB,IAAM,UAAA,GAAa,qBAAA;AAEnB,IAAM,KAAA,GAAQ,EAAE,IAAA,EAAM,OAAA,EAAQ;AAC9B,IAAM,MAAA,GAAS,EAAE,IAAA,EAAM,QAAA,EAAS;AAGzB,SAAS,kBAAkB,KAAA,EAAwB;AACxD,EAAA,OAAO,UAAA,CAAW,KAAK,KAAK,CAAA;AAC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kBAAA;AAAA,UAClB,SAAA,EAAW,aAAA;AAAA,UACX,OAAA,EAAS,gBAAA;AAAA,UAER,QAAA,EAAA,CAAA,CAAE;AAAA;AAAA,OACL;AAEF,MAAA;AAEA;AAIJ,EAAA,uBACEC,eAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,OAAA;AAAA,MACL,mBAAA,EAAkB,aAAA;AAAA,MAClB,cAAY,KAAA,CAAM,IAAA;AAAA,MAClB,SAAA,EAAU,oEAAA;AAAA,MAET,QAAA,EAAA;AAAA,QAAA,GAAA;AAAA,QACA,KAAA;AAAA,wBACDD,cAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,QAAA;AAAA,YACL,mBAAA,EAAkB,oBAAA;AAAA,YAClB,SAAA,EACE,UAAU,yBAAA,GAA4B,+BAAA;AAAA,YAGvC,QAAA,EAAA,QAAA,CAAS,MAAM,IAAI;AAAA;AAAA,SACtB;AAAA,QACC,IAAA;AAAA,wBACDA,cAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,qBAAkB,uBAAA,EAAwB,CAAA;AAAA,QAC9D;AAAA;AAAA;AAAA,GACH;AAEJ","file":"index.js","sourcesContent":["/**\n * BOFF-9797. The small part of the live avatar that the panel itself needs, whether or not it is ever opened: what a\n * host's `avatar.live` is, whether the live avatar can run on this page at all, and where its requests go.\n *\n * Everything else (the view, its state machine, the requests, the words, the bot check) is a separate chunk that a\n * site only downloads when its visitor first opens the Avatar view (see `explore-avatar-live.tsx`). That is why this\n * file is separate and kept to a few lines: it is the only part of the live avatar in the package root for a site that\n * does not pass `avatar.live`, and the part of it that decides, without loading anything, whether the chunk is wanted.\n * Types only, plus plain functions: nothing here imports a component, a context or a string table.\n */\nimport type { ExploreLocale } from \"./explore-i18n\";\nimport type { AvatarLiveModule } from \"../avatar-live/types\";\nimport type { UseExploreChatResult } from \"../hooks/use-explore-chat\";\n\n/**\n * BOFF-9797. A host's opt-in to the live avatar on its panel's Avatar tab. Every field is required; a config that is\n * incomplete leaves the tab as it was (and a warning in the console).\n */\nexport interface ExplorePanelAvatarLive {\n /** The site, as the live avatar service knows it: `healthybowl`. */\n site: string;\n /**\n * Loads the live avatar's room module: `() => import('@burdenoff/website-sdk/avatar-live')`. Called only after the\n * visitor presses Start on the consent card, never on page load or on opening the tab. That entry needs the\n * package's optional peer dependency for media rooms (see the README).\n */\n load: () => Promise<AvatarLiveModule>;\n /** The site's Cloudflare Turnstile site key, for the bot check that runs when the visitor presses Start. */\n turnstileSiteKey: string;\n /** The version of the suggested-question list the panel shows (its `examplePrompts`), such as `hb-en-1`. */\n manifestVersion: string;\n}\n\n/** What the live avatar reads of the panel's conversation: the transcript, whether it is read-only, and the token. */\nexport type AvatarConversation = Pick<\n UseExploreChatResult,\n \"messages\" | \"isSharedView\" | \"getConversationToken\"\n>;\n\n/** The web branch's routes, under the gateway's origin. */\nexport const AVATAR_WEB_API_PATH = \"/api/web-avatar/v1\";\n\nconst SITE = /^[a-z][a-z0-9-]{1,31}$/;\nconst VERSION = /^[A-Za-z0-9._-]{1,32}$/;\nconst SITE_KEY = /^[A-Za-z0-9_-]{1,128}$/;\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\"]);\n\n/** A site slug the contract accepts (`healthybowl`). */\nexport function isAvatarSite(value: string): boolean {\n return SITE.test(value);\n}\n\n/** A consent or manifest version the contract accepts (`hb-en-1`). */\nexport function isAvatarVersion(value: string): boolean {\n return VERSION.test(value);\n}\n\n/**\n * The web branch's base URL on the SDK's configured gateway: the gateway URL's origin, plus\n * {@link AVATAR_WEB_API_PATH}. Null for anything that is not an `https:` URL (or `http:` on this machine, for local\n * development).\n */\nexport function avatarApiBase(gatewayUrl: string | undefined): string | null {\n if (!gatewayUrl) return null;\n let url: URL;\n try {\n url = new URL(gatewayUrl);\n } catch {\n return null;\n }\n const local =\n url.protocol === \"http:\" && LOOPBACK_HOSTS.has(url.hostname.toLowerCase());\n if (url.protocol !== \"https:\" && !local) return null;\n return `${url.origin}${AVATAR_WEB_API_PATH}`;\n}\n\n/** Whether a host's `avatar.live` has everything the live avatar needs, in the shapes the contract accepts. */\nexport function liveConfigComplete(live: ExplorePanelAvatarLive): boolean {\n return (\n typeof live.load === \"function\" &&\n typeof live.site === \"string\" &&\n isAvatarSite(live.site) &&\n typeof live.manifestVersion === \"string\" &&\n isAvatarVersion(live.manifestVersion) &&\n typeof live.turnstileSiteKey === \"string\" &&\n SITE_KEY.test(live.turnstileSiteKey)\n );\n}\n\n/**\n * The locales whose live-avatar strings have been reviewed. The live avatar runs only in these; see\n * `explore-avatar-i18n.ts`. English only, until a named reviewer signs off on another.\n */\nconst REVIEWED: ReadonlySet<ExploreLocale> = new Set<ExploreLocale>([\"en\"]);\n\n/** Whether the live avatar may run in `locale`: its strings have been reviewed. */\nexport function isAvatarLiveLocaleReviewed(locale: ExploreLocale): boolean {\n return REVIEWED.has(locale);\n}\n","/**\n * BOFF-9797. The website live avatar's three requests, as a visitor's browser makes them.\n *\n * They go to the global gateway's web branch, under the SDK's configured gateway (`/api/web-avatar/v1/*` on its\n * origin), and follow the website avatar web API, v1:\n *\n * GET /availability?site=…&locale=… when the Avatar tab opens, never on page load\n * POST /sessions after the visitor's consent and the bot check\n * POST /sessions/{id}/end Stop, leaving the tab, closing the panel, hiding the page\n *\n * - **Never with credentials** (`credentials: 'omit'`): a website visitor has no account, no cookie and no workspace\n * here.\n * - **The bot check's token** goes in the `x-web-avatar-bot-token` header, on create only. The gateway verifies it and\n * drops it; the body is exactly the contract's six fields. The check itself is bound to that body (contract v1.1):\n * see {@link avatarBotBinding}.\n * - **The end is a simple request** (see {@link sendEnd}): no `Content-Type` of our own, so a page being hidden has no\n * CORS preflight to wait for.\n * - **Every answer is read into one of a few outcomes** the Avatar tab can show. A missing route, a forbidden one, a\n * refused origin and a network failure are all `inert`: the tab shows what it showed before there was a live\n * avatar. Nothing a server says is shown as it was said.\n * - Nothing here logs. The conversation token goes into the create body and nowhere else, and the session's secret\n * only into the end body.\n */\n\nimport { isAvatarSite, isAvatarVersion } from \"./explore-avatar-live-config\";\n\n// The few helpers the panel itself needs (where the requests go, and the shapes a config may take) live in\n// `explore-avatar-live-config.ts`, so that they do not drag this file into every site's bundle; they are re-exported\n// here, where the rest of the contract's grammar is.\nexport {\n AVATAR_WEB_API_PATH,\n avatarApiBase,\n isAvatarSite,\n isAvatarVersion,\n} from \"./explore-avatar-live-config\";\n\n/** How long the Avatar tab waits to hear whether the live avatar is offered. */\nconst AVAILABILITY_TIMEOUT_MS = 8_000;\n/** How long a create may take: past the gateway's own deadline for it, so the gateway's answer is what decides. */\nconst CREATE_TIMEOUT_MS = 30_000;\n\n/** The refusals the Avatar tab explains, each in a short sentence of its own. */\nexport type AvatarRefusal =\n | \"busy\"\n | \"limits\"\n | \"region\"\n | \"locale\"\n | \"paused\"\n | \"not_eligible\"\n | \"answer_claimed\";\n\n/** Why the browser ends a session. Analytics only: the secret is what ends it. */\nexport type AvatarEndReason = \"user\" | \"page_hide\" | \"client_error\";\n\n/** What an `ok` availability offers. */\nexport interface AvatarOffer {\n /** The consent version the visitor must agree to: the panel shows only copy written for exactly this version. */\n consentVersion: string;\n /** The longest a session can last, in seconds. */\n maxSessionSeconds: number;\n}\n\nexport type AvatarAvailability =\n | { kind: \"available\"; offer: AvatarOffer }\n | { kind: \"refused\"; reason: AvatarRefusal }\n /** Not offered here, or not reachable: the Avatar tab stays as it was before the live avatar. */\n | { kind: \"inert\" };\n\n/** A created session: what the browser needs to watch it and to end it. */\nexport interface AvatarSession {\n sessionId: string;\n /** Returned once; ends this session and nothing else. Kept out of the page's markup. */\n endSecret: string;\n /** When the server ends the session, in epoch milliseconds. */\n endsAt: number;\n join: {\n livekitUrl: string;\n /** Subscribe-only and short-lived. Kept out of the page's markup. */\n participantToken: string;\n workerIdentity: string;\n };\n captions: { locale: string; text: string };\n}\n\nexport type AvatarCreateResult =\n | { kind: \"created\"; session: AvatarSession }\n /** A session was created, but its answer cannot be used: the browser ends it at once. */\n | { kind: \"unusable\"; sessionId: string; endSecret: string }\n | { kind: \"refused\"; reason: AvatarRefusal }\n /** The consent version moved on since availability: ask again, and show the consent that is current. */\n | { kind: \"consent\" }\n | { kind: \"inert\" }\n | { kind: \"failed\" };\n\n/** The create body: exactly these six fields, in the contract's order. */\nexport interface AvatarCreateBody {\n site: string;\n locale: string;\n conversationToken: string;\n messageId: string;\n consentVersion: string;\n manifestVersion: string;\n}\n\nconst MESSAGE_ID = /^[A-Za-z0-9_-]{1,64}$/;\nconst CONVERSATION_TOKEN = /^[A-Za-z0-9._~+/=-]{16,512}$/;\nconst LOCALE = /^[A-Za-z0-9-]{1,16}$/;\nconst SESSION_ID = /^avs_[0-9a-f]{32}$/;\nconst END_SECRET = /^[A-Za-z0-9_-]{43}$/;\n\nconst INERT = { kind: \"inert\" } as const;\nconst FAILED = { kind: \"failed\" } as const;\n\n/** An answer id the contract accepts. */\nexport function isAvatarMessageId(value: string): boolean {\n return MESSAGE_ID.test(value);\n}\n\n/** A conversation token the contract accepts. */\nexport function isAvatarConversationToken(value: string): boolean {\n return CONVERSATION_TOKEN.test(value);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\n/** What each availability `reason` other than `ok` means for the Avatar tab. A reason not listed is inert. */\nconst AVAILABILITY_REASONS: ReadonlyMap<string, AvatarRefusal | \"inert\"> =\n new Map<string, AvatarRefusal | \"inert\">([\n [\"site\", \"inert\"],\n [\"unavailable\", \"inert\"],\n [\"region\", \"region\"],\n [\"locale\", \"locale\"],\n [\"paused\", \"paused\"],\n [\"busy\", \"busy\"],\n [\"limits\", \"limits\"],\n ]);\n\n/** Read an availability answer: its HTTP status and its parsed JSON body (or null). */\nexport function readAvailability(\n status: number,\n body: unknown,\n): AvatarAvailability {\n if (status !== 200 || !isRecord(body)) return INERT;\n const { available, reason } = body;\n if (typeof available !== \"boolean\" || typeof reason !== \"string\") {\n return INERT;\n }\n if (reason === \"ok\") {\n const { consentVersion, maxSessionSeconds } = body;\n if (\n available !== true ||\n typeof consentVersion !== \"string\" ||\n !isAvatarVersion(consentVersion) ||\n typeof maxSessionSeconds !== \"number\" ||\n !Number.isInteger(maxSessionSeconds) ||\n maxSessionSeconds < 1\n ) {\n return INERT;\n }\n return { kind: \"available\", offer: { consentVersion, maxSessionSeconds } };\n }\n const meaning = available ? undefined : AVAILABILITY_REASONS.get(reason);\n return meaning === undefined || meaning === \"inert\"\n ? INERT\n : { kind: \"refused\", reason: meaning };\n}\n\n/** The create error codes the Avatar tab explains. */\nconst CREATE_REFUSALS: ReadonlyMap<string, AvatarRefusal> = new Map<\n string,\n AvatarRefusal\n>([\n [\"busy\", \"busy\"],\n [\"limits\", \"limits\"],\n [\"region\", \"region\"],\n [\"locale\", \"locale\"],\n [\"paused\", \"paused\"],\n [\"not_eligible\", \"not_eligible\"],\n [\"answer_claimed\", \"answer_claimed\"],\n]);\n\nfunction errorCode(body: unknown): string | null {\n if (!isRecord(body) || !isRecord(body.error)) return null;\n const { code } = body.error;\n return typeof code === \"string\" ? code : null;\n}\n\nfunction readCreated(body: unknown): AvatarCreateResult {\n if (!isRecord(body)) return FAILED;\n const { sessionId, endSecret } = body;\n if (\n typeof sessionId !== \"string\" ||\n !SESSION_ID.test(sessionId) ||\n typeof endSecret !== \"string\" ||\n !END_SECRET.test(endSecret)\n ) {\n return FAILED;\n }\n const unusable = { kind: \"unusable\", sessionId, endSecret } as const;\n const { state, join, captions } = body;\n const endsAt =\n typeof body.endsAt === \"string\" ? Date.parse(body.endsAt) : NaN;\n if (\n state !== \"pending\" ||\n !Number.isFinite(endsAt) ||\n !isRecord(join) ||\n !isRecord(captions)\n ) {\n return unusable;\n }\n const { livekitUrl, participantToken, workerIdentity } = join;\n const { locale, text } = captions;\n if (\n typeof livekitUrl !== \"string\" ||\n !livekitUrl.startsWith(\"wss://\") ||\n typeof participantToken !== \"string\" ||\n participantToken === \"\" ||\n typeof workerIdentity !== \"string\" ||\n workerIdentity === \"\" ||\n typeof locale !== \"string\" ||\n typeof text !== \"string\"\n ) {\n return unusable;\n }\n return {\n kind: \"created\",\n session: {\n sessionId,\n endSecret,\n endsAt,\n join: { livekitUrl, participantToken, workerIdentity },\n captions: { locale, text },\n },\n };\n}\n\n/**\n * Read a create answer: its HTTP status and its parsed JSON body (or null).\n *\n * - 201: the session, or `unusable` when its fields cannot be used (the browser then ends it).\n * - `busy`, `limits`, `region`, `locale`, `paused`, `not_eligible`, `answer_claimed`: a refusal the tab explains.\n * - `consent`: the consent version moved on.\n * - Any other 401, 403, 404 or 405 (`untrusted_caller`, `bot_check`, `site`, `invalid_route`, `method_not_allowed`):\n * inert, as if there were no live avatar here.\n * - Anything else (`invalid_request`, `conflict`, `idempotency_mismatch`, `unavailable`, a gateway error page):\n * failed.\n */\nexport function readCreate(status: number, body: unknown): AvatarCreateResult {\n if (status === 201) return readCreated(body);\n const code = errorCode(body);\n if (code !== null) {\n const refusal = CREATE_REFUSALS.get(code);\n if (refusal !== undefined) return { kind: \"refused\", reason: refusal };\n if (code === \"consent\") return { kind: \"consent\" };\n }\n if (status === 401 || status === 403 || status === 404 || status === 405) {\n return INERT;\n }\n return FAILED;\n}\n\nasync function readJson(response: Response): Promise<unknown> {\n try {\n return (await response.json()) as unknown;\n } catch {\n return null;\n }\n}\n\n/** An abort signal for `timeoutMs`, also aborted with `outer`; `done` clears its timer. */\nfunction deadline(\n timeoutMs: number,\n outer?: AbortSignal,\n): { signal: AbortSignal; done: () => void } {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n const onOuter = () => controller.abort();\n if (outer?.aborted) controller.abort();\n else outer?.addEventListener(\"abort\", onOuter, { once: true });\n return {\n signal: controller.signal,\n done: () => {\n clearTimeout(timer);\n outer?.removeEventListener(\"abort\", onOuter);\n },\n };\n}\n\nexport interface AvatarRequestTarget {\n /** {@link avatarApiBase} of the SDK's gateway. */\n base: string;\n /** Headers every request carries: the alpha gateway's access headers, and nothing on production. */\n headers: Readonly<Record<string, string>>;\n}\n\n/** Ask whether the live avatar is offered for `site` in `locale`. Never throws: a failure is `inert`. */\nexport async function requestAvailability(\n target: AvatarRequestTarget & {\n site: string;\n locale: string;\n signal?: AbortSignal;\n },\n): Promise<AvatarAvailability> {\n if (!isAvatarSite(target.site) || !LOCALE.test(target.locale)) return INERT;\n const query = new URLSearchParams({\n site: target.site,\n locale: target.locale,\n });\n const timer = deadline(AVAILABILITY_TIMEOUT_MS, target.signal);\n try {\n const response = await fetch(`${target.base}/availability?${query}`, {\n method: \"GET\",\n credentials: \"omit\",\n cache: \"no-store\",\n headers: { ...target.headers },\n signal: timer.signal,\n });\n return readAvailability(response.status, await readJson(response));\n } catch {\n return INERT;\n } finally {\n timer.done();\n }\n}\n\n/**\n * Create a session. `botToken` is the bot check's token, for the gateway alone. Never throws: a network failure is\n * `inert`, an answer that cannot be read is `failed`.\n */\nexport async function requestCreate(\n target: AvatarRequestTarget & {\n body: AvatarCreateBody;\n idempotencyKey: string;\n botToken: string;\n },\n): Promise<AvatarCreateResult> {\n const { body } = target;\n // Exactly the contract's six fields, in its order: nothing else of the page's goes along.\n const payload = JSON.stringify({\n site: body.site,\n locale: body.locale,\n conversationToken: body.conversationToken,\n messageId: body.messageId,\n consentVersion: body.consentVersion,\n manifestVersion: body.manifestVersion,\n });\n const timer = deadline(CREATE_TIMEOUT_MS);\n try {\n const response = await fetch(`${target.base}/sessions`, {\n method: \"POST\",\n credentials: \"omit\",\n cache: \"no-store\",\n headers: {\n ...target.headers,\n \"Content-Type\": \"application/json\",\n \"Idempotency-Key\": target.idempotencyKey,\n \"x-web-avatar-bot-token\": target.botToken,\n },\n body: payload,\n signal: timer.signal,\n });\n return readCreate(response.status, await readJson(response));\n } catch {\n return INERT;\n } finally {\n timer.done();\n }\n}\n\n/**\n * Ask the server to end a session, without waiting for it: a `keepalive` request, sent in this same tick, so it still\n * goes when the page is being hidden or unloaded. The server ends the session on its own deadlines whether or not this\n * arrives.\n *\n * **A simple CORS request.** The body is a plain string and this sets no `Content-Type`, so the browser sends it as\n * `text/plain;charset=UTF-8`: a type the gateway's end route reads as JSON for exactly this reason. The session id is\n * in the URL, so a preflight could never be answered from the browser's cache, and one that has to complete while the\n * page unloads may never finish. On production nothing else is added, so no preflight is made. (On the alpha gateway\n * hosts the Access headers in `target.headers` are custom headers, which do bring a preflight there: see the README.)\n */\nexport function sendEnd(\n target: AvatarRequestTarget & {\n sessionId: string;\n secret: string;\n reason: AvatarEndReason;\n },\n): void {\n try {\n void fetch(\n `${target.base}/sessions/${encodeURIComponent(target.sessionId)}/end`,\n {\n method: \"POST\",\n keepalive: true,\n credentials: \"omit\",\n cache: \"no-store\",\n headers: { ...target.headers },\n body: JSON.stringify({ secret: target.secret, reason: target.reason }),\n },\n ).catch(() => undefined);\n } catch {\n // No fetch at all: the server's own deadlines end the session.\n }\n}\n\n/** What scopes the bot check's binding to this contract, and its version. */\nconst BOT_BINDING_PREFIX = \"boff-web-avatar-cdata/v1\";\n\n/** The browser's WebCrypto `subtle`, or null where it has none to offer (a page that is not a secure context). */\nfunction webCryptoSubtle(): SubtleCrypto | null {\n const subtle = globalThis.crypto?.subtle;\n return typeof subtle?.digest === \"function\" ? subtle : null;\n}\n\n/**\n * Whether this browser can make the bot check's binding ({@link avatarBotBinding}): it needs WebCrypto's SHA-256.\n * Without it no live avatar can start here, so a start asks first, before it loads anything for one.\n */\nexport function canBindBotCheck(): boolean {\n return webCryptoSubtle() !== null;\n}\n\nfunction base64UrlNoPad(bytes: Uint8Array): string {\n let binary = \"\";\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary)\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=+$/, \"\");\n}\n\n/**\n * The value the bot check is bound to, for Turnstile's `cData` (web API contract v1.1, additive):\n *\n * base64url_nopad( SHA-256( UTF-8( \"boff-web-avatar-cdata/v1\\n\" + site + \"\\n\" + locale + \"\\n\"\n * + conversationToken + \"\\n\" + messageId ) ) )\n *\n * The gateway recomputes it from the create body and checks it against the one Cloudflare returns with the verified\n * token, so a token minted for one request cannot be used for another. It must be made from the very values the create\n * body will carry, and before the widget is rendered: the caller builds the body once and hands the same one to this\n * and to {@link requestCreate}.\n *\n * Rejects where the browser has no WebCrypto (a page that is not a secure context): the bot check cannot be bound\n * there, so the live avatar does not start. {@link canBindBotCheck} says so beforehand, so that nothing is loaded for\n * a start that cannot happen.\n */\nexport async function avatarBotBinding(\n values: Pick<\n AvatarCreateBody,\n \"site\" | \"locale\" | \"conversationToken\" | \"messageId\"\n >,\n): Promise<string> {\n const subtle = webCryptoSubtle();\n if (subtle === null) {\n throw new Error(\"The bot check cannot be bound here: no WebCrypto.\");\n }\n const text = [\n BOT_BINDING_PREFIX,\n values.site,\n values.locale,\n values.conversationToken,\n values.messageId,\n ].join(\"\\n\");\n const digest = await subtle.digest(\"SHA-256\", new TextEncoder().encode(text));\n return base64UrlNoPad(new Uint8Array(digest));\n}\n\n/** A random UUID v4 for `Idempotency-Key`, or null where the browser has no cryptographic random source. */\nexport function newIdempotencyKey(): string | null {\n const crypto = globalThis.crypto;\n if (typeof crypto?.randomUUID === \"function\") return crypto.randomUUID();\n if (typeof crypto?.getRandomValues !== \"function\") return null;\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\n \"\",\n );\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n","/**\n * BOFF-9797. The words of the live avatar's Avatar tab, in the six product locales, bundled like the rest of\n * Explore's copy (see `explore-i18n.ts` for why a marketing site bundles its strings).\n *\n * ## Review\n *\n * English is the reviewed copy. The other five locales are drafts awaiting translation review: each is a complete\n * object (a missing key is a type error), but the live avatar runs only in a locale that\n * {@link isAvatarLiveLocaleReviewed} lists. In any other, the Avatar tab stays as it was before the live avatar and\n * asks the server nothing. A locale is added there (in `explore-avatar-live-config.ts`) once its strings, and its\n * consent copy, have been reviewed.\n *\n * ## Consent\n *\n * The consent card's copy is versioned: the server names the version it will accept (`consentVersion`), and the panel\n * shows a consent card only when it holds copy written for exactly that version in the visitor's locale\n * ({@link avatarConsentCopy}). A version the SDK does not know, or a locale without reviewed copy for it, offers no\n * consent card at all, so a visitor never agrees to words other than the ones the server records.\n */\n\nimport { isAvatarLiveLocaleReviewed } from \"./explore-avatar-live-config\";\n\nimport type { ExploreLocale } from \"./explore-i18n\";\n\n// The reviewed locales are decided in `explore-avatar-live-config.ts`, which the panel reads without loading this file.\nexport { isAvatarLiveLocaleReviewed };\n\nexport interface AvatarLiveStrings {\n /** Status while the tab asks whether the live avatar is offered. Announced politely. */\n checking: string;\n /** No answer to read yet. */\n needsAnswer: string;\n needsAnswerDetail: string;\n /**\n * The conversation can never be read: its first answer failed, or it has gone past the first question and answer.\n * Only a new chat can. The headline (announced politely), then the explanation. The avatar service reads exactly one\n * answer: the first, completed, to a suggested question.\n */\n startNewChat: string;\n startNewChatDetail: string;\n /** The consent card's buttons. */\n start: string;\n notNow: string;\n /** After the privacy link, for screen readers: it opens in a new tab. */\n opensInNewTab: string;\n /** Status while the bot check runs. Announced politely. */\n botCheck: string;\n /** Status while the session is created and the room joined. Announced politely. */\n connecting: string;\n /** Status once the avatar's video plays. Announced politely. */\n speaking: string;\n /** Shown over the live video, always: the visitor is watching an AI, not a person. */\n badge: string;\n /** The video's accessible name. */\n video: string;\n /** The captions' accessible name. */\n captions: string;\n /** Before the countdown, which is never announced. */\n timeLeft: string;\n stop: string;\n /** Where the browser holds sound back until a tap (Safari, iOS). */\n tapForSound: string;\n /** How a session ended. Announced politely. */\n finished: string;\n stopped: string;\n failed: string;\n interrupted: string;\n /** Under the captions and after a session: the answer itself is still in the conversation. */\n answerInChat: string;\n backToChat: string;\n /** The refusals, one short sentence each, with no numbers in them. */\n busy: string;\n limits: string;\n region: string;\n locale: string;\n paused: string;\n notEligible: string;\n answerClaimed: string;\n}\n\nconst EN: AvatarLiveStrings = {\n checking: \"Checking whether the live avatar is available…\",\n needsAnswer: \"Choose a suggested question in Chat first.\",\n needsAnswerDetail: \"The avatar can read only the first answer aloud.\",\n startNewChat: \"Start a new chat to use the avatar.\",\n startNewChatDetail:\n \"The avatar reads aloud only the first answer in a chat, and only to a suggested question. Start a new chat and choose a suggested question.\",\n start: \"Start live avatar\",\n notNow: \"Not now\",\n opensInNewTab: \"(opens in a new tab)\",\n botCheck: \"Checking your browser…\",\n connecting: \"Connecting to the live avatar…\",\n speaking: \"The avatar is speaking.\",\n badge: \"AI avatar · not a real person\",\n video: \"Live AI avatar video\",\n captions: \"Captions\",\n timeLeft: \"Time left\",\n stop: \"Stop\",\n tapForSound: \"Tap to turn on sound\",\n finished: \"The avatar has finished.\",\n stopped: \"You stopped the avatar.\",\n failed: \"The live avatar couldn't start.\",\n interrupted: \"The live avatar stopped early.\",\n answerInChat: \"The full answer is in Chat.\",\n backToChat: \"Back to Chat\",\n busy: \"The live avatar is busy right now. Please try again in a few minutes.\",\n limits:\n \"The live avatar has reached its limit for now. Please try again later.\",\n region: \"The live avatar isn't offered in your region yet.\",\n locale: \"The live avatar isn't offered in this language yet.\",\n paused: \"The live avatar is paused right now.\",\n notEligible: \"The avatar can read answers to the suggested questions.\",\n answerClaimed: \"The avatar has already read this answer.\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"zh\" is in REVIEWED.\nconst ZH: AvatarLiveStrings = {\n checking: \"正在检查实时虚拟形象是否可用…\",\n needsAnswer: \"请先在聊天中选择一个推荐问题。\",\n needsAnswerDetail: \"虚拟形象只能朗读第一个回答。\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"请开始新的聊天,再使用虚拟形象。\",\n startNewChatDetail:\n \"虚拟形象只朗读一次聊天中的第一个回答,且仅限回答推荐问题。请开始新的聊天,并选择一个推荐问题。\",\n start: \"启动实时虚拟形象\",\n notNow: \"暂不\",\n opensInNewTab: \"(在新标签页中打开)\",\n botCheck: \"正在检查您的浏览器…\",\n connecting: \"正在连接实时虚拟形象…\",\n speaking: \"虚拟形象正在讲话。\",\n badge: \"AI 虚拟形象 · 不是真人\",\n video: \"实时 AI 虚拟形象视频\",\n captions: \"字幕\",\n timeLeft: \"剩余时间\",\n stop: \"停止\",\n tapForSound: \"点按以开启声音\",\n finished: \"虚拟形象已讲完。\",\n stopped: \"您已停止虚拟形象。\",\n failed: \"实时虚拟形象无法启动。\",\n interrupted: \"实时虚拟形象提前停止了。\",\n answerInChat: \"完整回答在聊天中。\",\n backToChat: \"返回聊天\",\n busy: \"实时虚拟形象目前繁忙,请几分钟后再试。\",\n limits: \"实时虚拟形象暂时已达到使用上限,请稍后再试。\",\n region: \"您所在的地区暂不提供实时虚拟形象。\",\n locale: \"此语言暂不提供实时虚拟形象。\",\n paused: \"实时虚拟形象目前已暂停。\",\n notEligible: \"虚拟形象可以朗读推荐问题的回答。\",\n answerClaimed: \"虚拟形象已经朗读过这个回答。\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"hi\" is in REVIEWED.\nconst HI: AvatarLiveStrings = {\n checking: \"जाँच हो रही है कि लाइव अवतार उपलब्ध है या नहीं…\",\n needsAnswer: \"पहले चैट में कोई सुझाया गया प्रश्न चुनें।\",\n needsAnswerDetail: \"अवतार केवल पहला उत्तर ज़ोर से पढ़ सकता है।\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"अवतार का उपयोग करने के लिए नई चैट शुरू करें।\",\n startNewChatDetail:\n \"अवतार किसी चैट का केवल पहला उत्तर ज़ोर से पढ़ता है, और वह भी सुझाए गए प्रश्न का ही। नई चैट शुरू करें और कोई सुझाया गया प्रश्न चुनें।\",\n start: \"लाइव अवतार शुरू करें\",\n notNow: \"अभी नहीं\",\n opensInNewTab: \"(नए टैब में खुलता है)\",\n botCheck: \"आपके ब्राउज़र की जाँच हो रही है…\",\n connecting: \"लाइव अवतार से जुड़ रहे हैं…\",\n speaking: \"अवतार बोल रहा है।\",\n badge: \"AI अवतार · असली व्यक्ति नहीं\",\n video: \"लाइव AI अवतार वीडियो\",\n captions: \"कैप्शन\",\n timeLeft: \"बचा हुआ समय\",\n stop: \"रोकें\",\n tapForSound: \"आवाज़ चालू करने के लिए टैप करें\",\n finished: \"अवतार ने पढ़ना पूरा कर लिया है।\",\n stopped: \"आपने अवतार को रोक दिया।\",\n failed: \"लाइव अवतार शुरू नहीं हो सका।\",\n interrupted: \"लाइव अवतार बीच में ही रुक गया।\",\n answerInChat: \"पूरा उत्तर चैट में है।\",\n backToChat: \"चैट पर वापस जाएँ\",\n busy: \"लाइव अवतार अभी व्यस्त है। कृपया कुछ मिनट बाद फिर कोशिश करें।\",\n limits:\n \"लाइव अवतार अभी अपनी सीमा तक पहुँच गया है। कृपया बाद में फिर कोशिश करें।\",\n region: \"आपके क्षेत्र में लाइव अवतार अभी उपलब्ध नहीं है।\",\n locale: \"इस भाषा में लाइव अवतार अभी उपलब्ध नहीं है।\",\n paused: \"लाइव अवतार अभी रुका हुआ है।\",\n notEligible: \"अवतार सुझाए गए प्रश्नों के उत्तर पढ़ सकता है।\",\n answerClaimed: \"अवतार यह उत्तर पहले ही पढ़ चुका है।\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"es\" is in REVIEWED.\nconst ES: AvatarLiveStrings = {\n checking: \"Comprobando si el avatar en vivo está disponible…\",\n needsAnswer: \"Primero elige una pregunta sugerida en el chat.\",\n needsAnswerDetail:\n \"El avatar solo puede leer en voz alta la primera respuesta.\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"Inicia un chat nuevo para usar el avatar.\",\n startNewChatDetail:\n \"El avatar solo lee en voz alta la primera respuesta de un chat, y solo si es la de una pregunta sugerida. Inicia un chat nuevo y elige una pregunta sugerida.\",\n start: \"Iniciar el avatar en vivo\",\n notNow: \"Ahora no\",\n opensInNewTab: \"(se abre en una pestaña nueva)\",\n botCheck: \"Comprobando tu navegador…\",\n connecting: \"Conectando con el avatar en vivo…\",\n speaking: \"El avatar está hablando.\",\n badge: \"Avatar de IA · no es una persona real\",\n video: \"Vídeo del avatar de IA en vivo\",\n captions: \"Subtítulos\",\n timeLeft: \"Tiempo restante\",\n stop: \"Detener\",\n tapForSound: \"Toca para activar el sonido\",\n finished: \"El avatar ha terminado.\",\n stopped: \"Has detenido el avatar.\",\n failed: \"No se pudo iniciar el avatar en vivo.\",\n interrupted: \"El avatar en vivo se detuvo antes de tiempo.\",\n answerInChat: \"La respuesta completa está en el chat.\",\n backToChat: \"Volver al chat\",\n busy: \"El avatar en vivo está ocupado en este momento. Vuelve a intentarlo en unos minutos.\",\n limits:\n \"El avatar en vivo ha alcanzado su límite por ahora. Vuelve a intentarlo más tarde.\",\n region: \"El avatar en vivo aún no está disponible en tu región.\",\n locale: \"El avatar en vivo aún no está disponible en este idioma.\",\n paused: \"El avatar en vivo está en pausa en este momento.\",\n notEligible: \"El avatar puede leer las respuestas a las preguntas sugeridas.\",\n answerClaimed: \"El avatar ya ha leído esta respuesta.\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed, including its right-to-left layout. Not shown\n// until \"ar\" is in REVIEWED.\nconst AR: AvatarLiveStrings = {\n checking: \"جارٍ التحقق من توفر الأفاتار المباشر…\",\n needsAnswer: \"اختر أولًا سؤالًا مقترحًا في الدردشة.\",\n needsAnswerDetail: \"يمكن للأفاتار قراءة الإجابة الأولى فقط بصوت عالٍ.\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"ابدأ دردشة جديدة لاستخدام الأفاتار.\",\n startNewChatDetail:\n \"يقرأ الأفاتار بصوت عالٍ الإجابة الأولى في الدردشة فقط، وفقط إذا كانت إجابة عن سؤال مقترح. ابدأ دردشة جديدة واختر سؤالًا مقترحًا.\",\n start: \"بدء الأفاتار المباشر\",\n notNow: \"ليس الآن\",\n opensInNewTab: \"(يُفتح في علامة تبويب جديدة)\",\n botCheck: \"جارٍ التحقق من متصفحك…\",\n connecting: \"جارٍ الاتصال بالأفاتار المباشر…\",\n speaking: \"الأفاتار يتحدث الآن.\",\n badge: \"أفاتار بالذكاء الاصطناعي · ليس شخصًا حقيقيًا\",\n video: \"فيديو الأفاتار المباشر بالذكاء الاصطناعي\",\n captions: \"التسميات التوضيحية\",\n timeLeft: \"الوقت المتبقي\",\n stop: \"إيقاف\",\n tapForSound: \"انقر لتشغيل الصوت\",\n finished: \"انتهى الأفاتار.\",\n stopped: \"لقد أوقفت الأفاتار.\",\n failed: \"تعذّر بدء الأفاتار المباشر.\",\n interrupted: \"توقف الأفاتار المباشر قبل أن ينتهي.\",\n answerInChat: \"الإجابة الكاملة موجودة في الدردشة.\",\n backToChat: \"العودة إلى الدردشة\",\n busy: \"الأفاتار المباشر مشغول الآن. يُرجى المحاولة مرة أخرى بعد بضع دقائق.\",\n limits: \"بلغ الأفاتار المباشر حدّه في الوقت الحالي. يُرجى المحاولة لاحقًا.\",\n region: \"الأفاتار المباشر غير متاح في منطقتك بعد.\",\n locale: \"الأفاتار المباشر غير متاح بهذه اللغة بعد.\",\n paused: \"الأفاتار المباشر متوقف مؤقتًا الآن.\",\n notEligible: \"يمكن للأفاتار قراءة إجابات الأسئلة المقترحة.\",\n answerClaimed: \"قرأ الأفاتار هذه الإجابة من قبل.\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"ta\" is in REVIEWED.\nconst TA: AvatarLiveStrings = {\n checking: \"நேரலை அவதார் கிடைக்கிறதா எனச் சரிபார்க்கிறது…\",\n needsAnswer:\n \"முதலில் அரட்டையில் பரிந்துரைக்கப்பட்ட ஒரு கேள்வியைத் தேர்ந்தெடுக்கவும்.\",\n needsAnswerDetail: \"அவதார் முதல் பதிலை மட்டுமே உரக்கப் படிக்க முடியும்.\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"அவதாரைப் பயன்படுத்த புதிய அரட்டையைத் தொடங்கவும்.\",\n startNewChatDetail:\n \"ஓர் அரட்டையின் முதல் பதிலை மட்டுமே, அதுவும் பரிந்துரைக்கப்பட்ட கேள்விக்கான பதிலை மட்டுமே அவதார் உரக்கப் படிக்கும். புதிய அரட்டையைத் தொடங்கி, பரிந்துரைக்கப்பட்ட ஒரு கேள்வியைத் தேர்ந்தெடுக்கவும்.\",\n start: \"நேரலை அவதாரைத் தொடங்கு\",\n notNow: \"இப்போது வேண்டாம்\",\n opensInNewTab: \"(புதிய தாவலில் திறக்கும்)\",\n botCheck: \"உங்கள் உலாவியைச் சரிபார்க்கிறது…\",\n connecting: \"நேரலை அவதாருடன் இணைக்கிறது…\",\n speaking: \"அவதார் பேசுகிறது.\",\n badge: \"AI அவதார் · உண்மையான நபர் அல்ல\",\n video: \"நேரலை AI அவதார் வீடியோ\",\n captions: \"வசனங்கள்\",\n timeLeft: \"மீதமுள்ள நேரம்\",\n stop: \"நிறுத்து\",\n tapForSound: \"ஒலியை இயக்கத் தட்டவும்\",\n finished: \"அவதார் படித்து முடித்தது.\",\n stopped: \"நீங்கள் அவதாரை நிறுத்தினீர்கள்.\",\n failed: \"நேரலை அவதாரைத் தொடங்க முடியவில்லை.\",\n interrupted: \"நேரலை அவதார் இடையிலேயே நின்றுவிட்டது.\",\n answerInChat: \"முழுப் பதில் அரட்டையில் உள்ளது.\",\n backToChat: \"அரட்டைக்குத் திரும்பு\",\n busy: \"நேரலை அவதார் இப்போது வேறு பயன்பாட்டில் உள்ளது. சில நிமிடங்களில் மீண்டும் முயலவும்.\",\n limits:\n \"நேரலை அவதார் தற்போதைக்குத் தன் வரம்பை எட்டிவிட்டது. பிறகு மீண்டும் முயலவும்.\",\n region: \"உங்கள் பகுதியில் நேரலை அவதார் இன்னும் கிடைக்கவில்லை.\",\n locale: \"இந்த மொழியில் நேரலை அவதார் இன்னும் கிடைக்கவில்லை.\",\n paused: \"நேரலை அவதார் இப்போது இடைநிறுத்தப்பட்டுள்ளது.\",\n notEligible:\n \"பரிந்துரைக்கப்பட்ட கேள்விகளுக்கான பதில்களை அவதார் படிக்க முடியும்.\",\n answerClaimed: \"இந்தப் பதிலை அவதார் ஏற்கெனவே படித்துவிட்டது.\",\n};\n\nconst STRINGS: Record<ExploreLocale, AvatarLiveStrings> = {\n en: EN,\n zh: ZH,\n hi: HI,\n es: ES,\n ar: AR,\n ta: TA,\n};\n\nexport function avatarLiveStrings(locale: ExploreLocale): AvatarLiveStrings {\n return STRINGS[locale] ?? EN;\n}\n\n/** One version of the consent card's copy, in one locale. */\nexport interface AvatarConsentCopy {\n title: string;\n /** What the avatar is and does, for a site with a product name. Takes `{product}`. */\n introProduct: string;\n /** The same without a product name. */\n intro: string;\n /** Who processes what when the visitor starts. */\n processing: string;\n /** What is and is not used, recorded and kept, and who it is for. */\n storage: string;\n /** The link to the site's privacy notice, `/privacy#live-avatar`. */\n privacyLink: string;\n}\n\n/**\n * The consent copy the server's `consentVersion` names, by version and then by locale. A version is added here, never\n * edited: changed wording is a new version, which the server starts asking for at the same time.\n */\nconst CONSENT: ReadonlyMap<\n string,\n Readonly<Partial<Record<ExploreLocale, AvatarConsentCopy>>>\n> = new Map([\n [\n \"web-consent-2026-11\",\n {\n en: {\n title: \"Live AI avatar (beta)\",\n introProduct:\n \"This is an AI avatar, not a real person. It reads the assistant's first eligible answer to a suggested {product} question aloud for up to a minute. The answer is AI-generated and can be wrong.\",\n intro:\n \"This is an AI avatar, not a real person. It reads the assistant's first eligible answer to a suggested question aloud for up to a minute. The answer is AI-generated and can be wrong.\",\n processing:\n \"When you start, Cloudflare checks for bots. The answer text goes to Google to create the voice. Your browser connects to LiveKit, which sees your IP address. LiveKit fetches our temporary audio file and passes the voice to Protoface, which makes the avatar video streamed through LiveKit.\",\n storage:\n \"Your microphone and camera are not used. We do not record the live session. We temporarily store the generated voice file and keep a record of this consent. The privacy notice explains our safeguards, storage periods and the providers' processing. For people aged eighteen and over.\",\n privacyLink: \"How we handle this\",\n },\n },\n ],\n]);\n\n/** The consent copy for exactly `version` in `locale`, or null when the SDK has none to show for it. */\nexport function avatarConsentCopy(\n version: string,\n locale: ExploreLocale,\n): AvatarConsentCopy | null {\n if (!isAvatarLiveLocaleReviewed(locale)) return null;\n return CONSENT.get(version)?.[locale] ?? null;\n}\n","/**\n * BOFF-9797. Cloudflare Turnstile, for the live avatar's start only.\n *\n * Nothing here runs until the visitor presses Start on the live avatar's consent card: the script is added to the page\n * then, once, and a widget is rendered for that one start (action `avatar_start`). The widget stays invisible unless\n * Cloudflare needs the visitor to interact with it. The token it returns goes to the gateway in a header and is used\n * once.\n *\n * The widget is rendered with `cData`, the binding of this check to the create request it is for (web API contract\n * v1.1: see `avatarBotBinding` in `explore-avatar-api.ts`), so it cannot be rendered before the binding is known.\n */\n\nconst SCRIPT_SRC =\n \"https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit\";\n/** How long the script may take to load before the start is given up. */\nconst SCRIPT_TIMEOUT_MS = 15_000;\n\n/** The part of Turnstile's render options used here. */\ninterface TurnstileRenderOptions {\n sitekey: string;\n action: string;\n /** Customer data Turnstile returns with the verified token: the binding to the create request. */\n cData: string;\n appearance: \"interaction-only\";\n size: \"flexible\";\n \"response-field\": false;\n callback: (token: string) => void;\n \"error-callback\": () => boolean;\n \"expired-callback\": () => void;\n \"timeout-callback\": () => void;\n}\n\n/** The part of `window.turnstile` used here. */\ninterface TurnstileApi {\n render: (\n container: HTMLElement,\n options: TurnstileRenderOptions,\n ) => string | null | undefined;\n remove: (widgetId: string) => void;\n}\n\nfunction readApi(): TurnstileApi | null {\n if (typeof window === \"undefined\") return null;\n const api = (window as unknown as { turnstile?: Partial<TurnstileApi> })\n .turnstile;\n return api &&\n typeof api.render === \"function\" &&\n typeof api.remove === \"function\"\n ? (api as TurnstileApi)\n : null;\n}\n\nlet loading: Promise<TurnstileApi> | null = null;\n\n/** Turnstile's API, adding its script to the page the first time. A failed load can be tried again later. */\nexport function loadTurnstile(): Promise<TurnstileApi> {\n const ready = readApi();\n if (ready) return Promise.resolve(ready);\n if (loading) return loading;\n loading = new Promise<TurnstileApi>((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = SCRIPT_SRC;\n script.async = true;\n script.setAttribute(\"data-boff-explore\", \"avatar-live-turnstile\");\n const fail = () => {\n clearTimeout(timer);\n loading = null;\n script.remove();\n reject(new Error(\"The bot check could not be loaded.\"));\n };\n const timer = setTimeout(fail, SCRIPT_TIMEOUT_MS);\n script.addEventListener(\"load\", () => {\n const api = readApi();\n if (!api) {\n fail();\n return;\n }\n clearTimeout(timer);\n resolve(api);\n });\n script.addEventListener(\"error\", fail);\n document.head.appendChild(script);\n });\n return loading;\n}\n\nexport interface TurnstileRun {\n /** The token, once Cloudflare has one; rejects when the check fails, expires, times out or is cancelled. */\n token: Promise<string>;\n /** Remove the widget, and reject `token` if it is still waiting. Safe to call more than once. */\n cancel: () => void;\n}\n\n/**\n * Run one bot check in `container` with `siteKey`, for `action`, bound to `cData` (or to what it resolves to: the widget\n * is rendered once its script has loaded AND the binding is known, and a binding that cannot be made fails the check).\n */\nexport function runTurnstile(\n container: HTMLElement | null,\n siteKey: string,\n action: string,\n cData: string | Promise<string>,\n): TurnstileRun {\n // A binding that cannot be made fails `token`; it is never an unhandled rejection of its own.\n Promise.resolve(cData).catch(() => undefined);\n let settled = false;\n let cancelled = false;\n let widget: { api: TurnstileApi; id: string } | null = null;\n let rejectToken: (error: Error) => void = () => undefined;\n\n const removeWidget = () => {\n if (!widget) return;\n const { api, id } = widget;\n widget = null;\n try {\n api.remove(id);\n } catch {\n // Already gone with its container.\n }\n };\n\n const token = new Promise<string>((resolve, reject) => {\n rejectToken = (error: Error) => {\n if (settled) return;\n settled = true;\n reject(error);\n };\n if (!container) {\n rejectToken(new Error(\"No place for the bot check.\"));\n return;\n }\n Promise.all([loadTurnstile(), cData]).then(\n ([api, binding]) => {\n if (cancelled || settled) return;\n const failed = () => {\n removeWidget();\n rejectToken(new Error(\"The bot check did not pass.\"));\n };\n const id = api.render(container, {\n sitekey: siteKey,\n action,\n cData: binding,\n appearance: \"interaction-only\",\n size: \"flexible\",\n \"response-field\": false,\n callback: (value: string) => {\n if (settled) return;\n settled = true;\n resolve(value);\n },\n \"error-callback\": () => {\n failed();\n // Handled here: Turnstile need not report it again.\n return true;\n },\n \"expired-callback\": failed,\n \"timeout-callback\": failed,\n });\n if (typeof id === \"string\" && id !== \"\") {\n widget = { api, id };\n if (settled) removeWidget();\n } else if (!settled) {\n rejectToken(new Error(\"The bot check could not start.\"));\n }\n },\n (error: unknown) => {\n rejectToken(\n error instanceof Error\n ? error\n : new Error(\"The bot check could not be loaded.\"),\n );\n },\n );\n });\n\n // A cancelled check nobody waits on any more is not an error worth reporting.\n token.catch(() => undefined);\n\n return {\n token,\n cancel: () => {\n cancelled = true;\n removeWidget();\n rejectToken(new Error(\"The bot check was cancelled.\"));\n },\n };\n}\n","/**\n * Substitute `{product}` and friends without pulling in a formatting library.\n *\n * A module of its own so the live avatar's view, which is loaded on its own (see `explore-avatar-live.tsx`), can use\n * it without carrying `explore-i18n.ts`, the panel's strings. `explore-i18n.ts` re-exports it.\n */\nexport function fill(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key) => values[key] ?? match);\n}\n","/**\n * Utility function to merge Tailwind CSS classes\n * Combines clsx and tailwind-merge for optimal class handling\n */\n\nimport { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge multiple class names intelligently\n * - Handles conditional classes via clsx\n * - Deduplicates and resolves Tailwind conflicts via tailwind-merge\n *\n * @example\n * ```ts\n * cn('px-4 py-2', 'bg-blue-500', { 'text-white': isActive })\n * // => 'px-4 py-2 bg-blue-500 text-white' (if isActive is true)\n * ```\n */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","/**\n * AvatarLiveView — the Avatar tab's live avatar (BOFF-9797), opt-in: its view and its state machine.\n *\n * `ExploreAvatarLive` (`explore-avatar-live.tsx`) renders this, and only once the Avatar view has been opened on a panel\n * whose host passes `avatar.live`. This file, and the requests, the words and the bot check it brings with it, is a\n * chunk of its own that a site downloads at that moment and not before; a site that never passes `avatar.live` never\n * does. It reads nothing from the page's React contexts (the package builds each entry on its own, so a context read\n * here would be a second, empty one): everything it needs comes in as props from `ExploreAvatarLive`.\n *\n * The visitor watches and listens; their browser never sends the avatar anything to say. What happens, in order:\n *\n * 1. **The tab opens** (never on page load): one availability request to the gateway's web branch. Nothing else is\n * loaded or asked for until the visitor agrees.\n * 2. **Offered, with the conversation's first answer:** a consent card (its copy is versioned; the panel shows only\n * copy written for the version the server names), Start, Not now and a link to the privacy notice. The avatar reads\n * one answer only: a conversation that is exactly a suggested question and its completed answer. A failed first\n * answer, or a second question, asks the visitor to start a new chat instead.\n * 3. **Start:** the live module (`live.load`) and the bot check load, then one create request: the contract's six\n * fields, an `Idempotency-Key` and the bot check's token, without credentials. The bot check is bound to that very\n * request (`cData`, contract v1.1), so the body is made once, before the widget is rendered.\n * 4. **Created:** the room is joined to watch only. The avatar's video, its captions, a badge saying it is an AI and\n * not a person, a countdown (never announced), Stop and Continue in Chat.\n * 5. **Ending:** Stop, leaving the tab, closing the panel or hiding the page asks the server to end the session with a\n * `keepalive` request. The server ends it on its own deadlines either way.\n *\n * Any refusal is one short sentence and \"Continue in Chat\". A route that is not there, a refused origin or a network\n * failure shows the tab as it was before the live avatar. The conversation token goes into the create request and\n * nowhere else; the session's secret and room token are kept in refs, never in the page.\n */\n\"use client\";\n\nimport {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\n\nimport {\n avatarBotBinding,\n canBindBotCheck,\n isAvatarConversationToken,\n isAvatarMessageId,\n newIdempotencyKey,\n requestAvailability,\n requestCreate,\n sendEnd,\n type AvatarCreateBody,\n type AvatarCreateResult,\n type AvatarEndReason,\n type AvatarOffer,\n type AvatarRefusal,\n type AvatarSession,\n} from \"./explore-avatar-api\";\nimport {\n avatarConsentCopy,\n avatarLiveStrings,\n type AvatarConsentCopy,\n type AvatarLiveStrings,\n} from \"./explore-avatar-i18n\";\nimport { runTurnstile, type TurnstileRun } from \"./explore-avatar-turnstile\";\nimport { fill } from \"./explore-fill\";\nimport { cn } from \"../utils/cn\";\n\nimport type {\n AvatarConversation,\n ExplorePanelAvatarLive,\n} from \"./explore-avatar-live-config\";\nimport type { ExploreLocale } from \"./explore-i18n\";\nimport type { ExploreMessage } from \"./explore-types\";\nimport type {\n AvatarLiveModule,\n ReceiveOnlyEvent,\n ReceiveOnlySession,\n} from \"../avatar-live/types\";\n\n/** Where the consent card's privacy link goes: the site's privacy notice, at its live avatar section. */\nconst PRIVACY_HREF = \"/privacy#live-avatar\";\n\n/** How long a joined room waits for the avatar's video before the session is given up. */\nconst SPEAKER_WAIT_MS = 30_000;\n/** Past a session's end, how long before the browser leaves a room that is somehow still open. */\nconst END_GRACE_MS = 10_000;\n/** How far the server's end may sit from this browser's clock before the browser counts down on its own clock. */\nconst CLOCK_TOLERANCE_MS = 5_000;\n\n/** The control each step puts focus on when the one the visitor was on has gone. */\nconst PRIMARY =\n '[data-avatar-primary], [data-boff-explore=\"panel-continue-chat\"]';\n\ninterface Offer extends AvatarOffer {\n /** The locale availability was asked for: the consent copy shown and the create request are both in this one. */\n locale: ExploreLocale;\n copy: AvatarConsentCopy;\n}\n\n/** What the page shows of a session: never its secret or its room token. */\ninterface ShownSession {\n /** When this browser counts the session as over, on its own clock. */\n endsAt: number;\n captions: { locale: string; text: string };\n}\n\ntype EndedHow = \"finished\" | \"stopped\" | \"failed\" | \"interrupted\";\n\ntype Phase =\n | { name: \"idle\" }\n | { name: \"checking\" }\n | { name: \"inert\" }\n | { name: \"needs-answer\"; offer: Offer }\n | { name: \"consent\"; offer: Offer; messageId: string }\n | { name: \"refused\"; reason: AvatarRefusal }\n | { name: \"bot-check\"; offer: Offer; messageId: string }\n | { name: \"creating\" }\n | { name: \"pending\"; session: ShownSession }\n | { name: \"live\"; session: ShownSession }\n | { name: \"ended\"; how: EndedHow };\n\nconst IDLE: Phase = { name: \"idle\" };\nconst INERT: Phase = { name: \"inert\" };\n\n/** One press of Start, until its create request has answered. */\ninterface StartRun {\n /** Set when the visitor (or the page) gave up on it, with the reason to end a session it still creates. */\n cancelled: AvatarEndReason | null;\n turnstile: TurnstileRun | null;\n}\n\n/** A created session, from its 201 until it ends. */\ninterface SessionHandle {\n session: AvatarSession;\n base: string;\n headers: Readonly<Record<string, string>>;\n module: AvatarLiveModule;\n /** The join, once started. */\n room: Promise<ReceiveOnlySession | null> | null;\n /** The joined room, once joined: `enablePlayback` must be called inside the visitor's tap, so not via a promise. */\n joined: ReceiveOnlySession | null;\n /** When this browser counts the session as over, on its own clock (see `begin`). */\n endsAt: number;\n /** The avatar's video has arrived. */\n speakerArrived: boolean;\n done: boolean;\n}\n\nconst REFUSAL_TEXT: Record<AvatarRefusal, keyof AvatarLiveStrings> = {\n busy: \"busy\",\n limits: \"limits\",\n region: \"region\",\n locale: \"locale\",\n paused: \"paused\",\n not_eligible: \"notEligible\",\n answer_claimed: \"answerClaimed\",\n};\n\n/** What the conversation offers the avatar to read. */\ninterface Exchange {\n /** The answer the avatar may read, or null. */\n answerId: string | null;\n /**\n * The conversation can never be read: its first answer failed or is unusable, or it has gone past the first\n * exchange. Only a new chat can be. False while there is simply nothing to read yet.\n */\n startOver: boolean;\n}\n\nconst WAITING: Exchange = { answerId: null, startOver: false };\nconst START_OVER: Exchange = { answerId: null, startOver: true };\n\n/**\n * The one answer the avatar may read, and why there is none. The avatar service accepts a conversation only when it\n * holds EXACTLY two messages: the first USER message (a suggested question) and the first ASSISTANT answer, COMPLETED.\n * This is the same rule, so the avatar is never offered, and the visitor never goes through consent and the bot check,\n * for a conversation the service would refuse:\n *\n * - exactly that exchange: its answer;\n * - nothing asked yet, or the question asked and its answer still on its way: nothing yet (the view says to choose a\n * suggested question, and offers the avatar once the answer completes);\n * - anything else (a failed or empty first answer, a second question, whatever came after a failed answer asked\n * again without Retry): never, in this conversation (the view says to start a new chat).\n *\n * That the question is one of the suggested ones is the service's to judge (`not_eligible`), not the browser's.\n */\nfunction firstExchange(\n messages: readonly ExploreMessage[] | undefined,\n): Exchange {\n if (!messages || messages.length === 0) return WAITING;\n if (messages.length > 2) return START_OVER;\n const [question, answer] = messages;\n if (question?.role !== \"USER\") return START_OVER;\n if (answer === undefined) return WAITING;\n if (answer.role !== \"ASSISTANT\") return START_OVER;\n if (answer.status === \"PENDING\" || answer.status === \"RUNNING\") {\n return WAITING;\n }\n if (\n answer.status !== \"COMPLETED\" ||\n answer.content.trim() === \"\" ||\n !isAvatarMessageId(answer.id)\n ) {\n return START_OVER;\n }\n return { answerId: answer.id, startOver: false };\n}\n\n/**\n * The step that offers `messageId` to the visitor: the consent card, unless this visit has already used that answer\n * (`claimed` holds every answer a session was created for, or that the server said it already has one for), in which\n * case it says so instead. The ways back to a consent card for an answer that may have been used in the meantime go\n * through here: the availability answer, and returning from a bot check.\n */\nfunction offering(\n offer: Offer,\n messageId: string,\n claimed: ReadonlySet<string>,\n): Phase {\n return claimed.has(messageId)\n ? { name: \"refused\", reason: \"answer_claimed\" }\n : { name: \"consent\", offer, messageId };\n}\n\nasync function loadModule(\n load: () => Promise<AvatarLiveModule>,\n): Promise<AvatarLiveModule> {\n const loaded: unknown = await load();\n const join =\n loaded !== null && typeof loaded === \"object\"\n ? (loaded as Partial<AvatarLiveModule>).joinReceiveOnly\n : undefined;\n if (typeof join !== \"function\") {\n throw new Error(\"The live avatar module could not be loaded.\");\n }\n return loaded as AvatarLiveModule;\n}\n\n/** `m:ss`. */\nfunction clock(seconds: number): string {\n const whole = Math.max(0, Math.ceil(seconds));\n return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, \"0\")}`;\n}\n\nexport interface AvatarLiveViewProps {\n live: ExplorePanelAvatarLive;\n /** The Avatar view is showing: the panel is open and its Avatar tab is selected. */\n active: boolean;\n locale: ExploreLocale;\n /** The product the panel speaks for, when it is one product's own; null on the portfolio's. */\n productName: string | null;\n /** The approved still picture. */\n still: { src: string; alt: string };\n /** The Avatar tab as it was before the live avatar: shown whenever the live avatar is not offered or not reachable. */\n fallback: ReactNode;\n /** Back to the Chat tab. Leaving the Avatar tab ends a session, like any other way out of it. */\n onContinueInChat: () => void;\n /** \"Continue in Chat\" in the panel's language: the panel's own word for it, so this chunk carries none of the panel's. */\n continueInChat: string;\n /**\n * Nothing to ask the server about: an incomplete config, no gateway, no shared conversation to read (no provider, or a\n * read-only shared one), or a locale whose strings have not been reviewed. The tab stays as it was. Decided by\n * `ExploreAvatarLive`, which also decides whether this view is loaded at all; it can change while this view is\n * mounted (the panel's locale switching), and what is under way then ends.\n */\n off: boolean;\n /** {@link avatarApiBase} of the SDK's gateway, null when there is none to use. */\n base: string | null;\n /** Headers every request carries: the alpha gateway's access headers, and nothing on production. */\n headers: Readonly<Record<string, string>>;\n /** The panel's conversation, null when there is no provider. */\n conversation: AvatarConversation | null;\n}\n\nexport function AvatarLiveView({\n live,\n active,\n locale,\n productName,\n still,\n fallback,\n onContinueInChat,\n continueInChat,\n off,\n base,\n headers,\n conversation,\n}: AvatarLiveViewProps) {\n const S = avatarLiveStrings(locale);\n const uid = useId();\n const consentTitleId = `${uid}-consent`;\n\n const { answerId, startOver } = firstExchange(conversation?.messages);\n\n const [phase, setPhase] = useState<Phase>(IDLE);\n const [blocked, setBlocked] = useState(false);\n const [now, setNow] = useState(() => Date.now());\n\n const phaseRef = useRef<Phase>(IDLE);\n /** This render's view of everything the asynchronous steps read, so they never act on a stale one. */\n const latest = useRef({ live, locale, base, headers, answerId, off });\n latest.current = { live, locale, base, headers, answerId, off };\n const conversationRef = useRef(conversation);\n conversationRef.current = conversation;\n\n const checkRef = useRef<AbortController | null>(null);\n /**\n * The locale the last availability question was asked for (or settled without asking): a later change of locale asks\n * again (see the effect on `locale`), and a view that has just asked for the new locale does not ask twice.\n */\n const askedLocale = useRef(locale);\n const startRef = useRef<StartRun | null>(null);\n const sessionRef = useRef<SessionHandle | null>(null);\n /**\n * Every answer whose session this visit has already created (or found already read): none of them is offered again.\n * A set and not the latest one: a create the visitor gave up on can answer long after they moved to another chat and\n * used its first answer, and what it reports is added to what is known, never put in its place.\n */\n const claimedRef = useRef<Set<string>>(new Set());\n\n const rootRef = useRef<HTMLDivElement>(null);\n const videoRef = useRef<HTMLVideoElement>(null);\n const audioRef = useRef<HTMLAudioElement>(null);\n const botBoxRef = useRef<HTMLDivElement>(null);\n\n const go = useCallback((next: Phase) => {\n phaseRef.current = next;\n setPhase(next);\n }, []);\n\n /** End the session: tell the server (unless it ended it), leave the room, and show how it ended. */\n const finish = useCallback(\n (how: EndedHow, reason: AvatarEndReason | null) => {\n const handle = sessionRef.current;\n if (!handle || handle.done) return;\n handle.done = true;\n sessionRef.current = null;\n if (reason !== null) {\n sendEnd({\n base: handle.base,\n headers: handle.headers,\n sessionId: handle.session.sessionId,\n secret: handle.session.endSecret,\n reason,\n });\n }\n const room = handle.joined;\n handle.joined = null;\n if (room) void room.leave().catch(() => undefined);\n setBlocked(false);\n go({ name: \"ended\", how });\n },\n [go],\n );\n\n /** Give up on a Start still on its way to a session. A session it still creates is ended with `reason`. */\n const cancelStart = useCallback((reason: AvatarEndReason) => {\n const run = startRef.current;\n if (!run) return;\n startRef.current = null;\n run.cancelled = reason;\n run.turnstile?.cancel();\n }, []);\n\n const check = useCallback(() => {\n const { live, locale, base, headers, off } = latest.current;\n checkRef.current?.abort();\n checkRef.current = null;\n askedLocale.current = locale;\n if (off || base === null) {\n go(INERT);\n return;\n }\n const controller = new AbortController();\n checkRef.current = controller;\n go({ name: \"checking\" });\n void requestAvailability({\n base,\n headers,\n site: live.site,\n locale,\n signal: controller.signal,\n }).then((result) => {\n if (checkRef.current !== controller) return;\n checkRef.current = null;\n if (result.kind === \"inert\") {\n go(INERT);\n return;\n }\n if (result.kind === \"refused\") {\n go({ name: \"refused\", reason: result.reason });\n return;\n }\n // The copy for the version the server named, in the locale it was asked about (a later locale change asks\n // again: see the effect on `locale`).\n const copy = avatarConsentCopy(result.offer.consentVersion, locale);\n // A consent version this SDK has no reviewed copy for: no card, rather than words the server does not record.\n if (copy === null) {\n go(INERT);\n return;\n }\n const offer: Offer = { ...result.offer, locale, copy };\n const messageId = latest.current.answerId;\n go(\n messageId === null\n ? { name: \"needs-answer\", offer }\n : offering(offer, messageId, claimedRef.current),\n );\n });\n }, [go]);\n\n const begin = useCallback(\n (\n session: AvatarSession,\n module: AvatarLiveModule,\n offer: Offer,\n target: { base: string; headers: Readonly<Record<string, string>> },\n ) => {\n // Count down on the server's end when this browser's clock agrees with it, else on this browser's own clock.\n const received = Date.now();\n const longest = offer.maxSessionSeconds * 1000;\n const ahead = session.endsAt - received;\n const endsAt =\n ahead > 0 && ahead <= longest + CLOCK_TOLERANCE_MS\n ? session.endsAt\n : received + longest;\n sessionRef.current = {\n session,\n base: target.base,\n headers: target.headers,\n module,\n room: null,\n joined: null,\n endsAt,\n speakerArrived: false,\n done: false,\n };\n setBlocked(false);\n setNow(received);\n go({\n name: \"pending\",\n session: { endsAt, captions: session.captions },\n });\n },\n [go],\n );\n\n const settle = useCallback(\n (\n result: AvatarCreateResult,\n run: StartRun,\n context: {\n module: AvatarLiveModule;\n offer: Offer;\n messageId: string;\n base: string;\n headers: Readonly<Record<string, string>>;\n },\n ) => {\n const created =\n result.kind === \"created\"\n ? {\n sessionId: result.session.sessionId,\n secret: result.session.endSecret,\n }\n : result.kind === \"unusable\"\n ? { sessionId: result.sessionId, secret: result.endSecret }\n : null;\n // A session now exists for this answer (this create made it, or the server says an earlier one did): it is used.\n const claimed =\n created !== null ||\n (result.kind === \"refused\" && result.reason === \"answer_claimed\");\n if (claimed) claimedRef.current.add(context.messageId);\n if (run.cancelled !== null) {\n // Given up while the request was on its way: a session it created is ended at once.\n if (created !== null) {\n sendEnd({\n base: context.base,\n headers: context.headers,\n sessionId: created.sessionId,\n secret: created.secret,\n reason: run.cancelled,\n });\n }\n // The visitor may be back on the consent card for this very answer by now (they left during the create and came\n // back before it answered): it has been read, so the card gives way to saying so rather than offering it again.\n const shown = phaseRef.current;\n if (\n claimed &&\n shown.name === \"consent\" &&\n shown.messageId === context.messageId\n ) {\n go({ name: \"refused\", reason: \"answer_claimed\" });\n }\n return;\n }\n switch (result.kind) {\n case \"created\":\n begin(result.session, context.module, context.offer, context);\n return;\n case \"unusable\":\n sendEnd({\n base: context.base,\n headers: context.headers,\n sessionId: result.sessionId,\n secret: result.endSecret,\n reason: \"client_error\",\n });\n go({ name: \"ended\", how: \"failed\" });\n return;\n case \"refused\":\n go({ name: \"refused\", reason: result.reason });\n return;\n case \"consent\":\n // The consent version moved on: ask again, and show the consent that is current now.\n check();\n return;\n case \"inert\":\n go(INERT);\n return;\n case \"failed\":\n go({ name: \"ended\", how: \"failed\" });\n return;\n }\n },\n [begin, check, go],\n );\n\n const start = useCallback(() => {\n const current = phaseRef.current;\n if (current.name !== \"consent\") return;\n const { live, base, headers } = latest.current;\n if (base === null) return;\n // No WebCrypto (a page that is not a secure context): the bot check cannot be bound to a create request, so no live\n // avatar can start here. Nothing is loaded for a start that cannot happen (no module, no bot-check script), and the\n // tab stays as it was.\n if (!canBindBotCheck()) {\n go(INERT);\n return;\n }\n const { offer, messageId } = current;\n // The create request's values, read once, here. The bot check is bound to exactly these (`avatarBotBinding`, before\n // its widget is rendered), so the request that follows it carries this same body and reads nothing again.\n const conversationToken =\n conversationRef.current?.getConversationToken() ?? null;\n const idempotencyKey = newIdempotencyKey();\n if (\n conversationToken === null ||\n !isAvatarConversationToken(conversationToken) ||\n idempotencyKey === null\n ) {\n // Nothing to create a session for: no module, no bot check.\n go({ name: \"ended\", how: \"failed\" });\n return;\n }\n const body: AvatarCreateBody = {\n site: live.site,\n locale: offer.locale,\n conversationToken,\n messageId,\n consentVersion: offer.consentVersion,\n manifestVersion: live.manifestVersion,\n };\n const run: StartRun = { cancelled: null, turnstile: null };\n startRef.current = run;\n go({ name: \"bot-check\", offer, messageId });\n // Only now that the visitor has agreed: the live module and the bot check.\n const module = loadModule(live.load);\n const turnstile = runTurnstile(\n botBoxRef.current,\n live.turnstileSiteKey,\n \"avatar_start\",\n avatarBotBinding(body),\n );\n run.turnstile = turnstile;\n void (async () => {\n let loaded: AvatarLiveModule;\n let botToken: string;\n try {\n [loaded, botToken] = await Promise.all([module, turnstile.token]);\n } catch {\n turnstile.cancel();\n if (run.cancelled === null) {\n startRef.current = null;\n go(INERT);\n }\n return;\n }\n // The widget has done its work.\n turnstile.cancel();\n if (run.cancelled !== null) return;\n go({ name: \"creating\" });\n const result = await requestCreate({\n base,\n headers,\n idempotencyKey,\n botToken,\n body,\n });\n if (startRef.current === run) startRef.current = null;\n settle(result, run, { module: loaded, offer, messageId, base, headers });\n })();\n }, [go, settle]);\n\n /** The visitor's Stop, at any step from Start on. */\n const stop = useCallback(() => {\n const current = phaseRef.current;\n if (current.name === \"bot-check\") {\n // Nothing was created: back to the consent card.\n cancelStart(\"user\");\n go(offering(current.offer, current.messageId, claimedRef.current));\n return;\n }\n if (current.name === \"creating\") {\n cancelStart(\"user\");\n go({ name: \"ended\", how: \"stopped\" });\n return;\n }\n if (current.name === \"pending\" || current.name === \"live\") {\n finish(\"stopped\", \"user\");\n }\n }, [cancelStart, finish, go]);\n\n /**\n * Leaving the Avatar view (`user`: another tab, the panel closing, or the live avatar going off) and hiding the page\n * (`page_hide`) both end what is under way. Leaving the view drops an availability check too (opening the view asks\n * again); hiding the page keeps one, and returns a bot check to the consent card, so the view is as the visitor left\n * it when they come back.\n */\n const leave = useCallback(\n (reason: \"user\" | \"page_hide\") => {\n const current = phaseRef.current;\n const how: EndedHow = reason === \"user\" ? \"stopped\" : \"interrupted\";\n switch (current.name) {\n case \"checking\": {\n if (reason !== \"user\") return;\n const controller = checkRef.current;\n checkRef.current = null;\n controller?.abort();\n go(IDLE);\n return;\n }\n case \"bot-check\":\n cancelStart(reason);\n go(\n reason === \"user\"\n ? IDLE\n : offering(current.offer, current.messageId, claimedRef.current),\n );\n return;\n case \"creating\":\n cancelStart(reason);\n go({ name: \"ended\", how });\n return;\n case \"pending\":\n case \"live\":\n finish(how, reason);\n return;\n default:\n return;\n }\n },\n [cancelStart, finish, go],\n );\n\n // The Avatar view showing, and hiding. Opening it asks again, except where this visit has already used the answer.\n //\n // The live view is also hidden while `off` puts the fallback in its place (the panel's locale switching to one whose\n // strings have not been reviewed, say). That unmounts the video and audio elements a room is attached to and takes\n // Stop away, so whatever is under way ends as it does when the visitor leaves the view: a bot check is called off, a\n // create in flight is ended once it answers, a session is ended and its room left. Coming back asks again.\n const showing = active && !off;\n useEffect(() => {\n if (!showing) {\n leave(\"user\");\n return;\n }\n const current = phaseRef.current;\n const { answerId: offered } = latest.current;\n const used = offered !== null && claimedRef.current.has(offered);\n if (current.name === \"ended\" && used) return;\n if (\n current.name === \"refused\" &&\n current.reason === \"answer_claimed\" &&\n used\n ) {\n return;\n }\n if (\n current.name === \"idle\" ||\n current.name === \"inert\" ||\n current.name === \"refused\" ||\n current.name === \"needs-answer\" ||\n current.name === \"consent\" ||\n current.name === \"ended\" ||\n // Asking, with nothing actually asking: React's strict mode unmounts and mounts a component again with the state it\n // left, and the unmount in between dropped the question. (This view mounts already showing, the first time the\n // Avatar view opens.)\n (current.name === \"checking\" && checkRef.current === null)\n ) {\n check();\n }\n }, [showing, check, leave]);\n\n // The panel's locale changing before Start: an availability answer, and the consent copy chosen for it, belong to the\n // locale they were asked about, so the view asks again (or, hidden, starts over when it next opens). A session already\n // under way keeps its own.\n useEffect(() => {\n if (askedLocale.current === locale) return;\n askedLocale.current = locale;\n const current = phaseRef.current.name;\n if (\n current !== \"checking\" &&\n current !== \"needs-answer\" &&\n current !== \"consent\" &&\n current !== \"refused\" &&\n current !== \"inert\"\n ) {\n return;\n }\n if (active) {\n check();\n } else {\n checkRef.current?.abort();\n checkRef.current = null;\n go(IDLE);\n }\n }, [active, check, go, locale]);\n\n // The first answer arriving (it may complete while the Avatar view shows), or the conversation starting over.\n useEffect(() => {\n const current = phaseRef.current;\n if (current.name === \"needs-answer\" && answerId !== null) {\n go({ name: \"consent\", offer: current.offer, messageId: answerId });\n } else if (current.name === \"consent\" && current.messageId !== answerId) {\n go(\n answerId === null\n ? { name: \"needs-answer\", offer: current.offer }\n : { ...current, messageId: answerId },\n );\n }\n }, [answerId, go]);\n\n const onRoomEvent = useCallback(\n (handle: SessionHandle, event: ReceiveOnlyEvent) => {\n if (handle.done || sessionRef.current !== handle) return;\n const wasLive = phaseRef.current.name === \"live\";\n switch (event.type) {\n case \"speaker-track\":\n if (event.kind === \"video\") handle.speakerArrived = true;\n return;\n case \"playback-blocked\":\n setBlocked(event.blocked);\n return;\n case \"speaker-left\":\n finish(\n wasLive ? \"finished\" : \"failed\",\n wasLive ? null : \"client_error\",\n );\n return;\n case \"disconnected\":\n if (event.byServer) finish(wasLive ? \"finished\" : \"failed\", null);\n else finish(wasLive ? \"interrupted\" : \"failed\", \"client_error\");\n return;\n }\n },\n [finish],\n );\n\n // A created session: join its room once the video and audio elements are on the page.\n useEffect(() => {\n if (phase.name !== \"pending\") return;\n const handle = sessionRef.current;\n if (!handle || handle.room !== null || handle.done) return;\n const video = videoRef.current;\n const audio = audioRef.current;\n if (!video || !audio) {\n finish(\"failed\", \"client_error\");\n return;\n }\n let joining: Promise<ReceiveOnlySession>;\n try {\n joining = handle.module.joinReceiveOnly({\n url: handle.session.join.livekitUrl,\n token: handle.session.join.participantToken,\n workerIdentity: handle.session.join.workerIdentity,\n video,\n audio,\n onEvent: (event) => onRoomEvent(handle, event),\n });\n } catch (error) {\n joining = Promise.reject(error);\n }\n handle.room = joining.then(\n (room) => {\n if (handle.done) {\n void room.leave().catch(() => undefined);\n return null;\n }\n handle.joined = room;\n return room;\n },\n () => {\n if (!handle.done) finish(\"failed\", \"client_error\");\n return null;\n },\n );\n }, [phase.name, finish, onRoomEvent]);\n\n // While a session lasts: give up on a speaker who never comes, and leave a room still open after the session's end.\n useEffect(() => {\n if (phase.name !== \"pending\" && phase.name !== \"live\") return;\n const handle = sessionRef.current;\n if (!handle) return;\n const timers: Array<ReturnType<typeof setTimeout>> = [];\n if (phase.name === \"pending\") {\n timers.push(\n setTimeout(() => {\n if (sessionRef.current === handle && !handle.speakerArrived) {\n finish(\"failed\", \"client_error\");\n }\n }, SPEAKER_WAIT_MS),\n );\n }\n timers.push(\n setTimeout(\n () => {\n if (sessionRef.current !== handle) return;\n finish(\n phaseRef.current.name === \"live\" ? \"finished\" : \"failed\",\n \"client_error\",\n );\n },\n Math.max(0, handle.endsAt + END_GRACE_MS - Date.now()),\n ),\n );\n return () => timers.forEach((timer) => clearTimeout(timer));\n }, [phase.name, finish]);\n\n // The countdown: once a second while a session lasts.\n const ticking = phase.name === \"pending\" || phase.name === \"live\";\n useEffect(() => {\n if (!ticking) return;\n const timer = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(timer);\n }, [ticking]);\n\n // Hiding the page (another app, another tab, leaving) ends a session.\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const onPageHide = () => leave(\"page_hide\");\n const onVisibility = () => {\n if (document.visibilityState === \"hidden\") leave(\"page_hide\");\n };\n window.addEventListener(\"pagehide\", onPageHide);\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => {\n window.removeEventListener(\"pagehide\", onPageHide);\n document.removeEventListener(\"visibilitychange\", onVisibility);\n };\n }, [leave]);\n\n // Unmounted with something under way: end it, as closing the panel would.\n useEffect(\n () => () => {\n const controller = checkRef.current;\n checkRef.current = null;\n controller?.abort();\n const run = startRef.current;\n startRef.current = null;\n if (run) {\n run.cancelled = \"user\";\n run.turnstile?.cancel();\n }\n const handle = sessionRef.current;\n sessionRef.current = null;\n if (handle && !handle.done) {\n handle.done = true;\n sendEnd({\n base: handle.base,\n headers: handle.headers,\n sessionId: handle.session.sessionId,\n secret: handle.session.endSecret,\n reason: \"user\",\n });\n if (handle.joined) void handle.joined.leave().catch(() => undefined);\n }\n },\n [],\n );\n\n // Each step's own control takes focus when the one the visitor was on has gone (Start, once pressed, say): focus\n // left on the page's body would also take Escape out of the panel. \"Tap to turn on sound\" is one of those controls:\n // it goes the moment playback resumes (`blocked` clears), so focus moves on to Stop rather than falling to the body.\n useEffect(() => {\n if (!active) return;\n const focused = document.activeElement;\n if (focused && focused !== document.body && focused.isConnected) return;\n rootRef.current?.querySelector<HTMLElement>(PRIMARY)?.focus();\n }, [active, phase.name, blocked]);\n\n const onPlaying = useCallback(() => {\n const current = phaseRef.current;\n const handle = sessionRef.current;\n if (current.name !== \"pending\" || !handle) return;\n handle.speakerArrived = true;\n go({ name: \"live\", session: current.session });\n }, [go]);\n\n const enablePlayback = useCallback(() => {\n // Called straight from the tap: browsers allow sound only from inside the visitor's gesture.\n void sessionRef.current?.joined?.enablePlayback().catch(() => undefined);\n }, []);\n\n if (off || phase.name === \"inert\") {\n return (\n // `display: contents`: the earlier Avatar view's picture, line and button lay out in the pane exactly as before.\n <div\n ref={rootRef}\n style={{ display: \"contents\" }}\n data-boff-explore=\"avatar-live\"\n data-phase={off ? \"off\" : \"inert\"}\n >\n {fallback}\n </div>\n );\n }\n\n const primaryButton =\n \"inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background motion-reduce:transition-none\";\n const secondaryButton =\n \"inline-flex items-center justify-center rounded-md border border-border bg-background px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background motion-reduce:transition-none\";\n const stillPicture = (small: boolean) => (\n <img\n src={still.src}\n alt={still.alt}\n decoding=\"async\"\n width={small ? 64 : 128}\n height={small ? 64 : 128}\n className={cn(\n \"shrink-0 rounded-full border border-border object-cover shadow-sm\",\n small ? \"h-16 w-16\" : \"h-32 w-32\",\n )}\n />\n );\n const continueButton = (\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-continue\"\n className={primaryButton}\n onClick={onContinueInChat}\n >\n {continueInChat}\n </button>\n );\n const stopButton = (\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-stop\"\n className={secondaryButton}\n onClick={stop}\n >\n {S.stop}\n </button>\n );\n\n // The headline of each step, in the one polite status region: announced as it changes, the countdown never.\n const headline: Record<Phase[\"name\"], string> = {\n idle: \"\",\n checking: S.checking,\n inert: \"\",\n \"needs-answer\": startOver ? S.startNewChat : S.needsAnswer,\n consent: \"\",\n refused: phase.name === \"refused\" ? S[REFUSAL_TEXT[phase.reason]] : \"\",\n \"bot-check\": S.botCheck,\n creating: S.connecting,\n pending: S.connecting,\n live: S.speaking,\n ended: phase.name === \"ended\" ? S[phase.how] : \"\",\n };\n const outcome =\n phase.name === \"needs-answer\" ||\n phase.name === \"refused\" ||\n phase.name === \"ended\";\n\n let top: ReactNode = null;\n let media: ReactNode = stillPicture(false);\n let body: ReactNode = null;\n let actions: ReactNode = null;\n\n switch (phase.name) {\n case \"needs-answer\":\n // Nothing to read yet (choose a suggested question), or never in this conversation (start a new chat).\n body = (\n <p className=\"text-sm text-muted-foreground\">\n {startOver ? S.startNewChatDetail : S.needsAnswerDetail}\n </p>\n );\n actions = continueButton;\n break;\n case \"consent\": {\n const { copy } = phase.offer;\n media = stillPicture(true);\n body = (\n <section\n aria-labelledby={consentTitleId}\n data-boff-explore=\"avatar-live-consent\"\n className=\"w-full max-w-sm rounded-lg border border-border p-4 text-start\"\n >\n <h2 id={consentTitleId} className=\"text-base font-semibold\">\n {copy.title}\n </h2>\n <p className=\"mt-2 text-sm\">\n {productName === null\n ? copy.intro\n : fill(copy.introProduct, { product: productName })}\n </p>\n <p className=\"mt-2 text-sm text-muted-foreground\">\n {copy.processing}\n </p>\n <p className=\"mt-2 text-sm text-muted-foreground\">{copy.storage}</p>\n <a\n href={PRIVACY_HREF}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n data-boff-explore=\"avatar-live-privacy\"\n className=\"mt-2 inline-block text-sm font-medium text-primary underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {copy.privacyLink}\n <span className=\"sr-only\"> {S.opensInNewTab}</span>\n </a>\n </section>\n );\n actions = (\n <div className=\"flex flex-wrap items-center justify-center gap-2\">\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-start\"\n className={primaryButton}\n onClick={start}\n >\n {S.start}\n </button>\n <button\n type=\"button\"\n data-boff-explore=\"avatar-live-not-now\"\n className={secondaryButton}\n onClick={onContinueInChat}\n >\n {S.notNow}\n </button>\n </div>\n );\n break;\n }\n case \"refused\":\n actions = continueButton;\n break;\n case \"bot-check\":\n case \"creating\":\n actions = stopButton;\n break;\n case \"pending\":\n case \"live\": {\n const playing = phase.name === \"live\";\n const left = Math.max(0, (phase.session.endsAt - now) / 1000);\n top = (\n <p\n data-boff-explore=\"avatar-live-badge\"\n className=\"rounded-full bg-muted px-3 py-1 text-xs font-medium text-foreground\"\n >\n {S.badge}\n </p>\n );\n media = (\n <div className=\"relative h-48 w-48 shrink-0 overflow-hidden rounded-xl border border-border bg-muted\">\n <video\n ref={videoRef}\n aria-label={S.video}\n data-boff-explore=\"avatar-live-video\"\n playsInline\n autoPlay\n muted\n onPlaying={onPlaying}\n className={cn(\n \"h-full w-full object-cover\",\n !playing && \"opacity-0\",\n )}\n />\n {playing ? null : (\n <img\n src={still.src}\n alt=\"\"\n decoding=\"async\"\n className=\"absolute inset-0 h-full w-full object-cover\"\n />\n )}\n <audio ref={audioRef} data-boff-explore=\"avatar-live-audio\" />\n </div>\n );\n body = (\n <>\n <section\n aria-label={S.captions}\n data-boff-explore=\"avatar-live-captions\"\n lang={phase.session.captions.locale || undefined}\n dir=\"auto\"\n tabIndex={0}\n className=\"max-h-32 w-full max-w-sm overflow-y-auto rounded-lg bg-muted p-3 text-start text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {phase.session.captions.text}\n </section>\n <p className=\"text-xs text-muted-foreground\">{S.answerInChat}</p>\n <p className=\"text-sm tabular-nums text-muted-foreground\">\n {S.timeLeft}{\" \"}\n <span role=\"timer\" data-boff-explore=\"avatar-live-countdown\">\n {clock(left)}\n </span>\n </p>\n </>\n );\n actions = (\n <div className=\"flex flex-wrap items-center justify-center gap-2\">\n {blocked ? (\n <button\n type=\"button\"\n data-boff-explore=\"avatar-live-sound\"\n className={primaryButton}\n onClick={enablePlayback}\n >\n {S.tapForSound}\n </button>\n ) : null}\n {stopButton}\n <button\n type=\"button\"\n data-boff-explore=\"avatar-live-continue\"\n className={secondaryButton}\n onClick={onContinueInChat}\n >\n {continueInChat}\n </button>\n </div>\n );\n break;\n }\n case \"ended\":\n body = <p className=\"text-sm text-muted-foreground\">{S.answerInChat}</p>;\n actions = (\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-back\"\n className={primaryButton}\n onClick={onContinueInChat}\n >\n {S.backToChat}\n </button>\n );\n break;\n default:\n break;\n }\n\n // The same slots in every step, so the status region and the bot check's box stay the same elements throughout.\n return (\n <div\n ref={rootRef}\n data-boff-explore=\"avatar-live\"\n data-phase={phase.name}\n className=\"flex max-h-full w-full flex-col items-center gap-4 overflow-y-auto\"\n >\n {top}\n {media}\n <p\n role=\"status\"\n data-boff-explore=\"avatar-live-status\"\n className={\n outcome ? \"text-base font-semibold\" : \"text-sm text-muted-foreground\"\n }\n >\n {headline[phase.name]}\n </p>\n {body}\n <div ref={botBoxRef} data-boff-explore=\"avatar-live-bot-check\" />\n {actions}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/explore-avatar-live-config.ts","../../src/components/explore-avatar-api.ts","../../src/components/explore-avatar-i18n.ts","../../src/components/explore-avatar-turnstile.ts","../../src/components/explore-fill.ts","../../src/utils/cn.ts","../../src/components/explore-avatar-live-view.tsx"],"names":["twMerge","clsx","INERT","useId","useState","useRef","useCallback","live","locale","base","headers","off","body","useEffect","jsx","jsxs","Fragment"],"mappings":";;;;;;;;AA0CA,IAAM,IAAA,GAAO,wBAAA;AACb,IAAM,OAAA,GAAU,wBAAA;AAKT,SAAS,aAAa,KAAA,EAAwB;AACnD,EAAA,OAAO,IAAA,CAAK,KAAK,KAAK,CAAA;AACxB;AAGO,SAAS,gBAAgB,KAAA,EAAwB;AACtD,EAAA,OAAO,OAAA,CAAQ,KAAK,KAAK,CAAA;AAC3B;AAsCA,IAAM,QAAA,mBAAuC,IAAI,GAAA,CAAmB,CAAC,IAAI,CAAC,CAAA;AAGnE,SAAS,2BAA2B,MAAA,EAAgC;AACzE,EAAA,OAAO,QAAA,CAAS,IAAI,MAAM,CAAA;AAC5B;;;AC7DA,IAAM,uBAAA,GAA0B,GAAA;AAEhC,IAAM,iBAAA,GAAoB,GAAA;AAiE1B,IAAM,UAAA,GAAa,uBAAA;AACnB,IAAM,kBAAA,GAAqB,8BAAA;AAC3B,IAAM,MAAA,GAAS,sBAAA;AACf,IAAM,UAAA,GAAa,oBAAA;AACnB,IAAM,UAAA,GAAa,qBAAA;AAEnB,IAAM,KAAA,GAAQ,EAAE,IAAA,EAAM,OAAA,EAAQ;AAC9B,IAAM,MAAA,GAAS,EAAE,IAAA,EAAM,QAAA,EAAS;AAGzB,SAAS,kBAAkB,KAAA,EAAwB;AACxD,EAAA,OAAO,UAAA,CAAW,KAAK,KAAK,CAAA;AAC9B;AAGO,SAAS,0BAA0B,KAAA,EAAwB;AAChE,EAAA,OAAO,kBAAA,CAAmB,KAAK,KAAK,CAAA;AACtC;AAEA,SAAS,SAA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AA;AACpE,MAAA,OAAA,mBACEA,cAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,qBAAA,EAAoB,EAAA;AAAA,UACpB,mBAAA,EAAkB,kBAAA;AAAA,UAClB,SAAA,EAAW,aAAA;AAAA,UACX,OAAA,EAAS,gBAAA;AAAA,UAER,QAAA,EAAA,CAAA,CAAE;AAAA;AAAA,OACL;AAEF,MAAA;AAEA;AAIJ,EAAA,uBACEC,eAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,OAAA;AAAA,MACL,mBAAA,EAAkB,aAAA;AAAA,MAClB,cAAY,KAAA,CAAM,IAAA;AAAA,MAClB,SAAA,EAAU,oEAAA;AAAA,MAET,QAAA,EAAA;AAAA,QAAA,GAAA;AAAA,QACA,KAAA;AAAA,wBACDD,cAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,QAAA;AAAA,YACL,mBAAA,EAAkB,oBAAA;AAAA,YAClB,SAAA,EACE,UAAU,yBAAA,GAA4B,+BAAA;AAAA,YAGvC,QAAA,EAAA,QAAA,CAAS,MAAM,IAAI;AAAA;AAAA,SACtB;AAAA,QACC,IAAA;AAAA,wBACDA,cAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,qBAAkB,uBAAA,EAAwB,CAAA;AAAA,QAC9D;AAAA;AAAA;AAAA,GACH;AAEJ","file":"index.js","sourcesContent":["/**\n * BOFF-9797. The small part of the live avatar that the panel itself needs, whether or not it is ever opened: what a\n * host's `avatar.live` is, whether the live avatar can run on this page at all, and where its requests go.\n *\n * Everything else (the view, its state machine, the requests, the words, the bot check) is a separate chunk that a\n * site only downloads when its visitor first opens the Avatar view (see `explore-avatar-live.tsx`). That is why this\n * file is separate and kept to a few lines: it is the only part of the live avatar in the package root for a site that\n * does not pass `avatar.live`, and the part of it that decides, without loading anything, whether the chunk is wanted.\n * Types only, plus plain functions: nothing here imports a component, a context or a string table.\n */\nimport type { ExploreLocale } from \"./explore-i18n\";\nimport type { AvatarLiveModule } from \"../avatar-live/types\";\nimport type { UseExploreChatResult } from \"../hooks/use-explore-chat\";\n\n/**\n * BOFF-9797. A host's opt-in to the live avatar on its panel's Avatar tab. Every field is required; a config that is\n * incomplete leaves the tab as it was (and a warning in the console).\n */\nexport interface ExplorePanelAvatarLive {\n /** The site, as the live avatar service knows it: `healthybowl`. */\n site: string;\n /**\n * Loads the live avatar's room module: `() => import('@burdenoff/website-sdk/avatar-live')`. Called only after the\n * visitor presses Start on the consent card, never on page load or on opening the tab. That entry needs the\n * package's optional peer dependency for media rooms (see the README).\n */\n load: () => Promise<AvatarLiveModule>;\n /** The site's Cloudflare Turnstile site key, for the bot check that runs when the visitor presses Start. */\n turnstileSiteKey: string;\n /** The version of the suggested-question list the panel shows (its `examplePrompts`), such as `hb-en-1`. */\n manifestVersion: string;\n}\n\n/** What the live avatar reads of the panel's conversation: the transcript, whether it is read-only, and the token. */\nexport type AvatarConversation = Pick<\n UseExploreChatResult,\n \"messages\" | \"isSharedView\" | \"getConversationToken\"\n>;\n\n/** The web branch's routes, under the gateway's origin. */\nexport const AVATAR_WEB_API_PATH = \"/api/web-avatar/v1\";\n\nconst SITE = /^[a-z][a-z0-9-]{1,31}$/;\nconst VERSION = /^[A-Za-z0-9._-]{1,32}$/;\nconst SITE_KEY = /^[A-Za-z0-9_-]{1,128}$/;\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\"]);\n\n/** A site slug the contract accepts (`healthybowl`). */\nexport function isAvatarSite(value: string): boolean {\n return SITE.test(value);\n}\n\n/** A consent or manifest version the contract accepts (`hb-en-1`). */\nexport function isAvatarVersion(value: string): boolean {\n return VERSION.test(value);\n}\n\n/**\n * The web branch's base URL on the SDK's configured gateway: the gateway URL's origin, plus\n * {@link AVATAR_WEB_API_PATH}. Null for anything that is not an `https:` URL (or `http:` on this machine, for local\n * development).\n */\nexport function avatarApiBase(gatewayUrl: string | undefined): string | null {\n if (!gatewayUrl) return null;\n let url: URL;\n try {\n url = new URL(gatewayUrl);\n } catch {\n return null;\n }\n const local =\n url.protocol === \"http:\" && LOOPBACK_HOSTS.has(url.hostname.toLowerCase());\n if (url.protocol !== \"https:\" && !local) return null;\n return `${url.origin}${AVATAR_WEB_API_PATH}`;\n}\n\n/** Whether a host's `avatar.live` has everything the live avatar needs, in the shapes the contract accepts. */\nexport function liveConfigComplete(live: ExplorePanelAvatarLive): boolean {\n return (\n typeof live.load === \"function\" &&\n typeof live.site === \"string\" &&\n isAvatarSite(live.site) &&\n typeof live.manifestVersion === \"string\" &&\n isAvatarVersion(live.manifestVersion) &&\n typeof live.turnstileSiteKey === \"string\" &&\n SITE_KEY.test(live.turnstileSiteKey)\n );\n}\n\n/**\n * The locales whose live-avatar strings have been reviewed. The live avatar runs only in these; see\n * `explore-avatar-i18n.ts`. English only, until a named reviewer signs off on another.\n */\nconst REVIEWED: ReadonlySet<ExploreLocale> = new Set<ExploreLocale>([\"en\"]);\n\n/** Whether the live avatar may run in `locale`: its strings have been reviewed. */\nexport function isAvatarLiveLocaleReviewed(locale: ExploreLocale): boolean {\n return REVIEWED.has(locale);\n}\n","/**\n * BOFF-9797. The website live avatar's three requests, as a visitor's browser makes them.\n *\n * They go to the global gateway's web branch, under the SDK's configured gateway (`/api/web-avatar/v1/*` on its\n * origin), and follow the website avatar web API, v1:\n *\n * GET /availability?site=…&locale=… when the Avatar tab opens, never on page load\n * POST /sessions after the visitor's consent and the bot check\n * POST /sessions/{id}/end Stop, leaving the tab, closing the panel, hiding the page\n *\n * - **Never with credentials** (`credentials: 'omit'`): a website visitor has no account, no cookie and no workspace\n * here.\n * - **The bot check's token** goes in the `x-web-avatar-bot-token` header, on create only. The gateway verifies it and\n * drops it; the body is exactly the contract's six fields. The check itself is bound to that body (contract v1.1):\n * see {@link avatarBotBinding}.\n * - **The end is a simple request** (see {@link sendEnd}): no `Content-Type` of our own, so a page being hidden has no\n * CORS preflight to wait for.\n * - **Every answer is read into one of a few outcomes** the Avatar tab can show. A missing route, a forbidden one, a\n * refused origin and a network failure are all `inert`: the tab shows what it showed before there was a live\n * avatar. Nothing a server says is shown as it was said.\n * - Nothing here logs. The conversation token goes into the create body and nowhere else, and the session's secret\n * only into the end body.\n */\n\nimport { isAvatarSite, isAvatarVersion } from \"./explore-avatar-live-config\";\n\n// The few helpers the panel itself needs (where the requests go, and the shapes a config may take) live in\n// `explore-avatar-live-config.ts`, so that they do not drag this file into every site's bundle; they are re-exported\n// here, where the rest of the contract's grammar is.\nexport {\n AVATAR_WEB_API_PATH,\n avatarApiBase,\n isAvatarSite,\n isAvatarVersion,\n} from \"./explore-avatar-live-config\";\n\n/** How long the Avatar tab waits to hear whether the live avatar is offered. */\nconst AVAILABILITY_TIMEOUT_MS = 8_000;\n/** How long a create may take: past the gateway's own deadline for it, so the gateway's answer is what decides. */\nconst CREATE_TIMEOUT_MS = 30_000;\n\n/** The refusals the Avatar tab explains, each in a short sentence of its own. */\nexport type AvatarRefusal =\n | \"busy\"\n | \"limits\"\n | \"region\"\n | \"locale\"\n | \"paused\"\n | \"not_eligible\"\n | \"answer_claimed\";\n\n/** Why the browser ends a session. Analytics only: the secret is what ends it. */\nexport type AvatarEndReason = \"user\" | \"page_hide\" | \"client_error\";\n\n/** What an `ok` availability offers. */\nexport interface AvatarOffer {\n /** The consent version the visitor must agree to: the panel shows only copy written for exactly this version. */\n consentVersion: string;\n /** The longest a session can last, in seconds. */\n maxSessionSeconds: number;\n}\n\nexport type AvatarAvailability =\n | { kind: \"available\"; offer: AvatarOffer }\n | { kind: \"refused\"; reason: AvatarRefusal }\n /** Not offered here, or not reachable: the Avatar tab stays as it was before the live avatar. */\n | { kind: \"inert\" };\n\n/** A created session: what the browser needs to watch it and to end it. */\nexport interface AvatarSession {\n sessionId: string;\n /** Returned once; ends this session and nothing else. Kept out of the page's markup. */\n endSecret: string;\n /** When the server ends the session, in epoch milliseconds. */\n endsAt: number;\n join: {\n livekitUrl: string;\n /** Subscribe-only and short-lived. Kept out of the page's markup. */\n participantToken: string;\n workerIdentity: string;\n };\n captions: { locale: string; text: string };\n}\n\nexport type AvatarCreateResult =\n | { kind: \"created\"; session: AvatarSession }\n /** A session was created, but its answer cannot be used: the browser ends it at once. */\n | { kind: \"unusable\"; sessionId: string; endSecret: string }\n | { kind: \"refused\"; reason: AvatarRefusal }\n /** The consent version moved on since availability: ask again, and show the consent that is current. */\n | { kind: \"consent\" }\n | { kind: \"inert\" }\n | { kind: \"failed\" };\n\n/** The create body: exactly these six fields, in the contract's order. */\nexport interface AvatarCreateBody {\n site: string;\n locale: string;\n conversationToken: string;\n messageId: string;\n consentVersion: string;\n manifestVersion: string;\n}\n\nconst MESSAGE_ID = /^[A-Za-z0-9_-]{1,64}$/;\nconst CONVERSATION_TOKEN = /^[A-Za-z0-9._~+/=-]{16,512}$/;\nconst LOCALE = /^[A-Za-z0-9-]{1,16}$/;\nconst SESSION_ID = /^avs_[0-9a-f]{32}$/;\nconst END_SECRET = /^[A-Za-z0-9_-]{43}$/;\n\nconst INERT = { kind: \"inert\" } as const;\nconst FAILED = { kind: \"failed\" } as const;\n\n/** An answer id the contract accepts. */\nexport function isAvatarMessageId(value: string): boolean {\n return MESSAGE_ID.test(value);\n}\n\n/** A conversation token the contract accepts. */\nexport function isAvatarConversationToken(value: string): boolean {\n return CONVERSATION_TOKEN.test(value);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\n/** What each availability `reason` other than `ok` means for the Avatar tab. A reason not listed is inert. */\nconst AVAILABILITY_REASONS: ReadonlyMap<string, AvatarRefusal | \"inert\"> =\n new Map<string, AvatarRefusal | \"inert\">([\n [\"site\", \"inert\"],\n [\"unavailable\", \"inert\"],\n [\"region\", \"region\"],\n [\"locale\", \"locale\"],\n [\"paused\", \"paused\"],\n [\"busy\", \"busy\"],\n [\"limits\", \"limits\"],\n ]);\n\n/** Read an availability answer: its HTTP status and its parsed JSON body (or null). */\nexport function readAvailability(\n status: number,\n body: unknown,\n): AvatarAvailability {\n if (status !== 200 || !isRecord(body)) return INERT;\n const { available, reason } = body;\n if (typeof available !== \"boolean\" || typeof reason !== \"string\") {\n return INERT;\n }\n if (reason === \"ok\") {\n const { consentVersion, maxSessionSeconds } = body;\n if (\n available !== true ||\n typeof consentVersion !== \"string\" ||\n !isAvatarVersion(consentVersion) ||\n typeof maxSessionSeconds !== \"number\" ||\n !Number.isInteger(maxSessionSeconds) ||\n maxSessionSeconds < 1\n ) {\n return INERT;\n }\n return { kind: \"available\", offer: { consentVersion, maxSessionSeconds } };\n }\n const meaning = available ? undefined : AVAILABILITY_REASONS.get(reason);\n return meaning === undefined || meaning === \"inert\"\n ? INERT\n : { kind: \"refused\", reason: meaning };\n}\n\n/** The create error codes the Avatar tab explains. */\nconst CREATE_REFUSALS: ReadonlyMap<string, AvatarRefusal> = new Map<\n string,\n AvatarRefusal\n>([\n [\"busy\", \"busy\"],\n [\"limits\", \"limits\"],\n [\"region\", \"region\"],\n [\"locale\", \"locale\"],\n [\"paused\", \"paused\"],\n [\"not_eligible\", \"not_eligible\"],\n [\"answer_claimed\", \"answer_claimed\"],\n]);\n\nfunction errorCode(body: unknown): string | null {\n if (!isRecord(body) || !isRecord(body.error)) return null;\n const { code } = body.error;\n return typeof code === \"string\" ? code : null;\n}\n\nfunction readCreated(body: unknown): AvatarCreateResult {\n if (!isRecord(body)) return FAILED;\n const { sessionId, endSecret } = body;\n if (\n typeof sessionId !== \"string\" ||\n !SESSION_ID.test(sessionId) ||\n typeof endSecret !== \"string\" ||\n !END_SECRET.test(endSecret)\n ) {\n return FAILED;\n }\n const unusable = { kind: \"unusable\", sessionId, endSecret } as const;\n const { state, join, captions } = body;\n const endsAt =\n typeof body.endsAt === \"string\" ? Date.parse(body.endsAt) : NaN;\n if (\n state !== \"pending\" ||\n !Number.isFinite(endsAt) ||\n !isRecord(join) ||\n !isRecord(captions)\n ) {\n return unusable;\n }\n const { livekitUrl, participantToken, workerIdentity } = join;\n const { locale, text } = captions;\n if (\n typeof livekitUrl !== \"string\" ||\n !livekitUrl.startsWith(\"wss://\") ||\n typeof participantToken !== \"string\" ||\n participantToken === \"\" ||\n typeof workerIdentity !== \"string\" ||\n workerIdentity === \"\" ||\n typeof locale !== \"string\" ||\n typeof text !== \"string\"\n ) {\n return unusable;\n }\n return {\n kind: \"created\",\n session: {\n sessionId,\n endSecret,\n endsAt,\n join: { livekitUrl, participantToken, workerIdentity },\n captions: { locale, text },\n },\n };\n}\n\n/**\n * Read a create answer: its HTTP status and its parsed JSON body (or null).\n *\n * - 201: the session, or `unusable` when its fields cannot be used (the browser then ends it).\n * - `busy`, `limits`, `region`, `locale`, `paused`, `not_eligible`, `answer_claimed`: a refusal the tab explains.\n * - `consent`: the consent version moved on.\n * - Any other 401, 403, 404 or 405 (`untrusted_caller`, `bot_check`, `site`, `invalid_route`, `method_not_allowed`):\n * inert, as if there were no live avatar here.\n * - Anything else (`invalid_request`, `conflict`, `idempotency_mismatch`, `unavailable`, a gateway error page):\n * failed.\n */\nexport function readCreate(status: number, body: unknown): AvatarCreateResult {\n if (status === 201) return readCreated(body);\n const code = errorCode(body);\n if (code !== null) {\n const refusal = CREATE_REFUSALS.get(code);\n if (refusal !== undefined) return { kind: \"refused\", reason: refusal };\n if (code === \"consent\") return { kind: \"consent\" };\n }\n if (status === 401 || status === 403 || status === 404 || status === 405) {\n return INERT;\n }\n return FAILED;\n}\n\nasync function readJson(response: Response): Promise<unknown> {\n try {\n return (await response.json()) as unknown;\n } catch {\n return null;\n }\n}\n\n/** An abort signal for `timeoutMs`, also aborted with `outer`; `done` clears its timer. */\nfunction deadline(\n timeoutMs: number,\n outer?: AbortSignal,\n): { signal: AbortSignal; done: () => void } {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n const onOuter = () => controller.abort();\n if (outer?.aborted) controller.abort();\n else outer?.addEventListener(\"abort\", onOuter, { once: true });\n return {\n signal: controller.signal,\n done: () => {\n clearTimeout(timer);\n outer?.removeEventListener(\"abort\", onOuter);\n },\n };\n}\n\nexport interface AvatarRequestTarget {\n /** {@link avatarApiBase} of the SDK's gateway. */\n base: string;\n /** Headers every request carries: the alpha gateway's access headers, and nothing on production. */\n headers: Readonly<Record<string, string>>;\n}\n\n/** Ask whether the live avatar is offered for `site` in `locale`. Never throws: a failure is `inert`. */\nexport async function requestAvailability(\n target: AvatarRequestTarget & {\n site: string;\n locale: string;\n signal?: AbortSignal;\n },\n): Promise<AvatarAvailability> {\n if (!isAvatarSite(target.site) || !LOCALE.test(target.locale)) return INERT;\n const query = new URLSearchParams({\n site: target.site,\n locale: target.locale,\n });\n const timer = deadline(AVAILABILITY_TIMEOUT_MS, target.signal);\n try {\n const response = await fetch(`${target.base}/availability?${query}`, {\n method: \"GET\",\n credentials: \"omit\",\n cache: \"no-store\",\n headers: { ...target.headers },\n signal: timer.signal,\n });\n return readAvailability(response.status, await readJson(response));\n } catch {\n return INERT;\n } finally {\n timer.done();\n }\n}\n\n/**\n * Create a session. `botToken` is the bot check's token, for the gateway alone. Never throws: a network failure is\n * `inert`, an answer that cannot be read is `failed`.\n */\nexport async function requestCreate(\n target: AvatarRequestTarget & {\n body: AvatarCreateBody;\n idempotencyKey: string;\n botToken: string;\n },\n): Promise<AvatarCreateResult> {\n const { body } = target;\n // Exactly the contract's six fields, in its order: nothing else of the page's goes along.\n const payload = JSON.stringify({\n site: body.site,\n locale: body.locale,\n conversationToken: body.conversationToken,\n messageId: body.messageId,\n consentVersion: body.consentVersion,\n manifestVersion: body.manifestVersion,\n });\n const timer = deadline(CREATE_TIMEOUT_MS);\n try {\n const response = await fetch(`${target.base}/sessions`, {\n method: \"POST\",\n credentials: \"omit\",\n cache: \"no-store\",\n headers: {\n ...target.headers,\n \"Content-Type\": \"application/json\",\n \"Idempotency-Key\": target.idempotencyKey,\n \"x-web-avatar-bot-token\": target.botToken,\n },\n body: payload,\n signal: timer.signal,\n });\n return readCreate(response.status, await readJson(response));\n } catch {\n return INERT;\n } finally {\n timer.done();\n }\n}\n\n/**\n * Ask the server to end a session, without waiting for it: a `keepalive` request, sent in this same tick, so it still\n * goes when the page is being hidden or unloaded. The server ends the session on its own deadlines whether or not this\n * arrives.\n *\n * **A simple CORS request.** The body is a plain string and this sets no `Content-Type`, so the browser sends it as\n * `text/plain;charset=UTF-8`: a type the gateway's end route reads as JSON for exactly this reason. The session id is\n * in the URL, so a preflight could never be answered from the browser's cache, and one that has to complete while the\n * page unloads may never finish. On production nothing else is added, so no preflight is made. (On the alpha gateway\n * hosts the Access headers in `target.headers` are custom headers, which do bring a preflight there: see the README.)\n */\nexport function sendEnd(\n target: AvatarRequestTarget & {\n sessionId: string;\n secret: string;\n reason: AvatarEndReason;\n },\n): void {\n try {\n void fetch(\n `${target.base}/sessions/${encodeURIComponent(target.sessionId)}/end`,\n {\n method: \"POST\",\n keepalive: true,\n credentials: \"omit\",\n cache: \"no-store\",\n headers: { ...target.headers },\n body: JSON.stringify({ secret: target.secret, reason: target.reason }),\n },\n ).catch(() => undefined);\n } catch {\n // No fetch at all: the server's own deadlines end the session.\n }\n}\n\n/** What scopes the bot check's binding to this contract, and its version. */\nconst BOT_BINDING_PREFIX = \"boff-web-avatar-cdata/v1\";\n\n/** The browser's WebCrypto `subtle`, or null where it has none to offer (a page that is not a secure context). */\nfunction webCryptoSubtle(): SubtleCrypto | null {\n const subtle = globalThis.crypto?.subtle;\n return typeof subtle?.digest === \"function\" ? subtle : null;\n}\n\n/**\n * Whether this browser can make the bot check's binding ({@link avatarBotBinding}): it needs WebCrypto's SHA-256.\n * Without it no live avatar can start here, so a start asks first, before it loads anything for one.\n */\nexport function canBindBotCheck(): boolean {\n return webCryptoSubtle() !== null;\n}\n\nfunction base64UrlNoPad(bytes: Uint8Array): string {\n let binary = \"\";\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary)\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=+$/, \"\");\n}\n\n/**\n * The value the bot check is bound to, for Turnstile's `cData` (web API contract v1.1, additive):\n *\n * base64url_nopad( SHA-256( UTF-8( \"boff-web-avatar-cdata/v1\\n\" + site + \"\\n\" + locale + \"\\n\"\n * + conversationToken + \"\\n\" + messageId ) ) )\n *\n * The gateway recomputes it from the create body and checks it against the one Cloudflare returns with the verified\n * token, so a token minted for one request cannot be used for another. It must be made from the very values the create\n * body will carry, and before the widget is rendered: the caller builds the body once and hands the same one to this\n * and to {@link requestCreate}.\n *\n * Rejects where the browser has no WebCrypto (a page that is not a secure context): the bot check cannot be bound\n * there, so the live avatar does not start. {@link canBindBotCheck} says so beforehand, so that nothing is loaded for\n * a start that cannot happen.\n */\nexport async function avatarBotBinding(\n values: Pick<\n AvatarCreateBody,\n \"site\" | \"locale\" | \"conversationToken\" | \"messageId\"\n >,\n): Promise<string> {\n const subtle = webCryptoSubtle();\n if (subtle === null) {\n throw new Error(\"The bot check cannot be bound here: no WebCrypto.\");\n }\n const text = [\n BOT_BINDING_PREFIX,\n values.site,\n values.locale,\n values.conversationToken,\n values.messageId,\n ].join(\"\\n\");\n const digest = await subtle.digest(\"SHA-256\", new TextEncoder().encode(text));\n return base64UrlNoPad(new Uint8Array(digest));\n}\n\n/** A random UUID v4 for `Idempotency-Key`, or null where the browser has no cryptographic random source. */\nexport function newIdempotencyKey(): string | null {\n const crypto = globalThis.crypto;\n if (typeof crypto?.randomUUID === \"function\") return crypto.randomUUID();\n if (typeof crypto?.getRandomValues !== \"function\") return null;\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\n \"\",\n );\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n","/**\n * BOFF-9797. The words of the live avatar's Avatar tab, in the six product locales, bundled like the rest of\n * Explore's copy (see `explore-i18n.ts` for why a marketing site bundles its strings).\n *\n * ## Review\n *\n * English is the reviewed copy. The other five locales are drafts awaiting translation review: each is a complete\n * object (a missing key is a type error), but the live avatar runs only in a locale that\n * {@link isAvatarLiveLocaleReviewed} lists. In any other, the Avatar tab stays as it was before the live avatar and\n * asks the server nothing. A locale is added there (in `explore-avatar-live-config.ts`) once its strings, and its\n * consent copy, have been reviewed.\n *\n * ## Consent\n *\n * The consent card's copy is versioned: the server names the version it will accept (`consentVersion`), and the panel\n * shows a consent card only when it holds copy written for exactly that version in the visitor's locale\n * ({@link avatarConsentCopy}). A version the SDK does not know, or a locale without reviewed copy for it, offers no\n * consent card at all, so a visitor never agrees to words other than the ones the server records.\n */\n\nimport { isAvatarLiveLocaleReviewed } from \"./explore-avatar-live-config\";\n\nimport type { ExploreLocale } from \"./explore-i18n\";\n\n// The reviewed locales are decided in `explore-avatar-live-config.ts`, which the panel reads without loading this file.\nexport { isAvatarLiveLocaleReviewed };\n\nexport interface AvatarLiveStrings {\n /** Status while the tab asks whether the live avatar is offered. Announced politely. */\n checking: string;\n /** No answer to read yet. */\n needsAnswer: string;\n needsAnswerDetail: string;\n /**\n * The conversation can never be read: its first answer failed, or it has gone past the first question and answer.\n * Only a new chat can. The headline (announced politely), then the explanation. The avatar service reads exactly one\n * answer: the first, completed, to a suggested question.\n */\n startNewChat: string;\n startNewChatDetail: string;\n /** The consent card's buttons. */\n start: string;\n notNow: string;\n /** After the privacy link, for screen readers: it opens in a new tab. */\n opensInNewTab: string;\n /** Status while the bot check runs. Announced politely. */\n botCheck: string;\n /** Status while the session is created and the room joined. Announced politely. */\n connecting: string;\n /** Status once the avatar's video plays. Announced politely. */\n speaking: string;\n /** Shown over the live video, always: the visitor is watching an AI, not a person. */\n badge: string;\n /** The video's accessible name. */\n video: string;\n /** The captions' accessible name. */\n captions: string;\n /** Before the countdown, which is never announced. */\n timeLeft: string;\n stop: string;\n /** Where the browser holds sound back until a tap (Safari, iOS). */\n tapForSound: string;\n /**\n * How a session ended. Announced politely. `finished` is \"the server closed the room, or the session's time ran out\n * with the room still open\": the browser cannot tell the avatar reading to the end from a server-side stop or a\n * hand-over, so it says only that the live avatar has ended.\n */\n finished: string;\n stopped: string;\n failed: string;\n interrupted: string;\n /** Under the captions and after a session: the answer itself is still in the conversation. */\n answerInChat: string;\n backToChat: string;\n /** The refusals, one short sentence each, with no numbers in them. */\n busy: string;\n limits: string;\n region: string;\n locale: string;\n paused: string;\n notEligible: string;\n answerClaimed: string;\n}\n\nconst EN: AvatarLiveStrings = {\n checking: \"Checking whether the live avatar is available…\",\n needsAnswer: \"Choose a suggested question in Chat first.\",\n needsAnswerDetail: \"The avatar can read only the first answer aloud.\",\n startNewChat: \"Start a new chat to use the avatar.\",\n startNewChatDetail:\n \"The avatar reads aloud only the first answer in a chat, and only to a suggested question. Start a new chat and choose a suggested question.\",\n start: \"Start live avatar\",\n notNow: \"Not now\",\n opensInNewTab: \"(opens in a new tab)\",\n botCheck: \"Checking your browser…\",\n connecting: \"Connecting to the live avatar…\",\n speaking: \"The avatar is speaking.\",\n badge: \"AI avatar · not a real person\",\n video: \"Live AI avatar video\",\n captions: \"Captions\",\n timeLeft: \"Time left\",\n stop: \"Stop\",\n tapForSound: \"Tap to turn on sound\",\n finished: \"The live avatar has ended.\",\n stopped: \"You stopped the avatar.\",\n failed: \"The live avatar couldn't start.\",\n interrupted: \"The live avatar stopped early.\",\n answerInChat: \"The full answer is in Chat.\",\n backToChat: \"Back to Chat\",\n busy: \"The live avatar is busy right now. Please try again in a few minutes.\",\n limits:\n \"The live avatar has reached its limit for now. Please try again later.\",\n region: \"The live avatar isn't offered in your region yet.\",\n locale: \"The live avatar isn't offered in this language yet.\",\n paused: \"The live avatar is paused right now.\",\n notEligible: \"The avatar can read answers to the suggested questions.\",\n answerClaimed: \"The avatar has already read this answer.\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"zh\" is in REVIEWED.\nconst ZH: AvatarLiveStrings = {\n checking: \"正在检查实时虚拟形象是否可用…\",\n needsAnswer: \"请先在聊天中选择一个推荐问题。\",\n needsAnswerDetail: \"虚拟形象只能朗读第一个回答。\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"请开始新的聊天,再使用虚拟形象。\",\n startNewChatDetail:\n \"虚拟形象只朗读一次聊天中的第一个回答,且仅限回答推荐问题。请开始新的聊天,并选择一个推荐问题。\",\n start: \"启动实时虚拟形象\",\n notNow: \"暂不\",\n opensInNewTab: \"(在新标签页中打开)\",\n botCheck: \"正在检查您的浏览器…\",\n connecting: \"正在连接实时虚拟形象…\",\n speaking: \"虚拟形象正在讲话。\",\n badge: \"AI 虚拟形象 · 不是真人\",\n video: \"实时 AI 虚拟形象视频\",\n captions: \"字幕\",\n timeLeft: \"剩余时间\",\n stop: \"停止\",\n tapForSound: \"点按以开启声音\",\n finished: \"实时虚拟形象已结束。\",\n stopped: \"您已停止虚拟形象。\",\n failed: \"实时虚拟形象无法启动。\",\n interrupted: \"实时虚拟形象提前停止了。\",\n answerInChat: \"完整回答在聊天中。\",\n backToChat: \"返回聊天\",\n busy: \"实时虚拟形象目前繁忙,请几分钟后再试。\",\n limits: \"实时虚拟形象暂时已达到使用上限,请稍后再试。\",\n region: \"您所在的地区暂不提供实时虚拟形象。\",\n locale: \"此语言暂不提供实时虚拟形象。\",\n paused: \"实时虚拟形象目前已暂停。\",\n notEligible: \"虚拟形象可以朗读推荐问题的回答。\",\n answerClaimed: \"虚拟形象已经朗读过这个回答。\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"hi\" is in REVIEWED.\nconst HI: AvatarLiveStrings = {\n checking: \"जाँच हो रही है कि लाइव अवतार उपलब्ध है या नहीं…\",\n needsAnswer: \"पहले चैट में कोई सुझाया गया प्रश्न चुनें।\",\n needsAnswerDetail: \"अवतार केवल पहला उत्तर ज़ोर से पढ़ सकता है।\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"अवतार का उपयोग करने के लिए नई चैट शुरू करें।\",\n startNewChatDetail:\n \"अवतार किसी चैट का केवल पहला उत्तर ज़ोर से पढ़ता है, और वह भी सुझाए गए प्रश्न का ही। नई चैट शुरू करें और कोई सुझाया गया प्रश्न चुनें।\",\n start: \"लाइव अवतार शुरू करें\",\n notNow: \"अभी नहीं\",\n opensInNewTab: \"(नए टैब में खुलता है)\",\n botCheck: \"आपके ब्राउज़र की जाँच हो रही है…\",\n connecting: \"लाइव अवतार से जुड़ रहे हैं…\",\n speaking: \"अवतार बोल रहा है।\",\n badge: \"AI अवतार · असली व्यक्ति नहीं\",\n video: \"लाइव AI अवतार वीडियो\",\n captions: \"कैप्शन\",\n timeLeft: \"बचा हुआ समय\",\n stop: \"रोकें\",\n tapForSound: \"आवाज़ चालू करने के लिए टैप करें\",\n finished: \"लाइव अवतार समाप्त हो गया है।\",\n stopped: \"आपने अवतार को रोक दिया।\",\n failed: \"लाइव अवतार शुरू नहीं हो सका।\",\n interrupted: \"लाइव अवतार बीच में ही रुक गया।\",\n answerInChat: \"पूरा उत्तर चैट में है।\",\n backToChat: \"चैट पर वापस जाएँ\",\n busy: \"लाइव अवतार अभी व्यस्त है। कृपया कुछ मिनट बाद फिर कोशिश करें।\",\n limits:\n \"लाइव अवतार अभी अपनी सीमा तक पहुँच गया है। कृपया बाद में फिर कोशिश करें।\",\n region: \"आपके क्षेत्र में लाइव अवतार अभी उपलब्ध नहीं है।\",\n locale: \"इस भाषा में लाइव अवतार अभी उपलब्ध नहीं है।\",\n paused: \"लाइव अवतार अभी रुका हुआ है।\",\n notEligible: \"अवतार सुझाए गए प्रश्नों के उत्तर पढ़ सकता है।\",\n answerClaimed: \"अवतार यह उत्तर पहले ही पढ़ चुका है।\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"es\" is in REVIEWED.\nconst ES: AvatarLiveStrings = {\n checking: \"Comprobando si el avatar en vivo está disponible…\",\n needsAnswer: \"Primero elige una pregunta sugerida en el chat.\",\n needsAnswerDetail:\n \"El avatar solo puede leer en voz alta la primera respuesta.\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"Inicia un chat nuevo para usar el avatar.\",\n startNewChatDetail:\n \"El avatar solo lee en voz alta la primera respuesta de un chat, y solo si es la de una pregunta sugerida. Inicia un chat nuevo y elige una pregunta sugerida.\",\n start: \"Iniciar el avatar en vivo\",\n notNow: \"Ahora no\",\n opensInNewTab: \"(se abre en una pestaña nueva)\",\n botCheck: \"Comprobando tu navegador…\",\n connecting: \"Conectando con el avatar en vivo…\",\n speaking: \"El avatar está hablando.\",\n badge: \"Avatar de IA · no es una persona real\",\n video: \"Vídeo del avatar de IA en vivo\",\n captions: \"Subtítulos\",\n timeLeft: \"Tiempo restante\",\n stop: \"Detener\",\n tapForSound: \"Toca para activar el sonido\",\n finished: \"El avatar en vivo ha terminado.\",\n stopped: \"Has detenido el avatar.\",\n failed: \"No se pudo iniciar el avatar en vivo.\",\n interrupted: \"El avatar en vivo se detuvo antes de tiempo.\",\n answerInChat: \"La respuesta completa está en el chat.\",\n backToChat: \"Volver al chat\",\n busy: \"El avatar en vivo está ocupado en este momento. Vuelve a intentarlo en unos minutos.\",\n limits:\n \"El avatar en vivo ha alcanzado su límite por ahora. Vuelve a intentarlo más tarde.\",\n region: \"El avatar en vivo aún no está disponible en tu región.\",\n locale: \"El avatar en vivo aún no está disponible en este idioma.\",\n paused: \"El avatar en vivo está en pausa en este momento.\",\n notEligible: \"El avatar puede leer las respuestas a las preguntas sugeridas.\",\n answerClaimed: \"El avatar ya ha leído esta respuesta.\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed, including its right-to-left layout. Not shown\n// until \"ar\" is in REVIEWED.\nconst AR: AvatarLiveStrings = {\n checking: \"جارٍ التحقق من توفر الأفاتار المباشر…\",\n needsAnswer: \"اختر أولًا سؤالًا مقترحًا في الدردشة.\",\n needsAnswerDetail: \"يمكن للأفاتار قراءة الإجابة الأولى فقط بصوت عالٍ.\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"ابدأ دردشة جديدة لاستخدام الأفاتار.\",\n startNewChatDetail:\n \"يقرأ الأفاتار بصوت عالٍ الإجابة الأولى في الدردشة فقط، وفقط إذا كانت إجابة عن سؤال مقترح. ابدأ دردشة جديدة واختر سؤالًا مقترحًا.\",\n start: \"بدء الأفاتار المباشر\",\n notNow: \"ليس الآن\",\n opensInNewTab: \"(يُفتح في علامة تبويب جديدة)\",\n botCheck: \"جارٍ التحقق من متصفحك…\",\n connecting: \"جارٍ الاتصال بالأفاتار المباشر…\",\n speaking: \"الأفاتار يتحدث الآن.\",\n badge: \"أفاتار بالذكاء الاصطناعي · ليس شخصًا حقيقيًا\",\n video: \"فيديو الأفاتار المباشر بالذكاء الاصطناعي\",\n captions: \"التسميات التوضيحية\",\n timeLeft: \"الوقت المتبقي\",\n stop: \"إيقاف\",\n tapForSound: \"انقر لتشغيل الصوت\",\n finished: \"انتهى الأفاتار المباشر.\",\n stopped: \"لقد أوقفت الأفاتار.\",\n failed: \"تعذّر بدء الأفاتار المباشر.\",\n interrupted: \"توقف الأفاتار المباشر قبل أن ينتهي.\",\n answerInChat: \"الإجابة الكاملة موجودة في الدردشة.\",\n backToChat: \"العودة إلى الدردشة\",\n busy: \"الأفاتار المباشر مشغول الآن. يُرجى المحاولة مرة أخرى بعد بضع دقائق.\",\n limits: \"بلغ الأفاتار المباشر حدّه في الوقت الحالي. يُرجى المحاولة لاحقًا.\",\n region: \"الأفاتار المباشر غير متاح في منطقتك بعد.\",\n locale: \"الأفاتار المباشر غير متاح بهذه اللغة بعد.\",\n paused: \"الأفاتار المباشر متوقف مؤقتًا الآن.\",\n notEligible: \"يمكن للأفاتار قراءة إجابات الأسئلة المقترحة.\",\n answerClaimed: \"قرأ الأفاتار هذه الإجابة من قبل.\",\n};\n\n// TRANSLATION REVIEW PENDING (BOFF-9797): a draft, not yet reviewed. Not shown until \"ta\" is in REVIEWED.\nconst TA: AvatarLiveStrings = {\n checking: \"நேரலை அவதார் கிடைக்கிறதா எனச் சரிபார்க்கிறது…\",\n needsAnswer:\n \"முதலில் அரட்டையில் பரிந்துரைக்கப்பட்ட ஒரு கேள்வியைத் தேர்ந்தெடுக்கவும்.\",\n needsAnswerDetail: \"அவதார் முதல் பதிலை மட்டுமே உரக்கப் படிக்க முடியும்.\",\n // TRANSLATION REVIEW PENDING (BOFF-9797): draft.\n startNewChat: \"அவதாரைப் பயன்படுத்த புதிய அரட்டையைத் தொடங்கவும்.\",\n startNewChatDetail:\n \"ஓர் அரட்டையின் முதல் பதிலை மட்டுமே, அதுவும் பரிந்துரைக்கப்பட்ட கேள்விக்கான பதிலை மட்டுமே அவதார் உரக்கப் படிக்கும். புதிய அரட்டையைத் தொடங்கி, பரிந்துரைக்கப்பட்ட ஒரு கேள்வியைத் தேர்ந்தெடுக்கவும்.\",\n start: \"நேரலை அவதாரைத் தொடங்கு\",\n notNow: \"இப்போது வேண்டாம்\",\n opensInNewTab: \"(புதிய தாவலில் திறக்கும்)\",\n botCheck: \"உங்கள் உலாவியைச் சரிபார்க்கிறது…\",\n connecting: \"நேரலை அவதாருடன் இணைக்கிறது…\",\n speaking: \"அவதார் பேசுகிறது.\",\n badge: \"AI அவதார் · உண்மையான நபர் அல்ல\",\n video: \"நேரலை AI அவதார் வீடியோ\",\n captions: \"வசனங்கள்\",\n timeLeft: \"மீதமுள்ள நேரம்\",\n stop: \"நிறுத்து\",\n tapForSound: \"ஒலியை இயக்கத் தட்டவும்\",\n finished: \"நேரலை அவதார் முடிவடைந்தது.\",\n stopped: \"நீங்கள் அவதாரை நிறுத்தினீர்கள்.\",\n failed: \"நேரலை அவதாரைத் தொடங்க முடியவில்லை.\",\n interrupted: \"நேரலை அவதார் இடையிலேயே நின்றுவிட்டது.\",\n answerInChat: \"முழுப் பதில் அரட்டையில் உள்ளது.\",\n backToChat: \"அரட்டைக்குத் திரும்பு\",\n busy: \"நேரலை அவதார் இப்போது வேறு பயன்பாட்டில் உள்ளது. சில நிமிடங்களில் மீண்டும் முயலவும்.\",\n limits:\n \"நேரலை அவதார் தற்போதைக்குத் தன் வரம்பை எட்டிவிட்டது. பிறகு மீண்டும் முயலவும்.\",\n region: \"உங்கள் பகுதியில் நேரலை அவதார் இன்னும் கிடைக்கவில்லை.\",\n locale: \"இந்த மொழியில் நேரலை அவதார் இன்னும் கிடைக்கவில்லை.\",\n paused: \"நேரலை அவதார் இப்போது இடைநிறுத்தப்பட்டுள்ளது.\",\n notEligible:\n \"பரிந்துரைக்கப்பட்ட கேள்விகளுக்கான பதில்களை அவதார் படிக்க முடியும்.\",\n answerClaimed: \"இந்தப் பதிலை அவதார் ஏற்கெனவே படித்துவிட்டது.\",\n};\n\nconst STRINGS: Record<ExploreLocale, AvatarLiveStrings> = {\n en: EN,\n zh: ZH,\n hi: HI,\n es: ES,\n ar: AR,\n ta: TA,\n};\n\nexport function avatarLiveStrings(locale: ExploreLocale): AvatarLiveStrings {\n return STRINGS[locale] ?? EN;\n}\n\n/** One version of the consent card's copy, in one locale. */\nexport interface AvatarConsentCopy {\n title: string;\n /** What the avatar is and does, for a site with a product name. Takes `{product}`. */\n introProduct: string;\n /** The same without a product name. */\n intro: string;\n /** Who processes what when the visitor starts. */\n processing: string;\n /** What is and is not used, recorded and kept, and who it is for. */\n storage: string;\n /** The link to the site's privacy notice, `/privacy#live-avatar`. */\n privacyLink: string;\n}\n\n/**\n * The consent copy the server's `consentVersion` names, by version and then by locale. A version is added here, never\n * edited: changed wording is a new version, which the server starts asking for at the same time.\n */\nconst CONSENT: ReadonlyMap<\n string,\n Readonly<Partial<Record<ExploreLocale, AvatarConsentCopy>>>\n> = new Map([\n [\n \"web-consent-2026-11\",\n {\n en: {\n title: \"Live AI avatar (beta)\",\n introProduct:\n \"This is an AI avatar, not a real person. It reads the assistant's first eligible answer to a suggested {product} question aloud for up to a minute. The answer is AI-generated and can be wrong.\",\n intro:\n \"This is an AI avatar, not a real person. It reads the assistant's first eligible answer to a suggested question aloud for up to a minute. The answer is AI-generated and can be wrong.\",\n processing:\n \"When you start, Cloudflare checks for bots. The answer text goes to Google to create the voice. Your browser connects to LiveKit, which sees your IP address. LiveKit fetches our temporary audio file and passes the voice to Protoface, which makes the avatar video streamed through LiveKit.\",\n storage:\n \"Your microphone and camera are not used. We do not record the live session. We temporarily store the generated voice file and keep a record of this consent. The privacy notice explains our safeguards, storage periods and the providers' processing. For people aged eighteen and over.\",\n privacyLink: \"How we handle this\",\n },\n },\n ],\n [\n // The voice is no longer a stored file: the server holds it in memory and plays it into the LiveKit room for Protoface.\n \"web-consent-2026-10-31\",\n {\n en: {\n title: \"Live AI avatar (beta)\",\n introProduct:\n \"This is an AI avatar, not a real person. It reads the assistant's first eligible answer to a suggested {product} question aloud for up to a minute. The answer is AI-generated and can be wrong.\",\n intro:\n \"This is an AI avatar, not a real person. It reads the assistant's first eligible answer to a suggested question aloud for up to a minute. The answer is AI-generated and can be wrong.\",\n processing:\n \"When you start, Cloudflare checks for bots. The answer text goes to Google to create the voice. Our server sends that voice through LiveKit to Protoface, which makes the avatar video streamed through LiveKit. Your browser connects to LiveKit, which sees your IP address.\",\n storage:\n \"Your microphone and camera are not used. We do not record the live session or store the generated voice. We keep a record of this consent. The privacy notice explains our safeguards, storage periods and the providers' processing. For people aged eighteen and over.\",\n privacyLink: \"How we handle this\",\n },\n },\n ],\n]);\n\n/** The consent copy for exactly `version` in `locale`, or null when the SDK has none to show for it. */\nexport function avatarConsentCopy(\n version: string,\n locale: ExploreLocale,\n): AvatarConsentCopy | null {\n if (!isAvatarLiveLocaleReviewed(locale)) return null;\n return CONSENT.get(version)?.[locale] ?? null;\n}\n","/**\n * BOFF-9797. Cloudflare Turnstile, for the live avatar's start only.\n *\n * Nothing here runs until the visitor presses Start on the live avatar's consent card: the script is added to the page\n * then, once, and a widget is rendered for that one start (action `avatar_start`). The widget stays invisible unless\n * Cloudflare needs the visitor to interact with it. The token it returns goes to the gateway in a header and is used\n * once.\n *\n * The widget is rendered with `cData`, the binding of this check to the create request it is for (web API contract\n * v1.1: see `avatarBotBinding` in `explore-avatar-api.ts`), so it cannot be rendered before the binding is known.\n */\n\nconst SCRIPT_SRC =\n \"https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit\";\n/** How long the script may take to load before the start is given up. */\nconst SCRIPT_TIMEOUT_MS = 15_000;\n\n/** The part of Turnstile's render options used here. */\ninterface TurnstileRenderOptions {\n sitekey: string;\n action: string;\n /** Customer data Turnstile returns with the verified token: the binding to the create request. */\n cData: string;\n appearance: \"interaction-only\";\n size: \"flexible\";\n \"response-field\": false;\n callback: (token: string) => void;\n \"error-callback\": () => boolean;\n \"expired-callback\": () => void;\n \"timeout-callback\": () => void;\n}\n\n/** The part of `window.turnstile` used here. */\ninterface TurnstileApi {\n render: (\n container: HTMLElement,\n options: TurnstileRenderOptions,\n ) => string | null | undefined;\n remove: (widgetId: string) => void;\n}\n\nfunction readApi(): TurnstileApi | null {\n if (typeof window === \"undefined\") return null;\n const api = (window as unknown as { turnstile?: Partial<TurnstileApi> })\n .turnstile;\n return api &&\n typeof api.render === \"function\" &&\n typeof api.remove === \"function\"\n ? (api as TurnstileApi)\n : null;\n}\n\nlet loading: Promise<TurnstileApi> | null = null;\n\n/** Turnstile's API, adding its script to the page the first time. A failed load can be tried again later. */\nexport function loadTurnstile(): Promise<TurnstileApi> {\n const ready = readApi();\n if (ready) return Promise.resolve(ready);\n if (loading) return loading;\n loading = new Promise<TurnstileApi>((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = SCRIPT_SRC;\n script.async = true;\n script.setAttribute(\"data-boff-explore\", \"avatar-live-turnstile\");\n const fail = () => {\n clearTimeout(timer);\n loading = null;\n script.remove();\n reject(new Error(\"The bot check could not be loaded.\"));\n };\n const timer = setTimeout(fail, SCRIPT_TIMEOUT_MS);\n script.addEventListener(\"load\", () => {\n const api = readApi();\n if (!api) {\n fail();\n return;\n }\n clearTimeout(timer);\n resolve(api);\n });\n script.addEventListener(\"error\", fail);\n document.head.appendChild(script);\n });\n return loading;\n}\n\nexport interface TurnstileRun {\n /** The token, once Cloudflare has one; rejects when the check fails, expires, times out or is cancelled. */\n token: Promise<string>;\n /** Remove the widget, and reject `token` if it is still waiting. Safe to call more than once. */\n cancel: () => void;\n}\n\n/**\n * Run one bot check in `container` with `siteKey`, for `action`, bound to `cData` (or to what it resolves to: the widget\n * is rendered once its script has loaded AND the binding is known, and a binding that cannot be made fails the check).\n */\nexport function runTurnstile(\n container: HTMLElement | null,\n siteKey: string,\n action: string,\n cData: string | Promise<string>,\n): TurnstileRun {\n // A binding that cannot be made fails `token`; it is never an unhandled rejection of its own.\n Promise.resolve(cData).catch(() => undefined);\n let settled = false;\n let cancelled = false;\n let widget: { api: TurnstileApi; id: string } | null = null;\n let rejectToken: (error: Error) => void = () => undefined;\n\n const removeWidget = () => {\n if (!widget) return;\n const { api, id } = widget;\n widget = null;\n try {\n api.remove(id);\n } catch {\n // Already gone with its container.\n }\n };\n\n const token = new Promise<string>((resolve, reject) => {\n rejectToken = (error: Error) => {\n if (settled) return;\n settled = true;\n reject(error);\n };\n if (!container) {\n rejectToken(new Error(\"No place for the bot check.\"));\n return;\n }\n Promise.all([loadTurnstile(), cData]).then(\n ([api, binding]) => {\n if (cancelled || settled) return;\n const failed = () => {\n removeWidget();\n rejectToken(new Error(\"The bot check did not pass.\"));\n };\n const id = api.render(container, {\n sitekey: siteKey,\n action,\n cData: binding,\n appearance: \"interaction-only\",\n size: \"flexible\",\n \"response-field\": false,\n callback: (value: string) => {\n if (settled) return;\n settled = true;\n resolve(value);\n },\n \"error-callback\": () => {\n failed();\n // Handled here: Turnstile need not report it again.\n return true;\n },\n \"expired-callback\": failed,\n \"timeout-callback\": failed,\n });\n if (typeof id === \"string\" && id !== \"\") {\n widget = { api, id };\n if (settled) removeWidget();\n } else if (!settled) {\n rejectToken(new Error(\"The bot check could not start.\"));\n }\n },\n (error: unknown) => {\n rejectToken(\n error instanceof Error\n ? error\n : new Error(\"The bot check could not be loaded.\"),\n );\n },\n );\n });\n\n // A cancelled check nobody waits on any more is not an error worth reporting.\n token.catch(() => undefined);\n\n return {\n token,\n cancel: () => {\n cancelled = true;\n removeWidget();\n rejectToken(new Error(\"The bot check was cancelled.\"));\n },\n };\n}\n","/**\n * Substitute `{product}` and friends without pulling in a formatting library.\n *\n * A module of its own so the live avatar's view, which is loaded on its own (see `explore-avatar-live.tsx`), can use\n * it without carrying `explore-i18n.ts`, the panel's strings. `explore-i18n.ts` re-exports it.\n */\nexport function fill(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key) => values[key] ?? match);\n}\n","/**\n * Utility function to merge Tailwind CSS classes\n * Combines clsx and tailwind-merge for optimal class handling\n */\n\nimport { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge multiple class names intelligently\n * - Handles conditional classes via clsx\n * - Deduplicates and resolves Tailwind conflicts via tailwind-merge\n *\n * @example\n * ```ts\n * cn('px-4 py-2', 'bg-blue-500', { 'text-white': isActive })\n * // => 'px-4 py-2 bg-blue-500 text-white' (if isActive is true)\n * ```\n */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","/**\n * AvatarLiveView — the Avatar tab's live avatar (BOFF-9797), opt-in: its view and its state machine.\n *\n * `ExploreAvatarLive` (`explore-avatar-live.tsx`) renders this, and only once the Avatar view has been opened on a panel\n * whose host passes `avatar.live`. This file, and the requests, the words and the bot check it brings with it, is a\n * chunk of its own that a site downloads at that moment and not before; a site that never passes `avatar.live` never\n * does. It reads nothing from the page's React contexts (the package builds each entry on its own, so a context read\n * here would be a second, empty one): everything it needs comes in as props from `ExploreAvatarLive`.\n *\n * The visitor watches and listens; their browser never sends the avatar anything to say. What happens, in order:\n *\n * 1. **The tab opens** (never on page load): one availability request to the gateway's web branch. Nothing else is\n * loaded or asked for until the visitor agrees.\n * 2. **Offered, with the conversation's first answer:** a consent card (its copy is versioned; the panel shows only\n * copy written for the version the server names), Start, Not now and a link to the privacy notice. The avatar reads\n * one answer only: a conversation that is exactly a suggested question and its completed answer. A failed first\n * answer, or a second question, asks the visitor to start a new chat instead.\n * 3. **Start:** the live module (`live.load`) and the bot check load, then one create request: the contract's six\n * fields, an `Idempotency-Key` and the bot check's token, without credentials. The bot check is bound to that very\n * request (`cData`, contract v1.1), so the body is made once, before the widget is rendered.\n * 4. **Created:** the room is joined to watch only. The avatar's video, its captions, a badge saying it is an AI and\n * not a person, a countdown (never announced), Stop and Continue in Chat.\n * 5. **Ending:** Stop, leaving the tab, closing the panel or hiding the page asks the server to end the session with a\n * `keepalive` request. The server ends it on its own deadlines either way.\n *\n * Any refusal is one short sentence and \"Continue in Chat\". A route that is not there, a refused origin or a network\n * failure shows the tab as it was before the live avatar. The conversation token goes into the create request and\n * nowhere else; the session's secret and room token are kept in refs, never in the page.\n */\n\"use client\";\n\nimport {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\n\nimport {\n avatarBotBinding,\n canBindBotCheck,\n isAvatarConversationToken,\n isAvatarMessageId,\n newIdempotencyKey,\n requestAvailability,\n requestCreate,\n sendEnd,\n type AvatarCreateBody,\n type AvatarCreateResult,\n type AvatarEndReason,\n type AvatarOffer,\n type AvatarRefusal,\n type AvatarSession,\n} from \"./explore-avatar-api\";\nimport {\n avatarConsentCopy,\n avatarLiveStrings,\n type AvatarConsentCopy,\n type AvatarLiveStrings,\n} from \"./explore-avatar-i18n\";\nimport { runTurnstile, type TurnstileRun } from \"./explore-avatar-turnstile\";\nimport { fill } from \"./explore-fill\";\nimport { cn } from \"../utils/cn\";\n\nimport type {\n AvatarConversation,\n ExplorePanelAvatarLive,\n} from \"./explore-avatar-live-config\";\nimport type { ExploreLocale } from \"./explore-i18n\";\nimport type { ExploreMessage } from \"./explore-types\";\nimport type {\n AvatarLiveModule,\n ReceiveOnlyEvent,\n ReceiveOnlySession,\n} from \"../avatar-live/types\";\n\n/** Where the consent card's privacy link goes: the site's privacy notice, at its live avatar section. */\nconst PRIVACY_HREF = \"/privacy#live-avatar\";\n\n/** How long a joined room waits for the avatar's video before the session is given up. */\nconst SPEAKER_WAIT_MS = 30_000;\n/** Past a session's end, how long before the browser leaves a room that is somehow still open. */\nconst END_GRACE_MS = 10_000;\n/** How far the server's end may sit from this browser's clock before the browser counts down on its own clock. */\nconst CLOCK_TOLERANCE_MS = 5_000;\n\n/** The control each step puts focus on when the one the visitor was on has gone. */\nconst PRIMARY =\n '[data-avatar-primary], [data-boff-explore=\"panel-continue-chat\"]';\n\ninterface Offer extends AvatarOffer {\n /** The locale availability was asked for: the consent copy shown and the create request are both in this one. */\n locale: ExploreLocale;\n copy: AvatarConsentCopy;\n}\n\n/** What the page shows of a session: never its secret or its room token. */\ninterface ShownSession {\n /** When this browser counts the session as over, on its own clock. */\n endsAt: number;\n captions: { locale: string; text: string };\n}\n\n/**\n * How a session ended. `finished` means the server closed the room (the worker left, or the room was closed by the\n * server) while the avatar was live, or the session's time ran out with the room still open: the browser cannot tell the\n * avatar reading to the end from a server-side stop or a hand-over, so the words for it say only that the live avatar\n * has ended.\n */\ntype EndedHow = \"finished\" | \"stopped\" | \"failed\" | \"interrupted\";\n\ntype Phase =\n | { name: \"idle\" }\n | { name: \"checking\" }\n | { name: \"inert\" }\n | { name: \"needs-answer\"; offer: Offer }\n | { name: \"consent\"; offer: Offer; messageId: string }\n | { name: \"refused\"; reason: AvatarRefusal }\n | { name: \"bot-check\"; offer: Offer; messageId: string }\n | { name: \"creating\" }\n | { name: \"pending\"; session: ShownSession }\n | { name: \"live\"; session: ShownSession }\n | { name: \"ended\"; how: EndedHow };\n\nconst IDLE: Phase = { name: \"idle\" };\nconst INERT: Phase = { name: \"inert\" };\n\n/** One press of Start, until its create request has answered. */\ninterface StartRun {\n /** Set when the visitor (or the page) gave up on it, with the reason to end a session it still creates. */\n cancelled: AvatarEndReason | null;\n turnstile: TurnstileRun | null;\n}\n\n/** A created session, from its 201 until it ends. */\ninterface SessionHandle {\n session: AvatarSession;\n base: string;\n headers: Readonly<Record<string, string>>;\n module: AvatarLiveModule;\n /** The join, once started. */\n room: Promise<ReceiveOnlySession | null> | null;\n /** The joined room, once joined: `enablePlayback` must be called inside the visitor's tap, so not via a promise. */\n joined: ReceiveOnlySession | null;\n /** When this browser counts the session as over, on its own clock (see `begin`). */\n endsAt: number;\n /** The avatar's video has arrived. */\n speakerArrived: boolean;\n done: boolean;\n}\n\nconst REFUSAL_TEXT: Record<AvatarRefusal, keyof AvatarLiveStrings> = {\n busy: \"busy\",\n limits: \"limits\",\n region: \"region\",\n locale: \"locale\",\n paused: \"paused\",\n not_eligible: \"notEligible\",\n answer_claimed: \"answerClaimed\",\n};\n\n/** What the conversation offers the avatar to read. */\ninterface Exchange {\n /** The answer the avatar may read, or null. */\n answerId: string | null;\n /**\n * The conversation can never be read: its first answer failed or is unusable, or it has gone past the first\n * exchange. Only a new chat can be. False while there is simply nothing to read yet.\n */\n startOver: boolean;\n}\n\nconst WAITING: Exchange = { answerId: null, startOver: false };\nconst START_OVER: Exchange = { answerId: null, startOver: true };\n\n/**\n * The one answer the avatar may read, and why there is none. The avatar service accepts a conversation only when it\n * holds EXACTLY two messages: the first USER message (a suggested question) and the first ASSISTANT answer, COMPLETED.\n * This is the same rule, so the avatar is never offered, and the visitor never goes through consent and the bot check,\n * for a conversation the service would refuse:\n *\n * - exactly that exchange: its answer;\n * - nothing asked yet, or the question asked and its answer still on its way: nothing yet (the view says to choose a\n * suggested question, and offers the avatar once the answer completes);\n * - anything else (a failed or empty first answer, a second question, whatever came after a failed answer asked\n * again without Retry): never, in this conversation (the view says to start a new chat).\n *\n * That the question is one of the suggested ones is the service's to judge (`not_eligible`), not the browser's.\n */\nfunction firstExchange(\n messages: readonly ExploreMessage[] | undefined,\n): Exchange {\n if (!messages || messages.length === 0) return WAITING;\n if (messages.length > 2) return START_OVER;\n const [question, answer] = messages;\n if (question?.role !== \"USER\") return START_OVER;\n if (answer === undefined) return WAITING;\n if (answer.role !== \"ASSISTANT\") return START_OVER;\n if (answer.status === \"PENDING\" || answer.status === \"RUNNING\") {\n return WAITING;\n }\n if (\n answer.status !== \"COMPLETED\" ||\n answer.content.trim() === \"\" ||\n !isAvatarMessageId(answer.id)\n ) {\n return START_OVER;\n }\n return { answerId: answer.id, startOver: false };\n}\n\n/**\n * The step that offers `messageId` to the visitor: the consent card, unless this visit has already used that answer\n * (`claimed` holds every answer a session was created for, or that the server said it already has one for), in which\n * case it says so instead. The ways back to a consent card for an answer that may have been used in the meantime go\n * through here: the availability answer, and returning from a bot check.\n */\nfunction offering(\n offer: Offer,\n messageId: string,\n claimed: ReadonlySet<string>,\n): Phase {\n return claimed.has(messageId)\n ? { name: \"refused\", reason: \"answer_claimed\" }\n : { name: \"consent\", offer, messageId };\n}\n\nasync function loadModule(\n load: () => Promise<AvatarLiveModule>,\n): Promise<AvatarLiveModule> {\n const loaded: unknown = await load();\n const join =\n loaded !== null && typeof loaded === \"object\"\n ? (loaded as Partial<AvatarLiveModule>).joinReceiveOnly\n : undefined;\n if (typeof join !== \"function\") {\n throw new Error(\"The live avatar module could not be loaded.\");\n }\n return loaded as AvatarLiveModule;\n}\n\n/** `m:ss`. */\nfunction clock(seconds: number): string {\n const whole = Math.max(0, Math.ceil(seconds));\n return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, \"0\")}`;\n}\n\nexport interface AvatarLiveViewProps {\n live: ExplorePanelAvatarLive;\n /** The Avatar view is showing: the panel is open and its Avatar tab is selected. */\n active: boolean;\n locale: ExploreLocale;\n /** The product the panel speaks for, when it is one product's own; null on the portfolio's. */\n productName: string | null;\n /** The approved still picture. */\n still: { src: string; alt: string };\n /** The Avatar tab as it was before the live avatar: shown whenever the live avatar is not offered or not reachable. */\n fallback: ReactNode;\n /** Back to the Chat tab. Leaving the Avatar tab ends a session, like any other way out of it. */\n onContinueInChat: () => void;\n /** \"Continue in Chat\" in the panel's language: the panel's own word for it, so this chunk carries none of the panel's. */\n continueInChat: string;\n /**\n * Nothing to ask the server about: an incomplete config, no gateway, no shared conversation to read (no provider, or a\n * read-only shared one), or a locale whose strings have not been reviewed. The tab stays as it was. Decided by\n * `ExploreAvatarLive`, which also decides whether this view is loaded at all; it can change while this view is\n * mounted (the panel's locale switching), and what is under way then ends.\n */\n off: boolean;\n /** {@link avatarApiBase} of the SDK's gateway, null when there is none to use. */\n base: string | null;\n /** Headers every request carries: the alpha gateway's access headers, and nothing on production. */\n headers: Readonly<Record<string, string>>;\n /** The panel's conversation, null when there is no provider. */\n conversation: AvatarConversation | null;\n}\n\nexport function AvatarLiveView({\n live,\n active,\n locale,\n productName,\n still,\n fallback,\n onContinueInChat,\n continueInChat,\n off,\n base,\n headers,\n conversation,\n}: AvatarLiveViewProps) {\n const S = avatarLiveStrings(locale);\n const uid = useId();\n const consentTitleId = `${uid}-consent`;\n\n const { answerId, startOver } = firstExchange(conversation?.messages);\n\n const [phase, setPhase] = useState<Phase>(IDLE);\n const [blocked, setBlocked] = useState(false);\n const [now, setNow] = useState(() => Date.now());\n\n const phaseRef = useRef<Phase>(IDLE);\n /** This render's view of everything the asynchronous steps read, so they never act on a stale one. */\n const latest = useRef({ live, locale, base, headers, answerId, off });\n latest.current = { live, locale, base, headers, answerId, off };\n const conversationRef = useRef(conversation);\n conversationRef.current = conversation;\n\n const checkRef = useRef<AbortController | null>(null);\n /**\n * The locale the last availability question was asked for (or settled without asking): a later change of locale asks\n * again (see the effect on `locale`), and a view that has just asked for the new locale does not ask twice.\n */\n const askedLocale = useRef(locale);\n const startRef = useRef<StartRun | null>(null);\n const sessionRef = useRef<SessionHandle | null>(null);\n /**\n * Every answer whose session this visit has already created (or found already read): none of them is offered again.\n * A set and not the latest one: a create the visitor gave up on can answer long after they moved to another chat and\n * used its first answer, and what it reports is added to what is known, never put in its place.\n */\n const claimedRef = useRef<Set<string>>(new Set());\n\n const rootRef = useRef<HTMLDivElement>(null);\n const videoRef = useRef<HTMLVideoElement>(null);\n const audioRef = useRef<HTMLAudioElement>(null);\n const botBoxRef = useRef<HTMLDivElement>(null);\n\n const go = useCallback((next: Phase) => {\n phaseRef.current = next;\n setPhase(next);\n }, []);\n\n /** End the session: tell the server (unless it ended it), leave the room, and show how it ended. */\n const finish = useCallback(\n (how: EndedHow, reason: AvatarEndReason | null) => {\n const handle = sessionRef.current;\n if (!handle || handle.done) return;\n handle.done = true;\n sessionRef.current = null;\n if (reason !== null) {\n sendEnd({\n base: handle.base,\n headers: handle.headers,\n sessionId: handle.session.sessionId,\n secret: handle.session.endSecret,\n reason,\n });\n }\n const room = handle.joined;\n handle.joined = null;\n if (room) void room.leave().catch(() => undefined);\n setBlocked(false);\n go({ name: \"ended\", how });\n },\n [go],\n );\n\n /** Give up on a Start still on its way to a session. A session it still creates is ended with `reason`. */\n const cancelStart = useCallback((reason: AvatarEndReason) => {\n const run = startRef.current;\n if (!run) return;\n startRef.current = null;\n run.cancelled = reason;\n run.turnstile?.cancel();\n }, []);\n\n const check = useCallback(() => {\n const { live, locale, base, headers, off } = latest.current;\n checkRef.current?.abort();\n checkRef.current = null;\n askedLocale.current = locale;\n if (off || base === null) {\n go(INERT);\n return;\n }\n const controller = new AbortController();\n checkRef.current = controller;\n go({ name: \"checking\" });\n void requestAvailability({\n base,\n headers,\n site: live.site,\n locale,\n signal: controller.signal,\n }).then((result) => {\n if (checkRef.current !== controller) return;\n checkRef.current = null;\n if (result.kind === \"inert\") {\n go(INERT);\n return;\n }\n if (result.kind === \"refused\") {\n go({ name: \"refused\", reason: result.reason });\n return;\n }\n // The copy for the version the server named, in the locale it was asked about (a later locale change asks\n // again: see the effect on `locale`).\n const copy = avatarConsentCopy(result.offer.consentVersion, locale);\n // A consent version this SDK has no reviewed copy for: no card, rather than words the server does not record.\n if (copy === null) {\n go(INERT);\n return;\n }\n const offer: Offer = { ...result.offer, locale, copy };\n const messageId = latest.current.answerId;\n go(\n messageId === null\n ? { name: \"needs-answer\", offer }\n : offering(offer, messageId, claimedRef.current),\n );\n });\n }, [go]);\n\n const begin = useCallback(\n (\n session: AvatarSession,\n module: AvatarLiveModule,\n offer: Offer,\n target: { base: string; headers: Readonly<Record<string, string>> },\n ) => {\n // Count down on the server's end when this browser's clock agrees with it, else on this browser's own clock.\n const received = Date.now();\n const longest = offer.maxSessionSeconds * 1000;\n const ahead = session.endsAt - received;\n const endsAt =\n ahead > 0 && ahead <= longest + CLOCK_TOLERANCE_MS\n ? session.endsAt\n : received + longest;\n sessionRef.current = {\n session,\n base: target.base,\n headers: target.headers,\n module,\n room: null,\n joined: null,\n endsAt,\n speakerArrived: false,\n done: false,\n };\n setBlocked(false);\n setNow(received);\n go({\n name: \"pending\",\n session: { endsAt, captions: session.captions },\n });\n },\n [go],\n );\n\n const settle = useCallback(\n (\n result: AvatarCreateResult,\n run: StartRun,\n context: {\n module: AvatarLiveModule;\n offer: Offer;\n messageId: string;\n base: string;\n headers: Readonly<Record<string, string>>;\n },\n ) => {\n const created =\n result.kind === \"created\"\n ? {\n sessionId: result.session.sessionId,\n secret: result.session.endSecret,\n }\n : result.kind === \"unusable\"\n ? { sessionId: result.sessionId, secret: result.endSecret }\n : null;\n // A session now exists for this answer (this create made it, or the server says an earlier one did): it is used.\n const claimed =\n created !== null ||\n (result.kind === \"refused\" && result.reason === \"answer_claimed\");\n if (claimed) claimedRef.current.add(context.messageId);\n if (run.cancelled !== null) {\n // Given up while the request was on its way: a session it created is ended at once.\n if (created !== null) {\n sendEnd({\n base: context.base,\n headers: context.headers,\n sessionId: created.sessionId,\n secret: created.secret,\n reason: run.cancelled,\n });\n }\n // The visitor may be back on the consent card for this very answer by now (they left during the create and came\n // back before it answered): it has been read, so the card gives way to saying so rather than offering it again.\n const shown = phaseRef.current;\n if (\n claimed &&\n shown.name === \"consent\" &&\n shown.messageId === context.messageId\n ) {\n go({ name: \"refused\", reason: \"answer_claimed\" });\n }\n return;\n }\n switch (result.kind) {\n case \"created\":\n begin(result.session, context.module, context.offer, context);\n return;\n case \"unusable\":\n sendEnd({\n base: context.base,\n headers: context.headers,\n sessionId: result.sessionId,\n secret: result.endSecret,\n reason: \"client_error\",\n });\n go({ name: \"ended\", how: \"failed\" });\n return;\n case \"refused\":\n go({ name: \"refused\", reason: result.reason });\n return;\n case \"consent\":\n // The consent version moved on: ask again, and show the consent that is current now.\n check();\n return;\n case \"inert\":\n go(INERT);\n return;\n case \"failed\":\n go({ name: \"ended\", how: \"failed\" });\n return;\n }\n },\n [begin, check, go],\n );\n\n const start = useCallback(() => {\n const current = phaseRef.current;\n if (current.name !== \"consent\") return;\n const { live, base, headers } = latest.current;\n if (base === null) return;\n // No WebCrypto (a page that is not a secure context): the bot check cannot be bound to a create request, so no live\n // avatar can start here. Nothing is loaded for a start that cannot happen (no module, no bot-check script), and the\n // tab stays as it was.\n if (!canBindBotCheck()) {\n go(INERT);\n return;\n }\n const { offer, messageId } = current;\n // The create request's values, read once, here. The bot check is bound to exactly these (`avatarBotBinding`, before\n // its widget is rendered), so the request that follows it carries this same body and reads nothing again.\n const conversationToken =\n conversationRef.current?.getConversationToken() ?? null;\n const idempotencyKey = newIdempotencyKey();\n if (\n conversationToken === null ||\n !isAvatarConversationToken(conversationToken) ||\n idempotencyKey === null\n ) {\n // Nothing to create a session for: no module, no bot check.\n go({ name: \"ended\", how: \"failed\" });\n return;\n }\n const body: AvatarCreateBody = {\n site: live.site,\n locale: offer.locale,\n conversationToken,\n messageId,\n consentVersion: offer.consentVersion,\n manifestVersion: live.manifestVersion,\n };\n const run: StartRun = { cancelled: null, turnstile: null };\n startRef.current = run;\n go({ name: \"bot-check\", offer, messageId });\n // Only now that the visitor has agreed: the live module and the bot check.\n const module = loadModule(live.load);\n const turnstile = runTurnstile(\n botBoxRef.current,\n live.turnstileSiteKey,\n \"avatar_start\",\n avatarBotBinding(body),\n );\n run.turnstile = turnstile;\n void (async () => {\n let loaded: AvatarLiveModule;\n let botToken: string;\n try {\n [loaded, botToken] = await Promise.all([module, turnstile.token]);\n } catch {\n turnstile.cancel();\n if (run.cancelled === null) {\n startRef.current = null;\n go(INERT);\n }\n return;\n }\n // The widget has done its work.\n turnstile.cancel();\n if (run.cancelled !== null) return;\n go({ name: \"creating\" });\n const result = await requestCreate({\n base,\n headers,\n idempotencyKey,\n botToken,\n body,\n });\n if (startRef.current === run) startRef.current = null;\n settle(result, run, { module: loaded, offer, messageId, base, headers });\n })();\n }, [go, settle]);\n\n /** The visitor's Stop, at any step from Start on. */\n const stop = useCallback(() => {\n const current = phaseRef.current;\n if (current.name === \"bot-check\") {\n // Nothing was created: back to the consent card.\n cancelStart(\"user\");\n go(offering(current.offer, current.messageId, claimedRef.current));\n return;\n }\n if (current.name === \"creating\") {\n cancelStart(\"user\");\n go({ name: \"ended\", how: \"stopped\" });\n return;\n }\n if (current.name === \"pending\" || current.name === \"live\") {\n finish(\"stopped\", \"user\");\n }\n }, [cancelStart, finish, go]);\n\n /**\n * Leaving the Avatar view (`user`: another tab, the panel closing, or the live avatar going off) and hiding the page\n * (`page_hide`) both end what is under way. Leaving the view drops an availability check too (opening the view asks\n * again); hiding the page keeps one, and returns a bot check to the consent card, so the view is as the visitor left\n * it when they come back.\n */\n const leave = useCallback(\n (reason: \"user\" | \"page_hide\") => {\n const current = phaseRef.current;\n const how: EndedHow = reason === \"user\" ? \"stopped\" : \"interrupted\";\n switch (current.name) {\n case \"checking\": {\n if (reason !== \"user\") return;\n const controller = checkRef.current;\n checkRef.current = null;\n controller?.abort();\n go(IDLE);\n return;\n }\n case \"bot-check\":\n cancelStart(reason);\n go(\n reason === \"user\"\n ? IDLE\n : offering(current.offer, current.messageId, claimedRef.current),\n );\n return;\n case \"creating\":\n cancelStart(reason);\n go({ name: \"ended\", how });\n return;\n case \"pending\":\n case \"live\":\n finish(how, reason);\n return;\n default:\n return;\n }\n },\n [cancelStart, finish, go],\n );\n\n // The Avatar view showing, and hiding. Opening it asks again, except where this visit has already used the answer.\n //\n // The live view is also hidden while `off` puts the fallback in its place (the panel's locale switching to one whose\n // strings have not been reviewed, say). That unmounts the video and audio elements a room is attached to and takes\n // Stop away, so whatever is under way ends as it does when the visitor leaves the view: a bot check is called off, a\n // create in flight is ended once it answers, a session is ended and its room left. Coming back asks again.\n const showing = active && !off;\n useEffect(() => {\n if (!showing) {\n leave(\"user\");\n return;\n }\n const current = phaseRef.current;\n const { answerId: offered } = latest.current;\n const used = offered !== null && claimedRef.current.has(offered);\n if (current.name === \"ended\" && used) return;\n if (\n current.name === \"refused\" &&\n current.reason === \"answer_claimed\" &&\n used\n ) {\n return;\n }\n if (\n current.name === \"idle\" ||\n current.name === \"inert\" ||\n current.name === \"refused\" ||\n current.name === \"needs-answer\" ||\n current.name === \"consent\" ||\n current.name === \"ended\" ||\n // Asking, with nothing actually asking: React's strict mode unmounts and mounts a component again with the state it\n // left, and the unmount in between dropped the question. (This view mounts already showing, the first time the\n // Avatar view opens.)\n (current.name === \"checking\" && checkRef.current === null)\n ) {\n check();\n }\n }, [showing, check, leave]);\n\n // The panel's locale changing before Start: an availability answer, and the consent copy chosen for it, belong to the\n // locale they were asked about, so the view asks again (or, hidden, starts over when it next opens). A session already\n // under way keeps its own.\n useEffect(() => {\n if (askedLocale.current === locale) return;\n askedLocale.current = locale;\n const current = phaseRef.current.name;\n if (\n current !== \"checking\" &&\n current !== \"needs-answer\" &&\n current !== \"consent\" &&\n current !== \"refused\" &&\n current !== \"inert\"\n ) {\n return;\n }\n if (active) {\n check();\n } else {\n checkRef.current?.abort();\n checkRef.current = null;\n go(IDLE);\n }\n }, [active, check, go, locale]);\n\n // The first answer arriving (it may complete while the Avatar view shows), or the conversation starting over.\n useEffect(() => {\n const current = phaseRef.current;\n if (current.name === \"needs-answer\" && answerId !== null) {\n go({ name: \"consent\", offer: current.offer, messageId: answerId });\n } else if (current.name === \"consent\" && current.messageId !== answerId) {\n go(\n answerId === null\n ? { name: \"needs-answer\", offer: current.offer }\n : { ...current, messageId: answerId },\n );\n }\n }, [answerId, go]);\n\n const onRoomEvent = useCallback(\n (handle: SessionHandle, event: ReceiveOnlyEvent) => {\n if (handle.done || sessionRef.current !== handle) return;\n const wasLive = phaseRef.current.name === \"live\";\n switch (event.type) {\n case \"speaker-track\":\n if (event.kind === \"video\") handle.speakerArrived = true;\n return;\n case \"playback-blocked\":\n setBlocked(event.blocked);\n return;\n case \"speaker-left\":\n finish(\n wasLive ? \"finished\" : \"failed\",\n wasLive ? null : \"client_error\",\n );\n return;\n case \"disconnected\":\n if (event.byServer) finish(wasLive ? \"finished\" : \"failed\", null);\n else finish(wasLive ? \"interrupted\" : \"failed\", \"client_error\");\n return;\n }\n },\n [finish],\n );\n\n // A created session: join its room once the video and audio elements are on the page.\n useEffect(() => {\n if (phase.name !== \"pending\") return;\n const handle = sessionRef.current;\n if (!handle || handle.room !== null || handle.done) return;\n const video = videoRef.current;\n const audio = audioRef.current;\n if (!video || !audio) {\n finish(\"failed\", \"client_error\");\n return;\n }\n let joining: Promise<ReceiveOnlySession>;\n try {\n joining = handle.module.joinReceiveOnly({\n url: handle.session.join.livekitUrl,\n token: handle.session.join.participantToken,\n workerIdentity: handle.session.join.workerIdentity,\n video,\n audio,\n onEvent: (event) => onRoomEvent(handle, event),\n });\n } catch (error) {\n joining = Promise.reject(error);\n }\n handle.room = joining.then(\n (room) => {\n if (handle.done) {\n void room.leave().catch(() => undefined);\n return null;\n }\n handle.joined = room;\n return room;\n },\n () => {\n if (!handle.done) finish(\"failed\", \"client_error\");\n return null;\n },\n );\n }, [phase.name, finish, onRoomEvent]);\n\n // While a session lasts: give up on a speaker who never comes, and leave a room still open after the session's end.\n useEffect(() => {\n if (phase.name !== \"pending\" && phase.name !== \"live\") return;\n const handle = sessionRef.current;\n if (!handle) return;\n const timers: Array<ReturnType<typeof setTimeout>> = [];\n if (phase.name === \"pending\") {\n timers.push(\n setTimeout(() => {\n if (sessionRef.current === handle && !handle.speakerArrived) {\n finish(\"failed\", \"client_error\");\n }\n }, SPEAKER_WAIT_MS),\n );\n }\n timers.push(\n setTimeout(\n () => {\n if (sessionRef.current !== handle) return;\n finish(\n phaseRef.current.name === \"live\" ? \"finished\" : \"failed\",\n \"client_error\",\n );\n },\n Math.max(0, handle.endsAt + END_GRACE_MS - Date.now()),\n ),\n );\n return () => timers.forEach((timer) => clearTimeout(timer));\n }, [phase.name, finish]);\n\n // The countdown: once a second while a session lasts.\n const ticking = phase.name === \"pending\" || phase.name === \"live\";\n useEffect(() => {\n if (!ticking) return;\n const timer = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(timer);\n }, [ticking]);\n\n // Hiding the page (another app, another tab, leaving) ends a session.\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const onPageHide = () => leave(\"page_hide\");\n const onVisibility = () => {\n if (document.visibilityState === \"hidden\") leave(\"page_hide\");\n };\n window.addEventListener(\"pagehide\", onPageHide);\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => {\n window.removeEventListener(\"pagehide\", onPageHide);\n document.removeEventListener(\"visibilitychange\", onVisibility);\n };\n }, [leave]);\n\n // Unmounted with something under way: end it, as closing the panel would.\n useEffect(\n () => () => {\n const controller = checkRef.current;\n checkRef.current = null;\n controller?.abort();\n const run = startRef.current;\n startRef.current = null;\n if (run) {\n run.cancelled = \"user\";\n run.turnstile?.cancel();\n }\n const handle = sessionRef.current;\n sessionRef.current = null;\n if (handle && !handle.done) {\n handle.done = true;\n sendEnd({\n base: handle.base,\n headers: handle.headers,\n sessionId: handle.session.sessionId,\n secret: handle.session.endSecret,\n reason: \"user\",\n });\n if (handle.joined) void handle.joined.leave().catch(() => undefined);\n }\n },\n [],\n );\n\n // Each step's own control takes focus when the one the visitor was on has gone (Start, once pressed, say): focus\n // left on the page's body would also take Escape out of the panel. \"Tap to turn on sound\" is one of those controls:\n // it goes the moment playback resumes (`blocked` clears), so focus moves on to Stop rather than falling to the body.\n useEffect(() => {\n if (!active) return;\n const focused = document.activeElement;\n if (focused && focused !== document.body && focused.isConnected) return;\n rootRef.current?.querySelector<HTMLElement>(PRIMARY)?.focus();\n }, [active, phase.name, blocked]);\n\n const onPlaying = useCallback(() => {\n const current = phaseRef.current;\n const handle = sessionRef.current;\n if (current.name !== \"pending\" || !handle) return;\n handle.speakerArrived = true;\n go({ name: \"live\", session: current.session });\n }, [go]);\n\n const enablePlayback = useCallback(() => {\n // Called straight from the tap: browsers allow sound only from inside the visitor's gesture.\n void sessionRef.current?.joined?.enablePlayback().catch(() => undefined);\n }, []);\n\n if (off || phase.name === \"inert\") {\n return (\n // `display: contents`: the earlier Avatar view's picture, line and button lay out in the pane exactly as before.\n <div\n ref={rootRef}\n style={{ display: \"contents\" }}\n data-boff-explore=\"avatar-live\"\n data-phase={off ? \"off\" : \"inert\"}\n >\n {fallback}\n </div>\n );\n }\n\n const primaryButton =\n \"inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background motion-reduce:transition-none\";\n const secondaryButton =\n \"inline-flex items-center justify-center rounded-md border border-border bg-background px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background motion-reduce:transition-none\";\n const stillPicture = (small: boolean) => (\n <img\n src={still.src}\n alt={still.alt}\n decoding=\"async\"\n width={small ? 64 : 128}\n height={small ? 64 : 128}\n className={cn(\n \"shrink-0 rounded-full border border-border object-cover shadow-sm\",\n small ? \"h-16 w-16\" : \"h-32 w-32\",\n )}\n />\n );\n const continueButton = (\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-continue\"\n className={primaryButton}\n onClick={onContinueInChat}\n >\n {continueInChat}\n </button>\n );\n const stopButton = (\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-stop\"\n className={secondaryButton}\n onClick={stop}\n >\n {S.stop}\n </button>\n );\n\n // The headline of each step, in the one polite status region: announced as it changes, the countdown never.\n const headline: Record<Phase[\"name\"], string> = {\n idle: \"\",\n checking: S.checking,\n inert: \"\",\n \"needs-answer\": startOver ? S.startNewChat : S.needsAnswer,\n consent: \"\",\n refused: phase.name === \"refused\" ? S[REFUSAL_TEXT[phase.reason]] : \"\",\n \"bot-check\": S.botCheck,\n creating: S.connecting,\n pending: S.connecting,\n live: S.speaking,\n ended: phase.name === \"ended\" ? S[phase.how] : \"\",\n };\n const outcome =\n phase.name === \"needs-answer\" ||\n phase.name === \"refused\" ||\n phase.name === \"ended\";\n\n let top: ReactNode = null;\n let media: ReactNode = stillPicture(false);\n let body: ReactNode = null;\n let actions: ReactNode = null;\n\n switch (phase.name) {\n case \"needs-answer\":\n // Nothing to read yet (choose a suggested question), or never in this conversation (start a new chat).\n body = (\n <p className=\"text-sm text-muted-foreground\">\n {startOver ? S.startNewChatDetail : S.needsAnswerDetail}\n </p>\n );\n actions = continueButton;\n break;\n case \"consent\": {\n const { copy } = phase.offer;\n media = stillPicture(true);\n body = (\n <section\n aria-labelledby={consentTitleId}\n data-boff-explore=\"avatar-live-consent\"\n className=\"w-full max-w-sm rounded-lg border border-border p-4 text-start\"\n >\n <h2 id={consentTitleId} className=\"text-base font-semibold\">\n {copy.title}\n </h2>\n <p className=\"mt-2 text-sm\">\n {productName === null\n ? copy.intro\n : fill(copy.introProduct, { product: productName })}\n </p>\n <p className=\"mt-2 text-sm text-muted-foreground\">\n {copy.processing}\n </p>\n <p className=\"mt-2 text-sm text-muted-foreground\">{copy.storage}</p>\n <a\n href={PRIVACY_HREF}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n data-boff-explore=\"avatar-live-privacy\"\n className=\"mt-2 inline-block text-sm font-medium text-primary underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {copy.privacyLink}\n <span className=\"sr-only\"> {S.opensInNewTab}</span>\n </a>\n </section>\n );\n actions = (\n <div className=\"flex flex-wrap items-center justify-center gap-2\">\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-start\"\n className={primaryButton}\n onClick={start}\n >\n {S.start}\n </button>\n <button\n type=\"button\"\n data-boff-explore=\"avatar-live-not-now\"\n className={secondaryButton}\n onClick={onContinueInChat}\n >\n {S.notNow}\n </button>\n </div>\n );\n break;\n }\n case \"refused\":\n actions = continueButton;\n break;\n case \"bot-check\":\n case \"creating\":\n actions = stopButton;\n break;\n case \"pending\":\n case \"live\": {\n const playing = phase.name === \"live\";\n const left = Math.max(0, (phase.session.endsAt - now) / 1000);\n top = (\n <p\n data-boff-explore=\"avatar-live-badge\"\n className=\"rounded-full bg-muted px-3 py-1 text-xs font-medium text-foreground\"\n >\n {S.badge}\n </p>\n );\n media = (\n <div className=\"relative h-48 w-48 shrink-0 overflow-hidden rounded-xl border border-border bg-muted\">\n <video\n ref={videoRef}\n aria-label={S.video}\n data-boff-explore=\"avatar-live-video\"\n playsInline\n autoPlay\n muted\n onPlaying={onPlaying}\n className={cn(\n \"h-full w-full object-cover\",\n !playing && \"opacity-0\",\n )}\n />\n {playing ? null : (\n <img\n src={still.src}\n alt=\"\"\n decoding=\"async\"\n className=\"absolute inset-0 h-full w-full object-cover\"\n />\n )}\n <audio ref={audioRef} data-boff-explore=\"avatar-live-audio\" />\n </div>\n );\n body = (\n <>\n <section\n aria-label={S.captions}\n data-boff-explore=\"avatar-live-captions\"\n lang={phase.session.captions.locale || undefined}\n dir=\"auto\"\n tabIndex={0}\n className=\"max-h-32 w-full max-w-sm overflow-y-auto rounded-lg bg-muted p-3 text-start text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {phase.session.captions.text}\n </section>\n <p className=\"text-xs text-muted-foreground\">{S.answerInChat}</p>\n <p className=\"text-sm tabular-nums text-muted-foreground\">\n {S.timeLeft}{\" \"}\n <span role=\"timer\" data-boff-explore=\"avatar-live-countdown\">\n {clock(left)}\n </span>\n </p>\n </>\n );\n actions = (\n <div className=\"flex flex-wrap items-center justify-center gap-2\">\n {blocked ? (\n <button\n type=\"button\"\n data-boff-explore=\"avatar-live-sound\"\n className={primaryButton}\n onClick={enablePlayback}\n >\n {S.tapForSound}\n </button>\n ) : null}\n {stopButton}\n <button\n type=\"button\"\n data-boff-explore=\"avatar-live-continue\"\n className={secondaryButton}\n onClick={onContinueInChat}\n >\n {continueInChat}\n </button>\n </div>\n );\n break;\n }\n case \"ended\":\n body = <p className=\"text-sm text-muted-foreground\">{S.answerInChat}</p>;\n actions = (\n <button\n type=\"button\"\n data-avatar-primary=\"\"\n data-boff-explore=\"avatar-live-back\"\n className={primaryButton}\n onClick={onContinueInChat}\n >\n {S.backToChat}\n </button>\n );\n break;\n default:\n break;\n }\n\n // The same slots in every step, so the status region and the bot check's box stay the same elements throughout.\n return (\n <div\n ref={rootRef}\n data-boff-explore=\"avatar-live\"\n data-phase={phase.name}\n className=\"flex max-h-full w-full flex-col items-center gap-4 overflow-y-auto\"\n >\n {top}\n {media}\n <p\n role=\"status\"\n data-boff-explore=\"avatar-live-status\"\n className={\n outcome ? \"text-base font-semibold\" : \"text-sm text-muted-foreground\"\n }\n >\n {headline[phase.name]}\n </p>\n {body}\n <div ref={botBoxRef} data-boff-explore=\"avatar-live-bot-check\" />\n {actions}\n </div>\n );\n}\n"]}