@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.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { createContext, useContext, forwardRef, createElement, useMemo, useState, useEffect, useRef, useCallback } from 'react';
3
+ import React__default, { createContext, useContext, useRef, useCallback, forwardRef, createElement, useMemo, useState, useEffect } from 'react';
4
4
 
5
5
  function _OverloadYield(e, d) {
6
6
  this.v = e, this.k = d;
@@ -3580,6 +3580,77 @@ function darkenColor(color, amount) {
3580
3580
  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);
3581
3581
  }
3582
3582
 
3583
+ var useActionHandler = () => {
3584
+ var handlersRef = useRef(new Map());
3585
+ var defaultHandlerRef = useRef(messageData => {
3586
+ var _a;
3587
+ var message = (_a = messageData) !== null && _a !== void 0 ? _a : {};
3588
+ var actionType = message.actionType || '';
3589
+ if (actionType) {
3590
+ // Log unknown actions for debugging but do not crash
3591
+ // eslint-disable-next-line no-console
3592
+ console.warn("[ActionHandler] Unknown action type received: \"".concat(actionType, "\". Message data:"), messageData);
3593
+ }
3594
+ });
3595
+ var registerHandler = useCallback((actionType, handler) => {
3596
+ if (!actionType) {
3597
+ // eslint-disable-next-line no-console
3598
+ console.warn('[ActionHandler] Attempted to register handler with empty action type. Ignored.');
3599
+ return;
3600
+ }
3601
+ if (handlersRef.current.has(actionType)) {
3602
+ // eslint-disable-next-line no-console
3603
+ console.warn("[ActionHandler] Handler for action type \"".concat(actionType, "\" already exists. Overwriting with new handler."));
3604
+ }
3605
+ handlersRef.current.set(actionType, handler);
3606
+ }, []);
3607
+ var unregisterHandler = useCallback(actionType => {
3608
+ if (!actionType) {
3609
+ return;
3610
+ }
3611
+ handlersRef.current.delete(actionType);
3612
+ }, []);
3613
+ var handleAction = useCallback(/*#__PURE__*/function () {
3614
+ var _ref = _asyncToGenerator(function* (actionType, messageData) {
3615
+ // Ignore empty, null, or undefined action types (no-op)
3616
+ if (!actionType || actionType === '') {
3617
+ return;
3618
+ }
3619
+ var handler = handlersRef.current.get(actionType);
3620
+ if (handler) {
3621
+ try {
3622
+ yield handler(messageData);
3623
+ } catch (error) {
3624
+ // eslint-disable-next-line no-console
3625
+ console.error("[ActionHandler] Error executing handler for action type \"".concat(actionType, "\":"), error);
3626
+ }
3627
+ return;
3628
+ }
3629
+ var defaultHandler = defaultHandlerRef.current;
3630
+ if (defaultHandler) {
3631
+ try {
3632
+ yield Promise.resolve(defaultHandler(messageData));
3633
+ } catch (error) {
3634
+ // eslint-disable-next-line no-console
3635
+ console.error("[ActionHandler] Error executing default handler for unknown action type \"".concat(actionType, "\":"), error);
3636
+ }
3637
+ }
3638
+ });
3639
+ return function (_x, _x2) {
3640
+ return _ref.apply(this, arguments);
3641
+ };
3642
+ }(), []);
3643
+ var getRegisteredActions = useCallback(() => {
3644
+ return Array.from(handlersRef.current.keys());
3645
+ }, []);
3646
+ return {
3647
+ registerHandler,
3648
+ unregisterHandler,
3649
+ handleAction,
3650
+ getRegisteredActions
3651
+ };
3652
+ };
3653
+
3583
3654
  /**
3584
3655
  * @license @tabler/icons-react v3.35.0 - MIT
3585
3656
  *
@@ -6962,7 +7033,7 @@ var ably = {exports: {}};
6962
7033
  });
6963
7034
  return _withTimeoutAsync2.apply(this, arguments);
6964
7035
  }
6965
- var version = "2.15.0";
7036
+ var version = "2.13.0";
6966
7037
 
6967
7038
  // src/common/lib/util/defaults.ts
6968
7039
  var agent = "ably-js/" + version;
@@ -7210,10 +7281,10 @@ var ably = {exports: {}};
7210
7281
  };
7211
7282
  function defaultGetHeaders(options) {
7212
7283
  var {
7213
- format,
7284
+ format = defaultHeadersOptions.format,
7214
7285
  protocolVersion = defaultHeadersOptions.protocolVersion
7215
7286
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7216
- var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
7287
+ var accept = contentTypes[format];
7217
7288
  return {
7218
7289
  accept,
7219
7290
  "X-Ably-Version": protocolVersion.toString(),
@@ -7222,11 +7293,11 @@ var ably = {exports: {}};
7222
7293
  }
7223
7294
  function defaultPostHeaders(options) {
7224
7295
  var {
7225
- format,
7296
+ format = defaultHeadersOptions.format,
7226
7297
  protocolVersion = defaultHeadersOptions.protocolVersion
7227
7298
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7228
- var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
7229
- var contentType = accept;
7299
+ var contentType;
7300
+ var accept = contentType = contentTypes[format];
7230
7301
  return {
7231
7302
  accept,
7232
7303
  "content-type": contentType,
@@ -7550,9 +7621,7 @@ var ably = {exports: {}};
7550
7621
  tokenUri = function tokenUri(host) {
7551
7622
  return client.baseUri(host) + path;
7552
7623
  };
7553
- var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options, {
7554
- format: "json" /* json */
7555
- });
7624
+ var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options);
7556
7625
  if (resolvedAuthOptions.requestHeaders) _mixin(requestHeaders, resolvedAuthOptions.requestHeaders);
7557
7626
  logger_default.logAction(_this3.logger, logger_default.LOG_MICRO, "Auth.requestToken().requestToken", "Sending POST to " + path + "; Token params: " + JSON.stringify(signedTokenParams));
7558
7627
  _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));
@@ -9244,7 +9313,9 @@ var ably = {exports: {}};
9244
9313
  return _asyncToGenerator(function* () {
9245
9314
  var client = _this26.client;
9246
9315
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9247
- headers = defaults_default.defaultPostHeaders(client.options),
9316
+ headers = defaults_default.defaultPostHeaders(client.options, {
9317
+ format
9318
+ }),
9248
9319
  params = {};
9249
9320
  var body = _mixin({
9250
9321
  recipient
@@ -9268,7 +9339,9 @@ var ably = {exports: {}};
9268
9339
  var client = _this27.client;
9269
9340
  var body = devicedetails_default.fromValues(device);
9270
9341
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9271
- headers = defaults_default.defaultPostHeaders(client.options),
9342
+ headers = defaults_default.defaultPostHeaders(client.options, {
9343
+ format
9344
+ }),
9272
9345
  params = {};
9273
9346
  _mixin(headers, client.options.headers);
9274
9347
  if (client.options.pushFullWait) _mixin(params, {
@@ -9284,7 +9357,9 @@ var ably = {exports: {}};
9284
9357
  return _asyncToGenerator(function* () {
9285
9358
  var client = _this28.client,
9286
9359
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9287
- headers = defaults_default.defaultGetHeaders(client.options),
9360
+ headers = defaults_default.defaultGetHeaders(client.options, {
9361
+ format
9362
+ }),
9288
9363
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
9289
9364
  if (typeof deviceId !== "string" || !deviceId.length) {
9290
9365
  throw new _ErrorInfo2("First argument to DeviceRegistrations#get must be a deviceId string or DeviceDetails", 4e4, 400);
@@ -9300,7 +9375,9 @@ var ably = {exports: {}};
9300
9375
  var client = _this29.client,
9301
9376
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9302
9377
  envelope = _this29.client.http.supportsLinkHeaders ? void 0 : format,
9303
- headers = defaults_default.defaultGetHeaders(client.options);
9378
+ headers = defaults_default.defaultGetHeaders(client.options, {
9379
+ format
9380
+ });
9304
9381
  _mixin(headers, client.options.headers);
9305
9382
  return new paginatedresource_default(client, "/push/deviceRegistrations", headers, envelope, /*#__PURE__*/function () {
9306
9383
  var _ref3 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9316,7 +9393,10 @@ var ably = {exports: {}};
9316
9393
  var _this30 = this;
9317
9394
  return _asyncToGenerator(function* () {
9318
9395
  var client = _this30.client,
9319
- headers = defaults_default.defaultGetHeaders(client.options),
9396
+ format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9397
+ headers = defaults_default.defaultGetHeaders(client.options, {
9398
+ format
9399
+ }),
9320
9400
  params = {},
9321
9401
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
9322
9402
  if (typeof deviceId !== "string" || !deviceId.length) {
@@ -9357,7 +9437,9 @@ var ably = {exports: {}};
9357
9437
  var client = _this32.client;
9358
9438
  var body = pushchannelsubscription_default.fromValues(subscription);
9359
9439
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9360
- headers = defaults_default.defaultPostHeaders(client.options),
9440
+ headers = defaults_default.defaultPostHeaders(client.options, {
9441
+ format
9442
+ }),
9361
9443
  params = {};
9362
9444
  _mixin(headers, client.options.headers);
9363
9445
  if (client.options.pushFullWait) _mixin(params, {
@@ -9374,7 +9456,9 @@ var ably = {exports: {}};
9374
9456
  var client = _this33.client,
9375
9457
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9376
9458
  envelope = _this33.client.http.supportsLinkHeaders ? void 0 : format,
9377
- headers = defaults_default.defaultGetHeaders(client.options);
9459
+ headers = defaults_default.defaultGetHeaders(client.options, {
9460
+ format
9461
+ });
9378
9462
  _mixin(headers, client.options.headers);
9379
9463
  return new paginatedresource_default(client, "/push/channelSubscriptions", headers, envelope, /*#__PURE__*/function () {
9380
9464
  var _ref4 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9407,7 +9491,9 @@ var ably = {exports: {}};
9407
9491
  var client = _this35.client,
9408
9492
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9409
9493
  envelope = _this35.client.http.supportsLinkHeaders ? void 0 : format,
9410
- headers = defaults_default.defaultGetHeaders(client.options);
9494
+ headers = defaults_default.defaultGetHeaders(client.options, {
9495
+ format
9496
+ });
9411
9497
  _mixin(headers, client.options.headers);
9412
9498
  if (client.options.pushFullWait) _mixin(params, {
9413
9499
  fullWait: "true"
@@ -9570,7 +9656,9 @@ var ably = {exports: {}};
9570
9656
  var client = _this38.channel.client,
9571
9657
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9572
9658
  envelope = _this38.channel.client.http.supportsLinkHeaders ? void 0 : format,
9573
- headers = defaults_default.defaultGetHeaders(client.options);
9659
+ headers = defaults_default.defaultGetHeaders(client.options, {
9660
+ format
9661
+ });
9574
9662
  _mixin(headers, client.options.headers);
9575
9663
  return new paginatedresource_default(client, _this38.channel.client.rest.presenceMixin.basePath(_this38), headers, envelope, /*#__PURE__*/function () {
9576
9664
  var _ref6 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9694,21 +9782,6 @@ var ably = {exports: {}};
9694
9782
  } else if (!this.annotations.summary) {
9695
9783
  this.annotations.summary = {};
9696
9784
  }
9697
- if (this.annotations && this.annotations.summary) {
9698
- for (var [type, summaryEntry] of Object.entries(this.annotations.summary)) {
9699
- if (type.endsWith(":distinct.v1") || type.endsWith(":unique.v1") || type.endsWith(":multiple.v1")) {
9700
- for (var [, entry] of Object.entries(summaryEntry)) {
9701
- if (!entry.clipped) {
9702
- entry.clipped = false;
9703
- }
9704
- }
9705
- } else if (type.endsWith(":flag.v1")) {
9706
- if (!summaryEntry.clipped) {
9707
- summaryEntry.clipped = false;
9708
- }
9709
- }
9710
- }
9711
- }
9712
9785
  }
9713
9786
  encode(options) {
9714
9787
  var _this40 = this;
@@ -9858,7 +9931,9 @@ var ably = {exports: {}};
9858
9931
  options = client.options,
9859
9932
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9860
9933
  idempotentRestPublishing = client.options.idempotentRestPublishing,
9861
- headers = defaults_default.defaultPostHeaders(client.options);
9934
+ headers = defaults_default.defaultPostHeaders(client.options, {
9935
+ format
9936
+ });
9862
9937
  _mixin(headers, options.headers);
9863
9938
  if (idempotentRestPublishing && allEmptyIds(messages)) {
9864
9939
  var msgIdBase = yield _randomString(MSG_ID_ENTROPY_BYTES);
@@ -9887,38 +9962,6 @@ var ably = {exports: {}};
9887
9962
  return _this46.client.rest.channelMixin.status(_this46);
9888
9963
  })();
9889
9964
  }
9890
- getMessage(serialOrMessage) {
9891
- var _this47 = this;
9892
- return _asyncToGenerator(function* () {
9893
- logger_default.logAction(_this47.logger, logger_default.LOG_MICRO, "RestChannel.getMessage()", "channel = " + _this47.name);
9894
- return _this47.client.rest.channelMixin.getMessage(_this47, serialOrMessage);
9895
- })();
9896
- }
9897
- updateMessage(message, operation, params) {
9898
- var _this48 = this;
9899
- return _asyncToGenerator(function* () {
9900
- logger_default.logAction(_this48.logger, logger_default.LOG_MICRO, "RestChannel.updateMessage()", "channel = " + _this48.name);
9901
- return _this48.client.rest.channelMixin.updateDeleteMessage(_this48, {
9902
- isDelete: false
9903
- }, message, operation, params);
9904
- })();
9905
- }
9906
- deleteMessage(message, operation, params) {
9907
- var _this49 = this;
9908
- return _asyncToGenerator(function* () {
9909
- logger_default.logAction(_this49.logger, logger_default.LOG_MICRO, "RestChannel.deleteMessage()", "channel = " + _this49.name);
9910
- return _this49.client.rest.channelMixin.updateDeleteMessage(_this49, {
9911
- isDelete: true
9912
- }, message, operation, params);
9913
- })();
9914
- }
9915
- getMessageVersions(serialOrMessage, params) {
9916
- var _this50 = this;
9917
- return _asyncToGenerator(function* () {
9918
- logger_default.logAction(_this50.logger, logger_default.LOG_MICRO, "RestChannel.getMessageVersions()", "channel = " + _this50.name);
9919
- return _this50.client.rest.channelMixin.getMessageVersions(_this50, serialOrMessage, params);
9920
- })();
9921
- }
9922
9965
  };
9923
9966
  var restchannel_default = RestChannel;
9924
9967
 
@@ -9947,7 +9990,9 @@ var ably = {exports: {}};
9947
9990
  var client = channel.client,
9948
9991
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9949
9992
  envelope = channel.client.http.supportsLinkHeaders ? void 0 : format,
9950
- headers = defaults_default.defaultGetHeaders(client.options);
9993
+ headers = defaults_default.defaultGetHeaders(client.options, {
9994
+ format
9995
+ });
9951
9996
  _mixin(headers, client.options.headers);
9952
9997
  return new paginatedresource_default(client, this.basePath(channel) + "/messages", headers, envelope, /*#__PURE__*/function () {
9953
9998
  var _ref7 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9960,81 +10005,16 @@ var ably = {exports: {}};
9960
10005
  }()).get(params);
9961
10006
  }
9962
10007
  static status(channel) {
9963
- var _this51 = this;
10008
+ var _this47 = this;
9964
10009
  return _asyncToGenerator(function* () {
9965
10010
  var format = channel.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
9966
- var headers = defaults_default.defaultPostHeaders(channel.client.options);
9967
- var response = yield resource_default.get(channel.client, _this51.basePath(channel), headers, {}, format, true);
10011
+ var headers = defaults_default.defaultPostHeaders(channel.client.options, {
10012
+ format
10013
+ });
10014
+ var response = yield resource_default.get(channel.client, _this47.basePath(channel), headers, {}, format, true);
9968
10015
  return response.body;
9969
10016
  })();
9970
10017
  }
9971
- static getMessage(channel, serialOrMessage) {
9972
- var _this52 = this;
9973
- return _asyncToGenerator(function* () {
9974
- var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
9975
- if (!serial) {
9976
- 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);
9977
- }
9978
- var client = channel.client;
9979
- var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
9980
- var headers = defaults_default.defaultGetHeaders(client.options);
9981
- _mixin(headers, client.options.headers);
9982
- var {
9983
- body,
9984
- unpacked
9985
- } = yield resource_default.get(client, _this52.basePath(channel) + "/messages/" + encodeURIComponent(serial), headers, {}, null, true);
9986
- var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
9987
- return _fromEncoded2(decoded, channel);
9988
- })();
9989
- }
9990
- static updateDeleteMessage(channel, opts, message, operation, params) {
9991
- var _this53 = this;
9992
- return _asyncToGenerator(function* () {
9993
- if (!message.serial) {
9994
- 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);
9995
- }
9996
- var client = channel.client;
9997
- var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
9998
- var headers = defaults_default.defaultPostHeaders(client.options);
9999
- _mixin(headers, client.options.headers);
10000
- var encoded = null;
10001
- if (message.data !== void 0) {
10002
- encoded = yield message_default.fromValues(message).encode(channel.channelOptions);
10003
- }
10004
- var req = {
10005
- serial: message.serial,
10006
- operation,
10007
- name: message.name,
10008
- data: encoded && encoded.data,
10009
- encoding: encoded && encoded.encoding,
10010
- extras: message.extras
10011
- };
10012
- var requestBody = serialize(req, client._MsgPack, format);
10013
- var method = opts.isDelete ? resource_default.post : resource_default.patch;
10014
- var pathSuffix = opts.isDelete ? "/delete" : "";
10015
- yield method(client, _this53.basePath(channel) + "/messages/" + encodeURIComponent(message.serial) + pathSuffix, requestBody, headers, params || {}, null, true);
10016
- })();
10017
- }
10018
- static getMessageVersions(channel, serialOrMessage, params) {
10019
- var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
10020
- if (!serial) {
10021
- 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);
10022
- }
10023
- var client = channel.client;
10024
- var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
10025
- var envelope = channel.client.http.supportsLinkHeaders ? void 0 : format;
10026
- var headers = defaults_default.defaultGetHeaders(client.options);
10027
- _mixin(headers, client.options.headers);
10028
- return new paginatedresource_default(client, this.basePath(channel) + "/messages/" + encodeURIComponent(serial) + "/versions", headers, envelope, /*#__PURE__*/function () {
10029
- var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
10030
- var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10031
- return _fromEncodedArray2(decoded, channel);
10032
- });
10033
- return function (_x62, _x63, _x64) {
10034
- return _ref8.apply(this, arguments);
10035
- };
10036
- }()).get(params || {});
10037
- }
10038
10018
  };
10039
10019
 
10040
10020
  // src/common/lib/client/restpresencemixin.ts
@@ -10043,20 +10023,22 @@ var ably = {exports: {}};
10043
10023
  return RestChannelMixin.basePath(presence.channel) + "/presence";
10044
10024
  }
10045
10025
  static history(presence, params) {
10046
- var _this54 = this;
10026
+ var _this48 = this;
10047
10027
  return _asyncToGenerator(function* () {
10048
10028
  var client = presence.channel.client,
10049
10029
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10050
10030
  envelope = presence.channel.client.http.supportsLinkHeaders ? void 0 : format,
10051
- headers = defaults_default.defaultGetHeaders(client.options);
10031
+ headers = defaults_default.defaultGetHeaders(client.options, {
10032
+ format
10033
+ });
10052
10034
  _mixin(headers, client.options.headers);
10053
- return new paginatedresource_default(client, _this54.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
10054
- var _ref9 = _asyncToGenerator(function* (body, headers2, unpacked) {
10035
+ return new paginatedresource_default(client, _this48.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
10036
+ var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
10055
10037
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10056
10038
  return _fromEncodedArray(decoded, presence.channel);
10057
10039
  });
10058
- return function (_x65, _x66, _x67) {
10059
- return _ref9.apply(this, arguments);
10040
+ return function (_x62, _x63, _x64) {
10041
+ return _ref8.apply(this, arguments);
10060
10042
  };
10061
10043
  }()).get(params);
10062
10044
  })();
@@ -10078,39 +10060,32 @@ var ably = {exports: {}};
10078
10060
  this.push = new push_default(this.client);
10079
10061
  }
10080
10062
  stats(params) {
10081
- var _this55 = this;
10063
+ var _this49 = this;
10082
10064
  return _asyncToGenerator(function* () {
10083
- var headers = defaults_default.defaultGetHeaders(_this55.client.options),
10084
- format = _this55.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10085
- envelope = _this55.client.http.supportsLinkHeaders ? void 0 : format;
10086
- _mixin(headers, _this55.client.options.headers);
10087
- return new paginatedresource_default(_this55.client, "/stats", headers, envelope, /*#__PURE__*/function () {
10088
- var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
10089
- var statsValues = unpacked ? body : _decodeBody(body, _this55.client._MsgPack, format);
10090
- for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
10091
- return statsValues;
10092
- });
10093
- return function (_x68, _x69, _x70) {
10094
- return _ref0.apply(this, arguments);
10095
- };
10096
- }()).get(params);
10065
+ var headers = defaults_default.defaultGetHeaders(_this49.client.options),
10066
+ format = _this49.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10067
+ envelope = _this49.client.http.supportsLinkHeaders ? void 0 : format;
10068
+ _mixin(headers, _this49.client.options.headers);
10069
+ return new paginatedresource_default(_this49.client, "/stats", headers, envelope, function (body, headers2, unpacked) {
10070
+ var statsValues = unpacked ? body : JSON.parse(body);
10071
+ for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
10072
+ return statsValues;
10073
+ }).get(params);
10097
10074
  })();
10098
10075
  }
10099
10076
  time(params) {
10100
- var _this56 = this;
10077
+ var _this50 = this;
10101
10078
  return _asyncToGenerator(function* () {
10102
- var headers = defaults_default.defaultGetHeaders(_this56.client.options, {
10103
- format: "json" /* json */
10104
- });
10105
- if (_this56.client.options.headers) _mixin(headers, _this56.client.options.headers);
10079
+ var headers = defaults_default.defaultGetHeaders(_this50.client.options);
10080
+ if (_this50.client.options.headers) _mixin(headers, _this50.client.options.headers);
10106
10081
  var timeUri = host => {
10107
- return _this56.client.baseUri(host) + "/time";
10082
+ return _this50.client.baseUri(host) + "/time";
10108
10083
  };
10109
10084
  var {
10110
10085
  error,
10111
10086
  body,
10112
10087
  unpacked
10113
- } = yield _this56.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
10088
+ } = yield _this50.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
10114
10089
  if (error) {
10115
10090
  throw error;
10116
10091
  }
@@ -10119,47 +10094,47 @@ var ably = {exports: {}};
10119
10094
  if (!time) {
10120
10095
  throw new _ErrorInfo2("Internal error (unexpected result type from GET /time)", 5e4, 500);
10121
10096
  }
10122
- _this56.client.serverTimeOffset = time - Date.now();
10097
+ _this50.client.serverTimeOffset = time - Date.now();
10123
10098
  return time;
10124
10099
  })();
10125
10100
  }
10126
10101
  request(method, path, version2, params, body, customHeaders) {
10127
- var _this57 = this;
10102
+ var _this51 = this;
10128
10103
  return _asyncToGenerator(function* () {
10129
10104
  var _a2;
10130
10105
  var [encoder, decoder, format] = (() => {
10131
- if (_this57.client.options.useBinaryProtocol) {
10132
- if (!_this57.client._MsgPack) {
10106
+ if (_this51.client.options.useBinaryProtocol) {
10107
+ if (!_this51.client._MsgPack) {
10133
10108
  _throwMissingPluginError("MsgPack");
10134
10109
  }
10135
- return [_this57.client._MsgPack.encode, _this57.client._MsgPack.decode, "msgpack" /* msgpack */];
10110
+ return [_this51.client._MsgPack.encode, _this51.client._MsgPack.decode, "msgpack" /* msgpack */];
10136
10111
  } else {
10137
10112
  return [JSON.stringify, JSON.parse, "json" /* json */];
10138
10113
  }
10139
10114
  })();
10140
- var envelope = _this57.client.http.supportsLinkHeaders ? void 0 : format;
10115
+ var envelope = _this51.client.http.supportsLinkHeaders ? void 0 : format;
10141
10116
  params = params || {};
10142
10117
  var _method = method.toLowerCase();
10143
- var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this57.client.options, {
10118
+ var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this51.client.options, {
10144
10119
  format,
10145
10120
  protocolVersion: version2
10146
- }) : defaults_default.defaultPostHeaders(_this57.client.options, {
10121
+ }) : defaults_default.defaultPostHeaders(_this51.client.options, {
10147
10122
  format,
10148
10123
  protocolVersion: version2
10149
10124
  });
10150
10125
  if (typeof body !== "string") {
10151
10126
  body = (_a2 = encoder(body)) != null ? _a2 : null;
10152
10127
  }
10153
- _mixin(headers, _this57.client.options.headers);
10128
+ _mixin(headers, _this51.client.options.headers);
10154
10129
  if (customHeaders) {
10155
10130
  _mixin(headers, customHeaders);
10156
10131
  }
10157
- var paginatedResource = new paginatedresource_default(_this57.client, path, headers, envelope, /*#__PURE__*/function () {
10158
- var _ref1 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
10132
+ var paginatedResource = new paginatedresource_default(_this51.client, path, headers, envelope, /*#__PURE__*/function () {
10133
+ var _ref9 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
10159
10134
  return _ensureArray(unpacked ? resbody : decoder(resbody));
10160
10135
  });
10161
- return function (_x71, _x72, _x73) {
10162
- return _ref1.apply(this, arguments);
10136
+ return function (_x65, _x66, _x67) {
10137
+ return _ref9.apply(this, arguments);
10163
10138
  };
10164
10139
  }(), /* useHttpPaginatedResponse: */
10165
10140
  true);
@@ -10174,7 +10149,7 @@ var ably = {exports: {}};
10174
10149
  })();
10175
10150
  }
10176
10151
  batchPublish(specOrSpecs) {
10177
- var _this58 = this;
10152
+ var _this52 = this;
10178
10153
  return _asyncToGenerator(function* () {
10179
10154
  var requestBodyDTO;
10180
10155
  var singleSpecMode;
@@ -10185,12 +10160,14 @@ var ably = {exports: {}};
10185
10160
  requestBodyDTO = [specOrSpecs];
10186
10161
  singleSpecMode = true;
10187
10162
  }
10188
- var format = _this58.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10189
- headers = defaults_default.defaultPostHeaders(_this58.client.options);
10190
- if (_this58.client.options.headers) _mixin(headers, _this58.client.options.headers);
10191
- var requestBody = _encodeBody(requestBodyDTO, _this58.client._MsgPack, format);
10192
- var response = yield resource_default.post(_this58.client, "/messages", requestBody, headers, {}, null, true);
10193
- var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this58.client._MsgPack, format);
10163
+ var format = _this52.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10164
+ headers = defaults_default.defaultPostHeaders(_this52.client.options, {
10165
+ format
10166
+ });
10167
+ if (_this52.client.options.headers) _mixin(headers, _this52.client.options.headers);
10168
+ var requestBody = _encodeBody(requestBodyDTO, _this52.client._MsgPack, format);
10169
+ var response = yield resource_default.post(_this52.client, "/messages", requestBody, headers, {}, null, true);
10170
+ var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this52.client._MsgPack, format);
10194
10171
  if (singleSpecMode) {
10195
10172
  return batchResults[0];
10196
10173
  } else {
@@ -10199,35 +10176,39 @@ var ably = {exports: {}};
10199
10176
  })();
10200
10177
  }
10201
10178
  batchPresence(channels) {
10202
- var _this59 = this;
10179
+ var _this53 = this;
10203
10180
  return _asyncToGenerator(function* () {
10204
- var format = _this59.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10205
- headers = defaults_default.defaultGetHeaders(_this59.client.options);
10206
- if (_this59.client.options.headers) _mixin(headers, _this59.client.options.headers);
10181
+ var format = _this53.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10182
+ headers = defaults_default.defaultPostHeaders(_this53.client.options, {
10183
+ format
10184
+ });
10185
+ if (_this53.client.options.headers) _mixin(headers, _this53.client.options.headers);
10207
10186
  var channelsParam = channels.join(",");
10208
- var response = yield resource_default.get(_this59.client, "/presence", headers, {
10187
+ var response = yield resource_default.get(_this53.client, "/presence", headers, {
10209
10188
  channels: channelsParam
10210
10189
  }, null, true);
10211
- return response.unpacked ? response.body : _decodeBody(response.body, _this59.client._MsgPack, format);
10190
+ return response.unpacked ? response.body : _decodeBody(response.body, _this53.client._MsgPack, format);
10212
10191
  })();
10213
10192
  }
10214
10193
  revokeTokens(specifiers, options) {
10215
- var _this60 = this;
10194
+ var _this54 = this;
10216
10195
  return _asyncToGenerator(function* () {
10217
- if (useTokenAuth(_this60.client.options)) {
10196
+ if (useTokenAuth(_this54.client.options)) {
10218
10197
  throw new _ErrorInfo2("Cannot revoke tokens when using token auth", 40162, 401);
10219
10198
  }
10220
- var keyName = _this60.client.options.keyName;
10199
+ var keyName = _this54.client.options.keyName;
10221
10200
  var resolvedOptions = options != null ? options : {};
10222
10201
  var requestBodyDTO = __spreadValues({
10223
10202
  targets: specifiers.map(specifier => "".concat(specifier.type, ":").concat(specifier.value))
10224
10203
  }, resolvedOptions);
10225
- var format = _this60.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10226
- headers = defaults_default.defaultPostHeaders(_this60.client.options);
10227
- if (_this60.client.options.headers) _mixin(headers, _this60.client.options.headers);
10228
- var requestBody = _encodeBody(requestBodyDTO, _this60.client._MsgPack, format);
10229
- var response = yield resource_default.post(_this60.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
10230
- return response.unpacked ? response.body : _decodeBody(response.body, _this60.client._MsgPack, format);
10204
+ var format = _this54.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10205
+ headers = defaults_default.defaultPostHeaders(_this54.client.options, {
10206
+ format
10207
+ });
10208
+ if (_this54.client.options.headers) _mixin(headers, _this54.client.options.headers);
10209
+ var requestBody = _encodeBody(requestBodyDTO, _this54.client._MsgPack, format);
10210
+ var response = yield resource_default.post(_this54.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
10211
+ return response.unpacked ? response.body : _decodeBody(response.body, _this54.client._MsgPack, format);
10231
10212
  })();
10232
10213
  }
10233
10214
  };
@@ -10311,7 +10292,7 @@ var ably = {exports: {}};
10311
10292
 
10312
10293
  // src/common/lib/types/annotation.ts
10313
10294
  var actions4 = ["annotation.create", "annotation.delete"];
10314
- function fromEncoded3(_x74, _x75, _x76) {
10295
+ function fromEncoded3(_x68, _x69, _x70) {
10315
10296
  return _fromEncoded8.apply(this, arguments);
10316
10297
  }
10317
10298
  function _fromEncoded8() {
@@ -10321,7 +10302,7 @@ var ably = {exports: {}};
10321
10302
  });
10322
10303
  return _fromEncoded8.apply(this, arguments);
10323
10304
  }
10324
- function fromEncodedArray3(_x77, _x78, _x79) {
10305
+ function fromEncodedArray3(_x71, _x72, _x73) {
10325
10306
  return _fromEncodedArray8.apply(this, arguments);
10326
10307
  }
10327
10308
  function _fromEncodedArray8() {
@@ -10332,7 +10313,7 @@ var ably = {exports: {}};
10332
10313
  });
10333
10314
  return _fromEncodedArray8.apply(this, arguments);
10334
10315
  }
10335
- function _fromEncoded3(_x80, _x81) {
10316
+ function _fromEncoded3(_x74, _x75) {
10336
10317
  return _fromEncoded9.apply(this, arguments);
10337
10318
  }
10338
10319
  function _fromEncoded9() {
@@ -10341,7 +10322,7 @@ var ably = {exports: {}};
10341
10322
  });
10342
10323
  return _fromEncoded9.apply(this, arguments);
10343
10324
  }
10344
- function _fromEncodedArray3(_x82, _x83) {
10325
+ function _fromEncodedArray3(_x76, _x77) {
10345
10326
  return _fromEncodedArray9.apply(this, arguments);
10346
10327
  }
10347
10328
  function _fromEncodedArray9() {
@@ -10354,10 +10335,10 @@ var ably = {exports: {}};
10354
10335
  }
10355
10336
  var Annotation = class _Annotation extends BaseMessage {
10356
10337
  encode() {
10357
- var _this61 = this;
10338
+ var _this55 = this;
10358
10339
  return _asyncToGenerator(function* () {
10359
- var res = Object.assign(new WireAnnotation(), _this61, {
10360
- action: actions4.indexOf(_this61.action || "annotation.create")
10340
+ var res = Object.assign(new WireAnnotation(), _this55, {
10341
+ action: actions4.indexOf(_this55.action || "annotation.create")
10361
10342
  });
10362
10343
  return encode(res, {});
10363
10344
  })();
@@ -10386,10 +10367,10 @@ var ably = {exports: {}};
10386
10367
  return values.map(v => _WireAnnotation.fromValues(v));
10387
10368
  }
10388
10369
  decode(channelOptions, logger) {
10389
- var _this62 = this;
10370
+ var _this56 = this;
10390
10371
  return _asyncToGenerator(function* () {
10391
- var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this62), {
10392
- action: actions4[_this62.action]
10372
+ var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this56), {
10373
+ action: actions4[_this56.action]
10393
10374
  }));
10394
10375
  try {
10395
10376
  yield decode(res, channelOptions);
@@ -10458,43 +10439,47 @@ var ably = {exports: {}};
10458
10439
  this.channel = channel;
10459
10440
  }
10460
10441
  publish(msgOrSerial, annotationValues) {
10461
- var _this63 = this;
10442
+ var _this57 = this;
10462
10443
  return _asyncToGenerator(function* () {
10463
10444
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
10464
10445
  var wireAnnotation = yield annotation.encode();
10465
- var client = _this63.channel.client,
10446
+ var client = _this57.channel.client,
10466
10447
  options = client.options,
10467
10448
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10468
- headers = defaults_default.defaultPostHeaders(client.options),
10449
+ headers = defaults_default.defaultPostHeaders(client.options, {
10450
+ format
10451
+ }),
10469
10452
  params = {};
10470
10453
  _mixin(headers, client.options.headers);
10471
10454
  var requestBody = _encodeBody([wireAnnotation], client._MsgPack, format);
10472
- yield resource_default.post(client, basePathForSerial(_this63.channel, annotation.messageSerial), requestBody, headers, params, null, true);
10455
+ yield resource_default.post(client, basePathForSerial(_this57.channel, annotation.messageSerial), requestBody, headers, params, null, true);
10473
10456
  })();
10474
10457
  }
10475
10458
  delete(msgOrSerial, annotationValues) {
10476
- var _this64 = this;
10459
+ var _this58 = this;
10477
10460
  return _asyncToGenerator(function* () {
10478
10461
  annotationValues.action = "annotation.delete";
10479
- return _this64.publish(msgOrSerial, annotationValues);
10462
+ return _this58.publish(msgOrSerial, annotationValues);
10480
10463
  })();
10481
10464
  }
10482
10465
  get(msgOrSerial, params) {
10483
- var _this65 = this;
10466
+ var _this59 = this;
10484
10467
  return _asyncToGenerator(function* () {
10485
- var client = _this65.channel.client,
10468
+ var client = _this59.channel.client,
10486
10469
  messageSerial = serialFromMsgOrSerial(msgOrSerial),
10487
10470
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10488
10471
  envelope = client.http.supportsLinkHeaders ? void 0 : format,
10489
- headers = defaults_default.defaultGetHeaders(client.options);
10472
+ headers = defaults_default.defaultGetHeaders(client.options, {
10473
+ format
10474
+ });
10490
10475
  _mixin(headers, client.options.headers);
10491
- return new paginatedresource_default(client, basePathForSerial(_this65.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
10492
- var _ref10 = _asyncToGenerator(function* (body, _, unpacked) {
10476
+ return new paginatedresource_default(client, basePathForSerial(_this59.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
10477
+ var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
10493
10478
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10494
- return _fromEncodedArray3(decoded, _this65.channel);
10479
+ return _fromEncodedArray3(decoded, _this59.channel);
10495
10480
  });
10496
- return function (_x84, _x85, _x86) {
10497
- return _ref10.apply(this, arguments);
10481
+ return function (_x78, _x79, _x80) {
10482
+ return _ref0.apply(this, arguments);
10498
10483
  };
10499
10484
  }()).get(params);
10500
10485
  })();
@@ -10665,7 +10650,7 @@ var ably = {exports: {}};
10665
10650
  this._mode = 0;
10666
10651
  this.retryCount = 0;
10667
10652
  this.history = /*#__PURE__*/function () {
10668
- var _ref11 = _asyncToGenerator(function* (params) {
10653
+ var _ref1 = _asyncToGenerator(function* (params) {
10669
10654
  logger_default.logAction(this.logger, logger_default.LOG_MICRO, "RealtimeChannel.history()", "channel = " + this.name);
10670
10655
  var restMixin = this.client.rest.channelMixin;
10671
10656
  if (params && params.untilAttach) {
@@ -10680,8 +10665,8 @@ var ably = {exports: {}};
10680
10665
  }
10681
10666
  return restMixin.history(this, params);
10682
10667
  });
10683
- return function (_x87) {
10684
- return _ref11.apply(this, arguments);
10668
+ return function (_x81) {
10669
+ return _ref1.apply(this, arguments);
10685
10670
  };
10686
10671
  }();
10687
10672
  this.whenState = state => {
@@ -10760,20 +10745,20 @@ var ably = {exports: {}};
10760
10745
  return args;
10761
10746
  }
10762
10747
  setOptions(options) {
10763
- var _this66 = this;
10748
+ var _this60 = this;
10764
10749
  return _asyncToGenerator(function* () {
10765
10750
  var _a2;
10766
- var previousChannelOptions = _this66.channelOptions;
10751
+ var previousChannelOptions = _this60.channelOptions;
10767
10752
  var err = validateChannelOptions(options);
10768
10753
  if (err) {
10769
10754
  throw err;
10770
10755
  }
10771
- _this66.channelOptions = normaliseChannelOptions((_a2 = _this66.client._Crypto) != null ? _a2 : null, _this66.logger, options);
10772
- if (_this66._decodingContext) _this66._decodingContext.channelOptions = _this66.channelOptions;
10773
- if (_this66._shouldReattachToSetOptions(options, previousChannelOptions)) {
10774
- _this66.attachImpl();
10756
+ _this60.channelOptions = normaliseChannelOptions((_a2 = _this60.client._Crypto) != null ? _a2 : null, _this60.logger, options);
10757
+ if (_this60._decodingContext) _this60._decodingContext.channelOptions = _this60.channelOptions;
10758
+ if (_this60._shouldReattachToSetOptions(options, previousChannelOptions)) {
10759
+ _this60.attachImpl();
10775
10760
  return new Promise((resolve, reject) => {
10776
- _this66._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
10761
+ _this60._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
10777
10762
  switch (this.event) {
10778
10763
  case "update":
10779
10764
  case "attached":
@@ -10810,7 +10795,7 @@ var ably = {exports: {}};
10810
10795
  }
10811
10796
  publish() {
10812
10797
  var _arguments2 = arguments,
10813
- _this67 = this;
10798
+ _this61 = this;
10814
10799
  return _asyncToGenerator(function* () {
10815
10800
  var messages;
10816
10801
  var argCount = _arguments2.length;
@@ -10828,20 +10813,20 @@ var ably = {exports: {}};
10828
10813
  data: _arguments2.length <= 1 ? undefined : _arguments2[1]
10829
10814
  })];
10830
10815
  }
10831
- var maxMessageSize = _this67.client.options.maxMessageSize;
10832
- var wireMessages = yield encodeArray(messages, _this67.channelOptions);
10816
+ var maxMessageSize = _this61.client.options.maxMessageSize;
10817
+ var wireMessages = yield encodeArray(messages, _this61.channelOptions);
10833
10818
  var size = getMessagesSize(wireMessages);
10834
10819
  if (size > maxMessageSize) {
10835
10820
  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);
10836
10821
  }
10837
- _this67.throwIfUnpublishableState();
10838
- logger_default.logAction(_this67.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this67.state + ", message count = " + wireMessages.length);
10822
+ _this61.throwIfUnpublishableState();
10823
+ logger_default.logAction(_this61.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this61.state + ", message count = " + wireMessages.length);
10839
10824
  var pm = fromValues({
10840
10825
  action: actions.MESSAGE,
10841
- channel: _this67.name,
10826
+ channel: _this61.name,
10842
10827
  messages: wireMessages
10843
10828
  });
10844
- return _this67.sendMessage(pm);
10829
+ return _this61.sendMessage(pm);
10845
10830
  })();
10846
10831
  }
10847
10832
  throwIfUnpublishableState() {
@@ -10861,13 +10846,13 @@ var ably = {exports: {}};
10861
10846
  }
10862
10847
  }
10863
10848
  attach() {
10864
- var _this68 = this;
10849
+ var _this62 = this;
10865
10850
  return _asyncToGenerator(function* () {
10866
- if (_this68.state === "attached") {
10851
+ if (_this62.state === "attached") {
10867
10852
  return null;
10868
10853
  }
10869
10854
  return new Promise((resolve, reject) => {
10870
- _this68._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
10855
+ _this62._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
10871
10856
  });
10872
10857
  })();
10873
10858
  }
@@ -10925,25 +10910,25 @@ var ably = {exports: {}};
10925
10910
  this.sendMessage(attachMsg).catch(noop);
10926
10911
  }
10927
10912
  detach() {
10928
- var _this69 = this;
10913
+ var _this63 = this;
10929
10914
  return _asyncToGenerator(function* () {
10930
- var connectionManager = _this69.connectionManager;
10915
+ var connectionManager = _this63.connectionManager;
10931
10916
  if (!connectionManager.activeState()) {
10932
10917
  throw connectionManager.getError();
10933
10918
  }
10934
- switch (_this69.state) {
10919
+ switch (_this63.state) {
10935
10920
  case "suspended":
10936
- _this69.notifyState("detached");
10921
+ _this63.notifyState("detached");
10937
10922
  return;
10938
10923
  case "detached":
10939
10924
  return;
10940
10925
  case "failed":
10941
10926
  throw new _ErrorInfo2("Unable to detach; channel state = failed", 90001, 400);
10942
10927
  default:
10943
- _this69.requestState("detaching");
10928
+ _this63.requestState("detaching");
10944
10929
  case "detaching":
10945
10930
  return new Promise((resolve, reject) => {
10946
- _this69.once(function (stateChange) {
10931
+ _this63.once(function (stateChange) {
10947
10932
  switch (this.event) {
10948
10933
  case "detached":
10949
10934
  resolve();
@@ -10972,22 +10957,22 @@ var ably = {exports: {}};
10972
10957
  }
10973
10958
  subscribe() {
10974
10959
  var _arguments3 = arguments,
10975
- _this70 = this;
10960
+ _this64 = this;
10976
10961
  return _asyncToGenerator(function* () {
10977
10962
  for (var _len0 = _arguments3.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
10978
10963
  args[_key0] = _arguments3[_key0];
10979
10964
  }
10980
10965
  var [event, listener] = _RealtimeChannel.processListenerArgs(args);
10981
- if (_this70.state === "failed") {
10982
- throw _ErrorInfo2.fromValues(_this70.invalidStateError());
10966
+ if (_this64.state === "failed") {
10967
+ throw _ErrorInfo2.fromValues(_this64.invalidStateError());
10983
10968
  }
10984
10969
  if (event && typeof event === "object" && !Array.isArray(event)) {
10985
- _this70.client._FilteredSubscriptions.subscribeFilter(_this70, event, listener);
10970
+ _this64.client._FilteredSubscriptions.subscribeFilter(_this64, event, listener);
10986
10971
  } else {
10987
- _this70.subscriptions.on(event, listener);
10972
+ _this64.subscriptions.on(event, listener);
10988
10973
  }
10989
- if (_this70.channelOptions.attachOnSubscribe !== false) {
10990
- return _this70.attach();
10974
+ if (_this64.channelOptions.attachOnSubscribe !== false) {
10975
+ return _this64.attach();
10991
10976
  } else {
10992
10977
  return null;
10993
10978
  }
@@ -11026,10 +11011,10 @@ var ably = {exports: {}};
11026
11011
  connectionManager.send(syncMessage);
11027
11012
  }
11028
11013
  sendMessage(msg) {
11029
- var _this71 = this;
11014
+ var _this65 = this;
11030
11015
  return _asyncToGenerator(function* () {
11031
11016
  return new Promise((resolve, reject) => {
11032
- _this71.connectionManager.send(msg, _this71.client.options.queueMessages, err => {
11017
+ _this65.connectionManager.send(msg, _this65.client.options.queueMessages, err => {
11033
11018
  if (err) {
11034
11019
  reject(err);
11035
11020
  } else {
@@ -11040,14 +11025,14 @@ var ably = {exports: {}};
11040
11025
  })();
11041
11026
  }
11042
11027
  sendPresence(presence) {
11043
- var _this72 = this;
11028
+ var _this66 = this;
11044
11029
  return _asyncToGenerator(function* () {
11045
11030
  var msg = fromValues({
11046
11031
  action: actions.PRESENCE,
11047
- channel: _this72.name,
11032
+ channel: _this66.name,
11048
11033
  presence
11049
11034
  });
11050
- return _this72.sendMessage(msg);
11035
+ return _this66.sendMessage(msg);
11051
11036
  })();
11052
11037
  }
11053
11038
  sendState(objectMessages) {
@@ -11060,61 +11045,61 @@ var ably = {exports: {}};
11060
11045
  }
11061
11046
  // Access to this method is synchronised by ConnectionManager#processChannelMessage, in order to synchronise access to the state stored in _decodingContext.
11062
11047
  processMessage(message) {
11063
- var _this73 = this;
11048
+ var _this67 = this;
11064
11049
  return _asyncToGenerator(function* () {
11065
11050
  if (message.action === actions.ATTACHED || message.action === actions.MESSAGE || message.action === actions.PRESENCE || message.action === actions.OBJECT || message.action === actions.ANNOTATION) {
11066
- _this73.setChannelSerial(message.channelSerial);
11051
+ _this67.setChannelSerial(message.channelSerial);
11067
11052
  }
11068
11053
  var syncChannelSerial,
11069
11054
  isSync = false;
11070
11055
  switch (message.action) {
11071
11056
  case actions.ATTACHED:
11072
11057
  {
11073
- _this73.properties.attachSerial = message.channelSerial;
11074
- _this73._mode = message.getMode();
11075
- _this73.params = message.params || {};
11058
+ _this67.properties.attachSerial = message.channelSerial;
11059
+ _this67._mode = message.getMode();
11060
+ _this67.params = message.params || {};
11076
11061
  var modesFromFlags = message.decodeModesFromFlags();
11077
- _this73.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
11062
+ _this67.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
11078
11063
  var resumed = message.hasFlag("RESUMED");
11079
11064
  var hasPresence = message.hasFlag("HAS_PRESENCE");
11080
11065
  var hasBacklog = message.hasFlag("HAS_BACKLOG");
11081
11066
  var hasObjects = message.hasFlag("HAS_OBJECTS");
11082
- if (_this73.state === "attached") {
11067
+ if (_this67.state === "attached") {
11083
11068
  if (!resumed) {
11084
- if (_this73._presence) {
11085
- _this73._presence.onAttached(hasPresence);
11069
+ if (_this67._presence) {
11070
+ _this67._presence.onAttached(hasPresence);
11086
11071
  }
11087
- if (_this73._objects) {
11088
- _this73._objects.onAttached(hasObjects);
11072
+ if (_this67._objects) {
11073
+ _this67._objects.onAttached(hasObjects);
11089
11074
  }
11090
11075
  }
11091
- var change = new channelstatechange_default(_this73.state, _this73.state, resumed, hasBacklog, message.error);
11092
- _this73._allChannelChanges.emit("update", change);
11093
- if (!resumed || _this73.channelOptions.updateOnAttached) {
11094
- _this73.emit("update", change);
11076
+ var change = new channelstatechange_default(_this67.state, _this67.state, resumed, hasBacklog, message.error);
11077
+ _this67._allChannelChanges.emit("update", change);
11078
+ if (!resumed || _this67.channelOptions.updateOnAttached) {
11079
+ _this67.emit("update", change);
11095
11080
  }
11096
- } else if (_this73.state === "detaching") {
11097
- _this73.checkPendingState();
11081
+ } else if (_this67.state === "detaching") {
11082
+ _this67.checkPendingState();
11098
11083
  } else {
11099
- _this73.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
11084
+ _this67.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
11100
11085
  }
11101
11086
  break;
11102
11087
  }
11103
11088
  case actions.DETACHED:
11104
11089
  {
11105
11090
  var detachErr = message.error ? _ErrorInfo2.fromValues(message.error) : new _ErrorInfo2("Channel detached", 90001, 404);
11106
- if (_this73.state === "detaching") {
11107
- _this73.notifyState("detached", detachErr);
11108
- } else if (_this73.state === "attaching") {
11109
- _this73.notifyState("suspended", detachErr);
11110
- } else if (_this73.state === "attached" || _this73.state === "suspended") {
11111
- _this73.requestState("attaching", detachErr);
11091
+ if (_this67.state === "detaching") {
11092
+ _this67.notifyState("detached", detachErr);
11093
+ } else if (_this67.state === "attaching") {
11094
+ _this67.notifyState("suspended", detachErr);
11095
+ } else if (_this67.state === "attached" || _this67.state === "suspended") {
11096
+ _this67.requestState("attaching", detachErr);
11112
11097
  }
11113
11098
  break;
11114
11099
  }
11115
11100
  case actions.SYNC:
11116
11101
  isSync = true;
11117
- syncChannelSerial = _this73.syncChannelSerial = message.channelSerial;
11102
+ syncChannelSerial = _this67.syncChannelSerial = message.channelSerial;
11118
11103
  if (!message.presence) break;
11119
11104
  case actions.PRESENCE:
11120
11105
  {
@@ -11122,45 +11107,45 @@ var ably = {exports: {}};
11122
11107
  break;
11123
11108
  }
11124
11109
  populateFieldsFromParent(message);
11125
- var options = _this73.channelOptions;
11126
- if (_this73._presence) {
11110
+ var options = _this67.channelOptions;
11111
+ if (_this67._presence) {
11127
11112
  var presenceMessages = yield Promise.all(message.presence.map(wpm => {
11128
- return wpm.decode(options, _this73.logger);
11113
+ return wpm.decode(options, _this67.logger);
11129
11114
  }));
11130
- _this73._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
11115
+ _this67._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
11131
11116
  }
11132
11117
  break;
11133
11118
  }
11134
11119
  case actions.OBJECT:
11135
11120
  case actions.OBJECT_SYNC:
11136
11121
  {
11137
- if (!_this73._objects || !message.state) {
11122
+ if (!_this67._objects || !message.state) {
11138
11123
  return;
11139
11124
  }
11140
11125
  populateFieldsFromParent(message);
11141
- var format = _this73.client.connection.connectionManager.getActiveTransportFormat();
11142
- var objectMessages = message.state.map(om => om.decode(_this73.client, format));
11126
+ var format = _this67.client.connection.connectionManager.getActiveTransportFormat();
11127
+ var objectMessages = message.state.map(om => om.decode(_this67.client, format));
11143
11128
  if (message.action === actions.OBJECT) {
11144
- _this73._objects.handleObjectMessages(objectMessages);
11129
+ _this67._objects.handleObjectMessages(objectMessages);
11145
11130
  } else {
11146
- _this73._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
11131
+ _this67._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
11147
11132
  }
11148
11133
  break;
11149
11134
  }
11150
11135
  case actions.MESSAGE:
11151
11136
  {
11152
- if (_this73.state !== "attached") {
11153
- 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 + '").');
11137
+ if (_this67.state !== "attached") {
11138
+ 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 + '").');
11154
11139
  return;
11155
11140
  }
11156
11141
  populateFieldsFromParent(message);
11157
11142
  var encoded = message.messages,
11158
11143
  firstMessage = encoded[0],
11159
11144
  lastMessage = encoded[encoded.length - 1];
11160
- if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this73._lastPayload.messageId) {
11161
- var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this73.name + '".';
11162
- logger_default.logAction(_this73.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
11163
- _this73._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
11145
+ if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this67._lastPayload.messageId) {
11146
+ var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this67.name + '".';
11147
+ logger_default.logAction(_this67.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
11148
+ _this67._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
11164
11149
  break;
11165
11150
  }
11166
11151
  var messages = [];
@@ -11168,34 +11153,34 @@ var ably = {exports: {}};
11168
11153
  var {
11169
11154
  decoded,
11170
11155
  err
11171
- } = yield encoded[i].decodeWithErr(_this73._decodingContext, _this73.logger);
11156
+ } = yield encoded[i].decodeWithErr(_this67._decodingContext, _this67.logger);
11172
11157
  messages[i] = decoded;
11173
11158
  if (err) {
11174
11159
  switch (err.code) {
11175
11160
  case 40018:
11176
- _this73._startDecodeFailureRecovery(err);
11161
+ _this67._startDecodeFailureRecovery(err);
11177
11162
  return;
11178
11163
  case 40019:
11179
11164
  case 40021:
11180
- _this73.notifyState("failed", err);
11165
+ _this67.notifyState("failed", err);
11181
11166
  return;
11182
11167
  }
11183
11168
  }
11184
11169
  }
11185
- _this73._lastPayload.messageId = lastMessage.id;
11186
- _this73._lastPayload.protocolMessageChannelSerial = message.channelSerial;
11187
- _this73.onEvent(messages);
11170
+ _this67._lastPayload.messageId = lastMessage.id;
11171
+ _this67._lastPayload.protocolMessageChannelSerial = message.channelSerial;
11172
+ _this67.onEvent(messages);
11188
11173
  break;
11189
11174
  }
11190
11175
  case actions.ANNOTATION:
11191
11176
  {
11192
11177
  populateFieldsFromParent(message);
11193
- var _options = _this73.channelOptions;
11194
- if (_this73._annotations) {
11178
+ var _options = _this67.channelOptions;
11179
+ if (_this67._annotations) {
11195
11180
  var annotations = yield Promise.all((message.annotations || []).map(wpm => {
11196
- return wpm.decode(_options, _this73.logger);
11181
+ return wpm.decode(_options, _this67.logger);
11197
11182
  }));
11198
- _this73._annotations._processIncoming(annotations);
11183
+ _this67._annotations._processIncoming(annotations);
11199
11184
  }
11200
11185
  break;
11201
11186
  }
@@ -11203,14 +11188,14 @@ var ably = {exports: {}};
11203
11188
  {
11204
11189
  var _err = message.error;
11205
11190
  if (_err && _err.code == 80016) {
11206
- _this73.checkPendingState();
11191
+ _this67.checkPendingState();
11207
11192
  } else {
11208
- _this73.notifyState("failed", _ErrorInfo2.fromValues(_err));
11193
+ _this67.notifyState("failed", _ErrorInfo2.fromValues(_err));
11209
11194
  }
11210
11195
  break;
11211
11196
  }
11212
11197
  default:
11213
- logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
11198
+ logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
11214
11199
  }
11215
11200
  })();
11216
11201
  }
@@ -11366,45 +11351,9 @@ var ably = {exports: {}};
11366
11351
  }
11367
11352
  }
11368
11353
  status() {
11369
- var _this74 = this;
11370
- return _asyncToGenerator(function* () {
11371
- return _this74.client.rest.channelMixin.status(_this74);
11372
- })();
11373
- }
11374
- getMessage(serialOrMessage) {
11375
- var _this75 = this;
11376
- return _asyncToGenerator(function* () {
11377
- logger_default.logAction(_this75.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessage()", "channel = " + _this75.name);
11378
- var restMixin = _this75.client.rest.channelMixin;
11379
- return restMixin.getMessage(_this75, serialOrMessage);
11380
- })();
11381
- }
11382
- updateMessage(message, operation, params) {
11383
- var _this76 = this;
11384
- return _asyncToGenerator(function* () {
11385
- logger_default.logAction(_this76.logger, logger_default.LOG_MICRO, "RealtimeChannel.updateMessage()", "channel = " + _this76.name);
11386
- var restMixin = _this76.client.rest.channelMixin;
11387
- return restMixin.updateDeleteMessage(_this76, {
11388
- isDelete: false
11389
- }, message, operation, params);
11390
- })();
11391
- }
11392
- deleteMessage(message, operation, params) {
11393
- var _this77 = this;
11394
- return _asyncToGenerator(function* () {
11395
- logger_default.logAction(_this77.logger, logger_default.LOG_MICRO, "RealtimeChannel.deleteMessage()", "channel = " + _this77.name);
11396
- var restMixin = _this77.client.rest.channelMixin;
11397
- return restMixin.updateDeleteMessage(_this77, {
11398
- isDelete: true
11399
- }, message, operation, params);
11400
- })();
11401
- }
11402
- getMessageVersions(serialOrMessage, params) {
11403
- var _this78 = this;
11354
+ var _this68 = this;
11404
11355
  return _asyncToGenerator(function* () {
11405
- logger_default.logAction(_this78.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessageVersions()", "channel = " + _this78.name);
11406
- var restMixin = _this78.client.rest.channelMixin;
11407
- return restMixin.getMessageVersions(_this78, serialOrMessage, params);
11356
+ return _this68.client.rest.channelMixin.status(_this68);
11408
11357
  })();
11409
11358
  }
11410
11359
  };
@@ -11423,31 +11372,31 @@ var ably = {exports: {}};
11423
11372
  this.subscriptions = new eventemitter_default(this.logger);
11424
11373
  }
11425
11374
  publish(msgOrSerial, annotationValues) {
11426
- var _this79 = this;
11375
+ var _this69 = this;
11427
11376
  return _asyncToGenerator(function* () {
11428
- var channelName = _this79.channel.name;
11377
+ var channelName = _this69.channel.name;
11429
11378
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
11430
11379
  var wireAnnotation = yield annotation.encode();
11431
- _this79.channel.throwIfUnpublishableState();
11432
- logger_default.logAction(_this79.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
11380
+ _this69.channel.throwIfUnpublishableState();
11381
+ logger_default.logAction(_this69.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
11433
11382
  var pm = fromValues({
11434
11383
  action: actions.ANNOTATION,
11435
11384
  channel: channelName,
11436
11385
  annotations: [wireAnnotation]
11437
11386
  });
11438
- return _this79.channel.sendMessage(pm);
11387
+ return _this69.channel.sendMessage(pm);
11439
11388
  })();
11440
11389
  }
11441
11390
  delete(msgOrSerial, annotationValues) {
11442
- var _this80 = this;
11391
+ var _this70 = this;
11443
11392
  return _asyncToGenerator(function* () {
11444
11393
  annotationValues.action = "annotation.delete";
11445
- return _this80.publish(msgOrSerial, annotationValues);
11394
+ return _this70.publish(msgOrSerial, annotationValues);
11446
11395
  })();
11447
11396
  }
11448
11397
  subscribe() {
11449
11398
  var _arguments4 = arguments,
11450
- _this81 = this;
11399
+ _this71 = this;
11451
11400
  return _asyncToGenerator(function* () {
11452
11401
  for (var _len10 = _arguments4.length, _args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
11453
11402
  _args[_key10] = _arguments4[_key10];
@@ -11455,15 +11404,15 @@ var ably = {exports: {}};
11455
11404
  var args = realtimechannel_default.processListenerArgs(_args);
11456
11405
  var event = args[0];
11457
11406
  var listener = args[1];
11458
- var channel = _this81.channel;
11407
+ var channel = _this71.channel;
11459
11408
  if (channel.state === "failed") {
11460
11409
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
11461
11410
  }
11462
- _this81.subscriptions.on(event, listener);
11463
- if (_this81.channel.channelOptions.attachOnSubscribe !== false) {
11411
+ _this71.subscriptions.on(event, listener);
11412
+ if (_this71.channel.channelOptions.attachOnSubscribe !== false) {
11464
11413
  yield channel.attach();
11465
11414
  }
11466
- if ((_this81.channel.state === "attached" && _this81.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
11415
+ if ((_this71.channel.state === "attached" && _this71.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
11467
11416
  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);
11468
11417
  }
11469
11418
  })();
@@ -11483,9 +11432,9 @@ var ably = {exports: {}};
11483
11432
  }
11484
11433
  }
11485
11434
  get(msgOrSerial, params) {
11486
- var _this82 = this;
11435
+ var _this72 = this;
11487
11436
  return _asyncToGenerator(function* () {
11488
- return restannotations_default.prototype.get.call(_this82, msgOrSerial, params);
11437
+ return restannotations_default.prototype.get.call(_this72, msgOrSerial, params);
11489
11438
  })();
11490
11439
  }
11491
11440
  };
@@ -13147,23 +13096,23 @@ var ably = {exports: {}};
13147
13096
  }
13148
13097
  }
13149
13098
  processChannelMessage(message) {
13150
- var _this83 = this;
13099
+ var _this73 = this;
13151
13100
  return _asyncToGenerator(function* () {
13152
- yield _this83.realtime.channels.processChannelMessage(message);
13101
+ yield _this73.realtime.channels.processChannelMessage(message);
13153
13102
  })();
13154
13103
  }
13155
13104
  ping() {
13156
- var _this84 = this;
13105
+ var _this74 = this;
13157
13106
  return _asyncToGenerator(function* () {
13158
13107
  var _a2;
13159
- if (_this84.state.state !== "connected") {
13108
+ if (_this74.state.state !== "connected") {
13160
13109
  throw new _ErrorInfo2("Unable to ping service; not connected", 4e4, 400);
13161
13110
  }
13162
- var transport = (_a2 = _this84.activeProtocol) == null ? void 0 : _a2.getTransport();
13111
+ var transport = (_a2 = _this74.activeProtocol) == null ? void 0 : _a2.getTransport();
13163
13112
  if (!transport) {
13164
- throw _this84.getStateError();
13113
+ throw _this74.getStateError();
13165
13114
  }
13166
- logger_default.logAction(_this84.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
13115
+ logger_default.logAction(_this74.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
13167
13116
  var pingStart = Date.now();
13168
13117
  var id = _cheapRandStr();
13169
13118
  return _withTimeoutAsync(new Promise(resolve => {
@@ -13175,7 +13124,7 @@ var ably = {exports: {}};
13175
13124
  };
13176
13125
  transport.on("heartbeat", onHeartbeat);
13177
13126
  transport.ping(id);
13178
- }), _this84.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
13127
+ }), _this74.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
13179
13128
  })();
13180
13129
  }
13181
13130
  abort(error) {
@@ -13324,10 +13273,10 @@ var ably = {exports: {}};
13324
13273
  });
13325
13274
  }
13326
13275
  ping() {
13327
- var _this85 = this;
13276
+ var _this75 = this;
13328
13277
  return _asyncToGenerator(function* () {
13329
- logger_default.logAction(_this85.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
13330
- return _this85.connectionManager.ping();
13278
+ logger_default.logAction(_this75.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
13279
+ return _this75.connectionManager.ping();
13331
13280
  })();
13332
13281
  }
13333
13282
  close() {
@@ -13383,9 +13332,6 @@ var ably = {exports: {}};
13383
13332
  get channels() {
13384
13333
  return this._channels;
13385
13334
  }
13386
- get clientId() {
13387
- return this.auth.clientId;
13388
- }
13389
13335
  connect() {
13390
13336
  logger_default.logAction(this.logger, logger_default.LOG_MINOR, "Realtime.connect()", "");
13391
13337
  this.connection.connect();
@@ -13426,16 +13372,16 @@ var ably = {exports: {}};
13426
13372
  }
13427
13373
  // Access to this method is synchronised by ConnectionManager#processChannelMessage.
13428
13374
  processChannelMessage(msg) {
13429
- var _this86 = this;
13375
+ var _this76 = this;
13430
13376
  return _asyncToGenerator(function* () {
13431
13377
  var channelName = msg.channel;
13432
13378
  if (channelName === void 0) {
13433
- logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
13379
+ logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
13434
13380
  return;
13435
13381
  }
13436
- var channel = _this86.all[channelName];
13382
+ var channel = _this76.all[channelName];
13437
13383
  if (!channel) {
13438
- logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
13384
+ logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
13439
13385
  return;
13440
13386
  }
13441
13387
  yield channel.processMessage(msg);
@@ -13690,43 +13636,43 @@ var ably = {exports: {}};
13690
13636
  this.pendingPresence = [];
13691
13637
  }
13692
13638
  enter(data) {
13693
- var _this87 = this;
13639
+ var _this77 = this;
13694
13640
  return _asyncToGenerator(function* () {
13695
- if (isAnonymousOrWildcard(_this87)) {
13641
+ if (isAnonymousOrWildcard(_this77)) {
13696
13642
  throw new _ErrorInfo2("clientId must be specified to enter a presence channel", 40012, 400);
13697
13643
  }
13698
- return _this87._enterOrUpdateClient(void 0, void 0, data, "enter");
13644
+ return _this77._enterOrUpdateClient(void 0, void 0, data, "enter");
13699
13645
  })();
13700
13646
  }
13701
13647
  update(data) {
13702
- var _this88 = this;
13648
+ var _this78 = this;
13703
13649
  return _asyncToGenerator(function* () {
13704
- if (isAnonymousOrWildcard(_this88)) {
13650
+ if (isAnonymousOrWildcard(_this78)) {
13705
13651
  throw new _ErrorInfo2("clientId must be specified to update presence data", 40012, 400);
13706
13652
  }
13707
- return _this88._enterOrUpdateClient(void 0, void 0, data, "update");
13653
+ return _this78._enterOrUpdateClient(void 0, void 0, data, "update");
13708
13654
  })();
13709
13655
  }
13710
13656
  enterClient(clientId, data) {
13711
- var _this89 = this;
13657
+ var _this79 = this;
13712
13658
  return _asyncToGenerator(function* () {
13713
- return _this89._enterOrUpdateClient(void 0, clientId, data, "enter");
13659
+ return _this79._enterOrUpdateClient(void 0, clientId, data, "enter");
13714
13660
  })();
13715
13661
  }
13716
13662
  updateClient(clientId, data) {
13717
- var _this90 = this;
13663
+ var _this80 = this;
13718
13664
  return _asyncToGenerator(function* () {
13719
- return _this90._enterOrUpdateClient(void 0, clientId, data, "update");
13665
+ return _this80._enterOrUpdateClient(void 0, clientId, data, "update");
13720
13666
  })();
13721
13667
  }
13722
13668
  _enterOrUpdateClient(id, clientId, data, action) {
13723
- var _this91 = this;
13669
+ var _this81 = this;
13724
13670
  return _asyncToGenerator(function* () {
13725
- var channel = _this91.channel;
13671
+ var channel = _this81.channel;
13726
13672
  if (!channel.connectionManager.activeState()) {
13727
13673
  throw channel.connectionManager.getError();
13728
13674
  }
13729
- logger_default.logAction(_this91.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this91)));
13675
+ logger_default.logAction(_this81.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this81)));
13730
13676
  var presence = presencemessage_default.fromData(data);
13731
13677
  presence.action = action;
13732
13678
  if (id) {
@@ -13744,7 +13690,7 @@ var ably = {exports: {}};
13744
13690
  channel.attach();
13745
13691
  case "attaching":
13746
13692
  return new Promise((resolve, reject) => {
13747
- _this91.pendingPresence.push({
13693
+ _this81.pendingPresence.push({
13748
13694
  presence: wirePresMsg,
13749
13695
  callback: err => err ? reject(err) : resolve()
13750
13696
  });
@@ -13759,22 +13705,22 @@ var ably = {exports: {}};
13759
13705
  })();
13760
13706
  }
13761
13707
  leave(data) {
13762
- var _this92 = this;
13708
+ var _this82 = this;
13763
13709
  return _asyncToGenerator(function* () {
13764
- if (isAnonymousOrWildcard(_this92)) {
13710
+ if (isAnonymousOrWildcard(_this82)) {
13765
13711
  throw new _ErrorInfo2("clientId must have been specified to enter or leave a presence channel", 40012, 400);
13766
13712
  }
13767
- return _this92.leaveClient(void 0, data);
13713
+ return _this82.leaveClient(void 0, data);
13768
13714
  })();
13769
13715
  }
13770
13716
  leaveClient(clientId, data) {
13771
- var _this93 = this;
13717
+ var _this83 = this;
13772
13718
  return _asyncToGenerator(function* () {
13773
- var channel = _this93.channel;
13719
+ var channel = _this83.channel;
13774
13720
  if (!channel.connectionManager.activeState()) {
13775
13721
  throw channel.connectionManager.getError();
13776
13722
  }
13777
- logger_default.logAction(_this93.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this93.channel.name + ", client = " + clientId);
13723
+ logger_default.logAction(_this83.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this83.channel.name + ", client = " + clientId);
13778
13724
  var presence = presencemessage_default.fromData(data);
13779
13725
  presence.action = "leave";
13780
13726
  if (clientId) {
@@ -13786,7 +13732,7 @@ var ably = {exports: {}};
13786
13732
  return channel.sendPresence([wirePresMsg]);
13787
13733
  case "attaching":
13788
13734
  return new Promise((resolve, reject) => {
13789
- _this93.pendingPresence.push({
13735
+ _this83.pendingPresence.push({
13790
13736
  presence: wirePresMsg,
13791
13737
  callback: err => err ? reject(err) : resolve()
13792
13738
  });
@@ -13802,14 +13748,14 @@ var ably = {exports: {}};
13802
13748
  })();
13803
13749
  }
13804
13750
  get(params) {
13805
- var _this94 = this;
13751
+ var _this84 = this;
13806
13752
  return _asyncToGenerator(function* () {
13807
13753
  var waitForSync = !params || ("waitForSync" in params ? params.waitForSync : true);
13808
13754
  return new Promise((resolve, reject) => {
13809
13755
  function returnMembers(members) {
13810
13756
  resolve(params ? members.list(params) : members.values());
13811
13757
  }
13812
- if (_this94.channel.state === "suspended") {
13758
+ if (_this84.channel.state === "suspended") {
13813
13759
  if (waitForSync) {
13814
13760
  reject(_ErrorInfo2.fromValues({
13815
13761
  statusCode: 400,
@@ -13817,12 +13763,12 @@ var ably = {exports: {}};
13817
13763
  message: "Presence state is out of sync due to channel being in the SUSPENDED state"
13818
13764
  }));
13819
13765
  } else {
13820
- returnMembers(_this94.members);
13766
+ returnMembers(_this84.members);
13821
13767
  }
13822
13768
  return;
13823
13769
  }
13824
- waitAttached(_this94.channel, err => reject(err), () => {
13825
- var members = _this94.members;
13770
+ waitAttached(_this84.channel, err => reject(err), () => {
13771
+ var members = _this84.members;
13826
13772
  if (waitForSync) {
13827
13773
  members.waitSync(function () {
13828
13774
  returnMembers(members);
@@ -13835,19 +13781,19 @@ var ably = {exports: {}};
13835
13781
  })();
13836
13782
  }
13837
13783
  history(params) {
13838
- var _this95 = this;
13784
+ var _this85 = this;
13839
13785
  return _asyncToGenerator(function* () {
13840
- logger_default.logAction(_this95.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this95.name);
13841
- var restMixin = _this95.channel.client.rest.presenceMixin;
13786
+ logger_default.logAction(_this85.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this85.name);
13787
+ var restMixin = _this85.channel.client.rest.presenceMixin;
13842
13788
  if (params && params.untilAttach) {
13843
- if (_this95.channel.state === "attached") {
13789
+ if (_this85.channel.state === "attached") {
13844
13790
  delete params.untilAttach;
13845
- params.from_serial = _this95.channel.properties.attachSerial;
13791
+ params.from_serial = _this85.channel.properties.attachSerial;
13846
13792
  } else {
13847
- throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this95.channel.state, 4e4, 400);
13793
+ throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this85.channel.state, 4e4, 400);
13848
13794
  }
13849
13795
  }
13850
- return restMixin.history(_this95, params);
13796
+ return restMixin.history(_this85, params);
13851
13797
  })();
13852
13798
  }
13853
13799
  setPresence(presenceSet, isSync, syncChannelSerial) {
@@ -13975,7 +13921,7 @@ var ably = {exports: {}};
13975
13921
  }
13976
13922
  subscribe() {
13977
13923
  var _arguments5 = arguments,
13978
- _this96 = this;
13924
+ _this86 = this;
13979
13925
  return _asyncToGenerator(function* () {
13980
13926
  for (var _len12 = _arguments5.length, _args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
13981
13927
  _args[_key12] = _arguments5[_key12];
@@ -13983,11 +13929,11 @@ var ably = {exports: {}};
13983
13929
  var args = realtimechannel_default.processListenerArgs(_args);
13984
13930
  var event = args[0];
13985
13931
  var listener = args[1];
13986
- var channel = _this96.channel;
13932
+ var channel = _this86.channel;
13987
13933
  if (channel.state === "failed") {
13988
13934
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
13989
13935
  }
13990
- _this96.subscriptions.on(event, listener);
13936
+ _this86.subscriptions.on(event, listener);
13991
13937
  if (channel.channelOptions.attachOnSubscribe !== false) {
13992
13938
  yield channel.attach();
13993
13939
  }
@@ -14159,8 +14105,8 @@ var ably = {exports: {}};
14159
14105
  isRef: !!((_f = (_e = m.extras) == null ? void 0 : _e.ref) == null ? void 0 : _f.timeserial),
14160
14106
  clientId: m.clientId
14161
14107
  };
14162
- if (Object.entries(filter).find(_ref12 => {
14163
- var [key, value] = _ref12;
14108
+ if (Object.entries(filter).find(_ref10 => {
14109
+ var [key, value] = _ref10;
14164
14110
  return value !== void 0 ? mapping[key] !== value : false;
14165
14111
  })) {
14166
14112
  return;
@@ -14188,8 +14134,8 @@ var ably = {exports: {}};
14188
14134
  return [];
14189
14135
  }
14190
14136
  if (!realListener && filter) {
14191
- return Array.from(channel.filteredSubscriptions.entries()).map(_ref13 => {
14192
- var [key, filterMaps] = _ref13;
14137
+ return Array.from(channel.filteredSubscriptions.entries()).map(_ref11 => {
14138
+ var [key, filterMaps] = _ref11;
14193
14139
  var _a2;
14194
14140
  var listenerMaps = filterMaps.get(filter);
14195
14141
  filterMaps.delete(filter);
@@ -14661,38 +14607,38 @@ var ably = {exports: {}};
14661
14607
  return output;
14662
14608
  }
14663
14609
  encrypt(plaintext) {
14664
- var _this97 = this;
14610
+ var _this87 = this;
14665
14611
  return _asyncToGenerator(function* () {
14666
- logger_default.logAction(_this97.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
14667
- var iv = yield _this97.getIv();
14668
- var cryptoKey = yield crypto.subtle.importKey("raw", _this97.key, _this97.webCryptoAlgorithm, false, ["encrypt"]);
14612
+ logger_default.logAction(_this87.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
14613
+ var iv = yield _this87.getIv();
14614
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this87.key, _this87.webCryptoAlgorithm, false, ["encrypt"]);
14669
14615
  var ciphertext = yield crypto.subtle.encrypt({
14670
- name: _this97.webCryptoAlgorithm,
14616
+ name: _this87.webCryptoAlgorithm,
14671
14617
  iv
14672
14618
  }, cryptoKey, plaintext);
14673
- return _this97.concat(iv, ciphertext);
14619
+ return _this87.concat(iv, ciphertext);
14674
14620
  })();
14675
14621
  }
14676
14622
  decrypt(ciphertext) {
14677
- var _this98 = this;
14623
+ var _this88 = this;
14678
14624
  return _asyncToGenerator(function* () {
14679
- logger_default.logAction(_this98.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
14625
+ logger_default.logAction(_this88.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
14680
14626
  var ciphertextArrayBuffer = bufferUtils.toArrayBuffer(ciphertext);
14681
14627
  var iv = ciphertextArrayBuffer.slice(0, DEFAULT_BLOCKLENGTH);
14682
14628
  var ciphertextBody = ciphertextArrayBuffer.slice(DEFAULT_BLOCKLENGTH);
14683
- var cryptoKey = yield crypto.subtle.importKey("raw", _this98.key, _this98.webCryptoAlgorithm, false, ["decrypt"]);
14629
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this88.key, _this88.webCryptoAlgorithm, false, ["decrypt"]);
14684
14630
  return crypto.subtle.decrypt({
14685
- name: _this98.webCryptoAlgorithm,
14631
+ name: _this88.webCryptoAlgorithm,
14686
14632
  iv
14687
14633
  }, cryptoKey, ciphertextBody);
14688
14634
  })();
14689
14635
  }
14690
14636
  getIv() {
14691
- var _this99 = this;
14637
+ var _this89 = this;
14692
14638
  return _asyncToGenerator(function* () {
14693
- if (_this99.iv) {
14694
- var iv = _this99.iv;
14695
- _this99.iv = null;
14639
+ if (_this89.iv) {
14640
+ var iv = _this89.iv;
14641
+ _this89.iv = null;
14696
14642
  return iv;
14697
14643
  }
14698
14644
  var randomBlock = yield config.getRandomArrayBuffer(DEFAULT_BLOCKLENGTH);
@@ -14739,7 +14685,7 @@ var ably = {exports: {}};
14739
14685
  if (Platform.Config.xhrSupported && xhrRequestImplementation) {
14740
14686
  this.supportsAuthHeaders = true;
14741
14687
  this.Request = /*#__PURE__*/function () {
14742
- var _ref14 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14688
+ var _ref12 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14743
14689
  return new Promise(resolve => {
14744
14690
  var _a3;
14745
14691
  var req = xhrRequestImplementation.createRequest(uri, headers, params, body, XHRStates_default.REQ_SEND, (_a3 = client && client.options.timeouts) != null ? _a3 : null, this.logger, method);
@@ -14753,8 +14699,8 @@ var ably = {exports: {}};
14753
14699
  req.exec();
14754
14700
  });
14755
14701
  });
14756
- return function (_x88, _x89, _x90, _x91, _x92) {
14757
- return _ref14.apply(this, arguments);
14702
+ return function (_x82, _x83, _x84, _x85, _x86) {
14703
+ return _ref12.apply(this, arguments);
14758
14704
  };
14759
14705
  }();
14760
14706
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -14779,11 +14725,11 @@ var ably = {exports: {}};
14779
14725
  } else if (Platform.Config.fetchSupported && fetchRequestImplementation) {
14780
14726
  this.supportsAuthHeaders = true;
14781
14727
  this.Request = /*#__PURE__*/function () {
14782
- var _ref17 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14728
+ var _ref15 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14783
14729
  return fetchRequestImplementation(method, client != null ? client : null, uri, headers, params, body);
14784
14730
  });
14785
- return function (_x93, _x94, _x95, _x96, _x97) {
14786
- return _ref17.apply(this, arguments);
14731
+ return function (_x87, _x88, _x89, _x90, _x91) {
14732
+ return _ref15.apply(this, arguments);
14787
14733
  };
14788
14734
  }();
14789
14735
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -14814,14 +14760,14 @@ var ably = {exports: {}};
14814
14760
  return (_b = (_a2 = this.client) == null ? void 0 : _a2.logger) != null ? _b : logger_default.defaultLogger;
14815
14761
  }
14816
14762
  doUri(method, uri, headers, body, params) {
14817
- var _this100 = this;
14763
+ var _this90 = this;
14818
14764
  return _asyncToGenerator(function* () {
14819
- if (!_this100.Request) {
14765
+ if (!_this90.Request) {
14820
14766
  return {
14821
14767
  error: new PartialErrorInfo("Request invoked before assigned to", null, 500)
14822
14768
  };
14823
14769
  }
14824
- return _this100.Request(method, uri, headers, params, body);
14770
+ return _this90.Request(method, uri, headers, params, body);
14825
14771
  })();
14826
14772
  }
14827
14773
  shouldFallback(errorInfo) {
@@ -14951,7 +14897,7 @@ var ably = {exports: {}};
14951
14897
  globalObject4.crypto.getRandomValues(byteArray);
14952
14898
  return byteArray.buffer;
14953
14899
  });
14954
- function getRandomArrayBuffer(_x98) {
14900
+ function getRandomArrayBuffer(_x92) {
14955
14901
  return _getRandomArrayBuffer.apply(this, arguments);
14956
14902
  }
14957
14903
  return getRandomArrayBuffer;
@@ -16096,7 +16042,7 @@ var ably = {exports: {}};
16096
16042
  });
16097
16043
  return result;
16098
16044
  }
16099
- function fetchRequest(_x99, _x100, _x101, _x102, _x103, _x104) {
16045
+ function fetchRequest(_x93, _x94, _x95, _x96, _x97, _x98) {
16100
16046
  return _fetchRequest.apply(this, arguments);
16101
16047
  } // src/platform/web/lib/http/request/index.ts
16102
16048
  function _fetchRequest() {
@@ -16227,7 +16173,7 @@ var ably = {exports: {}};
16227
16173
  })(ably);
16228
16174
 
16229
16175
  class ClientAblyService {
16230
- static startConnection(sessionId, ablyToken, onMessageReceived, tenantId) {
16176
+ static startConnection(sessionId, ablyToken, onMessageReceived, tenantId, onActionReceived) {
16231
16177
  var _this = this;
16232
16178
  return _asyncToGenerator(function* () {
16233
16179
  // Prevent multiple connections
@@ -16291,6 +16237,8 @@ class ClientAblyService {
16291
16237
  }
16292
16238
  }, 10000);
16293
16239
  });
16240
+ // Store optional action handler for this connection
16241
+ _this.onActionReceived = onActionReceived !== null && onActionReceived !== void 0 ? onActionReceived : null;
16294
16242
  // Subscribe to the session room
16295
16243
  yield _this.joinChannel(sessionId, onMessageReceived, tenantId);
16296
16244
  } catch (error) {
@@ -16326,13 +16274,15 @@ class ClientAblyService {
16326
16274
  });
16327
16275
  // Subscribe to assistant/system responses
16328
16276
  _this2.channel.subscribe('ReceiveMessage', message => {
16329
- var _a, _b, _c, _d, _e, _f, _g, _h;
16277
+ var _a, _b;
16330
16278
  try {
16331
16279
  // Ensure messageContent is always a string (default to empty string if undefined)
16332
- 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 : '';
16333
- var senderType = ((_e = message.data) === null || _e === void 0 ? void 0 : _e.senderType) || 3; // Assistant
16334
- 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;
16335
- var attachments = ((_h = message.data) === null || _h === void 0 ? void 0 : _h.attachments) || [];
16280
+ var rawData = message.data;
16281
+ 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 : '';
16282
+ var senderType = (rawData === null || rawData === void 0 ? void 0 : rawData.senderType) || 3; // Assistant
16283
+ var needsAgent = (rawData === null || rawData === void 0 ? void 0 : rawData.needsAgent) || (rawData === null || rawData === void 0 ? void 0 : rawData.actionType) == 'needs_agent' || false;
16284
+ var attachments = (rawData === null || rawData === void 0 ? void 0 : rawData.attachments) || [];
16285
+ var actionType = rawData && typeof rawData.actionType === 'string' ? rawData.actionType : '';
16336
16286
  // Extract downloadUrl from attachments (Ably now returns downloadUrl directly)
16337
16287
  // Attachments can be: strings (URLs), objects with downloadUrl, or objects with id
16338
16288
  var attachmentUrls = attachments.map(attachment => {
@@ -16349,6 +16299,18 @@ class ClientAblyService {
16349
16299
  // If it's an object with id, we'll need to keep it for backward compatibility
16350
16300
  return null;
16351
16301
  }).filter(url => url !== null);
16302
+ // Invoke optional action handler first (non-blocking for message processing)
16303
+ if (_this2.onActionReceived && actionType !== undefined) {
16304
+ try {
16305
+ void _this2.onActionReceived(actionType, rawData);
16306
+ } catch (actionError) {
16307
+ console.error('[AblyService] Error in action handler callback', {
16308
+ error: actionError,
16309
+ actionType,
16310
+ rawData
16311
+ });
16312
+ }
16313
+ }
16352
16314
  onMessageReceived(messageContent, senderType, needsAgent, attachmentUrls);
16353
16315
  } catch (error) {
16354
16316
  console.error('[AblyService] Error processing message', {
@@ -16383,6 +16345,7 @@ class ClientAblyService {
16383
16345
  }
16384
16346
  _this3.isConnected = false;
16385
16347
  _this3.sessionId = null;
16348
+ _this3.onActionReceived = null;
16386
16349
  } catch (error) {
16387
16350
  console.error('[AblyService] Error in stopConnection', {
16388
16351
  error
@@ -16432,6 +16395,7 @@ ClientAblyService.channel = null;
16432
16395
  ClientAblyService.isConnected = false;
16433
16396
  ClientAblyService.sessionId = null;
16434
16397
  ClientAblyService.messageUnsubscribe = null;
16398
+ ClientAblyService.onActionReceived = null;
16435
16399
 
16436
16400
  var _excluded$e = ["title", "titleId"];
16437
16401
  var SvgClose = (_ref, ref) => {
@@ -39713,6 +39677,7 @@ var HelpCenterContent = _ref => {
39713
39677
  var [needsAgent, setNeedsAgent] = useState(false);
39714
39678
  var [assistantStatus, setAssistantStatus] = useState('idle');
39715
39679
  var [isReviewDialogOpen, setIsReviewDialogOpen] = useState(false);
39680
+ var actionHandler = useActionHandler();
39716
39681
  var handleTogglePopup = () => {
39717
39682
  setIsOpen(!isOpen);
39718
39683
  setShowArrowAnimation(isOpen);
@@ -39739,37 +39704,32 @@ var HelpCenterContent = _ref => {
39739
39704
  });
39740
39705
  setAssistantStatus('idle');
39741
39706
  };
39742
- var handleEndChat = /*#__PURE__*/function () {
39743
- var _ref2 = _asyncToGenerator(function* () {
39744
- if (!sessionId || !selectedOption) return;
39745
- try {
39746
- yield ClientAblyService.stopConnection();
39747
- setIsAblyConnected(false);
39748
- setAssistantStatus('idle');
39749
- var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
39750
- language: language
39751
- });
39752
- if (!response.ok) throw new Error('Failed to close chat session');
39753
- // Store sessionId for review before clearing the main sessionId
39754
- setReviewSessionId(sessionId);
39755
- // Clear the sessionId after successfully closing the session
39756
- setSessionId(null);
39757
- setSelectedOption(null);
39758
- setMessages([]);
39759
- setIsReviewDialogOpen(true);
39760
- } catch (error) {
39761
- setError('Failed to end chat session');
39762
- setAssistantStatus('idle');
39763
- // Even if there's an error, clear the session state to prevent stuck state
39764
- setReviewSessionId(sessionId);
39765
- setSessionId(null);
39766
- setSelectedOption(null);
39767
- }
39768
- });
39769
- return function handleEndChat() {
39770
- return _ref2.apply(this, arguments);
39771
- };
39772
- }();
39707
+ var handleEndChat = useCallback(/*#__PURE__*/_asyncToGenerator(function* () {
39708
+ if (!sessionId || !selectedOption) return;
39709
+ try {
39710
+ yield ClientAblyService.stopConnection();
39711
+ setIsAblyConnected(false);
39712
+ setAssistantStatus('idle');
39713
+ var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
39714
+ language: language
39715
+ });
39716
+ if (!response.ok) throw new Error('Failed to close chat session');
39717
+ // Store sessionId for review before clearing the main sessionId
39718
+ setReviewSessionId(sessionId);
39719
+ // Clear the sessionId after successfully closing the session
39720
+ setSessionId(null);
39721
+ setSelectedOption(null);
39722
+ setMessages([]);
39723
+ setIsReviewDialogOpen(true);
39724
+ } catch (error) {
39725
+ setError('Failed to end chat session');
39726
+ setAssistantStatus('idle');
39727
+ // Even if there's an error, clear the session state to prevent stuck state
39728
+ setReviewSessionId(sessionId);
39729
+ setSessionId(null);
39730
+ setSelectedOption(null);
39731
+ }
39732
+ }), [language, selectedOption, sessionId]);
39773
39733
  var handleSendChatReview = /*#__PURE__*/function () {
39774
39734
  var _ref4 = _asyncToGenerator(function* (_ref3) {
39775
39735
  var {
@@ -39840,7 +39800,9 @@ var HelpCenterContent = _ref => {
39840
39800
  var responseData = yield response.json();
39841
39801
  var newSessionId = responseData.chatSession.id;
39842
39802
  setSessionId(newSessionId);
39843
- yield ClientAblyService.startConnection(newSessionId, responseData.ablyToken, handleReceiveMessage, responseData.chatSession.tenantId);
39803
+ yield ClientAblyService.startConnection(newSessionId, responseData.ablyToken, handleReceiveMessage, responseData.chatSession.tenantId, (actionType, messageData) => {
39804
+ void actionHandler.handleAction(actionType, messageData);
39805
+ });
39844
39806
  // Verify the connection is actually active
39845
39807
  if (!ClientAblyService.isConnectionActive()) {
39846
39808
  throw new Error('Ably connection failed to establish properly');
@@ -39937,6 +39899,22 @@ var HelpCenterContent = _ref => {
39937
39899
  return _ref8.apply(this, arguments);
39938
39900
  };
39939
39901
  }();
39902
+ // Register known action handlers for realtime messages
39903
+ useEffect(() => {
39904
+ // "needs_agent" → trigger handoff / needs agent UI flow
39905
+ actionHandler.registerHandler('needs_agent', () => {
39906
+ setNeedsAgent(true);
39907
+ });
39908
+ // "end_session" → gracefully close the chat session and show review dialog
39909
+ actionHandler.registerHandler('end_session', () => {
39910
+ // Reuse existing end chat logic
39911
+ void handleEndChat();
39912
+ });
39913
+ return () => {
39914
+ actionHandler.unregisterHandler('needs_agent');
39915
+ actionHandler.unregisterHandler('end_session');
39916
+ };
39917
+ }, [actionHandler, handleEndChat]);
39940
39918
  useEffect(() => {
39941
39919
  if (isOpen && helpScreenId) {
39942
39920
  setStatus('loading');