joytalk 0.0.21 → 0.0.22

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/README.md CHANGED
@@ -53,6 +53,8 @@ await JTalk.init({
53
53
  });
54
54
  ```
55
55
 
56
+ ---
57
+
56
58
  ### 获取咨询列表
57
59
  通过 `getConsultationList` 方法,传入入口ID,获取咨询列表。
58
60
 
@@ -185,65 +187,104 @@ JTalk.on(EventType.STATUS_CHANGE, (status) => {
185
187
  **MessageCode 枚举:**
186
188
  - `MessageCode.CONNECT_SUCCESS` - 连接成功
187
189
  - `MessageCode.CONNECT_FAILED` - 连接失败
188
- - `MessageCode.MATCH_INFO` / `MessageCode.MATCH_SUCCESS` - 匹配成功
190
+ - `MessageCode.TRANSFER_CUSTOMER_SUCCESS` - 转接成功通知原客服
191
+ - `MessageCode.TRANSFER_TO_CUSTOMER_SUCCESS` - 转接成功通知转接客服
192
+ - `MessageCode.TRANSFER_USER_SUCCESS` - 转接成功通知用户
193
+ - `MessageCode.TRANSFER_FAIL` - 转接失败
189
194
  - `MessageCode.MATCH_FAIL` - 匹配失败
190
- - `MessageCode.SEND_SUCCESS` - 发送成功
191
- - `MessageCode.SEND_CALLBACK` - 发送回调
195
+ - `MessageCode.MATCH_INFO` - 匹配成功,返回信息
196
+ - `MessageCode.MATCH_SUCCESS` - 分配成功
192
197
  - `MessageCode.RETRACT` - 撤回
198
+ - `MessageCode.RETRACT_FAIL` - 撤回失败
193
199
  - `MessageCode.EDIT` - 编辑
194
- - `MessageCode.TRANSFER_*` - 转接相关
200
+ - `MessageCode.EDIT_FAIL` - 编辑失败
195
201
  - `MessageCode.COMMON_FAIL` - 通用错误
202
+ - `MessageCode.SEND_SUCCESS` - 发送成功
203
+ - `MessageCode.SEND_CALLBACK` - 发送回调
204
+ - `MessageCode.CHANGE_CHAT_STATUS` - 变更会话状态
205
+ - `MessageCode.REPLY_FAIL` - 回复消息失败
206
+ - `MessageCode.REPLY_SUCCESS` - 回复消息成功
207
+ - `MessageCode.UNBIND_SUCCESS` - 解绑成功
208
+ - `MessageCode.REMATCH` - 重新匹配
196
209
 
197
210
  ---
198
211
 
199
- ### 发送文本消息
200
- 通过 `sendText` 方法,发送文本消息。
212
+
213
+ ---
214
+ ### 获取聊天记录
215
+ 通过 `getHistoryMessages` 方法,获取聊天记录。
216
+ **注意:该方法需在已匹配客服后调用。**
201
217
 
202
218
  **示例:**
203
219
  ```typescript
204
- const content = '你好,我需要帮助';
205
- JTalk.sendText(content);
220
+ const { list, hasMore } = await JTalk.getHistoryMessages({ lastMsgId: '123456', size: 50 });
221
+ console.log(list, hasMore);
206
222
  ```
207
223
 
208
224
  **参数说明:**
225
+
209
226
  | 参数 | 说明 | 是否必填 | 默认值 |
210
227
  |------|------|----------|--------|
211
- | `content` | 消息内容 | | - |
228
+ | `lastMsgId` | 上一页最后一条消息 ID | | - |
229
+ | `size` | 每页条数 | 否 | 50 |
212
230
 
213
- ### 发送文件消息(图片 / 文件)
214
- 通过 `sendFile` 方法,发送图片或普通文件消息(视频见下方「发送视频消息」)。
231
+ **返回值说明:**
232
+
233
+ | 返回值 | 说明 |
234
+ |--------|------|
235
+ | `list` | 消息列表 |
236
+ | `hasMore` | 是否有更多数据 |
237
+
238
+ ---
239
+
240
+ ### 发送文本消息
241
+ 通过 `sendText` 方法,发送文本消息。
215
242
 
216
243
  **示例:**
217
244
  ```typescript
218
- // 发送图片
219
- const file = document.querySelector('input[type="file"]').files?.[0];
220
- if (file) {
221
- await JTalk.sendFile({ file, chatType: ChatType.IMAGE });
222
- }
223
- // 发送文件
224
- await JTalk.sendFile({ file: docFile, chatType: ChatType.FILE });
245
+ const content = '你好!';
246
+ const { messageId } = await JTalk.sendText(content);
247
+ console.log(messageId);
225
248
  ```
226
249
 
227
250
  **参数说明:**
228
-
229
251
  | 参数 | 说明 | 是否必填 | 默认值 |
230
252
  |------|------|----------|--------|
231
- | `file` | 文件对象 | 是 | - |
232
- | `chatType` | 聊天类型:`ChatType.IMAGE` 或 `ChatType.FILE` | 是 | - |
253
+ | `content` | 消息内容 | 是 | - |
254
+
255
+ **返回值说明:**
233
256
 
234
- ### 发送视频消息
235
- 通过 `sendFile` 方法并传入 `ChatType.VIDEO`,发送视频消息。建议先用 `getVideoThumbnail` 生成缩略图再发送。
257
+ | 返回值 | 说明 |
258
+ |--------|------|
259
+ | `messageId` | 消息 ID |
260
+
261
+ ---
262
+ ### 发送文件消息(图片 / 视频 / 文件)
263
+ 通过 `sendFile` 方法,发送图片、视频或普通文件消息。
236
264
 
237
265
  **示例:**
238
266
  ```typescript
267
+ // 发送图片
268
+ const file = document.querySelector('input[type="file"]').files?.[0];
269
+ if (file) {
270
+ const { messageId } = await JTalk.sendFile({ file, chatType: ChatType.IMAGE });
271
+ console.log(messageId);
272
+ }
273
+
274
+ // 发送视频
239
275
  const videoFile = document.querySelector('input[type="file"]').files?.[0];
240
276
  if (videoFile) {
277
+ // 获取视频缩略图
241
278
  const thumbnailFile = await JTalk.getVideoThumbnail(videoFile);
242
- await JTalk.sendFile({
243
- file: videoFile,
244
- thumbnailFile,
245
- chatType: ChatType.VIDEO,
246
- });
279
+ const { messageId } = await JTalk.sendFile({ file: videoFile, thumbnailFile, chatType: ChatType.VIDEO });
280
+ console.log(messageId);
281
+ }
282
+
283
+ // 发送文件
284
+ const file = document.querySelector('input[type="file"]').files?.[0];
285
+ if (file) {
286
+ const { messageId } = await JTalk.sendFile({ file, chatType: ChatType.FILE });
287
+ console.log(messageId);
247
288
  }
248
289
  ```
249
290
 
@@ -251,36 +292,56 @@ if (videoFile) {
251
292
 
252
293
  | 参数 | 说明 | 是否必填 | 默认值 |
253
294
  |------|------|----------|--------|
254
- | `file` | 视频文件对象 | 是 | - |
295
+ | `file` | 文件对象 | 是 | - |
255
296
  | `thumbnailFile` | 缩略图文件(可选,建议使用 getVideoThumbnail 生成) | 否 | - |
256
- | `chatType` | 固定为 `ChatType.VIDEO` | 是 | - |
297
+ | `chatType` | 聊天类型:`ChatType.IMAGE` `ChatType.VIDEO` 或 `ChatType.FILE` | 是 | - |
257
298
 
258
- ### 获取聊天记录
259
- 通过 `getHistoryMessages` 方法,获取聊天记录。需在已匹配客服后调用。
299
+ **返回值说明:**
300
+
301
+ | 返回值 | 说明 |
302
+ |--------|------|
303
+ | `messageId` | 消息 ID |
304
+
305
+ ---
306
+
307
+ ### 发送 FAQ 消息
308
+ 点击 FAQ 问题时,通过 `sendFaq` 方法,将该 FAQ 问题对象作为参数传入,SDK 会自动返回该 FAQ 问题的答案。
260
309
 
261
310
  **示例:**
262
311
  ```typescript
263
- const { list, hasMore } = await JTalk.getHistoryMessages({ size: 50 });
264
- // 加载更多
265
- const next = await JTalk.getHistoryMessages({
266
- lastMsgId: list[0]?.messageId,
267
- size: 50,
268
- });
312
+ const faqItem = {
313
+ faqId: 1,
314
+ faqItemId: 1,
315
+ id: 1,
316
+ imageUrl: ['https://example.com/image.jpg'],
317
+ question: '问题',
318
+ answer: '答案',
319
+ sortOrder: 1,
320
+ isMulti: false,
321
+ item: [],
322
+ };
323
+ await JTalk.sendFaq(faqItem);
269
324
  ```
270
325
 
271
326
  **参数说明:**
272
327
 
273
328
  | 参数 | 说明 | 是否必填 | 默认值 |
274
329
  |------|------|----------|--------|
275
- | `lastMsgId` | 上一页最后一条消息 ID | | - |
276
- | `size` | 每页条数 | 否 | 50 |
330
+ | `faqItem` | FAQ 问题对象 | | - |
277
331
 
278
- **返回值说明:**
332
+ **FaqItem 类型定义:**
279
333
 
280
- | 返回值 | 说明 |
281
- |--------|------|
282
- | `list` | 消息列表 |
283
- | `hasMore` | 是否有更多数据 |
334
+ | 参数 | 说明 |
335
+ |------|------|
336
+ | `faqId` | FAQ ID |
337
+ | `faqItemId` | FAQ 项 ID |
338
+ | `id` | ID |
339
+ | `imageUrl` | 图片 URL 列表 |
340
+ | `question` | 问题 |
341
+ | `answer` | 答案 |
342
+ | `sortOrder` | 排序 |
343
+ | `isMulti` | 是否多选 |
344
+ | `item` | 子项 |
284
345
 
285
346
  ---
286
347
 
@@ -290,7 +351,6 @@ const next = await JTalk.getHistoryMessages({
290
351
  - **`getStatus(): ConnectionStatus`** — 获取当前连接状态。
291
352
  - **`isConnected(): boolean`** — 是否已连接。
292
353
  - **`getVideoThumbnail(videoFile: File): Promise<File>`** — 获取视频首帧缩略图,发送视频时建议使用。
293
- - **`sendFaq(faqItem: FaqItem): void`** — 发送 FAQ 消息。
294
354
  - **`off(event, callback): void`** — 取消监听事件,需传入与 `on` 时相同的回调引用。
295
355
  - **公共属性:** `OBS_URL`(OBS 存储地址)、`userInfo`(当前用户信息,只读)。
296
356
 
@@ -6,7 +6,7 @@ declare const baseUrls: {
6
6
  /**
7
7
  * 获取 ListLines,再对 apis / downloads 分别测速,取最快作为 baseUrl
8
8
  */
9
- export declare function ensureBaseUrls(token: string): Promise<void>;
9
+ export declare function ensureBaseUrls(token: string, env: string): Promise<void>;
10
10
  declare const request: import('axios').AxiosInstance;
11
11
  export default request;
12
12
  export { baseUrls };
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function ot(e,t){return function(){return e.apply(t,arguments)}}const{toString:_t}=Object.prototype,{getPrototypeOf:Ie}=Object,{iterator:Se,toStringTag:it}=Symbol,Te=(e=>t=>{const n=_t.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>Te(t)===e),we=e=>t=>typeof t===e,{isArray:Y}=Array,X=we("undefined");function te(e){return e!==null&&!X(e)&&e.constructor!==null&&!X(e.constructor)&&D(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const at=P("ArrayBuffer");function It(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&at(e.buffer),t}const Lt=we("string"),D=we("function"),ct=we("number"),ne=e=>e!==null&&typeof e=="object",Ft=e=>e===!0||e===!1,ue=e=>{if(Te(e)!=="object")return!1;const t=Ie(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(it in e)&&!(Se in e)},Pt=e=>{if(!ne(e)||te(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xt=P("Date"),kt=P("File"),Bt=P("Blob"),Ht=P("FileList"),Mt=e=>ne(e)&&D(e.pipe),jt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||D(e.append)&&((t=Te(e))==="formdata"||t==="object"&&D(e.toString)&&e.toString()==="[object FormData]"))},vt=P("URLSearchParams"),[qt,$t,Gt,zt]=["ReadableStream","Request","Response","Headers"].map(P),Jt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function re(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Y(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(te(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function lt(e,t){if(te(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const G=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ut=e=>!X(e)&&e!==G;function ge(){const{caseless:e,skipUndefined:t}=ut(this)&&this||{},n={},r=(s,o)=>{const i=e&&lt(n,o)||o;ue(n[i])&&ue(s)?n[i]=ge(n[i],s):ue(s)?n[i]=ge({},s):Y(s)?n[i]=s.slice():(!t||!X(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&re(arguments[s],r);return n}const Wt=(e,t,n,{allOwnKeys:r}={})=>(re(t,(s,o)=>{n&&D(s)?e[o]=ot(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&Ie(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(Y(e))return e;let t=e.length;if(!ct(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ie(Uint8Array)),en=(e,t)=>{const r=(e&&e[Se]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},tn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nn=P("HTMLFormElement"),rn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),sn=P("RegExp"),ft=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};re(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},on=e=>{ft(e,(t,n)=>{if(D(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(D(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},an=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Y(e)?r(e):r(String(e).split(t)),n},cn=()=>{},ln=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function un(e){return!!(e&&D(e.append)&&e[it]==="FormData"&&e[Se])}const fn=e=>{const t=new Array(10),n=(r,s)=>{if(ne(r)){if(t.indexOf(r)>=0)return;if(te(r))return r;if(!("toJSON"in r)){t[s]=r;const o=Y(r)?[]:{};return re(r,(i,c)=>{const d=n(i,s+1);!X(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},dn=P("AsyncFunction"),hn=e=>e&&(ne(e)||D(e))&&D(e.then)&&D(e.catch),dt=((e,t)=>e?setImmediate:t?((n,r)=>(G.addEventListener("message",({source:s,data:o})=>{s===G&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),G.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",D(G.postMessage)),pn=typeof queueMicrotask<"u"?queueMicrotask.bind(G):typeof process<"u"&&process.nextTick||dt,mn=e=>e!=null&&D(e[Se]),a={isArray:Y,isArrayBuffer:at,isBuffer:te,isFormData:jt,isArrayBufferView:It,isString:Lt,isNumber:ct,isBoolean:Ft,isObject:ne,isPlainObject:ue,isEmptyObject:Pt,isReadableStream:qt,isRequest:$t,isResponse:Gt,isHeaders:zt,isUndefined:X,isDate:xt,isFile:kt,isBlob:Bt,isRegExp:sn,isFunction:D,isStream:Mt,isURLSearchParams:vt,isTypedArray:Zt,isFileList:Ht,forEach:re,merge:ge,extend:Wt,trim:Jt,stripBOM:Vt,inherits:Kt,toFlatObject:Xt,kindOf:Te,kindOfTest:P,endsWith:Yt,toArray:Qt,forEachEntry:en,matchAll:tn,isHTMLForm:nn,hasOwnProperty:qe,hasOwnProp:qe,reduceDescriptors:ft,freezeMethods:on,toObjectSet:an,toCamelCase:rn,noop:cn,toFiniteNumber:ln,findKey:lt,global:G,isContextDefined:ut,isSpecCompliantForm:un,toJSONObject:fn,isAsyncFn:dn,isThenable:hn,setImmediate:dt,asap:pn,isIterable:mn};function E(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(E,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const ht=E.prototype,pt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{pt[e]={value:e}});Object.defineProperties(E,pt);Object.defineProperty(ht,"isAxiosError",{value:!0});E.from=(e,t,n,r,s,o)=>{const i=Object.create(ht);a.toFlatObject(e,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return E.call(i,c,d,n,r,s),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",o&&Object.assign(i,o),i};const En=null;function Ue(e){return a.isPlainObject(e)||a.isArray(e)}function mt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function $e(e,t,n){return e?e.concat(t).map(function(s,o){return s=mt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Sn(e){return a.isArray(e)&&!e.some(Ue)}const Tn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function ye(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,h){return!a.isUndefined(h[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new E("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,h){let w=f;if(f&&!h&&typeof f=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Sn(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(w=a.toArray(f)))return m=mt(m),w.forEach(function(y,U){!(a.isUndefined(y)||y===null)&&t.append(i===!0?$e([m],U,o):i===null?m:m+"[]",u(y))}),!1}return Ue(f)?!0:(t.append($e(h,m,o),u(f)),!1)}const p=[],S=Object.assign(Tn,{defaultVisitor:l,convertValue:u,isVisitable:Ue});function A(f,m){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));p.push(f),a.forEach(f,function(w,I){(!(a.isUndefined(w)||w===null)&&s.call(t,w,a.isString(I)?I.trim():I,m,S))===!0&&A(w,m?m.concat(I):[I])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return A(e),t}function Ge(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Le(e,t){this._pairs=[],e&&ye(e,this,t)}const Et=Le.prototype;Et.append=function(t,n){this._pairs.push([t,n])};Et.toString=function(t){const n=t?function(r){return t.call(this,r,Ge)}:Ge;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function wn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function St(e,t,n){if(!t)return e;const r=n&&n.encode||wn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Le(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ze{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},yn=typeof URLSearchParams<"u"?URLSearchParams:Le,Rn=typeof FormData<"u"?FormData:null,bn=typeof Blob<"u"?Blob:null,An={isBrowser:!0,classes:{URLSearchParams:yn,FormData:Rn,Blob:bn},protocols:["http","https","file","blob","url","data"]},Fe=typeof window<"u"&&typeof document<"u",De=typeof navigator=="object"&&navigator||void 0,Nn=Fe&&(!De||["ReactNative","NativeScript","NS"].indexOf(De.product)<0),On=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cn=Fe&&window.location.href||"http://localhost",gn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fe,hasStandardBrowserEnv:Nn,hasStandardBrowserWebWorkerEnv:On,navigator:De,origin:Cn},Symbol.toStringTag,{value:"Module"})),C={...gn,...An};function Un(e,t){return ye(e,new C.classes.URLSearchParams,{visitor:function(n,r,s,o){return C.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Dn(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function wt(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(Dn(r),s,n,0)}),n}return null}function In(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const se={transitional:Tt,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(wt(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Un(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ye(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),In(t)):t}],transformResponse:[function(t){const n=this.transitional||se.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?E.from(c,E.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{se.headers[e]={}});const Ln=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Fn=e=>{const t={};let n,r,s;return e&&e.split(`
2
- `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Ln[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Je=Symbol("internals");function ee(e){return e&&String(e).trim().toLowerCase()}function fe(e){return e===!1||e==null?e:a.isArray(e)?e.map(fe):String(e)}function Pn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const xn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ne(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function kn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Bn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let _=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,u){const l=ee(d);if(!l)throw new Error("header name must be a non-empty string");const p=a.findKey(s,l);(!p||s[p]===void 0||u===!0||u===void 0&&s[p]!==!1)&&(s[p||d]=fe(c))}const i=(c,d)=>a.forEach(c,(u,l)=>o(u,l,d));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!xn(t))i(Fn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let c={},d,u;for(const l of t){if(!a.isArray(l))throw TypeError("Object iterator must return a key-value pair");c[u=l[0]]=(d=c[u])?a.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}i(c,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=ee(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Pn(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=ee(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ne(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=ee(i),i){const c=a.findKey(r,i);c&&(!n||Ne(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||Ne(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=fe(s),delete n[o];return}const c=t?kn(o):String(o).trim();c!==o&&delete n[o],n[c]=fe(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Je]=this[Je]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=ee(i);r[c]||(Bn(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};_.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(_.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(_);function Oe(e,t){const n=this||se,r=t||n,s=_.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function yt(e){return!!(e&&e.__CANCEL__)}function Q(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(Q,E,{__CANCEL__:!0});function Rt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new E("Request failed with status code "+n.status,[E.ERR_BAD_REQUEST,E.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Hn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Mn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=r[o];i||(i=u),n[s]=d,r[s]=u;let p=o,S=0;for(;p!==s;)S+=n[p++],p=p%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const A=l&&u-l;return A?Math.round(S*1e3/A):void 0}}function jn(e,t){let n=0,r=1e3/t,s,o;const i=(u,l=Date.now())=>{n=l,s=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{const l=Date.now(),p=l-n;p>=r?i(u,l):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-p)))},()=>s&&i(s)]}const he=(e,t,n=3)=>{let r=0;const s=Mn(50,250);return jn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),l=i<=c;r=i;const p={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},n)},We=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ve=e=>(...t)=>a.asap(()=>e(...t)),vn=C.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,C.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,qn=C.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function $n(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Gn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function bt(e,t,n){let r=!$n(t);return e&&(r||n==!1)?Gn(e,t):t}const Ke=e=>e instanceof _?{...e}:e;function J(e,t){t=t||{};const n={};function r(u,l,p,S){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:S},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,p,S){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,p,S)}else return r(u,l,p,S)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,p){if(p in t)return r(u,l);if(p in e)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,p)=>s(Ke(u),Ke(l),p,!0)};return a.forEach(Object.keys({...e,...t}),function(l){const p=d[l]||s,S=p(e[l],t[l],l);a.isUndefined(S)&&p!==c||(n[l]=S)}),n}const At=e=>{const t=J({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=_.from(i),t.url=St(bt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,p])=>{u.includes(l.toLowerCase())&&i.set(l,p)})}}if(C.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&vn(t.url))){const d=s&&o&&qn.read(o);d&&i.set(s,d)}return t},zn=typeof XMLHttpRequest<"u",Jn=zn&&function(e){return new Promise(function(n,r){const s=At(e);let o=s.data;const i=_.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,l,p,S,A,f;function m(){A&&A(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function w(){if(!h)return;const y=_.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),F={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:y,config:e,request:h};Rt(function(L){n(L),m()},function(L){r(L),m()},F),h=null}"onloadend"in h?h.onloadend=w:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(w)},h.onabort=function(){h&&(r(new E("Request aborted",E.ECONNABORTED,e,h)),h=null)},h.onerror=function(U){const F=U&&U.message?U.message:"Network Error",q=new E(F,E.ERR_NETWORK,e,h);q.event=U||null,r(q),h=null},h.ontimeout=function(){let U=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const F=s.transitional||Tt;s.timeoutErrorMessage&&(U=s.timeoutErrorMessage),r(new E(U,F.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(U,F){h.setRequestHeader(F,U)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),c&&c!=="json"&&(h.responseType=s.responseType),u&&([S,f]=he(u,!0),h.addEventListener("progress",S)),d&&h.upload&&([p,A]=he(d),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",A)),(s.cancelToken||s.signal)&&(l=y=>{h&&(r(!y||y.type?new Q(null,e,h):y),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const I=Hn(s.url);if(I&&C.protocols.indexOf(I)===-1){r(new E("Unsupported protocol "+I+":",E.ERR_BAD_REQUEST,e));return}h.send(o||null)})},Wn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const l=u instanceof Error?u:this.reason;r.abort(l instanceof E?l:new Q(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,o(new E(`timeout ${t} of ms exceeded`,E.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},Vn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},Kn=async function*(e,t){for await(const n of Xn(e))yield*Vn(n,t)},Xn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Xe=(e,t,n,r)=>{const s=Kn(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){c(),d.close();return}let p=l.byteLength;if(n){let S=o+=p;n(S)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},Ye=64*1024,{isFunction:ce}=a,Yn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:Qe,TextEncoder:Ze}=a.global,et=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Qn=e=>{e=a.merge.call({skipUndefined:!0},Yn,e);const{fetch:t,Request:n,Response:r}=e,s=t?ce(t):typeof fetch=="function",o=ce(n),i=ce(r);if(!s)return!1;const c=s&&ce(Qe),d=s&&(typeof Ze=="function"?(f=>m=>f.encode(m))(new Ze):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=o&&c&&et(()=>{let f=!1;const m=new n(C.origin,{body:new Qe,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),l=i&&c&&et(()=>a.isReadableStream(new r("").body)),p={stream:l&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!p[f]&&(p[f]=(m,h)=>{let w=m&&m[f];if(w)return w.call(m);throw new E(`Response type '${f}' is not supported`,E.ERR_NOT_SUPPORT,h)})});const S=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new n(C.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},A=async(f,m)=>{const h=a.toFiniteNumber(f.getContentLength());return h??S(m)};return async f=>{let{url:m,method:h,data:w,signal:I,cancelToken:y,timeout:U,onDownloadProgress:F,onUploadProgress:q,responseType:L,headers:be,withCredentials:oe="same-origin",fetchOptions:ke}=At(f),Be=t||fetch;L=L?(L+"").toLowerCase():"text";let ie=Wn([I,y&&y.toAbortSignal()],U),Z=null;const $=ie&&ie.unsubscribe&&(()=>{ie.unsubscribe()});let He;try{if(q&&u&&h!=="get"&&h!=="head"&&(He=await A(be,w))!==0){let j=new n(m,{method:"POST",body:w,duplex:"half"}),V;if(a.isFormData(w)&&(V=j.headers.get("content-type"))&&be.setContentType(V),j.body){const[Ae,ae]=We(He,he(Ve(q)));w=Xe(j.body,Ye,Ae,ae)}}a.isString(oe)||(oe=oe?"include":"omit");const x=o&&"credentials"in n.prototype,Me={...ke,signal:ie,method:h.toUpperCase(),headers:be.normalize().toJSON(),body:w,duplex:"half",credentials:x?oe:void 0};Z=o&&new n(m,Me);let M=await(o?Be(Z,ke):Be(m,Me));const je=l&&(L==="stream"||L==="response");if(l&&(F||je&&$)){const j={};["status","statusText","headers"].forEach(ve=>{j[ve]=M[ve]});const V=a.toFiniteNumber(M.headers.get("content-length")),[Ae,ae]=F&&We(V,he(Ve(F),!0))||[];M=new r(Xe(M.body,Ye,Ae,()=>{ae&&ae(),$&&$()}),j)}L=L||"text";let Dt=await p[a.findKey(p,L)||"text"](M,f);return!je&&$&&$(),await new Promise((j,V)=>{Rt(j,V,{data:Dt,headers:_.from(M.headers),status:M.status,statusText:M.statusText,config:f,request:Z})})}catch(x){throw $&&$(),x&&x.name==="TypeError"&&/Load failed|fetch/i.test(x.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,Z),{cause:x.cause||x}):E.from(x,x&&x.code,f,Z)}}},Zn=new Map,Nt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,c=i,d,u,l=Zn;for(;c--;)d=o[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:Qn(t)),l=u;return u};Nt();const Pe={http:En,xhr:Jn,fetch:{get:Nt}};a.forEach(Pe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const tt=e=>`- ${e}`,er=e=>a.isFunction(e)||e===null||e===!1;function tr(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let c;if(s=r,!er(r)&&(s=Pe[(c=String(r)).toLowerCase()],s===void 0))throw new E(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
4
- `+i.map(tt).join(`
5
- `):" "+tt(i[0]):"as no adapter specified";throw new E("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Ot={getAdapter:tr,adapters:Pe};function Ce(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Q(null,e)}function nt(e){return Ce(e),e.headers=_.from(e.headers),e.data=Oe.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ot.getAdapter(e.adapter||se.adapter,e)(e).then(function(r){return Ce(e),r.data=Oe.call(e,e.transformResponse,r),r.headers=_.from(r.headers),r},function(r){return yt(r)||(Ce(e),r&&r.response&&(r.response.data=Oe.call(e,e.transformResponse,r.response),r.response.headers=_.from(r.response.headers))),Promise.reject(r)})}const Ct="1.13.2",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const rt={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Ct+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new E(s(i," has been removed"+(n?" in "+n:"")),E.ERR_DEPRECATED);return n&&!rt[i]&&(rt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};Re.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function nr(e,t,n){if(typeof e!="object")throw new E("options must be an object",E.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new E("option "+o+" must be "+d,E.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new E("Unknown option "+o,E.ERR_BAD_OPTION)}}const de={assertOptions:nr,validators:Re},k=de.validators;let z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new ze,response:new ze}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=J(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&de.assertOptions(r,{silentJSONParsing:k.transitional(k.boolean),forcedJSONParsing:k.transitional(k.boolean),clarifyTimeoutError:k.transitional(k.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:de.assertOptions(s,{encode:k.function,serialize:k.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),de.assertOptions(n,{baseUrl:k.spelling("baseURL"),withXsrfToken:k.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=_.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,p=0,S;if(!d){const f=[nt.bind(this),void 0];for(f.unshift(...c),f.push(...u),S=f.length,l=Promise.resolve(n);p<S;)l=l.then(f[p++],f[p++]);return l}S=c.length;let A=n;for(;p<S;){const f=c[p++],m=c[p++];try{A=f(A)}catch(h){m.call(this,h);break}}try{l=nt.call(this,A)}catch(f){return Promise.reject(f)}for(p=0,S=u.length;p<S;)l=l.then(u[p++],u[p++]);return l}getUri(t){t=J(this.defaults,t);const n=bt(t.baseURL,t.url,t.allowAbsoluteUrls);return St(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){z.prototype[t]=function(n,r){return this.request(J(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(J(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}z.prototype[t]=n(),z.prototype[t+"Form"]=n(!0)});let rr=class gt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Q(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new gt(function(s){t=s}),cancel:t}}};function sr(e){return function(n){return e.apply(null,n)}}function or(e){return a.isObject(e)&&e.isAxiosError===!0}const _e={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(_e).forEach(([e,t])=>{_e[t]=e});function Ut(e){const t=new z(e),n=ot(z.prototype.request,t);return a.extend(n,z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Ut(J(e,s))},n}const T=Ut(se);T.Axios=z;T.CanceledError=Q;T.CancelToken=rr;T.isCancel=yt;T.VERSION=Ct;T.toFormData=ye;T.AxiosError=E;T.Cancel=T.CanceledError;T.all=function(t){return Promise.all(t)};T.spread=sr;T.isAxiosError=or;T.mergeConfig=J;T.AxiosHeaders=_;T.formToJSON=e=>wt(a.isHTMLForm(e)?new FormData(e):e);T.getAdapter=Ot.getAdapter;T.HttpStatusCode=_e;T.default=T;const{Axios:Cr,AxiosError:gr,CanceledError:Ur,isCancel:Dr,CancelToken:_r,VERSION:Ir,all:Lr,Cancel:Fr,isAxiosError:Pr,spread:xr,toFormData:kr,AxiosHeaders:Br,HttpStatusCode:Hr,formToJSON:Mr,getAdapter:jr,mergeConfig:vr}=T,pe="JOYTALK_TOKEN";var B=(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))(B||{}),H=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(H||{}),g=(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.REMATCH=60001]="REMATCH",e))(g||{}),me=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(me||{}),R=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(R||{}),N=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(N||{}),O=(e=>(e.UNMATCHED="1",e.MATCHING="2",e.MATCHED="3",e.UNBIND="4",e))(O||{});const b={UNINITIALIZED:{code:10001,msg:"未初始化"},DISCONNECTED:{code:10002,msg:"未连接"},NO_CUSTOMER_SERVICE:{code:10003,msg:"未分配客服"},MESSAGE_SEND_FAIL:{code:10004,msg:"消息发送失败"},DATA_PARSING_ERROR:{code:10005,msg:"数据解析异常"},FILE_NOT_EXIST:{code:10006,msg:"文件不存在"},FILE_PARSING_ERROR:{code:10007,msg:"文件解析异常"},AUTH_INFO_ERROR:{code:10008,msg:"授权信息错误"},FILE_UPLOAD_FAIL:{code:10009,msg:"文件上传失败"},PARAMETER_ERROR:{code:10010,msg:"参数异常"},EMPTY_DATA:{code:10011,msg:"数据为空"}},ir="/api/customer-service/customer/v1/CustomerService/TestLineLatency",ar="/api/customer-service/customer/v1/CustomerService/ListLines",cr="/pub/logo.png",v={api:"",download:"",ws:""};let le=null;function lr(e){const t=`${e.replace(/\/$/,"")}${ir}`;return T.get(t,{timeout:1e4}).then(n=>n.data?.code!==200?Promise.reject(new Error("TestLineLatency failed")):e)}function ur(e){const t=`${e.replace(/\/$/,"")}${cr}`;return T.get(t,{timeout:1e4}).then(()=>e).catch(()=>Promise.reject(new Error("Download latency test failed")))}function fr(e){return e?.length?Promise.any(e.map(t=>lr(t))):Promise.reject(new Error("No urls to test"))}function dr(e){return e?.length?Promise.any(e.map(t=>ur(t))):Promise.reject(new Error("No download urls to test"))}async function xe(e){if(v.api&&v.download)return;if(le)return le;const t="http://dev-joytalk-api.halaladmin.vip",n="http://dev-joytalk-img.halaladmin.vip";le=(async()=>{const r=await T.get(`${t.replace(/\/$/,"")}${ar}`,{headers:{Authorization:`Bearer ${e}`},timeout:15e3});if(r.data?.code!==200||!r.data?.data)throw new Error(r.data?.message||"ListLines failed or empty data");const s=(r.data.data.api??[]).map(l=>l.url).filter(Boolean),o=(r.data.data.download??[]).map(l=>l.url).filter(Boolean),i=t,c=n,[d,u]=await Promise.all([s.length?fr(s).catch(()=>i):Promise.resolve(i),o.length?dr(o).catch(()=>i):Promise.resolve(c)]);v.api=d,v.download=u,v.ws=d.replace(/http/g,"ws")})(),await le}const W=T.create({timeout:6e5});W.interceptors.request.use(async e=>{const t=localStorage.getItem(pe);return t?(e.headers.Authorization=`Bearer ${t}`,await xe(t),e.baseURL=v.api,e):Promise.reject(b.UNINITIALIZED)},e=>Promise.reject(e));W.interceptors.response.use(e=>e.data?.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));function Ee(){return v.download}function hr(){return v.ws}const pr=e=>W.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),mr=async e=>{const t=await Ee();return T.post(`${t}`,e,{headers:{"Content-Type":"multipart/form-data"}})},Er=e=>W.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),Sr=e=>W.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),Tr=()=>W.get("/api/open-auth/user/v1/UserService/GetUserInfo"),wr=e=>W.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e);class yr{events=new Map;on(t,n){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n)}off(t,n){const r=this.events.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(t,n){const r=this.events.get(t);r&&r.forEach(s=>{try{s(n)}catch(o){console.error(`事件回调执行错误 [${t}]:`,o)}})}removeAllListeners(t){t?this.events.delete(t):this.events.clear()}once(t,n){const r=s=>{n(s),this.off(t,r)};this.on(t,r)}}async function Rr(e){return await xe(e),`${await hr()}/api/ws?Authorization=${e}`}function br(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function Ar(e){return typeof e=="object"&&e!==null&&"data"in e&&"msgType"in e&&"toUid"in e&&"chatType"in e&&"code"in e}function st(e){const t=Ee()+"/";return e.contentType!==H.TEXT&&(e.content=JSON.parse(e.content),e.content?.fileUrl?.startsWith("http")||(e.content.fileUrl=t+e.content.fileUrl),e.content?.thumbnailUrl?.startsWith("http")||(e.content.thumbnailUrl=t+e.content.thumbnailUrl)),e.replyType&&e.replyType!==H.TEXT&&typeof e.replyContent=="string"&&(e.replyContent=JSON.parse(e.replyContent),e.replyContent?.fileUrl?.startsWith("http")||(e.replyContent.fileUrl=t+e.replyContent.fileUrl),e.replyContent?.thumbnailUrl?.startsWith("http")||(e.replyContent.thumbnailUrl=t+e.replyContent.thumbnailUrl)),e}class K extends yr{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,responseTimeout:1e4};ws=null;status=N.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;consultationTypeId="";sessionData=null;userInfo=null;static instance=null;matchStatus=O.UNMATCHED;constructor(){if(super(),K.instance)return K.instance;K.instance=this}async init(t){if(!t.token)return localStorage.removeItem(pe),Promise.reject(b.PARAMETER_ERROR);xe(t.token),this.config=Object.assign(this.config,t),localStorage.setItem(pe,this.config.token)}connect(t){return this.consultationTypeId=t,new Promise(async(n,r)=>{if(!this.config.token)return r(b.UNINITIALIZED);if(this.status===N.CONNECTED)return n();if(this.status!==N.CONNECTING){this.setStatus(N.CONNECTING);try{const s=await Rr(this.config.token);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(N.CONNECTED),this.emit(R.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){throw console.error("解析消息失败:",i),b.DATA_PARSING_ERROR}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(N.ERROR),this.emit(R.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(N.DISCONNECTED),this.emit(R.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(N.ERROR),this.emit(R.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.matchStatus=O.UNMATCHED,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(N.DISCONNECTED)}async sendMessage(t,n,r=B.SEND){const s={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status!==N.CONNECTED||!this.ws)if(this.ws&&this.status===N.DISCONNECTED){console.log("连接断开,尝试重新连接");try{await this.connect(this.consultationTypeId)}catch(o){throw console.error("重连失败:",o),b.DISCONNECTED}}else throw console.error(b.DISCONNECTED),b.DISCONNECTED;try{if(!this.ws)throw b.DISCONNECTED;return r===B.SEND?new Promise((o,i)=>{const c=br();s.ext=c;const d=setTimeout(()=>{this.off(c,u),i(b.MESSAGE_SEND_FAIL)},this.config.responseTimeout),u=l=>{clearTimeout(d),o({messageId:l,data:t})};this.once(c,u),this.ws.send(JSON.stringify(s))}):(this.ws.send(JSON.stringify(s)),{data:t})}catch(o){throw console.error("发送消息失败:",o),b.MESSAGE_SEND_FAIL}}async checkMatchStatus(){if(this.matchStatus===O.UNBIND&&(await this.sendMessage(this.consultationTypeId,void 0,B.INBOUND),await new Promise((t,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(b.MESSAGE_SEND_FAIL)},this.config.responseTimeout);this.once(R.MESSAGE,s=>{s.code===g.REMATCH&&(clearTimeout(r),t(!0))})})),this.matchStatus!==O.MATCHED)throw console.error(b.NO_CUSTOMER_SERVICE),b.NO_CUSTOMER_SERVICE}async sendText(t){return await this.checkMatchStatus(),this.sendMessage(t,H.TEXT)}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{await this.checkMatchStatus();const[s,o]=await Promise.all([this.handleUploadFile(t),n?this.handleUploadFile(n):Promise.resolve(void 0)]),i={fileName:t.name,fileUrl:s,thumbnailUrl:o,fileSize:t.size},{messageId:c}=await this.sendMessage(JSON.stringify(i),r),d=Ee();return{messageId:c,content:{fileName:t.name,fileUrl:`${d}/${s}`,thumbnailUrl:o?`${d}/${o}`:void 0,fileSize:t.size}}}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===N.CONNECTED}handleMessage(t){if(t==="ping"){this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.sendHeartbeat();return}if(t=JSON.parse(t),!!Ar(t))try{const n=t.data?JSON.parse(t.data):t.data;switch(t.data=n,t.code){case g.CONNECT_SUCCESS:if(this.matchStatus===O.MATCHED||this.matchStatus===O.MATCHING)return;this.matchStatus=O.MATCHING,this.sendMessage(this.consultationTypeId,void 0,B.INBOUND);break;case g.MATCH_INFO:case g.MATCH_SUCCESS:if(this.matchStatus===O.MATCHED)return;this.sessionData=t.data,this.matchStatus===O.UNBIND?(this.matchStatus=O.MATCHED,this.emit(R.MESSAGE,{...t,code:g.REMATCH})):(this.matchStatus=O.MATCHED,this.getFaqList(),this.emit(R.MESSAGE,t));break;case g.TRANSFER_USER_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;const r=t.data;this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,sessionId:r.sessionId},this.emit(R.MESSAGE,t);break;case g.SEND_SUCCESS:case g.EDIT:case g.REPLY_SUCCESS:const s=t.data;if(s.sessionId!==this.sessionData?.sessionId)return;st(s),this.emit(R.MESSAGE,t);break;case g.SEND_CALLBACK:const o=t.ext,c=t.data.messageId;this.emit(o,c);break;case g.UNBIND_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;this.matchStatus=O.UNBIND,this.sessionData=null,this.emit(R.MESSAGE,t);break;default:this.emit(R.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}setStatus(t){this.status!==t&&(this.status=t,this.emit(R.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(N.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.consultationTypeId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==N.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.responseTimeout&&(this.emit(R.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.responseTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){if(this.matchStatus!==O.MATCHED)return Promise.reject(b.NO_CUSTOMER_SERVICE);const r=await wr({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>st(o));return{hasMore:r.data.hasMore,list:s}}async getConsultationList(t){return(await Er({entranceId:t})).data}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await pr({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:u}=o.data,l=new FormData;l.append("key",u),l.append("AccessKeyId",i),l.append("signature",c),l.append("policy",d),l.append("file",t);const p=await mr(l);p.status===204?n(`${u}`):r(p.data)})}getVideoThumbnail=t=>new Promise((n,r)=>{const s=document.createElement("video"),o=document.createElement("canvas"),i=o.getContext("2d");if(!i){r(new Error("无法创建 canvas 上下文"));return}const c=URL.createObjectURL(t);s.preload="metadata",s.src=c,s.muted=!0,s.playsInline=!0,s.addEventListener("loadeddata",()=>{o.width=s.videoWidth,o.height=s.videoHeight,s.currentTime=0}),s.addEventListener("seeked",()=>{try{i.drawImage(s,0,0,o.width,o.height),o.toBlob(d=>{if(URL.revokeObjectURL(c),s.remove(),!d){r(b.FILE_PARSING_ERROR);return}const u=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",l=new File([d],u,{type:"image/jpeg",lastModified:Date.now()});n(l)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(b.FILE_PARSING_ERROR)}),s.load()});async getFaqList(){if(this.matchStatus!==O.MATCHED)return Promise.reject(b.NO_CUSTOMER_SERVICE);const t=await Sr({id:this.sessionData?.cid});if(!t.data?.topic?.length)return;const n={guideText:t.data.guideText,list:t.data.topic.map(r=>({...r,question:r.question}))};setTimeout(()=>{const r={code:g.SEND_SUCCESS,data:{content:n,contentType:H.FAQ,sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:B.SEND},msgType:B.SEND,chatType:H.FAQ};this.emit(R.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:g.SEND_SUCCESS,data:{sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:B.SEND,contentType:H.FAQ,content:{}},msgType:B.SEND,chatType:H.FAQ};if(t.isMulti)n.data.content={list:t.item},this.emit(R.MESSAGE,n);else{const r=t.item?.[0]||t,s=Ee();r.imageUrl=r.imageUrl?.map(o=>o?.startsWith("http")?o:`${s}/${o}`),n.data.content={answer:r},this.emit(R.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await Tr();return this.userInfo=t.data,this.userInfo}}exports.ChatType=H;exports.ConnectionStatus=N;exports.EventType=R;exports.JoyTalk=K;exports.MatchStatus=O;exports.MessageCode=g;exports.MessageType=B;exports.SendUserType=me;exports.TOKEN_KEY=pe;exports.default=K;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function ot(e,t){return function(){return e.apply(t,arguments)}}const{toString:Dt}=Object.prototype,{getPrototypeOf:De}=Object,{iterator:Ee,toStringTag:it}=Symbol,Se=(e=>t=>{const n=Dt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>Se(t)===e),Te=e=>t=>typeof t===e,{isArray:Q}=Array,Y=Te("undefined");function ne(e){return e!==null&&!Y(e)&&e.constructor!==null&&!Y(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const at=P("ArrayBuffer");function It(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&at(e.buffer),t}const Lt=Te("string"),_=Te("function"),ct=Te("number"),re=e=>e!==null&&typeof e=="object",Ft=e=>e===!0||e===!1,ue=e=>{if(Se(e)!=="object")return!1;const t=De(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(it in e)&&!(Ee in e)},Pt=e=>{if(!re(e)||ne(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xt=P("Date"),Bt=P("File"),kt=P("Blob"),Ht=P("FileList"),jt=e=>re(e)&&_(e.pipe),vt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=Se(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},Mt=P("URLSearchParams"),[qt,$t,Gt,zt]=["ReadableStream","Request","Response","Headers"].map(P),Jt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function se(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Q(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(ne(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function lt(e,t){if(ne(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const G=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ut=e=>!Y(e)&&e!==G;function Ce(){const{caseless:e,skipUndefined:t}=ut(this)&&this||{},n={},r=(s,o)=>{const i=e&&lt(n,o)||o;ue(n[i])&&ue(s)?n[i]=Ce(n[i],s):ue(s)?n[i]=Ce({},s):Q(s)?n[i]=s.slice():(!t||!Y(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&se(arguments[s],r);return n}const Wt=(e,t,n,{allOwnKeys:r}={})=>(se(t,(s,o)=>{n&&_(s)?e[o]=ot(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&De(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(Q(e))return e;let t=e.length;if(!ct(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&De(Uint8Array)),en=(e,t)=>{const r=(e&&e[Ee]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},tn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nn=P("HTMLFormElement"),rn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Me=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),sn=P("RegExp"),ft=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};se(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},on=e=>{ft(e,(t,n)=>{if(_(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(_(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},an=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Q(e)?r(e):r(String(e).split(t)),n},cn=()=>{},ln=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function un(e){return!!(e&&_(e.append)&&e[it]==="FormData"&&e[Ee])}const fn=e=>{const t=new Array(10),n=(r,s)=>{if(re(r)){if(t.indexOf(r)>=0)return;if(ne(r))return r;if(!("toJSON"in r)){t[s]=r;const o=Q(r)?[]:{};return se(r,(i,c)=>{const d=n(i,s+1);!Y(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},dn=P("AsyncFunction"),hn=e=>e&&(re(e)||_(e))&&_(e.then)&&_(e.catch),dt=((e,t)=>e?setImmediate:t?((n,r)=>(G.addEventListener("message",({source:s,data:o})=>{s===G&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),G.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",_(G.postMessage)),pn=typeof queueMicrotask<"u"?queueMicrotask.bind(G):typeof process<"u"&&process.nextTick||dt,mn=e=>e!=null&&_(e[Ee]),a={isArray:Q,isArrayBuffer:at,isBuffer:ne,isFormData:vt,isArrayBufferView:It,isString:Lt,isNumber:ct,isBoolean:Ft,isObject:re,isPlainObject:ue,isEmptyObject:Pt,isReadableStream:qt,isRequest:$t,isResponse:Gt,isHeaders:zt,isUndefined:Y,isDate:xt,isFile:Bt,isBlob:kt,isRegExp:sn,isFunction:_,isStream:jt,isURLSearchParams:Mt,isTypedArray:Zt,isFileList:Ht,forEach:se,merge:Ce,extend:Wt,trim:Jt,stripBOM:Vt,inherits:Kt,toFlatObject:Xt,kindOf:Se,kindOfTest:P,endsWith:Yt,toArray:Qt,forEachEntry:en,matchAll:tn,isHTMLForm:nn,hasOwnProperty:Me,hasOwnProp:Me,reduceDescriptors:ft,freezeMethods:on,toObjectSet:an,toCamelCase:rn,noop:cn,toFiniteNumber:ln,findKey:lt,global:G,isContextDefined:ut,isSpecCompliantForm:un,toJSONObject:fn,isAsyncFn:dn,isThenable:hn,setImmediate:dt,asap:pn,isIterable:mn};function E(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(E,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const ht=E.prototype,pt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{pt[e]={value:e}});Object.defineProperties(E,pt);Object.defineProperty(ht,"isAxiosError",{value:!0});E.from=(e,t,n,r,s,o)=>{const i=Object.create(ht);a.toFlatObject(e,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return E.call(i,c,d,n,r,s),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",o&&Object.assign(i,o),i};const En=null;function ge(e){return a.isPlainObject(e)||a.isArray(e)}function mt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function qe(e,t,n){return e?e.concat(t).map(function(s,o){return s=mt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Sn(e){return a.isArray(e)&&!e.some(ge)}const Tn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function we(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!a.isUndefined(p[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new E("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,p){let w=f;if(f&&!p&&typeof f=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Sn(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(w=a.toArray(f)))return m=mt(m),w.forEach(function(R,U){!(a.isUndefined(R)||R===null)&&t.append(i===!0?qe([m],U,o):i===null?m:m+"[]",u(R))}),!1}return ge(f)?!0:(t.append(qe(p,m,o),u(f)),!1)}const h=[],S=Object.assign(Tn,{defaultVisitor:l,convertValue:u,isVisitable:ge});function b(f,m){if(!a.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));h.push(f),a.forEach(f,function(w,I){(!(a.isUndefined(w)||w===null)&&s.call(t,w,a.isString(I)?I.trim():I,m,S))===!0&&b(w,m?m.concat(I):[I])}),h.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return b(e),t}function $e(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ie(e,t){this._pairs=[],e&&we(e,this,t)}const Et=Ie.prototype;Et.append=function(t,n){this._pairs.push([t,n])};Et.toString=function(t){const n=t?function(r){return t.call(this,r,$e)}:$e;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function wn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function St(e,t,n){if(!t)return e;const r=n&&n.encode||wn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Ie(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ge{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Rn=typeof URLSearchParams<"u"?URLSearchParams:Ie,yn=typeof FormData<"u"?FormData:null,An=typeof Blob<"u"?Blob:null,bn={isBrowser:!0,classes:{URLSearchParams:Rn,FormData:yn,Blob:An},protocols:["http","https","file","blob","url","data"]},Le=typeof window<"u"&&typeof document<"u",Ue=typeof navigator=="object"&&navigator||void 0,Nn=Le&&(!Ue||["ReactNative","NativeScript","NS"].indexOf(Ue.product)<0),On=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cn=Le&&window.location.href||"http://localhost",gn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Le,hasStandardBrowserEnv:Nn,hasStandardBrowserWebWorkerEnv:On,navigator:Ue,origin:Cn},Symbol.toStringTag,{value:"Module"})),C={...gn,...bn};function Un(e,t){return we(e,new C.classes.URLSearchParams,{visitor:function(n,r,s,o){return C.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function _n(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Dn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function wt(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Dn(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(_n(r),s,n,0)}),n}return null}function In(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:Tt,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(wt(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Un(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return we(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),In(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?E.from(c,E.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{oe.headers[e]={}});const Ln=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Fn=e=>{const t={};let n,r,s;return e&&e.split(`
2
+ `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Ln[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ze=Symbol("internals");function te(e){return e&&String(e).trim().toLowerCase()}function fe(e){return e===!1||e==null?e:a.isArray(e)?e.map(fe):String(e)}function Pn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const xn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function be(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function Bn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function kn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let D=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,u){const l=te(d);if(!l)throw new Error("header name must be a non-empty string");const h=a.findKey(s,l);(!h||s[h]===void 0||u===!0||u===void 0&&s[h]!==!1)&&(s[h||d]=fe(c))}const i=(c,d)=>a.forEach(c,(u,l)=>o(u,l,d));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!xn(t))i(Fn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let c={},d,u;for(const l of t){if(!a.isArray(l))throw TypeError("Object iterator must return a key-value pair");c[u=l[0]]=(d=c[u])?a.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}i(c,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=te(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Pn(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=te(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||be(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=te(i),i){const c=a.findKey(r,i);c&&(!n||be(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||be(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=fe(s),delete n[o];return}const c=t?Bn(o):String(o).trim();c!==o&&delete n[o],n[c]=fe(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ze]=this[ze]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=te(i);r[c]||(kn(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(D.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(D);function Ne(e,t){const n=this||oe,r=t||n,s=D.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Rt(e){return!!(e&&e.__CANCEL__)}function Z(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(Z,E,{__CANCEL__:!0});function yt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new E("Request failed with status code "+n.status,[E.ERR_BAD_REQUEST,E.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Hn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=r[o];i||(i=u),n[s]=d,r[s]=u;let h=o,S=0;for(;h!==s;)S+=n[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const b=l&&u-l;return b?Math.round(S*1e3/b):void 0}}function vn(e,t){let n=0,r=1e3/t,s,o;const i=(u,l=Date.now())=>{n=l,s=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{const l=Date.now(),h=l-n;h>=r?i(u,l):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-h)))},()=>s&&i(s)]}const he=(e,t,n=3)=>{let r=0;const s=jn(50,250);return vn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),l=i<=c;r=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},n)},Je=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},We=e=>(...t)=>a.asap(()=>e(...t)),Mn=C.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,C.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,qn=C.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function $n(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Gn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function At(e,t,n){let r=!$n(t);return e&&(r||n==!1)?Gn(e,t):t}const Ve=e=>e instanceof D?{...e}:e;function W(e,t){t=t||{};const n={};function r(u,l,h,S){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:S},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,h,S){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,h,S)}else return r(u,l,h,S)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,h){if(h in t)return r(u,l);if(h in e)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,h)=>s(Ve(u),Ve(l),h,!0)};return a.forEach(Object.keys({...e,...t}),function(l){const h=d[l]||s,S=h(e[l],t[l],l);a.isUndefined(S)&&h!==c||(n[l]=S)}),n}const bt=e=>{const t=W({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=D.from(i),t.url=St(At(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,h])=>{u.includes(l.toLowerCase())&&i.set(l,h)})}}if(C.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Mn(t.url))){const d=s&&o&&qn.read(o);d&&i.set(s,d)}return t},zn=typeof XMLHttpRequest<"u",Jn=zn&&function(e){return new Promise(function(n,r){const s=bt(e);let o=s.data;const i=D.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,l,h,S,b,f;function m(){b&&b(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const R=D.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),F={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:R,config:e,request:p};yt(function(L){n(L),m()},function(L){r(L),m()},F),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new E("Request aborted",E.ECONNABORTED,e,p)),p=null)},p.onerror=function(U){const F=U&&U.message?U.message:"Network Error",q=new E(F,E.ERR_NETWORK,e,p);q.event=U||null,r(q),p=null},p.ontimeout=function(){let U=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const F=s.transitional||Tt;s.timeoutErrorMessage&&(U=s.timeoutErrorMessage),r(new E(U,F.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(U,F){p.setRequestHeader(F,U)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),u&&([S,f]=he(u,!0),p.addEventListener("progress",S)),d&&p.upload&&([h,b]=he(d),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",b)),(s.cancelToken||s.signal)&&(l=R=>{p&&(r(!R||R.type?new Z(null,e,p):R),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const I=Hn(s.url);if(I&&C.protocols.indexOf(I)===-1){r(new E("Unsupported protocol "+I+":",E.ERR_BAD_REQUEST,e));return}p.send(o||null)})},Wn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const l=u instanceof Error?u:this.reason;r.abort(l instanceof E?l:new Z(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,o(new E(`timeout ${t} of ms exceeded`,E.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},Vn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},Kn=async function*(e,t){for await(const n of Xn(e))yield*Vn(n,t)},Xn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Ke=(e,t,n,r)=>{const s=Kn(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){c(),d.close();return}let h=l.byteLength;if(n){let S=o+=h;n(S)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},Xe=64*1024,{isFunction:le}=a,Yn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:Ye,TextEncoder:Qe}=a.global,Ze=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Qn=e=>{e=a.merge.call({skipUndefined:!0},Yn,e);const{fetch:t,Request:n,Response:r}=e,s=t?le(t):typeof fetch=="function",o=le(n),i=le(r);if(!s)return!1;const c=s&&le(Ye),d=s&&(typeof Qe=="function"?(f=>m=>f.encode(m))(new Qe):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=o&&c&&Ze(()=>{let f=!1;const m=new n(C.origin,{body:new Ye,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),l=i&&c&&Ze(()=>a.isReadableStream(new r("").body)),h={stream:l&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(m,p)=>{let w=m&&m[f];if(w)return w.call(m);throw new E(`Response type '${f}' is not supported`,E.ERR_NOT_SUPPORT,p)})});const S=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new n(C.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},b=async(f,m)=>{const p=a.toFiniteNumber(f.getContentLength());return p??S(m)};return async f=>{let{url:m,method:p,data:w,signal:I,cancelToken:R,timeout:U,onDownloadProgress:F,onUploadProgress:q,responseType:L,headers:ye,withCredentials:ie="same-origin",fetchOptions:xe}=bt(f),Be=t||fetch;L=L?(L+"").toLowerCase():"text";let ae=Wn([I,R&&R.toAbortSignal()],U),ee=null;const $=ae&&ae.unsubscribe&&(()=>{ae.unsubscribe()});let ke;try{if(q&&u&&p!=="get"&&p!=="head"&&(ke=await b(ye,w))!==0){let v=new n(m,{method:"POST",body:w,duplex:"half"}),K;if(a.isFormData(w)&&(K=v.headers.get("content-type"))&&ye.setContentType(K),v.body){const[Ae,ce]=Je(ke,he(We(q)));w=Ke(v.body,Xe,Ae,ce)}}a.isString(ie)||(ie=ie?"include":"omit");const x=o&&"credentials"in n.prototype,He={...xe,signal:ae,method:p.toUpperCase(),headers:ye.normalize().toJSON(),body:w,duplex:"half",credentials:x?ie:void 0};ee=o&&new n(m,He);let j=await(o?Be(ee,xe):Be(m,He));const je=l&&(L==="stream"||L==="response");if(l&&(F||je&&$)){const v={};["status","statusText","headers"].forEach(ve=>{v[ve]=j[ve]});const K=a.toFiniteNumber(j.headers.get("content-length")),[Ae,ce]=F&&Je(K,he(We(F),!0))||[];j=new r(Ke(j.body,Xe,Ae,()=>{ce&&ce(),$&&$()}),v)}L=L||"text";let _t=await h[a.findKey(h,L)||"text"](j,f);return!je&&$&&$(),await new Promise((v,K)=>{yt(v,K,{data:_t,headers:D.from(j.headers),status:j.status,statusText:j.statusText,config:f,request:ee})})}catch(x){throw $&&$(),x&&x.name==="TypeError"&&/Load failed|fetch/i.test(x.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,ee),{cause:x.cause||x}):E.from(x,x&&x.code,f,ee)}}},Zn=new Map,Nt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,c=i,d,u,l=Zn;for(;c--;)d=o[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:Qn(t)),l=u;return u};Nt();const Fe={http:En,xhr:Jn,fetch:{get:Nt}};a.forEach(Fe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const et=e=>`- ${e}`,er=e=>a.isFunction(e)||e===null||e===!1;function tr(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let c;if(s=r,!er(r)&&(s=Fe[(c=String(r)).toLowerCase()],s===void 0))throw new E(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
4
+ `+i.map(et).join(`
5
+ `):" "+et(i[0]):"as no adapter specified";throw new E("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Ot={getAdapter:tr,adapters:Fe};function Oe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Z(null,e)}function tt(e){return Oe(e),e.headers=D.from(e.headers),e.data=Ne.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ot.getAdapter(e.adapter||oe.adapter,e)(e).then(function(r){return Oe(e),r.data=Ne.call(e,e.transformResponse,r),r.headers=D.from(r.headers),r},function(r){return Rt(r)||(Oe(e),r&&r.response&&(r.response.data=Ne.call(e,e.transformResponse,r.response),r.response.headers=D.from(r.response.headers))),Promise.reject(r)})}const Ct="1.13.2",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const nt={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Ct+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new E(s(i," has been removed"+(n?" in "+n:"")),E.ERR_DEPRECATED);return n&&!nt[i]&&(nt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};Re.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function nr(e,t,n){if(typeof e!="object")throw new E("options must be an object",E.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new E("option "+o+" must be "+d,E.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new E("Unknown option "+o,E.ERR_BAD_OPTION)}}const de={assertOptions:nr,validators:Re},B=de.validators;let z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ge,response:new Ge}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
+ `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=W(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&de.assertOptions(r,{silentJSONParsing:B.transitional(B.boolean),forcedJSONParsing:B.transitional(B.boolean),clarifyTimeoutError:B.transitional(B.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:de.assertOptions(s,{encode:B.function,serialize:B.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),de.assertOptions(n,{baseUrl:B.spelling("baseURL"),withXsrfToken:B.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=D.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,h=0,S;if(!d){const f=[tt.bind(this),void 0];for(f.unshift(...c),f.push(...u),S=f.length,l=Promise.resolve(n);h<S;)l=l.then(f[h++],f[h++]);return l}S=c.length;let b=n;for(;h<S;){const f=c[h++],m=c[h++];try{b=f(b)}catch(p){m.call(this,p);break}}try{l=tt.call(this,b)}catch(f){return Promise.reject(f)}for(h=0,S=u.length;h<S;)l=l.then(u[h++],u[h++]);return l}getUri(t){t=W(this.defaults,t);const n=At(t.baseURL,t.url,t.allowAbsoluteUrls);return St(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){z.prototype[t]=function(n,r){return this.request(W(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(W(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}z.prototype[t]=n(),z.prototype[t+"Form"]=n(!0)});let rr=class gt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Z(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new gt(function(s){t=s}),cancel:t}}};function sr(e){return function(n){return e.apply(null,n)}}function or(e){return a.isObject(e)&&e.isAxiosError===!0}const _e={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(_e).forEach(([e,t])=>{_e[t]=e});function Ut(e){const t=new z(e),n=ot(z.prototype.request,t);return a.extend(n,z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Ut(W(e,s))},n}const T=Ut(oe);T.Axios=z;T.CanceledError=Z;T.CancelToken=rr;T.isCancel=Rt;T.VERSION=Ct;T.toFormData=we;T.AxiosError=E;T.Cancel=T.CanceledError;T.all=function(t){return Promise.all(t)};T.spread=sr;T.isAxiosError=or;T.mergeConfig=W;T.AxiosHeaders=D;T.formToJSON=e=>wt(a.isHTMLForm(e)?new FormData(e):e);T.getAdapter=Ot.getAdapter;T.HttpStatusCode=_e;T.default=T;const{Axios:Cr,AxiosError:gr,CanceledError:Ur,isCancel:_r,CancelToken:Dr,VERSION:Ir,all:Lr,Cancel:Fr,isAxiosError:Pr,spread:xr,toFormData:Br,AxiosHeaders:kr,HttpStatusCode:Hr,formToJSON:jr,getAdapter:vr,mergeConfig:Mr}=T,A={UNINITIALIZED:{code:10001,msg:"未初始化"},DISCONNECTED:{code:10002,msg:"未连接"},NO_CUSTOMER_SERVICE:{code:10003,msg:"未分配客服"},MESSAGE_SEND_FAIL:{code:10004,msg:"消息发送失败"},DATA_PARSING_ERROR:{code:10005,msg:"数据解析异常"},FILE_NOT_EXIST:{code:10006,msg:"文件不存在"},FILE_PARSING_ERROR:{code:10007,msg:"文件解析异常"},AUTH_INFO_ERROR:{code:10008,msg:"授权信息错误"},FILE_UPLOAD_FAIL:{code:10009,msg:"文件上传失败"},PARAMETER_ERROR:{code:10010,msg:"参数异常"},EMPTY_DATA:{code:10011,msg:"数据为空"}},ir="/api/customer-service/customer/v1/CustomerService/TestLineLatency",ar="/api/customer-service/customer/v1/CustomerService/ListLines",cr="/pub/logo.png",rt={development:{BASE_API_URL:"http://dev-joytalk-api.halaladmin.vip",OBS_URL:"http://dev-joytalk-img.halaladmin.vip"},prodtest:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"},production:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"}},M={api:"",download:"",ws:""};let X=null;function lr(e){const t=`${e.replace(/\/$/,"")}${ir}`;return T.get(t,{timeout:1e4}).then(n=>n.data?.code!==200?Promise.reject(new Error("TestLineLatency failed")):e)}function ur(e){const t=`${e.replace(/\/$/,"")}${cr}`;return T.get(t,{timeout:1e4}).then(()=>e).catch(()=>Promise.reject(new Error("Download latency test failed")))}function fr(e){return e?.length?Promise.any(e.map(t=>lr(t))):Promise.reject(new Error("No urls to test"))}function dr(e){return e?.length?Promise.any(e.map(t=>ur(t))):Promise.reject(new Error("No download urls to test"))}async function Pe(e,t){if(M.api&&M.download)return;if(X)return X;const n=rt[t].BASE_API_URL||"",r=rt[t].OBS_URL||"";n||(X=Promise.reject(new Error("环境配置错误")),await X),X=(async()=>{const s=await T.get(`${n.replace(/\/$/,"")}${ar}`,{headers:{Authorization:`Bearer ${e}`},timeout:15e3});if(s.data?.code!==200||!s.data?.data)throw new Error(s.data?.message||"ListLines failed or empty data");const o=(s.data.data.api??[]).map(h=>h.url).filter(Boolean),i=(s.data.data.download??[]).map(h=>h.url).filter(Boolean),c=n,d=r,[u,l]=await Promise.all([o.length?fr(o).catch(()=>c):Promise.resolve(c),i.length?dr(i).catch(()=>c):Promise.resolve(d)]);M.api=u,M.download=l,M.ws=u.replace(/http/g,"ws")})(),await X}const V=T.create({timeout:6e5});V.interceptors.request.use(async e=>{const t=new J,n=t.config.token;return n?(e.headers.Authorization=`Bearer ${n}`,await Pe(n,t.config.env),e.baseURL=M.api,e):Promise.reject(A.UNINITIALIZED)},e=>Promise.reject(e));V.interceptors.response.use(e=>e.data?.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));function pe(){return M.download}function hr(){return M.ws}const pr=e=>V.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),mr=async e=>{const t=await pe();return T.post(`${t}`,e,{headers:{"Content-Type":"multipart/form-data"}})},Er=e=>V.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),Sr=e=>V.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),Tr=()=>V.get("/api/open-auth/user/v1/UserService/GetUserInfo"),wr=e=>V.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e);var k=(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))(k||{}),H=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(H||{}),g=(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.REMATCH=60001]="REMATCH",e))(g||{}),me=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(me||{}),y=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(y||{}),N=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(N||{}),O=(e=>(e.UNMATCHED="1",e.MATCHING="2",e.MATCHED="3",e.UNBIND="4",e))(O||{});class Rr{events=new Map;on(t,n){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n)}off(t,n){const r=this.events.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(t,n){const r=this.events.get(t);r&&r.forEach(s=>{try{s(n)}catch(o){console.error(`事件回调执行错误 [${t}]:`,o)}})}removeAllListeners(t){t?this.events.delete(t):this.events.clear()}once(t,n){const r=s=>{n(s),this.off(t,r)};this.on(t,r)}}async function yr(e,t){return await Pe(e,t),`${await hr()}/api/ws?Authorization=${e}`}function Ar(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function br(e){return typeof e=="object"&&e!==null&&"data"in e&&"msgType"in e&&"toUid"in e&&"chatType"in e&&"code"in e}function st(e){const t=pe()+"/";return e.contentType!==H.TEXT&&(e.content=JSON.parse(e.content),e.content?.fileUrl?.startsWith("http")||(e.content.fileUrl=t+e.content.fileUrl),e.content?.thumbnailUrl?.startsWith("http")||(e.content.thumbnailUrl=t+e.content.thumbnailUrl)),e.replyType&&e.replyType!==H.TEXT&&typeof e.replyContent=="string"&&(e.replyContent=JSON.parse(e.replyContent),e.replyContent?.fileUrl?.startsWith("http")||(e.replyContent.fileUrl=t+e.replyContent.fileUrl),e.replyContent?.thumbnailUrl?.startsWith("http")||(e.replyContent.thumbnailUrl=t+e.replyContent.thumbnailUrl)),e}class J extends Rr{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,responseTimeout:1e4,env:"production"};ws=null;status=N.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;consultationTypeId="";sessionData=null;userInfo=null;static instance=null;matchStatus=O.UNMATCHED;constructor(){if(super(),J.instance)return J.instance;J.instance=this}async init(t){if(!t.token)return Promise.reject(A.PARAMETER_ERROR);Pe(t.token,t.env||"production"),this.config=Object.assign(this.config,t)}connect(t){return this.consultationTypeId=t,new Promise(async(n,r)=>{if(!this.config.token)return r(A.UNINITIALIZED);if(this.status===N.CONNECTED)return n();if(this.status!==N.CONNECTING){this.setStatus(N.CONNECTING);try{const s=await yr(this.config.token,this.config.env);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(N.CONNECTED),this.emit(y.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){throw console.error("解析消息失败:",i),A.DATA_PARSING_ERROR}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(N.ERROR),this.emit(y.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(N.DISCONNECTED),this.emit(y.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(N.ERROR),this.emit(y.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.matchStatus=O.UNMATCHED,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(N.DISCONNECTED)}async sendMessage(t,n,r=k.SEND){const s={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status!==N.CONNECTED||!this.ws)if(this.ws&&this.status===N.DISCONNECTED){console.log("连接断开,尝试重新连接");try{await this.connect(this.consultationTypeId)}catch(o){throw console.error("重连失败:",o),A.DISCONNECTED}}else throw console.error(A.DISCONNECTED),A.DISCONNECTED;try{if(!this.ws)throw A.DISCONNECTED;return r===k.SEND?new Promise((o,i)=>{const c=Ar();s.ext=c;const d=setTimeout(()=>{this.off(c,u),i(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout),u=l=>{clearTimeout(d),o({messageId:l,data:t})};this.once(c,u),this.ws.send(JSON.stringify(s))}):(this.ws.send(JSON.stringify(s)),{data:t})}catch(o){throw console.error("发送消息失败:",o),A.MESSAGE_SEND_FAIL}}async checkMatchStatus(){if(this.matchStatus===O.UNBIND&&(await this.sendMessage(this.consultationTypeId,void 0,k.INBOUND),await new Promise((t,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout);this.once(y.MESSAGE,s=>{s.code===g.REMATCH&&(clearTimeout(r),t(!0))})})),this.matchStatus!==O.MATCHED)throw console.error(A.NO_CUSTOMER_SERVICE),A.NO_CUSTOMER_SERVICE}async sendText(t){return await this.checkMatchStatus(),this.sendMessage(t,H.TEXT)}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{await this.checkMatchStatus();const[s,o]=await Promise.all([this.handleUploadFile(t),n?this.handleUploadFile(n):Promise.resolve(void 0)]),i={fileName:t.name,fileUrl:s,thumbnailUrl:o,fileSize:t.size},{messageId:c}=await this.sendMessage(JSON.stringify(i),r),d=pe();return{messageId:c,content:{fileName:t.name,fileUrl:`${d}/${s}`,thumbnailUrl:o?`${d}/${o}`:void 0,fileSize:t.size}}}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===N.CONNECTED}handleMessage(t){if(t==="ping"){this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.sendHeartbeat();return}if(t=JSON.parse(t),!!br(t))try{const n=t.data?JSON.parse(t.data):t.data;switch(t.data=n,t.code){case g.CONNECT_SUCCESS:if(this.matchStatus===O.MATCHED||this.matchStatus===O.MATCHING)return;this.matchStatus=O.MATCHING,this.sendMessage(this.consultationTypeId,void 0,k.INBOUND);break;case g.MATCH_INFO:case g.MATCH_SUCCESS:if(this.matchStatus===O.MATCHED)return;this.sessionData=t.data,this.matchStatus===O.UNBIND?(this.matchStatus=O.MATCHED,this.emit(y.MESSAGE,{...t,code:g.REMATCH})):(this.matchStatus=O.MATCHED,this.getFaqList(),this.emit(y.MESSAGE,t));break;case g.TRANSFER_USER_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;const r=t.data;this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,sessionId:r.sessionId},this.emit(y.MESSAGE,t);break;case g.SEND_SUCCESS:case g.EDIT:case g.REPLY_SUCCESS:const s=t.data;if(s.sessionId!==this.sessionData?.sessionId)return;st(s),this.emit(y.MESSAGE,t);break;case g.SEND_CALLBACK:const o=t.ext,c=t.data.messageId;this.emit(o,c);break;case g.UNBIND_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;this.matchStatus=O.UNBIND,this.sessionData=null,this.emit(y.MESSAGE,t);break;default:this.emit(y.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}setStatus(t){this.status!==t&&(this.status=t,this.emit(y.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(N.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.consultationTypeId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==N.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.responseTimeout&&(this.emit(y.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.responseTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const r=await wr({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>st(o));return{hasMore:r.data.hasMore,list:s}}async getConsultationList(t){return(await Er({entranceId:t})).data}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await pr({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:u}=o.data,l=new FormData;l.append("key",u),l.append("AccessKeyId",i),l.append("signature",c),l.append("policy",d),l.append("file",t);const h=await mr(l);h.status===204?n(`${u}`):r(h.data)})}getVideoThumbnail=t=>new Promise((n,r)=>{const s=document.createElement("video"),o=document.createElement("canvas"),i=o.getContext("2d");if(!i){r(new Error("无法创建 canvas 上下文"));return}const c=URL.createObjectURL(t);s.preload="metadata",s.src=c,s.muted=!0,s.playsInline=!0,s.addEventListener("loadeddata",()=>{o.width=s.videoWidth,o.height=s.videoHeight,s.currentTime=0}),s.addEventListener("seeked",()=>{try{i.drawImage(s,0,0,o.width,o.height),o.toBlob(d=>{if(URL.revokeObjectURL(c),s.remove(),!d){r(A.FILE_PARSING_ERROR);return}const u=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",l=new File([d],u,{type:"image/jpeg",lastModified:Date.now()});n(l)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(A.FILE_PARSING_ERROR)}),s.load()});async getFaqList(){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const t=await Sr({id:this.sessionData?.cid});if(!t.data?.topic?.length)return;const n={guideText:t.data.guideText,list:t.data.topic.map(r=>({...r,question:r.question}))};setTimeout(()=>{const r={code:g.SEND_SUCCESS,data:{content:n,contentType:H.FAQ,sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:k.SEND},msgType:k.SEND,chatType:H.FAQ};this.emit(y.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:g.SEND_SUCCESS,data:{sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:k.SEND,contentType:H.FAQ,content:{}},msgType:k.SEND,chatType:H.FAQ};if(t.isMulti)n.data.content={list:t.item},this.emit(y.MESSAGE,n);else{const r=t.item?.[0]||t,s=pe();r.imageUrl=r.imageUrl?.map(o=>o?.startsWith("http")?o:`${s}/${o}`),n.data.content={answer:r},this.emit(y.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await Tr();return this.userInfo=t.data,this.userInfo}}exports.ChatType=H;exports.ConnectionStatus=N;exports.EventType=y;exports.JoyTalk=J;exports.MatchStatus=O;exports.MessageCode=g;exports.MessageType=k;exports.SendUserType=me;exports.default=J;