@talkjs/core 1.5.1 → 1.5.3

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.
@@ -529,12 +529,12 @@ class I extends x {
529
529
  this.connection.call("SUBSCRIBE", ["users"], { ids: e2 }).then((e3) => this.subscribeCalls.forEach((t2) => t2.deferred.resolve(e3)));
530
530
  }
531
531
  }
532
- class T extends x {
532
+ class S extends x {
533
533
  constructor(e2, t2, s2) {
534
534
  super(s2, () => this.sendMutate()), this.conversationId = e2, this.connection = t2, this.calls = [];
535
535
  }
536
536
  canPush(e2, t2) {
537
- return !!T.isCorrectBatchTypeFor(e2, t2) && t2[1] === this.conversationId;
537
+ return !!S.isCorrectBatchTypeFor(e2, t2) && t2[1] === this.conversationId;
538
538
  }
539
539
  static isCorrectBatchTypeFor(e2, t2) {
540
540
  return s(t2, ["conversations", "*", "participants", "*"]) && ("PUT" === e2 || "POST" === e2 || "PATCH" === e2);
@@ -555,7 +555,7 @@ class T extends x {
555
555
  });
556
556
  }
557
557
  }
558
- class S {
558
+ class T {
559
559
  constructor(e2, t2, s2) {
560
560
  this.pendingBatch = null, this.connection = new E(e2, t2, s2);
561
561
  }
@@ -577,9 +577,9 @@ class S {
577
577
  }
578
578
  createEmptyBatchFor(e2, t2) {
579
579
  if (I.isCorrectBatchTypeFor(e2, t2)) return new I(this.connection, () => this.pendingBatch = null);
580
- if (T.isCorrectBatchTypeFor(e2, t2)) {
580
+ if (S.isCorrectBatchTypeFor(e2, t2)) {
581
581
  const e3 = t2[1];
582
- return new T(e3, this.connection, () => this.pendingBatch = null);
582
+ return new S(e3, this.connection, () => this.pendingBatch = null);
583
583
  }
584
584
  return null;
585
585
  }
@@ -587,7 +587,7 @@ class S {
587
587
  const D = { 200: "RESOLVE", 400: "RESOLVE", 401: "RETRY", 402: "RESOLVE", 403: "RESOLVE", 404: "RESOLVE", 405: "RESOLVE", 409: "RESOLVE", 429: "DELAY", 500: "DELAY" };
588
588
  class M {
589
589
  constructor(e2, t2, s2) {
590
- this.throttler = new F(), this.alive = true, this.connection = new S(e2, t2, s2);
590
+ this.throttler = new F(), this.alive = true, this.connection = new T(e2, t2, s2);
591
591
  }
592
592
  call(e2, t2, s2) {
593
593
  return __async(this, null, function* () {
@@ -799,7 +799,7 @@ class $ extends j {
799
799
  class W extends $ {
800
800
  constructor(e2, t2) {
801
801
  const s2 = new Promise((e3) => setTimeout(e3)).then(() => this.fetchInitial(e2));
802
- super({ seq: e2, resultPromise: s2 }, t2), this.initialSeq = e2, this.getDeepMutex = new U(), this.lastDeep = void 0;
802
+ super({ seq: e2, resultPromise: s2 }, t2.onTeardown), this.initialSeq = e2, this.getDeepMutex = new U(), this.lastDeep = void 0;
803
803
  }
804
804
  refetchInitial(e2) {
805
805
  return __async(this, null, function* () {
@@ -868,15 +868,9 @@ class q extends W {
868
868
  this.setError(l("UNSUBSCRIBED"));
869
869
  }, this.unsubscribeDebounceMs);
870
870
  }
871
- getLoadMoreSeq() {
872
- var _a2;
873
- const e2 = (_a2 = this.lastEmitSeq) != null ? _a2 : 0, t2 = this.mostRecentState.seq;
874
- return Math.max(e2, t2) + 1e-6;
875
- }
876
871
  emit(e2) {
877
872
  return __async(this, null, function* () {
878
873
  var _a2;
879
- if (this.onlyUsedInternally) return;
880
874
  if (this.lastEmitSeq && this.lastEmitSeq >= e2) return;
881
875
  if (false === ((_a2 = this.lastEmitResult) == null ? void 0 : _a2.ok)) return;
882
876
  this.lastEmitSeq = e2;
@@ -1082,7 +1076,7 @@ function se(e2, t2) {
1082
1076
  }
1083
1077
  class ne extends W {
1084
1078
  constructor(e2, t2, s2, n2) {
1085
- super(e2), this.conversationId = t2, this.message = s2, this.realtimeClient = n2;
1079
+ super(e2, {}), this.conversationId = t2, this.message = s2, this.realtimeClient = n2;
1086
1080
  }
1087
1081
  get messageId() {
1088
1082
  return "string" == typeof this.message ? this.message : this.message.id;
@@ -1168,7 +1162,7 @@ function ie(e2) {
1168
1162
  }
1169
1163
  class ae extends W {
1170
1164
  constructor(e2, t2, s2, n2) {
1171
- super(e2), this.createdAt = t2, this.dataStore = s2, this.referencedDataStore = n2;
1165
+ super(e2, {}), this.createdAt = t2, this.dataStore = s2, this.referencedDataStore = n2;
1172
1166
  }
1173
1167
  get messageId() {
1174
1168
  return this.dataStore.messageId;
@@ -1208,7 +1202,7 @@ class ae extends W {
1208
1202
  }
1209
1203
  class oe extends q {
1210
1204
  constructor(e2, t2, s2, n2, r2) {
1211
- super(e2, n2, r2), this.conversationId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
1205
+ super(e2, n2, r2), this.conversationId = t2, this.realtimeClient = s2, this.handlers = r2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
1212
1206
  }
1213
1207
  listen(e2) {
1214
1208
  return this.onlyUsedInternally && this.mostRecentState.resultPromise.then((e3) => {
@@ -1274,10 +1268,13 @@ class oe extends q {
1274
1268
  const t2 = yield this.mostRecentState.resultPromise;
1275
1269
  if (!t2.ok) return;
1276
1270
  if (null === t2.value.windowEnd) return;
1277
- const s2 = t2.value.windowEnd.cursor, n2 = yield ue({ count: e2, cursor: s2, conversationId: this.conversationId, realtimeClient: this.realtimeClient }), r2 = this.getLoadMoreSeq();
1278
- this.mutate(r2, (e3) => null === e3.value.windowEnd || s2 !== e3.value.windowEnd.cursor ? e3 : n2.ok ? null === n2.value.messages ? (console.warn("[TalkJS] When loading more messages, the conversation no longer existed. We should have been told about this."), e3) : ce({ seq: r2, prevState: e3.value, messages: n2.value.messages, cursor: n2.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : n2), yield this.emitMutex.runExclusive(() => this.emit(r2));
1271
+ const s2 = t2.value.windowEnd.cursor, n2 = yield ue({ count: e2, cursor: s2, conversationId: this.conversationId, realtimeClient: this.realtimeClient });
1272
+ yield this.handlers.onLoadedMore({ type: "virtual.messages.loadedmore", conversationId: this.conversationId, data: n2 });
1279
1273
  });
1280
1274
  }
1275
+ loadedMore(e2, t2) {
1276
+ this.mutate(e2, (s2) => null === s2.value.windowEnd ? s2 : t2.data.ok ? null === t2.data.value.messages ? (console.warn("[TalkJS] When loading more messages, the conversation no longer existed. We should have been told about this."), s2) : ce({ seq: e2, prevState: s2.value, messages: t2.data.value.messages, cursor: t2.data.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : t2.data);
1277
+ }
1281
1278
  messageCreated(e2, t2) {
1282
1279
  this.mutate(e2, (s2) => {
1283
1280
  if (null === s2.value.stores) return console.warn("[TalkJS] Received a 'message.created' event for a nonexistent conversation."), s2;
@@ -1490,7 +1487,7 @@ class pe extends q {
1490
1487
  }
1491
1488
  class fe extends W {
1492
1489
  constructor(e2, t2, s2, n2) {
1493
- super(e2), this.conversationId = t2, this.participantData = s2, this.realtimeClient = n2;
1490
+ super(e2, {}), this.conversationId = t2, this.participantData = s2, this.realtimeClient = n2;
1494
1491
  }
1495
1492
  fetchInitial(e2) {
1496
1493
  return __async(this, null, function* () {
@@ -1546,7 +1543,7 @@ class fe extends W {
1546
1543
  }
1547
1544
  class me extends q {
1548
1545
  constructor(e2, t2, s2, n2, r2) {
1549
- super(e2, n2, r2), this.conversationId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
1546
+ super(e2, n2, r2), this.conversationId = t2, this.realtimeClient = s2, this.handlers = r2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
1550
1547
  }
1551
1548
  fetchInitial(e2) {
1552
1549
  return __async(this, null, function* () {
@@ -1593,10 +1590,13 @@ class me extends q {
1593
1590
  const t2 = yield this.mostRecentState.resultPromise;
1594
1591
  if (!t2.ok) return;
1595
1592
  if (null === t2.value.windowEnd) return;
1596
- const s2 = t2.value.windowEnd.cursor, n2 = yield ge({ count: e2, cursor: s2, conversationId: this.conversationId, realtimeClient: this.realtimeClient }), r2 = this.getLoadMoreSeq();
1597
- this.mutate(r2, (e3) => null === e3.value.windowEnd || s2 !== e3.value.windowEnd.cursor ? e3 : n2.ok ? null === n2.value.participants ? (console.warn("[TalkJS] When loading more participants, the conversation no longer existed. We should have been told about this."), e3) : ve({ seq: r2, prevStores: e3.value.stores, participants: n2.value.participants, cursor: n2.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : n2), yield this.emitMutex.runExclusive(() => this.emit(r2));
1593
+ const s2 = t2.value.windowEnd.cursor, n2 = yield ge({ count: e2, cursor: s2, conversationId: this.conversationId, realtimeClient: this.realtimeClient });
1594
+ yield this.handlers.onLoadedMore({ type: "virtual.participants.loadedmore", conversationId: this.conversationId, data: n2 });
1598
1595
  });
1599
1596
  }
1597
+ loadedMore(e2, t2) {
1598
+ this.mutate(e2, (s2) => null === s2.value.windowEnd ? s2 : t2.data.ok ? null === t2.data.value.participants ? (console.warn("[TalkJS] When loading more participants, the conversation no longer existed. We should have been told about this."), s2) : ve({ seq: e2, prevStores: s2.value.stores, participants: t2.data.value.participants, cursor: t2.data.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : t2.data);
1599
+ }
1600
1600
  participantCreated(e2, t2) {
1601
1601
  this.mutate(e2, (s2) => {
1602
1602
  if (null === s2.value.stores) return console.warn("[TalkJS] Received a 'participant.created' event for a nonexistent conversation."), s2;
@@ -1663,7 +1663,7 @@ function ve({ seq: e2, prevStores: t2, participants: s2, cursor: n2, conversatio
1663
1663
  }
1664
1664
  class we extends q {
1665
1665
  constructor(e2, t2, s2, n2, r2) {
1666
- super(e2, n2, r2), this.getConvDataStore = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
1666
+ super(e2, n2, r2), this.getConvDataStore = t2, this.realtimeClient = s2, this.handlers = r2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
1667
1667
  }
1668
1668
  fetchInitial(e2) {
1669
1669
  return __async(this, null, function* () {
@@ -1712,8 +1712,8 @@ class we extends q {
1712
1712
  const t2 = yield this.mostRecentState.resultPromise;
1713
1713
  if (!t2.ok) return;
1714
1714
  if (null === t2.value.windowEnd) return;
1715
- const s2 = t2.value.windowEnd.cursor, n2 = yield be({ count: e2, cursor: s2, realtimeClient: this.realtimeClient }), r2 = this.getLoadMoreSeq();
1716
- this.mutate(r2, (e3) => null === e3.value.windowEnd || s2 !== e3.value.windowEnd.cursor ? e3 : n2.ok ? null === n2.value.conversations ? (console.warn("[TalkJS] When loading more conversations, the user stopped existing, which should be impossible."), e3) : ye({ seq: r2, prevStores: e3.value.stores, conversations: n2.value.conversations, cursor: n2.value.nextCursor, getConvDataStore: this.getConvDataStore }) : n2), yield this.emitMutex.runExclusive(() => this.emit(r2));
1715
+ const s2 = t2.value.windowEnd.cursor, n2 = yield be({ count: e2, cursor: s2, realtimeClient: this.realtimeClient });
1716
+ yield this.handlers.onLoadedMore({ type: "virtual.conversations.loadedmore", data: n2 });
1717
1717
  });
1718
1718
  }
1719
1719
  getConvFromCache(e2) {
@@ -1725,6 +1725,9 @@ class we extends q {
1725
1725
  return void 0 === s2 ? l("NOT_IN_CACHE") : s2.store.getFromCache();
1726
1726
  });
1727
1727
  }
1728
+ loadedMore(e2, t2) {
1729
+ this.mutate(e2, (s2) => null === s2.value.windowEnd ? s2 : t2.data.ok ? null === t2.data.value.conversations ? (console.warn("[TalkJS] When loading more conversations, the user stopped existing, which should be impossible."), s2) : ye({ seq: e2, prevStores: s2.value.stores, conversations: t2.data.value.conversations, cursor: t2.data.value.nextCursor, getConvDataStore: this.getConvDataStore }) : t2.data);
1730
+ }
1728
1731
  userCreated(e2, t2) {
1729
1732
  this.mutate(e2, (e3) => null !== e3.value.stores ? e3 : c({ lastChanged: e3.value.lastChanged, stores: {}, windowEnd: null }));
1730
1733
  }
@@ -1897,28 +1900,28 @@ class Ee extends q {
1897
1900
  }
1898
1901
  class ke {
1899
1902
  constructor(e2, t2, s2) {
1900
- this.realtimeClient = s2, this.convDataStores = {}, this.storeMap = {}, this.emitMutex = new U(), this.seqOffset = 0, this.seqInThisConnection = 0, this.refetchOnNextNetworkLoss = true, this.connection = new N(e2, t2, { onUpstreamRestarting: () => {
1903
+ this.realtimeClient = s2, this.convDataStores = {}, this.storeMap = {}, this.emitMutex = new U(), this.virtualSeqOffset = 0, this.realPublishSeq = 0, this.refetchOnNextNetworkLoss = true, this.connection = new N(e2, t2, { onUpstreamRestarting: () => {
1901
1904
  this.refetchOnNextNetworkLoss = false;
1902
1905
  }, onReady: () => {
1903
1906
  this.refetchOnNextNetworkLoss = true;
1904
1907
  }, onResubscribeSent: () => {
1905
- if (this.seqOffset += this.seq, this.seqInThisConnection = 0, this.refetchOnNextNetworkLoss) {
1906
- this.seqOffset++;
1907
- const e3 = this.seq;
1908
+ if (this.virtualSeqOffset += this.realPublishSeq, this.realPublishSeq = 0, this.refetchOnNextNetworkLoss) {
1909
+ this.virtualSeqOffset++;
1910
+ const e3 = this.virtualSeq;
1908
1911
  this.refetchAll(e3), this.emitAll(e3);
1909
1912
  }
1910
1913
  }, onResubscribeError: (e3, t3) => {
1911
1914
  var _a2;
1912
1915
  (_a2 = this.storeMap[xe(e3)]) == null ? void 0 : _a2.setError(t3);
1913
1916
  }, onPublish: (e3, t3) => {
1914
- this.seqInThisConnection = e3;
1915
- const s3 = this.seq;
1917
+ this.realPublishSeq = e3;
1918
+ const s3 = this.virtualSeq;
1916
1919
  for (const e4 of t3) this.handlePublish(s3, e4);
1917
1920
  this.emitAll(s3);
1918
1921
  } });
1919
1922
  }
1920
- get seq() {
1921
- return this.seqOffset + this.seqInThisConnection;
1923
+ get virtualSeq() {
1924
+ return this.realPublishSeq + this.virtualSeqOffset;
1922
1925
  }
1923
1926
  refetchAll(e2) {
1924
1927
  Object.values(this.storeMap).forEach((t2) => t2 == null ? void 0 : t2.refetch(e2));
@@ -1930,7 +1933,7 @@ class ke {
1930
1933
  }));
1931
1934
  }
1932
1935
  handlePublish(e2, t2) {
1933
- var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t2, _u, _v, _w, _x, _y, _z, _A;
1936
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t2, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
1934
1937
  switch (t2.type) {
1935
1938
  case "user.created":
1936
1939
  return (_a2 = this.storeMap[`/users/${t2.userId}`]) == null ? void 0 : _a2.userCreated(e2, t2), (_b = this.storeMap["/me/conversations"]) == null ? void 0 : _b.userCreated(e2, t2), void ((_c = this.storeMap[`/users/${t2.userId}/online`]) == null ? void 0 : _c.userCreated(e2, t2));
@@ -1964,6 +1967,12 @@ class ke {
1964
1967
  return void ((_z = this.storeMap[`/me/conversations/${t2.conversationId}/participants`]) == null ? void 0 : _z.participantDeleted(e2, t2));
1965
1968
  case "user.online.changed":
1966
1969
  return void ((_A = this.storeMap[`/users/${t2.userId}/online`]) == null ? void 0 : _A.userOnlineChanged(e2, t2));
1970
+ case "virtual.conversations.loadedmore":
1971
+ return void ((_B = this.storeMap["/me/conversations"]) == null ? void 0 : _B.loadedMore(e2, t2));
1972
+ case "virtual.messages.loadedmore":
1973
+ return void ((_C = this.storeMap[`/me/conversations/${t2.conversationId}/messages`]) == null ? void 0 : _C.loadedMore(e2, t2));
1974
+ case "virtual.participants.loadedmore":
1975
+ return void ((_D = this.storeMap[`/me/conversations/${t2.conversationId}/participants`]) == null ? void 0 : _D.loadedMore(e2, t2));
1967
1976
  }
1968
1977
  }
1969
1978
  call(e2, t2, n2, r2) {
@@ -2033,6 +2042,13 @@ class ke {
2033
2042
  }
2034
2043
  }, a2;
2035
2044
  }
2045
+ onVirtualPublish(e2) {
2046
+ return __async(this, null, function* () {
2047
+ this.virtualSeqOffset++;
2048
+ const t2 = this.virtualSeq;
2049
+ this.handlePublish(t2, e2), yield this.emitAll(t2);
2050
+ });
2051
+ }
2036
2052
  getOrCreateStore(e2) {
2037
2053
  const t2 = xe(e2);
2038
2054
  if (t2 in this.storeMap) return this.storeMap[t2];
@@ -2051,13 +2067,13 @@ class ke {
2051
2067
  return this.connection.isConnected();
2052
2068
  }
2053
2069
  instantiateStore(e2, t2) {
2054
- if (s(e2, ["users", "*"])) return new G(this.seq, e2[1], this.realtimeClient, this.emitMutex, t2);
2055
- if (s(e2, ["me", "conversations", "*"])) return new le(this.seq, this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, t2);
2056
- if (s(e2, ["me", "conversations", "*", "messages"])) return new oe(this.seq, e2[2], this.realtimeClient, this.emitMutex, t2);
2057
- if (s(e2, ["me", "conversations", "*", "participants"])) return new me(this.seq, e2[2], this.realtimeClient, this.emitMutex, t2);
2058
- if (s(e2, ["me", "conversations", "*", "typing"])) return new pe(this.seq, e2[2], this.realtimeClient, this.emitMutex, t2);
2059
- if (s(e2, ["me", "conversations"])) return new we(this.seq, (e3) => this.subscribeConvData(e3), this.realtimeClient, this.emitMutex, t2);
2060
- if (s(e2, ["users", "*", "online"])) return new Ee(this.seq, e2[1], this.realtimeClient, this.emitMutex, t2);
2070
+ if (s(e2, ["users", "*"])) return new G(this.virtualSeq, e2[1], this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2071
+ if (s(e2, ["me", "conversations", "*"])) return new le(this.virtualSeq, this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2072
+ if (s(e2, ["me", "conversations", "*", "messages"])) return new oe(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2, onLoadedMore: (e3) => this.onVirtualPublish(e3) });
2073
+ if (s(e2, ["me", "conversations", "*", "participants"])) return new me(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2, onLoadedMore: (e3) => this.onVirtualPublish(e3) });
2074
+ if (s(e2, ["me", "conversations", "*", "typing"])) return new pe(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2075
+ if (s(e2, ["me", "conversations"])) return new we(this.virtualSeq, (e3) => this.subscribeConvData(e3), this.realtimeClient, this.emitMutex, { onTeardown: t2, onLoadedMore: (e3) => this.onVirtualPublish(e3) });
2076
+ if (s(e2, ["users", "*", "online"])) return new Ee(this.virtualSeq, e2[1], this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2061
2077
  throw "Unreachable";
2062
2078
  }
2063
2079
  subscribeConvData(e2) {
@@ -2066,9 +2082,9 @@ class ke {
2066
2082
  const e3 = this.convDataStores[t2];
2067
2083
  return { store: e3, unsubscribe: e3.registerInternalSubscription() };
2068
2084
  }
2069
- const s2 = new Ce(this.seq, e2, this.realtimeClient, this.emitMutex, () => {
2085
+ const s2 = new Ce(this.virtualSeq, e2, this.realtimeClient, this.emitMutex, { onTeardown: () => {
2070
2086
  delete this.convDataStores[t2];
2071
- });
2087
+ } });
2072
2088
  return this.convDataStores[t2] = s2, { store: s2, unsubscribe: s2.registerInternalSubscription() };
2073
2089
  }
2074
2090
  }
@@ -2102,7 +2118,7 @@ class Ie {
2102
2118
  listMessages(e2, t2) {
2103
2119
  return __async(this, null, function* () {
2104
2120
  const s2 = yield this.call("GET", ["me", "conversations", e2, "messages"], t2);
2105
- if (!s2.ok) return Te(s2, "Listing messages in " + e2);
2121
+ if (!s2.ok) return Se(s2, "Listing messages in " + e2);
2106
2122
  const n2 = s2.value.data.data, r2 = yield Promise.all(n2.map((t3) => this.createMessageSnapshot(t3, e2))), i2 = r2.find((e3) => !e3.ok);
2107
2123
  if (void 0 !== i2 && !i2.ok) return i2;
2108
2124
  return c(r2.map(({ value: e3 }) => e3));
@@ -2131,7 +2147,7 @@ class Ie {
2131
2147
  const s2 = yield this.call("GET", ["me", "conversations", e2, "messages", t2], {});
2132
2148
  if (!s2.ok && "server" === s2.where && 404 === s2.value.status) return c(null);
2133
2149
  if (!s2.ok && "server" === s2.where && 403 === s2.value.status && "NOT_A_PARTICIPANT" === s2.value.errorCode) return c(null);
2134
- if (!s2.ok) return Te(s2, `Fetching referenced message ${t2} in conversation ${e2}`);
2150
+ if (!s2.ok) return Se(s2, `Fetching referenced message ${t2} in conversation ${e2}`);
2135
2151
  const n2 = s2.value.data, r2 = yield this.getUser(n2.senderId);
2136
2152
  if (!r2.ok) return r2;
2137
2153
  const i2 = r2.value;
@@ -2142,7 +2158,7 @@ class Ie {
2142
2158
  return __async(this, null, function* () {
2143
2159
  const t2 = yield this.call("GET", ["users", e2], { includePrivateFields: false });
2144
2160
  if (!t2.ok && "server" === t2.where && 404 === t2.value.status) return c(null);
2145
- if (!t2.ok) return Te(t2, "Get user " + e2);
2161
+ if (!t2.ok) return Se(t2, "Get user " + e2);
2146
2162
  return c(this.createUserSnapshot(t2.value.data));
2147
2163
  });
2148
2164
  }
@@ -2153,10 +2169,10 @@ class Ie {
2153
2169
  return { id: e2.id, type: e2.type, sender: t2, referencedMessageId: e2.referencedMessageId, custom: e2.custom, createdAt: e2.createdAt, editedAt: e2.editedAt, origin: e2.origin, content: e2.content, reactions: ie(e2.reactions), plaintext: te(e2.content, {}) };
2154
2170
  }
2155
2171
  }
2156
- function Te(e2, t2) {
2172
+ function Se(e2, t2) {
2157
2173
  return "server" === e2.where ? h(__spreadProps(__spreadValues({}, e2.value), { operation: t2 })) : e2;
2158
2174
  }
2159
- function Se(e2, s2) {
2175
+ function Te(e2, s2) {
2160
2176
  var _a2;
2161
2177
  if (s2.ok) return s2.value;
2162
2178
  throw "SESSION_DESTROYED" === s2.value ? new Error(`${e2} failed because the session was destroyed`) : new Error(t((_a2 = s2.value.operation) != null ? _a2 : e2, s2.value));
@@ -2171,7 +2187,7 @@ class De {
2171
2187
  get() {
2172
2188
  return __async(this, null, function* () {
2173
2189
  const e2 = yield this._realtimeClient.getUser(this.brandedId);
2174
- return Se("Get user " + this.id, e2);
2190
+ return Te("Get user " + this.id, e2);
2175
2191
  });
2176
2192
  }
2177
2193
  set(t2) {
@@ -2737,7 +2753,7 @@ var Qe, Ve = function() {
2737
2753
  }, e2.urlMatchDoesNotHaveAtLeastOneWordChar = function(e3, t2) {
2738
2754
  return !(!e3 || !t2) && (!this.hasFullProtocolRegex.test(t2) && !this.hasWordCharAfterProtocolRegex.test(e3));
2739
2755
  }, e2.hasFullProtocolRegex = /^[A-Za-z][-.+A-Za-z0-9]*:\/\//, e2.uriSchemeRegex = /^[A-Za-z][-.+A-Za-z0-9]*:/, e2.hasWordCharAfterProtocolRegex = new RegExp(":[^\\s]*?[" + ct + "]"), e2.ipRegex = /[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?(:[0-9]*)?\/?$/, e2;
2740
- }(), xt = (Qe = new RegExp("[/?#](?:[" + pt + "\\-+&@#/%=~_()|'$*\\[\\]{}?!:,.;^✓]*[" + pt + "\\-+&@#/%=~_()|'$*\\[\\]{}✓])?"), new RegExp(["(?:", "(", /(?:[A-Za-z][-.+A-Za-z0-9]{0,63}:(?![A-Za-z][-.+A-Za-z0-9]{0,63}:\/\/)(?!\d+\/?)(?:\/\/)?)/.source, vt(2), ")", "|", "(", "(//)?", /(?:www\.)/.source, vt(6), ")", "|", "(", "(//)?", vt(10) + "\\.", bt.source, "(?![-" + dt + "])", ")", ")", "(?::[0-9]+)?", "(?:" + Qe.source + ")?"].join(""), "gi")), It = new RegExp("[" + pt + "]"), Tt = function(e2) {
2756
+ }(), xt = (Qe = new RegExp("[/?#](?:[" + pt + "\\-+&@#/%=~_()|'$*\\[\\]{}?!:,.;^✓]*[" + pt + "\\-+&@#/%=~_()|'$*\\[\\]{}✓])?"), new RegExp(["(?:", "(", /(?:[A-Za-z][-.+A-Za-z0-9]{0,63}:(?![A-Za-z][-.+A-Za-z0-9]{0,63}:\/\/)(?!\d+\/?)(?:\/\/)?)/.source, vt(2), ")", "|", "(", "(//)?", /(?:www\.)/.source, vt(6), ")", "|", "(", "(//)?", vt(10) + "\\.", bt.source, "(?![-" + dt + "])", ")", ")", "(?::[0-9]+)?", "(?:" + Qe.source + ")?"].join(""), "gi")), It = new RegExp("[" + pt + "]"), St = function(e2) {
2741
2757
  function t2(t3) {
2742
2758
  var s2 = e2.call(this, t3) || this;
2743
2759
  return s2.stripPrefix = { scheme: true, www: true }, s2.stripTrailingSlash = true, s2.decodePercentEncoding = true, s2.matcherRegex = xt, s2.wordCharRegExp = It, s2.stripPrefix = t3.stripPrefix, s2.stripTrailingSlash = t3.stripTrailingSlash, s2.decodePercentEncoding = t3.decodePercentEncoding, s2;
@@ -2784,10 +2800,10 @@ var Qe, Ve = function() {
2784
2800
  var n2 = new RegExp("^((.?//)?[-." + pt + "]*[-" + pt + "]\\.[-" + pt + "]+)").exec(e3);
2785
2801
  return null === n2 ? -1 : (s2 += n2[1].length, e3 = e3.slice(n2[1].length), /^[^-.A-Za-z0-9:\/?#]/.test(e3) ? s2 : -1);
2786
2802
  }, t2;
2787
- }(st), St = new RegExp("#[_" + pt + "]{1,139}(?![_" + pt + "])", "g"), Dt = new RegExp("[^" + pt + "]"), Mt = function(e2) {
2803
+ }(st), Tt = new RegExp("#[_" + pt + "]{1,139}(?![_" + pt + "])", "g"), Dt = new RegExp("[^" + pt + "]"), Mt = function(e2) {
2788
2804
  function t2(t3) {
2789
2805
  var s2 = e2.call(this, t3) || this;
2790
- return s2.serviceName = "twitter", s2.matcherRegex = St, s2.nonWordCharRegex = Dt, s2.serviceName = t3.serviceName, s2;
2806
+ return s2.serviceName = "twitter", s2.matcherRegex = Tt, s2.nonWordCharRegex = Dt, s2.serviceName = t3.serviceName, s2;
2791
2807
  }
2792
2808
  return Ye(t2, e2), t2.prototype.parseMatches = function(e3) {
2793
2809
  for (var t3, s2 = this.matcherRegex, n2 = this.nonWordCharRegex, r2 = this.serviceName, i2 = this.tagBuilder, a2 = []; null !== (t3 = s2.exec(e3)); ) {
@@ -2872,10 +2888,10 @@ function Ut(e2, t2) {
2872
2888
  I2(f2);
2873
2889
  break;
2874
2890
  case 12:
2875
- T2(f2);
2891
+ S2(f2);
2876
2892
  break;
2877
2893
  case 13:
2878
- S2();
2894
+ T2();
2879
2895
  break;
2880
2896
  case 14:
2881
2897
  D2(f2);
@@ -2939,10 +2955,10 @@ function Ut(e2, t2) {
2939
2955
  function I2(e3) {
2940
2956
  at.test(e3) ? h2 = 4 : "/" === e3 ? h2 = 12 : ">" === e3 ? U2() : "<" === e3 ? O2() : (h2 = 4, c2--);
2941
2957
  }
2942
- function T2(e3) {
2958
+ function S2(e3) {
2943
2959
  ">" === e3 ? (p2 = new jt(Ve(Ve({}, p2), { isClosing: true })), U2()) : h2 = 4;
2944
2960
  }
2945
- function S2(t3) {
2961
+ function T2(t3) {
2946
2962
  "--" === e2.substr(c2, 2) ? (c2 += 2, p2 = new jt(Ve(Ve({}, p2), { type: "comment" })), h2 = 14) : "DOCTYPE" === e2.substr(c2, 7).toUpperCase() ? (c2 += 7, p2 = new jt(Ve(Ve({}, p2), { type: "doctype" })), h2 = 20) : P2();
2947
2963
  }
2948
2964
  function D2(e3) {
@@ -3082,12 +3098,12 @@ var jt = function(e2) {
3082
3098
  return this.replaceFn && (t2 = this.replaceFn.call(this.context, e3)), "string" == typeof t2 ? t2 : false === t2 ? e3.getMatchedText() : t2 instanceof Ge ? t2.toAnchorString() : e3.buildTag().toAnchorString();
3083
3099
  }, e2.prototype.getMatchers = function() {
3084
3100
  if (this.matchers) return this.matchers;
3085
- var e3 = this.getTagBuilder(), t2 = [new Mt({ tagBuilder: e3, serviceName: this.hashtag }), new At({ tagBuilder: e3 }), new Bt({ tagBuilder: e3 }), new Ot({ tagBuilder: e3, serviceName: this.mention }), new Tt({ tagBuilder: e3, stripPrefix: this.stripPrefix, stripTrailingSlash: this.stripTrailingSlash, decodePercentEncoding: this.decodePercentEncoding })];
3101
+ var e3 = this.getTagBuilder(), t2 = [new Mt({ tagBuilder: e3, serviceName: this.hashtag }), new At({ tagBuilder: e3 }), new Bt({ tagBuilder: e3 }), new Ot({ tagBuilder: e3, serviceName: this.mention }), new St({ tagBuilder: e3, stripPrefix: this.stripPrefix, stripTrailingSlash: this.stripTrailingSlash, decodePercentEncoding: this.decodePercentEncoding })];
3086
3102
  return this.matchers = t2;
3087
3103
  }, e2.prototype.getTagBuilder = function() {
3088
3104
  var e3 = this.tagBuilder;
3089
3105
  return e3 || (e3 = this.tagBuilder = new Le({ newWindow: this.newWindow, truncate: this.truncate, className: this.className })), e3;
3090
- }, e2.version = "3.14.3", e2.AnchorTagBuilder = Le, e2.HtmlTag = Ge, e2.matcher = { Email: At, Hashtag: Mt, Matcher: st, Mention: Ot, Phone: Bt, Url: Tt }, e2.match = { Email: Ze, Hashtag: Ke, Match: ze, Mention: Xe, Phone: et, Url: tt }, e2;
3106
+ }, e2.version = "3.14.3", e2.AnchorTagBuilder = Le, e2.HtmlTag = Ge, e2.matcher = { Email: At, Hashtag: Mt, Matcher: st, Mention: Ot, Phone: Bt, Url: St }, e2.match = { Email: Ze, Hashtag: Ke, Match: ze, Mention: Xe, Phone: et, Url: tt }, e2;
3091
3107
  }();
3092
3108
  function Wt(e2, t2 = e2) {
3093
3109
  return { type: "autolink", url: e2, text: t2 };
@@ -3149,29 +3165,32 @@ const ts = function(e2) {
3149
3165
  function ss(e2, t2 = { except: [] }) {
3150
3166
  let s2 = function(e3, t3) {
3151
3167
  let s3 = [e3];
3152
- return s3 = ns(s3, t3.multilineSteps), s3 = ns(s3, [ts]), s3 = ns(s3, t3.singlelineSteps), s3 = rs(s3), s3;
3168
+ return s3 = rs(s3, t3.multilineSteps), s3 = rs(s3, [ts]), s3 = rs(s3, t3.singlelineSteps), s3 = is(s3), s3;
3153
3169
  }(e2, es(t2));
3154
- return s2 = is(s2, false), s2;
3170
+ return s2 = as(s2, false), s2;
3171
+ }
3172
+ function ns(e2) {
3173
+ return ss(e2, { except: ["FormattedLink", "Actions"] });
3155
3174
  }
3156
- function ns(e2, t2) {
3175
+ function rs(e2, t2) {
3157
3176
  return t2.reduce((e3, t3) => Be(e3, t3), e2);
3158
3177
  }
3159
- function rs(e2) {
3178
+ function is(e2) {
3160
3179
  const t2 = [];
3161
3180
  let s2 = -1;
3162
- for (const n2 of e2) "string" == typeof n2 ? "string" == typeof t2[s2] ? t2[s2] += n2 : t2[++s2] = n2 : t2[++s2] = "children" in n2 ? __spreadProps(__spreadValues({}, n2), { children: rs(n2.children) }) : n2;
3181
+ for (const n2 of e2) "string" == typeof n2 ? "string" == typeof t2[s2] ? t2[s2] += n2 : t2[++s2] = n2 : t2[++s2] = "children" in n2 ? __spreadProps(__spreadValues({}, n2), { children: is(n2.children) }) : n2;
3163
3182
  return t2;
3164
3183
  }
3165
- function is(e2, t2) {
3184
+ function as(e2, t2) {
3166
3185
  const s2 = [];
3167
3186
  let n2 = [];
3168
3187
  for (let r2 = 0; r2 < e2.length; r2++) {
3169
3188
  const i2 = e2[r2];
3170
- "string" == typeof i2 ? n2.push(i2) : "children" in i2 ? (n2.length > 0 && (s2.push(n2.join("")), n2 = []), i2.children = is(i2.children, t2 || "link" === i2.type || "actionbutton" === i2.type || "actionlink" === i2.type), s2.push(i2)) : "autolink" === i2.type && t2 ? n2.push(i2.text) : (n2.length > 0 && (s2.push(n2.join("")), n2 = []), s2.push(i2));
3189
+ "string" == typeof i2 ? n2.push(i2) : "children" in i2 ? (n2.length > 0 && (s2.push(n2.join("")), n2 = []), i2.children = as(i2.children, t2 || "link" === i2.type || "actionbutton" === i2.type || "actionlink" === i2.type), s2.push(i2)) : "autolink" === i2.type && t2 ? n2.push(i2.text) : (n2.length > 0 && (s2.push(n2.join("")), n2 = []), s2.push(i2));
3171
3190
  }
3172
3191
  return n2.length > 0 && (s2.push(n2.join("")), n2 = []), s2;
3173
3192
  }
3174
- class as {
3193
+ class os {
3175
3194
  constructor(e2, t2, s2, n2) {
3176
3195
  this.emoji = e2, this.messageId = t2, this.conversationId = s2, this._realtimeClient = n2;
3177
3196
  }
@@ -3194,7 +3213,7 @@ class as {
3194
3213
  });
3195
3214
  }
3196
3215
  }
3197
- class os {
3216
+ class us {
3198
3217
  constructor(e2, t2, s2) {
3199
3218
  this.id = e2, this.conversationId = t2, this._realtimeClient = s2;
3200
3219
  }
@@ -3207,7 +3226,7 @@ class os {
3207
3226
  reaction(e2) {
3208
3227
  if ("string" != typeof e2) throw new Error(`Creating ReactionRef failed because emoji "${e2}" is not a string`);
3209
3228
  if ("" === e2) throw new Error(`Creating ReactionRef failed because emoji "${e2}" is an empty string`);
3210
- return new as(e2, this.brandedId, this.brandedConversationId, this._realtimeClient);
3229
+ return new os(e2, this.brandedId, this.brandedConversationId, this._realtimeClient);
3211
3230
  }
3212
3231
  get() {
3213
3232
  return __async(this, null, function* () {
@@ -3215,12 +3234,12 @@ class os {
3215
3234
  if (!t2.ok && "server" === t2.where && 404 === t2.value.status) return null;
3216
3235
  if (!t2.ok && "server" === t2.where && 403 === t2.value.status && "NOT_A_PARTICIPANT" === t2.value.errorCode) return null;
3217
3236
  const s2 = e("Get message " + this.id, t2), n2 = yield this._realtimeClient.createMessageSnapshot(s2, this.brandedConversationId);
3218
- return Se("Get message " + this.id, n2);
3237
+ return Te("Get message " + this.id, n2);
3219
3238
  });
3220
3239
  }
3221
3240
  edit(t2) {
3222
3241
  return __async(this, null, function* () {
3223
- const s2 = { content: us(t2), custom: "string" == typeof t2 ? void 0 : t2.custom }, n2 = yield this._realtimeClient.call("PATCH", ["conversations", this.brandedConversationId, "messages", this.brandedId], s2);
3242
+ const s2 = { content: cs(t2), custom: "string" == typeof t2 ? void 0 : t2.custom }, n2 = yield this._realtimeClient.call("PATCH", ["conversations", this.brandedConversationId, "messages", this.brandedId], s2);
3224
3243
  e(`Edit message ${this.id} in conversation ${this.conversationId}`, n2);
3225
3244
  });
3226
3245
  }
@@ -3231,7 +3250,7 @@ class os {
3231
3250
  });
3232
3251
  }
3233
3252
  }
3234
- function us(e2) {
3253
+ function cs(e2) {
3235
3254
  if ("string" == typeof e2) {
3236
3255
  return [{ type: "text", children: ss(e2) }];
3237
3256
  }
@@ -3240,7 +3259,7 @@ function us(e2) {
3240
3259
  }
3241
3260
  if ("content" in e2 && e2.content) return e2.content;
3242
3261
  }
3243
- class cs {
3262
+ class ls {
3244
3263
  constructor(e2, t2) {
3245
3264
  this.id = e2, this._realtimeClient = t2, this.uselessObjForTypeCheck = { subject: null, photoUrl: null, welcomeMessages: null, custom: null, access: null, notify: null };
3246
3265
  }
@@ -3261,13 +3280,13 @@ class cs {
3261
3280
  message(e2) {
3262
3281
  if ("string" != typeof e2) throw new Error(`Creating MessageRef failed because ID "${e2}" is not a string`);
3263
3282
  if ("" === e2) throw new Error(`Creating MessageRef failed because ID "${e2}" is an empty string`);
3264
- return new os(e2, this.brandedId, this._realtimeClient);
3283
+ return new us(e2, this.brandedId, this._realtimeClient);
3265
3284
  }
3266
3285
  get() {
3267
3286
  return __async(this, null, function* () {
3268
3287
  const t2 = this._realtimeClient.listMessages(this.brandedId, { limit: 1 }), s2 = yield this._realtimeClient.call("GET", ["me", "conversations", this.brandedId], {});
3269
3288
  if (!s2.ok && "server" === s2.where && 404 === s2.value.status) return null;
3270
- const n2 = e("Get conversation " + this.id, s2), r2 = Se("Get last message in conversation " + this.id, yield t2), i2 = 0 === r2.length ? null : r2[0];
3289
+ const n2 = e("Get conversation " + this.id, s2), r2 = Te("Get last message in conversation " + this.id, yield t2), i2 = 0 === r2.length ? null : r2[0];
3271
3290
  return this._realtimeClient.createConversationSnapshotPreloaded(n2, i2);
3272
3291
  });
3273
3292
  }
@@ -3310,8 +3329,8 @@ class cs {
3310
3329
  }
3311
3330
  send(t2) {
3312
3331
  return __async(this, null, function* () {
3313
- const s2 = { content: ls(t2), referencedMessageId: hs(t2), custom: "string" == typeof t2 ? void 0 : t2.custom, idempotencyKey: Fe((/* @__PURE__ */ new Date()).getTime()) }, n2 = yield this._realtimeClient.call("POST", ["conversations", this.brandedId, "messages"], s2), r2 = e("Send message to conversation " + this.id, n2);
3314
- return new os(r2.id, this.brandedId, this._realtimeClient);
3332
+ const s2 = { content: hs(t2), referencedMessageId: ds(t2), custom: "string" == typeof t2 ? void 0 : t2.custom, idempotencyKey: Fe((/* @__PURE__ */ new Date()).getTime()) }, n2 = yield this._realtimeClient.call("POST", ["conversations", this.brandedId, "messages"], s2), r2 = e("Send message to conversation " + this.id, n2);
3333
+ return new us(r2.id, this.brandedId, this._realtimeClient);
3315
3334
  });
3316
3335
  }
3317
3336
  subscribeMessages(e2) {
@@ -3333,21 +3352,21 @@ class cs {
3333
3352
  });
3334
3353
  }
3335
3354
  }
3336
- function ls(e2) {
3355
+ function hs(e2) {
3337
3356
  if ("string" == typeof e2) {
3338
- return [{ type: "text", children: ss(e2, { except: ["FormattedLink", "Actions"] }) }];
3357
+ return [{ type: "text", children: ns(e2) }];
3339
3358
  }
3340
3359
  if ("text" in e2) {
3341
- return [{ type: "text", children: ss(e2.text, { except: ["FormattedLink", "Actions"] }) }];
3360
+ return [{ type: "text", children: ns(e2.text) }];
3342
3361
  }
3343
3362
  return e2.content;
3344
3363
  }
3345
- function hs(e2) {
3364
+ function ds(e2) {
3346
3365
  if ("string" == typeof e2) return;
3347
3366
  const t2 = e2.referencedMessage;
3348
3367
  return void 0 !== t2 ? "string" == typeof t2 ? t2 : t2.id : void 0;
3349
3368
  }
3350
- class ds {
3369
+ class ps {
3351
3370
  constructor(e2, t2, s2) {
3352
3371
  this.realtimeWsApiUrl = e2, this.internalHttpApiUrl = t2, this.restApiHttpUrl = s2;
3353
3372
  }
@@ -3359,23 +3378,23 @@ class ds {
3359
3378
  return this.realtimeWsApiUrl + `/${e2}/realtime/${i2}?talkjs-client-build=${r2 != null ? r2 : "standalone"}&talkjs-core=${s2}&talkjs-client-id=${n2}`;
3360
3379
  }
3361
3380
  static fromHost(e2) {
3362
- const t2 = new ds("wss://realtime.talkjs.com/v1", "https://app.talkjs.com/api/v0", "https://api.talkjs.com/v1");
3381
+ const t2 = new ps("wss://realtime.talkjs.com/v1", "https://app.talkjs.com/api/v0", "https://api.talkjs.com/v1");
3363
3382
  if (!e2) return t2;
3364
3383
  if (e2.endsWith("talkjs.com")) {
3365
3384
  const s2 = e2.match(/\w+-(\w+)\.talkjs\.com/);
3366
3385
  if (s2) {
3367
3386
  const e3 = s2[1];
3368
- return new ds(`wss://realtime-${e3}.talkjs.com/v1`, `https://app-${e3}.talkjs.com/api/v0`, `https://api-${e3}.talkjs.com/v1`);
3387
+ return new ps(`wss://realtime-${e3}.talkjs.com/v1`, `https://app-${e3}.talkjs.com/api/v0`, `https://api-${e3}.talkjs.com/v1`);
3369
3388
  }
3370
3389
  return t2;
3371
3390
  }
3372
- return e2.includes("localhost") || e2.includes("localtest.me") || /^\d+\.\d+\.\d+\.\d+(:\d+)?$/.test(e2) ? new ds(`ws://${e2}/public_api/v1`, `http://${e2}/api/v0`, `http://${e2}/public_api/v1`) : new ds(`wss://${e2}/public_api/v1`, `https://${e2}/api/v0`, `https://${e2}/public_api/v1`);
3391
+ return e2.includes("localhost") || e2.includes("localtest.me") || /^\d+\.\d+\.\d+\.\d+(:\d+)?$/.test(e2) ? new ps(`ws://${e2}/public_api/v1`, `http://${e2}/api/v0`, `http://${e2}/public_api/v1`) : new ps(`wss://${e2}/public_api/v1`, `https://${e2}/api/v0`, `https://${e2}/public_api/v1`);
3373
3392
  }
3374
3393
  }
3375
- function ps({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2 }) {
3394
+ function fs({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2 }) {
3376
3395
  var _a2;
3377
3396
  (!r2 || r2 <= 0) && (r2 = 1);
3378
- const u2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-08-22T14:45:07.259Z" };
3397
+ const u2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-09-02T09:13:11.435Z" };
3379
3398
  s2 instanceof FormData || (u2["Content-Type"] = (_a2 = n2 == null ? void 0 : n2.contentType) != null ? _a2 : "application/json");
3380
3399
  return a(r2, () => __async(this, null, function* () {
3381
3400
  if (o2) {
@@ -3387,19 +3406,19 @@ function ps({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRe
3387
3406
  throw e3;
3388
3407
  });
3389
3408
  }), { initialDelay: 0.2, log: void 0, shouldRetry: (s3) => __async(this, null, function* () {
3390
- return o2 && 401 === s3.status ? (Cs.log(`401 error from ${e2} ${t2}, ${yield o2.getToken()}`), o2.refreshToken(), true) : i2 ? i2(s3) : !("status" in s3 && s3.status >= 400 && s3.status < 500);
3409
+ return o2 && 401 === s3.status ? (As.log(`401 error from ${e2} ${t2}, ${yield o2.getToken()}`), o2.refreshToken(), true) : i2 ? i2(s3) : !("status" in s3 && s3.status >= 400 && s3.status < 500);
3391
3410
  }) }).catch((s3) => {
3392
3411
  if (Math.random() < 0.1 && !t2.toString().startsWith("https://capture.trackjs.com")) {
3393
3412
  const n3 = `Network Error for ${e2} ${t2}`;
3394
3413
  if ("undefined" != typeof window) if (s3 instanceof Response) {
3395
- s3.clone().text().then((e3) => Cs.log(`${n3} ${s3.status} ${e3} (10% logged)`));
3396
- } else Cs.log(`${n3} ${s3} (10% logged)`);
3414
+ s3.clone().text().then((e3) => As.log(`${n3} ${s3.status} ${e3} (10% logged)`));
3415
+ } else As.log(`${n3} ${s3} (10% logged)`);
3397
3416
  console.error("[TalkJS]", n3);
3398
3417
  }
3399
3418
  throw s3;
3400
3419
  });
3401
3420
  }
3402
- const { cdnHost: fs, appHost: ms, restHost: gs, realtimeHost: vs, appProtocol: ws, appWsProtocol: bs } = function() {
3421
+ const { cdnHost: ms, appHost: gs, restHost: vs, realtimeHost: ws, appProtocol: bs, appWsProtocol: ys } = function() {
3403
3422
  if ("undefined" == typeof window) return { cdnHost: "test-hostname", appHost: "test-hostname", appProtocol: "http:", appWsProtocol: "ws:" };
3404
3423
  const e2 = function() {
3405
3424
  if (document.currentScript) return document.currentScript.src;
@@ -3424,11 +3443,11 @@ const { cdnHost: fs, appHost: ms, restHost: gs, realtimeHost: vs, appProtocol: w
3424
3443
  }(n2), a2 = t2.protocol;
3425
3444
  return { cdnHost: s2, appHost: n2, restHost: r2, realtimeHost: i2, appProtocol: a2, appWsProtocol: "https:" === a2 ? "wss:" : "ws:" };
3426
3445
  }();
3427
- const ys = ms.startsWith("app.talkjs.com");
3428
- const Cs = "undefined" == typeof window ? { log: (e2) => Promise.resolve(), setData: (e2) => {
3446
+ const Cs = gs.startsWith("app.talkjs.com");
3447
+ const As = "undefined" == typeof window ? { log: (e2) => Promise.resolve(), setData: (e2) => {
3429
3448
  } } : new class {
3430
3449
  constructor(e2) {
3431
- this._timeCreated = Date.now(), this._enabled = ys, this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-08-22T14:45:07.259Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: window.location.href, referrer: document.referrer, userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: window.location.href, stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2025-08-22T14:45:07.259Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
3450
+ this._timeCreated = Date.now(), this._enabled = Cs, this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-09-02T09:13:11.435Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: window.location.href, referrer: document.referrer, userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: window.location.href, stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2025-09-02T09:13:11.435Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
3432
3451
  }
3433
3452
  setData({ appId: e2, meId: t2, sessionId: s2 }) {
3434
3453
  this._trackJSData.customer.userId = e2, this._trackJSData.customer.sessionId = `${e2}/${t2}`, this._trackJSData.customer.correlationId = s2;
@@ -3438,14 +3457,14 @@ const Cs = "undefined" == typeof window ? { log: (e2) => Promise.resolve(), setD
3438
3457
  try {
3439
3458
  if (!this._enabled) return Promise.resolve();
3440
3459
  const t2 = __spreadProps(__spreadValues({}, this._trackJSData), { message: e2 });
3441
- yield ps({ method: "POST", url: this._url, data: JSON.stringify(t2), options: { contentType: "text/plain" } });
3460
+ yield fs({ method: "POST", url: this._url, data: JSON.stringify(t2), options: { contentType: "text/plain" } });
3442
3461
  } catch (e3) {
3443
3462
  console.error("[TalkJS] Failed when sending an error report. Error: ", e3);
3444
3463
  }
3445
3464
  });
3446
3465
  }
3447
3466
  }("970cd0be0fb74630b75c8451051299dc");
3448
- class As {
3467
+ class Es {
3449
3468
  constructor(e2, t2 = {}) {
3450
3469
  this._onSubscription = t2, this._handlers = {};
3451
3470
  for (const t3 in e2) Object.hasOwnProperty.call(e2, t3) && (this._handlers[t3] = []);
@@ -3490,9 +3509,9 @@ class As {
3490
3509
  return this.on(e2, t2), { unsubscribe: () => this.off(e2, t2) };
3491
3510
  }
3492
3511
  }
3493
- class Es {
3512
+ class ks {
3494
3513
  constructor(e2, t2, s2, n2, r2, i2) {
3495
- if (this.appId = t2, this.userId = s2, this.tokenFetcher = r2, this.usingBokens = false, this.requestInProgress = false, this.eventEmitter = new As({ tokenChanged(e3) {
3514
+ if (this.appId = t2, this.userId = s2, this.tokenFetcher = r2, this.usingBokens = false, this.requestInProgress = false, this.eventEmitter = new Es({ tokenChanged(e3) {
3496
3515
  }, tokenRefreshFailed(e3) {
3497
3516
  }, tokenAccepted(e3) {
3498
3517
  } }), this.sessionExpiryWarningTimeoutId = void 0, i2 && (n2 || r2)) throw new Error("[TalkJS] If providing a signature for authentication, you must not provide a token or tokenFetcher.");
@@ -3584,7 +3603,7 @@ class Es {
3584
3603
  const e3 = function(e4) {
3585
3604
  const t3 = e4.split(".");
3586
3605
  if (3 !== t3.length) throw "Token does not contain exactly two `.`. Check that you generated your JWT correctly. It should be `<header>.<payload>.<signature>`.";
3587
- return { header: ks(t3[0]), payload: ks(t3[1]) };
3606
+ return { header: xs(t3[0]), payload: xs(t3[1]) };
3588
3607
  }(s2);
3589
3608
  n2 = e3.header, r2 = e3.payload;
3590
3609
  } catch (e3) {
@@ -3598,7 +3617,7 @@ class Es {
3598
3617
  const e3 = this.checkJwtPayload(r2);
3599
3618
  t2.push(...e3);
3600
3619
  }
3601
- if (t2.length) if (this.usingBokens) Cs.log(`JWT Errors detected by AuthProvider when using bokens: ${t2.join("\n")}`);
3620
+ if (t2.length) if (this.usingBokens) As.log(`JWT Errors detected by AuthProvider when using bokens: ${t2.join("\n")}`);
3602
3621
  else {
3603
3622
  console.warn("[TalkJS] Authentication token appears to be generated incorrectly. Will still attempt to authenticate, but TalkJS may not work as expected. See below for a description of any problems and how to fix them.");
3604
3623
  const s3 = t2.length > 1;
@@ -3627,7 +3646,7 @@ class Es {
3627
3646
  sendBokenRequest(e2, t2) {
3628
3647
  return __async(this, null, function* () {
3629
3648
  let s2 = 0;
3630
- const n2 = e2.getBokensUrl(this.appId, this.userId, t2), r2 = yield ps({ method: "GET", url: n2, attempts: 1e4, shouldRetry: (e3) => {
3649
+ const n2 = e2.getBokensUrl(this.appId, this.userId, t2), r2 = yield fs({ method: "GET", url: n2, attempts: 1e4, shouldRetry: (e3) => {
3631
3650
  if (e3 instanceof Error) return true;
3632
3651
  if (401 === e3.status) throw "Check that you provided a valid signature.";
3633
3652
  if (404 === e3.status) throw "Check that you specified the correct App ID.";
@@ -3640,7 +3659,7 @@ class Es {
3640
3659
  });
3641
3660
  }
3642
3661
  }
3643
- function ks(e2) {
3662
+ function xs(e2) {
3644
3663
  try {
3645
3664
  const t2 = e2.replace(/-/g, "+").replace(/_/g, "/"), s2 = decodeURIComponent(atob(t2).split("").map((e3) => "%" + ("00" + e3.charCodeAt(0).toString(16)).slice(-2)).join(""));
3646
3665
  return JSON.parse(s2);
@@ -3648,7 +3667,7 @@ function ks(e2) {
3648
3667
  throw `Could not base64-decode and JSON-parse token section: ${e2}. Check that you base-64 encoded the section correctly.`;
3649
3668
  }
3650
3669
  }
3651
- class xs {
3670
+ class Is {
3652
3671
  constructor(e2) {
3653
3672
  this.target = e2;
3654
3673
  }
@@ -3656,7 +3675,7 @@ class xs {
3656
3675
  return this.target;
3657
3676
  }
3658
3677
  }
3659
- const Is = new class {
3678
+ const Ss = new class {
3660
3679
  constructor() {
3661
3680
  this.registry = {};
3662
3681
  }
@@ -3664,7 +3683,7 @@ const Is = new class {
3664
3683
  var _a2;
3665
3684
  const t2 = this.key(e2), s2 = (_a2 = this.registry[t2]) == null ? void 0 : _a2.deref();
3666
3685
  if (s2) return s2;
3667
- const n2 = new Ss(e2), r2 = globalThis.WeakRef ? new WeakRef(n2) : new xs(n2);
3686
+ const n2 = new Ds(e2), r2 = globalThis.WeakRef ? new WeakRef(n2) : new Is(n2);
3668
3687
  return this.registry[t2] = r2, n2;
3669
3688
  }
3670
3689
  deregister(e2, t2) {
@@ -3676,9 +3695,9 @@ const Is = new class {
3676
3695
  }
3677
3696
  }();
3678
3697
  function Ts(e2) {
3679
- return e2.forceCreateNew ? new Ss(e2) : Is.getOrCreate(e2);
3698
+ return e2.forceCreateNew ? new Ds(e2) : Ss.getOrCreate(e2);
3680
3699
  }
3681
- class Ss {
3700
+ class Ds {
3682
3701
  constructor(e2) {
3683
3702
  !function(e3) {
3684
3703
  function t3(e4, t4) {
@@ -3688,13 +3707,13 @@ class Ss {
3688
3707
  void 0 !== e3.tokenFetcher && t3("function" == typeof e3.tokenFetcher, "The `tokenFetcher` property of TalkSession#constructor must be a function.");
3689
3708
  }(e2);
3690
3709
  const { appId: t2, userId: s2, token: n2, tokenFetcher: r2, signature: i2 } = e2;
3691
- this._appId = t2, this._apiUrls = e2.apiUrls ? new ds(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : ds.fromHost(e2.host), this._authProvider = new Es(this._apiUrls, t2, s2, n2, r2, i2);
3710
+ this._appId = t2, this._apiUrls = e2.apiUrls ? new ps(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : ps.fromHost(e2.host), this._authProvider = new ks(this._apiUrls, t2, s2, n2, r2, i2);
3692
3711
  const a2 = Math.random().toString().split(".")[1];
3693
- this._realtimeClient = new Ie(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.5.0", a2, e2.clientBuild), s2, this._authProvider), this.currentUser = new De(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
3712
+ this._realtimeClient = new Ie(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.5.2", a2, e2.clientBuild), s2, this._authProvider), this.currentUser = new De(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
3694
3713
  console.error(`[TalkSession] ${e3}`);
3695
3714
  }), function(e3, t3, s3) {
3696
3715
  return __async(this, null, function* () {
3697
- return ps({ method: "GET", url: `${t3}/${e3}/app`, authProvider: s3 }).then((e4) => 200 === e4.status || 404 !== e4.status && (console.warn(`[TalkJS] Received unexpected ${e4.status} status code when validating app ID. Assuming that the app ID is valid.`), true)).catch((e4) => {
3716
+ return fs({ method: "GET", url: `${t3}/${e3}/app`, authProvider: s3 }).then((e4) => 200 === e4.status || 404 !== e4.status && (console.warn(`[TalkJS] Received unexpected ${e4.status} status code when validating app ID. Assuming that the app ID is valid.`), true)).catch((e4) => {
3698
3717
  if ("string" != typeof e4 && "status" in e4) {
3699
3718
  const t4 = e4;
3700
3719
  return 200 === t4.status || 404 !== t4.status && (console.warn(`[TalkJS] Received unexpected ${t4.status} status code when validating app ID. Assuming that the app ID is valid.`), true);
@@ -3722,37 +3741,37 @@ class Ss {
3722
3741
  conversation(e2) {
3723
3742
  if ("string" != typeof e2) throw new Error(`Creating ConversationRef failed because ID "${e2}" is not a string`);
3724
3743
  if ("" === e2) throw new Error(`Creating ConversationRef failed because ID "${e2}" is an empty string`);
3725
- return new cs(e2, this._realtimeClient);
3744
+ return new ls(e2, this._realtimeClient);
3726
3745
  }
3727
3746
  subscribeConversations(e2) {
3728
3747
  return this._realtimeClient.subscribe(["me", "conversations"], e2);
3729
3748
  }
3730
3749
  terminate(e2) {
3731
- Is.deregister(this._appId, this.currentUser.id), this._terminationReason.resolve(e2), this._realtimeClient.destroy();
3750
+ Ss.deregister(this._appId, this.currentUser.id), this._terminationReason.resolve(e2), this._realtimeClient.destroy();
3732
3751
  }
3733
3752
  _isConnected() {
3734
3753
  return this._realtimeClient.isConnected();
3735
3754
  }
3736
3755
  uploadFile(e2, t2) {
3737
- return Ds(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, t2);
3756
+ return Ms(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, t2);
3738
3757
  }
3739
3758
  uploadImage(e2, t2) {
3740
- return Ds(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "image" }, t2));
3759
+ return Ms(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "image" }, t2));
3741
3760
  }
3742
3761
  uploadVideo(e2, t2) {
3743
- return Ds(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "video" }, t2));
3762
+ return Ms(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "video" }, t2));
3744
3763
  }
3745
3764
  uploadAudio(e2, t2) {
3746
- return Ds(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "audio" }, t2));
3765
+ return Ms(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "audio" }, t2));
3747
3766
  }
3748
3767
  uploadVoice(e2, t2) {
3749
- return Ds(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "voice" }, t2));
3768
+ return Ms(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "voice" }, t2));
3750
3769
  }
3751
3770
  }
3752
- function Ds(_0, _1, _2, _3) {
3771
+ function Ms(_0, _1, _2, _3) {
3753
3772
  return __async(this, arguments, function* (e2, t2, s2, { subtype: n2, filename: r2, width: i2, height: a2, duration: o2 }) {
3754
3773
  const u2 = new FormData();
3755
- return u2.set("file", s2, r2), void 0 !== n2 && u2.set("subtype", n2), void 0 !== i2 && u2.set("width", i2.toString()), void 0 !== a2 && u2.set("height", a2.toString()), void 0 !== o2 && u2.set("duration", o2.toString()), ps({ method: "POST", url: e2, data: u2, authProvider: t2 }).then((e3) => e3.json()).then((e3) => e3.attachmentToken).catch((e3) => __async(this, null, function* () {
3774
+ return u2.set("file", s2, r2), void 0 !== n2 && u2.set("subtype", n2), void 0 !== i2 && u2.set("width", i2.toString()), void 0 !== a2 && u2.set("height", a2.toString()), void 0 !== o2 && u2.set("duration", o2.toString()), fs({ method: "POST", url: e2, data: u2, authProvider: t2 }).then((e3) => e3.json()).then((e3) => e3.attachmentToken).catch((e3) => __async(this, null, function* () {
3756
3775
  if (e3 instanceof Response) {
3757
3776
  const t3 = yield e3.json(), s3 = `Unexpected response when uploading file, status code ${e3.status} ${t3.errorCode}, ${t3.reasons}`;
3758
3777
  throw new Error(s3);