@aslaluroba/help-center-react 3.2.4 → 3.2.5

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
@@ -3606,6 +3606,77 @@ function darkenColor(color, amount) {
3606
3606
  return '#' + (0x1000000 + (R > 255 ? 255 : R < 0 ? 0 : R) * 0x10000 + (G > 255 ? 255 : G < 0 ? 0 : G) * 0x100 + (B > 255 ? 255 : B < 0 ? 0 : B)).toString(16).slice(1);
3607
3607
  }
3608
3608
 
3609
+ var useActionHandler = () => {
3610
+ var handlersRef = React.useRef(new Map());
3611
+ var defaultHandlerRef = React.useRef(messageData => {
3612
+ var _a;
3613
+ var message = (_a = messageData) !== null && _a !== void 0 ? _a : {};
3614
+ var actionType = message.actionType || '';
3615
+ if (actionType) {
3616
+ // Log unknown actions for debugging but do not crash
3617
+ // eslint-disable-next-line no-console
3618
+ console.warn("[ActionHandler] Unknown action type received: \"".concat(actionType, "\". Message data:"), messageData);
3619
+ }
3620
+ });
3621
+ var registerHandler = React.useCallback((actionType, handler) => {
3622
+ if (!actionType) {
3623
+ // eslint-disable-next-line no-console
3624
+ console.warn('[ActionHandler] Attempted to register handler with empty action type. Ignored.');
3625
+ return;
3626
+ }
3627
+ if (handlersRef.current.has(actionType)) {
3628
+ // eslint-disable-next-line no-console
3629
+ console.warn("[ActionHandler] Handler for action type \"".concat(actionType, "\" already exists. Overwriting with new handler."));
3630
+ }
3631
+ handlersRef.current.set(actionType, handler);
3632
+ }, []);
3633
+ var unregisterHandler = React.useCallback(actionType => {
3634
+ if (!actionType) {
3635
+ return;
3636
+ }
3637
+ handlersRef.current.delete(actionType);
3638
+ }, []);
3639
+ var handleAction = React.useCallback(/*#__PURE__*/function () {
3640
+ var _ref = _asyncToGenerator(function* (actionType, messageData) {
3641
+ // Ignore empty, null, or undefined action types (no-op)
3642
+ if (!actionType || actionType === '') {
3643
+ return;
3644
+ }
3645
+ var handler = handlersRef.current.get(actionType);
3646
+ if (handler) {
3647
+ try {
3648
+ yield handler(messageData);
3649
+ } catch (error) {
3650
+ // eslint-disable-next-line no-console
3651
+ console.error("[ActionHandler] Error executing handler for action type \"".concat(actionType, "\":"), error);
3652
+ }
3653
+ return;
3654
+ }
3655
+ var defaultHandler = defaultHandlerRef.current;
3656
+ if (defaultHandler) {
3657
+ try {
3658
+ yield Promise.resolve(defaultHandler(messageData));
3659
+ } catch (error) {
3660
+ // eslint-disable-next-line no-console
3661
+ console.error("[ActionHandler] Error executing default handler for unknown action type \"".concat(actionType, "\":"), error);
3662
+ }
3663
+ }
3664
+ });
3665
+ return function (_x, _x2) {
3666
+ return _ref.apply(this, arguments);
3667
+ };
3668
+ }(), []);
3669
+ var getRegisteredActions = React.useCallback(() => {
3670
+ return Array.from(handlersRef.current.keys());
3671
+ }, []);
3672
+ return {
3673
+ registerHandler,
3674
+ unregisterHandler,
3675
+ handleAction,
3676
+ getRegisteredActions
3677
+ };
3678
+ };
3679
+
3609
3680
  /**
3610
3681
  * @license @tabler/icons-react v3.35.0 - MIT
3611
3682
  *
@@ -6988,7 +7059,7 @@ var ably = {exports: {}};
6988
7059
  });
6989
7060
  return _withTimeoutAsync2.apply(this, arguments);
6990
7061
  }
6991
- var version = "2.15.0";
7062
+ var version = "2.13.0";
6992
7063
 
6993
7064
  // src/common/lib/util/defaults.ts
6994
7065
  var agent = "ably-js/" + version;
@@ -7236,10 +7307,10 @@ var ably = {exports: {}};
7236
7307
  };
7237
7308
  function defaultGetHeaders(options) {
7238
7309
  var {
7239
- format,
7310
+ format = defaultHeadersOptions.format,
7240
7311
  protocolVersion = defaultHeadersOptions.protocolVersion
7241
7312
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7242
- var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
7313
+ var accept = contentTypes[format];
7243
7314
  return {
7244
7315
  accept,
7245
7316
  "X-Ably-Version": protocolVersion.toString(),
@@ -7248,11 +7319,11 @@ var ably = {exports: {}};
7248
7319
  }
7249
7320
  function defaultPostHeaders(options) {
7250
7321
  var {
7251
- format,
7322
+ format = defaultHeadersOptions.format,
7252
7323
  protocolVersion = defaultHeadersOptions.protocolVersion
7253
7324
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7254
- var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
7255
- var contentType = accept;
7325
+ var contentType;
7326
+ var accept = contentType = contentTypes[format];
7256
7327
  return {
7257
7328
  accept,
7258
7329
  "content-type": contentType,
@@ -7576,9 +7647,7 @@ var ably = {exports: {}};
7576
7647
  tokenUri = function tokenUri(host) {
7577
7648
  return client.baseUri(host) + path;
7578
7649
  };
7579
- var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options, {
7580
- format: "json" /* json */
7581
- });
7650
+ var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options);
7582
7651
  if (resolvedAuthOptions.requestHeaders) _mixin(requestHeaders, resolvedAuthOptions.requestHeaders);
7583
7652
  logger_default.logAction(_this3.logger, logger_default.LOG_MICRO, "Auth.requestToken().requestToken", "Sending POST to " + path + "; Token params: " + JSON.stringify(signedTokenParams));
7584
7653
  _whenPromiseSettles(_this3.client.http.do(HttpMethods_default.Post, tokenUri, requestHeaders, JSON.stringify(signedTokenParams), null), (err, result) => err ? tokenCb(err) : tokenCb(result.error, result.body, result.unpacked));
@@ -9270,7 +9339,9 @@ var ably = {exports: {}};
9270
9339
  return _asyncToGenerator(function* () {
9271
9340
  var client = _this26.client;
9272
9341
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9273
- headers = defaults_default.defaultPostHeaders(client.options),
9342
+ headers = defaults_default.defaultPostHeaders(client.options, {
9343
+ format
9344
+ }),
9274
9345
  params = {};
9275
9346
  var body = _mixin({
9276
9347
  recipient
@@ -9294,7 +9365,9 @@ var ably = {exports: {}};
9294
9365
  var client = _this27.client;
9295
9366
  var body = devicedetails_default.fromValues(device);
9296
9367
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9297
- headers = defaults_default.defaultPostHeaders(client.options),
9368
+ headers = defaults_default.defaultPostHeaders(client.options, {
9369
+ format
9370
+ }),
9298
9371
  params = {};
9299
9372
  _mixin(headers, client.options.headers);
9300
9373
  if (client.options.pushFullWait) _mixin(params, {
@@ -9310,7 +9383,9 @@ var ably = {exports: {}};
9310
9383
  return _asyncToGenerator(function* () {
9311
9384
  var client = _this28.client,
9312
9385
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9313
- headers = defaults_default.defaultGetHeaders(client.options),
9386
+ headers = defaults_default.defaultGetHeaders(client.options, {
9387
+ format
9388
+ }),
9314
9389
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
9315
9390
  if (typeof deviceId !== "string" || !deviceId.length) {
9316
9391
  throw new _ErrorInfo2("First argument to DeviceRegistrations#get must be a deviceId string or DeviceDetails", 4e4, 400);
@@ -9326,7 +9401,9 @@ var ably = {exports: {}};
9326
9401
  var client = _this29.client,
9327
9402
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9328
9403
  envelope = _this29.client.http.supportsLinkHeaders ? void 0 : format,
9329
- headers = defaults_default.defaultGetHeaders(client.options);
9404
+ headers = defaults_default.defaultGetHeaders(client.options, {
9405
+ format
9406
+ });
9330
9407
  _mixin(headers, client.options.headers);
9331
9408
  return new paginatedresource_default(client, "/push/deviceRegistrations", headers, envelope, /*#__PURE__*/function () {
9332
9409
  var _ref3 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9342,7 +9419,10 @@ var ably = {exports: {}};
9342
9419
  var _this30 = this;
9343
9420
  return _asyncToGenerator(function* () {
9344
9421
  var client = _this30.client,
9345
- headers = defaults_default.defaultGetHeaders(client.options),
9422
+ format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9423
+ headers = defaults_default.defaultGetHeaders(client.options, {
9424
+ format
9425
+ }),
9346
9426
  params = {},
9347
9427
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
9348
9428
  if (typeof deviceId !== "string" || !deviceId.length) {
@@ -9383,7 +9463,9 @@ var ably = {exports: {}};
9383
9463
  var client = _this32.client;
9384
9464
  var body = pushchannelsubscription_default.fromValues(subscription);
9385
9465
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9386
- headers = defaults_default.defaultPostHeaders(client.options),
9466
+ headers = defaults_default.defaultPostHeaders(client.options, {
9467
+ format
9468
+ }),
9387
9469
  params = {};
9388
9470
  _mixin(headers, client.options.headers);
9389
9471
  if (client.options.pushFullWait) _mixin(params, {
@@ -9400,7 +9482,9 @@ var ably = {exports: {}};
9400
9482
  var client = _this33.client,
9401
9483
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9402
9484
  envelope = _this33.client.http.supportsLinkHeaders ? void 0 : format,
9403
- headers = defaults_default.defaultGetHeaders(client.options);
9485
+ headers = defaults_default.defaultGetHeaders(client.options, {
9486
+ format
9487
+ });
9404
9488
  _mixin(headers, client.options.headers);
9405
9489
  return new paginatedresource_default(client, "/push/channelSubscriptions", headers, envelope, /*#__PURE__*/function () {
9406
9490
  var _ref4 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9433,7 +9517,9 @@ var ably = {exports: {}};
9433
9517
  var client = _this35.client,
9434
9518
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9435
9519
  envelope = _this35.client.http.supportsLinkHeaders ? void 0 : format,
9436
- headers = defaults_default.defaultGetHeaders(client.options);
9520
+ headers = defaults_default.defaultGetHeaders(client.options, {
9521
+ format
9522
+ });
9437
9523
  _mixin(headers, client.options.headers);
9438
9524
  if (client.options.pushFullWait) _mixin(params, {
9439
9525
  fullWait: "true"
@@ -9596,7 +9682,9 @@ var ably = {exports: {}};
9596
9682
  var client = _this38.channel.client,
9597
9683
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9598
9684
  envelope = _this38.channel.client.http.supportsLinkHeaders ? void 0 : format,
9599
- headers = defaults_default.defaultGetHeaders(client.options);
9685
+ headers = defaults_default.defaultGetHeaders(client.options, {
9686
+ format
9687
+ });
9600
9688
  _mixin(headers, client.options.headers);
9601
9689
  return new paginatedresource_default(client, _this38.channel.client.rest.presenceMixin.basePath(_this38), headers, envelope, /*#__PURE__*/function () {
9602
9690
  var _ref6 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9720,21 +9808,6 @@ var ably = {exports: {}};
9720
9808
  } else if (!this.annotations.summary) {
9721
9809
  this.annotations.summary = {};
9722
9810
  }
9723
- if (this.annotations && this.annotations.summary) {
9724
- for (var [type, summaryEntry] of Object.entries(this.annotations.summary)) {
9725
- if (type.endsWith(":distinct.v1") || type.endsWith(":unique.v1") || type.endsWith(":multiple.v1")) {
9726
- for (var [, entry] of Object.entries(summaryEntry)) {
9727
- if (!entry.clipped) {
9728
- entry.clipped = false;
9729
- }
9730
- }
9731
- } else if (type.endsWith(":flag.v1")) {
9732
- if (!summaryEntry.clipped) {
9733
- summaryEntry.clipped = false;
9734
- }
9735
- }
9736
- }
9737
- }
9738
9811
  }
9739
9812
  encode(options) {
9740
9813
  var _this40 = this;
@@ -9884,7 +9957,9 @@ var ably = {exports: {}};
9884
9957
  options = client.options,
9885
9958
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9886
9959
  idempotentRestPublishing = client.options.idempotentRestPublishing,
9887
- headers = defaults_default.defaultPostHeaders(client.options);
9960
+ headers = defaults_default.defaultPostHeaders(client.options, {
9961
+ format
9962
+ });
9888
9963
  _mixin(headers, options.headers);
9889
9964
  if (idempotentRestPublishing && allEmptyIds(messages)) {
9890
9965
  var msgIdBase = yield _randomString(MSG_ID_ENTROPY_BYTES);
@@ -9913,38 +9988,6 @@ var ably = {exports: {}};
9913
9988
  return _this46.client.rest.channelMixin.status(_this46);
9914
9989
  })();
9915
9990
  }
9916
- getMessage(serialOrMessage) {
9917
- var _this47 = this;
9918
- return _asyncToGenerator(function* () {
9919
- logger_default.logAction(_this47.logger, logger_default.LOG_MICRO, "RestChannel.getMessage()", "channel = " + _this47.name);
9920
- return _this47.client.rest.channelMixin.getMessage(_this47, serialOrMessage);
9921
- })();
9922
- }
9923
- updateMessage(message, operation, params) {
9924
- var _this48 = this;
9925
- return _asyncToGenerator(function* () {
9926
- logger_default.logAction(_this48.logger, logger_default.LOG_MICRO, "RestChannel.updateMessage()", "channel = " + _this48.name);
9927
- return _this48.client.rest.channelMixin.updateDeleteMessage(_this48, {
9928
- isDelete: false
9929
- }, message, operation, params);
9930
- })();
9931
- }
9932
- deleteMessage(message, operation, params) {
9933
- var _this49 = this;
9934
- return _asyncToGenerator(function* () {
9935
- logger_default.logAction(_this49.logger, logger_default.LOG_MICRO, "RestChannel.deleteMessage()", "channel = " + _this49.name);
9936
- return _this49.client.rest.channelMixin.updateDeleteMessage(_this49, {
9937
- isDelete: true
9938
- }, message, operation, params);
9939
- })();
9940
- }
9941
- getMessageVersions(serialOrMessage, params) {
9942
- var _this50 = this;
9943
- return _asyncToGenerator(function* () {
9944
- logger_default.logAction(_this50.logger, logger_default.LOG_MICRO, "RestChannel.getMessageVersions()", "channel = " + _this50.name);
9945
- return _this50.client.rest.channelMixin.getMessageVersions(_this50, serialOrMessage, params);
9946
- })();
9947
- }
9948
9991
  };
9949
9992
  var restchannel_default = RestChannel;
9950
9993
 
@@ -9973,7 +10016,9 @@ var ably = {exports: {}};
9973
10016
  var client = channel.client,
9974
10017
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9975
10018
  envelope = channel.client.http.supportsLinkHeaders ? void 0 : format,
9976
- headers = defaults_default.defaultGetHeaders(client.options);
10019
+ headers = defaults_default.defaultGetHeaders(client.options, {
10020
+ format
10021
+ });
9977
10022
  _mixin(headers, client.options.headers);
9978
10023
  return new paginatedresource_default(client, this.basePath(channel) + "/messages", headers, envelope, /*#__PURE__*/function () {
9979
10024
  var _ref7 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9986,81 +10031,16 @@ var ably = {exports: {}};
9986
10031
  }()).get(params);
9987
10032
  }
9988
10033
  static status(channel) {
9989
- var _this51 = this;
10034
+ var _this47 = this;
9990
10035
  return _asyncToGenerator(function* () {
9991
10036
  var format = channel.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
9992
- var headers = defaults_default.defaultPostHeaders(channel.client.options);
9993
- var response = yield resource_default.get(channel.client, _this51.basePath(channel), headers, {}, format, true);
10037
+ var headers = defaults_default.defaultPostHeaders(channel.client.options, {
10038
+ format
10039
+ });
10040
+ var response = yield resource_default.get(channel.client, _this47.basePath(channel), headers, {}, format, true);
9994
10041
  return response.body;
9995
10042
  })();
9996
10043
  }
9997
- static getMessage(channel, serialOrMessage) {
9998
- var _this52 = this;
9999
- return _asyncToGenerator(function* () {
10000
- var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
10001
- if (!serial) {
10002
- throw new _ErrorInfo2('This message lacks a serial. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
10003
- }
10004
- var client = channel.client;
10005
- var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
10006
- var headers = defaults_default.defaultGetHeaders(client.options);
10007
- _mixin(headers, client.options.headers);
10008
- var {
10009
- body,
10010
- unpacked
10011
- } = yield resource_default.get(client, _this52.basePath(channel) + "/messages/" + encodeURIComponent(serial), headers, {}, null, true);
10012
- var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10013
- return _fromEncoded2(decoded, channel);
10014
- })();
10015
- }
10016
- static updateDeleteMessage(channel, opts, message, operation, params) {
10017
- var _this53 = this;
10018
- return _asyncToGenerator(function* () {
10019
- if (!message.serial) {
10020
- throw new _ErrorInfo2('This message lacks a serial and cannot be updated. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
10021
- }
10022
- var client = channel.client;
10023
- var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
10024
- var headers = defaults_default.defaultPostHeaders(client.options);
10025
- _mixin(headers, client.options.headers);
10026
- var encoded = null;
10027
- if (message.data !== void 0) {
10028
- encoded = yield message_default.fromValues(message).encode(channel.channelOptions);
10029
- }
10030
- var req = {
10031
- serial: message.serial,
10032
- operation,
10033
- name: message.name,
10034
- data: encoded && encoded.data,
10035
- encoding: encoded && encoded.encoding,
10036
- extras: message.extras
10037
- };
10038
- var requestBody = serialize(req, client._MsgPack, format);
10039
- var method = opts.isDelete ? resource_default.post : resource_default.patch;
10040
- var pathSuffix = opts.isDelete ? "/delete" : "";
10041
- yield method(client, _this53.basePath(channel) + "/messages/" + encodeURIComponent(message.serial) + pathSuffix, requestBody, headers, params || {}, null, true);
10042
- })();
10043
- }
10044
- static getMessageVersions(channel, serialOrMessage, params) {
10045
- var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
10046
- if (!serial) {
10047
- throw new _ErrorInfo2('This message lacks a serial. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
10048
- }
10049
- var client = channel.client;
10050
- var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
10051
- var envelope = channel.client.http.supportsLinkHeaders ? void 0 : format;
10052
- var headers = defaults_default.defaultGetHeaders(client.options);
10053
- _mixin(headers, client.options.headers);
10054
- return new paginatedresource_default(client, this.basePath(channel) + "/messages/" + encodeURIComponent(serial) + "/versions", headers, envelope, /*#__PURE__*/function () {
10055
- var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
10056
- var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10057
- return _fromEncodedArray2(decoded, channel);
10058
- });
10059
- return function (_x62, _x63, _x64) {
10060
- return _ref8.apply(this, arguments);
10061
- };
10062
- }()).get(params || {});
10063
- }
10064
10044
  };
10065
10045
 
10066
10046
  // src/common/lib/client/restpresencemixin.ts
@@ -10069,20 +10049,22 @@ var ably = {exports: {}};
10069
10049
  return RestChannelMixin.basePath(presence.channel) + "/presence";
10070
10050
  }
10071
10051
  static history(presence, params) {
10072
- var _this54 = this;
10052
+ var _this48 = this;
10073
10053
  return _asyncToGenerator(function* () {
10074
10054
  var client = presence.channel.client,
10075
10055
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10076
10056
  envelope = presence.channel.client.http.supportsLinkHeaders ? void 0 : format,
10077
- headers = defaults_default.defaultGetHeaders(client.options);
10057
+ headers = defaults_default.defaultGetHeaders(client.options, {
10058
+ format
10059
+ });
10078
10060
  _mixin(headers, client.options.headers);
10079
- return new paginatedresource_default(client, _this54.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
10080
- var _ref9 = _asyncToGenerator(function* (body, headers2, unpacked) {
10061
+ return new paginatedresource_default(client, _this48.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
10062
+ var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
10081
10063
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10082
10064
  return _fromEncodedArray(decoded, presence.channel);
10083
10065
  });
10084
- return function (_x65, _x66, _x67) {
10085
- return _ref9.apply(this, arguments);
10066
+ return function (_x62, _x63, _x64) {
10067
+ return _ref8.apply(this, arguments);
10086
10068
  };
10087
10069
  }()).get(params);
10088
10070
  })();
@@ -10104,39 +10086,32 @@ var ably = {exports: {}};
10104
10086
  this.push = new push_default(this.client);
10105
10087
  }
10106
10088
  stats(params) {
10107
- var _this55 = this;
10089
+ var _this49 = this;
10108
10090
  return _asyncToGenerator(function* () {
10109
- var headers = defaults_default.defaultGetHeaders(_this55.client.options),
10110
- format = _this55.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10111
- envelope = _this55.client.http.supportsLinkHeaders ? void 0 : format;
10112
- _mixin(headers, _this55.client.options.headers);
10113
- return new paginatedresource_default(_this55.client, "/stats", headers, envelope, /*#__PURE__*/function () {
10114
- var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
10115
- var statsValues = unpacked ? body : _decodeBody(body, _this55.client._MsgPack, format);
10116
- for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
10117
- return statsValues;
10118
- });
10119
- return function (_x68, _x69, _x70) {
10120
- return _ref0.apply(this, arguments);
10121
- };
10122
- }()).get(params);
10091
+ var headers = defaults_default.defaultGetHeaders(_this49.client.options),
10092
+ format = _this49.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10093
+ envelope = _this49.client.http.supportsLinkHeaders ? void 0 : format;
10094
+ _mixin(headers, _this49.client.options.headers);
10095
+ return new paginatedresource_default(_this49.client, "/stats", headers, envelope, function (body, headers2, unpacked) {
10096
+ var statsValues = unpacked ? body : JSON.parse(body);
10097
+ for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
10098
+ return statsValues;
10099
+ }).get(params);
10123
10100
  })();
10124
10101
  }
10125
10102
  time(params) {
10126
- var _this56 = this;
10103
+ var _this50 = this;
10127
10104
  return _asyncToGenerator(function* () {
10128
- var headers = defaults_default.defaultGetHeaders(_this56.client.options, {
10129
- format: "json" /* json */
10130
- });
10131
- if (_this56.client.options.headers) _mixin(headers, _this56.client.options.headers);
10105
+ var headers = defaults_default.defaultGetHeaders(_this50.client.options);
10106
+ if (_this50.client.options.headers) _mixin(headers, _this50.client.options.headers);
10132
10107
  var timeUri = host => {
10133
- return _this56.client.baseUri(host) + "/time";
10108
+ return _this50.client.baseUri(host) + "/time";
10134
10109
  };
10135
10110
  var {
10136
10111
  error,
10137
10112
  body,
10138
10113
  unpacked
10139
- } = yield _this56.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
10114
+ } = yield _this50.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
10140
10115
  if (error) {
10141
10116
  throw error;
10142
10117
  }
@@ -10145,47 +10120,47 @@ var ably = {exports: {}};
10145
10120
  if (!time) {
10146
10121
  throw new _ErrorInfo2("Internal error (unexpected result type from GET /time)", 5e4, 500);
10147
10122
  }
10148
- _this56.client.serverTimeOffset = time - Date.now();
10123
+ _this50.client.serverTimeOffset = time - Date.now();
10149
10124
  return time;
10150
10125
  })();
10151
10126
  }
10152
10127
  request(method, path, version2, params, body, customHeaders) {
10153
- var _this57 = this;
10128
+ var _this51 = this;
10154
10129
  return _asyncToGenerator(function* () {
10155
10130
  var _a2;
10156
10131
  var [encoder, decoder, format] = (() => {
10157
- if (_this57.client.options.useBinaryProtocol) {
10158
- if (!_this57.client._MsgPack) {
10132
+ if (_this51.client.options.useBinaryProtocol) {
10133
+ if (!_this51.client._MsgPack) {
10159
10134
  _throwMissingPluginError("MsgPack");
10160
10135
  }
10161
- return [_this57.client._MsgPack.encode, _this57.client._MsgPack.decode, "msgpack" /* msgpack */];
10136
+ return [_this51.client._MsgPack.encode, _this51.client._MsgPack.decode, "msgpack" /* msgpack */];
10162
10137
  } else {
10163
10138
  return [JSON.stringify, JSON.parse, "json" /* json */];
10164
10139
  }
10165
10140
  })();
10166
- var envelope = _this57.client.http.supportsLinkHeaders ? void 0 : format;
10141
+ var envelope = _this51.client.http.supportsLinkHeaders ? void 0 : format;
10167
10142
  params = params || {};
10168
10143
  var _method = method.toLowerCase();
10169
- var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this57.client.options, {
10144
+ var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this51.client.options, {
10170
10145
  format,
10171
10146
  protocolVersion: version2
10172
- }) : defaults_default.defaultPostHeaders(_this57.client.options, {
10147
+ }) : defaults_default.defaultPostHeaders(_this51.client.options, {
10173
10148
  format,
10174
10149
  protocolVersion: version2
10175
10150
  });
10176
10151
  if (typeof body !== "string") {
10177
10152
  body = (_a2 = encoder(body)) != null ? _a2 : null;
10178
10153
  }
10179
- _mixin(headers, _this57.client.options.headers);
10154
+ _mixin(headers, _this51.client.options.headers);
10180
10155
  if (customHeaders) {
10181
10156
  _mixin(headers, customHeaders);
10182
10157
  }
10183
- var paginatedResource = new paginatedresource_default(_this57.client, path, headers, envelope, /*#__PURE__*/function () {
10184
- var _ref1 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
10158
+ var paginatedResource = new paginatedresource_default(_this51.client, path, headers, envelope, /*#__PURE__*/function () {
10159
+ var _ref9 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
10185
10160
  return _ensureArray(unpacked ? resbody : decoder(resbody));
10186
10161
  });
10187
- return function (_x71, _x72, _x73) {
10188
- return _ref1.apply(this, arguments);
10162
+ return function (_x65, _x66, _x67) {
10163
+ return _ref9.apply(this, arguments);
10189
10164
  };
10190
10165
  }(), /* useHttpPaginatedResponse: */
10191
10166
  true);
@@ -10200,7 +10175,7 @@ var ably = {exports: {}};
10200
10175
  })();
10201
10176
  }
10202
10177
  batchPublish(specOrSpecs) {
10203
- var _this58 = this;
10178
+ var _this52 = this;
10204
10179
  return _asyncToGenerator(function* () {
10205
10180
  var requestBodyDTO;
10206
10181
  var singleSpecMode;
@@ -10211,12 +10186,14 @@ var ably = {exports: {}};
10211
10186
  requestBodyDTO = [specOrSpecs];
10212
10187
  singleSpecMode = true;
10213
10188
  }
10214
- var format = _this58.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10215
- headers = defaults_default.defaultPostHeaders(_this58.client.options);
10216
- if (_this58.client.options.headers) _mixin(headers, _this58.client.options.headers);
10217
- var requestBody = _encodeBody(requestBodyDTO, _this58.client._MsgPack, format);
10218
- var response = yield resource_default.post(_this58.client, "/messages", requestBody, headers, {}, null, true);
10219
- var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this58.client._MsgPack, format);
10189
+ var format = _this52.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10190
+ headers = defaults_default.defaultPostHeaders(_this52.client.options, {
10191
+ format
10192
+ });
10193
+ if (_this52.client.options.headers) _mixin(headers, _this52.client.options.headers);
10194
+ var requestBody = _encodeBody(requestBodyDTO, _this52.client._MsgPack, format);
10195
+ var response = yield resource_default.post(_this52.client, "/messages", requestBody, headers, {}, null, true);
10196
+ var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this52.client._MsgPack, format);
10220
10197
  if (singleSpecMode) {
10221
10198
  return batchResults[0];
10222
10199
  } else {
@@ -10225,35 +10202,39 @@ var ably = {exports: {}};
10225
10202
  })();
10226
10203
  }
10227
10204
  batchPresence(channels) {
10228
- var _this59 = this;
10205
+ var _this53 = this;
10229
10206
  return _asyncToGenerator(function* () {
10230
- var format = _this59.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10231
- headers = defaults_default.defaultGetHeaders(_this59.client.options);
10232
- if (_this59.client.options.headers) _mixin(headers, _this59.client.options.headers);
10207
+ var format = _this53.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10208
+ headers = defaults_default.defaultPostHeaders(_this53.client.options, {
10209
+ format
10210
+ });
10211
+ if (_this53.client.options.headers) _mixin(headers, _this53.client.options.headers);
10233
10212
  var channelsParam = channels.join(",");
10234
- var response = yield resource_default.get(_this59.client, "/presence", headers, {
10213
+ var response = yield resource_default.get(_this53.client, "/presence", headers, {
10235
10214
  channels: channelsParam
10236
10215
  }, null, true);
10237
- return response.unpacked ? response.body : _decodeBody(response.body, _this59.client._MsgPack, format);
10216
+ return response.unpacked ? response.body : _decodeBody(response.body, _this53.client._MsgPack, format);
10238
10217
  })();
10239
10218
  }
10240
10219
  revokeTokens(specifiers, options) {
10241
- var _this60 = this;
10220
+ var _this54 = this;
10242
10221
  return _asyncToGenerator(function* () {
10243
- if (useTokenAuth(_this60.client.options)) {
10222
+ if (useTokenAuth(_this54.client.options)) {
10244
10223
  throw new _ErrorInfo2("Cannot revoke tokens when using token auth", 40162, 401);
10245
10224
  }
10246
- var keyName = _this60.client.options.keyName;
10225
+ var keyName = _this54.client.options.keyName;
10247
10226
  var resolvedOptions = options != null ? options : {};
10248
10227
  var requestBodyDTO = __spreadValues({
10249
10228
  targets: specifiers.map(specifier => "".concat(specifier.type, ":").concat(specifier.value))
10250
10229
  }, resolvedOptions);
10251
- var format = _this60.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10252
- headers = defaults_default.defaultPostHeaders(_this60.client.options);
10253
- if (_this60.client.options.headers) _mixin(headers, _this60.client.options.headers);
10254
- var requestBody = _encodeBody(requestBodyDTO, _this60.client._MsgPack, format);
10255
- var response = yield resource_default.post(_this60.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
10256
- return response.unpacked ? response.body : _decodeBody(response.body, _this60.client._MsgPack, format);
10230
+ var format = _this54.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10231
+ headers = defaults_default.defaultPostHeaders(_this54.client.options, {
10232
+ format
10233
+ });
10234
+ if (_this54.client.options.headers) _mixin(headers, _this54.client.options.headers);
10235
+ var requestBody = _encodeBody(requestBodyDTO, _this54.client._MsgPack, format);
10236
+ var response = yield resource_default.post(_this54.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
10237
+ return response.unpacked ? response.body : _decodeBody(response.body, _this54.client._MsgPack, format);
10257
10238
  })();
10258
10239
  }
10259
10240
  };
@@ -10337,7 +10318,7 @@ var ably = {exports: {}};
10337
10318
 
10338
10319
  // src/common/lib/types/annotation.ts
10339
10320
  var actions4 = ["annotation.create", "annotation.delete"];
10340
- function fromEncoded3(_x74, _x75, _x76) {
10321
+ function fromEncoded3(_x68, _x69, _x70) {
10341
10322
  return _fromEncoded8.apply(this, arguments);
10342
10323
  }
10343
10324
  function _fromEncoded8() {
@@ -10347,7 +10328,7 @@ var ably = {exports: {}};
10347
10328
  });
10348
10329
  return _fromEncoded8.apply(this, arguments);
10349
10330
  }
10350
- function fromEncodedArray3(_x77, _x78, _x79) {
10331
+ function fromEncodedArray3(_x71, _x72, _x73) {
10351
10332
  return _fromEncodedArray8.apply(this, arguments);
10352
10333
  }
10353
10334
  function _fromEncodedArray8() {
@@ -10358,7 +10339,7 @@ var ably = {exports: {}};
10358
10339
  });
10359
10340
  return _fromEncodedArray8.apply(this, arguments);
10360
10341
  }
10361
- function _fromEncoded3(_x80, _x81) {
10342
+ function _fromEncoded3(_x74, _x75) {
10362
10343
  return _fromEncoded9.apply(this, arguments);
10363
10344
  }
10364
10345
  function _fromEncoded9() {
@@ -10367,7 +10348,7 @@ var ably = {exports: {}};
10367
10348
  });
10368
10349
  return _fromEncoded9.apply(this, arguments);
10369
10350
  }
10370
- function _fromEncodedArray3(_x82, _x83) {
10351
+ function _fromEncodedArray3(_x76, _x77) {
10371
10352
  return _fromEncodedArray9.apply(this, arguments);
10372
10353
  }
10373
10354
  function _fromEncodedArray9() {
@@ -10380,10 +10361,10 @@ var ably = {exports: {}};
10380
10361
  }
10381
10362
  var Annotation = class _Annotation extends BaseMessage {
10382
10363
  encode() {
10383
- var _this61 = this;
10364
+ var _this55 = this;
10384
10365
  return _asyncToGenerator(function* () {
10385
- var res = Object.assign(new WireAnnotation(), _this61, {
10386
- action: actions4.indexOf(_this61.action || "annotation.create")
10366
+ var res = Object.assign(new WireAnnotation(), _this55, {
10367
+ action: actions4.indexOf(_this55.action || "annotation.create")
10387
10368
  });
10388
10369
  return encode(res, {});
10389
10370
  })();
@@ -10412,10 +10393,10 @@ var ably = {exports: {}};
10412
10393
  return values.map(v => _WireAnnotation.fromValues(v));
10413
10394
  }
10414
10395
  decode(channelOptions, logger) {
10415
- var _this62 = this;
10396
+ var _this56 = this;
10416
10397
  return _asyncToGenerator(function* () {
10417
- var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this62), {
10418
- action: actions4[_this62.action]
10398
+ var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this56), {
10399
+ action: actions4[_this56.action]
10419
10400
  }));
10420
10401
  try {
10421
10402
  yield decode(res, channelOptions);
@@ -10484,43 +10465,47 @@ var ably = {exports: {}};
10484
10465
  this.channel = channel;
10485
10466
  }
10486
10467
  publish(msgOrSerial, annotationValues) {
10487
- var _this63 = this;
10468
+ var _this57 = this;
10488
10469
  return _asyncToGenerator(function* () {
10489
10470
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
10490
10471
  var wireAnnotation = yield annotation.encode();
10491
- var client = _this63.channel.client,
10472
+ var client = _this57.channel.client,
10492
10473
  options = client.options,
10493
10474
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10494
- headers = defaults_default.defaultPostHeaders(client.options),
10475
+ headers = defaults_default.defaultPostHeaders(client.options, {
10476
+ format
10477
+ }),
10495
10478
  params = {};
10496
10479
  _mixin(headers, client.options.headers);
10497
10480
  var requestBody = _encodeBody([wireAnnotation], client._MsgPack, format);
10498
- yield resource_default.post(client, basePathForSerial(_this63.channel, annotation.messageSerial), requestBody, headers, params, null, true);
10481
+ yield resource_default.post(client, basePathForSerial(_this57.channel, annotation.messageSerial), requestBody, headers, params, null, true);
10499
10482
  })();
10500
10483
  }
10501
10484
  delete(msgOrSerial, annotationValues) {
10502
- var _this64 = this;
10485
+ var _this58 = this;
10503
10486
  return _asyncToGenerator(function* () {
10504
10487
  annotationValues.action = "annotation.delete";
10505
- return _this64.publish(msgOrSerial, annotationValues);
10488
+ return _this58.publish(msgOrSerial, annotationValues);
10506
10489
  })();
10507
10490
  }
10508
10491
  get(msgOrSerial, params) {
10509
- var _this65 = this;
10492
+ var _this59 = this;
10510
10493
  return _asyncToGenerator(function* () {
10511
- var client = _this65.channel.client,
10494
+ var client = _this59.channel.client,
10512
10495
  messageSerial = serialFromMsgOrSerial(msgOrSerial),
10513
10496
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10514
10497
  envelope = client.http.supportsLinkHeaders ? void 0 : format,
10515
- headers = defaults_default.defaultGetHeaders(client.options);
10498
+ headers = defaults_default.defaultGetHeaders(client.options, {
10499
+ format
10500
+ });
10516
10501
  _mixin(headers, client.options.headers);
10517
- return new paginatedresource_default(client, basePathForSerial(_this65.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
10518
- var _ref10 = _asyncToGenerator(function* (body, _, unpacked) {
10502
+ return new paginatedresource_default(client, basePathForSerial(_this59.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
10503
+ var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
10519
10504
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10520
- return _fromEncodedArray3(decoded, _this65.channel);
10505
+ return _fromEncodedArray3(decoded, _this59.channel);
10521
10506
  });
10522
- return function (_x84, _x85, _x86) {
10523
- return _ref10.apply(this, arguments);
10507
+ return function (_x78, _x79, _x80) {
10508
+ return _ref0.apply(this, arguments);
10524
10509
  };
10525
10510
  }()).get(params);
10526
10511
  })();
@@ -10691,7 +10676,7 @@ var ably = {exports: {}};
10691
10676
  this._mode = 0;
10692
10677
  this.retryCount = 0;
10693
10678
  this.history = /*#__PURE__*/function () {
10694
- var _ref11 = _asyncToGenerator(function* (params) {
10679
+ var _ref1 = _asyncToGenerator(function* (params) {
10695
10680
  logger_default.logAction(this.logger, logger_default.LOG_MICRO, "RealtimeChannel.history()", "channel = " + this.name);
10696
10681
  var restMixin = this.client.rest.channelMixin;
10697
10682
  if (params && params.untilAttach) {
@@ -10706,8 +10691,8 @@ var ably = {exports: {}};
10706
10691
  }
10707
10692
  return restMixin.history(this, params);
10708
10693
  });
10709
- return function (_x87) {
10710
- return _ref11.apply(this, arguments);
10694
+ return function (_x81) {
10695
+ return _ref1.apply(this, arguments);
10711
10696
  };
10712
10697
  }();
10713
10698
  this.whenState = state => {
@@ -10786,20 +10771,20 @@ var ably = {exports: {}};
10786
10771
  return args;
10787
10772
  }
10788
10773
  setOptions(options) {
10789
- var _this66 = this;
10774
+ var _this60 = this;
10790
10775
  return _asyncToGenerator(function* () {
10791
10776
  var _a2;
10792
- var previousChannelOptions = _this66.channelOptions;
10777
+ var previousChannelOptions = _this60.channelOptions;
10793
10778
  var err = validateChannelOptions(options);
10794
10779
  if (err) {
10795
10780
  throw err;
10796
10781
  }
10797
- _this66.channelOptions = normaliseChannelOptions((_a2 = _this66.client._Crypto) != null ? _a2 : null, _this66.logger, options);
10798
- if (_this66._decodingContext) _this66._decodingContext.channelOptions = _this66.channelOptions;
10799
- if (_this66._shouldReattachToSetOptions(options, previousChannelOptions)) {
10800
- _this66.attachImpl();
10782
+ _this60.channelOptions = normaliseChannelOptions((_a2 = _this60.client._Crypto) != null ? _a2 : null, _this60.logger, options);
10783
+ if (_this60._decodingContext) _this60._decodingContext.channelOptions = _this60.channelOptions;
10784
+ if (_this60._shouldReattachToSetOptions(options, previousChannelOptions)) {
10785
+ _this60.attachImpl();
10801
10786
  return new Promise((resolve, reject) => {
10802
- _this66._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
10787
+ _this60._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
10803
10788
  switch (this.event) {
10804
10789
  case "update":
10805
10790
  case "attached":
@@ -10836,7 +10821,7 @@ var ably = {exports: {}};
10836
10821
  }
10837
10822
  publish() {
10838
10823
  var _arguments2 = arguments,
10839
- _this67 = this;
10824
+ _this61 = this;
10840
10825
  return _asyncToGenerator(function* () {
10841
10826
  var messages;
10842
10827
  var argCount = _arguments2.length;
@@ -10854,20 +10839,20 @@ var ably = {exports: {}};
10854
10839
  data: _arguments2.length <= 1 ? undefined : _arguments2[1]
10855
10840
  })];
10856
10841
  }
10857
- var maxMessageSize = _this67.client.options.maxMessageSize;
10858
- var wireMessages = yield encodeArray(messages, _this67.channelOptions);
10842
+ var maxMessageSize = _this61.client.options.maxMessageSize;
10843
+ var wireMessages = yield encodeArray(messages, _this61.channelOptions);
10859
10844
  var size = getMessagesSize(wireMessages);
10860
10845
  if (size > maxMessageSize) {
10861
10846
  throw new _ErrorInfo2("Maximum size of messages that can be published at once exceeded (was ".concat(size, " bytes; limit is ").concat(maxMessageSize, " bytes)"), 40009, 400);
10862
10847
  }
10863
- _this67.throwIfUnpublishableState();
10864
- logger_default.logAction(_this67.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this67.state + ", message count = " + wireMessages.length);
10848
+ _this61.throwIfUnpublishableState();
10849
+ logger_default.logAction(_this61.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this61.state + ", message count = " + wireMessages.length);
10865
10850
  var pm = fromValues({
10866
10851
  action: actions.MESSAGE,
10867
- channel: _this67.name,
10852
+ channel: _this61.name,
10868
10853
  messages: wireMessages
10869
10854
  });
10870
- return _this67.sendMessage(pm);
10855
+ return _this61.sendMessage(pm);
10871
10856
  })();
10872
10857
  }
10873
10858
  throwIfUnpublishableState() {
@@ -10887,13 +10872,13 @@ var ably = {exports: {}};
10887
10872
  }
10888
10873
  }
10889
10874
  attach() {
10890
- var _this68 = this;
10875
+ var _this62 = this;
10891
10876
  return _asyncToGenerator(function* () {
10892
- if (_this68.state === "attached") {
10877
+ if (_this62.state === "attached") {
10893
10878
  return null;
10894
10879
  }
10895
10880
  return new Promise((resolve, reject) => {
10896
- _this68._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
10881
+ _this62._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
10897
10882
  });
10898
10883
  })();
10899
10884
  }
@@ -10951,25 +10936,25 @@ var ably = {exports: {}};
10951
10936
  this.sendMessage(attachMsg).catch(noop);
10952
10937
  }
10953
10938
  detach() {
10954
- var _this69 = this;
10939
+ var _this63 = this;
10955
10940
  return _asyncToGenerator(function* () {
10956
- var connectionManager = _this69.connectionManager;
10941
+ var connectionManager = _this63.connectionManager;
10957
10942
  if (!connectionManager.activeState()) {
10958
10943
  throw connectionManager.getError();
10959
10944
  }
10960
- switch (_this69.state) {
10945
+ switch (_this63.state) {
10961
10946
  case "suspended":
10962
- _this69.notifyState("detached");
10947
+ _this63.notifyState("detached");
10963
10948
  return;
10964
10949
  case "detached":
10965
10950
  return;
10966
10951
  case "failed":
10967
10952
  throw new _ErrorInfo2("Unable to detach; channel state = failed", 90001, 400);
10968
10953
  default:
10969
- _this69.requestState("detaching");
10954
+ _this63.requestState("detaching");
10970
10955
  case "detaching":
10971
10956
  return new Promise((resolve, reject) => {
10972
- _this69.once(function (stateChange) {
10957
+ _this63.once(function (stateChange) {
10973
10958
  switch (this.event) {
10974
10959
  case "detached":
10975
10960
  resolve();
@@ -10998,22 +10983,22 @@ var ably = {exports: {}};
10998
10983
  }
10999
10984
  subscribe() {
11000
10985
  var _arguments3 = arguments,
11001
- _this70 = this;
10986
+ _this64 = this;
11002
10987
  return _asyncToGenerator(function* () {
11003
10988
  for (var _len0 = _arguments3.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
11004
10989
  args[_key0] = _arguments3[_key0];
11005
10990
  }
11006
10991
  var [event, listener] = _RealtimeChannel.processListenerArgs(args);
11007
- if (_this70.state === "failed") {
11008
- throw _ErrorInfo2.fromValues(_this70.invalidStateError());
10992
+ if (_this64.state === "failed") {
10993
+ throw _ErrorInfo2.fromValues(_this64.invalidStateError());
11009
10994
  }
11010
10995
  if (event && typeof event === "object" && !Array.isArray(event)) {
11011
- _this70.client._FilteredSubscriptions.subscribeFilter(_this70, event, listener);
10996
+ _this64.client._FilteredSubscriptions.subscribeFilter(_this64, event, listener);
11012
10997
  } else {
11013
- _this70.subscriptions.on(event, listener);
10998
+ _this64.subscriptions.on(event, listener);
11014
10999
  }
11015
- if (_this70.channelOptions.attachOnSubscribe !== false) {
11016
- return _this70.attach();
11000
+ if (_this64.channelOptions.attachOnSubscribe !== false) {
11001
+ return _this64.attach();
11017
11002
  } else {
11018
11003
  return null;
11019
11004
  }
@@ -11052,10 +11037,10 @@ var ably = {exports: {}};
11052
11037
  connectionManager.send(syncMessage);
11053
11038
  }
11054
11039
  sendMessage(msg) {
11055
- var _this71 = this;
11040
+ var _this65 = this;
11056
11041
  return _asyncToGenerator(function* () {
11057
11042
  return new Promise((resolve, reject) => {
11058
- _this71.connectionManager.send(msg, _this71.client.options.queueMessages, err => {
11043
+ _this65.connectionManager.send(msg, _this65.client.options.queueMessages, err => {
11059
11044
  if (err) {
11060
11045
  reject(err);
11061
11046
  } else {
@@ -11066,14 +11051,14 @@ var ably = {exports: {}};
11066
11051
  })();
11067
11052
  }
11068
11053
  sendPresence(presence) {
11069
- var _this72 = this;
11054
+ var _this66 = this;
11070
11055
  return _asyncToGenerator(function* () {
11071
11056
  var msg = fromValues({
11072
11057
  action: actions.PRESENCE,
11073
- channel: _this72.name,
11058
+ channel: _this66.name,
11074
11059
  presence
11075
11060
  });
11076
- return _this72.sendMessage(msg);
11061
+ return _this66.sendMessage(msg);
11077
11062
  })();
11078
11063
  }
11079
11064
  sendState(objectMessages) {
@@ -11086,61 +11071,61 @@ var ably = {exports: {}};
11086
11071
  }
11087
11072
  // Access to this method is synchronised by ConnectionManager#processChannelMessage, in order to synchronise access to the state stored in _decodingContext.
11088
11073
  processMessage(message) {
11089
- var _this73 = this;
11074
+ var _this67 = this;
11090
11075
  return _asyncToGenerator(function* () {
11091
11076
  if (message.action === actions.ATTACHED || message.action === actions.MESSAGE || message.action === actions.PRESENCE || message.action === actions.OBJECT || message.action === actions.ANNOTATION) {
11092
- _this73.setChannelSerial(message.channelSerial);
11077
+ _this67.setChannelSerial(message.channelSerial);
11093
11078
  }
11094
11079
  var syncChannelSerial,
11095
11080
  isSync = false;
11096
11081
  switch (message.action) {
11097
11082
  case actions.ATTACHED:
11098
11083
  {
11099
- _this73.properties.attachSerial = message.channelSerial;
11100
- _this73._mode = message.getMode();
11101
- _this73.params = message.params || {};
11084
+ _this67.properties.attachSerial = message.channelSerial;
11085
+ _this67._mode = message.getMode();
11086
+ _this67.params = message.params || {};
11102
11087
  var modesFromFlags = message.decodeModesFromFlags();
11103
- _this73.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
11088
+ _this67.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
11104
11089
  var resumed = message.hasFlag("RESUMED");
11105
11090
  var hasPresence = message.hasFlag("HAS_PRESENCE");
11106
11091
  var hasBacklog = message.hasFlag("HAS_BACKLOG");
11107
11092
  var hasObjects = message.hasFlag("HAS_OBJECTS");
11108
- if (_this73.state === "attached") {
11093
+ if (_this67.state === "attached") {
11109
11094
  if (!resumed) {
11110
- if (_this73._presence) {
11111
- _this73._presence.onAttached(hasPresence);
11095
+ if (_this67._presence) {
11096
+ _this67._presence.onAttached(hasPresence);
11112
11097
  }
11113
- if (_this73._objects) {
11114
- _this73._objects.onAttached(hasObjects);
11098
+ if (_this67._objects) {
11099
+ _this67._objects.onAttached(hasObjects);
11115
11100
  }
11116
11101
  }
11117
- var change = new channelstatechange_default(_this73.state, _this73.state, resumed, hasBacklog, message.error);
11118
- _this73._allChannelChanges.emit("update", change);
11119
- if (!resumed || _this73.channelOptions.updateOnAttached) {
11120
- _this73.emit("update", change);
11102
+ var change = new channelstatechange_default(_this67.state, _this67.state, resumed, hasBacklog, message.error);
11103
+ _this67._allChannelChanges.emit("update", change);
11104
+ if (!resumed || _this67.channelOptions.updateOnAttached) {
11105
+ _this67.emit("update", change);
11121
11106
  }
11122
- } else if (_this73.state === "detaching") {
11123
- _this73.checkPendingState();
11107
+ } else if (_this67.state === "detaching") {
11108
+ _this67.checkPendingState();
11124
11109
  } else {
11125
- _this73.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
11110
+ _this67.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
11126
11111
  }
11127
11112
  break;
11128
11113
  }
11129
11114
  case actions.DETACHED:
11130
11115
  {
11131
11116
  var detachErr = message.error ? _ErrorInfo2.fromValues(message.error) : new _ErrorInfo2("Channel detached", 90001, 404);
11132
- if (_this73.state === "detaching") {
11133
- _this73.notifyState("detached", detachErr);
11134
- } else if (_this73.state === "attaching") {
11135
- _this73.notifyState("suspended", detachErr);
11136
- } else if (_this73.state === "attached" || _this73.state === "suspended") {
11137
- _this73.requestState("attaching", detachErr);
11117
+ if (_this67.state === "detaching") {
11118
+ _this67.notifyState("detached", detachErr);
11119
+ } else if (_this67.state === "attaching") {
11120
+ _this67.notifyState("suspended", detachErr);
11121
+ } else if (_this67.state === "attached" || _this67.state === "suspended") {
11122
+ _this67.requestState("attaching", detachErr);
11138
11123
  }
11139
11124
  break;
11140
11125
  }
11141
11126
  case actions.SYNC:
11142
11127
  isSync = true;
11143
- syncChannelSerial = _this73.syncChannelSerial = message.channelSerial;
11128
+ syncChannelSerial = _this67.syncChannelSerial = message.channelSerial;
11144
11129
  if (!message.presence) break;
11145
11130
  case actions.PRESENCE:
11146
11131
  {
@@ -11148,45 +11133,45 @@ var ably = {exports: {}};
11148
11133
  break;
11149
11134
  }
11150
11135
  populateFieldsFromParent(message);
11151
- var options = _this73.channelOptions;
11152
- if (_this73._presence) {
11136
+ var options = _this67.channelOptions;
11137
+ if (_this67._presence) {
11153
11138
  var presenceMessages = yield Promise.all(message.presence.map(wpm => {
11154
- return wpm.decode(options, _this73.logger);
11139
+ return wpm.decode(options, _this67.logger);
11155
11140
  }));
11156
- _this73._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
11141
+ _this67._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
11157
11142
  }
11158
11143
  break;
11159
11144
  }
11160
11145
  case actions.OBJECT:
11161
11146
  case actions.OBJECT_SYNC:
11162
11147
  {
11163
- if (!_this73._objects || !message.state) {
11148
+ if (!_this67._objects || !message.state) {
11164
11149
  return;
11165
11150
  }
11166
11151
  populateFieldsFromParent(message);
11167
- var format = _this73.client.connection.connectionManager.getActiveTransportFormat();
11168
- var objectMessages = message.state.map(om => om.decode(_this73.client, format));
11152
+ var format = _this67.client.connection.connectionManager.getActiveTransportFormat();
11153
+ var objectMessages = message.state.map(om => om.decode(_this67.client, format));
11169
11154
  if (message.action === actions.OBJECT) {
11170
- _this73._objects.handleObjectMessages(objectMessages);
11155
+ _this67._objects.handleObjectMessages(objectMessages);
11171
11156
  } else {
11172
- _this73._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
11157
+ _this67._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
11173
11158
  }
11174
11159
  break;
11175
11160
  }
11176
11161
  case actions.MESSAGE:
11177
11162
  {
11178
- if (_this73.state !== "attached") {
11179
- logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", 'Message "' + message.id + '" skipped as this channel "' + _this73.name + '" state is not "attached" (state is "' + _this73.state + '").');
11163
+ if (_this67.state !== "attached") {
11164
+ logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", 'Message "' + message.id + '" skipped as this channel "' + _this67.name + '" state is not "attached" (state is "' + _this67.state + '").');
11180
11165
  return;
11181
11166
  }
11182
11167
  populateFieldsFromParent(message);
11183
11168
  var encoded = message.messages,
11184
11169
  firstMessage = encoded[0],
11185
11170
  lastMessage = encoded[encoded.length - 1];
11186
- if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this73._lastPayload.messageId) {
11187
- var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this73.name + '".';
11188
- logger_default.logAction(_this73.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
11189
- _this73._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
11171
+ if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this67._lastPayload.messageId) {
11172
+ var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this67.name + '".';
11173
+ logger_default.logAction(_this67.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
11174
+ _this67._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
11190
11175
  break;
11191
11176
  }
11192
11177
  var messages = [];
@@ -11194,34 +11179,34 @@ var ably = {exports: {}};
11194
11179
  var {
11195
11180
  decoded,
11196
11181
  err
11197
- } = yield encoded[i].decodeWithErr(_this73._decodingContext, _this73.logger);
11182
+ } = yield encoded[i].decodeWithErr(_this67._decodingContext, _this67.logger);
11198
11183
  messages[i] = decoded;
11199
11184
  if (err) {
11200
11185
  switch (err.code) {
11201
11186
  case 40018:
11202
- _this73._startDecodeFailureRecovery(err);
11187
+ _this67._startDecodeFailureRecovery(err);
11203
11188
  return;
11204
11189
  case 40019:
11205
11190
  case 40021:
11206
- _this73.notifyState("failed", err);
11191
+ _this67.notifyState("failed", err);
11207
11192
  return;
11208
11193
  }
11209
11194
  }
11210
11195
  }
11211
- _this73._lastPayload.messageId = lastMessage.id;
11212
- _this73._lastPayload.protocolMessageChannelSerial = message.channelSerial;
11213
- _this73.onEvent(messages);
11196
+ _this67._lastPayload.messageId = lastMessage.id;
11197
+ _this67._lastPayload.protocolMessageChannelSerial = message.channelSerial;
11198
+ _this67.onEvent(messages);
11214
11199
  break;
11215
11200
  }
11216
11201
  case actions.ANNOTATION:
11217
11202
  {
11218
11203
  populateFieldsFromParent(message);
11219
- var _options = _this73.channelOptions;
11220
- if (_this73._annotations) {
11204
+ var _options = _this67.channelOptions;
11205
+ if (_this67._annotations) {
11221
11206
  var annotations = yield Promise.all((message.annotations || []).map(wpm => {
11222
- return wpm.decode(_options, _this73.logger);
11207
+ return wpm.decode(_options, _this67.logger);
11223
11208
  }));
11224
- _this73._annotations._processIncoming(annotations);
11209
+ _this67._annotations._processIncoming(annotations);
11225
11210
  }
11226
11211
  break;
11227
11212
  }
@@ -11229,14 +11214,14 @@ var ably = {exports: {}};
11229
11214
  {
11230
11215
  var _err = message.error;
11231
11216
  if (_err && _err.code == 80016) {
11232
- _this73.checkPendingState();
11217
+ _this67.checkPendingState();
11233
11218
  } else {
11234
- _this73.notifyState("failed", _ErrorInfo2.fromValues(_err));
11219
+ _this67.notifyState("failed", _ErrorInfo2.fromValues(_err));
11235
11220
  }
11236
11221
  break;
11237
11222
  }
11238
11223
  default:
11239
- logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
11224
+ logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
11240
11225
  }
11241
11226
  })();
11242
11227
  }
@@ -11392,45 +11377,9 @@ var ably = {exports: {}};
11392
11377
  }
11393
11378
  }
11394
11379
  status() {
11395
- var _this74 = this;
11396
- return _asyncToGenerator(function* () {
11397
- return _this74.client.rest.channelMixin.status(_this74);
11398
- })();
11399
- }
11400
- getMessage(serialOrMessage) {
11401
- var _this75 = this;
11402
- return _asyncToGenerator(function* () {
11403
- logger_default.logAction(_this75.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessage()", "channel = " + _this75.name);
11404
- var restMixin = _this75.client.rest.channelMixin;
11405
- return restMixin.getMessage(_this75, serialOrMessage);
11406
- })();
11407
- }
11408
- updateMessage(message, operation, params) {
11409
- var _this76 = this;
11410
- return _asyncToGenerator(function* () {
11411
- logger_default.logAction(_this76.logger, logger_default.LOG_MICRO, "RealtimeChannel.updateMessage()", "channel = " + _this76.name);
11412
- var restMixin = _this76.client.rest.channelMixin;
11413
- return restMixin.updateDeleteMessage(_this76, {
11414
- isDelete: false
11415
- }, message, operation, params);
11416
- })();
11417
- }
11418
- deleteMessage(message, operation, params) {
11419
- var _this77 = this;
11420
- return _asyncToGenerator(function* () {
11421
- logger_default.logAction(_this77.logger, logger_default.LOG_MICRO, "RealtimeChannel.deleteMessage()", "channel = " + _this77.name);
11422
- var restMixin = _this77.client.rest.channelMixin;
11423
- return restMixin.updateDeleteMessage(_this77, {
11424
- isDelete: true
11425
- }, message, operation, params);
11426
- })();
11427
- }
11428
- getMessageVersions(serialOrMessage, params) {
11429
- var _this78 = this;
11380
+ var _this68 = this;
11430
11381
  return _asyncToGenerator(function* () {
11431
- logger_default.logAction(_this78.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessageVersions()", "channel = " + _this78.name);
11432
- var restMixin = _this78.client.rest.channelMixin;
11433
- return restMixin.getMessageVersions(_this78, serialOrMessage, params);
11382
+ return _this68.client.rest.channelMixin.status(_this68);
11434
11383
  })();
11435
11384
  }
11436
11385
  };
@@ -11449,31 +11398,31 @@ var ably = {exports: {}};
11449
11398
  this.subscriptions = new eventemitter_default(this.logger);
11450
11399
  }
11451
11400
  publish(msgOrSerial, annotationValues) {
11452
- var _this79 = this;
11401
+ var _this69 = this;
11453
11402
  return _asyncToGenerator(function* () {
11454
- var channelName = _this79.channel.name;
11403
+ var channelName = _this69.channel.name;
11455
11404
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
11456
11405
  var wireAnnotation = yield annotation.encode();
11457
- _this79.channel.throwIfUnpublishableState();
11458
- logger_default.logAction(_this79.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
11406
+ _this69.channel.throwIfUnpublishableState();
11407
+ logger_default.logAction(_this69.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
11459
11408
  var pm = fromValues({
11460
11409
  action: actions.ANNOTATION,
11461
11410
  channel: channelName,
11462
11411
  annotations: [wireAnnotation]
11463
11412
  });
11464
- return _this79.channel.sendMessage(pm);
11413
+ return _this69.channel.sendMessage(pm);
11465
11414
  })();
11466
11415
  }
11467
11416
  delete(msgOrSerial, annotationValues) {
11468
- var _this80 = this;
11417
+ var _this70 = this;
11469
11418
  return _asyncToGenerator(function* () {
11470
11419
  annotationValues.action = "annotation.delete";
11471
- return _this80.publish(msgOrSerial, annotationValues);
11420
+ return _this70.publish(msgOrSerial, annotationValues);
11472
11421
  })();
11473
11422
  }
11474
11423
  subscribe() {
11475
11424
  var _arguments4 = arguments,
11476
- _this81 = this;
11425
+ _this71 = this;
11477
11426
  return _asyncToGenerator(function* () {
11478
11427
  for (var _len10 = _arguments4.length, _args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
11479
11428
  _args[_key10] = _arguments4[_key10];
@@ -11481,15 +11430,15 @@ var ably = {exports: {}};
11481
11430
  var args = realtimechannel_default.processListenerArgs(_args);
11482
11431
  var event = args[0];
11483
11432
  var listener = args[1];
11484
- var channel = _this81.channel;
11433
+ var channel = _this71.channel;
11485
11434
  if (channel.state === "failed") {
11486
11435
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
11487
11436
  }
11488
- _this81.subscriptions.on(event, listener);
11489
- if (_this81.channel.channelOptions.attachOnSubscribe !== false) {
11437
+ _this71.subscriptions.on(event, listener);
11438
+ if (_this71.channel.channelOptions.attachOnSubscribe !== false) {
11490
11439
  yield channel.attach();
11491
11440
  }
11492
- if ((_this81.channel.state === "attached" && _this81.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
11441
+ if ((_this71.channel.state === "attached" && _this71.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
11493
11442
  throw new _ErrorInfo2("You are trying to add an annotation listener, but you haven't requested the annotation_subscribe channel mode in ChannelOptions, so this won't do anything (we only deliver annotations to clients who have explicitly requested them)", 93001, 400);
11494
11443
  }
11495
11444
  })();
@@ -11509,9 +11458,9 @@ var ably = {exports: {}};
11509
11458
  }
11510
11459
  }
11511
11460
  get(msgOrSerial, params) {
11512
- var _this82 = this;
11461
+ var _this72 = this;
11513
11462
  return _asyncToGenerator(function* () {
11514
- return restannotations_default.prototype.get.call(_this82, msgOrSerial, params);
11463
+ return restannotations_default.prototype.get.call(_this72, msgOrSerial, params);
11515
11464
  })();
11516
11465
  }
11517
11466
  };
@@ -13173,23 +13122,23 @@ var ably = {exports: {}};
13173
13122
  }
13174
13123
  }
13175
13124
  processChannelMessage(message) {
13176
- var _this83 = this;
13125
+ var _this73 = this;
13177
13126
  return _asyncToGenerator(function* () {
13178
- yield _this83.realtime.channels.processChannelMessage(message);
13127
+ yield _this73.realtime.channels.processChannelMessage(message);
13179
13128
  })();
13180
13129
  }
13181
13130
  ping() {
13182
- var _this84 = this;
13131
+ var _this74 = this;
13183
13132
  return _asyncToGenerator(function* () {
13184
13133
  var _a2;
13185
- if (_this84.state.state !== "connected") {
13134
+ if (_this74.state.state !== "connected") {
13186
13135
  throw new _ErrorInfo2("Unable to ping service; not connected", 4e4, 400);
13187
13136
  }
13188
- var transport = (_a2 = _this84.activeProtocol) == null ? void 0 : _a2.getTransport();
13137
+ var transport = (_a2 = _this74.activeProtocol) == null ? void 0 : _a2.getTransport();
13189
13138
  if (!transport) {
13190
- throw _this84.getStateError();
13139
+ throw _this74.getStateError();
13191
13140
  }
13192
- logger_default.logAction(_this84.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
13141
+ logger_default.logAction(_this74.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
13193
13142
  var pingStart = Date.now();
13194
13143
  var id = _cheapRandStr();
13195
13144
  return _withTimeoutAsync(new Promise(resolve => {
@@ -13201,7 +13150,7 @@ var ably = {exports: {}};
13201
13150
  };
13202
13151
  transport.on("heartbeat", onHeartbeat);
13203
13152
  transport.ping(id);
13204
- }), _this84.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
13153
+ }), _this74.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
13205
13154
  })();
13206
13155
  }
13207
13156
  abort(error) {
@@ -13350,10 +13299,10 @@ var ably = {exports: {}};
13350
13299
  });
13351
13300
  }
13352
13301
  ping() {
13353
- var _this85 = this;
13302
+ var _this75 = this;
13354
13303
  return _asyncToGenerator(function* () {
13355
- logger_default.logAction(_this85.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
13356
- return _this85.connectionManager.ping();
13304
+ logger_default.logAction(_this75.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
13305
+ return _this75.connectionManager.ping();
13357
13306
  })();
13358
13307
  }
13359
13308
  close() {
@@ -13409,9 +13358,6 @@ var ably = {exports: {}};
13409
13358
  get channels() {
13410
13359
  return this._channels;
13411
13360
  }
13412
- get clientId() {
13413
- return this.auth.clientId;
13414
- }
13415
13361
  connect() {
13416
13362
  logger_default.logAction(this.logger, logger_default.LOG_MINOR, "Realtime.connect()", "");
13417
13363
  this.connection.connect();
@@ -13452,16 +13398,16 @@ var ably = {exports: {}};
13452
13398
  }
13453
13399
  // Access to this method is synchronised by ConnectionManager#processChannelMessage.
13454
13400
  processChannelMessage(msg) {
13455
- var _this86 = this;
13401
+ var _this76 = this;
13456
13402
  return _asyncToGenerator(function* () {
13457
13403
  var channelName = msg.channel;
13458
13404
  if (channelName === void 0) {
13459
- logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
13405
+ logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
13460
13406
  return;
13461
13407
  }
13462
- var channel = _this86.all[channelName];
13408
+ var channel = _this76.all[channelName];
13463
13409
  if (!channel) {
13464
- logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
13410
+ logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
13465
13411
  return;
13466
13412
  }
13467
13413
  yield channel.processMessage(msg);
@@ -13716,43 +13662,43 @@ var ably = {exports: {}};
13716
13662
  this.pendingPresence = [];
13717
13663
  }
13718
13664
  enter(data) {
13719
- var _this87 = this;
13665
+ var _this77 = this;
13720
13666
  return _asyncToGenerator(function* () {
13721
- if (isAnonymousOrWildcard(_this87)) {
13667
+ if (isAnonymousOrWildcard(_this77)) {
13722
13668
  throw new _ErrorInfo2("clientId must be specified to enter a presence channel", 40012, 400);
13723
13669
  }
13724
- return _this87._enterOrUpdateClient(void 0, void 0, data, "enter");
13670
+ return _this77._enterOrUpdateClient(void 0, void 0, data, "enter");
13725
13671
  })();
13726
13672
  }
13727
13673
  update(data) {
13728
- var _this88 = this;
13674
+ var _this78 = this;
13729
13675
  return _asyncToGenerator(function* () {
13730
- if (isAnonymousOrWildcard(_this88)) {
13676
+ if (isAnonymousOrWildcard(_this78)) {
13731
13677
  throw new _ErrorInfo2("clientId must be specified to update presence data", 40012, 400);
13732
13678
  }
13733
- return _this88._enterOrUpdateClient(void 0, void 0, data, "update");
13679
+ return _this78._enterOrUpdateClient(void 0, void 0, data, "update");
13734
13680
  })();
13735
13681
  }
13736
13682
  enterClient(clientId, data) {
13737
- var _this89 = this;
13683
+ var _this79 = this;
13738
13684
  return _asyncToGenerator(function* () {
13739
- return _this89._enterOrUpdateClient(void 0, clientId, data, "enter");
13685
+ return _this79._enterOrUpdateClient(void 0, clientId, data, "enter");
13740
13686
  })();
13741
13687
  }
13742
13688
  updateClient(clientId, data) {
13743
- var _this90 = this;
13689
+ var _this80 = this;
13744
13690
  return _asyncToGenerator(function* () {
13745
- return _this90._enterOrUpdateClient(void 0, clientId, data, "update");
13691
+ return _this80._enterOrUpdateClient(void 0, clientId, data, "update");
13746
13692
  })();
13747
13693
  }
13748
13694
  _enterOrUpdateClient(id, clientId, data, action) {
13749
- var _this91 = this;
13695
+ var _this81 = this;
13750
13696
  return _asyncToGenerator(function* () {
13751
- var channel = _this91.channel;
13697
+ var channel = _this81.channel;
13752
13698
  if (!channel.connectionManager.activeState()) {
13753
13699
  throw channel.connectionManager.getError();
13754
13700
  }
13755
- logger_default.logAction(_this91.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this91)));
13701
+ logger_default.logAction(_this81.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this81)));
13756
13702
  var presence = presencemessage_default.fromData(data);
13757
13703
  presence.action = action;
13758
13704
  if (id) {
@@ -13770,7 +13716,7 @@ var ably = {exports: {}};
13770
13716
  channel.attach();
13771
13717
  case "attaching":
13772
13718
  return new Promise((resolve, reject) => {
13773
- _this91.pendingPresence.push({
13719
+ _this81.pendingPresence.push({
13774
13720
  presence: wirePresMsg,
13775
13721
  callback: err => err ? reject(err) : resolve()
13776
13722
  });
@@ -13785,22 +13731,22 @@ var ably = {exports: {}};
13785
13731
  })();
13786
13732
  }
13787
13733
  leave(data) {
13788
- var _this92 = this;
13734
+ var _this82 = this;
13789
13735
  return _asyncToGenerator(function* () {
13790
- if (isAnonymousOrWildcard(_this92)) {
13736
+ if (isAnonymousOrWildcard(_this82)) {
13791
13737
  throw new _ErrorInfo2("clientId must have been specified to enter or leave a presence channel", 40012, 400);
13792
13738
  }
13793
- return _this92.leaveClient(void 0, data);
13739
+ return _this82.leaveClient(void 0, data);
13794
13740
  })();
13795
13741
  }
13796
13742
  leaveClient(clientId, data) {
13797
- var _this93 = this;
13743
+ var _this83 = this;
13798
13744
  return _asyncToGenerator(function* () {
13799
- var channel = _this93.channel;
13745
+ var channel = _this83.channel;
13800
13746
  if (!channel.connectionManager.activeState()) {
13801
13747
  throw channel.connectionManager.getError();
13802
13748
  }
13803
- logger_default.logAction(_this93.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this93.channel.name + ", client = " + clientId);
13749
+ logger_default.logAction(_this83.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this83.channel.name + ", client = " + clientId);
13804
13750
  var presence = presencemessage_default.fromData(data);
13805
13751
  presence.action = "leave";
13806
13752
  if (clientId) {
@@ -13812,7 +13758,7 @@ var ably = {exports: {}};
13812
13758
  return channel.sendPresence([wirePresMsg]);
13813
13759
  case "attaching":
13814
13760
  return new Promise((resolve, reject) => {
13815
- _this93.pendingPresence.push({
13761
+ _this83.pendingPresence.push({
13816
13762
  presence: wirePresMsg,
13817
13763
  callback: err => err ? reject(err) : resolve()
13818
13764
  });
@@ -13828,14 +13774,14 @@ var ably = {exports: {}};
13828
13774
  })();
13829
13775
  }
13830
13776
  get(params) {
13831
- var _this94 = this;
13777
+ var _this84 = this;
13832
13778
  return _asyncToGenerator(function* () {
13833
13779
  var waitForSync = !params || ("waitForSync" in params ? params.waitForSync : true);
13834
13780
  return new Promise((resolve, reject) => {
13835
13781
  function returnMembers(members) {
13836
13782
  resolve(params ? members.list(params) : members.values());
13837
13783
  }
13838
- if (_this94.channel.state === "suspended") {
13784
+ if (_this84.channel.state === "suspended") {
13839
13785
  if (waitForSync) {
13840
13786
  reject(_ErrorInfo2.fromValues({
13841
13787
  statusCode: 400,
@@ -13843,12 +13789,12 @@ var ably = {exports: {}};
13843
13789
  message: "Presence state is out of sync due to channel being in the SUSPENDED state"
13844
13790
  }));
13845
13791
  } else {
13846
- returnMembers(_this94.members);
13792
+ returnMembers(_this84.members);
13847
13793
  }
13848
13794
  return;
13849
13795
  }
13850
- waitAttached(_this94.channel, err => reject(err), () => {
13851
- var members = _this94.members;
13796
+ waitAttached(_this84.channel, err => reject(err), () => {
13797
+ var members = _this84.members;
13852
13798
  if (waitForSync) {
13853
13799
  members.waitSync(function () {
13854
13800
  returnMembers(members);
@@ -13861,19 +13807,19 @@ var ably = {exports: {}};
13861
13807
  })();
13862
13808
  }
13863
13809
  history(params) {
13864
- var _this95 = this;
13810
+ var _this85 = this;
13865
13811
  return _asyncToGenerator(function* () {
13866
- logger_default.logAction(_this95.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this95.name);
13867
- var restMixin = _this95.channel.client.rest.presenceMixin;
13812
+ logger_default.logAction(_this85.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this85.name);
13813
+ var restMixin = _this85.channel.client.rest.presenceMixin;
13868
13814
  if (params && params.untilAttach) {
13869
- if (_this95.channel.state === "attached") {
13815
+ if (_this85.channel.state === "attached") {
13870
13816
  delete params.untilAttach;
13871
- params.from_serial = _this95.channel.properties.attachSerial;
13817
+ params.from_serial = _this85.channel.properties.attachSerial;
13872
13818
  } else {
13873
- throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this95.channel.state, 4e4, 400);
13819
+ throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this85.channel.state, 4e4, 400);
13874
13820
  }
13875
13821
  }
13876
- return restMixin.history(_this95, params);
13822
+ return restMixin.history(_this85, params);
13877
13823
  })();
13878
13824
  }
13879
13825
  setPresence(presenceSet, isSync, syncChannelSerial) {
@@ -14001,7 +13947,7 @@ var ably = {exports: {}};
14001
13947
  }
14002
13948
  subscribe() {
14003
13949
  var _arguments5 = arguments,
14004
- _this96 = this;
13950
+ _this86 = this;
14005
13951
  return _asyncToGenerator(function* () {
14006
13952
  for (var _len12 = _arguments5.length, _args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
14007
13953
  _args[_key12] = _arguments5[_key12];
@@ -14009,11 +13955,11 @@ var ably = {exports: {}};
14009
13955
  var args = realtimechannel_default.processListenerArgs(_args);
14010
13956
  var event = args[0];
14011
13957
  var listener = args[1];
14012
- var channel = _this96.channel;
13958
+ var channel = _this86.channel;
14013
13959
  if (channel.state === "failed") {
14014
13960
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
14015
13961
  }
14016
- _this96.subscriptions.on(event, listener);
13962
+ _this86.subscriptions.on(event, listener);
14017
13963
  if (channel.channelOptions.attachOnSubscribe !== false) {
14018
13964
  yield channel.attach();
14019
13965
  }
@@ -14185,8 +14131,8 @@ var ably = {exports: {}};
14185
14131
  isRef: !!((_f = (_e = m.extras) == null ? void 0 : _e.ref) == null ? void 0 : _f.timeserial),
14186
14132
  clientId: m.clientId
14187
14133
  };
14188
- if (Object.entries(filter).find(_ref12 => {
14189
- var [key, value] = _ref12;
14134
+ if (Object.entries(filter).find(_ref10 => {
14135
+ var [key, value] = _ref10;
14190
14136
  return value !== void 0 ? mapping[key] !== value : false;
14191
14137
  })) {
14192
14138
  return;
@@ -14214,8 +14160,8 @@ var ably = {exports: {}};
14214
14160
  return [];
14215
14161
  }
14216
14162
  if (!realListener && filter) {
14217
- return Array.from(channel.filteredSubscriptions.entries()).map(_ref13 => {
14218
- var [key, filterMaps] = _ref13;
14163
+ return Array.from(channel.filteredSubscriptions.entries()).map(_ref11 => {
14164
+ var [key, filterMaps] = _ref11;
14219
14165
  var _a2;
14220
14166
  var listenerMaps = filterMaps.get(filter);
14221
14167
  filterMaps.delete(filter);
@@ -14687,38 +14633,38 @@ var ably = {exports: {}};
14687
14633
  return output;
14688
14634
  }
14689
14635
  encrypt(plaintext) {
14690
- var _this97 = this;
14636
+ var _this87 = this;
14691
14637
  return _asyncToGenerator(function* () {
14692
- logger_default.logAction(_this97.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
14693
- var iv = yield _this97.getIv();
14694
- var cryptoKey = yield crypto.subtle.importKey("raw", _this97.key, _this97.webCryptoAlgorithm, false, ["encrypt"]);
14638
+ logger_default.logAction(_this87.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
14639
+ var iv = yield _this87.getIv();
14640
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this87.key, _this87.webCryptoAlgorithm, false, ["encrypt"]);
14695
14641
  var ciphertext = yield crypto.subtle.encrypt({
14696
- name: _this97.webCryptoAlgorithm,
14642
+ name: _this87.webCryptoAlgorithm,
14697
14643
  iv
14698
14644
  }, cryptoKey, plaintext);
14699
- return _this97.concat(iv, ciphertext);
14645
+ return _this87.concat(iv, ciphertext);
14700
14646
  })();
14701
14647
  }
14702
14648
  decrypt(ciphertext) {
14703
- var _this98 = this;
14649
+ var _this88 = this;
14704
14650
  return _asyncToGenerator(function* () {
14705
- logger_default.logAction(_this98.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
14651
+ logger_default.logAction(_this88.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
14706
14652
  var ciphertextArrayBuffer = bufferUtils.toArrayBuffer(ciphertext);
14707
14653
  var iv = ciphertextArrayBuffer.slice(0, DEFAULT_BLOCKLENGTH);
14708
14654
  var ciphertextBody = ciphertextArrayBuffer.slice(DEFAULT_BLOCKLENGTH);
14709
- var cryptoKey = yield crypto.subtle.importKey("raw", _this98.key, _this98.webCryptoAlgorithm, false, ["decrypt"]);
14655
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this88.key, _this88.webCryptoAlgorithm, false, ["decrypt"]);
14710
14656
  return crypto.subtle.decrypt({
14711
- name: _this98.webCryptoAlgorithm,
14657
+ name: _this88.webCryptoAlgorithm,
14712
14658
  iv
14713
14659
  }, cryptoKey, ciphertextBody);
14714
14660
  })();
14715
14661
  }
14716
14662
  getIv() {
14717
- var _this99 = this;
14663
+ var _this89 = this;
14718
14664
  return _asyncToGenerator(function* () {
14719
- if (_this99.iv) {
14720
- var iv = _this99.iv;
14721
- _this99.iv = null;
14665
+ if (_this89.iv) {
14666
+ var iv = _this89.iv;
14667
+ _this89.iv = null;
14722
14668
  return iv;
14723
14669
  }
14724
14670
  var randomBlock = yield config.getRandomArrayBuffer(DEFAULT_BLOCKLENGTH);
@@ -14765,7 +14711,7 @@ var ably = {exports: {}};
14765
14711
  if (Platform.Config.xhrSupported && xhrRequestImplementation) {
14766
14712
  this.supportsAuthHeaders = true;
14767
14713
  this.Request = /*#__PURE__*/function () {
14768
- var _ref14 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14714
+ var _ref12 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14769
14715
  return new Promise(resolve => {
14770
14716
  var _a3;
14771
14717
  var req = xhrRequestImplementation.createRequest(uri, headers, params, body, XHRStates_default.REQ_SEND, (_a3 = client && client.options.timeouts) != null ? _a3 : null, this.logger, method);
@@ -14779,8 +14725,8 @@ var ably = {exports: {}};
14779
14725
  req.exec();
14780
14726
  });
14781
14727
  });
14782
- return function (_x88, _x89, _x90, _x91, _x92) {
14783
- return _ref14.apply(this, arguments);
14728
+ return function (_x82, _x83, _x84, _x85, _x86) {
14729
+ return _ref12.apply(this, arguments);
14784
14730
  };
14785
14731
  }();
14786
14732
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -14805,11 +14751,11 @@ var ably = {exports: {}};
14805
14751
  } else if (Platform.Config.fetchSupported && fetchRequestImplementation) {
14806
14752
  this.supportsAuthHeaders = true;
14807
14753
  this.Request = /*#__PURE__*/function () {
14808
- var _ref17 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14754
+ var _ref15 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14809
14755
  return fetchRequestImplementation(method, client != null ? client : null, uri, headers, params, body);
14810
14756
  });
14811
- return function (_x93, _x94, _x95, _x96, _x97) {
14812
- return _ref17.apply(this, arguments);
14757
+ return function (_x87, _x88, _x89, _x90, _x91) {
14758
+ return _ref15.apply(this, arguments);
14813
14759
  };
14814
14760
  }();
14815
14761
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -14840,14 +14786,14 @@ var ably = {exports: {}};
14840
14786
  return (_b = (_a2 = this.client) == null ? void 0 : _a2.logger) != null ? _b : logger_default.defaultLogger;
14841
14787
  }
14842
14788
  doUri(method, uri, headers, body, params) {
14843
- var _this100 = this;
14789
+ var _this90 = this;
14844
14790
  return _asyncToGenerator(function* () {
14845
- if (!_this100.Request) {
14791
+ if (!_this90.Request) {
14846
14792
  return {
14847
14793
  error: new PartialErrorInfo("Request invoked before assigned to", null, 500)
14848
14794
  };
14849
14795
  }
14850
- return _this100.Request(method, uri, headers, params, body);
14796
+ return _this90.Request(method, uri, headers, params, body);
14851
14797
  })();
14852
14798
  }
14853
14799
  shouldFallback(errorInfo) {
@@ -14977,7 +14923,7 @@ var ably = {exports: {}};
14977
14923
  globalObject4.crypto.getRandomValues(byteArray);
14978
14924
  return byteArray.buffer;
14979
14925
  });
14980
- function getRandomArrayBuffer(_x98) {
14926
+ function getRandomArrayBuffer(_x92) {
14981
14927
  return _getRandomArrayBuffer.apply(this, arguments);
14982
14928
  }
14983
14929
  return getRandomArrayBuffer;
@@ -16122,7 +16068,7 @@ var ably = {exports: {}};
16122
16068
  });
16123
16069
  return result;
16124
16070
  }
16125
- function fetchRequest(_x99, _x100, _x101, _x102, _x103, _x104) {
16071
+ function fetchRequest(_x93, _x94, _x95, _x96, _x97, _x98) {
16126
16072
  return _fetchRequest.apply(this, arguments);
16127
16073
  } // src/platform/web/lib/http/request/index.ts
16128
16074
  function _fetchRequest() {
@@ -16253,7 +16199,7 @@ var ably = {exports: {}};
16253
16199
  })(ably);
16254
16200
 
16255
16201
  class ClientAblyService {
16256
- static startConnection(sessionId, ablyToken, onMessageReceived, tenantId) {
16202
+ static startConnection(sessionId, ablyToken, onMessageReceived, tenantId, onActionReceived) {
16257
16203
  var _this = this;
16258
16204
  return _asyncToGenerator(function* () {
16259
16205
  // Prevent multiple connections
@@ -16317,6 +16263,8 @@ class ClientAblyService {
16317
16263
  }
16318
16264
  }, 10000);
16319
16265
  });
16266
+ // Store optional action handler for this connection
16267
+ _this.onActionReceived = onActionReceived !== null && onActionReceived !== void 0 ? onActionReceived : null;
16320
16268
  // Subscribe to the session room
16321
16269
  yield _this.joinChannel(sessionId, onMessageReceived, tenantId);
16322
16270
  } catch (error) {
@@ -16352,13 +16300,15 @@ class ClientAblyService {
16352
16300
  });
16353
16301
  // Subscribe to assistant/system responses
16354
16302
  _this2.channel.subscribe('ReceiveMessage', message => {
16355
- var _a, _b, _c, _d, _e, _f, _g, _h;
16303
+ var _a, _b;
16356
16304
  try {
16357
16305
  // Ensure messageContent is always a string (default to empty string if undefined)
16358
- var messageContent = typeof message.data === 'string' ? message.data : (_d = (_b = (_a = message.data) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : (_c = message.data) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : '';
16359
- var senderType = ((_e = message.data) === null || _e === void 0 ? void 0 : _e.senderType) || 3; // Assistant
16360
- var needsAgent = ((_f = message.data) === null || _f === void 0 ? void 0 : _f.needsAgent) || ((_g = message.data) === null || _g === void 0 ? void 0 : _g.actionType) == 'needs_agent' || false;
16361
- var attachments = ((_h = message.data) === null || _h === void 0 ? void 0 : _h.attachments) || [];
16306
+ var rawData = message.data;
16307
+ var messageContent = typeof rawData === 'string' ? rawData : (_b = (_a = rawData === null || rawData === void 0 ? void 0 : rawData.content) !== null && _a !== void 0 ? _a : rawData === null || rawData === void 0 ? void 0 : rawData.message) !== null && _b !== void 0 ? _b : '';
16308
+ var senderType = (rawData === null || rawData === void 0 ? void 0 : rawData.senderType) || 3; // Assistant
16309
+ var needsAgent = (rawData === null || rawData === void 0 ? void 0 : rawData.needsAgent) || (rawData === null || rawData === void 0 ? void 0 : rawData.actionType) == 'needs_agent' || false;
16310
+ var attachments = (rawData === null || rawData === void 0 ? void 0 : rawData.attachments) || [];
16311
+ var actionType = rawData && typeof rawData.actionType === 'string' ? rawData.actionType : '';
16362
16312
  // Extract downloadUrl from attachments (Ably now returns downloadUrl directly)
16363
16313
  // Attachments can be: strings (URLs), objects with downloadUrl, or objects with id
16364
16314
  var attachmentUrls = attachments.map(attachment => {
@@ -16375,6 +16325,18 @@ class ClientAblyService {
16375
16325
  // If it's an object with id, we'll need to keep it for backward compatibility
16376
16326
  return null;
16377
16327
  }).filter(url => url !== null);
16328
+ // Invoke optional action handler first (non-blocking for message processing)
16329
+ if (_this2.onActionReceived && actionType !== undefined) {
16330
+ try {
16331
+ void _this2.onActionReceived(actionType, rawData);
16332
+ } catch (actionError) {
16333
+ console.error('[AblyService] Error in action handler callback', {
16334
+ error: actionError,
16335
+ actionType,
16336
+ rawData
16337
+ });
16338
+ }
16339
+ }
16378
16340
  onMessageReceived(messageContent, senderType, needsAgent, attachmentUrls);
16379
16341
  } catch (error) {
16380
16342
  console.error('[AblyService] Error processing message', {
@@ -16409,6 +16371,7 @@ class ClientAblyService {
16409
16371
  }
16410
16372
  _this3.isConnected = false;
16411
16373
  _this3.sessionId = null;
16374
+ _this3.onActionReceived = null;
16412
16375
  } catch (error) {
16413
16376
  console.error('[AblyService] Error in stopConnection', {
16414
16377
  error
@@ -16458,6 +16421,7 @@ ClientAblyService.channel = null;
16458
16421
  ClientAblyService.isConnected = false;
16459
16422
  ClientAblyService.sessionId = null;
16460
16423
  ClientAblyService.messageUnsubscribe = null;
16424
+ ClientAblyService.onActionReceived = null;
16461
16425
 
16462
16426
  var _excluded$e = ["title", "titleId"];
16463
16427
  var SvgClose = (_ref, ref) => {
@@ -39739,6 +39703,7 @@ var HelpCenterContent = _ref => {
39739
39703
  var [needsAgent, setNeedsAgent] = React.useState(false);
39740
39704
  var [assistantStatus, setAssistantStatus] = React.useState('idle');
39741
39705
  var [isReviewDialogOpen, setIsReviewDialogOpen] = React.useState(false);
39706
+ var actionHandler = useActionHandler();
39742
39707
  var handleTogglePopup = () => {
39743
39708
  setIsOpen(!isOpen);
39744
39709
  setShowArrowAnimation(isOpen);
@@ -39765,37 +39730,32 @@ var HelpCenterContent = _ref => {
39765
39730
  });
39766
39731
  setAssistantStatus('idle');
39767
39732
  };
39768
- var handleEndChat = /*#__PURE__*/function () {
39769
- var _ref2 = _asyncToGenerator(function* () {
39770
- if (!sessionId || !selectedOption) return;
39771
- try {
39772
- yield ClientAblyService.stopConnection();
39773
- setIsAblyConnected(false);
39774
- setAssistantStatus('idle');
39775
- var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
39776
- language: language
39777
- });
39778
- if (!response.ok) throw new Error('Failed to close chat session');
39779
- // Store sessionId for review before clearing the main sessionId
39780
- setReviewSessionId(sessionId);
39781
- // Clear the sessionId after successfully closing the session
39782
- setSessionId(null);
39783
- setSelectedOption(null);
39784
- setMessages([]);
39785
- setIsReviewDialogOpen(true);
39786
- } catch (error) {
39787
- setError('Failed to end chat session');
39788
- setAssistantStatus('idle');
39789
- // Even if there's an error, clear the session state to prevent stuck state
39790
- setReviewSessionId(sessionId);
39791
- setSessionId(null);
39792
- setSelectedOption(null);
39793
- }
39794
- });
39795
- return function handleEndChat() {
39796
- return _ref2.apply(this, arguments);
39797
- };
39798
- }();
39733
+ var handleEndChat = React.useCallback(/*#__PURE__*/_asyncToGenerator(function* () {
39734
+ if (!sessionId || !selectedOption) return;
39735
+ try {
39736
+ yield ClientAblyService.stopConnection();
39737
+ setIsAblyConnected(false);
39738
+ setAssistantStatus('idle');
39739
+ var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
39740
+ language: language
39741
+ });
39742
+ if (!response.ok) throw new Error('Failed to close chat session');
39743
+ // Store sessionId for review before clearing the main sessionId
39744
+ setReviewSessionId(sessionId);
39745
+ // Clear the sessionId after successfully closing the session
39746
+ setSessionId(null);
39747
+ setSelectedOption(null);
39748
+ setMessages([]);
39749
+ setIsReviewDialogOpen(true);
39750
+ } catch (error) {
39751
+ setError('Failed to end chat session');
39752
+ setAssistantStatus('idle');
39753
+ // Even if there's an error, clear the session state to prevent stuck state
39754
+ setReviewSessionId(sessionId);
39755
+ setSessionId(null);
39756
+ setSelectedOption(null);
39757
+ }
39758
+ }), [language, selectedOption, sessionId]);
39799
39759
  var handleSendChatReview = /*#__PURE__*/function () {
39800
39760
  var _ref4 = _asyncToGenerator(function* (_ref3) {
39801
39761
  var {
@@ -39866,7 +39826,9 @@ var HelpCenterContent = _ref => {
39866
39826
  var responseData = yield response.json();
39867
39827
  var newSessionId = responseData.chatSession.id;
39868
39828
  setSessionId(newSessionId);
39869
- yield ClientAblyService.startConnection(newSessionId, responseData.ablyToken, handleReceiveMessage, responseData.chatSession.tenantId);
39829
+ yield ClientAblyService.startConnection(newSessionId, responseData.ablyToken, handleReceiveMessage, responseData.chatSession.tenantId, (actionType, messageData) => {
39830
+ void actionHandler.handleAction(actionType, messageData);
39831
+ });
39870
39832
  // Verify the connection is actually active
39871
39833
  if (!ClientAblyService.isConnectionActive()) {
39872
39834
  throw new Error('Ably connection failed to establish properly');
@@ -39963,6 +39925,22 @@ var HelpCenterContent = _ref => {
39963
39925
  return _ref8.apply(this, arguments);
39964
39926
  };
39965
39927
  }();
39928
+ // Register known action handlers for realtime messages
39929
+ React.useEffect(() => {
39930
+ // "needs_agent" → trigger handoff / needs agent UI flow
39931
+ actionHandler.registerHandler('needs_agent', () => {
39932
+ setNeedsAgent(true);
39933
+ });
39934
+ // "end_session" → gracefully close the chat session and show review dialog
39935
+ actionHandler.registerHandler('end_session', () => {
39936
+ // Reuse existing end chat logic
39937
+ void handleEndChat();
39938
+ });
39939
+ return () => {
39940
+ actionHandler.unregisterHandler('needs_agent');
39941
+ actionHandler.unregisterHandler('end_session');
39942
+ };
39943
+ }, [actionHandler, handleEndChat]);
39966
39944
  React.useEffect(() => {
39967
39945
  if (isOpen && helpScreenId) {
39968
39946
  setStatus('loading');