@talkjs/core 1.5.9 → 1.6.1

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.
@@ -135,7 +135,7 @@ let p = null;
135
135
  function f({ WebSocket: e2 }) {
136
136
  p = e2;
137
137
  }
138
- class m {
138
+ class g {
139
139
  constructor(e2, t2) {
140
140
  this.realtimeUrl = e2, this.handlers = t2, this.socket = null, this.stateMachine = new u("ReconnectingSocket", ["STOPPED", "CONNECTING", "READY", "DISCONNECTED", "TERMINATED"], { startWs: { from: ["STOPPED", "DISCONNECTED"], to: "CONNECTING", afterTransition: () => {
141
141
  const e3 = new (function() {
@@ -184,9 +184,9 @@ class m {
184
184
  this.stateMachine.transition("destroy");
185
185
  }
186
186
  }
187
- class g {
187
+ class m {
188
188
  constructor(e2, t2) {
189
- this.handlers = t2, this.socket = new m(e2, { onOpen: () => this.handlers.onOpen(), onClose: () => this.handlers.onClose(), onMessage: (e3) => this.onWebSocketMessage(e3) });
189
+ this.handlers = t2, this.socket = new g(e2, { onOpen: () => this.handlers.onOpen(), onClose: () => this.handlers.onClose(), onMessage: (e3) => this.onWebSocketMessage(e3) });
190
190
  }
191
191
  call(e2, t2, s2, n2) {
192
192
  const r2 = `/${s2.map((e3) => encodeURIComponent(e3)).join("/")}`, i2 = JSON.stringify([e2, t2, r2, n2]);
@@ -205,7 +205,7 @@ class g {
205
205
  this.socket.terminate();
206
206
  }
207
207
  onWebSocketMessage(e2) {
208
- if ("Auth token expired" !== e2.data) try {
208
+ try {
209
209
  const t2 = JSON.parse(e2.data);
210
210
  if ("PUBLISH" === t2[1]) {
211
211
  const e3 = t2[0], s2 = JSON.stringify([e3, "ACK"]);
@@ -220,7 +220,6 @@ class g {
220
220
  }
221
221
  } catch (e3) {
222
222
  }
223
- else this.handlers.onAuthExpired();
224
223
  }
225
224
  }
226
225
  class v {
@@ -249,7 +248,7 @@ class w {
249
248
  }
250
249
  class b {
251
250
  constructor(e2, t2) {
252
- this.handlers = t2, this.seqCounter = new w(), this.responseHandlers = {}, this.heartbeats = new y(this), this.socket = new g(e2, { onUpstreamRestarting: () => {
251
+ this.handlers = t2, this.seqCounter = new w(), this.responseHandlers = {}, this.heartbeats = new y(this), this.socket = new m(e2, { onUpstreamRestarting: () => {
253
252
  this.heartbeats.serverActive(), this.handlers.onUpstreamRestarting();
254
253
  }, onOpen: () => {
255
254
  this.heartbeats.clientActive(), this.heartbeats.serverActive(), this.handlers.onReady();
@@ -321,15 +320,15 @@ class C {
321
320
  this.authProvider = t2, this.handlers = s2, this.stateMachine = new u("AuthenticatedConnection", ["WAITING_FOR_WS", "LOGGING_IN", "RENEWING_SESSION", "READY", "TERMINATED"], { logIn: { from: ["WAITING_FOR_WS"], to: "LOGGING_IN", afterTransition: () => __async(this, null, function* () {
322
321
  yield this.renewSession();
323
322
  }) }, logInFailed: { from: ["LOGGING_IN"], to: "LOGGING_IN", afterTransition: () => __async(this, null, function* () {
324
- this.authProvider.refreshToken(), yield this.renewSession();
323
+ this.authProvider.invalidateAndRefresh(), yield this.renewSession();
325
324
  }) }, scheduledReauth: { from: ["READY"], to: "RENEWING_SESSION", afterTransition: () => __async(this, null, function* () {
326
325
  yield this.renewSession();
327
326
  }) }, scheduledReauthFailed: { from: ["RENEWING_SESSION"], to: "RENEWING_SESSION", afterTransition: () => __async(this, null, function* () {
328
- this.authProvider.refreshToken(), yield this.renewSession();
327
+ this.authProvider.invalidateAndRefresh(), yield this.renewSession();
329
328
  }) }, authenticated: { from: ["LOGGING_IN", "RENEWING_SESSION"], to: "READY", afterTransition: ({ from: e3 }) => {
330
329
  "LOGGING_IN" === e3 && this.handlers.onReady();
331
330
  } }, authExpired: { from: ["READY", "RENEWING_SESSION"], to: "LOGGING_IN", afterTransition: () => __async(this, null, function* () {
332
- this.handlers.onNotReady(), this.authProvider.refreshToken(), yield this.renewSession();
331
+ this.handlers.onNotReady(), this.authProvider.invalidateAndRefresh(), yield this.renewSession();
333
332
  }) }, wsDisconnected: { from: ["READY", "LOGGING_IN", "RENEWING_SESSION"], to: "WAITING_FOR_WS", afterTransition: ({ from: e3 }) => {
334
333
  "READY" !== e3 && "RENEWING_SESSION" !== e3 || this.handlers.onNotReady(), this.authProvider.clearScheduledRefresh();
335
334
  } }, destroy: { from: "ANY", to: "TERMINATED", afterTransition: () => {
@@ -354,14 +353,18 @@ class C {
354
353
  this.connection.stopWs();
355
354
  }
356
355
  startWs() {
357
- this.connection.startWs();
356
+ this.connection.startWs(), this.authProvider.getToken().catch(() => {
357
+ });
358
358
  }
359
359
  destroy() {
360
360
  this.stateMachine.transition("destroy");
361
361
  }
362
362
  renewSession() {
363
363
  return __async(this, null, function* () {
364
- const e2 = yield this.authProvider.getToken(), s2 = yield this.connection.call("POST", ["session", "renew"], { token: e2 });
364
+ const e2 = yield this.authProvider.getToken().catch(() => {
365
+ });
366
+ if (!e2) return;
367
+ const s2 = yield this.connection.call("POST", ["session", "renew"], { token: e2 });
365
368
  if (!s2.ok && "client" === s2.where) return;
366
369
  const n2 = s2.value;
367
370
  if (n2.status, 200 === n2.status) {
@@ -956,7 +959,7 @@ function V(e2, t2) {
956
959
  const s2 = t2.lastIndex;
957
960
  let n2;
958
961
  const r2 = [];
959
- for (; null !== (n2 = t2.exec(e2)); ) r2.push(n2);
962
+ for (; null !== (n2 = t2.exec(e2)); ) r2.push(n2), "" === n2[0] && (t2.lastIndex += 1);
960
963
  return t2.lastIndex = s2, r2;
961
964
  }
962
965
  function Z(e2) {
@@ -1012,8 +1015,12 @@ function se(e2) {
1012
1015
  return s2 = s2.replace(/[^im]/g, "") + "g", new RegExp(t2[1], s2);
1013
1016
  }
1014
1017
  class ne {
1015
- constructor({ mode: e2, allowedHostnames: t2, allowedPhoneNrs: s2, allowedMatches: n2, forbiddenMatches: r2, suppressLinks: i2, suppressEmailAddresses: a2, suppressPhoneNumbers: o2, replacement: u2 }) {
1016
- X.oneOf(e2, ["all", "otherOnly", "off"]), this.mode = e2, this.suppressLinks = false !== i2, this.suppressEmailAddresses = false !== a2, this.suppressPhoneNumbers = false !== o2, this.allowedHostnames = t2 || [], this.allowedPhoneNrs = (s2 || []).filter((e3) => e3).map((e3) => e3.replace(/[^0-9]/g, "")), this.allowedMatches = (n2 || []).filter(te).map((e3) => se(e3)), this.forbiddenMatches = (r2 || []).filter(te).map((e3) => se(e3)), X(() => this.allowedMatches.every((e3) => e3.flags.includes("g")), "All regexes in `suppressContactInfo.allowedMatches` must be global. Check `allowedMatches`!"), X(() => this.forbiddenMatches.every((e3) => e3.flags.includes("g")), "All regexes in `suppressContactInfo.forbiddenMatches` must be global. Check `forbiddenMatches`!"), u2 = u2 == null ? void 0 : u2.trim(), this.replacement = u2 && u2.length > 0 ? u2 : void 0;
1018
+ constructor({ mode: e2, allowedHostnames: t2, allowedPhoneNrs: s2, allowedMatches: n2, forbiddenMatches: r2, forbiddenWords: i2, suppressLinks: a2, suppressEmailAddresses: o2, suppressPhoneNumbers: u2, replacement: c2 }) {
1019
+ if (X.oneOf(e2, ["all", "otherOnly", "off"]), this.mode = e2, this.suppressLinks = false !== a2, this.suppressEmailAddresses = false !== o2, this.suppressPhoneNumbers = false !== u2, this.allowedHostnames = t2 || [], this.allowedPhoneNrs = (s2 || []).filter((e3) => e3).map((e3) => e3.replace(/[^0-9]/g, "")), this.allowedMatches = (n2 || []).filter(te).map((e3) => se(e3)), this.forbiddenMatches = (r2 || []).filter(te).map((e3) => se(e3)), i2) {
1020
+ const e3 = i2.split("\n").map((e4) => e4.trim().toLowerCase()).filter((e4) => e4.length > 0 && !e4.startsWith("#")).map((e4) => e4.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"));
1021
+ e3.length && this.forbiddenMatches.push(new RegExp(`\\b(${e3.join("|")})\\b`, "gi"));
1022
+ }
1023
+ X(() => this.allowedMatches.every((e3) => e3.flags.includes("g")), "All regexes in `suppressContactInfo.allowedMatches` must be global. Check `allowedMatches`!"), X(() => this.forbiddenMatches.every((e3) => e3.flags.includes("g")), "All regexes in `suppressContactInfo.forbiddenMatches` must be global. Check `forbiddenMatches`!"), c2 = c2 == null ? void 0 : c2.trim(), this.replacement = c2 && c2.length > 0 ? c2 : void 0;
1017
1024
  }
1018
1025
  shouldSuppress({ isContentBySender: e2 }) {
1019
1026
  return "all" === this.mode || "otherOnly" === this.mode && !e2;
@@ -1272,7 +1279,7 @@ class pe extends z {
1272
1279
  fetchInitial(e2) {
1273
1280
  return __async(this, null, function* () {
1274
1281
  const t2 = this.onlyUsedInternally ? 1 : 30, s2 = yield fe({ realtimeClient: this.realtimeClient, conversationId: this.conversationId, count: t2 });
1275
- return s2.ok ? null === s2.value.messages ? c({ lastChanged: e2, lastMessageChanged: e2, stores: null, inWindow: null, windowEnd: null }) : me({ seq: e2, messages: s2.value.messages, cursor: s2.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : s2;
1282
+ return s2.ok ? null === s2.value.messages ? c({ lastChanged: e2, lastMessageChanged: e2, stores: null, inWindow: null, windowEnd: null }) : ge({ seq: e2, messages: s2.value.messages, cursor: s2.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : s2;
1276
1283
  });
1277
1284
  }
1278
1285
  teardownNested(e2) {
@@ -1330,7 +1337,7 @@ class pe extends z {
1330
1337
  });
1331
1338
  }
1332
1339
  loadedMore(e2, t2) {
1333
- 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) : me({ seq: e2, prevState: s2.value, messages: t2.data.value.messages, cursor: t2.data.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : t2.data);
1340
+ 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) : ge({ seq: e2, prevState: s2.value, messages: t2.data.value.messages, cursor: t2.data.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : t2.data);
1334
1341
  }
1335
1342
  messageCreated(e2, t2) {
1336
1343
  this.mutate(e2, (s2) => {
@@ -1409,7 +1416,7 @@ function fe(_0) {
1409
1416
  return (i2.ok || "server" !== i2.where || 404 !== i2.value.status) && (i2.ok || "server" !== i2.where || 403 !== i2.value.status || "NOT_A_PARTICIPANT" !== i2.value.errorCode) ? i2 : c({ messages: null, nextCursor: null });
1410
1417
  });
1411
1418
  }
1412
- function me({ seq: e2, prevState: t2, messages: s2, cursor: n2, conversationId: r2, realtimeClient: i2 }) {
1419
+ function ge({ seq: e2, prevState: t2, messages: s2, cursor: n2, conversationId: r2, realtimeClient: i2 }) {
1413
1420
  var _a2, _b, _c, _d;
1414
1421
  const a2 = t2 ? __spreadValues({}, t2.stores) : {};
1415
1422
  for (const t3 of s2) if (void 0 === a2[t3.id]) {
@@ -1430,7 +1437,7 @@ function me({ seq: e2, prevState: t2, messages: s2, cursor: n2, conversationId:
1430
1437
  if (null === n2) return c({ lastChanged: e2, lastMessageChanged: h2, stores: a2, inWindow: o2, windowEnd: null });
1431
1438
  return c({ lastChanged: e2, lastMessageChanged: h2, stores: a2, inWindow: o2, windowEnd: { cursor: n2, oldestMessageTs: s2[s2.length - 1].createdAt } });
1432
1439
  }
1433
- class ge extends z {
1440
+ class me extends z {
1434
1441
  constructor(e2, t2, s2, n2, r2) {
1435
1442
  super(e2, n2, r2), this.convData = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 0;
1436
1443
  }
@@ -2128,7 +2135,7 @@ class Me {
2128
2135
  }
2129
2136
  instantiateStore(e2, t2) {
2130
2137
  if (s(e2, ["users", "*"])) return new ce(this.virtualSeq, e2[1], this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2131
- if (s(e2, ["me", "conversations", "*"])) return new ge(this.virtualSeq, this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2138
+ if (s(e2, ["me", "conversations", "*"])) return new me(this.virtualSeq, this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2132
2139
  if (s(e2, ["me", "conversations", "*", "messages"])) return new pe(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2, onLoadedMore: (e3) => this.onVirtualPublish(e3) });
2133
2140
  if (s(e2, ["me", "conversations", "*", "participants"])) return new Ce(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2, onLoadedMore: (e3) => this.onVirtualPublish(e3) });
2134
2141
  if (s(e2, ["me", "conversations", "*", "typing"])) return new be(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2 });
@@ -2695,7 +2702,7 @@ var tt, st = function() {
2695
2702
  }, t2;
2696
2703
  }(Ke), ut = function(e2) {
2697
2704
  this.__jsduckDummyDocProp = null, this.tagBuilder = e2.tagBuilder;
2698
- }, ct = /[A-Za-z]/, lt = /[\d]/, ht = /[\D]/, dt = /\s/, pt = /['"]/, ft = /[\x00-\x1F\x7F]/, mt = /A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC/.source, gt = mt + /\u2700-\u27bf\udde6-\uddff\ud800-\udbff\udc00-\udfff\ufe0e\ufe0f\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0\ud83c\udffb-\udfff\u200d\u3299\u3297\u303d\u3030\u24c2\ud83c\udd70-\udd71\udd7e-\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01-\ude02\ude1a\ude2f\ude32-\ude3a\ude50-\ude51\u203c\u2049\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u00a9\u00ae\u2122\u2139\udc04\u2600-\u26FF\u2b05\u2b06\u2b07\u2b1b\u2b1c\u2b50\u2b55\u231a\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\udccf\u2935\u2934\u2190-\u21ff/.source + /\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F/.source, vt = /0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19/.source, wt = gt + vt, bt = gt + vt, yt = "(?:[" + vt + "]{1,3}\\.){3}[" + vt + "]{1,3}", Ct = "[" + bt + "](?:[" + bt + "\\-]{0,61}[" + bt + "])?", At = function(e2) {
2705
+ }, ct = /[A-Za-z]/, lt = /[\d]/, ht = /[\D]/, dt = /\s/, pt = /['"]/, ft = /[\x00-\x1F\x7F]/, gt = /A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC/.source, mt = gt + /\u2700-\u27bf\udde6-\uddff\ud800-\udbff\udc00-\udfff\ufe0e\ufe0f\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0\ud83c\udffb-\udfff\u200d\u3299\u3297\u303d\u3030\u24c2\ud83c\udd70-\udd71\udd7e-\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01-\ude02\ude1a\ude2f\ude32-\ude3a\ude50-\ude51\u203c\u2049\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u00a9\u00ae\u2122\u2139\udc04\u2600-\u26FF\u2b05\u2b06\u2b07\u2b1b\u2b1c\u2b50\u2b55\u231a\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\udccf\u2935\u2934\u2190-\u21ff/.source + /\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F/.source, vt = /0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19/.source, wt = mt + vt, bt = mt + vt, yt = "(?:[" + vt + "]{1,3}\\.){3}[" + vt + "]{1,3}", Ct = "[" + bt + "](?:[" + bt + "\\-]{0,61}[" + bt + "])?", At = function(e2) {
2699
2706
  return "(?=(" + Ct + "))\\" + e2;
2700
2707
  }, Et = function(e2) {
2701
2708
  return "(?:" + At(e2) + "(?:\\." + At(e2 + 1) + "){0,126}|" + yt + ")";
@@ -2718,10 +2725,10 @@ var tt, st = function() {
2718
2725
  f2(h2);
2719
2726
  break;
2720
2727
  case 3:
2721
- m2(h2);
2728
+ g2(h2);
2722
2729
  break;
2723
2730
  case 4:
2724
- g2(h2);
2731
+ m2(h2);
2725
2732
  break;
2726
2733
  case 5:
2727
2734
  v2(h2);
@@ -2747,10 +2754,10 @@ var tt, st = function() {
2747
2754
  function f2(e4) {
2748
2755
  "." === e4 ? c2 = 3 : "@" === e4 ? c2 = 4 : s2.test(e4) || C2();
2749
2756
  }
2750
- function m2(e4) {
2757
+ function g2(e4) {
2751
2758
  "." === e4 || "@" === e4 ? C2() : s2.test(e4) ? c2 = 2 : C2();
2752
2759
  }
2753
- function g2(e4) {
2760
+ function m2(e4) {
2754
2761
  kt.test(e4) ? c2 = 5 : C2();
2755
2762
  }
2756
2763
  function v2(e4) {
@@ -2801,7 +2808,7 @@ var tt, st = function() {
2801
2808
  return !(!e3 || t2 && this.hasFullProtocolRegex.test(t2) || -1 !== e3.indexOf("."));
2802
2809
  }, e2.urlMatchDoesNotHaveAtLeastOneWordChar = function(e3, t2) {
2803
2810
  return !(!e3 || !t2) && (!this.hasFullProtocolRegex.test(t2) && !this.hasWordCharAfterProtocolRegex.test(e3));
2804
- }, e2.hasFullProtocolRegex = /^[A-Za-z][-.+A-Za-z0-9]*:\/\//, e2.uriSchemeRegex = /^[A-Za-z][-.+A-Za-z0-9]*:/, e2.hasWordCharAfterProtocolRegex = new RegExp(":[^\\s]*?[" + mt + "]"), 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;
2811
+ }, e2.hasFullProtocolRegex = /^[A-Za-z][-.+A-Za-z0-9]*:\/\//, e2.uriSchemeRegex = /^[A-Za-z][-.+A-Za-z0-9]*:/, e2.hasWordCharAfterProtocolRegex = new RegExp(":[^\\s]*?[" + gt + "]"), 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;
2805
2812
  }(), Ft = (tt = new RegExp("[/?#](?:[" + bt + "\\-+&@#/%=~_()|'$*\\[\\]{}?!:,.;^✓]*[" + bt + "\\-+&@#/%=~_()|'$*\\[\\]{}✓])?"), new RegExp(["(?:", "(", /(?:[A-Za-z][-.+A-Za-z0-9]{0,63}:(?![A-Za-z][-.+A-Za-z0-9]{0,63}:\/\/)(?!\d+\/?)(?:\/\/)?)/.source, Et(2), ")", "|", "(", "(//)?", /(?:www\.)/.source, Et(6), ")", "|", "(", "(//)?", Et(10) + "\\.", xt.source, "(?![-" + wt + "])", ")", ")", "(?::[0-9]+)?", "(?:" + tt.source + ")?"].join(""), "gi")), Bt = new RegExp("[" + bt + "]"), Rt = function(e2) {
2806
2813
  function t2(t3) {
2807
2814
  var s2 = e2.call(this, t3) || this;
@@ -2809,14 +2816,14 @@ var tt, st = function() {
2809
2816
  }
2810
2817
  return et(t2, e2), t2.prototype.parseMatches = function(e3) {
2811
2818
  for (var t3, s2 = this.matcherRegex, n2 = this.stripPrefix, r2 = this.stripTrailingSlash, i2 = this.decodePercentEncoding, a2 = this.tagBuilder, o2 = [], u2 = function() {
2812
- var s3 = t3[0], u3 = t3[1], l2 = t3[4], h2 = t3[5], d2 = t3[9], p2 = t3.index, f2 = h2 || d2, m2 = e3.charAt(p2 - 1);
2819
+ var s3 = t3[0], u3 = t3[1], l2 = t3[4], h2 = t3[5], d2 = t3[9], p2 = t3.index, f2 = h2 || d2, g2 = e3.charAt(p2 - 1);
2813
2820
  if (!Mt.isValid(s3, u3)) return "continue";
2814
- if (p2 > 0 && "@" === m2) return "continue";
2815
- if (p2 > 0 && f2 && c2.wordCharRegExp.test(m2)) return "continue";
2821
+ if (p2 > 0 && "@" === g2) return "continue";
2822
+ if (p2 > 0 && f2 && c2.wordCharRegExp.test(g2)) return "continue";
2816
2823
  if (/\?$/.test(s3) && (s3 = s3.substr(0, s3.length - 1)), c2.matchHasUnbalancedClosingParen(s3)) s3 = s3.substr(0, s3.length - 1);
2817
2824
  else {
2818
- var g2 = c2.matchHasInvalidCharAfterTld(s3, u3);
2819
- g2 > -1 && (s3 = s3.substr(0, g2));
2825
+ var m2 = c2.matchHasInvalidCharAfterTld(s3, u3);
2826
+ m2 > -1 && (s3 = s3.substr(0, m2));
2820
2827
  }
2821
2828
  var v2 = ["http://", "https://"].find(function(e4) {
2822
2829
  return !!u3 && -1 !== u3.indexOf(e4);
@@ -2901,10 +2908,10 @@ function Lt(e2, t2) {
2901
2908
  var f2 = e2.charAt(c2);
2902
2909
  switch (h2) {
2903
2910
  case 0:
2904
- m2(f2);
2911
+ g2(f2);
2905
2912
  break;
2906
2913
  case 1:
2907
- g2(f2);
2914
+ m2(f2);
2908
2915
  break;
2909
2916
  case 2:
2910
2917
  w2(f2);
@@ -2968,10 +2975,10 @@ function Lt(e2, t2) {
2968
2975
  }
2969
2976
  c2++;
2970
2977
  }
2971
- function m2(e3) {
2978
+ function g2(e3) {
2972
2979
  "<" === e3 && P2();
2973
2980
  }
2974
- function g2(e3) {
2981
+ function m2(e3) {
2975
2982
  "!" === e3 ? h2 = 13 : "/" === e3 ? (h2 = 2, p2 = new Gt(st(st({}, p2), { isClosing: true }))) : "<" === e3 ? P2() : ct.test(e3) ? (h2 = 3, p2 = new Gt(st(st({}, p2), { isOpening: true }))) : (h2 = 0, p2 = u2);
2976
2983
  }
2977
2984
  function v2(e3) {
@@ -3293,7 +3300,7 @@ class fs {
3293
3300
  }
3294
3301
  edit(t2) {
3295
3302
  return __async(this, null, function* () {
3296
- const s2 = { content: ms(t2), custom: "string" == typeof t2 ? void 0 : t2.custom }, n2 = yield this._realtimeClient.call("PATCH", ["conversations", this.brandedConversationId, "messages", this.brandedId], s2);
3303
+ const s2 = { content: gs(t2), custom: "string" == typeof t2 ? void 0 : t2.custom }, n2 = yield this._realtimeClient.call("PATCH", ["conversations", this.brandedConversationId, "messages", this.brandedId], s2);
3297
3304
  e(`Edit message ${this.id} in conversation ${this.conversationId}`, n2);
3298
3305
  });
3299
3306
  }
@@ -3304,7 +3311,7 @@ class fs {
3304
3311
  });
3305
3312
  }
3306
3313
  }
3307
- function ms(e2) {
3314
+ function gs(e2) {
3308
3315
  if ("string" == typeof e2) {
3309
3316
  return [{ type: "text", children: us(e2) }];
3310
3317
  }
@@ -3313,7 +3320,7 @@ function ms(e2) {
3313
3320
  }
3314
3321
  if ("content" in e2 && e2.content) return e2.content;
3315
3322
  }
3316
- class gs {
3323
+ class ms {
3317
3324
  constructor(e2, t2) {
3318
3325
  this.id = e2, this._realtimeClient = t2, this.uselessObjForTypeCheck = { subject: null, photoUrl: null, welcomeMessages: null, custom: null, access: null, notify: null };
3319
3326
  }
@@ -3455,7 +3462,7 @@ class bs {
3455
3462
  function ys({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2, errorTracker: u2 }) {
3456
3463
  var _a2;
3457
3464
  (!r2 || r2 <= 0) && (r2 = 1);
3458
- const c2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-11-04T15:29:42.017Z" };
3465
+ const c2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-12-30T13:54:18.982Z" };
3459
3466
  s2 instanceof FormData || (c2["Content-Type"] = (_a2 = n2 == null ? void 0 : n2.contentType) != null ? _a2 : "application/json");
3460
3467
  return a(r2, () => __async(this, null, function* () {
3461
3468
  if (o2) {
@@ -3467,7 +3474,7 @@ function ys({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRe
3467
3474
  throw e3;
3468
3475
  });
3469
3476
  }), { initialDelay: 0.2, log: void 0, shouldRetry: (s3) => __async(this, null, function* () {
3470
- return o2 && 401 === s3.status ? (u2 == null ? void 0 : u2.log(`401 error from ${e2} ${t2}, ${yield o2.getToken()}`), o2.refreshToken(), true) : i2 ? i2(s3) : !("status" in s3 && s3.status >= 400 && s3.status < 500);
3477
+ return o2 && 401 === s3.status ? (u2 == null ? void 0 : u2.log(`401 error from ${e2} ${t2}, ${yield o2.getToken()}`), o2.invalidateAndRefresh(), true) : i2 ? i2(s3) : !("status" in s3 && s3.status >= 400 && s3.status < 500);
3471
3478
  }) }).catch((s3) => {
3472
3479
  if (Math.random() < 0.1 && !t2.toString().startsWith("https://capture.trackjs.com")) {
3473
3480
  const n3 = `Network Error for ${e2} ${t2}`;
@@ -3484,7 +3491,7 @@ class Cs {
3484
3491
  __privateAdd(this, _e2);
3485
3492
  __privateAdd(this, _t2);
3486
3493
  var _a2, _b, _c, _d;
3487
- this._timeCreated = Date.now(), __privateSet(this, _e2, (_b = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-11-04T15:29:42.017Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2025-11-04T15:29:42.017Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
3494
+ this._timeCreated = Date.now(), __privateSet(this, _e2, (_b = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-12-30T13:54:18.982Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2025-12-30T13:54:18.982Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
3488
3495
  }
3489
3496
  setData({ appId: e2, meId: t2, sessionId: s2 }) {
3490
3497
  this._trackJSData.customer.userId = e2, this._trackJSData.customer.sessionId = `${e2}/${t2}`, this._trackJSData.customer.correlationId = s2;
@@ -3551,42 +3558,85 @@ class Es {
3551
3558
  }
3552
3559
  }
3553
3560
  class ks {
3554
- constructor(e2, t2, s2, n2, r2, i2) {
3555
- this.appId = t2, this.userId = s2, this.tokenFetcher = r2, this.usingBokens = false, this.requestInProgress = false, this.eventEmitter = new Es({ tokenChanged(e3) {
3561
+ constructor(e2) {
3562
+ this.handlers = e2, this.tokenResult = null, this.pendingToken = null;
3563
+ }
3564
+ getTokenResult() {
3565
+ return __async(this, null, function* () {
3566
+ if (this.tokenResult) return this.tokenResult;
3567
+ if (this.pendingToken) return this.pendingToken.promise;
3568
+ const e2 = o();
3569
+ return this.pendingToken = e2, this.handlers.onNeedToken(), e2.promise;
3570
+ });
3571
+ }
3572
+ setTokenResult(e2) {
3573
+ this.pendingToken && (this.pendingToken.resolve(e2), this.pendingToken = null), this.tokenResult = e2, this.handlers.onChange(e2);
3574
+ }
3575
+ refreshToken() {
3576
+ this.pendingToken || (this.pendingToken = o(), this.handlers.onNeedToken());
3577
+ }
3578
+ invalidateAndRefresh() {
3579
+ this.tokenResult = null, this.refreshToken();
3580
+ }
3581
+ }
3582
+ class xs {
3583
+ constructor(e2, t2, s2, n2) {
3584
+ this.apiUrls = e2, this.appId = t2, this.userId = s2, this.signature = n2, this.inner = new ks({ onChange: (e3) => {
3585
+ e3.ok ? this.eventEmitter.emit("tokenChanged", e3.value) : this.emitTokenRefreshFailed(e3.value);
3586
+ }, onNeedToken: () => __async(this, null, function* () {
3587
+ if (this._usingBokens && !this.signature && !this._calledBokens && (yield new Promise((e3) => setTimeout(e3, 1))), this._usingBokens) yield this.sendBokenRequest().then((e3) => this.inner.setTokenResult(c(e3))).catch((e3) => this.inner.setTokenResult(h(e3)));
3588
+ else if (this.onNeedToken) this.onNeedToken();
3589
+ else {
3590
+ const e3 = l("Cannot refresh token, no `onNeedToken` provided.");
3591
+ this.inner.setTokenResult(e3);
3592
+ }
3593
+ }) }), this._usingBokens = true, this._calledBokens = false, this.onNeedToken = void 0, this.eventEmitter = new Es({ tokenChanged(e3) {
3556
3594
  }, tokenRefreshFailed(e3) {
3557
3595
  }, tokenAccepted(e3) {
3558
3596
  } }), this.sessionExpiryWarningTimeoutId = void 0;
3559
- const a2 = "undefined" != typeof window && e2.restApiHttpUrl.includes("api.talkjs.com");
3560
- if (this.errorTracker = a2 ? new Cs("970cd0be0fb74630b75c8451051299dc") : As, i2 && (n2 || r2)) throw new Error("[TalkJS] If providing a signature for authentication, you must not provide a token or tokenFetcher.");
3561
- n2 ? this.fetchToken(() => n2) : (r2 || (this.usingBokens = true, this.tokenFetcher = () => this.sendBokenRequest(e2, i2)), this.refreshToken());
3597
+ const r2 = "undefined" != typeof window && e2.restApiHttpUrl.includes("api.talkjs.com");
3598
+ this.errorTracker = r2 ? new Cs("970cd0be0fb74630b75c8451051299dc") : As;
3562
3599
  }
3563
- get canRefreshToken() {
3564
- return this.usingBokens || !!this.tokenFetcher;
3600
+ get usingBokens() {
3601
+ return this._usingBokens;
3565
3602
  }
3566
3603
  getToken() {
3567
- return this.token;
3604
+ return __async(this, null, function* () {
3605
+ const e2 = yield this.inner.getTokenResult();
3606
+ if (e2.ok) return e2.value;
3607
+ throw e2.value;
3608
+ });
3609
+ }
3610
+ checkCanSetAuth() {
3611
+ if (this._calledBokens) throw new Error("[TalkJS] Cannot switch to JWT authentication once connected to TalkJS servers. To use JWTs, call `setToken` or set `onNeedToken` before triggering any requests or mounting any components. We recommend setting up authentication in your app's entry point (App.jsx, main.js, or similar) so it runs first.");
3612
+ }
3613
+ setToken(e2) {
3614
+ this.checkCanSetAuth(), setTimeout(() => this.checkJwt(e2), 200), this._usingBokens = false, this.inner.setTokenResult(c(e2));
3615
+ }
3616
+ setTokenError(e2) {
3617
+ this._usingBokens = false, this.inner.setTokenResult(l(e2));
3568
3618
  }
3569
3619
  refreshToken() {
3570
- if (!this.requestInProgress) {
3571
- if (!this.tokenFetcher) throw this.emitTokenRefreshFailed("no `tokenFetcher` provided"), new Error("[TalkJS] Cannot refresh token, no `tokenFetcher` provided.");
3572
- this.fetchToken(this.tokenFetcher);
3573
- }
3620
+ this.inner.refreshToken();
3621
+ }
3622
+ invalidateAndRefresh() {
3623
+ this.inner.invalidateAndRefresh();
3624
+ }
3625
+ setOnNeedToken(e2) {
3626
+ this.checkCanSetAuth(), this._usingBokens = false, this.onNeedToken = e2;
3574
3627
  }
3575
3628
  onTokenChanged(e2) {
3576
3629
  return this.eventEmitter.on("tokenChanged", e2), () => {
3577
3630
  this.eventEmitter.off("tokenChanged", e2);
3578
3631
  };
3579
3632
  }
3580
- emitTokenChanged(e2) {
3581
- this.eventEmitter.emit("tokenChanged", e2);
3582
- }
3583
3633
  onTokenRefreshFailed(e2) {
3584
3634
  return this.eventEmitter.on("tokenRefreshFailed", e2), () => {
3585
3635
  this.eventEmitter.off("tokenRefreshFailed", e2);
3586
3636
  };
3587
3637
  }
3588
3638
  emitTokenRefreshFailed(e2) {
3589
- this.eventEmitter.emit("tokenRefreshFailed", e2), console.error(`[TalkJS] Could not authenticate, cannot recover automatically: ${e2}`);
3639
+ this.eventEmitter.emit("tokenRefreshFailed", e2);
3590
3640
  }
3591
3641
  onTokenAccepted(e2) {
3592
3642
  return this.eventEmitter.on("tokenAccepted", e2), () => {
@@ -3601,38 +3651,12 @@ class ks {
3601
3651
  }
3602
3652
  scheduleRefresh(e2) {
3603
3653
  if (this.clearScheduledRefresh(), null === e2) return;
3604
- const t2 = void 0 !== this.tokenFetcher;
3605
- e2 < 120 && !t2 ? console.warn(`[TalkJS] TalkJS will stop working in ${e2} seconds due to auth token expiry. Token expires in ${e2} seconds, and cannot be refreshed because no \`tokenFetcher\` was provided when creating the session. Non-refreshable tokens are recommended to expire at least 24 hours in the future.`) : e2 < 120 && t2 ? console.warn(`[TalkJS] TalkJS auth token will expire and need to be refreshed in ${e2} seconds. Refreshable JWTs are recommended to expire at least 30 minutes in the future, to improve performance and reduce unnecessary refreshes.`) : e2 < 3300 && !t2 && console.warn(`[TalkJS debug] TalkJS will stop working in ${Math.round(e2 / 60)} minutes due to auth token expiry. Non-refreshable tokens are recommended to expire at least 24 hours in the future. Alternatively, provide a \`tokenFetcher\` when creating the session, so that tokens can be refreshed when they expire.`);
3606
- if (void 0 !== this.tokenFetcher) {
3607
- const t3 = e2 > 600 ? e2 - 300 : e2 / 2, s2 = Math.min(1728e6, 1e3 * t3);
3608
- this.sessionExpiryWarningTimeoutId = setTimeout(() => {
3609
- this.refreshToken();
3610
- }, s2);
3611
- } else e2 < 2e6 && (this.sessionExpiryWarningTimeoutId = setTimeout(() => {
3612
- this.emitTokenRefreshFailed("Token has expired and no `tokenFetcher` was provided when creating the session, so it cannot be refreshed.");
3613
- }, 1e3 * e2));
3614
- }
3615
- fetchToken(e2) {
3616
- return __async(this, null, function* () {
3617
- if (this.requestInProgress) return;
3618
- this.requestInProgress = true;
3619
- const t2 = () => __async(this, null, function* () {
3620
- const t3 = yield e2();
3621
- return this.checkJwt(t3), t3;
3622
- });
3623
- try {
3624
- const e3 = void 0 !== this.token;
3625
- this.token = t2(), yield this.token.then((t3) => {
3626
- e3 && this.emitTokenChanged(t3);
3627
- }).catch((e4) => {
3628
- this.emitTokenRefreshFailed(e4);
3629
- });
3630
- } catch (e3) {
3631
- this.emitTokenRefreshFailed(e3);
3632
- } finally {
3633
- this.requestInProgress = false;
3634
- }
3635
- });
3654
+ const t2 = void 0 !== this.onNeedToken;
3655
+ e2 < 120 && !t2 ? console.warn(`[TalkJS] TalkJS will stop working in ${e2} seconds due to auth token expiry. Token expires in ${e2} seconds, and cannot be refreshed because no \`onNeedToken\` callback was provided. Non-refreshable tokens are recommended to expire at least 24 hours in the future.`) : e2 < 120 && t2 ? console.warn(`[TalkJS] TalkJS auth token will expire and need to be refreshed in ${e2} seconds. Refreshable JWTs are recommended to expire at least 30 minutes in the future, to improve performance and reduce unnecessary refreshes.`) : e2 < 3300 && !t2 && console.warn(`[TalkJS debug] TalkJS will stop working in ${Math.round(e2 / 60)} minutes due to auth token expiry. Non-refreshable tokens are recommended to expire at least 24 hours in the future. Alternatively, set \`onNeedToken\` with a callback that will run whenever a new token is needed.`);
3656
+ const s2 = e2 > 600 ? e2 - 300 : e2 / 2, n2 = Math.min(1728e6, 1e3 * s2);
3657
+ this.sessionExpiryWarningTimeoutId = setTimeout(() => {
3658
+ void 0 !== this.onNeedToken && this.refreshToken();
3659
+ }, n2);
3636
3660
  }
3637
3661
  checkJwt(e2) {
3638
3662
  !function(e3) {
@@ -3646,7 +3670,7 @@ class ks {
3646
3670
  const e3 = function(e4) {
3647
3671
  const t3 = e4.split(".");
3648
3672
  if (3 !== t3.length) throw "Token does not contain exactly two `.`. Check that you generated your JWT correctly. It should be `<header>.<payload>.<signature>`.";
3649
- return { header: xs(t3[0]), payload: xs(t3[1]) };
3673
+ return { header: Ts(t3[0]), payload: Ts(t3[1]) };
3650
3674
  }(s2);
3651
3675
  n2 = e3.header, r2 = e3.payload;
3652
3676
  } catch (e3) {
@@ -3686,23 +3710,24 @@ class ks {
3686
3710
  const a2 = e2.nbf;
3687
3711
  return void 0 === a2 || ("number" != typeof a2 ? t2.push(`Token payload contains a \`nbf\` (not-before) claim, but \`nbf\` was ${typeof r2} instead of a number. If set, \`nbf\` should be the date when the JWT becomes valid, as a number of seconds since 1970-01-01.`) : a2 > 1e11 && t2.push(`Token payload contains a \`nbf\` (not-before) claim, but \`nbf\` is very large (${a2}, representing ${new Date(1e3 * a2).toLocaleDateString()}). If set, \`nbf\` should be the date when the JWT becomes valid, as a number of seconds since 1970-01-01. Double-check that you are using seconds and not milliseconds or nanoseconds.`)), t2;
3688
3712
  }
3689
- sendBokenRequest(e2, t2) {
3713
+ sendBokenRequest() {
3690
3714
  return __async(this, null, function* () {
3691
- let s2 = 0;
3692
- const n2 = e2.getBokensUrl(this.appId, this.userId, t2), r2 = yield ys({ method: "GET", url: n2, attempts: 1e4, shouldRetry: (e3) => {
3693
- if (e3 instanceof Error) return true;
3694
- if (401 === e3.status) throw "Check that you provided a valid signature.";
3695
- if (404 === e3.status) throw "Check that you specified the correct App ID.";
3696
- if (429 === e3.status || 502 === e3.status) return true;
3697
- if (e3.status >= 400 && e3.status < 500) throw `Unexpected HTTP ${e3.status} response when fetching auth token. Check that you configured the session correctly.`;
3698
- if (s2++, s2 >= 5) throw `Unexpected HTTP ${e3.status} response when fetching auth token, retrying did not help.`;
3715
+ this._calledBokens = true;
3716
+ let e2 = 0;
3717
+ const t2 = this.apiUrls.getBokensUrl(this.appId, this.userId, this.signature), s2 = yield ys({ method: "GET", url: t2, attempts: 1e4, shouldRetry: (t3) => {
3718
+ if (t3 instanceof Error) return true;
3719
+ if (401 === t3.status) throw "Check that you provided a valid signature.";
3720
+ if (404 === t3.status) throw "Check that you specified the correct App ID.";
3721
+ if (429 === t3.status || 502 === t3.status) return true;
3722
+ if (t3.status >= 400 && t3.status < 500) throw `Unexpected HTTP ${t3.status} response when fetching auth token. Check that you configured the session correctly.`;
3723
+ if (e2++, e2 >= 5) throw `Unexpected HTTP ${t3.status} response when fetching auth token, retrying did not help.`;
3699
3724
  return true;
3700
3725
  }, errorTracker: this.errorTracker });
3701
- return (yield r2.json()).boken;
3726
+ return (yield s2.json()).boken;
3702
3727
  });
3703
3728
  }
3704
3729
  }
3705
- function xs(e2) {
3730
+ function Ts(e2) {
3706
3731
  try {
3707
3732
  const t2 = e2.replace(/-/g, "+").replace(/_/g, "/"), s2 = decodeURIComponent(atob(t2).split("").map((e3) => "%" + ("00" + e3.charCodeAt(0).toString(16)).slice(-2)).join(""));
3708
3733
  return JSON.parse(s2);
@@ -3710,24 +3735,15 @@ function xs(e2) {
3710
3735
  throw `Could not base64-decode and JSON-parse token section: ${e2}. Check that you base-64 encoded the section correctly.`;
3711
3736
  }
3712
3737
  }
3713
- class Ts {
3714
- constructor(e2) {
3715
- this.target = e2;
3716
- }
3717
- deref() {
3718
- return this.target;
3719
- }
3720
- }
3721
3738
  const Is = new class {
3722
3739
  constructor() {
3723
3740
  this.registry = {};
3724
3741
  }
3725
3742
  getOrCreate(e2) {
3726
- var _a2;
3727
- const t2 = this.key(e2), s2 = (_a2 = this.registry[t2]) == null ? void 0 : _a2.deref();
3743
+ const t2 = this.key(e2), s2 = this.registry[t2];
3728
3744
  if (s2) return s2;
3729
- const n2 = new Ss(e2), r2 = globalThis.WeakRef ? new WeakRef(n2) : new Ts(n2);
3730
- return this.registry[t2] = r2, n2;
3745
+ const n2 = new Ss(e2);
3746
+ return this.registry[t2] = n2, n2;
3731
3747
  }
3732
3748
  deregister(e2, t2) {
3733
3749
  const s2 = this.key({ appId: e2, userId: t2 });
@@ -3743,21 +3759,30 @@ function Ds(e2) {
3743
3759
  }
3744
3760
  class Ss {
3745
3761
  constructor(e2) {
3746
- !function(e3) {
3762
+ this._onNeedToken = void 0, function(e3) {
3747
3763
  function t3(e4, t4) {
3748
3764
  if (!e4) throw new Error("[TalkJS] TalkSession: " + t4);
3749
3765
  }
3750
- t3(e3 && "object" == typeof e3, "Expected an object argument in TalkSession#constructor."), t3(e3.appId && "string" == typeof e3.appId, "The `appId` property of TalkSession#constructor is required and it must be a non-empty string."), t3("string" == typeof e3.userId, "The `userId` property of TalkSession#constructor is required and it must be a string."), void 0 !== e3.token && t3(e3.token && "string" == typeof e3.token, "The `token` property of TalkSession#constructor must be a non-empty string.");
3751
- void 0 !== e3.tokenFetcher && t3("function" == typeof e3.tokenFetcher, "The `tokenFetcher` property of TalkSession#constructor must be a function.");
3766
+ t3(e3 && "object" == typeof e3, "Expected an object argument in `getTalkSession`."), t3(e3.appId && "string" == typeof e3.appId, "The `appId` property of the `getTalkSession` options is required and it must be a non-empty string."), t3("string" == typeof e3.userId, "The `userId` property of the `getTalkSession` options is required and it must be a string."), void 0 !== e3.token && t3(e3.token && "string" == typeof e3.token, "The `token` property of the `getTalkSession` options must be a non-empty string.");
3767
+ void 0 !== e3.tokenFetcher && t3("function" == typeof e3.tokenFetcher, "The `tokenFetcher` property of the `getTalkSession` options must be a function.");
3752
3768
  }(e2);
3753
3769
  const { appId: t2, userId: s2, token: n2, tokenFetcher: r2, signature: i2 } = e2;
3754
- this._appId = t2, this._apiUrls = e2.apiUrls ? new bs(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : bs.fromHost(e2.host), this._authProvider = new ks(this._apiUrls, t2, s2, n2, r2, i2);
3770
+ this._appId = t2, this._apiUrls = e2.apiUrls ? new bs(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : bs.fromHost(e2.host), this._authProvider = new xs(this._apiUrls, t2, s2, i2), n2 && this._authProvider.setToken(n2), r2 && this._authProvider.setOnNeedToken(() => __async(this, null, function* () {
3771
+ try {
3772
+ const e3 = yield r2();
3773
+ this._authProvider.setToken(e3);
3774
+ } catch (e3) {
3775
+ this._authProvider.setTokenError(`${e3}`);
3776
+ }
3777
+ }));
3755
3778
  const a2 = Math.random().toString().split(".")[1];
3756
- this._realtimeClient = new Be(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.5.8", a2, e2.clientBuild), s2, this._authProvider), this.currentUser = new _e(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
3757
- console.error(`[TalkSession] ${e3}`);
3758
- }), function(e3, t3, s3) {
3779
+ this._realtimeClient = new Be(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.6.0", a2, e2.clientBuild), s2, this._authProvider), this.currentUser = new _e(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
3780
+ console.error(`[TalkJS] ${e3}`);
3781
+ }), function(e3, t3) {
3759
3782
  return __async(this, null, function* () {
3760
- return ys({ method: "GET", url: `${t3}/${e3}/app`, authProvider: s3, errorTracker: s3.errorTracker }).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) => {
3783
+ return ys({ method: "GET", url: `${t3}/${e3}` }).then((e4) => __async(this, null, function* () {
3784
+ return 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);
3785
+ })).catch((e4) => {
3761
3786
  if ("string" != typeof e4 && "status" in e4) {
3762
3787
  const t4 = e4;
3763
3788
  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);
@@ -3765,12 +3790,27 @@ class Ss {
3765
3790
  return console.warn("[TalkJS] Encountered network issues when validating app ID. Assuming that the app ID is valid."), true;
3766
3791
  });
3767
3792
  });
3768
- }(this._appId, this._apiUrls.internalHttpApiUrl, this._authProvider).then((e3) => {
3793
+ }(this._appId, this._apiUrls.internalHttpApiUrl).then((e3) => {
3769
3794
  e3 || this.terminate(new Error(`The app ID ${this._appId} does not exist. Make sure you are using the correct app ID as found on the TalkJS dashboard. App IDs are case-sensitive.`));
3770
3795
  }), this._authProvider.onTokenRefreshFailed((e3) => {
3771
3796
  this.terminate(new Error(`Could not authenticate, cannot recover automatically: ${e3}`));
3772
3797
  });
3773
3798
  }
3799
+ setToken(e2) {
3800
+ this._authProvider.setToken(e2);
3801
+ }
3802
+ get onNeedToken() {
3803
+ return this._onNeedToken;
3804
+ }
3805
+ set onNeedToken(e2) {
3806
+ this._onNeedToken = e2, void 0 === e2 ? this._authProvider.setOnNeedToken(void 0) : this._authProvider.setOnNeedToken(() => {
3807
+ try {
3808
+ e2();
3809
+ } catch (e3) {
3810
+ console.error("[TalkJS] error when calling `onNeedToken` - your auth token will expire soon.", e3);
3811
+ }
3812
+ });
3813
+ }
3774
3814
  onError(e2) {
3775
3815
  const t2 = o();
3776
3816
  return Promise.race([t2.promise, this._terminationReason.promise]).then((t3) => {
@@ -3785,7 +3825,7 @@ class Ss {
3785
3825
  conversation(e2) {
3786
3826
  if ("string" != typeof e2) throw new Error(`Creating ConversationRef failed because ID "${e2}" is not a string`);
3787
3827
  if ("" === e2) throw new Error(`Creating ConversationRef failed because ID "${e2}" is an empty string`);
3788
- return new gs(e2, this._realtimeClient);
3828
+ return new ms(e2, this._realtimeClient);
3789
3829
  }
3790
3830
  subscribeConversations(e2) {
3791
3831
  return this._realtimeClient.subscribe(["me", "conversations"], e2);
@@ -3815,7 +3855,7 @@ class Ss {
3815
3855
  function Ms(_0, _1, _2, _3) {
3816
3856
  return __async(this, arguments, function* (e2, t2, s2, { subtype: n2, filename: r2, width: i2, height: a2, duration: o2 }) {
3817
3857
  const u2 = new FormData();
3818
- 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()), ys({ method: "POST", url: e2, data: u2, authProvider: t2, errorTracker: t2.errorTracker }).then((e3) => e3.json()).then((e3) => e3.attachmentToken).catch((e3) => __async(this, null, function* () {
3858
+ 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()), ys({ method: "POST", url: e2, data: u2, authProvider: t2, errorTracker: t2.errorTracker }).then((e3) => e3.json()).then((e3) => e3.fileToken).catch((e3) => __async(this, null, function* () {
3819
3859
  if (e3 instanceof Response) {
3820
3860
  const t3 = yield e3.json(), s3 = `Unexpected response when uploading file, status code ${e3.status} ${t3.errorCode}, ${t3.reasons}`;
3821
3861
  throw new Error(s3);