joytalk 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -61,10 +61,10 @@ function ut(e, t) {
61
61
  return null;
62
62
  }
63
63
  const J = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, ft = (e) => !Q(e) && e !== J;
64
- function ge() {
64
+ function Oe() {
65
65
  const { caseless: e, skipUndefined: t } = ft(this) && this || {}, n = {}, r = (s, o) => {
66
66
  const i = e && ut(n, o) || o;
67
- fe(n[i]) && fe(s) ? n[i] = ge(n[i], s) : fe(s) ? n[i] = ge({}, s) : Z(s) ? n[i] = s.slice() : (!t || !Q(s)) && (n[i] = s);
67
+ fe(n[i]) && fe(s) ? n[i] = Oe(n[i], s) : fe(s) ? n[i] = Oe({}, s) : Z(s) ? n[i] = s.slice() : (!t || !Q(s)) && (n[i] = s);
68
68
  };
69
69
  for (let s = 0, o = arguments.length; s < o; s++)
70
70
  arguments[s] && oe(arguments[s], r);
@@ -203,7 +203,7 @@ const dn = (e) => {
203
203
  isTypedArray: en,
204
204
  isFileList: Ht,
205
205
  forEach: oe,
206
- merge: ge,
206
+ merge: Oe,
207
207
  extend: Wt,
208
208
  trim: Vt,
209
209
  stripBOM: Kt,
@@ -474,7 +474,7 @@ const wt = {
474
474
  silentJSONParsing: !0,
475
475
  forcedJSONParsing: !0,
476
476
  clarifyTimeoutError: !1
477
- }, yn = typeof URLSearchParams < "u" ? URLSearchParams : Fe, An = typeof FormData < "u" ? FormData : null, bn = typeof Blob < "u" ? Blob : null, Nn = {
477
+ }, yn = typeof URLSearchParams < "u" ? URLSearchParams : Fe, An = typeof FormData < "u" ? FormData : null, bn = typeof Blob < "u" ? Blob : null, gn = {
478
478
  isBrowser: !0,
479
479
  classes: {
480
480
  URLSearchParams: yn,
@@ -482,22 +482,22 @@ const wt = {
482
482
  Blob: bn
483
483
  },
484
484
  protocols: ["http", "https", "file", "blob", "url", "data"]
485
- }, Pe = typeof window < "u" && typeof document < "u", Ue = typeof navigator == "object" && navigator || void 0, On = Pe && (!Ue || ["ReactNative", "NativeScript", "NS"].indexOf(Ue.product) < 0), gn = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
485
+ }, Pe = typeof window < "u" && typeof document < "u", Ue = typeof navigator == "object" && navigator || void 0, Nn = Pe && (!Ue || ["ReactNative", "NativeScript", "NS"].indexOf(Ue.product) < 0), On = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
486
486
  self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Cn = Pe && window.location.href || "http://localhost", Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
487
487
  __proto__: null,
488
488
  hasBrowserEnv: Pe,
489
- hasStandardBrowserEnv: On,
490
- hasStandardBrowserWebWorkerEnv: gn,
489
+ hasStandardBrowserEnv: Nn,
490
+ hasStandardBrowserWebWorkerEnv: On,
491
491
  navigator: Ue,
492
492
  origin: Cn
493
- }, Symbol.toStringTag, { value: "Module" })), O = {
493
+ }, Symbol.toStringTag, { value: "Module" })), N = {
494
494
  ...Un,
495
- ...Nn
495
+ ...gn
496
496
  };
497
497
  function _n(e, t) {
498
- return we(e, new O.classes.URLSearchParams(), {
498
+ return we(e, new N.classes.URLSearchParams(), {
499
499
  visitor: function(n, r, s, o) {
500
- return O.isNode && a.isBuffer(n) ? (this.append(r, n.toString("base64")), !1) : o.defaultVisitor.apply(this, arguments);
500
+ return N.isNode && a.isBuffer(n) ? (this.append(r, n.toString("base64")), !1) : o.defaultVisitor.apply(this, arguments);
501
501
  },
502
502
  ...t
503
503
  });
@@ -592,8 +592,8 @@ const ie = {
592
592
  maxContentLength: -1,
593
593
  maxBodyLength: -1,
594
594
  env: {
595
- FormData: O.classes.FormData,
596
- Blob: O.classes.Blob
595
+ FormData: N.classes.FormData,
596
+ Blob: N.classes.Blob
597
597
  },
598
598
  validateStatus: function(t) {
599
599
  return t >= 200 && t < 300;
@@ -809,7 +809,7 @@ a.reduceDescriptors(D.prototype, ({ value: e }, t) => {
809
809
  };
810
810
  });
811
811
  a.freezeMethods(D);
812
- function Ne(e, t) {
812
+ function ge(e, t) {
813
813
  const n = this || ie, r = t || n, s = D.from(r.headers);
814
814
  let o = r.data;
815
815
  return a.forEach(e, function(c) {
@@ -893,10 +893,10 @@ const pe = (e, t, n = 3) => {
893
893
  total: e,
894
894
  loaded: r
895
895
  }), t[1]];
896
- }, Ke = (e) => (...t) => a.asap(() => e(...t)), $n = O.hasStandardBrowserEnv ? /* @__PURE__ */ ((e, t) => (n) => (n = new URL(n, O.origin), e.protocol === n.protocol && e.host === n.host && (t || e.port === n.port)))(
897
- new URL(O.origin),
898
- O.navigator && /(msie|trident)/i.test(O.navigator.userAgent)
899
- ) : () => !0, qn = O.hasStandardBrowserEnv ? (
896
+ }, Ke = (e) => (...t) => a.asap(() => e(...t)), $n = N.hasStandardBrowserEnv ? /* @__PURE__ */ ((e, t) => (n) => (n = new URL(n, N.origin), e.protocol === n.protocol && e.host === n.host && (t || e.port === n.port)))(
897
+ new URL(N.origin),
898
+ N.navigator && /(msie|trident)/i.test(N.navigator.userAgent)
899
+ ) : () => !0, qn = N.hasStandardBrowserEnv ? (
900
900
  // Standard browser envs support document.cookie
901
901
  {
902
902
  write(e, t, n, r, s, o, i) {
@@ -1000,14 +1000,14 @@ function W(e, t) {
1000
1000
  a.isUndefined(S) && h !== c || (n[l] = S);
1001
1001
  }), n;
1002
1002
  }
1003
- const Nt = (e) => {
1003
+ const gt = (e) => {
1004
1004
  const t = W({}, e);
1005
1005
  let { data: n, withXSRFToken: r, xsrfHeaderName: s, xsrfCookieName: o, headers: i, auth: c } = t;
1006
1006
  if (t.headers = i = D.from(i), t.url = Tt(bt(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), c && i.set(
1007
1007
  "Authorization",
1008
1008
  "Basic " + btoa((c.username || "") + ":" + (c.password ? unescape(encodeURIComponent(c.password)) : ""))
1009
1009
  ), a.isFormData(n)) {
1010
- if (O.hasStandardBrowserEnv || O.hasStandardBrowserWebWorkerEnv)
1010
+ if (N.hasStandardBrowserEnv || N.hasStandardBrowserWebWorkerEnv)
1011
1011
  i.setContentType(void 0);
1012
1012
  else if (a.isFunction(n.getHeaders)) {
1013
1013
  const d = n.getHeaders(), u = ["content-type", "content-length"];
@@ -1016,14 +1016,14 @@ const Nt = (e) => {
1016
1016
  });
1017
1017
  }
1018
1018
  }
1019
- if (O.hasStandardBrowserEnv && (r && a.isFunction(r) && (r = r(t)), r || r !== !1 && $n(t.url))) {
1019
+ if (N.hasStandardBrowserEnv && (r && a.isFunction(r) && (r = r(t)), r || r !== !1 && $n(t.url))) {
1020
1020
  const d = s && o && qn.read(o);
1021
1021
  d && i.set(s, d);
1022
1022
  }
1023
1023
  return t;
1024
1024
  }, Jn = typeof XMLHttpRequest < "u", Vn = Jn && function(e) {
1025
1025
  return new Promise(function(n, r) {
1026
- const s = Nt(e);
1026
+ const s = gt(e);
1027
1027
  let o = s.data;
1028
1028
  const i = D.from(s.headers).normalize();
1029
1029
  let { responseType: c, onUploadProgress: d, onDownloadProgress: u } = s, l, h, S, w, f;
@@ -1073,7 +1073,7 @@ const Nt = (e) => {
1073
1073
  p && (r(!y || y.type ? new ee(null, e, p) : y), p.abort(), p = null);
1074
1074
  }, s.cancelToken && s.cancelToken.subscribe(l), s.signal && (s.signal.aborted ? l() : s.signal.addEventListener("abort", l)));
1075
1075
  const I = Hn(s.url);
1076
- if (I && O.protocols.indexOf(I) === -1) {
1076
+ if (I && N.protocols.indexOf(I) === -1) {
1077
1077
  r(new E("Unsupported protocol " + I + ":", E.ERR_BAD_REQUEST, e));
1078
1078
  return;
1079
1079
  }
@@ -1180,7 +1180,7 @@ const Nt = (e) => {
1180
1180
  return !1;
1181
1181
  const c = s && ue(Ze), d = s && (typeof et == "function" ? /* @__PURE__ */ ((f) => (m) => f.encode(m))(new et()) : async (f) => new Uint8Array(await new n(f).arrayBuffer())), u = o && c && tt(() => {
1182
1182
  let f = !1;
1183
- const m = new n(O.origin, {
1183
+ const m = new n(N.origin, {
1184
1184
  body: new Ze(),
1185
1185
  method: "POST",
1186
1186
  get duplex() {
@@ -1205,7 +1205,7 @@ const Nt = (e) => {
1205
1205
  if (a.isBlob(f))
1206
1206
  return f.size;
1207
1207
  if (a.isSpecCompliantForm(f))
1208
- return (await new n(O.origin, {
1208
+ return (await new n(N.origin, {
1209
1209
  method: "POST",
1210
1210
  body: f
1211
1211
  }).arrayBuffer()).byteLength;
@@ -1231,7 +1231,7 @@ const Nt = (e) => {
1231
1231
  headers: ye,
1232
1232
  withCredentials: ae = "same-origin",
1233
1233
  fetchOptions: ke
1234
- } = Nt(f), ve = t || fetch;
1234
+ } = gt(f), ve = t || fetch;
1235
1235
  L = L ? (L + "").toLowerCase() : "text";
1236
1236
  let ce = Wn([I, y && y.toAbortSignal()], C), te = null;
1237
1237
  const z = ce && ce.unsubscribe && (() => {
@@ -1303,7 +1303,7 @@ const Nt = (e) => {
1303
1303
  ) : E.from(B, B && B.code, f, te);
1304
1304
  }
1305
1305
  };
1306
- }, er = /* @__PURE__ */ new Map(), Ot = (e) => {
1306
+ }, er = /* @__PURE__ */ new Map(), Nt = (e) => {
1307
1307
  let t = e && e.env || {};
1308
1308
  const { fetch: n, Request: r, Response: s } = t, o = [
1309
1309
  r,
@@ -1315,12 +1315,12 @@ const Nt = (e) => {
1315
1315
  d = o[c], u = l.get(d), u === void 0 && l.set(d, u = c ? /* @__PURE__ */ new Map() : Zn(t)), l = u;
1316
1316
  return u;
1317
1317
  };
1318
- Ot();
1318
+ Nt();
1319
1319
  const xe = {
1320
1320
  http: Sn,
1321
1321
  xhr: Vn,
1322
1322
  fetch: {
1323
- get: Ot
1323
+ get: Nt
1324
1324
  }
1325
1325
  };
1326
1326
  a.forEach(xe, (e, t) => {
@@ -1361,7 +1361,7 @@ function nr(e, t) {
1361
1361
  }
1362
1362
  return s;
1363
1363
  }
1364
- const gt = {
1364
+ const Ot = {
1365
1365
  /**
1366
1366
  * Resolve an adapter from a list of adapter names or functions.
1367
1367
  * @type {Function}
@@ -1373,22 +1373,22 @@ const gt = {
1373
1373
  */
1374
1374
  adapters: xe
1375
1375
  };
1376
- function Oe(e) {
1376
+ function Ne(e) {
1377
1377
  if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
1378
1378
  throw new ee(null, e);
1379
1379
  }
1380
1380
  function rt(e) {
1381
- return Oe(e), e.headers = D.from(e.headers), e.data = Ne.call(
1381
+ return Ne(e), e.headers = D.from(e.headers), e.data = ge.call(
1382
1382
  e,
1383
1383
  e.transformRequest
1384
- ), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), gt.getAdapter(e.adapter || ie.adapter, e)(e).then(function(r) {
1385
- return Oe(e), r.data = Ne.call(
1384
+ ), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), Ot.getAdapter(e.adapter || ie.adapter, e)(e).then(function(r) {
1385
+ return Ne(e), r.data = ge.call(
1386
1386
  e,
1387
1387
  e.transformResponse,
1388
1388
  r
1389
1389
  ), r.headers = D.from(r.headers), r;
1390
1390
  }, function(r) {
1391
- return yt(r) || (Oe(e), r && r.response && (r.response.data = Ne.call(
1391
+ return yt(r) || (Ne(e), r && r.response && (r.response.data = ge.call(
1392
1392
  e,
1393
1393
  e.transformResponse,
1394
1394
  r.response
@@ -1746,7 +1746,7 @@ T.isAxiosError = ir;
1746
1746
  T.mergeConfig = W;
1747
1747
  T.AxiosHeaders = D;
1748
1748
  T.formToJSON = (e) => Rt(a.isHTMLForm(e) ? new FormData(e) : e);
1749
- T.getAdapter = gt.getAdapter;
1749
+ T.getAdapter = Ot.getAdapter;
1750
1750
  T.HttpStatusCode = _e;
1751
1751
  T.default = T;
1752
1752
  const {
@@ -1883,7 +1883,7 @@ const q = T.create({
1883
1883
  q.interceptors.request.use(
1884
1884
  async (e) => {
1885
1885
  const t = new Y(), n = t.config.token;
1886
- return n ? (e.headers.Authorization = `Bearer ${n}`, await Be(n, t.config.env), e.baseURL = F.api, e) : Promise.reject(A.UNINITIALIZED);
1886
+ return n ? (e.headers.Authorization = `Bearer ${n}`, t.config.language && (e.headers["Accept-Language"] = t.config.language), await Be(n, t.config.env), e.baseURL = F.api, e) : Promise.reject(A.UNINITIALIZED);
1887
1887
  },
1888
1888
  (e) => Promise.reject(e)
1889
1889
  );
@@ -1928,19 +1928,24 @@ const Er = (e) => q.post(
1928
1928
  "/api/open-auth/user/v1/UserService/GetUserHistoryMessages",
1929
1929
  e
1930
1930
  ), br = (e) => {
1931
- const n = new Y().config.env, r = pr() || De[n].BASE_API_URL;
1931
+ const t = new Y(), n = t.config.env, r = pr() || De[n].BASE_API_URL;
1932
1932
  return T.post(
1933
1933
  `${r}/api/open-auth/openAuth/v1/OpenAuthService/AnonymousAuth`,
1934
- e
1934
+ e,
1935
+ {
1936
+ headers: t.config.language ? {
1937
+ "Accept-Language": t.config.language
1938
+ } : void 0
1939
+ }
1935
1940
  );
1936
- }, Nr = (e) => q.get(
1941
+ }, gr = (e) => q.get(
1937
1942
  "/api/chat/chat/v1/Chat/GetMsg",
1938
1943
  {
1939
1944
  params: e
1940
1945
  }
1941
1946
  );
1942
- var v = /* @__PURE__ */ ((e) => (e.SEND = "1", e.WITHDRAW = "2", e.EDIT = "3", e.SYSTEM_NOTICE = "4", e.TRANSFER = "5", e.INBOUND = "6", e.REPLY = "7", e.UNBIND = "8", e))(v || {}), $ = /* @__PURE__ */ ((e) => (e.TEXT = "1", e.IMAGE = "2", e.VIDEO = "3", e.FILE = "4", e.FAQ = "5", e))($ || {}), U = /* @__PURE__ */ ((e) => (e[e.CONNECT_SUCCESS = 200] = "CONNECT_SUCCESS", e[e.CONNECT_FAILED = 40001] = "CONNECT_FAILED", e[e.TRANSFER_CUSTOMER_SUCCESS = 201] = "TRANSFER_CUSTOMER_SUCCESS", e[e.TRANSFER_TO_CUSTOMER_SUCCESS = 202] = "TRANSFER_TO_CUSTOMER_SUCCESS", e[e.TRANSFER_USER_SUCCESS = 203] = "TRANSFER_USER_SUCCESS", e[e.TRANSFER_FAIL = 50001] = "TRANSFER_FAIL", e[e.MATCH_FAIL = 50002] = "MATCH_FAIL", e[e.MATCH_INFO = 50005] = "MATCH_INFO", e[e.MATCH_SUCCESS = 50006] = "MATCH_SUCCESS", e[e.RETRACT = 204] = "RETRACT", e[e.RETRACT_FAIL = 50003] = "RETRACT_FAIL", e[e.EDIT = 205] = "EDIT", e[e.EDIT_FAIL = 50004] = "EDIT_FAIL", e[e.COMMON_FAIL = 5e4] = "COMMON_FAIL", e[e.SEND_SUCCESS = 206] = "SEND_SUCCESS", e[e.SEND_CALLBACK = 207] = "SEND_CALLBACK", e[e.CHANGE_CHAT_STATUS = 208] = "CHANGE_CHAT_STATUS", e[e.REPLY_FAIL = 50008] = "REPLY_FAIL", e[e.REPLY_SUCCESS = 209] = "REPLY_SUCCESS", e[e.UNBIND_SUCCESS = 60006] = "UNBIND_SUCCESS", e[e.BAN_CUSTOMER = 60007] = "BAN_CUSTOMER", e[e.BAN_ENTRY = 60008] = "BAN_ENTRY", e[e.REMATCH = 60001] = "REMATCH", e))(U || {}), Ie = /* @__PURE__ */ ((e) => (e.CUSTOMER = "1", e.USER = "2", e.ANONYMOUS = "3", e))(Ie || {}), b = /* @__PURE__ */ ((e) => (e.CONNECTED = "connected", e.DISCONNECTED = "disconnected", e.ERROR = "error", e.MESSAGE = "message", e.STATUS_CHANGE = "status_change", e.HEARTBEAT_TIMEOUT = "heartbeat_timeout", e))(b || {}), g = /* @__PURE__ */ ((e) => (e.DISCONNECTED = "disconnected", e.CONNECTING = "connecting", e.CONNECTED = "connected", e.RECONNECTING = "reconnecting", e.ERROR = "error", e))(g || {}), N = /* @__PURE__ */ ((e) => (e.UNMATCHED = "1", e.MATCHING = "2", e.MATCHED = "3", e.UNBIND = "4", e))(N || {});
1943
- class Or {
1947
+ var v = /* @__PURE__ */ ((e) => (e.SEND = "1", e.WITHDRAW = "2", e.EDIT = "3", e.SYSTEM_NOTICE = "4", e.TRANSFER = "5", e.INBOUND = "6", e.REPLY = "7", e.UNBIND = "8", e))(v || {}), $ = /* @__PURE__ */ ((e) => (e.TEXT = "1", e.IMAGE = "2", e.VIDEO = "3", e.FILE = "4", e.FAQ = "5", e))($ || {}), U = /* @__PURE__ */ ((e) => (e[e.CONNECT_SUCCESS = 200] = "CONNECT_SUCCESS", e[e.CONNECT_FAILED = 40001] = "CONNECT_FAILED", e[e.TRANSFER_CUSTOMER_SUCCESS = 201] = "TRANSFER_CUSTOMER_SUCCESS", e[e.TRANSFER_TO_CUSTOMER_SUCCESS = 202] = "TRANSFER_TO_CUSTOMER_SUCCESS", e[e.TRANSFER_USER_SUCCESS = 203] = "TRANSFER_USER_SUCCESS", e[e.TRANSFER_FAIL = 50001] = "TRANSFER_FAIL", e[e.MATCH_FAIL = 50002] = "MATCH_FAIL", e[e.MATCH_INFO = 50005] = "MATCH_INFO", e[e.MATCH_SUCCESS = 50006] = "MATCH_SUCCESS", e[e.RETRACT = 204] = "RETRACT", e[e.RETRACT_FAIL = 50003] = "RETRACT_FAIL", e[e.EDIT = 205] = "EDIT", e[e.EDIT_FAIL = 50004] = "EDIT_FAIL", e[e.COMMON_FAIL = 5e4] = "COMMON_FAIL", e[e.SEND_SUCCESS = 206] = "SEND_SUCCESS", e[e.SEND_CALLBACK = 207] = "SEND_CALLBACK", e[e.CHANGE_CHAT_STATUS = 208] = "CHANGE_CHAT_STATUS", e[e.REPLY_FAIL = 50008] = "REPLY_FAIL", e[e.REPLY_SUCCESS = 209] = "REPLY_SUCCESS", e[e.UNBIND_SUCCESS = 60006] = "UNBIND_SUCCESS", e[e.BAN_CUSTOMER = 60007] = "BAN_CUSTOMER", e[e.BAN_ENTRY = 60008] = "BAN_ENTRY", e[e.REMATCH = 60001] = "REMATCH", e))(U || {}), Ie = /* @__PURE__ */ ((e) => (e.CUSTOMER = "1", e.USER = "2", e.ANONYMOUS = "3", e))(Ie || {}), b = /* @__PURE__ */ ((e) => (e.CONNECTED = "connected", e.DISCONNECTED = "disconnected", e.ERROR = "error", e.MESSAGE = "message", e.STATUS_CHANGE = "status_change", e.HEARTBEAT_TIMEOUT = "heartbeat_timeout", e))(b || {}), O = /* @__PURE__ */ ((e) => (e.DISCONNECTED = "disconnected", e.CONNECTING = "connecting", e.CONNECTED = "connected", e.RECONNECTING = "reconnecting", e.ERROR = "error", e))(O || {}), g = /* @__PURE__ */ ((e) => (e.UNMATCHED = "1", e.MATCHING = "2", e.MATCHED = "3", e.UNBIND = "4", e))(g || {});
1948
+ class Nr {
1944
1949
  events = /* @__PURE__ */ new Map();
1945
1950
  /**
1946
1951
  * 监听事件
@@ -1996,7 +2001,7 @@ class Or {
1996
2001
  this.on(t, r);
1997
2002
  }
1998
2003
  }
1999
- async function gr(e, t) {
2004
+ async function Or(e, t) {
2000
2005
  return await Be(e, t), `${await mr()}/api/ws?Authorization=${e}`;
2001
2006
  }
2002
2007
  function Cr() {
@@ -2006,7 +2011,7 @@ function Ur(e) {
2006
2011
  return typeof e == "object" && e !== null && "data" in e && "msgType" in e && "toUid" in e && "chatType" in e && "code" in e;
2007
2012
  }
2008
2013
  function ot(e) {
2009
- return e.customerServiceAvatar = M(e.customerServiceAvatar), e.userAvatar = M(e.customerServiceAvatar), e.contentType !== $.TEXT && (e.content = JSON.parse(e.content), e.content.fileUrl = M(e.content.fileUrl), e.content.thumbnailUrl = M(e.content.thumbnailUrl)), e.replyType && e.replyType !== $.TEXT && typeof e.replyContent == "string" && (e.replyContent = JSON.parse(
2014
+ return e.customerServiceAvatar = M(e.customerServiceAvatar), e.userAvatar = M(e.customerServiceAvatar), e.contentType !== $.TEXT && (e.content = JSON.parse(e.content), e.content.fileUrl = M(e.content.fileUrl), e.content.thumbnailUrl = M(e.content.thumbnailUrl)), e.replyType && e.replyType !== $.TEXT && e.replyContent && typeof e.replyContent == "string" && (e.replyContent = JSON.parse(
2010
2015
  e.replyContent
2011
2016
  ), e.replyContent.fileUrl = M(e.replyContent.fileUrl), e.replyContent.thumbnailUrl = M(
2012
2017
  e.replyContent.thumbnailUrl
@@ -2015,17 +2020,18 @@ function ot(e) {
2015
2020
  function M(e = "") {
2016
2021
  return e && !e.startsWith("http") ? me() + "/" + e : e;
2017
2022
  }
2018
- class Y extends Or {
2023
+ class Y extends Nr {
2019
2024
  config = {
2020
2025
  token: "",
2021
2026
  autoReconnect: !0,
2022
2027
  reconnectInterval: 3e3,
2023
2028
  maxReconnectAttempts: 5,
2024
2029
  responseTimeout: 15e3,
2025
- env: "production"
2030
+ env: "production",
2031
+ language: "en-US"
2026
2032
  };
2027
2033
  ws = null;
2028
- status = g.DISCONNECTED;
2034
+ status = O.DISCONNECTED;
2029
2035
  reconnectTimer = null;
2030
2036
  reconnectAttempts = 0;
2031
2037
  /** 心跳超时定时器 */
@@ -2038,11 +2044,11 @@ class Y extends Or {
2038
2044
  userInfo = null;
2039
2045
  static instance = null;
2040
2046
  /** 匹配状态 */
2041
- matchStatus = N.UNMATCHED;
2042
- constructor({ env: t = "production" } = {}) {
2047
+ matchStatus = g.UNMATCHED;
2048
+ constructor({ env: t } = {}) {
2043
2049
  if (super(), Y.instance)
2044
2050
  return Y.instance;
2045
- Y.instance = this, this.config.env = t;
2051
+ Y.instance = this, this.config.env = t || "production";
2046
2052
  }
2047
2053
  async init(t) {
2048
2054
  if (!t.token)
@@ -2057,17 +2063,17 @@ class Y extends Or {
2057
2063
  return this.consultationTypeId = t, new Promise(async (n, r) => {
2058
2064
  if (!this.config.token)
2059
2065
  return r(A.UNINITIALIZED);
2060
- if (this.status === g.CONNECTED)
2066
+ if (this.status === O.CONNECTED)
2061
2067
  return n();
2062
- if (this.status !== g.CONNECTING) {
2063
- this.setStatus(g.CONNECTING);
2068
+ if (this.status !== O.CONNECTING) {
2069
+ this.setStatus(O.CONNECTING);
2064
2070
  try {
2065
- const s = await gr(
2071
+ const s = await Or(
2066
2072
  this.config.token,
2067
2073
  this.config.env
2068
2074
  );
2069
2075
  this.ws = new WebSocket(s), this.ws.onopen = () => {
2070
- this.reconnectAttempts = 0, this.setStatus(g.CONNECTED), this.emit(b.CONNECTED), n();
2076
+ this.reconnectAttempts = 0, this.setStatus(O.CONNECTED), this.emit(b.CONNECTED), n();
2071
2077
  }, this.ws.onmessage = (o) => {
2072
2078
  try {
2073
2079
  this.handleMessage(o.data);
@@ -2075,12 +2081,12 @@ class Y extends Or {
2075
2081
  throw console.error("解析消息失败:", i), A.DATA_PARSING_ERROR;
2076
2082
  }
2077
2083
  }, this.ws.onerror = (o) => {
2078
- console.error("连接错误:", o), this.setStatus(g.ERROR), this.emit(b.ERROR, o), r(o);
2084
+ console.error("连接错误:", o), this.setStatus(O.ERROR), this.emit(b.ERROR, o), r(o);
2079
2085
  }, this.ws.onclose = () => {
2080
- this.config.env === "development" && console.warn("连接断开", (/* @__PURE__ */ new Date()).toISOString()), this.setStatus(g.DISCONNECTED), this.emit(b.DISCONNECTED), this.heartbeatTimeoutTimer && (clearTimeout(this.heartbeatTimeoutTimer), this.heartbeatTimeoutTimer = null), this.config.autoReconnect && this.reconnectAttempts < this.config.maxReconnectAttempts && this.scheduleReconnect();
2086
+ this.config.env === "development" && console.warn("连接断开", (/* @__PURE__ */ new Date()).toISOString()), this.setStatus(O.DISCONNECTED), this.emit(b.DISCONNECTED), this.heartbeatTimeoutTimer && (clearTimeout(this.heartbeatTimeoutTimer), this.heartbeatTimeoutTimer = null), this.config.autoReconnect && this.reconnectAttempts < this.config.maxReconnectAttempts && this.scheduleReconnect();
2081
2087
  };
2082
2088
  } catch (s) {
2083
- this.setStatus(g.ERROR), this.emit(b.ERROR, s), r(s);
2089
+ this.setStatus(O.ERROR), this.emit(b.ERROR, s), r(s);
2084
2090
  }
2085
2091
  }
2086
2092
  });
@@ -2090,7 +2096,7 @@ class Y extends Or {
2090
2096
  * @returns void
2091
2097
  */
2092
2098
  disconnect() {
2093
- this.config.autoReconnect = !1, this.sessionData = null, this.matchStatus = N.UNMATCHED, this.clearReconnectTimer(), this.heartbeatTimeoutTimer && (clearTimeout(this.heartbeatTimeoutTimer), this.heartbeatTimeoutTimer = null), this.ws && (this.ws.close(), this.ws = null), this.setStatus(g.DISCONNECTED);
2099
+ this.config.autoReconnect = !1, this.sessionData = null, this.matchStatus = g.UNMATCHED, this.clearReconnectTimer(), this.heartbeatTimeoutTimer && (clearTimeout(this.heartbeatTimeoutTimer), this.heartbeatTimeoutTimer = null), this.ws && (this.ws.close(), this.ws = null), this.setStatus(O.DISCONNECTED);
2094
2100
  }
2095
2101
  /**
2096
2102
  * 发送消息
@@ -2107,8 +2113,8 @@ class Y extends Or {
2107
2113
  chatType: n,
2108
2114
  editId: void 0
2109
2115
  };
2110
- if (this.status !== g.CONNECTED || !this.ws)
2111
- if (this.ws && this.status === g.DISCONNECTED) {
2116
+ if (this.status !== O.CONNECTED || !this.ws)
2117
+ if (this.ws && this.status === O.DISCONNECTED) {
2112
2118
  console.log("连接断开,尝试重新连接");
2113
2119
  try {
2114
2120
  await this.connect(this.consultationTypeId);
@@ -2123,7 +2129,7 @@ class Y extends Or {
2123
2129
  return r === v.SEND ? new Promise(async (o, i) => {
2124
2130
  const c = Cr();
2125
2131
  s.ext = c;
2126
- const d = await Nr({ ext: c });
2132
+ const d = await gr({ ext: c });
2127
2133
  d.data?.messageId ? (this.ws.send(JSON.stringify(s)), o({ messageId: d.data.messageId, data: t })) : i(A.MESSAGE_SEND_FAIL);
2128
2134
  }) : (this.ws.send(JSON.stringify(s)), { data: t });
2129
2135
  } catch (o) {
@@ -2135,7 +2141,7 @@ class Y extends Or {
2135
2141
  * @returns Promise<void>
2136
2142
  */
2137
2143
  async checkMatchStatus() {
2138
- if (this.matchStatus === N.UNBIND && (await this.sendMessage(
2144
+ if (this.matchStatus === g.UNBIND && (await this.sendMessage(
2139
2145
  this.consultationTypeId,
2140
2146
  void 0,
2141
2147
  v.INBOUND
@@ -2146,7 +2152,7 @@ class Y extends Or {
2146
2152
  this.once(b.MESSAGE, (s) => {
2147
2153
  s.code === U.REMATCH && (clearTimeout(r), t(!0));
2148
2154
  });
2149
- })), this.matchStatus !== N.MATCHED)
2155
+ })), this.matchStatus !== g.MATCHED)
2150
2156
  throw console.error(A.NO_CUSTOMER_SERVICE), A.NO_CUSTOMER_SERVICE;
2151
2157
  }
2152
2158
  /**
@@ -2207,7 +2213,7 @@ class Y extends Or {
2207
2213
  * @returns boolean
2208
2214
  */
2209
2215
  isConnected() {
2210
- return this.status === g.CONNECTED;
2216
+ return this.status === O.CONNECTED;
2211
2217
  }
2212
2218
  /**
2213
2219
  * 处理收到的消息
@@ -2225,7 +2231,7 @@ class Y extends Or {
2225
2231
  switch (t.data = n, t.code) {
2226
2232
  // 连接成功
2227
2233
  case U.CONNECT_SUCCESS:
2228
- this.matchStatus === N.MATCHED || this.matchStatus === N.MATCHING ? this.matchStatus = N.UNBIND : this.matchStatus = N.MATCHING, this.sendMessage(
2234
+ this.matchStatus === g.MATCHED || this.matchStatus === g.MATCHING ? this.matchStatus = g.UNBIND : this.matchStatus = g.MATCHING, this.sendMessage(
2229
2235
  this.consultationTypeId,
2230
2236
  void 0,
2231
2237
  v.INBOUND
@@ -2234,12 +2240,12 @@ class Y extends Or {
2234
2240
  // 匹配成功
2235
2241
  case U.MATCH_INFO:
2236
2242
  case U.MATCH_SUCCESS:
2237
- if (this.matchStatus === N.MATCHED)
2243
+ if (this.matchStatus === g.MATCHED)
2238
2244
  return;
2239
- t.data.customerAvatar = M(t.data.customerAvatar), this.sessionData = t.data, this.matchStatus === N.UNBIND ? (this.matchStatus = N.MATCHED, this.emit(b.MESSAGE, {
2245
+ t.data.customerAvatar = M(t.data.customerAvatar), this.sessionData = t.data, this.matchStatus === g.UNBIND ? (this.matchStatus = g.MATCHED, this.emit(b.MESSAGE, {
2240
2246
  ...t,
2241
2247
  code: U.REMATCH
2242
- })) : (this.matchStatus = N.MATCHED, this.getFaqList(), this.emit(b.MESSAGE, t));
2248
+ })) : (this.matchStatus = g.MATCHED, this.getFaqList(), this.emit(b.MESSAGE, t));
2243
2249
  break;
2244
2250
  // 转接用户成功
2245
2251
  case U.TRANSFER_USER_SUCCESS:
@@ -2270,7 +2276,7 @@ class Y extends Or {
2270
2276
  case U.UNBIND_SUCCESS:
2271
2277
  if (n.sessionId !== this.sessionData?.sessionId)
2272
2278
  return;
2273
- this.matchStatus = N.UNBIND, this.sessionData = null, this.emit(b.MESSAGE, t);
2279
+ this.matchStatus = g.UNBIND, this.sessionData = null, this.emit(b.MESSAGE, t);
2274
2280
  break;
2275
2281
  default:
2276
2282
  this.emit(b.MESSAGE, t);
@@ -2296,7 +2302,7 @@ class Y extends Or {
2296
2302
  this.config.env === "development" && console.warn(
2297
2303
  `第${this.reconnectAttempts + 1}次安排重连`,
2298
2304
  (/* @__PURE__ */ new Date()).toISOString()
2299
- ), this.clearReconnectTimer(), this.reconnectAttempts++, this.setStatus(g.RECONNECTING), this.reconnectTimer = setTimeout(() => {
2305
+ ), this.clearReconnectTimer(), this.reconnectAttempts++, this.setStatus(O.RECONNECTING), this.reconnectTimer = setTimeout(() => {
2300
2306
  this.connect(this.consultationTypeId).catch((t) => {
2301
2307
  console.error("重连失败:", t);
2302
2308
  });
@@ -2314,7 +2320,7 @@ class Y extends Or {
2314
2320
  * @returns void
2315
2321
  */
2316
2322
  sendHeartbeat() {
2317
- if (!(this.status !== g.CONNECTED || !this.ws))
2323
+ if (!(this.status !== O.CONNECTED || !this.ws))
2318
2324
  try {
2319
2325
  this.ws.send("pong"), this.lastHeartbeatTime = Date.now(), this.heartbeatTimeoutTimer = setTimeout(() => {
2320
2326
  Date.now() - this.lastHeartbeatTime >= this.config.responseTimeout && (this.emit(b.HEARTBEAT_TIMEOUT), this.config.env === "development" && console.warn("心跳超时,尝试重连", (/* @__PURE__ */ new Date()).toISOString()), this.ws && this.ws.close());
@@ -2332,7 +2338,7 @@ class Y extends Or {
2332
2338
  lastMsgId: t,
2333
2339
  size: n = 50
2334
2340
  }) {
2335
- if (this.matchStatus !== N.MATCHED)
2341
+ if (this.matchStatus !== g.MATCHED)
2336
2342
  return Promise.reject(A.NO_CUSTOMER_SERVICE);
2337
2343
  const r = await Ar({
2338
2344
  sessionId: this.sessionData?.sessionId,
@@ -2407,7 +2413,7 @@ class Y extends Or {
2407
2413
  }), s.load();
2408
2414
  });
2409
2415
  async getFaqList() {
2410
- if (this.matchStatus !== N.MATCHED)
2416
+ if (this.matchStatus !== g.MATCHED)
2411
2417
  return Promise.reject(A.NO_CUSTOMER_SERVICE);
2412
2418
  const t = await Rr({ id: this.sessionData?.cid });
2413
2419
  if (!t.data?.topic?.length)
@@ -2476,13 +2482,16 @@ class Y extends Or {
2476
2482
  userSource: "H5"
2477
2483
  })).data;
2478
2484
  }
2485
+ setLanguage(t) {
2486
+ this.config.language = t || "en-US";
2487
+ }
2479
2488
  }
2480
2489
  export {
2481
2490
  $ as ChatType,
2482
- g as ConnectionStatus,
2491
+ O as ConnectionStatus,
2483
2492
  b as EventType,
2484
2493
  Y as JoyTalk,
2485
- N as MatchStatus,
2494
+ g as MatchStatus,
2486
2495
  U as MessageCode,
2487
2496
  v as MessageType,
2488
2497
  Ie as SendUserType,