joytalk 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function Ze(e,t){return function(){return e.apply(t,arguments)}}const{toString:At}=Object.prototype,{getPrototypeOf:Ce}=Object,{iterator:he,toStringTag:et}=Symbol,pe=(e=>t=>{const n=At.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),F=e=>(e=e.toLowerCase(),t=>pe(t)===e),me=e=>t=>typeof t===e,{isArray:V}=Array,W=me("undefined");function Z(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&N(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const tt=F("ArrayBuffer");function gt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&tt(e.buffer),t}const Nt=me("string"),N=me("function"),nt=me("number"),ee=e=>e!==null&&typeof e=="object",Ct=e=>e===!0||e===!1,ae=e=>{if(pe(e)!=="object")return!1;const t=Ce(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(et in e)&&!(he in e)},Ut=e=>{if(!ee(e)||Z(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},_t=F("Date"),Dt=F("File"),It=F("Blob"),Ft=F("FileList"),Lt=e=>ee(e)&&N(e.pipe),xt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||N(e.append)&&((t=pe(e))==="formdata"||t==="object"&&N(e.toString)&&e.toString()==="[object FormData]"))},Pt=F("URLSearchParams"),[kt,Bt,jt,Ht]=["ReadableStream","Request","Response","Headers"].map(F),vt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function te(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),V(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(Z(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 rt(e,t){if(Z(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 q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,st=e=>!W(e)&&e!==q;function Oe(){const{caseless:e,skipUndefined:t}=st(this)&&this||{},n={},r=(s,o)=>{const i=e&&rt(n,o)||o;ae(n[i])&&ae(s)?n[i]=Oe(n[i],s):ae(s)?n[i]=Oe({},s):V(s)?n[i]=s.slice():(!t||!W(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&te(arguments[s],r);return n}const Mt=(e,t,n,{allOwnKeys:r}={})=>(te(t,(s,o)=>{n&&N(s)?e[o]=Ze(s,n):e[o]=s},{allOwnKeys:r}),e),qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$t=(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)},Jt=(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&&Ce(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},zt=(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},Gt=e=>{if(!e)return null;if(V(e))return e;let t=e.length;if(!nt(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Wt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ce(Uint8Array)),Vt=(e,t)=>{const r=(e&&e[he]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Kt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Xt=F("HTMLFormElement"),Qt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Be=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Yt=F("RegExp"),ot=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};te(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},Zt=e=>{ot(e,(t,n)=>{if(N(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(N(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+"'")})}})},en=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return V(e)?r(e):r(String(e).split(t)),n},tn=()=>{},nn=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function rn(e){return!!(e&&N(e.append)&&e[et]==="FormData"&&e[he])}const sn=e=>{const t=new Array(10),n=(r,s)=>{if(ee(r)){if(t.indexOf(r)>=0)return;if(Z(r))return r;if(!("toJSON"in r)){t[s]=r;const o=V(r)?[]:{};return te(r,(i,c)=>{const d=n(i,s+1);!W(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},on=F("AsyncFunction"),an=e=>e&&(ee(e)||N(e))&&N(e.then)&&N(e.catch),it=((e,t)=>e?setImmediate:t?((n,r)=>(q.addEventListener("message",({source:s,data:o})=>{s===q&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),q.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",N(q.postMessage)),cn=typeof queueMicrotask<"u"?queueMicrotask.bind(q):typeof process<"u"&&process.nextTick||it,un=e=>e!=null&&N(e[he]),a={isArray:V,isArrayBuffer:tt,isBuffer:Z,isFormData:xt,isArrayBufferView:gt,isString:Nt,isNumber:nt,isBoolean:Ct,isObject:ee,isPlainObject:ae,isEmptyObject:Ut,isReadableStream:kt,isRequest:Bt,isResponse:jt,isHeaders:Ht,isUndefined:W,isDate:_t,isFile:Dt,isBlob:It,isRegExp:Yt,isFunction:N,isStream:Lt,isURLSearchParams:Pt,isTypedArray:Wt,isFileList:Ft,forEach:te,merge:Oe,extend:Mt,trim:vt,stripBOM:qt,inherits:$t,toFlatObject:Jt,kindOf:pe,kindOfTest:F,endsWith:zt,toArray:Gt,forEachEntry:Vt,matchAll:Kt,isHTMLForm:Xt,hasOwnProperty:Be,hasOwnProp:Be,reduceDescriptors:ot,freezeMethods:Zt,toObjectSet:en,toCamelCase:Qt,noop:tn,toFiniteNumber:nn,findKey:rt,global:q,isContextDefined:st,isSpecCompliantForm:rn,toJSONObject:sn,isAsyncFn:on,isThenable:an,setImmediate:it,asap:cn,isIterable:un};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 at=E.prototype,ct={};["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=>{ct[e]={value:e}});Object.defineProperties(E,ct);Object.defineProperty(at,"isAxiosError",{value:!0});E.from=(e,t,n,r,s,o)=>{const i=Object.create(at);a.toFlatObject(e,i,function(u){return u!==Error.prototype},l=>l!=="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 ln=null;function Ae(e){return a.isPlainObject(e)||a.isArray(e)}function ut(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function je(e,t,n){return e?e.concat(t).map(function(s,o){return s=ut(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function fn(e){return a.isArray(e)&&!e.some(Ae)}const dn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Ee(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||u,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 l(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 u(f,m,h){let T=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)&&fn(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(T=a.toArray(f)))return m=ut(m),T.forEach(function(b,g){!(a.isUndefined(b)||b===null)&&t.append(i===!0?je([m],g,o):i===null?m:m+"[]",l(b))}),!1}return Ae(f)?!0:(t.append(je(h,m,o),l(f)),!1)}const p=[],S=Object.assign(dn,{defaultVisitor:u,convertValue:l,isVisitable:Ae});function y(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(T,_){(!(a.isUndefined(T)||T===null)&&s.call(t,T,a.isString(_)?_.trim():_,m,S))===!0&&y(T,m?m.concat(_):[_])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}function He(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ue(e,t){this._pairs=[],e&&Ee(e,this,t)}const lt=Ue.prototype;lt.append=function(t,n){this._pairs.push([t,n])};lt.toString=function(t){const n=t?function(r){return t.call(this,r,He)}:He;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function hn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ft(e,t,n){if(!t)return e;const r=n&&n.encode||hn;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 Ue(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ve{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 dt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},pn=typeof URLSearchParams<"u"?URLSearchParams:Ue,mn=typeof FormData<"u"?FormData:null,En=typeof Blob<"u"?Blob:null,Sn={isBrowser:!0,classes:{URLSearchParams:pn,FormData:mn,Blob:En},protocols:["http","https","file","blob","url","data"]},_e=typeof window<"u"&&typeof document<"u",ge=typeof navigator=="object"&&navigator||void 0,Rn=_e&&(!ge||["ReactNative","NativeScript","NS"].indexOf(ge.product)<0),Tn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bn=_e&&window.location.href||"http://localhost",yn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:_e,hasStandardBrowserEnv:Rn,hasStandardBrowserWebWorkerEnv:Tn,navigator:ge,origin:bn},Symbol.toStringTag,{value:"Module"})),O={...yn,...Sn};function wn(e,t){return Ee(e,new O.classes.URLSearchParams,{visitor:function(n,r,s,o){return O.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function On(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function An(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 ht(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]=An(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(On(r),s,n,0)}),n}return null}function gn(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 ne={transitional:dt,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(ht(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 wn(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Ee(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),gn(t)):t}],transformResponse:[function(t){const n=this.transitional||ne.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:O.classes.FormData,Blob:O.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=>{ne.headers[e]={}});const Nn=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"]),Cn=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]&&Nn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Me=Symbol("internals");function Q(e){return e&&String(e).trim().toLowerCase()}function ce(e){return e===!1||e==null?e:a.isArray(e)?e.map(ce):String(e)}function Un(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 _n=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 Dn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function In(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 C=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,l){const u=Q(d);if(!u)throw new Error("header name must be a non-empty string");const p=a.findKey(s,u);(!p||s[p]===void 0||l===!0||l===void 0&&s[p]!==!1)&&(s[p||d]=ce(c))}const i=(c,d)=>a.forEach(c,(l,u)=>o(l,u,d));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!_n(t))i(Cn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let c={},d,l;for(const u of t){if(!a.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[l=u[0]]=(d=c[l])?a.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}i(c,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=Q(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Un(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=Q(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=Q(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]=ce(s),delete n[o];return}const c=t?Dn(o):String(o).trim();c!==o&&delete n[o],n[c]=ce(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[Me]=this[Me]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=Q(i);r[c]||(In(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};C.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(C.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(C);function ye(e,t){const n=this||ne,r=t||n,s=C.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 pt(e){return!!(e&&e.__CANCEL__)}function K(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(K,E,{__CANCEL__:!0});function mt(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 Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ln(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 l=Date.now(),u=r[o];i||(i=l),n[s]=d,r[s]=l;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),l-i<t)return;const y=u&&l-u;return y?Math.round(S*1e3/y):void 0}}function xn(e,t){let n=0,r=1e3/t,s,o;const i=(l,u=Date.now())=>{n=u,s=null,o&&(clearTimeout(o),o=null),e(...l)};return[(...l)=>{const u=Date.now(),p=u-n;p>=r?i(l,u):(s=l,o||(o=setTimeout(()=>{o=null,i(s)},r-p)))},()=>s&&i(s)]}const le=(e,t,n=3)=>{let r=0;const s=Ln(50,250);return xn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,l=s(d),u=i<=c;r=i;const p={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},n)},qe=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},$e=e=>(...t)=>a.asap(()=>e(...t)),Pn=O.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,O.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(O.origin),O.navigator&&/(msie|trident)/i.test(O.navigator.userAgent)):()=>!0,kn=O.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 Bn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Et(e,t,n){let r=!Bn(t);return e&&(r||n==!1)?jn(e,t):t}const Je=e=>e instanceof C?{...e}:e;function J(e,t){t=t||{};const n={};function r(l,u,p,S){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:S},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(l,u,p,S){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l,p,S)}else return r(l,u,p,S)}function o(l,u){if(!a.isUndefined(u))return r(void 0,u)}function i(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l)}else return r(void 0,u)}function c(l,u,p){if(p in t)return r(l,u);if(p in e)return r(void 0,l)}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:(l,u,p)=>s(Je(l),Je(u),p,!0)};return a.forEach(Object.keys({...e,...t}),function(u){const p=d[u]||s,S=p(e[u],t[u],u);a.isUndefined(S)&&p!==c||(n[u]=S)}),n}const St=e=>{const t=J({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=C.from(i),t.url=ft(Et(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(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),l=["content-type","content-length"];Object.entries(d).forEach(([u,p])=>{l.includes(u.toLowerCase())&&i.set(u,p)})}}if(O.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Pn(t.url))){const d=s&&o&&kn.read(o);d&&i.set(s,d)}return t},Hn=typeof XMLHttpRequest<"u",vn=Hn&&function(e){return new Promise(function(n,r){const s=St(e);let o=s.data;const i=C.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=s,u,p,S,y,f;function m(){y&&y(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function T(){if(!h)return;const b=C.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),I={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:b,config:e,request:h};mt(function(D){n(D),m()},function(D){r(D),m()},I),h=null}"onloadend"in h?h.onloadend=T:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(T)},h.onabort=function(){h&&(r(new E("Request aborted",E.ECONNABORTED,e,h)),h=null)},h.onerror=function(g){const I=g&&g.message?g.message:"Network Error",v=new E(I,E.ERR_NETWORK,e,h);v.event=g||null,r(v),h=null},h.ontimeout=function(){let g=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const I=s.transitional||dt;s.timeoutErrorMessage&&(g=s.timeoutErrorMessage),r(new E(g,I.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(g,I){h.setRequestHeader(I,g)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),c&&c!=="json"&&(h.responseType=s.responseType),l&&([S,f]=le(l,!0),h.addEventListener("progress",S)),d&&h.upload&&([p,y]=le(d),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",y)),(s.cancelToken||s.signal)&&(u=b=>{h&&(r(!b||b.type?new K(null,e,h):b),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const _=Fn(s.url);if(_&&O.protocols.indexOf(_)===-1){r(new E("Unsupported protocol "+_+":",E.ERR_BAD_REQUEST,e));return}h.send(o||null)})},Mn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(l){if(!s){s=!0,c();const u=l instanceof Error?l:this.reason;r.abort(u instanceof E?u:new K(u instanceof Error?u.message:u))}};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(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},qn=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},$n=async function*(e,t){for await(const n of Jn(e))yield*qn(n,t)},Jn=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()}},ze=(e,t,n,r)=>{const s=$n(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await s.next();if(l){c(),d.close();return}let p=u.byteLength;if(n){let S=o+=p;n(S)}d.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},Ge=64*1024,{isFunction:ie}=a,zn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:We,TextEncoder:Ve}=a.global,Ke=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Gn=e=>{e=a.merge.call({skipUndefined:!0},zn,e);const{fetch:t,Request:n,Response:r}=e,s=t?ie(t):typeof fetch=="function",o=ie(n),i=ie(r);if(!s)return!1;const c=s&&ie(We),d=s&&(typeof Ve=="function"?(f=>m=>f.encode(m))(new Ve):async f=>new Uint8Array(await new n(f).arrayBuffer())),l=o&&c&&Ke(()=>{let f=!1;const m=new n(O.origin,{body:new We,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),u=i&&c&&Ke(()=>a.isReadableStream(new r("").body)),p={stream:u&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!p[f]&&(p[f]=(m,h)=>{let T=m&&m[f];if(T)return T.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(O.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},y=async(f,m)=>{const h=a.toFiniteNumber(f.getContentLength());return h??S(m)};return async f=>{let{url:m,method:h,data:T,signal:_,cancelToken:b,timeout:g,onDownloadProgress:I,onUploadProgress:v,responseType:D,headers:Re,withCredentials:re="same-origin",fetchOptions:Ie}=St(f),Fe=t||fetch;D=D?(D+"").toLowerCase():"text";let se=Mn([_,b&&b.toAbortSignal()],g),X=null;const M=se&&se.unsubscribe&&(()=>{se.unsubscribe()});let Le;try{if(v&&l&&h!=="get"&&h!=="head"&&(Le=await y(Re,T))!==0){let j=new n(m,{method:"POST",body:T,duplex:"half"}),G;if(a.isFormData(T)&&(G=j.headers.get("content-type"))&&Re.setContentType(G),j.body){const[Te,oe]=qe(Le,le($e(v)));T=ze(j.body,Ge,Te,oe)}}a.isString(re)||(re=re?"include":"omit");const L=o&&"credentials"in n.prototype,xe={...Ie,signal:se,method:h.toUpperCase(),headers:Re.normalize().toJSON(),body:T,duplex:"half",credentials:L?re:void 0};X=o&&new n(m,xe);let B=await(o?Fe(X,Ie):Fe(m,xe));const Pe=u&&(D==="stream"||D==="response");if(u&&(I||Pe&&M)){const j={};["status","statusText","headers"].forEach(ke=>{j[ke]=B[ke]});const G=a.toFiniteNumber(B.headers.get("content-length")),[Te,oe]=I&&qe(G,le($e(I),!0))||[];B=new r(ze(B.body,Ge,Te,()=>{oe&&oe(),M&&M()}),j)}D=D||"text";let Ot=await p[a.findKey(p,D)||"text"](B,f);return!Pe&&M&&M(),await new Promise((j,G)=>{mt(j,G,{data:Ot,headers:C.from(B.headers),status:B.status,statusText:B.statusText,config:f,request:X})})}catch(L){throw M&&M(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,X),{cause:L.cause||L}):E.from(L,L&&L.code,f,X)}}},Wn=new Map,Rt=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,l,u=Wn;for(;c--;)d=o[c],l=u.get(d),l===void 0&&u.set(d,l=c?new Map:Gn(t)),u=l;return l};Rt();const De={http:ln,xhr:vn,fetch:{get:Rt}};a.forEach(De,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Xe=e=>`- ${e}`,Vn=e=>a.isFunction(e)||e===null||e===!1;function Kn(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,!Vn(r)&&(s=De[(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,l])=>`adapter ${d} `+(l===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function Ze(e,t){return function(){return e.apply(t,arguments)}}const{toString:At}=Object.prototype,{getPrototypeOf:Ce}=Object,{iterator:he,toStringTag:et}=Symbol,pe=(e=>t=>{const n=At.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),F=e=>(e=e.toLowerCase(),t=>pe(t)===e),me=e=>t=>typeof t===e,{isArray:V}=Array,W=me("undefined");function Z(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&g(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const tt=F("ArrayBuffer");function Nt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&tt(e.buffer),t}const gt=me("string"),g=me("function"),nt=me("number"),ee=e=>e!==null&&typeof e=="object",Ct=e=>e===!0||e===!1,ae=e=>{if(pe(e)!=="object")return!1;const t=Ce(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(et in e)&&!(he in e)},Ut=e=>{if(!ee(e)||Z(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},_t=F("Date"),Dt=F("File"),It=F("Blob"),Ft=F("FileList"),Lt=e=>ee(e)&&g(e.pipe),xt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||g(e.append)&&((t=pe(e))==="formdata"||t==="object"&&g(e.toString)&&e.toString()==="[object FormData]"))},Pt=F("URLSearchParams"),[kt,Bt,jt,Ht]=["ReadableStream","Request","Response","Headers"].map(F),vt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function te(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),V(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(Z(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 rt(e,t){if(Z(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 q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,st=e=>!W(e)&&e!==q;function Oe(){const{caseless:e,skipUndefined:t}=st(this)&&this||{},n={},r=(s,o)=>{const i=e&&rt(n,o)||o;ae(n[i])&&ae(s)?n[i]=Oe(n[i],s):ae(s)?n[i]=Oe({},s):V(s)?n[i]=s.slice():(!t||!W(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&te(arguments[s],r);return n}const Mt=(e,t,n,{allOwnKeys:r}={})=>(te(t,(s,o)=>{n&&g(s)?e[o]=Ze(s,n):e[o]=s},{allOwnKeys:r}),e),qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$t=(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)},Jt=(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&&Ce(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},zt=(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},Gt=e=>{if(!e)return null;if(V(e))return e;let t=e.length;if(!nt(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Wt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ce(Uint8Array)),Vt=(e,t)=>{const r=(e&&e[he]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Kt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Xt=F("HTMLFormElement"),Qt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Be=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Yt=F("RegExp"),ot=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};te(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},Zt=e=>{ot(e,(t,n)=>{if(g(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(g(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+"'")})}})},en=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return V(e)?r(e):r(String(e).split(t)),n},tn=()=>{},nn=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function rn(e){return!!(e&&g(e.append)&&e[et]==="FormData"&&e[he])}const sn=e=>{const t=new Array(10),n=(r,s)=>{if(ee(r)){if(t.indexOf(r)>=0)return;if(Z(r))return r;if(!("toJSON"in r)){t[s]=r;const o=V(r)?[]:{};return te(r,(i,c)=>{const d=n(i,s+1);!W(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},on=F("AsyncFunction"),an=e=>e&&(ee(e)||g(e))&&g(e.then)&&g(e.catch),it=((e,t)=>e?setImmediate:t?((n,r)=>(q.addEventListener("message",({source:s,data:o})=>{s===q&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),q.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",g(q.postMessage)),cn=typeof queueMicrotask<"u"?queueMicrotask.bind(q):typeof process<"u"&&process.nextTick||it,un=e=>e!=null&&g(e[he]),a={isArray:V,isArrayBuffer:tt,isBuffer:Z,isFormData:xt,isArrayBufferView:Nt,isString:gt,isNumber:nt,isBoolean:Ct,isObject:ee,isPlainObject:ae,isEmptyObject:Ut,isReadableStream:kt,isRequest:Bt,isResponse:jt,isHeaders:Ht,isUndefined:W,isDate:_t,isFile:Dt,isBlob:It,isRegExp:Yt,isFunction:g,isStream:Lt,isURLSearchParams:Pt,isTypedArray:Wt,isFileList:Ft,forEach:te,merge:Oe,extend:Mt,trim:vt,stripBOM:qt,inherits:$t,toFlatObject:Jt,kindOf:pe,kindOfTest:F,endsWith:zt,toArray:Gt,forEachEntry:Vt,matchAll:Kt,isHTMLForm:Xt,hasOwnProperty:Be,hasOwnProp:Be,reduceDescriptors:ot,freezeMethods:Zt,toObjectSet:en,toCamelCase:Qt,noop:tn,toFiniteNumber:nn,findKey:rt,global:q,isContextDefined:st,isSpecCompliantForm:rn,toJSONObject:sn,isAsyncFn:on,isThenable:an,setImmediate:it,asap:cn,isIterable:un};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 at=E.prototype,ct={};["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=>{ct[e]={value:e}});Object.defineProperties(E,ct);Object.defineProperty(at,"isAxiosError",{value:!0});E.from=(e,t,n,r,s,o)=>{const i=Object.create(at);a.toFlatObject(e,i,function(u){return u!==Error.prototype},l=>l!=="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 ln=null;function Ae(e){return a.isPlainObject(e)||a.isArray(e)}function ut(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function je(e,t,n){return e?e.concat(t).map(function(s,o){return s=ut(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function fn(e){return a.isArray(e)&&!e.some(Ae)}const dn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Ee(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||u,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 l(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 u(f,m,h){let T=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)&&fn(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(T=a.toArray(f)))return m=ut(m),T.forEach(function(y,N){!(a.isUndefined(y)||y===null)&&t.append(i===!0?je([m],N,o):i===null?m:m+"[]",l(y))}),!1}return Ae(f)?!0:(t.append(je(h,m,o),l(f)),!1)}const p=[],S=Object.assign(dn,{defaultVisitor:u,convertValue:l,isVisitable:Ae});function w(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(T,U){(!(a.isUndefined(T)||T===null)&&s.call(t,T,a.isString(U)?U.trim():U,m,S))===!0&&w(T,m?m.concat(U):[U])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return w(e),t}function He(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ue(e,t){this._pairs=[],e&&Ee(e,this,t)}const lt=Ue.prototype;lt.append=function(t,n){this._pairs.push([t,n])};lt.toString=function(t){const n=t?function(r){return t.call(this,r,He)}:He;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function hn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ft(e,t,n){if(!t)return e;const r=n&&n.encode||hn;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 Ue(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ve{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 dt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},pn=typeof URLSearchParams<"u"?URLSearchParams:Ue,mn=typeof FormData<"u"?FormData:null,En=typeof Blob<"u"?Blob:null,Sn={isBrowser:!0,classes:{URLSearchParams:pn,FormData:mn,Blob:En},protocols:["http","https","file","blob","url","data"]},_e=typeof window<"u"&&typeof document<"u",Ne=typeof navigator=="object"&&navigator||void 0,Rn=_e&&(!Ne||["ReactNative","NativeScript","NS"].indexOf(Ne.product)<0),Tn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yn=_e&&window.location.href||"http://localhost",wn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:_e,hasStandardBrowserEnv:Rn,hasStandardBrowserWebWorkerEnv:Tn,navigator:Ne,origin:yn},Symbol.toStringTag,{value:"Module"})),O={...wn,...Sn};function bn(e,t){return Ee(e,new O.classes.URLSearchParams,{visitor:function(n,r,s,o){return O.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function On(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function An(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 ht(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]=An(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(On(r),s,n,0)}),n}return null}function Nn(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 ne={transitional:dt,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(ht(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 bn(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Ee(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Nn(t)):t}],transformResponse:[function(t){const n=this.transitional||ne.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:O.classes.FormData,Blob:O.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=>{ne.headers[e]={}});const gn=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"]),Cn=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]&&gn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Me=Symbol("internals");function Q(e){return e&&String(e).trim().toLowerCase()}function ce(e){return e===!1||e==null?e:a.isArray(e)?e.map(ce):String(e)}function Un(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 _n=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ye(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 Dn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function In(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 C=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,l){const u=Q(d);if(!u)throw new Error("header name must be a non-empty string");const p=a.findKey(s,u);(!p||s[p]===void 0||l===!0||l===void 0&&s[p]!==!1)&&(s[p||d]=ce(c))}const i=(c,d)=>a.forEach(c,(l,u)=>o(l,u,d));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!_n(t))i(Cn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let c={},d,l;for(const u of t){if(!a.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[l=u[0]]=(d=c[l])?a.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}i(c,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=Q(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Un(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=Q(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ye(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=Q(i),i){const c=a.findKey(r,i);c&&(!n||ye(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||ye(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]=ce(s),delete n[o];return}const c=t?Dn(o):String(o).trim();c!==o&&delete n[o],n[c]=ce(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[Me]=this[Me]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=Q(i);r[c]||(In(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};C.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(C.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(C);function we(e,t){const n=this||ne,r=t||n,s=C.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 pt(e){return!!(e&&e.__CANCEL__)}function K(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(K,E,{__CANCEL__:!0});function mt(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 Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ln(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 l=Date.now(),u=r[o];i||(i=l),n[s]=d,r[s]=l;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),l-i<t)return;const w=u&&l-u;return w?Math.round(S*1e3/w):void 0}}function xn(e,t){let n=0,r=1e3/t,s,o;const i=(l,u=Date.now())=>{n=u,s=null,o&&(clearTimeout(o),o=null),e(...l)};return[(...l)=>{const u=Date.now(),p=u-n;p>=r?i(l,u):(s=l,o||(o=setTimeout(()=>{o=null,i(s)},r-p)))},()=>s&&i(s)]}const le=(e,t,n=3)=>{let r=0;const s=Ln(50,250);return xn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,l=s(d),u=i<=c;r=i;const p={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},n)},qe=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},$e=e=>(...t)=>a.asap(()=>e(...t)),Pn=O.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,O.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(O.origin),O.navigator&&/(msie|trident)/i.test(O.navigator.userAgent)):()=>!0,kn=O.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 Bn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Et(e,t,n){let r=!Bn(t);return e&&(r||n==!1)?jn(e,t):t}const Je=e=>e instanceof C?{...e}:e;function J(e,t){t=t||{};const n={};function r(l,u,p,S){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:S},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(l,u,p,S){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l,p,S)}else return r(l,u,p,S)}function o(l,u){if(!a.isUndefined(u))return r(void 0,u)}function i(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l)}else return r(void 0,u)}function c(l,u,p){if(p in t)return r(l,u);if(p in e)return r(void 0,l)}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:(l,u,p)=>s(Je(l),Je(u),p,!0)};return a.forEach(Object.keys({...e,...t}),function(u){const p=d[u]||s,S=p(e[u],t[u],u);a.isUndefined(S)&&p!==c||(n[u]=S)}),n}const St=e=>{const t=J({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=C.from(i),t.url=ft(Et(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(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),l=["content-type","content-length"];Object.entries(d).forEach(([u,p])=>{l.includes(u.toLowerCase())&&i.set(u,p)})}}if(O.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Pn(t.url))){const d=s&&o&&kn.read(o);d&&i.set(s,d)}return t},Hn=typeof XMLHttpRequest<"u",vn=Hn&&function(e){return new Promise(function(n,r){const s=St(e);let o=s.data;const i=C.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=s,u,p,S,w,f;function m(){w&&w(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function T(){if(!h)return;const y=C.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),I={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:y,config:e,request:h};mt(function(_){n(_),m()},function(_){r(_),m()},I),h=null}"onloadend"in h?h.onloadend=T:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(T)},h.onabort=function(){h&&(r(new E("Request aborted",E.ECONNABORTED,e,h)),h=null)},h.onerror=function(N){const I=N&&N.message?N.message:"Network Error",v=new E(I,E.ERR_NETWORK,e,h);v.event=N||null,r(v),h=null},h.ontimeout=function(){let N=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const I=s.transitional||dt;s.timeoutErrorMessage&&(N=s.timeoutErrorMessage),r(new E(N,I.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(N,I){h.setRequestHeader(I,N)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),c&&c!=="json"&&(h.responseType=s.responseType),l&&([S,f]=le(l,!0),h.addEventListener("progress",S)),d&&h.upload&&([p,w]=le(d),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",w)),(s.cancelToken||s.signal)&&(u=y=>{h&&(r(!y||y.type?new K(null,e,h):y),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const U=Fn(s.url);if(U&&O.protocols.indexOf(U)===-1){r(new E("Unsupported protocol "+U+":",E.ERR_BAD_REQUEST,e));return}h.send(o||null)})},Mn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(l){if(!s){s=!0,c();const u=l instanceof Error?l:this.reason;r.abort(u instanceof E?u:new K(u instanceof Error?u.message:u))}};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(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},qn=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},$n=async function*(e,t){for await(const n of Jn(e))yield*qn(n,t)},Jn=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()}},ze=(e,t,n,r)=>{const s=$n(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await s.next();if(l){c(),d.close();return}let p=u.byteLength;if(n){let S=o+=p;n(S)}d.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},Ge=64*1024,{isFunction:ie}=a,zn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:We,TextEncoder:Ve}=a.global,Ke=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Gn=e=>{e=a.merge.call({skipUndefined:!0},zn,e);const{fetch:t,Request:n,Response:r}=e,s=t?ie(t):typeof fetch=="function",o=ie(n),i=ie(r);if(!s)return!1;const c=s&&ie(We),d=s&&(typeof Ve=="function"?(f=>m=>f.encode(m))(new Ve):async f=>new Uint8Array(await new n(f).arrayBuffer())),l=o&&c&&Ke(()=>{let f=!1;const m=new n(O.origin,{body:new We,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),u=i&&c&&Ke(()=>a.isReadableStream(new r("").body)),p={stream:u&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!p[f]&&(p[f]=(m,h)=>{let T=m&&m[f];if(T)return T.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(O.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},w=async(f,m)=>{const h=a.toFiniteNumber(f.getContentLength());return h??S(m)};return async f=>{let{url:m,method:h,data:T,signal:U,cancelToken:y,timeout:N,onDownloadProgress:I,onUploadProgress:v,responseType:_,headers:Re,withCredentials:re="same-origin",fetchOptions:Ie}=St(f),Fe=t||fetch;_=_?(_+"").toLowerCase():"text";let se=Mn([U,y&&y.toAbortSignal()],N),X=null;const M=se&&se.unsubscribe&&(()=>{se.unsubscribe()});let Le;try{if(v&&l&&h!=="get"&&h!=="head"&&(Le=await w(Re,T))!==0){let j=new n(m,{method:"POST",body:T,duplex:"half"}),G;if(a.isFormData(T)&&(G=j.headers.get("content-type"))&&Re.setContentType(G),j.body){const[Te,oe]=qe(Le,le($e(v)));T=ze(j.body,Ge,Te,oe)}}a.isString(re)||(re=re?"include":"omit");const L=o&&"credentials"in n.prototype,xe={...Ie,signal:se,method:h.toUpperCase(),headers:Re.normalize().toJSON(),body:T,duplex:"half",credentials:L?re:void 0};X=o&&new n(m,xe);let B=await(o?Fe(X,Ie):Fe(m,xe));const Pe=u&&(_==="stream"||_==="response");if(u&&(I||Pe&&M)){const j={};["status","statusText","headers"].forEach(ke=>{j[ke]=B[ke]});const G=a.toFiniteNumber(B.headers.get("content-length")),[Te,oe]=I&&qe(G,le($e(I),!0))||[];B=new r(ze(B.body,Ge,Te,()=>{oe&&oe(),M&&M()}),j)}_=_||"text";let Ot=await p[a.findKey(p,_)||"text"](B,f);return!Pe&&M&&M(),await new Promise((j,G)=>{mt(j,G,{data:Ot,headers:C.from(B.headers),status:B.status,statusText:B.statusText,config:f,request:X})})}catch(L){throw M&&M(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,X),{cause:L.cause||L}):E.from(L,L&&L.code,f,X)}}},Wn=new Map,Rt=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,l,u=Wn;for(;c--;)d=o[c],l=u.get(d),l===void 0&&u.set(d,l=c?new Map:Gn(t)),u=l;return l};Rt();const De={http:ln,xhr:vn,fetch:{get:Rt}};a.forEach(De,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Xe=e=>`- ${e}`,Vn=e=>a.isFunction(e)||e===null||e===!1;function Kn(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,!Vn(r)&&(s=De[(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,l])=>`adapter ${d} `+(l===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
4
4
  `+i.map(Xe).join(`
5
- `):" "+Xe(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 Tt={getAdapter:Kn,adapters:De};function we(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new K(null,e)}function Qe(e){return we(e),e.headers=C.from(e.headers),e.data=ye.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Tt.getAdapter(e.adapter||ne.adapter,e)(e).then(function(r){return we(e),r.data=ye.call(e,e.transformResponse,r),r.headers=C.from(r.headers),r},function(r){return pt(r)||(we(e),r&&r.response&&(r.response.data=ye.call(e,e.transformResponse,r.response),r.response.headers=C.from(r.response.headers))),Promise.reject(r)})}const bt="1.13.2",Se={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Se[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Ye={};Se.transitional=function(t,n,r){function s(o,i){return"[Axios v"+bt+"] 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&&!Ye[i]&&(Ye[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}};Se.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Xn(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 ue={assertOptions:Xn,validators:Se},x=ue.validators;let $=class{constructor(t){this.defaults=t||{},this.interceptors={request:new ve,response:new ve}}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&&ue.assertOptions(r,{silentJSONParsing:x.transitional(x.boolean),forcedJSONParsing:x.transitional(x.boolean),clarifyTimeoutError:x.transitional(x.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:ue.assertOptions(s,{encode:x.function,serialize:x.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ue.assertOptions(n,{baseUrl:x.spelling("baseURL"),withXsrfToken:x.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=C.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 l=[];this.interceptors.response.forEach(function(m){l.push(m.fulfilled,m.rejected)});let u,p=0,S;if(!d){const f=[Qe.bind(this),void 0];for(f.unshift(...c),f.push(...l),S=f.length,u=Promise.resolve(n);p<S;)u=u.then(f[p++],f[p++]);return u}S=c.length;let y=n;for(;p<S;){const f=c[p++],m=c[p++];try{y=f(y)}catch(h){m.call(this,h);break}}try{u=Qe.call(this,y)}catch(f){return Promise.reject(f)}for(p=0,S=l.length;p<S;)u=u.then(l[p++],l[p++]);return u}getUri(t){t=J(this.defaults,t);const n=Et(t.baseURL,t.url,t.allowAbsoluteUrls);return ft(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){$.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}))}}$.prototype[t]=n(),$.prototype[t+"Form"]=n(!0)});let Qn=class yt{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 K(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 yt(function(s){t=s}),cancel:t}}};function Yn(e){return function(n){return e.apply(null,n)}}function Zn(e){return a.isObject(e)&&e.isAxiosError===!0}const Ne={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(Ne).forEach(([e,t])=>{Ne[t]=e});function wt(e){const t=new $(e),n=Ze($.prototype.request,t);return a.extend(n,$.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return wt(J(e,s))},n}const R=wt(ne);R.Axios=$;R.CanceledError=K;R.CancelToken=Qn;R.isCancel=pt;R.VERSION=bt;R.toFormData=Ee;R.AxiosError=E;R.Cancel=R.CanceledError;R.all=function(t){return Promise.all(t)};R.spread=Yn;R.isAxiosError=Zn;R.mergeConfig=J;R.AxiosHeaders=C;R.formToJSON=e=>ht(a.isHTMLForm(e)?new FormData(e):e);R.getAdapter=Tt.getAdapter;R.HttpStatusCode=Ne;R.default=R;const{Axios:fr,AxiosError:dr,CanceledError:hr,isCancel:pr,CancelToken:mr,VERSION:Er,all:Sr,Cancel:Rr,isAxiosError:Tr,spread:br,toFormData:yr,AxiosHeaders:wr,HttpStatusCode:Or,formToJSON:Ar,getAdapter:gr,mergeConfig:Nr}=R,fe="JOYTALK_TOKEN";var H=(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))(H||{}),P=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(P||{}),k=(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))(k||{}),de=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(de||{}),A=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(A||{}),w=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(w||{});const U={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:"数据为空"}},z=R.create({baseURL:"http://dev-joytalk-api.halaladmin.vip",timeout:6e5});z.interceptors.request.use(e=>{if(!e.noAuth){const t=localStorage.getItem(fe);if(!t)return Promise.reject(U.UNINITIALIZED);e.headers.Authorization=`Bearer ${t}`}return delete e.noAuth,e},e=>Promise.reject(e));z.interceptors.response.use(e=>e.data.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));const er=e=>z.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),tr=e=>R.post("https://joytalk-fat.obs.ap-southeast-1.myhuaweicloud.com",e,{headers:{"Content-Type":"multipart/form-data"}}),nr=e=>z.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),rr=e=>z.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),sr=()=>z.get("/api/open-auth/user/v1/UserService/GetUserInfo"),or=e=>z.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e);class ir{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()}}function ar(e){return`ws://dev-joytalk-api.halaladmin.vip/api/ws?Authorization=${e}`}const cr="https://joytalk-fat.obs.ap-southeast-1.myhuaweicloud.com/";class Y extends ir{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,heartbeatTimeout:1e4};ws=null;status=w.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;customerGroupId="";OBS_URL=cr;sessionData=null;userInfo=null;static instance=null;constructor(){if(super(),Y.instance)return Y.instance;Y.instance=this}async init(t){if(!t.token)return localStorage.removeItem(fe),Promise.reject(U.PARAMETER_ERROR);this.config=Object.assign(this.config,t),localStorage.setItem(fe,this.config.token)}connect(t){return this.customerGroupId=t,new Promise((n,r)=>{if(!this.config.token)return r(U.UNINITIALIZED);if(this.status===w.CONNECTED)return n();if(this.status!==w.CONNECTING){this.setStatus(w.CONNECTING);try{const s=ar(this.config.token);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(w.CONNECTED),this.emit(A.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){console.error("解析消息失败:",i)}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(w.ERROR),this.emit(A.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(w.DISCONNECTED),this.emit(A.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(w.ERROR),this.emit(A.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(w.DISCONNECTED)}sendMessage(t,n,r=H.SEND){return new Promise((s,o)=>{console.log("发送消息",{data:t,chatType:n,msgType:r,status:this.status,ws:this.ws});const i={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status===w.DISCONNECTED&&this.ws)console.log("连接断开,重新连接"),this.connect(this.customerGroupId).then(()=>{if(this.ws)return console.log("连接成功,重新发送消息"),this.sendMessage(t,n,r);console.error(U.DISCONNECTED),o(U.DISCONNECTED)}).catch(c=>{o(c)});else if(this.status!==w.CONNECTED||!this.ws)console.log("连接断开,重新连接"),console.error(U.DISCONNECTED),o(U.DISCONNECTED);else try{this.ws.send(JSON.stringify(i)),s(t)}catch{console.error(U.MESSAGE_SEND_FAIL),o(U.MESSAGE_SEND_FAIL)}})}sendText(t){return this.sessionData?this.sendMessage(t,P.TEXT):(console.error(U.NO_CUSTOMER_SERVICE),Promise.reject(U.NO_CUSTOMER_SERVICE))}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{if(!this.sessionData)return console.error(U.NO_CUSTOMER_SERVICE),Promise.reject(U.NO_CUSTOMER_SERVICE);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};return this.sendMessage(JSON.stringify(i),r)}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===w.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),this.isMessage(t))try{switch(t.code){case k.CONNECT_SUCCESS:if(this.sessionData)return;this.sendMessage(this.customerGroupId,void 0,H.INBOUND);break;case k.MATCH_INFO:case k.MATCH_SUCCESS:if(this.sessionData)return;const n=JSON.parse(typeof t.data=="string"?t.data:JSON.stringify(t.data));this.sessionData=n,t.data=n,this.getFaqList(),this.emit(A.MESSAGE,t);break;case k.TRANSFER_USER_SUCCESS:const r=JSON.parse(typeof t.data=="string"?t.data:JSON.stringify(t.data));this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,segmentId:r.segmentId,sessionId:r.sessionId,uid:r.uid},t.data=this.sessionData,this.emit(A.MESSAGE,t);break;case k.SEND_SUCCESS:const s=JSON.parse(typeof t.data=="string"?t.data:JSON.stringify(t.data));if(s.sessionId!==this.sessionData?.sessionId)return;t.chatType!==P.TEXT&&typeof s.content=="string"&&(s.content=JSON.parse(s.content),s.content?.fileUrl?.startsWith("http")||(s.content.fileUrl=this.OBS_URL+s.content.fileUrl),s.content?.thumbnailUrl?.startsWith("http")||(s.content.thumbnailUrl=this.OBS_URL+s.content.thumbnailUrl)),t.data=s,this.emit(A.MESSAGE,t);break;default:this.emit(A.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}isMessage(t){return typeof t=="object"&&t!==null&&"data"in t&&"msgType"in t&&"toUid"in t&&"chatType"in t&&"code"in t}setStatus(t){this.status!==t&&(this.status=t,this.emit(A.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(w.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.customerGroupId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==w.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.heartbeatTimeout&&(this.emit(A.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.heartbeatTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){const r=await or({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>{let i=o.content;return o.contentType===P.TEXT?i=o.content:(i=JSON.parse(o.content),i?.fileUrl?.startsWith("http")||(i.fileUrl=this.OBS_URL+i.fileUrl),i?.thumbnailUrl?.startsWith("http")||(i.thumbnailUrl=this.OBS_URL+i.thumbnailUrl)),{...o,content:i}});return{hasMore:r.data.hasMore,list:s}}getConsultationList(t){return nr({entranceId:t})}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await er({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:l}=o.data,u=new FormData;u.append("key",l),u.append("AccessKeyId",i),u.append("signature",c),u.append("policy",d),u.append("file",t),(await tr(u)).status===204?n(this.OBS_URL+l):r(new Error("上传文件失败"))})}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(new Error("无法生成缩略图"));return}const l=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",u=new File([d],l,{type:"image/jpeg",lastModified:Date.now()});n(u)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(new Error("视频加载失败"))}),s.load()});async getFaqList(){const t=await rr({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:k.SEND_SUCCESS,data:{content:n,contentType:P.FAQ,sendUserType:de.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND},msgType:H.SEND,chatType:P.FAQ,toUid:this.sessionData?.uid};this.emit(A.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:k.SEND_SUCCESS,data:{sendUserType:de.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND,contentType:P.FAQ,content:{}},msgType:H.SEND,chatType:P.FAQ,toUid:this.sessionData?.uid};if(t.isMulti)n.data.content={list:t.item},this.emit(A.MESSAGE,n);else{const r=t.item?.[0]||t;r.imageUrl=r.imageUrl?.map(s=>s?.startsWith("http")?s:this.OBS_URL+s),n.data.content={answer:r},this.emit(A.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await sr();return this.userInfo=t.data,this.userInfo}}exports.ChatType=P;exports.ConnectionStatus=w;exports.EventType=A;exports.MessageCode=k;exports.MessageType=H;exports.SendUserType=de;exports.TOKEN_KEY=fe;exports.default=Y;
5
+ `):" "+Xe(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 Tt={getAdapter:Kn,adapters:De};function be(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new K(null,e)}function Qe(e){return be(e),e.headers=C.from(e.headers),e.data=we.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Tt.getAdapter(e.adapter||ne.adapter,e)(e).then(function(r){return be(e),r.data=we.call(e,e.transformResponse,r),r.headers=C.from(r.headers),r},function(r){return pt(r)||(be(e),r&&r.response&&(r.response.data=we.call(e,e.transformResponse,r.response),r.response.headers=C.from(r.response.headers))),Promise.reject(r)})}const yt="1.13.2",Se={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Se[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Ye={};Se.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] 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&&!Ye[i]&&(Ye[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}};Se.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Xn(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 ue={assertOptions:Xn,validators:Se},x=ue.validators;let $=class{constructor(t){this.defaults=t||{},this.interceptors={request:new ve,response:new ve}}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&&ue.assertOptions(r,{silentJSONParsing:x.transitional(x.boolean),forcedJSONParsing:x.transitional(x.boolean),clarifyTimeoutError:x.transitional(x.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:ue.assertOptions(s,{encode:x.function,serialize:x.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ue.assertOptions(n,{baseUrl:x.spelling("baseURL"),withXsrfToken:x.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=C.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 l=[];this.interceptors.response.forEach(function(m){l.push(m.fulfilled,m.rejected)});let u,p=0,S;if(!d){const f=[Qe.bind(this),void 0];for(f.unshift(...c),f.push(...l),S=f.length,u=Promise.resolve(n);p<S;)u=u.then(f[p++],f[p++]);return u}S=c.length;let w=n;for(;p<S;){const f=c[p++],m=c[p++];try{w=f(w)}catch(h){m.call(this,h);break}}try{u=Qe.call(this,w)}catch(f){return Promise.reject(f)}for(p=0,S=l.length;p<S;)u=u.then(l[p++],l[p++]);return u}getUri(t){t=J(this.defaults,t);const n=Et(t.baseURL,t.url,t.allowAbsoluteUrls);return ft(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){$.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}))}}$.prototype[t]=n(),$.prototype[t+"Form"]=n(!0)});let Qn=class wt{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 K(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 wt(function(s){t=s}),cancel:t}}};function Yn(e){return function(n){return e.apply(null,n)}}function Zn(e){return a.isObject(e)&&e.isAxiosError===!0}const ge={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(ge).forEach(([e,t])=>{ge[t]=e});function bt(e){const t=new $(e),n=Ze($.prototype.request,t);return a.extend(n,$.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return bt(J(e,s))},n}const R=bt(ne);R.Axios=$;R.CanceledError=K;R.CancelToken=Qn;R.isCancel=pt;R.VERSION=yt;R.toFormData=Ee;R.AxiosError=E;R.Cancel=R.CanceledError;R.all=function(t){return Promise.all(t)};R.spread=Yn;R.isAxiosError=Zn;R.mergeConfig=J;R.AxiosHeaders=C;R.formToJSON=e=>ht(a.isHTMLForm(e)?new FormData(e):e);R.getAdapter=Tt.getAdapter;R.HttpStatusCode=ge;R.default=R;const{Axios:fr,AxiosError:dr,CanceledError:hr,isCancel:pr,CancelToken:mr,VERSION:Er,all:Sr,Cancel:Rr,isAxiosError:Tr,spread:yr,toFormData:wr,AxiosHeaders:br,HttpStatusCode:Or,formToJSON:Ar,getAdapter:Nr,mergeConfig:gr}=R,fe="JOYTALK_TOKEN";var H=(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))(H||{}),P=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(P||{}),k=(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))(k||{}),de=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(de||{}),A=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(A||{}),b=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(b||{});const D={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:"数据为空"}},z=R.create({baseURL:"http://dev-joytalk-api.halaladmin.vip",timeout:6e5});z.interceptors.request.use(e=>{if(!e.noAuth){const t=localStorage.getItem(fe);if(!t)return Promise.reject(D.UNINITIALIZED);e.headers.Authorization=`Bearer ${t}`}return delete e.noAuth,e},e=>Promise.reject(e));z.interceptors.response.use(e=>e.data.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));const er=e=>z.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),tr=e=>R.post("https://joytalk-fat.obs.ap-southeast-1.myhuaweicloud.com",e,{headers:{"Content-Type":"multipart/form-data"}}),nr=e=>z.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),rr=e=>z.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),sr=()=>z.get("/api/open-auth/user/v1/UserService/GetUserInfo"),or=e=>z.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e);class ir{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()}}function ar(e){return`ws://dev-joytalk-api.halaladmin.vip/api/ws?Authorization=${e}`}const cr="https://joytalk-fat.obs.ap-southeast-1.myhuaweicloud.com/";class Y extends ir{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,heartbeatTimeout:1e4};ws=null;status=b.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;customerGroupId="";OBS_URL=cr;sessionData=null;userInfo=null;static instance=null;constructor(){if(super(),Y.instance)return Y.instance;Y.instance=this}async init(t){if(!t.token)return localStorage.removeItem(fe),Promise.reject(D.PARAMETER_ERROR);this.config=Object.assign(this.config,t),localStorage.setItem(fe,this.config.token)}connect(t){return this.customerGroupId=t,new Promise((n,r)=>{if(!this.config.token)return r(D.UNINITIALIZED);if(this.status===b.CONNECTED)return n();if(this.status!==b.CONNECTING){this.setStatus(b.CONNECTING);try{const s=ar(this.config.token);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(b.CONNECTED),this.emit(A.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){console.error("解析消息失败:",i)}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(b.ERROR),this.emit(A.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(b.DISCONNECTED),this.emit(A.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(b.ERROR),this.emit(A.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(b.DISCONNECTED)}async sendMessage(t,n,r=H.SEND){console.log("发送消息",{data:t,chatType:n,msgType:r,status:this.status,ws:this.ws});const s={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status!==b.CONNECTED||!this.ws)if(this.ws&&this.status===b.DISCONNECTED){console.log("连接断开,尝试重新连接");try{await this.connect(this.customerGroupId)}catch(o){throw console.error("重连失败:",o),D.DISCONNECTED}}else throw console.error(D.DISCONNECTED),D.DISCONNECTED;try{if(!this.ws)throw D.DISCONNECTED;return this.ws.send(JSON.stringify(s)),t}catch(o){throw console.error("发送消息失败:",o),D.MESSAGE_SEND_FAIL}}async sendText(t){if(!this.sessionData)throw console.error(D.NO_CUSTOMER_SERVICE),D.NO_CUSTOMER_SERVICE;return this.sendMessage(t,P.TEXT)}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{if(!this.sessionData)throw console.error(D.NO_CUSTOMER_SERVICE),D.NO_CUSTOMER_SERVICE;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};return this.sendMessage(JSON.stringify(i),r)}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===b.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),this.isMessage(t))try{switch(t.code){case k.CONNECT_SUCCESS:if(this.sessionData)return;this.sendMessage(this.customerGroupId,void 0,H.INBOUND);break;case k.MATCH_INFO:case k.MATCH_SUCCESS:if(this.sessionData)return;const n=JSON.parse(typeof t.data=="string"?t.data:JSON.stringify(t.data));this.sessionData=n,t.data=n,this.getFaqList(),this.emit(A.MESSAGE,t);break;case k.TRANSFER_USER_SUCCESS:const r=JSON.parse(typeof t.data=="string"?t.data:JSON.stringify(t.data));this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,segmentId:r.segmentId,sessionId:r.sessionId,uid:r.uid},t.data=this.sessionData,this.emit(A.MESSAGE,t);break;case k.SEND_SUCCESS:const s=JSON.parse(typeof t.data=="string"?t.data:JSON.stringify(t.data));if(s.sessionId!==this.sessionData?.sessionId)return;t.chatType!==P.TEXT&&typeof s.content=="string"&&(s.content=JSON.parse(s.content),s.content?.fileUrl?.startsWith("http")||(s.content.fileUrl=this.OBS_URL+s.content.fileUrl),s.content?.thumbnailUrl?.startsWith("http")||(s.content.thumbnailUrl=this.OBS_URL+s.content.thumbnailUrl)),t.data=s,this.emit(A.MESSAGE,t);break;default:this.emit(A.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}isMessage(t){return typeof t=="object"&&t!==null&&"data"in t&&"msgType"in t&&"toUid"in t&&"chatType"in t&&"code"in t}setStatus(t){this.status!==t&&(this.status=t,this.emit(A.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(b.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.customerGroupId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==b.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.heartbeatTimeout&&(this.emit(A.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.heartbeatTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){const r=await or({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>{let i=o.content;return o.contentType===P.TEXT?i=o.content:(i=JSON.parse(o.content),i?.fileUrl?.startsWith("http")||(i.fileUrl=this.OBS_URL+i.fileUrl),i?.thumbnailUrl?.startsWith("http")||(i.thumbnailUrl=this.OBS_URL+i.thumbnailUrl)),{...o,content:i}});return{hasMore:r.data.hasMore,list:s}}getConsultationList(t){return nr({entranceId:t})}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await er({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:l}=o.data,u=new FormData;u.append("key",l),u.append("AccessKeyId",i),u.append("signature",c),u.append("policy",d),u.append("file",t),(await tr(u)).status===204?n(this.OBS_URL+l):r(new Error("上传文件失败"))})}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(new Error("无法生成缩略图"));return}const l=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",u=new File([d],l,{type:"image/jpeg",lastModified:Date.now()});n(u)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(new Error("视频加载失败"))}),s.load()});async getFaqList(){const t=await rr({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:k.SEND_SUCCESS,data:{content:n,contentType:P.FAQ,sendUserType:de.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND},msgType:H.SEND,chatType:P.FAQ,toUid:this.sessionData?.uid};this.emit(A.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:k.SEND_SUCCESS,data:{sendUserType:de.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND,contentType:P.FAQ,content:{}},msgType:H.SEND,chatType:P.FAQ,toUid:this.sessionData?.uid};if(t.isMulti)n.data.content={list:t.item},this.emit(A.MESSAGE,n);else{const r=t.item?.[0]||t;r.imageUrl=r.imageUrl?.map(s=>s?.startsWith("http")?s:this.OBS_URL+s),n.data.content={answer:r},this.emit(A.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await sr();return this.userInfo=t.data,this.userInfo}}exports.ChatType=P;exports.ConnectionStatus=b;exports.EventType=A;exports.MessageCode=k;exports.MessageType=H;exports.SendUserType=de;exports.TOKEN_KEY=fe;exports.default=Y;