@glodon-aiot/agent-cli-sdk 3.0.5 → 3.0.6

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.
@@ -1087,7 +1087,7 @@ class v0 {
1087
1087
  // https://github.com/axios/axios#handling-errors
1088
1088
  handleError(O) {
1089
1089
  var L, Y;
1090
- return O.response ? (console.log(O.response.data), console.log(O.response.status), console.log(O.response.headers), (L = this.errorHandler) != null && L.onHttpStatusError && (console.log("HTTP 错误", this.errorHandler), this.errorHandler.onHttpStatusError(O.response.status, "", O.response))) : O.request ? (console.log(O.request), (Y = this.errorHandler) != null && Y.onNetworkError && this.errorHandler.onNetworkError()) : console.error("axios request config error:", O), new Error(O.message);
1090
+ return O.response ? (L = this.errorHandler) != null && L.onHttpStatusError && (console.log("HTTP 错误", this.errorHandler), this.errorHandler.onHttpStatusError(O.response.status, "", O.response)) : O.request ? (console.log(O.request), (Y = this.errorHandler) != null && Y.onNetworkError && this.errorHandler.onNetworkError()) : console.error("axios request config error:", O), new Error(O.message);
1091
1091
  }
1092
1092
  }
1093
1093
  const y0 = (K) => K >= 10002 && K <= 10012, b0 = (K, O) => y0(K) ? "数据操作错误" : O || "未知接口错误";
@@ -31697,7 +31697,7 @@ var la;
31697
31697
  (function(K) {
31698
31698
  K[K.enable = 1] = "enable", K[K.disable = 2] = "disable";
31699
31699
  })(la || (la = {}));
31700
- const Vr = new ni("[Session] ", !0);
31700
+ const Vr = new ni("[Session] ");
31701
31701
  var Xr;
31702
31702
  (function(K) {
31703
31703
  K.DataRequestFailed = "data request error", K.SocketConnectionFailed = "socket error", K.IdUndefined = "session id is not defined", K.SendingEmptyContent = "failed at sending empty content", K.Frozen = "session is frozen", K.UserModeError = "failed at setting socket user mode", K.Inactive = "session is inactive";
@@ -32631,7 +32631,7 @@ function Rm(K) {
32631
32631
  if (!(O != null && O.startsWith(iu)))
32632
32632
  throw new Error(`Expected content-type to be ${iu}, Actual: ${O}`);
32633
32633
  }
32634
- const uh = new ni("[DialogSession] ", !0);
32634
+ const uh = new ni("[DialogSession] ");
32635
32635
  class Nm extends Vh {
32636
32636
  constructor(O, L = "", Y, ut, ht, W) {
32637
32637
  super(O, L, Y, ut, ht, W), Object.defineProperty(this, "ctrl", {
@@ -12,7 +12,7 @@
12
12
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
14
  ***************************************************************************** */function Kh(K,O){var L={};for(var Y in K)Object.prototype.hasOwnProperty.call(K,Y)&&O.indexOf(Y)<0&&(L[Y]=K[Y]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ut=0,Y=Object.getOwnPropertySymbols(K);ut<Y.length;ut++)O.indexOf(Y[ut])<0&&Object.prototype.propertyIsEnumerable.call(K,Y[ut])&&(L[Y[ut]]=K[Y[ut]]);return L}function Le(K,O,L,Y){function ut(ht){return ht instanceof L?ht:new L(function(W){W(ht)})}return new(L||(L=Promise))(function(ht,W){function _(v){try{x(Y.next(v))}catch(m){W(m)}}function y(v){try{x(Y.throw(v))}catch(m){W(m)}}function x(v){v.done?ht(v.value):ut(v.value).then(_,y)}x((Y=Y.apply(K,O||[])).next())})}const va=typeof Buffer=="function",bu=typeof TextDecoder=="function"?new TextDecoder:void 0;typeof TextEncoder=="function"&&new TextEncoder;const Jh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Gh=Array.prototype.slice.call(Jh),no=(K=>{let O={};return K.forEach((L,Y)=>O[L]=Y),O})(Gh),Yh=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,en=String.fromCharCode.bind(String),wu=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):K=>new Uint8Array(Array.prototype.slice.call(K,0)),Mu=K=>K.replace(/[^A-Za-z0-9\+\/]/g,""),Qh=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,tf=K=>{switch(K.length){case 4:var O=(7&K.charCodeAt(0))<<18|(63&K.charCodeAt(1))<<12|(63&K.charCodeAt(2))<<6|63&K.charCodeAt(3),L=O-65536;return en((L>>>10)+55296)+en((L&1023)+56320);case 3:return en((15&K.charCodeAt(0))<<12|(63&K.charCodeAt(1))<<6|63&K.charCodeAt(2));default:return en((31&K.charCodeAt(0))<<6|63&K.charCodeAt(1))}},ef=K=>K.replace(Qh,tf),xu=typeof atob=="function"?K=>atob(Mu(K)):va?K=>Buffer.from(K,"base64").toString("binary"):K=>{if(K=K.replace(/\s+/g,""),!Yh.test(K))throw new TypeError("malformed base64.");K+="==".slice(2-(K.length&3));let O,L="",Y,ut;for(let ht=0;ht<K.length;)O=no[K.charAt(ht++)]<<18|no[K.charAt(ht++)]<<12|(Y=no[K.charAt(ht++)])<<6|(ut=no[K.charAt(ht++)]),L+=Y===64?en(O>>16&255):ut===64?en(O>>16&255,O>>8&255):en(O>>16&255,O>>8&255,O&255);return L},rf=va?K=>wu(Buffer.from(K,"base64")):K=>wu(xu(K).split("").map(O=>O.charCodeAt(0))),nf=va?K=>Buffer.from(K,"base64").toString("utf8"):bu?K=>bu.decode(rf(K)):K=>ef(xu(K)),of=K=>Mu(K.replace(/[-_]/g,O=>O=="-"?"+":"/")),af=K=>nf(of(K)),oo=K=>JSON.parse(af(K.split(".")[1])),sf=K=>{const O=oo(K).exp;return new Date().valueOf()/1e3>=O},uf=K=>K==null?void 0:K.replace(/[\r\n]+/gm,""),cf=K=>K.replace(/\\|\\/g,"");var lf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _u(K){return K&&K.__esModule&&Object.prototype.hasOwnProperty.call(K,"default")?K.default:K}var ya={exports:{}},Su=function(O,L){return function(){for(var ut=new Array(arguments.length),ht=0;ht<ut.length;ht++)ut[ht]=arguments[ht];return O.apply(L,ut)}},hf=Su,rn=Object.prototype.toString;function ba(K){return rn.call(K)==="[object Array]"}function wa(K){return typeof K>"u"}function ff(K){return K!==null&&!wa(K)&&K.constructor!==null&&!wa(K.constructor)&&typeof K.constructor.isBuffer=="function"&&K.constructor.isBuffer(K)}function pf(K){return rn.call(K)==="[object ArrayBuffer]"}function df(K){return typeof FormData<"u"&&K instanceof FormData}function mf(K){var O;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?O=ArrayBuffer.isView(K):O=K&&K.buffer&&K.buffer instanceof ArrayBuffer,O}function gf(K){return typeof K=="string"}function vf(K){return typeof K=="number"}function Eu(K){return K!==null&&typeof K=="object"}function ao(K){if(rn.call(K)!=="[object Object]")return!1;var O=Object.getPrototypeOf(K);return O===null||O===Object.prototype}function yf(K){return rn.call(K)==="[object Date]"}function bf(K){return rn.call(K)==="[object File]"}function wf(K){return rn.call(K)==="[object Blob]"}function ku(K){return rn.call(K)==="[object Function]"}function Mf(K){return Eu(K)&&ku(K.pipe)}function xf(K){return typeof URLSearchParams<"u"&&K instanceof URLSearchParams}function _f(K){return K.trim?K.trim():K.replace(/^\s+|\s+$/g,"")}function Sf(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function Ma(K,O){if(!(K===null||typeof K>"u"))if(typeof K!="object"&&(K=[K]),ba(K))for(var L=0,Y=K.length;L<Y;L++)O.call(null,K[L],L,K);else for(var ut in K)Object.prototype.hasOwnProperty.call(K,ut)&&O.call(null,K[ut],ut,K)}function xa(){var K={};function O(ut,ht){ao(K[ht])&&ao(ut)?K[ht]=xa(K[ht],ut):ao(ut)?K[ht]=xa({},ut):ba(ut)?K[ht]=ut.slice():K[ht]=ut}for(var L=0,Y=arguments.length;L<Y;L++)Ma(arguments[L],O);return K}function Ef(K,O,L){return Ma(O,function(ut,ht){L&&typeof ut=="function"?K[ht]=hf(ut,L):K[ht]=ut}),K}function kf(K){return K.charCodeAt(0)===65279&&(K=K.slice(1)),K}var Qi={isArray:ba,isArrayBuffer:pf,isBuffer:ff,isFormData:df,isArrayBufferView:mf,isString:gf,isNumber:vf,isObject:Eu,isPlainObject:ao,isUndefined:wa,isDate:yf,isFile:bf,isBlob:wf,isFunction:ku,isStream:Mf,isURLSearchParams:xf,isStandardBrowserEnv:Sf,forEach:Ma,merge:xa,extend:Ef,trim:_f,stripBOM:kf},mn=Qi;function Iu(K){return encodeURIComponent(K).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Ou=function(O,L,Y){if(!L)return O;var ut;if(Y)ut=Y(L);else if(mn.isURLSearchParams(L))ut=L.toString();else{var ht=[];mn.forEach(L,function(y,x){y===null||typeof y>"u"||(mn.isArray(y)?x=x+"[]":y=[y],mn.forEach(y,function(m){mn.isDate(m)?m=m.toISOString():mn.isObject(m)&&(m=JSON.stringify(m)),ht.push(Iu(x)+"="+Iu(m))}))}),ut=ht.join("&")}if(ut){var W=O.indexOf("#");W!==-1&&(O=O.slice(0,W)),O+=(O.indexOf("?")===-1?"?":"&")+ut}return O},If=Qi;function so(){this.handlers=[]}so.prototype.use=function(O,L,Y){return this.handlers.push({fulfilled:O,rejected:L,synchronous:Y?Y.synchronous:!1,runWhen:Y?Y.runWhen:null}),this.handlers.length-1},so.prototype.eject=function(O){this.handlers[O]&&(this.handlers[O]=null)},so.prototype.forEach=function(O){If.forEach(this.handlers,function(Y){Y!==null&&O(Y)})};var Of=so,Af=Qi,Tf=function(O,L){Af.forEach(O,function(ut,ht){ht!==L&&ht.toUpperCase()===L.toUpperCase()&&(O[L]=ut,delete O[ht])})},Au=function(O,L,Y,ut,ht){return O.config=L,Y&&(O.code=Y),O.request=ut,O.response=ht,O.isAxiosError=!0,O.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:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},O},_a,Tu;function Bu(){if(Tu)return _a;Tu=1;var K=Au;return _a=function(L,Y,ut,ht,W){var _=new Error(L);return K(_,Y,ut,ht,W)},_a}var Sa,ju;function Bf(){if(ju)return Sa;ju=1;var K=Bu();return Sa=function(L,Y,ut){var ht=ut.config.validateStatus;!ut.status||!ht||ht(ut.status)?L(ut):Y(K("Request failed with status code "+ut.status,ut.config,null,ut.request,ut))},Sa}var Ea,Ru;function jf(){if(Ru)return Ea;Ru=1;var K=Qi;return Ea=K.isStandardBrowserEnv()?function(){return{write:function(Y,ut,ht,W,_,y){var x=[];x.push(Y+"="+encodeURIComponent(ut)),K.isNumber(ht)&&x.push("expires="+new Date(ht).toGMTString()),K.isString(W)&&x.push("path="+W),K.isString(_)&&x.push("domain="+_),y===!0&&x.push("secure"),document.cookie=x.join("; ")},read:function(Y){var ut=document.cookie.match(new RegExp("(^|;\\s*)("+Y+")=([^;]*)"));return ut?decodeURIComponent(ut[3]):null},remove:function(Y){this.write(Y,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),Ea}var ka,Nu;function Rf(){return Nu||(Nu=1,ka=function(O){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(O)}),ka}var Ia,Cu;function Nf(){return Cu||(Cu=1,Ia=function(O,L){return L?O.replace(/\/+$/,"")+"/"+L.replace(/^\/+/,""):O}),Ia}var Oa,Pu;function Cf(){if(Pu)return Oa;Pu=1;var K=Rf(),O=Nf();return Oa=function(Y,ut){return Y&&!K(ut)?O(Y,ut):ut},Oa}var Aa,Lu;function Pf(){if(Lu)return Aa;Lu=1;var K=Qi,O=["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"];return Aa=function(Y){var ut={},ht,W,_;return Y&&K.forEach(Y.split(`
15
- `),function(x){if(_=x.indexOf(":"),ht=K.trim(x.substr(0,_)).toLowerCase(),W=K.trim(x.substr(_+1)),ht){if(ut[ht]&&O.indexOf(ht)>=0)return;ht==="set-cookie"?ut[ht]=(ut[ht]?ut[ht]:[]).concat([W]):ut[ht]=ut[ht]?ut[ht]+", "+W:W}}),ut},Aa}var Ta,Du;function Lf(){if(Du)return Ta;Du=1;var K=Qi;return Ta=K.isStandardBrowserEnv()?function(){var L=/(msie|trident)/i.test(navigator.userAgent),Y=document.createElement("a"),ut;function ht(W){var _=W;return L&&(Y.setAttribute("href",_),_=Y.href),Y.setAttribute("href",_),{href:Y.href,protocol:Y.protocol?Y.protocol.replace(/:$/,""):"",host:Y.host,search:Y.search?Y.search.replace(/^\?/,""):"",hash:Y.hash?Y.hash.replace(/^#/,""):"",hostname:Y.hostname,port:Y.port,pathname:Y.pathname.charAt(0)==="/"?Y.pathname:"/"+Y.pathname}}return ut=ht(window.location.href),function(_){var y=K.isString(_)?ht(_):_;return y.protocol===ut.protocol&&y.host===ut.host}}():function(){return function(){return!0}}(),Ta}var Ba,Uu;function uo(){if(Uu)return Ba;Uu=1;function K(O){this.message=O}return K.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},K.prototype.__CANCEL__=!0,Ba=K,Ba}var ja,qu;function Fu(){if(qu)return ja;qu=1;var K=Qi,O=Bf(),L=jf(),Y=Ou,ut=Cf(),ht=Pf(),W=Lf(),_=Bu(),y=co(),x=uo();return ja=function(m){return new Promise(function(a,p){var c=m.data,l=m.headers,f=m.responseType,g;function h(){m.cancelToken&&m.cancelToken.unsubscribe(g),m.signal&&m.signal.removeEventListener("abort",g)}K.isFormData(c)&&delete l["Content-Type"];var u=new XMLHttpRequest;if(m.auth){var w=m.auth.username||"",b=m.auth.password?unescape(encodeURIComponent(m.auth.password)):"";l.Authorization="Basic "+btoa(w+":"+b)}var E=ut(m.baseURL,m.url);u.open(m.method.toUpperCase(),Y(E,m.params,m.paramsSerializer),!0),u.timeout=m.timeout;function I(){if(u){var B="getAllResponseHeaders"in u?ht(u.getAllResponseHeaders()):null,P=!f||f==="text"||f==="json"?u.responseText:u.response,N={data:P,status:u.status,statusText:u.statusText,headers:B,config:m,request:u};O(function(et){a(et),h()},function(et){p(et),h()},N),u=null}}if("onloadend"in u?u.onloadend=I:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(I)},u.onabort=function(){u&&(p(_("Request aborted",m,"ECONNABORTED",u)),u=null)},u.onerror=function(){p(_("Network Error",m,null,u)),u=null},u.ontimeout=function(){var P=m.timeout?"timeout of "+m.timeout+"ms exceeded":"timeout exceeded",N=m.transitional||y.transitional;m.timeoutErrorMessage&&(P=m.timeoutErrorMessage),p(_(P,m,N.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},K.isStandardBrowserEnv()){var M=(m.withCredentials||W(E))&&m.xsrfCookieName?L.read(m.xsrfCookieName):void 0;M&&(l[m.xsrfHeaderName]=M)}"setRequestHeader"in u&&K.forEach(l,function(P,N){typeof c>"u"&&N.toLowerCase()==="content-type"?delete l[N]:u.setRequestHeader(N,P)}),K.isUndefined(m.withCredentials)||(u.withCredentials=!!m.withCredentials),f&&f!=="json"&&(u.responseType=m.responseType),typeof m.onDownloadProgress=="function"&&u.addEventListener("progress",m.onDownloadProgress),typeof m.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",m.onUploadProgress),(m.cancelToken||m.signal)&&(g=function(B){u&&(p(!B||B&&B.type?new x("canceled"):B),u.abort(),u=null)},m.cancelToken&&m.cancelToken.subscribe(g),m.signal&&(m.signal.aborted?g():m.signal.addEventListener("abort",g))),c||(c=null),u.send(c)})},ja}var Ra,zu;function co(){if(zu)return Ra;zu=1;var K=Qi,O=Tf,L=Au,Y={"Content-Type":"application/x-www-form-urlencoded"};function ut(y,x){!K.isUndefined(y)&&K.isUndefined(y["Content-Type"])&&(y["Content-Type"]=x)}function ht(){var y;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(y=Fu()),y}function W(y,x,v){if(K.isString(y))try{return(x||JSON.parse)(y),K.trim(y)}catch(m){if(m.name!=="SyntaxError")throw m}return(v||JSON.stringify)(y)}var _={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:ht(),transformRequest:[function(x,v){return O(v,"Accept"),O(v,"Content-Type"),K.isFormData(x)||K.isArrayBuffer(x)||K.isBuffer(x)||K.isStream(x)||K.isFile(x)||K.isBlob(x)?x:K.isArrayBufferView(x)?x.buffer:K.isURLSearchParams(x)?(ut(v,"application/x-www-form-urlencoded;charset=utf-8"),x.toString()):K.isObject(x)||v&&v["Content-Type"]==="application/json"?(ut(v,"application/json"),W(x)):x}],transformResponse:[function(x){var v=this.transitional||_.transitional,m=v&&v.silentJSONParsing,S=v&&v.forcedJSONParsing,a=!m&&this.responseType==="json";if(a||S&&K.isString(x)&&x.length)try{return JSON.parse(x)}catch(p){if(a)throw p.name==="SyntaxError"?L(p,this,"E_JSON_PARSE"):p}return x}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(x){return x>=200&&x<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};return K.forEach(["delete","get","head"],function(x){_.headers[x]={}}),K.forEach(["post","put","patch"],function(x){_.headers[x]=K.merge(Y)}),Ra=_,Ra}var Df=Qi,Uf=co(),qf=function(O,L,Y){var ut=this||Uf;return Df.forEach(Y,function(W){O=W.call(ut,O,L)}),O},Na,$u;function Hu(){return $u||($u=1,Na=function(O){return!!(O&&O.__CANCEL__)}),Na}var Wu=Qi,Ca=qf,Ff=Hu(),zf=co(),$f=uo();function Pa(K){if(K.cancelToken&&K.cancelToken.throwIfRequested(),K.signal&&K.signal.aborted)throw new $f("canceled")}var Hf=function(O){Pa(O),O.headers=O.headers||{},O.data=Ca.call(O,O.data,O.headers,O.transformRequest),O.headers=Wu.merge(O.headers.common||{},O.headers[O.method]||{},O.headers),Wu.forEach(["delete","get","head","post","put","patch","common"],function(ut){delete O.headers[ut]});var L=O.adapter||zf.adapter;return L(O).then(function(ut){return Pa(O),ut.data=Ca.call(O,ut.data,ut.headers,O.transformResponse),ut},function(ut){return Ff(ut)||(Pa(O),ut&&ut.response&&(ut.response.data=Ca.call(O,ut.response.data,ut.response.headers,O.transformResponse))),Promise.reject(ut)})},tr=Qi,Vu=function(O,L){L=L||{};var Y={};function ut(v,m){return tr.isPlainObject(v)&&tr.isPlainObject(m)?tr.merge(v,m):tr.isPlainObject(m)?tr.merge({},m):tr.isArray(m)?m.slice():m}function ht(v){if(tr.isUndefined(L[v])){if(!tr.isUndefined(O[v]))return ut(void 0,O[v])}else return ut(O[v],L[v])}function W(v){if(!tr.isUndefined(L[v]))return ut(void 0,L[v])}function _(v){if(tr.isUndefined(L[v])){if(!tr.isUndefined(O[v]))return ut(void 0,O[v])}else return ut(void 0,L[v])}function y(v){if(v in L)return ut(O[v],L[v]);if(v in O)return ut(void 0,O[v])}var x={url:W,method:W,data:W,baseURL:_,transformRequest:_,transformResponse:_,paramsSerializer:_,timeout:_,timeoutMessage:_,withCredentials:_,adapter:_,responseType:_,xsrfCookieName:_,xsrfHeaderName:_,onUploadProgress:_,onDownloadProgress:_,decompress:_,maxContentLength:_,maxBodyLength:_,transport:_,httpAgent:_,httpsAgent:_,cancelToken:_,socketPath:_,responseEncoding:_,validateStatus:y};return tr.forEach(Object.keys(O).concat(Object.keys(L)),function(m){var S=x[m]||ht,a=S(m);tr.isUndefined(a)&&S!==y||(Y[m]=a)}),Y},La,Xu;function Zu(){return Xu||(Xu=1,La={version:"0.24.0"}),La}var Wf=Zu().version,Da={};["object","boolean","number","function","string","symbol"].forEach(function(K,O){Da[K]=function(Y){return typeof Y===K||"a"+(O<1?"n ":" ")+K}});var Ku={};Da.transitional=function(O,L,Y){function ut(ht,W){return"[Axios v"+Wf+"] Transitional option '"+ht+"'"+W+(Y?". "+Y:"")}return function(ht,W,_){if(O===!1)throw new Error(ut(W," has been removed"+(L?" in "+L:"")));return L&&!Ku[W]&&(Ku[W]=!0,console.warn(ut(W," has been deprecated since v"+L+" and will be removed in the near future"))),O?O(ht,W,_):!0}};function Vf(K,O,L){if(typeof K!="object")throw new TypeError("options must be an object");for(var Y=Object.keys(K),ut=Y.length;ut-- >0;){var ht=Y[ut],W=O[ht];if(W){var _=K[ht],y=_===void 0||W(_,ht,K);if(y!==!0)throw new TypeError("option "+ht+" must be "+y);continue}if(L!==!0)throw Error("Unknown option "+ht)}}var Xf={assertOptions:Vf,validators:Da},Ju=Qi,Zf=Ou,Gu=Of,Yu=Hf,lo=Vu,Qu=Xf,gn=Qu.validators;function Nn(K){this.defaults=K,this.interceptors={request:new Gu,response:new Gu}}Nn.prototype.request=function(O){typeof O=="string"?(O=arguments[1]||{},O.url=arguments[0]):O=O||{},O=lo(this.defaults,O),O.method?O.method=O.method.toLowerCase():this.defaults.method?O.method=this.defaults.method.toLowerCase():O.method="get";var L=O.transitional;L!==void 0&&Qu.assertOptions(L,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1);var Y=[],ut=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(O)===!1||(ut=ut&&S.synchronous,Y.unshift(S.fulfilled,S.rejected))});var ht=[];this.interceptors.response.forEach(function(S){ht.push(S.fulfilled,S.rejected)});var W;if(!ut){var _=[Yu,void 0];for(Array.prototype.unshift.apply(_,Y),_=_.concat(ht),W=Promise.resolve(O);_.length;)W=W.then(_.shift(),_.shift());return W}for(var y=O;Y.length;){var x=Y.shift(),v=Y.shift();try{y=x(y)}catch(m){v(m);break}}try{W=Yu(y)}catch(m){return Promise.reject(m)}for(;ht.length;)W=W.then(ht.shift(),ht.shift());return W},Nn.prototype.getUri=function(O){return O=lo(this.defaults,O),Zf(O.url,O.params,O.paramsSerializer).replace(/^\?/,"")},Ju.forEach(["delete","get","head","options"],function(O){Nn.prototype[O]=function(L,Y){return this.request(lo(Y||{},{method:O,url:L,data:(Y||{}).data}))}}),Ju.forEach(["post","put","patch"],function(O){Nn.prototype[O]=function(L,Y,ut){return this.request(lo(ut||{},{method:O,url:L,data:Y}))}});var Kf=Nn,Ua,tc;function Jf(){if(tc)return Ua;tc=1;var K=uo();function O(L){if(typeof L!="function")throw new TypeError("executor must be a function.");var Y;this.promise=new Promise(function(W){Y=W});var ut=this;this.promise.then(function(ht){if(ut._listeners){var W,_=ut._listeners.length;for(W=0;W<_;W++)ut._listeners[W](ht);ut._listeners=null}}),this.promise.then=function(ht){var W,_=new Promise(function(y){ut.subscribe(y),W=y}).then(ht);return _.cancel=function(){ut.unsubscribe(W)},_},L(function(W){ut.reason||(ut.reason=new K(W),Y(ut.reason))})}return O.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},O.prototype.subscribe=function(Y){if(this.reason){Y(this.reason);return}this._listeners?this._listeners.push(Y):this._listeners=[Y]},O.prototype.unsubscribe=function(Y){if(this._listeners){var ut=this._listeners.indexOf(Y);ut!==-1&&this._listeners.splice(ut,1)}},O.source=function(){var Y,ut=new O(function(W){Y=W});return{token:ut,cancel:Y}},Ua=O,Ua}var qa,ec;function Gf(){return ec||(ec=1,qa=function(O){return function(Y){return O.apply(null,Y)}}),qa}var Fa,ic;function Yf(){return ic||(ic=1,Fa=function(O){return typeof O=="object"&&O.isAxiosError===!0}),Fa}var rc=Qi,Qf=Su,ho=Kf,tp=Vu,ep=co();function nc(K){var O=new ho(K),L=Qf(ho.prototype.request,O);return rc.extend(L,ho.prototype,O),rc.extend(L,O),L.create=function(ut){return nc(tp(K,ut))},L}var Sr=nc(ep);Sr.Axios=ho,Sr.Cancel=uo(),Sr.CancelToken=Jf(),Sr.isCancel=Hu(),Sr.VERSION=Zu().version,Sr.all=function(O){return Promise.all(O)},Sr.spread=Gf(),Sr.isAxiosError=Yf(),ya.exports=Sr,ya.exports.default=Sr;var ip=ya.exports,rp=ip;const oc=_u(rp);var np=Object.defineProperty,ac=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,sc=(K,O,L)=>O in K?np(K,O,{enumerable:!0,configurable:!0,writable:!0,value:L}):K[O]=L,za=(K,O)=>{for(var L in O||(O={}))op.call(O,L)&&sc(K,L,O[L]);if(ac)for(var L of ac(O))ap.call(O,L)&&sc(K,L,O[L]);return K},ar=(K,O,L)=>new Promise((Y,ut)=>{var ht=y=>{try{_(L.next(y))}catch(x){ut(x)}},W=y=>{try{_(L.throw(y))}catch(x){ut(x)}},_=y=>y.done?Y(y.value):Promise.resolve(y.value).then(ht,W);_((L=L.apply(K,O)).next())});class sp{constructor(O,L){this.axios=O,this.errorHandler=L}get(O,L,Y){return ar(this,null,function*(){const ut=this.axios.get(O,{params:L});return this.handleResponse(ut,Y)})}listPaged(O,L){return ar(this,null,function*(){const Y=this.axios.get(O,{params:L});return this.handleResponse(Y)})}list(O,L){return ar(this,null,function*(){const Y=this.axios.get(O,{params:L});return this.handleResponse(Y)})}delete(O,L){return ar(this,null,function*(){const Y=this.axios.delete(O,{params:L});return this.handleResponse(Y)})}post(O,L,Y,ut){return ar(this,null,function*(){const ht=this.axios.post(O,L,za({params:Y},ut));return this.handleResponse(ht)})}postForm(O,L,Y){return ar(this,null,function*(){const ut=this.axios.post(O,L,{params:Y,headers:{"Content-Type":"multipart/form-data"}});return this.handleResponse(ut)})}patch(O,L,Y){return ar(this,null,function*(){const ut=this.axios.patch(O,L,{params:Y});return this.handleResponse(ut)})}put(O,L){return ar(this,null,function*(){const Y=this.axios.put(O,L);return this.handleResponse(Y)})}upload(O,L,Y){return ar(this,null,function*(){const ut=this.axios.post(O,L,za({},Y));return this.handleResponse(ut)})}getNonStandard(O,L){return ar(this,null,function*(){const Y=this.axios.get(O,L);try{const ut=yield Y;if(ut.status===200)return ut}catch(ut){throw this.handleError(ut)}})}postNonStandard(O,L,Y,ut){return ar(this,null,function*(){var ht,W;const _=yield this.axios.post(O,L,za({params:Y},ut));if(_.status===200)if((ht=_.data)!=null&&ht.code)(W=this.errorHandler)!=null&&W.onAppStatusError&&this.errorHandler.onAppStatusError(_.data.code,_.data.message);else return _.data})}handleResponse(O,L){return ar(this,null,function*(){try{const Y=yield O;return this.handleAppError(Y.data,L).data}catch(Y){throw this.handleError(Y)}})}handleAppError(O,L){var Y;if(O.code<200||O.code>=300)throw(Y=this.errorHandler)!=null&&Y.onAppStatusError?this.errorHandler.onAppStatusError(O.code,cp(O.code,O.message),L):console.error("未处理应用错误:",O),{isAxiosError:!1,message:O.message};return O}handleError(O){var L,Y;return O.response?(console.log(O.response.data),console.log(O.response.status),console.log(O.response.headers),(L=this.errorHandler)!=null&&L.onHttpStatusError&&(console.log("HTTP 错误",this.errorHandler),this.errorHandler.onHttpStatusError(O.response.status,"",O.response))):O.request?(console.log(O.request),(Y=this.errorHandler)!=null&&Y.onNetworkError&&this.errorHandler.onNetworkError()):console.error("axios request config error:",O),new Error(O.message)}}const up=K=>K>=10002&&K<=10012,cp=(K,O)=>up(K)?"数据操作错误":O||"未知接口错误";var lp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},uc={exports:{}},$a=(K,O)=>{if(O=Symbol[K])return O;throw Error("Symbol."+K+" is not defined")},vn=Math.pow,Ha=(K,O,L)=>new Promise((Y,ut)=>{var ht=y=>{try{_(L.next(y))}catch(x){ut(x)}},W=y=>{try{_(L.throw(y))}catch(x){ut(x)}},_=y=>y.done?Y(y.value):Promise.resolve(y.value).then(ht,W);_((L=L.apply(K,O)).next())}),hp=function(K,O){this[0]=K,this[1]=O},fp=K=>{var O=K[$a("asyncIterator")],L=!1,Y,ut={};return O==null?(O=K[$a("iterator")](),Y=ht=>ut[ht]=W=>O[ht](W)):(O=O.call(K),Y=ht=>ut[ht]=W=>{if(L){if(L=!1,ht==="throw")throw W;return W}return L=!0,{done:!1,value:new hp(new Promise(_=>{var y=O[ht](W);if(!(y instanceof Object))throw TypeError("Object expected");_(y)}),1)}}),ut[$a("iterator")]=()=>ut,Y("next"),"throw"in O?Y("throw"):ut.throw=ht=>{throw ht},"return"in O&&Y("return"),ut};/*! For license information please see minio-zj.js.LICENSE.txt */(function(K,O){(function(L,Y){K.exports=Y()})(lp,()=>(()=>{var L={9809:(W,_,y)=>{const x=_;x.bignum=y(4590),x.define=y(2500).define,x.base=y(1979),x.constants=y(6826),x.decoders=y(8307),x.encoders=y(6579)},2500:(W,_,y)=>{const x=y(6579),v=y(8307),m=y(5717);function S(a,p){this.name=a,this.body=p,this.decoders={},this.encoders={}}_.define=function(a,p){return new S(a,p)},S.prototype._createNamed=function(a){const p=this.name;function c(l){this._initNamed(l,p)}return m(c,a),c.prototype._initNamed=function(l,f){a.call(this,l,f)},new c(this)},S.prototype._getDecoder=function(a){return a=a||"der",this.decoders.hasOwnProperty(a)||(this.decoders[a]=this._createNamed(v[a])),this.decoders[a]},S.prototype.decode=function(a,p,c){return this._getDecoder(p).decode(a,c)},S.prototype._getEncoder=function(a){return a=a||"der",this.encoders.hasOwnProperty(a)||(this.encoders[a]=this._createNamed(x[a])),this.encoders[a]},S.prototype.encode=function(a,p,c){return this._getEncoder(p).encode(a,c)}},6625:(W,_,y)=>{const x=y(5717),v=y(8465).b,m=y(2399).Buffer;function S(p,c){v.call(this,c),m.isBuffer(p)?(this.base=p,this.offset=0,this.length=p.length):this.error("Input not Buffer")}function a(p,c){if(Array.isArray(p))this.length=0,this.value=p.map(function(l){return a.isEncoderBuffer(l)||(l=new a(l,c)),this.length+=l.length,l},this);else if(typeof p=="number"){if(!(0<=p&&p<=255))return c.error("non-byte EncoderBuffer value");this.value=p,this.length=1}else if(typeof p=="string")this.value=p,this.length=m.byteLength(p);else{if(!m.isBuffer(p))return c.error("Unsupported type: "+typeof p);this.value=p,this.length=p.length}}x(S,v),_.C=S,S.isDecoderBuffer=function(p){return p instanceof S||typeof p=="object"&&m.isBuffer(p.base)&&p.constructor.name==="DecoderBuffer"&&typeof p.offset=="number"&&typeof p.length=="number"&&typeof p.save=="function"&&typeof p.restore=="function"&&typeof p.isEmpty=="function"&&typeof p.readUInt8=="function"&&typeof p.skip=="function"&&typeof p.raw=="function"},S.prototype.save=function(){return{offset:this.offset,reporter:v.prototype.save.call(this)}},S.prototype.restore=function(p){const c=new S(this.base);return c.offset=p.offset,c.length=this.offset,this.offset=p.offset,v.prototype.restore.call(this,p.reporter),c},S.prototype.isEmpty=function(){return this.offset===this.length},S.prototype.readUInt8=function(p){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(p||"DecoderBuffer overrun")},S.prototype.skip=function(p,c){if(!(this.offset+p<=this.length))return this.error(c||"DecoderBuffer overrun");const l=new S(this.base);return l._reporterState=this._reporterState,l.offset=this.offset,l.length=this.offset+p,this.offset+=p,l},S.prototype.raw=function(p){return this.base.slice(p?p.offset:this.offset,this.length)},_.R=a,a.isEncoderBuffer=function(p){return p instanceof a||typeof p=="object"&&p.constructor.name==="EncoderBuffer"&&typeof p.length=="number"&&typeof p.join=="function"},a.prototype.join=function(p,c){return p||(p=m.alloc(this.length)),c||(c=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(l){l.join(p,c),c+=l.length}):(typeof this.value=="number"?p[c]=this.value:typeof this.value=="string"?p.write(this.value,c):m.isBuffer(this.value)&&this.value.copy(p,c),c+=this.length)),p}},1979:(W,_,y)=>{const x=_;x.Reporter=y(8465).b,x.DecoderBuffer=y(6625).C,x.EncoderBuffer=y(6625).R,x.Node=y(1949)},1949:(W,_,y)=>{const x=y(8465).b,v=y(6625).R,m=y(6625).C,S=y(9746),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],p=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function c(f,g,h){const u={};this._baseState=u,u.name=h,u.enc=f,u.parent=g||null,u.children=null,u.tag=null,u.args=null,u.reverseArgs=null,u.choice=null,u.optional=!1,u.any=!1,u.obj=!1,u.use=null,u.useDecoder=null,u.key=null,u.default=null,u.explicit=null,u.implicit=null,u.contains=null,u.parent||(u.children=[],this._wrap())}W.exports=c;const l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){const f=this._baseState,g={};l.forEach(function(u){g[u]=f[u]});const h=new this.constructor(g.parent);return h._baseState=g,h},c.prototype._wrap=function(){const f=this._baseState;p.forEach(function(g){this[g]=function(){const h=new this.constructor(this);return f.children.push(h),h[g].apply(h,arguments)}},this)},c.prototype._init=function(f){const g=this._baseState;S(g.parent===null),f.call(this),g.children=g.children.filter(function(h){return h._baseState.parent===this},this),S.equal(g.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(f){const g=this._baseState,h=f.filter(function(u){return u instanceof this.constructor},this);f=f.filter(function(u){return!(u instanceof this.constructor)},this),h.length!==0&&(S(g.children===null),g.children=h,h.forEach(function(u){u._baseState.parent=this},this)),f.length!==0&&(S(g.args===null),g.args=f,g.reverseArgs=f.map(function(u){if(typeof u!="object"||u.constructor!==Object)return u;const w={};return Object.keys(u).forEach(function(b){b==(0|b)&&(b|=0);const E=u[b];w[E]=b}),w}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(f){c.prototype[f]=function(){const g=this._baseState;throw new Error(f+" not implemented for encoding: "+g.enc)}}),a.forEach(function(f){c.prototype[f]=function(){const g=this._baseState,h=Array.prototype.slice.call(arguments);return S(g.tag===null),g.tag=f,this._useArgs(h),this}}),c.prototype.use=function(f){S(f);const g=this._baseState;return S(g.use===null),g.use=f,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(f){const g=this._baseState;return S(g.default===null),g.default=f,g.optional=!0,this},c.prototype.explicit=function(f){const g=this._baseState;return S(g.explicit===null&&g.implicit===null),g.explicit=f,this},c.prototype.implicit=function(f){const g=this._baseState;return S(g.explicit===null&&g.implicit===null),g.implicit=f,this},c.prototype.obj=function(){const f=this._baseState,g=Array.prototype.slice.call(arguments);return f.obj=!0,g.length!==0&&this._useArgs(g),this},c.prototype.key=function(f){const g=this._baseState;return S(g.key===null),g.key=f,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(f){const g=this._baseState;return S(g.choice===null),g.choice=f,this._useArgs(Object.keys(f).map(function(h){return f[h]})),this},c.prototype.contains=function(f){const g=this._baseState;return S(g.use===null),g.contains=f,this},c.prototype._decode=function(f,g){const h=this._baseState;if(h.parent===null)return f.wrapResult(h.children[0]._decode(f,g));let u,w=h.default,b=!0,E=null;if(h.key!==null&&(E=f.enterKey(h.key)),h.optional){let I=null;if(h.explicit!==null?I=h.explicit:h.implicit!==null?I=h.implicit:h.tag!==null&&(I=h.tag),I!==null||h.any){if(b=this._peekTag(f,I,h.any),f.isError(b))return b}else{const M=f.save();try{h.choice===null?this._decodeGeneric(h.tag,f,g):this._decodeChoice(f,g),b=!0}catch{b=!1}f.restore(M)}}if(h.obj&&b&&(u=f.enterObject()),b){if(h.explicit!==null){const M=this._decodeTag(f,h.explicit);if(f.isError(M))return M;f=M}const I=f.offset;if(h.use===null&&h.choice===null){let M;h.any&&(M=f.save());const B=this._decodeTag(f,h.implicit!==null?h.implicit:h.tag,h.any);if(f.isError(B))return B;h.any?w=f.raw(M):f=B}if(g&&g.track&&h.tag!==null&&g.track(f.path(),I,f.length,"tagged"),g&&g.track&&h.tag!==null&&g.track(f.path(),f.offset,f.length,"content"),h.any||(w=h.choice===null?this._decodeGeneric(h.tag,f,g):this._decodeChoice(f,g)),f.isError(w))return w;if(h.any||h.choice!==null||h.children===null||h.children.forEach(function(M){M._decode(f,g)}),h.contains&&(h.tag==="octstr"||h.tag==="bitstr")){const M=new m(w);w=this._getUse(h.contains,f._reporterState.obj)._decode(M,g)}}return h.obj&&b&&(w=f.leaveObject(u)),h.key===null||w===null&&b!==!0?E!==null&&f.exitKey(E):f.leaveKey(E,h.key,w),w},c.prototype._decodeGeneric=function(f,g,h){const u=this._baseState;return f==="seq"||f==="set"?null:f==="seqof"||f==="setof"?this._decodeList(g,f,u.args[0],h):/str$/.test(f)?this._decodeStr(g,f,h):f==="objid"&&u.args?this._decodeObjid(g,u.args[0],u.args[1],h):f==="objid"?this._decodeObjid(g,null,null,h):f==="gentime"||f==="utctime"?this._decodeTime(g,f,h):f==="null_"?this._decodeNull(g,h):f==="bool"?this._decodeBool(g,h):f==="objDesc"?this._decodeStr(g,f,h):f==="int"||f==="enum"?this._decodeInt(g,u.args&&u.args[0],h):u.use!==null?this._getUse(u.use,g._reporterState.obj)._decode(g,h):g.error("unknown tag: "+f)},c.prototype._getUse=function(f,g){const h=this._baseState;return h.useDecoder=this._use(f,g),S(h.useDecoder._baseState.parent===null),h.useDecoder=h.useDecoder._baseState.children[0],h.implicit!==h.useDecoder._baseState.implicit&&(h.useDecoder=h.useDecoder.clone(),h.useDecoder._baseState.implicit=h.implicit),h.useDecoder},c.prototype._decodeChoice=function(f,g){const h=this._baseState;let u=null,w=!1;return Object.keys(h.choice).some(function(b){const E=f.save(),I=h.choice[b];try{const M=I._decode(f,g);if(f.isError(M))return!1;u={type:b,value:M},w=!0}catch{return f.restore(E),!1}return!0},this),w?u:f.error("Choice not matched")},c.prototype._createEncoderBuffer=function(f){return new v(f,this.reporter)},c.prototype._encode=function(f,g,h){const u=this._baseState;if(u.default!==null&&u.default===f)return;const w=this._encodeValue(f,g,h);return w===void 0||this._skipDefault(w,g,h)?void 0:w},c.prototype._encodeValue=function(f,g,h){const u=this._baseState;if(u.parent===null)return u.children[0]._encode(f,g||new x);let w=null;if(this.reporter=g,u.optional&&f===void 0){if(u.default===null)return;f=u.default}let b=null,E=!1;if(u.any)w=this._createEncoderBuffer(f);else if(u.choice)w=this._encodeChoice(f,g);else if(u.contains)b=this._getUse(u.contains,h)._encode(f,g),E=!0;else if(u.children)b=u.children.map(function(I){if(I._baseState.tag==="null_")return I._encode(null,g,f);if(I._baseState.key===null)return g.error("Child should have a key");const M=g.enterKey(I._baseState.key);if(typeof f!="object")return g.error("Child expected, but input is not object");const B=I._encode(f[I._baseState.key],g,f);return g.leaveKey(M),B},this).filter(function(I){return I}),b=this._createEncoderBuffer(b);else if(u.tag==="seqof"||u.tag==="setof"){if(!u.args||u.args.length!==1)return g.error("Too many args for : "+u.tag);if(!Array.isArray(f))return g.error("seqof/setof, but data is not Array");const I=this.clone();I._baseState.implicit=null,b=this._createEncoderBuffer(f.map(function(M){const B=this._baseState;return this._getUse(B.args[0],f)._encode(M,g)},I))}else u.use!==null?w=this._getUse(u.use,h)._encode(f,g):(b=this._encodePrimitive(u.tag,f),E=!0);if(!u.any&&u.choice===null){const I=u.implicit!==null?u.implicit:u.tag,M=u.implicit===null?"universal":"context";I===null?u.use===null&&g.error("Tag could be omitted only for .use()"):u.use===null&&(w=this._encodeComposite(I,E,M,b))}return u.explicit!==null&&(w=this._encodeComposite(u.explicit,!1,"context",w)),w},c.prototype._encodeChoice=function(f,g){const h=this._baseState,u=h.choice[f.type];return u||S(!1,f.type+" not found in "+JSON.stringify(Object.keys(h.choice))),u._encode(f.value,g)},c.prototype._encodePrimitive=function(f,g){const h=this._baseState;if(/str$/.test(f))return this._encodeStr(g,f);if(f==="objid"&&h.args)return this._encodeObjid(g,h.reverseArgs[0],h.args[1]);if(f==="objid")return this._encodeObjid(g,null,null);if(f==="gentime"||f==="utctime")return this._encodeTime(g,f);if(f==="null_")return this._encodeNull();if(f==="int"||f==="enum")return this._encodeInt(g,h.args&&h.reverseArgs[0]);if(f==="bool")return this._encodeBool(g);if(f==="objDesc")return this._encodeStr(g,f);throw new Error("Unsupported tag: "+f)},c.prototype._isNumstr=function(f){return/^[0-9 ]*$/.test(f)},c.prototype._isPrintstr=function(f){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(f)}},8465:(W,_,y)=>{const x=y(5717);function v(S){this._reporterState={obj:null,path:[],options:S||{},errors:[]}}function m(S,a){this.path=S,this.rethrow(a)}_.b=v,v.prototype.isError=function(S){return S instanceof m},v.prototype.save=function(){const S=this._reporterState;return{obj:S.obj,pathLen:S.path.length}},v.prototype.restore=function(S){const a=this._reporterState;a.obj=S.obj,a.path=a.path.slice(0,S.pathLen)},v.prototype.enterKey=function(S){return this._reporterState.path.push(S)},v.prototype.exitKey=function(S){const a=this._reporterState;a.path=a.path.slice(0,S-1)},v.prototype.leaveKey=function(S,a,p){const c=this._reporterState;this.exitKey(S),c.obj!==null&&(c.obj[a]=p)},v.prototype.path=function(){return this._reporterState.path.join("/")},v.prototype.enterObject=function(){const S=this._reporterState,a=S.obj;return S.obj={},a},v.prototype.leaveObject=function(S){const a=this._reporterState,p=a.obj;return a.obj=S,p},v.prototype.error=function(S){let a;const p=this._reporterState,c=S instanceof m;if(a=c?S:new m(p.path.map(function(l){return"["+JSON.stringify(l)+"]"}).join(""),S.message||S,S.stack),!p.options.partial)throw a;return c||p.errors.push(a),a},v.prototype.wrapResult=function(S){const a=this._reporterState;return a.options.partial?{result:this.isError(S)?null:S,errors:a.errors}:S},x(m,Error),m.prototype.rethrow=function(S){if(this.message=S+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,m),!this.stack)try{throw new Error(this.message)}catch(a){this.stack=a.stack}return this}},160:(W,_)=>{function y(x){const v={};return Object.keys(x).forEach(function(m){(0|m)==m&&(m|=0);const S=x[m];v[S]=m}),v}_.tagClass={0:"universal",1:"application",2:"context",3:"private"},_.tagClassByName=y(_.tagClass),_.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},_.tagByName=y(_.tag)},6826:(W,_,y)=>{const x=_;x._reverse=function(v){const m={};return Object.keys(v).forEach(function(S){(0|S)==S&&(S|=0);const a=v[S];m[a]=S}),m},x.der=y(160)},1671:(W,_,y)=>{const x=y(5717),v=y(4590),m=y(6625).C,S=y(1949),a=y(160);function p(g){this.enc="der",this.name=g.name,this.entity=g,this.tree=new c,this.tree._init(g.body)}function c(g){S.call(this,"der",g)}function l(g,h){let u=g.readUInt8(h);if(g.isError(u))return u;const w=a.tagClass[u>>6],b=(32&u)==0;if((31&u)==31){let E=u;for(u=0;(128&E)==128;){if(E=g.readUInt8(h),g.isError(E))return E;u<<=7,u|=127&E}}else u&=31;return{cls:w,primitive:b,tag:u,tagStr:a.tag[u]}}function f(g,h,u){let w=g.readUInt8(u);if(g.isError(w))return w;if(!h&&w===128)return null;if(!(128&w))return w;const b=127&w;if(b>4)return g.error("length octect is too long");w=0;for(let E=0;E<b;E++){w<<=8;const I=g.readUInt8(u);if(g.isError(I))return I;w|=I}return w}W.exports=p,p.prototype.decode=function(g,h){return m.isDecoderBuffer(g)||(g=new m(g,h)),this.tree._decode(g,h)},x(c,S),c.prototype._peekTag=function(g,h,u){if(g.isEmpty())return!1;const w=g.save(),b=l(g,'Failed to peek tag: "'+h+'"');return g.isError(b)?b:(g.restore(w),b.tag===h||b.tagStr===h||b.tagStr+"of"===h||u)},c.prototype._decodeTag=function(g,h,u){const w=l(g,'Failed to decode tag of "'+h+'"');if(g.isError(w))return w;let b=f(g,w.primitive,'Failed to get length of "'+h+'"');if(g.isError(b))return b;if(!u&&w.tag!==h&&w.tagStr!==h&&w.tagStr+"of"!==h)return g.error('Failed to match tag: "'+h+'"');if(w.primitive||b!==null)return g.skip(b,'Failed to match body of: "'+h+'"');const E=g.save(),I=this._skipUntilEnd(g,'Failed to skip indefinite length body: "'+this.tag+'"');return g.isError(I)?I:(b=g.offset-E.offset,g.restore(E),g.skip(b,'Failed to match body of: "'+h+'"'))},c.prototype._skipUntilEnd=function(g,h){for(;;){const u=l(g,h);if(g.isError(u))return u;const w=f(g,u.primitive,h);if(g.isError(w))return w;let b;if(b=u.primitive||w!==null?g.skip(w):this._skipUntilEnd(g,h),g.isError(b))return b;if(u.tagStr==="end")break}},c.prototype._decodeList=function(g,h,u,w){const b=[];for(;!g.isEmpty();){const E=this._peekTag(g,"end");if(g.isError(E))return E;const I=u.decode(g,"der",w);if(g.isError(I)&&E)break;b.push(I)}return b},c.prototype._decodeStr=function(g,h){if(h==="bitstr"){const u=g.readUInt8();return g.isError(u)?u:{unused:u,data:g.raw()}}if(h==="bmpstr"){const u=g.raw();if(u.length%2==1)return g.error("Decoding of string type: bmpstr length mismatch");let w="";for(let b=0;b<u.length/2;b++)w+=String.fromCharCode(u.readUInt16BE(2*b));return w}if(h==="numstr"){const u=g.raw().toString("ascii");return this._isNumstr(u)?u:g.error("Decoding of string type: numstr unsupported characters")}if(h==="octstr"||h==="objDesc")return g.raw();if(h==="printstr"){const u=g.raw().toString("ascii");return this._isPrintstr(u)?u:g.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(h)?g.raw().toString():g.error("Decoding of string type: "+h+" unsupported")},c.prototype._decodeObjid=function(g,h,u){let w;const b=[];let E=0,I=0;for(;!g.isEmpty();)I=g.readUInt8(),E<<=7,E|=127&I,!(128&I)&&(b.push(E),E=0);128&I&&b.push(E);const M=b[0]/40|0,B=b[0]%40;if(w=u?b:[M,B].concat(b.slice(1)),h){let P=h[w.join(" ")];P===void 0&&(P=h[w.join(".")]),P!==void 0&&(w=P)}return w},c.prototype._decodeTime=function(g,h){const u=g.raw().toString();let w,b,E,I,M,B;if(h==="gentime")w=0|u.slice(0,4),b=0|u.slice(4,6),E=0|u.slice(6,8),I=0|u.slice(8,10),M=0|u.slice(10,12),B=0|u.slice(12,14);else{if(h!=="utctime")return g.error("Decoding "+h+" time is not supported yet");w=0|u.slice(0,2),b=0|u.slice(2,4),E=0|u.slice(4,6),I=0|u.slice(6,8),M=0|u.slice(8,10),B=0|u.slice(10,12),w=w<70?2e3+w:1900+w}return Date.UTC(w,b-1,E,I,M,B,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(g){const h=g.readUInt8();return g.isError(h)?h:h!==0},c.prototype._decodeInt=function(g,h){const u=g.raw();let w=new v(u);return h&&(w=h[w.toString(10)]||w),w},c.prototype._use=function(g,h){return typeof g=="function"&&(g=g(h)),g._getDecoder("der").tree}},8307:(W,_,y)=>{const x=_;x.der=y(1671),x.pem=y(9631)},9631:(W,_,y)=>{const x=y(5717),v=y(2399).Buffer,m=y(1671);function S(a){m.call(this,a),this.enc="pem"}x(S,m),W.exports=S,S.prototype.decode=function(a,p){const c=a.toString().split(/[\r\n]+/g),l=p.label.toUpperCase(),f=/^-----(BEGIN|END) ([^-]+)-----$/;let g=-1,h=-1;for(let b=0;b<c.length;b++){const E=c[b].match(f);if(E!==null&&E[2]===l){if(g!==-1){if(E[1]!=="END")break;h=b;break}if(E[1]!=="BEGIN")break;g=b}}if(g===-1||h===-1)throw new Error("PEM section not found for: "+l);const u=c.slice(g+1,h).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const w=v.from(u,"base64");return m.prototype.decode.call(this,w,p)}},6984:(W,_,y)=>{const x=y(5717),v=y(2399).Buffer,m=y(1949),S=y(160);function a(l){this.enc="der",this.name=l.name,this.entity=l,this.tree=new p,this.tree._init(l.body)}function p(l){m.call(this,"der",l)}function c(l){return l<10?"0"+l:l}W.exports=a,a.prototype.encode=function(l,f){return this.tree._encode(l,f).join()},x(p,m),p.prototype._encodeComposite=function(l,f,g,h){const u=function(E,I,M,B){let P;if(E==="seqof"?E="seq":E==="setof"&&(E="set"),S.tagByName.hasOwnProperty(E))P=S.tagByName[E];else{if(typeof E!="number"||(0|E)!==E)return B.error("Unknown tag: "+E);P=E}return P>=31?B.error("Multi-octet tag encoding unsupported"):(I||(P|=32),P|=S.tagClassByName[M||"universal"]<<6,P)}(l,f,g,this.reporter);if(h.length<128){const E=v.alloc(2);return E[0]=u,E[1]=h.length,this._createEncoderBuffer([E,h])}let w=1;for(let E=h.length;E>=256;E>>=8)w++;const b=v.alloc(2+w);b[0]=u,b[1]=128|w;for(let E=1+w,I=h.length;I>0;E--,I>>=8)b[E]=255&I;return this._createEncoderBuffer([b,h])},p.prototype._encodeStr=function(l,f){if(f==="bitstr")return this._createEncoderBuffer([0|l.unused,l.data]);if(f==="bmpstr"){const g=v.alloc(2*l.length);for(let h=0;h<l.length;h++)g.writeUInt16BE(l.charCodeAt(h),2*h);return this._createEncoderBuffer(g)}return f==="numstr"?this._isNumstr(l)?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: numstr supports only digits and space"):f==="printstr"?this._isPrintstr(l)?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(f)||f==="objDesc"?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: "+f+" unsupported")},p.prototype._encodeObjid=function(l,f,g){if(typeof l=="string"){if(!f)return this.reporter.error("string objid given, but no values map found");if(!f.hasOwnProperty(l))return this.reporter.error("objid not found in values map");l=f[l].split(/[\s.]+/g);for(let b=0;b<l.length;b++)l[b]|=0}else if(Array.isArray(l)){l=l.slice();for(let b=0;b<l.length;b++)l[b]|=0}if(!Array.isArray(l))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(l));if(!g){if(l[1]>=40)return this.reporter.error("Second objid identifier OOB");l.splice(0,2,40*l[0]+l[1])}let h=0;for(let b=0;b<l.length;b++){let E=l[b];for(h++;E>=128;E>>=7)h++}const u=v.alloc(h);let w=u.length-1;for(let b=l.length-1;b>=0;b--){let E=l[b];for(u[w--]=127&E;(E>>=7)>0;)u[w--]=128|127&E}return this._createEncoderBuffer(u)},p.prototype._encodeTime=function(l,f){let g;const h=new Date(l);return f==="gentime"?g=[c(h.getUTCFullYear()),c(h.getUTCMonth()+1),c(h.getUTCDate()),c(h.getUTCHours()),c(h.getUTCMinutes()),c(h.getUTCSeconds()),"Z"].join(""):f==="utctime"?g=[c(h.getUTCFullYear()%100),c(h.getUTCMonth()+1),c(h.getUTCDate()),c(h.getUTCHours()),c(h.getUTCMinutes()),c(h.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+f+" time is not supported yet"),this._encodeStr(g,"octstr")},p.prototype._encodeNull=function(){return this._createEncoderBuffer("")},p.prototype._encodeInt=function(l,f){if(typeof l=="string"){if(!f)return this.reporter.error("String int or enum given, but no values map");if(!f.hasOwnProperty(l))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(l));l=f[l]}if(typeof l!="number"&&!v.isBuffer(l)){const u=l.toArray();!l.sign&&128&u[0]&&u.unshift(0),l=v.from(u)}if(v.isBuffer(l)){let u=l.length;l.length===0&&u++;const w=v.alloc(u);return l.copy(w),l.length===0&&(w[0]=0),this._createEncoderBuffer(w)}if(l<128)return this._createEncoderBuffer(l);if(l<256)return this._createEncoderBuffer([0,l]);let g=1;for(let u=l;u>=256;u>>=8)g++;const h=new Array(g);for(let u=h.length-1;u>=0;u--)h[u]=255&l,l>>=8;return 128&h[0]&&h.unshift(0),this._createEncoderBuffer(v.from(h))},p.prototype._encodeBool=function(l){return this._createEncoderBuffer(l?255:0)},p.prototype._use=function(l,f){return typeof l=="function"&&(l=l(f)),l._getEncoder("der").tree},p.prototype._skipDefault=function(l,f,g){const h=this._baseState;let u;if(h.default===null)return!1;const w=l.join();if(h.defaultBuffer===void 0&&(h.defaultBuffer=this._encodeValue(h.default,f,g).join()),w.length!==h.defaultBuffer.length)return!1;for(u=0;u<w.length;u++)if(w[u]!==h.defaultBuffer[u])return!1;return!0}},6579:(W,_,y)=>{const x=_;x.der=y(6984),x.pem=y(2883)},2883:(W,_,y)=>{const x=y(5717),v=y(6984);function m(S){v.call(this,S),this.enc="pem"}x(m,v),W.exports=m,m.prototype.encode=function(S,a){const p=v.prototype.encode.call(this,S).toString("base64"),c=["-----BEGIN "+a.label+"-----"];for(let l=0;l<p.length;l+=64)c.push(p.slice(l,l+64));return c.push("-----END "+a.label+"-----"),c.join(`
15
+ `),function(x){if(_=x.indexOf(":"),ht=K.trim(x.substr(0,_)).toLowerCase(),W=K.trim(x.substr(_+1)),ht){if(ut[ht]&&O.indexOf(ht)>=0)return;ht==="set-cookie"?ut[ht]=(ut[ht]?ut[ht]:[]).concat([W]):ut[ht]=ut[ht]?ut[ht]+", "+W:W}}),ut},Aa}var Ta,Du;function Lf(){if(Du)return Ta;Du=1;var K=Qi;return Ta=K.isStandardBrowserEnv()?function(){var L=/(msie|trident)/i.test(navigator.userAgent),Y=document.createElement("a"),ut;function ht(W){var _=W;return L&&(Y.setAttribute("href",_),_=Y.href),Y.setAttribute("href",_),{href:Y.href,protocol:Y.protocol?Y.protocol.replace(/:$/,""):"",host:Y.host,search:Y.search?Y.search.replace(/^\?/,""):"",hash:Y.hash?Y.hash.replace(/^#/,""):"",hostname:Y.hostname,port:Y.port,pathname:Y.pathname.charAt(0)==="/"?Y.pathname:"/"+Y.pathname}}return ut=ht(window.location.href),function(_){var y=K.isString(_)?ht(_):_;return y.protocol===ut.protocol&&y.host===ut.host}}():function(){return function(){return!0}}(),Ta}var Ba,Uu;function uo(){if(Uu)return Ba;Uu=1;function K(O){this.message=O}return K.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},K.prototype.__CANCEL__=!0,Ba=K,Ba}var ja,qu;function Fu(){if(qu)return ja;qu=1;var K=Qi,O=Bf(),L=jf(),Y=Ou,ut=Cf(),ht=Pf(),W=Lf(),_=Bu(),y=co(),x=uo();return ja=function(m){return new Promise(function(a,p){var c=m.data,l=m.headers,f=m.responseType,g;function h(){m.cancelToken&&m.cancelToken.unsubscribe(g),m.signal&&m.signal.removeEventListener("abort",g)}K.isFormData(c)&&delete l["Content-Type"];var u=new XMLHttpRequest;if(m.auth){var w=m.auth.username||"",b=m.auth.password?unescape(encodeURIComponent(m.auth.password)):"";l.Authorization="Basic "+btoa(w+":"+b)}var E=ut(m.baseURL,m.url);u.open(m.method.toUpperCase(),Y(E,m.params,m.paramsSerializer),!0),u.timeout=m.timeout;function I(){if(u){var B="getAllResponseHeaders"in u?ht(u.getAllResponseHeaders()):null,P=!f||f==="text"||f==="json"?u.responseText:u.response,N={data:P,status:u.status,statusText:u.statusText,headers:B,config:m,request:u};O(function(et){a(et),h()},function(et){p(et),h()},N),u=null}}if("onloadend"in u?u.onloadend=I:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(I)},u.onabort=function(){u&&(p(_("Request aborted",m,"ECONNABORTED",u)),u=null)},u.onerror=function(){p(_("Network Error",m,null,u)),u=null},u.ontimeout=function(){var P=m.timeout?"timeout of "+m.timeout+"ms exceeded":"timeout exceeded",N=m.transitional||y.transitional;m.timeoutErrorMessage&&(P=m.timeoutErrorMessage),p(_(P,m,N.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},K.isStandardBrowserEnv()){var M=(m.withCredentials||W(E))&&m.xsrfCookieName?L.read(m.xsrfCookieName):void 0;M&&(l[m.xsrfHeaderName]=M)}"setRequestHeader"in u&&K.forEach(l,function(P,N){typeof c>"u"&&N.toLowerCase()==="content-type"?delete l[N]:u.setRequestHeader(N,P)}),K.isUndefined(m.withCredentials)||(u.withCredentials=!!m.withCredentials),f&&f!=="json"&&(u.responseType=m.responseType),typeof m.onDownloadProgress=="function"&&u.addEventListener("progress",m.onDownloadProgress),typeof m.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",m.onUploadProgress),(m.cancelToken||m.signal)&&(g=function(B){u&&(p(!B||B&&B.type?new x("canceled"):B),u.abort(),u=null)},m.cancelToken&&m.cancelToken.subscribe(g),m.signal&&(m.signal.aborted?g():m.signal.addEventListener("abort",g))),c||(c=null),u.send(c)})},ja}var Ra,zu;function co(){if(zu)return Ra;zu=1;var K=Qi,O=Tf,L=Au,Y={"Content-Type":"application/x-www-form-urlencoded"};function ut(y,x){!K.isUndefined(y)&&K.isUndefined(y["Content-Type"])&&(y["Content-Type"]=x)}function ht(){var y;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(y=Fu()),y}function W(y,x,v){if(K.isString(y))try{return(x||JSON.parse)(y),K.trim(y)}catch(m){if(m.name!=="SyntaxError")throw m}return(v||JSON.stringify)(y)}var _={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:ht(),transformRequest:[function(x,v){return O(v,"Accept"),O(v,"Content-Type"),K.isFormData(x)||K.isArrayBuffer(x)||K.isBuffer(x)||K.isStream(x)||K.isFile(x)||K.isBlob(x)?x:K.isArrayBufferView(x)?x.buffer:K.isURLSearchParams(x)?(ut(v,"application/x-www-form-urlencoded;charset=utf-8"),x.toString()):K.isObject(x)||v&&v["Content-Type"]==="application/json"?(ut(v,"application/json"),W(x)):x}],transformResponse:[function(x){var v=this.transitional||_.transitional,m=v&&v.silentJSONParsing,S=v&&v.forcedJSONParsing,a=!m&&this.responseType==="json";if(a||S&&K.isString(x)&&x.length)try{return JSON.parse(x)}catch(p){if(a)throw p.name==="SyntaxError"?L(p,this,"E_JSON_PARSE"):p}return x}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(x){return x>=200&&x<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};return K.forEach(["delete","get","head"],function(x){_.headers[x]={}}),K.forEach(["post","put","patch"],function(x){_.headers[x]=K.merge(Y)}),Ra=_,Ra}var Df=Qi,Uf=co(),qf=function(O,L,Y){var ut=this||Uf;return Df.forEach(Y,function(W){O=W.call(ut,O,L)}),O},Na,$u;function Hu(){return $u||($u=1,Na=function(O){return!!(O&&O.__CANCEL__)}),Na}var Wu=Qi,Ca=qf,Ff=Hu(),zf=co(),$f=uo();function Pa(K){if(K.cancelToken&&K.cancelToken.throwIfRequested(),K.signal&&K.signal.aborted)throw new $f("canceled")}var Hf=function(O){Pa(O),O.headers=O.headers||{},O.data=Ca.call(O,O.data,O.headers,O.transformRequest),O.headers=Wu.merge(O.headers.common||{},O.headers[O.method]||{},O.headers),Wu.forEach(["delete","get","head","post","put","patch","common"],function(ut){delete O.headers[ut]});var L=O.adapter||zf.adapter;return L(O).then(function(ut){return Pa(O),ut.data=Ca.call(O,ut.data,ut.headers,O.transformResponse),ut},function(ut){return Ff(ut)||(Pa(O),ut&&ut.response&&(ut.response.data=Ca.call(O,ut.response.data,ut.response.headers,O.transformResponse))),Promise.reject(ut)})},tr=Qi,Vu=function(O,L){L=L||{};var Y={};function ut(v,m){return tr.isPlainObject(v)&&tr.isPlainObject(m)?tr.merge(v,m):tr.isPlainObject(m)?tr.merge({},m):tr.isArray(m)?m.slice():m}function ht(v){if(tr.isUndefined(L[v])){if(!tr.isUndefined(O[v]))return ut(void 0,O[v])}else return ut(O[v],L[v])}function W(v){if(!tr.isUndefined(L[v]))return ut(void 0,L[v])}function _(v){if(tr.isUndefined(L[v])){if(!tr.isUndefined(O[v]))return ut(void 0,O[v])}else return ut(void 0,L[v])}function y(v){if(v in L)return ut(O[v],L[v]);if(v in O)return ut(void 0,O[v])}var x={url:W,method:W,data:W,baseURL:_,transformRequest:_,transformResponse:_,paramsSerializer:_,timeout:_,timeoutMessage:_,withCredentials:_,adapter:_,responseType:_,xsrfCookieName:_,xsrfHeaderName:_,onUploadProgress:_,onDownloadProgress:_,decompress:_,maxContentLength:_,maxBodyLength:_,transport:_,httpAgent:_,httpsAgent:_,cancelToken:_,socketPath:_,responseEncoding:_,validateStatus:y};return tr.forEach(Object.keys(O).concat(Object.keys(L)),function(m){var S=x[m]||ht,a=S(m);tr.isUndefined(a)&&S!==y||(Y[m]=a)}),Y},La,Xu;function Zu(){return Xu||(Xu=1,La={version:"0.24.0"}),La}var Wf=Zu().version,Da={};["object","boolean","number","function","string","symbol"].forEach(function(K,O){Da[K]=function(Y){return typeof Y===K||"a"+(O<1?"n ":" ")+K}});var Ku={};Da.transitional=function(O,L,Y){function ut(ht,W){return"[Axios v"+Wf+"] Transitional option '"+ht+"'"+W+(Y?". "+Y:"")}return function(ht,W,_){if(O===!1)throw new Error(ut(W," has been removed"+(L?" in "+L:"")));return L&&!Ku[W]&&(Ku[W]=!0,console.warn(ut(W," has been deprecated since v"+L+" and will be removed in the near future"))),O?O(ht,W,_):!0}};function Vf(K,O,L){if(typeof K!="object")throw new TypeError("options must be an object");for(var Y=Object.keys(K),ut=Y.length;ut-- >0;){var ht=Y[ut],W=O[ht];if(W){var _=K[ht],y=_===void 0||W(_,ht,K);if(y!==!0)throw new TypeError("option "+ht+" must be "+y);continue}if(L!==!0)throw Error("Unknown option "+ht)}}var Xf={assertOptions:Vf,validators:Da},Ju=Qi,Zf=Ou,Gu=Of,Yu=Hf,lo=Vu,Qu=Xf,gn=Qu.validators;function Nn(K){this.defaults=K,this.interceptors={request:new Gu,response:new Gu}}Nn.prototype.request=function(O){typeof O=="string"?(O=arguments[1]||{},O.url=arguments[0]):O=O||{},O=lo(this.defaults,O),O.method?O.method=O.method.toLowerCase():this.defaults.method?O.method=this.defaults.method.toLowerCase():O.method="get";var L=O.transitional;L!==void 0&&Qu.assertOptions(L,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1);var Y=[],ut=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(O)===!1||(ut=ut&&S.synchronous,Y.unshift(S.fulfilled,S.rejected))});var ht=[];this.interceptors.response.forEach(function(S){ht.push(S.fulfilled,S.rejected)});var W;if(!ut){var _=[Yu,void 0];for(Array.prototype.unshift.apply(_,Y),_=_.concat(ht),W=Promise.resolve(O);_.length;)W=W.then(_.shift(),_.shift());return W}for(var y=O;Y.length;){var x=Y.shift(),v=Y.shift();try{y=x(y)}catch(m){v(m);break}}try{W=Yu(y)}catch(m){return Promise.reject(m)}for(;ht.length;)W=W.then(ht.shift(),ht.shift());return W},Nn.prototype.getUri=function(O){return O=lo(this.defaults,O),Zf(O.url,O.params,O.paramsSerializer).replace(/^\?/,"")},Ju.forEach(["delete","get","head","options"],function(O){Nn.prototype[O]=function(L,Y){return this.request(lo(Y||{},{method:O,url:L,data:(Y||{}).data}))}}),Ju.forEach(["post","put","patch"],function(O){Nn.prototype[O]=function(L,Y,ut){return this.request(lo(ut||{},{method:O,url:L,data:Y}))}});var Kf=Nn,Ua,tc;function Jf(){if(tc)return Ua;tc=1;var K=uo();function O(L){if(typeof L!="function")throw new TypeError("executor must be a function.");var Y;this.promise=new Promise(function(W){Y=W});var ut=this;this.promise.then(function(ht){if(ut._listeners){var W,_=ut._listeners.length;for(W=0;W<_;W++)ut._listeners[W](ht);ut._listeners=null}}),this.promise.then=function(ht){var W,_=new Promise(function(y){ut.subscribe(y),W=y}).then(ht);return _.cancel=function(){ut.unsubscribe(W)},_},L(function(W){ut.reason||(ut.reason=new K(W),Y(ut.reason))})}return O.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},O.prototype.subscribe=function(Y){if(this.reason){Y(this.reason);return}this._listeners?this._listeners.push(Y):this._listeners=[Y]},O.prototype.unsubscribe=function(Y){if(this._listeners){var ut=this._listeners.indexOf(Y);ut!==-1&&this._listeners.splice(ut,1)}},O.source=function(){var Y,ut=new O(function(W){Y=W});return{token:ut,cancel:Y}},Ua=O,Ua}var qa,ec;function Gf(){return ec||(ec=1,qa=function(O){return function(Y){return O.apply(null,Y)}}),qa}var Fa,ic;function Yf(){return ic||(ic=1,Fa=function(O){return typeof O=="object"&&O.isAxiosError===!0}),Fa}var rc=Qi,Qf=Su,ho=Kf,tp=Vu,ep=co();function nc(K){var O=new ho(K),L=Qf(ho.prototype.request,O);return rc.extend(L,ho.prototype,O),rc.extend(L,O),L.create=function(ut){return nc(tp(K,ut))},L}var Sr=nc(ep);Sr.Axios=ho,Sr.Cancel=uo(),Sr.CancelToken=Jf(),Sr.isCancel=Hu(),Sr.VERSION=Zu().version,Sr.all=function(O){return Promise.all(O)},Sr.spread=Gf(),Sr.isAxiosError=Yf(),ya.exports=Sr,ya.exports.default=Sr;var ip=ya.exports,rp=ip;const oc=_u(rp);var np=Object.defineProperty,ac=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,sc=(K,O,L)=>O in K?np(K,O,{enumerable:!0,configurable:!0,writable:!0,value:L}):K[O]=L,za=(K,O)=>{for(var L in O||(O={}))op.call(O,L)&&sc(K,L,O[L]);if(ac)for(var L of ac(O))ap.call(O,L)&&sc(K,L,O[L]);return K},ar=(K,O,L)=>new Promise((Y,ut)=>{var ht=y=>{try{_(L.next(y))}catch(x){ut(x)}},W=y=>{try{_(L.throw(y))}catch(x){ut(x)}},_=y=>y.done?Y(y.value):Promise.resolve(y.value).then(ht,W);_((L=L.apply(K,O)).next())});class sp{constructor(O,L){this.axios=O,this.errorHandler=L}get(O,L,Y){return ar(this,null,function*(){const ut=this.axios.get(O,{params:L});return this.handleResponse(ut,Y)})}listPaged(O,L){return ar(this,null,function*(){const Y=this.axios.get(O,{params:L});return this.handleResponse(Y)})}list(O,L){return ar(this,null,function*(){const Y=this.axios.get(O,{params:L});return this.handleResponse(Y)})}delete(O,L){return ar(this,null,function*(){const Y=this.axios.delete(O,{params:L});return this.handleResponse(Y)})}post(O,L,Y,ut){return ar(this,null,function*(){const ht=this.axios.post(O,L,za({params:Y},ut));return this.handleResponse(ht)})}postForm(O,L,Y){return ar(this,null,function*(){const ut=this.axios.post(O,L,{params:Y,headers:{"Content-Type":"multipart/form-data"}});return this.handleResponse(ut)})}patch(O,L,Y){return ar(this,null,function*(){const ut=this.axios.patch(O,L,{params:Y});return this.handleResponse(ut)})}put(O,L){return ar(this,null,function*(){const Y=this.axios.put(O,L);return this.handleResponse(Y)})}upload(O,L,Y){return ar(this,null,function*(){const ut=this.axios.post(O,L,za({},Y));return this.handleResponse(ut)})}getNonStandard(O,L){return ar(this,null,function*(){const Y=this.axios.get(O,L);try{const ut=yield Y;if(ut.status===200)return ut}catch(ut){throw this.handleError(ut)}})}postNonStandard(O,L,Y,ut){return ar(this,null,function*(){var ht,W;const _=yield this.axios.post(O,L,za({params:Y},ut));if(_.status===200)if((ht=_.data)!=null&&ht.code)(W=this.errorHandler)!=null&&W.onAppStatusError&&this.errorHandler.onAppStatusError(_.data.code,_.data.message);else return _.data})}handleResponse(O,L){return ar(this,null,function*(){try{const Y=yield O;return this.handleAppError(Y.data,L).data}catch(Y){throw this.handleError(Y)}})}handleAppError(O,L){var Y;if(O.code<200||O.code>=300)throw(Y=this.errorHandler)!=null&&Y.onAppStatusError?this.errorHandler.onAppStatusError(O.code,cp(O.code,O.message),L):console.error("未处理应用错误:",O),{isAxiosError:!1,message:O.message};return O}handleError(O){var L,Y;return O.response?(L=this.errorHandler)!=null&&L.onHttpStatusError&&(console.log("HTTP 错误",this.errorHandler),this.errorHandler.onHttpStatusError(O.response.status,"",O.response)):O.request?(console.log(O.request),(Y=this.errorHandler)!=null&&Y.onNetworkError&&this.errorHandler.onNetworkError()):console.error("axios request config error:",O),new Error(O.message)}}const up=K=>K>=10002&&K<=10012,cp=(K,O)=>up(K)?"数据操作错误":O||"未知接口错误";var lp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},uc={exports:{}},$a=(K,O)=>{if(O=Symbol[K])return O;throw Error("Symbol."+K+" is not defined")},vn=Math.pow,Ha=(K,O,L)=>new Promise((Y,ut)=>{var ht=y=>{try{_(L.next(y))}catch(x){ut(x)}},W=y=>{try{_(L.throw(y))}catch(x){ut(x)}},_=y=>y.done?Y(y.value):Promise.resolve(y.value).then(ht,W);_((L=L.apply(K,O)).next())}),hp=function(K,O){this[0]=K,this[1]=O},fp=K=>{var O=K[$a("asyncIterator")],L=!1,Y,ut={};return O==null?(O=K[$a("iterator")](),Y=ht=>ut[ht]=W=>O[ht](W)):(O=O.call(K),Y=ht=>ut[ht]=W=>{if(L){if(L=!1,ht==="throw")throw W;return W}return L=!0,{done:!1,value:new hp(new Promise(_=>{var y=O[ht](W);if(!(y instanceof Object))throw TypeError("Object expected");_(y)}),1)}}),ut[$a("iterator")]=()=>ut,Y("next"),"throw"in O?Y("throw"):ut.throw=ht=>{throw ht},"return"in O&&Y("return"),ut};/*! For license information please see minio-zj.js.LICENSE.txt */(function(K,O){(function(L,Y){K.exports=Y()})(lp,()=>(()=>{var L={9809:(W,_,y)=>{const x=_;x.bignum=y(4590),x.define=y(2500).define,x.base=y(1979),x.constants=y(6826),x.decoders=y(8307),x.encoders=y(6579)},2500:(W,_,y)=>{const x=y(6579),v=y(8307),m=y(5717);function S(a,p){this.name=a,this.body=p,this.decoders={},this.encoders={}}_.define=function(a,p){return new S(a,p)},S.prototype._createNamed=function(a){const p=this.name;function c(l){this._initNamed(l,p)}return m(c,a),c.prototype._initNamed=function(l,f){a.call(this,l,f)},new c(this)},S.prototype._getDecoder=function(a){return a=a||"der",this.decoders.hasOwnProperty(a)||(this.decoders[a]=this._createNamed(v[a])),this.decoders[a]},S.prototype.decode=function(a,p,c){return this._getDecoder(p).decode(a,c)},S.prototype._getEncoder=function(a){return a=a||"der",this.encoders.hasOwnProperty(a)||(this.encoders[a]=this._createNamed(x[a])),this.encoders[a]},S.prototype.encode=function(a,p,c){return this._getEncoder(p).encode(a,c)}},6625:(W,_,y)=>{const x=y(5717),v=y(8465).b,m=y(2399).Buffer;function S(p,c){v.call(this,c),m.isBuffer(p)?(this.base=p,this.offset=0,this.length=p.length):this.error("Input not Buffer")}function a(p,c){if(Array.isArray(p))this.length=0,this.value=p.map(function(l){return a.isEncoderBuffer(l)||(l=new a(l,c)),this.length+=l.length,l},this);else if(typeof p=="number"){if(!(0<=p&&p<=255))return c.error("non-byte EncoderBuffer value");this.value=p,this.length=1}else if(typeof p=="string")this.value=p,this.length=m.byteLength(p);else{if(!m.isBuffer(p))return c.error("Unsupported type: "+typeof p);this.value=p,this.length=p.length}}x(S,v),_.C=S,S.isDecoderBuffer=function(p){return p instanceof S||typeof p=="object"&&m.isBuffer(p.base)&&p.constructor.name==="DecoderBuffer"&&typeof p.offset=="number"&&typeof p.length=="number"&&typeof p.save=="function"&&typeof p.restore=="function"&&typeof p.isEmpty=="function"&&typeof p.readUInt8=="function"&&typeof p.skip=="function"&&typeof p.raw=="function"},S.prototype.save=function(){return{offset:this.offset,reporter:v.prototype.save.call(this)}},S.prototype.restore=function(p){const c=new S(this.base);return c.offset=p.offset,c.length=this.offset,this.offset=p.offset,v.prototype.restore.call(this,p.reporter),c},S.prototype.isEmpty=function(){return this.offset===this.length},S.prototype.readUInt8=function(p){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(p||"DecoderBuffer overrun")},S.prototype.skip=function(p,c){if(!(this.offset+p<=this.length))return this.error(c||"DecoderBuffer overrun");const l=new S(this.base);return l._reporterState=this._reporterState,l.offset=this.offset,l.length=this.offset+p,this.offset+=p,l},S.prototype.raw=function(p){return this.base.slice(p?p.offset:this.offset,this.length)},_.R=a,a.isEncoderBuffer=function(p){return p instanceof a||typeof p=="object"&&p.constructor.name==="EncoderBuffer"&&typeof p.length=="number"&&typeof p.join=="function"},a.prototype.join=function(p,c){return p||(p=m.alloc(this.length)),c||(c=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(l){l.join(p,c),c+=l.length}):(typeof this.value=="number"?p[c]=this.value:typeof this.value=="string"?p.write(this.value,c):m.isBuffer(this.value)&&this.value.copy(p,c),c+=this.length)),p}},1979:(W,_,y)=>{const x=_;x.Reporter=y(8465).b,x.DecoderBuffer=y(6625).C,x.EncoderBuffer=y(6625).R,x.Node=y(1949)},1949:(W,_,y)=>{const x=y(8465).b,v=y(6625).R,m=y(6625).C,S=y(9746),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],p=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function c(f,g,h){const u={};this._baseState=u,u.name=h,u.enc=f,u.parent=g||null,u.children=null,u.tag=null,u.args=null,u.reverseArgs=null,u.choice=null,u.optional=!1,u.any=!1,u.obj=!1,u.use=null,u.useDecoder=null,u.key=null,u.default=null,u.explicit=null,u.implicit=null,u.contains=null,u.parent||(u.children=[],this._wrap())}W.exports=c;const l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){const f=this._baseState,g={};l.forEach(function(u){g[u]=f[u]});const h=new this.constructor(g.parent);return h._baseState=g,h},c.prototype._wrap=function(){const f=this._baseState;p.forEach(function(g){this[g]=function(){const h=new this.constructor(this);return f.children.push(h),h[g].apply(h,arguments)}},this)},c.prototype._init=function(f){const g=this._baseState;S(g.parent===null),f.call(this),g.children=g.children.filter(function(h){return h._baseState.parent===this},this),S.equal(g.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(f){const g=this._baseState,h=f.filter(function(u){return u instanceof this.constructor},this);f=f.filter(function(u){return!(u instanceof this.constructor)},this),h.length!==0&&(S(g.children===null),g.children=h,h.forEach(function(u){u._baseState.parent=this},this)),f.length!==0&&(S(g.args===null),g.args=f,g.reverseArgs=f.map(function(u){if(typeof u!="object"||u.constructor!==Object)return u;const w={};return Object.keys(u).forEach(function(b){b==(0|b)&&(b|=0);const E=u[b];w[E]=b}),w}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(f){c.prototype[f]=function(){const g=this._baseState;throw new Error(f+" not implemented for encoding: "+g.enc)}}),a.forEach(function(f){c.prototype[f]=function(){const g=this._baseState,h=Array.prototype.slice.call(arguments);return S(g.tag===null),g.tag=f,this._useArgs(h),this}}),c.prototype.use=function(f){S(f);const g=this._baseState;return S(g.use===null),g.use=f,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(f){const g=this._baseState;return S(g.default===null),g.default=f,g.optional=!0,this},c.prototype.explicit=function(f){const g=this._baseState;return S(g.explicit===null&&g.implicit===null),g.explicit=f,this},c.prototype.implicit=function(f){const g=this._baseState;return S(g.explicit===null&&g.implicit===null),g.implicit=f,this},c.prototype.obj=function(){const f=this._baseState,g=Array.prototype.slice.call(arguments);return f.obj=!0,g.length!==0&&this._useArgs(g),this},c.prototype.key=function(f){const g=this._baseState;return S(g.key===null),g.key=f,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(f){const g=this._baseState;return S(g.choice===null),g.choice=f,this._useArgs(Object.keys(f).map(function(h){return f[h]})),this},c.prototype.contains=function(f){const g=this._baseState;return S(g.use===null),g.contains=f,this},c.prototype._decode=function(f,g){const h=this._baseState;if(h.parent===null)return f.wrapResult(h.children[0]._decode(f,g));let u,w=h.default,b=!0,E=null;if(h.key!==null&&(E=f.enterKey(h.key)),h.optional){let I=null;if(h.explicit!==null?I=h.explicit:h.implicit!==null?I=h.implicit:h.tag!==null&&(I=h.tag),I!==null||h.any){if(b=this._peekTag(f,I,h.any),f.isError(b))return b}else{const M=f.save();try{h.choice===null?this._decodeGeneric(h.tag,f,g):this._decodeChoice(f,g),b=!0}catch{b=!1}f.restore(M)}}if(h.obj&&b&&(u=f.enterObject()),b){if(h.explicit!==null){const M=this._decodeTag(f,h.explicit);if(f.isError(M))return M;f=M}const I=f.offset;if(h.use===null&&h.choice===null){let M;h.any&&(M=f.save());const B=this._decodeTag(f,h.implicit!==null?h.implicit:h.tag,h.any);if(f.isError(B))return B;h.any?w=f.raw(M):f=B}if(g&&g.track&&h.tag!==null&&g.track(f.path(),I,f.length,"tagged"),g&&g.track&&h.tag!==null&&g.track(f.path(),f.offset,f.length,"content"),h.any||(w=h.choice===null?this._decodeGeneric(h.tag,f,g):this._decodeChoice(f,g)),f.isError(w))return w;if(h.any||h.choice!==null||h.children===null||h.children.forEach(function(M){M._decode(f,g)}),h.contains&&(h.tag==="octstr"||h.tag==="bitstr")){const M=new m(w);w=this._getUse(h.contains,f._reporterState.obj)._decode(M,g)}}return h.obj&&b&&(w=f.leaveObject(u)),h.key===null||w===null&&b!==!0?E!==null&&f.exitKey(E):f.leaveKey(E,h.key,w),w},c.prototype._decodeGeneric=function(f,g,h){const u=this._baseState;return f==="seq"||f==="set"?null:f==="seqof"||f==="setof"?this._decodeList(g,f,u.args[0],h):/str$/.test(f)?this._decodeStr(g,f,h):f==="objid"&&u.args?this._decodeObjid(g,u.args[0],u.args[1],h):f==="objid"?this._decodeObjid(g,null,null,h):f==="gentime"||f==="utctime"?this._decodeTime(g,f,h):f==="null_"?this._decodeNull(g,h):f==="bool"?this._decodeBool(g,h):f==="objDesc"?this._decodeStr(g,f,h):f==="int"||f==="enum"?this._decodeInt(g,u.args&&u.args[0],h):u.use!==null?this._getUse(u.use,g._reporterState.obj)._decode(g,h):g.error("unknown tag: "+f)},c.prototype._getUse=function(f,g){const h=this._baseState;return h.useDecoder=this._use(f,g),S(h.useDecoder._baseState.parent===null),h.useDecoder=h.useDecoder._baseState.children[0],h.implicit!==h.useDecoder._baseState.implicit&&(h.useDecoder=h.useDecoder.clone(),h.useDecoder._baseState.implicit=h.implicit),h.useDecoder},c.prototype._decodeChoice=function(f,g){const h=this._baseState;let u=null,w=!1;return Object.keys(h.choice).some(function(b){const E=f.save(),I=h.choice[b];try{const M=I._decode(f,g);if(f.isError(M))return!1;u={type:b,value:M},w=!0}catch{return f.restore(E),!1}return!0},this),w?u:f.error("Choice not matched")},c.prototype._createEncoderBuffer=function(f){return new v(f,this.reporter)},c.prototype._encode=function(f,g,h){const u=this._baseState;if(u.default!==null&&u.default===f)return;const w=this._encodeValue(f,g,h);return w===void 0||this._skipDefault(w,g,h)?void 0:w},c.prototype._encodeValue=function(f,g,h){const u=this._baseState;if(u.parent===null)return u.children[0]._encode(f,g||new x);let w=null;if(this.reporter=g,u.optional&&f===void 0){if(u.default===null)return;f=u.default}let b=null,E=!1;if(u.any)w=this._createEncoderBuffer(f);else if(u.choice)w=this._encodeChoice(f,g);else if(u.contains)b=this._getUse(u.contains,h)._encode(f,g),E=!0;else if(u.children)b=u.children.map(function(I){if(I._baseState.tag==="null_")return I._encode(null,g,f);if(I._baseState.key===null)return g.error("Child should have a key");const M=g.enterKey(I._baseState.key);if(typeof f!="object")return g.error("Child expected, but input is not object");const B=I._encode(f[I._baseState.key],g,f);return g.leaveKey(M),B},this).filter(function(I){return I}),b=this._createEncoderBuffer(b);else if(u.tag==="seqof"||u.tag==="setof"){if(!u.args||u.args.length!==1)return g.error("Too many args for : "+u.tag);if(!Array.isArray(f))return g.error("seqof/setof, but data is not Array");const I=this.clone();I._baseState.implicit=null,b=this._createEncoderBuffer(f.map(function(M){const B=this._baseState;return this._getUse(B.args[0],f)._encode(M,g)},I))}else u.use!==null?w=this._getUse(u.use,h)._encode(f,g):(b=this._encodePrimitive(u.tag,f),E=!0);if(!u.any&&u.choice===null){const I=u.implicit!==null?u.implicit:u.tag,M=u.implicit===null?"universal":"context";I===null?u.use===null&&g.error("Tag could be omitted only for .use()"):u.use===null&&(w=this._encodeComposite(I,E,M,b))}return u.explicit!==null&&(w=this._encodeComposite(u.explicit,!1,"context",w)),w},c.prototype._encodeChoice=function(f,g){const h=this._baseState,u=h.choice[f.type];return u||S(!1,f.type+" not found in "+JSON.stringify(Object.keys(h.choice))),u._encode(f.value,g)},c.prototype._encodePrimitive=function(f,g){const h=this._baseState;if(/str$/.test(f))return this._encodeStr(g,f);if(f==="objid"&&h.args)return this._encodeObjid(g,h.reverseArgs[0],h.args[1]);if(f==="objid")return this._encodeObjid(g,null,null);if(f==="gentime"||f==="utctime")return this._encodeTime(g,f);if(f==="null_")return this._encodeNull();if(f==="int"||f==="enum")return this._encodeInt(g,h.args&&h.reverseArgs[0]);if(f==="bool")return this._encodeBool(g);if(f==="objDesc")return this._encodeStr(g,f);throw new Error("Unsupported tag: "+f)},c.prototype._isNumstr=function(f){return/^[0-9 ]*$/.test(f)},c.prototype._isPrintstr=function(f){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(f)}},8465:(W,_,y)=>{const x=y(5717);function v(S){this._reporterState={obj:null,path:[],options:S||{},errors:[]}}function m(S,a){this.path=S,this.rethrow(a)}_.b=v,v.prototype.isError=function(S){return S instanceof m},v.prototype.save=function(){const S=this._reporterState;return{obj:S.obj,pathLen:S.path.length}},v.prototype.restore=function(S){const a=this._reporterState;a.obj=S.obj,a.path=a.path.slice(0,S.pathLen)},v.prototype.enterKey=function(S){return this._reporterState.path.push(S)},v.prototype.exitKey=function(S){const a=this._reporterState;a.path=a.path.slice(0,S-1)},v.prototype.leaveKey=function(S,a,p){const c=this._reporterState;this.exitKey(S),c.obj!==null&&(c.obj[a]=p)},v.prototype.path=function(){return this._reporterState.path.join("/")},v.prototype.enterObject=function(){const S=this._reporterState,a=S.obj;return S.obj={},a},v.prototype.leaveObject=function(S){const a=this._reporterState,p=a.obj;return a.obj=S,p},v.prototype.error=function(S){let a;const p=this._reporterState,c=S instanceof m;if(a=c?S:new m(p.path.map(function(l){return"["+JSON.stringify(l)+"]"}).join(""),S.message||S,S.stack),!p.options.partial)throw a;return c||p.errors.push(a),a},v.prototype.wrapResult=function(S){const a=this._reporterState;return a.options.partial?{result:this.isError(S)?null:S,errors:a.errors}:S},x(m,Error),m.prototype.rethrow=function(S){if(this.message=S+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,m),!this.stack)try{throw new Error(this.message)}catch(a){this.stack=a.stack}return this}},160:(W,_)=>{function y(x){const v={};return Object.keys(x).forEach(function(m){(0|m)==m&&(m|=0);const S=x[m];v[S]=m}),v}_.tagClass={0:"universal",1:"application",2:"context",3:"private"},_.tagClassByName=y(_.tagClass),_.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},_.tagByName=y(_.tag)},6826:(W,_,y)=>{const x=_;x._reverse=function(v){const m={};return Object.keys(v).forEach(function(S){(0|S)==S&&(S|=0);const a=v[S];m[a]=S}),m},x.der=y(160)},1671:(W,_,y)=>{const x=y(5717),v=y(4590),m=y(6625).C,S=y(1949),a=y(160);function p(g){this.enc="der",this.name=g.name,this.entity=g,this.tree=new c,this.tree._init(g.body)}function c(g){S.call(this,"der",g)}function l(g,h){let u=g.readUInt8(h);if(g.isError(u))return u;const w=a.tagClass[u>>6],b=(32&u)==0;if((31&u)==31){let E=u;for(u=0;(128&E)==128;){if(E=g.readUInt8(h),g.isError(E))return E;u<<=7,u|=127&E}}else u&=31;return{cls:w,primitive:b,tag:u,tagStr:a.tag[u]}}function f(g,h,u){let w=g.readUInt8(u);if(g.isError(w))return w;if(!h&&w===128)return null;if(!(128&w))return w;const b=127&w;if(b>4)return g.error("length octect is too long");w=0;for(let E=0;E<b;E++){w<<=8;const I=g.readUInt8(u);if(g.isError(I))return I;w|=I}return w}W.exports=p,p.prototype.decode=function(g,h){return m.isDecoderBuffer(g)||(g=new m(g,h)),this.tree._decode(g,h)},x(c,S),c.prototype._peekTag=function(g,h,u){if(g.isEmpty())return!1;const w=g.save(),b=l(g,'Failed to peek tag: "'+h+'"');return g.isError(b)?b:(g.restore(w),b.tag===h||b.tagStr===h||b.tagStr+"of"===h||u)},c.prototype._decodeTag=function(g,h,u){const w=l(g,'Failed to decode tag of "'+h+'"');if(g.isError(w))return w;let b=f(g,w.primitive,'Failed to get length of "'+h+'"');if(g.isError(b))return b;if(!u&&w.tag!==h&&w.tagStr!==h&&w.tagStr+"of"!==h)return g.error('Failed to match tag: "'+h+'"');if(w.primitive||b!==null)return g.skip(b,'Failed to match body of: "'+h+'"');const E=g.save(),I=this._skipUntilEnd(g,'Failed to skip indefinite length body: "'+this.tag+'"');return g.isError(I)?I:(b=g.offset-E.offset,g.restore(E),g.skip(b,'Failed to match body of: "'+h+'"'))},c.prototype._skipUntilEnd=function(g,h){for(;;){const u=l(g,h);if(g.isError(u))return u;const w=f(g,u.primitive,h);if(g.isError(w))return w;let b;if(b=u.primitive||w!==null?g.skip(w):this._skipUntilEnd(g,h),g.isError(b))return b;if(u.tagStr==="end")break}},c.prototype._decodeList=function(g,h,u,w){const b=[];for(;!g.isEmpty();){const E=this._peekTag(g,"end");if(g.isError(E))return E;const I=u.decode(g,"der",w);if(g.isError(I)&&E)break;b.push(I)}return b},c.prototype._decodeStr=function(g,h){if(h==="bitstr"){const u=g.readUInt8();return g.isError(u)?u:{unused:u,data:g.raw()}}if(h==="bmpstr"){const u=g.raw();if(u.length%2==1)return g.error("Decoding of string type: bmpstr length mismatch");let w="";for(let b=0;b<u.length/2;b++)w+=String.fromCharCode(u.readUInt16BE(2*b));return w}if(h==="numstr"){const u=g.raw().toString("ascii");return this._isNumstr(u)?u:g.error("Decoding of string type: numstr unsupported characters")}if(h==="octstr"||h==="objDesc")return g.raw();if(h==="printstr"){const u=g.raw().toString("ascii");return this._isPrintstr(u)?u:g.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(h)?g.raw().toString():g.error("Decoding of string type: "+h+" unsupported")},c.prototype._decodeObjid=function(g,h,u){let w;const b=[];let E=0,I=0;for(;!g.isEmpty();)I=g.readUInt8(),E<<=7,E|=127&I,!(128&I)&&(b.push(E),E=0);128&I&&b.push(E);const M=b[0]/40|0,B=b[0]%40;if(w=u?b:[M,B].concat(b.slice(1)),h){let P=h[w.join(" ")];P===void 0&&(P=h[w.join(".")]),P!==void 0&&(w=P)}return w},c.prototype._decodeTime=function(g,h){const u=g.raw().toString();let w,b,E,I,M,B;if(h==="gentime")w=0|u.slice(0,4),b=0|u.slice(4,6),E=0|u.slice(6,8),I=0|u.slice(8,10),M=0|u.slice(10,12),B=0|u.slice(12,14);else{if(h!=="utctime")return g.error("Decoding "+h+" time is not supported yet");w=0|u.slice(0,2),b=0|u.slice(2,4),E=0|u.slice(4,6),I=0|u.slice(6,8),M=0|u.slice(8,10),B=0|u.slice(10,12),w=w<70?2e3+w:1900+w}return Date.UTC(w,b-1,E,I,M,B,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(g){const h=g.readUInt8();return g.isError(h)?h:h!==0},c.prototype._decodeInt=function(g,h){const u=g.raw();let w=new v(u);return h&&(w=h[w.toString(10)]||w),w},c.prototype._use=function(g,h){return typeof g=="function"&&(g=g(h)),g._getDecoder("der").tree}},8307:(W,_,y)=>{const x=_;x.der=y(1671),x.pem=y(9631)},9631:(W,_,y)=>{const x=y(5717),v=y(2399).Buffer,m=y(1671);function S(a){m.call(this,a),this.enc="pem"}x(S,m),W.exports=S,S.prototype.decode=function(a,p){const c=a.toString().split(/[\r\n]+/g),l=p.label.toUpperCase(),f=/^-----(BEGIN|END) ([^-]+)-----$/;let g=-1,h=-1;for(let b=0;b<c.length;b++){const E=c[b].match(f);if(E!==null&&E[2]===l){if(g!==-1){if(E[1]!=="END")break;h=b;break}if(E[1]!=="BEGIN")break;g=b}}if(g===-1||h===-1)throw new Error("PEM section not found for: "+l);const u=c.slice(g+1,h).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const w=v.from(u,"base64");return m.prototype.decode.call(this,w,p)}},6984:(W,_,y)=>{const x=y(5717),v=y(2399).Buffer,m=y(1949),S=y(160);function a(l){this.enc="der",this.name=l.name,this.entity=l,this.tree=new p,this.tree._init(l.body)}function p(l){m.call(this,"der",l)}function c(l){return l<10?"0"+l:l}W.exports=a,a.prototype.encode=function(l,f){return this.tree._encode(l,f).join()},x(p,m),p.prototype._encodeComposite=function(l,f,g,h){const u=function(E,I,M,B){let P;if(E==="seqof"?E="seq":E==="setof"&&(E="set"),S.tagByName.hasOwnProperty(E))P=S.tagByName[E];else{if(typeof E!="number"||(0|E)!==E)return B.error("Unknown tag: "+E);P=E}return P>=31?B.error("Multi-octet tag encoding unsupported"):(I||(P|=32),P|=S.tagClassByName[M||"universal"]<<6,P)}(l,f,g,this.reporter);if(h.length<128){const E=v.alloc(2);return E[0]=u,E[1]=h.length,this._createEncoderBuffer([E,h])}let w=1;for(let E=h.length;E>=256;E>>=8)w++;const b=v.alloc(2+w);b[0]=u,b[1]=128|w;for(let E=1+w,I=h.length;I>0;E--,I>>=8)b[E]=255&I;return this._createEncoderBuffer([b,h])},p.prototype._encodeStr=function(l,f){if(f==="bitstr")return this._createEncoderBuffer([0|l.unused,l.data]);if(f==="bmpstr"){const g=v.alloc(2*l.length);for(let h=0;h<l.length;h++)g.writeUInt16BE(l.charCodeAt(h),2*h);return this._createEncoderBuffer(g)}return f==="numstr"?this._isNumstr(l)?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: numstr supports only digits and space"):f==="printstr"?this._isPrintstr(l)?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(f)||f==="objDesc"?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: "+f+" unsupported")},p.prototype._encodeObjid=function(l,f,g){if(typeof l=="string"){if(!f)return this.reporter.error("string objid given, but no values map found");if(!f.hasOwnProperty(l))return this.reporter.error("objid not found in values map");l=f[l].split(/[\s.]+/g);for(let b=0;b<l.length;b++)l[b]|=0}else if(Array.isArray(l)){l=l.slice();for(let b=0;b<l.length;b++)l[b]|=0}if(!Array.isArray(l))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(l));if(!g){if(l[1]>=40)return this.reporter.error("Second objid identifier OOB");l.splice(0,2,40*l[0]+l[1])}let h=0;for(let b=0;b<l.length;b++){let E=l[b];for(h++;E>=128;E>>=7)h++}const u=v.alloc(h);let w=u.length-1;for(let b=l.length-1;b>=0;b--){let E=l[b];for(u[w--]=127&E;(E>>=7)>0;)u[w--]=128|127&E}return this._createEncoderBuffer(u)},p.prototype._encodeTime=function(l,f){let g;const h=new Date(l);return f==="gentime"?g=[c(h.getUTCFullYear()),c(h.getUTCMonth()+1),c(h.getUTCDate()),c(h.getUTCHours()),c(h.getUTCMinutes()),c(h.getUTCSeconds()),"Z"].join(""):f==="utctime"?g=[c(h.getUTCFullYear()%100),c(h.getUTCMonth()+1),c(h.getUTCDate()),c(h.getUTCHours()),c(h.getUTCMinutes()),c(h.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+f+" time is not supported yet"),this._encodeStr(g,"octstr")},p.prototype._encodeNull=function(){return this._createEncoderBuffer("")},p.prototype._encodeInt=function(l,f){if(typeof l=="string"){if(!f)return this.reporter.error("String int or enum given, but no values map");if(!f.hasOwnProperty(l))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(l));l=f[l]}if(typeof l!="number"&&!v.isBuffer(l)){const u=l.toArray();!l.sign&&128&u[0]&&u.unshift(0),l=v.from(u)}if(v.isBuffer(l)){let u=l.length;l.length===0&&u++;const w=v.alloc(u);return l.copy(w),l.length===0&&(w[0]=0),this._createEncoderBuffer(w)}if(l<128)return this._createEncoderBuffer(l);if(l<256)return this._createEncoderBuffer([0,l]);let g=1;for(let u=l;u>=256;u>>=8)g++;const h=new Array(g);for(let u=h.length-1;u>=0;u--)h[u]=255&l,l>>=8;return 128&h[0]&&h.unshift(0),this._createEncoderBuffer(v.from(h))},p.prototype._encodeBool=function(l){return this._createEncoderBuffer(l?255:0)},p.prototype._use=function(l,f){return typeof l=="function"&&(l=l(f)),l._getEncoder("der").tree},p.prototype._skipDefault=function(l,f,g){const h=this._baseState;let u;if(h.default===null)return!1;const w=l.join();if(h.defaultBuffer===void 0&&(h.defaultBuffer=this._encodeValue(h.default,f,g).join()),w.length!==h.defaultBuffer.length)return!1;for(u=0;u<w.length;u++)if(w[u]!==h.defaultBuffer[u])return!1;return!0}},6579:(W,_,y)=>{const x=_;x.der=y(6984),x.pem=y(2883)},2883:(W,_,y)=>{const x=y(5717),v=y(6984);function m(S){v.call(this,S),this.enc="pem"}x(m,v),W.exports=m,m.prototype.encode=function(S,a){const p=v.prototype.encode.call(this,S).toString("base64"),c=["-----BEGIN "+a.label+"-----"];for(let l=0;l<p.length;l+=64)c.push(p.slice(l,l+64));return c.push("-----END "+a.label+"-----"),c.join(`
16
16
  `)}},4590:function(W,_,y){(function(x,v){function m(t,n){if(!t)throw new Error(n||"Assertion failed")}function S(t,n){t.super_=n;var r=function(){};r.prototype=n.prototype,t.prototype=new r,t.prototype.constructor=t}function a(t,n,r){if(a.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,t!==null&&(n!=="le"&&n!=="be"||(r=n,n=10),this._init(t||0,n||10,r||"be"))}var p;typeof x=="object"?x.exports=a:v.BN=a,a.BN=a,a.wordSize=26;try{p=typeof window<"u"&&window.Buffer!==void 0?window.Buffer:y(950).Buffer}catch{}function c(t,n){var r=t.charCodeAt(n);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function l(t,n,r){var i=c(t,r);return r-1>=n&&(i|=c(t,r-1)<<4),i}function f(t,n,r,i){for(var e=0,o=Math.min(t.length,r),s=n;s<o;s++){var A=t.charCodeAt(s)-48;e*=i,e+=A>=49?A-49+10:A>=17?A-17+10:A}return e}a.isBN=function(t){return t instanceof a||t!==null&&typeof t=="object"&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,n){return t.cmp(n)>0?t:n},a.min=function(t,n){return t.cmp(n)<0?t:n},a.prototype._init=function(t,n,r){if(typeof t=="number")return this._initNumber(t,n,r);if(typeof t=="object")return this._initArray(t,n,r);n==="hex"&&(n=16),m(n===(0|n)&&n>=2&&n<=36);var i=0;(t=t.toString().replace(/\s+/g,""))[0]==="-"&&(i++,this.negative=1),i<t.length&&(n===16?this._parseHex(t,i,r):(this._parseBase(t,n,i),r==="le"&&this._initArray(this.toArray(),n,r)))},a.prototype._initNumber=function(t,n,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(m(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),r==="le"&&this._initArray(this.toArray(),n,r)},a.prototype._initArray=function(t,n,r){if(m(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var e,o,s=0;if(r==="be")for(i=t.length-1,e=0;i>=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if(r==="le")for(i=0,e=0;i<t.length;i+=3)o=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this.strip()},a.prototype._parseHex=function(t,n,r){this.length=Math.ceil((t.length-n)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var e,o=0,s=0;if(r==="be")for(i=t.length-1;i>=n;i-=2)e=l(t,n,i)<<o,this.words[s]|=67108863&e,o>=18?(o-=18,s+=1,this.words[s]|=e>>>26):o+=8;else for(i=(t.length-n)%2==0?n+1:n;i<t.length;i+=2)e=l(t,n,i)<<o,this.words[s]|=67108863&e,o>=18?(o-=18,s+=1,this.words[s]|=e>>>26):o+=8;this.strip()},a.prototype._parseBase=function(t,n,r){this.words=[0],this.length=1;for(var i=0,e=1;e<=67108863;e*=n)i++;i--,e=e/n|0;for(var o=t.length-r,s=o%i,A=Math.min(o,o-s)+r,C=0,j=r;j<A;j+=i)C=f(t,j,j+i,n),this.imuln(e),this.words[0]+C<67108864?this.words[0]+=C:this._iaddn(C);if(s!==0){var T=1;for(C=f(t,j,t.length,n),j=0;j<s;j++)T*=n;this.imuln(T),this.words[0]+C<67108864?this.words[0]+=C:this._iaddn(C)}this.strip()},a.prototype.copy=function(t){t.words=new Array(this.length);for(var n=0;n<this.length;n++)t.words[n]=this.words[n];t.length=this.length,t.negative=this.negative,t.red=this.red},a.prototype.clone=function(){var t=new a(null);return this.copy(t),t},a.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},a.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var g=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function w(t,n,r){r.negative=n.negative^t.negative;var i=t.length+n.length|0;r.length=i,i=i-1|0;var e=0|t.words[0],o=0|n.words[0],s=e*o,A=67108863&s,C=s/67108864|0;r.words[0]=A;for(var j=1;j<i;j++){for(var T=C>>>26,R=67108863&C,q=Math.min(j,n.length-1),Z=Math.max(0,j-t.length+1);Z<=q;Z++){var rt=j-Z|0;T+=(s=(e=0|t.words[rt])*(o=0|n.words[Z])+R)/67108864|0,R=67108863&s}r.words[j]=0|R,C=0|T}return C!==0?r.words[j]=0|C:r.length--,r.strip()}a.prototype.toString=function(t,n){var r;if(n=0|n||1,(t=t||10)===16||t==="hex"){r="";for(var i=0,e=0,o=0;o<this.length;o++){var s=this.words[o],A=(16777215&(s<<i|e)).toString(16);r=(e=s>>>24-i&16777215)!=0||o!==this.length-1?g[6-A.length]+A+r:A+r,(i+=2)>=26&&(i-=26,o--)}for(e!==0&&(r=e.toString(16)+r);r.length%n!=0;)r="0"+r;return this.negative!==0&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var C=h[t],j=u[t];r="";var T=this.clone();for(T.negative=0;!T.isZero();){var R=T.modn(j).toString(t);r=(T=T.idivn(j)).isZero()?R+r:g[C-R.length]+R+r}for(this.isZero()&&(r="0"+r);r.length%n!=0;)r="0"+r;return this.negative!==0&&(r="-"+r),r}m(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=67108864*this.words[1]:this.length===3&&this.words[2]===1?t+=4503599627370496+67108864*this.words[1]:this.length>2&&m(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(t,n){return m(p!==void 0),this.toArrayLike(p,t,n)},a.prototype.toArray=function(t,n){return this.toArrayLike(Array,t,n)},a.prototype.toArrayLike=function(t,n,r){var i=this.byteLength(),e=r||Math.max(1,i);m(i<=e,"byte array longer than desired length"),m(e>0,"Requested array length <= 0"),this.strip();var o,s,A=n==="le",C=new t(e),j=this.clone();if(A){for(s=0;!j.isZero();s++)o=j.andln(255),j.iushrn(8),C[s]=o;for(;s<e;s++)C[s]=0}else{for(s=0;s<e-i;s++)C[s]=0;for(s=0;!j.isZero();s++)o=j.andln(255),j.iushrn(8),C[e-s-1]=o}return C},Math.clz32?a.prototype._countBits=function(t){return 32-Math.clz32(t)}:a.prototype._countBits=function(t){var n=t,r=0;return n>=4096&&(r+=13,n>>>=13),n>=64&&(r+=7,n>>>=7),n>=8&&(r+=4,n>>>=4),n>=2&&(r+=2,n>>>=2),r+n},a.prototype._zeroBits=function(t){if(t===0)return 26;var n=t,r=0;return!(8191&n)&&(r+=13,n>>>=13),!(127&n)&&(r+=7,n>>>=7),!(15&n)&&(r+=4,n>>>=4),!(3&n)&&(r+=2,n>>>=2),!(1&n)&&r++,r},a.prototype.bitLength=function(){var t=this.words[this.length-1],n=this._countBits(t);return 26*(this.length-1)+n},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,n=0;n<this.length;n++){var r=this._zeroBits(this.words[n]);if(t+=r,r!==26)break}return t},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},a.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]|t.words[n];return this.strip()},a.prototype.ior=function(t){return m((this.negative|t.negative)==0),this.iuor(t)},a.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var n;n=this.length>t.length?t:this;for(var r=0;r<n.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=n.length,this.strip()},a.prototype.iand=function(t){return m((this.negative|t.negative)==0),this.iuand(t)},a.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var n,r;this.length>t.length?(n=this,r=t):(n=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=n.words[i]^r.words[i];if(this!==n)for(;i<n.length;i++)this.words[i]=n.words[i];return this.length=n.length,this.strip()},a.prototype.ixor=function(t){return m((this.negative|t.negative)==0),this.iuxor(t)},a.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){m(typeof t=="number"&&t>=0);var n=0|Math.ceil(t/26),r=t%26;this._expand(n),r>0&&n--;for(var i=0;i<n;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,n){m(typeof t=="number"&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=n?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},a.prototype.iadd=function(t){var n,r,i;if(this.negative!==0&&t.negative===0)return this.negative=0,n=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,n=this.isub(t),t.negative=1,n._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var e=0,o=0;o<i.length;o++)n=(0|r.words[o])+(0|i.words[o])+e,this.words[o]=67108863&n,e=n>>>26;for(;e!==0&&o<r.length;o++)n=(0|r.words[o])+e,this.words[o]=67108863&n,e=n>>>26;if(this.length=r.length,e!==0)this.words[this.length]=e,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},a.prototype.add=function(t){var n;return t.negative!==0&&this.negative===0?(t.negative=0,n=this.sub(t),t.negative^=1,n):t.negative===0&&this.negative!==0?(this.negative=0,n=t.sub(this),this.negative=1,n):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var n=this.iadd(t);return t.negative=1,n._normSign()}if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,e=this.cmp(t);if(e===0)return this.negative=0,this.length=1,this.words[0]=0,this;e>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s<i.length;s++)o=(n=(0|r.words[s])-(0|i.words[s])+o)>>26,this.words[s]=67108863&n;for(;o!==0&&s<r.length;s++)o=(n=(0|r.words[s])+o)>>26,this.words[s]=67108863&n;if(o===0&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},a.prototype.sub=function(t){return this.clone().isub(t)};var b=function(t,n,r){var i,e,o,s=t.words,A=n.words,C=r.words,j=0,T=0|s[0],R=8191&T,q=T>>>13,Z=0|s[1],rt=8191&Z,D=Z>>>13,G=0|s[2],z=8191&G,X=G>>>13,st=0|s[3],nt=8191&st,lt=st>>>13,Et=0|s[4],gt=8191&Et,bt=Et>>>13,Bt=0|s[5],Mt=8191&Bt,It=Bt>>>13,J=0|s[6],tt=8191&J,F=J>>>13,H=0|s[7],U=8191&H,it=H>>>13,pt=0|s[8],ft=8191&pt,mt=pt>>>13,re=0|s[9],_t=8191&re,At=re>>>13,fe=0|A[0],kt=8191&fe,Kt=fe>>>13,Ce=0|A[1],Pt=8191&Ce,Ht=Ce>>>13,je=0|A[2],Rt=8191&je,Wt=je>>>13,ye=0|A[3],Nt=8191&ye,Xt=ye>>>13,ke=0|A[4],jt=8191&ke,Zt=ke>>>13,Oe=0|A[5],Dt=8191&Oe,Jt=Oe>>>13,De=0|A[6],Lt=8191&De,Qt=De>>>13,ze=0|A[7],Ut=8191&ze,Yt=ze>>>13,$e=0|A[8],qt=8191&$e,ee=$e>>>13,He=0|A[9],Ft=8191&He,te=He>>>13;r.negative=t.negative^n.negative,r.length=19;var Ae=(j+(i=Math.imul(R,kt))|0)+((8191&(e=(e=Math.imul(R,Kt))+Math.imul(q,kt)|0))<<13)|0;j=((o=Math.imul(q,Kt))+(e>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(rt,kt),e=(e=Math.imul(rt,Kt))+Math.imul(D,kt)|0,o=Math.imul(D,Kt);var Re=(j+(i=i+Math.imul(R,Pt)|0)|0)+((8191&(e=(e=e+Math.imul(R,Ht)|0)+Math.imul(q,Pt)|0))<<13)|0;j=((o=o+Math.imul(q,Ht)|0)+(e>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(z,kt),e=(e=Math.imul(z,Kt))+Math.imul(X,kt)|0,o=Math.imul(X,Kt),i=i+Math.imul(rt,Pt)|0,e=(e=e+Math.imul(rt,Ht)|0)+Math.imul(D,Pt)|0,o=o+Math.imul(D,Ht)|0;var Ke=(j+(i=i+Math.imul(R,Rt)|0)|0)+((8191&(e=(e=e+Math.imul(R,Wt)|0)+Math.imul(q,Rt)|0))<<13)|0;j=((o=o+Math.imul(q,Wt)|0)+(e>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,i=Math.imul(nt,kt),e=(e=Math.imul(nt,Kt))+Math.imul(lt,kt)|0,o=Math.imul(lt,Kt),i=i+Math.imul(z,Pt)|0,e=(e=e+Math.imul(z,Ht)|0)+Math.imul(X,Pt)|0,o=o+Math.imul(X,Ht)|0,i=i+Math.imul(rt,Rt)|0,e=(e=e+Math.imul(rt,Wt)|0)+Math.imul(D,Rt)|0,o=o+Math.imul(D,Wt)|0;var ai=(j+(i=i+Math.imul(R,Nt)|0)|0)+((8191&(e=(e=e+Math.imul(R,Xt)|0)+Math.imul(q,Nt)|0))<<13)|0;j=((o=o+Math.imul(q,Xt)|0)+(e>>>13)|0)+(ai>>>26)|0,ai&=67108863,i=Math.imul(gt,kt),e=(e=Math.imul(gt,Kt))+Math.imul(bt,kt)|0,o=Math.imul(bt,Kt),i=i+Math.imul(nt,Pt)|0,e=(e=e+Math.imul(nt,Ht)|0)+Math.imul(lt,Pt)|0,o=o+Math.imul(lt,Ht)|0,i=i+Math.imul(z,Rt)|0,e=(e=e+Math.imul(z,Wt)|0)+Math.imul(X,Rt)|0,o=o+Math.imul(X,Wt)|0,i=i+Math.imul(rt,Nt)|0,e=(e=e+Math.imul(rt,Xt)|0)+Math.imul(D,Nt)|0,o=o+Math.imul(D,Xt)|0;var ri=(j+(i=i+Math.imul(R,jt)|0)|0)+((8191&(e=(e=e+Math.imul(R,Zt)|0)+Math.imul(q,jt)|0))<<13)|0;j=((o=o+Math.imul(q,Zt)|0)+(e>>>13)|0)+(ri>>>26)|0,ri&=67108863,i=Math.imul(Mt,kt),e=(e=Math.imul(Mt,Kt))+Math.imul(It,kt)|0,o=Math.imul(It,Kt),i=i+Math.imul(gt,Pt)|0,e=(e=e+Math.imul(gt,Ht)|0)+Math.imul(bt,Pt)|0,o=o+Math.imul(bt,Ht)|0,i=i+Math.imul(nt,Rt)|0,e=(e=e+Math.imul(nt,Wt)|0)+Math.imul(lt,Rt)|0,o=o+Math.imul(lt,Wt)|0,i=i+Math.imul(z,Nt)|0,e=(e=e+Math.imul(z,Xt)|0)+Math.imul(X,Nt)|0,o=o+Math.imul(X,Xt)|0,i=i+Math.imul(rt,jt)|0,e=(e=e+Math.imul(rt,Zt)|0)+Math.imul(D,jt)|0,o=o+Math.imul(D,Zt)|0;var si=(j+(i=i+Math.imul(R,Dt)|0)|0)+((8191&(e=(e=e+Math.imul(R,Jt)|0)+Math.imul(q,Dt)|0))<<13)|0;j=((o=o+Math.imul(q,Jt)|0)+(e>>>13)|0)+(si>>>26)|0,si&=67108863,i=Math.imul(tt,kt),e=(e=Math.imul(tt,Kt))+Math.imul(F,kt)|0,o=Math.imul(F,Kt),i=i+Math.imul(Mt,Pt)|0,e=(e=e+Math.imul(Mt,Ht)|0)+Math.imul(It,Pt)|0,o=o+Math.imul(It,Ht)|0,i=i+Math.imul(gt,Rt)|0,e=(e=e+Math.imul(gt,Wt)|0)+Math.imul(bt,Rt)|0,o=o+Math.imul(bt,Wt)|0,i=i+Math.imul(nt,Nt)|0,e=(e=e+Math.imul(nt,Xt)|0)+Math.imul(lt,Nt)|0,o=o+Math.imul(lt,Xt)|0,i=i+Math.imul(z,jt)|0,e=(e=e+Math.imul(z,Zt)|0)+Math.imul(X,jt)|0,o=o+Math.imul(X,Zt)|0,i=i+Math.imul(rt,Dt)|0,e=(e=e+Math.imul(rt,Jt)|0)+Math.imul(D,Dt)|0,o=o+Math.imul(D,Jt)|0;var ui=(j+(i=i+Math.imul(R,Lt)|0)|0)+((8191&(e=(e=e+Math.imul(R,Qt)|0)+Math.imul(q,Lt)|0))<<13)|0;j=((o=o+Math.imul(q,Qt)|0)+(e>>>13)|0)+(ui>>>26)|0,ui&=67108863,i=Math.imul(U,kt),e=(e=Math.imul(U,Kt))+Math.imul(it,kt)|0,o=Math.imul(it,Kt),i=i+Math.imul(tt,Pt)|0,e=(e=e+Math.imul(tt,Ht)|0)+Math.imul(F,Pt)|0,o=o+Math.imul(F,Ht)|0,i=i+Math.imul(Mt,Rt)|0,e=(e=e+Math.imul(Mt,Wt)|0)+Math.imul(It,Rt)|0,o=o+Math.imul(It,Wt)|0,i=i+Math.imul(gt,Nt)|0,e=(e=e+Math.imul(gt,Xt)|0)+Math.imul(bt,Nt)|0,o=o+Math.imul(bt,Xt)|0,i=i+Math.imul(nt,jt)|0,e=(e=e+Math.imul(nt,Zt)|0)+Math.imul(lt,jt)|0,o=o+Math.imul(lt,Zt)|0,i=i+Math.imul(z,Dt)|0,e=(e=e+Math.imul(z,Jt)|0)+Math.imul(X,Dt)|0,o=o+Math.imul(X,Jt)|0,i=i+Math.imul(rt,Lt)|0,e=(e=e+Math.imul(rt,Qt)|0)+Math.imul(D,Lt)|0,o=o+Math.imul(D,Qt)|0;var ci=(j+(i=i+Math.imul(R,Ut)|0)|0)+((8191&(e=(e=e+Math.imul(R,Yt)|0)+Math.imul(q,Ut)|0))<<13)|0;j=((o=o+Math.imul(q,Yt)|0)+(e>>>13)|0)+(ci>>>26)|0,ci&=67108863,i=Math.imul(ft,kt),e=(e=Math.imul(ft,Kt))+Math.imul(mt,kt)|0,o=Math.imul(mt,Kt),i=i+Math.imul(U,Pt)|0,e=(e=e+Math.imul(U,Ht)|0)+Math.imul(it,Pt)|0,o=o+Math.imul(it,Ht)|0,i=i+Math.imul(tt,Rt)|0,e=(e=e+Math.imul(tt,Wt)|0)+Math.imul(F,Rt)|0,o=o+Math.imul(F,Wt)|0,i=i+Math.imul(Mt,Nt)|0,e=(e=e+Math.imul(Mt,Xt)|0)+Math.imul(It,Nt)|0,o=o+Math.imul(It,Xt)|0,i=i+Math.imul(gt,jt)|0,e=(e=e+Math.imul(gt,Zt)|0)+Math.imul(bt,jt)|0,o=o+Math.imul(bt,Zt)|0,i=i+Math.imul(nt,Dt)|0,e=(e=e+Math.imul(nt,Jt)|0)+Math.imul(lt,Dt)|0,o=o+Math.imul(lt,Jt)|0,i=i+Math.imul(z,Lt)|0,e=(e=e+Math.imul(z,Qt)|0)+Math.imul(X,Lt)|0,o=o+Math.imul(X,Qt)|0,i=i+Math.imul(rt,Ut)|0,e=(e=e+Math.imul(rt,Yt)|0)+Math.imul(D,Ut)|0,o=o+Math.imul(D,Yt)|0;var li=(j+(i=i+Math.imul(R,qt)|0)|0)+((8191&(e=(e=e+Math.imul(R,ee)|0)+Math.imul(q,qt)|0))<<13)|0;j=((o=o+Math.imul(q,ee)|0)+(e>>>13)|0)+(li>>>26)|0,li&=67108863,i=Math.imul(_t,kt),e=(e=Math.imul(_t,Kt))+Math.imul(At,kt)|0,o=Math.imul(At,Kt),i=i+Math.imul(ft,Pt)|0,e=(e=e+Math.imul(ft,Ht)|0)+Math.imul(mt,Pt)|0,o=o+Math.imul(mt,Ht)|0,i=i+Math.imul(U,Rt)|0,e=(e=e+Math.imul(U,Wt)|0)+Math.imul(it,Rt)|0,o=o+Math.imul(it,Wt)|0,i=i+Math.imul(tt,Nt)|0,e=(e=e+Math.imul(tt,Xt)|0)+Math.imul(F,Nt)|0,o=o+Math.imul(F,Xt)|0,i=i+Math.imul(Mt,jt)|0,e=(e=e+Math.imul(Mt,Zt)|0)+Math.imul(It,jt)|0,o=o+Math.imul(It,Zt)|0,i=i+Math.imul(gt,Dt)|0,e=(e=e+Math.imul(gt,Jt)|0)+Math.imul(bt,Dt)|0,o=o+Math.imul(bt,Jt)|0,i=i+Math.imul(nt,Lt)|0,e=(e=e+Math.imul(nt,Qt)|0)+Math.imul(lt,Lt)|0,o=o+Math.imul(lt,Qt)|0,i=i+Math.imul(z,Ut)|0,e=(e=e+Math.imul(z,Yt)|0)+Math.imul(X,Ut)|0,o=o+Math.imul(X,Yt)|0,i=i+Math.imul(rt,qt)|0,e=(e=e+Math.imul(rt,ee)|0)+Math.imul(D,qt)|0,o=o+Math.imul(D,ee)|0;var hi=(j+(i=i+Math.imul(R,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(R,te)|0)+Math.imul(q,Ft)|0))<<13)|0;j=((o=o+Math.imul(q,te)|0)+(e>>>13)|0)+(hi>>>26)|0,hi&=67108863,i=Math.imul(_t,Pt),e=(e=Math.imul(_t,Ht))+Math.imul(At,Pt)|0,o=Math.imul(At,Ht),i=i+Math.imul(ft,Rt)|0,e=(e=e+Math.imul(ft,Wt)|0)+Math.imul(mt,Rt)|0,o=o+Math.imul(mt,Wt)|0,i=i+Math.imul(U,Nt)|0,e=(e=e+Math.imul(U,Xt)|0)+Math.imul(it,Nt)|0,o=o+Math.imul(it,Xt)|0,i=i+Math.imul(tt,jt)|0,e=(e=e+Math.imul(tt,Zt)|0)+Math.imul(F,jt)|0,o=o+Math.imul(F,Zt)|0,i=i+Math.imul(Mt,Dt)|0,e=(e=e+Math.imul(Mt,Jt)|0)+Math.imul(It,Dt)|0,o=o+Math.imul(It,Jt)|0,i=i+Math.imul(gt,Lt)|0,e=(e=e+Math.imul(gt,Qt)|0)+Math.imul(bt,Lt)|0,o=o+Math.imul(bt,Qt)|0,i=i+Math.imul(nt,Ut)|0,e=(e=e+Math.imul(nt,Yt)|0)+Math.imul(lt,Ut)|0,o=o+Math.imul(lt,Yt)|0,i=i+Math.imul(z,qt)|0,e=(e=e+Math.imul(z,ee)|0)+Math.imul(X,qt)|0,o=o+Math.imul(X,ee)|0;var fi=(j+(i=i+Math.imul(rt,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(rt,te)|0)+Math.imul(D,Ft)|0))<<13)|0;j=((o=o+Math.imul(D,te)|0)+(e>>>13)|0)+(fi>>>26)|0,fi&=67108863,i=Math.imul(_t,Rt),e=(e=Math.imul(_t,Wt))+Math.imul(At,Rt)|0,o=Math.imul(At,Wt),i=i+Math.imul(ft,Nt)|0,e=(e=e+Math.imul(ft,Xt)|0)+Math.imul(mt,Nt)|0,o=o+Math.imul(mt,Xt)|0,i=i+Math.imul(U,jt)|0,e=(e=e+Math.imul(U,Zt)|0)+Math.imul(it,jt)|0,o=o+Math.imul(it,Zt)|0,i=i+Math.imul(tt,Dt)|0,e=(e=e+Math.imul(tt,Jt)|0)+Math.imul(F,Dt)|0,o=o+Math.imul(F,Jt)|0,i=i+Math.imul(Mt,Lt)|0,e=(e=e+Math.imul(Mt,Qt)|0)+Math.imul(It,Lt)|0,o=o+Math.imul(It,Qt)|0,i=i+Math.imul(gt,Ut)|0,e=(e=e+Math.imul(gt,Yt)|0)+Math.imul(bt,Ut)|0,o=o+Math.imul(bt,Yt)|0,i=i+Math.imul(nt,qt)|0,e=(e=e+Math.imul(nt,ee)|0)+Math.imul(lt,qt)|0,o=o+Math.imul(lt,ee)|0;var Je=(j+(i=i+Math.imul(z,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(z,te)|0)+Math.imul(X,Ft)|0))<<13)|0;j=((o=o+Math.imul(X,te)|0)+(e>>>13)|0)+(Je>>>26)|0,Je&=67108863,i=Math.imul(_t,Nt),e=(e=Math.imul(_t,Xt))+Math.imul(At,Nt)|0,o=Math.imul(At,Xt),i=i+Math.imul(ft,jt)|0,e=(e=e+Math.imul(ft,Zt)|0)+Math.imul(mt,jt)|0,o=o+Math.imul(mt,Zt)|0,i=i+Math.imul(U,Dt)|0,e=(e=e+Math.imul(U,Jt)|0)+Math.imul(it,Dt)|0,o=o+Math.imul(it,Jt)|0,i=i+Math.imul(tt,Lt)|0,e=(e=e+Math.imul(tt,Qt)|0)+Math.imul(F,Lt)|0,o=o+Math.imul(F,Qt)|0,i=i+Math.imul(Mt,Ut)|0,e=(e=e+Math.imul(Mt,Yt)|0)+Math.imul(It,Ut)|0,o=o+Math.imul(It,Yt)|0,i=i+Math.imul(gt,qt)|0,e=(e=e+Math.imul(gt,ee)|0)+Math.imul(bt,qt)|0,o=o+Math.imul(bt,ee)|0;var pi=(j+(i=i+Math.imul(nt,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(nt,te)|0)+Math.imul(lt,Ft)|0))<<13)|0;j=((o=o+Math.imul(lt,te)|0)+(e>>>13)|0)+(pi>>>26)|0,pi&=67108863,i=Math.imul(_t,jt),e=(e=Math.imul(_t,Zt))+Math.imul(At,jt)|0,o=Math.imul(At,Zt),i=i+Math.imul(ft,Dt)|0,e=(e=e+Math.imul(ft,Jt)|0)+Math.imul(mt,Dt)|0,o=o+Math.imul(mt,Jt)|0,i=i+Math.imul(U,Lt)|0,e=(e=e+Math.imul(U,Qt)|0)+Math.imul(it,Lt)|0,o=o+Math.imul(it,Qt)|0,i=i+Math.imul(tt,Ut)|0,e=(e=e+Math.imul(tt,Yt)|0)+Math.imul(F,Ut)|0,o=o+Math.imul(F,Yt)|0,i=i+Math.imul(Mt,qt)|0,e=(e=e+Math.imul(Mt,ee)|0)+Math.imul(It,qt)|0,o=o+Math.imul(It,ee)|0;var gi=(j+(i=i+Math.imul(gt,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(gt,te)|0)+Math.imul(bt,Ft)|0))<<13)|0;j=((o=o+Math.imul(bt,te)|0)+(e>>>13)|0)+(gi>>>26)|0,gi&=67108863,i=Math.imul(_t,Dt),e=(e=Math.imul(_t,Jt))+Math.imul(At,Dt)|0,o=Math.imul(At,Jt),i=i+Math.imul(ft,Lt)|0,e=(e=e+Math.imul(ft,Qt)|0)+Math.imul(mt,Lt)|0,o=o+Math.imul(mt,Qt)|0,i=i+Math.imul(U,Ut)|0,e=(e=e+Math.imul(U,Yt)|0)+Math.imul(it,Ut)|0,o=o+Math.imul(it,Yt)|0,i=i+Math.imul(tt,qt)|0,e=(e=e+Math.imul(tt,ee)|0)+Math.imul(F,qt)|0,o=o+Math.imul(F,ee)|0;var ei=(j+(i=i+Math.imul(Mt,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(Mt,te)|0)+Math.imul(It,Ft)|0))<<13)|0;j=((o=o+Math.imul(It,te)|0)+(e>>>13)|0)+(ei>>>26)|0,ei&=67108863,i=Math.imul(_t,Lt),e=(e=Math.imul(_t,Qt))+Math.imul(At,Lt)|0,o=Math.imul(At,Qt),i=i+Math.imul(ft,Ut)|0,e=(e=e+Math.imul(ft,Yt)|0)+Math.imul(mt,Ut)|0,o=o+Math.imul(mt,Yt)|0,i=i+Math.imul(U,qt)|0,e=(e=e+Math.imul(U,ee)|0)+Math.imul(it,qt)|0,o=o+Math.imul(it,ee)|0;var ii=(j+(i=i+Math.imul(tt,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(tt,te)|0)+Math.imul(F,Ft)|0))<<13)|0;j=((o=o+Math.imul(F,te)|0)+(e>>>13)|0)+(ii>>>26)|0,ii&=67108863,i=Math.imul(_t,Ut),e=(e=Math.imul(_t,Yt))+Math.imul(At,Ut)|0,o=Math.imul(At,Yt),i=i+Math.imul(ft,qt)|0,e=(e=e+Math.imul(ft,ee)|0)+Math.imul(mt,qt)|0,o=o+Math.imul(mt,ee)|0;var Ye=(j+(i=i+Math.imul(U,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(U,te)|0)+Math.imul(it,Ft)|0))<<13)|0;j=((o=o+Math.imul(it,te)|0)+(e>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,i=Math.imul(_t,qt),e=(e=Math.imul(_t,ee))+Math.imul(At,qt)|0,o=Math.imul(At,ee);var di=(j+(i=i+Math.imul(ft,Ft)|0)|0)+((8191&(e=(e=e+Math.imul(ft,te)|0)+Math.imul(mt,Ft)|0))<<13)|0;j=((o=o+Math.imul(mt,te)|0)+(e>>>13)|0)+(di>>>26)|0,di&=67108863;var ni=(j+(i=Math.imul(_t,Ft))|0)+((8191&(e=(e=Math.imul(_t,te))+Math.imul(At,Ft)|0))<<13)|0;return j=((o=Math.imul(At,te))+(e>>>13)|0)+(ni>>>26)|0,ni&=67108863,C[0]=Ae,C[1]=Re,C[2]=Ke,C[3]=ai,C[4]=ri,C[5]=si,C[6]=ui,C[7]=ci,C[8]=li,C[9]=hi,C[10]=fi,C[11]=Je,C[12]=pi,C[13]=gi,C[14]=ei,C[15]=ii,C[16]=Ye,C[17]=di,C[18]=ni,j!==0&&(C[19]=j,r.length++),r};function E(t,n,r){return new I().mulp(t,n,r)}function I(t,n){this.x=t,this.y=n}Math.imul||(b=w),a.prototype.mulTo=function(t,n){var r,i=this.length+t.length;return r=this.length===10&&t.length===10?b(this,t,n):i<63?w(this,t,n):i<1024?function(e,o,s){s.negative=o.negative^e.negative,s.length=e.length+o.length;for(var A=0,C=0,j=0;j<s.length-1;j++){var T=C;C=0;for(var R=67108863&A,q=Math.min(j,o.length-1),Z=Math.max(0,j-e.length+1);Z<=q;Z++){var rt=j-Z,D=(0|e.words[rt])*(0|o.words[Z]),G=67108863&D;R=67108863&(G=G+R|0),C+=(T=(T=T+(D/67108864|0)|0)+(G>>>26)|0)>>>26,T&=67108863}s.words[j]=R,A=T,T=C}return A!==0?s.words[j]=A:s.length--,s.strip()}(this,t,n):E(this,t,n),r},I.prototype.makeRBT=function(t){for(var n=new Array(t),r=a.prototype._countBits(t)-1,i=0;i<t;i++)n[i]=this.revBin(i,r,t);return n},I.prototype.revBin=function(t,n,r){if(t===0||t===r-1)return t;for(var i=0,e=0;e<n;e++)i|=(1&t)<<n-e-1,t>>=1;return i},I.prototype.permute=function(t,n,r,i,e,o){for(var s=0;s<o;s++)i[s]=n[t[s]],e[s]=r[t[s]]},I.prototype.transform=function(t,n,r,i,e,o){this.permute(o,t,n,r,i,e);for(var s=1;s<e;s<<=1)for(var A=s<<1,C=Math.cos(2*Math.PI/A),j=Math.sin(2*Math.PI/A),T=0;T<e;T+=A)for(var R=C,q=j,Z=0;Z<s;Z++){var rt=r[T+Z],D=i[T+Z],G=r[T+Z+s],z=i[T+Z+s],X=R*G-q*z;z=R*z+q*G,G=X,r[T+Z]=rt+G,i[T+Z]=D+z,r[T+Z+s]=rt-G,i[T+Z+s]=D-z,Z!==A&&(X=C*R-j*q,q=C*q+j*R,R=X)}},I.prototype.guessLen13b=function(t,n){var r=1|Math.max(n,t),i=1&r,e=0;for(r=r/2|0;r;r>>>=1)e++;return 1<<e+1+i},I.prototype.conjugate=function(t,n,r){if(!(r<=1))for(var i=0;i<r/2;i++){var e=t[i];t[i]=t[r-i-1],t[r-i-1]=e,e=n[i],n[i]=-n[r-i-1],n[r-i-1]=-e}},I.prototype.normalize13b=function(t,n){for(var r=0,i=0;i<n/2;i++){var e=8192*Math.round(t[2*i+1]/n)+Math.round(t[2*i]/n)+r;t[i]=67108863&e,r=e<67108864?0:e/67108864|0}return t},I.prototype.convert13b=function(t,n,r,i){for(var e=0,o=0;o<n;o++)e+=0|t[o],r[2*o]=8191&e,e>>>=13,r[2*o+1]=8191&e,e>>>=13;for(o=2*n;o<i;++o)r[o]=0;m(e===0),m((-8192&e)==0)},I.prototype.stub=function(t){for(var n=new Array(t),r=0;r<t;r++)n[r]=0;return n},I.prototype.mulp=function(t,n,r){var i=2*this.guessLen13b(t.length,n.length),e=this.makeRBT(i),o=this.stub(i),s=new Array(i),A=new Array(i),C=new Array(i),j=new Array(i),T=new Array(i),R=new Array(i),q=r.words;q.length=i,this.convert13b(t.words,t.length,s,i),this.convert13b(n.words,n.length,j,i),this.transform(s,o,A,C,i,e),this.transform(j,o,T,R,i,e);for(var Z=0;Z<i;Z++){var rt=A[Z]*T[Z]-C[Z]*R[Z];C[Z]=A[Z]*R[Z]+C[Z]*T[Z],A[Z]=rt}return this.conjugate(A,C,i),this.transform(A,C,q,o,i,e),this.conjugate(q,o,i),this.normalize13b(q,i),r.negative=t.negative^n.negative,r.length=t.length+n.length,r.strip()},a.prototype.mul=function(t){var n=new a(null);return n.words=new Array(this.length+t.length),this.mulTo(t,n)},a.prototype.mulf=function(t){var n=new a(null);return n.words=new Array(this.length+t.length),E(this,t,n)},a.prototype.imul=function(t){return this.clone().mulTo(t,this)},a.prototype.imuln=function(t){m(typeof t=="number"),m(t<67108864);for(var n=0,r=0;r<this.length;r++){var i=(0|this.words[r])*t,e=(67108863&i)+(67108863&n);n>>=26,n+=i/67108864|0,n+=e>>>26,this.words[r]=67108863&e}return n!==0&&(this.words[r]=n,this.length++),this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var n=function(o){for(var s=new Array(o.bitLength()),A=0;A<s.length;A++){var C=A/26|0,j=A%26;s[A]=(o.words[C]&1<<j)>>>j}return s}(t);if(n.length===0)return new a(1);for(var r=this,i=0;i<n.length&&n[i]===0;i++,r=r.sqr());if(++i<n.length)for(var e=r.sqr();i<n.length;i++,e=e.sqr())n[i]!==0&&(r=r.mul(e));return r},a.prototype.iushln=function(t){m(typeof t=="number"&&t>=0);var n,r=t%26,i=(t-r)/26,e=67108863>>>26-r<<26-r;if(r!==0){var o=0;for(n=0;n<this.length;n++){var s=this.words[n]&e,A=(0|this.words[n])-s<<r;this.words[n]=A|o,o=s>>>26-r}o&&(this.words[n]=o,this.length++)}if(i!==0){for(n=this.length-1;n>=0;n--)this.words[n+i]=this.words[n];for(n=0;n<i;n++)this.words[n]=0;this.length+=i}return this.strip()},a.prototype.ishln=function(t){return m(this.negative===0),this.iushln(t)},a.prototype.iushrn=function(t,n,r){var i;m(typeof t=="number"&&t>=0),i=n?(n-n%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<<e,A=r;if(i-=o,i=Math.max(0,i),A){for(var C=0;C<o;C++)A.words[C]=this.words[C];A.length=o}if(o!==0)if(this.length>o)for(this.length-=o,C=0;C<this.length;C++)this.words[C]=this.words[C+o];else this.words[0]=0,this.length=1;var j=0;for(C=this.length-1;C>=0&&(j!==0||C>=i);C--){var T=0|this.words[C];this.words[C]=j<<26-e|T>>>e,j=T&s}return A&&j!==0&&(A.words[A.length++]=j),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(t,n,r){return m(this.negative===0),this.iushrn(t,n,r)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){m(typeof t=="number"&&t>=0);var n=t%26,r=(t-n)/26,i=1<<n;return!(this.length<=r||!(this.words[r]&i))},a.prototype.imaskn=function(t){m(typeof t=="number"&&t>=0);var n=t%26,r=(t-n)/26;if(m(this.negative===0,"imaskn works only with positive numbers"),this.length<=r)return this;if(n!==0&&r++,this.length=Math.min(r,this.length),n!==0){var i=67108863^67108863>>>n<<n;this.words[this.length-1]&=i}return this.strip()},a.prototype.maskn=function(t){return this.clone().imaskn(t)},a.prototype.iaddn=function(t){return m(typeof t=="number"),m(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},a.prototype._iaddn=function(t){this.words[0]+=t;for(var n=0;n<this.length&&this.words[n]>=67108864;n++)this.words[n]-=67108864,n===this.length-1?this.words[n+1]=1:this.words[n+1]++;return this.length=Math.max(this.length,n+1),this},a.prototype.isubn=function(t){if(m(typeof t=="number"),m(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var n=0;n<this.length&&this.words[n]<0;n++)this.words[n]+=67108864,this.words[n+1]-=1;return this.strip()},a.prototype.addn=function(t){return this.clone().iaddn(t)},a.prototype.subn=function(t){return this.clone().isubn(t)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(t,n,r){var i,e,o=t.length+r;this._expand(o);var s=0;for(i=0;i<t.length;i++){e=(0|this.words[i+r])+s;var A=(0|t.words[i])*n;s=((e-=67108863&A)>>26)-(A/67108864|0),this.words[i+r]=67108863&e}for(;i<this.length-r;i++)s=(e=(0|this.words[i+r])+s)>>26,this.words[i+r]=67108863&e;if(s===0)return this.strip();for(m(s===-1),s=0,i=0;i<this.length;i++)s=(e=-(0|this.words[i])+s)>>26,this.words[i]=67108863&e;return this.negative=1,this.strip()},a.prototype._wordDiv=function(t,n){var r=(this.length,t.length),i=this.clone(),e=t,o=0|e.words[e.length-1];(r=26-this._countBits(o))!=0&&(e=e.ushln(r),i.iushln(r),o=0|e.words[e.length-1]);var s,A=i.length-e.length;if(n!=="mod"){(s=new a(null)).length=A+1,s.words=new Array(s.length);for(var C=0;C<s.length;C++)s.words[C]=0}var j=i.clone()._ishlnsubmul(e,1,A);j.negative===0&&(i=j,s&&(s.words[A]=1));for(var T=A-1;T>=0;T--){var R=67108864*(0|i.words[e.length+T])+(0|i.words[e.length+T-1]);for(R=Math.min(R/o|0,67108863),i._ishlnsubmul(e,R,T);i.negative!==0;)R--,i.negative=0,i._ishlnsubmul(e,1,T),i.isZero()||(i.negative^=1);s&&(s.words[T]=R)}return s&&s.strip(),i.strip(),n!=="div"&&r!==0&&i.iushrn(r),{div:s||null,mod:i}},a.prototype.divmod=function(t,n,r){return m(!t.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:this.negative!==0&&t.negative===0?(o=this.neg().divmod(t,n),n!=="mod"&&(i=o.div.neg()),n!=="div"&&(e=o.mod.neg(),r&&e.negative!==0&&e.iadd(t)),{div:i,mod:e}):this.negative===0&&t.negative!==0?(o=this.divmod(t.neg(),n),n!=="mod"&&(i=o.div.neg()),{div:i,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),n),n!=="div"&&(e=o.mod.neg(),r&&e.negative!==0&&e.isub(t)),{div:o.div,mod:e}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:t.length===1?n==="div"?{div:this.divn(t.words[0]),mod:null}:n==="mod"?{div:null,mod:new a(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modn(t.words[0]))}:this._wordDiv(t,n);var i,e,o},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var n=this.divmod(t);if(n.mod.isZero())return n.div;var r=n.div.negative!==0?n.mod.isub(t):n.mod,i=t.ushrn(1),e=t.andln(1),o=r.cmp(i);return o<0||e===1&&o===0?n.div:n.div.negative!==0?n.div.isubn(1):n.div.iaddn(1)},a.prototype.modn=function(t){m(t<=67108863);for(var n=67108864%t,r=0,i=this.length-1;i>=0;i--)r=(n*r+(0|this.words[i]))%t;return r},a.prototype.idivn=function(t){m(t<=67108863);for(var n=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*n;this.words[r]=i/t|0,n=i%t}return this.strip()},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){m(t.negative===0),m(!t.isZero());var n=this,r=t.clone();n=n.negative!==0?n.umod(t):n.clone();for(var i=new a(1),e=new a(0),o=new a(0),s=new a(1),A=0;n.isEven()&&r.isEven();)n.iushrn(1),r.iushrn(1),++A;for(var C=r.clone(),j=n.clone();!n.isZero();){for(var T=0,R=1;!(n.words[0]&R)&&T<26;++T,R<<=1);if(T>0)for(n.iushrn(T);T-- >0;)(i.isOdd()||e.isOdd())&&(i.iadd(C),e.isub(j)),i.iushrn(1),e.iushrn(1);for(var q=0,Z=1;!(r.words[0]&Z)&&q<26;++q,Z<<=1);if(q>0)for(r.iushrn(q);q-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(C),s.isub(j)),o.iushrn(1),s.iushrn(1);n.cmp(r)>=0?(n.isub(r),i.isub(o),e.isub(s)):(r.isub(n),o.isub(i),s.isub(e))}return{a:o,b:s,gcd:r.iushln(A)}},a.prototype._invmp=function(t){m(t.negative===0),m(!t.isZero());var n=this,r=t.clone();n=n.negative!==0?n.umod(t):n.clone();for(var i,e=new a(1),o=new a(0),s=r.clone();n.cmpn(1)>0&&r.cmpn(1)>0;){for(var A=0,C=1;!(n.words[0]&C)&&A<26;++A,C<<=1);if(A>0)for(n.iushrn(A);A-- >0;)e.isOdd()&&e.iadd(s),e.iushrn(1);for(var j=0,T=1;!(r.words[0]&T)&&j<26;++j,T<<=1);if(j>0)for(r.iushrn(j);j-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);n.cmp(r)>=0?(n.isub(r),e.isub(o)):(r.isub(n),o.isub(e))}return(i=n.cmpn(1)===0?e:o).cmpn(0)<0&&i.iadd(t),i},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var n=this.clone(),r=t.clone();n.negative=0,r.negative=0;for(var i=0;n.isEven()&&r.isEven();i++)n.iushrn(1),r.iushrn(1);for(;;){for(;n.isEven();)n.iushrn(1);for(;r.isEven();)r.iushrn(1);var e=n.cmp(r);if(e<0){var o=n;n=r,r=o}else if(e===0||r.cmpn(1)===0)break;n.isub(r)}return r.iushln(i)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return(1&this.words[0])==0},a.prototype.isOdd=function(){return(1&this.words[0])==1},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){m(typeof t=="number");var n=t%26,r=(t-n)/26,i=1<<n;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var e=i,o=r;e!==0&&o<this.length;o++){var s=0|this.words[o];e=(s+=e)>>>26,s&=67108863,this.words[o]=s}return e!==0&&(this.words[o]=e,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(t){var n,r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;if(this.strip(),this.length>1)n=1;else{r&&(t=-t),m(t<=67108863,"Number is too big");var i=0|this.words[0];n=i===t?0:i<t?-1:1}return this.negative!==0?0|-n:n},a.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var n=this.ucmp(t);return this.negative!==0?0|-n:n},a.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var n=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],e=0|t.words[r];if(i!==e){i<e?n=-1:i>e&&(n=1);break}}return n},a.prototype.gtn=function(t){return this.cmpn(t)===1},a.prototype.gt=function(t){return this.cmp(t)===1},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return this.cmpn(t)===-1},a.prototype.lt=function(t){return this.cmp(t)===-1},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return this.cmpn(t)===0},a.prototype.eq=function(t){return this.cmp(t)===0},a.red=function(t){return new Q(t)},a.prototype.toRed=function(t){return m(!this.red,"Already a number in reduction context"),m(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return m(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return m(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return m(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return m(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return m(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return m(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return m(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return m(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return m(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return m(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return m(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return m(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return m(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return m(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return m(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};function B(t,n){this.name=t,this.p=new a(n,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function P(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function N(){B.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function $(){B.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function et(){B.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Q(t){if(typeof t=="string"){var n=a._prime(t);this.m=n.p,this.prime=n}else m(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function ot(t){Q.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}B.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},B.prototype.ireduce=function(t){var n,r=t;do this.split(r,this.tmp),n=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength();while(n>this.n);var i=n<this.n?-1:r.ucmp(this.p);return i===0?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},B.prototype.split=function(t,n){t.iushrn(this.n,0,n)},B.prototype.imulK=function(t){return t.imul(this.k)},S(P,B),P.prototype.split=function(t,n){for(var r=4194303,i=Math.min(t.length,9),e=0;e<i;e++)n.words[e]=t.words[e];if(n.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(n.words[n.length++]=o&r,e=10;e<t.length;e++){var s=0|t.words[e];t.words[e-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[e-10]=o,o===0&&t.length>10?t.length-=10:t.length-=9},P.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var n=0,r=0;r<t.length;r++){var i=0|t.words[r];n+=977*i,t.words[r]=67108863&n,n=64*i+(n/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t},S(N,B),S($,B),S(et,B),et.prototype.imulK=function(t){for(var n=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+n,e=67108863&i;i>>>=26,t.words[r]=e,n=i}return n!==0&&(t.words[t.length++]=n),t},a._prime=function(t){if(M[t])return M[t];var n;if(t==="k256")n=new P;else if(t==="p224")n=new N;else if(t==="p192")n=new $;else{if(t!=="p25519")throw new Error("Unknown prime "+t);n=new et}return M[t]=n,n},Q.prototype._verify1=function(t){m(t.negative===0,"red works only with positives"),m(t.red,"red works only with red numbers")},Q.prototype._verify2=function(t,n){m((t.negative|n.negative)==0,"red works only with positives"),m(t.red&&t.red===n.red,"red works only with red numbers")},Q.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},Q.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},Q.prototype.add=function(t,n){this._verify2(t,n);var r=t.add(n);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},Q.prototype.iadd=function(t,n){this._verify2(t,n);var r=t.iadd(n);return r.cmp(this.m)>=0&&r.isub(this.m),r},Q.prototype.sub=function(t,n){this._verify2(t,n);var r=t.sub(n);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},Q.prototype.isub=function(t,n){this._verify2(t,n);var r=t.isub(n);return r.cmpn(0)<0&&r.iadd(this.m),r},Q.prototype.shl=function(t,n){return this._verify1(t),this.imod(t.ushln(n))},Q.prototype.imul=function(t,n){return this._verify2(t,n),this.imod(t.imul(n))},Q.prototype.mul=function(t,n){return this._verify2(t,n),this.imod(t.mul(n))},Q.prototype.isqr=function(t){return this.imul(t,t.clone())},Q.prototype.sqr=function(t){return this.mul(t,t)},Q.prototype.sqrt=function(t){if(t.isZero())return t.clone();var n=this.m.andln(3);if(m(n%2==1),n===3){var r=this.m.add(new a(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),e=0;!i.isZero()&&i.andln(1)===0;)e++,i.iushrn(1);m(!i.isZero());var o=new a(1).toRed(this),s=o.redNeg(),A=this.m.subn(1).iushrn(1),C=this.m.bitLength();for(C=new a(2*C*C).toRed(this);this.pow(C,A).cmp(s)!==0;)C.redIAdd(s);for(var j=this.pow(C,i),T=this.pow(t,i.addn(1).iushrn(1)),R=this.pow(t,i),q=e;R.cmp(o)!==0;){for(var Z=R,rt=0;Z.cmp(o)!==0;rt++)Z=Z.redSqr();m(rt<q);var D=this.pow(j,new a(1).iushln(q-rt-1));T=T.redMul(D),j=D.redSqr(),R=R.redMul(j),q=rt}return T},Q.prototype.invm=function(t){var n=t._invmp(this.m);return n.negative!==0?(n.negative=0,this.imod(n).redNeg()):this.imod(n)},Q.prototype.pow=function(t,n){if(n.isZero())return new a(1).toRed(this);if(n.cmpn(1)===0)return t.clone();var r=new Array(16);r[0]=new a(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var e=r[0],o=0,s=0,A=n.bitLength()%26;for(A===0&&(A=26),i=n.length-1;i>=0;i--){for(var C=n.words[i],j=A-1;j>=0;j--){var T=C>>j&1;e!==r[0]&&(e=this.sqr(e)),T!==0||o!==0?(o<<=1,o|=T,(++s==4||i===0&&j===0)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}A=26}return e},Q.prototype.convertTo=function(t){var n=t.umod(this.m);return n===t?n.clone():n},Q.prototype.convertFrom=function(t){var n=t.clone();return n.red=null,n},a.mont=function(t){return new ot(t)},S(ot,Q),ot.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},ot.prototype.convertFrom=function(t){var n=this.imod(t.mul(this.rinv));return n.red=null,n},ot.prototype.imul=function(t,n){if(t.isZero()||n.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(n),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(i).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},ot.prototype.mul=function(t,n){if(t.isZero()||n.isZero())return new a(0)._forceRed(this);var r=t.mul(n),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(i).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},ot.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}})(W=y.nmd(W),this)},9282:(W,_,y)=>{var x=y(4155),v=y(5108);function m(j){return m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(T){return typeof T}:function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},m(j)}var S,a,p=y(2136).codes,c=p.ERR_AMBIGUOUS_ARGUMENT,l=p.ERR_INVALID_ARG_TYPE,f=p.ERR_INVALID_ARG_VALUE,g=p.ERR_INVALID_RETURN_VALUE,h=p.ERR_MISSING_ARGS,u=y(5961),w=y(9539).inspect,b=y(9539).types,E=b.isPromise,I=b.isRegExp,M=Object.assign?Object.assign:y(8091).assign,B=Object.is?Object.is:y(609);function P(){var j=y(9158);S=j.isDeepEqual,a=j.isDeepStrictEqual}var N=!1,$=W.exports=t,et={};function Q(j){throw j.message instanceof Error?j.message:new u(j)}function ot(j,T,R,q){if(!R){var Z=!1;if(T===0)Z=!0,q="No value argument passed to `assert.ok()`";else if(q instanceof Error)throw q;var rt=new u({actual:R,expected:!0,message:q,operator:"==",stackStartFn:j});throw rt.generatedMessage=Z,rt}}function t(){for(var j=arguments.length,T=new Array(j),R=0;R<j;R++)T[R]=arguments[R];ot.apply(void 0,[t,T.length].concat(T))}$.fail=function j(T,R,q,Z,rt){var D,G=arguments.length;if(G===0?D="Failed":G===1?(q=T,T=void 0):(N===!1&&(N=!0,(x.emitWarning?x.emitWarning:v.warn.bind(v))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")),G===2&&(Z="!=")),q instanceof Error)throw q;var z={actual:T,expected:R,operator:Z===void 0?"fail":Z,stackStartFn:rt||j};q!==void 0&&(z.message=q);var X=new u(z);throw D&&(X.message=D,X.generatedMessage=!0),X},$.AssertionError=u,$.ok=t,$.equal=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");T!=R&&Q({actual:T,expected:R,message:q,operator:"==",stackStartFn:j})},$.notEqual=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");T==R&&Q({actual:T,expected:R,message:q,operator:"!=",stackStartFn:j})},$.deepEqual=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");S===void 0&&P(),S(T,R)||Q({actual:T,expected:R,message:q,operator:"deepEqual",stackStartFn:j})},$.notDeepEqual=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");S===void 0&&P(),S(T,R)&&Q({actual:T,expected:R,message:q,operator:"notDeepEqual",stackStartFn:j})},$.deepStrictEqual=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");S===void 0&&P(),a(T,R)||Q({actual:T,expected:R,message:q,operator:"deepStrictEqual",stackStartFn:j})},$.notDeepStrictEqual=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");S===void 0&&P(),a(T,R)&&Q({actual:T,expected:R,message:q,operator:"notDeepStrictEqual",stackStartFn:j})},$.strictEqual=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");B(T,R)||Q({actual:T,expected:R,message:q,operator:"strictEqual",stackStartFn:j})},$.notStrictEqual=function j(T,R,q){if(arguments.length<2)throw new h("actual","expected");B(T,R)&&Q({actual:T,expected:R,message:q,operator:"notStrictEqual",stackStartFn:j})};var n=function j(T,R,q){var Z=this;(function(rt,D){if(!(rt instanceof D))throw new TypeError("Cannot call a class as a function")})(this,j),R.forEach(function(rt){rt in T&&(q!==void 0&&typeof q[rt]=="string"&&I(T[rt])&&T[rt].test(q[rt])?Z[rt]=q[rt]:Z[rt]=T[rt])})};function r(j,T,R,q){if(typeof T!="function"){if(I(T))return T.test(j);if(arguments.length===2)throw new l("expected",["Function","RegExp"],T);if(m(j)!=="object"||j===null){var Z=new u({actual:j,expected:T,message:R,operator:"deepStrictEqual",stackStartFn:q});throw Z.operator=q.name,Z}var rt=Object.keys(T);if(T instanceof Error)rt.push("name","message");else if(rt.length===0)throw new f("error",T,"may not be an empty object");return S===void 0&&P(),rt.forEach(function(D){typeof j[D]=="string"&&I(T[D])&&T[D].test(j[D])||function(G,z,X,st,nt,lt){if(!(X in G)||!a(G[X],z[X])){if(!st){var Et=new n(G,nt),gt=new n(z,nt,G),bt=new u({actual:Et,expected:gt,operator:"deepStrictEqual",stackStartFn:lt});throw bt.actual=G,bt.expected=z,bt.operator=lt.name,bt}Q({actual:G,expected:z,message:st,operator:lt.name,stackStartFn:lt})}}(j,T,D,R,rt,q)}),!0}return T.prototype!==void 0&&j instanceof T||!Error.isPrototypeOf(T)&&T.call({},j)===!0}function i(j){if(typeof j!="function")throw new l("fn","Function",j);try{j()}catch(T){return T}return et}function e(j){return E(j)||j!==null&&m(j)==="object"&&typeof j.then=="function"&&typeof j.catch=="function"}function o(j){return Promise.resolve().then(function(){var T;if(typeof j=="function"){if(!e(T=j()))throw new g("instance of Promise","promiseFn",T)}else{if(!e(j))throw new l("promiseFn",["Function","Promise"],j);T=j}return Promise.resolve().then(function(){return T}).then(function(){return et}).catch(function(R){return R})})}function s(j,T,R,q){if(typeof R=="string"){if(arguments.length===4)throw new l("error",["Object","Error","Function","RegExp"],R);if(m(T)==="object"&&T!==null){if(T.message===R)throw new c("error/message",'The error message "'.concat(T.message,'" is identical to the message.'))}else if(T===R)throw new c("error/message",'The error "'.concat(T,'" is identical to the message.'));q=R,R=void 0}else if(R!=null&&m(R)!=="object"&&typeof R!="function")throw new l("error",["Object","Error","Function","RegExp"],R);if(T===et){var Z="";R&&R.name&&(Z+=" (".concat(R.name,")")),Z+=q?": ".concat(q):".";var rt=j.name==="rejects"?"rejection":"exception";Q({actual:void 0,expected:R,operator:j.name,message:"Missing expected ".concat(rt).concat(Z),stackStartFn:j})}if(R&&!r(T,R,q,j))throw T}function A(j,T,R,q){if(T!==et){if(typeof R=="string"&&(q=R,R=void 0),!R||r(T,R)){var Z=q?": ".concat(q):".",rt=j.name==="doesNotReject"?"rejection":"exception";Q({actual:T,expected:R,operator:j.name,message:"Got unwanted ".concat(rt).concat(Z,`
17
17
  `)+'Actual message: "'.concat(T&&T.message,'"'),stackStartFn:j})}throw T}}function C(){for(var j=arguments.length,T=new Array(j),R=0;R<j;R++)T[R]=arguments[R];ot.apply(void 0,[C,T.length].concat(T))}$.throws=function j(T){for(var R=arguments.length,q=new Array(R>1?R-1:0),Z=1;Z<R;Z++)q[Z-1]=arguments[Z];s.apply(void 0,[j,i(T)].concat(q))},$.rejects=function j(T){for(var R=arguments.length,q=new Array(R>1?R-1:0),Z=1;Z<R;Z++)q[Z-1]=arguments[Z];return o(T).then(function(rt){return s.apply(void 0,[j,rt].concat(q))})},$.doesNotThrow=function j(T){for(var R=arguments.length,q=new Array(R>1?R-1:0),Z=1;Z<R;Z++)q[Z-1]=arguments[Z];A.apply(void 0,[j,i(T)].concat(q))},$.doesNotReject=function j(T){for(var R=arguments.length,q=new Array(R>1?R-1:0),Z=1;Z<R;Z++)q[Z-1]=arguments[Z];return o(T).then(function(rt){return A.apply(void 0,[j,rt].concat(q))})},$.ifError=function j(T){if(T!=null){var R="ifError got unwanted exception: ";m(T)==="object"&&typeof T.message=="string"?T.message.length===0&&T.constructor?R+=T.constructor.name:R+=T.message:R+=w(T);var q=new u({actual:T,expected:null,operator:"ifError",message:R,stackStartFn:j}),Z=T.stack;if(typeof Z=="string"){var rt=Z.split(`
18
18
  `);rt.shift();for(var D=q.stack.split(`
@@ -134,7 +134,7 @@ Source:
134
134
  *
135
135
  * @author Feross Aboukhadijeh <https://feross.org>
136
136
  * @license MIT
137
- */(function(K){const O=fo,L=Za,Y=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;K.Buffer=_,K.SlowBuffer=g,K.INSPECT_MAX_BYTES=50;const ut=2147483647;K.kMaxLength=ut,_.TYPED_ARRAY_SUPPORT=ht(),!_.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ht(){try{const F=new Uint8Array(1),H={foo:function(){return 42}};return Object.setPrototypeOf(H,Uint8Array.prototype),Object.setPrototypeOf(F,H),F.foo()===42}catch{return!1}}Object.defineProperty(_.prototype,"parent",{enumerable:!0,get:function(){if(_.isBuffer(this))return this.buffer}}),Object.defineProperty(_.prototype,"offset",{enumerable:!0,get:function(){if(_.isBuffer(this))return this.byteOffset}});function W(F){if(F>ut)throw new RangeError('The value "'+F+'" is invalid for option "size"');const H=new Uint8Array(F);return Object.setPrototypeOf(H,_.prototype),H}function _(F,H,U){if(typeof F=="number"){if(typeof H=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(F)}return y(F,H,U)}_.poolSize=8192;function y(F,H,U){if(typeof F=="string")return S(F,H);if(ArrayBuffer.isView(F))return p(F);if(F==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof F);if(Bt(F,ArrayBuffer)||F&&Bt(F.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Bt(F,SharedArrayBuffer)||F&&Bt(F.buffer,SharedArrayBuffer)))return c(F,H,U);if(typeof F=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const it=F.valueOf&&F.valueOf();if(it!=null&&it!==F)return _.from(it,H,U);const pt=l(F);if(pt)return pt;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof F[Symbol.toPrimitive]=="function")return _.from(F[Symbol.toPrimitive]("string"),H,U);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof F)}_.from=function(F,H,U){return y(F,H,U)},Object.setPrototypeOf(_.prototype,Uint8Array.prototype),Object.setPrototypeOf(_,Uint8Array);function x(F){if(typeof F!="number")throw new TypeError('"size" argument must be of type number');if(F<0)throw new RangeError('The value "'+F+'" is invalid for option "size"')}function v(F,H,U){return x(F),F<=0?W(F):H!==void 0?typeof U=="string"?W(F).fill(H,U):W(F).fill(H):W(F)}_.alloc=function(F,H,U){return v(F,H,U)};function m(F){return x(F),W(F<0?0:f(F)|0)}_.allocUnsafe=function(F){return m(F)},_.allocUnsafeSlow=function(F){return m(F)};function S(F,H){if((typeof H!="string"||H==="")&&(H="utf8"),!_.isEncoding(H))throw new TypeError("Unknown encoding: "+H);const U=h(F,H)|0;let it=W(U);const pt=it.write(F,H);return pt!==U&&(it=it.slice(0,pt)),it}function a(F){const H=F.length<0?0:f(F.length)|0,U=W(H);for(let it=0;it<H;it+=1)U[it]=F[it]&255;return U}function p(F){if(Bt(F,Uint8Array)){const H=new Uint8Array(F);return c(H.buffer,H.byteOffset,H.byteLength)}return a(F)}function c(F,H,U){if(H<0||F.byteLength<H)throw new RangeError('"offset" is outside of buffer bounds');if(F.byteLength<H+(U||0))throw new RangeError('"length" is outside of buffer bounds');let it;return H===void 0&&U===void 0?it=new Uint8Array(F):U===void 0?it=new Uint8Array(F,H):it=new Uint8Array(F,H,U),Object.setPrototypeOf(it,_.prototype),it}function l(F){if(_.isBuffer(F)){const H=f(F.length)|0,U=W(H);return U.length===0||F.copy(U,0,0,H),U}if(F.length!==void 0)return typeof F.length!="number"||Mt(F.length)?W(0):a(F);if(F.type==="Buffer"&&Array.isArray(F.data))return a(F.data)}function f(F){if(F>=ut)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ut.toString(16)+" bytes");return F|0}function g(F){return+F!=F&&(F=0),_.alloc(+F)}_.isBuffer=function(H){return H!=null&&H._isBuffer===!0&&H!==_.prototype},_.compare=function(H,U){if(Bt(H,Uint8Array)&&(H=_.from(H,H.offset,H.byteLength)),Bt(U,Uint8Array)&&(U=_.from(U,U.offset,U.byteLength)),!_.isBuffer(H)||!_.isBuffer(U))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(H===U)return 0;let it=H.length,pt=U.length;for(let ft=0,mt=Math.min(it,pt);ft<mt;++ft)if(H[ft]!==U[ft]){it=H[ft],pt=U[ft];break}return it<pt?-1:pt<it?1:0},_.isEncoding=function(H){switch(String(H).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},_.concat=function(H,U){if(!Array.isArray(H))throw new TypeError('"list" argument must be an Array of Buffers');if(H.length===0)return _.alloc(0);let it;if(U===void 0)for(U=0,it=0;it<H.length;++it)U+=H[it].length;const pt=_.allocUnsafe(U);let ft=0;for(it=0;it<H.length;++it){let mt=H[it];if(Bt(mt,Uint8Array))ft+mt.length>pt.length?(_.isBuffer(mt)||(mt=_.from(mt)),mt.copy(pt,ft)):Uint8Array.prototype.set.call(pt,mt,ft);else if(_.isBuffer(mt))mt.copy(pt,ft);else throw new TypeError('"list" argument must be an Array of Buffers');ft+=mt.length}return pt};function h(F,H){if(_.isBuffer(F))return F.length;if(ArrayBuffer.isView(F)||Bt(F,ArrayBuffer))return F.byteLength;if(typeof F!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof F);const U=F.length,it=arguments.length>2&&arguments[2]===!0;if(!it&&U===0)return 0;let pt=!1;for(;;)switch(H){case"ascii":case"latin1":case"binary":return U;case"utf8":case"utf-8":return nt(F).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U*2;case"hex":return U>>>1;case"base64":return gt(F).length;default:if(pt)return it?-1:nt(F).length;H=(""+H).toLowerCase(),pt=!0}}_.byteLength=h;function u(F,H,U){let it=!1;if((H===void 0||H<0)&&(H=0),H>this.length||((U===void 0||U>this.length)&&(U=this.length),U<=0)||(U>>>=0,H>>>=0,U<=H))return"";for(F||(F="utf8");;)switch(F){case"hex":return r(this,H,U);case"utf8":case"utf-8":return et(this,H,U);case"ascii":return t(this,H,U);case"latin1":case"binary":return n(this,H,U);case"base64":return $(this,H,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i(this,H,U);default:if(it)throw new TypeError("Unknown encoding: "+F);F=(F+"").toLowerCase(),it=!0}}_.prototype._isBuffer=!0;function w(F,H,U){const it=F[H];F[H]=F[U],F[U]=it}_.prototype.swap16=function(){const H=this.length;if(H%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let U=0;U<H;U+=2)w(this,U,U+1);return this},_.prototype.swap32=function(){const H=this.length;if(H%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let U=0;U<H;U+=4)w(this,U,U+3),w(this,U+1,U+2);return this},_.prototype.swap64=function(){const H=this.length;if(H%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let U=0;U<H;U+=8)w(this,U,U+7),w(this,U+1,U+6),w(this,U+2,U+5),w(this,U+3,U+4);return this},_.prototype.toString=function(){const H=this.length;return H===0?"":arguments.length===0?et(this,0,H):u.apply(this,arguments)},_.prototype.toLocaleString=_.prototype.toString,_.prototype.equals=function(H){if(!_.isBuffer(H))throw new TypeError("Argument must be a Buffer");return this===H?!0:_.compare(this,H)===0},_.prototype.inspect=function(){let H="";const U=K.INSPECT_MAX_BYTES;return H=this.toString("hex",0,U).replace(/(.{2})/g,"$1 ").trim(),this.length>U&&(H+=" ... "),"<Buffer "+H+">"},Y&&(_.prototype[Y]=_.prototype.inspect),_.prototype.compare=function(H,U,it,pt,ft){if(Bt(H,Uint8Array)&&(H=_.from(H,H.offset,H.byteLength)),!_.isBuffer(H))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof H);if(U===void 0&&(U=0),it===void 0&&(it=H?H.length:0),pt===void 0&&(pt=0),ft===void 0&&(ft=this.length),U<0||it>H.length||pt<0||ft>this.length)throw new RangeError("out of range index");if(pt>=ft&&U>=it)return 0;if(pt>=ft)return-1;if(U>=it)return 1;if(U>>>=0,it>>>=0,pt>>>=0,ft>>>=0,this===H)return 0;let mt=ft-pt,re=it-U;const _t=Math.min(mt,re),At=this.slice(pt,ft),fe=H.slice(U,it);for(let kt=0;kt<_t;++kt)if(At[kt]!==fe[kt]){mt=At[kt],re=fe[kt];break}return mt<re?-1:re<mt?1:0};function b(F,H,U,it,pt){if(F.length===0)return-1;if(typeof U=="string"?(it=U,U=0):U>2147483647?U=2147483647:U<-2147483648&&(U=-2147483648),U=+U,Mt(U)&&(U=pt?0:F.length-1),U<0&&(U=F.length+U),U>=F.length){if(pt)return-1;U=F.length-1}else if(U<0)if(pt)U=0;else return-1;if(typeof H=="string"&&(H=_.from(H,it)),_.isBuffer(H))return H.length===0?-1:E(F,H,U,it,pt);if(typeof H=="number")return H=H&255,typeof Uint8Array.prototype.indexOf=="function"?pt?Uint8Array.prototype.indexOf.call(F,H,U):Uint8Array.prototype.lastIndexOf.call(F,H,U):E(F,[H],U,it,pt);throw new TypeError("val must be string, number or Buffer")}function E(F,H,U,it,pt){let ft=1,mt=F.length,re=H.length;if(it!==void 0&&(it=String(it).toLowerCase(),it==="ucs2"||it==="ucs-2"||it==="utf16le"||it==="utf-16le")){if(F.length<2||H.length<2)return-1;ft=2,mt/=2,re/=2,U/=2}function _t(fe,kt){return ft===1?fe[kt]:fe.readUInt16BE(kt*ft)}let At;if(pt){let fe=-1;for(At=U;At<mt;At++)if(_t(F,At)===_t(H,fe===-1?0:At-fe)){if(fe===-1&&(fe=At),At-fe+1===re)return fe*ft}else fe!==-1&&(At-=At-fe),fe=-1}else for(U+re>mt&&(U=mt-re),At=U;At>=0;At--){let fe=!0;for(let kt=0;kt<re;kt++)if(_t(F,At+kt)!==_t(H,kt)){fe=!1;break}if(fe)return At}return-1}_.prototype.includes=function(H,U,it){return this.indexOf(H,U,it)!==-1},_.prototype.indexOf=function(H,U,it){return b(this,H,U,it,!0)},_.prototype.lastIndexOf=function(H,U,it){return b(this,H,U,it,!1)};function I(F,H,U,it){U=Number(U)||0;const pt=F.length-U;it?(it=Number(it),it>pt&&(it=pt)):it=pt;const ft=H.length;it>ft/2&&(it=ft/2);let mt;for(mt=0;mt<it;++mt){const re=parseInt(H.substr(mt*2,2),16);if(Mt(re))return mt;F[U+mt]=re}return mt}function M(F,H,U,it){return bt(nt(H,F.length-U),F,U,it)}function B(F,H,U,it){return bt(lt(H),F,U,it)}function P(F,H,U,it){return bt(gt(H),F,U,it)}function N(F,H,U,it){return bt(Et(H,F.length-U),F,U,it)}_.prototype.write=function(H,U,it,pt){if(U===void 0)pt="utf8",it=this.length,U=0;else if(it===void 0&&typeof U=="string")pt=U,it=this.length,U=0;else if(isFinite(U))U=U>>>0,isFinite(it)?(it=it>>>0,pt===void 0&&(pt="utf8")):(pt=it,it=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ft=this.length-U;if((it===void 0||it>ft)&&(it=ft),H.length>0&&(it<0||U<0)||U>this.length)throw new RangeError("Attempt to write outside buffer bounds");pt||(pt="utf8");let mt=!1;for(;;)switch(pt){case"hex":return I(this,H,U,it);case"utf8":case"utf-8":return M(this,H,U,it);case"ascii":case"latin1":case"binary":return B(this,H,U,it);case"base64":return P(this,H,U,it);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,H,U,it);default:if(mt)throw new TypeError("Unknown encoding: "+pt);pt=(""+pt).toLowerCase(),mt=!0}},_.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $(F,H,U){return H===0&&U===F.length?O.fromByteArray(F):O.fromByteArray(F.slice(H,U))}function et(F,H,U){U=Math.min(F.length,U);const it=[];let pt=H;for(;pt<U;){const ft=F[pt];let mt=null,re=ft>239?4:ft>223?3:ft>191?2:1;if(pt+re<=U){let _t,At,fe,kt;switch(re){case 1:ft<128&&(mt=ft);break;case 2:_t=F[pt+1],(_t&192)===128&&(kt=(ft&31)<<6|_t&63,kt>127&&(mt=kt));break;case 3:_t=F[pt+1],At=F[pt+2],(_t&192)===128&&(At&192)===128&&(kt=(ft&15)<<12|(_t&63)<<6|At&63,kt>2047&&(kt<55296||kt>57343)&&(mt=kt));break;case 4:_t=F[pt+1],At=F[pt+2],fe=F[pt+3],(_t&192)===128&&(At&192)===128&&(fe&192)===128&&(kt=(ft&15)<<18|(_t&63)<<12|(At&63)<<6|fe&63,kt>65535&&kt<1114112&&(mt=kt))}}mt===null?(mt=65533,re=1):mt>65535&&(mt-=65536,it.push(mt>>>10&1023|55296),mt=56320|mt&1023),it.push(mt),pt+=re}return ot(it)}const Q=4096;function ot(F){const H=F.length;if(H<=Q)return String.fromCharCode.apply(String,F);let U="",it=0;for(;it<H;)U+=String.fromCharCode.apply(String,F.slice(it,it+=Q));return U}function t(F,H,U){let it="";U=Math.min(F.length,U);for(let pt=H;pt<U;++pt)it+=String.fromCharCode(F[pt]&127);return it}function n(F,H,U){let it="";U=Math.min(F.length,U);for(let pt=H;pt<U;++pt)it+=String.fromCharCode(F[pt]);return it}function r(F,H,U){const it=F.length;(!H||H<0)&&(H=0),(!U||U<0||U>it)&&(U=it);let pt="";for(let ft=H;ft<U;++ft)pt+=It[F[ft]];return pt}function i(F,H,U){const it=F.slice(H,U);let pt="";for(let ft=0;ft<it.length-1;ft+=2)pt+=String.fromCharCode(it[ft]+it[ft+1]*256);return pt}_.prototype.slice=function(H,U){const it=this.length;H=~~H,U=U===void 0?it:~~U,H<0?(H+=it,H<0&&(H=0)):H>it&&(H=it),U<0?(U+=it,U<0&&(U=0)):U>it&&(U=it),U<H&&(U=H);const pt=this.subarray(H,U);return Object.setPrototypeOf(pt,_.prototype),pt};function e(F,H,U){if(F%1!==0||F<0)throw new RangeError("offset is not uint");if(F+H>U)throw new RangeError("Trying to access beyond buffer length")}_.prototype.readUintLE=_.prototype.readUIntLE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=this[H],ft=1,mt=0;for(;++mt<U&&(ft*=256);)pt+=this[H+mt]*ft;return pt},_.prototype.readUintBE=_.prototype.readUIntBE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=this[H+--U],ft=1;for(;U>0&&(ft*=256);)pt+=this[H+--U]*ft;return pt},_.prototype.readUint8=_.prototype.readUInt8=function(H,U){return H=H>>>0,U||e(H,1,this.length),this[H]},_.prototype.readUint16LE=_.prototype.readUInt16LE=function(H,U){return H=H>>>0,U||e(H,2,this.length),this[H]|this[H+1]<<8},_.prototype.readUint16BE=_.prototype.readUInt16BE=function(H,U){return H=H>>>0,U||e(H,2,this.length),this[H]<<8|this[H+1]},_.prototype.readUint32LE=_.prototype.readUInt32LE=function(H,U){return H=H>>>0,U||e(H,4,this.length),(this[H]|this[H+1]<<8|this[H+2]<<16)+this[H+3]*16777216},_.prototype.readUint32BE=_.prototype.readUInt32BE=function(H,U){return H=H>>>0,U||e(H,4,this.length),this[H]*16777216+(this[H+1]<<16|this[H+2]<<8|this[H+3])},_.prototype.readBigUInt64LE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=U+this[++H]*2**8+this[++H]*2**16+this[++H]*2**24,ft=this[++H]+this[++H]*2**8+this[++H]*2**16+it*2**24;return BigInt(pt)+(BigInt(ft)<<BigInt(32))}),_.prototype.readBigUInt64BE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=U*2**24+this[++H]*2**16+this[++H]*2**8+this[++H],ft=this[++H]*2**24+this[++H]*2**16+this[++H]*2**8+it;return(BigInt(pt)<<BigInt(32))+BigInt(ft)}),_.prototype.readIntLE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=this[H],ft=1,mt=0;for(;++mt<U&&(ft*=256);)pt+=this[H+mt]*ft;return ft*=128,pt>=ft&&(pt-=Math.pow(2,8*U)),pt},_.prototype.readIntBE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=U,ft=1,mt=this[H+--pt];for(;pt>0&&(ft*=256);)mt+=this[H+--pt]*ft;return ft*=128,mt>=ft&&(mt-=Math.pow(2,8*U)),mt},_.prototype.readInt8=function(H,U){return H=H>>>0,U||e(H,1,this.length),this[H]&128?(255-this[H]+1)*-1:this[H]},_.prototype.readInt16LE=function(H,U){H=H>>>0,U||e(H,2,this.length);const it=this[H]|this[H+1]<<8;return it&32768?it|4294901760:it},_.prototype.readInt16BE=function(H,U){H=H>>>0,U||e(H,2,this.length);const it=this[H+1]|this[H]<<8;return it&32768?it|4294901760:it},_.prototype.readInt32LE=function(H,U){return H=H>>>0,U||e(H,4,this.length),this[H]|this[H+1]<<8|this[H+2]<<16|this[H+3]<<24},_.prototype.readInt32BE=function(H,U){return H=H>>>0,U||e(H,4,this.length),this[H]<<24|this[H+1]<<16|this[H+2]<<8|this[H+3]},_.prototype.readBigInt64LE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=this[H+4]+this[H+5]*2**8+this[H+6]*2**16+(it<<24);return(BigInt(pt)<<BigInt(32))+BigInt(U+this[++H]*2**8+this[++H]*2**16+this[++H]*2**24)}),_.prototype.readBigInt64BE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=(U<<24)+this[++H]*2**16+this[++H]*2**8+this[++H];return(BigInt(pt)<<BigInt(32))+BigInt(this[++H]*2**24+this[++H]*2**16+this[++H]*2**8+it)}),_.prototype.readFloatLE=function(H,U){return H=H>>>0,U||e(H,4,this.length),L.read(this,H,!0,23,4)},_.prototype.readFloatBE=function(H,U){return H=H>>>0,U||e(H,4,this.length),L.read(this,H,!1,23,4)},_.prototype.readDoubleLE=function(H,U){return H=H>>>0,U||e(H,8,this.length),L.read(this,H,!0,52,8)},_.prototype.readDoubleBE=function(H,U){return H=H>>>0,U||e(H,8,this.length),L.read(this,H,!1,52,8)};function o(F,H,U,it,pt,ft){if(!_.isBuffer(F))throw new TypeError('"buffer" argument must be a Buffer instance');if(H>pt||H<ft)throw new RangeError('"value" argument is out of bounds');if(U+it>F.length)throw new RangeError("Index out of range")}_.prototype.writeUintLE=_.prototype.writeUIntLE=function(H,U,it,pt){if(H=+H,U=U>>>0,it=it>>>0,!pt){const re=Math.pow(2,8*it)-1;o(this,H,U,it,re,0)}let ft=1,mt=0;for(this[U]=H&255;++mt<it&&(ft*=256);)this[U+mt]=H/ft&255;return U+it},_.prototype.writeUintBE=_.prototype.writeUIntBE=function(H,U,it,pt){if(H=+H,U=U>>>0,it=it>>>0,!pt){const re=Math.pow(2,8*it)-1;o(this,H,U,it,re,0)}let ft=it-1,mt=1;for(this[U+ft]=H&255;--ft>=0&&(mt*=256);)this[U+ft]=H/mt&255;return U+it},_.prototype.writeUint8=_.prototype.writeUInt8=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,1,255,0),this[U]=H&255,U+1},_.prototype.writeUint16LE=_.prototype.writeUInt16LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,65535,0),this[U]=H&255,this[U+1]=H>>>8,U+2},_.prototype.writeUint16BE=_.prototype.writeUInt16BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,65535,0),this[U]=H>>>8,this[U+1]=H&255,U+2},_.prototype.writeUint32LE=_.prototype.writeUInt32LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,4294967295,0),this[U+3]=H>>>24,this[U+2]=H>>>16,this[U+1]=H>>>8,this[U]=H&255,U+4},_.prototype.writeUint32BE=_.prototype.writeUInt32BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,4294967295,0),this[U]=H>>>24,this[U+1]=H>>>16,this[U+2]=H>>>8,this[U+3]=H&255,U+4};function s(F,H,U,it,pt){D(H,it,pt,F,U,7);let ft=Number(H&BigInt(4294967295));F[U++]=ft,ft=ft>>8,F[U++]=ft,ft=ft>>8,F[U++]=ft,ft=ft>>8,F[U++]=ft;let mt=Number(H>>BigInt(32)&BigInt(4294967295));return F[U++]=mt,mt=mt>>8,F[U++]=mt,mt=mt>>8,F[U++]=mt,mt=mt>>8,F[U++]=mt,U}function A(F,H,U,it,pt){D(H,it,pt,F,U,7);let ft=Number(H&BigInt(4294967295));F[U+7]=ft,ft=ft>>8,F[U+6]=ft,ft=ft>>8,F[U+5]=ft,ft=ft>>8,F[U+4]=ft;let mt=Number(H>>BigInt(32)&BigInt(4294967295));return F[U+3]=mt,mt=mt>>8,F[U+2]=mt,mt=mt>>8,F[U+1]=mt,mt=mt>>8,F[U]=mt,U+8}_.prototype.writeBigUInt64LE=J(function(H,U=0){return s(this,H,U,BigInt(0),BigInt("0xffffffffffffffff"))}),_.prototype.writeBigUInt64BE=J(function(H,U=0){return A(this,H,U,BigInt(0),BigInt("0xffffffffffffffff"))}),_.prototype.writeIntLE=function(H,U,it,pt){if(H=+H,U=U>>>0,!pt){const _t=Math.pow(2,8*it-1);o(this,H,U,it,_t-1,-_t)}let ft=0,mt=1,re=0;for(this[U]=H&255;++ft<it&&(mt*=256);)H<0&&re===0&&this[U+ft-1]!==0&&(re=1),this[U+ft]=(H/mt>>0)-re&255;return U+it},_.prototype.writeIntBE=function(H,U,it,pt){if(H=+H,U=U>>>0,!pt){const _t=Math.pow(2,8*it-1);o(this,H,U,it,_t-1,-_t)}let ft=it-1,mt=1,re=0;for(this[U+ft]=H&255;--ft>=0&&(mt*=256);)H<0&&re===0&&this[U+ft+1]!==0&&(re=1),this[U+ft]=(H/mt>>0)-re&255;return U+it},_.prototype.writeInt8=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,1,127,-128),H<0&&(H=255+H+1),this[U]=H&255,U+1},_.prototype.writeInt16LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,32767,-32768),this[U]=H&255,this[U+1]=H>>>8,U+2},_.prototype.writeInt16BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,32767,-32768),this[U]=H>>>8,this[U+1]=H&255,U+2},_.prototype.writeInt32LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,2147483647,-2147483648),this[U]=H&255,this[U+1]=H>>>8,this[U+2]=H>>>16,this[U+3]=H>>>24,U+4},_.prototype.writeInt32BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,2147483647,-2147483648),H<0&&(H=4294967295+H+1),this[U]=H>>>24,this[U+1]=H>>>16,this[U+2]=H>>>8,this[U+3]=H&255,U+4},_.prototype.writeBigInt64LE=J(function(H,U=0){return s(this,H,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),_.prototype.writeBigInt64BE=J(function(H,U=0){return A(this,H,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function C(F,H,U,it,pt,ft){if(U+it>F.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("Index out of range")}function j(F,H,U,it,pt){return H=+H,U=U>>>0,pt||C(F,H,U,4),L.write(F,H,U,it,23,4),U+4}_.prototype.writeFloatLE=function(H,U,it){return j(this,H,U,!0,it)},_.prototype.writeFloatBE=function(H,U,it){return j(this,H,U,!1,it)};function T(F,H,U,it,pt){return H=+H,U=U>>>0,pt||C(F,H,U,8),L.write(F,H,U,it,52,8),U+8}_.prototype.writeDoubleLE=function(H,U,it){return T(this,H,U,!0,it)},_.prototype.writeDoubleBE=function(H,U,it){return T(this,H,U,!1,it)},_.prototype.copy=function(H,U,it,pt){if(!_.isBuffer(H))throw new TypeError("argument should be a Buffer");if(it||(it=0),!pt&&pt!==0&&(pt=this.length),U>=H.length&&(U=H.length),U||(U=0),pt>0&&pt<it&&(pt=it),pt===it||H.length===0||this.length===0)return 0;if(U<0)throw new RangeError("targetStart out of bounds");if(it<0||it>=this.length)throw new RangeError("Index out of range");if(pt<0)throw new RangeError("sourceEnd out of bounds");pt>this.length&&(pt=this.length),H.length-U<pt-it&&(pt=H.length-U+it);const ft=pt-it;return this===H&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(U,it,pt):Uint8Array.prototype.set.call(H,this.subarray(it,pt),U),ft},_.prototype.fill=function(H,U,it,pt){if(typeof H=="string"){if(typeof U=="string"?(pt=U,U=0,it=this.length):typeof it=="string"&&(pt=it,it=this.length),pt!==void 0&&typeof pt!="string")throw new TypeError("encoding must be a string");if(typeof pt=="string"&&!_.isEncoding(pt))throw new TypeError("Unknown encoding: "+pt);if(H.length===1){const mt=H.charCodeAt(0);(pt==="utf8"&&mt<128||pt==="latin1")&&(H=mt)}}else typeof H=="number"?H=H&255:typeof H=="boolean"&&(H=Number(H));if(U<0||this.length<U||this.length<it)throw new RangeError("Out of range index");if(it<=U)return this;U=U>>>0,it=it===void 0?this.length:it>>>0,H||(H=0);let ft;if(typeof H=="number")for(ft=U;ft<it;++ft)this[ft]=H;else{const mt=_.isBuffer(H)?H:_.from(H,pt),re=mt.length;if(re===0)throw new TypeError('The value "'+H+'" is invalid for argument "value"');for(ft=0;ft<it-U;++ft)this[ft+U]=mt[ft%re]}return this};const R={};function q(F,H,U){R[F]=class extends U{constructor(){super(),Object.defineProperty(this,"message",{value:H.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${F}]`,this.stack,delete this.name}get code(){return F}set code(pt){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:pt,writable:!0})}toString(){return`${this.name} [${F}]: ${this.message}`}}}q("ERR_BUFFER_OUT_OF_BOUNDS",function(F){return F?`${F} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),q("ERR_INVALID_ARG_TYPE",function(F,H){return`The "${F}" argument must be of type number. Received type ${typeof H}`},TypeError),q("ERR_OUT_OF_RANGE",function(F,H,U){let it=`The value of "${F}" is out of range.`,pt=U;return Number.isInteger(U)&&Math.abs(U)>2**32?pt=Z(String(U)):typeof U=="bigint"&&(pt=String(U),(U>BigInt(2)**BigInt(32)||U<-(BigInt(2)**BigInt(32)))&&(pt=Z(pt)),pt+="n"),it+=` It must be ${H}. Received ${pt}`,it},RangeError);function Z(F){let H="",U=F.length;const it=F[0]==="-"?1:0;for(;U>=it+4;U-=3)H=`_${F.slice(U-3,U)}${H}`;return`${F.slice(0,U)}${H}`}function rt(F,H,U){G(H,"offset"),(F[H]===void 0||F[H+U]===void 0)&&z(H,F.length-(U+1))}function D(F,H,U,it,pt,ft){if(F>U||F<H){const mt=typeof H=="bigint"?"n":"";let re;throw ft>3?H===0||H===BigInt(0)?re=`>= 0${mt} and < 2${mt} ** ${(ft+1)*8}${mt}`:re=`>= -(2${mt} ** ${(ft+1)*8-1}${mt}) and < 2 ** ${(ft+1)*8-1}${mt}`:re=`>= ${H}${mt} and <= ${U}${mt}`,new R.ERR_OUT_OF_RANGE("value",re,F)}rt(it,pt,ft)}function G(F,H){if(typeof F!="number")throw new R.ERR_INVALID_ARG_TYPE(H,"number",F)}function z(F,H,U){throw Math.floor(F)!==F?(G(F,U),new R.ERR_OUT_OF_RANGE(U||"offset","an integer",F)):H<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE(U||"offset",`>= ${U?1:0} and <= ${H}`,F)}const X=/[^+/0-9A-Za-z-_]/g;function st(F){if(F=F.split("=")[0],F=F.trim().replace(X,""),F.length<2)return"";for(;F.length%4!==0;)F=F+"=";return F}function nt(F,H){H=H||1/0;let U;const it=F.length;let pt=null;const ft=[];for(let mt=0;mt<it;++mt){if(U=F.charCodeAt(mt),U>55295&&U<57344){if(!pt){if(U>56319){(H-=3)>-1&&ft.push(239,191,189);continue}else if(mt+1===it){(H-=3)>-1&&ft.push(239,191,189);continue}pt=U;continue}if(U<56320){(H-=3)>-1&&ft.push(239,191,189),pt=U;continue}U=(pt-55296<<10|U-56320)+65536}else pt&&(H-=3)>-1&&ft.push(239,191,189);if(pt=null,U<128){if((H-=1)<0)break;ft.push(U)}else if(U<2048){if((H-=2)<0)break;ft.push(U>>6|192,U&63|128)}else if(U<65536){if((H-=3)<0)break;ft.push(U>>12|224,U>>6&63|128,U&63|128)}else if(U<1114112){if((H-=4)<0)break;ft.push(U>>18|240,U>>12&63|128,U>>6&63|128,U&63|128)}else throw new Error("Invalid code point")}return ft}function lt(F){const H=[];for(let U=0;U<F.length;++U)H.push(F.charCodeAt(U)&255);return H}function Et(F,H){let U,it,pt;const ft=[];for(let mt=0;mt<F.length&&!((H-=2)<0);++mt)U=F.charCodeAt(mt),it=U>>8,pt=U%256,ft.push(pt),ft.push(it);return ft}function gt(F){return O.toByteArray(st(F))}function bt(F,H,U,it){let pt;for(pt=0;pt<it&&!(pt+U>=H.length||pt>=F.length);++pt)H[pt+U]=F[pt];return pt}function Bt(F,H){return F instanceof H||F!=null&&F.constructor!=null&&F.constructor.name!=null&&F.constructor.name===H.name}function Mt(F){return F!==F}const It=function(){const F="0123456789abcdef",H=new Array(256);for(let U=0;U<16;++U){const it=U*16;for(let pt=0;pt<16;++pt)H[it+pt]=F[U]+F[pt]}return H}();function J(F){return typeof BigInt>"u"?tt:F}function tt(){throw new Error("BigInt not supported")}})(Va),window.Buffer=Va.Buffer,globalThis.Buffer=Va.Buffer;var ve=(K,O,L)=>new Promise((Y,ut)=>{var ht=y=>{try{_(L.next(y))}catch(x){ut(x)}},W=y=>{try{_(L.throw(y))}catch(x){ut(x)}},_=y=>y.done?Y(y.value):Promise.resolve(y.value).then(ht,W);_((L=L.apply(K,O)).next())});class _p extends sp{constructor(O,L){super(O??oc.create(),L)}getKnowledge(O,L){return ve(this,null,function*(){return this.get("/knowledge",{docId:O,name:L})})}postKnowledge(O){return ve(this,null,function*(){return this.post("/knowledge",O)})}getKnowledgeId(O){return ve(this,null,function*(){return this.get(`/knowledge/${O}`)})}patchKnowledgeId(O,L){return ve(this,null,function*(){return this.patch(`/knowledge/${O}`,L)})}delKnowledgeId(O){return ve(this,null,function*(){return this.delete(`/knowledge/${O}`)})}getKnowledgeIdFile(O){return ve(this,null,function*(){return this.get(`/knowledge/${O}/file`)})}getKnowledgeIdFileList(O,L){return ve(this,null,function*(){return this.listPaged(`/knowledge/${O}/file`,L)})}postKnowledgeIdFile(O,L){return ve(this,null,function*(){return this.post(`/knowledge/${O}/file`,L)})}getUploadTicket(O){return ve(this,null,function*(){return this.get("/upload/ticket",O)})}delKnowledgeIdFileFid(O,L){return ve(this,null,function*(){return this.delete(`/knowledge/${O}/file/${L}`)})}patchKnowledgeIdFileFid(O,L,Y){return ve(this,null,function*(){return this.patch(`/knowledge/${O}/file/${L}`,Y)})}listSessions(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/sessionsa`,L)})}postSession(O,L){return ve(this,null,function*(){return this.post(`/application/${O}/sessions`,L)})}getSession(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/sessions/${L}`)})}patchSessionsId(O,L,Y){return ve(this,null,function*(){return this.patch(`/application/${O}/sessions/${L}`,Y)})}delSessionsId(O,L){return ve(this,null,function*(){return this.delete(`/application/${O}/sessions/${L}`)})}getSessionKnowledgeFile(O,L,Y){return ve(this,null,function*(){return this.get(`/application/${O}session/${L}/file/${Y}`)})}postSessionKnowledgeFile(O,L,Y){return ve(this,null,function*(){return this.post(`/application/${O}session/${L}/file`,Y)})}postComments(O,L,Y){return ve(this,null,function*(){return this.post(`/application/${O}/sessions/${L}/comments`,Y)})}getChatHistorySessionId(O,L,Y){return ve(this,null,function*(){return this.get(`application/${O}/chatHistory/${L}`,Y)})}postChatHistorySessionId(O,L){return ve(this,null,function*(){return this.post(`/chatHistory/${O}`,L)})}getApplications(O){return ve(this,null,function*(){return this.get("/applications",O)})}postApplication(O){return ve(this,null,function*(){return this.post("/applications",O)})}getApplicationId(O){return ve(this,null,function*(){return this.get(`/applications/${O}`)})}patchApplicationId(O,L){return ve(this,null,function*(){return this.patch(`/applications/${O}`,L)})}delApplicationId(O){return ve(this,null,function*(){return this.delete(`/applications/${O}`)})}getApplicationIdSessions(O){return ve(this,null,function*(){return this.get(`/applications/${O}/session`)})}patchFileId(O,L){return ve(this,null,function*(){return this.patch(`/file/${O}`,L)})}getCvforceResource(O){return ve(this,null,function*(){return this.get("/cvforce/resource",O)})}postKnowledgeIdComposedFiles(O,L){return ve(this,null,function*(){return this.post(`/knowledge/${O}/composedFiles`,L)})}getTokensApplicationId(O,L){return ve(this,null,function*(){return this.get(`/tokens/${O}`,L)})}getTokens(O){return ve(this,null,function*(){return this.get("/tokens",O)})}uploadMinioFile(O,L){return ve(this,null,function*(){return new Promise((Y,ut)=>{const ht=new FileReader;ht.readAsArrayBuffer(L),ht.onload=W=>{cc.initMinio({endPoint:O.endpoints[0],useSSL:O.useSSL,accessKey:O.accessKey,secretKey:O.secretKey});const _=Buffer.from(W.target.result),y={"Content-Type":"application/octet-stream"};cc.putObjectBuffer(O.bucket,O.fileKeys[0],_,y,x=>{if(x)throw console.error(x),Error(x);Y(O.fileKeys[0])})}})})}uploadFile(O,L){return ve(this,null,function*(){const Y={files:[L.name],isv:"minio",knowledgeId:O};return this.getUploadTicket(Y).then(ut=>this.uploadMinioFile(ut.minio,L)).catch(ut=>{throw Error(ut)})})}uploadFiles(O,L){return ve(this,null,function*(){const Y={files:L.map(ut=>ut.name),isv:"minio",knowledgeId:O};return this.getUploadTicket(Y).then(ut=>Promise.all(L.map(ht=>this.uploadMinioFile(ut.minio,ht)))).catch(ut=>{throw Error(ut)})})}getAecModels(){return ve(this,null,function*(){return this.get("/aecModels")})}postTextFilter(O){return ve(this,null,function*(){return this.post("/textFilter",O)})}getTenantModel(){return ve(this,null,function*(){return this.get("/tenantModel")})}getPrompts(O,L){return ve(this,null,function*(){return this.get(`application/${O}/promptVariables`,L)})}postPrompt(O,L){return ve(this,null,function*(){return this.post(`application/${O}/promptVariables`,L)})}patchPromptId(O,L,Y){return ve(this,null,function*(){return this.patch(`application/${O}/promptVariables/${L}`,Y)})}delPromptId(O,L){return ve(this,null,function*(){return this.delete(`application/${O}/promptVariables/${L}`)})}getSessionPrompts(O){return ve(this,null,function*(){return this.get(`session/${O}/promptVariables`)})}patchSessionPromptId(O,L,Y){return ve(this,null,function*(){return this.patch(`session/${L}/promptVariables/${O}`,Y)})}getApplicationIdSessionIdPromptVariables(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/session/${L}/promptVariables`)})}patchApplicationIdSessionpromptVariablesId(O,L,Y,ut){return ve(this,null,function*(){return this.patch(`/application/${O}/session/${L}/promptVariables/${Y}`,ut)})}getPresetApplication(O){return ve(this,null,function*(){return this.get("presetApplication",O)})}postKnowledgeConfig(O){return ve(this,null,function*(){return this.post("/knowledgeConfig",O)})}getKnowledgeConfig(O){return ve(this,null,function*(){return this.get(`/knowledgeConfig/${O}`)})}patchKnowledgeConfig(O,L){return ve(this,null,function*(){return this.patch(`/knowledgeConfig/${O}`,L)})}getKnowledgeIdFileId(O,L){return ve(this,null,function*(){return this.get(`/knowledge/${O}/file/${L}`)})}getKnowledgeIdFileIdData(O,L,Y){return ve(this,null,function*(){return this.listPaged(`/knowledge/${O}/file/${L}/data`,Y)})}postKnowledgeIdFileIdData(O,L,Y){return ve(this,null,function*(){return this.post(`/knowledge/${O}/file/${L}/data`,{data:Y})})}patchKnowledgeIdFileIdData(O,L,Y,ut){return ve(this,null,function*(){return this.patch(`/knowledge/${O}/file/${L}/data/${Y}`,{data:ut})})}delKnowledgeIdFileIdDataDid(O,L,Y){return ve(this,null,function*(){return this.delete(`/knowledge/${O}/file/${L}/data/${Y}`)})}getPresetKnowledge(O){return ve(this,null,function*(){return this.get("/presetKnowledge",O)})}patchSessionsIdContext(O){return ve(this,null,function*(){return this.patch(`/sessions/${O}/context`,{})})}postResourceToken(O){return ve(this,null,function*(){return this.post("/resourceToken",O)})}getApplicationIdSession(O){return ve(this,null,function*(){return this.get(`/application/${O}/session`)})}patchApplicationIdSessionsIdContext(O,L){return ve(this,null,function*(){return this.patch(`/application/${O}/sessions/${L}/context`,{})})}postApplicationIdSessions(O,L){return ve(this,null,function*(){return this.post(`/application/${O}/sessions`,L)})}getApplicationIdChatHistorySessionId(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/chatHistory/${L}`)})}postApplicationIdChatHistorySessionIdComments(O,L,Y){return ve(this,null,function*(){return this.post(`/application/${O}/sessions/${L}/comments`,Y)})}getApplicationIdPrompts(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/promptVariables`,L)})}postKnowledgeSourceFile(O,L,Y){return ve(this,null,function*(){return this.post(`/knowledge/${O}/sourceFile/${L}`,Y)})}getMetadata(O){return ve(this,null,function*(){return this.get("/metadata",O)})}postGeneques(O){return ve(this,null,function*(){return this.post("/geneques",O)})}getBaseModel(O){return ve(this,null,function*(){return this.get("/baseModelInfo",{serviceId:O})})}}var vr=(K=>(K[K.Robot=1]="Robot",K[K.User=2]="User",K[K.System=3]="System",K))(vr||{}),pc=(K=>(K[K.Idle=0]="Idle",K[K.Quoted=1]="Quoted",K))(pc||{}),bn=(K=>(K[K.Dialog=0]="Dialog",K[K.Text=1]="Text",K[K.Agent=2]="Agent",K[K.All=3]="All",K))(bn||{});function dc(K,O,L){const Y=x=>{var v;return O&&(sf(O)&&L(403,"aiotToken is timeout"),x.headers=(v=x.headers)!==null&&v!==void 0?v:{},x.headers=Object.assign(Object.assign({},x.headers),{Authorization:O?`Bearer ${O}`:""})),x};function ut(x,v=!0){const m=`${K}${x}`,S=oc.create({baseURL:m});return v&&S.interceptors.request.use(Y),S}const ht=(x,v)=>{x===401&&L(x,"aiotToken is invalid")},W=(x,v)=>{x!==10001&&x!==10215&&L(x,v)},_=ut("/data/v1");return new _p(_,{onHttpStatusError:ht,onAppStatusError:W})}const kr=Object.create(null);kr.open="0",kr.close="1",kr.ping="2",kr.pong="3",kr.message="4",kr.upgrade="5",kr.noop="6";const po=Object.create(null);Object.keys(kr).forEach(K=>{po[kr[K]]=K});const Ka={type:"error",data:"parser error"},mc=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",gc=typeof ArrayBuffer=="function",vc=K=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(K):K&&K.buffer instanceof ArrayBuffer,Ja=({type:K,data:O},L,Y)=>mc&&O instanceof Blob?L?Y(O):yc(O,Y):gc&&(O instanceof ArrayBuffer||vc(O))?L?Y(O):yc(new Blob([O]),Y):Y(kr[K]+(O||"")),yc=(K,O)=>{const L=new FileReader;return L.onload=function(){const Y=L.result.split(",")[1];O("b"+(Y||""))},L.readAsDataURL(K)};function bc(K){return K instanceof Uint8Array?K:K instanceof ArrayBuffer?new Uint8Array(K):new Uint8Array(K.buffer,K.byteOffset,K.byteLength)}let Ga;function Sp(K,O){if(mc&&K.data instanceof Blob)return K.data.arrayBuffer().then(bc).then(O);if(gc&&(K.data instanceof ArrayBuffer||vc(K.data)))return O(bc(K.data));Ja(K,!1,L=>{Ga||(Ga=new TextEncoder),O(Ga.encode(L))})}const wc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let K=0;K<wc.length;K++)Cn[wc.charCodeAt(K)]=K;const Ep=K=>{let O=K.length*.75,L=K.length,Y,ut=0,ht,W,_,y;K[K.length-1]==="="&&(O--,K[K.length-2]==="="&&O--);const x=new ArrayBuffer(O),v=new Uint8Array(x);for(Y=0;Y<L;Y+=4)ht=Cn[K.charCodeAt(Y)],W=Cn[K.charCodeAt(Y+1)],_=Cn[K.charCodeAt(Y+2)],y=Cn[K.charCodeAt(Y+3)],v[ut++]=ht<<2|W>>4,v[ut++]=(W&15)<<4|_>>2,v[ut++]=(_&3)<<6|y&63;return x},kp=typeof ArrayBuffer=="function",Ya=(K,O)=>{if(typeof K!="string")return{type:"message",data:Mc(K,O)};const L=K.charAt(0);return L==="b"?{type:"message",data:Ip(K.substring(1),O)}:po[L]?K.length>1?{type:po[L],data:K.substring(1)}:{type:po[L]}:Ka},Ip=(K,O)=>{if(kp){const L=Ep(K);return Mc(L,O)}else return{base64:!0,data:K}},Mc=(K,O)=>{switch(O){case"blob":return K instanceof Blob?K:new Blob([K]);case"arraybuffer":default:return K instanceof ArrayBuffer?K:K.buffer}},xc=String.fromCharCode(30),Op=(K,O)=>{const L=K.length,Y=new Array(L);let ut=0;K.forEach((ht,W)=>{Ja(ht,!1,_=>{Y[W]=_,++ut===L&&O(Y.join(xc))})})},Ap=(K,O)=>{const L=K.split(xc),Y=[];for(let ut=0;ut<L.length;ut++){const ht=Ya(L[ut],O);if(Y.push(ht),ht.type==="error")break}return Y};function Tp(){return new TransformStream({transform(K,O){Sp(K,L=>{const Y=L.length;let ut;if(Y<126)ut=new Uint8Array(1),new DataView(ut.buffer).setUint8(0,Y);else if(Y<65536){ut=new Uint8Array(3);const ht=new DataView(ut.buffer);ht.setUint8(0,126),ht.setUint16(1,Y)}else{ut=new Uint8Array(9);const ht=new DataView(ut.buffer);ht.setUint8(0,127),ht.setBigUint64(1,BigInt(Y))}K.data&&typeof K.data!="string"&&(ut[0]|=128),O.enqueue(ut),O.enqueue(L)})}})}let Qa;function mo(K){return K.reduce((O,L)=>O+L.length,0)}function go(K,O){if(K[0].length===O)return K.shift();const L=new Uint8Array(O);let Y=0;for(let ut=0;ut<O;ut++)L[ut]=K[0][Y++],Y===K[0].length&&(K.shift(),Y=0);return K.length&&Y<K[0].length&&(K[0]=K[0].slice(Y)),L}function Bp(K,O){Qa||(Qa=new TextDecoder);const L=[];let Y=0,ut=-1,ht=!1;return new TransformStream({transform(W,_){for(L.push(W);;){if(Y===0){if(mo(L)<1)break;const y=go(L,1);ht=(y[0]&128)===128,ut=y[0]&127,ut<126?Y=3:ut===126?Y=1:Y=2}else if(Y===1){if(mo(L)<2)break;const y=go(L,2);ut=new DataView(y.buffer,y.byteOffset,y.length).getUint16(0),Y=3}else if(Y===2){if(mo(L)<8)break;const y=go(L,8),x=new DataView(y.buffer,y.byteOffset,y.length),v=x.getUint32(0);if(v>Math.pow(2,53-32)-1){_.enqueue(Ka);break}ut=v*Math.pow(2,32)+x.getUint32(4),Y=3}else{if(mo(L)<ut)break;const y=go(L,ut);_.enqueue(Ya(ht?y:Qa.decode(y),O)),Y=0}if(ut===0||ut>K){_.enqueue(Ka);break}}}})}const _c=4;function Bi(K){if(K)return jp(K)}function jp(K){for(var O in Bi.prototype)K[O]=Bi.prototype[O];return K}Bi.prototype.on=Bi.prototype.addEventListener=function(K,O){return this._callbacks=this._callbacks||{},(this._callbacks["$"+K]=this._callbacks["$"+K]||[]).push(O),this},Bi.prototype.once=function(K,O){function L(){this.off(K,L),O.apply(this,arguments)}return L.fn=O,this.on(K,L),this},Bi.prototype.off=Bi.prototype.removeListener=Bi.prototype.removeAllListeners=Bi.prototype.removeEventListener=function(K,O){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var L=this._callbacks["$"+K];if(!L)return this;if(arguments.length==1)return delete this._callbacks["$"+K],this;for(var Y,ut=0;ut<L.length;ut++)if(Y=L[ut],Y===O||Y.fn===O){L.splice(ut,1);break}return L.length===0&&delete this._callbacks["$"+K],this},Bi.prototype.emit=function(K){this._callbacks=this._callbacks||{};for(var O=new Array(arguments.length-1),L=this._callbacks["$"+K],Y=1;Y<arguments.length;Y++)O[Y-1]=arguments[Y];if(L){L=L.slice(0);for(var Y=0,ut=L.length;Y<ut;++Y)L[Y].apply(this,O)}return this},Bi.prototype.emitReserved=Bi.prototype.emit,Bi.prototype.listeners=function(K){return this._callbacks=this._callbacks||{},this._callbacks["$"+K]||[]},Bi.prototype.hasListeners=function(K){return!!this.listeners(K).length};const ur=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function Sc(K,...O){return O.reduce((L,Y)=>(K.hasOwnProperty(Y)&&(L[Y]=K[Y]),L),{})}const Rp=ur.setTimeout,Np=ur.clearTimeout;function vo(K,O){O.useNativeTimers?(K.setTimeoutFn=Rp.bind(ur),K.clearTimeoutFn=Np.bind(ur)):(K.setTimeoutFn=ur.setTimeout.bind(ur),K.clearTimeoutFn=ur.clearTimeout.bind(ur))}const Cp=1.33;function Pp(K){return typeof K=="string"?Lp(K):Math.ceil((K.byteLength||K.size)*Cp)}function Lp(K){let O=0,L=0;for(let Y=0,ut=K.length;Y<ut;Y++)O=K.charCodeAt(Y),O<128?L+=1:O<2048?L+=2:O<55296||O>=57344?L+=3:(Y++,L+=4);return L}function Dp(K){let O="";for(let L in K)K.hasOwnProperty(L)&&(O.length&&(O+="&"),O+=encodeURIComponent(L)+"="+encodeURIComponent(K[L]));return O}function Up(K){let O={},L=K.split("&");for(let Y=0,ut=L.length;Y<ut;Y++){let ht=L[Y].split("=");O[decodeURIComponent(ht[0])]=decodeURIComponent(ht[1])}return O}class qp extends Error{constructor(O,L,Y){super(O),this.description=L,this.context=Y,this.type="TransportError"}}class ts extends Bi{constructor(O){super(),this.writable=!1,vo(this,O),this.opts=O,this.query=O.query,this.socket=O.socket}onError(O,L,Y){return super.emitReserved("error",new qp(O,L,Y)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(O){this.readyState==="open"&&this.write(O)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(O){const L=Ya(O,this.socket.binaryType);this.onPacket(L)}onPacket(O){super.emitReserved("packet",O)}onClose(O){this.readyState="closed",super.emitReserved("close",O)}pause(O){}createUri(O,L={}){return O+"://"+this._hostname()+this._port()+this.opts.path+this._query(L)}_hostname(){const O=this.opts.hostname;return O.indexOf(":")===-1?O:"["+O+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(O){const L=Dp(O);return L.length?"?"+L:""}}const Ec="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),es=64,Fp={};let kc=0,yo=0,Ic;function Oc(K){let O="";do O=Ec[K%es]+O,K=Math.floor(K/es);while(K>0);return O}function Ac(){const K=Oc(+new Date);return K!==Ic?(kc=0,Ic=K):K+"."+Oc(kc++)}for(;yo<es;yo++)Fp[Ec[yo]]=yo;let Tc=!1;try{Tc=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const zp=Tc;function Bc(K){const O=K.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!O||zp))return new XMLHttpRequest}catch{}if(!O)try{return new ur[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Lm(){}function $p(){}const Hp=function(){return new Bc({xdomain:!1}).responseType!=null}();class Wp extends ts{constructor(O){if(super(O),this.polling=!1,typeof location<"u"){const Y=location.protocol==="https:";let ut=location.port;ut||(ut=Y?"443":"80"),this.xd=typeof location<"u"&&O.hostname!==location.hostname||ut!==O.port}const L=O&&O.forceBase64;this.supportsBinary=Hp&&!L,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(O){this.readyState="pausing";const L=()=>{this.readyState="paused",O()};if(this.polling||!this.writable){let Y=0;this.polling&&(Y++,this.once("pollComplete",function(){--Y||L()})),this.writable||(Y++,this.once("drain",function(){--Y||L()}))}else L()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(O){const L=Y=>{if(this.readyState==="opening"&&Y.type==="open"&&this.onOpen(),Y.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(Y)};Ap(O,this.socket.binaryType).forEach(L),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const O=()=>{this.write([{type:"close"}])};this.readyState==="open"?O():this.once("open",O)}write(O){this.writable=!1,Op(O,L=>{this.doWrite(L,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const O=this.opts.secure?"https":"http",L=this.query||{};return this.opts.timestampRequests!==!1&&(L[this.opts.timestampParam]=Ac()),!this.supportsBinary&&!L.sid&&(L.b64=1),this.createUri(O,L)}request(O={}){return Object.assign(O,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ir(this.uri(),O)}doWrite(O,L){const Y=this.request({method:"POST",data:O});Y.on("success",L),Y.on("error",(ut,ht)=>{this.onError("xhr post error",ut,ht)})}doPoll(){const O=this.request();O.on("data",this.onData.bind(this)),O.on("error",(L,Y)=>{this.onError("xhr poll error",L,Y)}),this.pollXhr=O}}class Ir extends Bi{constructor(O,L){super(),vo(this,L),this.opts=L,this.method=L.method||"GET",this.uri=O,this.data=L.data!==void 0?L.data:null,this.create()}create(){var O;const L=Sc(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");L.xdomain=!!this.opts.xd;const Y=this.xhr=new Bc(L);try{Y.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){Y.setDisableHeaderCheck&&Y.setDisableHeaderCheck(!0);for(let ut in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(ut)&&Y.setRequestHeader(ut,this.opts.extraHeaders[ut])}}catch{}if(this.method==="POST")try{Y.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{Y.setRequestHeader("Accept","*/*")}catch{}(O=this.opts.cookieJar)===null||O===void 0||O.addCookies(Y),"withCredentials"in Y&&(Y.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(Y.timeout=this.opts.requestTimeout),Y.onreadystatechange=()=>{var ut;Y.readyState===3&&((ut=this.opts.cookieJar)===null||ut===void 0||ut.parseCookies(Y)),Y.readyState===4&&(Y.status===200||Y.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof Y.status=="number"?Y.status:0)},0))},Y.send(this.data)}catch(ut){this.setTimeoutFn(()=>{this.onError(ut)},0);return}typeof document<"u"&&(this.index=Ir.requestsCount++,Ir.requests[this.index]=this)}onError(O){this.emitReserved("error",O,this.xhr),this.cleanup(!0)}cleanup(O){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=$p,O)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Ir.requests[this.index],this.xhr=null}}onLoad(){const O=this.xhr.responseText;O!==null&&(this.emitReserved("data",O),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(Ir.requestsCount=0,Ir.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",jc);else if(typeof addEventListener=="function"){const K="onpagehide"in ur?"pagehide":"unload";addEventListener(K,jc,!1)}}function jc(){for(let K in Ir.requests)Ir.requests.hasOwnProperty(K)&&Ir.requests[K].abort()}const is=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?O=>Promise.resolve().then(O):(O,L)=>L(O,0))(),bo=ur.WebSocket||ur.MozWebSocket,Rc=!0,Vp="arraybuffer",Nc=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Xp extends ts{constructor(O){super(O),this.supportsBinary=!O.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const O=this.uri(),L=this.opts.protocols,Y=Nc?{}:Sc(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(Y.headers=this.opts.extraHeaders);try{this.ws=Rc&&!Nc?L?new bo(O,L):new bo(O):new bo(O,L,Y)}catch(ut){return this.emitReserved("error",ut)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=O=>this.onClose({description:"websocket connection closed",context:O}),this.ws.onmessage=O=>this.onData(O.data),this.ws.onerror=O=>this.onError("websocket error",O)}write(O){this.writable=!1;for(let L=0;L<O.length;L++){const Y=O[L],ut=L===O.length-1;Ja(Y,this.supportsBinary,ht=>{const W={};try{Rc&&this.ws.send(ht)}catch{}ut&&is(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const O=this.opts.secure?"wss":"ws",L=this.query||{};return this.opts.timestampRequests&&(L[this.opts.timestampParam]=Ac()),this.supportsBinary||(L.b64=1),this.createUri(O,L)}check(){return!!bo}}class Zp extends ts{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(O=>{this.onError("webtransport error",O)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(O=>{const L=Bp(Number.MAX_SAFE_INTEGER,this.socket.binaryType),Y=O.readable.pipeThrough(L).getReader(),ut=Tp();ut.readable.pipeTo(O.writable),this.writer=ut.writable.getWriter();const ht=()=>{Y.read().then(({done:_,value:y})=>{_||(this.onPacket(y),ht())}).catch(_=>{})};ht();const W={type:"open"};this.query.sid&&(W.data=`{"sid":"${this.query.sid}"}`),this.writer.write(W).then(()=>this.onOpen())})}))}write(O){this.writable=!1;for(let L=0;L<O.length;L++){const Y=O[L],ut=L===O.length-1;this.writer.write(Y).then(()=>{ut&&is(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var O;(O=this.transport)===null||O===void 0||O.close()}}const Kp={websocket:Xp,webtransport:Zp,polling:Wp},Jp=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Gp=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function rs(K){if(K.length>2e3)throw"URI too long";const O=K,L=K.indexOf("["),Y=K.indexOf("]");L!=-1&&Y!=-1&&(K=K.substring(0,L)+K.substring(L,Y).replace(/:/g,";")+K.substring(Y,K.length));let ut=Jp.exec(K||""),ht={},W=14;for(;W--;)ht[Gp[W]]=ut[W]||"";return L!=-1&&Y!=-1&&(ht.source=O,ht.host=ht.host.substring(1,ht.host.length-1).replace(/;/g,":"),ht.authority=ht.authority.replace("[","").replace("]","").replace(/;/g,":"),ht.ipv6uri=!0),ht.pathNames=Yp(ht,ht.path),ht.queryKey=Qp(ht,ht.query),ht}function Yp(K,O){const L=/\/{2,9}/g,Y=O.replace(L,"/").split("/");return(O.slice(0,1)=="/"||O.length===0)&&Y.splice(0,1),O.slice(-1)=="/"&&Y.splice(Y.length-1,1),Y}function Qp(K,O){const L={};return O.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(Y,ut,ht){ut&&(L[ut]=ht)}),L}let Cc=class Rn extends Bi{constructor(O,L={}){super(),this.binaryType=Vp,this.writeBuffer=[],O&&typeof O=="object"&&(L=O,O=null),O?(O=rs(O),L.hostname=O.host,L.secure=O.protocol==="https"||O.protocol==="wss",L.port=O.port,O.query&&(L.query=O.query)):L.host&&(L.hostname=rs(L.host).host),vo(this,L),this.secure=L.secure!=null?L.secure:typeof location<"u"&&location.protocol==="https:",L.hostname&&!L.port&&(L.port=this.secure?"443":"80"),this.hostname=L.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=L.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=L.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},L),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Up(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(O){const L=Object.assign({},this.opts.query);L.EIO=_c,L.transport=O,this.id&&(L.sid=this.id);const Y=Object.assign({},this.opts,{query:L,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[O]);return new Kp[O](Y)}open(){let O;if(this.opts.rememberUpgrade&&Rn.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)O="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else O=this.transports[0];this.readyState="opening";try{O=this.createTransport(O)}catch{this.transports.shift(),this.open();return}O.open(),this.setTransport(O)}setTransport(O){this.transport&&this.transport.removeAllListeners(),this.transport=O,O.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",L=>this.onClose("transport close",L))}probe(O){let L=this.createTransport(O),Y=!1;Rn.priorWebsocketSuccess=!1;const ut=()=>{Y||(L.send([{type:"ping",data:"probe"}]),L.once("packet",m=>{if(!Y)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",L),!L)return;Rn.priorWebsocketSuccess=L.name==="websocket",this.transport.pause(()=>{Y||this.readyState!=="closed"&&(v(),this.setTransport(L),L.send([{type:"upgrade"}]),this.emitReserved("upgrade",L),L=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=L.name,this.emitReserved("upgradeError",S)}}))};function ht(){Y||(Y=!0,v(),L.close(),L=null)}const W=m=>{const S=new Error("probe error: "+m);S.transport=L.name,ht(),this.emitReserved("upgradeError",S)};function _(){W("transport closed")}function y(){W("socket closed")}function x(m){L&&m.name!==L.name&&ht()}const v=()=>{L.removeListener("open",ut),L.removeListener("error",W),L.removeListener("close",_),this.off("close",y),this.off("upgrading",x)};L.once("open",ut),L.once("error",W),L.once("close",_),this.once("close",y),this.once("upgrading",x),this.upgrades.indexOf("webtransport")!==-1&&O!=="webtransport"?this.setTimeoutFn(()=>{Y||L.open()},200):L.open()}onOpen(){if(this.readyState="open",Rn.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let O=0;const L=this.upgrades.length;for(;O<L;O++)this.probe(this.upgrades[O])}}onPacket(O){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",O),this.emitReserved("heartbeat"),this.resetPingTimeout(),O.type){case"open":this.onHandshake(JSON.parse(O.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const L=new Error("server error");L.code=O.data,this.onError(L);break;case"message":this.emitReserved("data",O.data),this.emitReserved("message",O.data);break}}onHandshake(O){this.emitReserved("handshake",O),this.id=O.sid,this.transport.query.sid=O.sid,this.upgrades=this.filterUpgrades(O.upgrades),this.pingInterval=O.pingInterval,this.pingTimeout=O.pingTimeout,this.maxPayload=O.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const O=this.getWritablePackets();this.transport.send(O),this.prevBufferLen=O.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let L=1;for(let Y=0;Y<this.writeBuffer.length;Y++){const ut=this.writeBuffer[Y].data;if(ut&&(L+=Pp(ut)),Y>0&&L>this.maxPayload)return this.writeBuffer.slice(0,Y);L+=2}return this.writeBuffer}write(O,L,Y){return this.sendPacket("message",O,L,Y),this}send(O,L,Y){return this.sendPacket("message",O,L,Y),this}sendPacket(O,L,Y,ut){if(typeof L=="function"&&(ut=L,L=void 0),typeof Y=="function"&&(ut=Y,Y=null),this.readyState==="closing"||this.readyState==="closed")return;Y=Y||{},Y.compress=Y.compress!==!1;const ht={type:O,data:L,options:Y};this.emitReserved("packetCreate",ht),this.writeBuffer.push(ht),ut&&this.once("flush",ut),this.flush()}close(){const O=()=>{this.onClose("forced close"),this.transport.close()},L=()=>{this.off("upgrade",L),this.off("upgradeError",L),O()},Y=()=>{this.once("upgrade",L),this.once("upgradeError",L)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?Y():O()}):this.upgrading?Y():O()),this}onError(O){Rn.priorWebsocketSuccess=!1,this.emitReserved("error",O),this.onClose("transport error",O)}onClose(O,L){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",O,L),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(O){const L=[];let Y=0;const ut=O.length;for(;Y<ut;Y++)~this.transports.indexOf(O[Y])&&L.push(O[Y]);return L}};Cc.protocol=_c;function td(K,O="",L){let Y=K;L=L||typeof location<"u"&&location,K==null&&(K=L.protocol+"//"+L.host),typeof K=="string"&&(K.charAt(0)==="/"&&(K.charAt(1)==="/"?K=L.protocol+K:K=L.host+K),/^(https?|wss?):\/\//.test(K)||(typeof L<"u"?K=L.protocol+"//"+K:K="https://"+K),Y=rs(K)),Y.port||(/^(http|ws)$/.test(Y.protocol)?Y.port="80":/^(http|ws)s$/.test(Y.protocol)&&(Y.port="443")),Y.path=Y.path||"/";const ht=Y.host.indexOf(":")!==-1?"["+Y.host+"]":Y.host;return Y.id=Y.protocol+"://"+ht+":"+Y.port+O,Y.href=Y.protocol+"://"+ht+(L&&L.port===Y.port?"":":"+Y.port),Y}const ed=typeof ArrayBuffer=="function",id=K=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(K):K.buffer instanceof ArrayBuffer,Pc=Object.prototype.toString,rd=typeof Blob=="function"||typeof Blob<"u"&&Pc.call(Blob)==="[object BlobConstructor]",nd=typeof File=="function"||typeof File<"u"&&Pc.call(File)==="[object FileConstructor]";function ns(K){return ed&&(K instanceof ArrayBuffer||id(K))||rd&&K instanceof Blob||nd&&K instanceof File}function wo(K,O){if(!K||typeof K!="object")return!1;if(Array.isArray(K)){for(let L=0,Y=K.length;L<Y;L++)if(wo(K[L]))return!0;return!1}if(ns(K))return!0;if(K.toJSON&&typeof K.toJSON=="function"&&arguments.length===1)return wo(K.toJSON(),!0);for(const L in K)if(Object.prototype.hasOwnProperty.call(K,L)&&wo(K[L]))return!0;return!1}function od(K){const O=[],L=K.data,Y=K;return Y.data=os(L,O),Y.attachments=O.length,{packet:Y,buffers:O}}function os(K,O){if(!K)return K;if(ns(K)){const L={_placeholder:!0,num:O.length};return O.push(K),L}else if(Array.isArray(K)){const L=new Array(K.length);for(let Y=0;Y<K.length;Y++)L[Y]=os(K[Y],O);return L}else if(typeof K=="object"&&!(K instanceof Date)){const L={};for(const Y in K)Object.prototype.hasOwnProperty.call(K,Y)&&(L[Y]=os(K[Y],O));return L}return K}function ad(K,O){return K.data=as(K.data,O),delete K.attachments,K}function as(K,O){if(!K)return K;if(K&&K._placeholder===!0){if(typeof K.num=="number"&&K.num>=0&&K.num<O.length)return O[K.num];throw new Error("illegal attachments")}else if(Array.isArray(K))for(let L=0;L<K.length;L++)K[L]=as(K[L],O);else if(typeof K=="object")for(const L in K)Object.prototype.hasOwnProperty.call(K,L)&&(K[L]=as(K[L],O));return K}const sd=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],ud=5;var ti;(function(K){K[K.CONNECT=0]="CONNECT",K[K.DISCONNECT=1]="DISCONNECT",K[K.EVENT=2]="EVENT",K[K.ACK=3]="ACK",K[K.CONNECT_ERROR=4]="CONNECT_ERROR",K[K.BINARY_EVENT=5]="BINARY_EVENT",K[K.BINARY_ACK=6]="BINARY_ACK"})(ti||(ti={}));class cd{constructor(O){this.replacer=O}encode(O){return(O.type===ti.EVENT||O.type===ti.ACK)&&wo(O)?this.encodeAsBinary({type:O.type===ti.EVENT?ti.BINARY_EVENT:ti.BINARY_ACK,nsp:O.nsp,data:O.data,id:O.id}):[this.encodeAsString(O)]}encodeAsString(O){let L=""+O.type;return(O.type===ti.BINARY_EVENT||O.type===ti.BINARY_ACK)&&(L+=O.attachments+"-"),O.nsp&&O.nsp!=="/"&&(L+=O.nsp+","),O.id!=null&&(L+=O.id),O.data!=null&&(L+=JSON.stringify(O.data,this.replacer)),L}encodeAsBinary(O){const L=od(O),Y=this.encodeAsString(L.packet),ut=L.buffers;return ut.unshift(Y),ut}}function Lc(K){return Object.prototype.toString.call(K)==="[object Object]"}class ss extends Bi{constructor(O){super(),this.reviver=O}add(O){let L;if(typeof O=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");L=this.decodeString(O);const Y=L.type===ti.BINARY_EVENT;Y||L.type===ti.BINARY_ACK?(L.type=Y?ti.EVENT:ti.ACK,this.reconstructor=new ld(L),L.attachments===0&&super.emitReserved("decoded",L)):super.emitReserved("decoded",L)}else if(ns(O)||O.base64)if(this.reconstructor)L=this.reconstructor.takeBinaryData(O),L&&(this.reconstructor=null,super.emitReserved("decoded",L));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+O)}decodeString(O){let L=0;const Y={type:Number(O.charAt(0))};if(ti[Y.type]===void 0)throw new Error("unknown packet type "+Y.type);if(Y.type===ti.BINARY_EVENT||Y.type===ti.BINARY_ACK){const ht=L+1;for(;O.charAt(++L)!=="-"&&L!=O.length;);const W=O.substring(ht,L);if(W!=Number(W)||O.charAt(L)!=="-")throw new Error("Illegal attachments");Y.attachments=Number(W)}if(O.charAt(L+1)==="/"){const ht=L+1;for(;++L&&!(O.charAt(L)===","||L===O.length););Y.nsp=O.substring(ht,L)}else Y.nsp="/";const ut=O.charAt(L+1);if(ut!==""&&Number(ut)==ut){const ht=L+1;for(;++L;){const W=O.charAt(L);if(W==null||Number(W)!=W){--L;break}if(L===O.length)break}Y.id=Number(O.substring(ht,L+1))}if(O.charAt(++L)){const ht=this.tryParse(O.substr(L));if(ss.isPayloadValid(Y.type,ht))Y.data=ht;else throw new Error("invalid payload")}return Y}tryParse(O){try{return JSON.parse(O,this.reviver)}catch{return!1}}static isPayloadValid(O,L){switch(O){case ti.CONNECT:return Lc(L);case ti.DISCONNECT:return L===void 0;case ti.CONNECT_ERROR:return typeof L=="string"||Lc(L);case ti.EVENT:case ti.BINARY_EVENT:return Array.isArray(L)&&(typeof L[0]=="number"||typeof L[0]=="string"&&sd.indexOf(L[0])===-1);case ti.ACK:case ti.BINARY_ACK:return Array.isArray(L)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ld{constructor(O){this.packet=O,this.buffers=[],this.reconPack=O}takeBinaryData(O){if(this.buffers.push(O),this.buffers.length===this.reconPack.attachments){const L=ad(this.reconPack,this.buffers);return this.finishedReconstruction(),L}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const hd=Object.freeze(Object.defineProperty({__proto__:null,Decoder:ss,Encoder:cd,get PacketType(){return ti},protocol:ud},Symbol.toStringTag,{value:"Module"}));function yr(K,O,L){return K.on(O,L),function(){K.off(O,L)}}const fd=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Dc extends Bi{constructor(O,L,Y){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=O,this.nsp=L,Y&&Y.auth&&(this.auth=Y.auth),this._opts=Object.assign({},Y),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const O=this.io;this.subs=[yr(O,"open",this.onopen.bind(this)),yr(O,"packet",this.onpacket.bind(this)),yr(O,"error",this.onerror.bind(this)),yr(O,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...O){return O.unshift("message"),this.emit.apply(this,O),this}emit(O,...L){if(fd.hasOwnProperty(O))throw new Error('"'+O.toString()+'" is a reserved event name');if(L.unshift(O),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(L),this;const Y={type:ti.EVENT,data:L};if(Y.options={},Y.options.compress=this.flags.compress!==!1,typeof L[L.length-1]=="function"){const W=this.ids++,_=L.pop();this._registerAckCallback(W,_),Y.id=W}const ut=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!ut||!this.connected)||(this.connected?(this.notifyOutgoingListeners(Y),this.packet(Y)):this.sendBuffer.push(Y)),this.flags={},this}_registerAckCallback(O,L){var Y;const ut=(Y=this.flags.timeout)!==null&&Y!==void 0?Y:this._opts.ackTimeout;if(ut===void 0){this.acks[O]=L;return}const ht=this.io.setTimeoutFn(()=>{delete this.acks[O];for(let _=0;_<this.sendBuffer.length;_++)this.sendBuffer[_].id===O&&this.sendBuffer.splice(_,1);L.call(this,new Error("operation has timed out"))},ut),W=(..._)=>{this.io.clearTimeoutFn(ht),L.apply(this,_)};W.withError=!0,this.acks[O]=W}emitWithAck(O,...L){return new Promise((Y,ut)=>{const ht=(W,_)=>W?ut(W):Y(_);ht.withError=!0,L.push(ht),this.emit(O,...L)})}_addToQueue(O){let L;typeof O[O.length-1]=="function"&&(L=O.pop());const Y={id:this._queueSeq++,tryCount:0,pending:!1,args:O,flags:Object.assign({fromQueue:!0},this.flags)};O.push((ut,...ht)=>Y!==this._queue[0]?void 0:(ut!==null?Y.tryCount>this._opts.retries&&(this._queue.shift(),L&&L(ut)):(this._queue.shift(),L&&L(null,...ht)),Y.pending=!1,this._drainQueue())),this._queue.push(Y),this._drainQueue()}_drainQueue(O=!1){if(!this.connected||this._queue.length===0)return;const L=this._queue[0];L.pending&&!O||(L.pending=!0,L.tryCount++,this.flags=L.flags,this.emit.apply(this,L.args))}packet(O){O.nsp=this.nsp,this.io._packet(O)}onopen(){typeof this.auth=="function"?this.auth(O=>{this._sendConnectPacket(O)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(O){this.packet({type:ti.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},O):O})}onerror(O){this.connected||this.emitReserved("connect_error",O)}onclose(O,L){this.connected=!1,delete this.id,this.emitReserved("disconnect",O,L),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(O=>{if(!this.sendBuffer.some(Y=>String(Y.id)===O)){const Y=this.acks[O];delete this.acks[O],Y.withError&&Y.call(this,new Error("socket has been disconnected"))}})}onpacket(O){if(O.nsp===this.nsp)switch(O.type){case ti.CONNECT:O.data&&O.data.sid?this.onconnect(O.data.sid,O.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ti.EVENT:case ti.BINARY_EVENT:this.onevent(O);break;case ti.ACK:case ti.BINARY_ACK:this.onack(O);break;case ti.DISCONNECT:this.ondisconnect();break;case ti.CONNECT_ERROR:this.destroy();const Y=new Error(O.data.message);Y.data=O.data.data,this.emitReserved("connect_error",Y);break}}onevent(O){const L=O.data||[];O.id!=null&&L.push(this.ack(O.id)),this.connected?this.emitEvent(L):this.receiveBuffer.push(Object.freeze(L))}emitEvent(O){if(this._anyListeners&&this._anyListeners.length){const L=this._anyListeners.slice();for(const Y of L)Y.apply(this,O)}super.emit.apply(this,O),this._pid&&O.length&&typeof O[O.length-1]=="string"&&(this._lastOffset=O[O.length-1])}ack(O){const L=this;let Y=!1;return function(...ut){Y||(Y=!0,L.packet({type:ti.ACK,id:O,data:ut}))}}onack(O){const L=this.acks[O.id];typeof L=="function"&&(delete this.acks[O.id],L.withError&&O.data.unshift(null),L.apply(this,O.data))}onconnect(O,L){this.id=O,this.recovered=L&&this._pid===L,this._pid=L,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(O=>this.emitEvent(O)),this.receiveBuffer=[],this.sendBuffer.forEach(O=>{this.notifyOutgoingListeners(O),this.packet(O)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(O=>O()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ti.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(O){return this.flags.compress=O,this}get volatile(){return this.flags.volatile=!0,this}timeout(O){return this.flags.timeout=O,this}onAny(O){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(O),this}prependAny(O){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(O),this}offAny(O){if(!this._anyListeners)return this;if(O){const L=this._anyListeners;for(let Y=0;Y<L.length;Y++)if(O===L[Y])return L.splice(Y,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(O){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(O),this}prependAnyOutgoing(O){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(O),this}offAnyOutgoing(O){if(!this._anyOutgoingListeners)return this;if(O){const L=this._anyOutgoingListeners;for(let Y=0;Y<L.length;Y++)if(O===L[Y])return L.splice(Y,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(O){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const L=this._anyOutgoingListeners.slice();for(const Y of L)Y.apply(this,O.data)}}}function wn(K){K=K||{},this.ms=K.min||100,this.max=K.max||1e4,this.factor=K.factor||2,this.jitter=K.jitter>0&&K.jitter<=1?K.jitter:0,this.attempts=0}wn.prototype.duration=function(){var K=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var O=Math.random(),L=Math.floor(O*this.jitter*K);K=Math.floor(O*10)&1?K+L:K-L}return Math.min(K,this.max)|0},wn.prototype.reset=function(){this.attempts=0},wn.prototype.setMin=function(K){this.ms=K},wn.prototype.setMax=function(K){this.max=K},wn.prototype.setJitter=function(K){this.jitter=K};class us extends Bi{constructor(O,L){var Y;super(),this.nsps={},this.subs=[],O&&typeof O=="object"&&(L=O,O=void 0),L=L||{},L.path=L.path||"/socket.io",this.opts=L,vo(this,L),this.reconnection(L.reconnection!==!1),this.reconnectionAttempts(L.reconnectionAttempts||1/0),this.reconnectionDelay(L.reconnectionDelay||1e3),this.reconnectionDelayMax(L.reconnectionDelayMax||5e3),this.randomizationFactor((Y=L.randomizationFactor)!==null&&Y!==void 0?Y:.5),this.backoff=new wn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(L.timeout==null?2e4:L.timeout),this._readyState="closed",this.uri=O;const ut=L.parser||hd;this.encoder=new ut.Encoder,this.decoder=new ut.Decoder,this._autoConnect=L.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(O){return arguments.length?(this._reconnection=!!O,this):this._reconnection}reconnectionAttempts(O){return O===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=O,this)}reconnectionDelay(O){var L;return O===void 0?this._reconnectionDelay:(this._reconnectionDelay=O,(L=this.backoff)===null||L===void 0||L.setMin(O),this)}randomizationFactor(O){var L;return O===void 0?this._randomizationFactor:(this._randomizationFactor=O,(L=this.backoff)===null||L===void 0||L.setJitter(O),this)}reconnectionDelayMax(O){var L;return O===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=O,(L=this.backoff)===null||L===void 0||L.setMax(O),this)}timeout(O){return arguments.length?(this._timeout=O,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(O){if(~this._readyState.indexOf("open"))return this;this.engine=new Cc(this.uri,this.opts);const L=this.engine,Y=this;this._readyState="opening",this.skipReconnect=!1;const ut=yr(L,"open",function(){Y.onopen(),O&&O()}),ht=_=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",_),O?O(_):this.maybeReconnectOnOpen()},W=yr(L,"error",ht);if(this._timeout!==!1){const _=this._timeout,y=this.setTimeoutFn(()=>{ut(),ht(new Error("timeout")),L.close()},_);this.opts.autoUnref&&y.unref(),this.subs.push(()=>{this.clearTimeoutFn(y)})}return this.subs.push(ut),this.subs.push(W),this}connect(O){return this.open(O)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const O=this.engine;this.subs.push(yr(O,"ping",this.onping.bind(this)),yr(O,"data",this.ondata.bind(this)),yr(O,"error",this.onerror.bind(this)),yr(O,"close",this.onclose.bind(this)),yr(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(O){try{this.decoder.add(O)}catch(L){this.onclose("parse error",L)}}ondecoded(O){is(()=>{this.emitReserved("packet",O)},this.setTimeoutFn)}onerror(O){this.emitReserved("error",O)}socket(O,L){let Y=this.nsps[O];return Y?this._autoConnect&&!Y.active&&Y.connect():(Y=new Dc(this,O,L),this.nsps[O]=Y),Y}_destroy(O){const L=Object.keys(this.nsps);for(const Y of L)if(this.nsps[Y].active)return;this._close()}_packet(O){const L=this.encoder.encode(O);for(let Y=0;Y<L.length;Y++)this.engine.write(L[Y],O.options)}cleanup(){this.subs.forEach(O=>O()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(O,L){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",O,L),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const O=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const L=this.backoff.duration();this._reconnecting=!0;const Y=this.setTimeoutFn(()=>{O.skipReconnect||(this.emitReserved("reconnect_attempt",O.backoff.attempts),!O.skipReconnect&&O.open(ut=>{ut?(O._reconnecting=!1,O.reconnect(),this.emitReserved("reconnect_error",ut)):O.onreconnect()}))},L);this.opts.autoUnref&&Y.unref(),this.subs.push(()=>{this.clearTimeoutFn(Y)})}}onreconnect(){const O=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",O)}}const Pn={};function Mo(K,O){typeof K=="object"&&(O=K,K=void 0),O=O||{};const L=td(K,O.path||"/socket.io"),Y=L.source,ut=L.id,ht=L.path,W=Pn[ut]&&ht in Pn[ut].nsps,_=O.forceNew||O["force new connection"]||O.multiplex===!1||W;let y;return _?y=new us(Y,O):(Pn[ut]||(Pn[ut]=new us(Y,O)),y=Pn[ut]),L.query&&!O.query&&(O.query=L.queryKey),y.socket(L.path,O)}Object.assign(Mo,{Manager:us,Socket:Dc,io:Mo,connect:Mo});var nn;(function(K){K[K.Normal=0]="Normal",K[K.Debug=1]="Debug"})(nn||(nn={}));let xo;const pd=new Uint8Array(16);function dd(){if(!xo&&(xo=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!xo))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return xo(pd)}const Li=[];for(let K=0;K<256;++K)Li.push((K+256).toString(16).slice(1));function md(K,O=0){return Li[K[O+0]]+Li[K[O+1]]+Li[K[O+2]]+Li[K[O+3]]+"-"+Li[K[O+4]]+Li[K[O+5]]+"-"+Li[K[O+6]]+Li[K[O+7]]+"-"+Li[K[O+8]]+Li[K[O+9]]+"-"+Li[K[O+10]]+Li[K[O+11]]+Li[K[O+12]]+Li[K[O+13]]+Li[K[O+14]]+Li[K[O+15]]}const Uc={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qc(K,O,L){if(Uc.randomUUID&&!O&&!K)return Uc.randomUUID();K=K||{};const Y=K.random||(K.rng||dd)();if(Y[6]=Y[6]&15|64,Y[8]=Y[8]&63|128,O){L=L||0;for(let ut=0;ut<16;++ut)O[L+ut]=Y[ut];return O}return md(Y)}const on=new Pi("[EventBus] ");class Fc{constructor(O=!1){Object.defineProperty(this,"eventListenerMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),O&&on.disable()}getEventListenerMap(){return Object.assign({},this.eventListenerMap)}on(O,L,Y=!1){this.eventListenerMap[O]||(this.eventListenerMap[O]=[]),Y?this.eventListenerMap[O].push({fn:L,once:!0}):this.eventListenerMap[O].push(L),on.log(`add event ${O} listener ${Y?", call once":""}`)}once(O,L){this.on(O,L,!0)}off(O,L){if(this.eventListenerMap[O]){const Y=this.eventListenerMap[O].findIndex(ut=>{if(typeof ut=="function"&&L===ut)return!0;if(ut=ut,ut.fn===L)return!0});Y<0?on.log(`event ${O} listener ${L.name} is not found`):(this.eventListenerMap[O].splice(Y,1),on.log(`remove event ${O} listener`))}else on.log(`event ${O} listeners is empty`)}emit(O,L){if(!this.eventListenerMap[O]){on.log(`event ${O} listeners is empty`);return}const Y=[];for(let ut=0;ut<this.eventListenerMap[O].length;ut++){const ht=this.eventListenerMap[O][ut];typeof ht=="function"?ht(L):Y.push(ht)}Y.forEach(ut=>{ut&&(ut.fn(L),this.off(O,ut.fn))}),on.log(`event ${O} is fired, has ${this.eventListenerMap[O].length} listeners`)}removeAllListeners(){this.eventListenerMap={}}}var _o;(function(K){K[K.enable=1]="enable",K[K.disable=2]="disable"})(_o||(_o={}));const zi=new Pi("[Session] ",!0);var $i;(function(K){K.DataRequestFailed="data request error",K.SocketConnectionFailed="socket error",K.IdUndefined="session id is not defined",K.SendingEmptyContent="failed at sending empty content",K.Frozen="session is frozen",K.UserModeError="failed at setting socket user mode",K.Inactive="session is inactive"})($i||($i={})),$i.IdUndefined+"",$i.SendingEmptyContent+"",$i.Frozen+"";class cs{constructor(O,L="",Y,ut,ht,W){Object.defineProperty(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:O}),Object.defineProperty(this,"lazyload",{enumerable:!0,configurable:!0,writable:!0,value:ut}),Object.defineProperty(this,"_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_frozen",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"inactivating",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_ready",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:new Fc}),Object.defineProperty(this,"_applicationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_application",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"messages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_loadingMessages",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_loadingMessagesSize",{enumerable:!0,configurable:!0,writable:!0,value:10}),Object.defineProperty(this,"cvforceApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"socket",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_promptVariables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"activing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_stopAnswer",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dataLoading",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dataLoaded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.client=W||null,this._applicationId=oo(O).rid||Mi.configuration.applicationId,this.cvforceApi=this.getService(),ht&&(this._application=ht),this.event.emit("init",{applicationId:this._applicationId,sessionId:L}),this.loadApplicationInfo().then(()=>{var _;if(L)this._id=L,this.event.emit("data:loading"),Y?(this.data=Y,ut||(this._dataLoading=!0,this.cvforceApi.getSession(this.applicationId,L).then(y=>Le(this,void 0,void 0,function*(){this.data=y,this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,L)})).then(()=>Le(this,void 0,void 0,function*(){this.messages=[],yield this.fetchMessages(),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data)})))):(this._dataLoading=!0,this.cvforceApi.getSession(this.applicationId,L).then(y=>Le(this,void 0,void 0,function*(){this.data=y,this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,L)})).then(()=>Le(this,void 0,void 0,function*(){this.messages=[],yield this.fetchMessages(),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data),this._dataLoading=!1,this._dataLoaded=!0})));else{const y=(Y==null?void 0:Y.name)||"新建会话";this.event.emit("data:creating",{applicationId:this._applicationId,name:y}),this.event.emit("data:loading"),this.cvforceApi.postSession(this.applicationId,{name:y,netOpen:Y==null?void 0:Y.netOpen,knowledgeList:(_=Y==null?void 0:Y.knowledges)===null||_===void 0?void 0:_.map(x=>x.id),applicationId:this._applicationId}).then(x=>Le(this,void 0,void 0,function*(){this._id=x.id,this.data=x,this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,this._id),yield(()=>{if(Y!=null&&Y.knowledges)return this.setKnowledges((Y==null?void 0:Y.knowledges)||void 0)})(),yield(()=>{if(Y!=null&&Y.promptVariables){const v=this._promptVariables.map(m=>{var S,a;const p=((a=(S=Y.promptVariables)===null||S===void 0?void 0:S.find(c=>c.key===m.key))===null||a===void 0?void 0:a.value)||"";return Object.assign(Object.assign({},m),{value:p})}).sort((m,S)=>m.key.localeCompare(S.key));return this.setPromptVariables(v||[])}else return})(),this.event.emit("data:created",this.data),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data),this._ready=!0,this.event.emit("ready")}))}})}fetchData(){return Le(this,void 0,void 0,function*(){if(!this.data)throw Error("session data is not loaded");return yield this.cvforceApi.getSession(this.applicationId,this.data.id).then(O=>Le(this,void 0,void 0,function*(){return this.data=O,this.event.emit("data:updated",this.data),O}))})}get id(){var O;return this._id||((O=this.data)===null||O===void 0?void 0:O.id)||""}get applicationId(){return this._applicationId}get application(){return this._application}loadApplicationInfo(){if(this._application)return Promise.resolve(this._application);if(this._applicationId&&!this._application)return this.event.emit("application:data:loading"),this.cvforceApi.getApplicationId(this._applicationId).then(O=>(this._application=O,this.event.emit("application:data:loaded",O),O));throw Error("application id is not defined")}get ready(){return this._ready}get frozen(){return this._frozen}set frozen(O){O===!1&&this.inactivating&&this.socket&&(this.socket.disconnect(),this.socket=null,this.event.emit("inactivated")),this._frozen=O,this.event.emit("frozen",O)}get knowledges(){if(!this.data)throw Error("session data is not loaded");return this.data.knowledges||void 0}setKnowledges(O){return Le(this,void 0,void 0,function*(){var L;if(((L=this._application)===null||L===void 0?void 0:L.type)===bn.Agent){console.warn("Agent Application Sessions are disabled to setKnowledges.");return}if(!this.data)throw Error("session data is not loaded");return yield this.cvforceApi.patchSessionsId(this._applicationId,this.data.id,{knowledges:O}),this.data.knowledges=O,this.event.emit("data:updated",this.data),this.event.emit("data:updated:knowledges",{knowledges:O}),O})}validateConfigs(){if(!this._id)throw Error("session id is not defined");if(!this.data)throw Error("session data is not loaded");const O=this.promptVariables.filter(L=>L.status===pc.Quoted).filter(L=>!L.value);if(O.length)throw Error(`在提示词中被引用的变量值不能为空, 请检查以下变量: ${O.map(L=>L.key).join(", ")}`)}get promptVariables(){return this._promptVariables.filter(O=>O.key!=="query")}setPromptVariables(O){return Le(this,void 0,void 0,function*(){var L;if(((L=this._application)===null||L===void 0?void 0:L.type)===bn.Agent){console.warn("Agent Application Sessions are disabled to setPromptVariables.");return}const Y=this._promptVariables.map(ut=>{var ht;const W=((ht=O==null?void 0:O.find(_=>_.key===ut.key))===null||ht===void 0?void 0:ht.value)||ut.value;return Object.assign(Object.assign({},ut),{value:W})}).sort((ut,ht)=>ut.key.localeCompare(ht.key));if(yield Promise.all(Y.filter(ut=>ut.key!=="query").map(ut=>{if(!this.data)throw Error("session data is not loaded");if(!(!ut.id||!ut.key))return this.cvforceApi.patchApplicationIdSessionpromptVariablesId(this._applicationId,this.data.id,ut.id,{value:ut.value}).catch(console.error)})),!this.data)throw Error("session data is not loaded");return this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,this.data.id),this.event.emit("data:updated",this.data),this.event.emit("data:updated:promptVariables",{promptVariables:this._promptVariables}),this._promptVariables})}get netOpen(){if(!this.data)throw Error("session data is not loaded");return this.data.netOpen||!1}setNetOpen(O){return Le(this,void 0,void 0,function*(){var L,Y,ut;if(zi.log("setNetOpen:",O),zi.log("application arrange setting value: ",(L=this._application)===null||L===void 0?void 0:L.arrange[0].enableNetOpen),((Y=this._application)===null||Y===void 0?void 0:Y.type)===bn.Agent){console.warn("Agent Application Sessions are disabled to setNetOpen.");return}if(((ut=this._application)===null||ut===void 0?void 0:ut.arrange[0].enableNetOpen)===!1){console.warn("This Application is disabled to change netOpen.");return}if(!this.data)throw Error("session data is not loaded");return yield this.cvforceApi.patchSessionsId(this._applicationId,this.data.id,{netOpen:O?_o.enable:_o.disable}),this.data.netOpen=O,zi.log("data:updated",this.data),this.event.emit("data:updated",this.data),this.event.emit("data:updated:netOpen",{netOpen:O}),O})}getService(){return dc(Mi.configuration.apiRoot,this.token,(O,L)=>{const Y=new Error($i.DataRequestFailed);zi.error(Y),this.event.emit("error",Y)})}addEventListener(O,L,Y=!1){if(typeof L!="function")throw Error("event listener is not a function");if(Y){this.event.once(O,L);return}this.event.on(O,L)}removeEventListener(O,L){this.event.off(O,L)}fetchMessages(){return Le(this,arguments,void 0,function*(O={}){var L,Y;const ut={pageSize:this._loadingMessagesSize};if(this._id){O=Object.assign(Object.assign({},ut),O),this.event.emit("history:loading"),zi.log("history:loading"),(O.endTime||O.startTime)&&(this.event.emit("history:moreloading",O),zi.log("history:moreloading",O)),this._loadingMessages=!0;const ht=yield this.cvforceApi.getChatHistorySessionId(this._applicationId,this._id,O),W=ht.map((y,x)=>{var v,m;let S=[],a;return typeof((v=y.agentHistoryList)===null||v===void 0?void 0:v.agentList)=="string"&&(S=JSON.parse(y.agentHistoryList.agentList).reduce((c,l)=>(c[l.data.step-1]||(c[l.data.step-1]=[]),c[l.data.step-1].push(l),c),[])),x===ht.length-1&&(a=(m=this.data)===null||m===void 0?void 0:m.lastRelatedQuestion),Object.assign(Object.assign({},y),{actions:S,relatedQuesion:a})});if(!O.endTime&&!O.startTime){const y=this.messages[this.messages.length-1];y&&!y.relatedQuesion&&(y.relatedQuesion=(L=this.data)===null||L===void 0?void 0:L.lastRelatedQuestion),this.messages=[...W,...this.messages]}else if(O.endTime&&!O.startTime){const y=this.messages.findIndex(x=>x.ts===O.endTime);this.messages.splice(0,y+1),this.messages=[...W,...this.messages]}else if(!O.endTime&&O.startTime){const y=this.messages.findLastIndex(x=>x.ts===O.endTime);this.messages.splice(y,this.messages.length-y-1),this.messages=[...this.messages,...W]}else{const y=this.messages.findIndex(v=>v.ts===O.endTime),x=this.messages.findLastIndex(v=>v.ts===O.endTime);this.messages.splice(y,x-y+1,...W)}const _=this.messages[this.messages.length-1];return _&&!_.relatedQuesion&&(_.relatedQuesion=(Y=this.data)===null||Y===void 0?void 0:Y.lastRelatedQuestion),this.event.emit("history:moreloaded",W),zi.log("history:loaded",this.messages),this.event.emit("history:loaded",this.messages),this._loadingMessages=!1,W}else{const ht=new Error($i.IdUndefined);return zi.error(ht),this.event.emit("error",ht),!1}})}rename(O){return Le(this,void 0,void 0,function*(){if(!this._id)throw Error("session is not created yet");if(O.trim()==="")throw Error("name is empty");return this.data=yield this.cvforceApi.patchSessionsId(this.applicationId,this._id,{name:O}),zi.log("data:updated",this.messages),this.event.emit("data:updated",this.data),this.event.emit("data:updated:name",{name:O}),!0})}pushMessage(O){return Le(this,void 0,void 0,function*(){this.messages.push(O),zi.log("history:add",O),this.event.emit("history:add",O),this.event.emit("message:new",O),this.event.emit("message:updated",O)})}reloadSessionInfo(){if(!this._id)throw Error("session is not created yet");return this._dataLoading=!0,this.cvforceApi.getSession(this.applicationId,this._id).then(O=>Le(this,void 0,void 0,function*(){if(this.data=O,!this._id)throw Error("session is not created yet");return this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,this._id),zi.log("data:updated",this.data),this.event.emit("data:updated",this.data),this.data})).then(()=>Le(this,void 0,void 0,function*(){return this.messages=[],yield this.fetchMessages(),this._dataLoading=!1,this._dataLoaded=!0,this.event.emit("data:loaded",this.data),this}))}reload(){return Le(this,void 0,void 0,function*(){return yield this.reloadSessionInfo(),this.socket?(this.inactivate(!0),this.activate()):(this.inactivate(!0),this.activate())})}delete(){return Le(this,void 0,void 0,function*(){if(!this.id){const O=new Error($i.IdUndefined);return zi.error(O),this.event.emit("error",O),!1}return this.event.emit("data:deleting"),yield this.cvforceApi.delSessionsId(this.applicationId,this.id),this.event.emit("data:deleted"),this.destroy()})}activate(){return Le(this,void 0,void 0,function*(){if(this.activing)return new Promise(L=>{this.addEventListener("activated",()=>{L(!0)},!0)});if(!this._id)throw Error("session is not avalible. id is undefined");this.activing=!0;const O=this._id;return this._dataLoading=!0,this._dataLoaded=!1,this.data=yield this.cvforceApi.getSession(this.applicationId,O).then(L=>Le(this,void 0,void 0,function*(){return this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,O),L})),this.messages.length||(this.messages=[],yield this.fetchMessages()),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data),this._dataLoaded=!0,this._dataLoading=!1,this.inactivating=!1,this.frozen=!0,yield this.prepareConnection(),this.event.emit("activated",this.socket),this.active=!0,this.activing=!1,this})}inactivate(O=!1){return this.socket?this._frozen?(O||(this.inactivating=!0),this.activing=!1,!0):(this.socket.close(),this.socket=null,this.event.emit("inactivated"),this.active=!1,this.activing=!1,!0):(this.activing=!1,!0)}get dataLoaded(){return this._dataLoaded}send(O){return Le(this,arguments,void 0,function*(L,Y={stream:!1}){var ut;try{this.validateConfigs()}catch(a){console.error(a)}const{stream:ht=!1,referenceFirst:W=!1}=Y,_=L.uuid||qc(),y=((ut=L.text)===null||ut===void 0?void 0:ut.trim())||"",x=L.fileIds;if(!y&&!(x!=null&&x.length)){const a=new Error($i.SendingEmptyContent);return zi.error(a),this.event.emit("error",a),!1}if(!this._id){const a=new Error($i.IdUndefined);return zi.error(a),this.event.emit("error",a),!1}if(this.frozen){const a=new Error($i.Frozen);return zi.error(a),this.event.emit("error",a),!1}this.frozen=!0,this._stopAnswer=!1;const v={sessionId:this.id,role:2,content:y,messageId:_,reference:[],searchReference:[],messageTime:""},m={content:y,stream:ht,requestId:_,fileIds:x,referenceFirst:W};this.pushMessage(v),this.event.emit("question:content",y);const S=a=>Le(this,void 0,void 0,function*(){if(a.role!==vr.Robot)return;switch(this.removeEventListener("answer:finish",S),this._id&&a.content&&a.index&&a.index<0&&(this.data=yield this.cvforceApi.patchSessionsId(this.applicationId,this._id,{finialMessage:a.content}),this.event.emit("data:updated",this.data),this.event.emit("data:updated:finialMessage",{finialMessage:a.content})),yield this.fillMessageReference(a),a.code){case 11915:a.content="请您换个问题问我吧~",a.index=-1,a.isSensitive=!0,a.isLoading=!1,a.sessionId=this._id||"",this.event.emit("message:error",a);break;case 200:a.index=-1,a.isLoading=!1;break;default:a.content=a.message||"未知错误",a.isLoading=!1,a.index=-1,this.event.emit("message:error",a)}const p=yield this.getRelatedQuesion(a);a=Object.assign(Object.assign({},a),p),a.isLoading=!1;let c=this.messages[this.messages.length-1];if(c&&c.role===vr.Robot){const l=Object.assign(Object.assign({},c),a);this.messages[this.messages.length-1]=l,this.event.emit("message:updated",l)}else this.pushMessage(a);this.frozen=!1});return this.addEventListener("answer:finish",S),this.sendQuestion(m,Object.assign(Object.assign({},Y),{stream:ht,referenceFirst:W})),v})}getRelatedQuesion(O){return Le(this,void 0,void 0,function*(){var L;if(!O.content||O.isSensitive||O.code!==200)return O;this.event.emit("message:relatedQuesion:loading",O);const Y=yield this.cvforceApi.postGeneques({content:O.content}).catch(W=>null);if(!Y){const W=[],_=Object.assign(Object.assign({},O),{relatedQuesion:W,index:-3,isLoading:!1});return this.event.emit("message:relatedQuesion:loaded",{relatedQuesion:W}),_}const ut=(L=Y.content)===null||L===void 0?void 0:L.split("*").map(uf).map(cf).filter(W=>!!W);O.relatedQuesion=ut,O.index=-3,O.isLoading=!1;const ht=Object.assign(Object.assign({},O),{relatedQuesion:ut,index:-3,isLoading:!1});return this.event.emit("message:relatedQuesion:loaded",ht),this._id&&this.cvforceApi.patchSessionsId(this._applicationId,this._id,{lastRelatedQuestion:ut}),ht})}fillMessageReference(O){return Le(this,void 0,void 0,function*(){var L;return(L=O.reference)===null||L===void 0||L.forEach((Y,ut)=>Le(this,void 0,void 0,function*(){const ht=yield this.cvforceApi.getKnowledgeIdFileId(Y.knowledgeId,Y.docId);O.reference[ut]=Object.assign(Object.assign({},Y),ht)})),O})}answerAgain(){return Le(this,arguments,void 0,function*(O={stream:!1}){const L=this.messages[this.messages.length-1];if(!L)throw Error("message list is empty");this.frozen=!0,this._stopAnswer=!1;const{stream:Y=!1}=O;let ut;L.role!==vr.User&&(ut=O.oldMessageId||L.messageId,this.messages.splice(this.messages.length-1,1),this.event.emit("message:remove",L),this.event.emit("history:remove",L));const ht=this.messages[this.messages.length-1],W={content:ht.content,fileIds:ht.fileIds,requestId:ht.messageId,stream:Y,oldMessageId:ut},_=y=>Le(this,void 0,void 0,function*(){if(y.role===vr.Robot&&y.index===-1){switch(this._id&&y.content&&y.index&&y.index<0&&(this.data=yield this.cvforceApi.patchSessionsId(this.applicationId,this._id,{finialMessage:y.content}),this.event.emit("data:updated",this.data),this.event.emit("data:updated:finialMessage",{finialMessage:y.content})),yield this.fillMessageReference(y),y.code){case 11915:y.content="请您换个问题问我吧~",y.index=-1,y.isSensitive=!0,y.isLoading=!1,y.sessionId=this._id||"",this.event.emit("message:error",y);break;case 200:y.index=-1,y.isLoading=!1;break;default:y.content=y.message||"未知错误",y.isLoading=!1,y.index=-1,this.event.emit("message:error",y)}const x=yield this.getRelatedQuesion(y);this.event.emit("message:updated",x),this.removeEventListener("message:content",_),this.frozen=!1}});this.addEventListener("message:content",_),this.sendQuestion(W,Object.assign(Object.assign({},O),{stream:Y}))})}setTop(O){return Le(this,void 0,void 0,function*(){if(!this._id)throw Error("session is not avalible. id is undefined");this.data=yield this.cvforceApi.patchSessionsId(this._applicationId,this._id,{top:O}),this.event.emit("data:updated",this.data),this.event.emit("data:updated:top",{top:O})})}suspend(){var O;this.stopAnswer(),this.frozen=!1,this._stopAnswer=!0;let L=this.messages[this.messages.length-1];const Y={messageId:qc(),isLoading:!1,index:-2,messageTime:hc(new Date).format("YYYY-MM-DD HH:ss:mm"),content:"",role:vr.System,sessionId:this.id||"",reference:[],searchReference:[]};if(L&&!L.messageId){if(L.index===-2)return;if(L.actions){const ut=L.actions[((O=L.actions)===null||O===void 0?void 0:O.length)-1];if(ut){const ht=ut[ut.length-1];if(ht&&(ht.type==="BEFORE_CALL"||ht.type==="FUNCTION_CALL")){const{pluginName:W,pluginCode:_,funcCode:y,funcName:x}=ht.data;ut.push({data:{pluginName:W,pluginCode:_,funcCode:y,funcName:x,step:ht.data.step+1},type:"ABORT"}),this.event.emit("message:action",{messageId:L.messageId,action:ut})}}}L=Object.assign(Object.assign({},L),Y),this.event.emit("message:content",L),this.event.emit("message:updated",L)}else this.pushMessage(Y),this.event.emit("message:content",Y);return this}postMessageComment(O){return Le(this,void 0,void 0,function*(){if(!this._applicationId||!this._id)throw Error("session is not avalible. id is undefined");return this.cvforceApi.postComments(this._applicationId,this._id,O).then(L=>{const Y=this.messages.find(ut=>ut.messageId===O.messageId);return Y&&(Y.comment=O,this.event.emit("message:comment",Y)),L})})}clear(){if(!this._id)throw Error("session is not avalible. id is undefined");return this.cvforceApi.patchApplicationIdSessionsIdContext(this._applicationId,this._id).then(()=>(this.event.emit("context:clear"),!0))}destroy(){var O;return this._ready=!1,this.event.removeAllListeners(),(O=this.socket)===null||O===void 0||O.disconnect(),this.socket=null,this.event.emit("destroy",{applicationId:this._applicationId,sessionId:this._id}),this._id||""}}const $r=new Pi("[AgentSession] ");class gd extends cs{constructor(O,L="",Y,ut,ht,W){super(O,L,Y,ut,ht,W)}prepareConnection(){return new Promise(O=>Le(this,void 0,void 0,function*(){this.socket&&O(!0);const L={version:"1.0",stream:"false",appId:this._applicationId,sessionId:this.id,Authorization:`${this.token}`,userMode:Mi.configuration.debug?nn.Debug:nn.Normal},Y=new URL(Mi.configuration.apiRoot),ut=yield Mo(Y.origin,{path:Y.pathname.replace("api","socketio")+"/copilot",query:L,transports:["websocket"]});ut.on("connect",()=>{$r.log("socket:connect"),this.event.emit("socket:connect"),ut.emit("init")}),ut.on("disconnect",()=>{$r.log("socket:disconnect"),this.event.emit("socket:disconnect")}),ut.on("ready",ht=>{if(ht.code===200){$r.log("ready");const W=Mi.configuration.debug?nn.Debug:nn.Normal;W===nn.Debug&&ht.userMode,this._ready||(this._ready=!0,this.event.emit("ready")),this.frozen=!1,O(!0)}else{this._ready&&(this._ready=!1);const W=new Error($i.SocketConnectionFailed);$r.error("error",W),this.event.emit("error",W),O(!1)}}),ut.on("action",(ht,W)=>Le(this,void 0,void 0,function*(){if(this._stopAnswer||!this.id)return;const{type:_,data:{runnerIsClient:y,pluginCode:x,funcCode:v,parameters:m,requestBody:S}}=ht,a=this.messages[this.messages.length-1];if(!a.messageId)a.actions||(a.actions=[]),a.actions[ht.data.step-1]||(a.actions[ht.data.step-1]=[]),a.actions[ht.data.step-1].push(ht),this.event.emit("message:action",{messageId:a.messageId,action:ht}),this.event.emit("message:updated",a);else{const p={messageId:"",content:"",role:vr.Robot,sessionId:this.id,reference:[],searchReference:[],isLoading:!0,messageTime:"",actions:[[ht]],comment:{isAgree:0}};this.pushMessage(p),this.event.emit("message:action",{messageId:p.messageId,action:ht})}if(this.inactivating){const p=new Error($i.Inactive);$r.warn("error",p),this.event.emit("error",p)}else if(_==="FUNCTION_CALL"&&y){if($r.log(`calling function ${v} of plugin ${x} with argument:
137
+ */(function(K){const O=fo,L=Za,Y=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;K.Buffer=_,K.SlowBuffer=g,K.INSPECT_MAX_BYTES=50;const ut=2147483647;K.kMaxLength=ut,_.TYPED_ARRAY_SUPPORT=ht(),!_.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ht(){try{const F=new Uint8Array(1),H={foo:function(){return 42}};return Object.setPrototypeOf(H,Uint8Array.prototype),Object.setPrototypeOf(F,H),F.foo()===42}catch{return!1}}Object.defineProperty(_.prototype,"parent",{enumerable:!0,get:function(){if(_.isBuffer(this))return this.buffer}}),Object.defineProperty(_.prototype,"offset",{enumerable:!0,get:function(){if(_.isBuffer(this))return this.byteOffset}});function W(F){if(F>ut)throw new RangeError('The value "'+F+'" is invalid for option "size"');const H=new Uint8Array(F);return Object.setPrototypeOf(H,_.prototype),H}function _(F,H,U){if(typeof F=="number"){if(typeof H=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(F)}return y(F,H,U)}_.poolSize=8192;function y(F,H,U){if(typeof F=="string")return S(F,H);if(ArrayBuffer.isView(F))return p(F);if(F==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof F);if(Bt(F,ArrayBuffer)||F&&Bt(F.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Bt(F,SharedArrayBuffer)||F&&Bt(F.buffer,SharedArrayBuffer)))return c(F,H,U);if(typeof F=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const it=F.valueOf&&F.valueOf();if(it!=null&&it!==F)return _.from(it,H,U);const pt=l(F);if(pt)return pt;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof F[Symbol.toPrimitive]=="function")return _.from(F[Symbol.toPrimitive]("string"),H,U);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof F)}_.from=function(F,H,U){return y(F,H,U)},Object.setPrototypeOf(_.prototype,Uint8Array.prototype),Object.setPrototypeOf(_,Uint8Array);function x(F){if(typeof F!="number")throw new TypeError('"size" argument must be of type number');if(F<0)throw new RangeError('The value "'+F+'" is invalid for option "size"')}function v(F,H,U){return x(F),F<=0?W(F):H!==void 0?typeof U=="string"?W(F).fill(H,U):W(F).fill(H):W(F)}_.alloc=function(F,H,U){return v(F,H,U)};function m(F){return x(F),W(F<0?0:f(F)|0)}_.allocUnsafe=function(F){return m(F)},_.allocUnsafeSlow=function(F){return m(F)};function S(F,H){if((typeof H!="string"||H==="")&&(H="utf8"),!_.isEncoding(H))throw new TypeError("Unknown encoding: "+H);const U=h(F,H)|0;let it=W(U);const pt=it.write(F,H);return pt!==U&&(it=it.slice(0,pt)),it}function a(F){const H=F.length<0?0:f(F.length)|0,U=W(H);for(let it=0;it<H;it+=1)U[it]=F[it]&255;return U}function p(F){if(Bt(F,Uint8Array)){const H=new Uint8Array(F);return c(H.buffer,H.byteOffset,H.byteLength)}return a(F)}function c(F,H,U){if(H<0||F.byteLength<H)throw new RangeError('"offset" is outside of buffer bounds');if(F.byteLength<H+(U||0))throw new RangeError('"length" is outside of buffer bounds');let it;return H===void 0&&U===void 0?it=new Uint8Array(F):U===void 0?it=new Uint8Array(F,H):it=new Uint8Array(F,H,U),Object.setPrototypeOf(it,_.prototype),it}function l(F){if(_.isBuffer(F)){const H=f(F.length)|0,U=W(H);return U.length===0||F.copy(U,0,0,H),U}if(F.length!==void 0)return typeof F.length!="number"||Mt(F.length)?W(0):a(F);if(F.type==="Buffer"&&Array.isArray(F.data))return a(F.data)}function f(F){if(F>=ut)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ut.toString(16)+" bytes");return F|0}function g(F){return+F!=F&&(F=0),_.alloc(+F)}_.isBuffer=function(H){return H!=null&&H._isBuffer===!0&&H!==_.prototype},_.compare=function(H,U){if(Bt(H,Uint8Array)&&(H=_.from(H,H.offset,H.byteLength)),Bt(U,Uint8Array)&&(U=_.from(U,U.offset,U.byteLength)),!_.isBuffer(H)||!_.isBuffer(U))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(H===U)return 0;let it=H.length,pt=U.length;for(let ft=0,mt=Math.min(it,pt);ft<mt;++ft)if(H[ft]!==U[ft]){it=H[ft],pt=U[ft];break}return it<pt?-1:pt<it?1:0},_.isEncoding=function(H){switch(String(H).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},_.concat=function(H,U){if(!Array.isArray(H))throw new TypeError('"list" argument must be an Array of Buffers');if(H.length===0)return _.alloc(0);let it;if(U===void 0)for(U=0,it=0;it<H.length;++it)U+=H[it].length;const pt=_.allocUnsafe(U);let ft=0;for(it=0;it<H.length;++it){let mt=H[it];if(Bt(mt,Uint8Array))ft+mt.length>pt.length?(_.isBuffer(mt)||(mt=_.from(mt)),mt.copy(pt,ft)):Uint8Array.prototype.set.call(pt,mt,ft);else if(_.isBuffer(mt))mt.copy(pt,ft);else throw new TypeError('"list" argument must be an Array of Buffers');ft+=mt.length}return pt};function h(F,H){if(_.isBuffer(F))return F.length;if(ArrayBuffer.isView(F)||Bt(F,ArrayBuffer))return F.byteLength;if(typeof F!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof F);const U=F.length,it=arguments.length>2&&arguments[2]===!0;if(!it&&U===0)return 0;let pt=!1;for(;;)switch(H){case"ascii":case"latin1":case"binary":return U;case"utf8":case"utf-8":return nt(F).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U*2;case"hex":return U>>>1;case"base64":return gt(F).length;default:if(pt)return it?-1:nt(F).length;H=(""+H).toLowerCase(),pt=!0}}_.byteLength=h;function u(F,H,U){let it=!1;if((H===void 0||H<0)&&(H=0),H>this.length||((U===void 0||U>this.length)&&(U=this.length),U<=0)||(U>>>=0,H>>>=0,U<=H))return"";for(F||(F="utf8");;)switch(F){case"hex":return r(this,H,U);case"utf8":case"utf-8":return et(this,H,U);case"ascii":return t(this,H,U);case"latin1":case"binary":return n(this,H,U);case"base64":return $(this,H,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i(this,H,U);default:if(it)throw new TypeError("Unknown encoding: "+F);F=(F+"").toLowerCase(),it=!0}}_.prototype._isBuffer=!0;function w(F,H,U){const it=F[H];F[H]=F[U],F[U]=it}_.prototype.swap16=function(){const H=this.length;if(H%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let U=0;U<H;U+=2)w(this,U,U+1);return this},_.prototype.swap32=function(){const H=this.length;if(H%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let U=0;U<H;U+=4)w(this,U,U+3),w(this,U+1,U+2);return this},_.prototype.swap64=function(){const H=this.length;if(H%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let U=0;U<H;U+=8)w(this,U,U+7),w(this,U+1,U+6),w(this,U+2,U+5),w(this,U+3,U+4);return this},_.prototype.toString=function(){const H=this.length;return H===0?"":arguments.length===0?et(this,0,H):u.apply(this,arguments)},_.prototype.toLocaleString=_.prototype.toString,_.prototype.equals=function(H){if(!_.isBuffer(H))throw new TypeError("Argument must be a Buffer");return this===H?!0:_.compare(this,H)===0},_.prototype.inspect=function(){let H="";const U=K.INSPECT_MAX_BYTES;return H=this.toString("hex",0,U).replace(/(.{2})/g,"$1 ").trim(),this.length>U&&(H+=" ... "),"<Buffer "+H+">"},Y&&(_.prototype[Y]=_.prototype.inspect),_.prototype.compare=function(H,U,it,pt,ft){if(Bt(H,Uint8Array)&&(H=_.from(H,H.offset,H.byteLength)),!_.isBuffer(H))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof H);if(U===void 0&&(U=0),it===void 0&&(it=H?H.length:0),pt===void 0&&(pt=0),ft===void 0&&(ft=this.length),U<0||it>H.length||pt<0||ft>this.length)throw new RangeError("out of range index");if(pt>=ft&&U>=it)return 0;if(pt>=ft)return-1;if(U>=it)return 1;if(U>>>=0,it>>>=0,pt>>>=0,ft>>>=0,this===H)return 0;let mt=ft-pt,re=it-U;const _t=Math.min(mt,re),At=this.slice(pt,ft),fe=H.slice(U,it);for(let kt=0;kt<_t;++kt)if(At[kt]!==fe[kt]){mt=At[kt],re=fe[kt];break}return mt<re?-1:re<mt?1:0};function b(F,H,U,it,pt){if(F.length===0)return-1;if(typeof U=="string"?(it=U,U=0):U>2147483647?U=2147483647:U<-2147483648&&(U=-2147483648),U=+U,Mt(U)&&(U=pt?0:F.length-1),U<0&&(U=F.length+U),U>=F.length){if(pt)return-1;U=F.length-1}else if(U<0)if(pt)U=0;else return-1;if(typeof H=="string"&&(H=_.from(H,it)),_.isBuffer(H))return H.length===0?-1:E(F,H,U,it,pt);if(typeof H=="number")return H=H&255,typeof Uint8Array.prototype.indexOf=="function"?pt?Uint8Array.prototype.indexOf.call(F,H,U):Uint8Array.prototype.lastIndexOf.call(F,H,U):E(F,[H],U,it,pt);throw new TypeError("val must be string, number or Buffer")}function E(F,H,U,it,pt){let ft=1,mt=F.length,re=H.length;if(it!==void 0&&(it=String(it).toLowerCase(),it==="ucs2"||it==="ucs-2"||it==="utf16le"||it==="utf-16le")){if(F.length<2||H.length<2)return-1;ft=2,mt/=2,re/=2,U/=2}function _t(fe,kt){return ft===1?fe[kt]:fe.readUInt16BE(kt*ft)}let At;if(pt){let fe=-1;for(At=U;At<mt;At++)if(_t(F,At)===_t(H,fe===-1?0:At-fe)){if(fe===-1&&(fe=At),At-fe+1===re)return fe*ft}else fe!==-1&&(At-=At-fe),fe=-1}else for(U+re>mt&&(U=mt-re),At=U;At>=0;At--){let fe=!0;for(let kt=0;kt<re;kt++)if(_t(F,At+kt)!==_t(H,kt)){fe=!1;break}if(fe)return At}return-1}_.prototype.includes=function(H,U,it){return this.indexOf(H,U,it)!==-1},_.prototype.indexOf=function(H,U,it){return b(this,H,U,it,!0)},_.prototype.lastIndexOf=function(H,U,it){return b(this,H,U,it,!1)};function I(F,H,U,it){U=Number(U)||0;const pt=F.length-U;it?(it=Number(it),it>pt&&(it=pt)):it=pt;const ft=H.length;it>ft/2&&(it=ft/2);let mt;for(mt=0;mt<it;++mt){const re=parseInt(H.substr(mt*2,2),16);if(Mt(re))return mt;F[U+mt]=re}return mt}function M(F,H,U,it){return bt(nt(H,F.length-U),F,U,it)}function B(F,H,U,it){return bt(lt(H),F,U,it)}function P(F,H,U,it){return bt(gt(H),F,U,it)}function N(F,H,U,it){return bt(Et(H,F.length-U),F,U,it)}_.prototype.write=function(H,U,it,pt){if(U===void 0)pt="utf8",it=this.length,U=0;else if(it===void 0&&typeof U=="string")pt=U,it=this.length,U=0;else if(isFinite(U))U=U>>>0,isFinite(it)?(it=it>>>0,pt===void 0&&(pt="utf8")):(pt=it,it=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ft=this.length-U;if((it===void 0||it>ft)&&(it=ft),H.length>0&&(it<0||U<0)||U>this.length)throw new RangeError("Attempt to write outside buffer bounds");pt||(pt="utf8");let mt=!1;for(;;)switch(pt){case"hex":return I(this,H,U,it);case"utf8":case"utf-8":return M(this,H,U,it);case"ascii":case"latin1":case"binary":return B(this,H,U,it);case"base64":return P(this,H,U,it);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,H,U,it);default:if(mt)throw new TypeError("Unknown encoding: "+pt);pt=(""+pt).toLowerCase(),mt=!0}},_.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $(F,H,U){return H===0&&U===F.length?O.fromByteArray(F):O.fromByteArray(F.slice(H,U))}function et(F,H,U){U=Math.min(F.length,U);const it=[];let pt=H;for(;pt<U;){const ft=F[pt];let mt=null,re=ft>239?4:ft>223?3:ft>191?2:1;if(pt+re<=U){let _t,At,fe,kt;switch(re){case 1:ft<128&&(mt=ft);break;case 2:_t=F[pt+1],(_t&192)===128&&(kt=(ft&31)<<6|_t&63,kt>127&&(mt=kt));break;case 3:_t=F[pt+1],At=F[pt+2],(_t&192)===128&&(At&192)===128&&(kt=(ft&15)<<12|(_t&63)<<6|At&63,kt>2047&&(kt<55296||kt>57343)&&(mt=kt));break;case 4:_t=F[pt+1],At=F[pt+2],fe=F[pt+3],(_t&192)===128&&(At&192)===128&&(fe&192)===128&&(kt=(ft&15)<<18|(_t&63)<<12|(At&63)<<6|fe&63,kt>65535&&kt<1114112&&(mt=kt))}}mt===null?(mt=65533,re=1):mt>65535&&(mt-=65536,it.push(mt>>>10&1023|55296),mt=56320|mt&1023),it.push(mt),pt+=re}return ot(it)}const Q=4096;function ot(F){const H=F.length;if(H<=Q)return String.fromCharCode.apply(String,F);let U="",it=0;for(;it<H;)U+=String.fromCharCode.apply(String,F.slice(it,it+=Q));return U}function t(F,H,U){let it="";U=Math.min(F.length,U);for(let pt=H;pt<U;++pt)it+=String.fromCharCode(F[pt]&127);return it}function n(F,H,U){let it="";U=Math.min(F.length,U);for(let pt=H;pt<U;++pt)it+=String.fromCharCode(F[pt]);return it}function r(F,H,U){const it=F.length;(!H||H<0)&&(H=0),(!U||U<0||U>it)&&(U=it);let pt="";for(let ft=H;ft<U;++ft)pt+=It[F[ft]];return pt}function i(F,H,U){const it=F.slice(H,U);let pt="";for(let ft=0;ft<it.length-1;ft+=2)pt+=String.fromCharCode(it[ft]+it[ft+1]*256);return pt}_.prototype.slice=function(H,U){const it=this.length;H=~~H,U=U===void 0?it:~~U,H<0?(H+=it,H<0&&(H=0)):H>it&&(H=it),U<0?(U+=it,U<0&&(U=0)):U>it&&(U=it),U<H&&(U=H);const pt=this.subarray(H,U);return Object.setPrototypeOf(pt,_.prototype),pt};function e(F,H,U){if(F%1!==0||F<0)throw new RangeError("offset is not uint");if(F+H>U)throw new RangeError("Trying to access beyond buffer length")}_.prototype.readUintLE=_.prototype.readUIntLE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=this[H],ft=1,mt=0;for(;++mt<U&&(ft*=256);)pt+=this[H+mt]*ft;return pt},_.prototype.readUintBE=_.prototype.readUIntBE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=this[H+--U],ft=1;for(;U>0&&(ft*=256);)pt+=this[H+--U]*ft;return pt},_.prototype.readUint8=_.prototype.readUInt8=function(H,U){return H=H>>>0,U||e(H,1,this.length),this[H]},_.prototype.readUint16LE=_.prototype.readUInt16LE=function(H,U){return H=H>>>0,U||e(H,2,this.length),this[H]|this[H+1]<<8},_.prototype.readUint16BE=_.prototype.readUInt16BE=function(H,U){return H=H>>>0,U||e(H,2,this.length),this[H]<<8|this[H+1]},_.prototype.readUint32LE=_.prototype.readUInt32LE=function(H,U){return H=H>>>0,U||e(H,4,this.length),(this[H]|this[H+1]<<8|this[H+2]<<16)+this[H+3]*16777216},_.prototype.readUint32BE=_.prototype.readUInt32BE=function(H,U){return H=H>>>0,U||e(H,4,this.length),this[H]*16777216+(this[H+1]<<16|this[H+2]<<8|this[H+3])},_.prototype.readBigUInt64LE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=U+this[++H]*2**8+this[++H]*2**16+this[++H]*2**24,ft=this[++H]+this[++H]*2**8+this[++H]*2**16+it*2**24;return BigInt(pt)+(BigInt(ft)<<BigInt(32))}),_.prototype.readBigUInt64BE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=U*2**24+this[++H]*2**16+this[++H]*2**8+this[++H],ft=this[++H]*2**24+this[++H]*2**16+this[++H]*2**8+it;return(BigInt(pt)<<BigInt(32))+BigInt(ft)}),_.prototype.readIntLE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=this[H],ft=1,mt=0;for(;++mt<U&&(ft*=256);)pt+=this[H+mt]*ft;return ft*=128,pt>=ft&&(pt-=Math.pow(2,8*U)),pt},_.prototype.readIntBE=function(H,U,it){H=H>>>0,U=U>>>0,it||e(H,U,this.length);let pt=U,ft=1,mt=this[H+--pt];for(;pt>0&&(ft*=256);)mt+=this[H+--pt]*ft;return ft*=128,mt>=ft&&(mt-=Math.pow(2,8*U)),mt},_.prototype.readInt8=function(H,U){return H=H>>>0,U||e(H,1,this.length),this[H]&128?(255-this[H]+1)*-1:this[H]},_.prototype.readInt16LE=function(H,U){H=H>>>0,U||e(H,2,this.length);const it=this[H]|this[H+1]<<8;return it&32768?it|4294901760:it},_.prototype.readInt16BE=function(H,U){H=H>>>0,U||e(H,2,this.length);const it=this[H+1]|this[H]<<8;return it&32768?it|4294901760:it},_.prototype.readInt32LE=function(H,U){return H=H>>>0,U||e(H,4,this.length),this[H]|this[H+1]<<8|this[H+2]<<16|this[H+3]<<24},_.prototype.readInt32BE=function(H,U){return H=H>>>0,U||e(H,4,this.length),this[H]<<24|this[H+1]<<16|this[H+2]<<8|this[H+3]},_.prototype.readBigInt64LE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=this[H+4]+this[H+5]*2**8+this[H+6]*2**16+(it<<24);return(BigInt(pt)<<BigInt(32))+BigInt(U+this[++H]*2**8+this[++H]*2**16+this[++H]*2**24)}),_.prototype.readBigInt64BE=J(function(H){H=H>>>0,G(H,"offset");const U=this[H],it=this[H+7];(U===void 0||it===void 0)&&z(H,this.length-8);const pt=(U<<24)+this[++H]*2**16+this[++H]*2**8+this[++H];return(BigInt(pt)<<BigInt(32))+BigInt(this[++H]*2**24+this[++H]*2**16+this[++H]*2**8+it)}),_.prototype.readFloatLE=function(H,U){return H=H>>>0,U||e(H,4,this.length),L.read(this,H,!0,23,4)},_.prototype.readFloatBE=function(H,U){return H=H>>>0,U||e(H,4,this.length),L.read(this,H,!1,23,4)},_.prototype.readDoubleLE=function(H,U){return H=H>>>0,U||e(H,8,this.length),L.read(this,H,!0,52,8)},_.prototype.readDoubleBE=function(H,U){return H=H>>>0,U||e(H,8,this.length),L.read(this,H,!1,52,8)};function o(F,H,U,it,pt,ft){if(!_.isBuffer(F))throw new TypeError('"buffer" argument must be a Buffer instance');if(H>pt||H<ft)throw new RangeError('"value" argument is out of bounds');if(U+it>F.length)throw new RangeError("Index out of range")}_.prototype.writeUintLE=_.prototype.writeUIntLE=function(H,U,it,pt){if(H=+H,U=U>>>0,it=it>>>0,!pt){const re=Math.pow(2,8*it)-1;o(this,H,U,it,re,0)}let ft=1,mt=0;for(this[U]=H&255;++mt<it&&(ft*=256);)this[U+mt]=H/ft&255;return U+it},_.prototype.writeUintBE=_.prototype.writeUIntBE=function(H,U,it,pt){if(H=+H,U=U>>>0,it=it>>>0,!pt){const re=Math.pow(2,8*it)-1;o(this,H,U,it,re,0)}let ft=it-1,mt=1;for(this[U+ft]=H&255;--ft>=0&&(mt*=256);)this[U+ft]=H/mt&255;return U+it},_.prototype.writeUint8=_.prototype.writeUInt8=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,1,255,0),this[U]=H&255,U+1},_.prototype.writeUint16LE=_.prototype.writeUInt16LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,65535,0),this[U]=H&255,this[U+1]=H>>>8,U+2},_.prototype.writeUint16BE=_.prototype.writeUInt16BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,65535,0),this[U]=H>>>8,this[U+1]=H&255,U+2},_.prototype.writeUint32LE=_.prototype.writeUInt32LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,4294967295,0),this[U+3]=H>>>24,this[U+2]=H>>>16,this[U+1]=H>>>8,this[U]=H&255,U+4},_.prototype.writeUint32BE=_.prototype.writeUInt32BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,4294967295,0),this[U]=H>>>24,this[U+1]=H>>>16,this[U+2]=H>>>8,this[U+3]=H&255,U+4};function s(F,H,U,it,pt){D(H,it,pt,F,U,7);let ft=Number(H&BigInt(4294967295));F[U++]=ft,ft=ft>>8,F[U++]=ft,ft=ft>>8,F[U++]=ft,ft=ft>>8,F[U++]=ft;let mt=Number(H>>BigInt(32)&BigInt(4294967295));return F[U++]=mt,mt=mt>>8,F[U++]=mt,mt=mt>>8,F[U++]=mt,mt=mt>>8,F[U++]=mt,U}function A(F,H,U,it,pt){D(H,it,pt,F,U,7);let ft=Number(H&BigInt(4294967295));F[U+7]=ft,ft=ft>>8,F[U+6]=ft,ft=ft>>8,F[U+5]=ft,ft=ft>>8,F[U+4]=ft;let mt=Number(H>>BigInt(32)&BigInt(4294967295));return F[U+3]=mt,mt=mt>>8,F[U+2]=mt,mt=mt>>8,F[U+1]=mt,mt=mt>>8,F[U]=mt,U+8}_.prototype.writeBigUInt64LE=J(function(H,U=0){return s(this,H,U,BigInt(0),BigInt("0xffffffffffffffff"))}),_.prototype.writeBigUInt64BE=J(function(H,U=0){return A(this,H,U,BigInt(0),BigInt("0xffffffffffffffff"))}),_.prototype.writeIntLE=function(H,U,it,pt){if(H=+H,U=U>>>0,!pt){const _t=Math.pow(2,8*it-1);o(this,H,U,it,_t-1,-_t)}let ft=0,mt=1,re=0;for(this[U]=H&255;++ft<it&&(mt*=256);)H<0&&re===0&&this[U+ft-1]!==0&&(re=1),this[U+ft]=(H/mt>>0)-re&255;return U+it},_.prototype.writeIntBE=function(H,U,it,pt){if(H=+H,U=U>>>0,!pt){const _t=Math.pow(2,8*it-1);o(this,H,U,it,_t-1,-_t)}let ft=it-1,mt=1,re=0;for(this[U+ft]=H&255;--ft>=0&&(mt*=256);)H<0&&re===0&&this[U+ft+1]!==0&&(re=1),this[U+ft]=(H/mt>>0)-re&255;return U+it},_.prototype.writeInt8=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,1,127,-128),H<0&&(H=255+H+1),this[U]=H&255,U+1},_.prototype.writeInt16LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,32767,-32768),this[U]=H&255,this[U+1]=H>>>8,U+2},_.prototype.writeInt16BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,2,32767,-32768),this[U]=H>>>8,this[U+1]=H&255,U+2},_.prototype.writeInt32LE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,2147483647,-2147483648),this[U]=H&255,this[U+1]=H>>>8,this[U+2]=H>>>16,this[U+3]=H>>>24,U+4},_.prototype.writeInt32BE=function(H,U,it){return H=+H,U=U>>>0,it||o(this,H,U,4,2147483647,-2147483648),H<0&&(H=4294967295+H+1),this[U]=H>>>24,this[U+1]=H>>>16,this[U+2]=H>>>8,this[U+3]=H&255,U+4},_.prototype.writeBigInt64LE=J(function(H,U=0){return s(this,H,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),_.prototype.writeBigInt64BE=J(function(H,U=0){return A(this,H,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function C(F,H,U,it,pt,ft){if(U+it>F.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("Index out of range")}function j(F,H,U,it,pt){return H=+H,U=U>>>0,pt||C(F,H,U,4),L.write(F,H,U,it,23,4),U+4}_.prototype.writeFloatLE=function(H,U,it){return j(this,H,U,!0,it)},_.prototype.writeFloatBE=function(H,U,it){return j(this,H,U,!1,it)};function T(F,H,U,it,pt){return H=+H,U=U>>>0,pt||C(F,H,U,8),L.write(F,H,U,it,52,8),U+8}_.prototype.writeDoubleLE=function(H,U,it){return T(this,H,U,!0,it)},_.prototype.writeDoubleBE=function(H,U,it){return T(this,H,U,!1,it)},_.prototype.copy=function(H,U,it,pt){if(!_.isBuffer(H))throw new TypeError("argument should be a Buffer");if(it||(it=0),!pt&&pt!==0&&(pt=this.length),U>=H.length&&(U=H.length),U||(U=0),pt>0&&pt<it&&(pt=it),pt===it||H.length===0||this.length===0)return 0;if(U<0)throw new RangeError("targetStart out of bounds");if(it<0||it>=this.length)throw new RangeError("Index out of range");if(pt<0)throw new RangeError("sourceEnd out of bounds");pt>this.length&&(pt=this.length),H.length-U<pt-it&&(pt=H.length-U+it);const ft=pt-it;return this===H&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(U,it,pt):Uint8Array.prototype.set.call(H,this.subarray(it,pt),U),ft},_.prototype.fill=function(H,U,it,pt){if(typeof H=="string"){if(typeof U=="string"?(pt=U,U=0,it=this.length):typeof it=="string"&&(pt=it,it=this.length),pt!==void 0&&typeof pt!="string")throw new TypeError("encoding must be a string");if(typeof pt=="string"&&!_.isEncoding(pt))throw new TypeError("Unknown encoding: "+pt);if(H.length===1){const mt=H.charCodeAt(0);(pt==="utf8"&&mt<128||pt==="latin1")&&(H=mt)}}else typeof H=="number"?H=H&255:typeof H=="boolean"&&(H=Number(H));if(U<0||this.length<U||this.length<it)throw new RangeError("Out of range index");if(it<=U)return this;U=U>>>0,it=it===void 0?this.length:it>>>0,H||(H=0);let ft;if(typeof H=="number")for(ft=U;ft<it;++ft)this[ft]=H;else{const mt=_.isBuffer(H)?H:_.from(H,pt),re=mt.length;if(re===0)throw new TypeError('The value "'+H+'" is invalid for argument "value"');for(ft=0;ft<it-U;++ft)this[ft+U]=mt[ft%re]}return this};const R={};function q(F,H,U){R[F]=class extends U{constructor(){super(),Object.defineProperty(this,"message",{value:H.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${F}]`,this.stack,delete this.name}get code(){return F}set code(pt){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:pt,writable:!0})}toString(){return`${this.name} [${F}]: ${this.message}`}}}q("ERR_BUFFER_OUT_OF_BOUNDS",function(F){return F?`${F} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),q("ERR_INVALID_ARG_TYPE",function(F,H){return`The "${F}" argument must be of type number. Received type ${typeof H}`},TypeError),q("ERR_OUT_OF_RANGE",function(F,H,U){let it=`The value of "${F}" is out of range.`,pt=U;return Number.isInteger(U)&&Math.abs(U)>2**32?pt=Z(String(U)):typeof U=="bigint"&&(pt=String(U),(U>BigInt(2)**BigInt(32)||U<-(BigInt(2)**BigInt(32)))&&(pt=Z(pt)),pt+="n"),it+=` It must be ${H}. Received ${pt}`,it},RangeError);function Z(F){let H="",U=F.length;const it=F[0]==="-"?1:0;for(;U>=it+4;U-=3)H=`_${F.slice(U-3,U)}${H}`;return`${F.slice(0,U)}${H}`}function rt(F,H,U){G(H,"offset"),(F[H]===void 0||F[H+U]===void 0)&&z(H,F.length-(U+1))}function D(F,H,U,it,pt,ft){if(F>U||F<H){const mt=typeof H=="bigint"?"n":"";let re;throw ft>3?H===0||H===BigInt(0)?re=`>= 0${mt} and < 2${mt} ** ${(ft+1)*8}${mt}`:re=`>= -(2${mt} ** ${(ft+1)*8-1}${mt}) and < 2 ** ${(ft+1)*8-1}${mt}`:re=`>= ${H}${mt} and <= ${U}${mt}`,new R.ERR_OUT_OF_RANGE("value",re,F)}rt(it,pt,ft)}function G(F,H){if(typeof F!="number")throw new R.ERR_INVALID_ARG_TYPE(H,"number",F)}function z(F,H,U){throw Math.floor(F)!==F?(G(F,U),new R.ERR_OUT_OF_RANGE(U||"offset","an integer",F)):H<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE(U||"offset",`>= ${U?1:0} and <= ${H}`,F)}const X=/[^+/0-9A-Za-z-_]/g;function st(F){if(F=F.split("=")[0],F=F.trim().replace(X,""),F.length<2)return"";for(;F.length%4!==0;)F=F+"=";return F}function nt(F,H){H=H||1/0;let U;const it=F.length;let pt=null;const ft=[];for(let mt=0;mt<it;++mt){if(U=F.charCodeAt(mt),U>55295&&U<57344){if(!pt){if(U>56319){(H-=3)>-1&&ft.push(239,191,189);continue}else if(mt+1===it){(H-=3)>-1&&ft.push(239,191,189);continue}pt=U;continue}if(U<56320){(H-=3)>-1&&ft.push(239,191,189),pt=U;continue}U=(pt-55296<<10|U-56320)+65536}else pt&&(H-=3)>-1&&ft.push(239,191,189);if(pt=null,U<128){if((H-=1)<0)break;ft.push(U)}else if(U<2048){if((H-=2)<0)break;ft.push(U>>6|192,U&63|128)}else if(U<65536){if((H-=3)<0)break;ft.push(U>>12|224,U>>6&63|128,U&63|128)}else if(U<1114112){if((H-=4)<0)break;ft.push(U>>18|240,U>>12&63|128,U>>6&63|128,U&63|128)}else throw new Error("Invalid code point")}return ft}function lt(F){const H=[];for(let U=0;U<F.length;++U)H.push(F.charCodeAt(U)&255);return H}function Et(F,H){let U,it,pt;const ft=[];for(let mt=0;mt<F.length&&!((H-=2)<0);++mt)U=F.charCodeAt(mt),it=U>>8,pt=U%256,ft.push(pt),ft.push(it);return ft}function gt(F){return O.toByteArray(st(F))}function bt(F,H,U,it){let pt;for(pt=0;pt<it&&!(pt+U>=H.length||pt>=F.length);++pt)H[pt+U]=F[pt];return pt}function Bt(F,H){return F instanceof H||F!=null&&F.constructor!=null&&F.constructor.name!=null&&F.constructor.name===H.name}function Mt(F){return F!==F}const It=function(){const F="0123456789abcdef",H=new Array(256);for(let U=0;U<16;++U){const it=U*16;for(let pt=0;pt<16;++pt)H[it+pt]=F[U]+F[pt]}return H}();function J(F){return typeof BigInt>"u"?tt:F}function tt(){throw new Error("BigInt not supported")}})(Va),window.Buffer=Va.Buffer,globalThis.Buffer=Va.Buffer;var ve=(K,O,L)=>new Promise((Y,ut)=>{var ht=y=>{try{_(L.next(y))}catch(x){ut(x)}},W=y=>{try{_(L.throw(y))}catch(x){ut(x)}},_=y=>y.done?Y(y.value):Promise.resolve(y.value).then(ht,W);_((L=L.apply(K,O)).next())});class _p extends sp{constructor(O,L){super(O??oc.create(),L)}getKnowledge(O,L){return ve(this,null,function*(){return this.get("/knowledge",{docId:O,name:L})})}postKnowledge(O){return ve(this,null,function*(){return this.post("/knowledge",O)})}getKnowledgeId(O){return ve(this,null,function*(){return this.get(`/knowledge/${O}`)})}patchKnowledgeId(O,L){return ve(this,null,function*(){return this.patch(`/knowledge/${O}`,L)})}delKnowledgeId(O){return ve(this,null,function*(){return this.delete(`/knowledge/${O}`)})}getKnowledgeIdFile(O){return ve(this,null,function*(){return this.get(`/knowledge/${O}/file`)})}getKnowledgeIdFileList(O,L){return ve(this,null,function*(){return this.listPaged(`/knowledge/${O}/file`,L)})}postKnowledgeIdFile(O,L){return ve(this,null,function*(){return this.post(`/knowledge/${O}/file`,L)})}getUploadTicket(O){return ve(this,null,function*(){return this.get("/upload/ticket",O)})}delKnowledgeIdFileFid(O,L){return ve(this,null,function*(){return this.delete(`/knowledge/${O}/file/${L}`)})}patchKnowledgeIdFileFid(O,L,Y){return ve(this,null,function*(){return this.patch(`/knowledge/${O}/file/${L}`,Y)})}listSessions(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/sessionsa`,L)})}postSession(O,L){return ve(this,null,function*(){return this.post(`/application/${O}/sessions`,L)})}getSession(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/sessions/${L}`)})}patchSessionsId(O,L,Y){return ve(this,null,function*(){return this.patch(`/application/${O}/sessions/${L}`,Y)})}delSessionsId(O,L){return ve(this,null,function*(){return this.delete(`/application/${O}/sessions/${L}`)})}getSessionKnowledgeFile(O,L,Y){return ve(this,null,function*(){return this.get(`/application/${O}session/${L}/file/${Y}`)})}postSessionKnowledgeFile(O,L,Y){return ve(this,null,function*(){return this.post(`/application/${O}session/${L}/file`,Y)})}postComments(O,L,Y){return ve(this,null,function*(){return this.post(`/application/${O}/sessions/${L}/comments`,Y)})}getChatHistorySessionId(O,L,Y){return ve(this,null,function*(){return this.get(`application/${O}/chatHistory/${L}`,Y)})}postChatHistorySessionId(O,L){return ve(this,null,function*(){return this.post(`/chatHistory/${O}`,L)})}getApplications(O){return ve(this,null,function*(){return this.get("/applications",O)})}postApplication(O){return ve(this,null,function*(){return this.post("/applications",O)})}getApplicationId(O){return ve(this,null,function*(){return this.get(`/applications/${O}`)})}patchApplicationId(O,L){return ve(this,null,function*(){return this.patch(`/applications/${O}`,L)})}delApplicationId(O){return ve(this,null,function*(){return this.delete(`/applications/${O}`)})}getApplicationIdSessions(O){return ve(this,null,function*(){return this.get(`/applications/${O}/session`)})}patchFileId(O,L){return ve(this,null,function*(){return this.patch(`/file/${O}`,L)})}getCvforceResource(O){return ve(this,null,function*(){return this.get("/cvforce/resource",O)})}postKnowledgeIdComposedFiles(O,L){return ve(this,null,function*(){return this.post(`/knowledge/${O}/composedFiles`,L)})}getTokensApplicationId(O,L){return ve(this,null,function*(){return this.get(`/tokens/${O}`,L)})}getTokens(O){return ve(this,null,function*(){return this.get("/tokens",O)})}uploadMinioFile(O,L){return ve(this,null,function*(){return new Promise((Y,ut)=>{const ht=new FileReader;ht.readAsArrayBuffer(L),ht.onload=W=>{cc.initMinio({endPoint:O.endpoints[0],useSSL:O.useSSL,accessKey:O.accessKey,secretKey:O.secretKey});const _=Buffer.from(W.target.result),y={"Content-Type":"application/octet-stream"};cc.putObjectBuffer(O.bucket,O.fileKeys[0],_,y,x=>{if(x)throw console.error(x),Error(x);Y(O.fileKeys[0])})}})})}uploadFile(O,L){return ve(this,null,function*(){const Y={files:[L.name],isv:"minio",knowledgeId:O};return this.getUploadTicket(Y).then(ut=>this.uploadMinioFile(ut.minio,L)).catch(ut=>{throw Error(ut)})})}uploadFiles(O,L){return ve(this,null,function*(){const Y={files:L.map(ut=>ut.name),isv:"minio",knowledgeId:O};return this.getUploadTicket(Y).then(ut=>Promise.all(L.map(ht=>this.uploadMinioFile(ut.minio,ht)))).catch(ut=>{throw Error(ut)})})}getAecModels(){return ve(this,null,function*(){return this.get("/aecModels")})}postTextFilter(O){return ve(this,null,function*(){return this.post("/textFilter",O)})}getTenantModel(){return ve(this,null,function*(){return this.get("/tenantModel")})}getPrompts(O,L){return ve(this,null,function*(){return this.get(`application/${O}/promptVariables`,L)})}postPrompt(O,L){return ve(this,null,function*(){return this.post(`application/${O}/promptVariables`,L)})}patchPromptId(O,L,Y){return ve(this,null,function*(){return this.patch(`application/${O}/promptVariables/${L}`,Y)})}delPromptId(O,L){return ve(this,null,function*(){return this.delete(`application/${O}/promptVariables/${L}`)})}getSessionPrompts(O){return ve(this,null,function*(){return this.get(`session/${O}/promptVariables`)})}patchSessionPromptId(O,L,Y){return ve(this,null,function*(){return this.patch(`session/${L}/promptVariables/${O}`,Y)})}getApplicationIdSessionIdPromptVariables(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/session/${L}/promptVariables`)})}patchApplicationIdSessionpromptVariablesId(O,L,Y,ut){return ve(this,null,function*(){return this.patch(`/application/${O}/session/${L}/promptVariables/${Y}`,ut)})}getPresetApplication(O){return ve(this,null,function*(){return this.get("presetApplication",O)})}postKnowledgeConfig(O){return ve(this,null,function*(){return this.post("/knowledgeConfig",O)})}getKnowledgeConfig(O){return ve(this,null,function*(){return this.get(`/knowledgeConfig/${O}`)})}patchKnowledgeConfig(O,L){return ve(this,null,function*(){return this.patch(`/knowledgeConfig/${O}`,L)})}getKnowledgeIdFileId(O,L){return ve(this,null,function*(){return this.get(`/knowledge/${O}/file/${L}`)})}getKnowledgeIdFileIdData(O,L,Y){return ve(this,null,function*(){return this.listPaged(`/knowledge/${O}/file/${L}/data`,Y)})}postKnowledgeIdFileIdData(O,L,Y){return ve(this,null,function*(){return this.post(`/knowledge/${O}/file/${L}/data`,{data:Y})})}patchKnowledgeIdFileIdData(O,L,Y,ut){return ve(this,null,function*(){return this.patch(`/knowledge/${O}/file/${L}/data/${Y}`,{data:ut})})}delKnowledgeIdFileIdDataDid(O,L,Y){return ve(this,null,function*(){return this.delete(`/knowledge/${O}/file/${L}/data/${Y}`)})}getPresetKnowledge(O){return ve(this,null,function*(){return this.get("/presetKnowledge",O)})}patchSessionsIdContext(O){return ve(this,null,function*(){return this.patch(`/sessions/${O}/context`,{})})}postResourceToken(O){return ve(this,null,function*(){return this.post("/resourceToken",O)})}getApplicationIdSession(O){return ve(this,null,function*(){return this.get(`/application/${O}/session`)})}patchApplicationIdSessionsIdContext(O,L){return ve(this,null,function*(){return this.patch(`/application/${O}/sessions/${L}/context`,{})})}postApplicationIdSessions(O,L){return ve(this,null,function*(){return this.post(`/application/${O}/sessions`,L)})}getApplicationIdChatHistorySessionId(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/chatHistory/${L}`)})}postApplicationIdChatHistorySessionIdComments(O,L,Y){return ve(this,null,function*(){return this.post(`/application/${O}/sessions/${L}/comments`,Y)})}getApplicationIdPrompts(O,L){return ve(this,null,function*(){return this.get(`/application/${O}/promptVariables`,L)})}postKnowledgeSourceFile(O,L,Y){return ve(this,null,function*(){return this.post(`/knowledge/${O}/sourceFile/${L}`,Y)})}getMetadata(O){return ve(this,null,function*(){return this.get("/metadata",O)})}postGeneques(O){return ve(this,null,function*(){return this.post("/geneques",O)})}getBaseModel(O){return ve(this,null,function*(){return this.get("/baseModelInfo",{serviceId:O})})}}var vr=(K=>(K[K.Robot=1]="Robot",K[K.User=2]="User",K[K.System=3]="System",K))(vr||{}),pc=(K=>(K[K.Idle=0]="Idle",K[K.Quoted=1]="Quoted",K))(pc||{}),bn=(K=>(K[K.Dialog=0]="Dialog",K[K.Text=1]="Text",K[K.Agent=2]="Agent",K[K.All=3]="All",K))(bn||{});function dc(K,O,L){const Y=x=>{var v;return O&&(sf(O)&&L(403,"aiotToken is timeout"),x.headers=(v=x.headers)!==null&&v!==void 0?v:{},x.headers=Object.assign(Object.assign({},x.headers),{Authorization:O?`Bearer ${O}`:""})),x};function ut(x,v=!0){const m=`${K}${x}`,S=oc.create({baseURL:m});return v&&S.interceptors.request.use(Y),S}const ht=(x,v)=>{x===401&&L(x,"aiotToken is invalid")},W=(x,v)=>{x!==10001&&x!==10215&&L(x,v)},_=ut("/data/v1");return new _p(_,{onHttpStatusError:ht,onAppStatusError:W})}const kr=Object.create(null);kr.open="0",kr.close="1",kr.ping="2",kr.pong="3",kr.message="4",kr.upgrade="5",kr.noop="6";const po=Object.create(null);Object.keys(kr).forEach(K=>{po[kr[K]]=K});const Ka={type:"error",data:"parser error"},mc=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",gc=typeof ArrayBuffer=="function",vc=K=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(K):K&&K.buffer instanceof ArrayBuffer,Ja=({type:K,data:O},L,Y)=>mc&&O instanceof Blob?L?Y(O):yc(O,Y):gc&&(O instanceof ArrayBuffer||vc(O))?L?Y(O):yc(new Blob([O]),Y):Y(kr[K]+(O||"")),yc=(K,O)=>{const L=new FileReader;return L.onload=function(){const Y=L.result.split(",")[1];O("b"+(Y||""))},L.readAsDataURL(K)};function bc(K){return K instanceof Uint8Array?K:K instanceof ArrayBuffer?new Uint8Array(K):new Uint8Array(K.buffer,K.byteOffset,K.byteLength)}let Ga;function Sp(K,O){if(mc&&K.data instanceof Blob)return K.data.arrayBuffer().then(bc).then(O);if(gc&&(K.data instanceof ArrayBuffer||vc(K.data)))return O(bc(K.data));Ja(K,!1,L=>{Ga||(Ga=new TextEncoder),O(Ga.encode(L))})}const wc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let K=0;K<wc.length;K++)Cn[wc.charCodeAt(K)]=K;const Ep=K=>{let O=K.length*.75,L=K.length,Y,ut=0,ht,W,_,y;K[K.length-1]==="="&&(O--,K[K.length-2]==="="&&O--);const x=new ArrayBuffer(O),v=new Uint8Array(x);for(Y=0;Y<L;Y+=4)ht=Cn[K.charCodeAt(Y)],W=Cn[K.charCodeAt(Y+1)],_=Cn[K.charCodeAt(Y+2)],y=Cn[K.charCodeAt(Y+3)],v[ut++]=ht<<2|W>>4,v[ut++]=(W&15)<<4|_>>2,v[ut++]=(_&3)<<6|y&63;return x},kp=typeof ArrayBuffer=="function",Ya=(K,O)=>{if(typeof K!="string")return{type:"message",data:Mc(K,O)};const L=K.charAt(0);return L==="b"?{type:"message",data:Ip(K.substring(1),O)}:po[L]?K.length>1?{type:po[L],data:K.substring(1)}:{type:po[L]}:Ka},Ip=(K,O)=>{if(kp){const L=Ep(K);return Mc(L,O)}else return{base64:!0,data:K}},Mc=(K,O)=>{switch(O){case"blob":return K instanceof Blob?K:new Blob([K]);case"arraybuffer":default:return K instanceof ArrayBuffer?K:K.buffer}},xc=String.fromCharCode(30),Op=(K,O)=>{const L=K.length,Y=new Array(L);let ut=0;K.forEach((ht,W)=>{Ja(ht,!1,_=>{Y[W]=_,++ut===L&&O(Y.join(xc))})})},Ap=(K,O)=>{const L=K.split(xc),Y=[];for(let ut=0;ut<L.length;ut++){const ht=Ya(L[ut],O);if(Y.push(ht),ht.type==="error")break}return Y};function Tp(){return new TransformStream({transform(K,O){Sp(K,L=>{const Y=L.length;let ut;if(Y<126)ut=new Uint8Array(1),new DataView(ut.buffer).setUint8(0,Y);else if(Y<65536){ut=new Uint8Array(3);const ht=new DataView(ut.buffer);ht.setUint8(0,126),ht.setUint16(1,Y)}else{ut=new Uint8Array(9);const ht=new DataView(ut.buffer);ht.setUint8(0,127),ht.setBigUint64(1,BigInt(Y))}K.data&&typeof K.data!="string"&&(ut[0]|=128),O.enqueue(ut),O.enqueue(L)})}})}let Qa;function mo(K){return K.reduce((O,L)=>O+L.length,0)}function go(K,O){if(K[0].length===O)return K.shift();const L=new Uint8Array(O);let Y=0;for(let ut=0;ut<O;ut++)L[ut]=K[0][Y++],Y===K[0].length&&(K.shift(),Y=0);return K.length&&Y<K[0].length&&(K[0]=K[0].slice(Y)),L}function Bp(K,O){Qa||(Qa=new TextDecoder);const L=[];let Y=0,ut=-1,ht=!1;return new TransformStream({transform(W,_){for(L.push(W);;){if(Y===0){if(mo(L)<1)break;const y=go(L,1);ht=(y[0]&128)===128,ut=y[0]&127,ut<126?Y=3:ut===126?Y=1:Y=2}else if(Y===1){if(mo(L)<2)break;const y=go(L,2);ut=new DataView(y.buffer,y.byteOffset,y.length).getUint16(0),Y=3}else if(Y===2){if(mo(L)<8)break;const y=go(L,8),x=new DataView(y.buffer,y.byteOffset,y.length),v=x.getUint32(0);if(v>Math.pow(2,53-32)-1){_.enqueue(Ka);break}ut=v*Math.pow(2,32)+x.getUint32(4),Y=3}else{if(mo(L)<ut)break;const y=go(L,ut);_.enqueue(Ya(ht?y:Qa.decode(y),O)),Y=0}if(ut===0||ut>K){_.enqueue(Ka);break}}}})}const _c=4;function Bi(K){if(K)return jp(K)}function jp(K){for(var O in Bi.prototype)K[O]=Bi.prototype[O];return K}Bi.prototype.on=Bi.prototype.addEventListener=function(K,O){return this._callbacks=this._callbacks||{},(this._callbacks["$"+K]=this._callbacks["$"+K]||[]).push(O),this},Bi.prototype.once=function(K,O){function L(){this.off(K,L),O.apply(this,arguments)}return L.fn=O,this.on(K,L),this},Bi.prototype.off=Bi.prototype.removeListener=Bi.prototype.removeAllListeners=Bi.prototype.removeEventListener=function(K,O){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var L=this._callbacks["$"+K];if(!L)return this;if(arguments.length==1)return delete this._callbacks["$"+K],this;for(var Y,ut=0;ut<L.length;ut++)if(Y=L[ut],Y===O||Y.fn===O){L.splice(ut,1);break}return L.length===0&&delete this._callbacks["$"+K],this},Bi.prototype.emit=function(K){this._callbacks=this._callbacks||{};for(var O=new Array(arguments.length-1),L=this._callbacks["$"+K],Y=1;Y<arguments.length;Y++)O[Y-1]=arguments[Y];if(L){L=L.slice(0);for(var Y=0,ut=L.length;Y<ut;++Y)L[Y].apply(this,O)}return this},Bi.prototype.emitReserved=Bi.prototype.emit,Bi.prototype.listeners=function(K){return this._callbacks=this._callbacks||{},this._callbacks["$"+K]||[]},Bi.prototype.hasListeners=function(K){return!!this.listeners(K).length};const ur=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function Sc(K,...O){return O.reduce((L,Y)=>(K.hasOwnProperty(Y)&&(L[Y]=K[Y]),L),{})}const Rp=ur.setTimeout,Np=ur.clearTimeout;function vo(K,O){O.useNativeTimers?(K.setTimeoutFn=Rp.bind(ur),K.clearTimeoutFn=Np.bind(ur)):(K.setTimeoutFn=ur.setTimeout.bind(ur),K.clearTimeoutFn=ur.clearTimeout.bind(ur))}const Cp=1.33;function Pp(K){return typeof K=="string"?Lp(K):Math.ceil((K.byteLength||K.size)*Cp)}function Lp(K){let O=0,L=0;for(let Y=0,ut=K.length;Y<ut;Y++)O=K.charCodeAt(Y),O<128?L+=1:O<2048?L+=2:O<55296||O>=57344?L+=3:(Y++,L+=4);return L}function Dp(K){let O="";for(let L in K)K.hasOwnProperty(L)&&(O.length&&(O+="&"),O+=encodeURIComponent(L)+"="+encodeURIComponent(K[L]));return O}function Up(K){let O={},L=K.split("&");for(let Y=0,ut=L.length;Y<ut;Y++){let ht=L[Y].split("=");O[decodeURIComponent(ht[0])]=decodeURIComponent(ht[1])}return O}class qp extends Error{constructor(O,L,Y){super(O),this.description=L,this.context=Y,this.type="TransportError"}}class ts extends Bi{constructor(O){super(),this.writable=!1,vo(this,O),this.opts=O,this.query=O.query,this.socket=O.socket}onError(O,L,Y){return super.emitReserved("error",new qp(O,L,Y)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(O){this.readyState==="open"&&this.write(O)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(O){const L=Ya(O,this.socket.binaryType);this.onPacket(L)}onPacket(O){super.emitReserved("packet",O)}onClose(O){this.readyState="closed",super.emitReserved("close",O)}pause(O){}createUri(O,L={}){return O+"://"+this._hostname()+this._port()+this.opts.path+this._query(L)}_hostname(){const O=this.opts.hostname;return O.indexOf(":")===-1?O:"["+O+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(O){const L=Dp(O);return L.length?"?"+L:""}}const Ec="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),es=64,Fp={};let kc=0,yo=0,Ic;function Oc(K){let O="";do O=Ec[K%es]+O,K=Math.floor(K/es);while(K>0);return O}function Ac(){const K=Oc(+new Date);return K!==Ic?(kc=0,Ic=K):K+"."+Oc(kc++)}for(;yo<es;yo++)Fp[Ec[yo]]=yo;let Tc=!1;try{Tc=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const zp=Tc;function Bc(K){const O=K.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!O||zp))return new XMLHttpRequest}catch{}if(!O)try{return new ur[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Lm(){}function $p(){}const Hp=function(){return new Bc({xdomain:!1}).responseType!=null}();class Wp extends ts{constructor(O){if(super(O),this.polling=!1,typeof location<"u"){const Y=location.protocol==="https:";let ut=location.port;ut||(ut=Y?"443":"80"),this.xd=typeof location<"u"&&O.hostname!==location.hostname||ut!==O.port}const L=O&&O.forceBase64;this.supportsBinary=Hp&&!L,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(O){this.readyState="pausing";const L=()=>{this.readyState="paused",O()};if(this.polling||!this.writable){let Y=0;this.polling&&(Y++,this.once("pollComplete",function(){--Y||L()})),this.writable||(Y++,this.once("drain",function(){--Y||L()}))}else L()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(O){const L=Y=>{if(this.readyState==="opening"&&Y.type==="open"&&this.onOpen(),Y.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(Y)};Ap(O,this.socket.binaryType).forEach(L),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const O=()=>{this.write([{type:"close"}])};this.readyState==="open"?O():this.once("open",O)}write(O){this.writable=!1,Op(O,L=>{this.doWrite(L,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const O=this.opts.secure?"https":"http",L=this.query||{};return this.opts.timestampRequests!==!1&&(L[this.opts.timestampParam]=Ac()),!this.supportsBinary&&!L.sid&&(L.b64=1),this.createUri(O,L)}request(O={}){return Object.assign(O,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ir(this.uri(),O)}doWrite(O,L){const Y=this.request({method:"POST",data:O});Y.on("success",L),Y.on("error",(ut,ht)=>{this.onError("xhr post error",ut,ht)})}doPoll(){const O=this.request();O.on("data",this.onData.bind(this)),O.on("error",(L,Y)=>{this.onError("xhr poll error",L,Y)}),this.pollXhr=O}}class Ir extends Bi{constructor(O,L){super(),vo(this,L),this.opts=L,this.method=L.method||"GET",this.uri=O,this.data=L.data!==void 0?L.data:null,this.create()}create(){var O;const L=Sc(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");L.xdomain=!!this.opts.xd;const Y=this.xhr=new Bc(L);try{Y.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){Y.setDisableHeaderCheck&&Y.setDisableHeaderCheck(!0);for(let ut in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(ut)&&Y.setRequestHeader(ut,this.opts.extraHeaders[ut])}}catch{}if(this.method==="POST")try{Y.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{Y.setRequestHeader("Accept","*/*")}catch{}(O=this.opts.cookieJar)===null||O===void 0||O.addCookies(Y),"withCredentials"in Y&&(Y.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(Y.timeout=this.opts.requestTimeout),Y.onreadystatechange=()=>{var ut;Y.readyState===3&&((ut=this.opts.cookieJar)===null||ut===void 0||ut.parseCookies(Y)),Y.readyState===4&&(Y.status===200||Y.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof Y.status=="number"?Y.status:0)},0))},Y.send(this.data)}catch(ut){this.setTimeoutFn(()=>{this.onError(ut)},0);return}typeof document<"u"&&(this.index=Ir.requestsCount++,Ir.requests[this.index]=this)}onError(O){this.emitReserved("error",O,this.xhr),this.cleanup(!0)}cleanup(O){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=$p,O)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Ir.requests[this.index],this.xhr=null}}onLoad(){const O=this.xhr.responseText;O!==null&&(this.emitReserved("data",O),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(Ir.requestsCount=0,Ir.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",jc);else if(typeof addEventListener=="function"){const K="onpagehide"in ur?"pagehide":"unload";addEventListener(K,jc,!1)}}function jc(){for(let K in Ir.requests)Ir.requests.hasOwnProperty(K)&&Ir.requests[K].abort()}const is=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?O=>Promise.resolve().then(O):(O,L)=>L(O,0))(),bo=ur.WebSocket||ur.MozWebSocket,Rc=!0,Vp="arraybuffer",Nc=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Xp extends ts{constructor(O){super(O),this.supportsBinary=!O.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const O=this.uri(),L=this.opts.protocols,Y=Nc?{}:Sc(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(Y.headers=this.opts.extraHeaders);try{this.ws=Rc&&!Nc?L?new bo(O,L):new bo(O):new bo(O,L,Y)}catch(ut){return this.emitReserved("error",ut)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=O=>this.onClose({description:"websocket connection closed",context:O}),this.ws.onmessage=O=>this.onData(O.data),this.ws.onerror=O=>this.onError("websocket error",O)}write(O){this.writable=!1;for(let L=0;L<O.length;L++){const Y=O[L],ut=L===O.length-1;Ja(Y,this.supportsBinary,ht=>{const W={};try{Rc&&this.ws.send(ht)}catch{}ut&&is(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const O=this.opts.secure?"wss":"ws",L=this.query||{};return this.opts.timestampRequests&&(L[this.opts.timestampParam]=Ac()),this.supportsBinary||(L.b64=1),this.createUri(O,L)}check(){return!!bo}}class Zp extends ts{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(O=>{this.onError("webtransport error",O)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(O=>{const L=Bp(Number.MAX_SAFE_INTEGER,this.socket.binaryType),Y=O.readable.pipeThrough(L).getReader(),ut=Tp();ut.readable.pipeTo(O.writable),this.writer=ut.writable.getWriter();const ht=()=>{Y.read().then(({done:_,value:y})=>{_||(this.onPacket(y),ht())}).catch(_=>{})};ht();const W={type:"open"};this.query.sid&&(W.data=`{"sid":"${this.query.sid}"}`),this.writer.write(W).then(()=>this.onOpen())})}))}write(O){this.writable=!1;for(let L=0;L<O.length;L++){const Y=O[L],ut=L===O.length-1;this.writer.write(Y).then(()=>{ut&&is(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var O;(O=this.transport)===null||O===void 0||O.close()}}const Kp={websocket:Xp,webtransport:Zp,polling:Wp},Jp=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Gp=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function rs(K){if(K.length>2e3)throw"URI too long";const O=K,L=K.indexOf("["),Y=K.indexOf("]");L!=-1&&Y!=-1&&(K=K.substring(0,L)+K.substring(L,Y).replace(/:/g,";")+K.substring(Y,K.length));let ut=Jp.exec(K||""),ht={},W=14;for(;W--;)ht[Gp[W]]=ut[W]||"";return L!=-1&&Y!=-1&&(ht.source=O,ht.host=ht.host.substring(1,ht.host.length-1).replace(/;/g,":"),ht.authority=ht.authority.replace("[","").replace("]","").replace(/;/g,":"),ht.ipv6uri=!0),ht.pathNames=Yp(ht,ht.path),ht.queryKey=Qp(ht,ht.query),ht}function Yp(K,O){const L=/\/{2,9}/g,Y=O.replace(L,"/").split("/");return(O.slice(0,1)=="/"||O.length===0)&&Y.splice(0,1),O.slice(-1)=="/"&&Y.splice(Y.length-1,1),Y}function Qp(K,O){const L={};return O.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(Y,ut,ht){ut&&(L[ut]=ht)}),L}let Cc=class Rn extends Bi{constructor(O,L={}){super(),this.binaryType=Vp,this.writeBuffer=[],O&&typeof O=="object"&&(L=O,O=null),O?(O=rs(O),L.hostname=O.host,L.secure=O.protocol==="https"||O.protocol==="wss",L.port=O.port,O.query&&(L.query=O.query)):L.host&&(L.hostname=rs(L.host).host),vo(this,L),this.secure=L.secure!=null?L.secure:typeof location<"u"&&location.protocol==="https:",L.hostname&&!L.port&&(L.port=this.secure?"443":"80"),this.hostname=L.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=L.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=L.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},L),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Up(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(O){const L=Object.assign({},this.opts.query);L.EIO=_c,L.transport=O,this.id&&(L.sid=this.id);const Y=Object.assign({},this.opts,{query:L,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[O]);return new Kp[O](Y)}open(){let O;if(this.opts.rememberUpgrade&&Rn.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)O="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else O=this.transports[0];this.readyState="opening";try{O=this.createTransport(O)}catch{this.transports.shift(),this.open();return}O.open(),this.setTransport(O)}setTransport(O){this.transport&&this.transport.removeAllListeners(),this.transport=O,O.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",L=>this.onClose("transport close",L))}probe(O){let L=this.createTransport(O),Y=!1;Rn.priorWebsocketSuccess=!1;const ut=()=>{Y||(L.send([{type:"ping",data:"probe"}]),L.once("packet",m=>{if(!Y)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",L),!L)return;Rn.priorWebsocketSuccess=L.name==="websocket",this.transport.pause(()=>{Y||this.readyState!=="closed"&&(v(),this.setTransport(L),L.send([{type:"upgrade"}]),this.emitReserved("upgrade",L),L=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=L.name,this.emitReserved("upgradeError",S)}}))};function ht(){Y||(Y=!0,v(),L.close(),L=null)}const W=m=>{const S=new Error("probe error: "+m);S.transport=L.name,ht(),this.emitReserved("upgradeError",S)};function _(){W("transport closed")}function y(){W("socket closed")}function x(m){L&&m.name!==L.name&&ht()}const v=()=>{L.removeListener("open",ut),L.removeListener("error",W),L.removeListener("close",_),this.off("close",y),this.off("upgrading",x)};L.once("open",ut),L.once("error",W),L.once("close",_),this.once("close",y),this.once("upgrading",x),this.upgrades.indexOf("webtransport")!==-1&&O!=="webtransport"?this.setTimeoutFn(()=>{Y||L.open()},200):L.open()}onOpen(){if(this.readyState="open",Rn.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let O=0;const L=this.upgrades.length;for(;O<L;O++)this.probe(this.upgrades[O])}}onPacket(O){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",O),this.emitReserved("heartbeat"),this.resetPingTimeout(),O.type){case"open":this.onHandshake(JSON.parse(O.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const L=new Error("server error");L.code=O.data,this.onError(L);break;case"message":this.emitReserved("data",O.data),this.emitReserved("message",O.data);break}}onHandshake(O){this.emitReserved("handshake",O),this.id=O.sid,this.transport.query.sid=O.sid,this.upgrades=this.filterUpgrades(O.upgrades),this.pingInterval=O.pingInterval,this.pingTimeout=O.pingTimeout,this.maxPayload=O.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const O=this.getWritablePackets();this.transport.send(O),this.prevBufferLen=O.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let L=1;for(let Y=0;Y<this.writeBuffer.length;Y++){const ut=this.writeBuffer[Y].data;if(ut&&(L+=Pp(ut)),Y>0&&L>this.maxPayload)return this.writeBuffer.slice(0,Y);L+=2}return this.writeBuffer}write(O,L,Y){return this.sendPacket("message",O,L,Y),this}send(O,L,Y){return this.sendPacket("message",O,L,Y),this}sendPacket(O,L,Y,ut){if(typeof L=="function"&&(ut=L,L=void 0),typeof Y=="function"&&(ut=Y,Y=null),this.readyState==="closing"||this.readyState==="closed")return;Y=Y||{},Y.compress=Y.compress!==!1;const ht={type:O,data:L,options:Y};this.emitReserved("packetCreate",ht),this.writeBuffer.push(ht),ut&&this.once("flush",ut),this.flush()}close(){const O=()=>{this.onClose("forced close"),this.transport.close()},L=()=>{this.off("upgrade",L),this.off("upgradeError",L),O()},Y=()=>{this.once("upgrade",L),this.once("upgradeError",L)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?Y():O()}):this.upgrading?Y():O()),this}onError(O){Rn.priorWebsocketSuccess=!1,this.emitReserved("error",O),this.onClose("transport error",O)}onClose(O,L){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",O,L),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(O){const L=[];let Y=0;const ut=O.length;for(;Y<ut;Y++)~this.transports.indexOf(O[Y])&&L.push(O[Y]);return L}};Cc.protocol=_c;function td(K,O="",L){let Y=K;L=L||typeof location<"u"&&location,K==null&&(K=L.protocol+"//"+L.host),typeof K=="string"&&(K.charAt(0)==="/"&&(K.charAt(1)==="/"?K=L.protocol+K:K=L.host+K),/^(https?|wss?):\/\//.test(K)||(typeof L<"u"?K=L.protocol+"//"+K:K="https://"+K),Y=rs(K)),Y.port||(/^(http|ws)$/.test(Y.protocol)?Y.port="80":/^(http|ws)s$/.test(Y.protocol)&&(Y.port="443")),Y.path=Y.path||"/";const ht=Y.host.indexOf(":")!==-1?"["+Y.host+"]":Y.host;return Y.id=Y.protocol+"://"+ht+":"+Y.port+O,Y.href=Y.protocol+"://"+ht+(L&&L.port===Y.port?"":":"+Y.port),Y}const ed=typeof ArrayBuffer=="function",id=K=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(K):K.buffer instanceof ArrayBuffer,Pc=Object.prototype.toString,rd=typeof Blob=="function"||typeof Blob<"u"&&Pc.call(Blob)==="[object BlobConstructor]",nd=typeof File=="function"||typeof File<"u"&&Pc.call(File)==="[object FileConstructor]";function ns(K){return ed&&(K instanceof ArrayBuffer||id(K))||rd&&K instanceof Blob||nd&&K instanceof File}function wo(K,O){if(!K||typeof K!="object")return!1;if(Array.isArray(K)){for(let L=0,Y=K.length;L<Y;L++)if(wo(K[L]))return!0;return!1}if(ns(K))return!0;if(K.toJSON&&typeof K.toJSON=="function"&&arguments.length===1)return wo(K.toJSON(),!0);for(const L in K)if(Object.prototype.hasOwnProperty.call(K,L)&&wo(K[L]))return!0;return!1}function od(K){const O=[],L=K.data,Y=K;return Y.data=os(L,O),Y.attachments=O.length,{packet:Y,buffers:O}}function os(K,O){if(!K)return K;if(ns(K)){const L={_placeholder:!0,num:O.length};return O.push(K),L}else if(Array.isArray(K)){const L=new Array(K.length);for(let Y=0;Y<K.length;Y++)L[Y]=os(K[Y],O);return L}else if(typeof K=="object"&&!(K instanceof Date)){const L={};for(const Y in K)Object.prototype.hasOwnProperty.call(K,Y)&&(L[Y]=os(K[Y],O));return L}return K}function ad(K,O){return K.data=as(K.data,O),delete K.attachments,K}function as(K,O){if(!K)return K;if(K&&K._placeholder===!0){if(typeof K.num=="number"&&K.num>=0&&K.num<O.length)return O[K.num];throw new Error("illegal attachments")}else if(Array.isArray(K))for(let L=0;L<K.length;L++)K[L]=as(K[L],O);else if(typeof K=="object")for(const L in K)Object.prototype.hasOwnProperty.call(K,L)&&(K[L]=as(K[L],O));return K}const sd=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],ud=5;var ti;(function(K){K[K.CONNECT=0]="CONNECT",K[K.DISCONNECT=1]="DISCONNECT",K[K.EVENT=2]="EVENT",K[K.ACK=3]="ACK",K[K.CONNECT_ERROR=4]="CONNECT_ERROR",K[K.BINARY_EVENT=5]="BINARY_EVENT",K[K.BINARY_ACK=6]="BINARY_ACK"})(ti||(ti={}));class cd{constructor(O){this.replacer=O}encode(O){return(O.type===ti.EVENT||O.type===ti.ACK)&&wo(O)?this.encodeAsBinary({type:O.type===ti.EVENT?ti.BINARY_EVENT:ti.BINARY_ACK,nsp:O.nsp,data:O.data,id:O.id}):[this.encodeAsString(O)]}encodeAsString(O){let L=""+O.type;return(O.type===ti.BINARY_EVENT||O.type===ti.BINARY_ACK)&&(L+=O.attachments+"-"),O.nsp&&O.nsp!=="/"&&(L+=O.nsp+","),O.id!=null&&(L+=O.id),O.data!=null&&(L+=JSON.stringify(O.data,this.replacer)),L}encodeAsBinary(O){const L=od(O),Y=this.encodeAsString(L.packet),ut=L.buffers;return ut.unshift(Y),ut}}function Lc(K){return Object.prototype.toString.call(K)==="[object Object]"}class ss extends Bi{constructor(O){super(),this.reviver=O}add(O){let L;if(typeof O=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");L=this.decodeString(O);const Y=L.type===ti.BINARY_EVENT;Y||L.type===ti.BINARY_ACK?(L.type=Y?ti.EVENT:ti.ACK,this.reconstructor=new ld(L),L.attachments===0&&super.emitReserved("decoded",L)):super.emitReserved("decoded",L)}else if(ns(O)||O.base64)if(this.reconstructor)L=this.reconstructor.takeBinaryData(O),L&&(this.reconstructor=null,super.emitReserved("decoded",L));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+O)}decodeString(O){let L=0;const Y={type:Number(O.charAt(0))};if(ti[Y.type]===void 0)throw new Error("unknown packet type "+Y.type);if(Y.type===ti.BINARY_EVENT||Y.type===ti.BINARY_ACK){const ht=L+1;for(;O.charAt(++L)!=="-"&&L!=O.length;);const W=O.substring(ht,L);if(W!=Number(W)||O.charAt(L)!=="-")throw new Error("Illegal attachments");Y.attachments=Number(W)}if(O.charAt(L+1)==="/"){const ht=L+1;for(;++L&&!(O.charAt(L)===","||L===O.length););Y.nsp=O.substring(ht,L)}else Y.nsp="/";const ut=O.charAt(L+1);if(ut!==""&&Number(ut)==ut){const ht=L+1;for(;++L;){const W=O.charAt(L);if(W==null||Number(W)!=W){--L;break}if(L===O.length)break}Y.id=Number(O.substring(ht,L+1))}if(O.charAt(++L)){const ht=this.tryParse(O.substr(L));if(ss.isPayloadValid(Y.type,ht))Y.data=ht;else throw new Error("invalid payload")}return Y}tryParse(O){try{return JSON.parse(O,this.reviver)}catch{return!1}}static isPayloadValid(O,L){switch(O){case ti.CONNECT:return Lc(L);case ti.DISCONNECT:return L===void 0;case ti.CONNECT_ERROR:return typeof L=="string"||Lc(L);case ti.EVENT:case ti.BINARY_EVENT:return Array.isArray(L)&&(typeof L[0]=="number"||typeof L[0]=="string"&&sd.indexOf(L[0])===-1);case ti.ACK:case ti.BINARY_ACK:return Array.isArray(L)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ld{constructor(O){this.packet=O,this.buffers=[],this.reconPack=O}takeBinaryData(O){if(this.buffers.push(O),this.buffers.length===this.reconPack.attachments){const L=ad(this.reconPack,this.buffers);return this.finishedReconstruction(),L}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const hd=Object.freeze(Object.defineProperty({__proto__:null,Decoder:ss,Encoder:cd,get PacketType(){return ti},protocol:ud},Symbol.toStringTag,{value:"Module"}));function yr(K,O,L){return K.on(O,L),function(){K.off(O,L)}}const fd=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Dc extends Bi{constructor(O,L,Y){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=O,this.nsp=L,Y&&Y.auth&&(this.auth=Y.auth),this._opts=Object.assign({},Y),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const O=this.io;this.subs=[yr(O,"open",this.onopen.bind(this)),yr(O,"packet",this.onpacket.bind(this)),yr(O,"error",this.onerror.bind(this)),yr(O,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...O){return O.unshift("message"),this.emit.apply(this,O),this}emit(O,...L){if(fd.hasOwnProperty(O))throw new Error('"'+O.toString()+'" is a reserved event name');if(L.unshift(O),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(L),this;const Y={type:ti.EVENT,data:L};if(Y.options={},Y.options.compress=this.flags.compress!==!1,typeof L[L.length-1]=="function"){const W=this.ids++,_=L.pop();this._registerAckCallback(W,_),Y.id=W}const ut=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!ut||!this.connected)||(this.connected?(this.notifyOutgoingListeners(Y),this.packet(Y)):this.sendBuffer.push(Y)),this.flags={},this}_registerAckCallback(O,L){var Y;const ut=(Y=this.flags.timeout)!==null&&Y!==void 0?Y:this._opts.ackTimeout;if(ut===void 0){this.acks[O]=L;return}const ht=this.io.setTimeoutFn(()=>{delete this.acks[O];for(let _=0;_<this.sendBuffer.length;_++)this.sendBuffer[_].id===O&&this.sendBuffer.splice(_,1);L.call(this,new Error("operation has timed out"))},ut),W=(..._)=>{this.io.clearTimeoutFn(ht),L.apply(this,_)};W.withError=!0,this.acks[O]=W}emitWithAck(O,...L){return new Promise((Y,ut)=>{const ht=(W,_)=>W?ut(W):Y(_);ht.withError=!0,L.push(ht),this.emit(O,...L)})}_addToQueue(O){let L;typeof O[O.length-1]=="function"&&(L=O.pop());const Y={id:this._queueSeq++,tryCount:0,pending:!1,args:O,flags:Object.assign({fromQueue:!0},this.flags)};O.push((ut,...ht)=>Y!==this._queue[0]?void 0:(ut!==null?Y.tryCount>this._opts.retries&&(this._queue.shift(),L&&L(ut)):(this._queue.shift(),L&&L(null,...ht)),Y.pending=!1,this._drainQueue())),this._queue.push(Y),this._drainQueue()}_drainQueue(O=!1){if(!this.connected||this._queue.length===0)return;const L=this._queue[0];L.pending&&!O||(L.pending=!0,L.tryCount++,this.flags=L.flags,this.emit.apply(this,L.args))}packet(O){O.nsp=this.nsp,this.io._packet(O)}onopen(){typeof this.auth=="function"?this.auth(O=>{this._sendConnectPacket(O)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(O){this.packet({type:ti.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},O):O})}onerror(O){this.connected||this.emitReserved("connect_error",O)}onclose(O,L){this.connected=!1,delete this.id,this.emitReserved("disconnect",O,L),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(O=>{if(!this.sendBuffer.some(Y=>String(Y.id)===O)){const Y=this.acks[O];delete this.acks[O],Y.withError&&Y.call(this,new Error("socket has been disconnected"))}})}onpacket(O){if(O.nsp===this.nsp)switch(O.type){case ti.CONNECT:O.data&&O.data.sid?this.onconnect(O.data.sid,O.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ti.EVENT:case ti.BINARY_EVENT:this.onevent(O);break;case ti.ACK:case ti.BINARY_ACK:this.onack(O);break;case ti.DISCONNECT:this.ondisconnect();break;case ti.CONNECT_ERROR:this.destroy();const Y=new Error(O.data.message);Y.data=O.data.data,this.emitReserved("connect_error",Y);break}}onevent(O){const L=O.data||[];O.id!=null&&L.push(this.ack(O.id)),this.connected?this.emitEvent(L):this.receiveBuffer.push(Object.freeze(L))}emitEvent(O){if(this._anyListeners&&this._anyListeners.length){const L=this._anyListeners.slice();for(const Y of L)Y.apply(this,O)}super.emit.apply(this,O),this._pid&&O.length&&typeof O[O.length-1]=="string"&&(this._lastOffset=O[O.length-1])}ack(O){const L=this;let Y=!1;return function(...ut){Y||(Y=!0,L.packet({type:ti.ACK,id:O,data:ut}))}}onack(O){const L=this.acks[O.id];typeof L=="function"&&(delete this.acks[O.id],L.withError&&O.data.unshift(null),L.apply(this,O.data))}onconnect(O,L){this.id=O,this.recovered=L&&this._pid===L,this._pid=L,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(O=>this.emitEvent(O)),this.receiveBuffer=[],this.sendBuffer.forEach(O=>{this.notifyOutgoingListeners(O),this.packet(O)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(O=>O()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ti.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(O){return this.flags.compress=O,this}get volatile(){return this.flags.volatile=!0,this}timeout(O){return this.flags.timeout=O,this}onAny(O){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(O),this}prependAny(O){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(O),this}offAny(O){if(!this._anyListeners)return this;if(O){const L=this._anyListeners;for(let Y=0;Y<L.length;Y++)if(O===L[Y])return L.splice(Y,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(O){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(O),this}prependAnyOutgoing(O){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(O),this}offAnyOutgoing(O){if(!this._anyOutgoingListeners)return this;if(O){const L=this._anyOutgoingListeners;for(let Y=0;Y<L.length;Y++)if(O===L[Y])return L.splice(Y,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(O){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const L=this._anyOutgoingListeners.slice();for(const Y of L)Y.apply(this,O.data)}}}function wn(K){K=K||{},this.ms=K.min||100,this.max=K.max||1e4,this.factor=K.factor||2,this.jitter=K.jitter>0&&K.jitter<=1?K.jitter:0,this.attempts=0}wn.prototype.duration=function(){var K=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var O=Math.random(),L=Math.floor(O*this.jitter*K);K=Math.floor(O*10)&1?K+L:K-L}return Math.min(K,this.max)|0},wn.prototype.reset=function(){this.attempts=0},wn.prototype.setMin=function(K){this.ms=K},wn.prototype.setMax=function(K){this.max=K},wn.prototype.setJitter=function(K){this.jitter=K};class us extends Bi{constructor(O,L){var Y;super(),this.nsps={},this.subs=[],O&&typeof O=="object"&&(L=O,O=void 0),L=L||{},L.path=L.path||"/socket.io",this.opts=L,vo(this,L),this.reconnection(L.reconnection!==!1),this.reconnectionAttempts(L.reconnectionAttempts||1/0),this.reconnectionDelay(L.reconnectionDelay||1e3),this.reconnectionDelayMax(L.reconnectionDelayMax||5e3),this.randomizationFactor((Y=L.randomizationFactor)!==null&&Y!==void 0?Y:.5),this.backoff=new wn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(L.timeout==null?2e4:L.timeout),this._readyState="closed",this.uri=O;const ut=L.parser||hd;this.encoder=new ut.Encoder,this.decoder=new ut.Decoder,this._autoConnect=L.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(O){return arguments.length?(this._reconnection=!!O,this):this._reconnection}reconnectionAttempts(O){return O===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=O,this)}reconnectionDelay(O){var L;return O===void 0?this._reconnectionDelay:(this._reconnectionDelay=O,(L=this.backoff)===null||L===void 0||L.setMin(O),this)}randomizationFactor(O){var L;return O===void 0?this._randomizationFactor:(this._randomizationFactor=O,(L=this.backoff)===null||L===void 0||L.setJitter(O),this)}reconnectionDelayMax(O){var L;return O===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=O,(L=this.backoff)===null||L===void 0||L.setMax(O),this)}timeout(O){return arguments.length?(this._timeout=O,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(O){if(~this._readyState.indexOf("open"))return this;this.engine=new Cc(this.uri,this.opts);const L=this.engine,Y=this;this._readyState="opening",this.skipReconnect=!1;const ut=yr(L,"open",function(){Y.onopen(),O&&O()}),ht=_=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",_),O?O(_):this.maybeReconnectOnOpen()},W=yr(L,"error",ht);if(this._timeout!==!1){const _=this._timeout,y=this.setTimeoutFn(()=>{ut(),ht(new Error("timeout")),L.close()},_);this.opts.autoUnref&&y.unref(),this.subs.push(()=>{this.clearTimeoutFn(y)})}return this.subs.push(ut),this.subs.push(W),this}connect(O){return this.open(O)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const O=this.engine;this.subs.push(yr(O,"ping",this.onping.bind(this)),yr(O,"data",this.ondata.bind(this)),yr(O,"error",this.onerror.bind(this)),yr(O,"close",this.onclose.bind(this)),yr(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(O){try{this.decoder.add(O)}catch(L){this.onclose("parse error",L)}}ondecoded(O){is(()=>{this.emitReserved("packet",O)},this.setTimeoutFn)}onerror(O){this.emitReserved("error",O)}socket(O,L){let Y=this.nsps[O];return Y?this._autoConnect&&!Y.active&&Y.connect():(Y=new Dc(this,O,L),this.nsps[O]=Y),Y}_destroy(O){const L=Object.keys(this.nsps);for(const Y of L)if(this.nsps[Y].active)return;this._close()}_packet(O){const L=this.encoder.encode(O);for(let Y=0;Y<L.length;Y++)this.engine.write(L[Y],O.options)}cleanup(){this.subs.forEach(O=>O()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(O,L){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",O,L),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const O=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const L=this.backoff.duration();this._reconnecting=!0;const Y=this.setTimeoutFn(()=>{O.skipReconnect||(this.emitReserved("reconnect_attempt",O.backoff.attempts),!O.skipReconnect&&O.open(ut=>{ut?(O._reconnecting=!1,O.reconnect(),this.emitReserved("reconnect_error",ut)):O.onreconnect()}))},L);this.opts.autoUnref&&Y.unref(),this.subs.push(()=>{this.clearTimeoutFn(Y)})}}onreconnect(){const O=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",O)}}const Pn={};function Mo(K,O){typeof K=="object"&&(O=K,K=void 0),O=O||{};const L=td(K,O.path||"/socket.io"),Y=L.source,ut=L.id,ht=L.path,W=Pn[ut]&&ht in Pn[ut].nsps,_=O.forceNew||O["force new connection"]||O.multiplex===!1||W;let y;return _?y=new us(Y,O):(Pn[ut]||(Pn[ut]=new us(Y,O)),y=Pn[ut]),L.query&&!O.query&&(O.query=L.queryKey),y.socket(L.path,O)}Object.assign(Mo,{Manager:us,Socket:Dc,io:Mo,connect:Mo});var nn;(function(K){K[K.Normal=0]="Normal",K[K.Debug=1]="Debug"})(nn||(nn={}));let xo;const pd=new Uint8Array(16);function dd(){if(!xo&&(xo=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!xo))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return xo(pd)}const Li=[];for(let K=0;K<256;++K)Li.push((K+256).toString(16).slice(1));function md(K,O=0){return Li[K[O+0]]+Li[K[O+1]]+Li[K[O+2]]+Li[K[O+3]]+"-"+Li[K[O+4]]+Li[K[O+5]]+"-"+Li[K[O+6]]+Li[K[O+7]]+"-"+Li[K[O+8]]+Li[K[O+9]]+"-"+Li[K[O+10]]+Li[K[O+11]]+Li[K[O+12]]+Li[K[O+13]]+Li[K[O+14]]+Li[K[O+15]]}const Uc={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qc(K,O,L){if(Uc.randomUUID&&!O&&!K)return Uc.randomUUID();K=K||{};const Y=K.random||(K.rng||dd)();if(Y[6]=Y[6]&15|64,Y[8]=Y[8]&63|128,O){L=L||0;for(let ut=0;ut<16;++ut)O[L+ut]=Y[ut];return O}return md(Y)}const on=new Pi("[EventBus] ");class Fc{constructor(O=!1){Object.defineProperty(this,"eventListenerMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),O&&on.disable()}getEventListenerMap(){return Object.assign({},this.eventListenerMap)}on(O,L,Y=!1){this.eventListenerMap[O]||(this.eventListenerMap[O]=[]),Y?this.eventListenerMap[O].push({fn:L,once:!0}):this.eventListenerMap[O].push(L),on.log(`add event ${O} listener ${Y?", call once":""}`)}once(O,L){this.on(O,L,!0)}off(O,L){if(this.eventListenerMap[O]){const Y=this.eventListenerMap[O].findIndex(ut=>{if(typeof ut=="function"&&L===ut)return!0;if(ut=ut,ut.fn===L)return!0});Y<0?on.log(`event ${O} listener ${L.name} is not found`):(this.eventListenerMap[O].splice(Y,1),on.log(`remove event ${O} listener`))}else on.log(`event ${O} listeners is empty`)}emit(O,L){if(!this.eventListenerMap[O]){on.log(`event ${O} listeners is empty`);return}const Y=[];for(let ut=0;ut<this.eventListenerMap[O].length;ut++){const ht=this.eventListenerMap[O][ut];typeof ht=="function"?ht(L):Y.push(ht)}Y.forEach(ut=>{ut&&(ut.fn(L),this.off(O,ut.fn))}),on.log(`event ${O} is fired, has ${this.eventListenerMap[O].length} listeners`)}removeAllListeners(){this.eventListenerMap={}}}var _o;(function(K){K[K.enable=1]="enable",K[K.disable=2]="disable"})(_o||(_o={}));const zi=new Pi("[Session] ");var $i;(function(K){K.DataRequestFailed="data request error",K.SocketConnectionFailed="socket error",K.IdUndefined="session id is not defined",K.SendingEmptyContent="failed at sending empty content",K.Frozen="session is frozen",K.UserModeError="failed at setting socket user mode",K.Inactive="session is inactive"})($i||($i={})),$i.IdUndefined+"",$i.SendingEmptyContent+"",$i.Frozen+"";class cs{constructor(O,L="",Y,ut,ht,W){Object.defineProperty(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:O}),Object.defineProperty(this,"lazyload",{enumerable:!0,configurable:!0,writable:!0,value:ut}),Object.defineProperty(this,"_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_frozen",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"inactivating",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_ready",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:new Fc}),Object.defineProperty(this,"_applicationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_application",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"messages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_loadingMessages",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_loadingMessagesSize",{enumerable:!0,configurable:!0,writable:!0,value:10}),Object.defineProperty(this,"cvforceApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"socket",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_promptVariables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"activing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_stopAnswer",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dataLoading",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dataLoaded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.client=W||null,this._applicationId=oo(O).rid||Mi.configuration.applicationId,this.cvforceApi=this.getService(),ht&&(this._application=ht),this.event.emit("init",{applicationId:this._applicationId,sessionId:L}),this.loadApplicationInfo().then(()=>{var _;if(L)this._id=L,this.event.emit("data:loading"),Y?(this.data=Y,ut||(this._dataLoading=!0,this.cvforceApi.getSession(this.applicationId,L).then(y=>Le(this,void 0,void 0,function*(){this.data=y,this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,L)})).then(()=>Le(this,void 0,void 0,function*(){this.messages=[],yield this.fetchMessages(),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data)})))):(this._dataLoading=!0,this.cvforceApi.getSession(this.applicationId,L).then(y=>Le(this,void 0,void 0,function*(){this.data=y,this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,L)})).then(()=>Le(this,void 0,void 0,function*(){this.messages=[],yield this.fetchMessages(),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data),this._dataLoading=!1,this._dataLoaded=!0})));else{const y=(Y==null?void 0:Y.name)||"新建会话";this.event.emit("data:creating",{applicationId:this._applicationId,name:y}),this.event.emit("data:loading"),this.cvforceApi.postSession(this.applicationId,{name:y,netOpen:Y==null?void 0:Y.netOpen,knowledgeList:(_=Y==null?void 0:Y.knowledges)===null||_===void 0?void 0:_.map(x=>x.id),applicationId:this._applicationId}).then(x=>Le(this,void 0,void 0,function*(){this._id=x.id,this.data=x,this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,this._id),yield(()=>{if(Y!=null&&Y.knowledges)return this.setKnowledges((Y==null?void 0:Y.knowledges)||void 0)})(),yield(()=>{if(Y!=null&&Y.promptVariables){const v=this._promptVariables.map(m=>{var S,a;const p=((a=(S=Y.promptVariables)===null||S===void 0?void 0:S.find(c=>c.key===m.key))===null||a===void 0?void 0:a.value)||"";return Object.assign(Object.assign({},m),{value:p})}).sort((m,S)=>m.key.localeCompare(S.key));return this.setPromptVariables(v||[])}else return})(),this.event.emit("data:created",this.data),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data),this._ready=!0,this.event.emit("ready")}))}})}fetchData(){return Le(this,void 0,void 0,function*(){if(!this.data)throw Error("session data is not loaded");return yield this.cvforceApi.getSession(this.applicationId,this.data.id).then(O=>Le(this,void 0,void 0,function*(){return this.data=O,this.event.emit("data:updated",this.data),O}))})}get id(){var O;return this._id||((O=this.data)===null||O===void 0?void 0:O.id)||""}get applicationId(){return this._applicationId}get application(){return this._application}loadApplicationInfo(){if(this._application)return Promise.resolve(this._application);if(this._applicationId&&!this._application)return this.event.emit("application:data:loading"),this.cvforceApi.getApplicationId(this._applicationId).then(O=>(this._application=O,this.event.emit("application:data:loaded",O),O));throw Error("application id is not defined")}get ready(){return this._ready}get frozen(){return this._frozen}set frozen(O){O===!1&&this.inactivating&&this.socket&&(this.socket.disconnect(),this.socket=null,this.event.emit("inactivated")),this._frozen=O,this.event.emit("frozen",O)}get knowledges(){if(!this.data)throw Error("session data is not loaded");return this.data.knowledges||void 0}setKnowledges(O){return Le(this,void 0,void 0,function*(){var L;if(((L=this._application)===null||L===void 0?void 0:L.type)===bn.Agent){console.warn("Agent Application Sessions are disabled to setKnowledges.");return}if(!this.data)throw Error("session data is not loaded");return yield this.cvforceApi.patchSessionsId(this._applicationId,this.data.id,{knowledges:O}),this.data.knowledges=O,this.event.emit("data:updated",this.data),this.event.emit("data:updated:knowledges",{knowledges:O}),O})}validateConfigs(){if(!this._id)throw Error("session id is not defined");if(!this.data)throw Error("session data is not loaded");const O=this.promptVariables.filter(L=>L.status===pc.Quoted).filter(L=>!L.value);if(O.length)throw Error(`在提示词中被引用的变量值不能为空, 请检查以下变量: ${O.map(L=>L.key).join(", ")}`)}get promptVariables(){return this._promptVariables.filter(O=>O.key!=="query")}setPromptVariables(O){return Le(this,void 0,void 0,function*(){var L;if(((L=this._application)===null||L===void 0?void 0:L.type)===bn.Agent){console.warn("Agent Application Sessions are disabled to setPromptVariables.");return}const Y=this._promptVariables.map(ut=>{var ht;const W=((ht=O==null?void 0:O.find(_=>_.key===ut.key))===null||ht===void 0?void 0:ht.value)||ut.value;return Object.assign(Object.assign({},ut),{value:W})}).sort((ut,ht)=>ut.key.localeCompare(ht.key));if(yield Promise.all(Y.filter(ut=>ut.key!=="query").map(ut=>{if(!this.data)throw Error("session data is not loaded");if(!(!ut.id||!ut.key))return this.cvforceApi.patchApplicationIdSessionpromptVariablesId(this._applicationId,this.data.id,ut.id,{value:ut.value}).catch(console.error)})),!this.data)throw Error("session data is not loaded");return this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,this.data.id),this.event.emit("data:updated",this.data),this.event.emit("data:updated:promptVariables",{promptVariables:this._promptVariables}),this._promptVariables})}get netOpen(){if(!this.data)throw Error("session data is not loaded");return this.data.netOpen||!1}setNetOpen(O){return Le(this,void 0,void 0,function*(){var L,Y,ut;if(zi.log("setNetOpen:",O),zi.log("application arrange setting value: ",(L=this._application)===null||L===void 0?void 0:L.arrange[0].enableNetOpen),((Y=this._application)===null||Y===void 0?void 0:Y.type)===bn.Agent){console.warn("Agent Application Sessions are disabled to setNetOpen.");return}if(((ut=this._application)===null||ut===void 0?void 0:ut.arrange[0].enableNetOpen)===!1){console.warn("This Application is disabled to change netOpen.");return}if(!this.data)throw Error("session data is not loaded");return yield this.cvforceApi.patchSessionsId(this._applicationId,this.data.id,{netOpen:O?_o.enable:_o.disable}),this.data.netOpen=O,zi.log("data:updated",this.data),this.event.emit("data:updated",this.data),this.event.emit("data:updated:netOpen",{netOpen:O}),O})}getService(){return dc(Mi.configuration.apiRoot,this.token,(O,L)=>{const Y=new Error($i.DataRequestFailed);zi.error(Y),this.event.emit("error",Y)})}addEventListener(O,L,Y=!1){if(typeof L!="function")throw Error("event listener is not a function");if(Y){this.event.once(O,L);return}this.event.on(O,L)}removeEventListener(O,L){this.event.off(O,L)}fetchMessages(){return Le(this,arguments,void 0,function*(O={}){var L,Y;const ut={pageSize:this._loadingMessagesSize};if(this._id){O=Object.assign(Object.assign({},ut),O),this.event.emit("history:loading"),zi.log("history:loading"),(O.endTime||O.startTime)&&(this.event.emit("history:moreloading",O),zi.log("history:moreloading",O)),this._loadingMessages=!0;const ht=yield this.cvforceApi.getChatHistorySessionId(this._applicationId,this._id,O),W=ht.map((y,x)=>{var v,m;let S=[],a;return typeof((v=y.agentHistoryList)===null||v===void 0?void 0:v.agentList)=="string"&&(S=JSON.parse(y.agentHistoryList.agentList).reduce((c,l)=>(c[l.data.step-1]||(c[l.data.step-1]=[]),c[l.data.step-1].push(l),c),[])),x===ht.length-1&&(a=(m=this.data)===null||m===void 0?void 0:m.lastRelatedQuestion),Object.assign(Object.assign({},y),{actions:S,relatedQuesion:a})});if(!O.endTime&&!O.startTime){const y=this.messages[this.messages.length-1];y&&!y.relatedQuesion&&(y.relatedQuesion=(L=this.data)===null||L===void 0?void 0:L.lastRelatedQuestion),this.messages=[...W,...this.messages]}else if(O.endTime&&!O.startTime){const y=this.messages.findIndex(x=>x.ts===O.endTime);this.messages.splice(0,y+1),this.messages=[...W,...this.messages]}else if(!O.endTime&&O.startTime){const y=this.messages.findLastIndex(x=>x.ts===O.endTime);this.messages.splice(y,this.messages.length-y-1),this.messages=[...this.messages,...W]}else{const y=this.messages.findIndex(v=>v.ts===O.endTime),x=this.messages.findLastIndex(v=>v.ts===O.endTime);this.messages.splice(y,x-y+1,...W)}const _=this.messages[this.messages.length-1];return _&&!_.relatedQuesion&&(_.relatedQuesion=(Y=this.data)===null||Y===void 0?void 0:Y.lastRelatedQuestion),this.event.emit("history:moreloaded",W),zi.log("history:loaded",this.messages),this.event.emit("history:loaded",this.messages),this._loadingMessages=!1,W}else{const ht=new Error($i.IdUndefined);return zi.error(ht),this.event.emit("error",ht),!1}})}rename(O){return Le(this,void 0,void 0,function*(){if(!this._id)throw Error("session is not created yet");if(O.trim()==="")throw Error("name is empty");return this.data=yield this.cvforceApi.patchSessionsId(this.applicationId,this._id,{name:O}),zi.log("data:updated",this.messages),this.event.emit("data:updated",this.data),this.event.emit("data:updated:name",{name:O}),!0})}pushMessage(O){return Le(this,void 0,void 0,function*(){this.messages.push(O),zi.log("history:add",O),this.event.emit("history:add",O),this.event.emit("message:new",O),this.event.emit("message:updated",O)})}reloadSessionInfo(){if(!this._id)throw Error("session is not created yet");return this._dataLoading=!0,this.cvforceApi.getSession(this.applicationId,this._id).then(O=>Le(this,void 0,void 0,function*(){if(this.data=O,!this._id)throw Error("session is not created yet");return this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,this._id),zi.log("data:updated",this.data),this.event.emit("data:updated",this.data),this.data})).then(()=>Le(this,void 0,void 0,function*(){return this.messages=[],yield this.fetchMessages(),this._dataLoading=!1,this._dataLoaded=!0,this.event.emit("data:loaded",this.data),this}))}reload(){return Le(this,void 0,void 0,function*(){return yield this.reloadSessionInfo(),this.socket?(this.inactivate(!0),this.activate()):(this.inactivate(!0),this.activate())})}delete(){return Le(this,void 0,void 0,function*(){if(!this.id){const O=new Error($i.IdUndefined);return zi.error(O),this.event.emit("error",O),!1}return this.event.emit("data:deleting"),yield this.cvforceApi.delSessionsId(this.applicationId,this.id),this.event.emit("data:deleted"),this.destroy()})}activate(){return Le(this,void 0,void 0,function*(){if(this.activing)return new Promise(L=>{this.addEventListener("activated",()=>{L(!0)},!0)});if(!this._id)throw Error("session is not avalible. id is undefined");this.activing=!0;const O=this._id;return this._dataLoading=!0,this._dataLoaded=!1,this.data=yield this.cvforceApi.getSession(this.applicationId,O).then(L=>Le(this,void 0,void 0,function*(){return this._promptVariables=yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId,O),L})),this.messages.length||(this.messages=[],yield this.fetchMessages()),this.event.emit("data:loaded",this.data),this.event.emit("data:updated",this.data),this._dataLoaded=!0,this._dataLoading=!1,this.inactivating=!1,this.frozen=!0,yield this.prepareConnection(),this.event.emit("activated",this.socket),this.active=!0,this.activing=!1,this})}inactivate(O=!1){return this.socket?this._frozen?(O||(this.inactivating=!0),this.activing=!1,!0):(this.socket.close(),this.socket=null,this.event.emit("inactivated"),this.active=!1,this.activing=!1,!0):(this.activing=!1,!0)}get dataLoaded(){return this._dataLoaded}send(O){return Le(this,arguments,void 0,function*(L,Y={stream:!1}){var ut;try{this.validateConfigs()}catch(a){console.error(a)}const{stream:ht=!1,referenceFirst:W=!1}=Y,_=L.uuid||qc(),y=((ut=L.text)===null||ut===void 0?void 0:ut.trim())||"",x=L.fileIds;if(!y&&!(x!=null&&x.length)){const a=new Error($i.SendingEmptyContent);return zi.error(a),this.event.emit("error",a),!1}if(!this._id){const a=new Error($i.IdUndefined);return zi.error(a),this.event.emit("error",a),!1}if(this.frozen){const a=new Error($i.Frozen);return zi.error(a),this.event.emit("error",a),!1}this.frozen=!0,this._stopAnswer=!1;const v={sessionId:this.id,role:2,content:y,messageId:_,reference:[],searchReference:[],messageTime:""},m={content:y,stream:ht,requestId:_,fileIds:x,referenceFirst:W};this.pushMessage(v),this.event.emit("question:content",y);const S=a=>Le(this,void 0,void 0,function*(){if(a.role!==vr.Robot)return;switch(this.removeEventListener("answer:finish",S),this._id&&a.content&&a.index&&a.index<0&&(this.data=yield this.cvforceApi.patchSessionsId(this.applicationId,this._id,{finialMessage:a.content}),this.event.emit("data:updated",this.data),this.event.emit("data:updated:finialMessage",{finialMessage:a.content})),yield this.fillMessageReference(a),a.code){case 11915:a.content="请您换个问题问我吧~",a.index=-1,a.isSensitive=!0,a.isLoading=!1,a.sessionId=this._id||"",this.event.emit("message:error",a);break;case 200:a.index=-1,a.isLoading=!1;break;default:a.content=a.message||"未知错误",a.isLoading=!1,a.index=-1,this.event.emit("message:error",a)}const p=yield this.getRelatedQuesion(a);a=Object.assign(Object.assign({},a),p),a.isLoading=!1;let c=this.messages[this.messages.length-1];if(c&&c.role===vr.Robot){const l=Object.assign(Object.assign({},c),a);this.messages[this.messages.length-1]=l,this.event.emit("message:updated",l)}else this.pushMessage(a);this.frozen=!1});return this.addEventListener("answer:finish",S),this.sendQuestion(m,Object.assign(Object.assign({},Y),{stream:ht,referenceFirst:W})),v})}getRelatedQuesion(O){return Le(this,void 0,void 0,function*(){var L;if(!O.content||O.isSensitive||O.code!==200)return O;this.event.emit("message:relatedQuesion:loading",O);const Y=yield this.cvforceApi.postGeneques({content:O.content}).catch(W=>null);if(!Y){const W=[],_=Object.assign(Object.assign({},O),{relatedQuesion:W,index:-3,isLoading:!1});return this.event.emit("message:relatedQuesion:loaded",{relatedQuesion:W}),_}const ut=(L=Y.content)===null||L===void 0?void 0:L.split("*").map(uf).map(cf).filter(W=>!!W);O.relatedQuesion=ut,O.index=-3,O.isLoading=!1;const ht=Object.assign(Object.assign({},O),{relatedQuesion:ut,index:-3,isLoading:!1});return this.event.emit("message:relatedQuesion:loaded",ht),this._id&&this.cvforceApi.patchSessionsId(this._applicationId,this._id,{lastRelatedQuestion:ut}),ht})}fillMessageReference(O){return Le(this,void 0,void 0,function*(){var L;return(L=O.reference)===null||L===void 0||L.forEach((Y,ut)=>Le(this,void 0,void 0,function*(){const ht=yield this.cvforceApi.getKnowledgeIdFileId(Y.knowledgeId,Y.docId);O.reference[ut]=Object.assign(Object.assign({},Y),ht)})),O})}answerAgain(){return Le(this,arguments,void 0,function*(O={stream:!1}){const L=this.messages[this.messages.length-1];if(!L)throw Error("message list is empty");this.frozen=!0,this._stopAnswer=!1;const{stream:Y=!1}=O;let ut;L.role!==vr.User&&(ut=O.oldMessageId||L.messageId,this.messages.splice(this.messages.length-1,1),this.event.emit("message:remove",L),this.event.emit("history:remove",L));const ht=this.messages[this.messages.length-1],W={content:ht.content,fileIds:ht.fileIds,requestId:ht.messageId,stream:Y,oldMessageId:ut},_=y=>Le(this,void 0,void 0,function*(){if(y.role===vr.Robot&&y.index===-1){switch(this._id&&y.content&&y.index&&y.index<0&&(this.data=yield this.cvforceApi.patchSessionsId(this.applicationId,this._id,{finialMessage:y.content}),this.event.emit("data:updated",this.data),this.event.emit("data:updated:finialMessage",{finialMessage:y.content})),yield this.fillMessageReference(y),y.code){case 11915:y.content="请您换个问题问我吧~",y.index=-1,y.isSensitive=!0,y.isLoading=!1,y.sessionId=this._id||"",this.event.emit("message:error",y);break;case 200:y.index=-1,y.isLoading=!1;break;default:y.content=y.message||"未知错误",y.isLoading=!1,y.index=-1,this.event.emit("message:error",y)}const x=yield this.getRelatedQuesion(y);this.event.emit("message:updated",x),this.removeEventListener("message:content",_),this.frozen=!1}});this.addEventListener("message:content",_),this.sendQuestion(W,Object.assign(Object.assign({},O),{stream:Y}))})}setTop(O){return Le(this,void 0,void 0,function*(){if(!this._id)throw Error("session is not avalible. id is undefined");this.data=yield this.cvforceApi.patchSessionsId(this._applicationId,this._id,{top:O}),this.event.emit("data:updated",this.data),this.event.emit("data:updated:top",{top:O})})}suspend(){var O;this.stopAnswer(),this.frozen=!1,this._stopAnswer=!0;let L=this.messages[this.messages.length-1];const Y={messageId:qc(),isLoading:!1,index:-2,messageTime:hc(new Date).format("YYYY-MM-DD HH:ss:mm"),content:"",role:vr.System,sessionId:this.id||"",reference:[],searchReference:[]};if(L&&!L.messageId){if(L.index===-2)return;if(L.actions){const ut=L.actions[((O=L.actions)===null||O===void 0?void 0:O.length)-1];if(ut){const ht=ut[ut.length-1];if(ht&&(ht.type==="BEFORE_CALL"||ht.type==="FUNCTION_CALL")){const{pluginName:W,pluginCode:_,funcCode:y,funcName:x}=ht.data;ut.push({data:{pluginName:W,pluginCode:_,funcCode:y,funcName:x,step:ht.data.step+1},type:"ABORT"}),this.event.emit("message:action",{messageId:L.messageId,action:ut})}}}L=Object.assign(Object.assign({},L),Y),this.event.emit("message:content",L),this.event.emit("message:updated",L)}else this.pushMessage(Y),this.event.emit("message:content",Y);return this}postMessageComment(O){return Le(this,void 0,void 0,function*(){if(!this._applicationId||!this._id)throw Error("session is not avalible. id is undefined");return this.cvforceApi.postComments(this._applicationId,this._id,O).then(L=>{const Y=this.messages.find(ut=>ut.messageId===O.messageId);return Y&&(Y.comment=O,this.event.emit("message:comment",Y)),L})})}clear(){if(!this._id)throw Error("session is not avalible. id is undefined");return this.cvforceApi.patchApplicationIdSessionsIdContext(this._applicationId,this._id).then(()=>(this.event.emit("context:clear"),!0))}destroy(){var O;return this._ready=!1,this.event.removeAllListeners(),(O=this.socket)===null||O===void 0||O.disconnect(),this.socket=null,this.event.emit("destroy",{applicationId:this._applicationId,sessionId:this._id}),this._id||""}}const $r=new Pi("[AgentSession] ");class gd extends cs{constructor(O,L="",Y,ut,ht,W){super(O,L,Y,ut,ht,W)}prepareConnection(){return new Promise(O=>Le(this,void 0,void 0,function*(){this.socket&&O(!0);const L={version:"1.0",stream:"false",appId:this._applicationId,sessionId:this.id,Authorization:`${this.token}`,userMode:Mi.configuration.debug?nn.Debug:nn.Normal},Y=new URL(Mi.configuration.apiRoot),ut=yield Mo(Y.origin,{path:Y.pathname.replace("api","socketio")+"/copilot",query:L,transports:["websocket"]});ut.on("connect",()=>{$r.log("socket:connect"),this.event.emit("socket:connect"),ut.emit("init")}),ut.on("disconnect",()=>{$r.log("socket:disconnect"),this.event.emit("socket:disconnect")}),ut.on("ready",ht=>{if(ht.code===200){$r.log("ready");const W=Mi.configuration.debug?nn.Debug:nn.Normal;W===nn.Debug&&ht.userMode,this._ready||(this._ready=!0,this.event.emit("ready")),this.frozen=!1,O(!0)}else{this._ready&&(this._ready=!1);const W=new Error($i.SocketConnectionFailed);$r.error("error",W),this.event.emit("error",W),O(!1)}}),ut.on("action",(ht,W)=>Le(this,void 0,void 0,function*(){if(this._stopAnswer||!this.id)return;const{type:_,data:{runnerIsClient:y,pluginCode:x,funcCode:v,parameters:m,requestBody:S}}=ht,a=this.messages[this.messages.length-1];if(!a.messageId)a.actions||(a.actions=[]),a.actions[ht.data.step-1]||(a.actions[ht.data.step-1]=[]),a.actions[ht.data.step-1].push(ht),this.event.emit("message:action",{messageId:a.messageId,action:ht}),this.event.emit("message:updated",a);else{const p={messageId:"",content:"",role:vr.Robot,sessionId:this.id,reference:[],searchReference:[],isLoading:!0,messageTime:"",actions:[[ht]],comment:{isAgree:0}};this.pushMessage(p),this.event.emit("message:action",{messageId:p.messageId,action:ht})}if(this.inactivating){const p=new Error($i.Inactive);$r.warn("error",p),this.event.emit("error",p)}else if(_==="FUNCTION_CALL"&&y){if($r.log(`calling function ${v} of plugin ${x} with argument:
138
138
  ${JSON.stringify(m)}`),!Mi.configuration.plugins[x]){W({code:404,message:"对不起,没有找到插件。"});return}const p=Mi.configuration.plugins[x][v];typeof p!="function"&&W({code:404,message:"对不起,没有找到插件方法。"});let c=m==null?void 0:m.query;try{c=JSON.parse(m==null?void 0:m.query)}catch{}p(c,(...l)=>{this._stopAnswer||W(...l)})}})),ut.on("answer",ht=>{if(!this._stopAnswer)if(ht.data.code!==200&&(ht.data.index=-1,this.event.emit("error",ht.data)),ht.data.index===-1){let W=this.messages[this.messages.length-1];if(W&&!W.messageId)W=Object.assign(Object.assign({},W),ht.data),this.event.emit("message:content",W),this.event.emit("message:updated",W),this.event.emit("answer:finish",W);else{const _=Object.assign({messageId:"",content:"",role:vr.Robot,sessionId:this.id,reference:[],searchReference:[],isLoading:!1,messageTime:"",actions:[],comment:{isAgree:0}},ht.data);this.event.emit("message:content",_),this.pushMessage(_),this.event.emit("answer:finish",_)}}else{let W=this.messages[this.messages.length-1];W&&!W.messageId?(W=Object.assign(Object.assign({},W),ht.data),this.messages[this.messages.length-1]=W,this.event.emit("message:content",W),this.event.emit("message:updated",W)):(this.pushMessage(ht.data),this.event.emit("message:content",ht.data))}}),ut.on("reference",ht=>Le(this,void 0,void 0,function*(){if(this._stopAnswer)return;if(!this.id){const m=new Error($i.IdUndefined);$r.error(m),this.event.emit("error",m),this.frozen=!1;return}const{type:W,data:_,requestId:y}=ht,x=this.messages.findIndex(m=>m.messageId===y&&m.role===vr.User);if(x<0)return;const v=x+1;if(v>=this.messages.length){const m={messageId:"",content:"",role:vr.Robot,sessionId:this.id,reference:[],searchReference:[],isLoading:!0,messageTime:"",actions:[],comment:{isAgree:0}};this.pushMessage(m)}W==="KG"?(this.messages[v]=Object.assign(Object.assign({},this.messages[v]),{reference:_.knowledgeReference}),yield this.fillMessageReference(this.messages[v]),this.event.emit("message:reference",_.knowledgeReference),this.event.emit("message:updated",this.messages[v])):W==="WEB_SEARCH"&&(this.messages[v]=Object.assign(Object.assign({},this.messages[v]),{searchReference:_.knowledgeReference}),this.event.emit("message:searchreference",_.searchReference),this.event.emit("message:updated",this.messages[v]))})),this.socket=ut,ut.open()}))}sendQuestion(O,L){return Le(this,void 0,void 0,function*(){var Y,ut;if(!this.active){if(yield this.activate(),!this.socket){const ht=new Error($i.SocketConnectionFailed);return $r.warn("error",ht),this.event.emit("error",ht),!1}(Y=this.socket)===null||Y===void 0||Y.emit("question",O);return}(ut=this.socket)===null||ut===void 0||ut.emit("question",O)})}stopAnswer(){var O;(O=this.socket)===null||O===void 0||O.emit("stop_answer")}}function vd(K,O){return Le(this,void 0,void 0,function*(){const L=K.getReader();let Y;for(;!(Y=yield L.read()).done;)O(Y.value)})}var br;(function(K){K[K.NewLine=10]="NewLine",K[K.CarriageReturn=13]="CarriageReturn",K[K.Space=32]="Space",K[K.Colon=58]="Colon"})(br||(br={}));function yd(K){let O,L,Y,ut=!1,ht;return function(_){O===void 0?(O=_,L=0,Y=-1,ht=!1):O=wd(O,_);const y=O.length;let x=0;for(;L<y;){ut&&(O[L]===br.NewLine&&(x=++L),ut=!1);let v=-1;for(;L<y&&v===-1;++L)switch(O[L]){case br.Colon:Y===-1&&(Y=L-x);break;case br.CarriageReturn:ut=!1,L+4<y&&O[L+1]===br.NewLine&&O[L+2]!==br.CarriageReturn&&O[L-1]!==br.NewLine&&O[L-2]!==br.CarriageReturn&&(ht=!0);case br.NewLine:v=L;break}if(v===-1)break;K(O.subarray(x,v),Y,ht),x=L,Y=-1,ht=!1}x===y?O=void 0:x!==0&&(O=O.subarray(x),L-=x)}}function bd(K,O,L){let Y=zc();const ut=new TextDecoder;return function(W,_,y){if(W.length===0)L==null||L(Y),Y=zc();else if(_>0){const x=ut.decode(W.subarray(0,_)),v=_+(W[_+1]===br.Space?2:1);let m=ut.decode(W.subarray(v));switch(y&&(m+=`
139
139
  `),x){case"data":Y.data=Y.data?Y.data+`
140
- `+m:m;break;case"event":Y.event=m;break;case"id":K(Y.id=m);break;case"retry":const S=parseInt(m,10);isNaN(S)||O(Y.retry=S);break}}}}function wd(K,O){const L=new Uint8Array(K.length+O.length);return L.set(K),L.set(O,K.length),L}function zc(){return{data:"",event:"",id:"",retry:void 0}}const ls="text/event-stream",Md=1e3,$c="last-event-id";function Hc(K,O){var{signal:L,headers:Y,onopen:ut,onmessage:ht,onclose:W,onerror:_,openWhenHidden:y,fetch:x}=O,v=Kh(O,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((m,S)=>{const a=Object.assign({},Y);a.accept||(a.accept=ls);let p;function c(){p.abort(),document.hidden||w()}y||document.addEventListener("visibilitychange",c);let l=Md,f=0;function g(){document.removeEventListener("visibilitychange",c),window.clearTimeout(f),p.abort()}L==null||L.addEventListener("abort",()=>{g(),m()});const h=x??window.fetch,u=ut??xd;function w(){return Le(this,void 0,void 0,function*(){var b;p=new AbortController;try{const E=yield h(K,Object.assign(Object.assign({},v),{headers:a,signal:p.signal}));yield u(E),yield vd(E.body,yd(bd(I=>{I?a[$c]=I:delete a[$c]},I=>{l=I},ht))),W==null||W(),g(),m()}catch(E){if(!p.signal.aborted)try{const I=(b=_==null?void 0:_(E))!==null&&b!==void 0?b:l;window.clearTimeout(f),f=window.setTimeout(w,I)}catch(I){g(),S(I)}}})}w()})}function xd(K){const O=K.headers.get("content-type");if(!(O!=null&&O.startsWith(ls)))throw new Error(`Expected content-type to be ${ls}, Actual: ${O}`)}const Wc=new Pi("[DialogSession] ",!0);class _d extends cs{constructor(O,L="",Y,ut,ht,W){super(O,L,Y,ut,ht,W),Object.defineProperty(this,"ctrl",{enumerable:!0,configurable:!0,writable:!0,value:new AbortController})}prepareConnection(){return new Promise(O=>Le(this,void 0,void 0,function*(){this._ready=!0,this.event.emit("ready"),this.frozen=!1,O(!0)}))}postChatV2EventSource(O,L,Y,ut,ht,W){return Le(this,void 0,void 0,function*(){const _={code:0,content:"",role:Wa.Robot,sessionId:L,reference:[],searchReference:[],messageTime:"",llmModel:"",comment:{isAgree:0},isReplying:!1},y=Object.assign(Object.assign({},Y),{stream:!0});Hc(`${Mi.configuration.apiRoot}/chat/v2/chat?applicationId=${O}&sessionId=${L}`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify(y),openWhenHidden:!0,signal:ut,onopen(x){return x.ok&&ht!=null&&ht.onopen&&ht.onopen(),Promise.resolve()},onmessage(x){if(!x.data.includes('{"code": ')){let m={};try{m=JSON.parse(x.data)}catch{}(m==null?void 0:m.mtype)==="search"?_.searchReference.push(m):_.content=_.content+x.data;const S={content:_.content,role:1,reference:_.reference,searchReference:_.searchReference,messageId:_.messageId,sessionId:L,messageTime:hc(new Date).format("YYYY-MM-DD HH:mm:ss"),comment:{isAgree:0},isReplying:!0};return(ht==null?void 0:ht.onmessage)&&ht.onmessage(S)}const v=JSON.parse(x.data);if(_.reference=v.data.reference,_.searchReference=v.data.searchReference,_.messageTime=v.data.messageTime,_.messageId=v.data.messageId,_.llmModel=v.data.llmModel,_.content=v.data.content,_.code=v.code,v.code===200){const m={code:_.code,content:_.content,role:1,reference:_.reference,searchReference:_.searchReference,messageId:_.messageId,sessionId:L,messageTime:_.messageTime,isReplying:!0};ht!=null&&ht.onmessage&&ht.onmessage(m)}else return ht!=null&&ht.onclose&&ht.onclose(_),W&&W({code:_.code,message:_.message})},onerror(){ht!=null&&ht.onerror&&ht.onerror()},onclose(){const x={code:_.code,content:_.content,role:1,reference:_.reference,searchReference:_.searchReference,messageId:_.messageId,sessionId:L,messageTime:_.messageTime,comment:{isAgree:0},isReplying:!1,index:-1};ht!=null&&ht.onclose&&ht.onclose(x)}})})}postChatV3EventSource(O,L,Y,ut,ht,W){return Le(this,void 0,void 0,function*(){const _={code:0,content:"",role:Wa.Robot,sessionId:L,reference:[],searchReference:[],messageTime:"",llmModel:"",comment:{isAgree:0},isReplying:!1,reasoningContent:"",thinkingSecs:"",thinkingStatus:""},y=Object.assign(Object.assign({},Y),{stream:!0});Hc(`${Mi.configuration.apiRoot}/chat/v3/chat?applicationId=${O}&sessionId=${L}`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify(y),openWhenHidden:!0,signal:ut,onopen(x){return x.ok&&ht!=null&&ht.onopen&&ht.onopen(),Promise.resolve()},onmessage(x){if(!x.data&&!x.event&&!x.id&&!x.retry)return;let v={};try{v=JSON.parse(x.data)}catch{console.error("parse eventData to JSON failed. ",x.data)}if(v.code!==200)return _.index=-1,_.code=v.code,_.message=v.message,ht!=null&&ht.onmessage&&ht.onmessage(_),W&&W({code:v.code,message:v.message});const m=v.data.type,S=v.data.payload;if(_.isReplying=!0,m==="search"&&_.searchReference.push(S),m==="thinking"){_.thinkingStatus="start";const p=S.choices[0];_.reasoningContent=_.reasoningContent+p.delta.reasoningContent}if(m==="thinkingOver"){_.thinkingStatus="end";const a=S.thinkingSecs;_.thinkingSecs=a}if(m==="text"){const p=S.choices[0];_.content=_.content+p.delta.content}if(m==="reference"&&(_.reference=S),m==="result"){const a=S.messageId,p=S.llmModel,c=S.messageTime;_.messageId=a,_.llmModel=p,_.messageTime=c,_.sessionId=L}m==="over"?_.index=-1:(_.code=v.code,_.message=v.message),ht!=null&&ht.onmessage&&ht.onmessage(_)},onerror(){ht!=null&&ht.onerror&&ht.onerror()},onclose(){const x=Object.assign(Object.assign({},_),{isReplying:!1});ht!=null&&ht.onclose&&ht.onclose(x)}})})}sendQuestion(O,L){return Le(this,void 0,void 0,function*(){var Y;const{content:ut,fileIds:ht,oldMessageId:W}=O,{stream:_,referenceFirst:y}=L;if(this.active||(yield this.activate()),this._id){let x={content:ut,fileIds:ht,referenceFirst:y,oldMessageId:W,promptVariables:this.promptVariables.reduce((v,m)=>Object.assign(Object.assign({},v),{[m.key]:m.value}),{}),knowledges:(Y=this.knowledges)===null||Y===void 0?void 0:Y.map(v=>v.id)};this.ctrl=new AbortController,this.postChatV3EventSource(this._applicationId,this._id,x,this.ctrl.signal,{onopen:()=>{Wc.log("open",this.ctrl)},onmessage:v=>{if(this._stopAnswer)return;let m=this.messages[this.messages.length-1];m&&m.role===vr.Robot?(m=Object.assign(Object.assign({},m),v),this.messages[this.messages.length-1]=m,this.event.emit("message:content",m),this.event.emit("message:updated",m)):(this.pushMessage(v),this.event.emit("message:content",v))},onclose:v=>Le(this,void 0,void 0,function*(){this._stopAnswer||(Wc.log(v,"onclose"),this.event.emit("answer:finish",v))}),onerror:()=>{this._stopAnswer||(this.event.emit("message:error",""),this.frozen=!1)}})}})}stopAnswer(){this.ctrl.abort()}}const Sd=new Pi("[BotClient] ");class Ed{constructor(O,L,Y=!0){if(Object.defineProperty(this,"_token",{enumerable:!0,configurable:!0,writable:!0,value:O}),Object.defineProperty(this,"lazyload",{enumerable:!0,configurable:!0,writable:!0,value:Y}),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:new Fc}),Object.defineProperty(this,"cvforceApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_applicationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_application",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_sessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_activeSession",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ready",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_questionContextMaxLength",{enumerable:!0,configurable:!0,writable:!0,value:4e3}),Object.defineProperty(this,"_promptVariables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),yu(L),this._applicationId=oo(O).rid||Mi.configuration.applicationId,!this._applicationId)throw"token is not vaild";this.cvforceApi=this.getService(),this.loadApplication().then(()=>{this.event.emit("ready")})}checkReady(){if(!this.ready)throw Error("client is not ready.")}get ready(){return this._ready}set ready(O){this._ready=O}get questionContextMaxLength(){return this.checkReady(),this._questionContextMaxLength}get promptVariables(){return this.checkReady(),this._promptVariables}get knowledges(){var O;return this.checkReady(),(O=this._application)===null||O===void 0?void 0:O.arrange[0].knowledges}get sessions(){return this.checkReady(),this._sessions}set sessions(O){this.checkReady(),this._sessions=O,this.event.emit("sessions:updated",O)}loadApplication(){return Le(this,void 0,void 0,function*(){var O,L;this._application=yield this.cvforceApi.getApplicationId(this._applicationId);const Y=(L=(O=this._application.arrange)===null||O===void 0?void 0:O[0])===null||L===void 0?void 0:L.llmModel;return Y&&(this._questionContextMaxLength=yield this.cvforceApi.getBaseModel(Y).then(ut=>ut.maxModelLength)),this._promptVariables=yield this.cvforceApi.getPrompts(this._applicationId),this._ready=!0,this.event.emit("application:loaded"),this._application})}getService(){return this.cvforceApi?this.cvforceApi:dc(Mi.configuration.apiRoot,this.token,(O,L)=>Sd.error(L))}get token(){return this._token}set token(O){this.checkReady(),this._token=O,this.ready=!1;const L=oo(O).rid;this._applicationId!==L&&(this._applicationId=L,this._application=null,this.loadApplication().then(()=>{this.event.emit("ready")}),this.clean())}get applicationId(){return this._applicationId}get application(){return this.checkReady(),this._application}get activeSession(){var O;return this.checkReady(),((O=this._activeSession)===null||O===void 0?void 0:O.id)||""}set activeSession(O){this.checkReady(),this.loadSession(O).then(L=>{this._activeSession&&this._activeSession.id!==O&&this._activeSession.inactivate(),this._activeSession=L})}createSession(O,L,Y,ut,ht){return Le(this,void 0,void 0,function*(){const W=this;return new Promise((_,y)=>{const x=v=>Le(this,void 0,void 0,function*(){if(v===bn.Agent)_(new gd(O,L,Y,ut,ht,W));else if(v===bn.Dialog)_(new _d(O,L,Y,ut,ht,W));else throw Error(`不支持的应用类型:${v}`)});if(this.ready){if(!this._application)throw Error("client is not ready");x(this._application.type)}else this.event.on("ready",()=>{if(!this._application)throw Error("_application is null");x(this._application.type)},!0)})})}getSessions(O){return Le(this,void 0,void 0,function*(){return new Promise((L,Y)=>{const ut=()=>this.cvforceApi.listSessions(this._applicationId,O).then(ht=>{const W=[];return ht.forEach(_=>Le(this,void 0,void 0,function*(){const y=this._sessions.find(x=>_.id===x.id);if(y)y.data=_,W.push(y);else{const x=yield this.createSession(this.token,_.id,_,this.lazyload,this._application||void 0);W.push(x)}})),this.sessions=W,W});if(this.ready){if(!this._application)throw Error("_application is null");L(ut())}else this.event.on("ready",()=>{if(!this._application)throw Error("_application is null");L(ut())},!0)})})}loadSession(){return Le(this,arguments,void 0,function*(O="",L){this.checkReady();let Y=this.sessions.find(ut=>ut.id===O);if(Y||(Y=yield this.createSession(this.token,O,L),this._sessions.push(Y)),this._activeSession){if(this._activeSession===Y)return Y;this._activeSession.inactivate()}return Y.id?(yield Y.activate(),this._activeSession=Y):Y.addEventListener("data:loaded",()=>{this._activeSession!==Y&&(Y==null||Y.activate(),this._activeSession=Y)},!0),Y})}reload(){return this.loadApplication().then(()=>Le(this,void 0,void 0,function*(){return yield this.getSessions(),this.event.emit("ready"),this}))}reloadSession(O){return Le(this,void 0,void 0,function*(){yield this.reload();let L=this._sessions.find(Y=>Y.id===O)||this._activeSession;if(!L){console.warn("reloadSession session failed.");return}return yield L.reload(),L})}setTop(O,L){return Le(this,arguments,void 0,function*(Y,ut,ht="top_time desc, sort_status desc, updated_at desc"){let W=Y?this._sessions.find(_=>_.id===Y):this._activeSession;if(!W){console.warn("setTop session failed.");return}return yield W.setTop(ut),this.getSessions({order:ht})})}addEventListener(O,L,Y=!1){if(typeof L!="function")throw Error("event listener is not a function");if(Y){this.event.once(O,L);return}this.event.on(O,L)}removeEventListener(O,L){this.event.off(O,L)}removeSession(O,L){return Le(this,void 0,void 0,function*(){this.checkReady();let Y=-1;if(typeof O=="string"?Y=this._sessions.findIndex(ut=>ut.id===O):Y=this._sessions.findIndex(ut=>ut.id===O.id),Y>-1){const ut=this._sessions[Y];L&&(yield ut.delete()),this._sessions.splice(Y,1)}else console.warn("session delete failed, session is not exist.")})}clean(){this._sessions.forEach(O=>O.destroy()),this.sessions=[]}}class kd{constructor(O,L={},Y){Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"loaded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"functions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),this.code=O,L&&(this.functions=L)}fetchData(){this.description="描述",this.loaded=!0}checkFunctions(){}}Mi.AgentPlugin=kd,Mi.BotClient=Ed,Mi.Session=cs,Mi.configure=yu,Object.defineProperty(Mi,Symbol.toStringTag,{value:"Module"})});
140
+ `+m:m;break;case"event":Y.event=m;break;case"id":K(Y.id=m);break;case"retry":const S=parseInt(m,10);isNaN(S)||O(Y.retry=S);break}}}}function wd(K,O){const L=new Uint8Array(K.length+O.length);return L.set(K),L.set(O,K.length),L}function zc(){return{data:"",event:"",id:"",retry:void 0}}const ls="text/event-stream",Md=1e3,$c="last-event-id";function Hc(K,O){var{signal:L,headers:Y,onopen:ut,onmessage:ht,onclose:W,onerror:_,openWhenHidden:y,fetch:x}=O,v=Kh(O,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((m,S)=>{const a=Object.assign({},Y);a.accept||(a.accept=ls);let p;function c(){p.abort(),document.hidden||w()}y||document.addEventListener("visibilitychange",c);let l=Md,f=0;function g(){document.removeEventListener("visibilitychange",c),window.clearTimeout(f),p.abort()}L==null||L.addEventListener("abort",()=>{g(),m()});const h=x??window.fetch,u=ut??xd;function w(){return Le(this,void 0,void 0,function*(){var b;p=new AbortController;try{const E=yield h(K,Object.assign(Object.assign({},v),{headers:a,signal:p.signal}));yield u(E),yield vd(E.body,yd(bd(I=>{I?a[$c]=I:delete a[$c]},I=>{l=I},ht))),W==null||W(),g(),m()}catch(E){if(!p.signal.aborted)try{const I=(b=_==null?void 0:_(E))!==null&&b!==void 0?b:l;window.clearTimeout(f),f=window.setTimeout(w,I)}catch(I){g(),S(I)}}})}w()})}function xd(K){const O=K.headers.get("content-type");if(!(O!=null&&O.startsWith(ls)))throw new Error(`Expected content-type to be ${ls}, Actual: ${O}`)}const Wc=new Pi("[DialogSession] ");class _d extends cs{constructor(O,L="",Y,ut,ht,W){super(O,L,Y,ut,ht,W),Object.defineProperty(this,"ctrl",{enumerable:!0,configurable:!0,writable:!0,value:new AbortController})}prepareConnection(){return new Promise(O=>Le(this,void 0,void 0,function*(){this._ready=!0,this.event.emit("ready"),this.frozen=!1,O(!0)}))}postChatV2EventSource(O,L,Y,ut,ht,W){return Le(this,void 0,void 0,function*(){const _={code:0,content:"",role:Wa.Robot,sessionId:L,reference:[],searchReference:[],messageTime:"",llmModel:"",comment:{isAgree:0},isReplying:!1},y=Object.assign(Object.assign({},Y),{stream:!0});Hc(`${Mi.configuration.apiRoot}/chat/v2/chat?applicationId=${O}&sessionId=${L}`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify(y),openWhenHidden:!0,signal:ut,onopen(x){return x.ok&&ht!=null&&ht.onopen&&ht.onopen(),Promise.resolve()},onmessage(x){if(!x.data.includes('{"code": ')){let m={};try{m=JSON.parse(x.data)}catch{}(m==null?void 0:m.mtype)==="search"?_.searchReference.push(m):_.content=_.content+x.data;const S={content:_.content,role:1,reference:_.reference,searchReference:_.searchReference,messageId:_.messageId,sessionId:L,messageTime:hc(new Date).format("YYYY-MM-DD HH:mm:ss"),comment:{isAgree:0},isReplying:!0};return(ht==null?void 0:ht.onmessage)&&ht.onmessage(S)}const v=JSON.parse(x.data);if(_.reference=v.data.reference,_.searchReference=v.data.searchReference,_.messageTime=v.data.messageTime,_.messageId=v.data.messageId,_.llmModel=v.data.llmModel,_.content=v.data.content,_.code=v.code,v.code===200){const m={code:_.code,content:_.content,role:1,reference:_.reference,searchReference:_.searchReference,messageId:_.messageId,sessionId:L,messageTime:_.messageTime,isReplying:!0};ht!=null&&ht.onmessage&&ht.onmessage(m)}else return ht!=null&&ht.onclose&&ht.onclose(_),W&&W({code:_.code,message:_.message})},onerror(){ht!=null&&ht.onerror&&ht.onerror()},onclose(){const x={code:_.code,content:_.content,role:1,reference:_.reference,searchReference:_.searchReference,messageId:_.messageId,sessionId:L,messageTime:_.messageTime,comment:{isAgree:0},isReplying:!1,index:-1};ht!=null&&ht.onclose&&ht.onclose(x)}})})}postChatV3EventSource(O,L,Y,ut,ht,W){return Le(this,void 0,void 0,function*(){const _={code:0,content:"",role:Wa.Robot,sessionId:L,reference:[],searchReference:[],messageTime:"",llmModel:"",comment:{isAgree:0},isReplying:!1,reasoningContent:"",thinkingSecs:"",thinkingStatus:""},y=Object.assign(Object.assign({},Y),{stream:!0});Hc(`${Mi.configuration.apiRoot}/chat/v3/chat?applicationId=${O}&sessionId=${L}`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify(y),openWhenHidden:!0,signal:ut,onopen(x){return x.ok&&ht!=null&&ht.onopen&&ht.onopen(),Promise.resolve()},onmessage(x){if(!x.data&&!x.event&&!x.id&&!x.retry)return;let v={};try{v=JSON.parse(x.data)}catch{console.error("parse eventData to JSON failed. ",x.data)}if(v.code!==200)return _.index=-1,_.code=v.code,_.message=v.message,ht!=null&&ht.onmessage&&ht.onmessage(_),W&&W({code:v.code,message:v.message});const m=v.data.type,S=v.data.payload;if(_.isReplying=!0,m==="search"&&_.searchReference.push(S),m==="thinking"){_.thinkingStatus="start";const p=S.choices[0];_.reasoningContent=_.reasoningContent+p.delta.reasoningContent}if(m==="thinkingOver"){_.thinkingStatus="end";const a=S.thinkingSecs;_.thinkingSecs=a}if(m==="text"){const p=S.choices[0];_.content=_.content+p.delta.content}if(m==="reference"&&(_.reference=S),m==="result"){const a=S.messageId,p=S.llmModel,c=S.messageTime;_.messageId=a,_.llmModel=p,_.messageTime=c,_.sessionId=L}m==="over"?_.index=-1:(_.code=v.code,_.message=v.message),ht!=null&&ht.onmessage&&ht.onmessage(_)},onerror(){ht!=null&&ht.onerror&&ht.onerror()},onclose(){const x=Object.assign(Object.assign({},_),{isReplying:!1});ht!=null&&ht.onclose&&ht.onclose(x)}})})}sendQuestion(O,L){return Le(this,void 0,void 0,function*(){var Y;const{content:ut,fileIds:ht,oldMessageId:W}=O,{stream:_,referenceFirst:y}=L;if(this.active||(yield this.activate()),this._id){let x={content:ut,fileIds:ht,referenceFirst:y,oldMessageId:W,promptVariables:this.promptVariables.reduce((v,m)=>Object.assign(Object.assign({},v),{[m.key]:m.value}),{}),knowledges:(Y=this.knowledges)===null||Y===void 0?void 0:Y.map(v=>v.id)};this.ctrl=new AbortController,this.postChatV3EventSource(this._applicationId,this._id,x,this.ctrl.signal,{onopen:()=>{Wc.log("open",this.ctrl)},onmessage:v=>{if(this._stopAnswer)return;let m=this.messages[this.messages.length-1];m&&m.role===vr.Robot?(m=Object.assign(Object.assign({},m),v),this.messages[this.messages.length-1]=m,this.event.emit("message:content",m),this.event.emit("message:updated",m)):(this.pushMessage(v),this.event.emit("message:content",v))},onclose:v=>Le(this,void 0,void 0,function*(){this._stopAnswer||(Wc.log(v,"onclose"),this.event.emit("answer:finish",v))}),onerror:()=>{this._stopAnswer||(this.event.emit("message:error",""),this.frozen=!1)}})}})}stopAnswer(){this.ctrl.abort()}}const Sd=new Pi("[BotClient] ");class Ed{constructor(O,L,Y=!0){if(Object.defineProperty(this,"_token",{enumerable:!0,configurable:!0,writable:!0,value:O}),Object.defineProperty(this,"lazyload",{enumerable:!0,configurable:!0,writable:!0,value:Y}),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:new Fc}),Object.defineProperty(this,"cvforceApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_applicationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_application",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_sessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_activeSession",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ready",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_questionContextMaxLength",{enumerable:!0,configurable:!0,writable:!0,value:4e3}),Object.defineProperty(this,"_promptVariables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),yu(L),this._applicationId=oo(O).rid||Mi.configuration.applicationId,!this._applicationId)throw"token is not vaild";this.cvforceApi=this.getService(),this.loadApplication().then(()=>{this.event.emit("ready")})}checkReady(){if(!this.ready)throw Error("client is not ready.")}get ready(){return this._ready}set ready(O){this._ready=O}get questionContextMaxLength(){return this.checkReady(),this._questionContextMaxLength}get promptVariables(){return this.checkReady(),this._promptVariables}get knowledges(){var O;return this.checkReady(),(O=this._application)===null||O===void 0?void 0:O.arrange[0].knowledges}get sessions(){return this.checkReady(),this._sessions}set sessions(O){this.checkReady(),this._sessions=O,this.event.emit("sessions:updated",O)}loadApplication(){return Le(this,void 0,void 0,function*(){var O,L;this._application=yield this.cvforceApi.getApplicationId(this._applicationId);const Y=(L=(O=this._application.arrange)===null||O===void 0?void 0:O[0])===null||L===void 0?void 0:L.llmModel;return Y&&(this._questionContextMaxLength=yield this.cvforceApi.getBaseModel(Y).then(ut=>ut.maxModelLength)),this._promptVariables=yield this.cvforceApi.getPrompts(this._applicationId),this._ready=!0,this.event.emit("application:loaded"),this._application})}getService(){return this.cvforceApi?this.cvforceApi:dc(Mi.configuration.apiRoot,this.token,(O,L)=>Sd.error(L))}get token(){return this._token}set token(O){this.checkReady(),this._token=O,this.ready=!1;const L=oo(O).rid;this._applicationId!==L&&(this._applicationId=L,this._application=null,this.loadApplication().then(()=>{this.event.emit("ready")}),this.clean())}get applicationId(){return this._applicationId}get application(){return this.checkReady(),this._application}get activeSession(){var O;return this.checkReady(),((O=this._activeSession)===null||O===void 0?void 0:O.id)||""}set activeSession(O){this.checkReady(),this.loadSession(O).then(L=>{this._activeSession&&this._activeSession.id!==O&&this._activeSession.inactivate(),this._activeSession=L})}createSession(O,L,Y,ut,ht){return Le(this,void 0,void 0,function*(){const W=this;return new Promise((_,y)=>{const x=v=>Le(this,void 0,void 0,function*(){if(v===bn.Agent)_(new gd(O,L,Y,ut,ht,W));else if(v===bn.Dialog)_(new _d(O,L,Y,ut,ht,W));else throw Error(`不支持的应用类型:${v}`)});if(this.ready){if(!this._application)throw Error("client is not ready");x(this._application.type)}else this.event.on("ready",()=>{if(!this._application)throw Error("_application is null");x(this._application.type)},!0)})})}getSessions(O){return Le(this,void 0,void 0,function*(){return new Promise((L,Y)=>{const ut=()=>this.cvforceApi.listSessions(this._applicationId,O).then(ht=>{const W=[];return ht.forEach(_=>Le(this,void 0,void 0,function*(){const y=this._sessions.find(x=>_.id===x.id);if(y)y.data=_,W.push(y);else{const x=yield this.createSession(this.token,_.id,_,this.lazyload,this._application||void 0);W.push(x)}})),this.sessions=W,W});if(this.ready){if(!this._application)throw Error("_application is null");L(ut())}else this.event.on("ready",()=>{if(!this._application)throw Error("_application is null");L(ut())},!0)})})}loadSession(){return Le(this,arguments,void 0,function*(O="",L){this.checkReady();let Y=this.sessions.find(ut=>ut.id===O);if(Y||(Y=yield this.createSession(this.token,O,L),this._sessions.push(Y)),this._activeSession){if(this._activeSession===Y)return Y;this._activeSession.inactivate()}return Y.id?(yield Y.activate(),this._activeSession=Y):Y.addEventListener("data:loaded",()=>{this._activeSession!==Y&&(Y==null||Y.activate(),this._activeSession=Y)},!0),Y})}reload(){return this.loadApplication().then(()=>Le(this,void 0,void 0,function*(){return yield this.getSessions(),this.event.emit("ready"),this}))}reloadSession(O){return Le(this,void 0,void 0,function*(){yield this.reload();let L=this._sessions.find(Y=>Y.id===O)||this._activeSession;if(!L){console.warn("reloadSession session failed.");return}return yield L.reload(),L})}setTop(O,L){return Le(this,arguments,void 0,function*(Y,ut,ht="top_time desc, sort_status desc, updated_at desc"){let W=Y?this._sessions.find(_=>_.id===Y):this._activeSession;if(!W){console.warn("setTop session failed.");return}return yield W.setTop(ut),this.getSessions({order:ht})})}addEventListener(O,L,Y=!1){if(typeof L!="function")throw Error("event listener is not a function");if(Y){this.event.once(O,L);return}this.event.on(O,L)}removeEventListener(O,L){this.event.off(O,L)}removeSession(O,L){return Le(this,void 0,void 0,function*(){this.checkReady();let Y=-1;if(typeof O=="string"?Y=this._sessions.findIndex(ut=>ut.id===O):Y=this._sessions.findIndex(ut=>ut.id===O.id),Y>-1){const ut=this._sessions[Y];L&&(yield ut.delete()),this._sessions.splice(Y,1)}else console.warn("session delete failed, session is not exist.")})}clean(){this._sessions.forEach(O=>O.destroy()),this.sessions=[]}}class kd{constructor(O,L={},Y){Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"loaded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"functions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),this.code=O,L&&(this.functions=L)}fetchData(){this.description="描述",this.loaded=!0}checkFunctions(){}}Mi.AgentPlugin=kd,Mi.BotClient=Ed,Mi.Session=cs,Mi.configure=yu,Object.defineProperty(Mi,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glodon-aiot/agent-cli-sdk",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "author": "glodoncv",
5
5
  "description": "aiot agent client js sdk",
6
6
  "type": "module",
@@ -81,7 +81,7 @@
81
81
  "registry": "https://registry.npmjs.org/"
82
82
  },
83
83
  "dependencies": {
84
- "@glodon-aiot/apis": "^3.0.5",
84
+ "@glodon-aiot/apis": "^3.0.6",
85
85
  "axios": "0.24.0",
86
86
  "buffer": "^6.0.3",
87
87
  "dayjs": "^1.11.13",