@xapp/chat-widget 1.97.1 → 1.98.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.
package/dist/index.js CHANGED
@@ -1133,15 +1133,15 @@ PERFORMANCE OF THIS SOFTWARE.
1133
1133
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1134
1134
 
1135
1135
 
1136
- var __assign = function() {
1137
- __assign = Object.assign || function __assign(t) {
1136
+ var __assign$1 = function() {
1137
+ __assign$1 = Object.assign || function __assign(t) {
1138
1138
  for (var s, i = 1, n = arguments.length; i < n; i++) {
1139
1139
  s = arguments[i];
1140
1140
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1141
1141
  }
1142
1142
  return t;
1143
1143
  };
1144
- return __assign.apply(this, arguments);
1144
+ return __assign$1.apply(this, arguments);
1145
1145
  };
1146
1146
 
1147
1147
  function __rest(s, e) {
@@ -1718,7 +1718,7 @@ function useServerConfig(env, nonce) {
1718
1718
  */
1719
1719
  function foldChannelId(mcp, channelId) {
1720
1720
  var _a;
1721
- return mcp ? __assign(__assign({}, mcp), { channelId: (_a = mcp.channelId) !== null && _a !== void 0 ? _a : channelId }) : mcp;
1721
+ return mcp ? __assign$1(__assign$1({}, mcp), { channelId: (_a = mcp.channelId) !== null && _a !== void 0 ? _a : channelId }) : mcp;
1722
1722
  }
1723
1723
  function useConnectionInfo(env) {
1724
1724
  var nonce = reactRedux.useSelector(function (state) { return state.connection.nonce; });
@@ -2428,9 +2428,9 @@ function executeAction(text, meta) {
2428
2428
  return function (chatServer) { return function (dispatch, getState) {
2429
2429
  // add in attributes from meta
2430
2430
  var attributes = getState().attributes;
2431
- attributes = __assign(__assign({}, attributes), { currentUrl: window.location.href });
2431
+ attributes = __assign$1(__assign$1({}, attributes), { currentUrl: window.location.href });
2432
2432
  var _a = meta || {}, token = _a.token, rest = __rest(_a, ["token"]);
2433
- attributes = __assign(__assign({}, attributes), rest);
2433
+ attributes = __assign$1(__assign$1({}, attributes), rest);
2434
2434
  // Add user message to Redux BEFORE sending to server
2435
2435
  // to ensure it appears above the bot's streaming response
2436
2436
  var visitor = getState().visitor;
@@ -3087,6 +3087,17 @@ PERFORMANCE OF THIS SOFTWARE.
3087
3087
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
3088
3088
 
3089
3089
 
3090
+ var __assign = function() {
3091
+ __assign = Object.assign || function __assign(t) {
3092
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3093
+ s = arguments[i];
3094
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3095
+ }
3096
+ return t;
3097
+ };
3098
+ return __assign.apply(this, arguments);
3099
+ };
3100
+
3090
3101
  function __awaiter(thisArg, _arguments, P, generator) {
3091
3102
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3092
3103
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -3320,6 +3331,162 @@ function useSuggestionsFetch$1(options) {
3320
3331
  return response;
3321
3332
  }
3322
3333
 
3334
+ /**
3335
+ * Marketing attribution capture, shared by every widget surface.
3336
+ *
3337
+ * The chat widget historically sent only `currentUrl`, which meant attribution
3338
+ * survived only when the visitor opened the chat on the very page the ad landed
3339
+ * them on. Anyone who browsed first arrived unattributed. These helpers capture
3340
+ * the parameters on first sight and persist them, so a conversation started three
3341
+ * pages later still carries the click that paid for it.
3342
+ *
3343
+ * Only the parameters below are ever read or stored. The query string as a whole
3344
+ * is not, because it routinely carries session tokens and PII.
3345
+ */
3346
+ /** Standard UTM parameters. */
3347
+ var UTM_PARAMETERS = [
3348
+ "utm_source",
3349
+ "utm_medium",
3350
+ "utm_campaign",
3351
+ "utm_term",
3352
+ "utm_content"
3353
+ ];
3354
+ /**
3355
+ * Platform click ids.
3356
+ *
3357
+ * `gbraid` and `wbraid` are what Google substitutes for `gclid` when the click
3358
+ * cannot be tied to a cookie — iOS and consent-mode traffic. For home services,
3359
+ * where most paid traffic is mobile, omitting them loses attribution on the
3360
+ * majority of the spend.
3361
+ */
3362
+ var CLICK_ID_PARAMETERS = [
3363
+ "gclid",
3364
+ "gbraid",
3365
+ "wbraid",
3366
+ "msclkid",
3367
+ "fbclid"
3368
+ ];
3369
+ var ATTRIBUTION_PARAMETERS = __spreadArray(__spreadArray([], UTM_PARAMETERS, true), CLICK_ID_PARAMETERS);
3370
+ var STORAGE_KEY_PREFIX = "xa_tracking_";
3371
+ /** Matches the 30 day window the form widget already uses. */
3372
+ var DEFAULT_PERSISTENCE_DAYS = 30;
3373
+ var MAX_VALUE_LENGTH = 255;
3374
+ /**
3375
+ * Values land in a request body and, downstream, in a CRM. Cap the length and
3376
+ * reject anything carrying markup or control characters.
3377
+ */
3378
+ function isValidValue(value) {
3379
+ // eslint-disable-next-line no-control-regex
3380
+ return value.length <= MAX_VALUE_LENGTH && !/[<>"'\x00-\x1f]/.test(value);
3381
+ }
3382
+ /**
3383
+ * Reads the attribution parameters present on a URL. Never throws — a URL we
3384
+ * cannot parse simply contributes nothing.
3385
+ */
3386
+ function extractAttributionFromUrl(url) {
3387
+ var parsed;
3388
+ try {
3389
+ parsed = new URL(url);
3390
+ }
3391
+ catch (_a) {
3392
+ return {};
3393
+ }
3394
+ var attribution = {};
3395
+ ATTRIBUTION_PARAMETERS.forEach(function (parameter) {
3396
+ var value = parsed.searchParams.get(parameter);
3397
+ if (value && isValidValue(value)) {
3398
+ attribution[parameter] = value;
3399
+ }
3400
+ });
3401
+ return attribution;
3402
+ }
3403
+ /**
3404
+ * Persists attribution for later conversations. Existing values are overwritten,
3405
+ * so the most recent click wins, matching how the ad platforms attribute.
3406
+ */
3407
+ function storeAttribution(attribution, persistenceDays) {
3408
+ if (persistenceDays === void 0) { persistenceDays = DEFAULT_PERSISTENCE_DAYS; }
3409
+ var expires = Date.now() + persistenceDays * 24 * 60 * 60 * 1000;
3410
+ Object.entries(attribution).forEach(function (_a) {
3411
+ var key = _a[0], value = _a[1];
3412
+ if (!value) {
3413
+ return;
3414
+ }
3415
+ try {
3416
+ localStorage.setItem("".concat(STORAGE_KEY_PREFIX).concat(key), JSON.stringify({ value: value, expires: expires }));
3417
+ }
3418
+ catch (_b) {
3419
+ // Storage can be full or blocked by the browser. Attribution is best
3420
+ // effort — never let it break the conversation.
3421
+ }
3422
+ });
3423
+ }
3424
+ /** Reads back unexpired stored attribution, cleaning up anything unreadable. */
3425
+ function getStoredAttribution() {
3426
+ var attribution = {};
3427
+ ATTRIBUTION_PARAMETERS.forEach(function (parameter) {
3428
+ var key = "".concat(STORAGE_KEY_PREFIX).concat(parameter);
3429
+ var stored;
3430
+ try {
3431
+ stored = localStorage.getItem(key);
3432
+ }
3433
+ catch (_a) {
3434
+ return;
3435
+ }
3436
+ if (!stored) {
3437
+ return;
3438
+ }
3439
+ try {
3440
+ var parsed = JSON.parse(stored);
3441
+ if (parsed && parsed.expires > Date.now() && typeof parsed.value === "string") {
3442
+ attribution[parameter] = parsed.value;
3443
+ }
3444
+ else {
3445
+ localStorage.removeItem(key);
3446
+ }
3447
+ }
3448
+ catch (_b) {
3449
+ localStorage.removeItem(key);
3450
+ }
3451
+ });
3452
+ return attribution;
3453
+ }
3454
+ /**
3455
+ * The attribution to send with a request: whatever is stored, with anything on
3456
+ * the current URL layered on top, and the current URL's values persisted for
3457
+ * subsequent pages.
3458
+ */
3459
+ function getAttribution(url) {
3460
+ if (url === void 0) { url = window.location.href; }
3461
+ var fromUrl = extractAttributionFromUrl(url);
3462
+ if (Object.keys(fromUrl).length > 0) {
3463
+ storeAttribution(fromUrl);
3464
+ }
3465
+ return __assign(__assign({}, getStoredAttribution()), fromUrl);
3466
+ }
3467
+ /**
3468
+ * Strips the query string from a URL, leaving origin + pathname.
3469
+ *
3470
+ * Referrers and page URLs routinely carry session tokens, email addresses and other
3471
+ * PII in their query strings, and a referrer captured at session start is sent with
3472
+ * every subsequent message — so the raw value must never be stored. Attribution is
3473
+ * read separately, by allowlist, before this is applied.
3474
+ *
3475
+ * Returns undefined for an empty or unparseable URL rather than passing it through.
3476
+ */
3477
+ function stripQueryString(url) {
3478
+ if (!url) {
3479
+ return undefined;
3480
+ }
3481
+ try {
3482
+ var parsed = new URL(url);
3483
+ return parsed.origin + parsed.pathname;
3484
+ }
3485
+ catch (_a) {
3486
+ return undefined;
3487
+ }
3488
+ }
3489
+
3323
3490
  /**
3324
3491
  * Stop the host page scrolling behind an open overlay.
3325
3492
  *
@@ -3601,13 +3768,14 @@ function uuid() {
3601
3768
  });
3602
3769
  return newUuid;
3603
3770
  }
3604
-
3605
3771
  var IconButton_1 = IconButton;
3606
3772
  var RichInput_1 = RichInput;
3607
3773
  var SuggestionsList_1 = SuggestionsList;
3608
3774
  var findItemByIndex_1 = findItemByIndex;
3775
+ var getAttribution_1 = getAttribution;
3609
3776
  var getItemsLength_1 = getItemsLength;
3610
3777
  var parseSuggestionsResponse_1 = parseSuggestionsResponse;
3778
+ var stripQueryString_1 = stripQueryString;
3611
3779
  var useBodyScrollLock_1 = useBodyScrollLock;
3612
3780
  var useSuggestionsFetch_1 = useSuggestionsFetch$1;
3613
3781
  var useVisualViewportProperties_1 = useVisualViewportProperties;
@@ -4065,7 +4233,19 @@ function getLocalISOString(date) {
4065
4233
  * PRIVACY NOTE: Query strings are stripped from URLs by default as they
4066
4234
  * may contain sensitive data (tokens, PII). Only origin + pathname are sent.
4067
4235
  */
4236
+ /**
4237
+ * Reads attribution for the current page, or undefined when there is none or there is
4238
+ * no browser to read it from.
4239
+ */
4240
+ function collectAttribution() {
4241
+ if (typeof window === "undefined") {
4242
+ return undefined;
4243
+ }
4244
+ var attribution = getAttribution_1(window.location.href);
4245
+ return Object.keys(attribution).length > 0 ? attribution : undefined;
4246
+ }
4068
4247
  function getPageContext(override) {
4248
+ var _a;
4069
4249
  var localTime = getLocalISOString();
4070
4250
  // If override provided, merge with defaults (override wins)
4071
4251
  // Overrides are typically for testing and may include full URLs
@@ -4076,6 +4256,14 @@ function getPageContext(override) {
4076
4256
  path: override.path,
4077
4257
  title: override.title,
4078
4258
  referrer: override.referrer,
4259
+ // Never skip attribution just because the page context was overridden.
4260
+ // The public knob is WidgetEnv.mcp.pageContextOverride, typed
4261
+ // PageContextOverride -- url/path/title/referrer, with no attribution
4262
+ // field -- and an SPA integrator sets it on every virtual route change.
4263
+ // Taking override.attribution alone would therefore be undefined for every
4264
+ // real caller, silently disabling attribution on the MCP path for exactly
4265
+ // the browse-then-chat case this exists to capture.
4266
+ attribution: (_a = override.attribution) !== null && _a !== void 0 ? _a : collectAttribution(),
4079
4267
  localTime: localTime,
4080
4268
  };
4081
4269
  }
@@ -4084,23 +4272,18 @@ function getPageContext(override) {
4084
4272
  }
4085
4273
  // Strip query strings from URL for privacy (may contain tokens/PII)
4086
4274
  var urlWithoutQuery = window.location.origin + window.location.pathname;
4087
- // Strip query strings from referrer as well
4088
- var referrerWithoutQuery;
4089
- if (document.referrer) {
4090
- try {
4091
- var refUrl = new URL(document.referrer);
4092
- referrerWithoutQuery = refUrl.origin + refUrl.pathname;
4093
- }
4094
- catch (_a) {
4095
- // Invalid referrer URL, skip it
4096
- referrerWithoutQuery = undefined;
4097
- }
4098
- }
4275
+ // Strip query strings from referrer as well -- shared with StentorDirectChat so the
4276
+ // two chat paths cannot disagree about what is safe to send.
4277
+ var referrerWithoutQuery = stripQueryString_1(document.referrer);
4278
+ // Pull the attribution parameters out BEFORE the query string is discarded.
4279
+ // Only the known utm_* and click id keys are read; everything else in the
4280
+ // query string stays stripped, so the privacy posture above is unchanged.
4099
4281
  return {
4100
4282
  url: urlWithoutQuery,
4101
4283
  path: window.location.pathname,
4102
4284
  title: document.title || undefined,
4103
4285
  referrer: referrerWithoutQuery,
4286
+ attribution: collectAttribution(),
4104
4287
  localTime: localTime,
4105
4288
  };
4106
4289
  }
@@ -4232,7 +4415,7 @@ var MCPChat = /** @class */ (function () {
4232
4415
  */
4233
4416
  MCPChat.prototype.buildRequestPayload = function (additionalData) {
4234
4417
  if (additionalData === void 0) { additionalData = {}; }
4235
- return __assign(__assign({
4418
+ return __assign$1(__assign$1({
4236
4419
  // Identity - server generates these, we just send back what we have
4237
4420
  userId: this._userId || undefined, sessionId: this._sessionId || undefined,
4238
4421
  // Fingerprint for user identification (can be disabled for privacy)
@@ -4695,12 +4878,12 @@ var MCPChat = /** @class */ (function () {
4695
4878
  if (!user) {
4696
4879
  // Ensure bot nick has agent: prefix and mark as AI
4697
4880
  var defaultBot = bot || { nick: "agent:robot", displayName: "Assistant" };
4698
- return __assign(__assign({}, defaultBot), { nick: this.ensureAgentNick(defaultBot.nick), isAI: true });
4881
+ return __assign$1(__assign$1({}, defaultBot), { nick: this.ensureAgentNick(defaultBot.nick), isAI: true });
4699
4882
  }
4700
4883
  if (user.displayName && user.nick && user.avatarPath) {
4701
- return __assign(__assign({}, user), { nick: this.ensureAgentNick(user.nick), isAI: true });
4884
+ return __assign$1(__assign$1({}, user), { nick: this.ensureAgentNick(user.nick), isAI: true });
4702
4885
  }
4703
- return __assign(__assign({}, user), { nick: this.ensureAgentNick(user.nick || (bot === null || bot === void 0 ? void 0 : bot.nick)), displayName: user.displayName || (bot === null || bot === void 0 ? void 0 : bot.displayName) || "Assistant", avatarPath: user.avatarPath || (bot === null || bot === void 0 ? void 0 : bot.avatarPath), isAI: true });
4886
+ return __assign$1(__assign$1({}, user), { nick: this.ensureAgentNick(user.nick || (bot === null || bot === void 0 ? void 0 : bot.nick)), displayName: user.displayName || (bot === null || bot === void 0 ? void 0 : bot.displayName) || "Assistant", avatarPath: user.avatarPath || (bot === null || bot === void 0 ? void 0 : bot.avatarPath), isAI: true });
4704
4887
  };
4705
4888
  MCPChat.prototype.sendChatMsgRequest = function (serviceRequest, cb) {
4706
4889
  return __awaiter$1(this, void 0, void 0, function () {
@@ -4882,7 +5065,7 @@ var MCPChat = /** @class */ (function () {
4882
5065
  // WARNING: Do not log headers object - it contains sensitive auth tokens
4883
5066
  cjs.fetchEventSource(endpoint, {
4884
5067
  method: "POST",
4885
- headers: __assign({ "Content-Type": "application/json" }, ((_this.config.mode || "homeowner") === "business_owner" && _this.config.authToken
5068
+ headers: __assign$1({ "Content-Type": "application/json" }, ((_this.config.mode || "homeowner") === "business_owner" && _this.config.authToken
4886
5069
  ? { Authorization: "Bearer ".concat(_this.config.authToken) }
4887
5070
  : {})),
4888
5071
  body: JSON.stringify(body),
@@ -5183,7 +5366,7 @@ var MCPChat = /** @class */ (function () {
5183
5366
  MCPChat.prototype.sendTyping = function () { };
5184
5367
  MCPChat.prototype.setVisitorInfo = function (visitorInfo, sessionId, cb) {
5185
5368
  this.visitorInfo = visitorInfo;
5186
- this._attributes = __assign({}, this.visitorInfo.attributes);
5369
+ this._attributes = __assign$1({}, this.visitorInfo.attributes);
5187
5370
  // do not set currentUrl if localhost
5188
5371
  var href = new URL(window.location.href);
5189
5372
  if (href === null || href === void 0 ? void 0 : href.host.toLowerCase().startsWith("localhost")) {
@@ -5423,6 +5606,35 @@ var MCPChat = /** @class */ (function () {
5423
5606
  return MCPChat;
5424
5607
  }());
5425
5608
 
5609
+ /**
5610
+ * Builds the attribute set for one outgoing message.
5611
+ *
5612
+ * Returns a **fresh object every call**. That is the point of this function, not an
5613
+ * incidental detail: the chat server's `_attributes` is a single object that lives for
5614
+ * the whole conversation, so writing attribution into it directly means the first value
5615
+ * seen is the value sent forever. A visitor who navigates within an SPA to a page with a
5616
+ * different `gclid` would keep sending the original one, which contradicts the
5617
+ * most-recent-click-wins behaviour `attribution.ts` documents and the ad platforms
5618
+ * assume.
5619
+ *
5620
+ * Precedence: whatever the host page set explicitly wins, because that was deliberate.
5621
+ * Everything else comes from the current attribution read.
5622
+ *
5623
+ * @param hostAttributes attributes the host page set at session start
5624
+ * @param attribution the attribution resolved for this message
5625
+ */
5626
+ function mergeAttribution(hostAttributes, attribution) {
5627
+ var host = hostAttributes || {};
5628
+ var merged = __assign$1({}, attribution);
5629
+ for (var _i = 0, _a = Object.entries(host); _i < _a.length; _i++) {
5630
+ var _b = _a[_i], key = _b[0], value = _b[1];
5631
+ if (value !== undefined) {
5632
+ merged[key] = value;
5633
+ }
5634
+ }
5635
+ return merged;
5636
+ }
5637
+
5426
5638
  /**
5427
5639
  * Sends a POST to your STENTOR based server.
5428
5640
  *
@@ -5599,10 +5811,10 @@ function responseToMessage(botResponse, now) {
5599
5811
  user: undefined
5600
5812
  };
5601
5813
  if (text && !html) {
5602
- responseMessage.msg = __assign(__assign({}, responseMessage.msg), { text: text });
5814
+ responseMessage.msg = __assign$1(__assign$1({}, responseMessage.msg), { text: text });
5603
5815
  }
5604
5816
  if (html) {
5605
- responseMessage.msg = __assign(__assign({}, responseMessage.msg), { html: html });
5817
+ responseMessage.msg = __assign$1(__assign$1({}, responseMessage.msg), { html: html });
5606
5818
  }
5607
5819
  if ((_e = outputSpeech === null || outputSpeech === void 0 ? void 0 : outputSpeech.suggestions) === null || _e === void 0 ? void 0 : _e.length) {
5608
5820
  responseMessage.msg.options = outputSpeech.suggestions.map(function (suggestion) {
@@ -5698,7 +5910,7 @@ var StentorDirectChat = /** @class */ (function () {
5698
5910
  type: "chat",
5699
5911
  detail: {
5700
5912
  type: "chat.msg",
5701
- user: __assign(__assign({}, data.user), { nick: "agent:robot" }),
5913
+ user: __assign$1(__assign$1({}, data.user), { nick: "agent:robot" }),
5702
5914
  msg: data.msg,
5703
5915
  timestamp: +new Date(),
5704
5916
  },
@@ -5710,7 +5922,7 @@ var StentorDirectChat = /** @class */ (function () {
5710
5922
  type: "chat",
5711
5923
  detail: {
5712
5924
  type: "chat.memberjoin",
5713
- user: __assign(__assign({}, data.user), { nick: "agent:robot" }),
5925
+ user: __assign$1(__assign$1({}, data.user), { nick: "agent:robot" }),
5714
5926
  timestamp: +new Date(),
5715
5927
  },
5716
5928
  });
@@ -5825,7 +6037,7 @@ var StentorDirectChat = /** @class */ (function () {
5825
6037
  if (user.displayName && user.nick && user.avatarPath) {
5826
6038
  return user;
5827
6039
  }
5828
- return __assign(__assign({}, user), { nick: user.nick || bot.nick || "Bot", displayName: user.displayName || bot.displayName || "Bot", avatarPath: user.avatarPath || bot.avatarPath });
6040
+ return __assign$1(__assign$1({}, user), { nick: user.nick || bot.nick || "Bot", displayName: user.displayName || bot.displayName || "Bot", avatarPath: user.avatarPath || bot.avatarPath });
5829
6041
  };
5830
6042
  StentorDirectChat.prototype.sendChatMsgRequest = function (serviceRequest, cb) {
5831
6043
  return __awaiter$1(this, void 0, void 0, function () {
@@ -5837,7 +6049,7 @@ var StentorDirectChat = /** @class */ (function () {
5837
6049
  case 1:
5838
6050
  agentResponse = _b.sent();
5839
6051
  if (!((_a = agentResponse.user) === null || _a === void 0 ? void 0 : _a.displayName)) {
5840
- agentResponse = __assign(__assign({}, agentResponse), { user: this.getBot(agentResponse.user) });
6052
+ agentResponse = __assign$1(__assign$1({}, agentResponse), { user: this.getBot(agentResponse.user) });
5841
6053
  }
5842
6054
  this.sendNewMessage(agentResponse);
5843
6055
  cb();
@@ -5849,7 +6061,7 @@ var StentorDirectChat = /** @class */ (function () {
5849
6061
  StentorDirectChat.prototype.sendTyping = function () { };
5850
6062
  StentorDirectChat.prototype.setVisitorInfo = function (visitorInfo, sessionId, cb) {
5851
6063
  this.visitorInfo = visitorInfo;
5852
- this._attributes = __assign({}, this.visitorInfo.attributes);
6064
+ this._attributes = __assign$1({}, this.visitorInfo.attributes);
5853
6065
  // do not set currentUrl if localhost, localhost is not liked by some firewalls, like AWS WAF
5854
6066
  var href = new URL(window.location.href);
5855
6067
  if (href === null || href === void 0 ? void 0 : href.host.toLowerCase().startsWith("localhost")) {
@@ -5860,6 +6072,18 @@ var StentorDirectChat = /** @class */ (function () {
5860
6072
  // not localhost, set it
5861
6073
  this._attributes.currentUrl = window.location.href;
5862
6074
  }
6075
+ // The page the visitor arrived FROM, which is a separate attribution signal
6076
+ // from currentUrl — the page they arrived ON.
6077
+ //
6078
+ // Stored WITHOUT its query string. A referrer captured here lives in
6079
+ // _attributes for the whole conversation and is sent with every message, and
6080
+ // referrer query strings routinely carry session tokens and email addresses.
6081
+ // The attribution parameters are read separately, by allowlist, so nothing of
6082
+ // value is lost by dropping the rest.
6083
+ var referrer = stripQueryString_1(document.referrer);
6084
+ if (referrer) {
6085
+ this._attributes.referrer = referrer;
6086
+ }
5863
6087
  this._accessToken = this.visitorInfo.accessToken;
5864
6088
  // This is for the bot
5865
6089
  this.userJoined({
@@ -5891,7 +6115,7 @@ var StentorDirectChat = /** @class */ (function () {
5891
6115
  userId = this._userId;
5892
6116
  sessionId = this._sessionId;
5893
6117
  accessToken = this._accessToken;
5894
- attributes = this._attributes || {};
6118
+ attributes = mergeAttribution(this._attributes, getAttribution_1());
5895
6119
  rwgToken = localStorage.getItem("xa_rwg_token");
5896
6120
  if (rwgToken) {
5897
6121
  attributes["rwg_token"] = rwgToken;
@@ -5936,7 +6160,7 @@ var StentorDirectChat = /** @class */ (function () {
5936
6160
  else {
5937
6161
  permissionRequest = (_c = message.msg) === null || _c === void 0 ? void 0 : _c.permissionRequest;
5938
6162
  if (permissionRequest) {
5939
- message = __assign(__assign({}, message), { msg: __assign(__assign({}, message.msg), { permissionRequest: undefined }) });
6163
+ message = __assign$1(__assign$1({}, message), { msg: __assign$1(__assign$1({}, message.msg), { permissionRequest: undefined }) });
5940
6164
  expired = now - permissionRequest.time > PERMISSION_QUESTION_EXPIRATION_MS$1;
5941
6165
  text = (_d = message.msg.text) === null || _d === void 0 ? void 0 : _d.toLowerCase();
5942
6166
  granted = !expired;
@@ -5977,7 +6201,7 @@ var StentorDirectChat = /** @class */ (function () {
5977
6201
  };
5978
6202
  }
5979
6203
  else if (message.type === "custom") {
5980
- request = __assign(__assign({}, JSON.parse(message.payload)), {
6204
+ request = __assign$1(__assign$1({}, JSON.parse(message.payload)), {
5981
6205
  // token: message.msg.token,
5982
6206
  sessionId: this._sessionId, userId: this._userId, isNewSession: false,
5983
6207
  // intentId: "OptionSelect",
@@ -6208,7 +6432,7 @@ function requestFromMessage(message, userId, isNewSession, sessionId, accessToke
6208
6432
  // Pending permission request?
6209
6433
  var permissionRequest = (_c = message.msg) === null || _c === void 0 ? void 0 : _c.permissionRequest;
6210
6434
  if (permissionRequest) {
6211
- message = __assign(__assign({}, message), { msg: __assign(__assign({}, message.msg), { permissionRequest: undefined }) });
6435
+ message = __assign$1(__assign$1({}, message), { msg: __assign$1(__assign$1({}, message.msg), { permissionRequest: undefined }) });
6212
6436
  var expired = now - permissionRequest.time > PERMISSION_QUESTION_EXPIRATION_MS;
6213
6437
  var text = (_d = message.msg.text) === null || _d === void 0 ? void 0 : _d.toLowerCase();
6214
6438
  var granted = !expired;
@@ -6247,7 +6471,7 @@ function requestFromMessage(message, userId, isNewSession, sessionId, accessToke
6247
6471
  };
6248
6472
  }
6249
6473
  else if (message.type === "custom") {
6250
- request = __assign(__assign({}, JSON.parse(message.payload)), {
6474
+ request = __assign$1(__assign$1({}, JSON.parse(message.payload)), {
6251
6475
  // token: message.msg.token,
6252
6476
  sessionId: sessionId, userId: userId, isNewSession: false,
6253
6477
  // intentId: "OptionSelect",
@@ -6283,7 +6507,7 @@ function requestFromMessage(message, userId, isNewSession, sessionId, accessToke
6283
6507
  }
6284
6508
  }
6285
6509
  if ((_e = message.msg) === null || _e === void 0 ? void 0 : _e.attributes) {
6286
- request.attributes = __assign(__assign({}, request.attributes), message.msg.attributes);
6510
+ request.attributes = __assign$1(__assign$1({}, request.attributes), message.msg.attributes);
6287
6511
  }
6288
6512
  return request;
6289
6513
  }
@@ -6445,7 +6669,7 @@ var StentorRouterChat = /** @class */ (function () {
6445
6669
  var response = data;
6446
6670
  // Extract router-managed attributes from message root (adjacent to event, data, sender, etc.)
6447
6671
  if (attributes && typeof attributes === "object" && Object.keys(attributes).length > 0) {
6448
- _this.routerAttributes = __assign({}, attributes);
6672
+ _this.routerAttributes = __assign$1({}, attributes);
6449
6673
  log("Extracted router attributes: ".concat(JSON.stringify(_this.routerAttributes)));
6450
6674
  }
6451
6675
  if (typeof ((_a = _this.options.hooks) === null || _a === void 0 ? void 0 : _a.onResponse) === "function") {
@@ -6952,7 +7176,7 @@ var StentorRouterChat = /** @class */ (function () {
6952
7176
  isAdmin: this.isAdmin,
6953
7177
  urlAttributes: this.urlAttributes,
6954
7178
  };
6955
- this.attributes = __assign(__assign(__assign({}, visitorInfoMessage.attributes), this.attributes), { currentUrl: window.location.href });
7179
+ this.attributes = __assign$1(__assign$1(__assign$1({}, visitorInfoMessage.attributes), this.attributes), { currentUrl: window.location.href });
6956
7180
  this.accessToken = visitorInfoMessage.accessToken;
6957
7181
  this.startSession(sessionId);
6958
7182
  this.postVisitorInfo(); // we, the widget, joined the server
@@ -12208,7 +12432,7 @@ var MultiSelect = function (props) {
12208
12432
  var handleToggle = React.useCallback(function (ev) {
12209
12433
  var _a;
12210
12434
  var id = ev.target.value;
12211
- onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
12435
+ onChange(__assign$1(__assign$1({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
12212
12436
  }, [checked, onChange]);
12213
12437
  return (require$$0.jsx("ul", { className: "xappw-multiselect", children: items === null || items === void 0 ? void 0 : items.map(function (item) { return (require$$0.jsx("li", { children: require$$0.jsxs("label", { children: [require$$0.jsx("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }), require$$0.jsx("span", { children: item.title })] }) }, item.id)); }) }));
12214
12438
  };
@@ -12924,7 +13148,7 @@ function useGreeting(active) {
12924
13148
  visitorId: curr.visitorId,
12925
13149
  userId: curr.userId,
12926
13150
  accessToken: curr.accessToken,
12927
- attributes: __assign(__assign({}, curr.attributes), { currentUrl: window.location.href })
13151
+ attributes: __assign$1(__assign$1({}, curr.attributes), { currentUrl: window.location.href })
12928
13152
  }, sessionId));
12929
13153
  if (!isAdmin) {
12930
13154
  var timeoutId_1 = setTimeout(function () {
@@ -34756,7 +34980,7 @@ function dateTimeToSpeech(value, type) {
34756
34980
  // If it is a time only, we need to just add the
34757
34981
  // current date for parsing. It won't be spoken
34758
34982
  // back to the user, just for parsing.
34759
- var toParse = __assign({}, value);
34983
+ var toParse = __assign$1({}, value);
34760
34984
  if (!toParse.date) {
34761
34985
  toParse.date = ("yyyy-MM-dd");
34762
34986
  }
@@ -35293,7 +35517,7 @@ var MessageList = function (_a) {
35293
35517
  case "chat.msg":
35294
35518
  return (require$$0.jsx(ChatMessage, { message: msg, sibling: sibling, agent: user, messageMiddleware: messageMiddleware, middlewareContext: ctxCache.resolve(user), minimizeOnClick: minimizeOnClick }, "cm-".concat(msg.type, "-").concat(msg.timestamp)));
35295
35519
  case "chat.failureMsg":
35296
- return (require$$0.jsx(FailureMessage, __assign({ agents: agents, time: time }, msg.failureMsg), "fm-".concat(msg.type, "-").concat(msg.timestamp)));
35520
+ return (require$$0.jsx(FailureMessage, __assign$1({ agents: agents, time: time }, msg.failureMsg), "fm-".concat(msg.type, "-").concat(msg.timestamp)));
35297
35521
  case "chat.memberjoin":
35298
35522
  case "chat.memberleave":
35299
35523
  case "chat.systemmessage":
@@ -35833,11 +36057,11 @@ var ErrorOverlay = function (_a) {
35833
36057
  if (lastError && lastError.message === error.message) {
35834
36058
  // Update count of last error
35835
36059
  return __spreadArray$1(__spreadArray$1([], prev.slice(0, -1), true), [
35836
- __assign(__assign({}, lastError), { count: lastError.count + 1, timestamp: timestamp }),
36060
+ __assign$1(__assign$1({}, lastError), { count: lastError.count + 1, timestamp: timestamp }),
35837
36061
  ], false);
35838
36062
  }
35839
36063
  // Add new error
35840
- var newError = __assign({ id: "".concat(timestamp, "-").concat(Math.random()), timestamp: timestamp, count: 1 }, error);
36064
+ var newError = __assign$1({ id: "".concat(timestamp, "-").concat(Math.random()), timestamp: timestamp, count: 1 }, error);
35841
36065
  // Keep only last 50 errors
35842
36066
  var updated = __spreadArray$1(__spreadArray$1([], prev, true), [newError], false);
35843
36067
  return updated.slice(-50);
@@ -36064,7 +36288,7 @@ function createDefaultState(state, options) {
36064
36288
  debugMode = true;
36065
36289
  }
36066
36290
  }
36067
- return __assign({ connection: {
36291
+ return __assign$1({ connection: {
36068
36292
  connectionStatus: "offline",
36069
36293
  token: null,
36070
36294
  greetingRequested: false
@@ -36079,7 +36303,7 @@ function createStateFromMessages(messages) {
36079
36303
  var lastMessage = messages.length > 0 ? messages[messages.length - 1] : undefined;
36080
36304
  var lastMsg = (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === "chat.msg" ? lastMessage.msg : null;
36081
36305
  var chips = ((_a = lastMsg === null || lastMsg === void 0 ? void 0 : lastMsg.options) === null || _a === void 0 ? void 0 : _a.length) ? lastMsg.options : [];
36082
- return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), chips: chips, isChatting: true, visuals: {
36306
+ return __assign$1(__assign$1({}, def), { connection: __assign$1(__assign$1({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), chips: chips, isChatting: true, visuals: {
36083
36307
  visible: true,
36084
36308
  opened: true,
36085
36309
  } });
@@ -36560,12 +36784,12 @@ var StaticChatWidgetContainer = function (props) {
36560
36784
  return createStaticStore(state);
36561
36785
  }, [state]);
36562
36786
  var config = React.useMemo(function () {
36563
- return __assign(__assign({}, props.config), { connection: {
36787
+ return __assign$1(__assign$1({}, props.config), { connection: {
36564
36788
  serverUrl: "",
36565
36789
  type: "local",
36566
36790
  } });
36567
36791
  }, [props.config]);
36568
- return (require$$0.jsx(reactRedux.Provider, { store: store, children: require$$0.jsx(ChatWidgetUI, __assign({}, props, { config: config, disableAutoScroll: props.disableAutoScroll, preview: props.preview })) }));
36792
+ return (require$$0.jsx(reactRedux.Provider, { store: store, children: require$$0.jsx(ChatWidgetUI, __assign$1({}, props, { config: config, disableAutoScroll: props.disableAutoScroll, preview: props.preview })) }));
36569
36793
  };
36570
36794
 
36571
36795
  var StaticMessagesChatWidgetContainer = function (props) {
@@ -36705,7 +36929,7 @@ var ChatWidgetConnected = function (props) {
36705
36929
  var connection = useConnectionInfo(rawConfig);
36706
36930
  var config = React.useMemo(function () {
36707
36931
  var _a;
36708
- return (__assign(__assign({}, rawConfig), { connection: connection, assetUrl: (_a = connection === null || connection === void 0 ? void 0 : connection.serverUrl) !== null && _a !== void 0 ? _a : defaultServerUrl, env: rawConfig }));
36932
+ return (__assign$1(__assign$1({}, rawConfig), { connection: connection, assetUrl: (_a = connection === null || connection === void 0 ? void 0 : connection.serverUrl) !== null && _a !== void 0 ? _a : defaultServerUrl, env: rawConfig }));
36709
36933
  }, [connection, rawConfig]);
36710
36934
  var token = reactRedux.useSelector(function (state) { return state.connection.token; });
36711
36935
  var options = React.useMemo(function () {
@@ -36745,7 +36969,7 @@ var ChatWidgetConnected = function (props) {
36745
36969
  if (configError) {
36746
36970
  return (require$$0.jsx("div", { className: "widget-container widget-container--error ".concat(modeClass), children: require$$0.jsxs("div", { className: "widget-error-message", children: ["Failed to load chat configuration: ", configError.message] }) }));
36747
36971
  }
36748
- return (require$$0.jsx(ChatConfigContext.Provider, { value: config, children: require$$0.jsx(ChatServerContext.Provider, { value: chatServer, children: require$$0.jsx(ChatWidgetUI, __assign({}, props, { config: rawConfig })) }) }));
36972
+ return (require$$0.jsx(ChatConfigContext.Provider, { value: config, children: require$$0.jsx(ChatServerContext.Provider, { value: chatServer, children: require$$0.jsx(ChatWidgetUI, __assign$1({}, props, { config: rawConfig })) }) }));
36749
36973
  };
36750
36974
  /**
36751
36975
  * Inner ChatWidget component that renders the actual UI.
@@ -37094,7 +37318,7 @@ var ChatWidgetUI = function (props) {
37094
37318
  // Update the button state to show it's pressed
37095
37319
  innerDispatch({
37096
37320
  type: "ws_button_display",
37097
- detail: __assign(__assign({}, chatState.wsButton), { isPressed: true, timestamp: +new Date() })
37321
+ detail: __assign$1(__assign$1({}, chatState.wsButton), { isPressed: true, timestamp: +new Date() })
37098
37322
  });
37099
37323
  }
37100
37324
  // Send the button pressed event to the server
@@ -37105,7 +37329,7 @@ var ChatWidgetUI = function (props) {
37105
37329
  if (chatState.wsButton) {
37106
37330
  innerDispatch({
37107
37331
  type: "ws_button_display",
37108
- detail: __assign(__assign({}, chatState.wsButton), { isPressed: false, timestamp: +new Date() })
37332
+ detail: __assign$1(__assign$1({}, chatState.wsButton), { isPressed: false, timestamp: +new Date() })
37109
37333
  });
37110
37334
  }
37111
37335
  });
@@ -37115,7 +37339,7 @@ var ChatWidgetUI = function (props) {
37115
37339
  // First set dismissing state to trigger animation
37116
37340
  innerDispatch({
37117
37341
  type: "ws_button_display",
37118
- detail: __assign(__assign({}, chatState.wsButton), { isDismissing: true, timestamp: +new Date() })
37342
+ detail: __assign$1(__assign$1({}, chatState.wsButton), { isDismissing: true, timestamp: +new Date() })
37119
37343
  });
37120
37344
  // Then actually dismiss after animation completes
37121
37345
  setTimeout(function () {
@@ -37203,7 +37427,7 @@ var ChatWidgetUI = function (props) {
37203
37427
  avatarPath: config.avatarUrl,
37204
37428
  display_name: "Agent",
37205
37429
  };
37206
- return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()).concat(actionBarVisible ? " widget-container--with-action-bar" : ""), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), require$$0.jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, debugMode: (_x = (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.connection) === null || _w === void 0 ? void 0 : _w.mcp) === null || _x === void 0 ? void 0 : _x.debugMode, onSubmit: handleOnSubmit }), require$$0.jsx(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_z = (_y = props.config) === null || _y === void 0 ? void 0 : _y.typingStatus) === null || _z === void 0 ? void 0 : _z.textTypingStatusEnabled, disableAutoScroll: props.disableAutoScroll, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }), require$$0.jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: require$$0.jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && require$$0.jsx(ServerOffline, {}), chatState.wsButton && visible && (require$$0.jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), require$$0.jsx(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_0 = config === null || config === void 0 ? void 0 : config.input) === null || _0 === void 0 ? void 0 : _0.placeholder, sendButtonIcon: (_2 = (_1 = config === null || config === void 0 ? void 0 : config.footer) === null || _1 === void 0 ? void 0 : _1.sendButton) === null || _2 === void 0 ? void 0 : _2.icon, sendButtonIconHover: (_4 = (_3 = config === null || config === void 0 ? void 0 : config.footer) === null || _3 === void 0 ? void 0 : _3.sendButton) === null || _4 === void 0 ? void 0 : _4.iconHover, sendButtonIconDisabled: (_6 = (_5 = config === null || config === void 0 ? void 0 : config.footer) === null || _5 === void 0 ? void 0 : _5.sendButton) === null || _6 === void 0 ? void 0 : _6.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: (_7 = props.config) === null || _7 === void 0 ? void 0 : _7.menu, footerConfig: (_8 = props.config) === null || _8 === void 0 ? void 0 : _8.footer, inputConfig: (_9 = props.config) === null || _9 === void 0 ? void 0 : _9.input, disabled: previewMode, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }), require$$0.jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: require$$0.jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), actionBarVisible && config.actionBar ? (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx(ActionBar, { config: __assign(__assign({}, config.actionBar), {
37430
+ return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()).concat(actionBarVisible ? " widget-container--with-action-bar" : ""), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), require$$0.jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, debugMode: (_x = (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.connection) === null || _w === void 0 ? void 0 : _w.mcp) === null || _x === void 0 ? void 0 : _x.debugMode, onSubmit: handleOnSubmit }), require$$0.jsx(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_z = (_y = props.config) === null || _y === void 0 ? void 0 : _y.typingStatus) === null || _z === void 0 ? void 0 : _z.textTypingStatusEnabled, disableAutoScroll: props.disableAutoScroll, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }), require$$0.jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: require$$0.jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && require$$0.jsx(ServerOffline, {}), chatState.wsButton && visible && (require$$0.jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), require$$0.jsx(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_0 = config === null || config === void 0 ? void 0 : config.input) === null || _0 === void 0 ? void 0 : _0.placeholder, sendButtonIcon: (_2 = (_1 = config === null || config === void 0 ? void 0 : config.footer) === null || _1 === void 0 ? void 0 : _1.sendButton) === null || _2 === void 0 ? void 0 : _2.icon, sendButtonIconHover: (_4 = (_3 = config === null || config === void 0 ? void 0 : config.footer) === null || _3 === void 0 ? void 0 : _3.sendButton) === null || _4 === void 0 ? void 0 : _4.iconHover, sendButtonIconDisabled: (_6 = (_5 = config === null || config === void 0 ? void 0 : config.footer) === null || _5 === void 0 ? void 0 : _5.sendButton) === null || _6 === void 0 ? void 0 : _6.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: (_7 = props.config) === null || _7 === void 0 ? void 0 : _7.menu, footerConfig: (_8 = props.config) === null || _8 === void 0 ? void 0 : _8.footer, inputConfig: (_9 = props.config) === null || _9 === void 0 ? void 0 : _9.input, disabled: previewMode, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }), require$$0.jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: require$$0.jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), actionBarVisible && config.actionBar ? (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx(ActionBar, { config: __assign$1(__assign$1({}, config.actionBar), {
37207
37431
  // Use actionBar.cta if set, otherwise fall back to widget-level cta
37208
37432
  cta: (_10 = config.actionBar.cta) !== null && _10 !== void 0 ? _10 : config.cta }), visible: visible, chatDisabled: config.disabled, formDisabled: isFormPage, hasUserInteracted: (_11 = chatState.visuals) === null || _11 === void 0 ? void 0 : _11.hasInteracted, onChatClick: chatButtonOnClick, onChatMinimize: handleMinimizeClick, onFormClick: handleFormButtonClick, onCtaDismiss: handleCtaDismiss }), formModalOpen && activeFormConfig && (require$$0.jsx(FormModal, { config: activeFormConfig, widgetEnv: config, onClose: handleFormModalClose }))] })) : (require$$0.jsx(ChatButton, { addClass: visible ? "visible" : "", onClick: chatButtonOnClick, config: config === null || config === void 0 ? void 0 : config.cta, imageUrl: (_12 = config === null || config === void 0 ? void 0 : config.chatButton) === null || _12 === void 0 ? void 0 : _12.imageUrl, visible: visible, hasInteracted: (_13 = chatState.visuals) === null || _13 === void 0 ? void 0 : _13.hasInteracted, onCtaDismiss: handleCtaDismiss })), require$$0.jsx(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })] }));
37209
37433
  };
@@ -37219,9 +37443,9 @@ var ChatWidgetWrapper = function (props) {
37219
37443
  // For visual layout, use "static" when mode is "preview" (legacy), otherwise use the actual mode
37220
37444
  var visualMode = rawMode === "preview" ? "static" : rawMode;
37221
37445
  if (isPreviewMode) {
37222
- return require$$0.jsx(ChatWidgetPreview, __assign({}, props, { mode: visualMode }));
37446
+ return require$$0.jsx(ChatWidgetPreview, __assign$1({}, props, { mode: visualMode }));
37223
37447
  }
37224
- return require$$0.jsx(ChatWidgetConnected, __assign({}, props));
37448
+ return require$$0.jsx(ChatWidgetConnected, __assign$1({}, props));
37225
37449
  };
37226
37450
 
37227
37451
  function tryParseJson(str) {
@@ -37301,7 +37525,7 @@ function persistStateReducer(storage, initialState, innerReducer) {
37301
37525
  // Clean up transient visual state on page load - don't persist across browser refreshes
37302
37526
  // visible is derived from config (autoOpenOnWidth, autoOpenOnPattern) and visuals.opened
37303
37527
  if (obj && obj.visuals) {
37304
- obj = __assign(__assign({}, obj), { visuals: __assign(__assign({}, obj.visuals), { hasInteracted: undefined, visible: undefined }) });
37528
+ obj = __assign$1(__assign$1({}, obj), { visuals: __assign$1(__assign$1({}, obj.visuals), { hasInteracted: undefined, visible: undefined }) });
37305
37529
  }
37306
37530
  return function (state, action) {
37307
37531
  if (state === void 0) { state = obj; }
@@ -37314,11 +37538,11 @@ function persistStateReducer(storage, initialState, innerReducer) {
37314
37538
  function connectionReducer(state, action) {
37315
37539
  switch (action.type) {
37316
37540
  case "connection_update":
37317
- return __assign(__assign({}, state), { connectionStatus: action.detail.status });
37541
+ return __assign$1(__assign$1({}, state), { connectionStatus: action.detail.status });
37318
37542
  case "receiveToken":
37319
- return __assign(__assign({}, state), { token: action.detail.token });
37543
+ return __assign$1(__assign$1({}, state), { token: action.detail.token });
37320
37544
  case "sendGreeting":
37321
- return __assign(__assign({}, state), { greetingRequested: true });
37545
+ return __assign$1(__assign$1({}, state), { greetingRequested: true });
37322
37546
  }
37323
37547
  return state;
37324
37548
  }
@@ -37333,9 +37557,9 @@ function memberJoin(state, detail) {
37333
37557
  // console.log(`######### No chats in member join action`);
37334
37558
  // set("sessionId", "");
37335
37559
  // }
37336
- var agents = __assign({}, state.agents);
37560
+ var agents = __assign$1({}, state.agents);
37337
37561
  var prevAgentInfo = state.agents[detail.user.nick];
37338
- agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false, hideUserInfo: detail.hideUserInfo });
37562
+ agents[detail.user.nick] = __assign$1(__assign$1({}, prevAgentInfo), { user: __assign$1(__assign$1({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false, hideUserInfo: detail.hideUserInfo });
37339
37563
  if (isAgent(detail.user.nick)) {
37340
37564
  // Always show join messages with special visual features (divider or custom message)
37341
37565
  // These are important conversation markers, not routine join notifications
@@ -37351,18 +37575,18 @@ function memberJoin(state, detail) {
37351
37575
  log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
37352
37576
  }
37353
37577
  }
37354
- return __assign(__assign({}, state), { isChatting: true, chats: ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) ? state.chats : joinMessages(state.chats, detail), agents: agents });
37578
+ return __assign$1(__assign$1({}, state), { isChatting: true, chats: ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) ? state.chats : joinMessages(state.chats, detail), agents: agents });
37355
37579
  }
37356
37580
  else {
37357
37581
  log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
37358
- return __assign(__assign({}, state), { isChatting: true, chats: joinMessages(state.chats, detail), agents: agents });
37582
+ return __assign$1(__assign$1({}, state), { isChatting: true, chats: joinMessages(state.chats, detail), agents: agents });
37359
37583
  }
37360
37584
  }
37361
37585
 
37362
37586
  function memberLeave(state, detail) {
37363
- var agents = __assign({}, state.agents);
37587
+ var agents = __assign$1({}, state.agents);
37364
37588
  var prevAgentInfo = state.agents[detail.user.nick];
37365
- agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { joined: false, typing: false });
37589
+ agents[detail.user.nick] = __assign$1(__assign$1({}, prevAgentInfo), { joined: false, typing: false });
37366
37590
  // count number of agents that are still joined
37367
37591
  var agentsJoined = Object.values(agents).filter(function (agent) { return agent.joined; });
37368
37592
  var isChatting = agentsJoined.length > 0;
@@ -37379,11 +37603,11 @@ function memberLeave(state, detail) {
37379
37603
  else {
37380
37604
  log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already left. NOT adding duplicate leave message to chat."));
37381
37605
  }
37382
- return __assign(__assign({}, state), { isChatting: isChatting, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? joinMessages(state.chats, detail) : state.chats, agents: agents });
37606
+ return __assign$1(__assign$1({}, state), { isChatting: isChatting, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? joinMessages(state.chats, detail) : state.chats, agents: agents });
37383
37607
  }
37384
37608
  else {
37385
37609
  log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
37386
- return __assign(__assign({}, state), { isChatting: isChatting, chats: joinMessages(state.chats, detail), agents: agents });
37610
+ return __assign$1(__assign$1({}, state), { isChatting: isChatting, chats: joinMessages(state.chats, detail), agents: agents });
37387
37611
  }
37388
37612
  }
37389
37613
 
@@ -37400,7 +37624,7 @@ function resetReducer(state) {
37400
37624
  var wasOnline = state.connection.connectionStatus === 'online';
37401
37625
  // Preserve opened state so widget doesn't close on refresh
37402
37626
  var wasOpened = (_a = state.visuals) === null || _a === void 0 ? void 0 : _a.opened;
37403
- return __assign(__assign({}, defaultState), { connection: __assign(__assign({}, defaultState.connection), { greetingRequested: false,
37627
+ return __assign$1(__assign$1({}, defaultState), { connection: __assign$1(__assign$1({}, defaultState.connection), { greetingRequested: false,
37404
37628
  // Generate new nonce to trigger server recreation and start fresh session
37405
37629
  nonce: uuid_1(),
37406
37630
  // Preserve connection status during transition if we were online
@@ -37454,24 +37678,24 @@ function update(state, action) {
37454
37678
  // workaround until state is split. Use combineReducers afterwards
37455
37679
  var newConnectionState = connectionReducer(state.connection, action);
37456
37680
  if (state.connection !== newConnectionState) {
37457
- state = __assign(__assign({}, state), { lastTimestamp: (_e = action.detail) === null || _e === void 0 ? void 0 : _e.timestamp, connection: newConnectionState });
37681
+ state = __assign$1(__assign$1({}, state), { lastTimestamp: (_e = action.detail) === null || _e === void 0 ? void 0 : _e.timestamp, connection: newConnectionState });
37458
37682
  }
37459
37683
  return state;
37460
37684
  case "account_status":
37461
- return __assign(__assign({}, state), { lastTimestamp: (_f = action.detail) === null || _f === void 0 ? void 0 : _f.timestamp, accountStatus: action.detail.status });
37685
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_f = action.detail) === null || _f === void 0 ? void 0 : _f.timestamp, accountStatus: action.detail.status });
37462
37686
  case "session_id":
37463
- return __assign(__assign({}, state), { lastTimestamp: (_g = action.detail) === null || _g === void 0 ? void 0 : _g.timestamp, sessionId: action.detail.sessionId });
37687
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_g = action.detail) === null || _g === void 0 ? void 0 : _g.timestamp, sessionId: action.detail.sessionId });
37464
37688
  case "visual_status":
37465
- return __assign(__assign({}, state), { lastTimestamp: (_h = action.detail) === null || _h === void 0 ? void 0 : _h.timestamp, visuals: __assign(__assign(__assign(__assign(__assign({}, (state.visuals || {})), (action.detail.status.drawer !== undefined && { drawer: action.detail.status.drawer })), (action.detail.status.opened !== undefined && { opened: action.detail.status.opened })), (action.detail.status.visible !== undefined && { visible: action.detail.status.visible })), (action.detail.status.hasInteracted !== undefined && { hasInteracted: action.detail.status.hasInteracted })) });
37689
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_h = action.detail) === null || _h === void 0 ? void 0 : _h.timestamp, visuals: __assign$1(__assign$1(__assign$1(__assign$1(__assign$1({}, (state.visuals || {})), (action.detail.status.drawer !== undefined && { drawer: action.detail.status.drawer })), (action.detail.status.opened !== undefined && { opened: action.detail.status.opened })), (action.detail.status.visible !== undefined && { visible: action.detail.status.visible })), (action.detail.status.hasInteracted !== undefined && { hasInteracted: action.detail.status.hasInteracted })) });
37466
37690
  case "toggle_debug_mode":
37467
37691
  var newDebugMode = !state.debugMode;
37468
37692
  // Update localStorage to persist the setting
37469
37693
  if (typeof window !== 'undefined' && window.localStorage) {
37470
37694
  window.localStorage.setItem('xaErrorOverlay', newDebugMode ? 'enabled' : 'disabled');
37471
37695
  }
37472
- return __assign(__assign({}, state), { debugMode: newDebugMode });
37696
+ return __assign$1(__assign$1({}, state), { debugMode: newDebugMode });
37473
37697
  case "ws_button_display":
37474
- return __assign(__assign({}, state), { lastTimestamp: (_j = action.detail) === null || _j === void 0 ? void 0 : _j.timestamp, wsButton: {
37698
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_j = action.detail) === null || _j === void 0 ? void 0 : _j.timestamp, wsButton: {
37475
37699
  id: action.detail.id,
37476
37700
  // Preserve existing text if new text is empty (e.g., during dismiss animation)
37477
37701
  text: action.detail.text || ((_k = state.wsButton) === null || _k === void 0 ? void 0 : _k.text) || '',
@@ -37482,19 +37706,19 @@ function update(state, action) {
37482
37706
  case "ws_button_dismiss":
37483
37707
  // Only dismiss if the id matches
37484
37708
  if (((_o = state.wsButton) === null || _o === void 0 ? void 0 : _o.id) === action.detail.id) {
37485
- return __assign(__assign({}, state), { lastTimestamp: (_p = action.detail) === null || _p === void 0 ? void 0 : _p.timestamp, wsButton: undefined });
37709
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_p = action.detail) === null || _p === void 0 ? void 0 : _p.timestamp, wsButton: undefined });
37486
37710
  }
37487
37711
  return state;
37488
37712
  case "department_update":
37489
- return __assign(__assign({}, state), { lastTimestamp: (_q = action.detail) === null || _q === void 0 ? void 0 : _q.timestamp, departments: __assign(__assign({}, state.departments), (_a = {}, _a[action.detail.id] = __assign({}, action.detail), _a)) });
37713
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_q = action.detail) === null || _q === void 0 ? void 0 : _q.timestamp, departments: __assign$1(__assign$1({}, state.departments), (_a = {}, _a[action.detail.id] = __assign$1({}, action.detail), _a)) });
37490
37714
  case "visitor_update":
37491
- return __assign(__assign({}, state), { lastTimestamp: (_r = action.detail) === null || _r === void 0 ? void 0 : _r.timestamp, visitor: __assign(__assign({}, state.visitor), action.detail) });
37715
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_r = action.detail) === null || _r === void 0 ? void 0 : _r.timestamp, visitor: __assign$1(__assign$1({}, state.visitor), action.detail) });
37492
37716
  case "agent_update":
37493
37717
  var prevUpdateAgent = state.agents[action.detail.nick];
37494
- return __assign(__assign({}, state), { lastTimestamp: (_s = action.detail) === null || _s === void 0 ? void 0 : _s.timestamp, agents: __assign(__assign({}, state.agents), (_b = {}, _b[action.detail.nick] = __assign(__assign({}, prevUpdateAgent), { user: __assign(__assign({}, prevUpdateAgent.user), action.detail), typing: (prevUpdateAgent || { typing: false }).typing // if we had it - keep it
37718
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_s = action.detail) === null || _s === void 0 ? void 0 : _s.timestamp, agents: __assign$1(__assign$1({}, state.agents), (_b = {}, _b[action.detail.nick] = __assign$1(__assign$1({}, prevUpdateAgent), { user: __assign$1(__assign$1({}, prevUpdateAgent.user), action.detail), typing: (prevUpdateAgent || { typing: false }).typing // if we had it - keep it
37495
37719
  }), _b)) });
37496
37720
  case "chat":
37497
- var newState = __assign(__assign({}, state), { lastTimestamp: (_t = action.detail) === null || _t === void 0 ? void 0 : _t.timestamp });
37721
+ var newState = __assign$1(__assign$1({}, state), { lastTimestamp: (_t = action.detail) === null || _t === void 0 ? void 0 : _t.timestamp });
37498
37722
  switch (action.detail.type) {
37499
37723
  case "chat.memberjoin":
37500
37724
  return memberJoin(state, action.detail);
@@ -37507,7 +37731,7 @@ function update(state, action) {
37507
37731
  case "chat.systemmessagedismiss":
37508
37732
  // Remove system message(s) with the specified id
37509
37733
  var dismissId_1 = action.detail.id;
37510
- return __assign(__assign({}, newState), { chats: newState.chats.filter(function (chat) {
37734
+ return __assign$1(__assign$1({}, newState), { chats: newState.chats.filter(function (chat) {
37511
37735
  // Keep all non-system messages, and system messages that don't match the id
37512
37736
  if (isChatSystemMessage(chat)) {
37513
37737
  return chat.id !== dismissId_1;
@@ -37519,10 +37743,10 @@ function update(state, action) {
37519
37743
  return newState;
37520
37744
  case "chat.request.rating":
37521
37745
  appendMessageToState(newState, action.detail);
37522
- return __assign(__assign({}, newState), { lastRatingRequestTimestamp: action.detail.timestamp });
37746
+ return __assign$1(__assign$1({}, newState), { lastRatingRequestTimestamp: action.detail.timestamp });
37523
37747
  case "chat.rating":
37524
37748
  appendMessageToState(newState, action.detail);
37525
- return __assign(__assign({}, newState), { hasRating: !!action.detail.newRating });
37749
+ return __assign$1(__assign$1({}, newState), { hasRating: !!action.detail.newRating });
37526
37750
  case "chat.file":
37527
37751
  case "chat.msg":
37528
37752
  appendMessageToState(newState, action.detail);
@@ -37542,19 +37766,19 @@ function update(state, action) {
37542
37766
  var clearedChats = newState.chats.filter(function (item) {
37543
37767
  return item !== oldFailureMsg_1;
37544
37768
  });
37545
- finalState = __assign(__assign({}, newState), { chats: clearedChats });
37769
+ finalState = __assign$1(__assign$1({}, newState), { chats: clearedChats });
37546
37770
  }
37547
37771
  appendMessageToState(finalState, action.detail);
37548
- return __assign(__assign({}, finalState), { agents: __assign(__assign({}, finalState.agents), (_c = {}, _c[action.detail.user.nick] = __assign(__assign({}, agentDetails), { typing: false, requestFailed: true }), _c)), failureMsg: action.detail.failureMsg });
37772
+ return __assign$1(__assign$1({}, finalState), { agents: __assign$1(__assign$1({}, finalState.agents), (_c = {}, _c[action.detail.user.nick] = __assign$1(__assign$1({}, agentDetails), { typing: false, requestFailed: true }), _c)), failureMsg: action.detail.failureMsg });
37549
37773
  case "chat.typing":
37550
37774
  var agent = state.agents[action.detail.user.nick];
37551
- return __assign(__assign({}, state), { lastTimestamp: (_v = action.detail) === null || _v === void 0 ? void 0 : _v.timestamp, agents: __assign(__assign({}, state.agents), (_d = {}, _d[action.detail.user.nick] = __assign(__assign({}, agent), { typing: action.detail.typing }), _d)) });
37775
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_v = action.detail) === null || _v === void 0 ? void 0 : _v.timestamp, agents: __assign$1(__assign$1({}, state.agents), (_d = {}, _d[action.detail.user.nick] = __assign$1(__assign$1({}, agent), { typing: action.detail.typing }), _d)) });
37552
37776
  case "chat.stream.start": {
37553
37777
  // Clean up any orphan streaming messages from interrupted streams
37554
37778
  // before creating the new placeholder.
37555
37779
  var cleanedChats = newState.chats.map(function (chat) {
37556
37780
  if (isChatMsgDetail(chat) && chat.isStreaming) {
37557
- return __assign(__assign({}, chat), { isStreaming: false, wasStreamed: true });
37781
+ return __assign$1(__assign$1({}, chat), { isStreaming: false, wasStreamed: true });
37558
37782
  }
37559
37783
  return chat;
37560
37784
  });
@@ -37572,7 +37796,7 @@ function update(state, action) {
37572
37796
  isStreaming: true,
37573
37797
  };
37574
37798
  var newChats = joinMessages(cleanedChats, streamingMsg);
37575
- return __assign(__assign({}, newState), { chats: newChats, streamingMessageId: action.detail.messageId });
37799
+ return __assign$1(__assign$1({}, newState), { chats: newChats, streamingMessageId: action.detail.messageId });
37576
37800
  }
37577
37801
  case "chat.stream.chunk": {
37578
37802
  // Find the streaming message by ID and append text
@@ -37582,10 +37806,10 @@ function update(state, action) {
37582
37806
  var streamingIndex_1 = findLastStreamingIndex(state.chats);
37583
37807
  if (streamingIndex_1 >= 0) {
37584
37808
  var chunkText_1 = chunkDetail.text;
37585
- return __assign(__assign({}, state), { lastTimestamp: chunkDetail === null || chunkDetail === void 0 ? void 0 : chunkDetail.timestamp, chats: state.chats.map(function (chat, index) {
37809
+ return __assign$1(__assign$1({}, state), { lastTimestamp: chunkDetail === null || chunkDetail === void 0 ? void 0 : chunkDetail.timestamp, chats: state.chats.map(function (chat, index) {
37586
37810
  var _a;
37587
37811
  if (index === streamingIndex_1 && isChatMsgDetail(chat)) {
37588
- return __assign(__assign({}, chat), { msg: __assign(__assign({}, chat.msg), { text: (((_a = chat.msg) === null || _a === void 0 ? void 0 : _a.text) || "") + chunkText_1 }) });
37812
+ return __assign$1(__assign$1({}, chat), { msg: __assign$1(__assign$1({}, chat.msg), { text: (((_a = chat.msg) === null || _a === void 0 ? void 0 : _a.text) || "") + chunkText_1 }) });
37589
37813
  }
37590
37814
  return chat;
37591
37815
  }) });
@@ -37601,10 +37825,10 @@ function update(state, action) {
37601
37825
  // Find the streaming message by ID (not by index - other messages could be inserted)
37602
37826
  var streamingIndex_2 = findLastStreamingIndex(state.chats);
37603
37827
  if (streamingIndex_2 >= 0) {
37604
- return __assign(__assign({}, state), { lastTimestamp: toolStartDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37828
+ return __assign$1(__assign$1({}, state), { lastTimestamp: toolStartDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37605
37829
  if (index === streamingIndex_2 && isChatMsgDetail(chat)) {
37606
37830
  var existingToolCalls = chat.toolCalls || [];
37607
- return __assign(__assign({}, chat), { toolCalls: __spreadArray$1(__spreadArray$1([], existingToolCalls, true), [
37831
+ return __assign$1(__assign$1({}, chat), { toolCalls: __spreadArray$1(__spreadArray$1([], existingToolCalls, true), [
37608
37832
  {
37609
37833
  name: toolStartDetail_1.toolName,
37610
37834
  toolCallId: toolStartDetail_1.toolCallId,
@@ -37631,7 +37855,7 @@ function update(state, action) {
37631
37855
  // Find the streaming message by ID (not by index - other messages could be inserted)
37632
37856
  var streamingIndex_3 = findLastStreamingIndex(state.chats);
37633
37857
  if (streamingIndex_3 >= 0) {
37634
- return __assign(__assign({}, state), { lastTimestamp: toolEndDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37858
+ return __assign$1(__assign$1({}, state), { lastTimestamp: toolEndDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37635
37859
  var _a;
37636
37860
  if (index === streamingIndex_3 && isChatMsgDetail(chat)) {
37637
37861
  var toolCalls = (_a = chat.toolCalls) === null || _a === void 0 ? void 0 : _a.map(function (tc) {
@@ -37641,11 +37865,11 @@ function update(state, action) {
37641
37865
  ? tc.toolCallId === toolEndDetail_1.toolCallId
37642
37866
  : tc.name === toolEndDetail_1.toolName && tc.isExecuting;
37643
37867
  if (isMatch) {
37644
- return __assign(__assign({}, tc), { displayName: toolEndDetail_1.displayName || tc.displayName, label: toolEndDetail_1.label, hidden: (_a = toolEndDetail_1.hidden) !== null && _a !== void 0 ? _a : tc.hidden, input: (_b = toolEndDetail_1.toolInput) !== null && _b !== void 0 ? _b : tc.input, result: toolEndDetail_1.toolResult, error: toolEndDetail_1.toolError, endTime: toolEndDetail_1.timestamp, isExecuting: false });
37868
+ return __assign$1(__assign$1({}, tc), { displayName: toolEndDetail_1.displayName || tc.displayName, label: toolEndDetail_1.label, hidden: (_a = toolEndDetail_1.hidden) !== null && _a !== void 0 ? _a : tc.hidden, input: (_b = toolEndDetail_1.toolInput) !== null && _b !== void 0 ? _b : tc.input, result: toolEndDetail_1.toolResult, error: toolEndDetail_1.toolError, endTime: toolEndDetail_1.timestamp, isExecuting: false });
37645
37869
  }
37646
37870
  return tc;
37647
37871
  });
37648
- return __assign(__assign({}, chat), { toolCalls: toolCalls });
37872
+ return __assign$1(__assign$1({}, chat), { toolCalls: toolCalls });
37649
37873
  }
37650
37874
  return chat;
37651
37875
  }) });
@@ -37667,9 +37891,9 @@ function update(state, action) {
37667
37891
  var toolCalls_1 = endDetail.toolCalls || endStreamingChat.toolCalls;
37668
37892
  // Update chips from message options (same as chat.msg handler)
37669
37893
  var chips = ((_w = finalMsg_1 === null || finalMsg_1 === void 0 ? void 0 : finalMsg_1.options) === null || _w === void 0 ? void 0 : _w.length) ? finalMsg_1.options : [];
37670
- return __assign(__assign({}, state), { lastTimestamp: endDetail === null || endDetail === void 0 ? void 0 : endDetail.timestamp, streamingMessageId: undefined, chips: chips, chats: state.chats.map(function (chat, index) {
37894
+ return __assign$1(__assign$1({}, state), { lastTimestamp: endDetail === null || endDetail === void 0 ? void 0 : endDetail.timestamp, streamingMessageId: undefined, chips: chips, chats: state.chats.map(function (chat, index) {
37671
37895
  if (index === streamingIndex_4 && isChatMsgDetail(chat)) {
37672
- return __assign(__assign({}, chat), { msg: finalMsg_1, isStreaming: false, wasStreamed: true, toolCalls: toolCalls_1 });
37896
+ return __assign$1(__assign$1({}, chat), { msg: finalMsg_1, isStreaming: false, wasStreamed: true, toolCalls: toolCalls_1 });
37673
37897
  }
37674
37898
  return chat;
37675
37899
  }) });
@@ -37684,9 +37908,9 @@ function update(state, action) {
37684
37908
  if (state.streamingMessageId === abortDetail.messageId) {
37685
37909
  var streamingIndex_5 = findLastStreamingIndex(state.chats);
37686
37910
  if (streamingIndex_5 >= 0) {
37687
- return __assign(__assign({}, state), { lastTimestamp: abortDetail.timestamp, streamingMessageId: undefined, chats: state.chats.map(function (chat, index) {
37911
+ return __assign$1(__assign$1({}, state), { lastTimestamp: abortDetail.timestamp, streamingMessageId: undefined, chats: state.chats.map(function (chat, index) {
37688
37912
  if (index === streamingIndex_5 && isChatMsgDetail(chat)) {
37689
- return __assign(__assign({}, chat), { isStreaming: false, wasStreamed: true });
37913
+ return __assign$1(__assign$1({}, chat), { isStreaming: false, wasStreamed: true });
37690
37914
  }
37691
37915
  return chat;
37692
37916
  }) });
@@ -37713,9 +37937,9 @@ function update(state, action) {
37713
37937
  }
37714
37938
  }
37715
37939
  if (lastBotIndex_1 >= 0) {
37716
- return __assign(__assign({}, state), { lastTimestamp: resumeDetail.timestamp, streamingMessageId: resumeDetail.messageId, chats: state.chats.map(function (chat, index) {
37940
+ return __assign$1(__assign$1({}, state), { lastTimestamp: resumeDetail.timestamp, streamingMessageId: resumeDetail.messageId, chats: state.chats.map(function (chat, index) {
37717
37941
  if (index === lastBotIndex_1 && isChatMsgDetail(chat)) {
37718
- return __assign(__assign({}, chat), { isStreaming: true, wasStreamed: false });
37942
+ return __assign$1(__assign$1({}, chat), { isStreaming: true, wasStreamed: false });
37719
37943
  }
37720
37944
  return chat;
37721
37945
  }) });
@@ -37867,8 +38091,8 @@ function generateKey(connection, sessionId) {
37867
38091
  */
37868
38092
  var ChatWidgetPreviewContainer = function (props) {
37869
38093
  var messageMiddleware = useStandardMiddleware();
37870
- var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware });
37871
- return require$$0.jsx(ChatWidgetWrapper, __assign({}, widgetProps));
38094
+ var widgetProps = __assign$1(__assign$1({}, props), { messageMiddleware: messageMiddleware });
38095
+ return require$$0.jsx(ChatWidgetWrapper, __assign$1({}, widgetProps));
37872
38096
  };
37873
38097
  /**
37874
38098
  * Connected mode container - creates store and connects to server.
@@ -37891,9 +38115,9 @@ var ChatWidgetConnectedContainer = function (props) {
37891
38115
  if ((_f = props.config) === null || _f === void 0 ? void 0 : _f.disabled) {
37892
38116
  return require$$0.jsx(require$$0.Fragment, {});
37893
38117
  }
37894
- var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware, getConfig: props.getConfig // Pass through getConfig callback
38118
+ var widgetProps = __assign$1(__assign$1({}, props), { messageMiddleware: messageMiddleware, getConfig: props.getConfig // Pass through getConfig callback
37895
38119
  });
37896
- return (require$$0.jsx(reactRedux.Provider, { store: chatStore, children: require$$0.jsx(ChatWidgetWrapper, __assign({}, widgetProps)) }));
38120
+ return (require$$0.jsx(reactRedux.Provider, { store: chatStore, children: require$$0.jsx(ChatWidgetWrapper, __assign$1({}, widgetProps)) }));
37897
38121
  };
37898
38122
  /**
37899
38123
  * Top-level container that dispatches between preview and connected modes.
@@ -37904,9 +38128,9 @@ var ChatWidgetContainer = function (props) {
37904
38128
  // Support both `preview` prop and legacy `mode="preview"`
37905
38129
  var isPreviewMode = props.preview === true || rawMode === "preview";
37906
38130
  if (isPreviewMode) {
37907
- return require$$0.jsx(ChatWidgetPreviewContainer, __assign({}, props));
38131
+ return require$$0.jsx(ChatWidgetPreviewContainer, __assign$1({}, props));
37908
38132
  }
37909
- return require$$0.jsx(ChatWidgetConnectedContainer, __assign({}, props));
38133
+ return require$$0.jsx(ChatWidgetConnectedContainer, __assign$1({}, props));
37910
38134
  };
37911
38135
 
37912
38136
  exports.React = React;