joytalk 0.0.18 → 0.0.19

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