@ada-cx/messaging-sdk 1.6.9 → 1.8.0

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.
@@ -62,7 +62,8 @@ export interface CoreChannelDependencies extends BaseChannelDependencies {
62
62
  setCrossWindowLiveChatActive: (value: boolean) => void;
63
63
  setSensitiveMetaFields: (fields: Record<string, unknown>) => void;
64
64
  /** Whether the host already delivered sensitiveMetaFields via the public setter,
65
- * so the core.ready init replay skips re-sending its frozen mount-time snapshot. */
65
+ * so the core.ready init replay skips re-sending its frozen mount-time snapshot.
66
+ * A trigger carrying sensitive fields also latches on send. */
66
67
  hasHostSentSensitiveMetaFields?: () => boolean;
67
68
  setHostViewportExpanded: (expanded: boolean) => void;
68
69
  setCustomAppFrameStyles: (styles: CustomAppFrameStyles) => void;
@@ -83,7 +83,7 @@ export interface AdaMessagingSettings {
83
83
  */
84
84
  allowMetaFieldsInReset?: boolean;
85
85
  /**
86
- * When true, unlocks the programmatic-control surface — `sendMessage()`,
86
+ * When true, unlocks `sendMessage()`, `selectQuickReply()`, `triggerPlaybook()`,
87
87
  * `setComposerText()`, `setDelegate()`, `getMessages()`, `getConversation()`,
88
88
  * and the `ada:message:sent` / `ada:message:received` events. Defaults to
89
89
  * false for security; the value is locked on the first config and cannot be
@@ -232,6 +232,10 @@ export interface PublicMessage {
232
232
  /** "programmatic" for SDK-originated sends; absent otherwise (legacy parity). */
233
233
  origin?: "programmatic";
234
234
  }
235
+ export interface TriggerPlaybookOptions {
236
+ metaFields?: Record<string, unknown>;
237
+ sensitiveMetaFields?: Record<string, unknown>;
238
+ }
235
239
  /** Result returned by sendMessage() once Messaging accepts the user message. */
236
240
  export interface SendMessageResult {
237
241
  id: string;
@@ -1,4 +1,4 @@
1
- import type { AdaMessagingClientConfig, AdaMessagingStartOptions, AdaSdkEventCallback, ConversationInfo, Delegate, MetaFieldValue, PublicMessage, ResetParams, SendMessageResult, WindowInfo } from "./client-types.js";
1
+ import type { AdaMessagingClientConfig, AdaMessagingStartOptions, AdaSdkEventCallback, ConversationInfo, Delegate, MetaFieldValue, PublicMessage, ResetParams, SendMessageResult, TriggerPlaybookOptions, WindowInfo } from "./client-types.js";
2
2
  /**
3
3
  * Ada Messaging Client — thin coordinator
4
4
  *
@@ -398,6 +398,7 @@ declare class AdaMessagingClient {
398
398
  * window.adaEmbed.setMetaFields({ userId: "u123", plan: "pro" });
399
399
  */
400
400
  setMetaFields(fields: Record<string, unknown>): void;
401
+ private _retainMetaFields;
401
402
  /**
402
403
  * Show or hide the Ada dashboard test-mode banner ("Testing Process: X").
403
404
  * `null` (or empty) hides it. Dashboard-only — only the Ada dashboard calls this.
@@ -447,6 +448,18 @@ declare class AdaMessagingClient {
447
448
  * window.adaEmbed.sendMessage("I need help with my order");
448
449
  */
449
450
  sendMessage(body: string): Promise<SendMessageResult>;
451
+ triggerPlaybook(playbookId: string, options?: TriggerPlaybookOptions): Promise<void>;
452
+ /**
453
+ * Select a quick reply from the current transcript. Requires `enableProgrammaticControl`.
454
+ * Resolves when core accepts the send. Core reads the reply fields from its own transcript.
455
+ *
456
+ * @param messageId - The ID returned by `getMessages()` or `ada:message:received`.
457
+ * @param index - The zero-based index in `data.quickReplies`.
458
+ *
459
+ * @example
460
+ * await window.adaEmbed.selectQuickReply(message.id, 0);
461
+ */
462
+ selectQuickReply(messageId: string, index: number): Promise<void>;
450
463
  /**
451
464
  * Handle an incoming push notification by opening the chat drawer.
452
465
  * Typically called from your notification service worker or app delegate.
@@ -1,4 +1,4 @@
1
- import type { AdaMessagingStartOptions, AdaSdkEventCallback, ConversationInfo, Delegate, MetaFieldValue, PublicMessage, ResetParams, SendMessageResult, WindowInfo } from "./client-types.js";
1
+ import type { AdaMessagingStartOptions, AdaSdkEventCallback, ConversationInfo, Delegate, MetaFieldValue, PublicMessage, ResetParams, SendMessageResult, TriggerPlaybookOptions, WindowInfo } from "./client-types.js";
2
2
  /** One queued call captured by the embed loader before the SDK was ready. */
3
3
  export interface LoaderQueueAction {
4
4
  method: string;
@@ -124,6 +124,10 @@ export interface AdaEmbedInterface {
124
124
  * `enableProgrammaticControl`; resolves the accepted message id.
125
125
  */
126
126
  sendMessage: (body: string) => Promise<SendMessageResult>;
127
+ /** Start a specific Playbook; requires enableProgrammaticControl and the Playbook's startable_from_sdk setting; resolves on accept, rejects with the refusal reason. */
128
+ triggerPlaybook: (playbookId: string, options?: TriggerPlaybookOptions) => Promise<void>;
129
+ /** Select a stored quick reply by index. Requires `enableProgrammaticControl`. */
130
+ selectQuickReply: (messageId: string, index: number) => Promise<void>;
127
131
  /** Open the chat in response to a host-handled push notification tap. */
128
132
  handleNotification: () => Promise<void>;
129
133
  /**
@@ -503,11 +503,22 @@ export interface SdkToFrameEvents {
503
503
  };
504
504
  /** Hide the bot greeting popup in the intro frame (SDK → intro) */
505
505
  "intro.greeting.hide": undefined;
506
+ "sdk.playbook.trigger": {
507
+ requestId: string;
508
+ playbookId: string;
509
+ metaFields?: Record<string, unknown>;
510
+ sensitiveMetaFields?: Record<string, unknown>;
511
+ };
506
512
  /** Send a user message into the conversation (SDK → core) */
507
513
  "sdk.message.send": {
508
514
  requestId?: string;
509
515
  body: string;
510
516
  };
517
+ "sdk.quickReply.select": {
518
+ requestId: string;
519
+ messageId: string;
520
+ index: number;
521
+ };
511
522
  /** Respond to a Zendesk Chat auth token request (SDK → core) */
512
523
  "sdk.zd.auth.response": {
513
524
  token: string | null;
@@ -708,12 +719,21 @@ export interface FrameToSdkEvents {
708
719
  "core.ready": undefined;
709
720
  /** Core installed its SDK message router and can accept reset-bound commands. */
710
721
  "core.protocol.ready": undefined;
722
+ "core.playbook.response": {
723
+ requestId: string;
724
+ accepted?: boolean;
725
+ error?: string;
726
+ };
711
727
  /** Core responds to a programmatic sendMessage request (core → SDK) */
712
728
  "core.message.response": {
713
729
  requestId: string;
714
730
  id?: string;
715
731
  error?: string;
716
732
  };
733
+ "core.quickReply.response": {
734
+ requestId: string;
735
+ error?: string;
736
+ };
717
737
  /** Core confirmed an sdk.reset durable clear/reconfiguration barrier. */
718
738
  "core.reset.response": {
719
739
  requestId: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AdaMessagingClient } from "./client/client.js";
2
- export type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo, } from "./client/client-types.js";
2
+ export type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, TriggerPlaybookOptions, WindowInfo, } from "./client/client-types.js";
3
3
  export { type ChatHtmlConfig, resolveChatHtmlConfig, } from "./client/config-helpers.js";
4
4
  export type { AdaEmbedInterface, LoaderQueueAction, LoaderQueueActionOutcome, LoaderQueueActionOutcomeHandler, } from "./client/embed-interface.js";
5
5
  export { createAdaEmbedInterface, dispatchEmbedLoaderInitialActionQueue, dispatchEmbedLoaderInitialActionQueueForAtomicHandoff, } from "./client/embed-interface.js";
@@ -1,4 +1,4 @@
1
- import type { MetaFieldValue } from "./client/client-types.js";
1
+ import type { MetaFieldValue, TriggerPlaybookOptions } from "./client/client-types.js";
2
2
  import type { HostTelemetryContext } from "./host-telemetry.js";
3
3
  /** Which web runtime the webview mounts: the Messaging SDK or legacy embed2/Chat. */
4
4
  export type AdaWebSdkMode = "messaging" | "legacy";
@@ -113,6 +113,8 @@ interface LegacyAdaEmbed {
113
113
  reset?: (payload?: unknown) => unknown;
114
114
  setLanguage?: (language: string) => unknown;
115
115
  sendMessage?: (body: string) => unknown;
116
+ triggerPlaybook?: (playbookId: string, options?: TriggerPlaybookOptions) => unknown;
117
+ selectQuickReply?: (messageId: string, index: number) => unknown;
116
118
  setMetaFields?: (fields: Record<string, unknown>) => unknown;
117
119
  setSensitiveMetaFields?: (fields: Record<string, unknown>) => unknown;
118
120
  setDeviceToken?: (token: string) => unknown;
@@ -69,7 +69,7 @@ var UNSTAMPED_SHA_PATTERN = /^0{40}$/;
69
69
  * unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns
70
70
  * `false`); only published tarballs carry a real SHA.
71
71
  */
72
- var CDN_BUILD_SHA = "5d21963652bb4111febf12f4ad58845073726264";
72
+ var CDN_BUILD_SHA = "9127673bc66718428b8a960ffb074e6c00adf0b5";
73
73
  /**
74
74
  * Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit
75
75
  * SHA rather than the unstamped repo placeholder.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/build-info.ts","../../src/client/embed-lifecycle.ts","../../src/npm/loader.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","// The repo copy carries the 40-zero placeholder; the publish workflow\n// (.github/workflows/messaging-publish-web-packages.yml) stamps the real\n// commit SHA into the built output via scripts/stamp-cdn-build-sha.mjs and\n// verifies the packed tarball before `npm publish`. Keep the placeholder as\n// a single 40-zero string literal: the stamp is a same-length text\n// replacement, so source maps stay valid.\nconst GIT_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_SHA_PATTERN = /^0{40}$/;\n\n/**\n * Git commit SHA of the monorepo commit this npm version was published from.\n * The CDN pipeline deploys each main commit's runtime under an immutable\n * SHA root, so this value names the CDN build associated with this npm\n * version. Pass it as the `pinBuildSha` loader option to load exactly that\n * runtime build — not recommended for production (see the README).\n *\n * In the repository, and in any locally built copy, the value is the\n * unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns\n * `false`); only published tarballs carry a real SHA.\n */\nexport const CDN_BUILD_SHA: string = \"5d21963652bb4111febf12f4ad58845073726264\";\n\n/**\n * Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit\n * SHA rather than the unstamped repo placeholder.\n */\nexport function isCdnBuildShaStamped(sha: string = CDN_BUILD_SHA): boolean {\n\tconst normalized = sha.trim().toLowerCase();\n\treturn (\n\t\tGIT_SHA_PATTERN.test(normalized) && !UNSTAMPED_SHA_PATTERN.test(normalized)\n\t);\n}\n","/**\n * Lifecycle channel between `createAdaEmbedInterface` and the npm loader's\n * memo: a non-enumerable getter over closure state, so the loader never\n * mutates the public surface and `Object.freeze` on the facade still works.\n * `Symbol.for` because the loader and the CDN runtime are separate builds;\n * a runtime that predates the getter yields `undefined` — degrade gracefully.\n */\nexport const EMBED_LIFECYCLE_STOPPED = Symbol.for(\n\t\"ada-cx/messaging-sdk/embed-stopped\",\n);\n\n/** Read the facade's stopped flag; `undefined` when the runtime predates it. */\nexport function readEmbedStoppedFlag(ada: object): boolean | undefined {\n\tconst value = (ada as Record<symbol, unknown>)[EMBED_LIFECYCLE_STOPPED];\n\treturn typeof value === \"boolean\" ? value : undefined;\n}\n\n/** Define the getter at facade creation time, before any host freeze. */\nexport function defineEmbedStoppedFlag(\n\tada: object,\n\treadStopped: () => boolean,\n): void {\n\tObject.defineProperty(ada, EMBED_LIFECYCLE_STOPPED, {\n\t\tget: readStopped,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n}\n","import type { AdaMessagingClient } from \"../client/client\";\nimport type { AdaMessagingStartOptions } from \"../client/client-types\";\nimport type {\n\tAdaEmbedInterface,\n\tcreateAdaEmbedInterface,\n\tdispatchEmbedLoaderInitialActionQueue,\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff,\n} from \"../client/embed-interface\";\nimport { readEmbedStoppedFlag } from \"../client/embed-lifecycle\";\nimport type {\n\tmountAdaWebViewRuntime,\n\tresolveAdaWebViewRuntimeAssets,\n} from \"../mobile-webview-runtime\";\n\n/**\n * Production CDN root the loader resolves the SDK bootstrap from when no\n * `cdnBase` override is given. The npm package never pins a runtime version;\n * the bootstrap at this root resolves the current rollout at load time.\n */\nexport const DEFAULT_MESSAGING_CDN_BASE =\n\t\"https://messaging-assets.ada.support/\";\n\nexport const FALLBACK_MESSAGING_CDN_BASE =\n\t\"https://static.ada.support/messaging/\";\n\nconst SDK_BOOTSTRAP_FILENAME = \"sdk.js\";\n\n// The CDN pipeline deploys each main commit's runtime as an immutable\n// SHA-rooted entry (`<cdnBase>/<sha>/sdk/index.js`); the mutable `sdk.js`\n// bootstrap resolves the current rollout to one of those roots at load time.\n// A pin bypasses the bootstrap and imports one root directly.\nconst PINNED_SDK_ENTRY_PATH = \"sdk/index.js\";\n\n// Strict on purpose: the pin is interpolated into a CDN path, so only a full\n// lowercase 40-hex git SHA may pass (mirrors scripts/sdk.js's\n// VERSION_OVERRIDE_PATTERN security boundary, minus the short-SHA and pr-N\n// forms — the npm surface pins exactly what CDN_BUILD_SHA carries).\nconst PINNED_BUILD_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_BUILD_SHA_PATTERN = /^0{40}$/;\n\n/** Why a {@link MessagingSdkLoadError} was raised. */\nexport type MessagingSdkLoadErrorCode =\n\t/**\n\t * The `cdnBase` option is not a valid `https:` URL (plain `http:` is\n\t * allowed only for loopback hosts).\n\t */\n\t| \"invalid_cdn_base\"\n\t/** The `pinBuildSha` option is not a full 40-character hex git SHA. */\n\t| \"invalid_build_sha\"\n\t/**\n\t * The `pinBuildSha` option is the unstamped 40-zero placeholder: this\n\t * copy of the package was built from the repository, not published, so\n\t * its `CDN_BUILD_SHA` names no CDN build.\n\t */\n\t| \"unstamped_build_sha\"\n\t/** The dynamic import of the CDN bootstrap failed (fetch or evaluation). */\n\t| \"sdk_import_failed\"\n\t/** The imported module does not expose the Ada Messaging SDK surface. */\n\t| \"sdk_module_invalid\";\n\n/** Typed failure raised by {@link loadMessagingSdk} and {@link loadAdaMessaging}. */\nexport class MessagingSdkLoadError extends Error {\n\treadonly code: MessagingSdkLoadErrorCode;\n\tdeclare readonly fallbackCause?: MessagingSdkLoadError;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: MessagingSdkLoadErrorCode,\n\t\tcause?: unknown,\n\t\tfallbackCause?: MessagingSdkLoadError,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MessagingSdkLoadError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) {\n\t\t\tthis.cause = cause;\n\t\t}\n\t\tif (fallbackCause !== undefined) {\n\t\t\tObject.defineProperty(this, \"fallbackCause\", {\n\t\t\t\tvalue: fallbackCause,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * The programmatic messaging interface {@link loadAdaMessaging} resolves. An\n * alias of the runtime's `AdaEmbedInterface`, which keeps that name because it\n * is also the legacy `window.adaEmbed` compat facade.\n */\nexport type AdaMessagingInterface = AdaEmbedInterface;\n\n/**\n * The public surface of the CDN-resolved SDK module, as loaded from\n * `<cdnBase>/sdk.js`. Types only — the implementation always comes from the\n * CDN at load time and is never part of this npm package.\n */\nexport interface MessagingSdkModule {\n\tAdaMessagingClient: typeof AdaMessagingClient;\n\tcreateAdaEmbedInterface: typeof createAdaEmbedInterface;\n\tdispatchEmbedLoaderInitialActionQueue: typeof dispatchEmbedLoaderInitialActionQueue;\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff: typeof dispatchEmbedLoaderInitialActionQueueForAtomicHandoff;\n\tmountAdaWebViewRuntime: typeof mountAdaWebViewRuntime;\n\tresolveAdaWebViewRuntimeAssets: typeof resolveAdaWebViewRuntimeAssets;\n}\n\ntype ImportSdkModule = (url: string) => Promise<unknown>;\n\nexport interface LoadMessagingSdkOptions {\n\t/**\n\t * CDN root to resolve `sdk.js` from. Must be an `https:` URL; plain\n\t * `http:` is accepted only for loopback hosts (`localhost`, `127.0.0.1`,\n\t * `[::1]`, `*.localhost`) during local development. Defaults to the\n\t * production root ({@link DEFAULT_MESSAGING_CDN_BASE}). An explicit value,\n\t * including {@link FALLBACK_MESSAGING_CDN_BASE}, disables the automatic\n\t * static-root fallback.\n\t */\n\tcdnBase?: string;\n\t/**\n\t * Full 40-character git commit SHA of a deployed CDN build. When set, the\n\t * loader skips the rollout bootstrap and imports that build's immutable\n\t * entry (`<cdnBase>/<sha>/sdk/index.js`) directly. Pass the package's\n\t * `CDN_BUILD_SHA` export to pin the build associated with this npm\n\t * version. NOT recommended for production: a pinned runtime misses Ada's\n\t * fixes and rollouts, and may predate server contract changes. Composes\n\t * with `cdnBase` for staged validation.\n\t */\n\tpinBuildSha?: string;\n\t/**\n\t * Import seam for unit tests. Defaults to a native dynamic `import()` of\n\t * the resolved bootstrap URL.\n\t */\n\timportModule?: ImportSdkModule;\n}\n\n// Both annotations are load-bearing: bundlers rewrite bare dynamic imports,\n// and this specifier must reach the browser untouched so the runtime always\n// resolves from Ada's CDN. The npm build for this entry is unminified so the\n// annotations survive into the published output.\nconst defaultImportModule: ImportSdkModule = (url) =>\n\timport(/* webpackIgnore: true */ /* @vite-ignore */ url);\n\n// Keyed by import seam so production memoizes on the module-level default\n// while each injected test seam gets an isolated cache.\ninterface SdkLoaderState {\n\timports: Map<string, Promise<MessagingSdkModule>>;\n\tdefaultLoads: Map<string, Promise<MessagingSdkModule>>;\n}\n\nconst loadsByImporter = new WeakMap<ImportSdkModule, SdkLoaderState>();\n\n// Share the warning across independently bundled copies of this loader.\nconst FALLBACK_WARNING_KEY = Symbol.for(\"ada.messaging.sdk.fallbackWarning\");\nconst warningScope = globalThis as typeof globalThis & {\n\t[FALLBACK_WARNING_KEY]?: boolean;\n};\n\n// Mirrors the loopback semantics of the shared `isLoopbackHost` /\n// `validateMessagingEndpoint` (shared/utils/src/url.ts) and the bridge\n// loader's copy (packages/bridge/src/npm/loader.ts). Inlined because the\n// published loader must stay dependency-free; keep the host set in sync.\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\", \"::1\"]);\n\nfunction isLoopbackHostname(hostname: string): boolean {\n\tconst normalized = hostname.trim().toLowerCase();\n\t// `*.localhost` resolves to the loopback interface and is \"potentially\n\t// trustworthy\" per the Secure Contexts spec; no production host ends in\n\t// `.localhost`.\n\treturn LOOPBACK_HOSTS.has(normalized) || normalized.endsWith(\".localhost\");\n}\n\nfunction resolvePinnedBuildSha(pinBuildSha: string): string {\n\tconst sha = pinBuildSha.trim().toLowerCase();\n\tif (!PINNED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The pinBuildSha option must be a full 40-character hex git SHA: \"${pinBuildSha}\".`,\n\t\t\t\"invalid_build_sha\",\n\t\t);\n\t}\n\tif (UNSTAMPED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t\"The pinBuildSha option is the unstamped CDN_BUILD_SHA placeholder. Only the published npm package carries a stamped SHA; a repository or local build cannot pin a CDN build.\",\n\t\t\t\"unstamped_build_sha\",\n\t\t);\n\t}\n\treturn sha;\n}\n\n/**\n * The runtime this URL serves carries the SDK's security logic (endpoint\n * validation, session handling, the origin checks), so a cleartext transport\n * would let an on-path attacker replace it wholesale: `https:` is required,\n * with a loopback-only `http:` exception for local development.\n */\nfunction resolveSdkBootstrapUrl(\n\tcdnBase: string | undefined,\n\tpinBuildSha: string | undefined,\n): string {\n\tconst base = (cdnBase ?? DEFAULT_MESSAGING_CDN_BASE).trim();\n\t// Resolving against a base without a trailing slash would drop its last\n\t// path segment, so normalize before building the bootstrap URL.\n\tconst normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n\tconst entryPath =\n\t\tpinBuildSha === undefined\n\t\t\t? SDK_BOOTSTRAP_FILENAME\n\t\t\t: `${resolvePinnedBuildSha(pinBuildSha)}/${PINNED_SDK_ENTRY_PATH}`;\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(entryPath, normalizedBase);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option is not a valid URL: \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t\tcause,\n\t\t);\n\t}\n\tconst isHttps = url.protocol === \"https:\";\n\tconst isLoopbackHttp =\n\t\turl.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n\tif (!isHttps && !isLoopbackHttp) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option must use https (plain http is allowed only for loopback hosts): \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t);\n\t}\n\treturn url.toString();\n}\n\n// A partial CDN module (mid-deploy, or a rolled-back build missing a newer\n// export) must fail here as a typed sdk_module_invalid error, not later as a\n// TypeError on the first missing call — so every export is checked. The\n// `satisfies` clause rejects names that are not interface members; the\n// exhaustiveness type below is what forces this list to grow with it.\nconst REQUIRED_SDK_EXPORTS = [\n\t\"AdaMessagingClient\",\n\t\"createAdaEmbedInterface\",\n\t\"dispatchEmbedLoaderInitialActionQueue\",\n\t\"dispatchEmbedLoaderInitialActionQueueForAtomicHandoff\",\n\t\"mountAdaWebViewRuntime\",\n\t\"resolveAdaWebViewRuntimeAssets\",\n] as const satisfies readonly (keyof MessagingSdkModule)[];\n\n// Compile-time exhaustiveness: adding a MessagingSdkModule member without\n// listing it in REQUIRED_SDK_EXPORTS turns this type into `never`, failing\n// the `true` assignment below.\ntype AllSdkExportsListed =\n\tExclude<\n\t\tkeyof MessagingSdkModule,\n\t\t(typeof REQUIRED_SDK_EXPORTS)[number]\n\t> extends never\n\t\t? true\n\t\t: never;\nconst _allSdkExportsListed: AllSdkExportsListed = true;\nvoid _allSdkExportsListed;\n\nfunction isMessagingSdkModule(value: unknown): value is MessagingSdkModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst candidate = value as Record<string, unknown>;\n\treturn REQUIRED_SDK_EXPORTS.every(\n\t\t(key) => typeof candidate[key] === \"function\",\n\t);\n}\n\nasync function importSdkModule(\n\turl: string,\n\timportModule: ImportSdkModule,\n): Promise<MessagingSdkModule> {\n\tlet loaded: unknown;\n\ttry {\n\t\tloaded = await importModule(url);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The Ada Messaging SDK failed to load from ${url}.`,\n\t\t\t\"sdk_import_failed\",\n\t\t\tcause,\n\t\t);\n\t}\n\tif (!isMessagingSdkModule(loaded)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The module at ${url} does not expose the Ada Messaging SDK interface.`,\n\t\t\t\"sdk_module_invalid\",\n\t\t);\n\t}\n\treturn loaded;\n}\n\nfunction memoizeLoad(\n\tcache: Map<string, Promise<MessagingSdkModule>>,\n\turl: string,\n\tload: () => Promise<MessagingSdkModule>,\n): Promise<MessagingSdkModule> {\n\tconst existing = cache.get(url);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst pending = load();\n\tcache.set(url, pending);\n\tpending.catch(() => {\n\t\tif (cache.get(url) === pending) {\n\t\t\tcache.delete(url);\n\t\t}\n\t});\n\treturn pending;\n}\n\n/**\n * Load the Ada Messaging SDK module from Ada's CDN.\n *\n * The returned promise is memoized per resolved URL: concurrent and repeated\n * calls share one in-flight import. A failed load clears the memo so a later\n * call retries. Without `cdnBase`, an import failure at the default root is\n * retried once from {@link FALLBACK_MESSAGING_CDN_BASE}. Rejections are always\n * {@link MessagingSdkLoadError}.\n *\n * @example\n * const { createAdaEmbedInterface } = await loadMessagingSdk();\n */\nexport function loadMessagingSdk(\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<MessagingSdkModule> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tlet url: string;\n\tlet fallbackUrl: string | undefined;\n\ttry {\n\t\turl = resolveSdkBootstrapUrl(options.cdnBase, options.pinBuildSha);\n\t\tif (options.cdnBase === undefined) {\n\t\t\tfallbackUrl = resolveSdkBootstrapUrl(\n\t\t\t\tFALLBACK_MESSAGING_CDN_BASE,\n\t\t\t\toptions.pinBuildSha,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n\n\tconst state = loadsByImporter.get(importModule) ?? {\n\t\timports: new Map<string, Promise<MessagingSdkModule>>(),\n\t\tdefaultLoads: new Map<string, Promise<MessagingSdkModule>>(),\n\t};\n\tloadsByImporter.set(importModule, state);\n\tconst load = (entryUrl: string) =>\n\t\tmemoizeLoad(state.imports, entryUrl, () =>\n\t\t\timportSdkModule(entryUrl, importModule),\n\t\t);\n\tif (fallbackUrl === undefined) {\n\t\treturn load(url);\n\t}\n\n\tconst retryUrl = fallbackUrl;\n\t// Keep fallback outcomes separate so explicit-root callers share the import,\n\t// but never inherit another caller's permission to retry a different root.\n\treturn memoizeLoad(state.defaultLoads, url, () =>\n\t\tload(url).catch(async (error: unknown) => {\n\t\t\tif (\n\t\t\t\t!(error instanceof MessagingSdkLoadError) ||\n\t\t\t\terror.code !== \"sdk_import_failed\"\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// CSP rejects import() without a network request, so this retry adds no\n\t\t\t// user-visible delay; retrying a genuine network failure once is acceptable too.\n\t\t\tlet module: MessagingSdkModule;\n\t\t\ttry {\n\t\t\t\tmodule = await load(retryUrl);\n\t\t\t} catch (cause) {\n\t\t\t\tif (!(cause instanceof MessagingSdkLoadError)) {\n\t\t\t\t\tthrow cause;\n\t\t\t\t}\n\t\t\t\tthrow new MessagingSdkLoadError(\n\t\t\t\t\tcause.code === \"sdk_import_failed\"\n\t\t\t\t\t\t? `The Ada Messaging SDK failed to load from both ${url} and ${retryUrl}.`\n\t\t\t\t\t\t: cause.message,\n\t\t\t\t\tcause.code,\n\t\t\t\t\terror,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!warningScope[FALLBACK_WARNING_KEY]) {\n\t\t\t\twarningScope[FALLBACK_WARNING_KEY] = true;\n\t\t\t\tconst cause = error.cause;\n\t\t\t\t// Browsers reject blocked, unreachable, or missing imports with TypeError.\n\t\t\t\t// An evaluation-time TypeError still looks like a fetch failure, as before;\n\t\t\t\t// this heuristic narrows diagnostic noise but cannot prove the cause.\n\t\t\t\twarnHost(\n\t\t\t\t\tcause instanceof TypeError\n\t\t\t\t\t\t? `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the default root ${DEFAULT_MESSAGING_CDN_BASE} was blocked or unavailable. Add https://messaging-assets.ada.support to script-src, connect-src and frame-src, or pass cdnBase: \"${FALLBACK_MESSAGING_CDN_BASE}\".`\n\t\t\t\t\t\t: `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the module at ${url} failed to evaluate (${describeRejection(cause)}). This is an Ada-side problem, not your host's CSP. Report it to Ada.`,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn module;\n\t\t}),\n\t);\n}\n\n// Keyed by import seam like the module memo above: production memoizes on\n// the module-level default while each injected test seam gets an isolated\n// cache. `ada` is set when the promise resolves, so the stopped-interface\n// diagnostic can consult the resolved facade without wrapping it.\ninterface StartedInterfaceMemo {\n\tpromise: Promise<AdaMessagingInterface>;\n\tsettings: AdaMessagingStartOptions;\n\tada?: AdaMessagingInterface;\n}\n\nconst startedInterfaceByImporter = new WeakMap<\n\tImportSdkModule,\n\tStartedInterfaceMemo\n>();\n\n// A rejection can be any value, including one that throws on String(); a\n// diagnostic must never turn a successful fallback into a rejected load.\nfunction describeRejection(cause: unknown): string {\n\ttry {\n\t\treturn cause instanceof Error\n\t\t\t? `${cause.name}: ${cause.message}`\n\t\t\t: String(cause);\n\t} catch {\n\t\treturn \"unknown error\";\n\t}\n}\n\n// Ungated like the runtime logger's dropped-host-value channel so host\n// configuration diagnostics remain visible without debug logging.\nfunction warnHost(message: string, cause?: unknown): void {\n\ttry {\n\t\t// biome-ignore lint/suspicious/noConsole: the loader's sanctioned host-page diagnostic sink\n\t\tconsole.warn(`[Ada] ${message}`, ...(cause === undefined ? [] : [cause]));\n\t} catch {\n\t\t// A host may replace console methods; diagnostics must not throw.\n\t}\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\n// Structural equality over the settings surface. Two functions compare equal:\n// fresh inline callbacks on a re-run (React Strict Mode effects) are not a\n// settings change worth a warning. Exotic objects compare by reference.\nfunction settingsEqual(a: unknown, b: unknown): boolean {\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\tif (typeof a === \"function\" && typeof b === \"function\") {\n\t\treturn true;\n\t}\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\treturn (\n\t\t\ta.length === b.length &&\n\t\t\ta.every((item, index) => settingsEqual(item, b[index]))\n\t\t);\n\t}\n\tif (isPlainObject(a) && isPlainObject(b)) {\n\t\tconst aKeys = Object.keys(a);\n\t\tconst bKeys = new Set(Object.keys(b));\n\t\treturn (\n\t\t\taKeys.length === bKeys.size &&\n\t\t\taKeys.every((key) => bKeys.has(key) && settingsEqual(a[key], b[key]))\n\t\t);\n\t}\n\treturn false;\n}\n\n// Observes the facade's symbol-keyed lifecycle getter (embed-lifecycle.ts)\n// instead of wrapping stop/start, so the customer's interface is never\n// mutated; a pinned runtime that predates the getter yields no flag and the\n// stopped-interface diagnostic is skipped rather than guessed.\nfunction isInterfaceStopped(ada: AdaMessagingInterface): boolean {\n\treturn readEmbedStoppedFlag(ada) === true;\n}\n\nasync function startAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions,\n): Promise<AdaMessagingInterface> {\n\tconst sdkModule = await loadMessagingSdk(options);\n\tconst ada = sdkModule.createAdaEmbedInterface();\n\tawait ada.start(settings);\n\treturn ada;\n}\n\n/**\n * Load the SDK, create the messaging interface, and start the widget —\n * the npm-first equivalent of the script-tag + `window.adaSettings` setup.\n *\n * One widget per page: the returned promise is memoized, so repeated and\n * concurrent calls resolve to the same started interface and the first\n * call's settings win. A failed load or start clears the memo so a later\n * call retries. Manage the running widget through the returned interface:\n * `stop()` tears it down and a later `start(settings)` on the same interface\n * runs again. Calling {@link loadAdaMessaging} after `stop()` returns the\n * same stopped interface without restarting it. Both memo outcomes log a\n * console warning: ignored differing settings, and a resolved interface\n * whose widget was stopped.\n *\n * Never assigns the interface to `window` or any other global: the returned\n * reference is the only handle, so hold it in module scope. A reference in\n * module scope is reachable only by your own code, never by other scripts on\n * the page.\n *\n * @example\n * // module scope: your code keeps the only reference\n * const ada = await loadAdaMessaging({\n * handle: \"my-bot\",\n * enableProgrammaticControl: true,\n * });\n * await ada.sendMessage(\"Hello\");\n */\nexport function loadAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<AdaMessagingInterface> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tconst existing = startedInterfaceByImporter.get(importModule);\n\tif (existing) {\n\t\tif (!settingsEqual(settings, existing.settings)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() was already called: the new settings are ignored and the existing interface is returned. To apply new settings, call stop() then start(settings) on it.\",\n\t\t\t);\n\t\t}\n\t\tif (existing.ada && isInterfaceStopped(existing.ada)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() resolved an interface whose widget was stopped and never restarts it. Call start(settings) on it to run the widget again.\",\n\t\t\t);\n\t\t}\n\t\treturn existing.promise;\n\t}\n\tconst memo: StartedInterfaceMemo = {\n\t\tpromise: startAdaMessaging(settings, options),\n\t\tsettings,\n\t};\n\tstartedInterfaceByImporter.set(importModule, memo);\n\tmemo.promise.then(\n\t\t(ada) => {\n\t\t\tmemo.ada = ada;\n\t\t},\n\t\t() => {\n\t\t\tif (startedInterfaceByImporter.get(importModule) === memo) {\n\t\t\t\tstartedInterfaceByImporter.delete(importModule);\n\t\t\t}\n\t\t},\n\t);\n\treturn memo.promise;\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAM,uBAAuB,OAAO,UAAU;AAE9C,SAAS,YACR,QACA,MACA,OACO;AACP,QAAO,eAAe,QAAQ,MAAM;EACnC;EACA,cAAc;EACd,UAAU;EACV,CAAC;;AAGH,IAAI,CAAC,OAAO,OACX,aAAY,QAAQ,WAAW,QAAiB,QAAiB;AAChE,KAAI,UAAU,KACb,OAAM,IAAI,UACT,oEACA;AAEF,QAAO,qBAAqB,KAAK,OAAO,OAAO,EAAE,IAAmB;EACnE;AAGH,SAAS,GAER,OACgB;CAChB,MAAM,SAAS,KAAK,MAAM,OAAO,KAAK,OAAO,CAAC,IAAI;CAClD,IAAI,gBAAgB,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI;AACjD,KAAI,gBAAgB,EACnB,kBAAiB;AAElB,QAAO,gBAAgB,KAAK,iBAAiB,SAC1C,KAAA,IACA,KAAK;;AAGT,SAAS,SAAuB,OAAoC;CACnE,MAAM,QAAQ,OAAO,KAAK;CAC1B,MAAM,SAAS,MAAM;CACrB,IAAI,gBAAgB,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI;AACjD,KAAI,gBAAgB,EACnB,kBAAiB;AAElB,QAAO,gBAAgB,KAAK,iBAAiB,SAC1C,KAAA,IACA,MAAM,OAAO,cAAc;;AAG/B,IAAM,yBAAyB;CAC9B,WAAW;CACX,WAAW;CACX,W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;AAGzD,KAAI,cAAc,EAAE,IAAI,cAAc,EAAE,EAAE;EACzC,MAAM,QAAQ,OAAO,KAAK,EAAE;EAC5B,MAAM,QAAQ,IAAI,IAAI,OAAO,KAAK,EAAE,CAAC;AACrC,SACC,MAAM,WAAW,MAAM,QACvB,MAAM,OAAO,QAAQ,MAAM,IAAI,IAAI,IAAI,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC;;AAGvE,QAAO;;AAOR,SAAS,mBAAmB,KAAqC;AAChE,QAAO,qBAAqB,IAAI,KAAK;;AAGtC,eAAe,kBACd,UACA,SACiC;CAEjC,MAAM,OADY,MAAM,iBAAiB,QAAQ,EAC3B,yBAAyB;AAC/C,OAAM,IAAI,MAAM,SAAS;AACzB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BR,SAAgB,iBACf,UACA,UAAmC,EAAE,EACJ;CACjC,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,MAAM,WAAW,2BAA2B,IAAI,aAAa;AAC7D,KAAI,UAAU;AACb,MAAI,CAAC,cAAc,UAAU,SAAS,SAAS,CAC9C,UACC,6KACA;AAEF,MAAI,SAAS,OAAO,mBAAmB,SAAS,IAAI,CACnD,UACC,+IACA;AAEF,SAAO,SAAS;;CAEjB,MAAM,OAA6B;EAClC,SAAS,kBAAkB,UAAU,QAAQ;EAC7C;EACA;AACD,4BAA2B,IAAI,cAAc,KAAK;AAClD,MAAK,QAAQ,MACX,QAAQ;AACR,OAAK,MAAM;UAEN;AACL,MAAI,2BAA2B,IAAI,aAAa,KAAK,KACpD,4BAA2B,OAAO,aAAa;GAGjD;AACD,QAAO,KAAK"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/build-info.ts","../../src/client/embed-lifecycle.ts","../../src/npm/loader.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","// The repo copy carries the 40-zero placeholder; the publish workflow\n// (.github/workflows/messaging-publish-web-packages.yml) stamps the real\n// commit SHA into the built output via scripts/stamp-cdn-build-sha.mjs and\n// verifies the packed tarball before `npm publish`. Keep the placeholder as\n// a single 40-zero string literal: the stamp is a same-length text\n// replacement, so source maps stay valid.\nconst GIT_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_SHA_PATTERN = /^0{40}$/;\n\n/**\n * Git commit SHA of the monorepo commit this npm version was published from.\n * The CDN pipeline deploys each main commit's runtime under an immutable\n * SHA root, so this value names the CDN build associated with this npm\n * version. Pass it as the `pinBuildSha` loader option to load exactly that\n * runtime build — not recommended for production (see the README).\n *\n * In the repository, and in any locally built copy, the value is the\n * unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns\n * `false`); only published tarballs carry a real SHA.\n */\nexport const CDN_BUILD_SHA: string = \"9127673bc66718428b8a960ffb074e6c00adf0b5\";\n\n/**\n * Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit\n * SHA rather than the unstamped repo placeholder.\n */\nexport function isCdnBuildShaStamped(sha: string = CDN_BUILD_SHA): boolean {\n\tconst normalized = sha.trim().toLowerCase();\n\treturn (\n\t\tGIT_SHA_PATTERN.test(normalized) && !UNSTAMPED_SHA_PATTERN.test(normalized)\n\t);\n}\n","/**\n * Lifecycle channel between `createAdaEmbedInterface` and the npm loader's\n * memo: a non-enumerable getter over closure state, so the loader never\n * mutates the public surface and `Object.freeze` on the facade still works.\n * `Symbol.for` because the loader and the CDN runtime are separate builds;\n * a runtime that predates the getter yields `undefined` — degrade gracefully.\n */\nexport const EMBED_LIFECYCLE_STOPPED = Symbol.for(\n\t\"ada-cx/messaging-sdk/embed-stopped\",\n);\n\n/** Read the facade's stopped flag; `undefined` when the runtime predates it. */\nexport function readEmbedStoppedFlag(ada: object): boolean | undefined {\n\tconst value = (ada as Record<symbol, unknown>)[EMBED_LIFECYCLE_STOPPED];\n\treturn typeof value === \"boolean\" ? value : undefined;\n}\n\n/** Define the getter at facade creation time, before any host freeze. */\nexport function defineEmbedStoppedFlag(\n\tada: object,\n\treadStopped: () => boolean,\n): void {\n\tObject.defineProperty(ada, EMBED_LIFECYCLE_STOPPED, {\n\t\tget: readStopped,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n}\n","import type { AdaMessagingClient } from \"../client/client\";\nimport type { AdaMessagingStartOptions } from \"../client/client-types\";\nimport type {\n\tAdaEmbedInterface,\n\tcreateAdaEmbedInterface,\n\tdispatchEmbedLoaderInitialActionQueue,\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff,\n} from \"../client/embed-interface\";\nimport { readEmbedStoppedFlag } from \"../client/embed-lifecycle\";\nimport type {\n\tmountAdaWebViewRuntime,\n\tresolveAdaWebViewRuntimeAssets,\n} from \"../mobile-webview-runtime\";\n\n/**\n * Production CDN root the loader resolves the SDK bootstrap from when no\n * `cdnBase` override is given. The npm package never pins a runtime version;\n * the bootstrap at this root resolves the current rollout at load time.\n */\nexport const DEFAULT_MESSAGING_CDN_BASE =\n\t\"https://messaging-assets.ada.support/\";\n\nexport const FALLBACK_MESSAGING_CDN_BASE =\n\t\"https://static.ada.support/messaging/\";\n\nconst SDK_BOOTSTRAP_FILENAME = \"sdk.js\";\n\n// The CDN pipeline deploys each main commit's runtime as an immutable\n// SHA-rooted entry (`<cdnBase>/<sha>/sdk/index.js`); the mutable `sdk.js`\n// bootstrap resolves the current rollout to one of those roots at load time.\n// A pin bypasses the bootstrap and imports one root directly.\nconst PINNED_SDK_ENTRY_PATH = \"sdk/index.js\";\n\n// Strict on purpose: the pin is interpolated into a CDN path, so only a full\n// lowercase 40-hex git SHA may pass (mirrors scripts/sdk.js's\n// VERSION_OVERRIDE_PATTERN security boundary, minus the short-SHA and pr-N\n// forms — the npm surface pins exactly what CDN_BUILD_SHA carries).\nconst PINNED_BUILD_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_BUILD_SHA_PATTERN = /^0{40}$/;\n\n/** Why a {@link MessagingSdkLoadError} was raised. */\nexport type MessagingSdkLoadErrorCode =\n\t/**\n\t * The `cdnBase` option is not a valid `https:` URL (plain `http:` is\n\t * allowed only for loopback hosts).\n\t */\n\t| \"invalid_cdn_base\"\n\t/** The `pinBuildSha` option is not a full 40-character hex git SHA. */\n\t| \"invalid_build_sha\"\n\t/**\n\t * The `pinBuildSha` option is the unstamped 40-zero placeholder: this\n\t * copy of the package was built from the repository, not published, so\n\t * its `CDN_BUILD_SHA` names no CDN build.\n\t */\n\t| \"unstamped_build_sha\"\n\t/** The dynamic import of the CDN bootstrap failed (fetch or evaluation). */\n\t| \"sdk_import_failed\"\n\t/** The imported module does not expose the Ada Messaging SDK surface. */\n\t| \"sdk_module_invalid\";\n\n/** Typed failure raised by {@link loadMessagingSdk} and {@link loadAdaMessaging}. */\nexport class MessagingSdkLoadError extends Error {\n\treadonly code: MessagingSdkLoadErrorCode;\n\tdeclare readonly fallbackCause?: MessagingSdkLoadError;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: MessagingSdkLoadErrorCode,\n\t\tcause?: unknown,\n\t\tfallbackCause?: MessagingSdkLoadError,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MessagingSdkLoadError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) {\n\t\t\tthis.cause = cause;\n\t\t}\n\t\tif (fallbackCause !== undefined) {\n\t\t\tObject.defineProperty(this, \"fallbackCause\", {\n\t\t\t\tvalue: fallbackCause,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * The programmatic messaging interface {@link loadAdaMessaging} resolves. An\n * alias of the runtime's `AdaEmbedInterface`, which keeps that name because it\n * is also the legacy `window.adaEmbed` compat facade.\n * Includes `selectQuickReply(messageId, index)` for Web SDK integrations.\n */\nexport type AdaMessagingInterface = AdaEmbedInterface;\n\n/**\n * The public surface of the CDN-resolved SDK module, as loaded from\n * `<cdnBase>/sdk.js`. Types only — the implementation always comes from the\n * CDN at load time and is never part of this npm package.\n */\nexport interface MessagingSdkModule {\n\tAdaMessagingClient: typeof AdaMessagingClient;\n\tcreateAdaEmbedInterface: typeof createAdaEmbedInterface;\n\tdispatchEmbedLoaderInitialActionQueue: typeof dispatchEmbedLoaderInitialActionQueue;\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff: typeof dispatchEmbedLoaderInitialActionQueueForAtomicHandoff;\n\tmountAdaWebViewRuntime: typeof mountAdaWebViewRuntime;\n\tresolveAdaWebViewRuntimeAssets: typeof resolveAdaWebViewRuntimeAssets;\n}\n\ntype ImportSdkModule = (url: string) => Promise<unknown>;\n\nexport interface LoadMessagingSdkOptions {\n\t/**\n\t * CDN root to resolve `sdk.js` from. Must be an `https:` URL; plain\n\t * `http:` is accepted only for loopback hosts (`localhost`, `127.0.0.1`,\n\t * `[::1]`, `*.localhost`) during local development. Defaults to the\n\t * production root ({@link DEFAULT_MESSAGING_CDN_BASE}). An explicit value,\n\t * including {@link FALLBACK_MESSAGING_CDN_BASE}, disables the automatic\n\t * static-root fallback.\n\t */\n\tcdnBase?: string;\n\t/**\n\t * Full 40-character git commit SHA of a deployed CDN build. When set, the\n\t * loader skips the rollout bootstrap and imports that build's immutable\n\t * entry (`<cdnBase>/<sha>/sdk/index.js`) directly. Pass the package's\n\t * `CDN_BUILD_SHA` export to pin the build associated with this npm\n\t * version. NOT recommended for production: a pinned runtime misses Ada's\n\t * fixes and rollouts, and may predate server contract changes. Composes\n\t * with `cdnBase` for staged validation.\n\t */\n\tpinBuildSha?: string;\n\t/**\n\t * Import seam for unit tests. Defaults to a native dynamic `import()` of\n\t * the resolved bootstrap URL.\n\t */\n\timportModule?: ImportSdkModule;\n}\n\n// Both annotations are load-bearing: bundlers rewrite bare dynamic imports,\n// and this specifier must reach the browser untouched so the runtime always\n// resolves from Ada's CDN. The npm build for this entry is unminified so the\n// annotations survive into the published output.\nconst defaultImportModule: ImportSdkModule = (url) =>\n\timport(/* webpackIgnore: true */ /* @vite-ignore */ url);\n\n// Keyed by import seam so production memoizes on the module-level default\n// while each injected test seam gets an isolated cache.\ninterface SdkLoaderState {\n\timports: Map<string, Promise<MessagingSdkModule>>;\n\tdefaultLoads: Map<string, Promise<MessagingSdkModule>>;\n}\n\nconst loadsByImporter = new WeakMap<ImportSdkModule, SdkLoaderState>();\n\n// Share the warning across independently bundled copies of this loader.\nconst FALLBACK_WARNING_KEY = Symbol.for(\"ada.messaging.sdk.fallbackWarning\");\nconst warningScope = globalThis as typeof globalThis & {\n\t[FALLBACK_WARNING_KEY]?: boolean;\n};\n\n// Mirrors the loopback semantics of the shared `isLoopbackHost` /\n// `validateMessagingEndpoint` (shared/utils/src/url.ts) and the bridge\n// loader's copy (packages/bridge/src/npm/loader.ts). Inlined because the\n// published loader must stay dependency-free; keep the host set in sync.\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\", \"::1\"]);\n\nfunction isLoopbackHostname(hostname: string): boolean {\n\tconst normalized = hostname.trim().toLowerCase();\n\t// `*.localhost` resolves to the loopback interface and is \"potentially\n\t// trustworthy\" per the Secure Contexts spec; no production host ends in\n\t// `.localhost`.\n\treturn LOOPBACK_HOSTS.has(normalized) || normalized.endsWith(\".localhost\");\n}\n\nfunction resolvePinnedBuildSha(pinBuildSha: string): string {\n\tconst sha = pinBuildSha.trim().toLowerCase();\n\tif (!PINNED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The pinBuildSha option must be a full 40-character hex git SHA: \"${pinBuildSha}\".`,\n\t\t\t\"invalid_build_sha\",\n\t\t);\n\t}\n\tif (UNSTAMPED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t\"The pinBuildSha option is the unstamped CDN_BUILD_SHA placeholder. Only the published npm package carries a stamped SHA; a repository or local build cannot pin a CDN build.\",\n\t\t\t\"unstamped_build_sha\",\n\t\t);\n\t}\n\treturn sha;\n}\n\n/**\n * The runtime this URL serves carries the SDK's security logic (endpoint\n * validation, session handling, the origin checks), so a cleartext transport\n * would let an on-path attacker replace it wholesale: `https:` is required,\n * with a loopback-only `http:` exception for local development.\n */\nfunction resolveSdkBootstrapUrl(\n\tcdnBase: string | undefined,\n\tpinBuildSha: string | undefined,\n): string {\n\tconst base = (cdnBase ?? DEFAULT_MESSAGING_CDN_BASE).trim();\n\t// Resolving against a base without a trailing slash would drop its last\n\t// path segment, so normalize before building the bootstrap URL.\n\tconst normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n\tconst entryPath =\n\t\tpinBuildSha === undefined\n\t\t\t? SDK_BOOTSTRAP_FILENAME\n\t\t\t: `${resolvePinnedBuildSha(pinBuildSha)}/${PINNED_SDK_ENTRY_PATH}`;\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(entryPath, normalizedBase);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option is not a valid URL: \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t\tcause,\n\t\t);\n\t}\n\tconst isHttps = url.protocol === \"https:\";\n\tconst isLoopbackHttp =\n\t\turl.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n\tif (!isHttps && !isLoopbackHttp) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option must use https (plain http is allowed only for loopback hosts): \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t);\n\t}\n\treturn url.toString();\n}\n\n// A partial CDN module (mid-deploy, or a rolled-back build missing a newer\n// export) must fail here as a typed sdk_module_invalid error, not later as a\n// TypeError on the first missing call — so every export is checked. The\n// `satisfies` clause rejects names that are not interface members; the\n// exhaustiveness type below is what forces this list to grow with it.\nconst REQUIRED_SDK_EXPORTS = [\n\t\"AdaMessagingClient\",\n\t\"createAdaEmbedInterface\",\n\t\"dispatchEmbedLoaderInitialActionQueue\",\n\t\"dispatchEmbedLoaderInitialActionQueueForAtomicHandoff\",\n\t\"mountAdaWebViewRuntime\",\n\t\"resolveAdaWebViewRuntimeAssets\",\n] as const satisfies readonly (keyof MessagingSdkModule)[];\n\n// Compile-time exhaustiveness: adding a MessagingSdkModule member without\n// listing it in REQUIRED_SDK_EXPORTS turns this type into `never`, failing\n// the `true` assignment below.\ntype AllSdkExportsListed =\n\tExclude<\n\t\tkeyof MessagingSdkModule,\n\t\t(typeof REQUIRED_SDK_EXPORTS)[number]\n\t> extends never\n\t\t? true\n\t\t: never;\nconst _allSdkExportsListed: AllSdkExportsListed = true;\nvoid _allSdkExportsListed;\n\nfunction isMessagingSdkModule(value: unknown): value is MessagingSdkModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst candidate = value as Record<string, unknown>;\n\treturn REQUIRED_SDK_EXPORTS.every(\n\t\t(key) => typeof candidate[key] === \"function\",\n\t);\n}\n\nasync function importSdkModule(\n\turl: string,\n\timportModule: ImportSdkModule,\n): Promise<MessagingSdkModule> {\n\tlet loaded: unknown;\n\ttry {\n\t\tloaded = await importModule(url);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The Ada Messaging SDK failed to load from ${url}.`,\n\t\t\t\"sdk_import_failed\",\n\t\t\tcause,\n\t\t);\n\t}\n\tif (!isMessagingSdkModule(loaded)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The module at ${url} does not expose the Ada Messaging SDK interface.`,\n\t\t\t\"sdk_module_invalid\",\n\t\t);\n\t}\n\treturn loaded;\n}\n\nfunction memoizeLoad(\n\tcache: Map<string, Promise<MessagingSdkModule>>,\n\turl: string,\n\tload: () => Promise<MessagingSdkModule>,\n): Promise<MessagingSdkModule> {\n\tconst existing = cache.get(url);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst pending = load();\n\tcache.set(url, pending);\n\tpending.catch(() => {\n\t\tif (cache.get(url) === pending) {\n\t\t\tcache.delete(url);\n\t\t}\n\t});\n\treturn pending;\n}\n\n/**\n * Load the Ada Messaging SDK module from Ada's CDN.\n *\n * The returned promise is memoized per resolved URL: concurrent and repeated\n * calls share one in-flight import. A failed load clears the memo so a later\n * call retries. Without `cdnBase`, an import failure at the default root is\n * retried once from {@link FALLBACK_MESSAGING_CDN_BASE}. Rejections are always\n * {@link MessagingSdkLoadError}.\n *\n * @example\n * const { createAdaEmbedInterface } = await loadMessagingSdk();\n */\nexport function loadMessagingSdk(\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<MessagingSdkModule> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tlet url: string;\n\tlet fallbackUrl: string | undefined;\n\ttry {\n\t\turl = resolveSdkBootstrapUrl(options.cdnBase, options.pinBuildSha);\n\t\tif (options.cdnBase === undefined) {\n\t\t\tfallbackUrl = resolveSdkBootstrapUrl(\n\t\t\t\tFALLBACK_MESSAGING_CDN_BASE,\n\t\t\t\toptions.pinBuildSha,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n\n\tconst state = loadsByImporter.get(importModule) ?? {\n\t\timports: new Map<string, Promise<MessagingSdkModule>>(),\n\t\tdefaultLoads: new Map<string, Promise<MessagingSdkModule>>(),\n\t};\n\tloadsByImporter.set(importModule, state);\n\tconst load = (entryUrl: string) =>\n\t\tmemoizeLoad(state.imports, entryUrl, () =>\n\t\t\timportSdkModule(entryUrl, importModule),\n\t\t);\n\tif (fallbackUrl === undefined) {\n\t\treturn load(url);\n\t}\n\n\tconst retryUrl = fallbackUrl;\n\t// Keep fallback outcomes separate so explicit-root callers share the import,\n\t// but never inherit another caller's permission to retry a different root.\n\treturn memoizeLoad(state.defaultLoads, url, () =>\n\t\tload(url).catch(async (error: unknown) => {\n\t\t\tif (\n\t\t\t\t!(error instanceof MessagingSdkLoadError) ||\n\t\t\t\terror.code !== \"sdk_import_failed\"\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// CSP rejects import() without a network request, so this retry adds no\n\t\t\t// user-visible delay; retrying a genuine network failure once is acceptable too.\n\t\t\tlet module: MessagingSdkModule;\n\t\t\ttry {\n\t\t\t\tmodule = await load(retryUrl);\n\t\t\t} catch (cause) {\n\t\t\t\tif (!(cause instanceof MessagingSdkLoadError)) {\n\t\t\t\t\tthrow cause;\n\t\t\t\t}\n\t\t\t\tthrow new MessagingSdkLoadError(\n\t\t\t\t\tcause.code === \"sdk_import_failed\"\n\t\t\t\t\t\t? `The Ada Messaging SDK failed to load from both ${url} and ${retryUrl}.`\n\t\t\t\t\t\t: cause.message,\n\t\t\t\t\tcause.code,\n\t\t\t\t\terror,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!warningScope[FALLBACK_WARNING_KEY]) {\n\t\t\t\twarningScope[FALLBACK_WARNING_KEY] = true;\n\t\t\t\tconst cause = error.cause;\n\t\t\t\t// Browsers reject blocked, unreachable, or missing imports with TypeError.\n\t\t\t\t// An evaluation-time TypeError still looks like a fetch failure, as before;\n\t\t\t\t// this heuristic narrows diagnostic noise but cannot prove the cause.\n\t\t\t\twarnHost(\n\t\t\t\t\tcause instanceof TypeError\n\t\t\t\t\t\t? `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the default root ${DEFAULT_MESSAGING_CDN_BASE} was blocked or unavailable. Add https://messaging-assets.ada.support to script-src, connect-src and frame-src, or pass cdnBase: \"${FALLBACK_MESSAGING_CDN_BASE}\".`\n\t\t\t\t\t\t: `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the module at ${url} failed to evaluate (${describeRejection(cause)}). This is an Ada-side problem, not your host's CSP. Report it to Ada.`,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn module;\n\t\t}),\n\t);\n}\n\n// Keyed by import seam like the module memo above: production memoizes on\n// the module-level default while each injected test seam gets an isolated\n// cache. `ada` is set when the promise resolves, so the stopped-interface\n// diagnostic can consult the resolved facade without wrapping it.\ninterface StartedInterfaceMemo {\n\tpromise: Promise<AdaMessagingInterface>;\n\tsettings: AdaMessagingStartOptions;\n\tada?: AdaMessagingInterface;\n}\n\nconst startedInterfaceByImporter = new WeakMap<\n\tImportSdkModule,\n\tStartedInterfaceMemo\n>();\n\n// A rejection can be any value, including one that throws on String(); a\n// diagnostic must never turn a successful fallback into a rejected load.\nfunction describeRejection(cause: unknown): string {\n\ttry {\n\t\treturn cause instanceof Error\n\t\t\t? `${cause.name}: ${cause.message}`\n\t\t\t: String(cause);\n\t} catch {\n\t\treturn \"unknown error\";\n\t}\n}\n\n// Ungated like the runtime logger's dropped-host-value channel so host\n// configuration diagnostics remain visible without debug logging.\nfunction warnHost(message: string, cause?: unknown): void {\n\ttry {\n\t\t// biome-ignore lint/suspicious/noConsole: the loader's sanctioned host-page diagnostic sink\n\t\tconsole.warn(`[Ada] ${message}`, ...(cause === undefined ? [] : [cause]));\n\t} catch {\n\t\t// A host may replace console methods; diagnostics must not throw.\n\t}\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\n// Structural equality over the settings surface. Two functions compare equal:\n// fresh inline callbacks on a re-run (React Strict Mode effects) are not a\n// settings change worth a warning. Exotic objects compare by reference.\nfunction settingsEqual(a: unknown, b: unknown): boolean {\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\tif (typeof a === \"function\" && typeof b === \"function\") {\n\t\treturn true;\n\t}\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\treturn (\n\t\t\ta.length === b.length &&\n\t\t\ta.every((item, index) => settingsEqual(item, b[index]))\n\t\t);\n\t}\n\tif (isPlainObject(a) && isPlainObject(b)) {\n\t\tconst aKeys = Object.keys(a);\n\t\tconst bKeys = new Set(Object.keys(b));\n\t\treturn (\n\t\t\taKeys.length === bKeys.size &&\n\t\t\taKeys.every((key) => bKeys.has(key) && settingsEqual(a[key], b[key]))\n\t\t);\n\t}\n\treturn false;\n}\n\n// Observes the facade's symbol-keyed lifecycle getter (embed-lifecycle.ts)\n// instead of wrapping stop/start, so the customer's interface is never\n// mutated; a pinned runtime that predates the getter yields no flag and the\n// stopped-interface diagnostic is skipped rather than guessed.\nfunction isInterfaceStopped(ada: AdaMessagingInterface): boolean {\n\treturn readEmbedStoppedFlag(ada) === true;\n}\n\nasync function startAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions,\n): Promise<AdaMessagingInterface> {\n\tconst sdkModule = await loadMessagingSdk(options);\n\tconst ada = sdkModule.createAdaEmbedInterface();\n\tawait ada.start(settings);\n\treturn ada;\n}\n\n/**\n * Load the SDK, create the messaging interface, and start the widget —\n * the npm-first equivalent of the script-tag + `window.adaSettings` setup.\n *\n * One widget per page: the returned promise is memoized, so repeated and\n * concurrent calls resolve to the same started interface and the first\n * call's settings win. A failed load or start clears the memo so a later\n * call retries. Manage the running widget through the returned interface:\n * `stop()` tears it down and a later `start(settings)` on the same interface\n * runs again. Calling {@link loadAdaMessaging} after `stop()` returns the\n * same stopped interface without restarting it. Both memo outcomes log a\n * console warning: ignored differing settings, and a resolved interface\n * whose widget was stopped.\n *\n * Never assigns the interface to `window` or any other global: the returned\n * reference is the only handle, so hold it in module scope. A reference in\n * module scope is reachable only by your own code, never by other scripts on\n * the page.\n *\n * @example\n * // module scope: your code keeps the only reference\n * const ada = await loadAdaMessaging({\n * handle: \"my-bot\",\n * enableProgrammaticControl: true,\n * });\n * await ada.sendMessage(\"Hello\");\n */\nexport function loadAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<AdaMessagingInterface> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tconst existing = startedInterfaceByImporter.get(importModule);\n\tif (existing) {\n\t\tif (!settingsEqual(settings, existing.settings)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() was already called: the new settings are ignored and the existing interface is returned. To apply new settings, call stop() then start(settings) on it.\",\n\t\t\t);\n\t\t}\n\t\tif (existing.ada && isInterfaceStopped(existing.ada)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() resolved an interface whose widget was stopped and never restarts it. Call start(settings) on it to run the widget again.\",\n\t\t\t);\n\t\t}\n\t\treturn existing.promise;\n\t}\n\tconst memo: StartedInterfaceMemo = {\n\t\tpromise: startAdaMessaging(settings, options),\n\t\tsettings,\n\t};\n\tstartedInterfaceByImporter.set(importModule, memo);\n\tmemo.promise.then(\n\t\t(ada) => {\n\t\t\tmemo.ada = ada;\n\t\t},\n\t\t() => {\n\t\t\tif (startedInterfaceByImporter.get(importModule) === memo) {\n\t\t\t\tstartedInterfaceByImporter.delete(importModule);\n\t\t\t}\n\t\t},\n\t);\n\treturn memo.promise;\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAM,uBAAuB,OAAO,UAAU;AAE9C,SAAS,YACR,QACA,MACA,OACO;AACP,QAAO,eAAe,QAAQ,MAAM;EACnC;EACA,cAAc;EACd,UAAU;EACV,CAAC;;AAGH,IAAI,CAAC,OAAO,OACX,aAAY,QAAQ,WAAW,QAAiB,QAAiB;AAChE,KAAI,UAAU,KACb,OAAM,IAAI,UACT,oEACA;AAEF,QAAO,qBAAqB,KAAK,OAAO,OAAO,EAAE,IAAmB;EACnE;AAGH,SAAS,GAER,OACgB;CAChB,MAAM,SAAS,KAAK,MAAM,OAAO,KAAK,OA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,SAAS;;CAEjB,MAAM,OAA6B;EAClC,SAAS,kBAAkB,UAAU,QAAQ;EAC7C;EACA;AACD,4BAA2B,IAAI,cAAc,KAAK;AAClD,MAAK,QAAQ,MACX,QAAQ;AACR,OAAK,MAAM;UAEN;AACL,MAAI,2BAA2B,IAAI,aAAa,KAAK,KACpD,4BAA2B,OAAO,aAAa;GAGjD;AACD,QAAO,KAAK"}
@@ -1,7 +1,7 @@
1
1
  import type { AdaMessagingClient } from "../client/client.js" with { "resolution-mode": "import" };
2
2
  export type { AdaMessagingClient };
3
- import type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo, } from "../client/client-types.js" with { "resolution-mode": "import" };
4
- export type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo };
3
+ import type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, TriggerPlaybookOptions, WindowInfo, } from "../client/client-types.js" with { "resolution-mode": "import" };
4
+ export type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, TriggerPlaybookOptions, WindowInfo };
5
5
  import type { ChatHtmlConfig, resolveChatHtmlConfig, } from "../client/config-helpers.js" with { "resolution-mode": "import" };
6
6
  export type { ChatHtmlConfig, resolveChatHtmlConfig };
7
7
  import type { AdaEmbedInterface, createAdaEmbedInterface, dispatchEmbedLoaderInitialActionQueue, dispatchEmbedLoaderInitialActionQueueForAtomicHandoff, LoaderQueueAction, LoaderQueueActionOutcome, LoaderQueueActionOutcomeHandler, } from "../client/embed-interface.js" with { "resolution-mode": "import" };
@@ -1,5 +1,5 @@
1
1
  export type { AdaMessagingClient } from "../client/client.js";
2
- export type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo, } from "../client/client-types.js";
2
+ export type { AdaMessagingBranding, AdaMessagingBrandingLauncher, AdaMessagingClientConfig, AdaMessagingLocalizedText, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, TriggerPlaybookOptions, WindowInfo, } from "../client/client-types.js";
3
3
  export type { ChatHtmlConfig, resolveChatHtmlConfig, } from "../client/config-helpers.js";
4
4
  export type { AdaEmbedInterface, createAdaEmbedInterface, dispatchEmbedLoaderInitialActionQueue, dispatchEmbedLoaderInitialActionQueueForAtomicHandoff, LoaderQueueAction, LoaderQueueActionOutcome, LoaderQueueActionOutcomeHandler, } from "../client/embed-interface.js";
5
5
  export type { FrameChannel, FrameChild, FrameMessage, FrameName, FrameToSdkEvents, SdkToFrameEvents, } from "../frame-channel/index.js";
package/dist/npm/index.js CHANGED
@@ -68,7 +68,7 @@ var UNSTAMPED_SHA_PATTERN = /^0{40}$/;
68
68
  * unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns
69
69
  * `false`); only published tarballs carry a real SHA.
70
70
  */
71
- var CDN_BUILD_SHA = "5d21963652bb4111febf12f4ad58845073726264";
71
+ var CDN_BUILD_SHA = "9127673bc66718428b8a960ffb074e6c00adf0b5";
72
72
  /**
73
73
  * Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit
74
74
  * SHA rather than the unstamped repo placeholder.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/build-info.ts","../../src/client/embed-lifecycle.ts","../../src/npm/loader.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","// The repo copy carries the 40-zero placeholder; the publish workflow\n// (.github/workflows/messaging-publish-web-packages.yml) stamps the real\n// commit SHA into the built output via scripts/stamp-cdn-build-sha.mjs and\n// verifies the packed tarball before `npm publish`. Keep the placeholder as\n// a single 40-zero string literal: the stamp is a same-length text\n// replacement, so source maps stay valid.\nconst GIT_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_SHA_PATTERN = /^0{40}$/;\n\n/**\n * Git commit SHA of the monorepo commit this npm version was published from.\n * The CDN pipeline deploys each main commit's runtime under an immutable\n * SHA root, so this value names the CDN build associated with this npm\n * version. Pass it as the `pinBuildSha` loader option to load exactly that\n * runtime build — not recommended for production (see the README).\n *\n * In the repository, and in any locally built copy, the value is the\n * unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns\n * `false`); only published tarballs carry a real SHA.\n */\nexport const CDN_BUILD_SHA: string = \"5d21963652bb4111febf12f4ad58845073726264\";\n\n/**\n * Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit\n * SHA rather than the unstamped repo placeholder.\n */\nexport function isCdnBuildShaStamped(sha: string = CDN_BUILD_SHA): boolean {\n\tconst normalized = sha.trim().toLowerCase();\n\treturn (\n\t\tGIT_SHA_PATTERN.test(normalized) && !UNSTAMPED_SHA_PATTERN.test(normalized)\n\t);\n}\n","/**\n * Lifecycle channel between `createAdaEmbedInterface` and the npm loader's\n * memo: a non-enumerable getter over closure state, so the loader never\n * mutates the public surface and `Object.freeze` on the facade still works.\n * `Symbol.for` because the loader and the CDN runtime are separate builds;\n * a runtime that predates the getter yields `undefined` — degrade gracefully.\n */\nexport const EMBED_LIFECYCLE_STOPPED = Symbol.for(\n\t\"ada-cx/messaging-sdk/embed-stopped\",\n);\n\n/** Read the facade's stopped flag; `undefined` when the runtime predates it. */\nexport function readEmbedStoppedFlag(ada: object): boolean | undefined {\n\tconst value = (ada as Record<symbol, unknown>)[EMBED_LIFECYCLE_STOPPED];\n\treturn typeof value === \"boolean\" ? value : undefined;\n}\n\n/** Define the getter at facade creation time, before any host freeze. */\nexport function defineEmbedStoppedFlag(\n\tada: object,\n\treadStopped: () => boolean,\n): void {\n\tObject.defineProperty(ada, EMBED_LIFECYCLE_STOPPED, {\n\t\tget: readStopped,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n}\n","import type { AdaMessagingClient } from \"../client/client\";\nimport type { AdaMessagingStartOptions } from \"../client/client-types\";\nimport type {\n\tAdaEmbedInterface,\n\tcreateAdaEmbedInterface,\n\tdispatchEmbedLoaderInitialActionQueue,\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff,\n} from \"../client/embed-interface\";\nimport { readEmbedStoppedFlag } from \"../client/embed-lifecycle\";\nimport type {\n\tmountAdaWebViewRuntime,\n\tresolveAdaWebViewRuntimeAssets,\n} from \"../mobile-webview-runtime\";\n\n/**\n * Production CDN root the loader resolves the SDK bootstrap from when no\n * `cdnBase` override is given. The npm package never pins a runtime version;\n * the bootstrap at this root resolves the current rollout at load time.\n */\nexport const DEFAULT_MESSAGING_CDN_BASE =\n\t\"https://messaging-assets.ada.support/\";\n\nexport const FALLBACK_MESSAGING_CDN_BASE =\n\t\"https://static.ada.support/messaging/\";\n\nconst SDK_BOOTSTRAP_FILENAME = \"sdk.js\";\n\n// The CDN pipeline deploys each main commit's runtime as an immutable\n// SHA-rooted entry (`<cdnBase>/<sha>/sdk/index.js`); the mutable `sdk.js`\n// bootstrap resolves the current rollout to one of those roots at load time.\n// A pin bypasses the bootstrap and imports one root directly.\nconst PINNED_SDK_ENTRY_PATH = \"sdk/index.js\";\n\n// Strict on purpose: the pin is interpolated into a CDN path, so only a full\n// lowercase 40-hex git SHA may pass (mirrors scripts/sdk.js's\n// VERSION_OVERRIDE_PATTERN security boundary, minus the short-SHA and pr-N\n// forms — the npm surface pins exactly what CDN_BUILD_SHA carries).\nconst PINNED_BUILD_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_BUILD_SHA_PATTERN = /^0{40}$/;\n\n/** Why a {@link MessagingSdkLoadError} was raised. */\nexport type MessagingSdkLoadErrorCode =\n\t/**\n\t * The `cdnBase` option is not a valid `https:` URL (plain `http:` is\n\t * allowed only for loopback hosts).\n\t */\n\t| \"invalid_cdn_base\"\n\t/** The `pinBuildSha` option is not a full 40-character hex git SHA. */\n\t| \"invalid_build_sha\"\n\t/**\n\t * The `pinBuildSha` option is the unstamped 40-zero placeholder: this\n\t * copy of the package was built from the repository, not published, so\n\t * its `CDN_BUILD_SHA` names no CDN build.\n\t */\n\t| \"unstamped_build_sha\"\n\t/** The dynamic import of the CDN bootstrap failed (fetch or evaluation). */\n\t| \"sdk_import_failed\"\n\t/** The imported module does not expose the Ada Messaging SDK surface. */\n\t| \"sdk_module_invalid\";\n\n/** Typed failure raised by {@link loadMessagingSdk} and {@link loadAdaMessaging}. */\nexport class MessagingSdkLoadError extends Error {\n\treadonly code: MessagingSdkLoadErrorCode;\n\tdeclare readonly fallbackCause?: MessagingSdkLoadError;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: MessagingSdkLoadErrorCode,\n\t\tcause?: unknown,\n\t\tfallbackCause?: MessagingSdkLoadError,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MessagingSdkLoadError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) {\n\t\t\tthis.cause = cause;\n\t\t}\n\t\tif (fallbackCause !== undefined) {\n\t\t\tObject.defineProperty(this, \"fallbackCause\", {\n\t\t\t\tvalue: fallbackCause,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * The programmatic messaging interface {@link loadAdaMessaging} resolves. An\n * alias of the runtime's `AdaEmbedInterface`, which keeps that name because it\n * is also the legacy `window.adaEmbed` compat facade.\n */\nexport type AdaMessagingInterface = AdaEmbedInterface;\n\n/**\n * The public surface of the CDN-resolved SDK module, as loaded from\n * `<cdnBase>/sdk.js`. Types only — the implementation always comes from the\n * CDN at load time and is never part of this npm package.\n */\nexport interface MessagingSdkModule {\n\tAdaMessagingClient: typeof AdaMessagingClient;\n\tcreateAdaEmbedInterface: typeof createAdaEmbedInterface;\n\tdispatchEmbedLoaderInitialActionQueue: typeof dispatchEmbedLoaderInitialActionQueue;\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff: typeof dispatchEmbedLoaderInitialActionQueueForAtomicHandoff;\n\tmountAdaWebViewRuntime: typeof mountAdaWebViewRuntime;\n\tresolveAdaWebViewRuntimeAssets: typeof resolveAdaWebViewRuntimeAssets;\n}\n\ntype ImportSdkModule = (url: string) => Promise<unknown>;\n\nexport interface LoadMessagingSdkOptions {\n\t/**\n\t * CDN root to resolve `sdk.js` from. Must be an `https:` URL; plain\n\t * `http:` is accepted only for loopback hosts (`localhost`, `127.0.0.1`,\n\t * `[::1]`, `*.localhost`) during local development. Defaults to the\n\t * production root ({@link DEFAULT_MESSAGING_CDN_BASE}). An explicit value,\n\t * including {@link FALLBACK_MESSAGING_CDN_BASE}, disables the automatic\n\t * static-root fallback.\n\t */\n\tcdnBase?: string;\n\t/**\n\t * Full 40-character git commit SHA of a deployed CDN build. When set, the\n\t * loader skips the rollout bootstrap and imports that build's immutable\n\t * entry (`<cdnBase>/<sha>/sdk/index.js`) directly. Pass the package's\n\t * `CDN_BUILD_SHA` export to pin the build associated with this npm\n\t * version. NOT recommended for production: a pinned runtime misses Ada's\n\t * fixes and rollouts, and may predate server contract changes. Composes\n\t * with `cdnBase` for staged validation.\n\t */\n\tpinBuildSha?: string;\n\t/**\n\t * Import seam for unit tests. Defaults to a native dynamic `import()` of\n\t * the resolved bootstrap URL.\n\t */\n\timportModule?: ImportSdkModule;\n}\n\n// Both annotations are load-bearing: bundlers rewrite bare dynamic imports,\n// and this specifier must reach the browser untouched so the runtime always\n// resolves from Ada's CDN. The npm build for this entry is unminified so the\n// annotations survive into the published output.\nconst defaultImportModule: ImportSdkModule = (url) =>\n\timport(/* webpackIgnore: true */ /* @vite-ignore */ url);\n\n// Keyed by import seam so production memoizes on the module-level default\n// while each injected test seam gets an isolated cache.\ninterface SdkLoaderState {\n\timports: Map<string, Promise<MessagingSdkModule>>;\n\tdefaultLoads: Map<string, Promise<MessagingSdkModule>>;\n}\n\nconst loadsByImporter = new WeakMap<ImportSdkModule, SdkLoaderState>();\n\n// Share the warning across independently bundled copies of this loader.\nconst FALLBACK_WARNING_KEY = Symbol.for(\"ada.messaging.sdk.fallbackWarning\");\nconst warningScope = globalThis as typeof globalThis & {\n\t[FALLBACK_WARNING_KEY]?: boolean;\n};\n\n// Mirrors the loopback semantics of the shared `isLoopbackHost` /\n// `validateMessagingEndpoint` (shared/utils/src/url.ts) and the bridge\n// loader's copy (packages/bridge/src/npm/loader.ts). Inlined because the\n// published loader must stay dependency-free; keep the host set in sync.\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\", \"::1\"]);\n\nfunction isLoopbackHostname(hostname: string): boolean {\n\tconst normalized = hostname.trim().toLowerCase();\n\t// `*.localhost` resolves to the loopback interface and is \"potentially\n\t// trustworthy\" per the Secure Contexts spec; no production host ends in\n\t// `.localhost`.\n\treturn LOOPBACK_HOSTS.has(normalized) || normalized.endsWith(\".localhost\");\n}\n\nfunction resolvePinnedBuildSha(pinBuildSha: string): string {\n\tconst sha = pinBuildSha.trim().toLowerCase();\n\tif (!PINNED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The pinBuildSha option must be a full 40-character hex git SHA: \"${pinBuildSha}\".`,\n\t\t\t\"invalid_build_sha\",\n\t\t);\n\t}\n\tif (UNSTAMPED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t\"The pinBuildSha option is the unstamped CDN_BUILD_SHA placeholder. Only the published npm package carries a stamped SHA; a repository or local build cannot pin a CDN build.\",\n\t\t\t\"unstamped_build_sha\",\n\t\t);\n\t}\n\treturn sha;\n}\n\n/**\n * The runtime this URL serves carries the SDK's security logic (endpoint\n * validation, session handling, the origin checks), so a cleartext transport\n * would let an on-path attacker replace it wholesale: `https:` is required,\n * with a loopback-only `http:` exception for local development.\n */\nfunction resolveSdkBootstrapUrl(\n\tcdnBase: string | undefined,\n\tpinBuildSha: string | undefined,\n): string {\n\tconst base = (cdnBase ?? DEFAULT_MESSAGING_CDN_BASE).trim();\n\t// Resolving against a base without a trailing slash would drop its last\n\t// path segment, so normalize before building the bootstrap URL.\n\tconst normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n\tconst entryPath =\n\t\tpinBuildSha === undefined\n\t\t\t? SDK_BOOTSTRAP_FILENAME\n\t\t\t: `${resolvePinnedBuildSha(pinBuildSha)}/${PINNED_SDK_ENTRY_PATH}`;\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(entryPath, normalizedBase);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option is not a valid URL: \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t\tcause,\n\t\t);\n\t}\n\tconst isHttps = url.protocol === \"https:\";\n\tconst isLoopbackHttp =\n\t\turl.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n\tif (!isHttps && !isLoopbackHttp) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option must use https (plain http is allowed only for loopback hosts): \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t);\n\t}\n\treturn url.toString();\n}\n\n// A partial CDN module (mid-deploy, or a rolled-back build missing a newer\n// export) must fail here as a typed sdk_module_invalid error, not later as a\n// TypeError on the first missing call — so every export is checked. The\n// `satisfies` clause rejects names that are not interface members; the\n// exhaustiveness type below is what forces this list to grow with it.\nconst REQUIRED_SDK_EXPORTS = [\n\t\"AdaMessagingClient\",\n\t\"createAdaEmbedInterface\",\n\t\"dispatchEmbedLoaderInitialActionQueue\",\n\t\"dispatchEmbedLoaderInitialActionQueueForAtomicHandoff\",\n\t\"mountAdaWebViewRuntime\",\n\t\"resolveAdaWebViewRuntimeAssets\",\n] as const satisfies readonly (keyof MessagingSdkModule)[];\n\n// Compile-time exhaustiveness: adding a MessagingSdkModule member without\n// listing it in REQUIRED_SDK_EXPORTS turns this type into `never`, failing\n// the `true` assignment below.\ntype AllSdkExportsListed =\n\tExclude<\n\t\tkeyof MessagingSdkModule,\n\t\t(typeof REQUIRED_SDK_EXPORTS)[number]\n\t> extends never\n\t\t? true\n\t\t: never;\nconst _allSdkExportsListed: AllSdkExportsListed = true;\nvoid _allSdkExportsListed;\n\nfunction isMessagingSdkModule(value: unknown): value is MessagingSdkModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst candidate = value as Record<string, unknown>;\n\treturn REQUIRED_SDK_EXPORTS.every(\n\t\t(key) => typeof candidate[key] === \"function\",\n\t);\n}\n\nasync function importSdkModule(\n\turl: string,\n\timportModule: ImportSdkModule,\n): Promise<MessagingSdkModule> {\n\tlet loaded: unknown;\n\ttry {\n\t\tloaded = await importModule(url);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The Ada Messaging SDK failed to load from ${url}.`,\n\t\t\t\"sdk_import_failed\",\n\t\t\tcause,\n\t\t);\n\t}\n\tif (!isMessagingSdkModule(loaded)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The module at ${url} does not expose the Ada Messaging SDK interface.`,\n\t\t\t\"sdk_module_invalid\",\n\t\t);\n\t}\n\treturn loaded;\n}\n\nfunction memoizeLoad(\n\tcache: Map<string, Promise<MessagingSdkModule>>,\n\turl: string,\n\tload: () => Promise<MessagingSdkModule>,\n): Promise<MessagingSdkModule> {\n\tconst existing = cache.get(url);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst pending = load();\n\tcache.set(url, pending);\n\tpending.catch(() => {\n\t\tif (cache.get(url) === pending) {\n\t\t\tcache.delete(url);\n\t\t}\n\t});\n\treturn pending;\n}\n\n/**\n * Load the Ada Messaging SDK module from Ada's CDN.\n *\n * The returned promise is memoized per resolved URL: concurrent and repeated\n * calls share one in-flight import. A failed load clears the memo so a later\n * call retries. Without `cdnBase`, an import failure at the default root is\n * retried once from {@link FALLBACK_MESSAGING_CDN_BASE}. Rejections are always\n * {@link MessagingSdkLoadError}.\n *\n * @example\n * const { createAdaEmbedInterface } = await loadMessagingSdk();\n */\nexport function loadMessagingSdk(\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<MessagingSdkModule> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tlet url: string;\n\tlet fallbackUrl: string | undefined;\n\ttry {\n\t\turl = resolveSdkBootstrapUrl(options.cdnBase, options.pinBuildSha);\n\t\tif (options.cdnBase === undefined) {\n\t\t\tfallbackUrl = resolveSdkBootstrapUrl(\n\t\t\t\tFALLBACK_MESSAGING_CDN_BASE,\n\t\t\t\toptions.pinBuildSha,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n\n\tconst state = loadsByImporter.get(importModule) ?? {\n\t\timports: new Map<string, Promise<MessagingSdkModule>>(),\n\t\tdefaultLoads: new Map<string, Promise<MessagingSdkModule>>(),\n\t};\n\tloadsByImporter.set(importModule, state);\n\tconst load = (entryUrl: string) =>\n\t\tmemoizeLoad(state.imports, entryUrl, () =>\n\t\t\timportSdkModule(entryUrl, importModule),\n\t\t);\n\tif (fallbackUrl === undefined) {\n\t\treturn load(url);\n\t}\n\n\tconst retryUrl = fallbackUrl;\n\t// Keep fallback outcomes separate so explicit-root callers share the import,\n\t// but never inherit another caller's permission to retry a different root.\n\treturn memoizeLoad(state.defaultLoads, url, () =>\n\t\tload(url).catch(async (error: unknown) => {\n\t\t\tif (\n\t\t\t\t!(error instanceof MessagingSdkLoadError) ||\n\t\t\t\terror.code !== \"sdk_import_failed\"\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// CSP rejects import() without a network request, so this retry adds no\n\t\t\t// user-visible delay; retrying a genuine network failure once is acceptable too.\n\t\t\tlet module: MessagingSdkModule;\n\t\t\ttry {\n\t\t\t\tmodule = await load(retryUrl);\n\t\t\t} catch (cause) {\n\t\t\t\tif (!(cause instanceof MessagingSdkLoadError)) {\n\t\t\t\t\tthrow cause;\n\t\t\t\t}\n\t\t\t\tthrow new MessagingSdkLoadError(\n\t\t\t\t\tcause.code === \"sdk_import_failed\"\n\t\t\t\t\t\t? `The Ada Messaging SDK failed to load from both ${url} and ${retryUrl}.`\n\t\t\t\t\t\t: cause.message,\n\t\t\t\t\tcause.code,\n\t\t\t\t\terror,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!warningScope[FALLBACK_WARNING_KEY]) {\n\t\t\t\twarningScope[FALLBACK_WARNING_KEY] = true;\n\t\t\t\tconst cause = error.cause;\n\t\t\t\t// Browsers reject blocked, unreachable, or missing imports with TypeError.\n\t\t\t\t// An evaluation-time TypeError still looks like a fetch failure, as before;\n\t\t\t\t// this heuristic narrows diagnostic noise but cannot prove the cause.\n\t\t\t\twarnHost(\n\t\t\t\t\tcause instanceof TypeError\n\t\t\t\t\t\t? `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the default root ${DEFAULT_MESSAGING_CDN_BASE} was blocked or unavailable. Add https://messaging-assets.ada.support to script-src, connect-src and frame-src, or pass cdnBase: \"${FALLBACK_MESSAGING_CDN_BASE}\".`\n\t\t\t\t\t\t: `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the module at ${url} failed to evaluate (${describeRejection(cause)}). This is an Ada-side problem, not your host's CSP. Report it to Ada.`,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn module;\n\t\t}),\n\t);\n}\n\n// Keyed by import seam like the module memo above: production memoizes on\n// the module-level default while each injected test seam gets an isolated\n// cache. `ada` is set when the promise resolves, so the stopped-interface\n// diagnostic can consult the resolved facade without wrapping it.\ninterface StartedInterfaceMemo {\n\tpromise: Promise<AdaMessagingInterface>;\n\tsettings: AdaMessagingStartOptions;\n\tada?: AdaMessagingInterface;\n}\n\nconst startedInterfaceByImporter = new WeakMap<\n\tImportSdkModule,\n\tStartedInterfaceMemo\n>();\n\n// A rejection can be any value, including one that throws on String(); a\n// diagnostic must never turn a successful fallback into a rejected load.\nfunction describeRejection(cause: unknown): string {\n\ttry {\n\t\treturn cause instanceof Error\n\t\t\t? `${cause.name}: ${cause.message}`\n\t\t\t: String(cause);\n\t} catch {\n\t\treturn \"unknown error\";\n\t}\n}\n\n// Ungated like the runtime logger's dropped-host-value channel so host\n// configuration diagnostics remain visible without debug logging.\nfunction warnHost(message: string, cause?: unknown): void {\n\ttry {\n\t\t// biome-ignore lint/suspicious/noConsole: the loader's sanctioned host-page diagnostic sink\n\t\tconsole.warn(`[Ada] ${message}`, ...(cause === undefined ? [] : [cause]));\n\t} catch {\n\t\t// A host may replace console methods; diagnostics must not throw.\n\t}\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\n// Structural equality over the settings surface. Two functions compare equal:\n// fresh inline callbacks on a re-run (React Strict Mode effects) are not a\n// settings change worth a warning. Exotic objects compare by reference.\nfunction settingsEqual(a: unknown, b: unknown): boolean {\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\tif (typeof a === \"function\" && typeof b === \"function\") {\n\t\treturn true;\n\t}\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\treturn (\n\t\t\ta.length === b.length &&\n\t\t\ta.every((item, index) => settingsEqual(item, b[index]))\n\t\t);\n\t}\n\tif (isPlainObject(a) && isPlainObject(b)) {\n\t\tconst aKeys = Object.keys(a);\n\t\tconst bKeys = new Set(Object.keys(b));\n\t\treturn (\n\t\t\taKeys.length === bKeys.size &&\n\t\t\taKeys.every((key) => bKeys.has(key) && settingsEqual(a[key], b[key]))\n\t\t);\n\t}\n\treturn false;\n}\n\n// Observes the facade's symbol-keyed lifecycle getter (embed-lifecycle.ts)\n// instead of wrapping stop/start, so the customer's interface is never\n// mutated; a pinned runtime that predates the getter yields no flag and the\n// stopped-interface diagnostic is skipped rather than guessed.\nfunction isInterfaceStopped(ada: AdaMessagingInterface): boolean {\n\treturn readEmbedStoppedFlag(ada) === true;\n}\n\nasync function startAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions,\n): Promise<AdaMessagingInterface> {\n\tconst sdkModule = await loadMessagingSdk(options);\n\tconst ada = sdkModule.createAdaEmbedInterface();\n\tawait ada.start(settings);\n\treturn ada;\n}\n\n/**\n * Load the SDK, create the messaging interface, and start the widget —\n * the npm-first equivalent of the script-tag + `window.adaSettings` setup.\n *\n * One widget per page: the returned promise is memoized, so repeated and\n * concurrent calls resolve to the same started interface and the first\n * call's settings win. A failed load or start clears the memo so a later\n * call retries. Manage the running widget through the returned interface:\n * `stop()` tears it down and a later `start(settings)` on the same interface\n * runs again. Calling {@link loadAdaMessaging} after `stop()` returns the\n * same stopped interface without restarting it. Both memo outcomes log a\n * console warning: ignored differing settings, and a resolved interface\n * whose widget was stopped.\n *\n * Never assigns the interface to `window` or any other global: the returned\n * reference is the only handle, so hold it in module scope. A reference in\n * module scope is reachable only by your own code, never by other scripts on\n * the page.\n *\n * @example\n * // module scope: your code keeps the only reference\n * const ada = await loadAdaMessaging({\n * handle: \"my-bot\",\n * enableProgrammaticControl: true,\n * });\n * await ada.sendMessage(\"Hello\");\n */\nexport function loadAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<AdaMessagingInterface> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tconst existing = startedInterfaceByImporter.get(importModule);\n\tif (existing) {\n\t\tif (!settingsEqual(settings, existing.settings)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() was already called: the new settings are ignored and the existing interface is returned. To apply new settings, call stop() then start(settings) on it.\",\n\t\t\t);\n\t\t}\n\t\tif (existing.ada && isInterfaceStopped(existing.ada)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() resolved an interface whose widget was stopped and never restarts it. Call start(settings) on it to run the widget again.\",\n\t\t\t);\n\t\t}\n\t\treturn existing.promise;\n\t}\n\tconst memo: StartedInterfaceMemo = {\n\t\tpromise: startAdaMessaging(settings, options),\n\t\tsettings,\n\t};\n\tstartedInterfaceByImporter.set(importModule, memo);\n\tmemo.promise.then(\n\t\t(ada) => {\n\t\t\tmemo.ada = ada;\n\t\t},\n\t\t() => {\n\t\t\tif (startedInterfaceByImporter.get(importModule) === memo) {\n\t\t\t\tstartedInterfaceByImporter.delete(importModule);\n\t\t\t}\n\t\t},\n\t);\n\treturn memo.promise;\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAM,uBAAuB,OAAO,UAAU;AAE9C,SAAS,YACR,QACA,MACA,OACO;AACP,QAAO,eAAe,QAAQ,MAAM;EACnC;EACA,cAAc;EACd,UAAU;EACV,CAAC;;AAGH,IAAI,CAAC,OAAO,OACX,aAAY,QAAQ,WAAW,QAAiB,QAAiB;AAChE,KAAI,UAAU,KACb,OAAM,IAAI,UACT,oEACA;AAEF,QAAO,qBAAqB,KAAK,OAAO,OAAO,EAAE,IAAmB;EACnE;AAGH,SAAS,GAER,OACgB;CAChB,MAAM,SAAS,KAAK,MAAM,OAAO,KAAK,OAAO,CAAC,IAAI;CAClD,IAAI,gBAAgB,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI;AACjD,KAAI,gBAAgB,EACnB,kBAAiB;AAElB,QAAO,gBAAgB,KAAK,iBAAiB,SAC1C,KAAA,IACA,KAAK;;AAGT,SAAS,SAAuB,OAAoC;CACnE,MAAM,QAAQ,OAAO,KAAK;CAC1B,MAAM,SAAS,MAAM;CACrB,IAAI,gBAAgB,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI;AACjD,KAAI,gBAAgB,EACnB,kBAAiB;AAElB,QAAO,gBAAgB,KAAK,iBAAiB,SAC1C,KAAA,IACA,MAAM,OAAO,cAAc;;AAG/B,IAAM,yBAAyB;CAC9B,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,CAAC,OAAO,QAAQ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,IAAI,OAAO,KAAK,EAAE,CAAC;AACrC,SACC,MAAM,WAAW,MAAM,QACvB,MAAM,OAAO,QAAQ,MAAM,IAAI,IAAI,IAAI,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC;;AAGvE,QAAO;;AAOR,SAAS,mBAAmB,KAAqC;AAChE,QAAO,qBAAqB,IAAI,KAAK;;AAGtC,eAAe,kBACd,UACA,SACiC;CAEjC,MAAM,OADY,MAAM,iBAAiB,QAAQ,EAC3B,yBAAyB;AAC/C,OAAM,IAAI,MAAM,SAAS;AACzB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BR,SAAgB,iBACf,UACA,UAAmC,EAAE,EACJ;CACjC,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,MAAM,WAAW,2BAA2B,IAAI,aAAa;AAC7D,KAAI,UAAU;AACb,MAAI,CAAC,cAAc,UAAU,SAAS,SAAS,CAC9C,UACC,6KACA;AAEF,MAAI,SAAS,OAAO,mBAAmB,SAAS,IAAI,CACnD,UACC,+IACA;AAEF,SAAO,SAAS;;CAEjB,MAAM,OAA6B;EAClC,SAAS,kBAAkB,UAAU,QAAQ;EAC7C;EACA;AACD,4BAA2B,IAAI,cAAc,KAAK;AAClD,MAAK,QAAQ,MACX,QAAQ;AACR,OAAK,MAAM;UAEN;AACL,MAAI,2BAA2B,IAAI,aAAa,KAAK,KACpD,4BAA2B,OAAO,aAAa;GAGjD;AACD,QAAO,KAAK"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/build-info.ts","../../src/client/embed-lifecycle.ts","../../src/npm/loader.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","// The repo copy carries the 40-zero placeholder; the publish workflow\n// (.github/workflows/messaging-publish-web-packages.yml) stamps the real\n// commit SHA into the built output via scripts/stamp-cdn-build-sha.mjs and\n// verifies the packed tarball before `npm publish`. Keep the placeholder as\n// a single 40-zero string literal: the stamp is a same-length text\n// replacement, so source maps stay valid.\nconst GIT_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_SHA_PATTERN = /^0{40}$/;\n\n/**\n * Git commit SHA of the monorepo commit this npm version was published from.\n * The CDN pipeline deploys each main commit's runtime under an immutable\n * SHA root, so this value names the CDN build associated with this npm\n * version. Pass it as the `pinBuildSha` loader option to load exactly that\n * runtime build — not recommended for production (see the README).\n *\n * In the repository, and in any locally built copy, the value is the\n * unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns\n * `false`); only published tarballs carry a real SHA.\n */\nexport const CDN_BUILD_SHA: string = \"9127673bc66718428b8a960ffb074e6c00adf0b5\";\n\n/**\n * Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit\n * SHA rather than the unstamped repo placeholder.\n */\nexport function isCdnBuildShaStamped(sha: string = CDN_BUILD_SHA): boolean {\n\tconst normalized = sha.trim().toLowerCase();\n\treturn (\n\t\tGIT_SHA_PATTERN.test(normalized) && !UNSTAMPED_SHA_PATTERN.test(normalized)\n\t);\n}\n","/**\n * Lifecycle channel between `createAdaEmbedInterface` and the npm loader's\n * memo: a non-enumerable getter over closure state, so the loader never\n * mutates the public surface and `Object.freeze` on the facade still works.\n * `Symbol.for` because the loader and the CDN runtime are separate builds;\n * a runtime that predates the getter yields `undefined` — degrade gracefully.\n */\nexport const EMBED_LIFECYCLE_STOPPED = Symbol.for(\n\t\"ada-cx/messaging-sdk/embed-stopped\",\n);\n\n/** Read the facade's stopped flag; `undefined` when the runtime predates it. */\nexport function readEmbedStoppedFlag(ada: object): boolean | undefined {\n\tconst value = (ada as Record<symbol, unknown>)[EMBED_LIFECYCLE_STOPPED];\n\treturn typeof value === \"boolean\" ? value : undefined;\n}\n\n/** Define the getter at facade creation time, before any host freeze. */\nexport function defineEmbedStoppedFlag(\n\tada: object,\n\treadStopped: () => boolean,\n): void {\n\tObject.defineProperty(ada, EMBED_LIFECYCLE_STOPPED, {\n\t\tget: readStopped,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n}\n","import type { AdaMessagingClient } from \"../client/client\";\nimport type { AdaMessagingStartOptions } from \"../client/client-types\";\nimport type {\n\tAdaEmbedInterface,\n\tcreateAdaEmbedInterface,\n\tdispatchEmbedLoaderInitialActionQueue,\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff,\n} from \"../client/embed-interface\";\nimport { readEmbedStoppedFlag } from \"../client/embed-lifecycle\";\nimport type {\n\tmountAdaWebViewRuntime,\n\tresolveAdaWebViewRuntimeAssets,\n} from \"../mobile-webview-runtime\";\n\n/**\n * Production CDN root the loader resolves the SDK bootstrap from when no\n * `cdnBase` override is given. The npm package never pins a runtime version;\n * the bootstrap at this root resolves the current rollout at load time.\n */\nexport const DEFAULT_MESSAGING_CDN_BASE =\n\t\"https://messaging-assets.ada.support/\";\n\nexport const FALLBACK_MESSAGING_CDN_BASE =\n\t\"https://static.ada.support/messaging/\";\n\nconst SDK_BOOTSTRAP_FILENAME = \"sdk.js\";\n\n// The CDN pipeline deploys each main commit's runtime as an immutable\n// SHA-rooted entry (`<cdnBase>/<sha>/sdk/index.js`); the mutable `sdk.js`\n// bootstrap resolves the current rollout to one of those roots at load time.\n// A pin bypasses the bootstrap and imports one root directly.\nconst PINNED_SDK_ENTRY_PATH = \"sdk/index.js\";\n\n// Strict on purpose: the pin is interpolated into a CDN path, so only a full\n// lowercase 40-hex git SHA may pass (mirrors scripts/sdk.js's\n// VERSION_OVERRIDE_PATTERN security boundary, minus the short-SHA and pr-N\n// forms — the npm surface pins exactly what CDN_BUILD_SHA carries).\nconst PINNED_BUILD_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_BUILD_SHA_PATTERN = /^0{40}$/;\n\n/** Why a {@link MessagingSdkLoadError} was raised. */\nexport type MessagingSdkLoadErrorCode =\n\t/**\n\t * The `cdnBase` option is not a valid `https:` URL (plain `http:` is\n\t * allowed only for loopback hosts).\n\t */\n\t| \"invalid_cdn_base\"\n\t/** The `pinBuildSha` option is not a full 40-character hex git SHA. */\n\t| \"invalid_build_sha\"\n\t/**\n\t * The `pinBuildSha` option is the unstamped 40-zero placeholder: this\n\t * copy of the package was built from the repository, not published, so\n\t * its `CDN_BUILD_SHA` names no CDN build.\n\t */\n\t| \"unstamped_build_sha\"\n\t/** The dynamic import of the CDN bootstrap failed (fetch or evaluation). */\n\t| \"sdk_import_failed\"\n\t/** The imported module does not expose the Ada Messaging SDK surface. */\n\t| \"sdk_module_invalid\";\n\n/** Typed failure raised by {@link loadMessagingSdk} and {@link loadAdaMessaging}. */\nexport class MessagingSdkLoadError extends Error {\n\treadonly code: MessagingSdkLoadErrorCode;\n\tdeclare readonly fallbackCause?: MessagingSdkLoadError;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: MessagingSdkLoadErrorCode,\n\t\tcause?: unknown,\n\t\tfallbackCause?: MessagingSdkLoadError,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MessagingSdkLoadError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) {\n\t\t\tthis.cause = cause;\n\t\t}\n\t\tif (fallbackCause !== undefined) {\n\t\t\tObject.defineProperty(this, \"fallbackCause\", {\n\t\t\t\tvalue: fallbackCause,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * The programmatic messaging interface {@link loadAdaMessaging} resolves. An\n * alias of the runtime's `AdaEmbedInterface`, which keeps that name because it\n * is also the legacy `window.adaEmbed` compat facade.\n * Includes `selectQuickReply(messageId, index)` for Web SDK integrations.\n */\nexport type AdaMessagingInterface = AdaEmbedInterface;\n\n/**\n * The public surface of the CDN-resolved SDK module, as loaded from\n * `<cdnBase>/sdk.js`. Types only — the implementation always comes from the\n * CDN at load time and is never part of this npm package.\n */\nexport interface MessagingSdkModule {\n\tAdaMessagingClient: typeof AdaMessagingClient;\n\tcreateAdaEmbedInterface: typeof createAdaEmbedInterface;\n\tdispatchEmbedLoaderInitialActionQueue: typeof dispatchEmbedLoaderInitialActionQueue;\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff: typeof dispatchEmbedLoaderInitialActionQueueForAtomicHandoff;\n\tmountAdaWebViewRuntime: typeof mountAdaWebViewRuntime;\n\tresolveAdaWebViewRuntimeAssets: typeof resolveAdaWebViewRuntimeAssets;\n}\n\ntype ImportSdkModule = (url: string) => Promise<unknown>;\n\nexport interface LoadMessagingSdkOptions {\n\t/**\n\t * CDN root to resolve `sdk.js` from. Must be an `https:` URL; plain\n\t * `http:` is accepted only for loopback hosts (`localhost`, `127.0.0.1`,\n\t * `[::1]`, `*.localhost`) during local development. Defaults to the\n\t * production root ({@link DEFAULT_MESSAGING_CDN_BASE}). An explicit value,\n\t * including {@link FALLBACK_MESSAGING_CDN_BASE}, disables the automatic\n\t * static-root fallback.\n\t */\n\tcdnBase?: string;\n\t/**\n\t * Full 40-character git commit SHA of a deployed CDN build. When set, the\n\t * loader skips the rollout bootstrap and imports that build's immutable\n\t * entry (`<cdnBase>/<sha>/sdk/index.js`) directly. Pass the package's\n\t * `CDN_BUILD_SHA` export to pin the build associated with this npm\n\t * version. NOT recommended for production: a pinned runtime misses Ada's\n\t * fixes and rollouts, and may predate server contract changes. Composes\n\t * with `cdnBase` for staged validation.\n\t */\n\tpinBuildSha?: string;\n\t/**\n\t * Import seam for unit tests. Defaults to a native dynamic `import()` of\n\t * the resolved bootstrap URL.\n\t */\n\timportModule?: ImportSdkModule;\n}\n\n// Both annotations are load-bearing: bundlers rewrite bare dynamic imports,\n// and this specifier must reach the browser untouched so the runtime always\n// resolves from Ada's CDN. The npm build for this entry is unminified so the\n// annotations survive into the published output.\nconst defaultImportModule: ImportSdkModule = (url) =>\n\timport(/* webpackIgnore: true */ /* @vite-ignore */ url);\n\n// Keyed by import seam so production memoizes on the module-level default\n// while each injected test seam gets an isolated cache.\ninterface SdkLoaderState {\n\timports: Map<string, Promise<MessagingSdkModule>>;\n\tdefaultLoads: Map<string, Promise<MessagingSdkModule>>;\n}\n\nconst loadsByImporter = new WeakMap<ImportSdkModule, SdkLoaderState>();\n\n// Share the warning across independently bundled copies of this loader.\nconst FALLBACK_WARNING_KEY = Symbol.for(\"ada.messaging.sdk.fallbackWarning\");\nconst warningScope = globalThis as typeof globalThis & {\n\t[FALLBACK_WARNING_KEY]?: boolean;\n};\n\n// Mirrors the loopback semantics of the shared `isLoopbackHost` /\n// `validateMessagingEndpoint` (shared/utils/src/url.ts) and the bridge\n// loader's copy (packages/bridge/src/npm/loader.ts). Inlined because the\n// published loader must stay dependency-free; keep the host set in sync.\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\", \"::1\"]);\n\nfunction isLoopbackHostname(hostname: string): boolean {\n\tconst normalized = hostname.trim().toLowerCase();\n\t// `*.localhost` resolves to the loopback interface and is \"potentially\n\t// trustworthy\" per the Secure Contexts spec; no production host ends in\n\t// `.localhost`.\n\treturn LOOPBACK_HOSTS.has(normalized) || normalized.endsWith(\".localhost\");\n}\n\nfunction resolvePinnedBuildSha(pinBuildSha: string): string {\n\tconst sha = pinBuildSha.trim().toLowerCase();\n\tif (!PINNED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The pinBuildSha option must be a full 40-character hex git SHA: \"${pinBuildSha}\".`,\n\t\t\t\"invalid_build_sha\",\n\t\t);\n\t}\n\tif (UNSTAMPED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t\"The pinBuildSha option is the unstamped CDN_BUILD_SHA placeholder. Only the published npm package carries a stamped SHA; a repository or local build cannot pin a CDN build.\",\n\t\t\t\"unstamped_build_sha\",\n\t\t);\n\t}\n\treturn sha;\n}\n\n/**\n * The runtime this URL serves carries the SDK's security logic (endpoint\n * validation, session handling, the origin checks), so a cleartext transport\n * would let an on-path attacker replace it wholesale: `https:` is required,\n * with a loopback-only `http:` exception for local development.\n */\nfunction resolveSdkBootstrapUrl(\n\tcdnBase: string | undefined,\n\tpinBuildSha: string | undefined,\n): string {\n\tconst base = (cdnBase ?? DEFAULT_MESSAGING_CDN_BASE).trim();\n\t// Resolving against a base without a trailing slash would drop its last\n\t// path segment, so normalize before building the bootstrap URL.\n\tconst normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n\tconst entryPath =\n\t\tpinBuildSha === undefined\n\t\t\t? SDK_BOOTSTRAP_FILENAME\n\t\t\t: `${resolvePinnedBuildSha(pinBuildSha)}/${PINNED_SDK_ENTRY_PATH}`;\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(entryPath, normalizedBase);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option is not a valid URL: \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t\tcause,\n\t\t);\n\t}\n\tconst isHttps = url.protocol === \"https:\";\n\tconst isLoopbackHttp =\n\t\turl.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n\tif (!isHttps && !isLoopbackHttp) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option must use https (plain http is allowed only for loopback hosts): \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t);\n\t}\n\treturn url.toString();\n}\n\n// A partial CDN module (mid-deploy, or a rolled-back build missing a newer\n// export) must fail here as a typed sdk_module_invalid error, not later as a\n// TypeError on the first missing call — so every export is checked. The\n// `satisfies` clause rejects names that are not interface members; the\n// exhaustiveness type below is what forces this list to grow with it.\nconst REQUIRED_SDK_EXPORTS = [\n\t\"AdaMessagingClient\",\n\t\"createAdaEmbedInterface\",\n\t\"dispatchEmbedLoaderInitialActionQueue\",\n\t\"dispatchEmbedLoaderInitialActionQueueForAtomicHandoff\",\n\t\"mountAdaWebViewRuntime\",\n\t\"resolveAdaWebViewRuntimeAssets\",\n] as const satisfies readonly (keyof MessagingSdkModule)[];\n\n// Compile-time exhaustiveness: adding a MessagingSdkModule member without\n// listing it in REQUIRED_SDK_EXPORTS turns this type into `never`, failing\n// the `true` assignment below.\ntype AllSdkExportsListed =\n\tExclude<\n\t\tkeyof MessagingSdkModule,\n\t\t(typeof REQUIRED_SDK_EXPORTS)[number]\n\t> extends never\n\t\t? true\n\t\t: never;\nconst _allSdkExportsListed: AllSdkExportsListed = true;\nvoid _allSdkExportsListed;\n\nfunction isMessagingSdkModule(value: unknown): value is MessagingSdkModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst candidate = value as Record<string, unknown>;\n\treturn REQUIRED_SDK_EXPORTS.every(\n\t\t(key) => typeof candidate[key] === \"function\",\n\t);\n}\n\nasync function importSdkModule(\n\turl: string,\n\timportModule: ImportSdkModule,\n): Promise<MessagingSdkModule> {\n\tlet loaded: unknown;\n\ttry {\n\t\tloaded = await importModule(url);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The Ada Messaging SDK failed to load from ${url}.`,\n\t\t\t\"sdk_import_failed\",\n\t\t\tcause,\n\t\t);\n\t}\n\tif (!isMessagingSdkModule(loaded)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The module at ${url} does not expose the Ada Messaging SDK interface.`,\n\t\t\t\"sdk_module_invalid\",\n\t\t);\n\t}\n\treturn loaded;\n}\n\nfunction memoizeLoad(\n\tcache: Map<string, Promise<MessagingSdkModule>>,\n\turl: string,\n\tload: () => Promise<MessagingSdkModule>,\n): Promise<MessagingSdkModule> {\n\tconst existing = cache.get(url);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst pending = load();\n\tcache.set(url, pending);\n\tpending.catch(() => {\n\t\tif (cache.get(url) === pending) {\n\t\t\tcache.delete(url);\n\t\t}\n\t});\n\treturn pending;\n}\n\n/**\n * Load the Ada Messaging SDK module from Ada's CDN.\n *\n * The returned promise is memoized per resolved URL: concurrent and repeated\n * calls share one in-flight import. A failed load clears the memo so a later\n * call retries. Without `cdnBase`, an import failure at the default root is\n * retried once from {@link FALLBACK_MESSAGING_CDN_BASE}. Rejections are always\n * {@link MessagingSdkLoadError}.\n *\n * @example\n * const { createAdaEmbedInterface } = await loadMessagingSdk();\n */\nexport function loadMessagingSdk(\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<MessagingSdkModule> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tlet url: string;\n\tlet fallbackUrl: string | undefined;\n\ttry {\n\t\turl = resolveSdkBootstrapUrl(options.cdnBase, options.pinBuildSha);\n\t\tif (options.cdnBase === undefined) {\n\t\t\tfallbackUrl = resolveSdkBootstrapUrl(\n\t\t\t\tFALLBACK_MESSAGING_CDN_BASE,\n\t\t\t\toptions.pinBuildSha,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n\n\tconst state = loadsByImporter.get(importModule) ?? {\n\t\timports: new Map<string, Promise<MessagingSdkModule>>(),\n\t\tdefaultLoads: new Map<string, Promise<MessagingSdkModule>>(),\n\t};\n\tloadsByImporter.set(importModule, state);\n\tconst load = (entryUrl: string) =>\n\t\tmemoizeLoad(state.imports, entryUrl, () =>\n\t\t\timportSdkModule(entryUrl, importModule),\n\t\t);\n\tif (fallbackUrl === undefined) {\n\t\treturn load(url);\n\t}\n\n\tconst retryUrl = fallbackUrl;\n\t// Keep fallback outcomes separate so explicit-root callers share the import,\n\t// but never inherit another caller's permission to retry a different root.\n\treturn memoizeLoad(state.defaultLoads, url, () =>\n\t\tload(url).catch(async (error: unknown) => {\n\t\t\tif (\n\t\t\t\t!(error instanceof MessagingSdkLoadError) ||\n\t\t\t\terror.code !== \"sdk_import_failed\"\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// CSP rejects import() without a network request, so this retry adds no\n\t\t\t// user-visible delay; retrying a genuine network failure once is acceptable too.\n\t\t\tlet module: MessagingSdkModule;\n\t\t\ttry {\n\t\t\t\tmodule = await load(retryUrl);\n\t\t\t} catch (cause) {\n\t\t\t\tif (!(cause instanceof MessagingSdkLoadError)) {\n\t\t\t\t\tthrow cause;\n\t\t\t\t}\n\t\t\t\tthrow new MessagingSdkLoadError(\n\t\t\t\t\tcause.code === \"sdk_import_failed\"\n\t\t\t\t\t\t? `The Ada Messaging SDK failed to load from both ${url} and ${retryUrl}.`\n\t\t\t\t\t\t: cause.message,\n\t\t\t\t\tcause.code,\n\t\t\t\t\terror,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!warningScope[FALLBACK_WARNING_KEY]) {\n\t\t\t\twarningScope[FALLBACK_WARNING_KEY] = true;\n\t\t\t\tconst cause = error.cause;\n\t\t\t\t// Browsers reject blocked, unreachable, or missing imports with TypeError.\n\t\t\t\t// An evaluation-time TypeError still looks like a fetch failure, as before;\n\t\t\t\t// this heuristic narrows diagnostic noise but cannot prove the cause.\n\t\t\t\twarnHost(\n\t\t\t\t\tcause instanceof TypeError\n\t\t\t\t\t\t? `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the default root ${DEFAULT_MESSAGING_CDN_BASE} was blocked or unavailable. Add https://messaging-assets.ada.support to script-src, connect-src and frame-src, or pass cdnBase: \"${FALLBACK_MESSAGING_CDN_BASE}\".`\n\t\t\t\t\t\t: `Loaded the Messaging SDK from ${FALLBACK_MESSAGING_CDN_BASE} because the module at ${url} failed to evaluate (${describeRejection(cause)}). This is an Ada-side problem, not your host's CSP. Report it to Ada.`,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn module;\n\t\t}),\n\t);\n}\n\n// Keyed by import seam like the module memo above: production memoizes on\n// the module-level default while each injected test seam gets an isolated\n// cache. `ada` is set when the promise resolves, so the stopped-interface\n// diagnostic can consult the resolved facade without wrapping it.\ninterface StartedInterfaceMemo {\n\tpromise: Promise<AdaMessagingInterface>;\n\tsettings: AdaMessagingStartOptions;\n\tada?: AdaMessagingInterface;\n}\n\nconst startedInterfaceByImporter = new WeakMap<\n\tImportSdkModule,\n\tStartedInterfaceMemo\n>();\n\n// A rejection can be any value, including one that throws on String(); a\n// diagnostic must never turn a successful fallback into a rejected load.\nfunction describeRejection(cause: unknown): string {\n\ttry {\n\t\treturn cause instanceof Error\n\t\t\t? `${cause.name}: ${cause.message}`\n\t\t\t: String(cause);\n\t} catch {\n\t\treturn \"unknown error\";\n\t}\n}\n\n// Ungated like the runtime logger's dropped-host-value channel so host\n// configuration diagnostics remain visible without debug logging.\nfunction warnHost(message: string, cause?: unknown): void {\n\ttry {\n\t\t// biome-ignore lint/suspicious/noConsole: the loader's sanctioned host-page diagnostic sink\n\t\tconsole.warn(`[Ada] ${message}`, ...(cause === undefined ? [] : [cause]));\n\t} catch {\n\t\t// A host may replace console methods; diagnostics must not throw.\n\t}\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\n// Structural equality over the settings surface. Two functions compare equal:\n// fresh inline callbacks on a re-run (React Strict Mode effects) are not a\n// settings change worth a warning. Exotic objects compare by reference.\nfunction settingsEqual(a: unknown, b: unknown): boolean {\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\tif (typeof a === \"function\" && typeof b === \"function\") {\n\t\treturn true;\n\t}\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\treturn (\n\t\t\ta.length === b.length &&\n\t\t\ta.every((item, index) => settingsEqual(item, b[index]))\n\t\t);\n\t}\n\tif (isPlainObject(a) && isPlainObject(b)) {\n\t\tconst aKeys = Object.keys(a);\n\t\tconst bKeys = new Set(Object.keys(b));\n\t\treturn (\n\t\t\taKeys.length === bKeys.size &&\n\t\t\taKeys.every((key) => bKeys.has(key) && settingsEqual(a[key], b[key]))\n\t\t);\n\t}\n\treturn false;\n}\n\n// Observes the facade's symbol-keyed lifecycle getter (embed-lifecycle.ts)\n// instead of wrapping stop/start, so the customer's interface is never\n// mutated; a pinned runtime that predates the getter yields no flag and the\n// stopped-interface diagnostic is skipped rather than guessed.\nfunction isInterfaceStopped(ada: AdaMessagingInterface): boolean {\n\treturn readEmbedStoppedFlag(ada) === true;\n}\n\nasync function startAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions,\n): Promise<AdaMessagingInterface> {\n\tconst sdkModule = await loadMessagingSdk(options);\n\tconst ada = sdkModule.createAdaEmbedInterface();\n\tawait ada.start(settings);\n\treturn ada;\n}\n\n/**\n * Load the SDK, create the messaging interface, and start the widget —\n * the npm-first equivalent of the script-tag + `window.adaSettings` setup.\n *\n * One widget per page: the returned promise is memoized, so repeated and\n * concurrent calls resolve to the same started interface and the first\n * call's settings win. A failed load or start clears the memo so a later\n * call retries. Manage the running widget through the returned interface:\n * `stop()` tears it down and a later `start(settings)` on the same interface\n * runs again. Calling {@link loadAdaMessaging} after `stop()` returns the\n * same stopped interface without restarting it. Both memo outcomes log a\n * console warning: ignored differing settings, and a resolved interface\n * whose widget was stopped.\n *\n * Never assigns the interface to `window` or any other global: the returned\n * reference is the only handle, so hold it in module scope. A reference in\n * module scope is reachable only by your own code, never by other scripts on\n * the page.\n *\n * @example\n * // module scope: your code keeps the only reference\n * const ada = await loadAdaMessaging({\n * handle: \"my-bot\",\n * enableProgrammaticControl: true,\n * });\n * await ada.sendMessage(\"Hello\");\n */\nexport function loadAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<AdaMessagingInterface> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tconst existing = startedInterfaceByImporter.get(importModule);\n\tif (existing) {\n\t\tif (!settingsEqual(settings, existing.settings)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() was already called: the new settings are ignored and the existing interface is returned. To apply new settings, call stop() then start(settings) on it.\",\n\t\t\t);\n\t\t}\n\t\tif (existing.ada && isInterfaceStopped(existing.ada)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() resolved an interface whose widget was stopped and never restarts it. Call start(settings) on it to run the widget again.\",\n\t\t\t);\n\t\t}\n\t\treturn existing.promise;\n\t}\n\tconst memo: StartedInterfaceMemo = {\n\t\tpromise: startAdaMessaging(settings, options),\n\t\tsettings,\n\t};\n\tstartedInterfaceByImporter.set(importModule, memo);\n\tmemo.promise.then(\n\t\t(ada) => {\n\t\t\tmemo.ada = ada;\n\t\t},\n\t\t() => {\n\t\t\tif (startedInterfaceByImporter.get(importModule) === memo) {\n\t\t\t\tstartedInterfaceByImporter.delete(importModule);\n\t\t\t}\n\t\t},\n\t);\n\treturn memo.promise;\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAM,uBAAuB,OAAO,UAAU;AAE9C,SAAS,YACR,QACA,MACA,OACO;AACP,QAAO,eAAe,QAAQ,MAAM;EACnC;EACA,cAAc;EACd,UAAU;EACV,CAAC;;AAGH,IAAI,CAAC,OAAO,OACX,aAAY,QAAQ,WAAW,QAAiB,QAAiB;AAChE,KAAI,UAAU,KACb,OAAM,IAAI,UACT,oEACA;AAEF,QAAO,qBAAqB,KAAK,OAAO,OAAO,EAAE,IAAmB;EACnE;AAGH,SAAS,GAER,OACgB;CAChB,MAAM,SAAS,KAAK,MAAM,OAAO,KAAK,OAAO,CAAC,IAAI;CAClD,IAAI,gBAAgB,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI;AACjD,KAAI,gBAAgB,EACnB,kBAAiB;AAElB,QAA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,QAAQ,MACX,QAAQ;AACR,OAAK,MAAM;UAEN;AACL,MAAI,2BAA2B,IAAI,aAAa,KAAK,KACpD,4BAA2B,OAAO,aAAa;GAGjD;AACD,QAAO,KAAK"}
@@ -38,6 +38,7 @@ export declare class MessagingSdkLoadError extends Error {
38
38
  * The programmatic messaging interface {@link loadAdaMessaging} resolves. An
39
39
  * alias of the runtime's `AdaEmbedInterface`, which keeps that name because it
40
40
  * is also the legacy `window.adaEmbed` compat facade.
41
+ * Includes `selectQuickReply(messageId, index)` for Web SDK integrations.
41
42
  */
42
43
  export type AdaMessagingInterface = AdaEmbedInterface;
43
44
  /**
@@ -38,6 +38,7 @@ export declare class MessagingSdkLoadError extends Error {
38
38
  * The programmatic messaging interface {@link loadAdaMessaging} resolves. An
39
39
  * alias of the runtime's `AdaEmbedInterface`, which keeps that name because it
40
40
  * is also the legacy `window.adaEmbed` compat facade.
41
+ * Includes `selectQuickReply(messageId, index)` for Web SDK integrations.
41
42
  */
42
43
  export type AdaMessagingInterface = AdaEmbedInterface;
43
44
  /**
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var M=Object.prototype.hasOwnProperty;function g(n,e,a){Object.defineProperty(n,e,{value:a,configurable:!0,writable:!0})}Object.hasOwn||g(Object,"hasOwn",(n,e)=>{if(n==null)throw new TypeError("ada browser-polyfills: Cannot convert undefined or null to object");return M.call(Object(n),e)});function p(n){const e=Math.trunc(Number(this.length))||0;let a=Math.trunc(Number(n))||0;return a<0&&(a+=e),a<0||a>=e?void 0:this[a]}function T(n){const e=String(this),a=e.length;let r=Math.trunc(Number(n))||0;return r<0&&(r+=a),r<0||r>=a?void 0:e.charAt(r)}var O=[globalThis.Int8Array,globalThis.Uint8Array,globalThis.Uint8ClampedArray,globalThis.Int16Array,globalThis.Uint16Array,globalThis.Int32Array,globalThis.Uint32Array,globalThis.Float32Array,globalThis.Float64Array,globalThis.BigInt64Array,globalThis.BigUint64Array].filter(Boolean);Array.prototype.at||g(Array.prototype,"at",p);String.prototype.at||g(String.prototype,"at",T);for(const n of O){const e=n.prototype;e.at||g(e,"at",p)}var v=new Set(["ada:message:sent","ada:message:received"]);function C(n,e){return v.has(e)?n===e:n===e||e.startsWith(n)}function w(n){const e={};for(const[a,r]of Object.entries(n))(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||r===null)&&(e[a]=r);return e}function S(n={}){const e=[];let a=1,r=1,i=!1,c=null;const u={},l=[],d=new Map,y=new Map,b=(t,s)=>{for(const o of d.values())C(o.key,t)&&o.callback(s,{eventKey:t});if(!v.has(t))for(const o of y.values())o(t,s)},f=()=>{l.length=0,c=null},h={start:async()=>{},stop:async()=>{},toggle:async()=>{i=!i},deleteHistory:async()=>{f()},reset:async()=>{f()},setMetaFields:async t=>{Object.assign(u,w(t))},setSensitiveMetaFields:async()=>{},setTestModeBanner:async()=>{},getInfo:async()=>({isChatOpen:i,isDrawerOpen:i,hasActiveChatter:l.length>0,hasClosedChat:!1}),getMetaFields:async()=>({...u}),isOpen:async()=>i,getConversation:async()=>({id:c,handoff:{inLiveChat:!1}}),getMessages:async()=>[...l],setComposerText:async()=>{},setDelegate:()=>{},trackEvent:async()=>{},subscribeEvent:async(t,s)=>{const o=a++;return d.set(o,{key:t,callback:s}),o},unsubscribeEvent:async t=>{d.delete(t),y.delete(t)},subscribeAll:async t=>{const s=a++;return y.set(s,t),s},open:async()=>{i=!0},close:async()=>{i=!1},setLanguage:async()=>{},setTheme:async()=>{},setDeviceToken:async()=>{},acknowledgeSessionMirrorClear:async()=>{},deliverSessionMirrorSeed:async()=>{},sendMessage:async t=>{const s=`mock-message-${r++}`;return c=c??"mock-conversation",l.push({id:s,role:"user",type:"text",body:t,createdAt:Math.floor(Date.now()/1e3),origin:"programmatic"}),{id:s}},handleNotification:async()=>{i=!0},requestNotifications:async()=>"granted",createProactive:async()=>{},triggerCampaign:async()=>{},evaluateCampaignConditions:async()=>{},closeCampaign:async()=>{},triggerAnswer:async()=>{},triggerProactive:async()=>{},triggerGreeting:async()=>{},destroy:async()=>{d.clear(),y.clear(),i=!1}},m=Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0)),A={...h,...m};return{...Object.fromEntries(Object.entries(A).map(([t,s])=>[t,(...o)=>(e.push({method:t,args:o}),s(...o))])),calls:e,$emit:b}}exports.createMockAdaMessaging=S;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var O=Object.prototype.hasOwnProperty;function g(n,e,a){Object.defineProperty(n,e,{value:a,configurable:!0,writable:!0})}Object.hasOwn||g(Object,"hasOwn",(n,e)=>{if(n==null)throw new TypeError("ada browser-polyfills: Cannot convert undefined or null to object");return O.call(Object(n),e)});function v(n){const e=Math.trunc(Number(this.length))||0;let a=Math.trunc(Number(n))||0;return a<0&&(a+=e),a<0||a>=e?void 0:this[a]}function T(n){const e=String(this),a=e.length;let r=Math.trunc(Number(n))||0;return r<0&&(r+=a),r<0||r>=a?void 0:e.charAt(r)}var C=[globalThis.Int8Array,globalThis.Uint8Array,globalThis.Uint8ClampedArray,globalThis.Int16Array,globalThis.Uint16Array,globalThis.Int32Array,globalThis.Uint32Array,globalThis.Float32Array,globalThis.Float64Array,globalThis.BigInt64Array,globalThis.BigUint64Array].filter(Boolean);Array.prototype.at||g(Array.prototype,"at",v);String.prototype.at||g(String.prototype,"at",T);for(const n of C){const e=n.prototype;e.at||g(e,"at",v)}var b=new Set(["ada:message:sent","ada:message:received"]);function w(n,e){return b.has(e)?n===e:n===e||e.startsWith(n)}function p(n){const e={};for(const[a,r]of Object.entries(n))(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||r===null)&&(e[a]=r);return e}function S(n={}){const e=[];let a=1,r=1,o=!1,c=null;const u={},l=[],d=new Map,y=new Map,h=(t,s)=>{for(const i of d.values())w(i.key,t)&&i.callback(s,{eventKey:t});if(!b.has(t))for(const i of y.values())i(t,s)},f=()=>{l.length=0,c=null},m={start:async()=>{},stop:async()=>{},toggle:async()=>{o=!o},deleteHistory:async()=>{f()},reset:async()=>{f()},setMetaFields:async t=>{Object.assign(u,p(t))},setSensitiveMetaFields:async()=>{},setTestModeBanner:async()=>{},getInfo:async()=>({isChatOpen:o,isDrawerOpen:o,hasActiveChatter:l.length>0,hasClosedChat:!1}),getMetaFields:async()=>({...u}),isOpen:async()=>o,getConversation:async()=>({id:c,handoff:{inLiveChat:!1}}),getMessages:async()=>[...l],setComposerText:async()=>{},selectQuickReply:async()=>{},setDelegate:()=>{},trackEvent:async()=>{},subscribeEvent:async(t,s)=>{const i=a++;return d.set(i,{key:t,callback:s}),i},unsubscribeEvent:async t=>{d.delete(t),y.delete(t)},subscribeAll:async t=>{const s=a++;return y.set(s,t),s},open:async()=>{o=!0},close:async()=>{o=!1},setLanguage:async()=>{},setTheme:async()=>{},setDeviceToken:async()=>{},acknowledgeSessionMirrorClear:async()=>{},deliverSessionMirrorSeed:async()=>{},triggerPlaybook:async(t,s)=>{o=!0,Object.assign(u,p(s?.metaFields??{})),c=c??"mock-conversation"},sendMessage:async t=>{const s=`mock-message-${r++}`;return c=c??"mock-conversation",l.push({id:s,role:"user",type:"text",body:t,createdAt:Math.floor(Date.now()/1e3),origin:"programmatic"}),{id:s}},handleNotification:async()=>{o=!0},requestNotifications:async()=>"granted",createProactive:async()=>{},triggerCampaign:async()=>{},evaluateCampaignConditions:async()=>{},closeCampaign:async()=>{},triggerAnswer:async()=>{},triggerProactive:async()=>{},triggerGreeting:async()=>{},destroy:async()=>{d.clear(),y.clear(),o=!1}},A=Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0)),M={...m,...A};return{...Object.fromEntries(Object.entries(M).map(([t,s])=>[t,(...i)=>(e.push({method:t,args:i}),s(...i))])),calls:e,$emit:h}}exports.createMockAdaMessaging=S;
2
2
 
3
3
  //# sourceMappingURL=testing.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.cjs","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/testing.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","import type {\n\tAdaSdkEventCallback,\n\tMetaFieldValue,\n\tPublicMessage,\n} from \"../client/client-types\";\nimport type { AdaMessagingInterface } from \"./loader\";\n\n/** One recorded method invocation on a {@link MockAdaMessaging}. */\nexport interface RecordedAdaMessagingCall {\n\tmethod: string;\n\targs: unknown[];\n}\n\n/**\n * The mock returned by {@link createMockAdaMessaging}: the full\n * {@link AdaMessagingInterface} plus test hooks for inspecting calls and\n * simulating SDK events.\n */\nexport interface MockAdaMessaging extends AdaMessagingInterface {\n\t/** Every method invocation, in call order. */\n\tcalls: RecordedAdaMessagingCall[];\n\t/**\n\t * Deliver an event to `subscribeEvent` and `subscribeAll` callbacks, as if\n\t * the SDK emitted it (e.g. `$emit(\"ada:ready\", { isRolledOut: true })`).\n\t * Routing matches the real SDK: keyed subscriptions match by prefix\n\t * (`\"ada:campaigns\"` catches `\"ada:campaigns:shown\"`), except the\n\t * transcript events `ada:message:sent`/`ada:message:received`, which reach\n\t * exact-key subscribers only and never `subscribeAll`.\n\t */\n\t$emit: (key: string, data?: unknown) => void;\n}\n\ninterface KeyedSubscription {\n\tkey: string;\n\tcallback: AdaSdkEventCallback;\n}\n\n// Mirrors EXACT_MATCH_EVENT_KEYS in client/client-host-runtime.ts: transcript\n// events reach exact-key subscribers only, never prefix or subscribeAll\n// subscribers. Duplicated (not imported) so the published testing entry stays\n// free of runtime modules; a drift test pins the mock against the real matcher.\nconst EXACT_MATCH_EVENT_KEYS = new Set([\n\t\"ada:message:sent\",\n\t\"ada:message:received\",\n]);\n\nfunction keyedSubscriptionMatches(\n\tsubscriptionKey: string,\n\teventKey: string,\n): boolean {\n\tif (EXACT_MATCH_EVENT_KEYS.has(eventKey)) {\n\t\treturn subscriptionKey === eventKey;\n\t}\n\t// Raw prefix match, same as the real SDK: \"ada:campaigns\" also catches\n\t// \"ada:campaigns:shown\" and underscore-suffixed keys.\n\treturn subscriptionKey === eventKey || eventKey.startsWith(subscriptionKey);\n}\n\nfunction toMetaFieldRecord(\n\tfields: Record<string, unknown>,\n): Record<string, MetaFieldValue> {\n\tconst record: Record<string, MetaFieldValue> = {};\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tif (\n\t\t\ttypeof value === \"string\" ||\n\t\t\ttypeof value === \"number\" ||\n\t\t\ttypeof value === \"boolean\" ||\n\t\t\tvalue === null\n\t\t) {\n\t\t\trecord[key] = value;\n\t\t}\n\t}\n\treturn record;\n}\n\n/**\n * Create an in-memory messaging-interface stand-in for unit-testing an\n * integration without loading the SDK from the CDN.\n *\n * Every method resolves, records itself in `calls`, and keeps just enough\n * state to behave like the real interface: `sendMessage` appends a\n * programmatic user message that `getMessages` returns, `open`/`close`/\n * `toggle` drive `isOpen` and `getInfo`, `setMetaFields` feeds\n * `getMetaFields` (sensitive fields are never returned, matching the real\n * SDK), and `$emit` fans out to `subscribeEvent`/`subscribeAll` callbacks.\n *\n * Pass `overrides` to replace any method (e.g. with `vi.fn()`); overridden\n * methods are still recorded in `calls`.\n */\nexport function createMockAdaMessaging(\n\toverrides: Partial<AdaMessagingInterface> = {},\n): MockAdaMessaging {\n\tconst calls: RecordedAdaMessagingCall[] = [];\n\tlet nextSubscriptionId = 1;\n\tlet nextMessageId = 1;\n\tlet chatOpen = false;\n\tlet conversationId: string | null = null;\n\tconst metaFields: Record<string, MetaFieldValue> = {};\n\tconst messages: PublicMessage[] = [];\n\tconst keyedSubscriptions = new Map<number, KeyedSubscription>();\n\tconst wildcardSubscriptions = new Map<\n\t\tnumber,\n\t\t(key: string, data: unknown) => void\n\t>();\n\n\tconst emit = (key: string, data?: unknown): void => {\n\t\tfor (const subscription of keyedSubscriptions.values()) {\n\t\t\tif (keyedSubscriptionMatches(subscription.key, key)) {\n\t\t\t\tsubscription.callback(data, { eventKey: key });\n\t\t\t}\n\t\t}\n\t\tif (EXACT_MATCH_EVENT_KEYS.has(key)) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const callback of wildcardSubscriptions.values()) {\n\t\t\tcallback(key, data);\n\t\t}\n\t};\n\n\tconst clearTranscript = (): void => {\n\t\tmessages.length = 0;\n\t\tconversationId = null;\n\t};\n\n\tconst base: AdaMessagingInterface = {\n\t\tstart: async () => undefined,\n\t\tstop: async () => undefined,\n\t\ttoggle: async () => {\n\t\t\tchatOpen = !chatOpen;\n\t\t},\n\t\tdeleteHistory: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\treset: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\tsetMetaFields: async (fields) => {\n\t\t\tObject.assign(metaFields, toMetaFieldRecord(fields));\n\t\t},\n\t\t// Sensitive fields are accepted but never readable back, matching the\n\t\t// real SDK's getMetaFields contract.\n\t\tsetSensitiveMetaFields: async () => undefined,\n\t\tsetTestModeBanner: async () => undefined,\n\t\tgetInfo: async () => ({\n\t\t\tisChatOpen: chatOpen,\n\t\t\tisDrawerOpen: chatOpen,\n\t\t\thasActiveChatter: messages.length > 0,\n\t\t\thasClosedChat: false,\n\t\t}),\n\t\tgetMetaFields: async () => ({ ...metaFields }),\n\t\tisOpen: async () => chatOpen,\n\t\tgetConversation: async () => ({\n\t\t\tid: conversationId,\n\t\t\thandoff: { inLiveChat: false },\n\t\t}),\n\t\tgetMessages: async () => [...messages],\n\t\tsetComposerText: async () => undefined,\n\t\tsetDelegate: () => undefined,\n\t\ttrackEvent: async () => undefined,\n\t\tsubscribeEvent: async (key, callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\tkeyedSubscriptions.set(id, { key, callback });\n\t\t\treturn id;\n\t\t},\n\t\tunsubscribeEvent: async (id) => {\n\t\t\tkeyedSubscriptions.delete(id);\n\t\t\twildcardSubscriptions.delete(id);\n\t\t},\n\t\tsubscribeAll: async (callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\twildcardSubscriptions.set(id, callback);\n\t\t\treturn id;\n\t\t},\n\t\topen: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\tclose: async () => {\n\t\t\tchatOpen = false;\n\t\t},\n\t\tsetLanguage: async () => undefined,\n\t\tsetTheme: async () => undefined,\n\t\tsetDeviceToken: async () => undefined,\n\t\t// Optional on AdaEmbedInterface (internal mobile-webview plumbing), but\n\t\t// Ada's own maintained test double still implements the full surface — the\n\t\t// types-drift guard requires the shipped mock to cover every interface\n\t\t// member so a customer's double never lags it.\n\t\tacknowledgeSessionMirrorClear: async () => undefined,\n\t\tdeliverSessionMirrorSeed: async () => undefined,\n\t\tsendMessage: async (body) => {\n\t\t\tconst id = `mock-message-${nextMessageId++}`;\n\t\t\tconversationId = conversationId ?? \"mock-conversation\";\n\t\t\tmessages.push({\n\t\t\t\tid,\n\t\t\t\trole: \"user\",\n\t\t\t\ttype: \"text\",\n\t\t\t\tbody,\n\t\t\t\tcreatedAt: Math.floor(Date.now() / 1000),\n\t\t\t\torigin: \"programmatic\",\n\t\t\t});\n\t\t\treturn { id };\n\t\t},\n\t\thandleNotification: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\trequestNotifications: async () => \"granted\",\n\t\tcreateProactive: async () => undefined,\n\t\ttriggerCampaign: async () => undefined,\n\t\tevaluateCampaignConditions: async () => undefined,\n\t\tcloseCampaign: async () => undefined,\n\t\ttriggerAnswer: async () => undefined,\n\t\ttriggerProactive: async () => undefined,\n\t\ttriggerGreeting: async () => undefined,\n\t\tdestroy: async () => {\n\t\t\tkeyedSubscriptions.clear();\n\t\t\twildcardSubscriptions.clear();\n\t\t\tchatOpen = false;\n\t\t},\n\t};\n\n\tconst definedOverrides = Object.fromEntries(\n\t\tObject.entries(overrides).filter(([, value]) => value !== undefined),\n\t);\n\tconst implementation = { ...base, ...definedOverrides };\n\tconst recorded = Object.fromEntries(\n\t\tObject.entries(implementation).map(([method, fn]) => [\n\t\t\tmethod,\n\t\t\t(...args: unknown[]) => {\n\t\t\t\tcalls.push({ method, args });\n\t\t\t\treturn (fn as (...callArgs: unknown[]) => unknown)(...args);\n\t\t\t},\n\t\t]),\n\t) as unknown as AdaMessagingInterface;\n\n\treturn { ...recorded, calls, $emit: emit };\n}\n"],"mappings":"mEAWA,IAAM,EAAuB,OAAO,UAAU,eAE9C,SAAS,EACR,EACA,EACA,EACO,CACP,OAAO,eAAe,EAAQ,EAAM,CACnC,MAAA,EACA,aAAc,GACd,SAAU,GACV,EAGG,OAAO,QACX,EAAY,OAAQ,SAAA,CAAW,EAAiB,IAAiB,CAChE,GAAI,GAAU,KACb,MAAM,IAAI,UACT,mEAAA,EAGF,OAAO,EAAqB,KAAK,OAAO,CAAA,EAAS,CAAA,IAInD,SAAS,EAER,EACgB,CAChB,MAAM,EAAS,KAAK,MAAM,OAAO,KAAK,MAAA,CAAO,GAAK,EAClD,IAAI,EAAgB,KAAK,MAAM,OAAO,CAAA,CAAM,GAAK,EACjD,OAAI,EAAgB,IACnB,GAAiB,GAEX,EAAgB,GAAK,GAAiB,EAC1C,OACA,KAAK,CAAA,EAGT,SAAS,EAAuB,EAAoC,CACnE,MAAM,EAAQ,OAAO,IAAA,EACf,EAAS,EAAM,OACrB,IAAI,EAAgB,KAAK,MAAM,OAAO,CAAA,CAAM,GAAK,EACjD,OAAI,EAAgB,IACnB,GAAiB,GAEX,EAAgB,GAAK,GAAiB,EAC1C,OACA,EAAM,OAAO,CAAA,EAGjB,IAAM,EAAyB,CAC9B,WAAW,UACX,WAAW,WACX,WAAW,kBACX,WAAW,WACX,WAAW,YACX,WAAW,WACX,WAAW,YACX,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A4B,SAAA,GAC5B,cAAe,SAAA,GACf,cAAe,SAAA,GACf,iBAAkB,SAAA,GAClB,gBAAiB,SAAA,GACjB,QAAS,SAAY,CACpB,EAAmB,MAAA,EACnB,EAAsB,MAAA,EACtB,EAAW,KAIP,EAAmB,OAAO,YAC/B,OAAO,QAAQ,CAAA,EAAW,OAAA,CAAQ,CAAA,CAAG,CAAA,IAAW,IAAU,MAAA,CAAU,EAE/D,EAAiB,CAAE,GAAG,EAAM,GAAG,GAWrC,MAAO,CAAE,GAVQ,OAAO,YACvB,OAAO,QAAQ,CAAA,EAAgB,IAAA,CAAK,CAAC,EAAQ,CAAA,IAAQ,CACpD,EAAA,IACI,KACH,EAAM,KAAK,CAAE,OAAA,EAAQ,KAAA,EAAM,EACnB,EAA2C,GAAG,CAAA,GAEvD,CAAC,EAGmB,MAAA,EAAO,MAAO"}
1
+ {"version":3,"file":"testing.cjs","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/testing.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","import type {\n\tAdaSdkEventCallback,\n\tMetaFieldValue,\n\tPublicMessage,\n} from \"../client/client-types\";\nimport type { AdaMessagingInterface } from \"./loader\";\n\n/** One recorded method invocation on a {@link MockAdaMessaging}. */\nexport interface RecordedAdaMessagingCall {\n\tmethod: string;\n\targs: unknown[];\n}\n\n/**\n * The mock returned by {@link createMockAdaMessaging}: the full\n * {@link AdaMessagingInterface} plus test hooks for inspecting calls and\n * simulating SDK events.\n */\nexport interface MockAdaMessaging extends AdaMessagingInterface {\n\t/** Every method invocation, in call order. */\n\tcalls: RecordedAdaMessagingCall[];\n\t/**\n\t * Deliver an event to `subscribeEvent` and `subscribeAll` callbacks, as if\n\t * the SDK emitted it (e.g. `$emit(\"ada:ready\", { isRolledOut: true })`).\n\t * Routing matches the real SDK: keyed subscriptions match by prefix\n\t * (`\"ada:campaigns\"` catches `\"ada:campaigns:shown\"`), except the\n\t * transcript events `ada:message:sent`/`ada:message:received`, which reach\n\t * exact-key subscribers only and never `subscribeAll`.\n\t */\n\t$emit: (key: string, data?: unknown) => void;\n}\n\ninterface KeyedSubscription {\n\tkey: string;\n\tcallback: AdaSdkEventCallback;\n}\n\n// Mirrors EXACT_MATCH_EVENT_KEYS in client/client-host-runtime.ts: transcript\n// events reach exact-key subscribers only, never prefix or subscribeAll\n// subscribers. Duplicated (not imported) so the published testing entry stays\n// free of runtime modules; a drift test pins the mock against the real matcher.\nconst EXACT_MATCH_EVENT_KEYS = new Set([\n\t\"ada:message:sent\",\n\t\"ada:message:received\",\n]);\n\nfunction keyedSubscriptionMatches(\n\tsubscriptionKey: string,\n\teventKey: string,\n): boolean {\n\tif (EXACT_MATCH_EVENT_KEYS.has(eventKey)) {\n\t\treturn subscriptionKey === eventKey;\n\t}\n\t// Raw prefix match, same as the real SDK: \"ada:campaigns\" also catches\n\t// \"ada:campaigns:shown\" and underscore-suffixed keys.\n\treturn subscriptionKey === eventKey || eventKey.startsWith(subscriptionKey);\n}\n\nfunction toMetaFieldRecord(\n\tfields: Record<string, unknown>,\n): Record<string, MetaFieldValue> {\n\tconst record: Record<string, MetaFieldValue> = {};\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tif (\n\t\t\ttypeof value === \"string\" ||\n\t\t\ttypeof value === \"number\" ||\n\t\t\ttypeof value === \"boolean\" ||\n\t\t\tvalue === null\n\t\t) {\n\t\t\trecord[key] = value;\n\t\t}\n\t}\n\treturn record;\n}\n\n/**\n * Create an in-memory messaging-interface stand-in for unit-testing an\n * integration without loading the SDK from the CDN.\n *\n * Every method resolves, records itself in `calls`, and keeps just enough\n * state to behave like the real interface: `sendMessage` appends a\n * programmatic user message that `getMessages` returns, `open`/`close`/\n * `toggle` drive `isOpen` and `getInfo`, `setMetaFields` feeds\n * `getMetaFields` (sensitive fields are never returned, matching the real\n * SDK), and `$emit` fans out to `subscribeEvent`/`subscribeAll` callbacks.\n *\n * Pass `overrides` to replace any method (e.g. with `vi.fn()`); overridden\n * methods are still recorded in `calls`.\n */\nexport function createMockAdaMessaging(\n\toverrides: Partial<AdaMessagingInterface> = {},\n): MockAdaMessaging {\n\tconst calls: RecordedAdaMessagingCall[] = [];\n\tlet nextSubscriptionId = 1;\n\tlet nextMessageId = 1;\n\tlet chatOpen = false;\n\tlet conversationId: string | null = null;\n\tconst metaFields: Record<string, MetaFieldValue> = {};\n\tconst messages: PublicMessage[] = [];\n\tconst keyedSubscriptions = new Map<number, KeyedSubscription>();\n\tconst wildcardSubscriptions = new Map<\n\t\tnumber,\n\t\t(key: string, data: unknown) => void\n\t>();\n\n\tconst emit = (key: string, data?: unknown): void => {\n\t\tfor (const subscription of keyedSubscriptions.values()) {\n\t\t\tif (keyedSubscriptionMatches(subscription.key, key)) {\n\t\t\t\tsubscription.callback(data, { eventKey: key });\n\t\t\t}\n\t\t}\n\t\tif (EXACT_MATCH_EVENT_KEYS.has(key)) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const callback of wildcardSubscriptions.values()) {\n\t\t\tcallback(key, data);\n\t\t}\n\t};\n\n\tconst clearTranscript = (): void => {\n\t\tmessages.length = 0;\n\t\tconversationId = null;\n\t};\n\n\tconst base: AdaMessagingInterface = {\n\t\tstart: async () => undefined,\n\t\tstop: async () => undefined,\n\t\ttoggle: async () => {\n\t\t\tchatOpen = !chatOpen;\n\t\t},\n\t\tdeleteHistory: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\treset: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\tsetMetaFields: async (fields) => {\n\t\t\tObject.assign(metaFields, toMetaFieldRecord(fields));\n\t\t},\n\t\t// Sensitive fields are accepted but never readable back, matching the\n\t\t// real SDK's getMetaFields contract.\n\t\tsetSensitiveMetaFields: async () => undefined,\n\t\tsetTestModeBanner: async () => undefined,\n\t\tgetInfo: async () => ({\n\t\t\tisChatOpen: chatOpen,\n\t\t\tisDrawerOpen: chatOpen,\n\t\t\thasActiveChatter: messages.length > 0,\n\t\t\thasClosedChat: false,\n\t\t}),\n\t\tgetMetaFields: async () => ({ ...metaFields }),\n\t\tisOpen: async () => chatOpen,\n\t\tgetConversation: async () => ({\n\t\t\tid: conversationId,\n\t\t\thandoff: { inLiveChat: false },\n\t\t}),\n\t\tgetMessages: async () => [...messages],\n\t\tsetComposerText: async () => undefined,\n\t\tselectQuickReply: async () => undefined,\n\t\tsetDelegate: () => undefined,\n\t\ttrackEvent: async () => undefined,\n\t\tsubscribeEvent: async (key, callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\tkeyedSubscriptions.set(id, { key, callback });\n\t\t\treturn id;\n\t\t},\n\t\tunsubscribeEvent: async (id) => {\n\t\t\tkeyedSubscriptions.delete(id);\n\t\t\twildcardSubscriptions.delete(id);\n\t\t},\n\t\tsubscribeAll: async (callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\twildcardSubscriptions.set(id, callback);\n\t\t\treturn id;\n\t\t},\n\t\topen: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\tclose: async () => {\n\t\t\tchatOpen = false;\n\t\t},\n\t\tsetLanguage: async () => undefined,\n\t\tsetTheme: async () => undefined,\n\t\tsetDeviceToken: async () => undefined,\n\t\t// Optional on AdaEmbedInterface (internal mobile-webview plumbing), but\n\t\t// Ada's own maintained test double still implements the full surface — the\n\t\t// types-drift guard requires the shipped mock to cover every interface\n\t\t// member so a customer's double never lags it.\n\t\tacknowledgeSessionMirrorClear: async () => undefined,\n\t\tdeliverSessionMirrorSeed: async () => undefined,\n\t\ttriggerPlaybook: async (_playbookId, options) => {\n\t\t\tchatOpen = true;\n\t\t\tObject.assign(metaFields, toMetaFieldRecord(options?.metaFields ?? {}));\n\t\t\tconversationId = conversationId ?? \"mock-conversation\";\n\t\t},\n\t\tsendMessage: async (body) => {\n\t\t\tconst id = `mock-message-${nextMessageId++}`;\n\t\t\tconversationId = conversationId ?? \"mock-conversation\";\n\t\t\tmessages.push({\n\t\t\t\tid,\n\t\t\t\trole: \"user\",\n\t\t\t\ttype: \"text\",\n\t\t\t\tbody,\n\t\t\t\tcreatedAt: Math.floor(Date.now() / 1000),\n\t\t\t\torigin: \"programmatic\",\n\t\t\t});\n\t\t\treturn { id };\n\t\t},\n\t\thandleNotification: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\trequestNotifications: async () => \"granted\",\n\t\tcreateProactive: async () => undefined,\n\t\ttriggerCampaign: async () => undefined,\n\t\tevaluateCampaignConditions: async () => undefined,\n\t\tcloseCampaign: async () => undefined,\n\t\ttriggerAnswer: async () => undefined,\n\t\ttriggerProactive: async () => undefined,\n\t\ttriggerGreeting: async () => undefined,\n\t\tdestroy: async () => {\n\t\t\tkeyedSubscriptions.clear();\n\t\t\twildcardSubscriptions.clear();\n\t\t\tchatOpen = false;\n\t\t},\n\t};\n\n\tconst definedOverrides = Object.fromEntries(\n\t\tObject.entries(overrides).filter(([, value]) => value !== undefined),\n\t);\n\tconst implementation = { ...base, ...definedOverrides };\n\tconst recorded = Object.fromEntries(\n\t\tObject.entries(implementation).map(([method, fn]) => [\n\t\t\tmethod,\n\t\t\t(...args: unknown[]) => {\n\t\t\t\tcalls.push({ method, args });\n\t\t\t\treturn (fn as (...callArgs: unknown[]) => unknown)(...args);\n\t\t\t},\n\t\t]),\n\t) as unknown as AdaMessagingInterface;\n\n\treturn { ...recorded, calls, $emit: emit };\n}\n"],"mappings":"mEAWA,IAAM,EAAuB,OAAO,UA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,GAAG,EAAM,GAAG,GAWrC,MAAO,CAAE,GAVQ,OAAO,YACvB,OAAO,QAAQ,CAAA,EAAgB,IAAA,CAAK,CAAC,EAAQ,CAAA,IAAQ,CACpD,EAAA,IACI,KACH,EAAM,KAAK,CAAE,OAAA,EAAQ,KAAA,EAAM,EACnB,EAA2C,GAAG,CAAA,GAEvD,CAAC,EAGmB,MAAA,EAAO,MAAO"}
@@ -10,7 +10,7 @@ Object.hasOwn || g(Object, "hasOwn", (n, e) => {
10
10
  if (n == null) throw new TypeError("ada browser-polyfills: Cannot convert undefined or null to object");
11
11
  return T.call(Object(n), e);
12
12
  });
13
- function p(n) {
13
+ function v(n) {
14
14
  const e = Math.trunc(Number(this.length)) || 0;
15
15
  let a = Math.trunc(Number(n)) || 0;
16
16
  return a < 0 && (a += e), a < 0 || a >= e ? void 0 : this[a];
@@ -20,7 +20,7 @@ function M(n) {
20
20
  let r = Math.trunc(Number(n)) || 0;
21
21
  return r < 0 && (r += a), r < 0 || r >= a ? void 0 : e.charAt(r);
22
22
  }
23
- var O = [
23
+ var C = [
24
24
  globalThis.Int8Array,
25
25
  globalThis.Uint8Array,
26
26
  globalThis.Uint8ClampedArray,
@@ -33,59 +33,59 @@ var O = [
33
33
  globalThis.BigInt64Array,
34
34
  globalThis.BigUint64Array
35
35
  ].filter(Boolean);
36
- Array.prototype.at || g(Array.prototype, "at", p);
36
+ Array.prototype.at || g(Array.prototype, "at", v);
37
37
  String.prototype.at || g(String.prototype, "at", M);
38
- for (const n of O) {
38
+ for (const n of C) {
39
39
  const e = n.prototype;
40
- e.at || g(e, "at", p);
40
+ e.at || g(e, "at", v);
41
41
  }
42
- var v = /* @__PURE__ */ new Set(["ada:message:sent", "ada:message:received"]);
43
- function C(n, e) {
44
- return v.has(e) ? n === e : n === e || e.startsWith(n);
42
+ var b = /* @__PURE__ */ new Set(["ada:message:sent", "ada:message:received"]);
43
+ function w(n, e) {
44
+ return b.has(e) ? n === e : n === e || e.startsWith(n);
45
45
  }
46
- function w(n) {
46
+ function f(n) {
47
47
  const e = {};
48
48
  for (const [a, r] of Object.entries(n)) (typeof r == "string" || typeof r == "number" || typeof r == "boolean" || r === null) && (e[a] = r);
49
49
  return e;
50
50
  }
51
- function S(n = {}) {
51
+ function j(n = {}) {
52
52
  const e = [];
53
- let a = 1, r = 1, i = !1, c = null;
54
- const u = {}, l = [], d = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), h = (t, s) => {
55
- for (const o of d.values()) C(o.key, t) && o.callback(s, { eventKey: t });
56
- if (!v.has(t))
57
- for (const o of y.values()) o(t, s);
58
- }, f = () => {
53
+ let a = 1, r = 1, o = !1, c = null;
54
+ const u = {}, l = [], y = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), h = (t, s) => {
55
+ for (const i of y.values()) w(i.key, t) && i.callback(s, { eventKey: t });
56
+ if (!b.has(t))
57
+ for (const i of d.values()) i(t, s);
58
+ }, p = () => {
59
59
  l.length = 0, c = null;
60
- }, b = {
60
+ }, m = {
61
61
  start: async () => {
62
62
  },
63
63
  stop: async () => {
64
64
  },
65
65
  toggle: async () => {
66
- i = !i;
66
+ o = !o;
67
67
  },
68
68
  deleteHistory: async () => {
69
- f();
69
+ p();
70
70
  },
71
71
  reset: async () => {
72
- f();
72
+ p();
73
73
  },
74
74
  setMetaFields: async (t) => {
75
- Object.assign(u, w(t));
75
+ Object.assign(u, f(t));
76
76
  },
77
77
  setSensitiveMetaFields: async () => {
78
78
  },
79
79
  setTestModeBanner: async () => {
80
80
  },
81
81
  getInfo: async () => ({
82
- isChatOpen: i,
83
- isDrawerOpen: i,
82
+ isChatOpen: o,
83
+ isDrawerOpen: o,
84
84
  hasActiveChatter: l.length > 0,
85
85
  hasClosedChat: !1
86
86
  }),
87
87
  getMetaFields: async () => ({ ...u }),
88
- isOpen: async () => i,
88
+ isOpen: async () => o,
89
89
  getConversation: async () => ({
90
90
  id: c,
91
91
  handoff: { inLiveChat: !1 }
@@ -93,29 +93,31 @@ function S(n = {}) {
93
93
  getMessages: async () => [...l],
94
94
  setComposerText: async () => {
95
95
  },
96
+ selectQuickReply: async () => {
97
+ },
96
98
  setDelegate: () => {
97
99
  },
98
100
  trackEvent: async () => {
99
101
  },
100
102
  subscribeEvent: async (t, s) => {
101
- const o = a++;
102
- return d.set(o, {
103
+ const i = a++;
104
+ return y.set(i, {
103
105
  key: t,
104
106
  callback: s
105
- }), o;
107
+ }), i;
106
108
  },
107
109
  unsubscribeEvent: async (t) => {
108
- d.delete(t), y.delete(t);
110
+ y.delete(t), d.delete(t);
109
111
  },
110
112
  subscribeAll: async (t) => {
111
113
  const s = a++;
112
- return y.set(s, t), s;
114
+ return d.set(s, t), s;
113
115
  },
114
116
  open: async () => {
115
- i = !0;
117
+ o = !0;
116
118
  },
117
119
  close: async () => {
118
- i = !1;
120
+ o = !1;
119
121
  },
120
122
  setLanguage: async () => {
121
123
  },
@@ -127,6 +129,9 @@ function S(n = {}) {
127
129
  },
128
130
  deliverSessionMirrorSeed: async () => {
129
131
  },
132
+ triggerPlaybook: async (t, s) => {
133
+ o = !0, Object.assign(u, f(s?.metaFields ?? {})), c = c ?? "mock-conversation";
134
+ },
130
135
  sendMessage: async (t) => {
131
136
  const s = `mock-message-${r++}`;
132
137
  return c = c ?? "mock-conversation", l.push({
@@ -139,7 +144,7 @@ function S(n = {}) {
139
144
  }), { id: s };
140
145
  },
141
146
  handleNotification: async () => {
142
- i = !0;
147
+ o = !0;
143
148
  },
144
149
  requestNotifications: async () => "granted",
145
150
  createProactive: async () => {
@@ -157,23 +162,23 @@ function S(n = {}) {
157
162
  triggerGreeting: async () => {
158
163
  },
159
164
  destroy: async () => {
160
- d.clear(), y.clear(), i = !1;
165
+ y.clear(), d.clear(), o = !1;
161
166
  }
162
- }, m = Object.fromEntries(Object.entries(n).filter(([, t]) => t !== void 0)), A = {
163
- ...b,
164
- ...m
167
+ }, A = Object.fromEntries(Object.entries(n).filter(([, t]) => t !== void 0)), O = {
168
+ ...m,
169
+ ...A
165
170
  };
166
171
  return {
167
- ...Object.fromEntries(Object.entries(A).map(([t, s]) => [t, (...o) => (e.push({
172
+ ...Object.fromEntries(Object.entries(O).map(([t, s]) => [t, (...i) => (e.push({
168
173
  method: t,
169
- args: o
170
- }), s(...o))])),
174
+ args: i
175
+ }), s(...i))])),
171
176
  calls: e,
172
177
  $emit: h
173
178
  };
174
179
  }
175
180
  export {
176
- S as createMockAdaMessaging
181
+ j as createMockAdaMessaging
177
182
  };
178
183
 
179
184
  //# sourceMappingURL=testing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/testing.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","import type {\n\tAdaSdkEventCallback,\n\tMetaFieldValue,\n\tPublicMessage,\n} from \"../client/client-types\";\nimport type { AdaMessagingInterface } from \"./loader\";\n\n/** One recorded method invocation on a {@link MockAdaMessaging}. */\nexport interface RecordedAdaMessagingCall {\n\tmethod: string;\n\targs: unknown[];\n}\n\n/**\n * The mock returned by {@link createMockAdaMessaging}: the full\n * {@link AdaMessagingInterface} plus test hooks for inspecting calls and\n * simulating SDK events.\n */\nexport interface MockAdaMessaging extends AdaMessagingInterface {\n\t/** Every method invocation, in call order. */\n\tcalls: RecordedAdaMessagingCall[];\n\t/**\n\t * Deliver an event to `subscribeEvent` and `subscribeAll` callbacks, as if\n\t * the SDK emitted it (e.g. `$emit(\"ada:ready\", { isRolledOut: true })`).\n\t * Routing matches the real SDK: keyed subscriptions match by prefix\n\t * (`\"ada:campaigns\"` catches `\"ada:campaigns:shown\"`), except the\n\t * transcript events `ada:message:sent`/`ada:message:received`, which reach\n\t * exact-key subscribers only and never `subscribeAll`.\n\t */\n\t$emit: (key: string, data?: unknown) => void;\n}\n\ninterface KeyedSubscription {\n\tkey: string;\n\tcallback: AdaSdkEventCallback;\n}\n\n// Mirrors EXACT_MATCH_EVENT_KEYS in client/client-host-runtime.ts: transcript\n// events reach exact-key subscribers only, never prefix or subscribeAll\n// subscribers. Duplicated (not imported) so the published testing entry stays\n// free of runtime modules; a drift test pins the mock against the real matcher.\nconst EXACT_MATCH_EVENT_KEYS = new Set([\n\t\"ada:message:sent\",\n\t\"ada:message:received\",\n]);\n\nfunction keyedSubscriptionMatches(\n\tsubscriptionKey: string,\n\teventKey: string,\n): boolean {\n\tif (EXACT_MATCH_EVENT_KEYS.has(eventKey)) {\n\t\treturn subscriptionKey === eventKey;\n\t}\n\t// Raw prefix match, same as the real SDK: \"ada:campaigns\" also catches\n\t// \"ada:campaigns:shown\" and underscore-suffixed keys.\n\treturn subscriptionKey === eventKey || eventKey.startsWith(subscriptionKey);\n}\n\nfunction toMetaFieldRecord(\n\tfields: Record<string, unknown>,\n): Record<string, MetaFieldValue> {\n\tconst record: Record<string, MetaFieldValue> = {};\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tif (\n\t\t\ttypeof value === \"string\" ||\n\t\t\ttypeof value === \"number\" ||\n\t\t\ttypeof value === \"boolean\" ||\n\t\t\tvalue === null\n\t\t) {\n\t\t\trecord[key] = value;\n\t\t}\n\t}\n\treturn record;\n}\n\n/**\n * Create an in-memory messaging-interface stand-in for unit-testing an\n * integration without loading the SDK from the CDN.\n *\n * Every method resolves, records itself in `calls`, and keeps just enough\n * state to behave like the real interface: `sendMessage` appends a\n * programmatic user message that `getMessages` returns, `open`/`close`/\n * `toggle` drive `isOpen` and `getInfo`, `setMetaFields` feeds\n * `getMetaFields` (sensitive fields are never returned, matching the real\n * SDK), and `$emit` fans out to `subscribeEvent`/`subscribeAll` callbacks.\n *\n * Pass `overrides` to replace any method (e.g. with `vi.fn()`); overridden\n * methods are still recorded in `calls`.\n */\nexport function createMockAdaMessaging(\n\toverrides: Partial<AdaMessagingInterface> = {},\n): MockAdaMessaging {\n\tconst calls: RecordedAdaMessagingCall[] = [];\n\tlet nextSubscriptionId = 1;\n\tlet nextMessageId = 1;\n\tlet chatOpen = false;\n\tlet conversationId: string | null = null;\n\tconst metaFields: Record<string, MetaFieldValue> = {};\n\tconst messages: PublicMessage[] = [];\n\tconst keyedSubscriptions = new Map<number, KeyedSubscription>();\n\tconst wildcardSubscriptions = new Map<\n\t\tnumber,\n\t\t(key: string, data: unknown) => void\n\t>();\n\n\tconst emit = (key: string, data?: unknown): void => {\n\t\tfor (const subscription of keyedSubscriptions.values()) {\n\t\t\tif (keyedSubscriptionMatches(subscription.key, key)) {\n\t\t\t\tsubscription.callback(data, { eventKey: key });\n\t\t\t}\n\t\t}\n\t\tif (EXACT_MATCH_EVENT_KEYS.has(key)) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const callback of wildcardSubscriptions.values()) {\n\t\t\tcallback(key, data);\n\t\t}\n\t};\n\n\tconst clearTranscript = (): void => {\n\t\tmessages.length = 0;\n\t\tconversationId = null;\n\t};\n\n\tconst base: AdaMessagingInterface = {\n\t\tstart: async () => undefined,\n\t\tstop: async () => undefined,\n\t\ttoggle: async () => {\n\t\t\tchatOpen = !chatOpen;\n\t\t},\n\t\tdeleteHistory: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\treset: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\tsetMetaFields: async (fields) => {\n\t\t\tObject.assign(metaFields, toMetaFieldRecord(fields));\n\t\t},\n\t\t// Sensitive fields are accepted but never readable back, matching the\n\t\t// real SDK's getMetaFields contract.\n\t\tsetSensitiveMetaFields: async () => undefined,\n\t\tsetTestModeBanner: async () => undefined,\n\t\tgetInfo: async () => ({\n\t\t\tisChatOpen: chatOpen,\n\t\t\tisDrawerOpen: chatOpen,\n\t\t\thasActiveChatter: messages.length > 0,\n\t\t\thasClosedChat: false,\n\t\t}),\n\t\tgetMetaFields: async () => ({ ...metaFields }),\n\t\tisOpen: async () => chatOpen,\n\t\tgetConversation: async () => ({\n\t\t\tid: conversationId,\n\t\t\thandoff: { inLiveChat: false },\n\t\t}),\n\t\tgetMessages: async () => [...messages],\n\t\tsetComposerText: async () => undefined,\n\t\tsetDelegate: () => undefined,\n\t\ttrackEvent: async () => undefined,\n\t\tsubscribeEvent: async (key, callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\tkeyedSubscriptions.set(id, { key, callback });\n\t\t\treturn id;\n\t\t},\n\t\tunsubscribeEvent: async (id) => {\n\t\t\tkeyedSubscriptions.delete(id);\n\t\t\twildcardSubscriptions.delete(id);\n\t\t},\n\t\tsubscribeAll: async (callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\twildcardSubscriptions.set(id, callback);\n\t\t\treturn id;\n\t\t},\n\t\topen: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\tclose: async () => {\n\t\t\tchatOpen = false;\n\t\t},\n\t\tsetLanguage: async () => undefined,\n\t\tsetTheme: async () => undefined,\n\t\tsetDeviceToken: async () => undefined,\n\t\t// Optional on AdaEmbedInterface (internal mobile-webview plumbing), but\n\t\t// Ada's own maintained test double still implements the full surface — the\n\t\t// types-drift guard requires the shipped mock to cover every interface\n\t\t// member so a customer's double never lags it.\n\t\tacknowledgeSessionMirrorClear: async () => undefined,\n\t\tdeliverSessionMirrorSeed: async () => undefined,\n\t\tsendMessage: async (body) => {\n\t\t\tconst id = `mock-message-${nextMessageId++}`;\n\t\t\tconversationId = conversationId ?? \"mock-conversation\";\n\t\t\tmessages.push({\n\t\t\t\tid,\n\t\t\t\trole: \"user\",\n\t\t\t\ttype: \"text\",\n\t\t\t\tbody,\n\t\t\t\tcreatedAt: Math.floor(Date.now() / 1000),\n\t\t\t\torigin: \"programmatic\",\n\t\t\t});\n\t\t\treturn { id };\n\t\t},\n\t\thandleNotification: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\trequestNotifications: async () => \"granted\",\n\t\tcreateProactive: async () => undefined,\n\t\ttriggerCampaign: async () => undefined,\n\t\tevaluateCampaignConditions: async () => undefined,\n\t\tcloseCampaign: async () => undefined,\n\t\ttriggerAnswer: async () => undefined,\n\t\ttriggerProactive: async () => undefined,\n\t\ttriggerGreeting: async () => undefined,\n\t\tdestroy: async () => {\n\t\t\tkeyedSubscriptions.clear();\n\t\t\twildcardSubscriptions.clear();\n\t\t\tchatOpen = false;\n\t\t},\n\t};\n\n\tconst definedOverrides = Object.fromEntries(\n\t\tObject.entries(overrides).filter(([, value]) => value !== undefined),\n\t);\n\tconst implementation = { ...base, ...definedOverrides };\n\tconst recorded = Object.fromEntries(\n\t\tObject.entries(implementation).map(([method, fn]) => [\n\t\t\tmethod,\n\t\t\t(...args: unknown[]) => {\n\t\t\t\tcalls.push({ method, args });\n\t\t\t\treturn (fn as (...callArgs: unknown[]) => unknown)(...args);\n\t\t\t},\n\t\t]),\n\t) as unknown as AdaMessagingInterface;\n\n\treturn { ...recorded, calls, $emit: emit };\n}\n"],"mappings":"AAWA,IAAM,IAAuB,OAAO,UAAU;AAE9C,SAAS,EACR,GACA,GACA,GACO;AACP,SAAO,eAAe,GAAQ,GAAM;AAAA,IACnC,OAAA;AAAA,IACA,cAAc;AAAA,IACd,UAAU;AAAA,GACV;;AAGG,OAAO,UACX,EAAY,QAAQ,UAAA,CAAW,GAAiB,MAAiB;AAChE,MAAI,KAAU,KACb,OAAM,IAAI,UACT,mEAAA;AAGF,SAAO,EAAqB,KAAK,OAAO,CAAA,GAAS,CAAA;;AAInD,SAAS,EAER,GACgB;AAChB,QAAM,IAAS,KAAK,MAAM,OAAO,KAAK,MAAA,CAAO,KAA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AAAA;KAIP,IAAmB,OAAO,YAC/B,OAAO,QAAQ,CAAA,EAAW,OAAA,CAAQ,CAAA,EAAG,CAAA,MAAW,MAAU,MAAA,CAAU,GAE/D,IAAiB;AAAA,IAAE,GAAG;AAAA,IAAM,GAAG;AAAA;AAWrC,SAAO;AAAA,IAAE,GAVQ,OAAO,YACvB,OAAO,QAAQ,CAAA,EAAgB,IAAA,CAAK,CAAC,GAAQ,CAAA,MAAQ,CACpD,GAAA,IACI,OACH,EAAM,KAAK;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAA;AAAA,KAAM,GACnB,EAA2C,GAAG,CAAA,GAEvD,CAAC;AAAA,IAGmB,OAAA;AAAA,IAAO,OAAO;AAAA"}
1
+ {"version":3,"file":"testing.js","names":[],"sources":["../../../../shared/utils/src/browser-polyfills.ts","../../src/npm/testing.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","import type {\n\tAdaSdkEventCallback,\n\tMetaFieldValue,\n\tPublicMessage,\n} from \"../client/client-types\";\nimport type { AdaMessagingInterface } from \"./loader\";\n\n/** One recorded method invocation on a {@link MockAdaMessaging}. */\nexport interface RecordedAdaMessagingCall {\n\tmethod: string;\n\targs: unknown[];\n}\n\n/**\n * The mock returned by {@link createMockAdaMessaging}: the full\n * {@link AdaMessagingInterface} plus test hooks for inspecting calls and\n * simulating SDK events.\n */\nexport interface MockAdaMessaging extends AdaMessagingInterface {\n\t/** Every method invocation, in call order. */\n\tcalls: RecordedAdaMessagingCall[];\n\t/**\n\t * Deliver an event to `subscribeEvent` and `subscribeAll` callbacks, as if\n\t * the SDK emitted it (e.g. `$emit(\"ada:ready\", { isRolledOut: true })`).\n\t * Routing matches the real SDK: keyed subscriptions match by prefix\n\t * (`\"ada:campaigns\"` catches `\"ada:campaigns:shown\"`), except the\n\t * transcript events `ada:message:sent`/`ada:message:received`, which reach\n\t * exact-key subscribers only and never `subscribeAll`.\n\t */\n\t$emit: (key: string, data?: unknown) => void;\n}\n\ninterface KeyedSubscription {\n\tkey: string;\n\tcallback: AdaSdkEventCallback;\n}\n\n// Mirrors EXACT_MATCH_EVENT_KEYS in client/client-host-runtime.ts: transcript\n// events reach exact-key subscribers only, never prefix or subscribeAll\n// subscribers. Duplicated (not imported) so the published testing entry stays\n// free of runtime modules; a drift test pins the mock against the real matcher.\nconst EXACT_MATCH_EVENT_KEYS = new Set([\n\t\"ada:message:sent\",\n\t\"ada:message:received\",\n]);\n\nfunction keyedSubscriptionMatches(\n\tsubscriptionKey: string,\n\teventKey: string,\n): boolean {\n\tif (EXACT_MATCH_EVENT_KEYS.has(eventKey)) {\n\t\treturn subscriptionKey === eventKey;\n\t}\n\t// Raw prefix match, same as the real SDK: \"ada:campaigns\" also catches\n\t// \"ada:campaigns:shown\" and underscore-suffixed keys.\n\treturn subscriptionKey === eventKey || eventKey.startsWith(subscriptionKey);\n}\n\nfunction toMetaFieldRecord(\n\tfields: Record<string, unknown>,\n): Record<string, MetaFieldValue> {\n\tconst record: Record<string, MetaFieldValue> = {};\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tif (\n\t\t\ttypeof value === \"string\" ||\n\t\t\ttypeof value === \"number\" ||\n\t\t\ttypeof value === \"boolean\" ||\n\t\t\tvalue === null\n\t\t) {\n\t\t\trecord[key] = value;\n\t\t}\n\t}\n\treturn record;\n}\n\n/**\n * Create an in-memory messaging-interface stand-in for unit-testing an\n * integration without loading the SDK from the CDN.\n *\n * Every method resolves, records itself in `calls`, and keeps just enough\n * state to behave like the real interface: `sendMessage` appends a\n * programmatic user message that `getMessages` returns, `open`/`close`/\n * `toggle` drive `isOpen` and `getInfo`, `setMetaFields` feeds\n * `getMetaFields` (sensitive fields are never returned, matching the real\n * SDK), and `$emit` fans out to `subscribeEvent`/`subscribeAll` callbacks.\n *\n * Pass `overrides` to replace any method (e.g. with `vi.fn()`); overridden\n * methods are still recorded in `calls`.\n */\nexport function createMockAdaMessaging(\n\toverrides: Partial<AdaMessagingInterface> = {},\n): MockAdaMessaging {\n\tconst calls: RecordedAdaMessagingCall[] = [];\n\tlet nextSubscriptionId = 1;\n\tlet nextMessageId = 1;\n\tlet chatOpen = false;\n\tlet conversationId: string | null = null;\n\tconst metaFields: Record<string, MetaFieldValue> = {};\n\tconst messages: PublicMessage[] = [];\n\tconst keyedSubscriptions = new Map<number, KeyedSubscription>();\n\tconst wildcardSubscriptions = new Map<\n\t\tnumber,\n\t\t(key: string, data: unknown) => void\n\t>();\n\n\tconst emit = (key: string, data?: unknown): void => {\n\t\tfor (const subscription of keyedSubscriptions.values()) {\n\t\t\tif (keyedSubscriptionMatches(subscription.key, key)) {\n\t\t\t\tsubscription.callback(data, { eventKey: key });\n\t\t\t}\n\t\t}\n\t\tif (EXACT_MATCH_EVENT_KEYS.has(key)) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const callback of wildcardSubscriptions.values()) {\n\t\t\tcallback(key, data);\n\t\t}\n\t};\n\n\tconst clearTranscript = (): void => {\n\t\tmessages.length = 0;\n\t\tconversationId = null;\n\t};\n\n\tconst base: AdaMessagingInterface = {\n\t\tstart: async () => undefined,\n\t\tstop: async () => undefined,\n\t\ttoggle: async () => {\n\t\t\tchatOpen = !chatOpen;\n\t\t},\n\t\tdeleteHistory: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\treset: async () => {\n\t\t\tclearTranscript();\n\t\t},\n\t\tsetMetaFields: async (fields) => {\n\t\t\tObject.assign(metaFields, toMetaFieldRecord(fields));\n\t\t},\n\t\t// Sensitive fields are accepted but never readable back, matching the\n\t\t// real SDK's getMetaFields contract.\n\t\tsetSensitiveMetaFields: async () => undefined,\n\t\tsetTestModeBanner: async () => undefined,\n\t\tgetInfo: async () => ({\n\t\t\tisChatOpen: chatOpen,\n\t\t\tisDrawerOpen: chatOpen,\n\t\t\thasActiveChatter: messages.length > 0,\n\t\t\thasClosedChat: false,\n\t\t}),\n\t\tgetMetaFields: async () => ({ ...metaFields }),\n\t\tisOpen: async () => chatOpen,\n\t\tgetConversation: async () => ({\n\t\t\tid: conversationId,\n\t\t\thandoff: { inLiveChat: false },\n\t\t}),\n\t\tgetMessages: async () => [...messages],\n\t\tsetComposerText: async () => undefined,\n\t\tselectQuickReply: async () => undefined,\n\t\tsetDelegate: () => undefined,\n\t\ttrackEvent: async () => undefined,\n\t\tsubscribeEvent: async (key, callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\tkeyedSubscriptions.set(id, { key, callback });\n\t\t\treturn id;\n\t\t},\n\t\tunsubscribeEvent: async (id) => {\n\t\t\tkeyedSubscriptions.delete(id);\n\t\t\twildcardSubscriptions.delete(id);\n\t\t},\n\t\tsubscribeAll: async (callback) => {\n\t\t\tconst id = nextSubscriptionId++;\n\t\t\twildcardSubscriptions.set(id, callback);\n\t\t\treturn id;\n\t\t},\n\t\topen: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\tclose: async () => {\n\t\t\tchatOpen = false;\n\t\t},\n\t\tsetLanguage: async () => undefined,\n\t\tsetTheme: async () => undefined,\n\t\tsetDeviceToken: async () => undefined,\n\t\t// Optional on AdaEmbedInterface (internal mobile-webview plumbing), but\n\t\t// Ada's own maintained test double still implements the full surface — the\n\t\t// types-drift guard requires the shipped mock to cover every interface\n\t\t// member so a customer's double never lags it.\n\t\tacknowledgeSessionMirrorClear: async () => undefined,\n\t\tdeliverSessionMirrorSeed: async () => undefined,\n\t\ttriggerPlaybook: async (_playbookId, options) => {\n\t\t\tchatOpen = true;\n\t\t\tObject.assign(metaFields, toMetaFieldRecord(options?.metaFields ?? {}));\n\t\t\tconversationId = conversationId ?? \"mock-conversation\";\n\t\t},\n\t\tsendMessage: async (body) => {\n\t\t\tconst id = `mock-message-${nextMessageId++}`;\n\t\t\tconversationId = conversationId ?? \"mock-conversation\";\n\t\t\tmessages.push({\n\t\t\t\tid,\n\t\t\t\trole: \"user\",\n\t\t\t\ttype: \"text\",\n\t\t\t\tbody,\n\t\t\t\tcreatedAt: Math.floor(Date.now() / 1000),\n\t\t\t\torigin: \"programmatic\",\n\t\t\t});\n\t\t\treturn { id };\n\t\t},\n\t\thandleNotification: async () => {\n\t\t\tchatOpen = true;\n\t\t},\n\t\trequestNotifications: async () => \"granted\",\n\t\tcreateProactive: async () => undefined,\n\t\ttriggerCampaign: async () => undefined,\n\t\tevaluateCampaignConditions: async () => undefined,\n\t\tcloseCampaign: async () => undefined,\n\t\ttriggerAnswer: async () => undefined,\n\t\ttriggerProactive: async () => undefined,\n\t\ttriggerGreeting: async () => undefined,\n\t\tdestroy: async () => {\n\t\t\tkeyedSubscriptions.clear();\n\t\t\twildcardSubscriptions.clear();\n\t\t\tchatOpen = false;\n\t\t},\n\t};\n\n\tconst definedOverrides = Object.fromEntries(\n\t\tObject.entries(overrides).filter(([, value]) => value !== undefined),\n\t);\n\tconst implementation = { ...base, ...definedOverrides };\n\tconst recorded = Object.fromEntries(\n\t\tObject.entries(implementation).map(([method, fn]) => [\n\t\t\tmethod,\n\t\t\t(...args: unknown[]) => {\n\t\t\t\tcalls.push({ method, args });\n\t\t\t\treturn (fn as (...callArgs: unknown[]) => unknown)(...args);\n\t\t\t},\n\t\t]),\n\t) as unknown as AdaMessagingInterface;\n\n\treturn { ...recorded, calls, $emit: emit };\n}\n"],"mappings":"AAWA,IAAM,IAAuB,OAAO,UAAU;AAE9C,SAAS,EACR,GACA,GACA,GACO;AACP,SAAO,eAAe,GAAQ,GAAM;AAAA,IACnC,OAAA;AAAA,IAC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,IAAQ,GAAA;AAAA,QACnC,QAAQ;AAAA,OACR,GACM,EAAE,IAAA,EAAA;AAAA;IAEV,oBAAoB,YAAY;AAC/B,MAAA,IAAW;AAAA;IAEZ,sBAAsB,YAAY;AAAA,IAClC,iBAAiB,YAAA;AAAA;AAAA,IACjB,iBAAiB,YAAA;AAAA;AAAA,IACjB,4BAA4B,YAAA;AAAA;AAAA,IAC5B,eAAe,YAAA;AAAA;AAAA,IACf,eAAe,YAAA;AAAA;AAAA,IACf,kBAAkB,YAAA;AAAA;AAAA,IAClB,iBAAiB,YAAA;AAAA;AAAA,IACjB,SAAS,YAAY;AACpB,MAAA,EAAmB,MAAA,GACnB,EAAsB,MAAA,GACtB,IAAW;AAAA;KAIP,IAAmB,OAAO,YAC/B,OAAO,QAAQ,CAAA,EAAW,OAAA,CAAQ,CAAA,EAAG,CAAA,MAAW,MAAU,MAAA,CAAU,GAE/D,IAAiB;AAAA,IAAE,GAAG;AAAA,IAAM,GAAG;AAAA;AAWrC,SAAO;AAAA,IAAE,GAVQ,OAAO,YACvB,OAAO,QAAQ,CAAA,EAAgB,IAAA,CAAK,CAAC,GAAQ,CAAA,MAAQ,CACpD,GAAA,IACI,OACH,EAAM,KAAK;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAA;AAAA,KAAM,GACnB,EAA2C,GAAG,CAAA,GAEvD,CAAC;AAAA,IAGmB,OAAA;AAAA,IAAO,OAAO;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-cx/messaging-sdk",
3
- "version": "1.6.9",
3
+ "version": "1.8.0",
4
4
  "description": "TypeScript types, test mocks, and a thin CDN loader for the Ada Messaging SDK. The runtime always resolves from Ada's CDN and is never bundled into this package.",
5
5
  "homepage": "https://docs.ada.cx",
6
6
  "keywords": [