UNPKG

nim-web-sdk-ng

Version:

Yunxin IM SDK next generation

24 lines 1.3 MB
/**
 * 
 *   Version: 10.9.71
 * 
 *   Git Hash: f2dd8dce716f63985d0823f710605b924090d68b
 * 
 *   Created At: 1/5/2026, 9:48:45 AM
 * 
 *   Target: NIM_BROWSER_SDK.js
 *   
 */

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).NIM={})}(this,(function(t){"use strict";var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function createCommonjsModule(t){var i={exports:{}};return t(i,i.exports),i.exports}var u,m,check=function(t){return t&&t.Math==Math&&t},h=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof i&&i)||function(){return this}()||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},v=!fails((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),M=Function.prototype,I=M.apply,S=M.call,T="object"==typeof Reflect&&Reflect.apply||(v?S.bind(I):function(){return S.apply(I,arguments)}),C=Function.prototype,E=C.bind,A=C.call,k=v&&E.bind(A,A),R=v?function(t){return t&&k(t)}:function(t){return t&&function(){return A.apply(t,arguments)}},isCallable=function(t){return"function"==typeof t},w=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),N=Function.prototype.call,x=v?N.bind(N):function(){return N.apply(N,arguments)},O={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,L={f:P&&!O.call({1:2},1)?function propertyIsEnumerable(t){var i=P(this,t);return!!i&&i.enumerable}:O},createPropertyDescriptor=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}},V=R({}.toString),U=R("".slice),classofRaw=function(t){return U(V(t),8,-1)},D=Object,B=R("".split),q=fails((function(){return!D("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?B(t,""):D(t)}:D,isNullOrUndefined=function(t){return null==t},G=TypeError,requireObjectCoercible=function(t){if(isNullOrUndefined(t))throw G("Can't call method on "+t);return t},toIndexedObject=function(t){return q(requireObjectCoercible(t))},H="object"==typeof document&&document.all,j=void 0===H&&void 0!==H?function(t){return"object"==typeof t?null!==t:isCallable(t)||t===H}:function(t){return"object"==typeof t?null!==t:isCallable(t)},$={},aFunction=function(t){return isCallable(t)?t:void 0},getBuiltIn=function(t,i){return arguments.length<2?aFunction($[t])||aFunction(h[t]):$[t]&&$[t][i]||h[t]&&h[t][i]},z=R({}.isPrototypeOf),W=getBuiltIn("navigator","userAgent")||"",K=h.process,Y=h.Deno,Q=K&&K.versions||Y&&Y.version,J=Q&&Q.v8;J&&(m=(u=J.split("."))[0]>0&&u[0]<4?1:+(u[0]+u[1])),!m&&W&&(!(u=W.match(/Edge\/(\d+)/))||u[1]>=74)&&(u=W.match(/Chrome\/(\d+)/))&&(m=+u[1]);var X=m,Z=!!Object.getOwnPropertySymbols&&!fails((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&X&&X<41})),ee=Z&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,te=Object,re=ee?function(t){return"symbol"==typeof t}:function(t){var i=getBuiltIn("Symbol");return isCallable(i)&&z(i.prototype,te(t))},ne=String,tryToString=function(t){try{return ne(t)}catch(t){return"Object"}},ae=TypeError,aCallable=function(t){if(isCallable(t))return t;throw ae(tryToString(t)+" is not a function")},getMethod=function(t,i){var u=t[i];return isNullOrUndefined(u)?void 0:aCallable(u)},ie=TypeError,oe=Object.defineProperty,se="__core-js_shared__",ce=h[se]||function(t,i){try{oe(h,t,{value:i,configurable:!0,writable:!0})}catch(u){h[t]=i}return i}(se,{}),le=createCommonjsModule((function(t){(t.exports=function(t,i){return ce[t]||(ce[t]=void 0!==i?i:{})})("versions",[]).push({version:"3.25.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.0/LICENSE",source:"https://github.com/zloirock/core-js"})})),de=Object,toObject=function(t){return de(requireObjectCoercible(t))},ue=R({}.hasOwnProperty),pe=Object.hasOwn||function hasOwn(t,i){return ue(toObject(t),i)},me=0,he=Math.random(),ge=R(1..toString),uid=function(t){return"Symbol("+(void 0===t?"":t)+")_"+ge(++me+he,36)},ve=le("wks"),fe=h.Symbol,ye=fe&&fe.for,Me=ee?fe:fe&&fe.withoutSetter||uid,wellKnownSymbol=function(t){if(!pe(ve,t)||!Z&&"string"!=typeof ve[t]){var i="Symbol."+t;Z&&pe(fe,t)?ve[t]=fe[t]:ve[t]=ee&&ye?ye(i):Me(i)}return ve[t]},Ie=TypeError,_e=wellKnownSymbol("toPrimitive"),toPrimitive=function(t,i){if(!j(t)||re(t))return t;var u,m=getMethod(t,_e);if(m){if(void 0===i&&(i="default"),u=x(m,t,i),!j(u)||re(u))return u;throw Ie("Can't convert object to primitive value")}return void 0===i&&(i="number"),function(t,i){var u,m;if("string"===i&&isCallable(u=t.toString)&&!j(m=x(u,t)))return m;if(isCallable(u=t.valueOf)&&!j(m=x(u,t)))return m;if("string"!==i&&isCallable(u=t.toString)&&!j(m=x(u,t)))return m;throw ie("Can't convert object to primitive value")}(t,i)},toPropertyKey=function(t){var i=toPrimitive(t,"string");return re(i)?i:i+""},Se=h.document,Te=j(Se)&&j(Se.createElement),documentCreateElement=function(t){return Te?Se.createElement(t):{}},Ce=!w&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),be=Object.getOwnPropertyDescriptor,Ee={f:w?be:function getOwnPropertyDescriptor(t,i){if(t=toIndexedObject(t),i=toPropertyKey(i),Ce)try{return be(t,i)}catch(t){}if(pe(t,i))return createPropertyDescriptor(!x(L.f,t,i),t[i])}},Ae=/#|\.prototype\./,isForced=function(t,i){var u=Re[ke(t)];return u==Ne||u!=we&&(isCallable(i)?fails(i):!!i)},ke=isForced.normalize=function(t){return String(t).replace(Ae,".").toLowerCase()},Re=isForced.data={},we=isForced.NATIVE="N",Ne=isForced.POLYFILL="P",xe=isForced,Oe=R(R.bind),functionBindContext=function(t,i){return aCallable(t),void 0===i?t:v?Oe(t,i):function(){return t.apply(i,arguments)}},Pe=w&&fails((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Le=String,Ve=TypeError,anObject=function(t){if(j(t))return t;throw Ve(Le(t)+" is not an object")},Ue=TypeError,De=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,qe="enumerable",Fe="configurable",Ge="writable",He={f:w?Pe?function defineProperty(t,i,u){if(anObject(t),i=toPropertyKey(i),anObject(u),"function"==typeof t&&"prototype"===i&&"value"in u&&Ge in u&&!u.writable){var m=Be(t,i);m&&m.writable&&(t[i]=u.value,u={configurable:Fe in u?u.configurable:m.configurable,enumerable:qe in u?u.enumerable:m.enumerable,writable:!1})}return De(t,i,u)}:De:function defineProperty(t,i,u){if(anObject(t),i=toPropertyKey(i),anObject(u),Ce)try{return De(t,i,u)}catch(t){}if("get"in u||"set"in u)throw Ue("Accessors not supported");return"value"in u&&(t[i]=u.value),t}},je=w?function(t,i,u){return He.f(t,i,createPropertyDescriptor(1,u))}:function(t,i,u){return t[i]=u,t},$e=Ee.f,wrapConstructor=function(t){var Wrapper=function(i,u,m){if(this instanceof Wrapper){switch(arguments.length){case 0:return new t;case 1:return new t(i);case 2:return new t(i,u)}return new t(i,u,m)}return T(t,this,arguments)};return Wrapper.prototype=t.prototype,Wrapper},_export=function(t,i){var u,m,v,M,I,S,T,C,E=t.target,A=t.global,k=t.stat,w=t.proto,N=A?h:k?h[E]:(h[E]||{}).prototype,x=A?$:$[E]||je($,E,{})[E],O=x.prototype;for(v in i)u=!xe(A?v:E+(k?".":"#")+v,t.forced)&&N&&pe(N,v),I=x[v],u&&(S=t.dontCallGetSet?(C=$e(N,v))&&C.value:N[v]),M=u&&S?S:i[v],u&&typeof I==typeof M||(T=t.bind&&u?functionBindContext(M,h):t.wrap&&u?wrapConstructor(M):w&&isCallable(M)?R(M):M,(t.sham||M&&M.sham||I&&I.sham)&&je(T,"sham",!0),je(x,v,T),w&&(pe($,m=E+"Prototype")||je($,m,{}),je($[m],v,M),t.real&&O&&!O[v]&&je(O,v,M)))},ze=He.f;_export({target:"Object",stat:!0,forced:Object.defineProperty!==ze,sham:!w},{defineProperty:ze});var We,Ke=createCommonjsModule((function(t){var i=$.Object,u=t.exports=function defineProperty(t,u,m){return i.defineProperty(t,u,m)};i.defineProperty.sham&&(u.sham=!0)})),Ye=Ke,Qe=getDefaultExportFromCjs(createCommonjsModule((function(t){function _defineProperties(t,i){for(var u=0;u<i.length;u++){var m=i[u];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Ye(t,m.key,m)}}t.exports=function _createClass(t,i,u){return i&&_defineProperties(t.prototype,i),u&&_defineProperties(t,u),Ye(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}))),Je=getDefaultExportFromCjs(createCommonjsModule((function(t){t.exports=function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.__esModule=!0,t.exports.default=t.exports}))),Xe=Math.ceil,Ze=Math.floor,et=Math.trunc||function trunc(t){var i=+t;return(i>0?Ze:Xe)(i)},toIntegerOrInfinity=function(t){var i=+t;return i!=i||0===i?0:et(i)},tt=Math.max,rt=Math.min,toAbsoluteIndex=function(t,i){var u=toIntegerOrInfinity(t);return u<0?tt(u+i,0):rt(u,i)},nt=Math.min,toLength=function(t){return t>0?nt(toIntegerOrInfinity(t),9007199254740991):0},lengthOfArrayLike=function(t){return toLength(t.length)},createMethod$5=function(t){return function(i,u,m){var h,v=toIndexedObject(i),M=lengthOfArrayLike(v),I=toAbsoluteIndex(m,M);if(t&&u!=u){for(;M>I;)if((h=v[I++])!=h)return!0}else for(;M>I;I++)if((t||I in v)&&v[I]===u)return t||I||0;return!t&&-1}},at={includes:createMethod$5(!0),indexOf:createMethod$5(!1)},it={},ot=at.indexOf,st=R([].push),objectKeysInternal=function(t,i){var u,m=toIndexedObject(t),h=0,v=[];for(u in m)!pe(it,u)&&pe(m,u)&&st(v,u);for(;i.length>h;)pe(m,u=i[h++])&&(~ot(v,u)||st(v,u));return v},ct=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],lt=Object.keys||function keys(t){return objectKeysInternal(t,ct)},dt=w&&!Pe?Object.defineProperties:function defineProperties(t,i){anObject(t);for(var u,m=toIndexedObject(i),h=lt(i),v=h.length,M=0;v>M;)He.f(t,u=h[M++],m[u]);return t},ut={f:dt},pt=getBuiltIn("document","documentElement"),mt=le("keys"),sharedKey=function(t){return mt[t]||(mt[t]=uid(t))},ht=sharedKey("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(t){return"<script>"+t+"</"+"script>"},NullProtoObjectViaActiveX=function(t){t.write(scriptTag("")),t.close();var i=t.parentWindow.Object;return t=null,i},NullProtoObject=function(){try{We=new ActiveXObject("htmlfile")}catch(t){}var t,i;NullProtoObject="undefined"!=typeof document?document.domain&&We?NullProtoObjectViaActiveX(We):((i=documentCreateElement("iframe")).style.display="none",pt.appendChild(i),i.src=String("javascript:"),(t=i.contentWindow.document).open(),t.write(scriptTag("document.F=Object")),t.close(),t.F):NullProtoObjectViaActiveX(We);for(var u=ct.length;u--;)delete NullProtoObject.prototype[ct[u]];return NullProtoObject()};it[ht]=!0;var gt=Object.create||function create(t,i){var u;return null!==t?(EmptyConstructor.prototype=anObject(t),u=new EmptyConstructor,EmptyConstructor.prototype=null,u[ht]=t):u=NullProtoObject(),void 0===i?u:ut.f(u,i)};_export({target:"Object",stat:!0,sham:!w},{create:gt});var vt=$.Object,ft=function create(t,i){return vt.create(t,i)},yt=String,Mt=TypeError,It=Object.setPrototypeOf||("__proto__"in{}?function(){var t,i=!1,u={};try{(t=R(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(u,[]),i=u instanceof Array}catch(t){}return function setPrototypeOf(u,m){return anObject(u),function(t){if("object"==typeof t||isCallable(t))return t;throw Mt("Can't set "+yt(t)+" as a prototype")}(m),i?t(u,m):u.__proto__=m,u}}():void 0);_export({target:"Object",stat:!0},{setPrototypeOf:It});var _t=$.Object.setPrototypeOf,St=R([].slice),Tt=Function,Ct=R([].concat),bt=R([].join),Et={},construct$8=function(t,i,u){if(!pe(Et,i)){for(var m=[],h=0;h<i;h++)m[h]="a["+h+"]";Et[i]=Tt("C,a","return new C("+bt(m,",")+")")}return Et[i](t,u)},At=v?Tt.bind:function bind(t){var i=aCallable(this),u=i.prototype,m=St(arguments,1),h=function bound(){var u=Ct(m,St(arguments));return this instanceof h?construct$8(i,u.length,u):i.apply(t,u)};return j(u)&&(h.prototype=u),h};_export({target:"Function",proto:!0,forced:Function.bind!==At},{bind:At});var entryVirtual=function(t){return $[t+"Prototype"]},kt=entryVirtual("Function").bind,Rt=Function.prototype,bind$1=function(t){var i=t.bind;return t===Rt||z(Rt,t)&&i===Rt.bind?kt:i},wt=createCommonjsModule((function(t){function _setPrototypeOf(i,u){var m;return t.exports=_setPrototypeOf=_t?bind$1(m=_t).call(m):function _setPrototypeOf(t,i){return t.__proto__=i,t},t.exports.__esModule=!0,t.exports.default=t.exports,_setPrototypeOf(i,u)}t.exports=_setPrototypeOf,t.exports.__esModule=!0,t.exports.default=t.exports})),Nt=getDefaultExportFromCjs(createCommonjsModule((function(t){t.exports=function _inheritsLoose(t,i){t.prototype=ft(i.prototype),t.prototype.constructor=t,wt(t,i)},t.exports.__esModule=!0,t.exports.default=t.exports})));_export({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var xt=9007199254740991,Ot={f:Object.getOwnPropertySymbols},Pt=Object.assign,Lt=Object.defineProperty,Vt=R([].concat),Ut=!Pt||fails((function(){if(w&&1!==Pt({b:1},Pt(Lt({},"a",{enumerable:!0,get:function(){Lt(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},i={},u=Symbol(),m="abcdefghijklmnopqrst";return t[u]=7,m.split("").forEach((function(t){i[t]=t})),7!=Pt({},t)[u]||lt(Pt({},i)).join("")!=m}))?function assign(t,i){for(var u=toObject(t),m=arguments.length,h=1,v=Ot.f,M=L.f;m>h;)for(var I,S=q(arguments[h++]),T=v?Vt(lt(S),v(S)):lt(S),C=T.length,E=0;C>E;)I=T[E++],w&&!x(M,S,I)||(u[I]=S[I]);return u}:Pt;_export({target:"Object",stat:!0,arity:2,forced:Object.assign!==Ut},{assign:Ut});var Dt=$.Object.assign,Bt=fails((function(){lt(1)}));_export({target:"Object",stat:!0,forced:Bt},{keys:function keys(t){return lt(toObject(t))}});var qt,Ft,Gt,Ht=$.Object.keys,jt={},$t=h.WeakMap,zt=isCallable($t)&&/native code/.test(String($t)),Wt="Object already initialized",Kt=h.TypeError,Yt=h.WeakMap;if(zt||ce.state){var Qt=ce.state||(ce.state=new Yt),Jt=R(Qt.get),Xt=R(Qt.has),Zt=R(Qt.set);qt=function(t,i){if(Xt(Qt,t))throw Kt(Wt);return i.facade=t,Zt(Qt,t,i),i},Ft=function(t){return Jt(Qt,t)||{}},Gt=function(t){return Xt(Qt,t)}}else{var er=sharedKey("state");it[er]=!0,qt=function(t,i){if(pe(t,er))throw Kt(Wt);return i.facade=t,je(t,er,i),i},Ft=function(t){return pe(t,er)?t[er]:{}},Gt=function(t){return pe(t,er)}}var tr,rr,nr,ar={set:qt,get:Ft,has:Gt,enforce:function(t){return Gt(t)?Ft(t):qt(t,{})},getterFor:function(t){return function(i){var u;if(!j(i)||(u=Ft(i)).type!==t)throw Kt("Incompatible receiver, "+t+" required");return u}}},ir=Function.prototype,or=w&&Object.getOwnPropertyDescriptor,sr=pe(ir,"name"),cr={EXISTS:sr,PROPER:sr&&"something"===function something(){}.name,CONFIGURABLE:sr&&(!w||w&&or(ir,"name").configurable)},lr=!fails((function(){function F(){}return F.prototype.constructor=null,Object.getPrototypeOf(new F)!==F.prototype})),dr=sharedKey("IE_PROTO"),ur=Object,pr=ur.prototype,mr=lr?ur.getPrototypeOf:function(t){var i=toObject(t);if(pe(i,dr))return i[dr];var u=i.constructor;return isCallable(u)&&i instanceof u?u.prototype:i instanceof ur?pr:null},defineBuiltIn=function(t,i,u,m){return m&&m.enumerable?t[i]=u:je(t,i,u),t},hr=wellKnownSymbol("iterator"),gr=!1;[].keys&&("next"in(nr=[].keys())?(rr=mr(mr(nr)))!==Object.prototype&&(tr=rr):gr=!0);var vr=!j(tr)||fails((function(){var t={};return tr[hr].call(t)!==t}));tr=vr?{}:gt(tr),isCallable(tr[hr])||defineBuiltIn(tr,hr,(function(){return this}));var fr={IteratorPrototype:tr,BUGGY_SAFARI_ITERATORS:gr},yr={};yr[wellKnownSymbol("toStringTag")]="z";var Mr="[object z]"===String(yr),Ir=wellKnownSymbol("toStringTag"),_r=Object,Sr="Arguments"==classofRaw(function(){return arguments}()),Tr=Mr?classofRaw:function(t){var i,u,m;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(u=function(t,i){try{return t[i]}catch(t){}}(i=_r(t),Ir))?u:Sr?classofRaw(i):"Object"==(m=classofRaw(i))&&isCallable(i.callee)?"Arguments":m},Cr=Mr?{}.toString:function toString(){return"[object "+Tr(this)+"]"},br=He.f,Er=wellKnownSymbol("toStringTag"),setToStringTag=function(t,i,u,m){if(t){var h=u?t:t.prototype;pe(h,Er)||br(h,Er,{configurable:!0,value:i}),m&&!Mr&&je(h,"toString",Cr)}},Ar=fr.IteratorPrototype,returnThis$1=function(){return this},kr=cr.PROPER,Rr=fr.BUGGY_SAFARI_ITERATORS,wr=wellKnownSymbol("iterator"),Nr="keys",xr="values",Or="entries",returnThis=function(){return this},iteratorDefine=function(t,i,u,m,h,v,M){!function(t,i,u,m){var h=i+" Iterator";t.prototype=gt(Ar,{next:createPropertyDescriptor(+!m,u)}),setToStringTag(t,h,!1,!0),jt[h]=returnThis$1}(u,i,m);var I,S,T,getIterationMethod=function(t){if(t===h&&R)return R;if(!Rr&&t in A)return A[t];switch(t){case Nr:return function keys(){return new u(this,t)};case xr:return function values(){return new u(this,t)};case Or:return function entries(){return new u(this,t)}}return function(){return new u(this)}},C=i+" Iterator",E=!1,A=t.prototype,k=A[wr]||A["@@iterator"]||h&&A[h],R=!Rr&&k||getIterationMethod(h),w="Array"==i&&A.entries||k;if(w&&(I=mr(w.call(new t)))!==Object.prototype&&I.next&&(setToStringTag(I,C,!0,!0),jt[C]=returnThis),kr&&h==xr&&k&&k.name!==xr&&(E=!0,R=function values(){return x(k,this)}),h)if(S={values:getIterationMethod(xr),keys:v?R:getIterationMethod(Nr),entries:getIterationMethod(Or)},M)for(T in S)(Rr||E||!(T in A))&&defineBuiltIn(A,T,S[T]);else _export({target:i,proto:!0,forced:Rr||E},S);return M&&A[wr]!==R&&defineBuiltIn(A,wr,R,{name:h}),jt[i]=R,S};He.f;var Pr="Array Iterator",Lr=ar.set,Vr=ar.getterFor(Pr);iteratorDefine(Array,"Array",(function(t,i){Lr(this,{type:Pr,target:toIndexedObject(t),index:0,kind:i})}),(function(){var t=Vr(this),i=t.target,u=t.kind,m=t.index++;return!i||m>=i.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==u?{value:m,done:!1}:"values"==u?{value:i[m],done:!1}:{value:[m,i[m]],done:!1}}),"values"),jt.Arguments=jt.Array;var Ur=wellKnownSymbol("toStringTag");for(var Dr in{CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}){var Br=h[Dr],qr=Br&&Br.prototype;qr&&Tr(qr)!==Ur&&je(qr,Ur,Dr),jt[Dr]=jt.Array}var Fr=Array.isArray||function isArray(t){return"Array"==classofRaw(t)},Gr=R(Function.toString);isCallable(ce.inspectSource)||(ce.inspectSource=function(t){return Gr(t)});var Hr=ce.inspectSource,noop=function(){},jr=[],$r=getBuiltIn("Reflect","construct"),zr=/^\s*(?:class|function)\b/,Wr=R(zr.exec),Kr=!zr.exec(noop),Yr=function isConstructor(t){if(!isCallable(t))return!1;try{return $r(noop,jr,t),!0}catch(t){return!1}},Qr=function isConstructor(t){if(!isCallable(t))return!1;switch(Tr(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Kr||!!Wr(zr,Hr(t))}catch(t){return!0}};Qr.sham=!0;var Jr=!$r||fails((function(){var t;return Yr(Yr.call)||!Yr(Object)||!Yr((function(){t=!0}))||t}))?Qr:Yr,Xr=wellKnownSymbol("species"),Zr=Array,arraySpeciesCreate=function(t,i){return new(function(t){var i;return Fr(t)&&(i=t.constructor,(Jr(i)&&(i===Zr||Fr(i.prototype))||j(i)&&null===(i=i[Xr]))&&(i=void 0)),void 0===i?Zr:i}(t))(0===i?0:i)},en=R([].push),createMethod$4=function(t){var i=1==t,u=2==t,m=3==t,h=4==t,v=6==t,M=7==t,I=5==t||v;return function(S,T,C,E){for(var A,k,R=toObject(S),w=q(R),N=functionBindContext(T,C),x=lengthOfArrayLike(w),O=0,P=E||arraySpeciesCreate,L=i?P(S,x):u||M?P(S,0):void 0;x>O;O++)if((I||O in w)&&(k=N(A=w[O],O,R),t))if(i)L[O]=k;else if(k)switch(t){case 3:return!0;case 5:return A;case 6:return O;case 2:en(L,A)}else switch(t){case 4:return!1;case 7:en(L,A)}return v?-1:m||h?h:L}},tn={forEach:createMethod$4(0),map:createMethod$4(1),filter:createMethod$4(2),some:createMethod$4(3),every:createMethod$4(4),find:createMethod$4(5),findIndex:createMethod$4(6),filterReject:createMethod$4(7)},arrayMethodIsStrict=function(t,i){var u=[][t];return!!u&&fails((function(){u.call(null,i||function(){return 1},1)}))},rn=tn.forEach,nn=arrayMethodIsStrict("forEach")?[].forEach:function forEach(t){return rn(this,t,arguments.length>1?arguments[1]:void 0)};_export({target:"Array",proto:!0,forced:[].forEach!=nn},{forEach:nn});var an=entryVirtual("Array").forEach,sn=Array.prototype,cn={DOMTokenList:!0,NodeList:!0},forEach$1=function(t){var i=t.forEach;return t===sn||z(sn,t)&&i===sn.forEach||pe(cn,Tr(t))?an:i},ln=tn.findIndex,dn="findIndex",un=!0;dn in[]&&Array(1).findIndex((function(){un=!1})),_export({target:"Array",proto:!0,forced:un},{findIndex:function findIndex(t){return ln(this,t,arguments.length>1?arguments[1]:void 0)}});var pn=entryVirtual("Array").findIndex,mn=Array.prototype,findIndex$1=function(t){var i=t.findIndex;return t===mn||z(mn,t)&&i===mn.findIndex?pn:i},hn=TypeError,gn=Object.getOwnPropertyDescriptor,vn=w&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}()?function(t,i){if(Fr(t)&&!gn(t,"length").writable)throw hn("Cannot set read only .length");return t.length=i}:function(t,i){return t.length=i},fn=TypeError,doesNotExceedSafeInteger=function(t){if(t>9007199254740991)throw fn("Maximum allowed index exceeded");return t},createProperty=function(t,i,u){var m=toPropertyKey(i);m in t?He.f(t,m,createPropertyDescriptor(0,u)):t[m]=u},yn=TypeError,deletePropertyOrThrow=function(t,i){if(!delete t[i])throw yn("Cannot delete property "+tryToString(i)+" of "+tryToString(t))},Mn=wellKnownSymbol("species"),arrayMethodHasSpeciesSupport=function(t){return X>=51||!fails((function(){var i=[];return(i.constructor={})[Mn]=function(){return{foo:1}},1!==i[t](Boolean).foo}))},In=arrayMethodHasSpeciesSupport("splice"),_n=Math.max,Sn=Math.min;_export({target:"Array",proto:!0,forced:!In},{splice:function splice(t,i){var u,m,h,v,M,I,S=toObject(this),T=lengthOfArrayLike(S),C=toAbsoluteIndex(t,T),E=arguments.length;for(0===E?u=m=0:1===E?(u=0,m=T-C):(u=E-2,m=Sn(_n(toIntegerOrInfinity(i),0),T-C)),doesNotExceedSafeInteger(T+u-m),h=arraySpeciesCreate(S,m),v=0;v<m;v++)(M=C+v)in S&&createProperty(h,v,S[M]);if(h.length=m,u<m){for(v=C;v<T-m;v++)I=v+u,(M=v+m)in S?S[I]=S[M]:deletePropertyOrThrow(S,I);for(v=T;v>T-m+u;v--)deletePropertyOrThrow(S,v-1)}else if(u>m)for(v=T-m;v>C;v--)I=v+u-1,(M=v+m-1)in S?S[I]=S[M]:deletePropertyOrThrow(S,I);for(v=0;v<u;v++)S[v+C]=arguments[v+2];return vn(S,T-m+u),h}});var Tn=entryVirtual("Array").splice,Cn=Array.prototype,splice=function(t){var i=t.splice;return t===Cn||z(Cn,t)&&i===Cn.splice?Tn:i},bn=getBuiltIn("JSON","stringify"),En=R(/./.exec),An=R("".charAt),kn=R("".charCodeAt),Rn=R("".replace),wn=R(1..toString),Nn=/[\uD800-\uDFFF]/g,xn=/^[\uD800-\uDBFF]$/,On=/^[\uDC00-\uDFFF]$/,Pn=!Z||fails((function(){var t=getBuiltIn("Symbol")();return"[null]"!=bn([t])||"{}"!=bn({a:t})||"{}"!=bn(Object(t))})),Ln=fails((function(){return'"\\udf06\\ud834"'!==bn("\udf06\ud834")||'"\\udead"'!==bn("\udead")})),stringifyWithSymbolsFix=function(t,i){var u=St(arguments),m=i;if((j(i)||void 0!==t)&&!re(t))return Fr(i)||(i=function(t,i){if(isCallable(m)&&(i=x(m,this,t,i)),!re(i))return i}),u[1]=i,T(bn,null,u)},fixIllFormed=function(t,i,u){var m=An(u,i-1),h=An(u,i+1);return En(xn,t)&&!En(On,h)||En(On,t)&&!En(xn,m)?"\\u"+wn(kn(t,0),16):t};bn&&_export({target:"JSON",stat:!0,arity:3,forced:Pn||Ln},{stringify:function stringify(t,i,u){var m=St(arguments),h=T(Pn?stringifyWithSymbolsFix:bn,null,m);return Ln&&"string"==typeof h?Rn(h,Nn,fixIllFormed):h}}),$.JSON||($.JSON={stringify:JSON.stringify});var Vn=function stringify(t,i,u){return T($.JSON.stringify,null,arguments)},Un=Vn;_export({target:"Array",stat:!0},{isArray:Fr});var Dn=$.Array.isArray,Bn=ct.concat("length","prototype"),qn={f:Object.getOwnPropertyNames||function getOwnPropertyNames(t){return objectKeysInternal(t,Bn)}},Fn=R([].concat),Gn=getBuiltIn("Reflect","ownKeys")||function ownKeys(t){var i=qn.f(anObject(t)),u=Ot.f;return u?Fn(i,u(t)):i},Hn=Error,jn=R("".replace),$n=String(Hn("zxcasd").stack),zn=/\n\s*at [^:]*:[^\n]*/,Wn=zn.test($n),errorStackClear=function(t,i){if(Wn&&"string"==typeof t&&!Hn.prepareStackTrace)for(;i--;)t=jn(t,zn,"");return t},installErrorCause=function(t,i){j(i)&&"cause"in i&&je(t,"cause",i.cause)},Kn=wellKnownSymbol("iterator"),Yn=Array.prototype,isArrayIteratorMethod=function(t){return void 0!==t&&(jt.Array===t||Yn[Kn]===t)},Qn=wellKnownSymbol("iterator"),getIteratorMethod$5=function(t){if(!isNullOrUndefined(t))return getMethod(t,Qn)||getMethod(t,"@@iterator")||jt[Tr(t)]},Jn=TypeError,getIterator=function(t,i){var u=arguments.length<2?getIteratorMethod$5(t):i;if(aCallable(u))return anObject(x(u,t));throw Jn(tryToString(t)+" is not iterable")},iteratorClose=function(t,i,u){var m,h;anObject(t);try{if(!(m=getMethod(t,"return"))){if("throw"===i)throw u;return u}m=x(m,t)}catch(t){h=!0,m=t}if("throw"===i)throw u;if(h)throw m;return anObject(m),u},Xn=TypeError,Result=function(t,i){this.stopped=t,this.result=i},Zn=Result.prototype,iterate=function(t,i,u){var m,h,v,M,I,S,T,C=u&&u.that,E=!(!u||!u.AS_ENTRIES),A=!(!u||!u.IS_RECORD),k=!(!u||!u.IS_ITERATOR),R=!(!u||!u.INTERRUPTED),w=functionBindContext(i,C),stop=function(t){return m&&iteratorClose(m,"normal",t),new Result(!0,t)},callFn=function(t){return E?(anObject(t),R?w(t[0],t[1],stop):w(t[0],t[1])):R?w(t,stop):w(t)};if(A)m=t.iterator;else if(k)m=t;else{if(!(h=getIteratorMethod$5(t)))throw Xn(tryToString(t)+" is not iterable");if(isArrayIteratorMethod(h)){for(v=0,M=lengthOfArrayLike(t);M>v;v++)if((I=callFn(t[v]))&&z(Zn,I))return I;return new Result(!1)}m=getIterator(t,h)}for(S=A?t.next:m.next;!(T=x(S,m)).done;){try{I=callFn(T.value)}catch(t){iteratorClose(m,"throw",t)}if("object"==typeof I&&I&&z(Zn,I))return I}return new Result(!1)},ea=String,toString=function(t){if("Symbol"===Tr(t))throw TypeError("Cannot convert a Symbol value to a string");return ea(t)},normalizeStringArgument=function(t,i){return void 0===t?arguments.length<2?"":i:toString(t)},ta=!fails((function(){var t=Error("a");return!("stack"in t)||(Object.defineProperty(t,"stack",createPropertyDescriptor(1,7)),7!==t.stack)})),ra=wellKnownSymbol("toStringTag"),na=Error,aa=[].push,ia=function AggregateError(t,i){var u,m=arguments.length>2?arguments[2]:void 0,h=z(oa,this);It?u=It(na(),h?mr(this):oa):(u=h?this:gt(oa),je(u,ra,"Error")),void 0!==i&&je(u,"message",normalizeStringArgument(i)),ta&&je(u,"stack",errorStackClear(u.stack,1)),installErrorCause(u,m);var v=[];return iterate(t,aa,{that:v}),je(u,"errors",v),u};It?It(ia,na):function(t,i,u){for(var m=Gn(i),h=He.f,v=Ee.f,M=0;M<m.length;M++){var I=m[M];pe(t,I)||u&&pe(u,I)||h(t,I,v(i,I))}}(ia,na,{name:!0});var oa=ia.prototype=gt(na.prototype,{constructor:createPropertyDescriptor(1,ia),message:createPropertyDescriptor(1,""),name:createPropertyDescriptor(1,"AggregateError")});_export({global:!0,constructor:!0,arity:2},{AggregateError:ia});var sa,ca,la,da,ua="process"==classofRaw(h.process),pa=wellKnownSymbol("species"),setSpecies=function(t){var i=getBuiltIn(t),u=He.f;w&&i&&!i[pa]&&u(i,pa,{configurable:!0,get:function(){return this}})},ma=TypeError,anInstance=function(t,i){if(z(i,t))return t;throw ma("Incorrect invocation")},ha=TypeError,aConstructor=function(t){if(Jr(t))return t;throw ha(tryToString(t)+" is not a constructor")},ga=wellKnownSymbol("species"),speciesConstructor=function(t,i){var u,m=anObject(t).constructor;return void 0===m||isNullOrUndefined(u=anObject(m)[ga])?i:aConstructor(u)},va=TypeError,validateArgumentsLength=function(t,i){if(t<i)throw va("Not enough arguments");return t},fa=/(?:ipad|iphone|ipod).*applewebkit/i.test(W),ya=h.setImmediate,Ma=h.clearImmediate,Ia=h.process,_a=h.Dispatch,Sa=h.Function,Ta=h.MessageChannel,Ca=h.String,ba=0,Ea={},Aa="onreadystatechange";try{sa=h.location}catch(t){}var run=function(t){if(pe(Ea,t)){var i=Ea[t];delete Ea[t],i()}},runner=function(t){return function(){run(t)}},listener=function(t){run(t.data)},post=function(t){h.postMessage(Ca(t),sa.protocol+"//"+sa.host)};ya&&Ma||(ya=function setImmediate(t){validateArgumentsLength(arguments.length,1);var i=isCallable(t)?t:Sa(t),u=St(arguments,1);return Ea[++ba]=function(){T(i,void 0,u)},ca(ba),ba},Ma=function clearImmediate(t){delete Ea[t]},ua?ca=function(t){Ia.nextTick(runner(t))}:_a&&_a.now?ca=function(t){_a.now(runner(t))}:Ta&&!fa?(da=(la=new Ta).port2,la.port1.onmessage=listener,ca=functionBindContext(da.postMessage,da)):h.addEventListener&&isCallable(h.postMessage)&&!h.importScripts&&sa&&"file:"!==sa.protocol&&!fails(post)?(ca=post,h.addEventListener("message",listener,!1)):ca=Aa in documentCreateElement("script")?function(t){pt.appendChild(documentCreateElement("script")).onreadystatechange=function(){pt.removeChild(this),run(t)}}:function(t){setTimeout(runner(t),0)});var ka,Ra,wa,Na,xa,Oa,Pa,La,Va={set:ya,clear:Ma},Ua=/ipad|iphone|ipod/i.test(W)&&void 0!==h.Pebble,Da=/web0s(?!.*chrome)/i.test(W),Ba=Ee.f,qa=Va.set,Fa=h.MutationObserver||h.WebKitMutationObserver,Ga=h.document,Ha=h.process,ja=h.Promise,$a=Ba(h,"queueMicrotask"),za=$a&&$a.value;za||(ka=function(){var t,i;for(ua&&(t=Ha.domain)&&t.exit();Ra;){i=Ra.fn,Ra=Ra.next;try{i()}catch(t){throw Ra?Na():wa=void 0,t}}wa=void 0,t&&t.enter()},fa||ua||Da||!Fa||!Ga?!Ua&&ja&&ja.resolve?((Pa=ja.resolve(void 0)).constructor=ja,La=functionBindContext(Pa.then,Pa),Na=function(){La(ka)}):ua?Na=function(){Ha.nextTick(ka)}:(qa=functionBindContext(qa,h),Na=function(){qa(ka)}):(xa=!0,Oa=Ga.createTextNode(""),new Fa(ka).observe(Oa,{characterData:!0}),Na=function(){Oa.data=xa=!xa}));var Wa=za||function(t){var i={fn:t,next:void 0};wa&&(wa.next=i),Ra||(Ra=i,Na()),wa=i},perform=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Queue=function(){this.head=null,this.tail=null};Queue.prototype={add:function(t){var i={item:t,next:null};this.head?this.tail.next=i:this.head=i,this.tail=i},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var Ka,Ya,Qa=Queue,Ja=h.Promise,Xa="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Za=!Xa&&!ua&&"object"==typeof window&&"object"==typeof document,ei=Ja&&Ja.prototype,ti=wellKnownSymbol("species"),ri=!1,ni=isCallable(h.PromiseRejectionEvent),ai=xe("Promise",(function(){var t=Hr(Ja),i=t!==String(Ja);if(!i&&66===X)return!0;if(!ei.catch||!ei.finally)return!0;if(!X||X<51||!/native code/.test(t)){var u=new Ja((function(t){t(1)})),FakePromise=function(t){t((function(){}),(function(){}))};if((u.constructor={})[ti]=FakePromise,!(ri=u.then((function(){}))instanceof FakePromise))return!0}return!i&&(Za||Xa)&&!ni})),oi={CONSTRUCTOR:ai,REJECTION_EVENT:ni,SUBCLASSING:ri},si=TypeError,PromiseCapability=function(t){var i,u;this.promise=new t((function(t,m){if(void 0!==i||void 0!==u)throw si("Bad Promise constructor");i=t,u=m})),this.resolve=aCallable(i),this.reject=aCallable(u)},ci={f:function(t){return new PromiseCapability(t)}},li=Va.set,di="Promise",ui=oi.CONSTRUCTOR,pi=oi.REJECTION_EVENT,mi=ar.getterFor(di),hi=ar.set,gi=Ja&&Ja.prototype,vi=Ja,fi=gi,yi=h.TypeError,Mi=h.document,Ii=h.process,_i=ci.f,Si=_i,Ti=!!(Mi&&Mi.createEvent&&h.dispatchEvent),Ci="unhandledrejection",isThenable=function(t){var i;return!(!j(t)||!isCallable(i=t.then))&&i},callReaction=function(t,i){var u,m,h,v=i.value,M=1==i.state,I=M?t.ok:t.fail,S=t.resolve,T=t.reject,C=t.domain;try{I?(M||(2===i.rejection&&onHandleUnhandled(i),i.rejection=1),!0===I?u=v:(C&&C.enter(),u=I(v),C&&(C.exit(),h=!0)),u===t.promise?T(yi("Promise-chain cycle")):(m=isThenable(u))?x(m,u,S,T):S(u)):T(v)}catch(t){C&&!h&&C.exit(),T(t)}},notify=function(t,i){t.notified||(t.notified=!0,Wa((function(){for(var u,m=t.reactions;u=m.get();)callReaction(u,t);t.notified=!1,i&&!t.rejection&&onUnhandled(t)})))},dispatchEvent=function(t,i,u){var m,v;Ti?((m=Mi.createEvent("Event")).promise=i,m.reason=u,m.initEvent(t,!1,!0),h.dispatchEvent(m)):m={promise:i,reason:u},!pi&&(v=h["on"+t])?v(m):t===Ci&&function(t,i){var u=h.console;u&&u.error&&(1==arguments.length?u.error(t):u.error(t,i))}("Unhandled promise rejection",u)},onUnhandled=function(t){x(li,h,(function(){var i,u=t.facade,m=t.value;if(isUnhandled(t)&&(i=perform((function(){ua?Ii.emit("unhandledRejection",m,u):dispatchEvent(Ci,u,m)})),t.rejection=ua||isUnhandled(t)?2:1,i.error))throw i.value}))},isUnhandled=function(t){return 1!==t.rejection&&!t.parent},onHandleUnhandled=function(t){x(li,h,(function(){var i=t.facade;ua?Ii.emit("rejectionHandled",i):dispatchEvent("rejectionhandled",i,t.value)}))},bind=function(t,i,u){return function(m){t(i,m,u)}},internalReject=function(t,i,u){t.done||(t.done=!0,u&&(t=u),t.value=i,t.state=2,notify(t,!0))},internalResolve=function(t,i,u){if(!t.done){t.done=!0,u&&(t=u);try{if(t.facade===i)throw yi("Promise can't be resolved itself");var m=isThenable(i);m?Wa((function(){var u={done:!1};try{x(m,i,bind(internalResolve,u,t),bind(internalReject,u,t))}catch(i){internalReject(u,i,t)}})):(t.value=i,t.state=1,notify(t,!1))}catch(i){internalReject({done:!1},i,t)}}};ui&&(fi=(vi=function Promise(t){anInstance(this,fi),aCallable(t),x(Ka,this);var i=mi(this);try{t(bind(internalResolve,i),bind(internalReject,i))}catch(t){internalReject(i,t)}}).prototype,(Ka=function Promise(t){hi(this,{type:di,done:!1,notified:!1,parent:!1,reactions:new Qa,rejection:!1,state:0,value:void 0})}).prototype=defineBuiltIn(fi,"then",(function then(t,i){var u=mi(this),m=_i(speciesConstructor(this,vi));return u.parent=!0,m.ok=!isCallable(t)||t,m.fail=isCallable(i)&&i,m.domain=ua?Ii.domain:void 0,0==u.state?u.reactions.add(m):Wa((function(){callReaction(m,u)})),m.promise})),Ya=function(){var t=new Ka,i=mi(t);this.promise=t,this.resolve=bind(internalResolve,i),this.reject=bind(internalReject,i)},ci.f=_i=function(t){return t===vi||undefined===t?new Ya(t):Si(t)}),_export({global:!0,constructor:!0,wrap:!0,forced:ui},{Promise:vi}),setToStringTag(vi,di,!1,!0),setSpecies(di);var bi=wellKnownSymbol("iterator"),Ei=!1;try{var Ai=0,ki={next:function(){return{done:!!Ai++}},return:function(){Ei=!0}};ki[bi]=function(){return this},Array.from(ki,(function(){throw 2}))}catch(t){}var checkCorrectnessOfIteration=function(t,i){if(!i&&!Ei)return!1;var u=!1;try{var m={};m[bi]=function(){return{next:function(){return{done:u=!0}}}},t(m)}catch(t){}return u},Ri=oi.CONSTRUCTOR||!checkCorrectnessOfIteration((function(t){Ja.all(t).then(void 0,(function(){}))}));_export({target:"Promise",stat:!0,forced:Ri},{all:function all(t){var i=this,u=ci.f(i),m=u.resolve,h=u.reject,v=perform((function(){var u=aCallable(i.resolve),v=[],M=0,I=1;iterate(t,(function(t){var S=M++,T=!1;I++,x(u,i,t).then((function(t){T||(T=!0,v[S]=t,--I||m(v))}),h)})),--I||m(v)}));return v.error&&h(v.value),u.promise}});var wi=oi.CONSTRUCTOR;Ja&&Ja.prototype,_export({target:"Promise",proto:!0,forced:wi,real:!0},{catch:function(t){return this.then(void 0,t)}}),_export({target:"Promise",stat:!0,forced:Ri},{race:function race(t){var i=this,u=ci.f(i),m=u.reject,h=perform((function(){var h=aCallable(i.resolve);iterate(t,(function(t){x(h,i,t).then(u.resolve,m)}))}));return h.error&&m(h.value),u.promise}}),_export({target:"Promise",stat:!0,forced:oi.CONSTRUCTOR},{reject:function reject(t){var i=ci.f(this);return x(i.reject,void 0,t),i.promise}});var promiseResolve=function(t,i){if(anObject(t),j(i)&&i.constructor===t)return i;var u=ci.f(t);return(0,u.resolve)(i),u.promise},Ni=oi.CONSTRUCTOR,xi=getBuiltIn("Promise"),Oi=!Ni;_export({target:"Promise",stat:!0,forced:!0},{resolve:function resolve(t){return promiseResolve(Oi&&this===xi?Ja:this,t)}}),_export({target:"Promise",stat:!0},{allSettled:function allSettled(t){var i=this,u=ci.f(i),m=u.resolve,h=u.reject,v=perform((function(){var u=aCallable(i.resolve),h=[],v=0,M=1;iterate(t,(function(t){var I=v++,S=!1;M++,x(u,i,t).then((function(t){S||(S=!0,h[I]={status:"fulfilled",value:t},--M||m(h))}),(function(t){S||(S=!0,h[I]={status:"rejected",reason:t},--M||m(h))}))})),--M||m(h)}));return v.error&&h(v.value),u.promise}});var Pi="No one promise resolved";_export({target:"Promise",stat:!0},{any:function any(t){var i=this,u=getBuiltIn("AggregateError"),m=ci.f(i),h=m.resolve,v=m.reject,M=perform((function(){var m=aCallable(i.resolve),M=[],I=0,S=1,T=!1;iterate(t,(function(t){var C=I++,E=!1;S++,x(m,i,t).then((function(t){E||T||(T=!0,h(t))}),(function(t){E||T||(E=!0,M[C]=t,--S||v(new u(M,Pi)))}))})),--S||v(new u(M,Pi))}));return M.error&&v(M.value),m.promise}});var Li=Ja&&Ja.prototype,Vi=!!Ja&&fails((function(){Li.finally.call({then:function(){}},(function(){}))}));_export({target:"Promise",proto:!0,real:!0,forced:Vi},{finally:function(t){var i=speciesConstructor(this,getBuiltIn("Promise")),u=isCallable(t);return this.then(u?function(u){return promiseResolve(i,t()).then((function(){return u}))}:t,u?function(u){return promiseResolve(i,t()).then((function(){throw u}))}:t)}});var Ui=R("".charAt),Di=R("".charCodeAt),Bi=R("".slice),createMethod$3=function(t){return function(i,u){var m,h,v=toString(requireObjectCoercible(i)),M=toIntegerOrInfinity(u),I=v.length;return M<0||M>=I?t?"":void 0:(m=Di(v,M))<55296||m>56319||M+1===I||(h=Di(v,M+1))<56320||h>57343?t?Ui(v,M):m:t?Bi(v,M,M+2):h-56320+(m-55296<<10)+65536}},qi={codeAt:createMethod$3(!1),charAt:createMethod$3(!0)},Fi=qi.charAt,Gi="String Iterator",Hi=ar.set,ji=ar.getterFor(Gi);iteratorDefine(String,"String",(function(t){Hi(this,{type:Gi,string:toString(t),index:0})}),(function next(){var t,i=ji(this),u=i.string,m=i.index;return m>=u.length?{value:void 0,done:!0}:(t=Fi(u,m),i.index+=t.length,{value:t,done:!1})}));var $i=$.Promise;_export({target:"Promise",stat:!0,forced:!0},{try:function(t){var i=ci.f(this),u=perform(t);return(u.error?i.reject:i.resolve)(u.value),i.promise}});var zi=$i,Wi=L.f,Ki=R(Wi),Yi=R([].push),createMethod$2=function(t){return function(i){for(var u,m=toIndexedObject(i),h=lt(m),v=h.length,M=0,I=[];v>M;)u=h[M++],w&&!Ki(m,u)||Yi(I,t?[u,m[u]]:m[u]);return I}},Qi={entries:createMethod$2(!0),values:createMethod$2(!1)},Ji=Qi.values;_export({target:"Object",stat:!0},{values:function values(t){return Ji(t)}});var Xi=$.Object.values,Zi=Date,eo=R(Zi.prototype.getTime);_export({target:"Date",stat:!0},{now:function now(){return eo(new Zi)}});var to=$.Date.now,ro=wellKnownSymbol("isConcatSpreadable"),no=X>=51||!fails((function(){var t=[];return t[ro]=!1,t.concat()[0]!==t})),ao=arrayMethodHasSpeciesSupport("concat"),isConcatSpreadable=function(t){if(!j(t))return!1;var i=t[ro];return void 0!==i?!!i:Fr(t)};_export({target:"Array",proto:!0,arity:1,forced:!no||!ao},{concat:function concat(t){var i,u,m,h,v,M=toObject(this),I=arraySpeciesCreate(M,0),S=0;for(i=-1,m=arguments.length;i<m;i++)if(isConcatSpreadable(v=-1===i?M:arguments[i]))for(h=lengthOfArrayLike(v),doesNotExceedSafeInteger(S+h),u=0;u<h;u++,S++)u in v&&createProperty(I,S,v[u]);else doesNotExceedSafeInteger(S+1),createProperty(I,S++,v);return I.length=S,I}});var io=entryVirtual("Array").concat,oo=Array.prototype,concat=function(t){var i=t.concat;return t===oo||z(oo,t)&&i===oo.concat?io:i},so=/MSIE .\./.test(W),co=h.Function,wrap$1=function(t){return so?function(i,u){var m=validateArgumentsLength(arguments.length,1)>2,h=isCallable(i)?i:co(i),v=m?St(arguments,2):void 0;return t(m?function(){T(h,this,v)}:h,u)}:t},lo={setTimeout:wrap$1(h.setTimeout),setInterval:wrap$1(h.setInterval)},uo=lo.setInterval;_export({global:!0,bind:!0,forced:h.setInterval!==uo},{setInterval:uo});var po=lo.setTimeout;_export({global:!0,bind:!0,forced:h.setTimeout!==po},{setTimeout:po});var mo=$.setTimeout,ho=createCommonjsModule((function(t){var i=Object.prototype.hasOwnProperty,u="~";function Events(){}function EE(t,i,u){this.fn=t,this.context=i,this.once=u||!1}function addListener(t,i,m,h,v){if("function"!=typeof m)throw new TypeError("The listener must be a function");var M=new EE(m,h||t,v),I=u?u+i:i;return t._events[I]?t._events[I].fn?t._events[I]=[t._events[I],M]:t._events[I].push(M):(t._events[I]=M,t._eventsCount++),t}function clearEvent(t,i){0==--t._eventsCount?t._events=new Events:delete t._events[i]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),(new Events).__proto__||(u=!1)),EventEmitter.prototype.eventNames=function eventNames(){var t,m,h=[];if(0===this._eventsCount)return h;for(m in t=this._events)i.call(t,m)&&h.push(u?m.slice(1):m);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(t)):h},EventEmitter.prototype.listeners=function listeners(t){var i=u?u+t:t,m=this._events[i];if(!m)return[];if(m.fn)return[m.fn];for(var h=0,v=m.length,M=new Array(v);h<v;h++)M[h]=m[h].fn;return M},EventEmitter.prototype.listenerCount=function listenerCount(t){var i=u?u+t:t,m=this._events[i];return m?m.fn?1:m.length:0},EventEmitter.prototype.emit=function emit(t,i,m,h,v,M){var I=u?u+t:t;if(!this._events[I])return!1;var S,T,C=this._events[I],E=arguments.length;if(C.fn){switch(C.once&&this.removeListener(t,C.fn,void 0,!0),E){case 1:return C.fn.call(C.context),!0;case 2:return C.fn.call(C.context,i),!0;case 3:return C.fn.call(C.context,i,m),!0;case 4:return C.fn.call(C.context,i,m,h),!0;case 5:return C.fn.call(C.context,i,m,h,v),!0;case 6:return C.fn.call(C.context,i,m,h,v,M),!0}for(T=1,S=new Array(E-1);T<E;T++)S[T-1]=arguments[T];C.fn.apply(C.context,S)}else{var A,k=C.length;for(T=0;T<k;T++)switch(C[T].once&&this.removeListener(t,C[T].fn,void 0,!0),E){case 1:C[T].fn.call(C[T].context);break;case 2:C[T].fn.call(C[T].context,i);break;case 3:C[T].fn.call(C[T].context,i,m);break;case 4:C[T].fn.call(C[T].context,i,m,h);break;default:if(!S)for(A=1,S=new Array(E-1);A<E;A++)S[A-1]=arguments[A];C[T].fn.apply(C[T].context,S)}}return!0},EventEmitter.prototype.on=function on(t,i,u){return addListener(this,t,i,u,!1)},EventEmitter.prototype.once=function once(t,i,u){return addListener(this,t,i,u,!0)},EventEmitter.prototype.removeListener=function removeListener(t,i,m,h){var v=u?u+t:t;if(!this._events[v])return this;if(!i)return clearEvent(this,v),this;var M=this._events[v];if(M.fn)M.fn!==i||h&&!M.once||m&&M.context!==m||clearEvent(this,v);else{for(var I=0,S=[],T=M.length;I<T;I++)(M[I].fn!==i||h&&!M[I].once||m&&M[I].context!==m)&&S.push(M[I]);S.length?this._events[v]=1===S.length?S[0]:S:clearEvent(this,v)}return this},EventEmitter.prototype.removeAllListeners=function removeAllListeners(t){var i;return t?(i=u?u+t:t,this._events[i]&&clearEvent(this,i)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=u,EventEmitter.EventEmitter=EventEmitter,t.exports=EventEmitter}));_export({global:!0},{globalThis:h});var go=h,vo=Array,fo=Math.max,arraySliceSimple=function(t,i,u){for(var m=lengthOfArrayLike(t),h=toAbsoluteIndex(i,m),v=toAbsoluteIndex(void 0===u?m:u,m),M=vo(fo(v-h,0)),I=0;h<v;h++,I++)createProperty(M,I,t[h]);return M.length=I,M},yo=qn.f,Mo="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Io={f:function getOwnPropertyNames(t){return Mo&&"Window"==classofRaw(t)?function(t){try{return yo(t)}catch(t){return arraySliceSimple(Mo)}}(t):yo(toIndexedObject(t))}},_o={f:wellKnownSymbol},So=He.f,wellKnownSymbolDefine=function(t){var i=$.Symbol||($.Symbol={});pe(i,t)||So(i,t,{value:_o.f(t)})},symbolDefineToPrimitive=function(){var t=getBuiltIn("Symbol"),i=t&&t.prototype,u=i&&i.valueOf,m=wellKnownSymbol("toPrimitive");i&&!i[m]&&defineBuiltIn(i,m,(function(t){return x(u,this)}),{arity:1})},To=tn.forEach,Co=sharedKey("hidden"),bo="Symbol",Eo=ar.set,Ao=ar.getterFor(bo),ko=Object.prototype,Ro=h.Symbol,wo=Ro&&Ro.prototype,No=h.TypeError,xo=h.QObject,Oo=Ee.f,Po=He.f,Lo=Io.f,Vo=L.f,Uo=R([].push),Do=le("symbols"),Bo=le("op-symbols"),qo=le("wks"),Fo=!xo||!xo.prototype||!xo.prototype.findChild,Go=w&&fails((function(){return 7!=gt(Po({},"a",{get:function(){return Po(this,"a",{value:7}).a}})).a}))?function(t,i,u){var m=Oo(ko,i);m&&delete ko[i],Po(t,i,u),m&&t!==ko&&Po(ko,i,m)}:Po,wrap=function(t,i){var u=Do[t]=gt(wo);return Eo(u,{type:bo,tag:t,description:i}),w||(u.description=i),u},Ho=function defineProperty(t,i,u){t===ko&&Ho(Bo,i,u),anObject(t);var m=toPropertyKey(i);return anObject(u),pe(Do,m)?(u.enumerable?(pe(t,Co)&&t[Co][m]&&(t[Co][m]=!1),u=gt(u,{enumerable:createPropertyDescriptor(0,!1)})):(pe(t,Co)||Po(t,Co,createPropertyDescriptor(1,{})),t[Co][m]=!0),Go(t,m,u)):Po(t,m,u)},jo=function defineProperties(t,i){anObject(t);var u=toIndexedObject(i),m=lt(u).concat($getOwnPropertySymbols(u));return To(m,(function(i){w&&!x($o,u,i)||Ho(t,i,u[i])})),t},$o=function propertyIsEnumerable(t){var i=toPropertyKey(t),u=x(Vo,this,i);return!(this===ko&&pe(Do,i)&&!pe(Bo,i))&&(!(u||!pe(this,i)||!pe(Do,i)||pe(this,Co)&&this[Co][i])||u)},zo=function getOwnPropertyDescriptor(t,i){var u=toIndexedObject(t),m=toPropertyKey(i);if(u!==ko||!pe(Do,m)||pe(Bo,m)){var h=Oo(u,m);return!h||!pe(Do,m)||pe(u,Co)&&u[Co][m]||(h.enumerable=!0),h}},Wo=function getOwnPropertyNames(t){var i=Lo(toIndexedObject(t)),u=[];return To(i,(function(t){pe(Do,t)||pe(it,t)||Uo(u,t)})),u},$getOwnPropertySymbols=function(t){var i=t===ko,u=Lo(i?Bo:toIndexedObject(t)),m=[];return To(u,(function(t){!pe(Do,t)||i&&!pe(ko,t)||Uo(m,Do[t])})),m};Z||(Ro=function Symbol(){if(z(wo,this))throw No("Symbol is not a constructor");var t=arguments.length&&void 0!==arguments[0]?toString(arguments[0]):void 0,i=uid(t),setter=function(t){this===ko&&x(setter,Bo,t),pe(this,Co)&&pe(this[Co],i)&&(this[Co][i]=!1),Go(this,i,createPropertyDescriptor(1,t))};return w&&Fo&&Go(ko,i,{configurable:!0,set:setter}),wrap(i,t)},wo=Ro.prototype,defineBuiltIn(wo,"toString",(function toString(){return Ao(this).tag})),defineBuiltIn(Ro,"withoutSetter",(function(t){return wrap(uid(t),t)})),L.f=$o,He.f=Ho,ut.f=jo,Ee.f=zo,qn.f=Io.f=Wo,Ot.f=$getOwnPropertySymbols,_o.f=function(t){return wrap(wellKnownSymbol(t),t)},w&&Po(wo,"description",{configurable:!0,get:function description(){return Ao(this).description}})),_export({global:!0,constructor:!0,wrap:!0,forced:!Z,sham:!Z},{Symbol:Ro}),To(lt(qo),(function(t){wellKnownSymbolDefine(t)})),_export({target:bo,stat:!0,forced:!Z},{useSetter:function(){Fo=!0},useSimple:function(){Fo=!1}}),_export({target:"Object",stat:!0,forced:!Z,sham:!w},{create:function create(t,i){return void 0===i?gt(t):jo(gt(t),i)},defineProperty:Ho,defineProperties:jo,getOwnPropertyDescriptor:zo}),_export({target:"Object",stat:!0,forced:!Z},{getOwnPropertyNames:Wo}),symbolDefineToPrimitive(),setToStringTag(Ro,bo),it[Co]=!0;var Ko=Z&&!!Symbol.for&&!!Symbol.keyFor,Yo=le("string-to-symbol-registry"),Qo=le("symbol-to-string-registry");_export({target:"Symbol",stat:!0,forced:!Ko},{for:function(t){var i=toString(t);if(pe(Yo,i))return Yo[i];var u=getBuiltIn("Symbol")(i);return Yo[i]=u,Qo[u]=i,u}});var Jo=le("symbol-to-string-registry");_export({target:"Symbol",stat:!0,forced:!Ko},{keyFor:function keyFor(t){if(!re(t))throw TypeError(tryToString(t)+" is not a symbol");if(pe(Jo,t))return Jo[t]}});var Xo=!Z||fails((function(){Ot.f(1)}));_export({target:"Object",stat:!0,forced:Xo},{getOwnPropertySymbols:function getOwnPropertySymbols(t){var i=Ot.f;return i?i(toObject(t)):[]}}),wellKnownSymbolDefine("asyncIterator"),wellKnownSymbolDefine("hasInstance"),wellKnownSymbolDefine("isConcatSpreadable"),wellKnownSymbolDefine("iterator"),wellKnownSymbolDefine("match"),wellKnownSymbolDefine("matchAll"),wellKnownSymbolDefine("replace"),wellKnownSymbolDefine("search"),wellKnownSymbolDefine("species"),wellKnownSymbolDefine("split"),wellKnownSymbolDefine("toPrimitive"),symbolDefineToPrimitive(),wellKnownSymbolDefine("toStringTag"),setToStringTag(getBuiltIn("Symbol"),"Symbol"),wellKnownSymbolDefine("unscopables"),setToStringTag(h.JSON,"JSON",!0);var Zo=$.Symbol;wellKnownSymbolDefine("asyncDispose"),wellKnownSymbolDefine("dispose"),wellKnownSymbolDefine("matcher"),wellKnownSymbolDefine("metadataKey"),wellKnownSymbolDefine("observable"),wellKnownSymbolDefine("metadata"),wellKnownSymbolDefine("patternMatch"),wellKnownSymbolDefine("replaceAll");var es=Zo,ts=fails((function(){mr(1)}));_export({target:"Object",stat:!0,forced:ts,sham:!lr},{getPrototypeOf:function getPrototypeOf(t){return mr(toObject(t))}});var rs=$.Object.getPrototypeOf,ns=R([].reverse),as=[1,2];_export({target:"Array",proto:!0,forced:String(as)===String(as.reverse())},{reverse:function reverse(){return Fr(this)&&(this.length=this.length),ns(this)}});var is=entryVirtual("Array").reverse,os=Array.prototype,reverse$1=function(t){var i=t.reverse;return t===os||z(os,t)&&i===os.reverse?is:i},ss=arrayMethodHasSpeciesSupport("slice"),cs=wellKnownSymbol("species"),ls=Array,ds=Math.max;_export({target:"Array",proto:!0,forced:!ss},{slice:function slice(t,i){var u,m,h,v=toIndexedObject(this),M=lengthOfArrayLike(v),I=toAbsoluteIndex(t,M),S=toAbsoluteIndex(void 0===i?M:i,M);if(Fr(v)&&(u=v.constructor,(Jr(u)&&(u===ls||Fr(u.prototype))||j(u)&&null===(u=u[cs]))&&(u=void 0),u===ls||void 0===u))return St(v,I,S);for(m=new(void 0===u?ls:u)(ds(S-I,0)),h=0;I<S;I++,h++)I in v&&createProperty(m,h,v[I]);return m.length=h,m}});var us=entryVirtual("Array").slice,ps=Array.prototype,slice=function(t){var i=t.slice;return t===ps||z(ps,t)&&i===ps.slice?us:i},ms=_o.f("iterator"),hs=tn.find,gs="find",vs=!0;gs in[]&&Array(1).find((function(){vs=!1})),_export({target:"Array",proto:!0,forced:vs},{find:function find(t){return hs(this,t,arguments.length>1?arguments[1]:void 0)}});var fs=entryVirtual("Array").find,ys=Array.prototype,find=function(t){var i=t.find;return t===ys||z(ys,t)&&i===ys.find?fs:i},Ms=at.includes,Is=fails((function(){return!Array(1).includes()}));_export({target:"Array",proto:!0,forced:Is},{includes:function includes(t){return Ms(this,t,arguments.length>1?arguments[1]:void 0)}});var _s=entryVirtual("Array").includes,Ss=wellKnownSymbol("match"),Ts=TypeError,notARegexp=function(t){if(function(t){var i;return j(t)&&(void 0!==(i=t[Ss])?!!i:"RegExp"==classofRaw(t))}(t))throw Ts("The method doesn't accept regular expressions");return t},Cs=wellKnownSymbol("match"),correctIsRegexpLogic=function(t){var i=/./;try{"/./"[t](i)}catch(u){try{return i[Cs]=!1,"/./"[t](i)}catch(t){}}return!1},bs=R("".indexOf);_export({target:"String",proto:!0,forced:!correctIsRegexpLogic("includes")},{includes:function includes(t){return!!~bs(toString(requireObjectCoercible(this)),toString(notARegexp(t)),arguments.length>1?arguments[1]:void 0)}});var Es=entryVirtual("String").includes,As=Array.prototype,ks=String.prototype,includes=function(t){var i=t.includes;return t===As||z(As,t)&&i===As.includes?_s:"string"==typeof t||t===ks||z(ks,t)&&i===ks.includes?Es:i},Rs=tn.map,ws=arrayMethodHasSpeciesSupport("map");_export({target:"Array",proto:!0,forced:!ws},{map:function map(t){return Rs(this,t,arguments.length>1?arguments[1]:void 0)}});var Ns=entryVirtual("Array").map,xs=Array.prototype,map$6=function(t){var i=t.map;return t===xs||z(xs,t)&&i===xs.map?Ns:i},Os=tn.filter,Ps=arrayMethodHasSpeciesSupport("filter");_export({target:"Array",proto:!0,forced:!Ps},{filter:function filter(t){return Os(this,t,arguments.length>1?arguments[1]:void 0)}});var Ls=entryVirtual("Array").filter,Vs=Array.prototype,filter=function(t){var i=t.filter;return t===Vs||z(Vs,t)&&i===Vs.filter?Ls:i},Us=createCommonjsModule((function(t,i){t.exports=function(){function _regeneratorRuntime(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},i=Object.prototype,u=i.hasOwnProperty,m="function"==typeof es?es:{},h=m.iterator||"@@iterator",v=m.asyncIterator||"@@asyncIterator",M=m.toStringTag||"@@toStringTag";function define(t,i,u){return Ye(t,i,{value:u,enumerable:!0,configurable:!0,writable:!0}),t[i]}try{define({},"")}catch(t){define=function define(t,i,u){return t[i]=u}}function wrap(t,i,u,m){var h=i&&i.prototype instanceof Generator?i:Generator,v=ft(h.prototype),M=new Context(m||[]);return v._invoke=function(t,i,u){var m="suspendedStart";return function(h,v){if("executing"===m)throw new Error("Generator is already running");if("completed"===m){if("throw"===h)throw v;return doneResult()}for(u.method=h,u.arg=v;;){var M=u.delegate;if(M){var S=maybeInvokeDelegate(M,u);if(S){if(S===I)continue;return S}}if("next"===u.method)u.sent=u._sent=u.arg;else if("throw"===u.method){if("suspendedStart"===m)throw m="completed",u.arg;u.dispatchException(u.arg)}else"return"===u.method&&u.abrupt("return",u.arg);m="executing";var T=tryCatch(t,i,u);if("normal"===T.type){if(m=u.done?"completed":"suspendedYield",T.arg===I)continue;return{value:T.arg,done:u.done}}"throw"===T.type&&(m="completed",u.method="throw",u.arg=T.arg)}}}(t,u,M),v}function tryCatch(t,i,u){try{return{type:"normal",arg:t.call(i,u)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var I={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var S={};define(S,h,(function(){return this}));var T=rs&&rs(rs(values([])));T&&T!==i&&u.call(T,h)&&(S=T);var C=GeneratorFunctionPrototype.prototype=Generator.prototype=ft(S);function defineIteratorMethods(t){var i;forEach$1(i=["next","throw","return"]).call(i,(function(i){define(t,i,(function(t){return this._invoke(i,t)}))}))}function AsyncIterator(t,i){function invoke(m,h,v,M){var I=tryCatch(t[m],t,h);if("throw"!==I.type){var S=I.arg,T=S.value;return T&&"object"==typeof T&&u.call(T,"__await")?i.resolve(T.__await).then((function(t){invoke("next",t,v,M)}),(function(t){invoke("throw",t,v,M)})):i.resolve(T).then((function(t){S.value=t,v(S)}),(function(t){return invoke("throw",t,v,M)}))}M(I.arg)}var m;this._invoke=function(t,u){function callInvokeWithMethodAndArg(){return new i((function(i,m){invoke(t,u,i,m)}))}return m=m?m.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,i){var u=t.iterator[i.method];if(void 0===u){if(i.delegate=null,"throw"===i.method){if(t.iterator.return&&(i.method="return",i.arg=void 0,maybeInvokeDelegate(t,i),"throw"===i.method))return I;i.method="throw",i.arg=new TypeError("The iterator does not provide a 'throw' method")}return I}var m=tryCatch(u,t.iterator,i.arg);if("throw"===m.type)return i.method="throw",i.arg=m.arg,i.delegate=null,I;var h=m.arg;return h?h.done?(i[t.resultName]=h.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=void 0),i.delegate=null,I):h:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,I)}function pushTryEntry(t){var i={tryLoc:t[0]};1 in t&&(i.catchLoc=t[1]),2 in t&&(i.finallyLoc=t[2],i.afterLoc=t[3]),this.tryEntries.push(i)}function resetTryEntry(t){var i=t.completion||{};i.type="normal",delete i.arg,t.completion=i}function Context(t){this.tryEntries=[{tryLoc:"root"}],forEach$1(t).call(t,pushTryEntry,this),this.reset(!0)}function values(t){if(t){var i=t[h];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var m=-1,v=function next(){for(;++m<t.length;)if(u.call(t,m))return next.value=t[m],next.done=!1,next;return next.value=void 0,next.done=!0,next};return v.next=v}}return{next:doneResult}}function doneResult(){return{value:void 0,done:!0}}return GeneratorFunction.prototype=GeneratorFunctionPrototype,define(C,"constructor",GeneratorFunctionPrototype),define(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,M,"GeneratorFunction"),t.isGeneratorFunction=function(t){var i="function"==typeof t&&t.constructor;return!!i&&(i===GeneratorFunction||"GeneratorFunction"===(i.displayName||i.name))},t.mark=function(t){return _t?_t(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,M,"GeneratorFunction")),t.prototype=ft(C),t},t.awrap=function(t){return{__await:t}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,v,(function(){return this})),t.AsyncIterator=AsyncIterator,t.async=function(i,u,m,h,v){void 0===v&&(v=zi);var M=new AsyncIterator(wrap(i,u,m,h),v);return t.isGeneratorFunction(u)?M:M.next().then((function(t){return t.done?t.value:M.next()}))},defineIteratorMethods(C),define(C,M,"Generator"),define(C,h,(function(){return this})),define(C,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var i=[];for(var u in t)i.push(u);return reverse$1(i).call(i),function next(){for(;i.length;){var u=i.pop();if(u in t)return next.value=u,next.done=!1,next}return next.done=!0,next}},t.values=values,Context.prototype={constructor:Context,reset:function reset(t){var i;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,forEach$1(i=this.tryEntries).call(i,resetTryEntry),!t)for(var m in this)"t"===m.charAt(0)&&u.call(this,m)&&!isNaN(+slice(m).call(m,1))&&(this[m]=void 0)},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function dispatchException(t){if(this.done)throw t;var i=this;function handle(u,m){return v.type="throw",v.arg=t,i.next=u,m&&(i.method="next",i.arg=void 0),!!m}for(var m=this.tryEntries.length-1;m>=0;--m){var h=this.tryEntries[m],v=h.completion;if("root"===h.tryLoc)return handle("end");if(h.tryLoc<=this.prev){var M=u.call(h,"catchLoc"),I=u.call(h,"finallyLoc");if(M&&I){if(this.prev<h.catchLoc)return handle(h.catchLoc,!0);if(this.prev<h.finallyLoc)return handle(h.finallyLoc)}else if(M){if(this.prev<h.catchLoc)return handle(h.catchLoc,!0)}else{if(!I)throw new Error("try statement without catch or finally");if(this.prev<h.finallyLoc)return handle(h.finallyLoc)}}}},abrupt:function abrupt(t,i){for(var m=this.tryEntries.length-1;m>=0;--m){var h=this.tryEntries[m];if(h.tryLoc<=this.prev&&u.call(h,"finallyLoc")&&this.prev<h.finallyLoc){var v=h;break}}v&&("break"===t||"continue"===t)&&v.tryLoc<=i&&i<=v.finallyLoc&&(v=null);var M=v?v.completion:{};return M.type=t,M.arg=i,v?(this.method="next",this.next=v.finallyLoc,I):this.complete(M)},complete:function complete(t,i){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&i&&(this.next=i),I},finish:function finish(t){for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i];if(u.finallyLoc===t)return this.complete(u.completion,u.afterLoc),resetTryEntry(u),I}},catch:function _catch(t){for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i];if(u.tryLoc===t){var m=u.completion;if("throw"===m.type){var h=m.arg;resetTryEntry(u)}return h}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,i,u){return this.delegate={iterator:values(t),resultName:i,nextLoc:u},"next"===this.method&&(this.arg=void 0),I}},t}function _typeof(t){return _typeof="function"==typeof es&&"symbol"==typeof ms?function(t){return typeof t}:function(t){return t&&"function"==typeof es&&t.constructor===es&&t!==es.prototype?"symbol":typeof t},_typeof(t)}function _classCallCheck(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,i){for(var u=0;u<i.length;u++){var m=i[u];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Ye(t,m.key,m)}}function _createClass(t,i,u){return i&&_defineProperties(t.prototype,i),u&&_defineProperties(t,u),Ye(t,"prototype",{writable:!1}),t}function __awaiter(t,i,u,m){function adopt(t){return t instanceof u?t:new u((function(i){i(t)}))}return new(u||(u=zi))((function(u,h){function fulfilled(t){try{step(m.next(t))}catch(t){h(t)}}function rejected(t){try{step(m.throw(t))}catch(t){h(t)}}function step(t){t.done?u(t.value):adopt(t.value).then(fulfilled,rejected)}step((m=m.apply(t,i||[])).next())}))}var t={isDataReportEnable:!0,maxSize:100,msgListMaxSize:1e3,cacheMaxSize:1e3,maxDelay:3e5,maxInterval:3e4,minInterval:1e4,timeout:5e3,autoStart:!0,loginFailIgnoreInterval:72e5},i=12,u=8e3,m=function emptyFn(){},h=function(){function Reporter(i){_classCallCheck(this,Reporter),this.isUploadEnable=!0,this.serverAllowUpload=!1,this.initConfigLoaded=!1,this.loading=!1,this.isDestroyed=!1,this.reportConfig=t,this.configPath="dispatcher/req",this.dataReportPath="statics/report/common/form",this.traceMsgCache={},this.reqRetryCount=0,this.highPriorityMsgList=[],this.msgList=[],this.lowPriorityMsgList=[],this.cacheMsgList=[],this.lastReportTime=to(),this.timer=null,this.endedAsyncMsgByModule={},this.lastFailLogin={},this.setConfig(i),this.reportConfig.isDataReportEnable&&this.reportConfig.autoStart&&this.initUploadConfig()}return _createClass(Reporter,[{key:"setConfig",value:function setConfig(t){var i=Dt({},this.reportConfig.common,t.common);this.reportConfig=Dt({},this.reportConfig,t),this.reportConfig.common=i,this.reportConfig.common.sdk_type||(this.reportConfig.common.sdk_type="im")}},{key:"reportImmediately",value:function reportImmediately(t,i){var u=this;this.reportConfig.isDataReportEnable&&this.reportConfig.request(t,Dt({dataType:"json",method:"POST",timeout:this.reportConfig.timeout},i)).catch((function(t){var i,m;null===(m=null===(i=u.reportConfig)||void 0===i?void 0:i.logger)||void 0===m||m.warn("Reporter immediately upload failed",t)}))}},{key:"report",value:function report(i,u){var m=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(m.priority||(m.priority=this.getEventPriority(i,u)),this.reportConfig.isDataReportEnable&&i){if("login"===i&&!1===u.succeed&&u.process_id){var h,v=u.extension&&find(h=u.extension).call(h,(function(t){return"TCP"===t.operation_type})),M=v&&v.target||"",I=u.process_id+M,S=this.lastFailLogin[I]||0;if(u.start_time-S<t.loginFailIgnoreInterval)return;this.lastFailLogin[I]=u.start_time}var T=to();"HIGH"===m.priority?this.highPriorityMsgList.push({module:i,msg:u,createTime:T}):"NORMAL"===m.priority?this.msgList.push({module:i,msg:u,createTime:T}):"LOW"===m.priority&&this.lowPriorityMsgList.push({module:i,msg:u,createTime:T}),this.highPriorityMsgList.length>this.reportConfig.msgListMaxSize&&this.highPriorityMsgList.shift(),this.msgList.length>this.reportConfig.msgListMaxSize&&this.msgList.shift(),this.lowPriorityMsgList.length>this.reportConfig.msgListMaxSize&&this.lowPriorityMsgList.shift(),this.doReport()}}},{key:"reportTraceStart",value:function reportTraceStart(t,i){if(this.reportConfig.isDataReportEnable&&t&&!this.traceMsgCache[t]){var u=Dt(Dt({start_time:to()},i),{extension:[]});this.traceMsgCache[t]=u}}},{key:"reportTraceUpdate",value:function reportTraceUpdate(t){}},{key:"reportTraceUpdateV2",value:function reportTraceUpdateV2(t,i,u){var m,h=this;if(this.reportConfig.isDataReportEnable&&this.traceMsgCache[t]){var v=this.traceMsgCache[t].extension,M=v.length,I=(new Date).getTime();0===M?i.duration=I-this.traceMsgCache[t].start_time:v[M-1].end_time?i.duration=I-v[M-1].end_time:i.duration=I-this.traceMsgCache[t].start_time,v.push(Dt({end_time:I},i));var S=v.length-1;(null==u?void 0:u.asyncParams)&&((m=this.traceMsgCache[t]).asyncPromiseArray||(m.asyncPromiseArray=[]),this.traceMsgCache[t].asyncPromiseArray.push(u.asyncParams.then((function(i){h.traceMsgCache[t]&&h.traceMsgCache[t].extension[S]&&Dt(h.traceMsgCache[t].extension[S],i)}))))}}},{key:"reportTraceEnd",value:function reportTraceEnd(t){var i,u,m=this,h=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.reportConfig.isDataReportEnable&&this.traceMsgCache[t])if("nos"!==t||!1===h){"boolean"==typeof h?this.traceMsgCache[t].succeed=!!h:this.traceMsgCache[t].state=h,this.traceMsgCache[t].duration=to()-this.traceMsgCache[t].start_time,forEach$1(i=this.traceMsgCache[t].extension).call(i,(function(t){delete t.end_time}));var v=this.traceMsgCache[t];if(this.traceMsgCache[t]=null,v.asyncPromiseArray){(u=this.endedAsyncMsgByModule)[t]||(u[t]=[]),this.endedAsyncMsgByModule[t].push(v);var M=function asyncCallback(){var i;m.endedAsyncMsgByModule[t]&&includes(i=m.endedAsyncMsgByModule[t]).call(i,v)&&(delete v.asyncPromiseArray,m.report(t,v,{priority:m.getEventPriority(t,v)}))};zi.all(v.asyncPromiseArray).then(M).catch(M)}else this.report(t,v,{priority:this.getEventPriority(t,v)})}else this.traceMsgCache[t]=null}},{key:"getEventPriority",value:function getEventPriority(t,i){if("exceptions"===t){if(0===i.action)return"HIGH";if(2===i.action)return"HIGH";if(1===i.action&&0!==i.exception_service)return"HIGH"}else{if("msgReceive"===t)return"LOW";if("nim_api_trace"===t)return"LOW"}return"NORMAL"}},{key:"reportTraceCancel",value:function reportTraceCancel(t){this.reportConfig.isDataReportEnable&&(this.endedAsyncMsgByModule[t]=[],this.traceMsgCache[t]=null)}},{key:"pause",value:function pause(){this.reportConfig.isDataReportEnable&&(this.isUploadEnable=!1)}},{key:"restore",value:function restore(){this.reportConfig.isDataReportEnable&&(this.isUploadEnable=!0,this.initConfigLoaded||this.initUploadConfig())}},{key:"destroy",value:function destroy(){var t,i=this;this.reportConfig.isDataReportEnable&&(forEach$1(t=Ht(this.traceMsgCache)).call(t,(function(t){i.reportTraceEnd(t,1)})),null!==this.timer&&clearTimeout(this.timer),this.setConfig=m,this.report=m,this.reportTraceStart=m,this.reportTraceUpdate=m,this.reportTraceEnd=m,this.pause=m,this.restore=m,this.destroy=m,this.reqRetryCount=0,this.cacheMsgList=[],this.traceMsgCache={},this.lowPriorityMsgList=[],this.msgList=[],this.highPriorityMsgList=[],this.reportConfig={},this.isDestroyed=!0)}},{key:"initUploadConfig",value:function initUploadConfig(){var t,m;return __awaiter(this,void 0,void 0,_regeneratorRuntime().mark((function _callee(){var h,v,M,I,S,T=this;return _regeneratorRuntime().wrap((function _callee$(C){for(var E;;)switch(C.prev=C.next){case 0:if(!this.loading){C.next=2;break}return C.abrupt("return");case 2:this.loading=!0,h=this.reportConfig.common||{},v=map$6(E=this.reportConfig.compassDataEndpoint.split(",")).call(E,(function(t){var i;return concat(i="".concat(t,"/")).call(i,T.configPath)})),M=_regeneratorRuntime().mark((function _loop(M){return _regeneratorRuntime().wrap((function _loop$(I){for(;;)switch(I.prev=I.next){case 0:if(!T.initConfigLoaded&&!T.isDestroyed){I.next=2;break}return I.abrupt("return","break");case 2:return I.prev=2,I.next=5,T.reportConfig.request(v[M],{method:"GET",dataType:"json",params:{deviceId:h.dev_id,sdkVer:h.sdk_ver,platform:h.platform,hostEnv:h.host_env,appkey:h.app_key},timeout:T.reportConfig.timeout}).then((function(t){var i,u;if(!T.isDestroyed){if(200===t.status&&t.data&&200===t.data.code){T.initConfigLoaded=!0;var m=t.data.data||{};T.reportConfig.maxSize=m.maxSize>1e3?1e3:m.maxSize,T.reportConfig.maxInterval=m.maxInterval>1e4?1e4:m.maxInterval,T.reportConfig.maxInterval=m.maxInterval<10?10:m.maxInterval,T.reportConfig.minInterval=m.minInterval<2?2:m.minInterval,T.reportConfig.maxDelay=m.maxDelay||300,T.reportConfig.maxInterval=1e3*T.reportConfig.maxInterval,T.reportConfig.minInterval=1e3*T.reportConfig.minInterval,T.reportConfig.maxDelay=1e3*T.reportConfig.maxDelay,m.endpoint?T.dataReportEndpoint=m.endpoint:T.dataReportEndpoint=v[M],T.serverAllowUpload=!0,T.loading=!1,T.reportHeartBeat()}else 200===t.status&&(T.initConfigLoaded=!0);null===(u=null===(i=T.reportConfig)||void 0===i?void 0:i.logger)||void 0===u||u.log("Get reporter upload config success")}})).catch((function(t){var m,h;T.isDestroyed||(T.loading=!1,null===(h=null===(m=T.reportConfig)||void 0===m?void 0:m.logger)||void 0===h||h.error("Get reporter upload config failed",t),T.reqRetryCount<i&&(T.reqRetryCount++,mo((function(){T.isDestroyed||T.initUploadConfig()}),u)))}));case 5:I.next=14;break;case 7:if(I.prev=7,I.t0=I.catch(2),!T.isDestroyed){I.next=11;break}return I.abrupt("return",{v:void 0});case 11:T.loading=!1,null===(m=null===(t=T.reportConfig)||void 0===t?void 0:t.logger)||void 0===m||m.error("Exec reporter request failed",I.t0),T.reqRetryCount<i&&(T.reqRetryCount++,mo((function(){T.isDestroyed||T.initUploadConfig()}),u));case 14:case"end":return I.stop()}}),_loop,null,[[2,7]])})),I=0;case 7:if(!(I<v.length)){C.next=17;break}return C.delegateYield(M(I),"t0",9);case 9:if("break"!==(S=C.t0)){C.next=12;break}return C.abrupt("break",17);case 12:if("object"!==_typeof(S)){C.next=14;break}return C.abrupt("return",S.v);case 14:I++,C.next=7;break;case 17:case"end":return C.stop()}}),_callee,this)})))}},{key:"reportHeartBeat",value:function reportHeartBeat(){var t=this;this.isDestroyed||(this.timer=mo((function(){t.reportHeartBeat()}),this.reportConfig.minInterval),this.doReport())}},{key:"doReport",value:function doReport(){if(!this.isDestroyed){var t=this.highPriorityMsgList.length+this.msgList.length+this.lowPriorityMsgList.length+this.cacheMsgList.length>2*this.reportConfig.maxSize?this.reportConfig.minInterval:this.reportConfig.maxInterval;to()-this.lastReportTime>=t&&this.upload()}}},{key:"getUploadMsg",value:function getUploadMsg(){var t,i,u,m,h,v,M=this,I={},S=to();this.highPriorityMsgList=filter(t=this.highPriorityMsgList).call(t,(function(t){return S-t.createTime<M.reportConfig.maxDelay})),this.msgList=filter(i=this.msgList).call(i,(function(t){return S-t.createTime<M.reportConfig.maxDelay})),this.lowPriorityMsgList=filter(u=this.lowPriorityMsgList).call(u,(function(t){return S-t.createTime<M.reportConfig.maxDelay})),this.cacheMsgList=filter(m=this.cacheMsgList).call(m,(function(t){return S-t.createTime<M.reportConfig.maxDelay}));var T=slice(h=this.highPriorityMsgList).call(h,0,this.reportConfig.maxSize);if(this.highPriorityMsgList=slice(v=this.highPriorityMsgList).call(v,T.length),T.length<this.reportConfig.maxSize){var C,E,A=this.reportConfig.maxSize-T.length;T=concat(T).call(T,slice(C=this.msgList).call(C,0,A)),this.msgList=slice(E=this.msgList).call(E,A)}if(T.length<this.reportConfig.maxSize){var k,R,w=this.reportConfig.maxSize-T.length;T=concat(T).call(T,slice(k=this.lowPriorityMsgList).call(k,0,w)),this.lowPriorityMsgList=slice(R=this.lowPriorityMsgList).call(R,w)}if(T.length<this.reportConfig.maxSize){var N,x,O=this.reportConfig.maxSize-T.length;T=concat(T).call(T,slice(N=this.cacheMsgList).call(N,0,O)),this.cacheMsgList=slice(x=this.cacheMsgList).call(x,O)}return forEach$1(T).call(T,(function(t){I[t.module]?I[t.module].push(t.msg):I[t.module]=[t.msg]})),{uploadMsgArr:T,uploadMsg:I}}},{key:"upload",value:function upload(){var t,i,u=this;if(this.isUploadEnable&&this.serverAllowUpload&&!(this.lastReportTime&&to()-this.lastReportTime<this.reportConfig.minInterval)){var m=this.getUploadMsg(),h=m.uploadMsgArr,v=m.uploadMsg;if(h.length){this.lastReportTime=to();try{var M,I=concat(M="".concat(this.dataReportEndpoint,"/")).call(M,this.dataReportPath);this.reportConfig.request(I,{dataType:"json",method:"POST",data:{common:this.reportConfig.common,event:v},headers:{sdktype:"im"},timeout:this.reportConfig.timeout}).catch((function(t){var i,m,v,M;u.cacheMsgList=slice(i=concat(m=u.cacheMsgList).call(m,h)).call(i,0,u.reportConfig.cacheMaxSize),null===(M=null===(v=u.reportConfig)||void 0===v?void 0:v.logger)||void 0===M||M.warn("Reporter upload failed",t)}))}catch(u){null===(i=null===(t=this.reportConfig)||void 0===t?void 0:t.logger)||void 0===i||i.warn("Exec reporter request failed",u)}clearTimeout(this.timer),this.reportHeartBeat()}}}}]),Reporter}();return h}()})),Ds=entryVirtual("Array").values,Bs=Array.prototype,qs={DOMTokenList:!0,NodeList:!0},values=function(t){var i=t.values;return t===Bs||z(Bs,t)&&i===Bs.values||pe(qs,Tr(t))?Ds:i},Fs=at.indexOf,Gs=R([].indexOf),Hs=!!Gs&&1/Gs([1],1,-0)<0,js=arrayMethodIsStrict("indexOf");_export({target:"Array",proto:!0,forced:Hs||!js},{indexOf:function indexOf(t){var i=arguments.length>1?arguments[1]:void 0;return Hs?Gs(this,t,i)||0:Fs(this,t,i)}});var $s=entryVirtual("Array").indexOf,zs=Array.prototype,indexOf=function(t){var i=t.indexOf;return t===zs||z(zs,t)&&i===zs.indexOf?$s:i},Ws=tn.every,Ks=arrayMethodIsStrict("every");_export({target:"Array",proto:!0,forced:!Ks},{every:function every(t){return Ws(this,t,arguments.length>1?arguments[1]:void 0)}});var Ys=entryVirtual("Array").every,Qs=Array.prototype,every=function(t){var i=t.every;return t===Qs||z(Qs,t)&&i===Qs.every?Ys:i};var Js=fails((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),Xs=Object.isExtensible,Zs=fails((function(){Xs(1)}))||Js?function isExtensible(t){return!!j(t)&&((!Js||"ArrayBuffer"!=classofRaw(t))&&(!Xs||Xs(t)))}:Xs,ec=!fails((function(){return Object.isExtensible(Object.preventExtensions({}))})),tc=createCommonjsModule((function(t){var i=He.f,u=!1,m=uid("meta"),h=0,setMetadata=function(t){i(t,m,{value:{objectID:"O"+h++,weakData:{}}})},v=t.exports={enable:function(){v.enable=function(){},u=!0;var t=qn.f,i=R([].splice),h={};h[m]=1,t(h).length&&(qn.f=function(u){for(var h=t(u),v=0,M=h.length;v<M;v++)if(h[v]===m){i(h,v,1);break}return h},_export({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Io.f}))},fastKey:function(t,i){if(!j(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!pe(t,m)){if(!Zs(t))return"F";if(!i)return"E";setMetadata(t)}return t[m].objectID},getWeakData:function(t,i){if(!pe(t,m)){if(!Zs(t))return!0;if(!i)return!1;setMetadata(t)}return t[m].weakData},onFreeze:function(t){return ec&&u&&Zs(t)&&!pe(t,m)&&setMetadata(t),t}};it[m]=!0})),rc=He.f,nc=tn.forEach,ac=ar.set,ic=ar.getterFor,collection=function(t,i,u){var m,v=-1!==t.indexOf("Map"),M=-1!==t.indexOf("Weak"),I=v?"set":"add",S=h[t],T=S&&S.prototype,C={};if(w&&isCallable(S)&&(M||T.forEach&&!fails((function(){(new S).entries().next()})))){var E=(m=i((function(i,u){ac(anInstance(i,E),{type:t,collection:new S}),null!=u&&iterate(u,i[I],{that:i,AS_ENTRIES:v})}))).prototype,A=ic(t);nc(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(t){var i="add"==t||"set"==t;!(t in T)||M&&"clear"==t||je(E,t,(function(u,m){var h=A(this).collection;if(!i&&M&&!j(u))return"get"==t&&void 0;var v=h[t](0===u?0:u,m);return i?this:v}))})),M||rc(E,"size",{configurable:!0,get:function(){return A(this).collection.size}})}else m=u.getConstructor(i,t,v,I),tc.enable();return setToStringTag(m,t,!1,!0),C[t]=m,_export({global:!0,forced:!0},C),M||u.setStrong(m,t,v),m},defineBuiltIns=function(t,i,u){for(var m in i)u&&u.unsafe&&t[m]?t[m]=i[m]:defineBuiltIn(t,m,i[m],u);return t},oc=He.f,sc=tc.fastKey,cc=ar.set,lc=ar.getterFor,dc={getConstructor:function(t,i,u,m){var h=t((function(t,h){anInstance(t,v),cc(t,{type:i,index:gt(null),first:void 0,last:void 0,size:0}),w||(t.size=0),isNullOrUndefined(h)||iterate(h,t[m],{that:t,AS_ENTRIES:u})})),v=h.prototype,M=lc(i),define=function(t,i,u){var m,h,v=M(t),I=getEntry(t,i);return I?I.value=u:(v.last=I={index:h=sc(i,!0),key:i,value:u,previous:m=v.last,next:void 0,removed:!1},v.first||(v.first=I),m&&(m.next=I),w?v.size++:t.size++,"F"!==h&&(v.index[h]=I)),t},getEntry=function(t,i){var u,m=M(t),h=sc(i);if("F"!==h)return m.index[h];for(u=m.first;u;u=u.next)if(u.key==i)return u};return defineBuiltIns(v,{clear:function clear(){for(var t=M(this),i=t.index,u=t.first;u;)u.removed=!0,u.previous&&(u.previous=u.previous.next=void 0),delete i[u.index],u=u.next;t.first=t.last=void 0,w?t.size=0:this.size=0},delete:function(t){var i=this,u=M(i),m=getEntry(i,t);if(m){var h=m.next,v=m.previous;delete u.index[m.index],m.removed=!0,v&&(v.next=h),h&&(h.previous=v),u.first==m&&(u.first=h),u.last==m&&(u.last=v),w?u.size--:i.size--}return!!m},forEach:function forEach(t){for(var i,u=M(this),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);i=i?i.next:u.first;)for(m(i.value,i.key,this);i&&i.removed;)i=i.previous},has:function has(t){return!!getEntry(this,t)}}),defineBuiltIns(v,u?{get:function get(t){var i=getEntry(this,t);return i&&i.value},set:function set(t,i){return define(this,0===t?0:t,i)}}:{add:function add(t){return define(this,t=0===t?0:t,t)}}),w&&oc(v,"size",{get:function(){return M(this).size}}),h},setStrong:function(t,i,u){var m=i+" Iterator",h=lc(i),v=lc(m);iteratorDefine(t,i,(function(t,i){cc(this,{type:m,target:t,state:h(t),kind:i,last:void 0})}),(function(){for(var t=v(this),i=t.kind,u=t.last;u&&u.removed;)u=u.previous;return t.target&&(t.last=u=u?u.next:t.state.first)?"keys"==i?{value:u.key,done:!1}:"values"==i?{value:u.value,done:!1}:{value:[u.key,u.value],done:!1}:(t.target=void 0,{value:void 0,done:!0})}),u?"entries":"values",!u,!0),setSpecies(i)}};collection("Map",(function(t){return function Map(){return t(this,arguments.length?arguments[0]:void 0)}}),dc);var uc=$.Map,pc=[].push,mc=function from(t){var i,u,m,h,v=arguments.length,M=v>1?arguments[1]:void 0;return aConstructor(this),(i=void 0!==M)&&aCallable(M),isNullOrUndefined(t)?new this:(u=[],i?(m=0,h=functionBindContext(M,v>2?arguments[2]:void 0),iterate(t,(function(t){x(pc,u,h(t,m++))}))):iterate(t,pc,{that:u}),new this(u))};_export({target:"Map",stat:!0,forced:!0},{from:mc});var hc=function of(){return new this(St(arguments))};_export({target:"Map",stat:!0,forced:!0},{of:hc});var gc=function deleteAll(){for(var t,i=anObject(this),u=aCallable(i.delete),m=!0,h=0,v=arguments.length;h<v;h++)t=x(u,i,arguments[h]),m=m&&t;return!!m};_export({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:gc});_export({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function emplace(t,i){var u,m,h=anObject(this),v=aCallable(h.get),M=aCallable(h.has),I=aCallable(h.set);return x(M,h,t)?(u=x(v,h,t),"update"in i&&(u=i.update(u,t,h),x(I,h,t,u)),u):(m=i.insert(t,h),x(I,h,t,m),m)}});var vc=getIterator;_export({target:"Map",proto:!0,real:!0,forced:!0},{every:function every(t){var i=anObject(this),u=vc(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);return!iterate(u,(function(t,u,h){if(!m(u,t,i))return h()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}}),_export({target:"Map",proto:!0,real:!0,forced:!0},{filter:function filter(t){var i=anObject(this),u=vc(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0),h=new(speciesConstructor(i,getBuiltIn("Map"))),v=aCallable(h.set);return iterate(u,(function(t,u){m(u,t,i)&&x(v,h,t,u)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),h}}),_export({target:"Map",proto:!0,real:!0,forced:!0},{find:function find(t){var i=anObject(this),u=vc(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);return iterate(u,(function(t,u,h){if(m(u,t,i))return h(u)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}}),_export({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function findKey(t){var i=anObject(this),u=vc(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);return iterate(u,(function(t,u,h){if(m(u,t,i))return h(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var fc=R([].push);_export({target:"Map",stat:!0,forced:!0},{groupBy:function groupBy(t,i){aCallable(i);var u=getIterator(t),m=new this,h=aCallable(m.has),v=aCallable(m.get),M=aCallable(m.set);return iterate(u,(function(t){var u=i(t);x(h,m,u)?fc(x(v,m,u),t):x(M,m,u,[t])}),{IS_ITERATOR:!0}),m}});_export({target:"Map",proto:!0,real:!0,forced:!0},{includes:function includes(t){return iterate(vc(anObject(this)),(function(i,u,m){if((h=u)===(v=t)||h!=h&&v!=v)return m();var h,v}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}}),_export({target:"Map",stat:!0,forced:!0},{keyBy:function keyBy(t,i){var u=new this;aCallable(i);var m=aCallable(u.set);return iterate(t,(function(t){x(m,u,i(t),t)})),u}}),_export({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function keyOf(t){return iterate(vc(anObject(this)),(function(i,u,m){if(u===t)return m(i)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}}),_export({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function mapKeys(t){var i=anObject(this),u=vc(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0),h=new(speciesConstructor(i,getBuiltIn("Map"))),v=aCallable(h.set);return iterate(u,(function(t,u){x(v,h,m(u,t,i),u)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),h}}),_export({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function mapValues(t){var i=anObject(this),u=vc(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0),h=new(speciesConstructor(i,getBuiltIn("Map"))),v=aCallable(h.set);return iterate(u,(function(t,u){x(v,h,t,m(u,t,i))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),h}}),_export({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function merge(t){for(var i=anObject(this),u=aCallable(i.set),m=arguments.length,h=0;h<m;)iterate(arguments[h++],u,{that:i,AS_ENTRIES:!0});return i}});var yc=TypeError;_export({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function reduce(t){var i=anObject(this),u=vc(i),m=arguments.length<2,h=m?void 0:arguments[1];if(aCallable(t),iterate(u,(function(u,v){m?(m=!1,h=v):h=t(h,v,u,i)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),m)throw yc("Reduce of empty map with no initial value");return h}}),_export({target:"Map",proto:!0,real:!0,forced:!0},{some:function some(t){var i=anObject(this),u=vc(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);return iterate(u,(function(t,u,h){if(m(u,t,i))return h()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Mc=TypeError;_export({target:"Map",proto:!0,real:!0,forced:!0},{update:function update(t,i){var u=anObject(this),m=aCallable(u.get),h=aCallable(u.has),v=aCallable(u.set),M=arguments.length;aCallable(i);var I=x(h,u,t);if(!I&&M<3)throw Mc("Updating absent value");var S=I?x(m,u,t):aCallable(M>2?arguments[2]:void 0)(t,u);return x(v,u,t,i(S,t,u)),u}});var Ic=TypeError,_c=function upsert(t,i){var u,m=anObject(this),h=aCallable(m.get),v=aCallable(m.has),M=aCallable(m.set),I=arguments.length>2?arguments[2]:void 0;if(!isCallable(i)&&!isCallable(I))throw Ic("At least one callback required");return x(v,m,t)?(u=x(h,m,t),isCallable(i)&&(u=i(u),x(M,m,t,u))):isCallable(I)&&(u=I(),x(M,m,t,u)),u};_export({target:"Map",proto:!0,real:!0,forced:!0},{upsert:_c}),_export({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:_c});var Sc=uc,Tc=createCommonjsModule((function(t){function _getPrototypeOf(i){var u;return t.exports=_getPrototypeOf=_t?bind$1(u=rs).call(u):function _getPrototypeOf(t){return t.__proto__||rs(t)},t.exports.__esModule=!0,t.exports.default=t.exports,_getPrototypeOf(i)}t.exports=_getPrototypeOf,t.exports.__esModule=!0,t.exports.default=t.exports})),Cc=createCommonjsModule((function(t){t.exports=function _isNativeFunction(t){var i;return-1!==indexOf(i=Function.toString.call(t)).call(i,"[native code]")},t.exports.__esModule=!0,t.exports.default=t.exports})),bc=getBuiltIn("Reflect","construct"),Ec=Object.prototype,Ac=[].push,kc=fails((function(){function F(){}return!(bc((function(){}),[],F)instanceof F)})),Rc=!fails((function(){bc((function(){}))})),wc=kc||Rc;_export({target:"Reflect",stat:!0,forced:wc,sham:wc},{construct:function construct(t,i){aConstructor(t),anObject(i);var u=arguments.length<3?t:aConstructor(arguments[2]);if(Rc&&!kc)return bc(t,i,u);if(t==u){switch(i.length){case 0:return new t;case 1:return new t(i[0]);case 2:return new t(i[0],i[1]);case 3:return new t(i[0],i[1],i[2]);case 4:return new t(i[0],i[1],i[2],i[3])}var m=[null];return T(Ac,m,i),new(T(At,t,m))}var h=u.prototype,v=gt(j(h)?h:Ec),M=T(t,v,i);return j(M)?M:v}});var Nc=$.Reflect.construct,xc=createCommonjsModule((function(t){t.exports=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Nc)return!1;if(Nc.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Nc(Boolean,[],(function(){}))),!0}catch(t){return!1}},t.exports.__esModule=!0,t.exports.default=t.exports})),Oc=createCommonjsModule((function(t){function _construct(i,u,m){var h;xc()?(t.exports=_construct=bind$1(h=Nc).call(h),t.exports.__esModule=!0,t.exports.default=t.exports):(t.exports=_construct=function _construct(t,i,u){var m=[null];m.push.apply(m,i);var h=new(bind$1(Function).apply(t,m));return u&&wt(h,u.prototype),h},t.exports.__esModule=!0,t.exports.default=t.exports);return _construct.apply(null,arguments)}t.exports=_construct,t.exports.__esModule=!0,t.exports.default=t.exports})),Pc=createCommonjsModule((function(t){function _wrapNativeSuper(i){var u="function"==typeof Sc?new Sc:void 0;return t.exports=_wrapNativeSuper=function _wrapNativeSuper(t){if(null===t||!Cc(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==u){if(u.has(t))return u.get(t);u.set(t,Wrapper)}function Wrapper(){return Oc(t,arguments,Tc(this).constructor)}return Wrapper.prototype=ft(t.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),wt(Wrapper,t)},t.exports.__esModule=!0,t.exports.default=t.exports,_wrapNativeSuper(i)}t.exports=_wrapNativeSuper,t.exports.__esModule=!0,t.exports.default=t.exports})),Lc=getDefaultExportFromCjs(Pc),Vc=TypeError,createMethod$1=function(t){return function(i,u,m,h){aCallable(u);var v=toObject(i),M=q(v),I=lengthOfArrayLike(v),S=t?I-1:0,T=t?-1:1;if(m<2)for(;;){if(S in M){h=M[S],S+=T;break}if(S+=T,t?S<0:I<=S)throw Vc("Reduce of empty array with no initial value")}for(;t?S>=0:I>S;S+=T)S in M&&(h=u(h,M[S],S,v));return h}},Uc={left:createMethod$1(!1),right:createMethod$1(!0)}.left,Dc=arrayMethodIsStrict("reduce");_export({target:"Array",proto:!0,forced:!Dc||!ua&&X>79&&X<83},{reduce:function reduce(t){var i=arguments.length;return Uc(this,t,i,i>1?arguments[1]:void 0)}});var Bc,qc,Fc,Gc,Hc,jc,$c,zc,Wc,Kc,Yc,Qc,Jc,Xc,Zc,el,tl,rl,nl,al,il,ol,sl,cl,ll,dl,ul,pl,ml,hl,gl,vl,fl,yl,Ml,Il,_l,Sl,Tl,Cl,bl,El,Al,kl,Rl,wl,Nl,xl,Ol,Pl,Ll,Vl,Ul,Dl,Bl,ql,Fl,Gl=entryVirtual("Array").reduce,Hl=Array.prototype,reduce=function(t){var i=t.reduce;return t===Hl||z(Hl,t)&&i===Hl.reduce?Gl:i};!function(t){t[t.V2NIM_DATA_SYNC_TYPE_LEVEL_FULL=0]="V2NIM_DATA_SYNC_TYPE_LEVEL_FULL",t[t.V2NIM_DATA_SYNC_TYPE_LEVEL_BASIC=1]="V2NIM_DATA_SYNC_TYPE_LEVEL_BASIC"}(Bc||(Bc={})),function(t){t[t.V2NIM_DATA_SYNC_TYPE_MAIN=1]="V2NIM_DATA_SYNC_TYPE_MAIN",t[t.V2NIM_DATA_SYNC_TYPE_TEAM_MEMBER=2]="V2NIM_DATA_SYNC_TYPE_TEAM_MEMBER",t[t.V2NIM_DATA_SYNC_TYPE_SUPER_TEAM_MEMBER=3]="V2NIM_DATA_SYNC_TYPE_SUPER_TEAM_MEMBER"}(qc||(qc={})),function(t){t[t.V2NIM_DATA_SYNC_STATE_WAITING=1]="V2NIM_DATA_SYNC_STATE_WAITING",t[t.V2NIM_DATA_SYNC_STATE_SYNCING=2]="V2NIM_DATA_SYNC_STATE_SYNCING",t[t.V2NIM_DATA_SYNC_STATE_COMPLETED=3]="V2NIM_DATA_SYNC_STATE_COMPLETED"}(Fc||(Fc={})),function(t){t[t.V2NIM_CONVERSATION_TYPE_UNKNOWN=0]="V2NIM_CONVERSATION_TYPE_UNKNOWN",t[t.V2NIM_CONVERSATION_TYPE_P2P=1]="V2NIM_CONVERSATION_TYPE_P2P",t[t.V2NIM_CONVERSATION_TYPE_TEAM=2]="V2NIM_CONVERSATION_TYPE_TEAM",t[t.V2NIM_CONVERSATION_TYPE_SUPER_TEAM=3]="V2NIM_CONVERSATION_TYPE_SUPER_TEAM"}(Gc||(Gc={})),function(t){t[t.V2NIM_MESSAGE_STATUS_DEFAULT=0]="V2NIM_MESSAGE_STATUS_DEFAULT",t[t.V2NIM_MESSAGE_STATUS_REVOKE=1]="V2NIM_MESSAGE_STATUS_REVOKE",t[t.V2NIM_MESSAGE_STATUS_BACKFILL=2]="V2NIM_MESSAGE_STATUS_BACKFILL"}(Hc||(Hc={})),function(t){t[t.V2NIM_FRIEND_MODE_TYPE_ADD=1]="V2NIM_FRIEND_MODE_TYPE_ADD",t[t.V2NIM_FRIEND_MODE_TYPE_APPLY=2]="V2NIM_FRIEND_MODE_TYPE_APPLY"}(jc||(jc={})),function(t){t[t.V2NIM_FRIEND_ADD_APPLICATION_TYPE_LEGACY=0]="V2NIM_FRIEND_ADD_APPLICATION_TYPE_LEGACY",t[t.V2NIM_FRIEND_ADD_APPLICATION_TYPE_FROM_SELF=1]="V2NIM_FRIEND_ADD_APPLICATION_TYPE_FROM_SELF",t[t.V2NIM_FRIEND_ADD_APPLICATION_TYPE_TO_SELF=2]="V2NIM_FRIEND_ADD_APPLICATION_TYPE_TO_SELF",t[t.V2NIM_FRIEND_ADD_APPLICATION_TYPE_ALL=3]="V2NIM_FRIEND_ADD_APPLICATION_TYPE_ALL"}($c||($c={})),function(t){t[t.V2NIM_FRIEND_ADD_APPLICATION_STATUS_INIT=0]="V2NIM_FRIEND_ADD_APPLICATION_STATUS_INIT",t[t.V2NIM_FRIEND_ADD_APPLICATION_STATUS_AGREED=1]="V2NIM_FRIEND_ADD_APPLICATION_STATUS_AGREED",t[t.V2NIM_FRIEND_ADD_APPLICATION_STATUS_REJECTED=2]="V2NIM_FRIEND_ADD_APPLICATION_STATUS_REJECTED",t[t.V2NIM_FRIEND_ADD_APPLICATION_STATUS_EXPIRED=3]="V2NIM_FRIEND_ADD_APPLICATION_STATUS_EXPIRED",t[t.V2NIM_FRIEND_ADD_APPLICATION_STATUS_DIRECT_ADD=4]="V2NIM_FRIEND_ADD_APPLICATION_STATUS_DIRECT_ADD"}(zc||(zc={})),function(t){t[t.V2NIM_FRIEND_DELETION_TYPE_BY_SELF=1]="V2NIM_FRIEND_DELETION_TYPE_BY_SELF",t[t.V2NIM_FRIEND_DELETION_TYPE_BY_PEER=2]="V2NIM_FRIEND_DELETION_TYPE_BY_PEER"}(Wc||(Wc={})),function(t){t[t.V2NIM_FRIEND_VERIFY_TYPE_ADD=1]="V2NIM_FRIEND_VERIFY_TYPE_ADD",t[t.V2NIM_FRIEND_VERIFY_TYPE_APPLY=2]="V2NIM_FRIEND_VERIFY_TYPE_APPLY",t[t.V2NIM_FRIEND_VERIFY_TYPE_ACCEPT=3]="V2NIM_FRIEND_VERIFY_TYPE_ACCEPT",t[t.V2NIM_FRIEND_VERIFY_TYPE_REJECT=4]="V2NIM_FRIEND_VERIFY_TYPE_REJECT"}(Kc||(Kc={})),function(t){t[t.V2NIM_LOGIN_AUTH_TYPE_DEFAULT=0]="V2NIM_LOGIN_AUTH_TYPE_DEFAULT",t[t.V2NIM_LOGIN_AUTH_TYPE_DYNAMIC_TOKEN=1]="V2NIM_LOGIN_AUTH_TYPE_DYNAMIC_TOKEN",t[t.V2NIM_LOGIN_AUTH_TYPE_THIRD_PARTY=2]="V2NIM_LOGIN_AUTH_TYPE_THIRD_PARTY"}(Yc||(Yc={})),function(t){t[t.V2NIM_LOGIN_STATUS_LOGOUT=0]="V2NIM_LOGIN_STATUS_LOGOUT",t[t.V2NIM_LOGIN_STATUS_LOGINED=1]="V2NIM_LOGIN_STATUS_LOGINED",t[t.V2NIM_LOGIN_STATUS_LOGINING=2]="V2NIM_LOGIN_STATUS_LOGINING",t[t.V2NIM_LOGIN_STATUS_UNLOGIN=3]="V2NIM_LOGIN_STATUS_UNLOGIN"}(Qc||(Qc={})),function(t){t[t.V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN=0]="V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN",t[t.V2NIM_LOGIN_CLIENT_TYPE_ANDROID=1]="V2NIM_LOGIN_CLIENT_TYPE_ANDROID",t[t.V2NIM_LOGIN_CLIENT_TYPE_IOS=2]="V2NIM_LOGIN_CLIENT_TYPE_IOS",t[t.V2NIM_LOGIN_CLIENT_TYPE_PC=4]="V2NIM_LOGIN_CLIENT_TYPE_PC",t[t.V2NIM_LOGIN_CLIENT_TYPE_WP=8]="V2NIM_LOGIN_CLIENT_TYPE_WP",t[t.V2NIM_LOGIN_CLIENT_TYPE_WEB=16]="V2NIM_LOGIN_CLIENT_TYPE_WEB",t[t.V2NIM_LOGIN_CLIENT_TYPE_RESTFUL=32]="V2NIM_LOGIN_CLIENT_TYPE_RESTFUL",t[t.V2NIM_LOGIN_CLIENT_TYPE_MAC_OS=64]="V2NIM_LOGIN_CLIENT_TYPE_MAC_OS",t[t.V2NIM_LOGIN_CLIENT_TYPE_HARMONY_OS=65]="V2NIM_LOGIN_CLIENT_TYPE_HARMONY_OS"}(Jc||(Jc={})),function(t){t[t.V2NIM_KICKED_OFFLINE_REASON_CLIENT_EXCLUSIVE=1]="V2NIM_KICKED_OFFLINE_REASON_CLIENT_EXCLUSIVE",t[t.V2NIM_KICKED_OFFLINE_REASON_SERVER=2]="V2NIM_KICKED_OFFLINE_REASON_SERVER",t[t.V2NIM_KICKED_OFFLINE_REASON_CLIENT=3]="V2NIM_KICKED_OFFLINE_REASON_CLIENT",t[t.V2NIM_KICKED_OFFLINE_REASON_CLIENT_QUIETLY=4]="V2NIM_KICKED_OFFLINE_REASON_CLIENT_QUIETLY"}(Xc||(Xc={})),function(t){t[t.V2NIM_LOGIN_CLIENT_CHANGE_LIST=1]="V2NIM_LOGIN_CLIENT_CHANGE_LIST",t[t.V2NIM_LOGIN_CLIENT_CHANGE_LOGIN=2]="V2NIM_LOGIN_CLIENT_CHANGE_LOGIN",t[t.V2NIM_LOGIN_CLIENT_CHANGE_LOGOUT=3]="V2NIM_LOGIN_CLIENT_CHANGE_LOGOUT"}(Zc||(Zc={})),function(t){t[t.V2NIM_CONNECT_STATUS_DISCONNECTED=0]="V2NIM_CONNECT_STATUS_DISCONNECTED",t[t.V2NIM_CONNECT_STATUS_CONNECTED=1]="V2NIM_CONNECT_STATUS_CONNECTED",t[t.V2NIM_CONNECT_STATUS_CONNECTING=2]="V2NIM_CONNECT_STATUS_CONNECTING",t[t.V2NIM_CONNECT_STATUS_WAITING=3]="V2NIM_CONNECT_STATUS_WAITING"}(el||(el={})),function(t){t[t.NIM_MESSAGE_AI_STREAM_STATUS_STREAMING=-1]="NIM_MESSAGE_AI_STREAM_STATUS_STREAMING",t[t.NIM_MESSAGE_AI_STREAM_STATUS_NONE=0]="NIM_MESSAGE_AI_STREAM_STATUS_NONE",t[t.NIM_MESSAGE_AI_STREAM_STATUS_PLACEHOLDER=1]="NIM_MESSAGE_AI_STREAM_STATUS_PLACEHOLDER",t[t.NIM_MESSAGE_AI_STREAM_STATUS_CANCEL=2]="NIM_MESSAGE_AI_STREAM_STATUS_CANCEL",t[t.NIM_MESSAGE_AI_STREAM_STATUS_UPDATE=3]="NIM_MESSAGE_AI_STREAM_STATUS_UPDATE",t[t.NIM_MESSAGE_AI_STREAM_STATUS_COMPLETE=4]="NIM_MESSAGE_AI_STREAM_STATUS_COMPLETE",t[t.NIM_MESSAGE_AI_STREAM_STATUS_EXCEPTION=5]="NIM_MESSAGE_AI_STREAM_STATUS_EXCEPTION"}(tl||(tl={})),function(t){t[t.V2NIM_MESSAGE_AI_STREAM_STOP_OP_DEFAULT=0]="V2NIM_MESSAGE_AI_STREAM_STOP_OP_DEFAULT",t[t.V2NIM_MESSAGE_AI_STREAM_STOP_OP_REVOKE=1]="V2NIM_MESSAGE_AI_STREAM_STOP_OP_REVOKE",t[t.V2NIM_MESSAGE_AI_STREAM_STOP_OP_UPDATE=2]="V2NIM_MESSAGE_AI_STREAM_STOP_OP_UPDATE"}(rl||(rl={})),function(t){t[t.V2NIM_MESSAGE_AI_REGEN_OP_UPDATE=1]="V2NIM_MESSAGE_AI_REGEN_OP_UPDATE",t[t.V2NIM_MESSAGE_AI_REGEN_OP_NEW=2]="V2NIM_MESSAGE_AI_REGEN_OP_NEW"}(nl||(nl={})),function(t){t[t.V2NIM_MESSAGE_AI_STATUS_UNKNOW=0]="V2NIM_MESSAGE_AI_STATUS_UNKNOW",t[t.V2NIM_MESSAGE_AI_STATUS_AT=1]="V2NIM_MESSAGE_AI_STATUS_AT",t[t.V2NIM_MESSAGE_AI_STATUS_RESPONSE=2]="V2NIM_MESSAGE_AI_STATUS_RESPONSE"}(al||(al={})),function(t){t[t.V2NIM_MESSAGE_TYPE_INVALID=-1]="V2NIM_MESSAGE_TYPE_INVALID",t[t.V2NIM_MESSAGE_TYPE_TEXT=0]="V2NIM_MESSAGE_TYPE_TEXT",t[t.V2NIM_MESSAGE_TYPE_IMAGE=1]="V2NIM_MESSAGE_TYPE_IMAGE",t[t.V2NIM_MESSAGE_TYPE_AUDIO=2]="V2NIM_MESSAGE_TYPE_AUDIO",t[t.V2NIM_MESSAGE_TYPE_VIDEO=3]="V2NIM_MESSAGE_TYPE_VIDEO",t[t.V2NIM_MESSAGE_TYPE_LOCATION=4]="V2NIM_MESSAGE_TYPE_LOCATION",t[t.V2NIM_MESSAGE_TYPE_NOTIFICATION=5]="V2NIM_MESSAGE_TYPE_NOTIFICATION",t[t.V2NIM_MESSAGE_TYPE_FILE=6]="V2NIM_MESSAGE_TYPE_FILE",t[t.V2NIM_MESSAGE_TYPE_AVCHAT=7]="V2NIM_MESSAGE_TYPE_AVCHAT",t[t.V2NIM_MESSAGE_TYPE_TIPS=10]="V2NIM_MESSAGE_TYPE_TIPS",t[t.V2NIM_MESSAGE_TYPE_ROBOT=11]="V2NIM_MESSAGE_TYPE_ROBOT",t[t.V2NIM_MESSAGE_TYPE_CALL=12]="V2NIM_MESSAGE_TYPE_CALL",t[t.V2NIM_MESSAGE_TYPE_CUSTOM=100]="V2NIM_MESSAGE_TYPE_CUSTOM"}(il||(il={})),function(t){t[t.V2NIM_SEARCH_KEYWORD_MATCH_TYPE_OR=0]="V2NIM_SEARCH_KEYWORD_MATCH_TYPE_OR",t[t.V2NIM_SEARCH_KEYWORD_MATCH_TYPE_AND=1]="V2NIM_SEARCH_KEYWORD_MATCH_TYPE_AND"}(ol||(ol={})),function(t){t[t.V2NIM_SEARCH_DIRECTION_BACKWARD=0]="V2NIM_SEARCH_DIRECTION_BACKWARD",t[t.V2NIM_SEARCH_DIRECTION_FORWARD=1]="V2NIM_SEARCH_DIRECTION_FORWARD"}(sl||(sl={})),function(t){t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_UNDEFINED=-1]="V2NIM_MESSAGE_NOTIFICATION_TYPE_UNDEFINED",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE=0]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_KICK=1]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_KICK",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_LEAVE=2]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_LEAVE",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_UPDATE_TINFO=3]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_UPDATE_TINFO",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_DISMISS=4]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_DISMISS",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_APPLY_PASS=5]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_APPLY_PASS",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_OWNER_TRANSFER=6]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_OWNER_TRANSFER",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_ADD_MANAGER=7]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_ADD_MANAGER",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_REMOVE_MANAGER=8]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_REMOVE_MANAGER",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE_ACCEPT=9]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE_ACCEPT",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_BANNED_TEAM_MEMBER=10]="V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_BANNED_TEAM_MEMBER",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE=401]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_KICK=402]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_KICK",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_LEAVE=403]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_LEAVE",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_UPDATE_TINFO=404]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_UPDATE_TINFO",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_DISMISS=405]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_DISMISS",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_APPLY_PASS=410]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_APPLY_PASS",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_OWNER_TRANSFER=406]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_OWNER_TRANSFER",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_ADD_MANAGER=407]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_ADD_MANAGER",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_REMOVE_MANAGER=408]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_REMOVE_MANAGER",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE_ACCEPT=411]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE_ACCEPT",t[t.V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_BANNED_TEAM_MEMBER=409]="V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_BANNED_TEAM_MEMBER"}(cl||(cl={})),function(t){t[t.V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UNKNOWN=0]="V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UNKNOWN",t[t.V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_SUCCESS=1]="V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_SUCCESS",t[t.V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_FAILED=2]="V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_FAILED",t[t.V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UPLOADING=3]="V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UPLOADING"}(ll||(ll={})),function(t){t[t.V2NIM_MESSAGE_SENDING_STATE_UNKNOWN=0]="V2NIM_MESSAGE_SENDING_STATE_UNKNOWN",t[t.V2NIM_MESSAGE_SENDING_STATE_SUCCEEDED=1]="V2NIM_MESSAGE_SENDING_STATE_SUCCEEDED",t[t.V2NIM_MESSAGE_SENDING_STATE_FAILED=2]="V2NIM_MESSAGE_SENDING_STATE_FAILED",t[t.V2NIM_MESSAGE_SENDING_STATE_SENDING=3]="V2NIM_MESSAGE_SENDING_STATE_SENDING"}(dl||(dl={})),function(t){t[t.V2NIM_QUERY_DIRECTION_DESC=0]="V2NIM_QUERY_DIRECTION_DESC",t[t.V2NIM_QUERY_DIRECTION_ASC=1]="V2NIM_QUERY_DIRECTION_ASC"}(ul||(ul={})),function(t){t[t.V2NIM_CLEAR_HISTORY_MODE_ALL=0]="V2NIM_CLEAR_HISTORY_MODE_ALL",t[t.V2NIM_CLEAR_HISTORY_MODE_LOCAL=1]="V2NIM_CLEAR_HISTORY_MODE_LOCAL",t[t.V2NIM_CLEAR_HISTORY_MODE_LOCAL_IRREPARABLY=2]="V2NIM_CLEAR_HISTORY_MODE_LOCAL_IRREPARABLY"}(pl||(pl={})),function(t){t[t.V2NIM_MESSAGE_REVOKE_TYPE_UNDEFINED=0]="V2NIM_MESSAGE_REVOKE_TYPE_UNDEFINED",t[t.V2NIM_MESSAGE_REVOKE_TYPE_P2P_BOTHWAY=1]="V2NIM_MESSAGE_REVOKE_TYPE_P2P_BOTHWAY",t[t.V2NIM_MESSAGE_REVOKE_TYPE_TEAM_BOTHWAY=2]="V2NIM_MESSAGE_REVOKE_TYPE_TEAM_BOTHWAY",t[t.V2NIM_MESSAGE_REVOKE_TYPE_SUPERTEAM_BOTHWAY=3]="V2NIM_MESSAGE_REVOKE_TYPE_SUPERTEAM_BOTHWAY",t[t.V2NIM_MESSAGE_REVOKE_TYPE_P2P_ONEWAY=4]="V2NIM_MESSAGE_REVOKE_TYPE_P2P_ONEWAY",t[t.V2NIM_MESSAGE_REVOKE_TYPE_TEAM_ONEWAY=5]="V2NIM_MESSAGE_REVOKE_TYPE_TEAM_ONEWAY"}(ml||(ml={})),function(t){t[t.V2NIM_MESSAGE_PIN_STATE_NOT_PINNED=0]="V2NIM_MESSAGE_PIN_STATE_NOT_PINNED",t[t.V2NIM_MESSAGE_PIN_STATE_PINNED=1]="V2NIM_MESSAGE_PIN_STATE_PINNED",t[t.V2NIM_MESSAGE_PIN_STATE_UPDATED=2]="V2NIM_MESSAGE_PIN_STATE_UPDATED"}(hl||(hl={})),function(t){t[t.V2NIM_QUICK_COMMENT_STATE_ADD=1]="V2NIM_QUICK_COMMENT_STATE_ADD",t[t.V2NIM_QUICK_COMMENT_STATE_REMOVE=2]="V2NIM_QUICK_COMMENT_STATE_REMOVE"}(gl||(gl={})),function(t){t[t.V2NIM_CLIENT_ANTISPAM_OPERATE_NONE=0]="V2NIM_CLIENT_ANTISPAM_OPERATE_NONE",t[t.V2NIM_CLIENT_ANTISPAM_OPERATE_REPLACE=1]="V2NIM_CLIENT_ANTISPAM_OPERATE_REPLACE",t[t.V2NIM_CLIENT_ANTISPAM_OPERATE_CLIENT_SHIELD=2]="V2NIM_CLIENT_ANTISPAM_OPERATE_CLIENT_SHIELD",t[t.V2NIM_CLIENT_ANTISPAM_OPERATE_SERVER_SHIELD=3]="V2NIM_CLIENT_ANTISPAM_OPERATE_SERVER_SHIELD"}(vl||(vl={})),function(t){t[t.V2NIM_SORT_ORDER_DESC=0]="V2NIM_SORT_ORDER_DESC",t[t.V2NIM_SORT_ORDER_ASC=1]="V2NIM_SORT_ORDER_ASC"}(fl||(fl={})),function(t){t[t.P2P_DELETE_MSG=7]="P2P_DELETE_MSG",t[t.TEAM_DELETE_MSG=8]="TEAM_DELETE_MSG",t[t.SUPERTEAM_DELETE_MSG=12]="SUPERTEAM_DELETE_MSG",t[t.P2P_ONE_WAY_DELETE_MSG=13]="P2P_ONE_WAY_DELETE_MSG",t[t.TEAM_ONE_WAY_DELETE_MSG=14]="TEAM_ONE_WAY_DELETE_MSG",t[t.CUSTOM_P2P_MSG=100]="CUSTOM_P2P_MSG",t[t.CUSTOM_TEAM_MSG=101]="CUSTOM_TEAM_MSG",t[t.CUSTOM_SUPERTEAM_MSG=103]="CUSTOM_SUPERTEAM_MSG"}(yl||(yl={})),function(t){t[t.NIM_MESSAGE_STREAM_STATUS_STREAMING=-1]="NIM_MESSAGE_STREAM_STATUS_STREAMING",t[t.NIM_MESSAGE_STREAM_STATUS_NONE=0]="NIM_MESSAGE_STREAM_STATUS_NONE",t[t.NIM_MESSAGE_STREAM_STATUS_PLACEHOLDER=1]="NIM_MESSAGE_STREAM_STATUS_PLACEHOLDER",t[t.NIM_MESSAGE_STREAM_STATUS_CANCEL=2]="NIM_MESSAGE_STREAM_STATUS_CANCEL",t[t.NIM_MESSAGE_AI_STREAM_STATUS_UPDATE=3]="NIM_MESSAGE_AI_STREAM_STATUS_UPDATE",t[t.NIM_MESSAGE_STREAM_STATUS_COMPLETE=4]="NIM_MESSAGE_STREAM_STATUS_COMPLETE",t[t.NIM_MESSAGE_STREAM_STATUS_EXCEPTION=5]="NIM_MESSAGE_STREAM_STATUS_EXCEPTION"}(Ml||(Ml={})),function(t){t[t.V2NIM_MESSAGE_SOURCE_UNKNOWN=0]="V2NIM_MESSAGE_SOURCE_UNKNOWN",t[t.V2NIM_MESSAGE_SOURCE_ONLINE=1]="V2NIM_MESSAGE_SOURCE_ONLINE",t[t.V2NIM_MESSAGE_SOURCE_OFFLINE=2]="V2NIM_MESSAGE_SOURCE_OFFLINE",t[t.V2NIM_MESSAGE_SOURCE_ROAMING=3]="V2NIM_MESSAGE_SOURCE_ROAMING"}(Il||(Il={})),function(t){t[t.V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF=0]="V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF",t[t.V2NIM_TEAM_MESSAGE_MUTE_MODE_ON=1]="V2NIM_TEAM_MESSAGE_MUTE_MODE_ON",t[t.V2NIM_TEAM_MESSAGE_MUTE_MODE_NORMAL_ON=2]="V2NIM_TEAM_MESSAGE_MUTE_MODE_NORMAL_ON"}(_l||(_l={})),function(t){t[t.V2NIM_P2P_MESSAGE_MUTE_MODE_OFF=0]="V2NIM_P2P_MESSAGE_MUTE_MODE_OFF",t[t.V2NIM_P2P_MESSAGE_MUTE_MODE_ON=1]="V2NIM_P2P_MESSAGE_MUTE_MODE_ON"}(Sl||(Sl={})),function(t){t[t.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_NORMAL=1]="V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_NORMAL",t[t.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_SUPER=2]="V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_SUPER",t[t.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL=3]="V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL"}(Tl||(Tl={})),function(t){t[t.V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_ALL=0]="V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_ALL",t[t.V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_NORMAL=1]="V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_NORMAL",t[t.V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_MANAGER=2]="V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_MANAGER"}(Cl||(Cl={})),function(t){t[t.V2NIM_TEAM_TYPE_INVALID=0]="V2NIM_TEAM_TYPE_INVALID",t[t.V2NIM_TEAM_TYPE_ADVANCED=1]="V2NIM_TEAM_TYPE_ADVANCED",t[t.V2NIM_TEAM_TYPE_SUPER=2]="V2NIM_TEAM_TYPE_SUPER"}(bl||(bl={})),function(t){t[t.V2NIM_TEAM_JOIN_MODE_FREE=0]="V2NIM_TEAM_JOIN_MODE_FREE",t[t.V2NIM_TEAM_JOIN_MODE_APPLY=1]="V2NIM_TEAM_JOIN_MODE_APPLY",t[t.V2NIM_TEAM_JOIN_MODE_INVITE=2]="V2NIM_TEAM_JOIN_MODE_INVITE"}(El||(El={})),function(t){t[t.V2NIM_TEAM_AGREE_MODE_AUTH=0]="V2NIM_TEAM_AGREE_MODE_AUTH",t[t.V2NIM_TEAM_AGREE_MODE_NO_AUTH=1]="V2NIM_TEAM_AGREE_MODE_NO_AUTH"}(Al||(Al={})),function(t){t[t.V2NIM_TEAM_INVITE_MODE_MANAGER=0]="V2NIM_TEAM_INVITE_MODE_MANAGER",t[t.V2NIM_TEAM_INVITE_MODE_ALL=1]="V2NIM_TEAM_INVITE_MODE_ALL"}(kl||(kl={})),function(t){t[t.V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER=0]="V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER",t[t.V2NIM_TEAM_UPDATE_INFO_MODE_ALL=1]="V2NIM_TEAM_UPDATE_INFO_MODE_ALL"}(Rl||(Rl={})),function(t){t[t.V2NIM_TEAM_CHAT_BANNED_MODE_UNBAN=0]="V2NIM_TEAM_CHAT_BANNED_MODE_UNBAN",t[t.V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL=1]="V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL",t[t.V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_ALL=3]="V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_ALL"}(wl||(wl={})),function(t){t[t.V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER=0]="V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER",t[t.V2NIM_TEAM_UPDATE_EXTENSION_MODE_ALL=1]="V2NIM_TEAM_UPDATE_EXTENSION_MODE_ALL"}(Nl||(Nl={})),function(t){t[t.V2NIM_TEAM_MEMBER_ROLE_NORMAL=0]="V2NIM_TEAM_MEMBER_ROLE_NORMAL",t[t.V2NIM_TEAM_MEMBER_ROLE_OWNER=1]="V2NIM_TEAM_MEMBER_ROLE_OWNER",t[t.V2NIM_TEAM_MEMBER_ROLE_MANAGER=2]="V2NIM_TEAM_MEMBER_ROLE_MANAGER"}(xl||(xl={})),function(t){t[t.V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION=0]="V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION",t[t.V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_APPLICATION=1]="V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_APPLICATION",t[t.V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION=2]="V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION",t[t.V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION=3]="V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION",t[t.V2NIM_TEAM_JOIN_ACTION_TYPE_ACCEPT_APPLICATION=4]="V2NIM_TEAM_JOIN_ACTION_TYPE_ACCEPT_APPLICATION",t[t.V2NIM_TEAM_JOIN_ACTION_TYPE_ACCEPT_INVITATION=5]="V2NIM_TEAM_JOIN_ACTION_TYPE_ACCEPT_INVITATION"}(Ol||(Ol={})),function(t){t[t.V2NIM_TEAM_JOIN_ACTION_STATUS_INIT=0]="V2NIM_TEAM_JOIN_ACTION_STATUS_INIT",t[t.V2NIM_TEAM_JOIN_ACTION_STATUS_AGREED=1]="V2NIM_TEAM_JOIN_ACTION_STATUS_AGREED",t[t.V2NIM_TEAM_JOIN_ACTION_STATUS_REJECTED=2]="V2NIM_TEAM_JOIN_ACTION_STATUS_REJECTED",t[t.V2NIM_TEAM_JOIN_ACTION_STATUS_EXPIRED=3]="V2NIM_TEAM_JOIN_ACTION_STATUS_EXPIRED"}(Pl||(Pl={})),function(t){t[t.teamApply=0]="teamApply",t[t.teamApplyReject=1]="teamApplyReject",t[t.teamInvite=2]="teamInvite",t[t.teamInviteReject=3]="teamInviteReject",t[t.tlistUpdate=4]="tlistUpdate",t[t.superTeamApply=15]="superTeamApply",t[t.superTeamApplyReject=16]="superTeamApplyReject",t[t.superTeamInvite=17]="superTeamInvite",t[t.superTeamInviteReject=18]="superTeamInviteReject"}(Ll||(Ll={})),function(t){t[t.V2NIM_AI_MODEL_TYPE_UNKNOW=0]="V2NIM_AI_MODEL_TYPE_UNKNOW",t[t.V2NIM_AI_MODEL_TYPE_QWEN=1]="V2NIM_AI_MODEL_TYPE_QWEN",t[t.V2NIM_AI_MODEL_TYPE_AZURE=2]="V2NIM_AI_MODEL_TYPE_AZURE",t[t.V2NIM_AI_MODEL_TYPE_PRIVATE=3]="V2NIM_AI_MODEL_TYPE_PRIVATE"}(Vl||(Vl={})),function(t){t[t.V2NIM_AI_MODEL_STREAM_CALL_STATUS_NONE=0]="V2NIM_AI_MODEL_STREAM_CALL_STATUS_NONE",t[t.V2NIM_AI_MODEL_STREAM_CALL_STATUS_CANCEL=2]="V2NIM_AI_MODEL_STREAM_CALL_STATUS_CANCEL",t[t.V2NIM_AI_MODEL_STREAM_CALL_STATUS_COMPLETE=4]="V2NIM_AI_MODEL_STREAM_CALL_STATUS_COMPLETE",t[t.V2NIM_AI_MODEL_STREAM_CALL_STATUS_EXCEPTION=5]="V2NIM_AI_MODEL_STREAM_CALL_STATUS_EXCEPTION"}(Ul||(Ul={})),function(t){t.V2NIM_AI_MODEL_ROLE_TYPE_SYSTEM="system",t.V2NIM_AI_MODEL_ROLE_TYPE_USER="user",t.V2NIM_AI_MODEL_ROLE_TYPE_ASSISTANT="assistant"}(Dl||(Dl={})),function(t){t[t.V2NIM_SIGNALLING_EVENT_TYPE_UNKNOWN=0]="V2NIM_SIGNALLING_EVENT_TYPE_UNKNOWN",t[t.V2NIM_SIGNALLING_EVENT_TYPE_CLOSE=1]="V2NIM_SIGNALLING_EVENT_TYPE_CLOSE",t[t.V2NIM_SIGNALLING_EVENT_TYPE_JOIN=2]="V2NIM_SIGNALLING_EVENT_TYPE_JOIN",t[t.V2NIM_SIGNALLING_EVENT_TYPE_INVITE=3]="V2NIM_SIGNALLING_EVENT_TYPE_INVITE",t[t.V2NIM_SIGNALLING_EVENT_TYPE_CANCEL_INVITE=4]="V2NIM_SIGNALLING_EVENT_TYPE_CANCEL_INVITE",t[t.V2NIM_SIGNALLING_EVENT_TYPE_REJECT=5]="V2NIM_SIGNALLING_EVENT_TYPE_REJECT",t[t.V2NIM_SIGNALLING_EVENT_TYPE_ACCEPT=6]="V2NIM_SIGNALLING_EVENT_TYPE_ACCEPT",t[t.V2NIM_SIGNALLING_EVENT_TYPE_LEAVE=7]="V2NIM_SIGNALLING_EVENT_TYPE_LEAVE",t[t.V2NIM_SIGNALLING_EVENT_TYPE_CONTROL=8]="V2NIM_SIGNALLING_EVENT_TYPE_CONTROL",t[t.V2NIM_SIGNALLING_EVENT_TYPE_KICK=9]="V2NIM_SIGNALLING_EVENT_TYPE_KICK"}(Bl||(Bl={})),function(t){t[t.V2NIM_SIGNALLING_CHANNEL_TYPE_AUDIO=1]="V2NIM_SIGNALLING_CHANNEL_TYPE_AUDIO",t[t.V2NIM_SIGNALLING_CHANNEL_TYPE_VIDEO=2]="V2NIM_SIGNALLING_CHANNEL_TYPE_VIDEO",t[t.V2NIM_SIGNALLING_CHANNEL_TYPE_CUSTOM=3]="V2NIM_SIGNALLING_CHANNEL_TYPE_CUSTOM"}(ql||(ql={})),function(t){t[t.V2NIM_USER_STATUS_TYPE_UNKNOWN=0]="V2NIM_USER_STATUS_TYPE_UNKNOWN",t[t.V2NIM_USER_STATUS_TYPE_LOGIN=1]="V2NIM_USER_STATUS_TYPE_LOGIN",t[t.V2NIM_USER_STATUS_TYPE_LOGOUT=2]="V2NIM_USER_STATUS_TYPE_LOGOUT",t[t.V2NIM_USER_STATUS_TYPE_DISCONNECT=3]="V2NIM_USER_STATUS_TYPE_DISCONNECT"}(Fl||(Fl={}));var jl={V2NIM_ERROR_CODE_UNKNOWN:{code:0,message:"unknown error"},V2NIM_ERROR_CODE_SUCCESS:{code:200,message:"success"},V2NIM_ERROR_CODE_HANDSHAKE:{code:201,message:"handshake error"},V2NIM_ERROR_CODE_REQUEST_TEMPERARY_FORBIDDEN:{code:398,message:"request temprary forbidden"},V2NIM_ERROR_CODE_SERVER_UNIT_ERROR:{code:399,message:"server unit error"},V2NIM_ERROR_CODE_FORBIDDEN:{code:403,message:"forbidden"},V2NIM_ERROR_CODE_NOT_FOUND:{code:404,message:"not found"},V2NIM_ERROR_CODE_PARAMETER_ERROR:{code:414,message:"parameter error"},V2NIM_ERROR_CODE_RATE_LIMIT_REACHED:{code:416,message:"rate limit reached"},V2NIM_ERROR_CODE_MULTI_LOGIN_FORBIDDEN:{code:417,message:"multi login forbidden"},V2NIM_ERROR_CODE_SERVER_INTERNAL_ERROR:{code:500,message:"server internal error"},V2NIM_ERROR_CODE_SERVER_BUSY:{code:503,message:"server busy"},V2NIM_ERROR_CODE_APP_UNREACHABLE:{code:511,message:"app server unreachable"},V2NIM_ERROR_CODE_SERVICE_UNAVAILABLE:{code:514,message:"service unavailable"},V2NIM_ERROR_CODE_PROTOCOL_BLACKHOLE_FILTERED:{code:599,message:"protocol filtered by blackhole rule"},V2NIM_ERROR_CODE_NO_PERMISSION:{code:997,message:"appid has no permission to call the protocol"},V2NIM_ERROR_CODE_UNPACK_ERROR:{code:998,message:"unpack error"},V2NIM_ERROR_CODE_PACK_ERROR:{code:999,message:"pack error"},V2NIM_ERROR_CODE_IM_DISABLED:{code:101301,message:"IM disabled"},V2NIM_ERROR_CODE_SERVICE_ADDRESS_INVALID:{code:101302,message:"service address invalid"},V2NIM_ERROR_CODE_APPKEY_NOT_EXIST:{code:101303,message:"appkey not exist"},V2NIM_ERROR_CODE_BUNDLEID_CHECK_FAILED:{code:101304,message:"bundleid check failed"},V2NIM_ERROR_CODE_APPKEY_BLOCKED:{code:101403,message:"appkey blocked"},V2NIM_ERROR_CODE_INVALID_TOKEN:{code:102302,message:"invalid token"},V2NIM_ERROR_CODE_ROBOT_NOT_ALLOWED:{code:102303,message:"robot not allowed"},V2NIM_ERROR_CODE_ACCOUNT_NOT_EXIST:{code:102404,message:"account not exist"},V2NIM_ERROR_CODE_ACCOUNT_CHAT_BANNED:{code:102421,message:"account chat banned"},V2NIM_ERROR_CODE_ACCOUNT_BANNED:{code:102422,message:"account banned"},V2NIM_ERROR_CODE_ACCOUNT_IN_BLOCK_LIST:{code:102426,message:"account in block list"},V2NIM_ERROR_CODE_USER_PROFILE_NOT_EXIST:{code:103404,message:"user profile not exist"},V2NIM_ERROR_CODE_USER_PROFILE_HIT_ANTISPAM:{code:103451,message:"user profile hit antispam"},V2NIM_ERROR_CODE_PEER_FRIEND_LIMIT:{code:104301,message:"peer friend limit"},V2NIM_ERROR_CODE_FRIEND_APPLICATION_NOT_EXIST:{code:104302,message:"friend application not exist"},V2NIM_ERROR_CODE_FRIEND_NOT_EXIST:{code:104404,message:"friend not exist"},V2NIM_ERROR_CODE_FRIEND_ALREADY_EXIST:{code:104405,message:"friend already exist"},V2NIM_ERROR_CODE_SELF_FRIEND_OPERATION_NOT_ALLOWED:{code:104429,message:"self friend operation not allowed"},V2NIM_ERROR_CODE_FRIEND_LIMIT:{code:104435,message:"friend limit"},V2NIM_ERROR_CODE_FRIEND_OPERATION_RATE_LIMIT:{code:104449,message:"friend operation rate limit"},V2NIM_ERROR_CODE_FRIEND_HIT_ANTISPAM:{code:104451,message:"friend hit antispam"},V2NIM_ERROR_CODE_SELF_MUTE_OPERATION_NOT_ALLOWED:{code:105429,message:"self mute operation not allowed"},V2NIM_ERROR_CODE_MUTE_LIST_LIMIT:{code:105435,message:"mute list limit"},V2NIM_ERROR_CODE_SELF_BLOCK_LIST_OPERATION_NOT_ALLOWED:{code:106429,message:"self block list operation not allowed"},V2NIM_ERROR_CODE_BLOCK_LIST_LIMIT:{code:106435,message:"block list limit"},V2NIM_ERROR_CODE_REVOKE_THIRD_PARTY_MESSAGE_NOT_ALLOWED:{code:107301,message:"revoke third party message not allowed"},V2NIM_ERROR_CODE_SHORT_TO_LONG_URL_FAILED:{code:107307,message:"short to long URL failed"},V2NIM_ERROR_CODE_URL_INVALID:{code:107308,message:"URL invalid"},V2NIM_ERROR_CODE_DURATION_OUT_OF_RANGE:{code:107309,message:"duration out of range"},V2NIM_ERROR_CODE_GET_FILE_META_INFO_FAILED:{code:107310,message:"get file meta info failed"},V2NIM_ERROR_CODE_AUDIO_FILE_SIZE_LIMIT:{code:107311,message:"audio file size limit"},V2NIM_ERROR_CODE_VOICE_TO_TEXT_TIMEOUT:{code:107312,message:"voice to text timeout"},V2NIM_ERROR_CODE_VOICE_TO_TEXT_FAILED:{code:107313,message:"voice to text failed"},V2NIM_ERROR_CODE_REVOKE_EXCEED_TIME_LIMIT:{code:107314,message:"revoke message exceed time limit"},V2NIM_ERROR_CODE_REVOKE_MESSAGE_NOT_ALLOWED:{code:107315,message:"revoke specific message not allowed"},V2NIM_ERROR_CODE_FORCE_PUSH_LIST_LIMIT:{code:107316,message:"force push list limit"},V2NIM_ERROR_CODE_TEAM_MESSAGE_RECEIPT_RATE_LIMIT:{code:107317,message:"team message receipt rate limit"},V2NIM_ERROR_CODE_SNAPSHOT_NOT_EXIST:{code:107318,message:"snapshot not exist"},V2NIM_ERROR_CODE_PIN_LIMIT:{code:107319,message:"pin limit"},V2NIM_ERROR_CODE_PIN_NOT_EXIST:{code:107320,message:"pin not exist"},V2NIM_ERROR_CODE_QUICK_COMMENT_LIMIT:{code:107321,message:"quick comment limit"},V2NIM_ERROR_CODE_PIN_ALREADY_EXIST:{code:107322,message:"pin already exist"},V2NIM_ERROR_CODE_VOICE_TO_TEXT_FUNCTION_DISABLED:{code:107333,message:"voice to text function disabled"},V2NIM_ERROR_CODE_CLOUD_SEARCH_FUNCTION_DISABLED:{code:107334,message:"cloud search function disabled"},V2NIM_ERROR_CODE_ONE_WAY_DELETE_FUNCTION_DISABLED:{code:107335,message:"one-way delete function disabled"},V2NIM_ERRPR_CODE_ONEWAY_DELETION_NOT_ALLOW_FOR_TARGET_MESSAGES:{code:107338,message:"one-way deletion is not allowed for target messages"},V2NIM_ERRPR_CODE_SENDER_CANNOT_INCLUDED_IN_TARGET_LIST:{code:107339,message:"The message sender cannot be included in the target list"},V2NIM_ERROR_CODE_ROBOT_CANNOT_SEND_TARGET_MESSAGE:{code:107340,message:"Robot can not send target message"},V2NIM_ERROR_CODE_PIN_TARGET_MESSAGE_NOT_ALLOWED:{code:107345,message:"Pin target message is not allowed"},V2NIM_ERROR_CODE_TARGET_MESSAGE_NOT_ALLOWED_REPLY:{code:107346,message:"Target message not allowed reply"},V2NIM_ERROR_CODE_TARGET_MESSAGE_NOT_ALLOWED_QUICK_COMMENT:{code:107347,message:"Target message not allowed quick comment"},V2NIM_ERROR_CODE_REVOKE_MESSAGE_TO_SELF_NOT_ALLOWED:{code:107429,message:"revoke message to self not allowed"},V2NIM_ERROR_CODE_APP_CHAT_BANNED:{code:107410,message:"app chat banned"},V2NIM_ERROR_CODE_QUICK_COMMENT_FUNCTION_DISABLED:{code:107326,message:"quick comment function disabled"},V2NIM_ERROR_CODE_PIN_FUNCTION_DISABLED:{code:107327,message:"PIN function disabled"},V2NIM_ERROR_CODE_TEAM_READ_RECEIPT_FUNCTION_DISABLED:{code:107324,message:"read receipt for team messages function disabled"},V2NIM_ERROR_CODE_P2P_READ_RECEIPT_FUNCTION_DISABLED:{code:107325,message:"read receipt for p2p messages function disabled"},V2NIM_ERROR_CODE_RATE_LIMIT_FOR_MESSAGING_REACHED:{code:107323,message:"rate limit for messaging reached"},V2NIM_ERROR_CODE_MESSAGE_HIT_ANTISPAM:{code:107451,message:"message hit antispam"},V2NIM_ERROR_CODE_MESSAGE_NOT_EXIST:{code:107404,message:"message not exist"},V2NIM_ERROR_CODE_UNSENDING_MESSAGE_EXPIRED:{code:107406,message:"unsending message expired"},V2NIM_ERROR_CODE_TEAM_MARK_READ_FAILED:{code:107302,message:"sending message failed for marking message read failed for too many team members"},V2NIM_ERROR_CODE_SENDER_OR_MANAGER_PERMISSION_ONLY_REVOKE:{code:107303,message:"only sender or manager can revoke message"},V2NIM_ERROR_CODE_DELETE_SELF_MESSAGE_NOT_ALLOWED:{code:107328,message:"delete self message not allowed"},V2NIM_ERROR_CODE_NOT_CHATBOT_ACCOUNT:{code:107329,message:"is not chatbot account"},V2NIM_ERROR_CODE_MESSAGE_SENSE_REQUIRED:{code:107330,message:"sender or receiver must sense message"},V2NIM_ERROR_CODE_HIGH_PRIORITY_MESSAGE_RATE_LIMIT:{code:107304,message:"rate limit of high-priority messages exceeded"},ACK_MESSAGE_BE_HIGH_PRIORITY:{code:107305,message:"ack message should be high-priority"},V2NIM_ERROR_CODE_DUPLICATE_CLIENT_MESSAGE_ID:{code:107306,message:"duplicate client message ID"},V2NIM_ERROR_CODE_INVALID_TIME_RANGE:{code:107439,message:"invalid time range"},V2NIM_ERROR_CODE_NOT_ADVANCED_TEAM:{code:108302,message:"not advanced team"},V2NIM_ERROR_CODE_TEAM_MANAGER_LIMIT:{code:108303,message:"team manager limit"},V2NIM_ERROR_CODE_JOINED_TEAM_LIMIT:{code:108305,message:"joined team limit"},V2NIM_ERROR_CODE_TEAM_NORMAL_MEMBER_CHAT_BANNED:{code:108306,message:"team normal member chat banned"},V2NIM_ERROR_CODE_INVITED_ACCOUNT_NOT_FRIEND:{code:108307,message:"invited account not friend"},V2NIM_ERROR_CODE_REJECT_ALL_TEAM_APPLICATIONS:{code:108308,message:"reject all team applications"},V2NIM_ERROR_CODE_TARGETING_MESSAGE_FOR_TEAM_DISABLED:{code:108318,message:"Targeting messages for group chat is disabled"},V2NIM_ERROR_CODE_INCLUSIVE_AS_FALSE_NOT_ALLOWED_FOR_SUPER_TEAM:{code:108319,message:'Setting "inclusive" to false for super teams is not allowed'},V2NIM_ERROR_CODE_CANNOT_MAKE_SUPER_TEAM_MESSAGE_VISIBLE_TO_NEW_MEMBERS:{code:108320,message:"Cannot make super team targeted messages visible to new members"},V2NIM_ERROR_CODE_CANNOT_ALLOW_TARGETED_MESSAGES_INCLUSIVE_TO_NEW_MEMBERS:{code:108321,message:"Cannot allow targeted messages inclusive to new members"},V2NIM_ERROR_CODE_TEAM_NOT_EXIST:{code:108404,message:"team not exist"},V2NIM_ERROR_CODE_TEAM_ALREADY_CHAT_BANNED:{code:108420,message:"team already chat banned"},V2NIM_ERROR_CODE_ALL_TEAM_MEMBER_CHAT_BANNED:{code:108423,message:"all team member chat banned"},V2NIM_ERROR_CODE_EXTENDED_SUPER_TEAM_LIMIT:{code:108434,message:"extended super team limit"},V2NIM_ERROR_CODE_CREATED_TEAM_LIMIT:{code:108435,message:"created team limit"},V2NIM_ERROR_CODE_TEAM_INVITATION_LIMIT:{code:108437,message:"team invitation limit"},V2NIM_ERROR_CODE_TEAM_HIT_ANTISPAM:{code:108451,message:"team hit antispam"},V2NIM_ERROR_CODE_EXTENDED_SUPER_TEAM_LIMIT_NOT_CONFIGURED:{code:108304,message:"extended super team limit not configured"},V2NIM_ERROR_CODE_SUPER_TEAM_SERVICE_DISABLED:{code:108311,message:"super team service disabled"},V2NIM_ERROR_CODE_TEAM_READ_RECEIPT_RECORD_NOT_FOUND:{code:108301,message:"read receipt record for the team message not found"},V2NIM_ERROR_CODE_NOT_MANAGER:{code:108430,message:"unable to assign owner manager"},V2NIM_ERROR_CODE_ONLINE_MEMBER_COUNT_DISABLED:{code:108406,message:"number of online users service disabled"},V2NIM_ERROR_CODE_TRANSFER_DISABLED:{code:108310,message:"unable to transfer the ownership to owner"},V2NIM_ERROR_CODE_CREATE_TEAM_DISABLED:{code:108309,message:"unable to create team with more than %s people"},V2NIM_ERROR_CODE_EXTENDED_SUPER_TEAM_CREATE_FAILED:{code:108313,message:"/ extended super team creation failed,use open api to create the team"},V2NIM_ERROR_CODE_TEAM_MESSAGE_READ_RECEIPT_DISABLED:{code:108312,message:"read receipt for team messages function disabled"},V2NIM_ERROR_CODE_RETRY:{code:108449,message:"an error occurred, try again"},V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_NOT_TEAM_MEMBER:{code:109301,message:"list of chat banned users contains non team members"},V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_OPERATOR:{code:109303,message:"list of chat banned users contains the operator"},V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_TEAM_OWNER:{code:109304,message:"list of chat banned users contains the team owner"},V2NIM_ERROR_CODE_OPERATION_ON_TEAM_MANAGER_NOT_ALLOWED:{code:109305,message:"operation on team manager not allowed"},V2NIM_ERROR_CODE_NO_TEAM_INVITE_PERMISSION:{code:109306,message:"no team invite permission"},V2NIM_ERROR_CODE_TEAM_OWNER_QUIT_NOT_ALLOWED:{code:109307,message:"team owner quit not allowed"},V2NIM_ERROR_CODE_TEAM_OWNER_IN_KICK_LIST:{code:109308,message:"list of kicked user contains the team owner"},V2NIM_ERROR_CODE_INVITE_ROBOT_ACCOUNT_NOT_ALLOWED:{code:109309,message:"invite robot account not allowed"},V2NIM_ERROR_CODE_KICK_OPERATOR_NOT_ALLOWED:{code:109310,message:"kick operator not allowed"},V2NIM_ERROR_CODE_TEAM_MEMBER_ALREADY_EXIST:{code:109311,message:"team member already exist"},V2NIM_ERROR_CODE_TEAM_INVITATION_OR_APPLICATION_NOT_EXIST:{code:109313,message:"team invitation or application not exist"},V2NIM_ERROR_CODE_OPERATION_ON_TEAM_OWNER_NOT_ALLOWED:{code:109314,message:"operation on team owner not allowed"},V2NIM_ERROR_CODE_FORCED_PUSH_LIST_INCLUDES_NON_TARGETED_ACCOUNTS:{code:109318,message:"The forced push list includes non-targeted accounts"},V2NIM_ERROR_CODE_TEAM_MEMBER_NOT_EXIST:{code:109404,message:"team member not exist"},V2NIM_ERROR_CODE_TEAM_MEMBER_CHAT_BANNED:{code:109424,message:"team member chat banned"},V2NIM_ERROR_CODE_TEAM_OWNER_OPERATION_PERMISSION_REQUIRED:{code:109427,message:"team owner operation permission required"},V2NIM_ERROR_CODE_TEAM_OWNER_OR_MANAGER_OPERATION_PERMISSION_REQUIRED:{code:109432,message:"team owner or manager operation permission required"},V2NIM_ERROR_CODE_TEAM_MEMBER_CONCURRENT_OPERATION_FAILED:{code:109449,message:"team member concurrent operation failed"},V2NIM_ERROR_CODE_TEAM_MEMBER_HIT_ANTISPAM:{code:109451,message:"team member hit antispam"},V2NIM_ERROR_CODE_CONVERSATION_AND_ACCOUNT_MISMATCH:{code:110302,message:"conversation and account mismatch"},V2NIM_ERROR_CODE_CONVERSATION_STICK_TOP_LIMIT:{code:110303,message:"conversation stick top limit"},V2NIM_ERROR_CODE_CONVERSATION_BELONGED_GROUP_LIMIT:{code:110304,message:"conversation belonged group limit"},V2NIM_ERROR_CODE_CONVERSATION_IS_NOT_STICK_TOP:{code:110305,message:"conversation is not stick top"},V2NIM_ERROR_CODE_STICK_TOP_DISABLED:{code:110306,message:"conversation stick top disabled"},V2NIM_ERROR_CODE_CONVERSATION_NOT_EXIST:{code:110404,message:"conversation not exist"},V2NIM_ERROR_CODE_CHATROOM_LINK_UNAVAILABLE:{code:113304,message:"chatroom link unavailable"},V2NIM_ERROR_CODE_IM_CONNECTION_ABNORMAL:{code:113305,message:"IM connection abnormal"},V2NIM_ERROR_CODE_CHATROOM_NOT_EXIST:{code:113404,message:"chatroom not exist"},V2NIM_ERROR_CODE_CHATROOM_CLOSED:{code:113406,message:"chatroom closed"},V2NIM_ERROR_CODE_CHATROOM_REPEATED_OPERATION:{code:113409,message:"chatroom repeated operation"},V2NIM_ERROR_CODE_CHATROOM_DISABLED:{code:113410,message:"chatroom disabled"},V2NIM_ERROR_CODE_ALL_CHATROOM_MEMBER_CHAT_BANNED:{code:113423,message:"all chatroom member chat banned"},V2NIM_ERROR_CODE_CHATROOM_HIT_ANTISPAM:{code:113451,message:"chatroom hit antispam"},V2NIM_ERROR_CODE_ANONYMOUS_MEMBER_FORBIDDEN:{code:114303,message:"anonymous member forbidden"},V2NIM_ERROR_CODE_CHATROOM_MEMBER_NOT_EXIST:{code:114404,message:"chatroom member not exist"},V2NIM_ERROR_CODE_CHATROOM_MEMBER_REPEATED_OPERATION:{code:114405,message:"chatroom member repeated operation"},V2NIM_ERROR_CODE_CHATROOM_MEMBER_CHAT_BANNED:{code:114421,message:"chatroom member chat banned"},V2NIM_ERROR_CODE_ACCOUNT_IN_CHATROOM_BLOCK_LIST:{code:114426,message:"account in chatroom block list"},V2NIM_ERROR_CODE_CHATROOM_OWNER_OPERATION_PERMISSION_REQUIRED:{code:114427,message:"chatroom owner operation permission required"},V2NIM_ERROR_CODE_SELF_IN_CHATROOM_MEMBER_OPERATION_LIST:{code:114429,message:"self in chatroom member operation list"},V2NIM_ERROR_CODE_CHATROOM_OWNER_OR_MANAGER_OPERATION_PERMISSION_REQUIRED:{code:114432,message:"chatroom owner or manager operation permission required"},V2NIM_ERROR_CODE_CHATROOM_MEMBER_LIMIT:{code:114437,message:"chatroom member limit"},V2NIM_ERROR_CODE_CHATROOM_MEMBER_CONCURRENT_OPERATION_FAILED:{code:114449,message:"chatroom member concurrent operation failed"},V2NIM_ERROR_CODE_CHATROOM_MEMBER_HIT_ANTISPAM:{code:114451,message:"chatroom member hit antispam"},V2NIM_ERROR_CODE_CONVERSATION_GROUP_NOT_EXIST:{code:116404,message:"conversation group not exist"},V2NIM_ERROR_CODE_CONVERSATION_GROUP_LIMIT:{code:116435,message:"conversation group limit"},V2NIM_ERROR_CODE_CONVERSATIONS_IN_GROUP_LIMIT:{code:116437,message:"conversations in group limit"},V2NIM_ERROR_CODE_COLLECTION_LIMIT:{code:189301,message:"collection limit"},V2NIM_ERROR_CODE_COLLECTION_NOT_EXIST:{code:189302,message:"collection not exist"},V2NIM_ERROR_CODE_COLLECTION_CONCURRENT_OPERATION_FAILED:{code:189449,message:"collection concurrent operation failed"},V2NIM_ERROR_CODE_INTERNAL:{code:190001,message:"internal error"},V2NIM_ERROR_CODE_ILLEGAL_STATE:{code:190002,message:"illegal state"},V2NIM_ERROR_CODE_MISUSE:{code:191001,message:"misuse"},V2NIM_ERROR_CODE_CANCELLED:{code:191002,message:"operation cancelled"},V2NIM_ERROR_CODE_CALLBACK_FAILED:{code:191003,message:"callback failed"},V2NIM_ERROR_CODE_INVALID_PARAMETER:{code:191004,message:"invalid parameter"},V2NIM_ERROR_CODE_TIMEOUT:{code:191005,message:"timeout"},V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST:{code:191006,message:"resource not exist"},V2NIM_ERROR_CODE_RESOURCE_ALREADY_EXIST:{code:191007,message:"resource already exist"},V2NIM_ERROR_CODE_CONNECT_FAILED:{code:192001,message:"connect failed"},V2NIM_ERROR_CODE_CONNECT_TIMEOUT:{code:192002,message:"connect timeout"},V2NIM_ERROR_CODE_DISCONNECT:{code:192003,message:"disconnect"},V2NIM_ERROR_CODE_PROTOCOL_TIMEOUT:{code:192004,message:"protocol timeout"},V2NIM_ERROR_CODE_PROTOCOL_SEND_FAILED:{code:192005,message:"protocol send failed"},V2NIM_ERROR_CODE_REQUEST_FAILED:{code:192006,message:"request failed"},V2NIM_ERROR_CODE_FILE_NOT_FOUND:{code:194001,message:"file not found"},V2NIM_ERROR_CODE_FILE_CREATE_FAILED:{code:194002,message:"file create failed"},V2NIM_ERROR_CODE_FILE_OPEN_FAILED:{code:194003,message:"file open failed"},V2NIM_ERROR_CODE_FILE_WRITE_FAILED:{code:194004,message:"file write failed"},V2NIM_ERROR_CODE_FILE_READ_FAILED:{code:194005,message:"file read failed"},V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:{code:194006,message:"file upload failed"},V2NIM_ERROR_CODE_FILE_DOWNLOAD_FAILED:{code:194007,message:"file download failed"},V2NIM_ERROR_CODE_CLIENT_ANTISPAM:{code:195001,message:"client anti-spam"},V2NIM_ERROR_CODE_SERVER_ANTISPAM:{code:195002,message:"server anti-spam"},V2NIM_ERROR_CODE_STREAM_OUTPUT_STOPPED:{code:189318,message:"Streaming text response stopped"},V2NIM_ERROR_CODE_STREAM_OUTPUT_GENERATED:{code:189319,message:"Streaming text response generated"},V2NIM_ERROR_CODE_STREAM_OUTPUT_ABORTED:{code:189320,message:"Streaming text response aborted due to exception"},V2NIM_ERROR_CODE_INTERRUPTION_REJECTED:{code:189321,message:"Non-streaming messages cannot be interrupted"}},$l=Ht(jl),zl=reduce($l).call($l,(function(t,i){var u=jl[i];return t[i]=u.code,t}),{}),Wl=reduce($l).call($l,(function(t,i){var u=jl[i];return t[u.code]=u.message,t}),{}),Kl=Object.freeze({__proto__:null,V2NIMErrorCode:zl,V2NIMErrorDesc:Wl,get V2NIMDataSyncLevel(){return Bc},get V2NIMDataSyncType(){return qc},get V2NIMDataSyncState(){return Fc},get V2NIMConversationType(){return Gc},get V2NIMLastMessageState(){return Hc},get V2NIMFriendAddMode(){return jc},get V2NIMFriendAddApplicationType(){return $c},get V2NIMFriendAddApplicationStatus(){return zc},get V2NIMFriendDeletionType(){return Wc},get V2NIMFriendVerifyType(){return Kc},get V2NIMLoginAuthType(){return Yc},get V2NIMLoginStatus(){return Qc},get V2NIMLoginClientType(){return Jc},get V2NIMKickedOfflineReason(){return Xc},get V2NIMLoginClientChange(){return Zc},get V2NIMConnectStatus(){return el},get V2NIMMessageType(){return il},get V2NIMMessageNotificationType(){return cl},get V2NIMMessageAttachmentUploadState(){return ll},get V2NIMMessageSendingState(){return dl},get V2NIMQueryDirection(){return ul},get V2NIMMessageRevokeType(){return ml},get V2NIMMessagePinState(){return hl},get V2NIMMessageQuickCommentType(){return gl},get V2NIMClientAntispamOperateType(){return vl},get V2NIMSortOrder(){return fl},get V2NIMSystemMessageType(){return yl},get V2NIMMessageAIStreamStatus(){return tl},get V2NIMMessageAIStreamStopOpType(){return rl},get V2NIMMessageAIRegenOpType(){return nl},get V2NIMMessageAIStatus(){return al},get V2NIMSearchKeywordMatchType(){return ol},get V2NIMClearHistoryMode(){return pl},get V2NIMMessageStreamStatus(){return Ml},get V2NIMTeamMessageMuteMode(){return _l},get V2NIMP2PMessageMuteMode(){return Sl},get V2NIMTeamMemberRoleQueryType(){return Cl},get V2NIMTeamType(){return bl},get V2NIMTeamJoinMode(){return El},get V2NIMTeamAgreeMode(){return Al},get V2NIMTeamInviteMode(){return kl},get V2NIMTeamUpdateInfoMode(){return Rl},get V2NIMTeamChatBannedMode(){return wl},get V2NIMTeamUpdateExtensionMode(){return Nl},get V2NIMTeamJoinActionType(){return Ol},get V2NIMTeamJoinActionStatus(){return Pl},get V2NIMTeamNotificationType(){return Ll},get V2NIMTeamMemberRole(){return xl},get V2NIMTeamJoinActionTeamType(){return Tl},get V2NIMAIModelRoleType(){return Dl},get V2NIMAIModelType(){return Vl},get V2NIMAIModelStreamCallStatus(){return Ul},get V2NIMSignallingChannelType(){return ql},get V2NIMSignallingEventType(){return Bl},get V2NIMUserStatusType(){return Fl}}),Yl=function(t){function V2NIMErrorImpl(i){var u;return(u=t.call(this,i.desc)||this).name="V2NIMError",u.code=i.code||0,u.desc=i.desc||Wl[u.code]||td[u.code]||"",u.message=u.desc,u.detail=i.detail||{},u}return Nt(V2NIMErrorImpl,t),V2NIMErrorImpl.prototype.toString=function toString(){var t,i=this.name+"\n code: "+this.code+'\n message: "'+this.message+'"\n detail: '+(this.detail?Un(this.detail):"");return(null===(t=null==this?void 0:this.detail)||void 0===t?void 0:t.rawError)&&(i+="\n rawError: "+this.detail.rawError.message),i},V2NIMErrorImpl}(Lc(Error));var Ql=function(t){function ValidateError(i,u,m){var h;return void 0===u&&(u={}),(h=t.call(this,{code:zl.V2NIM_ERROR_CODE_PARAMETER_ERROR,detail:{reason:i,rules:m,data:u}})||this).name="validateError",h.message=h.message+"\n"+Un(h.detail,null,2),h.data=u,h.rules=m,h}return Nt(ValidateError,t),ValidateError}(Yl),Jl=function(t){function ValidateErrorV2(i){var u,m,h,v;return(u=t.call(this,{code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:null===(m=i.detail)||void 0===m?void 0:m.reason,rules:null===(h=i.detail)||void 0===h?void 0:h.rules,data:null===(v=i.detail)||void 0===v?void 0:v.data}})||this).name="ValidateErrorV2",u}return Nt(ValidateErrorV2,t),ValidateErrorV2}(Yl),Xl=function(t){function FormatError(i,u,m){var h;return(h=t.call(this,{code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:i,key:u,rules:m}})||this).name="formatError",h}return Nt(FormatError,t),FormatError}(Yl),Zl=function(t){function UploadError(i){var u;return(u=t.call(this,Dt({code:400},i))||this).desc=u.desc||"upload file error",u.message=u.desc,u.name="uploadError",u}return Nt(UploadError,t),UploadError}(Yl),ed=function(t){function CustomError(i,u,m){var h;return void 0===u&&(u={}),void 0===m&&(m=400),(h=t.call(this,{code:m,desc:i,detail:u})||this).name="customError",h.data=u,h}return Nt(CustomError,t),CustomError}(Yl),td={200:null,406:null,808:null,810:null,302:"The user name or password is incorrect.",405:"Parameter length too long",408:"Client request timed out",415:"Client network unavailable",422:"Account disabled",508:"Expiration date",509:"Invalid",7101:"Be pulled black",700:"Partial failure of batch operation",801:"The number of people in the team has reached the upper limit",802:"No permission",803:"The team does not exist or has not changed",804:"The user is not in the team",805:"Team type mismatch",806:"The number of teams created has reached the limit",807:"Team member not valid",809:"Already in the team",811:"The number of accounts in the forced push list exceeds the limit",812:"The team is muted",813:"Due to the limited number of team, some pull people successfully",814:"Disable team message read service",815:"Maximum number of team administrators",816:"Batch operation partial failure",9102:"Channel failure",9103:"This call has been answered / rejected at another end",10201:"Signaling: target NIM client is offline",10202:"Signaling: push is unreachable",10404:"Signaling: channel not exists",10405:"Signaling: channel already exists",10406:"Signaling: member of channel not exists",10407:"Signaling: member of channel already exists",10408:"Signaling: the invitation request does not exist or has expired",10409:"Signaling: the invitation request has been rejected",10410:"Signaling: the invitation request has been accepted",10414:"Signaling: request parameter error",10417:"Signaling: uid conflict",10419:"Signaling: the number of members of channel exceed the limit",10420:"Signaling: member is already in the channel on other client",10700:"Signaling: phased success",13002:"Abnormal chatroom status",13003:"In the blacklist",13004:"In the mute list",13006:"All members are muted, and only the administrator can speak"};function difference(t,i){return i=i||[],filter(t=t||[]).call(t,(function(t){return-1===indexOf(i).call(i,t)}))}function replacer(t,i){return i instanceof RegExp?"__REGEXP "+i.toString():i}function validate(t,i,u,m){var h;void 0===i&&(i={}),void 0===m&&(m=!1);var v={};return forEach$1(h=Ht(t)).call(h,(function(h){var M=t[h].type,I=u?"In "+u+", ":"";if(null==i){var S=I+"param is null or undefined";throw m?new Jl({detail:{reason:S,data:{key:h},rules:"required"}}):new Ql(S,{key:h},"required")}if(void 0===i[h]){if(!1===t[h].required)return void(v[h]=i[h]);var T=I+"param '"+h+"' is required";throw m?new Jl({detail:{reason:T,data:{key:h},rules:"required"}}):new Ql(T,{key:h},"required")}var C=rd[M];if(C&&!C(i,h,t[h],m)){var E=I+"param '"+h+"' unexpected",A={key:h,value:i[h]};throw m?new Jl({detail:{reason:E,data:A,rules:Un(t[h],replacer)}}):new Ql(E,A,Un(t[h],replacer))}v[h]=i[h]})),v}var rd={string:function string(t,i,u){var m=u.allowEmpty,h=u.max,v=u.min,M=u.regExp,I=t[i];return"string"==typeof I&&((!1!==m||""!==I)&&(!("number"==typeof h&&I.length>h)&&(!("number"==typeof v&&I.length<v)&&!(function isRegExp(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(M)&&!M.test(I)))))},number:function number(t,i,u){var m=u.min,h=u.max,v=t[i];return"number"==typeof v&&(!("number"==typeof m&&v<m)&&!("number"==typeof h&&v>h))},boolean:function boolean(t,i){return"boolean"==typeof t[i]},file:function file(t,i){return!0},enum:function _enum(t,i,u){var m=values(u),h=t[i];return!m||indexOf(m).call(m,h)>-1},jsonstr:function jsonstr(t,i){try{var u=JSON.parse(t[i]);return"object"==typeof u&&null!==u}catch(t){return!1}},func:function func(t,i){return"function"==typeof t[i]},array:function array(t,i,u,m){void 0===m&&(m=!1);var h=u.itemType,v=u.itemRules,M=u.rules,I=u.min,S=u.max,T=values(u),C=t[i];if(!Dn(C))return!1;if("number"==typeof S&&C.length>S)return!1;if("number"==typeof I&&C.length<I)return!1;if(v)forEach$1(C).call(C,(function(t,u){var h,M;validate(((h={})[u]=v,h),((M={})[u]=t,M),i+"["+u+"]",m)}));else if(M)forEach$1(C).call(C,(function(t,u){return validate(M,t,i+"["+u+"]",m)}));else if("enum"===h){if(T&&difference(C,T).length)return!1}else if(h&&!every(C).call(C,(function(t){return typeof t===h})))return!1;return!0},object:function object(t,i,u,m){void 0===m&&(m=!1);var h=u.rules,v=u.allowEmpty,M=t[i];if("object"!=typeof M||null===M)return!1;if(h){var I=Ht(h),S=Ht(M),T=filter(S).call(S,(function(t){return indexOf(I).call(I,t)>-1}));if(!1===v&&0===T.length)return!1;validate(h,M,i,m)}return!0}};function validateConversationId(t,i){if(!t)throw new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE});validate({conversationId:{type:"string",allowEmpty:!1,regExp:new RegExp("^"+t+"\\|[1-3]\\|")}},{conversationId:i},"",!0)}var callWithSafeIterationClosing=function(t,i,u,m){try{return m?i(anObject(u)[0],u[1]):i(u)}catch(i){iteratorClose(t,"throw",i)}},nd=Array,ad=!checkCorrectnessOfIteration((function(t){Array.from(t)}));_export({target:"Array",stat:!0,forced:ad},{from:function from(t){var i=toObject(t),u=Jr(this),m=arguments.length,h=m>1?arguments[1]:void 0,v=void 0!==h;v&&(h=functionBindContext(h,m>2?arguments[2]:void 0));var M,I,S,T,C,E,A=getIteratorMethod$5(i),k=0;if(!A||this===nd&&isArrayIteratorMethod(A))for(M=lengthOfArrayLike(i),I=u?new this(M):nd(M);M>k;k++)E=v?h(i[k],k):i[k],createProperty(I,k,E);else for(C=(T=getIterator(i,A)).next,I=u?new this:[];!(S=x(C,T)).done;k++)E=v?callWithSafeIterationClosing(T,h,[S.value,k],!0):S.value,createProperty(I,k,E);return I.length=k,I}});var id=$.Array.from,od=getIteratorMethod$5;function _createForOfIteratorHelperLoose$d(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$d(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$d(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$d(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$d(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var sd=function(){function TimerManager(){this.timerList=[],this.id=1,this.timer=null,this.timeout=0}var t=TimerManager.prototype;return t.addTimer=function addTimer(t,i,u){void 0===i&&(i=0),void 0===u&&(u=1);var m=(new Date).getTime(),h=this.id;return this.timerList.push({id:h,loop:u,count:0,timeout:m+i,interval:i,callback:t}),this.id++,this.checkTimer(m),h},t.checkTimer=function checkTimer(t){if(void 0===t&&(t=(new Date).getTime()),this.removeFinished(),0!==this.timerList.length||null==this.timer){for(var i,u,m=0,h=_createForOfIteratorHelperLoose$d(this.timerList);!(i=h()).done;){var v=i.value;(0===m||m>v.timeout)&&(m=v.timeout)}if(0!==this.timerList.length)if(null===this.timer||m<this.timeout||this.timeout<t)this.timer=mo(bind$1(u=this.nowTime).call(u,this),m-t),this.timeout=m}},t.nowTime=function nowTime(){for(var t,nowTime=(new Date).getTime(),i=_createForOfIteratorHelperLoose$d(this.timerList);!(t=i()).done;){var u=t.value;nowTime>=u.timeout&&(u.callback(),u.count++,u.timeout=nowTime+u.interval)}this.clerTime(),this.checkTimer(nowTime)},t.clerTime=function clerTime(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)},t.deleteTimer=function deleteTimer(t){for(var i=this.timerList.length-1;i>=0;i--){var u;if(this.timerList[i].id===t)splice(u=this.timerList).call(u,i,1)}},t.removeFinished=function removeFinished(){for(var t=this.timerList.length-1;t>=0;t--){var i,u=this.timerList[t];if(u.loop>=0&&u.count>=u.loop)splice(i=this.timerList).call(i,t,1)}},t.destroy=function destroy(){this.clerTime(),this.timerList=[],this.id=1,this.timer=null},TimerManager}(),cd=createCommonjsModule((function(t){function _typeof(i){return t.exports=_typeof="function"==typeof es&&"symbol"==typeof ms?function(t){return typeof t}:function(t){return t&&"function"==typeof es&&t.constructor===es&&t!==es.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,_typeof(i)}t.exports=_typeof,t.exports.__esModule=!0,t.exports.default=t.exports})),ld=createCommonjsModule((function(t){var i=cd.default;function _regeneratorRuntime(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
t.exports=_regeneratorRuntime=function _regeneratorRuntime(){return u},t.exports.__esModule=!0,t.exports.default=t.exports;var u={},m=Object.prototype,h=m.hasOwnProperty,v="function"==typeof es?es:{},M=v.iterator||"@@iterator",I=v.asyncIterator||"@@asyncIterator",S=v.toStringTag||"@@toStringTag";function define(t,i,u){return Ye(t,i,{value:u,enumerable:!0,configurable:!0,writable:!0}),t[i]}try{define({},"")}catch(t){define=function define(t,i,u){return t[i]=u}}function wrap(t,i,u,m){var h=i&&i.prototype instanceof Generator?i:Generator,v=ft(h.prototype),M=new Context(m||[]);return v._invoke=function(t,i,u){var m="suspendedStart";return function(h,v){if("executing"===m)throw new Error("Generator is already running");if("completed"===m){if("throw"===h)throw v;return doneResult()}for(u.method=h,u.arg=v;;){var M=u.delegate;if(M){var I=maybeInvokeDelegate(M,u);if(I){if(I===T)continue;return I}}if("next"===u.method)u.sent=u._sent=u.arg;else if("throw"===u.method){if("suspendedStart"===m)throw m="completed",u.arg;u.dispatchException(u.arg)}else"return"===u.method&&u.abrupt("return",u.arg);m="executing";var S=tryCatch(t,i,u);if("normal"===S.type){if(m=u.done?"completed":"suspendedYield",S.arg===T)continue;return{value:S.arg,done:u.done}}"throw"===S.type&&(m="completed",u.method="throw",u.arg=S.arg)}}}(t,u,M),v}function tryCatch(t,i,u){try{return{type:"normal",arg:t.call(i,u)}}catch(t){return{type:"throw",arg:t}}}u.wrap=wrap;var T={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var C={};define(C,M,(function(){return this}));var E=rs&&rs(rs(values([])));E&&E!==m&&h.call(E,M)&&(C=E);var A=GeneratorFunctionPrototype.prototype=Generator.prototype=ft(C);function defineIteratorMethods(t){var i;forEach$1(i=["next","throw","return"]).call(i,(function(i){define(t,i,(function(t){return this._invoke(i,t)}))}))}function AsyncIterator(t,u){function invoke(m,v,M,I){var S=tryCatch(t[m],t,v);if("throw"!==S.type){var T=S.arg,C=T.value;return C&&"object"==i(C)&&h.call(C,"__await")?u.resolve(C.__await).then((function(t){invoke("next",t,M,I)}),(function(t){invoke("throw",t,M,I)})):u.resolve(C).then((function(t){T.value=t,M(T)}),(function(t){return invoke("throw",t,M,I)}))}I(S.arg)}var m;this._invoke=function(t,i){function callInvokeWithMethodAndArg(){return new u((function(u,m){invoke(t,i,u,m)}))}return m=m?m.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,i){var u=t.iterator[i.method];if(void 0===u){if(i.delegate=null,"throw"===i.method){if(t.iterator.return&&(i.method="return",i.arg=void 0,maybeInvokeDelegate(t,i),"throw"===i.method))return T;i.method="throw",i.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var m=tryCatch(u,t.iterator,i.arg);if("throw"===m.type)return i.method="throw",i.arg=m.arg,i.delegate=null,T;var h=m.arg;return h?h.done?(i[t.resultName]=h.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=void 0),i.delegate=null,T):h:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,T)}function pushTryEntry(t){var i={tryLoc:t[0]};1 in t&&(i.catchLoc=t[1]),2 in t&&(i.finallyLoc=t[2],i.afterLoc=t[3]),this.tryEntries.push(i)}function resetTryEntry(t){var i=t.completion||{};i.type="normal",delete i.arg,t.completion=i}function Context(t){this.tryEntries=[{tryLoc:"root"}],forEach$1(t).call(t,pushTryEntry,this),this.reset(!0)}function values(t){if(t){var i=t[M];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var u=-1,m=function next(){for(;++u<t.length;)if(h.call(t,u))return next.value=t[u],next.done=!1,next;return next.value=void 0,next.done=!0,next};return m.next=m}}return{next:doneResult}}function doneResult(){return{value:void 0,done:!0}}return GeneratorFunction.prototype=GeneratorFunctionPrototype,define(A,"constructor",GeneratorFunctionPrototype),define(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,S,"GeneratorFunction"),u.isGeneratorFunction=function(t){var i="function"==typeof t&&t.constructor;return!!i&&(i===GeneratorFunction||"GeneratorFunction"===(i.displayName||i.name))},u.mark=function(t){return _t?_t(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,S,"GeneratorFunction")),t.prototype=ft(A),t},u.awrap=function(t){return{__await:t}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,I,(function(){return this})),u.AsyncIterator=AsyncIterator,u.async=function(t,i,m,h,v){void 0===v&&(v=zi);var M=new AsyncIterator(wrap(t,i,m,h),v);return u.isGeneratorFunction(i)?M:M.next().then((function(t){return t.done?t.value:M.next()}))},defineIteratorMethods(A),define(A,S,"Generator"),define(A,M,(function(){return this})),define(A,"toString",(function(){return"[object Generator]"})),u.keys=function(t){var i=[];for(var u in t)i.push(u);return reverse$1(i).call(i),function next(){for(;i.length;){var u=i.pop();if(u in t)return next.value=u,next.done=!1,next}return next.done=!0,next}},u.values=values,Context.prototype={constructor:Context,reset:function reset(t){var i;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,forEach$1(i=this.tryEntries).call(i,resetTryEntry),!t)for(var u in this)"t"===u.charAt(0)&&h.call(this,u)&&!isNaN(+slice(u).call(u,1))&&(this[u]=void 0)},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function dispatchException(t){if(this.done)throw t;var i=this;function handle(u,m){return v.type="throw",v.arg=t,i.next=u,m&&(i.method="next",i.arg=void 0),!!m}for(var u=this.tryEntries.length-1;u>=0;--u){var m=this.tryEntries[u],v=m.completion;if("root"===m.tryLoc)return handle("end");if(m.tryLoc<=this.prev){var M=h.call(m,"catchLoc"),I=h.call(m,"finallyLoc");if(M&&I){if(this.prev<m.catchLoc)return handle(m.catchLoc,!0);if(this.prev<m.finallyLoc)return handle(m.finallyLoc)}else if(M){if(this.prev<m.catchLoc)return handle(m.catchLoc,!0)}else{if(!I)throw new Error("try statement without catch or finally");if(this.prev<m.finallyLoc)return handle(m.finallyLoc)}}}},abrupt:function abrupt(t,i){for(var u=this.tryEntries.length-1;u>=0;--u){var m=this.tryEntries[u];if(m.tryLoc<=this.prev&&h.call(m,"finallyLoc")&&this.prev<m.finallyLoc){var v=m;break}}v&&("break"===t||"continue"===t)&&v.tryLoc<=i&&i<=v.finallyLoc&&(v=null);var M=v?v.completion:{};return M.type=t,M.arg=i,v?(this.method="next",this.next=v.finallyLoc,T):this.complete(M)},complete:function complete(t,i){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&i&&(this.next=i),T},finish:function finish(t){for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i];if(u.finallyLoc===t)return this.complete(u.completion,u.afterLoc),resetTryEntry(u),T}},catch:function _catch(t){for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i];if(u.tryLoc===t){var m=u.completion;if("throw"===m.type){var h=m.arg;resetTryEntry(u)}return h}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,i,u){return this.delegate={iterator:values(t),resultName:i,nextLoc:u},"next"===this.method&&(this.arg=void 0),T}},u}t.exports=_regeneratorRuntime,t.exports.__esModule=!0,t.exports.default=t.exports})),dd=ld(),ud=dd;try{regeneratorRuntime=dd}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=dd:Function("r","regeneratorRuntime = r")(dd)}function __rest(t,i){var u={};for(var m in t)Object.prototype.hasOwnProperty.call(t,m)&&i.indexOf(m)<0&&(u[m]=t[m]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(m=Object.getOwnPropertySymbols(t);h<m.length;h++)i.indexOf(m[h])<0&&Object.prototype.propertyIsEnumerable.call(t,m[h])&&(u[m[h]]=t[m[h]])}return u}function __awaiter(t,i,u,m){return new(u||(u=Promise))((function(h,v){function fulfilled(t){try{step(m.next(t))}catch(t){v(t)}}function rejected(t){try{step(m.throw(t))}catch(t){v(t)}}function step(t){t.done?h(t.value):function adopt(t){return t instanceof u?t:new u((function(i){i(t)}))}(t.value).then(fulfilled,rejected)}step((m=m.apply(t,i||[])).next())}))}function isPlainObject(t){return null!=t&&"object"==typeof t&&rs(t)==Object.prototype}function merge$1(t,i){var u=isPlainObject(t)||Dn(t),m=isPlainObject(i)||Dn(i);if(u&&m){for(var h in i){var v=merge$1(t[h],i[h]);void 0!==v&&(t[h]=v)}return t}return i}var pd={setLogger:function setLogger(t){throw new Error("setLogger not implemented.")},platform:"",WebSocket:function(){function AdapterSocket(t,i){throw this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.binaryType="",new Error("Method not implemented.")}var t=AdapterSocket.prototype;return t.close=function close(t,i){throw new Error("Method not implemented.")},t.send=function send(t){throw new Error("Method not implemented.")},t.onclose=function onclose(t){throw new Error("Method not implemented.")},t.onerror=function onerror(t){throw new Error("Method not implemented.")},t.onmessage=function onmessage(t){throw new Error("Method not implemented.")},t.onopen=function onopen(t){throw new Error("Method not implemented.")},AdapterSocket}(),localStorage:{},request:function request(t,i){throw new Error("request not implemented.")},uploadFile:function uploadFile(t){throw new Error("uploadFile not implemented.")},getSystemInfo:function getSystemInfo(){throw new Error("getSystemInfo not implemented.")},getFileUploadInformation:function getFileUploadInformation(t){throw new Error("getFileUploadInformation not implemented.")},envPayload:{},net:{getNetworkStatus:function getNetworkStatus(){return zi.resolve({net_type:0,net_connect:!0})},onNetworkStatusChange:function onNetworkStatusChange(t){},offNetworkStatusChange:function offNetworkStatusChange(){}},powerMonitor:{isActive:function isActive(){return!0},getStatus:function getStatus(){return 0},setStatus:function setStatus(t){},destroy:function destroy(){}},logStorage:function(){function AdapterLogStorageImpl(t){}var t=AdapterLogStorageImpl.prototype;return t.open=function open(){return zi.resolve()},t.close=function close(){},t.addLogs=function addLogs(t){return zi.resolve()},t.extractLogs=function extractLogs(){return zi.resolve()},t.afterUpload=function afterUpload(){return zi.resolve()},AdapterLogStorageImpl}()};var md=["error","warn","log","debug"],hd=function emptyFunc(){},gd=["off","error","warn","log","debug"],vd=function(){function Logger(t,i){void 0===i&&(i={}),this.storageArr=[],this.debugLevel="off",this.timer=0,this.strategies={debug:{name:"debg",func:console.log},log:{name:"info",func:console.log},warn:{name:"warn",func:console.warn},error:{name:"erro",func:console.error}},this.debug=hd,this.log=hd,this.warn=hd,this.error=hd,this.iid=Math.round(1e3*Math.random()),this.debugLevel=indexOf(gd).call(gd,t)>-1?t:"off",i.debugLevel&&(this.debugLevel=indexOf(gd).call(gd,i.debugLevel)>-1?i.debugLevel:this.debugLevel),this.logStorage=!1===i.storageEnable?null:new pd.logStorage({logDirPath:i.logDirPath||i.storageName||"nim_logs",logRetentionDays:i.logRetentionDays||10,totalLogSizeInMB:i.totalLogSizeInMB||200,maxLogFileSizeInMB:i.maxLogFileSizeInMB||10}),this.setOptions(i),this.setLogFunc(this.debugLevel),this.setTimer(),pd.setLogger(this),this.open()}var t=Logger.prototype;return t.getDebugMode=function getDebugMode(){return"debug"===this.debugLevel},t.open=function open(){var t=this;this.logStorage&&this.logStorage.open().then((function(){t.log("Logger::open success")})).catch((function(i){t.warn("Logger::open failed",i)}))},t.setOptions=function setOptions(t){if(t&&t.logFunc){var i=t.logFunc;for(var u in i){var m=u,h=i[m];h&&(this.strategies[m].func=h)}}},t.setLogFunc=function setLogFunc(t,i){var u=this;void 0===i&&(i="log");var m=findIndex$1(md).call(md,(function(i){return i===t})),h=findIndex$1(md).call(md,(function(t){return t===i}));forEach$1(md).call(md,(function(t,i){u[t]=function(){if(!(i>m&&i>h)){var u=slice(Array.prototype).call(arguments),v=this.strategies[t],M=this.formatArgs(u,v.name);i<=h&&this.logStorage&&this.prepareSaveLog(M,t),i<=m&&v.func(M)}}}))},t.extractLogs=function extractLogs(){var t;return this.logStorage?null===(t=this.logStorage)||void 0===t?void 0:t.extractLogs():zi.resolve("")},t.afterUpload=function afterUpload(){var t;return this.logStorage?null===(t=this.logStorage)||void 0===t?void 0:t.afterUpload():zi.resolve("")},t.prepareSaveLog=function prepareSaveLog(t,i){this.storageArr.push({text:t,level:i,time:to(),iid:this.iid}),this.timer||this.setTimer(),this.storageArr.length>=100&&(this.triggerTimer(),this.storageArr=[])},t.saveLogs=function saveLogs(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t;return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(this.logStorage){i.next=2;break}return i.abrupt("return");case 2:return t=this.storageArr,this.storageArr=[],i.prev=4,i.next=7,this.logStorage.addLogs(t);case 7:i.next=11;break;case 9:i.prev=9,i.t0=i.catch(4);case 11:case"end":return i.stop()}}),_callee,this,[[4,9]])})))},t.clearTimer=function clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=0},t.setTimer=function setTimer(){var t;this.clearTimer(),this.timer=mo(bind$1(t=this.triggerTimer).call(t,this),5e3)},t.triggerTimer=function triggerTimer(){this.clearTimer(),this.saveLogs()},t.formatArgs=function formatArgs(t,i){var u=new Date;return"[NIM "+this.iid+" "+i+" "+(u.getMonth()+1+"-"+u.getDate()+" "+u.getHours()+":"+u.getMinutes()+":"+u.getSeconds()+":"+u.getMilliseconds())+"] "+map$6(t).call(t,(function(t){return t instanceof Yl?t.toString():t instanceof Error?t&&t.message?t.message:t:"object"==typeof t?Un(t):t})).join(" ")},t.destroy=function destroy(){this.debug=hd,this.log=hd,this.warn=hd,this.error=hd,this.saveLogs(),this.clearTimer(),this.storageArr=[],this.logStorage&&this.logStorage.close()},Logger}(),fd=Math.min,yd=[].lastIndexOf,Md=!!yd&&1/[1].lastIndexOf(1,-0)<0,Id=arrayMethodIsStrict("lastIndexOf"),_d=Md||!Id?function lastIndexOf(t){if(Md)return T(yd,this,arguments)||0;var i=toIndexedObject(this),u=lengthOfArrayLike(i),m=u-1;for(arguments.length>1&&(m=fd(m,toIntegerOrInfinity(arguments[1]))),m<0&&(m=u+m);m>=0;m--)if(m in i&&i[m]===t)return m||0;return-1}:yd;_export({target:"Array",proto:!0,forced:_d!==[].lastIndexOf},{lastIndexOf:_d});var Sd,Td=entryVirtual("Array").lastIndexOf,Cd=Array.prototype,lastIndexOf=function(t){var i=t.lastIndexOf;return t===Cd||z(Cd,t)&&i===Cd.lastIndexOf?Td:i},bd="\t\n\v\f\r                 \u2028\u2029\ufeff",Ed=R("".replace),Ad="["+bd+"]",kd=RegExp("^"+Ad+Ad+"*"),Rd=RegExp(Ad+Ad+"*$"),createMethod=function(t){return function(i){var u=toString(requireObjectCoercible(i));return 1&t&&(u=Ed(u,kd,"")),2&t&&(u=Ed(u,Rd,"")),u}},wd={start:createMethod(1),end:createMethod(2),trim:createMethod(3)},Nd=cr.PROPER,xd=wd.trim;_export({target:"String",proto:!0,forced:(Sd="trim",fails((function(){return!!bd[Sd]()||"​…᠎"!=="​…᠎"[Sd]()||Nd&&bd[Sd].name!==Sd})))},{trim:function trim(){return xd(this)}});var Od=entryVirtual("String").trim,Pd=String.prototype,trim$2=function(t){var i=t.trim;return"string"==typeof t||t===Pd||z(Pd,t)&&i===Pd.trim?Od:i};var Ld=wd.trim,Vd=h.parseInt,Ud=h.Symbol,Dd=Ud&&Ud.iterator,Bd=/^[+-]?0x/i,qd=R(Bd.exec),Fd=8!==Vd(bd+"08")||22!==Vd(bd+"0x16")||Dd&&!fails((function(){Vd(Object(Dd))}))?function parseInt(t,i){var u=Ld(toString(t));return Vd(u,i>>>0||(qd(Bd,u)?16:10))}:Vd;_export({global:!0,forced:parseInt!=Fd},{parseInt:Fd});var Gd=$.parseInt;function get(t,i){if("object"!=typeof t||null===t)return t;for(var u=(i=i||"").split("."),m=0;m<u.length;m++){var h=u[m],v=t[h],M=indexOf(h).call(h,"["),I=indexOf(h).call(h,"]");if(-1!==M&&-1!==I&&M<I){var S=slice(h).call(h,0,M),T=Gd(slice(h).call(h,M+1,I));v=t[S],v=Dn(v)?v[T]:void 0}if(null==v)return v;t=v}return t}var Hd,jd=(Hd=function _s4(){return(65536*(1+Math.random())|0).toString(16).substring(1)},function(){return Hd()+Hd()+Hd()+Hd()+Hd()+Hd()+Hd()+Hd()});function getEnumKeys(t){var i;return filter(i=Ht(t)).call(i,(function(t){return!(+t>=0)}))}function getEnumKeyByEnumValue(t,i){var u,m=filter(u=Ht(t)).call(u,(function(u){return t[u]==i}));return m.length>0?m[0]:void 0}function getAccountFromSessionId(t,i){if(void 0===i&&(i="-"),!t)throw new ed("No sessionId",{},400);var u=indexOf(t).call(t,i);if(-1===u)throw new ed("Can not find conjunctions",{},400);var m=slice(t).call(t,0,u);return{accid:slice(t).call(t,u+1),scene:"super_team"===m?"superTeam":m}}function pendingIsMiniappEnv(){var t=pd.getSystemInfo().hostEnvEnum;return 6===t||102===t||103===t||104===t}function assignOptions(t,i){return function assignWith(t,i,u,m){for(var h in t=t||{},u=u||{},m=m||function(){},i=i||{}){var v=m(t[h],i[h]);t[h]=void 0===v?i[h]:v}for(var M in u){var I=m(t[M],u[M]);t[M]=void 0===I?u[M]:I}return t}({},t,i,(function(t,i){return void 0===i?t:i}))}function emptyFuncWithPromise(){return zi.resolve()}function emptyFunc(){}function getFileExtension(t){var i=lastIndexOf(t).call(t,"."),u=i>-1?slice(t).call(t,i+1):"";return/^\d+$/.test(trim$2(u).call(u))&&(u=""),u}function findIndexWithinTargetValue(t,i,u){return 0===t.length||t[0][i]<=u?0:t[t.length-1][i]>u?t.length:findIndex$1(t).call(t,(function(m,h){if(t[h-1]&&t[h-1][i]>u&&u>=m[i])return!0}))}function fillIdServer(t,i,u,m){var h="number"==typeof get(t,"raw.r[0]")?""+t.raw.r[0]:void 0;return i[u]=i[u]||h||m,i}var $d=function(){function CoreAdapters(t){this.lastSuccUploadHost="",this.core=t}var t=CoreAdapters.prototype;return t.getFileUploadInformation=function getFileUploadInformation(t){return pd.getFileUploadInformation(t)},t.request=function request(t,i,u){var m=this,h=(new Date).getTime(),v=(null==u?void 0:u.exception_service)||0;return pd.request(t,i).catch((function(u){var M,I,S,T,C=u;throw m.core.reporter.reportTraceStart("exceptions",{user_id:m.core.options.account||(null===(I=null===(M=m.core)||void 0===M?void 0:M.auth)||void 0===I?void 0:I.account),trace_id:null===(T=null===(S=m.core.clientSocket)||void 0===S?void 0:S.socket)||void 0===T?void 0:T.sessionId,start_time:h,action:1,exception_service:v}),m.core.reporter.reportTraceUpdateV2("exceptions",{code:"number"==typeof C.code?C.code:0,description:C.message||""+C.code,operation_type:0,target:t,context:i?Un(i):""},{asyncParams:pd.net.getNetworkStatus()}),m.core.reporter.reportTraceEnd("exceptions",1),u}))},t.uploadFile=function uploadFile(t,i){var u,m,h,v;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var M,I,S,T,C,E,A,k,R,w,N,x,O,P;return ud.wrap((function _callee$(L){for(;;)switch(L.prev=L.next){case 0:S="BROWSER"===pd.platform,T=S?t.chunkUploadHostBackupList:t.commonUploadHostBackupList,C=S?t.chunkUploadHost:t.commonUploadHost,E=indexOf(T).call(T,C),A=-1===E?concat(M=[C]).call(M,T):concat(I=[C]).call(I,slice(T).call(T,0,E),slice(T).call(T,E+1)),k=Math.max(indexOf(A).call(A,this.lastSuccUploadHost),0),R=null,w=0;case 8:if(!(w<A.length)){L.next=36;break}return N=(new Date).getTime(),x=A[(w+k)%A.length],null==i||i.update({retry_times:w}),L.prev=12,L.next=15,pd.uploadFile(Dt(Dt({},t),S?{chunkUploadHost:x}:{commonUploadHost:x}));case 15:return O=L.sent,this.lastSuccUploadHost=x,"string"==typeof O.size&&(O.size=Gd(O.size)),"string"==typeof O.dur&&(O.dur=Gd(O.dur)),"string"==typeof O.w&&(O.w=Gd(O.w)),"string"==typeof O.h&&(O.h=Gd(O.h)),L.abrupt("return",O);case 24:L.prev=24,L.t0=L.catch(12),this.core.cloudStorage.nos.nosErrorCount--,R=L.t0,P=L.t0,this.core.reporter.reportTraceStart("exceptions",{user_id:this.core.options.account||(null===(m=null===(u=this.core)||void 0===u?void 0:u.auth)||void 0===m?void 0:m.account),trace_id:null===(v=null===(h=this.core.clientSocket)||void 0===h?void 0:h.socket)||void 0===v?void 0:v.sessionId,start_time:N,action:1,exception_service:3}),this.core.reporter.reportTraceUpdateV2("exceptions",{code:"number"==typeof P.code?P.code:0,description:P.message||""+P.code,operation_type:1,target:x},{asyncParams:pd.net.getNetworkStatus()}),this.core.reporter.reportTraceEnd("exceptions",1),this._uploadFileErrHanler(L.t0);case 33:w++,L.next=8;break;case 36:throw R;case 37:case"end":return L.stop()}}),_callee,this,[[12,24]])})))},t._uploadFileErrHanler=function _uploadFileErrHanler(t){if(t&&(t.code>200||t.errCode>200))throw t},CoreAdapters}(),zd="weblink.netease.im:443",Wd=["https://lbs.netease.im/lbs/webconf.jsp","https://lbs-sdk.netease.im/lbs/webconf.jsp"],Kd="https://abt-online.netease.im/v1/api/abt/client/getExperimentInfo",Yd="imElite_sdk_abtest_web",Qd=function(){function ABTest(t,i){this.abtInfo={},this.core=t,this.config=assignOptions({isAbtestEnable:!0,abtestUrl:Kd,abtestProjectKey:Yd},i)}var t=ABTest.prototype;return t.setOptions=function setOptions(t){this.config=assignOptions(this.config,t)},t.abtRequest=function abtRequest(){var t,i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:if(this.config.isAbtestEnable){m.next=2;break}return m.abrupt("return");case 2:if(!this.abtInfo.experiments){m.next=4;break}return m.abrupt("return");case 4:if(this.config.abtestUrl){m.next=6;break}return m.abrupt("return");case 6:return m.prev=6,m.next=9,this.core.adapters.request(this.config.abtestUrl,{method:"POST",dataType:"json",headers:{sdktype:"ABTest"},data:{clientInfo:{projectKey:this.config.abtestProjectKey,appKey:this.core.options.appkey,osType:"Web",sdkVersion:"10.9.71",deviceId:this.core.config.deviceId},useLocalCache:!0}},{exception_service:7});case 9:u=m.sent,m.next=15;break;case 12:m.prev=12,m.t0=m.catch(6),this.core.logger.warn("ABTest request failed");case 15:this.abtInfo=(null===(i=null===(t=null==u?void 0:u.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.abtInfo)||{};case 16:case"end":return m.stop()}}),_callee,this,[[6,12]])})))},ABTest}();function getPromiseWithAbort(t){var i={},u=new zi((function(t,u){i.abort=u}));return i.promise=zi.race([t,u]),i}zi.reject;var Jd=function(){function PromiseManager(){this.abortFns=[]}var t=PromiseManager.prototype;return t.add=function add(t){var i=getPromiseWithAbort(t);return this.abortFns.push(i.abort),i.promise},t.clear=function clear(t){var i;forEach$1(i=this.abortFns).call(i,(function(i){return i(t||new Yl({code:zl.V2NIM_ERROR_CODE_CANCELLED,detail:{reason:"Aborted"}}))})),this.abortFns=[]},t.destroy=function destroy(){this.clear()},PromiseManager}(),Xd={tolerantRTT:3e3,bestRTT:100,maxChances:5,enable:!0},Zd={timestamp:0,rtt:0,baseClock:0,baseTime:0},eu=function(){function TimeOrigin(t,i,u){void 0===u&&(u="getServerTime"),this.serverOrigin=Zd,this.config=Xd,this.isSettingNTP=!1,this.currentChance=0,this.failedDelay=2e3,this.successDelay=3e5,this.timer=0,this.cmdName="getServerTime",this.core=t,this.logger=t.logger,this.promiseManager=new Jd,this.cmdName=u,i&&this.setOptions(i)}var t=TimeOrigin.prototype;return t.setOptions=function setOptions(t){this.config=Dt({},Xd,this.config,t)},t.reset=function reset(){this.timer&&clearTimeout(this.timer),this.promiseManager.clear(),this.serverOrigin=Zd,this.currentChance=0},t.setOriginTimetick=function setOriginTimetick(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t,i,u,m,h,v,M,I,S,T;return ud.wrap((function _callee$(C){for(;;)switch(C.prev=C.next){case 0:if(this.config.enable){C.next=2;break}return C.abrupt("return");case 2:if(!this.isSettingNTP){C.next=4;break}return C.abrupt("return");case 4:if(!(this.currentChance>=this.config.maxChances)){C.next=6;break}return C.abrupt("return");case 6:if(t=get(this.core,"auth.status"),i=get(this.core,"status"),u=get(this.core,"V2NIMLoginService.lifeCycle.loginStatus"),"logined"===t||"logined"===i||1===u){C.next=11;break}return C.abrupt("return");case 11:return this.isSettingNTP=!0,this.currentChance++,this.timer&&clearTimeout(this.timer),this.timer=0,m="TimeOrigin::setOriginTimetick:",h=to(),this.core.logger.debug(m+" getServerTime start, times "+this.currentChance),C.prev=18,C.next=21,this.promiseManager.add(this.core.sendCmd(this.cmdName));case 21:M=C.sent,v=get(M,"content.time"),this.isSettingNTP=!1,C.next=33;break;case 26:return C.prev=26,C.t0=C.catch(18),I=C.t0,this.isSettingNTP=!1,this.logger.warn(m+" Calculate Delay time, getServerTime error",I),I.code!==zl.V2NIM_ERROR_CODE_CANCELLED&&(clearTimeout(this.timer),this.timer=mo(bind$1(S=this.setOriginTimetick).call(S,this),this.failedDelay)),C.abrupt("return");case 33:if(v){C.next=37;break}return this.core.logger.warn(m+" Calculate Delay time incorrect format"),this.config.enable=!1,C.abrupt("return");case 37:T=to()-h,this.doSet(v,T);case 39:case"end":return C.stop()}}),_callee,this,[[18,26]])})))},t.doSet=function doSet(t,i){var u,m="TimeOrigin::setOriginTimetick:";if(i>this.config.tolerantRTT)this.logger.warn(m+" denied RTT:"+i),clearTimeout(this.timer),this.timer=mo(bind$1(u=this.setOriginTimetick).call(u,this),this.failedDelay);else if(i>this.config.bestRTT){var h;this.serverOrigin.rtt&&i>=this.serverOrigin.rtt?this.logger.warn(m+" ignore RTT:"+i):(this.setServerOrigin(i,t),this.logger.log(m+" accept reluctantly RTT:"+i)),clearTimeout(this.timer),this.timer=mo(bind$1(h=this.setOriginTimetick).call(h,this),this.failedDelay)}else{var v;this.setServerOrigin(i,t),this.logger.debug(m+" accept best RTT:"+i),this.currentChance=0,clearTimeout(this.timer),this.timer=mo(bind$1(v=this.setOriginTimetick).call(v,this),this.successDelay)}},t.getNTPTime=function getNTPTime(t){if(void 0===t&&(t=this.getTimeNode()),this.checkNodeReliable(t)){var i=Math.floor(t.time-this.serverOrigin.baseTime);return this.serverOrigin.timestamp+i}return to()},t.checkNodeReliable=function checkNodeReliable(t){if(void 0===t&&(t=this.getTimeNode()),this.serverOrigin.timestamp){if(0===this.serverOrigin.baseClock)return!0;var i=t.clock-this.serverOrigin.baseClock,u=t.time-this.serverOrigin.baseTime;return Math.abs(u-i)<500}return!1},t.checkPerformance=function checkPerformance(){return"BROWSER"===pd.platform&&!("undefined"==typeof performance||!performance.now)},TimeOrigin.checkPerformance=function checkPerformance(){return"BROWSER"===pd.platform&&!("undefined"==typeof performance||!performance.now)},t.getTimeNode=function getTimeNode(){return{clock:this.checkPerformance()?performance.now():0,time:to()}},TimeOrigin.getTimeNode=function getTimeNode(){return{clock:TimeOrigin.checkPerformance()?performance.now():0,time:to()}},t.setServerOrigin=function setServerOrigin(t,i){this.serverOrigin={timestamp:i+Math.floor(t/2),rtt:t,baseClock:this.checkPerformance()?performance.now():0,baseTime:to()}},TimeOrigin}(),tu={user_id:"",trace_id:"",action:7,exception_service:6,duration:0,start_time:0,state:1,extension:[]},ru=function(){function ReporterHookLinkKeep(t,i){this.traceData=tu,this.core=t,this.traceData=Dt({},tu,i),this.traceData.extension=[]}var t=ReporterHookLinkKeep.prototype;return t.reset=function reset(){this.traceData=Dt({},tu),this.traceData.extension=[]},t.start=function start(){var t,i;this.reset(),this.traceData.user_id=this.core.account,this.traceData.trace_id=(null===(i=null===(t=this.core.clientSocket)||void 0===t?void 0:t.socket)||void 0===i?void 0:i.sessionId)||"",this.traceData.start_time=(new Date).getTime()},t.update=function update(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m;return ud.wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,pd.net.getNetworkStatus();case 2:i=h.sent,u=i.net_type,m=i.net_connect,this.traceData.extension.push(Dt({code:0,foreground:!0,foreg_backg_switch:!1,net_type:u,net_connect:m},t));case 6:case"end":return h.stop()}}),_callee,this)})))},t.end=function end(t){var i=this.traceData.extension[0],u=this.traceData.extension[1];if(i&&0===i.operation_type&&u&&1===u.operation_type){var m=i.net_type!==u.net_type||i.net_connect!==u.net_connect;if(t||!m)return this.traceData.duration=(new Date).getTime()-this.traceData.start_time,this.core.reporter.report("exceptions",this.traceData),void this.reset();this.reset()}else this.reset()},ReporterHookLinkKeep}(),nu={user_id:"",trace_id:"",net_connect:!0,net_type:0,duration:0,start_time:0,history:[],succeed:!1},au=function(){function ReporterHookLBS(t){this.traceData=nu,this.core=t,this.reset()}var t=ReporterHookLBS.prototype;return t.reset=function reset(){this.traceData=Dt({},nu),this.traceData.history=[]},t.start=function start(t){this.reset(),this.traceData.user_id=t,this.traceData.start_time=to()},t.updateBegin=function updateBegin(t){this.traceData.history.push(Dt({head:"",body:"",start_time:to(),httpdns:!1,index:0},t))},t.updateComplete=function updateComplete(t){var i;forEach$1(i=this.traceData.history).call(i,(function(i){i.target===t.target&&(Dt(i,t),i.duration=to()-i.start_time)}))},t.end=function end(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h;return ud.wrap((function _callee$(v){for(;;)switch(v.prev=v.next){case 0:if(this.traceData.succeed=t,this.traceData.history=filter(i=this.traceData.history).call(i,(function(t){return void 0!==t.code})),0!==this.traceData.history.length){v.next=5;break}return this.reset(),v.abrupt("return");case 5:return this.traceData.duration=to()-this.traceData.start_time,v.next=8,pd.net.getNetworkStatus();case 8:u=v.sent,m=u.net_type,h=u.net_connect,this.traceData.net_type=m,this.traceData.net_connect=h,this.core.reporter.report("nim_sdk_lbs_records",this.traceData),this.reset();case 15:case"end":return v.stop()}}),_callee,this)})))},ReporterHookLBS}();function getIsDataReportEnable(t){var i,u,m=!0;return"boolean"==typeof(null===(i=null==t?void 0:t.reporterConfig)||void 0===i?void 0:i.enableCompass)?m=t.reporterConfig.enableCompass:"boolean"==typeof(null===(u=null==t?void 0:t.reporterConfig)||void 0===u?void 0:u.isDataReportEnable)&&(m=t.reporterConfig.isDataReportEnable),m}var iu={},ou={},su={},cu={apiVersion:"v1",debugLevel:"off",needReconnect:!0,reconnectionAttempts:xt,lbsUrls:Wd,linkUrl:zd,abtestUrl:Kd,isAbtestEnable:!0},lu=function(t){function NIM(i,u){var m,h,v;if(void 0===u&&(u={}),(v=t.call(this)||this).instanceName="NIM",v.pluginMap={},v.eventBus=new ho,v.options={},v.V2NIMConversationIdUtil={},v.V2NIMMessageCreator={},v.V2NIMMessageAttachmentCreator={},v.V2NIMClientAntispamUtil={},v.DataStructureConverter={},v.V2NIMMessageConverter={},v.V2NIMMessageLogUtil={},v.V2NIMMessageExtendUtil={},v.V2NIMStorageUtil={},v.V2NIMNotificationService={},v.V2NIMStorageService={},v.auth={},v.V1NIMLoginService={},v.V2NIMLoginService={},v.clientSocket={},v.V2NIMSyncService={},v.V2NIMLocalConversationService={},v.V2NIMConversationService={},v.V2NIMConversationGroupService={},v.V2NIMMessageService={},v.V2NIMTeamService={},v.V2NIMUserService={},v.V2NIMFriendService={},v.V2NIMSettingService={},v.V2NIMAIService={},v.V2NIMSignallingService={},v.V2NIMSubscriptionService={},v.V2NIMPassthroughService={},v.YSFService={},v.offlinePush={},v.sync={},v.msg={},v.msgLog={},v.session={},v.cloudSession={},v.misc={},v.user={},v.friend={},v.systemMessage={},v.team={},v.event={},v.msgExtend={},v.cloudStorage={},v.passThrough={},v.superTeam={},v.plugin={},v.signaling={},v.qchatChannel={},v.qchatMedia={},v.qchatMsg={},v.qchatRole={},v.qchatServer={},v.pluginMap=su,v.logger=new vd(i.debugLevel,u.loggerConfig),u.privateConf){var M=v.getConfigFromPrivate(u.privateConf),I=M.authConfig,S=M.cloudStorageConfig,T=M.reporterConfig;Dt(i,I),v.setInitOptions(i),v.otherOptions=Dt(Dt({},u),{cloudStorageConfig:Dt(Dt({storageKeyPrefix:"NIM"},u.cloudStorageConfig),S),reporterConfig:Dt(Dt({},u.reporterConfig),T),V1NIMLoginServiceConfig:Dt(Dt(Dt({},i),u.V1NIMLoginServiceConfig),I),V2NIMLoginServiceConfig:Dt(Dt({},u.V2NIMLoginServiceConfig),I)})}else v.setInitOptions(i),v.otherOptions=Dt(Dt({},u),{V1NIMLoginServiceConfig:Dt(Dt({},i),u.V1NIMLoginServiceConfig),cloudStorageConfig:Dt({storageKeyPrefix:"NIM"},u.cloudStorageConfig)});v.timerManager=new sd,v.timeOrigin=new eu(Je(v)),v.adapters=new $d(Je(v)),v.abtest=new Qd(Je(v),Dt(Dt({isAbtestEnable:v.options.isAbtestEnable,abtestUrl:v.options.abtestUrl},v.otherOptions.abtestConfig),{abtestProjectKey:Yd}));var C=pd.getSystemInfo(),E=function getCompassDataEndpoint(t,i){var u,m,h=null===(u=null==i?void 0:i.reporterConfig)||void 0===u?void 0:u.compassDataEndpoint,v=null===(m=null==i?void 0:i.reporterConfig)||void 0===m?void 0:m.reportConfigUrl;if(h)return h;if(v){var M=v.match(/^https:\/\/([^/]+)\/*/);if(Dn(M)&&M.length>=1)return"https://"+M[1];t.error("Invalid reportConfigUrl: "+v)}return pendingIsMiniappEnv()?"https://statistic.live.126.net":"https://statistic.live.126.net,https://statistic-overseas.yunxinfw.com"}(v.logger,v.otherOptions);v.reporter=new Us(Dt(Dt({},E?{compassDataEndpoint:E}:{}),{isDataReportEnable:getIsDataReportEnable(v.otherOptions),common:{app_key:i.appkey,dev_id:"",platform:"Web",sdk_ver:"10.9.71",env:"online",os_name:C.os,os_ver:C.osVer,lib_env:C.libEnv,host_env:C.hostEnv,host_env_ver:C.hostEnvVer,manufactor:C.manufactor,model:C.model,v2:"v1"!==v.options.apiVersion},request:pd.request,logger:v.logger,autoStart:!0})),v.reporterHookLinkKeep=new ru(Je(v)),v.reporterHookLBS=new au(Je(v));var A=v.getServiceKeys(Ht(iu));return forEach$1(A).call(A,(function(t){if(!v[t]||!v[t].name){var i=iu[t];v[t]=new i(Je(v))}})),forEach$1(m=Ht(iu)).call(m,(function(t){v.callSetOptions(t)})),forEach$1(h=Ht(ou)).call(h,(function(t){var i=ou[t];void 0!==i&&(v[t]=new i(Je(v)))})),NIM.instance=Je(v),v.logger.log("NIM init, version:10.9.71, sdk version:100971, appkey:"+i.appkey),v}Nt(NIM,t);var i=NIM.prototype;return i.getServiceKeys=function getServiceKeys(t){var i=findIndex$1(t).call(t,(function(t){return"V1NIMLoginService"===t}));if(i>-1){var u=t[i];splice(t).call(t,i,1),"v1"===this.options.apiVersion&&t.unshift(u)}var m=findIndex$1(t).call(t,(function(t){return"V2NIMLoginService"===t}));if(m>-1){var h=t[m];splice(t).call(t,m,1),"v2"===this.options.apiVersion&&t.unshift(h)}var v=findIndex$1(t).call(t,(function(t){return"sync"===t}));if(v>-1){var M=t[v];splice(t).call(t,v,1),"v1"===this.options.apiVersion&&t.push(M)}var I=findIndex$1(t).call(t,(function(t){return"V2NIMSyncService"===t}));if(I>-1){var S=t[I];splice(t).call(t,I,1),"v2"===this.options.apiVersion&&t.push(S)}return t},NIM.getInstance=function getInstance(t,i){if(!NIM.instance){if(t)return new NIM(t,i);throw new Error("Instance not exist, please input options")}if(t){if(NIM.instance.options.account===t.account&&NIM.instance.options.appkey===t.appkey)return NIM.instance.setOptions(t),NIM.instance;throw new Error("Unexpected login")}return NIM.instance},i.setInitOptions=function setInitOptions(t){validate({appkey:{type:"string"},apiVersion:{type:"enum",values:["v1","v2"],required:!1},binaryWebsocket:{type:"boolean",required:!1},needReconnect:{type:"boolean",required:!1},reconnectionAttempts:{type:"number",required:!1},customClientType:{type:"number",min:1,required:!1},authType:{type:"number",min:0,max:2,required:!1},lbsUrls:{type:"array",itemType:"string",min:1,required:!1},linkUrl:{type:"string",allowEmpty:!1,required:!1}},t),this.options=Dt(Dt({},cu),t)},i.getConfigFromPrivate=function getConfigFromPrivate(t){var i;return t?{authConfig:JSON.parse(Un({appkey:t.appkey||void 0,lbsUrls:t.weblbsUrl?[t.weblbsUrl]:void 0,linkUrl:t.link_web||void 0,linkSSL:null!==(i=t.websdkSsl)&&void 0!==i?i:void 0})),cloudStorageConfig:JSON.parse(Un({chunkUploadHost:t.nos_uploader||void 0,commonUploadHost:t.nos_uploader||void 0,commonUploadHostBackupList:t.nos_uploader?[t.nos_uploader]:void 0,chunkUploadHostBackupList:t.nos_uploader?[t.nos_uploader]:void 0,uploadReplaceFormat:t.nos_downloader_v2?(t.nosSsl?"https://":"http://")+t.nos_downloader_v2:void 0,downloadUrl:void 0!==t.nos_accelerate?t.nos_accelerate:void 0,downloadHostList:""===t.nos_accelerate_host?[]:"string"==typeof t.nos_accelerate_host?[t.nos_accelerate_host]:Dn(t.nos_accelerate_host)?t.nos_accelerate_host:void 0})),reporterConfig:JSON.parse(Un({enableCompass:"boolean"==typeof t.enableCompass?t.enableCompass:void 0,compassDataEndpoint:t.compassDataEndpoint||void 0}))}:{authConfig:{},cloudStorageConfig:{},reporterConfig:{}}},i.connect=function connect(t){return void 0===t&&(t={}),this.V1NIMLoginService.login(t)},i.setOptions=function setOptions(t){if("object"==typeof t&&null!==t){if(Object.prototype.hasOwnProperty.call(t,"account")&&t.account!==this.options.account||Object.prototype.hasOwnProperty.call(t,"appkey")&&t.appkey!==this.options.appkey)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"NIM::setOptions account and appkey is not allowed to reset"}});if(Object.prototype.hasOwnProperty.call(t,"apiVersion")&&t.apiVersion!==this.options.apiVersion)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"NIM::setOptions apiVersion is not allowed to reset"}});if(Object.prototype.hasOwnProperty.call(t,"binaryWebsocket")&&t.binaryWebsocket!==this.options.binaryWebsocket)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"NIM::setOptions binaryWebsocket is not allowed to reset"}});validate({token:{type:"string",required:!1},needReconnect:{type:"boolean",required:!1},reconnectionAttempts:{type:"number",required:!1},customClientType:{type:"number",min:1,required:!1},authType:{type:"number",min:0,max:2,required:!1},lbsUrls:{type:"array",itemType:"string",min:1,required:!1},linkUrl:{type:"string",allowEmpty:!1,required:!1}},t),this.logger.log("NIM::setOptions options is",t),this.options=Dt(Dt({},this.options),t),this.V1NIMLoginService.setOptions&&this.V1NIMLoginService.setOptions(this.options)}},i.getOptions=function getOptions(){return this.options},i.disconnect=function disconnect(){return this.V1NIMLoginService.logout()},i._disconnect=function _disconnect(){return"v1"===this.options.apiVersion?this.V1NIMLoginService.logout():"v2"===this.options.apiVersion?0===get(this.V2NIMLoginService,"lifeCycle.connectStatus")&&0===get(this.V2NIMLoginService,"lifeCycle.loginStatus")?zi.resolve():this.V2NIMLoginService.logout():zi.resolve()},i.destroy=function destroy(){var t=this;return NIM.instance=void 0,this._disconnect().then((function(){t.status="destroyed",t.removeAllListeners(),t.eventBus.removeAllListeners(),t.logger.destroy(),t.reporter.destroy(),t.timerManager.destroy(),t._clearModuleData("destroy"),t._removeAllModuleListeners(),t.connect=emptyFuncWithPromise,t.disconnect=emptyFuncWithPromise,t._disconnect=emptyFuncWithPromise,t.destroy=emptyFuncWithPromise}))},i._clearModuleData=function _clearModuleData(t){void 0===t&&(t="logout");var i=Xi(this);forEach$1(i).call(i,(function(i){i&&"function"==typeof i.reset&&i.reset(t)}))},i._removeAllModuleListeners=function _removeAllModuleListeners(){var t=Xi(this);forEach$1(t).call(t,(function(t){t&&"function"==typeof t.removeAllListeners&&t.removeAllListeners()}))},i.kick=function kick(t){return this.V1NIMLoginService.kick(t)},i.sendCmd=function sendCmd(t,i,u){return this.clientSocket.sendCmd(t,i,u)},i.emit=function emit(i){var u=this;try{for(var m,h,v=to(),M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];var T=(m=t.prototype.emit).call.apply(m,concat(h=[this,i]).call(h,I)),C=to()-v;return C>=10&&this.logger.warn("Core::emit event: "+i+" process takes: "+C+"ms"),T}catch(t){return this.logger.error("Core::emit event: "+i+". Error: "+t),mo((function(){throw u.logger.error("Core::emit throw error in setTimeout. event: "+i+". Error: "+t),t}),0),!1}},i._registerDep=function _registerDep(t,i){this[i]&&this[i].name||(this[i]=new t(this),this.callSetOptions(i))},i.callSetOptions=function callSetOptions(t){var i=t+"Config",u=t+"Options",m=this.otherOptions[i]||this.otherOptions[u]||{},h=get(this,t+".setOptions");"function"==typeof h&&("cloudStorage"===t&&(m=this.otherOptions[i]||this.otherOptions.serverConfig||{}),h.call(this[t],m))},NIM.registerService=function registerService(t,i){iu[i]=t},NIM.registerPrivateService=function registerPrivateService(t,i){ou[i]=t},NIM.registerPlugin=function registerPlugin(t,i){su[i]=t},Qe(NIM,[{key:"account",get:function get(){return this.auth.account}},{key:"status",get:function get(){return this.V1NIMLoginService.status},set:function set(t){this.V1NIMLoginService.status=t}},{key:"config",get:function get(){return{timeout:8e3,deviceId:this.auth.deviceId}}}]),NIM}(ho);lu.sdkVersion=100971,lu.sdkVersionFormat="10.9.71";var du=createCommonjsModule((function(t,i){t.exports=function(){function object2String(t){if(t){var i,u="";return forEach$1(i=Ht(t)).call(i,(function(i,m){u+=0===m?"?":"&",u+=i+"="+t[i]})),u}return""}var t=function(t){function V2NIMError(i,u,m,h){var v;return(v=t.call(this,m)||this).source=i,v.code=u,v.desc=m,v.detail=h||{},v}return Nt(V2NIMError,t),V2NIMError}(Lc(Error));function request(i,u){void 0===u&&(u={dataType:"json",method:"GET",timeout:5e3});var m="text"===u.dataType?"text/plain; charset=UTF-8":"application/json; charset=UTF-8",h="GET"===u.method?object2String(u.params):"";return new zi((function(v,M){if(window.XMLHttpRequest){var I,S=new XMLHttpRequest;if(S.onreadystatechange=function(){if(4===S.readyState)if(200===S.status){try{I=JSON.parse(S.response||"{}")}catch(t){I=S.response}v({status:S.status,data:I})}else mo((function(){M(new t(1,S.status,"readyState: "+S.readyState+"; statusText: "+S.statusText))}),0)},S.open(u.method,""+i+h),S.timeout=u.timeout||5e3,S.setRequestHeader("Content-Type",m),u.headers)for(var T in u.headers)S.setRequestHeader(T,u.headers[T]);S.ontimeout=function(i){M(new t(1,408,i&&i.message?i.message:"request timeout"))},S.send(Un(u.data))}else M(new t(2,10400,"request no suppout"))}))}return request}()})),uu=Math.floor,mergeSort=function(t,i){var u=t.length,m=uu(u/2);return u<8?insertionSort(t,i):merge(t,mergeSort(arraySliceSimple(t,0,m),i),mergeSort(arraySliceSimple(t,m),i),i)},insertionSort=function(t,i){for(var u,m,h=t.length,v=1;v<h;){for(m=v,u=t[v];m&&i(t[m-1],u)>0;)t[m]=t[--m];m!==v++&&(t[m]=u)}return t},merge=function(t,i,u,m){for(var h=i.length,v=u.length,M=0,I=0;M<h||I<v;)t[M+I]=M<h&&I<v?m(i[M],u[I])<=0?i[M++]:u[I++]:M<h?i[M++]:u[I++];return t},pu=mergeSort,mu=W.match(/firefox\/(\d+)/i),hu=!!mu&&+mu[1],gu=/MSIE|Trident/.test(W),vu=W.match(/AppleWebKit\/(\d+)\./),fu=!!vu&&+vu[1],yu=[],Mu=R(yu.sort),Iu=R(yu.push),_u=fails((function(){yu.sort(void 0)})),Su=fails((function(){yu.sort(null)})),Tu=arrayMethodIsStrict("sort"),Cu=!fails((function(){if(X)return X<70;if(!(hu&&hu>3)){if(gu)return!0;if(fu)return fu<603;var t,i,u,m,h="";for(t=65;t<76;t++){switch(i=String.fromCharCode(t),t){case 66:case 69:case 70:case 72:u=3;break;case 68:case 71:u=4;break;default:u=2}for(m=0;m<47;m++)yu.push({k:i+m,v:u})}for(yu.sort((function(t,i){return i.v-t.v})),m=0;m<yu.length;m++)i=yu[m].k.charAt(0),h.charAt(h.length-1)!==i&&(h+=i);return"DGBEFHACIJK"!==h}}));_export({target:"Array",proto:!0,forced:_u||!Su||!Tu||!Cu},{sort:function sort(t){void 0!==t&&aCallable(t);var i=toObject(this);if(Cu)return void 0===t?Mu(i):Mu(i,t);var u,m,h=[],v=lengthOfArrayLike(i);for(m=0;m<v;m++)m in i&&Iu(h,i[m]);for(pu(h,function(t){return function(i,u){return void 0===u?-1:void 0===i?1:void 0!==t?+t(i,u)||0:toString(i)>toString(u)?1:-1}}(t)),u=lengthOfArrayLike(h),m=0;m<u;)i[m]=h[m++];for(;m<v;)deletePropertyOrThrow(i,m++);return i}});var bu=entryVirtual("Array").sort,Eu=Array.prototype,sort=function(t){var i=t.sort;return t===Eu||z(Eu,t)&&i===Eu.sort?bu:i},Au=createCommonjsModule((function(t,i){self,t.exports=function(){var t={d:function d(i,u){for(var m in u)t.o(u,m)&&!t.o(i,m)&&Ye(i,m,{enumerable:!0,get:u[m]})},o:function o(t,i){return Object.prototype.hasOwnProperty.call(t,i)}},i={};t.d(i,{default:function _default(){return E}});var u=function e(t){for(var i in function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,e),this.directUploadAddr="https://wanproxy-web.127.net",this.retryCount=4,this.trunkSize=4194304,this.trunkUploadTimeout=0,this.getOffsetTimeout=1e4,this.version="1.0",this.enableCache=!0,this.logger=console,this.onError=function(t){},this.onProgress=function(t){},this.onUploadProgress=function(t){},this.onComplete=function(t){},this.onUploadInfo=function(t){},t)this[i]=t[i]};function n(t,i){var u=void 0!==es&&od(t)||t["@@iterator"];if(!u){if(Dn(t)||(u=function(t,i){if(t){var u;if("string"==typeof t)return r(t,i);var m=slice(u=Object.prototype.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?r(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){u&&(t=u);var m=0,h=function a(){};return{s:h,n:function n(){return m>=t.length?{done:!0}:{done:!1,value:t[m++]}},e:function e(t){throw t},f:h}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var v,M=!0,I=!1;return{s:function s(){u=u.call(t)},n:function n(){var t=u.next();return M=t.done,t},e:function e(t){I=!0,v=t},f:function f(){try{M||null==u.return||u.return()}finally{if(I)throw v}}}}function r(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=new Array(i);u<i;u++)m[u]=t[u];return m}var m={privateObj:{},setItem:function setItem(t,i){m.privateObj[t]=i},getItem:function getItem(t){return m.privateObj[t]},removeItem:function removeItem(t){delete m.privateObj[t]},getKeys:function getKeys(){return Ht(m.privateObj)}},h={getFileKey:function getFileKey(t){var i=t.size.toString(),u=t.lastModified.toString();return"_NosUploader_"+t.name+slice(i).call(i,i.length-5)+slice(u).call(u,u.length-5)},getFileInfo:function getFileInfo(t){var i=m.getItem(t);if(!i)return null;try{return JSON.parse(i)}catch(t){return null}},initFile:function initFile(t,i,u){h.clearExpiredInfo();var v=this.getFileKey(i),M={ctx:void 0!==t.ctx?t.ctx:"",bucket:t.bucketName,obj:t.objectName,token:t.token,modifyAt:to(),end:!1};return t.payload&&(M.payload=t.payload),u&&m.setItem(v,Un(M)),v},setUploadContext:function setUploadContext(t,i,u){var h=this.getFileInfo(t);h&&(h.ctx=i,u&&m.setItem(t,Un(h)))},setComplete:function setComplete(t,i){var u=this.getFileInfo(t);u&&(u.modifyAt=to(),u.end=!0,i&&m.setItem(t,Un(u)))},getUploadContext:function getUploadContext(t){var i=this.getFileInfo(t);return i?i.ctx:""},removeFileInfo:function removeFileInfo(t){0===indexOf(t).call(t,"_NosUploader_")&&m.removeItem(t)},clearExpiredInfo:function clearExpiredInfo(){var t,i="function"==typeof m.getKeys?m.getKeys():Ht(m),u=to(),v=[],M=n(i);try{for(M.s();!(t=M.n()).done;){var I=t.value;if(0===indexOf(I).call(I,"_NosUploader_")){var S=h.getFileInfo(I);null===S||u-S.modifyAt>E.expireTime?m.removeItem(I):v.push({fileInfo:S,key:I})}}}catch(t){M.e(t)}finally{M.f()}if(v.length>E.maxFileCache){var T,C,A=n(slice(T=sort(v).call(v,(function(t,i){return i.fileInfo.modifyAt-t.fileInfo.modifyAt}))).call(T,E.maxFileCache));try{for(A.s();!(C=A.n()).done;){var k,R=C.value;0===indexOf(k=R.key).call(k,"_NosUploader_")&&m.removeItem(R.key)}}catch(t){A.e(t)}finally{A.f()}}}},v=h;function c(t){return(c="function"==typeof es&&"symbol"==typeof ms?function(t){return typeof t}:function(t){return t&&"function"==typeof es&&t.constructor===es&&t!==es.prototype?"symbol":typeof t})(t)}function l(t,i){return!i||"object"!==c(i)&&"function"!=typeof i?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):i}function s(t){var i="function"==typeof Sc?new Sc:void 0;return(s=function s(t){var u,m;if(null===t||(m=t,-1===indexOf(u=Function.toString.call(m)).call(u,"[native code]")))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return f(t,arguments,y(this).constructor)}return n.prototype=ft(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),d(n,t)})(t)}function f(t,i,u){return(f=p()?Nc:function(t,i,u){var m=[null];m.push.apply(m,i);var h=new(bind$1(Function).apply(t,m));return u&&d(h,u.prototype),h}).apply(null,arguments)}function p(){if("undefined"==typeof Reflect||!Nc)return!1;if(Nc.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Nc(Boolean,[],(function(){}))),!0}catch(t){return!1}}function d(t,i){return(d=_t||function(t,i){return t.__proto__=i,t})(t,i)}function y(t){return(y=_t?rs:function(t){return t.__proto__||rs(t)})(t)}var M=function(t){!function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function");t.prototype=ft(i&&i.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),i&&d(t,i)}(r,t);var i,u,m=(i=r,u=p(),function(){var t,m=y(i);if(u){var h=y(this).constructor;t=Nc(m,arguments,h)}else t=m.apply(this,arguments);return l(this,t)});function r(t,i){var u;return function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,r),(u=m.call(this,"NosUploadError:"+t)).errCode=i,u.errMsg=t,u}return r}(s(Error)),I=function e(t,i,u){if("uploading"===t.uploadState){var m=t.config,h=t.param,I=v.getUploadContext(t.fileKey);if(!I)return u(0);var S=new XMLHttpRequest,T=m.directUploadAddr+"/".concat(h.bucketName)+"/".concat(encodeURIComponent(h.objectName))+"?uploadContext"+"&context=".concat(I)+"&version=".concat(m.version);S.onreadystatechange=function(){var h;if("abort"!==t.uploadState&&4===S.readyState){var I,C,E,A;try{A=JSON.parse(S.responseText)}catch(t){A={errMsg:"JsonParseError in getOffset. xhr.status = "+S.status+". xhr.responseText: "+S.responseText,errCode:500}}200===S.status?A.errCode?t.config.onError(new M(A.errMsg,A.errCode)):u(A.offset):S.status.toString().match(/^5/)?e(t,i-1,u):i>0?("function"==typeof(null===(h=m.logger)||void 0===h?void 0:h.error)&&m.logger.error(concat(I="getOffset(".concat(T,") error. retry after 3 seconds. ")).call(I,(new Date).toTimeString())),mo((function(){e(t,i-1,u)}),3500)):S.status?(v.removeFileInfo(t.fileKey),m.onError(new M(concat(C=concat(E="getOffset(".concat(T,") error: ")).call(E,S.status," ")).call(C,S.statusText)))):m.onError(new M("getOffset(".concat(T,") error. no Error Code")))}},S.open("get",T),S.setRequestHeader("x-nos-token",h.token),S.timeout=m.getOffsetTimeout,S.send()}};function g(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=new Array(i);u<i;u++)m[u]=t[u];return m}var S=function e(t,i,u,m){if("uploading"===t.uploadState){var h=t.param,I=t.config,S=slice(File.prototype),T=void 0!==h.ctx?h.ctx:"",C=i+I.trunkSize>=t.file.size,E=C?t.file.size:i+I.trunkSize,A=to(),k=new XMLHttpRequest,R=I.directUploadAddr+"/".concat(h.bucketName)+"/".concat(encodeURIComponent(h.objectName)),w={};k.upload.onprogress=function(u){if("abort"!==t.uploadState){var m=0;if(u.lengthComputable){var h=i+u.loaded;m=h/t.file.size,I.onProgress(m),I.onUploadProgress({loaded:h,total:t.file.size,percentage:m,percentageText:(100*m).toFixed(2)+"%"})}else I.onError(new M("browser does not support query upload progress"))}},k.onload=function(){if(200!==k.status){var t=k.getAllResponseHeaders();if(t){var i,u=reduce(i=t.split("\n")).call(i,(function(t,i){if(0===i.length)return t;var u,m,h=(m=2,function(t){if(Dn(t))return t}(u=i.split(": "))||function(t,i){var u=null==t?null:void 0!==es&&od(t)||t["@@iterator"];if(null!=u){var m,h,v=[],M=!0,I=!1;try{for(u=u.call(t);!(M=(m=u.next()).done)&&(v.push(m.value),!i||v.length!==i);M=!0);}catch(t){I=!0,h=t}finally{try{M||null==u.return||u.return()}finally{if(I)throw h}}return v}}(u,m)||function(t,i){if(t){var u;if("string"==typeof t)return g(t,i);var m=slice(u=Object.prototype.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?g(t,i):void 0}}(u,m)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),v=h[0],M=h[1];return t[v]=M,t}),{});I.onUploadInfo({rsp_headers:u})}}},k.onreadystatechange=function(){var h,S,T;if("abort"!==t.uploadState&&4===k.readyState){var E,N,x,O;if(k.responseText)try{O=JSON.parse(k.responseText)}catch(t){"function"==typeof(null===(h=I.logger)||void 0===h?void 0:h.error)&&I.logger.error("JsonParseError in uploadTrunk. xhr.status = "+k.status+". xhr.responseText: "+k.responseText,t),O={errMsg:"JsonParseError in uploadTrunk. xhr.status = "+k.status+". xhr.responseText: "+k.responseText}}else"function"==typeof(null===(S=I.logger)||void 0===S?void 0:S.error)&&I.logger.error("xhr.status = "+k.status+" and xhr.responseText empty");I.onUploadInfo({transfer_latency:to()-A}),200===k.status?(I.onUploadInfo({http_code:200}),t.setContext(O.context),C?(m(),t.setComplete()):e(t,O.offset,I.retryCount,m)):k.status.toString().match(/^5/)?(I.onUploadInfo({http_code:k.status,req_headers:w}),u>0?e(t,i,u-1,m):(v.removeFileInfo(t.fileKey),I.onError(new M(O.errMsg,O.errCode)))):(I.onUploadInfo({http_code:k.status||0,req_headers:w}),u>0?("function"==typeof(null===(T=I.logger)||void 0===T?void 0:T.error)&&I.logger.error(concat(E="uploadTrunk(".concat(R,") error. retry after 3 seconds. ")).call(E,(new Date).toTimeString())),mo((function(){e(t,i,u-1,m)}),3500)):k.status?(v.removeFileInfo(t.fileKey),I.onError(new M(concat(N=concat(x="uploadTrunk(".concat(R,") error: ")).call(x,k.status," ")).call(N,k.statusText)))):I.onError(new M("uploadTrunk(".concat(R,") error. no Error Code. Please check your network"))))}};var N=R+"?offset=".concat(i)+"&complete=".concat(C)+"&context=".concat(T)+"&version=".concat(I.version);if(I.onUploadInfo({remote_addr:N,part_size:C?t.file.size-i:I.trunkSize,index:Math.ceil(i/I.trunkSize)}),k.open("post",N),k.setRequestHeader("x-nos-token",h.token),w["x-nos-token"]=h.token,h.md5&&(k.setRequestHeader("content-md5",h.md5),w["content-md5"]=h.md5),t.file.type&&(k.setRequestHeader("content-type",t.file.type),w["content-type"]=t.file.type),I.trunkUploadTimeout&&I.trunkUploadTimeout>0&&(k.timeout=I.trunkUploadTimeout),"undefined"!=typeof FileReader){var x=new FileReader;x.onload=function(t){var i;(null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result)instanceof ArrayBuffer&&t.target.result.byteLength>0?k.send(t.target.result):I.onError(new M("Read ArrayBuffer failed",194003))},x.onerror=function(t){var i=t.target.error;I.onError(new M("Read ArrayBuffer error. ".concat(i.toString()),194003))},x.readAsArrayBuffer(S.call(t.file,i,E))}else k.send(S.call(t.file,i,E))}};function b(t,i){for(var u=0;u<i.length;u++){var m=i[u];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Ye(t,m.key,m)}}var T=function(){function e(t,i,u){!function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,e),this.uploadState="paused",this.config=u,this.file=t,this.param=i,this.fileKey=v.initFile(i,t,this.config.enableCache),this.resume()}var t;return(t=[{key:"resume",value:function value(){var t=this;if("uploading"!==this.uploadState){this.setUploadState("uploading");var i=this.config;I(this,i.retryCount,(function(u){S(t,u,i.retryCount,(function(){t.setUploadState("ended"),"function"==typeof i.onComplete&&i.onComplete(t.param)}))}))}}},{key:"pause",value:function value(){this.setUploadState("paused")}},{key:"abort",value:function value(){"ended"!==this.uploadState&&"abort"!==this.uploadState&&(this.setUploadState("abort"),this.config.onError(new M("Upload Aborted",10499)))}},{key:"setUploadState",value:function value(t){t!==this.uploadState&&(this.uploadState=t)}},{key:"setContext",value:function value(t){v.setUploadContext(this.fileKey,t,this.config.enableCache),this.param.ctx=t}},{key:"setComplete",value:function value(){v.setComplete(this.fileKey,this.config.enableCache),this.setUploadState("ended")}}])&&b(e.prototype,t),e}(),C={maxFileCache:1/0,expireTime:864e5,getFileUploadInformation:function getFileUploadInformation(t){var i=v.getFileKey(t),u=v.getFileInfo(i);return null===u?null:to()-u.modifyAt>C.expireTime?(v.removeFileInfo(i),null):{uploadInfo:Dt({bucketName:u.bucket,objectName:u.obj,token:u.token,ctx:u.ctx},u.payload?{payload:u.payload}:{}),complete:u.end}},setMaxFileCache:function setMaxFileCache(t){C.maxFileCache=t},setExpireTime:function setExpireTime(t){C.expireTime=t},printCaches:function printCaches(){if("undefined"!=typeof localStorage)for(var t=0,i=Ht(localStorage);t<i.length;t++){var u=i[t],m=v.getFileInfo(u);m&&console.log(m,"modifiedAt",new Date(m.modifyAt).toTimeString())}},createConfig:function createConfig(t){return new u(t)},createTask:function createTask(t,i,u){return new T(t,i,u)}},E=C;return i.default}()})),ku=tn.some,Ru=arrayMethodIsStrict("some");_export({target:"Array",proto:!0,forced:!Ru},{some:function some(t){return ku(this,t,arguments.length>1?arguments[1]:void 0)}});var wu=entryVirtual("Array").some,Nu=Array.prototype,some=function(t){var i=t.some;return t===Nu||z(Nu,t)&&i===Nu.some?wu:i},xu={debug:function debug(){},log:function log(){},warn:function warn(){},error:function error(){}};function setLogger(t){xu=t}function getLogger(){return xu}function isMobile(){if(!navigator||!navigator.userAgent)return!1;var t=[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i];return some(t).call(t,(function(t){return navigator.userAgent.match(t)}))}function isElectron(){var t;return!(!navigator||!navigator.userAgent)&&("object"==typeof navigator&&"string"==typeof navigator.userAgent&&indexOf(t=navigator.userAgent).call(t,"Electron")>=0)}function isBrowser(){return navigator&&navigator.userAgent}function uploadFileFn(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h,v,M,I;return ud.wrap((function _callee$(S){for(;;)switch(S.prev=S.next){case 0:if(h=getLogger(),t.fileInput||t.file){S.next=3;break}throw new Error("File not exist");case 3:if(!t.file){S.next=7;break}v=t.file,S.next=21;break;case 7:if("string"!=typeof t.fileInput){S.next=16;break}if(!((M=document.getElementById(t.fileInput))&&M.files&&M.files[0])){S.next=13;break}v=M.files[0],S.next=14;break;case 13:throw new Error("Can not get file from fileInput");case 14:S.next=21;break;case 16:if(!(t.fileInput&&t.fileInput.files&&t.fileInput.files[0])){S.next=20;break}v=t.fileInput.files[0],S.next=21;break;case 20:throw new Error("Can not get file from fileInput "+t.fileInput);case 21:if(!(t.maxSize&&v.size>t.maxSize)){S.next=23;break}throw new Error("The file exceeds maxSize limit. maxSize: "+t.maxSize+", get "+v.size);case 23:return S.next=25,new zi((function(i,u){var m,M=Au.getFileUploadInformation(v),I=Au.createConfig({enableCache:!0,retryCount:0,directUploadAddr:t.chunkUploadHost,onError:function onError(t){u(t)},onUploadProgress:t.onUploadProgress||function(){},onComplete:function onComplete(t){i(t)},onUploadInfo:function onUploadInfo(i){t.onUploadInfo&&t.onUploadInfo(i)}});if(M)if(M.complete)t.onUploadProgress&&t.onUploadProgress({total:v.size,loaded:v.size,percentage:1,percentageText:"100%"}),i(M.uploadInfo);else{m=Au.createTask(v,M.uploadInfo,I);try{t.onUploadStart&&t.onUploadStart(m)}catch(t){h.error("Adapter uploadFile: options.onUploadStart error",t&&t.message),m.abort(),u(t)}}else{m=Au.createTask(v,Dt(Dt({bucketName:t.nosToken.bucket,objectName:decodeURIComponent(t.nosToken.objectName),token:t.nosToken.token},t.md5?{md5:t.md5}:{}),t.payload?{payload:t.payload}:{}),I);try{t.onUploadStart&&t.onUploadStart(m)}catch(t){h.error("Adapter uploadFile: options.onUploadStart error",t&&t.message),m.abort(),u(t)}}}));case 25:return(I=S.sent).name=v.name,I.size=v.size,I.type=v.type,I.ext=lastIndexOf(i=I.name).call(i,".")>-1?slice(u=I.name).call(u,lastIndexOf(m=I.name).call(m,".")+1).toLowerCase():"",S.abrupt("return",I);case 31:case"end":return S.stop()}}),_callee)})))}function getFileUploadInformationFn(t){var i;if(t.file)i=t.file;else if("string"==typeof t.fileInput){var u=document.getElementById(t.fileInput);if(!(u&&u.files&&u.files[0]))throw new Error("Can not get file from fileInput");i=u.files[0]}else{if(!(t.fileInput&&t.fileInput.files&&t.fileInput.files[0]))throw new Error("Can not get file from fileInput "+t.fileInput);i=t.fileInput.files[0]}return Au.getFileUploadInformation(i)}
/*!
	 * Platform.js v1.3.6
	 * Copyright 2014-2020 Benjamin Tan
	 * Copyright 2011-2013 John-David Dalton
	 * Available under MIT license
	 */var Ou=createCommonjsModule((function(t,u){(function(){var m={function:!0,object:!0}[typeof window]&&window||this,h=u,v=t&&!t.nodeType&&t,M=h&&v&&"object"==typeof i&&i;!M||M.global!==M&&M.window!==M&&M.self!==M||(m=M);var I=Math.pow(2,53)-1,S=/\bOpera/,T=Object.prototype,C=T.hasOwnProperty,E=T.toString;function capitalize(t){return(t=String(t)).charAt(0).toUpperCase()+t.slice(1)}function format(t){return t=trim(t),/^(?:webOS|i(?:OS|P))/.test(t)?t:capitalize(t)}function forOwn(t,i){for(var u in t)C.call(t,u)&&i(t[u],u,t)}function getClassOf(t){return null==t?capitalize(t):E.call(t).slice(8,-1)}function qualify(t){return String(t).replace(/([ -])(?!$)/g,"$1?")}function reduce(t,i){var u=null;return function each(t,i){var u=-1,m=t?t.length:0;if("number"==typeof m&&m>-1&&m<=I)for(;++u<m;)i(t[u],u,t);else forOwn(t,i)}(t,(function(m,h){u=i(u,m,h,t)})),u}function trim(t){return String(t).replace(/^ +| +$/g,"")}var A=function parse(t){var i=m,u=t&&"object"==typeof t&&"String"!=getClassOf(t);u&&(i=t,t=null);var h=i.navigator||{},v=h.userAgent||"";t||(t=v);var M,I,T=u?!!h.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(E.toString()),C="Object",A=u?C:"ScriptBridgingProxyObject",k=u?C:"Environment",R=u&&i.java?"JavaPackage":getClassOf(i.java),w=u?C:"RuntimeObject",N=/\bJava/.test(R)&&i.java,x=N&&getClassOf(i.environment)==k,O=N?"a":"α",P=N?"b":"β",L=i.document||{},V=i.operamini||i.opera,U=S.test(U=u&&V?V["[[Class]]"]:getClassOf(V))?U:V=null,D=t,B=[],q=null,G=t==v,H=G&&V&&"function"==typeof V.version&&V.version(),j=function getLayout(i){return reduce(i,(function(i,u){return i||RegExp("\\b"+(u.pattern||qualify(u))+"\\b","i").exec(t)&&(u.label||u)}))}([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),$=function getName(i){return reduce(i,(function(i,u){return i||RegExp("\\b"+(u.pattern||qualify(u))+"\\b","i").exec(t)&&(u.label||u)}))}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),z=getProduct([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),W=function getManufacturer(i){return reduce(i,(function(i,u,m){return i||(u[z]||u[/^[a-z]+(?: +[a-z]+\b)*/i.exec(z)]||RegExp("\\b"+qualify(m)+"(?:\\b|\\w*\\d)","i").exec(t))&&m}))}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),K=function getOS(i){return reduce(i,(function(i,u){var m=u.pattern||qualify(u);return!i&&(i=RegExp("\\b"+m+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(i=function cleanupOS(t,i,u){var m={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return i&&u&&/^Win/i.test(t)&&!/^Windows Phone /i.test(t)&&(m=m[/[\d.]+$/.exec(t)])&&(t="Windows "+m),t=String(t),i&&u&&(t=t.replace(RegExp(i,"i"),u)),format(t.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(i,m,u.label||u)),i}))}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function getProduct(i){return reduce(i,(function(i,u){var m=u.pattern||qualify(u);return!i&&(i=RegExp("\\b"+m+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+m+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+m+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((i=String(u.label&&!RegExp(m,"i").test(u.label)?u.label:i).split("/"))[1]&&!/[\d.]+/.test(i[0])&&(i[0]+=" "+i[1]),u=u.label||u,i=format(i[0].replace(RegExp(m,"i"),u).replace(RegExp("; *(?:"+u+"[_-])?","i")," ").replace(RegExp("("+u+")[-_.]?(\\w)","i"),"$1 $2"))),i}))}function getVersion(i){return reduce(i,(function(i,u){return i||(RegExp(u+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(j&&(j=[j]),/\bAndroid\b/.test(K)&&!z&&(M=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(z=trim(M[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),W&&!z?z=getProduct([W]):W&&z&&(z=z.replace(RegExp("^("+qualify(W)+")[-_.\\s]","i"),W+" ").replace(RegExp("^("+qualify(W)+")[-_.]?(\\w)","i"),W+" $2")),(M=/\bGoogle TV\b/.exec(z))&&(z=M[0]),/\bSimulator\b/i.test(t)&&(z=(z?z+" ":"")+"Simulator"),"Opera Mini"==$&&/\bOPiOS\b/.test(t)&&B.push("running in Turbo/Uncompressed mode"),"IE"==$&&/\blike iPhone OS\b/.test(t)?(W=(M=parse(t.replace(/like iPhone OS/,""))).manufacturer,z=M.product):/^iP/.test(z)?($||($="Safari"),K="iOS"+((M=/ OS ([\d_]+)/i.exec(t))?" "+M[1].replace(/_/g,"."):"")):"Konqueror"==$&&/^Linux\b/i.test(K)?K="Kubuntu":W&&"Google"!=W&&(/Chrome/.test($)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(z))||/\bAndroid\b/.test(K)&&/^Chrome/.test($)&&/\bVersion\//i.test(t)?($="Android Browser",K=/\bAndroid\b/.test(K)?K:"Android"):"Silk"==$?(/\bMobi/i.test(t)||(K="Android",B.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&B.unshift("accelerated")):"UC Browser"==$&&/\bUCWEB\b/.test(t)?B.push("speed mode"):"PaleMoon"==$&&(M=/\bFirefox\/([\d.]+)\b/.exec(t))?B.push("identifying as Firefox "+M[1]):"Firefox"==$&&(M=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(K||(K="Firefox OS"),z||(z=M[1])):!$||(M=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec($))?($&&!z&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(M+"/")+8))&&($=null),(M=z||W||K)&&(z||W||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(K))&&($=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(K)?K:M)+" Browser")):"Electron"==$&&(M=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&B.push("Chromium "+M),H||(H=getVersion(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",qualify($),"(?:Firefox|Minefield|NetFront)"])),(M=("iCab"==j&&parseFloat(H)>3?"WebKit":/\bOpera\b/.test($)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(j)&&"WebKit"||!j&&/\bMSIE\b/i.test(t)&&("Mac OS"==K?"Tasman":"Trident")||"WebKit"==j&&/\bPlayStation\b(?! Vita\b)/i.test($)&&"NetFront")&&(j=[M]),"IE"==$&&(M=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?($+=" Mobile",K="Windows Phone "+(/\+$/.test(M)?M:M+".x"),B.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?($="IE Mobile",K="Windows Phone 8.x",B.unshift("desktop mode"),H||(H=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=$&&"Trident"==j&&(M=/\brv:([\d.]+)/.exec(t))&&($&&B.push("identifying as "+$+(H?" "+H:"")),$="IE",H=M[1]),G){if(function isHostType(t,i){var u=null!=t?typeof t[i]:"number";return!(/^(?:boolean|number|string|undefined)$/.test(u)||"object"==u&&!t[i])}(i,"global"))if(N&&(D=(M=N.lang.System).getProperty("os.arch"),K=K||M.getProperty("os.name")+" "+M.getProperty("os.version")),x){try{H=i.require("ringo/engine").version.join("."),$="RingoJS"}catch(t){(M=i.system)&&M.global.system==i.system&&($="Narwhal",K||(K=M[0].os||null))}$||($="Rhino")}else"object"==typeof i.process&&!i.process.browser&&(M=i.process)&&("object"==typeof M.versions&&("string"==typeof M.versions.electron?(B.push("Node "+M.versions.node),$="Electron",H=M.versions.electron):"string"==typeof M.versions.nw&&(B.push("Chromium "+H,"Node "+M.versions.node),$="NW.js",H=M.versions.nw)),$||($="Node.js",D=M.arch,K=M.platform,H=(H=/[\d.]+/.exec(M.version))?H[0]:null));else getClassOf(M=i.runtime)==A?($="Adobe AIR",K=M.flash.system.Capabilities.os):getClassOf(M=i.phantom)==w?($="PhantomJS",H=(M=M.version||null)&&M.major+"."+M.minor+"."+M.patch):"number"==typeof L.documentMode&&(M=/\bTrident\/(\d+)/i.exec(t))?(H=[H,L.documentMode],(M=+M[1]+4)!=H[1]&&(B.push("IE "+H[1]+" mode"),j&&(j[1]=""),H[1]=M),H="IE"==$?String(H[1].toFixed(1)):H[0]):"number"==typeof L.documentMode&&/^(?:Chrome|Firefox)\b/.test($)&&(B.push("masking as "+$+" "+H),$="IE",H="11.0",j=["Trident"],K="Windows");K=K&&format(K)}if(H&&(M=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(H)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(G&&h.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(q=/b/i.test(M)?"beta":"alpha",H=H.replace(RegExp(M+"\\+?$"),"")+("beta"==q?P:O)+(/\d+\+?/.exec(M)||"")),"Fennec"==$||"Firefox"==$&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(K))$="Firefox Mobile";else if("Maxthon"==$&&H)H=H.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(z))"Xbox 360"==z&&(K=null),"Xbox 360"==z&&/\bIEMobile\b/.test(t)&&B.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test($)&&(!$||z||/Browser|Mobi/.test($))||"Windows CE"!=K&&!/Mobi/i.test(t))if("IE"==$&&G)try{null===i.external&&B.unshift("platform preview")}catch(t){B.unshift("embedded")}else(/\bBlackBerry\b/.test(z)||/\bBB10\b/.test(t))&&(M=(RegExp(z.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||H)?(K=((M=[M,/BB10/.test(t)])[1]?(z=null,W="BlackBerry"):"Device Software")+" "+M[0],H=null):this!=forOwn&&"Wii"!=z&&(G&&V||/Opera/.test($)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==$&&/\bOS X (?:\d+\.){2,}/.test(K)||"IE"==$&&(K&&!/^Win/.test(K)&&H>5.5||/\bWindows XP\b/.test(K)&&H>8||8==H&&!/\bTrident\b/.test(t)))&&!S.test(M=parse.call(forOwn,t.replace(S,"")+";"))&&M.name&&(M="ing as "+M.name+((M=M.version)?" "+M:""),S.test($)?(/\bIE\b/.test(M)&&"Mac OS"==K&&(K=null),M="identify"+M):(M="mask"+M,$=U?format(U.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(M)&&(K=null),G||(H=null)),j=["Presto"],B.push(M));else $+=" Mobile";(M=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(M=[parseFloat(M.replace(/\.(\d)$/,".0$1")),M],"Safari"==$&&"+"==M[1].slice(-1)?($="WebKit Nightly",q="alpha",H=M[1].slice(0,-1)):H!=M[1]&&H!=(M[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(H=null),M[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==M[0]&&537.36==M[2]&&parseFloat(M[1])>=28&&"WebKit"==j&&(j=["Blink"]),G&&(T||M[1])?(j&&(j[1]="like Chrome"),M=M[1]||((M=M[0])<530?1:M<532?2:M<532.05?3:M<533?4:M<534.03?5:M<534.07?6:M<534.1?7:M<534.13?8:M<534.16?9:M<534.24?10:M<534.3?11:M<535.01?12:M<535.02?"13+":M<535.07?15:M<535.11?16:M<535.19?17:M<536.05?18:M<536.1?19:M<537.01?20:M<537.11?"21+":M<537.13?23:M<537.18?24:M<537.24?25:M<537.36?26:"Blink"!=j?"27":"28")):(j&&(j[1]="like Safari"),M=(M=M[0])<400?1:M<500?2:M<526?3:M<533?4:M<534?"4+":M<535?5:M<537?6:M<538?7:M<601?8:M<602?9:M<604?10:M<606?11:M<608?12:"12"),j&&(j[1]+=" "+(M+="number"==typeof M?".x":/[.+]/.test(M)?"":"+")),"Safari"==$&&(!H||parseInt(H)>45)?H=M:"Chrome"==$&&/\bHeadlessChrome/i.test(t)&&B.unshift("headless")),"Opera"==$&&(M=/\bzbov|zvav$/.exec(K))?($+=" ",B.unshift("desktop mode"),"zvav"==M?($+="Mini",H=null):$+="Mobile",K=K.replace(RegExp(" *"+M+"$"),"")):"Safari"==$&&/\bChrome\b/.exec(j&&j[1])?(B.unshift("desktop mode"),$="Chrome Mobile",H=null,/\bOS X\b/.test(K)?(W="Apple",K="iOS 4.3+"):K=null):/\bSRWare Iron\b/.test($)&&!H&&(H=getVersion("Chrome")),H&&0==H.indexOf(M=/[\d.]+$/.exec(K))&&t.indexOf("/"+M+"-")>-1&&(K=trim(K.replace(M,""))),K&&-1!=K.indexOf($)&&!RegExp($+" OS").test(K)&&(K=K.replace(RegExp(" *"+qualify($)+" *"),"")),j&&!/\b(?:Avant|Nook)\b/.test($)&&(/Browser|Lunascape|Maxthon/.test($)||"Safari"!=$&&/^iOS/.test(K)&&/\bSafari\b/.test(j[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test($)&&j[1])&&(M=j[j.length-1])&&B.push(M),B.length&&(B=["("+B.join("; ")+")"]),W&&z&&z.indexOf(W)<0&&B.push("on "+W),z&&B.push((/^on /.test(B[B.length-1])?"":"on ")+z),K&&(M=/ ([\d.+]+)$/.exec(K),I=M&&"/"==K.charAt(K.length-M[0].length-1),K={architecture:32,family:M&&!I?K.replace(M[0],""):K,version:M?M[1]:null,toString:function(){var t=this.version;return this.family+(t&&!I?" "+t:"")+(64==this.architecture?" 64-bit":"")}}),(M=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(D))&&!/\bi686\b/i.test(D)?(K&&(K.architecture=64,K.family=K.family.replace(RegExp(" *"+M),"")),$&&(/\bWOW64\b/i.test(t)||G&&/\w(?:86|32)$/.test(h.cpuClass||h.platform)&&!/\bWin64; x64\b/i.test(t))&&B.unshift("32-bit")):K&&/^OS X/.test(K.family)&&"Chrome"==$&&parseFloat(H)>=39&&(K.architecture=64),t||(t=null);var Y={};return Y.description=t,Y.layout=j&&j[0],Y.manufacturer=W,Y.name=$,Y.prerelease=q,Y.product=z,Y.ua=t,Y.version=$&&H,Y.os=K||{architecture:null,family:null,version:null,toString:function(){return"null"}},Y.parse=parse,Y.toString=function toStringPlatform(){return this.description||""},Y.version&&B.unshift(H),Y.name&&B.unshift($),K&&$&&(K!=String(K).split(" ")[0]||K!=$.split(" ")[0]&&!z)&&B.push(z?"("+K+")":"on "+K),B.length&&(Y.description=B.join(" ")),Y}();h&&v?forOwn(A,(function(t,i){h[i]=t})):m.platform=A}).call(i)}));function getSystemInfoFn(){var t,i,u=Ou.version||"";if(isElectron())try{var m=navigator.userAgent.match(/Electron\/([\d.]+\d+)/);m&&m[1]&&"string"==typeof m[1]&&(u=m[1])}catch(t){}return{os:(null===(t=Ou.os)||void 0===t?void 0:t.family)||"",osVer:(null===(i=Ou.os)||void 0===i?void 0:i.version)||"",browser:Ou.name||"",browserVer:Ou.version||"",libEnv:"BROWSER",hostEnv:isElectron()?"Electron":isMobile()?"H5":isBrowser()?"BROWSER":"Unset",hostEnvEnum:isElectron()?5:isMobile()?101:isBrowser()?100:0,hostEnvVer:u,userAgent:navigator&&navigator.userAgent,model:u,manufactor:Ou.name||""}}var Pu=null,Lu=null,Vu={getNetworkStatus:function getNetworkStatus(){return zi.resolve({net_type:0,net_connect:"undefined"==typeof navigator||"boolean"!=typeof navigator.onLine||navigator.onLine})},onNetworkStatusChange:function onNetworkStatusChange(t){Pu=function onlineListener(){t({isConnected:!0,networkType:0})},Lu=function offlineListener(){t({isConnected:!1,networkType:0})},window.addEventListener("online",Pu),window.addEventListener("offline",Lu)},offNetworkStatusChange:function offNetworkStatusChange(){Pu&&window.removeEventListener("online",Pu),Lu&&window.removeEventListener("offline",Lu),Pu=null,Lu=null}},Uu=getLogger(),Du=function getVisibilityEvent(){var t="hidden",i="visibilitychange";return"undefined"==typeof document||void 0!==document.hidden||(void 0!==document.webkitHidden?(t="webkitHidden",i="webkitvisibilitychange"):void 0!==document.msHidden?(t="msHidden",i="msvisibilitychange"):void 0!==document.mozHidden&&(t="mozHidden",i="mozvisibilitychange")),{hidden:t,visibilityChange:i}},Bu=function(t){function PowerMonitor(){var i;return(i=t.call(this)||this).status=0,i.visibilityListener=null,i.flag=!1,i._initVisibilityListener(),i}Nt(PowerMonitor,t);var i=PowerMonitor.prototype;return i.isActive=function isActive(){return 0===this.status},i.getStatus=function getStatus(){return this.status},i.setStatus=function setStatus(t){var i=this.status;t!==i&&(this.status=t,0===t&&1===i&&this.emit("onPowerMonitorTurnActive"),Uu.log("Adapter powerMonitor::setStatus: ",t))},i.destroy=function destroy(){if(this.status=0,this.flag=!1,this._canIUse()&&this.visibilityListener){var t=Du().visibilityChange;document.removeEventListener(t,this.visibilityListener),this.visibilityListener=null}},i._initVisibilityListener=function _initVisibilityListener(){if(!this.flag)if(!1!==this._canIUse()){var t=Du(),i=t.hidden,u=t.visibilityChange;i&&void 0!==document[i]&&(this.visibilityListener=function genVisibilityListener(t){return function(){var i=t.status,u=Du().hidden;u&&document[u]?t.status=1:(t.status=0,1===i&&t.emit("onPowerMonitorTurnActive")),Uu.log("Adapter powerMonitor::visibility change status:",t.status)}}(this),document.addEventListener(u,this.visibilityListener),this.flag=!0,Uu.log("Adapter powerMonitor::_initVisibilityListener success, isHidden:",null===document||void 0===document?void 0:document[i]))}else Uu.warn("Adapter powerMonitor::_initVisibilityListener no document.addEventListener")},i._canIUse=function _canIUse(){return"undefined"!=typeof document&&void 0!==document.addEventListener},PowerMonitor}(ho),qu="log",Fu=function(){function IDB(t,i){this.db=null,this.stores=[],this.name=t,this.version=i}var t=IDB.prototype;return t.getDB=function getDB(){if(!this.db)throw new Error("DB not ready");return this.db},t.getStore=function getStore(t){var i,u=find(i=this.stores).call(i,(function(i){return i.storeName===t}));if(!u)throw new Error("LogStorage: store not found. "+t);return u},t.open=function open(){var t=this,i=window.indexedDB.open(this.name,this.version);return new zi((function(u,m){i.onerror=function(t){var i=t.target;m(i.error)},i.onsuccess=function(i){var m,h,v=i.target;t.db=v.result,t.db.removeEventListener("close",bind$1(m=t.triggerDBCloseEvt).call(m,t)),t.db.addEventListener("close",bind$1(h=t.triggerDBCloseEvt).call(h,t)),t.stores.push(new Gu(qu,t)),u()},i.onupgradeneeded=function(i){var u=i.target;t.upgradeDBBySchema(u)}}))},t.triggerDBCloseEvt=function triggerDBCloseEvt(){try{this.db&&this.db.close(),this.db=null}catch(t){}this.open()},t.upgradeDBBySchema=function upgradeDBBySchema(t){var i=t.result,u=t.transaction&&i.objectStoreNames.contains(qu)?t.transaction.objectStore(qu):i.createObjectStore(qu,{keyPath:"id",autoIncrement:!0});try{u.index("time")}catch(t){u.createIndex("time","time",{unique:!1})}},t.close=function close(){var t;this.db&&(this.db.removeEventListener("close",bind$1(t=this.triggerDBCloseEvt).call(t,this)),this.db.close(),this.stores=[],this.db=null)},IDB}(),Gu=function(){function IDBStore(t,i){this.idb=null,this.storeName=t,this.idb=i}var t=IDBStore.prototype;return t.getDB=function getDB(){if(!this.idb)throw new Error("DB not ready");return this.idb.getDB()},t.getStoreName=function getStoreName(){return this.storeName},t.bulkCreate=function bulkCreate(t){var i=this.getDB(),u=this.getStoreName(),m=i.transaction(u,"readwrite"),h=m.objectStore(u);return forEach$1(t).call(t,(function(t){h.add(t)})),new zi((function(t,i){m.oncomplete=function(){t()},m.onerror=function(t){var u=t.target;i(u.error)},m.onabort=function(t){var u=t.target;u.error instanceof Error?i(u.error):i(new Error("TransactionAborted"))}}))},t.bulkDelete=function bulkDelete(t){var i=t.keyName,u=t.lower,m=t.upper,h=t.lowerOpen,v=void 0!==h&&h,M=t.upperOpen,I=void 0!==M&&M,S=IDBKeyRange.bound(u,m,v,I),T=this.getDB(),C=this.getStoreName(),E=T.transaction(C,"readwrite"),A=E.objectStore(C).index(i).openCursor(S),k=0;return A.onsuccess=function(t){var i=t.target.result;i&&(i.delete(),k++,i.continue())},new zi((function(t,i){E.oncomplete=function(){t(k)},E.onerror=function(t){var u=t.target;i(u.error)},E.onabort=function(t){var u=t.target;u.error instanceof Error?i(u.error):i(new Error("TransactionAborted"))}}))},t.readAll=function readAll(){var t=this.getDB(),i=this.getStoreName(),u=t.transaction(i,"readonly").objectStore(i);if(!u.getAll)throw new Error("IDBExtract not support");var m=u.getAll();return new zi((function(t,i){m.onsuccess=function(i){var u=i.target;t(u.result)},m.onerror=function(t){var u=t.target;i(u.error)}}))},IDBStore}(),Hu=function(){function LogStorageImpl(t){this.logRetentionDays=10,this.idb=new Fu(t.logDirPath,1),this.logRetentionDays=t.logRetentionDays>=1?t.logRetentionDays:10}var t=LogStorageImpl.prototype;return t.open=function open(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t;return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.idb.open();case 2:return t=this.idb.getStore(qu),i.prev=3,i.next=6,t.bulkDelete({keyName:"time",lower:0,upper:to()-24*this.logRetentionDays*60*60*1e3});case 6:i.next=10;break;case 8:i.prev=8,i.t0=i.catch(3);case 10:case"end":return i.stop()}}),_callee,this,[[3,8]])})))},t.close=function close(){this.idb.close()},t.addLogs=function addLogs(t){return this.idb.getStore(qu).bulkCreate(t)},t.extractLogs=function extractLogs(){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var t,i,u,m,h;return ud.wrap((function _callee2$(v){for(;;)switch(v.prev=v.next){case 0:return i=this.idb.getStore(qu),v.next=3,i.readAll();case 3:if(0!==(u=v.sent).length){v.next=6;break}return v.abrupt("return",void 0);case 6:return m=reduce(u).call(u,(function(t,i){var u=i.iid;return t[u]||(t[u]=[]),t[u].push(i),t}),{}),h=map$6(t=Ht(m)).call(t,(function(t){var i=m[t];return"==========iid:"+t+"==========\n "+map$6(i).call(i,(function(t){return t.text})).join("\n")})).join("\n"),v.abrupt("return",new File([h],"nim-logs.txt",{type:"text/plain"}));case 9:case"end":return v.stop()}}),_callee2,this)})))},t.afterUpload=function afterUpload(){return zi.resolve()},LogStorageImpl}();function _createForOfIteratorHelperLoose$c(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$c(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$c(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$c(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$c(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var ju={},$u={};function createCmd(t,i,u,m){var h=ju[t];if(!h)return u.error("createCmd:: can not find cmd config: ",t),null;var v,M={SER:i,SID:h.sid,CID:h.cid,Q:[]};h.params&&m&&forEach$1(v=h.params).call(v,(function(t){var i=m[t.name];if(null!=i){var u=t.type,h=t.reflectMapper,v=t.select;switch(t.type){case"PropertyArray":u="ArrayMable",i=map$6(i).call(i,(function(t){return{t:"Property",v:h?serialize(t,h,v):t}}));break;case"Property":i=h?serialize(i,h,v):i;break;case"Bool":i=i?"true":"false"}M.Q.push({t:u,v:i})}}));return{packet:M,hasPacketResponse:"boolean"!=typeof h.hasPacketResponse||h.hasPacketResponse,hasPacketTimer:"boolean"!=typeof h.hasPacketTimer||h.hasPacketTimer}}function parseCmd(t,i){var u,m;try{m=JSON.parse(t)}catch(u){return void i.error('Parse command error:"'+t+'"')}var h=m.sid+"_"+m.cid,v=m.r;if(includes(u=["4_1","4_2","4_10","4_11"]).call(u,h)){var M=m.r[1].headerPacket;h=M.sid+"_"+M.cid,m.sid=M.sid,m.cid=M.cid,v=m.r[1].body}var I=$u[h],S=[];if(I&&I.length>0){for(var T,C=_createForOfIteratorHelperLoose$c(I);!(T=C()).done;){var E=T.value;S.push(parseEachCmd(m,E.config,E.cmd,v,i))}return S}i.error("parseCmd:: mapper not exist",h,m.code)}function parseEachCmd(t,i,u,m,h){var v,M={cmd:u,raw:t,error:null,service:null==i?void 0:i.service,content:{},__receiveTimeNode:eu.getTimeNode()};(function isV2Sid(t){var i;return includes(i=[18,19,26,27,28,29,30,31,32,33,34,35,36]).call(i,t)})(i.sid)&&(t.code=function toReadableCode(t){if("number"!=typeof t||t!=t)throw new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"Read code failed",rawData:""+t}});if(t<0||t>=0&&t<1e3||t>=2e4&&t<=20099)return t;var i=(65535&t)>>9;i-=i<=38?1:2;return 1e5+1e3*i+(511&t)}(t.code));var I,S=function genCmdError(t,i){var u=Wl[t],m=td[t];return null===m?null:new Yl({code:t,desc:u||m||t,detail:{cmd:i,timetag:to()}})}(t.code,u);if(M.error=S,M.error){if(M.error.detail.cmd=u,!(null===(v=null==i?void 0:i.ignoreErrCodes)||void 0===v?void 0:includes(v).call(v,t.code)))return M;h.warn("parseCmd:: ignore error ",M.error),M.error.detail.ignore=!0}i.response&&forEach$1(I=i.response).call(I,(function(t,i){var u=m[i],h=t.type,v=t.name,I=t.reflectMapper;if(void 0!==u)switch(h){case"Property":M.content[v]=I?deserialize(u,I):u;break;case"PropertyArray":M.content[v]=map$6(u).call(u,(function(t){return I?deserialize(t,I):t}));break;case"Int":case"Long":case"Byte":M.content[v]=+u;break;case"Bool":M.content[v]="true"===u||!0===u||1===u;break;default:M.content[v]=u}}));return M}function serialize(t,i,u){var m={};for(var h in t=function flattenObjByMapper(t,i){var u={};for(var m in i){for(var h,v=i[m],M="number"==typeof v?m:v.access?v.access:m,I=t,S=_createForOfIteratorHelperLoose$c(M.split("."));!(h=S()).done;){var T=h.value;if(void 0===I[T]||null===I[T]){I=void 0;break}I=I[T]}void 0!==I&&(u[M]=I)}return u}(t,i),i){var v=i[h],M="number"==typeof v?h:v.access?v.access:h;if(!u||includes(u).call(u,h))if(M in t){if("number"==typeof v)m[v]=t[M];else if("object"==typeof v)if(v.converter){var I=v.converter(t[M],t);void 0!==I&&(m[v.id]=I)}else m[v.id]=t[M]}else"object"==typeof v&&v.def&&("function"==typeof v.def?m[v.id]=v.def(t):m[v.id]=v.def)}return m}function deserialize(t,i){var u={};for(var m in t){var h=i[m];if("string"==typeof h)u[h]=t[m];else if("object"==typeof h&&"prop"in h){var v=h.access?h.access:h.prop;if(h.converter){var M=h.converter(t[m],t);void 0!==M&&(u[v]=M)}else h.type&&"number"===h.type?u[v]=+t[m]:h.type&&"boolean"===h.type?u[v]=!("0"===t[m]||!t[m]):u[v]=t[m]}}for(var I in i){var S=i[I];if(S&&void 0!==S.def){var T=S.access?S.access:S.prop;T in u||("function"==typeof S.def?u[T]=S.def(t):u[T]=S.def)}}return u=function unflattenObj(t){var i={},u=function _loop(u){var m=u.split(".");reduce(m).call(m,(function(i,h,v){return i[h]||(i[h]=isNaN(Number(m[v+1]))?m.length-1==v?t[u]:{}:[])}),i)};for(var m in t)u(m);return i}(u),u}function registerParser(t){for(var i in Dt(ju,t.cmdConfig),t.cmdMap){var u=t.cmdMap[i],m=t.cmdConfig[u];if(m)if(Dn($u[i])){for(var h,v=!1,M=_createForOfIteratorHelperLoose$c($u[i]);!(h=M()).done;){var I=h.value;if(I.cmd===u&&I.config.service===m.service){v=!0;break}}v||$u[i].push({config:m,cmd:u})}else $u[i]=[{config:m,cmd:u}]}}function invertSerializeMap(t){var i,u={};return forEach$1(i=Ht(t)).call(i,(function(i){u[i]=invertSerializeItem(t[i])})),u}function invertSerializeItem(t){var i={};for(var u in t){var m=t[u];"number"==typeof m?i[m]=u:"object"==typeof m&&(i[m.id]={prop:u,type:m.retType,access:m.retAccess?m.retAccess:m.access?m.access:u,def:m.retDef,converter:m.retConverter})}return i}function boolToInt(t){return t?1:0}function intToBool(t){return 1===Gd(t)}function objectToJSONString(t){if(t&&"object"==typeof t)try{return Un(t)}catch(t){return}}function stringToJSONObject(t){if(t&&"string"==typeof t)try{return JSON.parse(t)}catch(t){return}}var zu,Wu,Ku,Yu,Qu,Ju={"1_2":"heartbeat","2_3":"login","2_5":"kicked","2_6":"logout","2_7":"nimLoginClientChange","2_8":"kick"},Xu={login:{clientType:3,os:4,sdkVersion:6,appLogin:8,protocolVersion:9,pushTokenName:10,pushToken:11,deviceId:13,appkey:18,account:19,browser:24,clientSession:26,deviceInfo:32,isReactNative:112,token:1e3,customTag:38,customClientType:39,sdkHumanVersion:40,hostEnv:41,userAgent:42,libEnv:44,authType:115,loginExt:116},loginRes:{lastLoginDeviceId:17,customTag:38,connectionId:102,ip:103,port:104,country:106,loginTime:109,hasXMPush:111},loginPort:{type:3,os:4,mac:5,deviceId:13,account:19,deviceInfo:32,customTag:38,customClientType:39,connectionId:102,ip:103,port:104,time:109,pushType:110,hasTokenPreviously:111},aosPushInfo:{pushType:110,hasTokenPreviously:111}},Zu=invertSerializeMap(Xu),ep={login:{sid:2,cid:3,service:"auth",params:[{type:"Property",name:"login",reflectMapper:Xu.login}],response:[{type:"Property",name:"loginRes",reflectMapper:Zu.loginRes},{type:"PropertyArray",name:"loginPorts",reflectMapper:Zu.loginPort},{type:"Property",name:"aosPushInfo",reflectMapper:Zu.aosPushInfo}]},logout:{sid:2,cid:6,service:"auth"},heartbeat:{sid:1,cid:2,service:"auth"},kicked:{sid:2,cid:5,service:"auth",response:[{type:"Int",name:"clientType"},{type:"Int",name:"reason"},{type:"String",name:"ext"},{type:"Int",name:"customClientType"}]},nimLoginClientChange:{sid:2,cid:7,service:"auth",response:[{type:"Byte",name:"state"},{type:"PropertyArray",name:"datas",reflectMapper:Zu.loginPort}]},kick:{sid:2,cid:8,service:"auth",params:[{type:"StrArray",name:"deviceIds"}],response:[{type:"StrArray",name:"deviceIds"}]}};function format(t,i){if(!isPlainObject(i))return{};var u=JSON.parse(Un(i)),m=doFormat(t,u);return JSON.parse(Un(Dt(Dt({},u),m)))}function doFormat(t,i){if(!isPlainObject(i))return{};var u={},m=Ht(t);return forEach$1(m).call(m,(function(m){var h=t[m].type;if("string"!=typeof h){var v=doFormat(t[m],i);Ht(v).length>0&&(u[m]=v)}else{var M=t[m],I=M.rawKey||m,S=tp[h](i,I,M);void 0!==S&&(i[I]=void 0,u[m]=S)}})),u}!function(t){t[t.text=0]="text",t[t.image=1]="image",t[t.audio=2]="audio",t[t.video=3]="video",t[t.geo=4]="geo",t[t.notification=5]="notification",t[t.file=6]="file",t[t.tip=10]="tip",t[t.robot=11]="robot",t[t.g2=12]="g2",t[t.custom=100]="custom"}(zu||(zu={})),function(t){t[t.p2p=0]="p2p",t[t.team=1]="team",t[t.superTeam=5]="superTeam"}(Wu||(Wu={})),function(t){t[t.Android=1]="Android",t[t.iOS=2]="iOS",t[t.PC=4]="PC",t[t.WindowsPhone=8]="WindowsPhone",t[t.Web=16]="Web",t[t.Server=32]="Server",t[t.Mac=64]="Mac",t[t.HarmonyOS=65]="HarmonyOS"}(Ku||(Ku={})),function(t){t[t.unread=1]="unread",t[t.read=2]="read",t[t.deleted=3]="deleted",t[t.sending=4]="sending",t[t.sendFailed=5]="sendFailed",t[t.sent=6]="sent",t[t.receipt=7]="receipt",t[t.refused=10]="refused"}(Yu||(Yu={})),function(t){t[t.default=0]="default",t[t.leave=1]="leave",t[t.roam=2]="roam"}(Qu||(Qu={}));var tp={number:function number(t,i){if(void 0!==t[i])return+t[i]},string:function string(t,i){if(void 0!==t[i])return t[i]},boolean:function boolean(t,i){return+t[i]>0||0!=+t[i]&&void 0},enum:function _enum(t,i,u){return values(u)[t[i]]},object:function object(t,i){if(void 0!==t[i])try{return JSON.parse(t[i])}catch(t){return{}}}};function formatReverse(t,i){if(!isPlainObject(i))return{};var u=JSON.parse(Un(i)),m=doFormatReverse(t,u);return JSON.parse(Un(Dt(Dt({},u),m)))}function doFormatReverse(t,i){var u;if(!isPlainObject(i))return reduce(u=Ht(t)).call(u,(function(i,u){return i[t[u].rawKey||u]=void 0,i}),{});var m={},h=Ht(t);return forEach$1(h).call(h,(function(u){var h=t[u].type;if("string"!=typeof h){var v=doFormatReverse(t[u],i[u]);return Dt(m,v),void(i[u]=void 0)}var M=t[u],I=M.rawKey||u,S=rp[h](i,u,M);i[I]=void 0,m[I]=S})),m}var rp={number:function number(t,i){return t[i]},string:function string(t,i){return t[i]},boolean:function boolean(t,i){return!0===t[i]?1:!1===t[i]?0:void 0},enum:function _enum(t,i,u){return values(u)[t[i]]},object:function object(t,i){if(void 0!==t[i])try{return Un(t[i])}catch(t){return""}}},np=rp;function formatMultiPortLoginInfo(t,i){return t&&t.length>0?map$6(t).call(t,(function(t){return Dt(Dt({},t),{account:t.account,connectionId:t.connectionId,deviceId:t.deviceId,ip:t.ip,mac:t.mac,os:t.os,type:getEnumKeyByEnumValue(Ku,t.type)||t.type,time:Gd(t.time),online:3!==i})})):[]}var ap={1:{reason:"samePlatformKick",message:"The same account is not allowed to multiple login at the same time"},2:{reason:"serverKick",message:"Kicked out by IM server"},3:{reason:"otherPlatformKick",message:"Kicked out by other client of your account"},4:{reason:"silentlyKick",message:"Quietly kicked"}};var ip,op=function(){function Backoff(t){void 0===t&&(t={}),this.attempts=0,this.ms=t.min||100,this.max=t.max||1e4,this.jitter=t.jitter||0,this.factor=t.factor||2}var t=Backoff.prototype;return t.duration=function duration(){var t,i=Math.pow(this.factor,this.attempts++);if(i===1/0||!isFinite(i))return 0|this.max;if(t=this.ms*i,!isFinite(t)||t>=this.max)return 0|this.max;if(this.jitter){var u=Math.random(),m=Math.floor(u*this.jitter*t);t=0==(1&Math.floor(10*u))?t-m:t+m,t=Math.max(Math.min(t,this.max),this.ms)}return 0|t},t.reset=function reset(){this.attempts=0},t.setMin=function setMin(t){this.ms=t},t.setMax=function setMax(t){this.max=t},t.setJitter=function setJitter(t){this.jitter=t},Backoff}(),sp=["disconnect","connect","heartbeat","message","json","event","ack","error","noop"],cp=["transport not supported","client not handshaken","unauthorized"],lp=["reconnect"],dp=function(t){function BaseWebsocket(i,u,m){var h;return(h=t.call(this)||this).websocket=null,h.socketConnectTimer=0,h.url="",h.linkSSL=!0,h.core=i,h.url=u,h.linkSSL=m,h.status="disconnected",h.logger=i.logger,h.connect(),h}Nt(BaseWebsocket,t);var i=BaseWebsocket.prototype;return i.connect=function connect(){var t=this;"connecting"!==this.status&&"connected"!==this.status?(this.status="connecting",this.core.adapters.request((this.linkSSL?"https":"http")+"://"+this.url+"/socket.io/1/?t="+to(),{method:"GET",dataType:"text",timeout:this.core.options.xhrConnectTimeout||8e3},{exception_service:6}).then((function(i){if("connecting"===t.status){var u=i.data.split(":"),m=u[0];return u[1],t.sessionId=m,t.logger.log("imsocket::XHR success. status "+t.status+", "+("connecting"===t.status?"continue websocket connection":"stop websocket connection")),t._createWebsocket((t.linkSSL?"wss":"ws")+"://"+t.url+"/socket.io/1/websocket/"+m)}})).catch((function(i){if("connecting"===t.status){var u='imsocket::XHR fail. raw message: "'+(i=i||{}).message+'", code: "'+i.code+'"',m=i.code;m="v2"===get(t.core,"options.apiVersion")?i.code===zl.V2NIM_ERROR_CODE_CONNECT_TIMEOUT?zl.V2NIM_ERROR_CODE_CONNECT_TIMEOUT:zl.V2NIM_ERROR_CODE_CONNECT_FAILED:408===i.code?408:415;var h=new Yl({code:m,detail:{reason:u,rawError:i}});t.logger.error(u),t.status="disconnected",t.emit("handshakeFailed",h)}}))):this.logger.warn("imsocket::socket is connecting or connected",this.status)},i.close=function close(){if(this.status="disconnected",this.websocket){this.logger.log("imsocket:: close websocket");try{this.websocket.send(this.encodePacket({type:"disconnect"}))}catch(t){this.logger.warn("imsocket::attempt to send encodePacket error",t)}try{this.websocket.close()}catch(t){this.logger.warn("imsocket::attempt to close websocket error",t)}this.clean(),this.emit("disconnect",{code:0,reason:"Active close websocket"})}},i.clean=function clean(){this.status="disconnected",clearTimeout(this.socketConnectTimer),this.websocket&&(this.socketUrl=void 0,this.websocket.onmessage=null,this.websocket.onopen=null,this.websocket.onerror=null,this.websocket.onclose=null,this.websocket=null)},i.onConnect=function onConnect(){this.status="connected",this.emit("connect"),clearTimeout(this.socketConnectTimer)},i._createWebsocket=function _createWebsocket(t){var i,u=this;this.socketConnectTimer=mo((function(){u.logger.error("imsocket::Websocket connect timeout. url: ",u.socketUrl),u.emit("handshakeFailed",new Yl({code:"v2"===get(u.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_CONNECT_TIMEOUT:415,detail:{reason:"imsocket::Websocket connect timeout. url: "+u.socketUrl}}))}),this.core.options.socketConnectTimeout||8e3),this.socketUrl=t,this.websocket=new pd.WebSocket(t),this.websocket.onmessage=bind$1(i=this.onMessage).call(i,this),this.websocket.onclose=function(t){t=t||{},u.logger.log("imsocket::Websocket onclose done "+t.wasClean+"/"+t.code+"/"+t.reason),u.clean(),u.emit("disconnect",{code:t.code||0,reason:t.reason})},this.websocket.onerror=function(t){u.logger.error("imsocket::Websocket onerror",t),"logined"===u.core.status&&u.core.clientSocket.ping()}},i.onMessage=function onMessage(t){var i,u=this.decodePacket(t.data);if(u)switch(u.type){case"connect":this.onConnect();break;case"disconnect":this.close(),this.emit("disconnect",{code:0,reason:"MessageEvent type disconnect"});break;case"message":case"json":this.emit("message",u.data);break;case"event":u.name&&this.emit(u.name,u.args);break;case"error":"unauthorized"===u.reason?this.emit("connect_failed",u.reason):this.emit("error",u.reason),this.logger.error("imsocket::Websocket connect failed, onmessage type error. url: ",this.socketUrl),clearTimeout(this.socketConnectTimer),this.emit("handshakeFailed",new Yl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_CONNECT_FAILED:408,detail:{reason:"imsocket::Websocket connect failed, onMessage socket error. url: "+this.socketUrl}}));break;case"heartbeat":null===(i=this.websocket)||void 0===i||i.send(this.encodePacket({type:"heartbeat"}));break;default:this.logger.warn("imsocket::Websocket no handler type",u.type)}},i.encodePacket=function encodePacket(t){var i,u,m=t.type,h=t.id,v=void 0===h?"":h,M=t.endpoint,I=void 0===M?"":M,S=t.ack,T=null;if(!m)return"";switch(m){case"error":i=t.reason?indexOf(cp).call(cp,t.reason):"",u=t.advice?indexOf(lp).call(lp,t.advice):"",""===i&&""===u||(T=i+(""!==u?"+"+u:""));break;case"message":""!==t.data&&(T=t.data);break;case"event":i={name:t.name},i=t.args&&t.args.length?{name:t.name,args:t.args}:{name:t.name},T=Un(i);break;case"json":T=Un(t.data);break;case"connect":t.qs&&(T=t.qs);break;case"ack":T=t.ackId+(t.args&&t.args.length?"+"+Un(t.args):"")}var C=[indexOf(sp).call(sp,m),v+("data"===S?"+":""),I];return null!=T&&C.push(T),C.join(":")},i.decodePacket=function decodePacket(t){if(t)if("�"!=t.charAt(0)){var i=t.match(/([^:]+):([0-9]+)?(\+)?:([^:]+)?:?([\s\S]*)?/);if(i){var u,m=i[1],h=i[2],v=i[3],M=i[4],I=i[5],S={type:sp[+m],endpoint:M};switch(h&&(S.id=h,S.ack=!v||"data"),S.type){case"error":u=I.split("+"),S.reason=cp[+u[0]]||"";break;case"message":S.data=I||"";break;case"connect":S.qs=I||"";break;case"event":try{var T=JSON.parse(I);S.name=T.name,S.args=T.args}catch(t){this.logger.error("imsocket::parseData::type::event error",t)}S.args=S.args||[];break;case"json":try{S.data=JSON.parse(I)}catch(t){this.logger.error("imsocket::parseData::type::json error",t)}break;case"ack":if((u=I.match(/^([0-9]+)(\+)?(.*)/))&&(S.ackId=u[1],S.args=[],u[3]))try{S.args=u[3]?JSON.parse(u[3]):[]}catch(t){this.logger.error("imsocket::parseData::type::ack error",t)}}return S}}else this.logger.error("imsocket::unrecognize dataStr",slice(t).call(t,0,20))},i.send=function send(t){var i,u={data:t,type:"message",endpoint:""};null===(i=this.websocket)||void 0===i||i.send(this.encodePacket(u))},BaseWebsocket}(ho);function uniq(t){t=t||[];for(var i=[],u=0;u<t.length;u++)-1===indexOf(i).call(i,t[u])&&i.push(t[u]);return i}function _createForOfIteratorHelperLoose$b(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$b(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$b(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$b(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$b(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}!function(t){t[t.ACTIVE=1]="ACTIVE",t[t.KICKED=2]="KICKED",t[t.OFFLINE=3]="OFFLINE"}(ip||(ip={}));var up=function(){function V1ClientSocket(t,i){this.linkUrls=[],this.isAutoReconnect=!1,this.packetTimeout=3e4,this.linkSSL=!0,this.packetSer=1,this.retryCount=0,this.reconnectTimer=0,this.backoff=new op({max:8e3,min:1600,jitter:.01}),this.sendingCmdMap=new Sc,this.pingTimer=0,this.hasNetworkListener=!1,this.core=t,i&&(this.auth=i),this.logger=t.logger,this.reporter=t.reporter,this.timerManager=t.timerManager}var t=V1ClientSocket.prototype;return t.setSessionId=function setSessionId(t){},t.setLinkSSL=function setLinkSSL(t){this.linkSSL=t},t.connect=function connect(t,i){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v,M,I;return ud.wrap((function _callee$(S){for(;;)switch(S.prev=S.next){case 0:if(validate({linkUrls:{type:"array",itemType:"string",required:!1}},t),/^(unconnected|waitReconnect)$/.test(this.core.status)){S.next=5;break}return u="Core socket status is "+this.core.status+", and would not connect",this.logger.warn(u),S.abrupt("return",zi.reject(u));case 5:this.core.status="connecting",t.linkUrls&&t.linkUrls.length>0&&(this.linkUrls=concat(m=t.linkUrls).call(m,this.linkUrls),this.linkUrls=uniq(this.linkUrls)),0===this.linkUrls.length&&this.linkUrls.push(zd),h=0;case 9:if(!(h<this.linkUrls.length)){S.next=31;break}return v=this.linkUrls[h],M=(new Date).getTime(),S.prev=12,S.next=15,this.doConnect(v);case 15:return this.core.status="connected",this.logger.log("clientsocketV1::connect success with url: "+v),S.abrupt("return",v);case 20:S.prev=20,S.t0=S.catch(12),I=S.t0,i&&i(I,v),this.reporter.reportTraceStart("exceptions",{user_id:this.core.options.account,start_time:M,action:0,exception_service:6}),this.reporter.reportTraceUpdateV2("exceptions",{code:"number"==typeof I.code?I.code:0,description:I.message||""+I.code,operation_type:0,target:v},{asyncParams:pd.net.getNetworkStatus()}),this.reporter.reportTraceEnd("exceptions",1),this.logger.warn("clientsocketV1::connect failed with url: "+v,S.t0);case 28:h++,S.next=9;break;case 31:throw 0===this.retryCount?this.doDisconnect(ip.ACTIVE,"SocketHandshakeFailed"):this.doDisconnect(ip.OFFLINE,"ReconnectHadRetryAllLinks"),new Error("clientSocketV1::socket xhr or socket connect failed");case 33:case"end":return S.stop()}}),_callee,this,[[12,20]])})))},t.doConnect=function doConnect(t){var i=this,u=!1;return new zi((function(m,h){var v;i.socket=new dp(i.core,t,i.linkSSL),i.socket.on("connect",(function(){i.logger.log("clientSocketV1::on connect",t),i.core.reporterHookLinkKeep&&(i.core.reporterHookLinkKeep.start(),i.core.reporterHookLinkKeep.update({code:0,description:"connection begin",operation_type:0,target:t})),u=!0,m()})),i.socket.on("message",bind$1(v=i.onMessage).call(v,i)),i.socket.on("disconnect",(function(m){return __awaiter(i,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:if(this.logger.log("clientSocketV1::socket on disconnect",m),!this.core.reporterHookLinkKeep){i.next=5;break}return i.next=4,this.core.reporterHookLinkKeep.update({code:(null==m?void 0:m.code)||0,description:(null==m?void 0:m.reason)||"socket on disconnect",operation_type:1,target:t});case 4:this.core.reporterHookLinkKeep.end(!1);case 5:u=!0,this.doDisconnect(ip.OFFLINE,"SocketOnDisconnect");case 7:case"end":return i.stop()}}),_callee2,this)})))})),i.socket.on("handshakeFailed",(function(t){u?i.ping():(i.logger.error('clientsocketV1::handshake failed: "'+(t&&t.message)+'"'),i.cleanSocket()),u=!0,h(t)}))}))},t.cleanSocket=function cleanSocket(){this.socket&&("function"==typeof this.socket.removeAllListeners&&this.socket.removeAllListeners(),"function"==typeof this.socket.close&&this.socket.close(),this.socket=void 0)},t.beforeConnect=function beforeConnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer)},t.resetConnectStatus=function resetConnectStatus(){clearTimeout(this.reconnectTimer),this.backoff.reset(),this.retryCount=0,this.initOnlineListener()},t.doDisconnect=function doDisconnect(t,i,u){var m,h,v,M,I;if(this.logger.log("doDisconnect:type:"+t+",description:"+i),"unconnected"!==this.core.status){var S={1:"close",2:"kicked",3:"broken"}[t]||"";this.markAllCmdInvaild(new Yl({code:415,desc:"Packet timeout due to instance disconnect",detail:{reason:"Packet timeout due to instance disconnect",disconnect_reason:S}})),this.timerManager.destroy(),clearTimeout(this.pingTimer),this.cleanSocket();var T=!this.core.options.needReconnect||this.retryCount>=this.core.options.reconnectionAttempts;if(t===ip.ACTIVE||T)this.logger.log("doDisconnect: emit disconnect, type "+t,T),this.core.status="unconnected",this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.core.eventBus.emit("disconnect"),this.core.emit("disconnect"),null===(m=this.auth)||void 0===m||m.emit("disconnect"),this.destroyOnlineListener();else if(t===ip.KICKED){this.logger.log("doDisconnect: kicked"),this.core.status="unconnected",this.reconnectTimer&&clearTimeout(this.reconnectTimer);var C="string"==typeof i?{reason:"unknow",message:i}:i;this.core.eventBus.emit("kicked",C),this.core.emit("kicked",C),null===(h=this.auth)||void 0===h||h.emit("kicked",C),this.destroyOnlineListener()}else t===ip.OFFLINE&&this.core.V1NIMLoginService.isManualLoginAttempt?(this.logger.log("doDisconnect: offline in manual login phase. no reconnect"),this.core.status="unconnected",this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.destroyOnlineListener()):t===ip.OFFLINE&&(null===(M=null===(v=this.auth)||void 0===v?void 0:v.authenticator)||void 0===M?void 0:M.checkLoginTerminalCode(null==u?void 0:u.code))?(this.logger.log("doDisconnect: login terminal code "+(null==u?void 0:u.code)+", no reconnect"),this.core.status="unconnected",this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.destroyOnlineListener(),this.core.eventBus.emit("disconnect"),this.core.emit("disconnect"),null===(I=this.auth)||void 0===I||I.emit("disconnect")):t===ip.OFFLINE?(this.logger.log("doDisconnect: start to reconnect"),this.attempToReconnect()):this.logger.log("doDisconnect: nothing to do")}else this.logger.warn("doDisconnect:already unconnected")},t.attempToReconnect=function attempToReconnect(){var t,i,u=this;if("waitReconnect"!==this.core.status){0===this.retryCount&&(this.core.eventBus.emit("disconnect"),this.core.emit("disconnect"),null===(t=this.auth)||void 0===t||t.emit("disconnect"));var m=this.backoff.duration();this.retryCount++,this.logger.log("willReconnect "+this.retryCount+" "+m),this.core.eventBus.emit("willReconnect",{retryCount:this.retryCount,duration:m}),this.core.emit("willReconnect",{retryCount:this.retryCount,duration:m}),null===(i=this.auth)||void 0===i||i.emit("willReconnect",{retryCount:this.retryCount,duration:m}),this.core.status="waitReconnect",this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=mo((function(){return __awaiter(u,void 0,void 0,ud.mark((function _callee3(){var t=this;return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:if("waitReconnect"===this.core.status){i.next=3;break}return this.logger.warn("doDisconnect: reconnectTimer status is "+this.core.status+", would not go on reconnecting"),i.abrupt("return");case 3:return i.next=5,pd.net.getNetworkStatus();case 5:!1===i.sent.net_connect?(this.logger.log("doDisconnect: skip this reconnection attempt because network is offline"),this.core.status="connecting",this.retryCount>=this.core.options.reconnectionAttempts?this.doDisconnect(ip.OFFLINE,"MaxReconnectionAttemptExceed"):this.attempToReconnect()):this.core.V1NIMLoginService.login({isAutoReconnect:!0}).catch((function(){t.logger.error("clientsocketV1::attempToReconnect failed "+t.retryCount)}));case 7:case"end":return i.stop()}}),_callee3,this)})))}),m)}else this.logger.warn("doDisconnect: already is waiting reconnect")},t.sendCmd=function sendCmd(t,i,u){var m=this;if("logined"!==this.core.status&&"login"!==t&&"chatroomLogin"!==t&&"qchatLogin"!==t)return this.logger.warn("instance status is "+this.core.status+", so can not sendCmd "+t),zi.reject({cmd:t,error:{code:"No_connected",message:"Connection not established",timetag:(new Date).getTime()}});if(!this.socket||!this.socket.send)return zi.reject("No_socket");var h="heartbeat"!==t,v=h?this.packetSer++:0,M=createCmd(t,v,this.logger,i);if(!M){var I="SendCmd "+v+" "+t+" error";return this.logger.error(I),zi.reject(new Error(I))}var S=M.packet,T=M.hasPacketResponse,C=M.hasPacketTimer,E=Un(S);h&&(this.logger.getDebugMode()?this.logger.debug("clientsocketV1::sendCmd",t,"ser:"+v,E):this.logger.log("clientsocketV1::sendCmd",t,"ser:"+v));var A=(new Date).getTime();return new zi((function(h,M){T&&m.sendingCmdMap.set(v,{cmd:t,params:i,callback:[h,M],timer:C?mo((function(){var i=new Yl({code:408,desc:"Packet Timeout",detail:{reason:"Packet Timeout",cmd:t,ser:v,timetag:to()}});m.markCmdInvalid(v,i,t)}),u&&u.timeout?u.timeout:m.core.config.timeout):null});try{m.socket.send(E),T||h(S)}catch(i){var I=new Yl({code:415,detail:{reason:i&&i.message||"Unable to send packet",cmd:t,ser:v,timetag:to(),rawError:i}});m.markCmdInvalid(v,I,t),M(i)}})).catch((function(t){var i,u=[408,415];if(!includes(u).call(u,t.code))return zi.reject(t);m.reporter.reportTraceStart("exceptions",{user_id:m.core.options.account,trace_id:null===(i=m.socket)||void 0===i?void 0:i.sessionId,start_time:A,action:2,exception_service:6});var h=get(t,"data.disconnect_reason")||"",v=408===t.code?"Send failed due to timeout":"Send failed. Reason unknown";return v=415===t.code?Un({disconnect_reason:h}):v,m.reporter.reportTraceUpdateV2("exceptions",{code:t.code||415,description:v,operation_type:1,target:S.SID+"-"+S.CID,context:""+S.SER},{asyncParams:pd.net.getNetworkStatus()}),m.reporter.reportTraceEnd("exceptions",1),zi.reject(t)}))},t.onMessage=function onMessage(t){var i=parseCmd(t,this.logger);if(i&&i.length>0){var u=i[0],m=u.raw.ser;u.error&&this.logger.error("core:onMessage packet error",u.raw.sid+"_"+u.raw.cid+", ser:"+m+",",u.error),"heartbeat"!==u.cmd&&(this.logger.getDebugMode()?this.logger.debug("imsocket::recvCmd ser:"+m,u.cmd,u.content):this.logger.log("imsocket::recvCmd ser:"+m,u.cmd));for(var h,v=_createForOfIteratorHelperLoose$b(i);!(h=v()).done;){var M=h.value;this.packetHandler(M)}}},t.packetHandler=function packetHandler(t){var i,u,m,h,v=this;if(t){var M=t.raw.ser,I=this.sendingCmdMap.get(M);if(I&&I.cmd===t.cmd){var S=I.callback,T=I.timer,C=I.params;if(clearTimeout(T),t.params=C,this.sendingCmdMap.delete(M),"heartbeat"===t.cmd)return void S[0]();var E=null===(u=null===(i=this.core[t.service])||void 0===i?void 0:i.process)||void 0===u?void 0:u.call(i,t);E&&"function"==typeof E.then?E.then((function(t){S[0](t)})).catch((function(t){S[1](t)})):(this.logger.log("imsocket:: handlerFn without promise",t.service,t.cmd),S[0]())}else{var A=null===(h=null===(m=this.core[t.service])||void 0===m?void 0:m.process)||void 0===h?void 0:h.call(m,t);A&&"function"==typeof A.then&&A.catch((function(t){v.logger.error("imsocket::no obj cache, no process handler",t)}))}}},t.markCmdInvalid=function markCmdInvalid(t,i,u){var m=this.sendingCmdMap.get(t);if(m){var h=m.callback,v=m.timer;v&&clearTimeout(v),this.sendingCmdMap.delete(t),this.logger.warn("packet "+t+", "+u+" is invalid:",i),h[1](i)}},t.markAllCmdInvaild=function markAllCmdInvaild(t){var i,u=this;this.logger.log("markAllCmdInvaild",t),forEach$1(i=this.sendingCmdMap).call(i,(function(i){var m=i.callback,h=i.timer,v=i.cmd;u.logger.log('markAllCmdInvaild:: cmd "'+v+'"'),h&&clearTimeout(h),m[1](t)})),this.sendingCmdMap.clear()},t.ping=function ping(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i=this;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return clearTimeout(this.pingTimer),u.prev=1,u.next=4,this.sendCmd("heartbeat");case 4:u.next=18;break;case 6:return u.prev=6,u.t0=u.catch(1),u.next=10,this.testHeartBeat5Timeout();case 10:if(!u.sent){u.next=18;break}if(!this.core.reporterHookLinkKeep){u.next=16;break}return u.next=15,this.core.reporterHookLinkKeep.update({code:0,description:"Heartbeat-discovered link failure",operation_type:1,target:null===(t=this.socket)||void 0===t?void 0:t.url});case 15:this.core.reporterHookLinkKeep.end(!0);case 16:return this.doDisconnect(ip.OFFLINE,"PingError"),u.abrupt("return");case 18:this.pingTimer=mo((function(){i.ping()}),3e4);case 19:case"end":return u.stop()}}),_callee4,this,[[1,6]])})))},t.testHeartBeat5Timeout=function testHeartBeat5Timeout(){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var t;return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:clearTimeout(this.pingTimer),t=0;case 2:if(!(t<5)){i.next=15;break}return i.prev=3,i.next=6,this.sendCmd("heartbeat",{},{timeout:3e3});case 6:return i.abrupt("return",!1);case 9:i.prev=9,i.t0=i.catch(3),this.logger.log("clientsocketV1:: test heartbeat "+t+" Timeout");case 12:t++,i.next=2;break;case 15:return i.abrupt("return",!0);case 16:case"end":return i.stop()}}),_callee5,this,[[3,9]])})))},t.initOnlineListener=function initOnlineListener(){var t=this;this.hasNetworkListener||(this.logger.log("clientsocketV1::onlineListener:init"),this.hasNetworkListener=!0,pd.net.onNetworkStatusChange((function(i){t.logger.log("clientsocketV1::onlineListener:network change",i),i.isConnected&&"logined"===t.core.status?t.ping():i.isConnected&&"waitReconnect"===t.core.status?(t.reconnectTimer&&clearTimeout(t.reconnectTimer),t.core.V1NIMLoginService.login({isAutoReconnect:!0}).catch((function(){t.logger.error("clientsocketV1::attempToReconnect failed "+t.retryCount)}))):i.isConnected||t.doDisconnect(ip.OFFLINE,"OfflineListener")})))},t.destroyOnlineListener=function destroyOnlineListener(){this.logger.log("clientsocketV1::onlineListener:destroy"),pd.net.offNetworkStatusChange(),this.hasNetworkListener=!1},t.disconnect=function disconnect(){switch(this.core.status){case"connected":case"logined":case"connecting":case"waitReconnect":return this.doDisconnect(ip.ACTIVE,"UserActiveDisconnect"),zi.resolve();default:return zi.resolve()}},V1ClientSocket}(),pp=function(){function V1NIMLoginLbs(t){this.socketLinkUrls=[],this.timer=0,this.failedCount=0,this.core=t,this.auth=t.V1NIMLoginService,this.logger=this.core.logger}var t=V1NIMLoginLbs.prototype;return t.getLbsInfos=function getLbsInfos(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t,i,u,m;return ud.wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:if(!(this.socketLinkUrls.length>0)){h.next=5;break}return t=this.socketLinkUrls,this.socketLinkUrls=[],this.core.logger.log("V1NIMLoginService::getLbsInfos:use cache link",t),h.abrupt("return",zi.resolve(t));case 5:return this.core.reporterHookLBS.start(this.core.account),i=uniq(this.auth.config.lbsUrls),h.prev=7,h.next=10,this.ladderLoad(i);case 10:if(200===(u=h.sent).status&&u.data){h.next=14;break}throw this.core.logger.error("V1NIMLoginService::getLbsInfos:error status",u.status,u),new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"V1NIMLoginService::getLbsInfos failed, status "+u.status}});case 14:this.success(u),h.next=25;break;case 17:if(h.prev=17,h.t0=h.catch(7),m=h.t0,this.core.logger.error("V1NIMLoginService::lbs getLbsInfos error, use default link: "+this.auth.config.linkUrl+". error:",h.t0),this.reportForFail(i[0],m.code,m.message),!this.checkTerminator(m.code)){h.next=24;break}throw h.t0;case 24:this.socketLinkUrls=[this.auth.config.linkUrl];case 25:return h.abrupt("return",this.socketLinkUrls);case 26:case"end":return h.stop()}}),_callee,this,[[7,17]])})))},t.checkTerminator=function checkTerminator(t){return t===zl.V2NIM_ERROR_CODE_CANCELLED||t===zl.V2NIM_ERROR_CODE_TIMEOUT},t.generateUrl=function generateUrl(t){return(t=this.processLbsUrl(t))+(indexOf(t).call(t,"?")>-1?"&":"?")+"k="+this.core.options.appkey+"&id="+this.core.auth.getLoginUser()+"&sv=180&pv=1&networkType=0&lv=1"},t.processLbsUrl=function processLbsUrl(t){return pendingIsMiniappEnv()?t.replace("/webconf","/wxwebconf"):t},t.requstLbs=function requstLbs(t){return this.auth.doLoginStepsManager.add(this.core.adapters.request(this.generateUrl(t),{method:"GET",dataType:"json",timeout:8e3}))},t.setLadderTimer=function setLadderTimer(t,i,u,m){var h=this;this.timer&&clearTimeout(this.timer);var v=t[i];this.timer=mo((function(){v&&(h.setLadderTimer(t,i+1,u,m),h.core.logger.log("V1NIMLoginService::getLbsInfos "+i+":",h.processLbsUrl(v)),h.reportForLbsStart(v,i),h.requstLbs(v).then((function(t){h.reset(),u(Dt(Dt({},t),{url:v}))})).catch((function(u){var M;if(h.core.logger.warn("V1NIMLoginService::getLbsInfos "+i+" failed:",u),h.failedCount+=1,h.reportForFailOnce(v,u.code,(null===(M=u.detail)||void 0===M?void 0:M.reason)||u.message),h.failedCount>=t.length||h.checkTerminator(u.code))return h.reset(),void m(u)})))}),2e3)},t.ladderLoad=function ladderLoad(t){var i=this;return new zi((function(u,m){t.length>1&&i.setLadderTimer(t,1,u,m);var h=t[0];i.core.logger.log("V1NIMLoginService::getLbsInfos 0:",h),i.reportForLbsStart(h,0),i.requstLbs(h).then((function(t){i.reset(),u(Dt(Dt({},t),{url:h}))})).catch((function(u){var v;i.failedCount+=1,i.core.logger.warn("V1NIMLoginService::getLbsInfos 0 failed:",u),i.reportForFailOnce(h,u.code,(null===(v=u.detail)||void 0===v?void 0:v.reason)||u.message),(i.failedCount>=t.length||i.checkTerminator(u.code))&&(i.reset(),m(u))}))}))},t.success=function success(t){var i,u,m,h,v=t.data,M=[this.auth.config.linkUrl];get(v,"common.link")&&(M=concat(h=get(v,"common.link")).call(h,M));get(v,'common["link.default"]')&&(M=concat(M).call(M,get(v,'common["link.default"]'))),this.socketLinkUrls=M,v["nos-chunk"]&&(this.logger.log("getLbsInfos success. lbs.nos-chunk",v["nos-chunk"]),null===(u=this.core.cloudStorage)||void 0===u||u.setOptions({chunkUploadHost:v["nos-chunk"]})),Dn(v.nosup)&&v.nosup.length>0&&(this.logger.log("getLbsInfos success. lbs.nosup",v.nosup),null===(m=this.core.cloudStorage)||void 0===m||m.setOptions({commonUploadHostBackupList:v.nosup,commonUploadHost:v.nosup[0]})),this.core.logger.log("V1NIMLoginService::getLbsInfos success, socket link:",slice(i=this.socketLinkUrls).call(i,0),"chunkUploadHost: ",t.data["nos-chunk"]),this.reportForLbsSuccess(t.url,t.data)},t.reportForLbsStart=function reportForLbsStart(t,i){this.core.reporterHookLBS.updateBegin({target:t,index:i})},t.reportForLbsSuccess=function reportForLbsSuccess(t,i){this.core.reporterHookLBS.updateComplete({target:t,code:200,body:Un(i)}),this.core.reporterHookLBS.end(!0),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"HTTP",target:t,code:200,succeed:!0},{asyncParams:pd.net.getNetworkStatus()})},t.reportForFailOnce=function reportForFailOnce(t,i,u){this.core.reporterHookLBS.updateComplete({target:t,code:i,body:u})},t.reportForFail=function reportForFail(t,i,u){this.core.reporterHookLBS.end(!1),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"HTTP",target:t,description:u,code:i,succeed:!1},{asyncParams:pd.net.getNetworkStatus()})},t.reset=function reset(){this.socketLinkUrls=[],this.failedCount=0,clearTimeout(this.timer)},V1NIMLoginLbs}(),mp=function(){function V1NIMLoginAuthenticator(t){this.core=t}var t=V1NIMLoginAuthenticator.prototype;return t.verifyAuthentication=function verifyAuthentication(t){var i,u,m;return void 0===t&&(t=!1),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var h,v,M,I,S,T,C,E,A,k,R,w;return ud.wrap((function _callee$(N){for(;;)switch(N.prev=N.next){case 0:return v=this.core.options,M=pd.getSystemInfo(),I=Dt(Dt({},v),{appLogin:t?0:1,appkey:v.appkey,account:v.account,token:v.token,deviceId:this.core.auth.deviceId,clientSession:this.core.auth.clientSession,clientType:16,protocolVersion:1,sdkVersion:100971,sdkHumanVersion:"10.9.71",os:M.os,browser:M.browser,userAgent:this.core.options.loginSDKTypeParamCompat?"Native/10.9.71":slice(h=M.userAgent.replace("{{appkey}}",v.appkey)).call(h,0,299),libEnv:this.core.options.loginSDKTypeParamCompat?void 0:M.libEnv,hostEnv:this.core.options.loginSDKTypeParamCompat?0:M.hostEnvEnum}),S=M.os.toLowerCase(),"UNIAPP"!==pd.platform||"ios"!==S&&"android"!==S||(I.isReactNative=1,I.clientType="ios"===S?2:1,T=!!(null===(i=this.core.offlinePush.authConfig)||void 0===i?void 0:i.honorCertificateName),M.pushDeviceInfo&&M.pushDeviceInfo.MANUFACTURER&&(I.deviceInfo=Un(Dt({IS_SUPPORT_HONOR:T},M.pushDeviceInfo)))),this.core.logger.log("clientSocketV1::do login,accid:"+v.account+";clientSession:"+(null===(m=null===(u=this.core.clientSocket)||void 0===u?void 0:u.socket)||void 0===m?void 0:m.sessionId)),N.next=8,this.core.clientSocket.sendCmd("login",{login:I});case 8:if(!(C=N.sent).error){N.next=11;break}throw C.error;case 11:return E=C.content,A=E.loginRes,k=E.loginPorts,R=E.aosPushInfo,w=formatMultiPortLoginInfo(k,2),(w=filter(w).call(w,(function(t){return t.connectionId!==A.connectionId}))).length>0&&this.core.emit("multiPortLogin",w),N.abrupt("return",Dt(Dt({},A),{aosPushInfo:R}));case 16:case"end":return N.stop()}}),_callee,this)})))},t.checkLoginTerminalCode=function checkLoginTerminalCode(t){if(void 0===t)return!1;var i=[201,302,317,403,404,417,422];return includes(i).call(i,t)},V1NIMLoginAuthenticator}(),hp=function(t){function V2Service(i,u){var m;return(m=t.call(this)||this).name=i,m.logger=u.logger,m.core=u,m}Nt(V2Service,t);var i=V2Service.prototype;return i.checkV2=function checkV2(){var t=this.core.options.apiVersion;if("v2"===t)return!0;throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:'The version "'+t+'" of client is not supported.'}})},i.checkLogin=function checkLogin(){if(0===this.core.V2NIMLoginService.getLoginStatus())throw new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE,detail:{reason:"Client logout."}})},i.emit=function emit(i){for(var u=this,m=arguments.length,h=new Array(m>1?m-1:0),v=1;v<m;v++)h[v-1]=arguments[v];this.logger.debug(this.name+"::emit event: '"+i.toString()+"',",void 0!==h[0]?h[0]:"",void 0!==h[1]?h[1]:"",void 0!==h[2]?h[2]:"");try{var M,I,S=(M=t.prototype.emit).call.apply(M,concat(I=[this,i]).call(I,h));return S}catch(t){return mo((function(){throw u.logger.error(u.name+"::emit throw error in setTimeout. event: "+i.toString()+". Error",t),t}),0),!1}},i.process=function process(t){var i=this[t.cmd+"Handler"],u=this.handler&&this.handler[t.cmd+"Handler"];if("function"==typeof i||"function"==typeof u){if(t.error)return this.logger.error(t.cmd+"::recvError",t.error),zi.reject(t.error);try{var m=i?i.call(this,t):u.call(this.handler,t);return zi.resolve(m)}catch(t){return zi.reject(t)}}var h=get(t,"error.detail.ignore");return t.error&&!h?zi.reject(t.error):zi.resolve(t)},V2Service}(ho),gp=function(){function Service(t,i){this.name=t,this.core=i,this.name=t,this.logger=i.logger,this.core=i}return Service.prototype.process=function process(t){var i=this[t.cmd+"Handler"];if("function"==typeof i)return i.call(this,t);var u=get(t,"error.detail.ignore");return t.error&&!u?zi.reject(t.error):zi.resolve(t)},Service}(),vp={"6_3":"notifylog","6_4":"uploadLog","6_23":"getServerTime","6_31":"notifyDetect","6_32":"uploadDetect","6_37":"wsDetect"},fp={type:1,params:2,result:3,t1:100,t2:101,t3:102,t4:103,t5:104,t6:105},yp={k1:1,k2:2,k3:3,k4:4,k5:5,k6:6,k7:7,k8:8,k9:9,k10:10},Mp={notifylog:{sid:6,cid:3,service:"misc"},uploadLog:{sid:6,cid:4,service:"misc",hasPacketResponse:!1,params:[{type:"String",name:"url"},{type:"Property",name:"data",reflectMapper:{type:1,content:2}}]},getServerTime:{sid:6,cid:23,service:"misc",response:[{type:"Long",name:"time"}]},notifyDetect:{sid:6,cid:31,service:"misc",response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(fp)}]},uploadDetect:{sid:6,cid:32,service:"misc",hasPacketResponse:!1,params:[{type:"Property",name:"data",reflectMapper:fp}]},wsDetect:{sid:6,cid:37,service:"misc",params:[{type:"Property",name:"tag",reflectMapper:yp}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(yp)}]}},Ip={type:{type:"number"},t1:{type:"number"},t2:{type:"number"},t3:{type:"number"},t4:{type:"number"},t5:{type:"number"},t6:{type:"number"}};var _p=function(t){function MiscService(i){var u;return(u=t.call(this,"misc",i)||this).logLock=!1,u.core=i,registerParser({cmdMap:vp,cmdConfig:Mp}),u.setListener(),u}Nt(MiscService,t);var i=MiscService.prototype;return i.setListener=function setListener(){var t,i=this;this.core.eventBus.on("BinaryClientSocket/unpackError",bind$1(t=this.wsDetect).call(t,this)),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",(function(){i.core.timeOrigin.setOriginTimetick()})),this.core.eventBus.on("logined",(function(){i.core.timeOrigin.setOriginTimetick()}))},i.getServerTime=function getServerTime(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t;return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.core.clientSocket.sendCmd("getServerTime");case 2:return t=i.sent,i.abrupt("return",Gd(t.content.time));case 4:case"end":return i.stop()}}),_callee,this)})))},i.wsDetect=function wsDetect(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h;return ud.wrap((function _callee2$(v){for(;;)switch(v.prev=v.next){case 0:return i=Dt({k1:"val1",k2:"val2"},t),u=null,v.prev=2,v.next=5,this.core.clientSocket.sendCmd("wsDetect",{tag:i});case 5:m=v.sent,u=m.content.data,v.next=14;break;case 9:return v.prev=9,v.t0=v.catch(2),(h=v.t0).code===zl.V2NIM_ERROR_CODE_UNPACK_ERROR?(this.logger.warn("misc::wsDetect:998"),this.wsDetectUnreliable(),this.reportBinarySocketDetectResult("packet 998")):this.logger.warn("misc::wsDetect:failed "+h.code),v.abrupt("return");case 14:u&&Un(u)!==Un(i)?(this.logger.warn("misc::wsDetect:content unreliable"),this.wsDetectUnreliable(),this.reportBinarySocketDetectResult("content unreliable")):this.logger.log("misc::wsDetect:success");case 15:case"end":return v.stop()}}),_callee2,this,[[2,9]])})))},i.wsDetectUnreliable=function wsDetectUnreliable(){this.core.clientSocket.doDisconnect(3,"WSDetectUnreliable")},i.reportBinarySocketDetectResult=function reportBinarySocketDetectResult(t){var i;this.core.reporter.reportTraceStart("exceptions",{user_id:this.core.account,trace_id:null===(i=this.core.clientSocket.socket)||void 0===i?void 0:i.sessionId,start_time:to(),action:2,exception_service:9}),this.core.reporter.reportTraceUpdateV2("exceptions",{code:998,description:"wsDetect::reconnect cause: "+t,operation_type:"5",target:"6-37"}),this.core.reporter.reportTraceEnd("exceptions",1)},i.notifyDetectHandler=function notifyDetectHandler(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return m=t.content.data,(i=format(Ip,m)).t3=t.__receiveTimeNode.time,i.t4=to(),u.prev=3,u.next=6,this.core.clientSocket.sendCmd("uploadDetect",{data:i});case 6:u.next=11;break;case 8:u.prev=8,u.t0=u.catch(3),this.core.logger.warn("misc::notifyDetectHandler:upload failed",u.t0);case 11:case"end":return u.stop()}var m}),_callee3,this,[[3,8]])})))},i.notifylogHandler=function notifylogHandler(){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var t,i,u,m,h;return ud.wrap((function _callee4$(v){for(;;)switch(v.prev=v.next){case 0:if(t=void 0,!this.logLock){v.next=4;break}return this.core.logger.warn("misc::notifylogHandler:locked"),v.abrupt("return");case 4:return this.logLock=!0,v.prev=5,v.next=8,this.core.logger.extractLogs();case 8:t=v.sent,v.next=15;break;case 11:return v.prev=11,v.t0=v.catch(5),this.logLock=!1,v.abrupt("return");case 15:if(t){v.next=18;break}return this.logLock=!1,v.abrupt("return");case 18:return i="",v.prev=19,v.next=22,this.core.cloudStorage.uploadFile("string"==typeof t?{type:"file",filePath:t}:{type:"file",file:t});case 22:u=v.sent,i=u.url,v.next=30;break;case 26:return v.prev=26,v.t1=v.catch(19),this.logLock=!1,v.abrupt("return");case 30:if(i){v.next=33;break}return this.logLock=!1,v.abrupt("return");case 33:return m=indexOf(i).call(i,"?")>0?"&":"?",h="string"==typeof t&&indexOf(t).call(t,".zip")>0?"zip":"log",i+=m+"download="+to()+"_web."+h,v.prev=36,v.next=39,this.core.clientSocket.sendCmd("uploadLog",{url:i});case 39:v.next=45;break;case 41:return v.prev=41,v.t2=v.catch(36),this.logLock=!1,v.abrupt("return");case 45:return v.prev=45,v.next=48,this.logger.afterUpload();case 48:v.next=52;break;case 50:v.prev=50,v.t3=v.catch(45);case 52:this.logLock=!1;case 53:case"end":return v.stop()}}),_callee4,this,[[5,11],[19,26],[36,41],[45,50]])})))},MiscService}(gp),Sp={needReconnect:!0,reconnectionAttempts:xt,lbsUrls:Wd,linkUrl:zd,xhrConnectTimeout:8e3,socketConnectTimeout:8e3,linkSSL:!0},Tp=function(t){function V1NIMLoginServiceImpl(i,u){var m;(m=t.call(this,"V1NIMLoginService",i)||this).account="",m.token="",m.deviceId="",m.processId="",m.clientSession="",m.status="unconnected",m.config=Sp,m.isManualLoginAttempt=!1,m.core._registerDep(_p,"misc"),registerParser({cmdMap:Ju,cmdConfig:ep}),i.V1NIMLoginService=Je(m),u&&m.setOptions(u);var h=new up(m.core,Je(m));return m.clientSocket=h,"v1"===m.core.options.apiVersion&&(m.core.clientSocket=h,m.core.auth=Je(m)),m.lbs=new pp(i),m.authenticator=new mp(i),m.doLoginStepsManager=new Jd,m}Nt(V1NIMLoginServiceImpl,t);var i=V1NIMLoginServiceImpl.prototype;return i.reset=function reset(){this.lbs.reset()},i.setOptions=function setOptions(t){var i,u,m;t&&Ht(t).length>0?(this.config=assignOptions(this.config,t),this.account=t.account||this.core.options.account,this.token=t.token||this.core.options.token,this.core.options=Dt(Dt({},this.core.options),this.config)):(this.config=assignOptions(this.core.options,this.config),this.account=this.core.options.account,this.token=this.core.options.token),null===(u=null===(i=this.core.clientSocket)||void 0===i?void 0:i.setLinkSSL)||void 0===u||u.call(i,null===(m=this.config.linkSSL)||void 0===m||m);var h="",v="";this.config.isFixedDeviceId?(h=pd.localStorage.getItem("__NIM_DEVC_ID__")||jd(),v=pd.localStorage.getItem("__NIM_CLIENT_SESSION_ID__")||jd(),pd.localStorage.setItem("__NIM_DEVC_ID__",h),pd.localStorage.setItem("__NIM_CLIENT_SESSION_ID__",v)):(h=jd(),v=jd()),this.deviceId=h,this.clientSession=v,this.core.reporter.setConfig({common:{dev_id:h}})},i.connect=function connect(t){return void 0===t&&(t={}),this.login(t)},i.login=function login(t){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return this._checkApiVersion(),t.isAutoReconnect||(this.isManualLoginAttempt=!0,this.processId=jd()),i.next=4,this._connect(t);case 4:return this.core.abtest.abtRequest(),i.prev=5,i.next=8,this.doLogin(t.isAutoReconnect);case 8:this.processId=jd(),this.isManualLoginAttempt=!1,i.next=16;break;case 12:throw i.prev=12,i.t0=i.catch(5),this.isManualLoginAttempt=!1,i.t0;case 16:case"end":return i.stop()}}),_callee,this,[[5,12]])})))},i._connect=function _connect(t){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h=this;return ud.wrap((function _callee2$(v){for(;;)switch(v.prev=v.next){case 0:if(/^(unconnected|waitReconnect)$/.test(this.core.status)){v.next=4;break}return i="NIM status is "+this.core.status+", and would not connect",this.logger.warn(i),v.abrupt("return",zi.reject(i));case 4:return this.clientSocket.beforeConnect(),this.core.reporter.reportTraceCancel("login"),this.core.reporter.reportTraceStart("login",{user_id:this.core.options.account,action:t.isAutoReconnect?"auto_login":"manual_login",binary_websocket:!1,process_id:this.processId}),this.core.reporter.reportTraceUpdateV2("login",{code:0,description:Un(Dt(Dt({},this.core.options),{account:"***",token:"***"})),operation_type:"conf_init",succeed:!0,duration:0,target:""},{asyncParams:pd.net.getNetworkStatus()}),v.next=10,this.lbs.getLbsInfos();case 10:return u=v.sent,v.prev=11,v.next=14,this.clientSocket.connect({linkUrls:u,isAutoReconnect:t.isAutoReconnect},(function(t,i){h.core.reporter.reportTraceUpdateV2("login",{operation_type:"TCP",target:i,code:t.code||408,description:"ws_handshake_failed:"+t.message,succeed:!1},{asyncParams:pd.net.getNetworkStatus()})}));case 14:(m=v.sent)&&this.core.reporter.reportTraceUpdateV2("login",{operation_type:"TCP",target:m,code:200,succeed:!0},{asyncParams:pd.net.getNetworkStatus()}),v.next=22;break;case 18:throw v.prev=18,v.t0=v.catch(11),this.core.reporter.reportTraceEnd("login",!1),v.t0;case 22:case"end":return v.stop()}}),_callee2,this,[[11,18]])})))},i.doLogin=function doLogin(t){return void 0===t&&(t=!1),__awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h,v;return ud.wrap((function _callee3$(M){for(;;)switch(M.prev=M.next){case 0:return M.prev=0,M.next=3,this.authenticator.verifyAuthentication(t);case 3:i=M.sent,this.core.reporter.reportTraceUpdateV2("login",{operation_type:"protocol",target:"2-3",code:200,succeed:!0},{asyncParams:pd.net.getNetworkStatus()}),this.core.reporter.reportTraceEnd("login",!0),this.core.status="logined",M.next=21;break;case 9:if(M.prev=9,M.t0=M.catch(0),u=M.t0,m=get(u,"data.disconnect_reason")||"",h=415===u.code?Un({disconnect_reason:m}):u.message,this.core.logger.warn("nim login:: login failed",M.t0),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"protocol",target:"2-3",code:u.code||0,succeed:!1,description:h},{asyncParams:pd.net.getNetworkStatus()}),this.core.reporter.reportTraceEnd("login",!1),this.clientSocket.doDisconnect(ip.OFFLINE,this.isManualLoginAttempt?"FailedToInitializeLogin":"ReconnectLoginFailed",M.t0),!this.isManualLoginAttempt){M.next=20;break}throw M.t0;case 20:return M.abrupt("return");case 21:return M.prev=21,v=i.loginTime?Gd(i.loginTime):to(),M.next=25,this.core.cloudStorage.init(v);case 25:M.next=30;break;case 27:M.prev=27,M.t1=M.catch(21),this.core.logger.error("NIM:login cloudStorage init failed ",M.t1);case 30:this.core.eventBus.emit("logined",i),this.core.emit("logined",i),this.emit("logined",i),this.core.logger.log("login done"),this.clientSocket.resetConnectStatus(),this.clientSocket.ping();case 36:case"end":return M.stop()}}),_callee3,this,[[0,9],[21,27]])})))},i.disconnect=function disconnect(){return this.logout()},i.logout=function logout(){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:this._checkApiVersion(),this.doLoginStepsManager.clear(),t.t0=this.status,t.next="logined"===t.t0?5:"connected"===t.t0||"connecting"===t.t0||"waitReconnect"===t.t0?18:"unconnected"===t.t0||"destroyed"===t.t0?21:22;break;case 5:return t.prev=5,t.next=8,this.clientSocket.sendCmd("logout",void 0,{timeout:1e3});case 8:this.clientSocket.doDisconnect(ip.ACTIVE,"UserActiveDisconnect"),this.core._clearModuleData(),t.next=17;break;case 12:t.prev=12,t.t1=t.catch(5),this.logger.error("Instance::disconnect sendCmd:logout error",t.t1),this.clientSocket.doDisconnect(ip.ACTIVE,"UserActiveDisconnect"),this.core._clearModuleData();case 17:return t.abrupt("break",22);case 18:return this.clientSocket.doDisconnect(ip.ACTIVE,"UserActiveDisconnect"),this.core._clearModuleData(),t.abrupt("return",zi.resolve());case 21:return t.abrupt("return",zi.resolve());case 22:case"end":return t.stop()}}),_callee4,this,[[5,12]])})))},i.kick=function kick(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var u;return ud.wrap((function _callee5$(m){for(;;)switch(m.prev=m.next){case 0:return this._checkApiVersion(),m.next=3,this.clientSocket.sendCmd("kick",t);case 3:return u=m.sent,m.abrupt("return",null===(i=u.content)||void 0===i?void 0:i.deviceIds);case 5:case"end":return m.stop()}}),_callee5,this)})))},i._checkApiVersion=function _checkApiVersion(){if("v1"!==this.core.options.apiVersion)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:'apiVersion is not "v1"'}})},i.nimLoginClientChangeHandler=function nimLoginClientChangeHandler(t){if(t.error)this.logger.error("nimLoginClientChangeHandler:: error, ",t.error);else{var i=t.content,u=formatMultiPortLoginInfo(i.datas,i.state);u.length>0&&(this.core.emit("multiPortLogin",u),this.emit("multiPortLogin",u))}},i.kickedHandler=function kickedHandler(t){if(t.error)this.logger.error("kickedHandler:: error, ",t.error);else{var i=function formatBeKickedTag$1(t){var i=format({clientType:{type:"enum",values:Ku},customClientType:{type:"number"}},t),u=ap[i.reason];return Dt(i,u=u||{reason:"unknow",message:"Unknown reason"})}(t.content);this.logger.warn("kicked::",i),this.clientSocket.doDisconnect(ip.KICKED,i),this.core._clearModuleData()}},i.getConnectStatus=function getConnectStatus(){switch(this.core.status){case"unconnected":case"destroyed":default:return 0;case"connecting":return 2;case"connected":case"logined":return 1;case"waitReconnect":return 3}},i.getLoginStatus=function getLoginStatus(){switch(this.core.status){case"unconnected":case"destroyed":case"waitReconnect":default:return 0;case"connecting":case"connected":return 2;case"logined":return 1}},i.getLoginUser=function getLoginUser(){return this.core.options.account},i.emit=function emit(i){for(var u,m,h,v,M=this.name+"::emit "+i.toString(),I=arguments.length,S=new Array(I>1?I-1:0),T=1;T<I;T++)S[T-1]=arguments[T];return(u=this.logger).log.apply(u,concat(m=[""+M]).call(m,S)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,S))},V1NIMLoginServiceImpl}(hp);function formatLoginInfo(t){return format({type:{type:"number"},port:{type:"number"},customClientType:{type:"number"},timestamp:{type:"number"},loginType:{type:"number"}},t)}var Cp={"26_3":"v2Login","26_5":"v2Logout","26_8":"v2KickOffline","26_9":"v2BeKicked","26_10":"v2LoginClientChange","36_1":"v2GetChatroomLinkAddress"},bp={"1_2":"heartbeat","2_7":"nimLoginClientChange","24_8":"qchatLoginClientChange"},Ep={webLoginReqTag:{clientType:3,os:4,sdkVersion:6,appLogin:8,protocolVersion:9,pushTokenName:10,pushToken:11,clientId:13,appkey:18,account:19,browser:24,clientSession:26,deviceInfo:32,isReactNative:112,customTag:38,customClientType:39,sdkHumanVersion:40,hostEnv:41,userAgent:42,libEnv:44,authType:115,thirdPartyExtension:116,env:119,isRoutable:120,token:1e3},mixAuthRepTag:{clientId:1,consid:2,clientIP:3,port:4,type:5,customClientType:6,timestamp:7,customTag:8,os:9,pushType:10,hasTokenPreviously:11,loginType:12},nimAuthRepTag:{type:3,os:4,mac:5,clientId:13,account:19,deviceInfo:32,customTag:38,customClientType:39,consid:102,clientIP:103,port:104,timestamp:109,pushType:110,hasTokenPreviously:111},qchatAuthRepTag:{clientId:8,consid:102,clientIP:103,port:104,type:6,customClientType:13,timestamp:105,os:30,pushType:100,hasTokenPreviously:101}},Ap={v2Login:{sid:26,cid:3,service:"auth",params:[{type:"Property",name:"tag",reflectMapper:Ep.webLoginReqTag}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ep.mixAuthRepTag)},{type:"PropertyArray",name:"loginClients",reflectMapper:invertSerializeItem(Ep.mixAuthRepTag)}]},v2Logout:{sid:26,cid:5,service:"auth"},v2KickOffline:{sid:26,cid:8,service:"auth",params:[{type:"StrArray",name:"clientIds"}],response:[{type:"StrArray",name:"clientIds"}]},v2BeKicked:{sid:26,cid:9,service:"auth",response:[{type:"Int",name:"clientType"},{type:"Int",name:"reason"},{type:"String",name:"reasonDesc"},{type:"Int",name:"customClientType"}]},v2LoginClientChange:{sid:26,cid:10,service:"auth",response:[{type:"Byte",name:"state"},{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Ep.mixAuthRepTag)}]},v2GetChatroomLinkAddress:{sid:36,cid:1,service:"auth",params:[{type:"Long",name:"roomId"},{type:"Bool",name:"miniProgram"}],response:[{type:"StrArray",name:"linkAddress"}]}},kp={heartbeat:{sid:1,cid:2,service:"auth"},nimLoginClientChange:{sid:2,cid:7,service:"auth",response:[{type:"Byte",name:"state"},{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Ep.nimAuthRepTag)}]},qchatLoginClientChange:{sid:24,cid:8,service:"auth",response:[{type:"Byte",name:"state"},{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ep.qchatAuthRepTag)}]}},Rp=qi.codeAt;_export({target:"String",proto:!0},{codePointAt:function codePointAt(t){return Rp(this,t)}});var wp=entryVirtual("String").codePointAt,Np=String.prototype,codePointAt=function(t){var i=t.codePointAt;return"string"==typeof t||t===Np||z(Np,t)&&i===Np.codePointAt?wp:i},xp=RangeError,Op=String.fromCharCode,Pp=String.fromCodePoint,Lp=R([].join),Vp=!!Pp&&1!=Pp.length;_export({target:"String",stat:!0,arity:1,forced:Vp},{fromCodePoint:function fromCodePoint(t){for(var i,u=[],m=arguments.length,h=0;m>h;){if(i=+arguments[h++],toAbsoluteIndex(i,1114111)!==i)throw xp(i+" is not a valid code point");u[h]=i<65536?Op(i):Op(55296+((i-=65536)>>10),i%1024+56320)}return Lp(u,"")}});var Up=$.String.fromCodePoint,Dp=function abs(t){var i;if(void 0!==t)return(i=BigNumber(t)).sign=1,i},Bp=function isArray(t){return"[object Array]"===Object.prototype.toString.call(t)},qp=function isValidType(t){var i;return some(i=["number"==typeof t,"string"==typeof t&&t.length>0,Bp(t)&&t.length>0,t instanceof BigNumber]).call(i,(function(t){return!0===t}))},Fp="Invalid Number",Gp="Invalid Number - Division By Zero";function BigNumber(t){var i;if(!(this instanceof BigNumber))return new BigNumber(t);if(this.number=[],this.sign=1,this.rest=0,qp(t)){if(Bp(t)){for((t.length&&"-"===t[0]||"+"===t[0])&&(this.sign="+"===t[0]?1:-1,t.shift(0)),i=t.length-1;i>=0;i--)if(!this.addDigit(t[i]))return}else for("-"!==(t=t.toString()).charAt(0)&&"+"!==t.charAt(0)||(this.sign="+"===t.charAt(0)?1:-1,t=t.substring(1)),i=t.length-1;i>=0;i--)if(!this.addDigit(Gd(t.charAt(i),10)))return}else this.number=Fp}BigNumber.prototype.addDigit=function(t){return function testDigit(t){return/^\d$/.test(t)}(t)?(this.number.push(t),this):(this.number=Fp,!1)},BigNumber.prototype._compare=function(t){var i,u;if(!qp(t))return null;if(i=BigNumber(t),this.sign!==i.sign)return this.sign;if(this.number.length>i.number.length)return this.sign;if(this.number.length<i.number.length)return-1*this.sign;for(u=this.number.length-1;u>=0;u--){if(this.number[u]>i.number[u])return this.sign;if(this.number[u]<i.number[u])return-1*this.sign}return 0},BigNumber.prototype.gt=function(t){return this._compare(t)>0},BigNumber.prototype.gte=function(t){return this._compare(t)>=0},BigNumber.prototype.equals=function(t){return 0===this._compare(t)},BigNumber.prototype.lte=function(t){return this._compare(t)<=0},BigNumber.prototype.lt=function(t){return this._compare(t)<0},BigNumber.prototype.subtract=function(t){var i;return void 0===t?this:(i=BigNumber(t),this.sign!==i.sign?(this.number=BigNumber._add(this,i),this):(this.sign=this.lt(i)?-1:1,this.number=Dp(this).lt(Dp(i))?BigNumber._subtract(i,this):BigNumber._subtract(this,i),this))},BigNumber._add=function(t,i){var u,m=0,h=Math.max(t.number.length,i.number.length);for(u=0;u<h||m>0;u++)t.number[u]=(m+=(t.number[u]||0)+(i.number[u]||0))%10,m=Math.floor(m/10);return t.number},BigNumber._subtract=function(t,i){var u,m,h=0,v=t.number.length;for(u=0;u<v;u++)t.number[u]-=(i.number[u]||0)+h,t.number[u]+=10*(h=t.number[u]<0?1:0);for(u=0,v=t.number.length-1;0===t.number[v-u]&&v-u>0;)u++;u>0&&splice(m=t.number).call(m,-u);return t.number},BigNumber.prototype.multiply=function(t){if(void 0===t)return this;var i,u,m=BigNumber(t),h=0,v=[];if(this.isZero()||m.isZero())return BigNumber(0);for(this.sign*=m.sign,i=0;i<this.number.length;i++)for(h=0,u=0;u<m.number.length||h>0;u++)v[i+u]=(h+=(v[i+u]||0)+this.number[i]*(m.number[u]||0))%10,h=Math.floor(h/10);return this.number=v,this},BigNumber.prototype.divide=function(t){if(void 0===t)return this;var i,u,m=BigNumber(t),h=[],v=BigNumber(0);if(m.isZero())return this.number=Gp,this;if(this.isZero())return this.rest=BigNumber(0),this;if(this.sign*=m.sign,m.sign=1,1===m.number.length&&1===m.number[0])return this.rest=BigNumber(0),this;for(i=this.number.length-1;i>=0;i--)for(v.multiply(10),v.number[0]=this.number[i],h[i]=0;m.lte(v);)h[i]++,v.subtract(m);for(i=0,u=h.length-1;0===h[u-i]&&u-i>0;)i++;return i>0&&splice(h).call(h,-i),this.rest=v,this.number=h,this},BigNumber.prototype.mod=function(t){return this.divide(t).rest},BigNumber.prototype.isZero=function(){var t;for(t=0;t<this.number.length;t++)if(0!==this.number[t])return!1;return!0},BigNumber.prototype.toString=function(){var t,i="";if("string"==typeof this.number)return this.number;for(t=this.number.length-1;t>=0;t--)i+=this.number[t];return this.sign>0?i:"-"+i};var Hp=Math.pow(2,32);function varintToBytes(t){for(var i=new Uint8Array(5),u=new DataView(i.buffer),m=0;0!=(4294967168&t);)u.setUint8(m++,127&t|128),t>>>=7;return u.setUint8(m++,127&t),slice(i).call(i,0,m)}function encodeText(t){if("function"==typeof TextEncoder)return(new TextEncoder).encode(t);var i=function textEncoder(t){for(var i=[],u=t.length,m=0;m<u;){var h=codePointAt(t).call(t,m),v=0,M=0;for(h<=127?(v=0,M=0):h<=2047?(v=6,M=192):h<=65535?(v=12,M=224):h<=2097151&&(v=18,M=240),i.push(M|h>>v),v-=6;v>=0;)i.push(128|h>>v&63),v-=6;m+=h>=65536?2:1}return i}(t);return new Uint8Array(i)}function decodeText(t){return"function"==typeof TextDecoder?new TextDecoder("utf-8").decode(t):function textDecoder(t){for(var i="",u=0;u<t.length;){var m=t[u],h=0,v=0;if(m<=127?(h=0,v=255&m):m<=223?(h=1,v=31&m):m<=239?(h=2,v=15&m):m<=244&&(h=3,v=7&m),t.length-u-h>0)for(var M=0;M<h;)v=v<<6|63&(m=t[u+M+1]),M+=1;else v=65533,h=t.length-u;i+=Up(v),u+=h+1}return i}(t)}var jp=function(){function Unpack(t){this.offset=0,this.buffer=new Uint8Array(t),this.view=new DataView(t)}var t=Unpack.prototype;return t.checkBufferBoundaryAccess=function checkBufferBoundaryAccess(){return this.offset>=this.buffer.byteLength},t.length=function length(){var t;return(null===(t=this.view)||void 0===t?void 0:t.byteLength)||0},t.getBuffer=function getBuffer(){return this.view.buffer},t.getOffset=function getOffset(){return this.offset},t.popRaw=function popRaw(t){try{var i,u=slice(i=this.buffer).call(i,this.offset,this.offset+t);return this.offset+=t,u}catch(t){throw new Error("UnpackException raw "+(t&&t.message))}},t.popByte=function popByte(){try{var t=this.view.getUint8(this.offset);return this.offset+=1,t}catch(t){throw new Error("UnpackException byte "+(t&&t.message))}},t.popVarbin=function popVarbin(){return this.popRaw(this.popVarInt())},t.popString=function popString(){try{return decodeText(this.popVarbin())}catch(t){throw new Error("UnpackException string "+(t&&t.message))}},t.popInt=function popInt(){try{var t=this.view.getUint32(this.offset,!0);return this.offset+=4,t}catch(t){throw new Error("UnpackException int "+(t&&t.message))}},t.popVarInt=function popVarInt(){var t=1,i=0,u=0,m=0;do{if(i+=(127&(u=this.popByte()))*t,t*=128,(m+=1)>5)throw new Error("Variable length quantity is too long")}while(0!=(128&u));return i},t.popLong=function popLong(){try{var t,i=function getBigUint64(t,i){void 0===i&&(i=!1);var u=new DataView(t.buffer),m=i?[4,0]:[0,4],h=m[0],v=m[1],M=u.getUint32(h,i),I=u.getUint32(v,i);return M>0?M*Hp+I:I}(slice(t=this.buffer).call(t,this.offset,this.offset+8),!0);return this.offset+=8,Number(i)}catch(t){throw new Error("UnpackException long "+(t&&t.message))}},t.popShort=function popShort(){try{var t=this.view.getUint16(this.offset,!0);return this.offset+=2,t}catch(t){throw new Error("UnpackException short "+(t&&t.message))}},t.popBoolean=function popBoolean(){return this.popByte()>0},t.toString=function toString(){return id(new Uint8Array(this.buffer)).toString()},t.reset=function reset(){this.offset=0,this.buffer=null,this.view=null},Unpack}(),$p=function(){function PacketDecoder(t){this.packetLength=0,this.serviceId=0,this.commandId=0,this.serialId=0,this.tag=0,this.resCode=200,this.innerHeader=null,this.msgId=0,this.bodyArr=[],this.unpack=new jp(t)}var t=PacketDecoder.prototype;return t.reset=function reset(){this.innerHeader=null,this.bodyArr=[],this.unpack.reset()},t.getBodyDetail=function getBodyDetail(){return this.bodyArr.join("")},t.unmarshalHeader=function unmarshalHeader(){var t,i=this._unmarshalHeader();this.packetLength=i.packetLength,this.serviceId=i.serviceId,this.commandId=i.commandId,this.serialId=i.serialId,this.tag=i.tag,this.resCode=i.resCode,4===i.serviceId&&includes(t=[1,2,10,11]).call(t,i.commandId)&&(this.msgId=this.unmarshalLong(),this.innerHeader=this._unmarshalHeader())},t._unmarshalHeader=function _unmarshalHeader(){var t=this.unpack.popVarInt(),i=this.unpack.popByte(),u=this.unpack.popByte(),m=this.unpack.popShort(),h=this.unpack.popByte(),v=200;return this.hasRescode(h)&&(v=this.unpack.popShort()),{packetLength:t,serviceId:i,commandId:u,serialId:m,tag:h,resCode:v}},t.hasRescode=function hasRescode(t){return 0!=((t=t||this.tag)&PacketDecoder.RES_CODE)},t.getHeader=function getHeader(){return{packetLength:this.packetLength,sid:this.serviceId,cid:this.commandId,ser:this.serialId,code:this.resCode}},t.getInnerHeader=function getInnerHeader(){return this.innerHeader?{sid:this.innerHeader.serviceId,cid:this.innerHeader.commandId}:null},t.unmarshalProperty=function unmarshalProperty(){var t=this.unpack.popVarInt(),i={};this.bodyArr.push("\nProperty("+t+") {");for(var u=0;u<t;u++){var m=this.unpack.popVarInt();this.bodyArr.push(m+":");var h=this.unpack.popString();this.bodyArr.push('"'+h.length+" "+this.unpack.getOffset()+'",'),i[m]=h}return this.bodyArr.push("},"),i},t.unmarshalPropertyArray=function unmarshalPropertyArray(){var t=this.unpack.popVarInt(),i=[];this.bodyArr.push("\nPropertyArray("+t+") [");for(var u=0;u<t;u++)i.push(this.unmarshalProperty());return this.bodyArr.push("],"),i},t.unmarshalLong=function unmarshalLong(){var t=this.unpack.popLong();return this.bodyArr.push("\nLong:"+t),t},t.unmarshalLongArray=function unmarshalLongArray(){var t=this.unpack.popVarInt(),i=[];this.bodyArr.push("\nLongArray "+t+":");for(var u=0;u<t;u++){var m=this.unpack.popLong();this.bodyArr.push(m+","),i.push(m)}return i},t.unmarshalStrArray=function unmarshalStrArray(){var t=this.unpack.popVarInt(),i=[];this.bodyArr.push("\nStrArray "+t+":");for(var u=0;u<t;u++){var m=this.unpack.popString();this.bodyArr.push(m+","),i.push(m)}return i},t.unmarshalStrLongMap=function unmarshalStrLongMap(){var t=this.unpack.popVarInt(),i={};this.bodyArr.push("\nStrLongMap "+t+":");for(var u=0;u<t;u++){var m=this.unpack.popString();this.bodyArr.push(m+",");var h=this.unpack.popLong();this.bodyArr.push(h+";"),i[m]=h}return i},t.unmarshalStrStrMap=function unmarshalStrStrMap(){var t=this.unpack.popVarInt(),i={};this.bodyArr.push("\nStrStrMap "+t+":");for(var u=0;u<t;u++){var m=this.unpack.popString();this.bodyArr.push(m+",");var h=this.unpack.popString();this.bodyArr.push(h+";"),i[m]=h}return i},t.unmarshalLongLongMap=function unmarshalLongLongMap(){var t=this.unpack.popVarInt(),i={};this.bodyArr.push("\nStrLongLongMap "+t+":");for(var u=0;u<t;u++){var m=this.unpack.popLong();this.bodyArr.push(m+",");var h=this.unpack.popLong();this.bodyArr.push(h+";"),i[m]=h}return{m_map:i}},t.unmarshalKVArray=function unmarshalKVArray(){var t=this.unpack.popVarInt(),i=[];this.bodyArr.push("\nKVArray "+t+":");for(var u=0;u<t;u++)i.push(this.unmarshalStrStrMap());return i},t.unmarshal=function unmarshal(t){var i,u=this,m=Dt(Dt({},this.getHeader()),{r:[]});if(this.innerHeader&&(m.r[0]=this.msgId,m.r[1]={body:[],headerPacket:this.getInnerHeader()}),!includes(i=[200,406,808,810,7101]).call(i,m.code))return Un(m);if(this.packetLength>0&&this.packetLength>this.unpack.length())throw new Error("UnpackException packetLength("+this.packetLength+") greater than bufferLength("+this.unpack.length()+")");var h=[];return t&&forEach$1(t).call(t,(function(t){if(!u.unpack.checkBufferBoundaryAccess())switch(t.type){case"PropertyArray":h.push(u.unmarshalPropertyArray());break;case"Property":h.push(u.unmarshalProperty());break;case"Byte":h.push(u.unpack.popByte());break;case"Int":h.push(u.unpack.popInt());break;case"Bool":h.push(u.unpack.popBoolean());break;case"Long":h.push(u.unmarshalLong());break;case"LongArray":h.push(u.unmarshalLongArray());break;case"String":h.push(u.unpack.popString());break;case"StrArray":h.push(u.unmarshalStrArray());break;case"StrStrMap":h.push(u.unmarshalStrStrMap());break;case"StrLongMap":h.push(u.unmarshalStrLongMap());break;case"LongLongMap":h.push(u.unmarshalLongLongMap());break;case"KVArray":h.push(u.unmarshalKVArray())}})),this.innerHeader?m.r[1].body=h:m.r=h,Un(m)},PacketDecoder}();$p.RES_CODE=2;var zp=function(){function Pack(){this.offset=0,this.pageSize=1024,this.capacity=1048576,this.buffer=new Uint8Array(this.pageSize),this.view=new DataView(this.buffer.buffer)}var t=Pack.prototype;return t.reset=function reset(){this.offset=0,this.buffer=null,this.view=null},t.size=function size(){return this.offset},t.getBuffer=function getBuffer(){var t;return slice(t=this.buffer).call(t,0,this.offset).buffer},t.ensureCapacity=function ensureCapacity(t){var i=this.offset+t;if(i>this.capacity)throw new Error("PackException over limit");if(i>this.buffer.byteLength){var u=Math.ceil(i/this.pageSize)*this.pageSize,m=new Uint8Array(u);m.set(this.buffer),this.buffer=m,this.view=new DataView(this.buffer.buffer)}},t.putRaw=function putRaw(t){this.ensureCapacity(t.length);try{this.buffer.set(t,this.offset),this.offset+=t.length}catch(t){throw new Error("PackException raw")}},t.putByte=function putByte(t){this.ensureCapacity(1);try{this.view.setUint8(this.offset++,t)}catch(t){throw new Error("PackException byte")}},t.putString=function putString(t){try{var i=encodeText(t);this.putVarbin(i)}catch(t){throw new Error("PackException string")}},t.putInt=function putInt(t){this.ensureCapacity(4);try{this.view.setInt32(this.offset,t,!0),this.offset+=4}catch(t){throw new Error("PackException int")}},t.putVarInt=function putVarInt(t){var i=varintToBytes(t);this.putRaw(i)},t.putBoolean=function putBoolean(t){this.ensureCapacity(1);try{this.view.setUint8(this.offset++,t?1:0)}catch(t){throw new Error("PackException boolean")}},t.putLong=function putLong(t){this.ensureCapacity(8);try{var i=function setBigUint64(t,i){void 0===i&&(i=!1);var u=new Uint8Array(8),m=new DataView(u.buffer),h=Number(t>Hp-1?t/Hp:0),v=Number(4294967295&t),M=i?[4,0]:[0,4],I=M[0],S=M[1];return m.setUint32(I,h,i),m.setUint32(S,v,i),u}(t,!0);this.buffer.set(i,this.offset),this.offset+=8}catch(t){throw new Error("PackException long")}},t.putStringAsLong=function putStringAsLong(t){this.ensureCapacity(8);try{var i=function setBigUint64ForNumberOverflow(t,i){var u,m;void 0===i&&(i=!1);var h=new Uint8Array(8),v=new DataView(h.buffer),M=reverse$1(u=BigNumber(t).divide(Hp).number).call(u).join(""),I=reverse$1(m=BigNumber(t).mod(Hp).number).call(m).join(""),S=Number(M),T=Number(I),C=i?[4,0]:[0,4],E=C[0],A=C[1];return v.setUint32(E,S,i),v.setUint32(A,T,i),h}(t,!0);this.buffer.set(i,this.offset),this.offset+=8}catch(t){throw new Error("PackException stringAsLong")}},t.putShort=function putShort(t){this.ensureCapacity(2);try{this.view.setInt16(this.offset,t,!0),this.offset+=2}catch(t){throw new Error("PackException short")}},t.putVarbin=function putVarbin(t){if(!t)return this.ensureCapacity(1),this.putVarInt(0);if(t.byteLength>Math.pow(2,31)-2)throw new Error("PackException varbin. too long");var i=varintToBytes(t.length);this.ensureCapacity(i.length+t.length);try{this.buffer.set(i,this.offset),this.offset+=i.length,this.buffer.set(t,this.offset),this.offset+=t.length}catch(t){throw new Error("PackException varbin")}},Pack}();function isConvertibleToNumber(t){if("number"!=typeof t){if(null==t)return!1;t=Number(t)}if(isNaN(t))throw new Error("Number type conversion error");return!0}function isUndefinedOrNull(t){return null==t}var Wp,Kp=function(){function PacketEncoder(t,i,u){this.pack=new zp,this.packetLength=0,this.serviceId=0,this.commandId=0,this.serialId=0,this.tag=0,this.serviceId=t,this.commandId=i,this.serialId=u}var t=PacketEncoder.prototype;return t.marshalHeader=function marshalHeader(){this.pack.putVarInt(this.packetLength),this.pack.putByte(this.serviceId),this.pack.putByte(this.commandId),this.pack.putShort(this.serialId),this.pack.putByte(this.tag)},t.marshalProperty=function marshalProperty(t){var i=this,u=Ht(t),m=filter(u).call(u,(function(t){return!isUndefinedOrNull(t)}));this.pack.putVarInt(m.length),forEach$1(m).call(m,(function(u){i.pack.putVarInt(Number(u)),Dn(t[u])||"[object Object]"===Object.prototype.toString.call(t[u])?i.pack.putString(Un(t[u])):i.pack.putString(String(t[u]))}))},t.marshalPropertyArray=function marshalPropertyArray(t){var i=this,u=t.length;this.pack.putVarInt(u),forEach$1(t).call(t,(function(t){i.marshalProperty(null==t?void 0:t.v)}))},t.marshalStrArray=function marshalStrArray(t){var i=this,u=filter(t).call(t,(function(t){return!isUndefinedOrNull(t)})),m=u.length;this.pack.putVarInt(m),forEach$1(u).call(u,(function(t){i.pack.putString(String(t))}))},t.marshalLongArray=function marshalLongArray(t){var i=this,u=filter(t).call(t,(function(t){return isConvertibleToNumber(t)})),m=u.length;this.pack.putVarInt(m),forEach$1(u).call(u,(function(t){i.putLong(t)}))},t.marshalStrStrMap=function marshalStrStrMap(t){var i=this,u=Ht(t),m=filter(u).call(u,(function(i){return!isUndefinedOrNull(t[i])&&!isUndefinedOrNull(i)}));this.pack.putVarInt(m.length),forEach$1(m).call(m,(function(u){i.pack.putString(String(u)),i.pack.putString(String(t[u]))}))},t.marshalStrLongMap=function marshalStrLongMap(t){var i=this,u=Ht(t),m=filter(u).call(u,(function(i){return isConvertibleToNumber(t[i])&&!isUndefinedOrNull(i)}));this.pack.putVarInt(m.length),forEach$1(m).call(m,(function(u){i.pack.putString(String(u)),i.putLong(t[u])}))},t.marshalLongLongMap=function marshalLongLongMap(t){var i=this,u=Ht(t),m=filter(u).call(u,(function(i){var u=Number(i);return isConvertibleToNumber(u)&&isConvertibleToNumber(t[u])}));this.pack.putVarInt(m.length),forEach$1(m).call(m,(function(u){var m=Number(u);i.putLong(m),i.putLong(t[m])}))},t.marshalKVArray=function marshalKVArray(t){var i=this,u=t.length;this.pack.putVarInt(u),forEach$1(t).call(t,(function(t){i.marshalStrStrMap(t)}))},t.putLong=function putLong(t){"string"==typeof t&&t.length>15?this.pack.putStringAsLong(t):this.pack.putLong(Number(t))},t.marshal=function marshal(t,i){var u=this;return this.marshalHeader(),i&&forEach$1(i).call(i,(function(i,m){var h,v=i.type,M=null===(h=t[m])||void 0===h?void 0:h.v;if(!isUndefinedOrNull(M))switch(v){case"PropertyArray":u.marshalPropertyArray(M);break;case"Property":u.marshalProperty(M);break;case"Byte":if(!isConvertibleToNumber(M))return;u.pack.putByte(Number(M));break;case"Int":if(!isConvertibleToNumber(M))return;u.pack.putInt(Number(M));break;case"Bool":"false"===M?M=!1:"true"===M&&(M=!0),u.pack.putBoolean(M);break;case"Long":if(!isConvertibleToNumber(M))return;u.putLong(M);break;case"LongArray":u.marshalLongArray(M);break;case"String":u.pack.putString(String(M));break;case"StrArray":u.marshalStrArray(M);break;case"StrStrMap":u.marshalStrStrMap(M);break;case"StrLongMap":u.marshalStrLongMap(M);break;case"LongLongMap":u.marshalLongLongMap(M);break;case"KVArray":u.marshalKVArray(M)}})),this.pack.getBuffer()},t.reset=function reset(){this.pack.reset()},PacketEncoder}(),Yp=function(t){function BaseWebsocket(i,u,m){var h;return(h=t.call(this)||this).websocket=null,h.socketConnectTimer=0,h.linkSSL=!0,h.url="",h.core=i,h.url=u,h.linkSSL=m,h.status="disconnected",h.logger=i.logger,h.connect(),h}Nt(BaseWebsocket,t);var i=BaseWebsocket.prototype;return i.connect=function connect(){"connecting"!==this.status&&"connected"!==this.status?(this.status="connecting",this._createWebsocket((this.linkSSL?"wss":"ws")+"://"+this.url+"/websocket")):this.logger.warn("imsocket::socket is connecting or connected",this.status)},i.close=function close(){if(this.status="disconnected",this.websocket){this.logger.log("imsocket:: close websocket");try{this.websocket.close()}catch(t){this.logger.warn("imsocket::attempt to close websocket error",t)}this.clean(),this.emit("disconnect")}},i.clean=function clean(){this.status="disconnected",clearTimeout(this.socketConnectTimer),this.websocket&&(this.socketUrl=void 0,this.websocket.onmessage=null,this.websocket.onopen=null,this.websocket.onerror=null,this.websocket.onclose=null,this.websocket=null)},i.onConnect=function onConnect(){this.status="connected",this.emit("connect"),clearTimeout(this.socketConnectTimer)},i._createWebsocket=function _createWebsocket(t){var i,u=this;this.socketConnectTimer=mo((function(){u.logger.error("imsocket::Websocket connect timeout. url: ",t),u.emit("connectFailed",new Yl({code:"v2"===get(u.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_CONNECT_TIMEOUT:415,detail:{reason:"imsocket::Websocket connect timeout. url: "+t}}))}),this.core.options.socketConnectTimeout||8e3),this.socketUrl=t,this.websocket=new pd.WebSocket(t),this.websocket.binaryType="arraybuffer",this.websocket.onmessage=bind$1(i=this.onMessage).call(i,this),this.websocket.onclose=function(t){t=t||{},u.logger.log("imsocket::Websocket onclose done "+t.wasClean+"/"+t.code+"/"+t.reason),"connected"===u.status?(u.clean(),u.emit("disconnect")):(u.clean(),u.emit("connectFailed",new Yl({code:"v2"===get(u.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_CONNECT_FAILED:414,detail:{reason:"imsocket::Websocket onclose done"}})))},this.websocket.onerror=function(t){u.logger.error("imsocket::Websocket onerror",t),"connected"===u.status?(u.clean(),u.emit("disconnect")):(u.clean(),u.emit("connectFailed",new Yl({code:"v2"===get(u.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_CONNECT_FAILED:414,detail:{reason:"imsocket::Websocket onerror."}})))},this.websocket.onopen=function(){u.onConnect()}},i.onMessage=function onMessage(t){if(t.data){var i=new $p(t.data),u={sid:-1,cid:-1,ser:-1,packetLength:-1},m=null;try{i.unmarshalHeader(),u=i.getHeader(),m=i.getInnerHeader()}catch(i){this.reportBinaryError({err:i,sid:m?m.sid:null==u?void 0:u.sid,cid:m?m.cid:null==u?void 0:u.cid,rawBuf:t.data,type:"decode"})}var h=m?m.sid:u.sid,v=m?m.cid:u.cid,M=h+"_"+v,I=$u[M];if(I&&I.length>0){var S,T=I[0].config;try{S=i.unmarshal(T.response)}catch(m){var C=i.getBodyDetail();this.reportBinaryError({err:m,rawBuf:t.data,sid:h,cid:v,parseDetail:C,type:"decode"}),i.reset();var E=Dt(Dt({},u),{sid:h,cid:v,code:zl.V2NIM_ERROR_CODE_UNPACK_ERROR});return this.logger.error('imsocket::onMessage "'+E.sid+"_"+E.cid+'", ser '+E.ser+", packetLength "+E.packetLength+" unmarshal error. "+C+" \n",m),void this.emit("message",Un(E))}this.emit("message",S)}else this.core.logger.warn("imsocket::onMessage cmd not found",M);i.reset()}},i.send=function send(t,i,u,m,h){var v,M,I=new Kp(t,i,u),S=ju[m],T="";try{T=Un(h),M=I.marshal(JSON.parse(T),S.params)}catch(m){throw this.reportBinaryError({err:m,sid:t,cid:i,rawStr:T,type:"encode"}),I.reset(),new Yl({code:zl.V2NIM_ERROR_CODE_PACK_ERROR,detail:{reason:t+"-"+i+", ser "+u+" marshal error",rawError:m}})}null===(v=this.websocket)||void 0===v||v.send(M),I.reset()},i.reportBinaryError=function reportBinaryError(t){var i,u,m,h=t.err,v=t.rawStr,M=t.sid,I=t.cid,S=t.type,T=t.parseDetail,C=t.rawBuf;if(C){try{m=function arrayBufferToBase64(t){if("function"!=typeof btoa)return"";for(var i="",u=new Uint8Array(t),m=u.byteLength,h=0;h<m;h++)i+=String.fromCharCode(u[h]);return u=null,btoa(i)}(C)}catch(t){m="reportBinaryError::arrayBufferToBase64 parsing failed, error: "+(null==t?void 0:t.message)+", sid: "+M+", cid: "+I,this.core.logger.error(m)}C=null}this.core.reporter.reportTraceStart("exceptions",{user_id:null===(i=this.core.auth)||void 0===i?void 0:i.account,trace_id:null===(u=this.core.clientSocket.socket)||void 0===u?void 0:u.sessionId,start_time:to(),action:2,exception_service:9});var E=h?(h.message+";;;"||h.code+";;;")+(T?"parseDetail: "+T+";;;":"")+(v?" rawStr: "+v:"")+(m?" rawBuf: "+m:""):"";this.core.reporter.reportTraceUpdateV2("exceptions",{code:"encode"===S?zl.V2NIM_ERROR_CODE_PACK_ERROR:zl.V2NIM_ERROR_CODE_UNPACK_ERROR,description:E,operation_type:"encode"===S?3:4,target:M+"-"+I},{asyncParams:pd.net.getNetworkStatus()}),this.core.reporter.reportTraceEnd("exceptions",1)},BaseWebsocket}(ho);function _createForOfIteratorHelperLoose$a(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$a(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$a(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$a(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$a(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}!function(t){t[t.ACTIVE=1]="ACTIVE",t[t.KICKED=2]="KICKED",t[t.OFFLINE=3]="OFFLINE"}(Wp||(Wp={}));var Qp,Jp=function(){function V2BinaryClientSocket(t){this.isReconnect=!1,this.packetTimeout=8e3,this.linkSSL=!0,this.packetSer=1,this.backoff=new op({max:8e3,min:1600,jitter:.01}),this.sendingCmdMap=new Sc,this.pingTimer=0,this.hasNetworkListener=!1,this.core=t,this.auth=t.auth,this.logger=t.logger,this.reporter=t.reporter,this.timerManager=t.timerManager,this.eventBus=t.eventBus,this.setListener()}var t=V2BinaryClientSocket.prototype;return t.setListener=function setListener(){var t=this;this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",(function(){t.isReconnect=!0}))},t.setSessionId=function setSessionId(t){this.socket&&(this.socket.sessionId=t)},t.setLinkSSL=function setLinkSSL(t){this.linkSSL=t},t.connect=function connect(t,i){var u,m;return void 0===i&&(i=!1),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var h,v,M,I;return ud.wrap((function _callee$(S){for(;;)switch(S.prev=S.next){case 0:if(this.isReconnect=i,1!==(h=this.core.auth.getConnectStatus())){S.next=7;break}return v="clientSocket::connect status is "+h+", and would not repeat connect",M=new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE,detail:{reason:v}}),this.logger.warn(v),S.abrupt("return",zi.reject(M));case 7:return this.auth.lifeCycle.processEvent("connect"),S.prev=8,S.next=11,this.auth.doLoginStepsManager.add(this.doConnect(t));case 11:this.logger.log("clientSocketV2:: connect success with link url: "+t+", isReconnect: "+i),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"TCP",target:t,code:200,mixlink:!0,succeed:!0},{asyncParams:pd.net.getNetworkStatus()}),this.auth.lifeCycle.processEvent("connectSucc"),S.next=28;break;case 16:if(S.prev=16,S.t0=S.catch(8),I=S.t0,this.core.reporter.reportTraceUpdateV2("login",{operation_type:"TCP",target:t,code:I.code||0,description:"connectFailed:"+I.message,mixlink:!0,succeed:!1},{asyncParams:pd.net.getNetworkStatus()}),I.code!==zl.V2NIM_ERROR_CODE_CANCELLED&&I.code!==zl.V2NIM_ERROR_CODE_TIMEOUT){S.next=25;break}throw null===(u=this.socket)||void 0===u||u.close(),null===(m=this.socket)||void 0===m||m.removeAllListeners(),this.socket=void 0,S.t0;case 25:throw this.logger.warn("clientSocketV2::connect failed with link url: "+t,I),this.auth.lifeCycle.processEvent("connectFail",I),S.t0;case 28:case"end":return S.stop()}}),_callee,this,[[8,16]])})))},t.doConnect=function doConnect(t){var i=this,u=!1;return new zi((function(m,h){var v;i.socket=new Yp(i.core,t,i.linkSSL),i.socket.on("connect",(function(){i.logger.log("clientSocketV2::socket on connect",t),i.core.reporterHookLinkKeep.start(),i.core.reporterHookLinkKeep.update({code:0,description:"connection begin",operation_type:0,target:t}),u=!0,m()})),i.socket.on("message",bind$1(v=i.onMessage).call(v,i)),i.socket.on("disconnect",(function(m){return __awaiter(i,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:return u=!0,this.logger.log("clientSocketV2::socket on disconnect "+t,m),i.next=4,this.core.reporterHookLinkKeep.update({code:(null==m?void 0:m.code)||0,description:(null==m?void 0:m.reason)||"socket on disconnect",operation_type:1,target:t});case 4:this.core.reporterHookLinkKeep.end(!1),this.doDisconnect(Wp.OFFLINE,"SocketOnDisconnect");case 6:case"end":return i.stop()}}),_callee2,this)})))})),i.socket.on("connectFailed",(function(m){u?i.ping():(i.logger.error("clientSocketV2::connectFailed:"+t+", reason:"+(m&&m.message)),i.cleanSocket()),u=!0,h(m)}))}))},t.cleanSocket=function cleanSocket(){this.socket&&("function"==typeof this.socket.removeAllListeners&&this.socket.removeAllListeners(),"function"==typeof this.socket.close&&this.socket.close(),this.socket=void 0)},t.resetSocketConfig=function resetSocketConfig(){this.backoff.reset(),this.initOnlineListener()},t.doDisconnect=function doDisconnect(t,i){if(this.logger.log("clientSocketV2::doDisconnect:type:"+t+",reason:",i),0!==this.core.auth.getConnectStatus()){var u={1:"close",2:"kicked",3:"broken"}[t]||"";this.markAllCmdInvaild(new Yl({code:zl.V2NIM_ERROR_CODE_DISCONNECT,detail:{reason:"Packet timeout due to instance disconnect",disconnect_reason:u}})),this.timerManager.destroy(),clearTimeout(this.pingTimer),this.cleanSocket(),t===Wp.ACTIVE||t===Wp.KICKED?this.destroyOnlineListener():t===Wp.OFFLINE&&(this.auth.lifeCycle.processEvent("connectionBroken",new Yl({code:zl.V2NIM_ERROR_CODE_DISCONNECT,detail:{reason:"connection broken due to internal reasons"}})),this.logger.log("clientSocketV2::doDisconnect: pending reconnect "+this.isReconnect),this.isReconnect&&this.auth.lifeCycle.processEvent("waiting"))}else this.logger.warn("clientSocketV2::doDisconnect:already disconnected")},t.sendCmd=function sendCmd(t,i,u){var m=this,h=this.core.auth.getLoginStatus(),v=["v2Login","login","chatroomLogin","v2ChatroomLogin"],M={cmd:t};if(1!==h&&!includes(v).call(v,t))return this.logger.warn("clientSocketV2::NIM login status is "+h+", so can not sendCmd "+t),zi.reject(new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE,detail:Dt({reason:"Can not sendCmd due to no logined"},M)}));var I="heartbeat"!==t,S=I?this.packetSer++:0,T=createCmd(t,S,this.logger,i);if(!T){var C=new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:Dt(Dt({},M),{reason:"SendCmd::createCmd error: "+S+" "+t})});return this.logger.error(C),zi.reject(C)}var E=T.packet,A=T.hasPacketResponse,k=T.hasPacketTimer,R=Un(E);I&&(this.logger.getDebugMode()?this.logger.debug("clientSocketV2::sendCmd: "+E.SID+"_"+E.CID+","+t+",ser:"+S,R):this.logger.log("clientSocketV2::sendCmd: "+E.SID+"_"+E.CID+","+t+",ser:"+S));var w=(new Date).getTime();return new zi((function(h,v){A&&m.sendingCmdMap.set(S,{cmd:t,params:i,callback:[h,v],timer:k?mo((function(){var i=new Yl({code:zl.V2NIM_ERROR_CODE_PROTOCOL_TIMEOUT,detail:Dt({ser:S,reason:"Packet Timeout: ser "+S+" cmd "+t,timetag:(new Date).getTime()},M)});m.markCmdInvalid(S,i,t)}),u&&u.timeout?u.timeout:m.packetTimeout):null});try{m.socket.send(E.SID,E.CID,S,t,E.Q),A||h(E)}catch(i){var I=new Yl({code:zl.V2NIM_ERROR_CODE_PROTOCOL_SEND_FAILED,detail:Dt({ser:S,reason:"Unable to send packet"+(i&&i.message?": "+i.message:""),timetag:(new Date).getTime(),rawError:i},M)});m.markCmdInvalid(S,I,t),v(I)}})).catch((function(t){return __awaiter(m,void 0,void 0,ud.mark((function _callee3(){var i,u;return ud.wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:if(i=t,u=[zl.V2NIM_ERROR_CODE_DISCONNECT,zl.V2NIM_ERROR_CODE_PROTOCOL_TIMEOUT,zl.V2NIM_ERROR_CODE_PROTOCOL_SEND_FAILED],includes(u).call(u,i.code)){m.next=4;break}return m.abrupt("return",zi.reject(i));case 4:return this.reportSendCmdFailed(i,{sid:E.SID,cid:E.CID,ser:S},w),m.abrupt("return",zi.reject(i));case 6:case"end":return m.stop()}}),_callee3,this)})))}))},t.reportSendCmdFailed=function reportSendCmdFailed(t,i,u){var m;this.reporter.reportTraceStart("exceptions",{user_id:this.core.auth.getLoginUser(),trace_id:null===(m=this.socket)||void 0===m?void 0:m.sessionId,start_time:u,action:2,exception_service:6});var h=get(t,"detail.disconnect_reason")||"",v=t.code===zl.V2NIM_ERROR_CODE_DISCONNECT?Un({disconnect_reason:h}):t.detail.reason;this.reporter.reportTraceUpdateV2("exceptions",{code:t.code,description:v,operation_type:1,target:i.sid+"-"+i.cid,context:""+i.ser},{asyncParams:pd.net.getNetworkStatus()}),this.reporter.reportTraceEnd("exceptions",1)},t.onMessage=function onMessage(t){var i=parseCmd(t,this.logger);if(i&&i.length>0){var u=i[0],m=u.raw.ser;u.error&&(this.logger.error("clientSocketV2::onMessage packet error",u.raw.sid+"_"+u.raw.cid+", ser:"+m+",",u.error),u.error.code===zl.V2NIM_ERROR_CODE_UNPACK_ERROR&&this.core.eventBus.emit("BinaryClientSocket/unpackError")),"heartbeat"!==u.cmd&&(this.logger.getDebugMode()?this.logger.debug("clientSocketV2::recvCmd "+u.raw.sid+"_"+u.raw.cid+","+u.cmd+",ser:"+m,t):this.logger.log("clientSocketV2::recvCmd "+u.raw.sid+"_"+u.raw.cid+","+u.cmd+",ser:"+m+",code:"+u.raw.code));for(var h,v=_createForOfIteratorHelperLoose$a(i);!(h=v()).done;){var M=h.value;this.packetHandler(M)}}},t.packetHandler=function packetHandler(t){var i,u,m,h,v=this;if(t){var M=t.raw.ser,I=this.sendingCmdMap.get(M);if(I&&I.cmd===t.cmd){var S=I.callback,T=I.timer,C=I.params;if(clearTimeout(T),t.params=C,this.sendingCmdMap.delete(M),"heartbeat"===t.cmd)return void S[0]();var E=null===(u=null===(i=this.core[t.service])||void 0===i?void 0:i.process)||void 0===u?void 0:u.call(i,t);E&&"function"==typeof E.then?E.then((function(t){S[0](t)})).catch((function(t){S[1](t)})):(this.logger.log("clientSocketV2::handlerFn without promise",t.service,t.cmd),S[0](t))}else{var A=null===(h=null===(m=this.core[t.service])||void 0===m?void 0:m.process)||void 0===h?void 0:h.call(m,t);A&&"function"==typeof A.then&&A.catch((function(t){v.logger.error("clientSocketV2::no obj cache, no process handler",t)}))}}},t.markCmdInvalid=function markCmdInvalid(t,i,u){var m=this.sendingCmdMap.get(t);if(m){var h=m.callback,v=m.timer;v&&clearTimeout(v),this.sendingCmdMap.delete(t),this.logger.warn("clientSocketV2::packet "+t+", "+u+" is invalid:",i),h[1](i)}},t.markAllCmdInvaild=function markAllCmdInvaild(t){var i,u=this;this.logger.log("markAllCmdInvaild",t),forEach$1(i=this.sendingCmdMap).call(i,(function(i){var m=i.callback,h=i.timer,v=i.cmd;u.logger.log("clientSocketV2::markAllCmdInvaild:cmd "+v),h&&clearTimeout(h),m[1](t)})),this.sendingCmdMap.clear()},t.ping=function ping(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i=this;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return clearTimeout(this.pingTimer),u.prev=1,u.next=4,this.sendCmd("heartbeat");case 4:u.next=20;break;case 6:if(u.prev=6,u.t0=u.catch(1),u.t0.code!==zl.V2NIM_ERROR_CODE_DISCONNECT){u.next=11;break}return u.abrupt("return");case 11:return u.next=13,this.testHeartBeat5Timeout();case 13:if(!u.sent){u.next=20;break}return u.next=17,this.core.reporterHookLinkKeep.update({code:0,description:"Heartbeat-discovered link failure",operation_type:1,target:null===(t=this.socket)||void 0===t?void 0:t.url});case 17:return this.core.reporterHookLinkKeep.end(!0),this.doDisconnect(Wp.OFFLINE,"PingError"),u.abrupt("return");case 20:this.pingTimer=mo((function(){i.ping()}),3e4);case 21:case"end":return u.stop()}}),_callee4,this,[[1,6]])})))},t.testHeartBeat5Timeout=function testHeartBeat5Timeout(){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var t;return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:clearTimeout(this.pingTimer),t=0;case 2:if(!(t<5)){i.next=15;break}return i.prev=3,i.next=6,this.sendCmd("heartbeat",{},{timeout:3e3});case 6:return i.abrupt("return",!1);case 9:i.prev=9,i.t0=i.catch(3),this.logger.log("clientSocketV2::test heartbeat "+t+" Timeout");case 12:t++,i.next=2;break;case 15:return i.abrupt("return",!0);case 16:case"end":return i.stop()}}),_callee5,this,[[3,9]])})))},t.initOnlineListener=function initOnlineListener(){var t=this;this.hasNetworkListener||(this.logger.log("clientSocketV2::onlineListener:init"),this.hasNetworkListener=!0,pd.net.onNetworkStatusChange((function(i){t.logger.log("clientSocketV2::onlineListener:network change",i);var u=t.auth.getLoginStatus();i.isConnected&&1===u?t.ping():i.isConnected&&3===u?(t.logger.log("clientSocketV2::onlineListener:online and connectStatus is waiting, do reLogin"),t.auth.reconnect.clearReconnectTimer(),t.auth.reconnect.doReLogin()):i.isConnected||t.doDisconnect(Wp.OFFLINE,"OfflineListener")})))},t.destroyOnlineListener=function destroyOnlineListener(){this.logger.log("clientSocketV2::onlineListener:destroy"),pd.net.offNetworkStatusChange(),this.hasNetworkListener=!1},V2BinaryClientSocket}();function _createForOfIteratorHelperLoose$9(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$9(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$9(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$9(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$9(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}!function(t){t[t.ACTIVE=1]="ACTIVE",t[t.KICKED=2]="KICKED",t[t.OFFLINE=3]="OFFLINE"}(Qp||(Qp={}));var Xp=function(){function V2ClientSocket(t){this.isReconnect=!1,this.packetTimeout=8e3,this.linkSSL=!0,this.packetSer=1,this.backoff=new op({max:8e3,min:1600,jitter:.01}),this.sendingCmdMap=new Sc,this.pingTimer=0,this.hasNetworkListener=!1,this.core=t,this.auth=t.auth,this.logger=t.logger,this.reporter=t.reporter,this.timerManager=t.timerManager,this.eventBus=t.eventBus,this.setListener()}var t=V2ClientSocket.prototype;return t.setListener=function setListener(){var t=this;this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",(function(){t.isReconnect=!0}))},t.setSessionId=function setSessionId(t){this.socket&&(this.socket.sessionId=t)},t.setLinkSSL=function setLinkSSL(t){this.linkSSL=t},t.connect=function connect(t,i){var u,m;return void 0===i&&(i=!1),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var h,v,M,I;return ud.wrap((function _callee$(S){for(;;)switch(S.prev=S.next){case 0:if(this.isReconnect=i,1!==(h=this.core.auth.getConnectStatus())){S.next=7;break}return v="clientSocket::connect status is "+h+", and would not repeat connect",M=new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE,detail:{reason:v}}),this.logger.warn(v),S.abrupt("return",zi.reject(M));case 7:return this.auth.lifeCycle.processEvent("connect"),S.prev=8,S.next=11,this.auth.doLoginStepsManager.add(this.doConnect(t));case 11:this.logger.log("clientSocketV2:: connect success with link url: "+t+", isReconnect: "+i),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"TCP",target:t,code:200,mixlink:!0,succeed:!0},{asyncParams:pd.net.getNetworkStatus()}),this.auth.lifeCycle.processEvent("connectSucc"),S.next=28;break;case 16:if(S.prev=16,S.t0=S.catch(8),I=S.t0,this.core.reporter.reportTraceUpdateV2("login",{operation_type:"TCP",target:t,code:I.code||0,description:"connectFailed:"+I.message,mixlink:!0,succeed:!1},{asyncParams:pd.net.getNetworkStatus()}),I.code!==zl.V2NIM_ERROR_CODE_CANCELLED&&I.code!==zl.V2NIM_ERROR_CODE_TIMEOUT){S.next=25;break}throw null===(u=this.socket)||void 0===u||u.close(),null===(m=this.socket)||void 0===m||m.removeAllListeners(),this.socket=void 0,S.t0;case 25:throw this.logger.warn("clientSocketV2::connect failed with link url: "+t,I),this.auth.lifeCycle.processEvent("connectFail",I),S.t0;case 28:case"end":return S.stop()}}),_callee,this,[[8,16]])})))},t.doConnect=function doConnect(t){var i=this,u=!1;return new zi((function(m,h){var v;i.socket=new dp(i.core,t,i.linkSSL),i.socket.on("connect",(function(){i.logger.log("clientSocketV2::socket on connect",t),i.core.reporterHookLinkKeep.start(),i.core.reporterHookLinkKeep.update({code:0,description:"connection begin",operation_type:0,target:t}),u=!0,m()})),i.socket.on("message",bind$1(v=i.onMessage).call(v,i)),i.socket.on("disconnect",(function(m){return __awaiter(i,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:return u=!0,this.logger.log("clientSocketV2::socket on disconnect",m),i.next=4,this.core.reporterHookLinkKeep.update({code:(null==m?void 0:m.code)||0,description:(null==m?void 0:m.reason)||"socket on disconnect",operation_type:1,target:t});case 4:this.core.reporterHookLinkKeep.end(!1),this.doDisconnect(Qp.OFFLINE,"SocketOnDisconnect");case 6:case"end":return i.stop()}}),_callee2,this)})))})),i.socket.on("handshakeFailed",(function(t){u?i.ping():(i.logger.error('clientSocketV2::handshake failed: "'+(t&&t.message)+'"'),i.cleanSocket()),u=!0,h(t)}))}))},t.cleanSocket=function cleanSocket(){this.socket&&("function"==typeof this.socket.removeAllListeners&&this.socket.removeAllListeners(),"function"==typeof this.socket.close&&this.socket.close(),this.socket=void 0)},t.resetSocketConfig=function resetSocketConfig(){this.backoff.reset(),this.initOnlineListener()},t.doDisconnect=function doDisconnect(t,i){if(this.logger.log("clientSocketV2::doDisconnect:type:"+t+",reason:",i),0!==this.core.auth.getConnectStatus()){var u={1:"close",2:"kicked",3:"broken"}[t]||"";this.markAllCmdInvaild(new Yl({code:zl.V2NIM_ERROR_CODE_DISCONNECT,detail:{reason:"Packet timeout due to instance disconnect",disconnect_reason:u}})),this.timerManager.destroy(),clearTimeout(this.pingTimer),this.cleanSocket(),t===Qp.ACTIVE||t===Qp.KICKED?this.destroyOnlineListener():t===Qp.OFFLINE&&(this.auth.lifeCycle.processEvent("connectionBroken",new Yl({code:zl.V2NIM_ERROR_CODE_DISCONNECT,detail:{reason:"connection broken due to internal reasons"}})),this.logger.log("clientSocketV2::doDisconnect: pending reconnect "+this.isReconnect),this.isReconnect&&this.auth.lifeCycle.processEvent("waiting"))}else this.logger.warn("clientSocketV2::doDisconnect:already disconnected")},t.sendCmd=function sendCmd(t,i,u){var m=this,h=this.core.auth.getLoginStatus(),v=["v2Login","login","chatroomLogin","v2ChatroomLogin"],M={cmd:t};if(1!==h&&!includes(v).call(v,t))return this.logger.warn("clientSocketV2::NIM login status is "+h+", so can not sendCmd "+t),zi.reject(new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE,detail:Dt({reason:"Can not sendCmd due to no logined"},M)}));var I="heartbeat"!==t,S=I?this.packetSer++:0,T=createCmd(t,S,this.logger,i);if(!T){var C=new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:Dt(Dt({},M),{reason:"SendCmd::createCmd error: "+S+" "+t})});return this.logger.error(C),zi.reject(C)}var E=T.packet,A=T.hasPacketResponse,k=T.hasPacketTimer,R=Un(E);I&&(this.logger.getDebugMode()?this.logger.debug("clientSocketV2::sendCmd: "+E.SID+"_"+E.CID+","+t+",ser:"+S,R):this.logger.log("clientSocketV2::sendCmd: "+E.SID+"_"+E.CID+","+t+",ser:"+S));var w=(new Date).getTime();return new zi((function(h,v){A&&m.sendingCmdMap.set(S,{cmd:t,params:i,callback:[h,v],timer:k?mo((function(){var i=new Yl({code:zl.V2NIM_ERROR_CODE_PROTOCOL_TIMEOUT,detail:Dt({ser:S,reason:"Packet Timeout: ser "+S+" cmd "+t,timetag:(new Date).getTime()},M)});m.markCmdInvalid(S,i,t)}),u&&u.timeout?u.timeout:m.packetTimeout):null});try{m.socket.send(R),A||h(E)}catch(i){var I=new Yl({code:zl.V2NIM_ERROR_CODE_PROTOCOL_SEND_FAILED,detail:Dt({ser:S,reason:"Unable to send packet"+(i&&i.message?": "+i.message:""),timetag:(new Date).getTime(),rawError:i},M)});m.markCmdInvalid(S,I,t),v(I)}})).catch((function(t){return __awaiter(m,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h,v;return ud.wrap((function _callee3$(M){for(;;)switch(M.prev=M.next){case 0:if(u=t,m=[zl.V2NIM_ERROR_CODE_DISCONNECT,zl.V2NIM_ERROR_CODE_PROTOCOL_TIMEOUT,zl.V2NIM_ERROR_CODE_PROTOCOL_SEND_FAILED],includes(m).call(m,u.code)){M.next=4;break}return M.abrupt("return",zi.reject(u));case 4:return this.reporter.reportTraceStart("exceptions",{user_id:this.core.auth.getLoginUser(),trace_id:null===(i=this.socket)||void 0===i?void 0:i.sessionId,start_time:w,action:2,exception_service:6}),h=get(u,"detail.disconnect_reason")||"",v=u.code===zl.V2NIM_ERROR_CODE_DISCONNECT?Un({disconnect_reason:h}):u.detail.reason,this.reporter.reportTraceUpdateV2("exceptions",{code:u.code,description:v,operation_type:1,target:E.SID+"-"+E.CID,context:""+E.SER},{asyncParams:pd.net.getNetworkStatus()}),this.reporter.reportTraceEnd("exceptions",1),M.abrupt("return",zi.reject(u));case 10:case"end":return M.stop()}}),_callee3,this)})))}))},t.onMessage=function onMessage(t){var i=parseCmd(t,this.logger);if(i&&i.length>0){var u=i[0],m=u.raw.ser;u.error&&this.logger.error("clientSocketV2::onMessage packet error",u.raw.sid+"_"+u.raw.cid+", ser:"+m+",",u.error),"heartbeat"!==u.cmd&&(this.logger.getDebugMode()?this.logger.debug("clientSocketV2::recvCmd "+u.raw.sid+"_"+u.raw.cid+","+u.cmd+",ser:"+m,u.content):this.logger.log("clientSocketV2::recvCmd "+u.raw.sid+"_"+u.raw.cid+","+u.cmd+",ser:"+m+";code:"+u.raw.code));for(var h,v=_createForOfIteratorHelperLoose$9(i);!(h=v()).done;){var M=h.value;this.packetHandler(M)}}},t.packetHandler=function packetHandler(t){var i,u,m,h,v=this;if(t){var M=t.raw.ser,I=this.sendingCmdMap.get(M);if(I&&I.cmd===t.cmd){var S=I.callback,T=I.timer,C=I.params;if(clearTimeout(T),t.params=C,this.sendingCmdMap.delete(M),"heartbeat"===t.cmd)return void S[0]();var E=null===(u=null===(i=this.core[t.service])||void 0===i?void 0:i.process)||void 0===u?void 0:u.call(i,t);E&&"function"==typeof E.then?E.then((function(t){S[0](t)})).catch((function(t){S[1](t)})):(this.logger.log("clientSocketV2::handlerFn without promise",t.service,t.cmd),S[0](t))}else{var A=null===(h=null===(m=this.core[t.service])||void 0===m?void 0:m.process)||void 0===h?void 0:h.call(m,t);A&&"function"==typeof A.then&&A.catch((function(t){v.logger.error("clientSocketV2::no obj cache, no process handler",t)}))}}},t.markCmdInvalid=function markCmdInvalid(t,i,u){var m=this.sendingCmdMap.get(t);if(m){var h=m.callback,v=m.timer;v&&clearTimeout(v),this.sendingCmdMap.delete(t),this.logger.warn("clientSocketV2::packet "+t+", "+u+" is invalid:",i),h[1](i)}},t.markAllCmdInvaild=function markAllCmdInvaild(t){var i,u=this;this.logger.log("markAllCmdInvaild",t),forEach$1(i=this.sendingCmdMap).call(i,(function(i){var m=i.callback,h=i.timer,v=i.cmd;u.logger.log("clientSocketV2::markAllCmdInvaild:cmd "+v),h&&clearTimeout(h),m[1](t)})),this.sendingCmdMap.clear()},t.ping=function ping(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i=this;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return clearTimeout(this.pingTimer),u.prev=1,u.next=4,this.sendCmd("heartbeat");case 4:u.next=20;break;case 6:if(u.prev=6,u.t0=u.catch(1),u.t0.code!==zl.V2NIM_ERROR_CODE_DISCONNECT){u.next=11;break}return u.abrupt("return");case 11:return u.next=13,this.testHeartBeat5Timeout();case 13:if(!u.sent){u.next=20;break}return u.next=17,this.core.reporterHookLinkKeep.update({code:0,description:"Heartbeat-discovered link failure",operation_type:1,target:null===(t=this.socket)||void 0===t?void 0:t.url});case 17:return this.core.reporterHookLinkKeep.end(!0),this.doDisconnect(Qp.OFFLINE,"PingError"),u.abrupt("return");case 20:this.pingTimer=mo((function(){i.ping()}),3e4);case 21:case"end":return u.stop()}}),_callee4,this,[[1,6]])})))},t.testHeartBeat5Timeout=function testHeartBeat5Timeout(){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var t;return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:clearTimeout(this.pingTimer),t=0;case 2:if(!(t<5)){i.next=15;break}return i.prev=3,i.next=6,this.sendCmd("heartbeat",{},{timeout:3e3});case 6:return i.abrupt("return",!1);case 9:i.prev=9,i.t0=i.catch(3),this.logger.log("clientSocketV2::test heartbeat "+t+" Timeout");case 12:t++,i.next=2;break;case 15:return i.abrupt("return",!0);case 16:case"end":return i.stop()}}),_callee5,this,[[3,9]])})))},t.initOnlineListener=function initOnlineListener(){var t=this;this.hasNetworkListener||(this.logger.log("clientSocketV2::onlineListener:init"),this.hasNetworkListener=!0,pd.net.onNetworkStatusChange((function(i){t.logger.log("clientSocketV2::onlineListener:network change",i);var u=t.auth.getConnectStatus(),m=t.auth.getLoginStatus();i.isConnected&&1===m?t.ping():i.isConnected&&3===u?(t.logger.log("clientSocketV2::onlineListener:online and connectStatus is waiting, do reLogin"),t.auth.reconnect.clearReconnectTimer(),t.auth.reconnect.doReLogin()):i.isConnected||t.doDisconnect(Qp.OFFLINE,"OfflineListener")})))},t.destroyOnlineListener=function destroyOnlineListener(){this.logger.log("clientSocketV2::onlineListener:destroy"),pd.net.offNetworkStatusChange(),this.hasNetworkListener=!1},V2ClientSocket}(),Zp=function(){function V2NIMLoginReconnect(t){var i,u,m=this;this.currenRetryCount=0,this.backoff=new op({max:8e3,min:1600,jitter:.01}),this.reconnectTimer=0,this.core=t,this.auth=t.V2NIMLoginService,null===(u=(i=pd.powerMonitor).on)||void 0===u||u.call(i,"onPowerMonitorTurnActive",(function(){m.core.logger.debug("reconnect::powerMonitor turn active"),3===m.auth.getLoginStatus()&&(m.core.logger.log("reconnect::powerMonitor turn active, try to reconnect"),m.auth.reconnect.clearReconnectTimer(),m.auth.reconnect.doReLogin())}))}var t=V2NIMLoginReconnect.prototype;return t.reset=function reset(){this.currenRetryCount=0,this.backoff.reset(),this.reconnectTimer&&clearTimeout(this.reconnectTimer)},t.destroy=function destroy(){var t,i;this.currenRetryCount=0,this.backoff.reset(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),pd.powerMonitor.destroy(),null===(i=(t=pd.powerMonitor).off)||void 0===i||i.call(t,"onPowerMonitorTurnActive")},t.clearReconnectTimer=function clearReconnectTimer(){this.reconnectTimer&&clearTimeout(this.reconnectTimer)},t.attempToReLogin=function attempToReLogin(){var t=this,i=this.backoff.duration();if("function"==typeof this.reconnectDelayProvider)try{var u=this.reconnectDelayProvider(i);"number"==typeof u&&u>=0&&(i=u>=1e3?u:u+200+Math.ceil(300*Math.random()))}catch(t){this.core.logger.error("reconnect::connectDelayProvider excute failed,",t)}return this.currenRetryCount++,this.core.logger.log("reconnect::reconnect timer is about to be set, delay "+i+" ms, current retry count is "+this.currenRetryCount),this.core.reporter.reportTraceStart("login",{user_id:this.auth.getLoginUser(),action:"auto_login",binary_websocket:this.auth.binaryWebsocket}),this.clearReconnectTimer(),this.reconnectTimer=mo((function(){t.core.logger.log("reconnect::reconnect timer is now triggered");var i=t.auth.getConnectStatus();3===i?t.doReLogin():t.core.logger.warn("reconnect::reconnect timer is over because connect status now is "+i)}),i),!0},t.doReLogin=function doReLogin(){var t=this;if(!pd.powerMonitor.isActive())return this.core.logger.log("reconnect::reLogin skip, cause app powerMonitor is not active"),void this.auth.lifeCycle.processEvent("waiting");this.auth.loginOption.forceMode=!1,this.auth.originLoginPromise=this.auth.doLogin(!0);var i=this.auth.previousLoginManager.add(this.auth.originLoginPromise);return i.then((function(){t.core.reporter.reportTraceEnd("login",!0)})).catch((function(i){var u=i;if(t.core.logger.warn("reconnect::try login but failed due to",u),t.core.reporter.reportTraceEnd("login",!1),t.auth.checkLoginTerminalCode(u&&u.code))return t.auth.clientSocket.doDisconnect(Wp.ACTIVE,"ReloginTerminated"),void t.auth.lifeCycle.processEvent("exited",u);u&&399===u.code&&t.auth.lbs.reset(),t.auth.lifeCycle.processEvent("waiting")})),i},t._setReconnectDelayProvider=function _setReconnectDelayProvider(t){this.reconnectDelayProvider=t},V2NIMLoginReconnect}(),em=function(){function V2NIMLoginLbs(t){this.socketLinkUrls=[],this.timer=0,this.failedCount=0,this.core=t,this.auth=t.V2NIMLoginService}var t=V2NIMLoginLbs.prototype;return t.getLbsInfos=function getLbsInfos(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t,i,u,m;return ud.wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:if(!(this.socketLinkUrls.length>0)){h.next=4;break}return t=this.socketLinkUrls.shift(),this.core.logger.log("V2NIMLoginService::getLbsInfos:use cache link",t),h.abrupt("return",zi.resolve(t));case 4:return this.auth.lifeCycle.processEvent("addressing"),this.core.reporterHookLBS.start(this.core.account),i=uniq(this.auth.config.lbsUrls),h.prev=7,h.next=10,this.ladderLoad(i);case 10:if(200===(u=h.sent).status&&u.data){h.next=14;break}throw this.core.logger.error("V1NIMLoginService::getLbsInfos:error status",u.status,u),new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"V2NIMLoginService::getLbsInfos failed, status "+u.status}});case 14:this.success(u),h.next=25;break;case 17:if(h.prev=17,h.t0=h.catch(7),m=h.t0,this.core.logger.error("V2NIMLoginService::lbs getLbsInfos error, use default link: "+this.auth.config.linkUrl+". error:",h.t0),this.reportForFail(i[0],m.code,m.message),!this.checkTerminator(m.code)){h.next=24;break}throw h.t0;case 24:this.socketLinkUrls=[this.auth.config.linkUrl];case 25:return h.abrupt("return",this.socketLinkUrls.shift());case 26:case"end":return h.stop()}}),_callee,this,[[7,17]])})))},t.checkTerminator=function checkTerminator(t){return t===zl.V2NIM_ERROR_CODE_CANCELLED||t===zl.V2NIM_ERROR_CODE_TIMEOUT},t.generateUrl=function generateUrl(t){return(t=this.processLbsUrl(t))+(indexOf(t).call(t,"?")>-1?"&":"?")+"k="+this.core.options.appkey+"&id="+this.core.auth.getLoginUser()+"&sv=180&pv=1&networkType=0&lv=1"},t.processLbsUrl=function processLbsUrl(t){return pendingIsMiniappEnv()?t.replace("/webconf","/wxwebconf"):t},t.requstLbs=function requstLbs(t){return this.auth.doLoginStepsManager.add(this.core.adapters.request(this.generateUrl(t),{method:"GET",dataType:"json",timeout:8e3}))},t.setLadderTimer=function setLadderTimer(t,i,u,m){var h=this;this.timer&&clearTimeout(this.timer);var v=t[i];this.timer=mo((function(){v&&(h.setLadderTimer(t,i+1,u,m),h.core.logger.log("V2NIMLoginService::getLbsInfos "+i+":",h.processLbsUrl(v)),h.reportForLbsStart(v,i),h.requstLbs(v).then((function(t){h.reset(),u(Dt(Dt({},t),{url:v}))})).catch((function(u){var M;if(h.core.logger.warn("V2NIMLoginService::getLbsInfos "+i+" failed:",u),h.failedCount+=1,h.reportForFailOnce(v,u.code,(null===(M=u.detail)||void 0===M?void 0:M.reason)||u.message),h.failedCount>=t.length||h.checkTerminator(u.code))return h.reset(),void m(u)})))}),2e3)},t.ladderLoad=function ladderLoad(t){var i=this;return new zi((function(u,m){t.length>1&&i.setLadderTimer(t,1,u,m);var h=t[0];i.core.logger.log("V2NIMLoginService::getLbsInfos 0:",h),i.reportForLbsStart(h,0),i.requstLbs(h).then((function(t){i.reset(),u(Dt(Dt({},t),{url:h}))})).catch((function(u){var v;i.failedCount+=1,i.core.logger.warn("V2NIMLoginService::getLbsInfos 0 failed:",u),i.reportForFailOnce(h,u.code,(null===(v=u.detail)||void 0===v?void 0:v.reason)||u.message),(i.failedCount>=t.length||i.checkTerminator(u.code))&&(i.reset(),m(u))}))}))},t.success=function success(t){var i,u,m,h,v=t.data.common,M=v["mix.link"]||[],I=v["link.default"]||[];this.socketLinkUrls=concat(i=concat(M).call(M,I)).call(i,this.auth.config.linkUrl),t.data["nos-chunk"]&&(null===(m=this.core.cloudStorage)||void 0===m?void 0:m.setOptions)&&(this.core.logger.log("getLbsInfos success. lbs.nos-chunk",t.data["nos-chunk"]),this.core.cloudStorage.setOptions({chunkUploadHost:t.data["nos-chunk"]})),Dn(t.data.nosup)&&t.data.nosup.length>0&&(null===(h=this.core.cloudStorage)||void 0===h?void 0:h.setOptions)&&(this.core.logger.log("getLbsInfos success. lbs.nosup",t.data.nosup),this.core.cloudStorage.setOptions({commonUploadHostBackupList:t.data.nosup,commonUploadHost:t.data.nosup[0]})),this.core.logger.log("V2NIMLoginService::getLbsInfos success, socket link:",slice(u=this.socketLinkUrls).call(u,0),"chunkUploadHost: ",t.data["nos-chunk"]),this.reportForLbsSuccess(t.url,t.data)},t.reportForLbsStart=function reportForLbsStart(t,i){this.core.reporterHookLBS.updateBegin({target:t,index:i})},t.reportForLbsSuccess=function reportForLbsSuccess(t,i){this.core.reporterHookLBS.updateComplete({target:t,code:200,body:Un(i)}),this.core.reporterHookLBS.end(!0),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"HTTP",target:t,code:200,succeed:!0},{asyncParams:pd.net.getNetworkStatus()})},t.reportForFailOnce=function reportForFailOnce(t,i,u){this.core.reporterHookLBS.updateComplete({target:t,code:i,body:u})},t.reportForFail=function reportForFail(t,i,u){this.core.reporterHookLBS.end(!1),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"HTTP",target:t,description:u,code:i,succeed:!1},{asyncParams:pd.net.getNetworkStatus()})},t.reset=function reset(){this.socketLinkUrls=[],this.failedCount=0,clearTimeout(this.timer)},V2NIMLoginLbs}();var tm=function(){function V2NIMLoginAuthenticator(t){this.lastLoginClientKey="__NIM_LAST_LOGIN_CLIENT__",this.loginClients=[],this.loginClientOfThisConnection={},this.core=t,this.auth=t.V2NIMLoginService}var t=V2NIMLoginAuthenticator.prototype;return t.verifyAuthentication=function verifyAuthentication(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var m,h,v,M,I,S,T,C,E,A,k,R;return ud.wrap((function _callee$(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this.auth.doLoginStepsManager.add(this.refreshLoginToken(this.auth.account));case 2:return h=w.sent,w.next=5,this.auth.doLoginStepsManager.add(this.refreshThirdPartyExt(this.auth.account));case 5:return v=w.sent,this.auth.token=h,M=pd.getSystemInfo(),I={appkey:this.core.options.appkey,account:this.auth.account,token:h,authType:this.auth.loginOption.authType,appLogin:t?0:1,clientType:16,clientSession:this.auth.clientSession,clientId:this.auth.deviceId,sdkVersion:100971,userAgent:this.core.options.loginSDKTypeParamCompat?"Native/10.9.71":slice(m=M.userAgent.replace("{{appkey}}",this.core.options.appkey)).call(m,0,299),libEnv:this.core.options.flutterSdkVersion?"FLUTTER":this.core.options.loginSDKTypeParamCompat?void 0:M.libEnv,hostEnv:this.core.options.flutterSdkVersion?4:this.core.options.loginSDKTypeParamCompat?0:M.hostEnvEnum,sdkHumanVersion:this.core.options.flutterSdkVersion||"10.9.71",os:M.os,browser:M.browser,protocolVersion:1,customClientType:this.auth.config.customClientType,customTag:this.auth.config.customTag,thirdPartyExtension:v,isRoutable:!1===(null===(i=this.auth.loginOption.routeConfig)||void 0===i?void 0:i.routeEnabled)?0:1,env:null===(u=this.auth.loginOption.routeConfig)||void 0===u?void 0:u.routeEnvironment},S=M.os.toLowerCase(),T=110===M.hostEnvEnum,"UNIAPP"===pd.platform&&T?(I.isReactNative=1,I.clientType="ios"===S?2:"android"===S?1:65,M.pushDeviceInfo&&M.pushDeviceInfo.MANUFACTURER&&(I.deviceInfo=Un(Dt({IS_SUPPORT_HONOR:!0},M.pushDeviceInfo)))):"React Native"===pd.platform&&(this.core.logger.log("V2NIMLoginService deviceInfo",this.core.V2NIMLoginService.deviceInfo,"os",S),I.isReactNative=1,I.clientType="ios"===S?2:1,I.deviceInfo=Un(Dt({IS_SUPPORT_HONOR:!0},this.core.V2NIMLoginService.deviceInfo))),this.core.logger.log("V2NIMLoginService::do login,accid:"+I.account+";clientSession:"+I.clientSession+";appLogin:"+I.appLogin),w.prev=13,w.next=16,this.auth.doLoginStepsManager.add(this.auth.clientSocket.sendCmd("v2Login",{tag:I}));case 16:C=w.sent,w.next=27;break;case 19:if(w.prev=19,w.t0=w.catch(13),E=w.t0,this.core.reporter.reportTraceUpdateV2("login",{operation_type:"protocol",target:"26-3",code:E.code||0,succeed:!1,description:E.message},{asyncParams:pd.net.getNetworkStatus()}),E.code!==zl.V2NIM_ERROR_CODE_CANCELLED&&E.code!==zl.V2NIM_ERROR_CODE_TIMEOUT){w.next=25;break}throw E;case 25:throw this.processLoginFailed(E),E;case 27:return A=C.content,k=A.data,R=A.loginClients,this.changeLoginClient(1,R),this.core.reporter.reportTraceUpdateV2("login",{operation_type:"protocol",target:"26-3",code:200,succeed:!0},{asyncParams:pd.net.getNetworkStatus()}),this.loginClientOfThisConnection=formatLoginInfo(k),this.core.clientSocket.setSessionId(k.consid),pd.localStorage.setItem(this.lastLoginClientKey,Un(Dt({account:this.auth.account},this.loginClientOfThisConnection))),w.abrupt("return",this.loginClientOfThisConnection);case 34:case"end":return w.stop()}}),_callee,this,[[13,19]])})))},t.refreshLoginToken=function refreshLoginToken(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m;return ud.wrap((function _callee2$(h){for(;;)switch(h.prev=h.next){case 0:if(0!==this.auth.loginOption.authType){h.next=2;break}return h.abrupt("return",this.auth.token);case 2:if("function"==typeof this.auth.loginOption.tokenProvider){h.next=4;break}return h.abrupt("return",this.auth.token);case 4:return h.prev=4,h.next=7,this.auth.loginOption.tokenProvider(t);case 7:if("string"!=typeof(i=h.sent)){h.next=12;break}return h.abrupt("return",i);case 12:throw this.core.logger.error("V2NIMLoginService::excute tokenProvider complete but got Unexpected value:",i),new Yl({code:zl.V2NIM_ERROR_CODE_CALLBACK_FAILED,detail:{reason:"Excute tokenProvider complete but got Unexpected value",rawData:i}});case 14:h.next=23;break;case 16:throw h.prev=16,h.t0=h.catch(4),u=h.t0,m=u,u.code!==zl.V2NIM_ERROR_CODE_CALLBACK_FAILED&&(this.core.logger.error("V2NIMLoginService::excute tokenProvider error:",u),m=new Yl({code:zl.V2NIM_ERROR_CODE_CALLBACK_FAILED,desc:"Excute tokenProvider error",detail:{rawError:h.t0}})),this.processLoginFailed(u),m;case 23:case"end":return h.stop()}}),_callee2,this,[[4,16]])})))},t.refreshThirdPartyExt=function refreshThirdPartyExt(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:if("function"==typeof this.auth.loginOption.loginExtensionProvider){h.next=2;break}return h.abrupt("return","");case 2:return h.prev=2,h.next=5,this.auth.loginOption.loginExtensionProvider(t);case 5:if("string"!=typeof(i=h.sent)){h.next=10;break}return h.abrupt("return",i);case 10:throw this.core.logger.error("V2NIMLoginService::excute loginExtensionProvider complete but got Unexpected value:",i),new Yl({code:zl.V2NIM_ERROR_CODE_CALLBACK_FAILED,detail:{reason:"Excute loginExtensionProvider complete but got Unexpected value",rawData:i}});case 12:h.next=25;break;case 14:if(h.prev=14,h.t0=h.catch(2),u=h.t0,m=u,u.code!==zl.V2NIM_ERROR_CODE_CALLBACK_FAILED&&(this.core.logger.error("V2NIMLoginService::excute loginExtensionProvider error:",u),m=new Yl({code:zl.V2NIM_ERROR_CODE_CALLBACK_FAILED,detail:{reason:"Excute loginExtensionProvider error",rawError:h.t0}})),2!==this.auth.loginOption.authType){h.next=24;break}throw this.processLoginFailed(u),m;case 24:return h.abrupt("return","");case 25:case"end":return h.stop()}}),_callee3,this,[[2,14]])})))},t.processLoginFailed=function processLoginFailed(t){this.auth.clientSocket.doDisconnect(Wp.ACTIVE,t),this.checkLoginTerminalCode(t.code)&&(this.auth.authenticator.reset(),this.auth.authenticator.clearLastLoginClient()),this.auth.lifeCycle.processEvent("loginFail",t)},t.changeLoginClient=function changeLoginClient(t,i){var u=this,m=map$6(i).call(i,(function(t){return formatLoginInfo(t)}));if(1===t)this.loginClients=m,this.auth.emit("onLoginClientChanged",t,this.loginClients);else if(2===t){var h=filter(m).call(m,(function(t){var i,m=filter(i=u.loginClients).call(i,(function(i){return i.clientId===t.clientId}));return u.loginClients.push(t),0===m.length}));h.length>0&&this.auth.emit("onLoginClientChanged",t,h)}else if(3===t){var v=filter(m).call(m,(function(t){var i;return function remove(t,i){i=i||function(){return!0};for(var u=[],m=(t=t||[]).length,h=0,v=0;v<m;v++)i(t[v-h])&&(u.push(splice(t).call(t,v-h,1)[0]),h+=1);return u}(u.loginClients,(function(i){return i.clientId===t.clientId&&i.consid===t.consid})),0===filter(i=u.loginClients).call(i,(function(i){return i.clientId===t.clientId})).length}));v.length>0&&this.auth.emit("onLoginClientChanged",t,v)}},t.checkAutoLogin=function checkAutoLogin(t){if(t)return!1;var i=pd.localStorage.getItem(this.lastLoginClientKey);if(!i)return!1;var u="",m="";try{var h=JSON.parse(i);u=get(h,"clientId"),m=get(h,"account")}catch(t){return!1}return u===this.auth.deviceId&&m===this.auth.account},t.checkLoginTerminalCode=function checkLoginTerminalCode(t){var i=[zl.V2NIM_ERROR_CODE_CANCELLED,zl.V2NIM_ERROR_CODE_TIMEOUT,zl.V2NIM_ERROR_CODE_HANDSHAKE,302,317,zl.V2NIM_ERROR_CODE_FORBIDDEN,zl.V2NIM_ERROR_CODE_NOT_FOUND,zl.V2NIM_ERROR_CODE_PARAMETER_ERROR,zl.V2NIM_ERROR_CODE_MULTI_LOGIN_FORBIDDEN,422,zl.V2NIM_ERROR_CODE_IM_DISABLED,zl.V2NIM_ERROR_CODE_APPKEY_NOT_EXIST,zl.V2NIM_ERROR_CODE_BUNDLEID_CHECK_FAILED,zl.V2NIM_ERROR_CODE_APPKEY_BLOCKED,zl.V2NIM_ERROR_CODE_INVALID_TOKEN,zl.V2NIM_ERROR_CODE_ROBOT_NOT_ALLOWED,zl.V2NIM_ERROR_CODE_ACCOUNT_NOT_EXIST,zl.V2NIM_ERROR_CODE_ACCOUNT_BANNED,zl.V2NIM_ERROR_CODE_USER_PROFILE_NOT_EXIST];return includes(i).call(i,t)},t.reset=function reset(){this.loginClients=[],this.loginClientOfThisConnection={}},t.clearLastLoginClient=function clearLastLoginClient(){pd.localStorage.removeItem(this.lastLoginClientKey)},V2NIMLoginAuthenticator}(),rm=function(){function V2NIMLoginLifeCycle(t){this.name="V2NIMLoginLifeCycle",this.loginStatus=0,this.connectStatus=0,this.core=t,this.auth=t.V2NIMLoginService,this.logger=t.logger}var t=V2NIMLoginLifeCycle.prototype;return t.processEvent=function processEvent(t,i,u){var m=this.getConnectStatus();switch(t){case"addressing":this.logger.log(this.name+"::addressing"),this.setLoginStatus(2),this.setConnectStatus(2);break;case"connect":this.logger.log(this.name+"::connecting"),this.setLoginStatus(2),this.setConnectStatus(2);break;case"connectSucc":this.logger.log(this.name+"::connect success"),this.setLoginStatus(2),this.setConnectStatus(1);break;case"connectFail":this.logger.log(this.name+"::connect fail",i),this.setLoginStatus(3),this.setConnectStatus(0,i);break;case"connectionBroken":this.logger.log(this.name+"::connectionBroken:",i),this.setLoginStatus(3),this.setConnectStatus(0,i),this.core.eventBus.emit("V2NIMLoginService/loginLifeCycleDisconnected",i);break;case"loginSucc":this.logger.log(this.name+"::login success, verify authentication success"),this.setLoginStatus(1),this.core.eventBus.emit("V2NIMLoginService/loginLifeCycleLoginSucc",u);break;case"loginFail":if(this.logger.log(this.name+"::login fail due to verify authentication failed:",i),!i)return;this.setLoginStatus(this.auth.authenticator.checkLoginTerminalCode(i.code)?0:3),this.setConnectStatus(0,i),this.auth.emit("onLoginFailed",i);break;case"logout":this.logger.log(this.name+"::logout"),this.setLoginStatus(0),this.setConnectStatus(0),this.core.eventBus.emit("V2NIMLoginService/loginLifeCycleLogout");break;case"kicked":this.logger.log(this.name+"::kicked",u),this.setLoginStatus(0),this.setConnectStatus(0,i),this.core.eventBus.emit("V2NIMLoginService/loginLifeCycleKicked");break;case"exited":this.logger.log(this.name+"::exited",i),this.setLoginStatus(0),this.setConnectStatus(0,i);break;case"waiting":this.logger.log(this.name+"::waiting to reconnect"),this.setLoginStatus(3),this.setConnectStatus(3),2!==m&&this.auth.reconnect.attempToReLogin()}},t.getConnectStatus=function getConnectStatus(){return this.connectStatus},t.getLoginStatus=function getLoginStatus(){return this.loginStatus},t.setLoginStatus=function setLoginStatus(t){t!==this.loginStatus&&(this.loginStatus=t,this.auth.emit("onLoginStatus",t))},t.setConnectStatus=function setConnectStatus(t,i){if(t!==this.connectStatus){var u=this.connectStatus;this.connectStatus=t,this.auth.emit("onConnectStatus",t),this.delegateConnectEvent(u,t,i)}},t.delegateConnectEvent=function delegateConnectEvent(t,i,u){1===t&&0===i&&u&&this.auth.emit("onDisconnected",u),2===t&&0===i&&u&&this.auth.emit("onConnectFailed",u)},V2NIMLoginLifeCycle}(),nm=function(){function V2NIMLoginDataSync(t){this.core=t,this.auth=t.V2NIMLoginService,this.datas=[]}var t=V2NIMLoginDataSync.prototype;return t.switchDataSync=function switchDataSync(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h,v,M,I,S;return ud.wrap((function _callee$(T){for(;;)switch(T.prev=T.next){case 0:m=t.type,h=t.state,v=t.error,M=t.subType,I=filter(i=this.datas).call(i,(function(t){return t.type===m&&t.subType===M})),I.length>0?(I[0].state=h,I[0].error=v):this.datas.push({type:m,state:h,subType:M}),S=every(u=this.datas).call(u,(function(t){return 3===t.state})),1===m&&(2===h&&"mainSync"===M?(this.core.eventBus.emit("V2NIMLoginService/syncing"),this.auth.emit("onDataSync",m,h)):3===h&&S&&(this.core.eventBus.emit("V2NIMLoginService/syncDone",v),this.auth.emit("onDataSync",m,h,v)));case 5:case"end":return T.stop()}}),_callee,this)})))},t.checkSyncing=function checkSyncing(){var t;return some(t=this.datas).call(t,(function(t){return"mainSync"===t.subType&&2===t.state}))},t.reset=function reset(){this.datas=[]},V2NIMLoginDataSync}();function pick(t,i){t=t||{};var u={};return forEach$1(i=i||[]).call(i,(function(i){void 0!==t[i]&&(u[i]=t[i])})),u}var am={retryCount:{type:"number",min:0,required:!1},forceMode:{type:"boolean",required:!1},authType:{type:"enum",values:[0,1,2],required:!1},syncLevel:{type:"enum",values:[1,0],required:!1},routeConfig:{type:"object",required:!1,rules:{routeEnabled:{type:"boolean",required:!1},routeEnvironment:{type:"string",required:!1}}}},im={retryCount:3,timeout:6e4,forceMode:!1,authType:0,syncLevel:0},om=function(t){function V2NIMLoginServiceImpl(i,u){var m,h;return void 0===u&&(u={}),(m=t.call(this,"V2NIMLoginService",i)||this).account="",m.previousLoginAccount="",m.token="",m.deviceId="",m.clientSession="",m.processId="",m.kickedDetail=null,m.binaryWebsocket=!0,m.core._registerDep(_p,"misc"),registerParser({cmdMap:Cp,cmdConfig:Ap}),"v2"===i.options.apiVersion&&(registerParser({cmdMap:bp,cmdConfig:kp}),m.core.auth=Je(m)),m.previousLoginManager=new Jd,m.doLoginStepsManager=new Jd,m.loginTimerManager=new sd,m.loginOption=Dt({},im),m.config={lbsUrls:Wd,linkUrl:zd,linkSSL:!0},m.setOptions(u),i.V2NIMLoginService=Je(m),!1!==m.core.options.binaryWebsocket&&"function"==typeof Uint8Array?(m.binaryWebsocket=!0,h=new Jp(m.core)):(m.binaryWebsocket=!1,h=new Xp(m.core)),m.clientSocket=h,"v2"===m.core.options.apiVersion&&(m.core.clientSocket=h),m.lifeCycle=new rm(i),m.reconnect=new Zp(i),m.lbs=new em(i),m.authenticator=new tm(i),m.dataSync=new nm(i),m}Nt(V2NIMLoginServiceImpl,t);var i=V2NIMLoginServiceImpl.prototype;return i.setOptions=function setOptions(t){var i,u,m;validate({lbsUrls:{type:"array",itemType:"string",min:1,required:!1},linkUrl:{type:"string",allowEmpty:!1,required:!1}},t,"",!0),this.config=assignOptions(this.config,t),null===(u=null===(i=this.core.clientSocket)||void 0===i?void 0:i.setLinkSSL)||void 0===u||u.call(i,null===(m=this.config.linkSSL)||void 0===m||m);var h="",v="";this.config.isFixedDeviceId?(h=pd.localStorage.getItem("__NIM_DEVC_ID__")||jd(),v=pd.localStorage.getItem("__NIM_CLIENT_SESSION_ID__")||jd(),pd.localStorage.setItem("__NIM_DEVC_ID__",h),pd.localStorage.setItem("__NIM_CLIENT_SESSION_ID__",v)):(h=jd(),v=jd()),this.deviceId=h,this.clientSession=v,this.core.reporter.setConfig({common:{dev_id:h}})},i.reset=function reset(){this.account="",this.token="",this.processId="",this.lbs.reset(),this.reconnect.destroy(),this.authenticator.reset(),this.authenticator.clearLastLoginClient(),this.dataSync.reset()},i.login=function login(t,i,u){return void 0===u&&(u={}),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var m,h,v=this;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:if(this._checkApiVersion(),m=pd.getSystemInfo()||{},h=m.os?m.os.toLowerCase():"","React Native"!==pd.platform||"android"!==h||!this.hasSettingService||!get(this.core.V2NIMSettingService,"push.offlinePushPlugin")){M.next=13;break}return M.prev=4,M.next=7,this.core.V2NIMSettingService.push.getRNDeviceInfo();case 7:this.deviceInfo=M.sent,M.next=13;break;case 10:M.prev=10,M.t0=M.catch(4),this.logger.error(M.t0);case 13:if("string"==typeof t&&""!==trim$2(t).call(t)){M.next=15;break}throw new Jl({detail:{reason:"Account must be string"}});case 15:if(validate(am,u,"",!0),0!==(u=assignOptions(im,u)).authType||i){M.next=19;break}throw new Jl({detail:{reason:"When authType is 0, token cannot be empty"}});case 19:if(""!==this.previousLoginAccount&&this.previousLoginAccount!==t&&this.core._clearModuleData(),0!==this.getLoginStatus()){M.next=24;break}this.logger.log("V2NIMLoginService::login:allowLogin:"+t,u),M.next=30;break;case 24:if(1!==this.getLoginStatus()){M.next=28;break}return M.abrupt("return",this.smoothForLogined(t,i,u));case 28:if(2!==this.getLoginStatus()){M.next=30;break}return M.abrupt("return",this.smoothForLogining(t,i,u));case 30:return this.account=t,this.previousLoginAccount=t,this.token=i,this.processId=jd(),this.loginOption=assignOptions(im,u),this.kickedDetail=null,this.loginTimerManager.destroy(),this.loginTimerManager.addTimer((function(){var t=new Yl({code:zl.V2NIM_ERROR_CODE_TIMEOUT,detail:{reason:"Login API timeout"}});v.doLoginStepsManager.clear(t),v.previousLoginManager.clear(t),v.originLoginPromise=void 0,v.lifeCycle.processEvent("exited",t)}),this.loginOption.timeout>0?this.loginOption.timeout:6e4,1),M.prev=38,M.next=41,this.multiTryDoLogin();case 41:this.loginTimerManager.destroy(),M.next=48;break;case 44:throw M.prev=44,M.t1=M.catch(38),this.loginTimerManager.destroy(),M.t1;case 48:case"end":return M.stop()}}),_callee,this,[[4,10],[38,44]])})))},i.setAppVisibility=function setAppVisibility(){this.logger.warn("V2NIMLoginService::setAppVisibility is deprecated @v10.9.40")},i.getChatroomLinkAddress=function getChatroomLinkAddress(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:return validate({roomId:{type:"string",regExp:/^\d+$/,required:!0,allowEmpty:!1},miniProgram:{type:"boolean",required:!1}},{roomId:t,miniProgram:i},"",!0),i=void 0===i?pendingIsMiniappEnv():i,m.next=4,this.clientSocket.sendCmd("v2GetChatroomLinkAddress",{roomId:t,miniProgram:i});case 4:return u=m.sent,m.abrupt("return",u.content.linkAddress);case 6:case"end":return m.stop()}}),_callee2,this)})))},i.multiTryDoLogin=function multiTryDoLogin(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h;return ud.wrap((function _callee3$(v){for(;;)switch(v.prev=v.next){case 0:i=new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"loginFailed"}}),u=0;case 2:if(!(u<=this.loginOption.retryCount)){v.next=32;break}return m="V2NIMLoginService::times of login try: "+u,u>0?this.logger.warn(m):this.logger.log(m),v.prev=5,this.originLoginPromise=t||this.doLogin(!1),t=void 0,v.next=10,this.previousLoginManager.add(this.originLoginPromise);case 10:return h=v.sent,this.core.reporter.reportTraceEnd("login",!0),this.doLoginStepsManager.clear(),this.previousLoginManager.clear(),this.originLoginPromise=void 0,v.abrupt("return",h);case 18:if(v.prev=18,v.t0=v.catch(5),i=v.t0||i,this.logger.error("V2NIMLoginService::login failed, times of login try: "+u+", err.code: "+(null==i?void 0:i.code)+', err.message: "'+(null==i?void 0:i.message)+'"'),i.code!==zl.V2NIM_ERROR_CODE_CANCELLED&&this.core.reporter.reportTraceEnd("login",!1),this.reconnect.clearReconnectTimer(),!this.checkLoginTerminalCode(i&&i.code)){v.next=28;break}throw this.lifeCycle.processEvent("exited",i),i;case 28:i&&399===i.code&&this.lbs.reset();case 29:u++,v.next=2;break;case 32:throw this.lifeCycle.processEvent("exited",i),i;case 34:case"end":return v.stop()}}),_callee3,this,[[5,18]])})))},i.doLogin=function doLogin(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var m,h,v;return ud.wrap((function _callee4$(M){for(;;)switch(M.prev=M.next){case 0:return m=!!t||this.authenticator.checkAutoLogin(this.loginOption.forceMode),this.core.reporter.reportTraceCancel("login"),this.core.reporter.reportTraceStart("login",m?{user_id:this.account,action:"auto_login",process_id:this.processId,binary_websocket:this.binaryWebsocket}:{user_id:this.account,action:"manual_login",process_id:this.processId,binary_websocket:this.binaryWebsocket}),this.core.reporter.reportTraceUpdateV2("login",{code:0,description:Un(this.loginOption),operation_type:"conf_init",succeed:!0,duration:0,target:""},{asyncParams:pd.net.getNetworkStatus()}),M.next=6,this.doLoginStepsManager.add(this.lbs.getLbsInfos());case 6:return h=M.sent,M.next=9,this.doLoginStepsManager.add(this.clientSocket.connect(h,t));case 9:return M.next=11,this.doLoginStepsManager.add(this.authenticator.verifyAuthentication(m));case 11:if(v=M.sent,this.processId=jd(),this.clientSocket.resetSocketConfig(),this.reconnect.reset(),this.dataSync.reset(),this.lifeCycle.processEvent("loginSucc",void 0,Dt(Dt({},v),{isReconnect:t})),this.clientSocket.ping(),this.core.abtest.abtRequest(),"function"==typeof(null===(i=this.core.V2NIMClientAntispamUtil)||void 0===i?void 0:i.downloadLocalAntiSpamVocabs)&&this.core.V2NIMClientAntispamUtil.downloadLocalAntiSpamVocabs(),"function"!=typeof(null===(u=this.core.cloudStorage)||void 0===u?void 0:u.init)){M.next=29;break}return M.prev=21,M.next=24,this.core.cloudStorage.init(v.timestamp);case 24:M.next=29;break;case 26:M.prev=26,M.t0=M.catch(21),this.logger.warn("doLogin::cloudStorage init error",M.t0);case 29:return M.abrupt("return",v);case 30:case"end":return M.stop()}}),_callee4,this,[[21,26]])})))},i.smoothForLogined=function smoothForLogined(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var m;return ud.wrap((function _callee5$(h){for(;;)switch(h.prev=h.next){case 0:if(m=this.checkIsSameLogin(t,i,u),this.logger.warn("V2NIMLoginService::smoothForLogined:Logined, isSameLogin "+m),!m){h.next=6;break}return h.abrupt("return");case 6:return h.next=8,this.logout();case 8:return h.abrupt("return",this.login(t,i,u));case 9:case"end":return h.stop()}}),_callee5,this)})))},i.smoothForLogining=function smoothForLogining(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var m;return ud.wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:if(m=this.checkIsSameLogin(t,i,u),this.logger.warn("V2NIMLoginService::smoothForLogining:Logining progress exists, abort the previous login attempt and start next attempt, isSameLogin "+m),this.previousLoginManager.clear(),this.reconnect.reset(),this.account=t,this.previousLoginAccount=t,this.token=i,this.loginOption=assignOptions(this.loginOption,u),!m){h.next=18;break}if(this.originLoginPromise){h.next=11;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"NoPreviousLoginExists"}});case 11:return this.reconnect.reset(),h.next=14,zi.resolve();case 14:return h.next=16,this.multiTryDoLogin(this.originLoginPromise);case 16:h.next=25;break;case 18:return this.doLoginStepsManager.clear(),this.clientSocket.doDisconnect(Wp.ACTIVE,"Aborted"),this.reset(),this.lifeCycle.processEvent("logout"),h.next=24,zi.resolve();case 24:return h.abrupt("return",this.login(t,i,u));case 25:case"end":return h.stop()}}),_callee6,this)})))},i.checkIsSameLogin=function checkIsSameLogin(t,i,u){return this.account===t&&this.loginOption.authType===u.authType&&(0!==u.authType||this.token===i)},i.logout=function logout(){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var t,i;return ud.wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:this._checkApiVersion(),this.doLoginStepsManager.clear(),this.previousLoginManager.clear(),this.loginTimerManager.destroy(),this.originLoginPromise=void 0,t=this.getConnectStatus(),i=this.getLoginStatus(),u.t0=i,u.next=1===u.t0?10:2===u.t0?25:3===u.t0?29:0===u.t0?33:35;break;case 10:return u.prev=10,u.next=13,this.clientSocket.sendCmd("v2Logout",void 0,{timeout:1e3});case 13:this.clientSocket.doDisconnect(Wp.ACTIVE,"UserActiveDisconnect"),this.core._clearModuleData(),this.lifeCycle.processEvent("logout"),u.next=24;break;case 18:u.prev=18,u.t1=u.catch(10),this.logger.error("Instance::disconnect sendCmd:logout error",u.t1),this.clientSocket.doDisconnect(Wp.ACTIVE,"UserActiveDisconnect"),this.core._clearModuleData(),this.lifeCycle.processEvent("logout");case 24:return u.abrupt("break",37);case 25:case 29:return this.clientSocket.doDisconnect(Wp.ACTIVE,"UserActiveDisconnect"),this.core._clearModuleData(),this.lifeCycle.processEvent("logout"),u.abrupt("break",37);case 33:throw this.core._clearModuleData(),new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE,detail:{reason:"Illegal logout. loginStatus "+i+". connectStatus "+t}});case 35:throw this.core._clearModuleData(),new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE,detail:{reason:"Illegal logout. illegal status: loginStatus "+i+". connectStatus "+t}});case 37:case"end":return u.stop()}}),_callee7,this,[[10,18]])})))},i.getConnectStatus=function getConnectStatus(){return this.lifeCycle.getConnectStatus()},i.getLoginStatus=function getLoginStatus(){return this.lifeCycle.getLoginStatus()},i.getLoginUser=function getLoginUser(){return this.account},i.getLoginClients=function getLoginClients(){var t;return map$6(t=function uniqBy(t,i){t=t||[],i=i||"";for(var u=[],m=[],h=0;h<t.length;h++){var v=t[h][i];-1===indexOf(m).call(m,v)&&(m.push(v),u.push(t[h]))}return u}(this.authenticator.loginClients,"clientId")).call(t,(function(t){return pick(t,["type","os","timestamp","customTag","customClientType","clientId","clientIP"])}))},i.getCurrentLoginClient=function getCurrentLoginClient(){var t;if(null===(t=this.authenticator.loginClientOfThisConnection)||void 0===t?void 0:t.clientId)return pick(this.authenticator.loginClientOfThisConnection,["type","os","timestamp","customTag","customClientType","clientId","clientIP"])},i.getDataSync=function getDataSync(){var t=this.dataSync.datas;return t&&t.length>0?map$6(t).call(t,(function(t){return{type:t.type,state:t.state}})):null},i.setReconnectDelayProvider=function setReconnectDelayProvider(t){this.reconnect._setReconnectDelayProvider(t)},i.kickOffline=function kickOffline(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i;return ud.wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:return this._checkApiVersion(),validate({clientId:{type:"string",allowEmpty:!1}},t,"",!0),u.next=4,this.clientSocket.sendCmd("v2KickOffline",{clientIds:[t.clientId]});case 4:if(i=u.sent,0!==get(i,"content.clientIds.length")){u.next=8;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_REQUEST_FAILED});case 8:case"end":return u.stop()}}),_callee8,this)})))},i.getKickedOfflineDetail=function getKickedOfflineDetail(){return this.kickedDetail},i.checkLoginTerminalCode=function checkLoginTerminalCode(t){return this.authenticator.checkLoginTerminalCode(t)},i.checkIllegalState=function checkIllegalState(){if(!this.getLoginUser())throw new Yl({code:zl.V2NIM_ERROR_CODE_ILLEGAL_STATE})},i._checkApiVersion=function _checkApiVersion(){if("v2"!==this.core.options.apiVersion)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:'apiVersion is not "v2"'}})},i.v2LoginHandler=function v2LoginHandler(t){if(t.error)throw this.clientSocket.doDisconnect(Wp.ACTIVE,t.error),t.error;return t},i.v2LoginClientChangeHandler=function v2LoginClientChangeHandler(t){this.authenticator.changeLoginClient(Gd(t.content.state),t.content.datas)},i.nimLoginClientChangeHandler=function nimLoginClientChangeHandler(t){this.authenticator.changeLoginClient(Gd(t.content.state),t.content.datas)},i.qchatLoginClientChangeHandler=function qchatLoginClientChangeHandler(t){var i=Gd(t.content.state);i=1===i?2:3,this.authenticator.changeLoginClient(i,[t.content.data])},i.v2BeKickedHandler=function v2BeKickedHandler(t){if(t.error)this.core.logger.error("v2BeKickedHandler error, ",t.error);else{var i=function formatBeKickedTag(t){return format({reason:{type:"number"},clientType:{type:"number"},customClientType:{type:"number"}},t)}(t.content);this.core.logger.warn("v2Bekicked::",i),this.kickedDetail=i,this.clientSocket.doDisconnect(Wp.KICKED,i),this.core._clearModuleData(),this.lifeCycle.processEvent("kicked",new Yl({code:zl.V2NIM_ERROR_CODE_DISCONNECT,detail:{reason:"disconnect due to kicked"}}),i),this.emit("onKickedOffline",i)}},i.emit=function emit(i){for(var u,m,h=this.name+"::emit "+i.toString(),v=arguments.length,M=new Array(v>1?v-1:0),I=1;I<v;I++)M[I-1]=arguments[I];if("onLoginFailed"===i||"onDisconnected"===i||"onConnectFailed"===i){var S=M[0];this.logger.log(""+h,S.toString())}else if("onDataSync"===i){var T=M[2];this.logger.log(""+h,M[0],M[1],T&&T.toString())}else{var C,E;(C=this.logger).log.apply(C,concat(E=[""+h]).call(E,M))}return(u=t.prototype.emit).call.apply(u,concat(m=[this,i]).call(m,M))},Qe(V2NIMLoginServiceImpl,[{key:"hasSettingService",get:function get(){var t;return!!(null===(t=this.core.V2NIMSettingService)||void 0===t?void 0:t.name)}}]),V2NIMLoginServiceImpl}(hp),sm=R("".startsWith),cm=R("".slice),lm=Math.min,dm=correctIsRegexpLogic("startsWith");_export({target:"String",proto:!0,forced:!dm},{startsWith:function startsWith(t){var i=toString(requireObjectCoercible(this));notARegexp(t);var u=toLength(lm(arguments.length>1?arguments[1]:void 0,i.length)),m=toString(t);return sm?sm(i,m,u):cm(i,u,u+m.length)===m}});var um=entryVirtual("String").startsWith,pm=String.prototype,startsWith=function(t){var i=t.startsWith;return"string"==typeof t||t===pm||z(pm,t)&&i===pm.startsWith?um:i},mm=function(){function V2NIMConversationIdUtilImpl(t){this.name="V2NIMConversationIdUtil",this.core=t}var t=V2NIMConversationIdUtilImpl.prototype;return t.conversationId=function conversationId(t,i){return this.core.account+"|"+t+"|"+i},t.p2pConversationId=function p2pConversationId(t){return this.core.account+"|1|"+t},t.teamConversationId=function teamConversationId(t){return this.core.account+"|2|"+t},t.superTeamConversationId=function superTeamConversationId(t){return this.core.account+"|3|"+t},t.messageConversationId=function messageConversationId(t){return 1===t.conversationType?t.senderId===this.core.account?this.p2pConversationId(t.receiverId):this.p2pConversationId(t.senderId):2===t.conversationType?this.teamConversationId(t.receiverId):this.superTeamConversationId(t.receiverId)},t.parseConversationType=function parseConversationType(t){try{if(t&&startsWith(t).call(t,this.core.account+"|")){var i=t.replace(this.core.account+"|","");return Number(i[0])}return this.core.logger.warn("conversationId is not start with "+this.core.account),0}catch(t){return 0}},t.parseConversationTargetId=function parseConversationTargetId(t){try{if(t&&startsWith(t).call(t,this.core.account+"|")){var i=t.replace(this.core.account+"|","");return slice(i).call(i,2)}return this.core.logger.warn("conversationId is not start with "+this.core.account),""}catch(t){return""}},t.convertToV1ConversationId=function convertToV1ConversationId(t){var i=this.parseConversationType(t);return(1===i?"p2p":2===i?"team":"superTeam")+"|"+this.parseConversationTargetId(t)},V2NIMConversationIdUtilImpl}(),hm=entryVirtual("Array").keys,gm=Array.prototype,vm={DOMTokenList:!0,NodeList:!0},keys=function(t){var i=t.keys;return t===gm||z(gm,t)&&i===gm.keys||pe(vm,Tr(t))?hm:i},fm=function(){function V2NIMMessageModelImpl(){this.messages=new Sc,this.capacity=1e4}var t=V2NIMMessageModelImpl.prototype;return t.reset=function reset(){this.messages.clear()},t.getMessageById=function getMessageById(t){if(t)return this.messages.get(t)},t.getMessagesByConversationId=function getMessagesByConversationId(t){var i,u=[];return forEach$1(i=this.messages).call(i,(function(i){i.conversationId===t&&u.push(i)})),u},t.getLastMessageOfConversation=function getLastMessageOfConversation(t){var i=this.getMessagesByConversationId(t);if(0!==i.length)return reduce(i).call(i,(function(t,i){return i.createTime>t.createTime?i:t}),i[0])},t.upsertMessages=function upsertMessages(t){var i=this;forEach$1(t).call(t,(function(t){i.setLRU(t.messageClientId,t)}))},t.setLRU=function setLRU(t,i){if(this.messages.has(t))this.messages.delete(t);else if(this.messages.size>=this.capacity){var u,m=keys(u=this.messages).call(u).next().value;m&&this.messages.delete(m)}this.messages.set(t,i)},t.deleteMessage=function deleteMessage(t){this.messages.delete(t)},t.deleteMessages=function deleteMessages(t,i){var u,m=this;forEach$1(u=this.messages).call(u,(function(u){t===u.conversationId&&(!i||i&&u.createTime<i)&&m.messages.delete(u.messageClientId)}))},V2NIMMessageModelImpl}(),ym={accountId:{type:"string",allowEmpty:!1},content:{type:"object",required:!1,rules:{msg:{type:"string",allowEmpty:!1},type:{type:"number",allowEmpty:!1}}},messages:{type:"array",required:!1,rules:{msg:{type:"string",allowEmpty:!1},type:{type:"number"},role:{type:"enum",values:["assistant","user","system"]}}},promptVariables:{type:"jsonstr",required:!1},modelConfigParams:{type:"object",required:!1,rules:{prompt:{type:"string",required:!1},maxTokens:{type:"number",required:!1},topP:{type:"number",required:!1},temperature:{type:"number",required:!1}}},aiStream:{type:"boolean",required:!1}},Mm=Dt({requestId:{type:"string",allowEmpty:!1}},ym),Im={requestId:{type:"string",allowEmpty:!1},accountId:{type:"string",allowEmpty:!1}},_m=[1,3,2,0],Sm=[2,7,12,100,6,1,-1,4,5,11,0,10,3],Tm={routeEnabled:{type:"boolean",required:!1},routeEnvironment:{type:"string",required:!1}},Cm={pushEnabled:{type:"boolean",required:!1},pushNickEnabled:{type:"boolean",required:!1},pushContent:{type:"string",required:!1},pushPayload:{type:"string",required:!1},forcePush:{type:"boolean",required:!1},forceContent:{type:"string",required:!1},forcePushAccountIds:{type:"array",required:!1,itemType:"string"}},bm={antispamEnabled:{type:"boolean",required:!1},antispamBusinessId:{type:"string",required:!1},antispamCustomMessage:{type:"string",required:!1},antispamCheating:{type:"string",required:!1},antispamExtension:{type:"string",required:!1}},Em={messageConfig:{type:"object",required:!1,rules:{readReceiptEnabled:{type:"boolean",required:!1},lastMessageUpdateEnabled:{type:"boolean",required:!1},historyEnabled:{type:"boolean",required:!1},roamingEnabled:{type:"boolean",required:!1},onlineSyncEnabled:{type:"boolean",required:!1},offlineEnabled:{type:"boolean",required:!1},unreadEnabled:{type:"boolean",required:!1}}},routeConfig:{type:"object",required:!1,rules:Tm},pushConfig:{type:"object",required:!1,rules:Cm},antiSpamConfig:{type:"object",required:!1,rules:bm},robotConfig:{type:"object",required:!1,rules:{accountId:{type:"string",required:!1},topic:{type:"string",required:!1},function:{type:"string",required:!1},customContent:{type:"string",required:!1}}},aiConfig:{type:"object",required:!1,rules:ym},targetConfig:{type:"object",required:!1,rules:{receiverIds:{type:"array",itemType:"string"},inclusive:{type:"boolean"},newMemberVisible:{type:"boolean",required:!1}}},clientAntispamEnabled:{type:"boolean",required:!1},clientAntispamReplace:{type:"string",required:!1}},Am={message:{type:"object",rules:{text:{type:"string",required:!1},messageType:{type:"enum",values:Sm},messageClientId:{type:"string",allowEmpty:!1}}},params:{type:"object",rules:Em,required:!1},replyMessage:{type:"object",rules:{conversationType:{type:"enum",values:[1,3,2,0]},receiverId:{type:"string",allowEmpty:!1},senderId:{type:"string",allowEmpty:!1},messageClientId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},createTime:{type:"number"}}}},km={conversationId:{type:"string",allowEmpty:!1},message:{type:"object",rules:{text:{type:"string",required:!1},messageType:{type:"enum",values:Sm},messageClientId:{type:"string",allowEmpty:!1},attachment:{type:"object",required:!1,rules:{file:{type:"file",required:!1}}}}},params:{type:"object",required:!1,rules:Em}},Rm={message:{type:"object",rules:{messageClientId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},conversationType:{type:"enum",values:_m},createTime:{type:"number"}}},params:{type:"object",rules:{postscript:{type:"string",required:!1},serverExtension:{type:"string",required:!1},pushContent:{type:"string",required:!1},pushPayload:{type:"string",required:!1},env:{type:"string",required:!1}},required:!1}},wm={conversationId:{type:"string",allowEmpty:!1},messageTypes:{type:"array",required:!1,itemType:"enum",values:Sm},beginTime:{type:"number",required:!1},endTime:{type:"number",required:!1},limit:{type:"number",min:1,required:!1},direction:{type:"enum",values:[1,0],required:!1},anchorMessage:{type:"object",required:!1,rules:{messageServerId:{type:"string",allowEmpty:!1},createTime:{type:"number"}}}},Nm={conversationType:{type:"enum",values:_m},receiverId:{type:"string",allowEmpty:!1},senderId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},messageClientId:{type:"string",allowEmpty:!1}},xm={messageRefers:{type:"array",required:!0,rules:Nm}},Om={conversationId:{type:"string",allowEmpty:!1},conversationType:{type:"enum",values:_m},receiverId:{type:"string",allowEmpty:!1},senderId:{type:"string",allowEmpty:!1},messageClientId:{type:"string",allowEmpty:!1},createTime:{type:"number"}},Pm={messages:{type:"array",rules:Om}},Lm={conversationId:{type:"string",allowEmpty:!1},serverExtension:{type:"string",required:!1},onlineSync:{type:"boolean",required:!1},deleteRoam:{type:"boolean",required:!1},clearMode:{type:"enum",values:[0,1,2],required:!1}},Vm={serverExtension:{type:"string",required:!1}},Um={messageClientId:{type:"string",allowEmpty:!1},conversationType:{type:"enum",values:[1]},receiverId:{type:"string",allowEmpty:!1},createTime:{type:"number"}},Dm={messages:{type:"array",rules:{messageClientId:{type:"string",allowEmpty:!1},conversationType:{type:"enum",values:[2]},receiverId:{type:"string",allowEmpty:!1},createTime:{type:"number"}},min:1}},Bm={voiceUrl:{type:"string",required:!1,allowEmpty:!1},file:{type:"file",required:!1},voicePath:{type:"string",required:!1,allowEmpty:!1},mimeType:{type:"string",required:!1,allowEmpty:!1},sampleRate:{type:"string",required:!1,allowEmpty:!1},duration:{type:"number",required:!0,min:0},sceneName:{type:"string",required:!1}},qm={message:{type:"object",rules:{conversationType:{type:"enum",values:_m},receiverId:{type:"string",allowEmpty:!1},senderId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},messageClientId:{type:"string",allowEmpty:!1},createTime:{type:"number"}}},index:{type:"number",min:1},serverExtension:{type:"string",required:!1},pushConfig:{type:"object",required:!1,rules:{pushEnabled:{type:"boolean",required:!1},needBadge:{type:"boolean",required:!1},title:{type:"string",required:!1,allowEmpty:!1},content:{type:"string",required:!1,allowEmpty:!1},pushPayload:{type:"string",required:!1,allowEmpty:!1}}}},Fm={messages:{type:"array",rules:{conversationType:{type:"enum",values:[1,3,2,0]},receiverId:{type:"string",allowEmpty:!1},senderId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},messageClientId:{type:"string",allowEmpty:!1},createTime:{type:"number"}}}},Gm={params:{type:"object",rules:{collectionType:{type:"number",min:1},collectionData:{type:"string",allowEmpty:!1},serverExtension:{type:"string",required:!1},uniqueId:{type:"string",required:!1}}}},Hm={collections:{type:"array",min:1,rules:{collectionId:{type:"string",allowEmpty:!1},createTime:{type:"number"}}}},jm={serverExtension:{type:"string",required:!1},collection:{type:"object",rules:{collectionId:{type:"string",allowEmpty:!1},collectionType:{type:"number"},createTime:{type:"number"}}}},$m={beginTime:{type:"number",required:!1},endTime:{type:"number",required:!1},limit:{type:"number",min:1,required:!1},direction:{type:"enum",required:!1,values:[1,0]},collectionType:{type:"number",required:!1},anchorCollection:{type:"object",required:!1,rules:{collectionId:{type:"string",allowEmpty:!1,required:!1},createTime:{type:"number",required:!1}}}},zm={keyword:{type:"string",allowEmpty:!1},beginTime:{type:"number",required:!1},endTime:{type:"number",required:!1},sortOrder:{type:"enum",values:[1,0],required:!1},conversationLimit:{type:"number",min:0,required:!1},messageLimit:{type:"number",min:1,required:!1},p2pAccountIds:{type:"array",required:!1,itemType:"string"},teamIds:{type:"array",required:!1,itemType:"string"},senderAccountIds:{type:"array",required:!1,itemType:"string"},messageTypes:{type:"array",required:!1,itemType:"enum",values:Sm},messageSubtypes:{type:"array",required:!1,itemType:"number"}},Wm={conversationId:{type:"string",required:!1,allowEmpty:!1},keywordList:{type:"array",required:!1,itemType:"string"},keywordMatchType:{type:"enum",values:[1,0],required:!1},senderAccountIds:{type:"array",required:!1,itemType:"string"},messageTypes:{type:"array",required:!1,itemType:"enum",values:Sm},messageSubtypes:{type:"array",required:!1,itemType:"number"},searchStartTime:{type:"number",required:!1},searchTimePeriod:{type:"number",required:!1},limit:{type:"number",min:1,required:!1},direction:{type:"enum",values:[0,1],required:!1},pageToken:{type:"string",required:!1}},Km={message:{type:"object",rules:{receiverId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},conversationType:{type:"enum",values:[2]}}}},Ym={messages:{type:"array",rules:{receiverId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},conversationType:{type:"enum",values:[2]}},min:1}},Qm={sceneName:{type:"string",required:!1},name:{type:"string",required:!1}},Jm=Dt(Dt({},Qm),{duration:{type:"number",required:!1}}),Xm=Dt(Dt({},Jm),{width:{type:"number",required:!1},height:{type:"number",required:!1}}),Zm=Dt(Dt({},Qm),{width:{type:"number",required:!1},height:{type:"number",required:!1}}),eh={messageRefer:{type:"object",required:!0,rules:Nm},beginTime:{type:"number",required:!1},endTime:{type:"number",required:!1},limit:{type:"number",min:1,required:!1},direction:{type:"enum",values:[1,0],required:!1},excludeMessageServerId:{type:"string",required:!1,allowEmpty:!1}},th={senderId:{type:"string",allowEmpty:!1},receiverId:{type:"string",allowEmpty:!1},createTime:{type:"number"},messageClientId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1}},rh={subType:{type:"number",min:0,required:!1},text:{type:"string",required:!1},attachment:{type:"object",required:!1},serverExtension:{type:"string",required:!1},routeConfig:{type:"object",required:!1,rules:Tm},pushConfig:{type:"object",required:!1,rules:Cm},antiSpamConfig:{type:"object",required:!1,rules:bm},clientAntispamEnabled:{type:"boolean",required:!1},clientAntispamReplace:{type:"string",required:!1}},nh={messageClientId:{type:"string",allowEmpty:!1},messageServerId:{type:"string",allowEmpty:!1},createTime:{type:"number"},aiConfig:{type:"object",rules:ym}},ah={operationType:{type:"enum",values:[0,1,2]},updateContent:{type:"string",allowEmpty:!0,required:!1}},ih={operationType:{type:"enum",values:[2,1],required:!0}},oh=function(){function ReceiptUtil(t,i){this.receiptDatas={},this.minActionTime=0,this.core=t,this.service=i}var t=ReceiptUtil.prototype;return t.reset=function reset(){this.receiptDatas={}},t.checkReceiptDataReliable=function checkReceiptDataReliable(t){if(!this.minActionTime)return!0;var i=this.getReceiptData(t);return!!i&&(!!i.actionTime&&i.actionTime>=this.minActionTime)},t.getReceiptData=function getReceiptData(t){return this.receiptDatas[t]},t.setReceiptData=function setReceiptData(t,i){this.receiptDatas[t]=this.receiptDatas[t]||{},Dt(this.receiptDatas[t],i)},t.sendP2PMessageReceipt=function sendP2PMessageReceipt(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(validate(Um,t,"",!0),t.senderId!==this.core.account){i.next=3;break}throw new Jl({detail:{reason:"sendP2PMessageReceipt. sender: "+t.senderId+" is not allowed to send msg receipt"}});case 3:return i.next=5,this.core.sendCmd("v2SendP2PMessageReceipt",{tag:{receiverId:t.senderId,messageClientId:t.messageClientId,createTime:t.createTime}});case 5:case"end":return i.stop()}}),_callee,this)})))},t.isPeerRead=function isPeerRead(t){var i;if(1!==t.conversationType)return!1;if(t.senderId!==this.core.account)return!1;if(t.senderId===this.core.account&&t.receiverId===this.core.account)return!0;var u=this.core.V2NIMConversationIdUtil.messageConversationId(t),m=(null===(i=this.getReceiptData(u))||void 0===i?void 0:i.receiptTime)||0;return this.checkReceiptDataReliable(u)||this.getP2pMessageReceiptsFromServer([u]),t.createTime<=m},t.getP2PMessageReceipt=function getP2PMessageReceipt(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:if(validateConversationId(this.core.account,t),1===this.core.V2NIMConversationIdUtil.parseConversationType(t)){u.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getP2PMessageReceipt: conversationId is not p2p conversationId"}});case 4:if(this.checkReceiptDataReliable(t)){u.next=7;break}return u.next=7,this.getP2pMessageReceiptsFromServer([t]);case 7:return u.abrupt("return",{conversationId:t,timestamp:(null===(i=this.getReceiptData(t))||void 0===i?void 0:i.receiptTime)||0});case 8:case"end":return u.stop()}}),_callee2,this)})))},t.getP2pMessageReceiptsFromServer=function getP2pMessageReceiptsFromServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h,v=this;return ud.wrap((function _callee3$(M){for(;;)switch(M.prev=M.next){case 0:if(t.length){M.next=2;break}return M.abrupt("return");case 2:return M.next=4,this.core.sendCmd("v2GetP2PMessageReceipts",{tags:map$6(t).call(t,(function(t){return{type:1,id:v.core.V2NIMConversationIdUtil.parseConversationTargetId(t)}}))});case 4:i=M.sent,u=i.content.datas,m=i.content.actionTime||this.core.timeOrigin.getNTPTime(),this.core.eventBus.emit("V2NIMSync/updateTimetag",{p2pMsgReceiptV2:m}),forEach$1(t).call(t,(function(t){v.setReceiptData(t,{receiptTime:0,actionTime:m})})),h=[],forEach$1(u).call(u,(function(t){var i,u=v.core.V2NIMConversationIdUtil.p2pConversationId(t.id),M=+t.msgTime||0;M>((null===(i=v.getReceiptData(u))||void 0===i?void 0:i.receiptTime)||0)&&h.push({conversationId:u,timestamp:M}),v.setReceiptData(u,{receiptTime:M,actionTime:m})})),h.length>0&&this.service.emit("onReceiveP2PMessageReadReceipts",h);case 12:case"end":return M.stop()}}),_callee3,this)})))},t.getTeamMessageReceipts=function getTeamMessageReceipts(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m=this;return ud.wrap((function _callee4$(h){for(;;)switch(h.prev=h.next){case 0:if(validate(Ym,{messages:t},"",!0),!some(t).call(t,(function(t){return t.senderId!==m.core.account}))){h.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getTeamMessageReceipts: exist messages senderId is not current user"}});case 3:if(!some(t).call(t,(function(i){return i.receiverId!==t[0].receiverId}))){h.next=5;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"getTeamMessageReceipts: exist messages receiverId is not same"}});case 5:return h.next=7,this.core.sendCmd("v2GetTeamMessageReceipts",{tag:t});case 7:return u=h.sent,h.abrupt("return",map$6(i=u.content.data).call(i,(function(t){return Dt(Dt({},t),{conversationId:m.core.V2NIMConversationIdUtil.teamConversationId(t.receiverId)})})));case 9:case"end":return h.stop()}}),_callee4,this)})))},t.getTeamMessageReceiptDetail=function getTeamMessageReceiptDetail(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i;return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:if(validate(Km,{message:t},"",!0),t.senderId===this.core.account){u.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getTeamMessageReceiptDetail::senderId "+t.senderId+" incorrect"}});case 3:return u.next=5,this.core.sendCmd("v2GetTeamMessageReceiptDetail",{tag:t});case 5:return i=u.sent,u.abrupt("return",{readReceipt:{conversationId:this.core.V2NIMConversationIdUtil.teamConversationId(t.receiverId),messageClientId:t.messageClientId,messageServerId:t.messageServerId,readCount:i.content.readAccountList.length,unreadCount:i.content.unreadAccountList.length},readAccountList:i.content.readAccountList,unreadAccountList:i.content.unreadAccountList});case 7:case"end":return u.stop()}}),_callee5,this)})))},t.sendTeamMessageReceipts=function sendTeamMessageReceipts(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i=this;return ud.wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:if(!some(t).call(t,(function(i){return i.conversationId!==t[0].conversationId}))){u.next=2;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"getTeamMessageReceipts: conversationId not same"}});case 2:if(validate(Dm,{messages:t},"",!0),!some(t).call(t,(function(t){return t.senderId===i.core.account}))){u.next=5;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getTeamMessageReceipts: exist messages senderId is not current user"}});case 5:return u.next=7,this.core.sendCmd("v2SendTeamMessageReceipts",{tag:t});case 7:return u.abrupt("return");case 8:case"end":return u.stop()}}),_callee6,this)})))},t.syncP2PMessagReceiptsHandler=function syncP2PMessagReceiptsHandler(t){var i,u=this,m=map$6(i=t.content.data).call(i,(function(t){var i=u.core.V2NIMConversationIdUtil.p2pConversationId(t.senderId),m=t.createTime;return u.setReceiptData(i,{receiptTime:m}),{conversationId:i,timestamp:m}}));this.service.emit("onReceiveP2PMessageReadReceipts",m)},t.syncP2pMessagReceiptsV2Handler=function syncP2pMessagReceiptsV2Handler(t){var i=this,u=t.content,m=u.ctx,h=u.contents,v=m.minTimetag,M=m.maxTimetag;for(var I in this.minActionTime=v,forEach$1(h).call(h,(function(t){var u=i.core.V2NIMConversationIdUtil.p2pConversationId(t.id);i.setReceiptData(u,{receiptTime:t.msgTime})})),this.receiptDatas){var S=this.receiptDatas[I];(!S.actionTime||S.actionTime>=v)&&this.setReceiptData(I,{actionTime:M})}},t.onP2PMessageReceiptsHandler=function onP2PMessageReceiptsHandler(t){var i=t.content.data,u=i.senderId,m=i.createTime,h=i.actionTime,v=this.core.V2NIMConversationIdUtil.p2pConversationId(u);this.setReceiptData(v,{receiptTime:m,actionTime:h}),this.core.eventBus.emit("V2NIMSync/updateTimetag",{p2pMsgReceiptV2:h}),this.service.emit("onReceiveP2PMessageReadReceipts",[{conversationId:v,timestamp:m}])},t.onTeamMessageReceiptsHandler=function onTeamMessageReceiptsHandler(t){var i,u=this,m=map$6(i=t.content.data).call(i,(function(t){return{conversationId:u.core.V2NIMConversationIdUtil.teamConversationId(t.receiverId),messageServerId:t.messageServerId,messageClientId:t.messageClientId,readCount:t.readCount,unreadCount:t.unreadCount,latestReadAccount:t.latestReadAccount}}));this.service.emit("onReceiveTeamMessageReadReceipts",m)},ReceiptUtil}(),sh={"4_37":"v2TeamJoinActionList","4_38":"v2TeamJoinActionListSync","4_39":"v2TeamJoinActionClearSync","31_1":"v2TeamCreate","32_1":"v2SuperTeamCreate","31_5":"v2TeamInviteMembers","32_5":"v2SuperTeamInviteMembers","31_6":"v2TeamKickMembers","32_6":"v2SuperTeamKickMembers","31_8":"v2TeamLeave","32_7":"v2SuperTeamLeave","31_7":"v2TeamUpdateInfo","32_8":"v2SuperTeamUpdateInfo","31_9":"v2TeamGetInfo","32_9":"v2SuperTeamGetInfo","31_12":"v2TeamDismiss","32_4":"v2SuperTeamDismiss","31_13":"v2TeamApplyToJoin","32_20":"v2SuperTeamApplyToJoin","31_14":"v2TeamAcceptJoinApplication","32_21":"v2SuperTeamAcceptJoinApplication","31_15":"v2TeamRejectJoinApplication","32_22":"v2SuperTeamRejectJoinApplication","31_16":"v2TeamAddManagers","32_26":"v2SuperTeamAddManagers","31_17":"v2TeamRemoveManagers","32_27":"v2SuperTeamRemoveManagers","31_18":"v2TeamTransferOwner","32_31":"v2SuperTeamTransferOwner","31_19":"v2TeamUpdateSelfMemberInfo","32_10":"v2SuperTeamUpdateSelfMemberInfo","31_20":"v2TeamUpdateMember","32_30":"v2SuperTeamUpdateMember","31_21":"v2TeamAcceptInvitation","32_23":"v2SuperTeamAcceptInvitation","31_22":"v2TeamRejectInvite","32_24":"v2SuperTeamRejectInvite","31_33":"v2TeamGetMemberInvitor","32_35":"v2SuperTeamGetMemberInvitor","31_25":"v2TeamMemberSetChatBannedStatus","32_29":"v2SuperTeamMemberSetChatBannedStatus","31_32":"v2TeamSetChatBannedMode","32_28":"v2SuperTeamSetChatBannedMode","31_34":"v2TeamGetByIds","32_36":"v2SuperTeamGetByIds","31_35":"v2TeamMemberGetListByIds","32_37":"v2SuperTeamMemberGetListByIds","31_36":"v2TeamMemberGetList","31_39":"v2TeamJoinActionDelete","31_40":"v2TeamJoinActionClear","8_41":"v2TeamJoinActionDeleteMultiSync","8_42":"v2TeamJoinActionClearMultiSync","8_101":"v2TeamCreateMultiSync","8_109":"v2TeamSync","8_119":"v2TeamMemberUpdateMultiSync","8_126":"v2TeamMembersOfSelfInSync","21_101":"v2SuperTeamCreateMultiSync","21_109":"v2SuperTeamSync","21_110":"v2SuperTeamMemberUpdateMultiSync","21_111":"v2SuperTeamMembersOfSelfInSync"},ch={antispamBusinessId:1},lh="V2NIMTeamService",dh={teamId:1,name:3,teamType:{id:4,retConverter:function retConverter(t){return 0==+t?1:+t}},ownerAccountId:5,memberLimit:{id:6,retType:"number"},isTeamEffective:{id:8,converter:boolToInt,retType:"boolean"},memberCount:{id:9,retType:"number"},memberUpdateTime:{id:10,retType:"number"},createTime:{id:11,retType:"number"},updateTime:{id:12,retType:"number"},isValidTeam:{id:13,retDef:!0,retConverter:function retConverter(t,i){return 1==+i[8]&&1==+t}},intro:14,announcement:15,joinMode:{id:16,retType:"number"},serverExtension:18,customerExtension:19,avatar:20,agreeMode:{id:21,retType:"number"},inviteMode:{id:22,retType:"number"},updateInfoMode:{id:23,retType:"number"},updateExtensionMode:{id:24,retType:"number"},chatBannedMode:{id:101,retType:"number"}},uh={teamId:1,accountId:3,memberRole:{id:4,retType:"number"},teamNick:5,bits:{id:7,retType:"number"},inTeam:{id:9,retType:"boolean"},joinTime:{id:10,retType:"number"},updateTime:{id:11,retType:"number"},serverExtension:12,chatBanned:{id:13,retType:"boolean"},invitorAccountId:14,followAccountIds:{id:16,retConverter:function retConverter(t){try{return JSON.parse(t)}catch(t){return[]}}}},ph={teamId:1,accountId:3,memberRole:{id:4,retType:"number"},teamNick:5,bits:{id:7,retType:"number"},inTeam:{id:9,retType:"boolean"},updateTime:{id:11,retType:"number"},serverExtension:12,chatBanned:{id:13,retType:"boolean"},invitorAccountId:14,joinTime:{id:15,retType:"number"},followAccountIds:{id:17,retConverter:function retConverter(t){try{return JSON.parse(t)}catch(t){return[]}}}},mh={accountIds:{id:1,converter:function converter(t){return Un(t)}},operation:2},gh={fromAccountId:1,targetAccountId:2,operatorAccountId:3,status:{id:4,retType:"number"},timestamp:{id:5,retType:"number"},updateTimestamp:{id:6,retType:"number"},postscriptHistory:{id:7,retConverter:function retConverter(t){if(t&&"string"==typeof t)try{var i=JSON.parse(t);return map$6(i).call(i,(function(t){return{fromAccount:t.accid,time:t.time,content:t.msg}}))}catch(t){return}}},serverId:8,teamId:9,teamType:{id:10,retType:"number"},finished:{id:11,retType:"boolean"},serverExtension:12},vh={serverId:1,teamType:{id:2,retType:"number"},teamId:3,serverTime:{id:4,retType:"number"}},fh={timestamp:{id:1,retType:"number"},type:{id:2,retType:"number"},serverTime:{id:3,retType:"number"}},yh={v2TeamCreate:{sid:31,cid:1,service:lh,params:[{type:"Property",name:"team",reflectMapper:dh},{type:"StrArray",name:"inviteeAccountIds"},{type:"String",name:"postscript"},{type:"Property",name:"antispamConfig",reflectMapper:ch}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)},{type:"StrArray",name:"failedList"}]},v2SuperTeamCreate:{sid:32,cid:1,service:lh,params:[{type:"Property",name:"team",reflectMapper:dh},{type:"StrArray",name:"inviteeAccountIds"},{type:"String",name:"postscript"},{type:"Property",name:"antispamConfig",reflectMapper:ch}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)},{type:"StrArray",name:"failedList"}]},v2TeamInviteMembers:{sid:31,cid:5,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"},{type:"String",name:"ps"},{type:"String",name:"attach"}],response:[{type:"Long",name:"time"},{type:"StrArray",name:"abortedAccidList"}]},v2SuperTeamInviteMembers:{sid:32,cid:5,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"},{type:"String",name:"ps"},{type:"String",name:"attach"}],response:[{type:"StrArray",name:"abortedAccidList"},{type:"Long",name:"time"}]},v2TeamUpdateInfo:{sid:31,cid:7,service:lh,params:[{type:"Property",name:"team",reflectMapper:dh},{type:"Property",name:"antispamConfig",reflectMapper:ch}],response:[{type:"Long",name:"teamId"},{type:"Long",name:"timestamp"}]},v2SuperTeamUpdateInfo:{sid:32,cid:8,service:lh,params:[{type:"Property",name:"team",reflectMapper:dh},{type:"Property",name:"antispamConfig",reflectMapper:ch}],response:[{type:"Long",name:"timestamp"}]},v2TeamLeave:{sid:31,cid:8,service:lh,params:[{type:"Long",name:"teamId"}]},v2SuperTeamLeave:{sid:32,cid:7,service:lh,params:[{type:"Long",name:"teamId"}]},v2TeamGetInfo:{sid:31,cid:9,service:lh,params:[{type:"Long",name:"teamId"}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)}]},v2SuperTeamGetInfo:{sid:32,cid:9,service:lh,params:[{type:"Long",name:"teamId"}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)}]},v2TeamGetByIds:{sid:31,cid:34,service:lh,params:[{type:"LongArray",name:"teamIds"}],response:[{type:"PropertyArray",name:"teams",reflectMapper:invertSerializeItem(dh)},{type:"LongArray",name:"tids"}]},v2SuperTeamGetByIds:{sid:32,cid:36,service:lh,params:[{type:"LongArray",name:"teamIds"}],response:[{type:"PropertyArray",name:"teams",reflectMapper:invertSerializeItem(dh)},{type:"LongArray",name:"tids"}]},v2TeamDismiss:{sid:31,cid:12,service:lh,params:[{type:"Long",name:"teamId"}]},v2SuperTeamDismiss:{sid:32,cid:4,service:lh,params:[{type:"Long",name:"teamId"}]},v2TeamAcceptInvitation:{sid:31,cid:21,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)}]},v2SuperTeamAcceptInvitation:{sid:32,cid:23,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)}]},v2TeamRejectInvite:{sid:31,cid:22,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},v2SuperTeamRejectInvite:{sid:32,cid:24,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},v2TeamKickMembers:{sid:31,cid:6,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},v2SuperTeamKickMembers:{sid:32,cid:6,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},v2TeamApplyToJoin:{sid:31,cid:13,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"ps"}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)},{type:"Int",name:"isInTeam"}]},v2SuperTeamApplyToJoin:{sid:32,cid:20,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"ps"}],response:[{type:"Property",name:"team",reflectMapper:invertSerializeItem(dh)},{type:"Int",name:"isInTeam"}]},v2TeamAcceptJoinApplication:{sid:31,cid:14,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}]},v2SuperTeamAcceptJoinApplication:{sid:32,cid:21,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}]},v2TeamRejectJoinApplication:{sid:31,cid:15,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},v2SuperTeamRejectJoinApplication:{sid:32,cid:22,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},v2TeamAddManagers:{sid:31,cid:16,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},v2SuperTeamAddManagers:{sid:32,cid:26,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},v2TeamRemoveManagers:{sid:31,cid:17,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},v2SuperTeamRemoveManagers:{sid:32,cid:27,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},v2TeamTransferOwner:{sid:31,cid:18,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"account"},{type:"Bool",name:"leave"}]},v2SuperTeamTransferOwner:{sid:32,cid:31,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"account"},{type:"Bool",name:"leave"}]},v2TeamUpdateSelfMemberInfo:{sid:31,cid:19,service:lh,params:[{type:"Property",name:"teamMember",reflectMapper:uh},{type:"Property",name:"specialFollowUpdate",reflectMapper:mh},{type:"Property",name:"antispam",reflectMapper:ch}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(uh)}]},v2SuperTeamUpdateSelfMemberInfo:{sid:32,cid:10,service:lh,params:[{type:"Property",name:"teamMember",reflectMapper:ph},{type:"Property",name:"specialFollowUpdate",reflectMapper:mh},{type:"Property",name:"antispam",reflectMapper:ch}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ph)}]},v2TeamUpdateMember:{sid:31,cid:20,service:lh,params:[{type:"Property",name:"teamMember",reflectMapper:uh},{type:"Property",name:"antispam",reflectMapper:ch}]},v2SuperTeamUpdateMember:{sid:32,cid:30,service:lh,params:[{type:"Property",name:"teamMember",reflectMapper:ph},{type:"Property",name:"antispam",reflectMapper:ch}]},v2TeamGetMemberInvitor:{sid:31,cid:33,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}],response:[{type:"StrStrMap",name:"accountsMap"}]},v2SuperTeamGetMemberInvitor:{sid:32,cid:35,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}],response:[{type:"StrStrMap",name:"accountsMap"}]},v2TeamMemberSetChatBannedStatus:{sid:31,cid:25,service:lh,params:[{type:"Long",name:"teamId"},{type:"String",name:"accountId"},{type:"Int",name:"chatBanned"}]},v2SuperTeamMemberSetChatBannedStatus:{sid:32,cid:29,service:lh,params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accountId"},{type:"Int",name:"chatBanned"}]},v2TeamSetChatBannedMode:{sid:31,cid:32,service:lh,params:[{type:"Long",name:"teamId"},{type:"Int",name:"chatBannedMode"}]},v2SuperTeamSetChatBannedMode:{sid:32,cid:28,service:lh,params:[{type:"Long",name:"teamId"},{type:"Int",name:"chatBannedMode"}]},v2TeamMemberGetListByIds:{sid:31,cid:35,service:lh,params:[{type:"StrArray",name:"tag"}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(uh)}]},v2SuperTeamMemberGetListByIds:{sid:32,cid:37,service:lh,params:[{type:"StrArray",name:"tag"}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ph)}]},v2TeamMemberGetList:{sid:31,cid:36,service:lh,params:[{type:"Property",name:"tag",reflectMapper:{teamId:1,teamType:2,roleQueryType:3,onlyChatBanned:{id:4,converter:function converter(t){return+t}},nextToken:5,limit:6,direction:7}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(uh)},{type:"Property",name:"pageInfo",reflectMapper:{1:"hasMore",2:"nextToken"}}]},v2TeamSync:{sid:8,cid:109,service:lh,response:[{type:"Long",name:"timetag"},{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(dh)}]},v2TeamCreateMultiSync:{sid:8,cid:101,service:lh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(dh)}]},v2TeamMemberUpdateMultiSync:{sid:8,cid:119,service:lh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(uh)}]},v2TeamMembersOfSelfInSync:{sid:8,cid:126,service:lh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(uh)},{type:"Long",name:"timetag"}]},v2SuperTeamSync:{sid:21,cid:109,service:lh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Dt(Dt({},dh),{teamType:{id:4,retConverter:function retConverter(){return 2}}}))},{type:"Bool",name:"isAll"},{type:"Long",name:"timetag"}]},v2SuperTeamCreateMultiSync:{sid:21,cid:101,service:lh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Dt(Dt({},dh),{teamType:{id:4,retConverter:function retConverter(){return 2}}}))}]},v2SuperTeamMemberUpdateMultiSync:{sid:21,cid:110,service:lh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ph)}]},v2SuperTeamMembersOfSelfInSync:{sid:21,cid:111,service:lh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ph)},{type:"Long",name:"timetag"}]},v2TeamJoinActionDelete:{sid:31,cid:39,service:lh,params:[{type:"Property",name:"tag",reflectMapper:vh}],response:[{type:"Long",name:"serverTime"}]},v2TeamJoinActionClear:{sid:31,cid:40,service:lh,params:[{type:"Property",name:"tag",reflectMapper:fh}],response:[{type:"Long",name:"serverTime"}]},v2TeamJoinActionDeleteMultiSync:{sid:8,cid:41,service:lh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(vh)}]},v2TeamJoinActionClearMultiSync:{sid:8,cid:42,service:lh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(fh)}]},v2TeamJoinActionList:{sid:4,cid:37,service:lh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(gh)},{type:"Long",name:"serverTime"}]},v2TeamJoinActionListSync:{sid:4,cid:38,service:lh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(gh)},{type:"Long",name:"serverTime"}]},v2TeamJoinActionClearSync:{sid:4,cid:39,service:lh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(gh)},{type:"PropertyArray",name:"clearInfos",reflectMapper:invertSerializeItem(fh)},{type:"Long",name:"serverTime"}]}};function formatTeamNotificationAttachData(t,i){if(!t)return{};var u=t;return u.tinfo&&(u.tinfo=function formatTeamFromTinfo(t){return deserialize(t,invertSerializeItem(dh))}(u.tinfo),u.tinfo.teamType=i),u.uinfos,void 0!==u.mute&&(u.mute=Gd(u.mute)),u}function generateTeamByTeamId(t,i,u){return void 0===u&&(u={}),Dt({teamId:t,teamType:i,name:"",ownerAccountId:"",memberLimit:0,memberCount:0,createTime:0,updateTime:0,intro:"",announcement:"",avatar:"",joinMode:0,agreeMode:0,inviteMode:0,updateInfoMode:0,updateExtensionMode:0,chatBannedMode:0,isValidTeam:!0,isTeamEffective:!0},u)}function generateMemberByTeamId(t,i,u,m){return void 0===m&&(m={}),Dt({teamId:t,teamType:i,accountId:u,joinTime:0,inTeam:!0,memberRole:0,chatBanned:!1},m)}function processTeamMembers(t,i){return void 0===i&&(i=1),map$6(t).call(t,(function(t){return function processTeamMember(t,i){return void 0===i&&(i=1),t.teamType=i,t.chatBanned=void 0!==t.chatBanned&&t.chatBanned,t}(t,i)}))}function completeMessage(t,i,u){var m,h=Dt(Dt({},i),{conversationId:t.V2NIMConversationIdUtil.messageConversationId(i),isSelf:i.senderId===t.account,sendingState:1,messageStatus:{errorCode:(null===(m=null==i?void 0:i.messageStatus)||void 0===m?void 0:m.errorCode)||200},messageSource:u||0});if(h.threadReply&&(h.threadReply=Dt(Dt({},h.threadReply),{conversationType:h.conversationType,conversationId:h.conversationId})),h.threadRoot&&(h.threadRoot=Dt(Dt({},h.threadRoot),{conversationType:h.conversationType,conversationId:h.conversationId})),h.isInBlackList&&(h.sendingState=2,h.messageStatus.errorCode=zl.V2NIM_ERROR_CODE_ACCOUNT_IN_BLOCK_LIST,delete h.isInBlackList),h.streamConfig){var v=get(h.streamConfig,"isStream");if(!1===v)delete h.streamConfig;else if(!0===v&&void 0===h.streamConfig.status)delete h.streamConfig,i.aiConfig&&(i.aiConfig.aiStream=!0,i.aiConfig.aiStreamStatus=0);else if("number"==typeof h.streamConfig.status)return h.streamConfig={status:h.streamConfig.status},function completeMessageStreamConfig(t){t.streamConfig&&t.aiConfig&&(t.aiConfig.aiStream=!0,t.aiConfig.aiStreamStatus=t.streamConfig.status,t.aiConfig.aiRAGs&&(t.streamConfig.rags=t.aiConfig.aiRAGs));if(t.attachment&&t.streamConfig){var i=t.attachment;t.streamConfig.lastChunk={content:i.msg,messageTime:t.createTime,chunkTime:i.timestamp,type:i.type,index:i.index},t.aiConfig&&(t.aiConfig.aiStreamLastChunk=t.streamConfig.lastChunk),delete t.attachment}t.aiConfig&&void 0===t.aiConfig.accountId&&delete t.aiConfig;return t}(h)}return h.aiConfig&&void 0===h.aiConfig.accountId&&delete h.aiConfig,formatMessageAttachment(h,t)}function formatMessageAttachment(t,i){return 5===t.messageType?function formatNotificationMessage(t,i){var u,m,h,v,M,I=i.attachment||{};if(i.attachment&&"type"in i.attachment)return i;var S=void 0;if(null===(u=I.data)||void 0===u?void 0:u.tinfo){var T=I.id,C=I.data,E=T>400?2:1,A=formatTeamNotificationAttachData(Dt({},C),E).tinfo;S={},A.teamId,S=__rest(A,["teamId"])}var k=Dt(Dt(Dt(Dt({raw:I.raw,type:convertNotificationType(t,I.id)},S?{updatedTeamInfo:S}:{}),{targetIds:(null===(m=I.data)||void 0===m?void 0:m.ids)||((null===(h=I.data)||void 0===h?void 0:h.id)?[I.data.id]:[])}),"string"==typeof(null===(v=I.data)||void 0===v?void 0:v.attach)?{serverExtension:I.data.attach}:{}),"number"==typeof(null===(M=I.data)||void 0===M?void 0:M.mute)?{chatBanned:0!==I.data.mute}:{});return Dt(Dt({},i),{attachment:k})}(i,t):100===t.messageType?function formatCustomMessage(t,i){var u,m,h;if("string"==typeof(null===(u=i.attachment)||void 0===u?void 0:u.raw)&&(null===(h=null===(m=t.V2NIMMessageService)||void 0===m?void 0:m.customAttachmentParsers)||void 0===h?void 0:h.length)>0){var v=i.subType||0,M=t.V2NIMMessageService.customAttachmentParsers,I=i.attachment.raw;some(M).call(M,(function(u){try{var m=u(v,I);if(isPlainObject(m))return m.raw=I,i.attachment=m,!0}catch(i){return t.logger.warn("customAttachmentParser: subType "+v+", raw: "+I+". parse error with "+i),!1}return!1}))}return i}(i,t):t}function completeMessageRefer(t,i){return Dt(Dt({},i),{conversationId:t.V2NIMConversationIdUtil.messageConversationId(i)})}function formatMessageRefer(t,i){var u=i.createTime,m=i.senderId,h=i.receiverId,v=i.conversationType;return{conversationType:v,conversationId:t.V2NIMConversationIdUtil.messageConversationId({conversationType:v,senderId:m,receiverId:h}),senderId:i.senderId,receiverId:i.receiverId,messageServerId:i.messageServerId,createTime:u,messageClientId:i.messageClientId}}function formatRevokeMessage(t,i){var u={7:1,8:2,12:3,13:1,14:2}[i.sysMsgType];return{postscript:i.postscript,revokeType:{7:1,8:2,12:3,13:4,14:5}[i.sysMsgType]||0,revokeAccountId:i.opeAccount||i.senderId,callbackExtension:i.callbackExtension,serverExtension:i.attach||"",messageRefer:{conversationType:u,conversationId:t.V2NIMConversationIdUtil.messageConversationId(Dt(Dt({},i),{conversationType:u,senderId:i.senderId,receiverId:i.receiverId})),senderId:i.senderId,receiverId:i.receiverId,messageServerId:i.messageServerId,createTime:i.deleteMsgCreatetime,messageClientId:i.messageClientId}}}function formatClearHistoryNotification(t,i){return{conversationId:1===i.conversationType?t.V2NIMConversationIdUtil.p2pConversationId(i.receiverId):2===i.conversationType?t.V2NIMConversationIdUtil.teamConversationId(i.teamId):t.V2NIMConversationIdUtil.superTeamConversationId(i.teamId),deleteTime:i.deleteTime,serverExtension:i.serverExtension}}function convertNotificationType(t,i){var u={0:0,401:401,1:1,402:402,2:2,403:403,3:3,404:404,4:4,405:405,5:5,410:410,6:6,406:406,7:7,407:407,8:8,408:408,9:9,411:411,10:10,409:409};return void 0===u[i]&&t.logger.warn("[V2NIMMessageService] undefined notification type: "+i),"number"==typeof u[i]?u[i]:-1}function formatSearchCloudMessageListEx(t,i){var u=[],m={};for(var h in forEach$1(i).call(i,(function(t){var i=t.conversationId;m[i]||(m[i]={conversationId:i,messages:[],count:0}),m[i].messages.push(t),m[i].count++})),m){var v=m[h];u.push(v)}return u}function attachmentToRaw(t,i){if(!i)return"";switch(t){case 100:return i.raw||"";case 1:case 3:case 2:case 6:return function mediaAttachmentToRaw(t){var i=t,u=i.width,m=i.height,h=i.duration;i.path,i.file,i.raw,i.ctx,i.payload,i.bucketName,i.objectName,i.token;var v=i.ext,M=__rest(i,["width","height","duration","path","file","raw","ctx","payload","bucketName","objectName","token","ext"]),I="string"==typeof v&&"."===v[0]?slice(v).call(v,1):v;return Un(Dt(Dt(Dt(Dt(Dt({},M),void 0===v?{}:{ext:I}),void 0===u?{}:{w:u}),void 0===m?{}:{h:m}),void 0===h?{}:{dur:h}))}(i);case 4:return function locationAttachmentToRaw(t){return Un({lat:t.latitude,lng:t.longitude,title:t.address})}(i);case 12:return function callAttachmentToRaw(t){t.raw;var i=__rest(t,["raw"]);try{var u;return Un(Dt(Dt({},i),{durations:map$6(u=t.durations).call(u,(function(t){return{accid:t.accountId,duration:t.duration}}))}))}catch(i){return Un(t)}}(i);default:return i.raw||Un(i)}}function rawToAttachment(t,i){var u;try{switch(u=JSON.parse(t),i){case 100:return{raw:t};case 4:return function locationRawToAttachment(t,i){return{latitude:i.lat,longitude:i.lng,address:i.title,raw:t}}(t,u);case 2:case 3:case 1:case 6:return function mediaRawToAttachment(t,i){var u=i.w,m=i.h,h=i.dur,v=i.ext,M=__rest(i,["w","h","dur","ext"]),I="string"==typeof v&&"."!==v[0]?"."+v:v;return Dt(Dt(Dt(Dt(Dt(Dt({},M),void 0===v?{}:{ext:I}),void 0===u?{}:{width:u}),void 0===m?{}:{height:m}),void 0===h?{}:{duration:h}),{raw:t})}(t,u);case 12:return function callRawToAttachment(t,i){var u;return Dt(Dt({},i),{durations:map$6(u=i.durations).call(u,(function(t){return{accountId:t.accid,duration:t.duration}})),raw:t})}(t,u);default:return"object"==typeof u&&u?Dt(Dt({},u),{raw:t}):{raw:t}}}catch(i){return"object"==typeof u&&u?Dt(Dt({},u),{raw:t}):{raw:t}}}var Mh=function(){function FileUtil(t){this.core=t}var t=FileUtil.prototype;return t.doSendFile=function doSendFile(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v,M,I,S,T;return ud.wrap((function _callee$(C){for(;;)switch(C.prev=C.next){case 0:return u=t.attachment,C.prev=1,C.next=4,this.core.V2NIMStorageService._uploadFile({taskId:t.messageClientId,uploadParams:{fileObj:(null==u?void 0:u.file)||(null==u?void 0:u.path),sceneName:null==u?void 0:u.sceneName}},i,{fileType:t.messageType});case 4:for(S in(h=C.sent)[0],v=h[1],M=Dt(Dt({},u),{uploadState:1}),void 0!==v.w&&(M.width=M.width||v.w),void 0!==v.h&&(M.height=M.height||v.h),void 0!==v.dur&&(M.duration=M.duration||v.dur),M.ext=M.ext&&-1===indexOf(m=M.ext).call(m,".")?"."+M.ext:M.ext,I=["w","h","dur","ext","name"],v)includes(I).call(I,S)||(M[S]=v[S]);M.raw,M.file,M.path,T=__rest(M,["raw","file","path"]),t.attachment=JSON.parse(Un(T)),t.attachment&&(t.attachment.raw=attachmentToRaw(t.messageType,t.attachment)),C.next=23;break;case 19:throw C.prev=19,C.t0=C.catch(1),t.attachment&&(t.attachment.uploadState=2),C.t0;case 23:case"end":return C.stop()}}),_callee,this,[[1,19]])})))},t.cancelMessageAttachmentUpload=function cancelMessageAttachmentUpload(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i;return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:if(validate({messageClientId:{type:"string",allowEmpty:!1}},t,"",!0),includes(i=[2,6,1,3]).call(i,t.messageType)){u.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"cancelMessageAttachmentUpload: messageType "+t.messageType+" incorrect"}});case 3:if(2!==t.sendingState&&1!==t.sendingState){u.next=5;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST,detail:{reason:"cancelMessageAttachmentUpload: message is already failed or succeeded"}});case 5:return u.next=7,this.core.V2NIMStorageService._cancelUploadFile(t.messageClientId);case 7:case"end":return u.stop()}}),_callee2,this)})))},FileUtil}(),Ih="V2NIMMessageService",_h={"30_1":"v2SendP2pMessage","31_2":"v2SendTeamMessage","30_31":"v2MessageP2pModify","31_37":"v2MessageTeamModify","32_38":"v2MessageSuperTeamModify","7_33":"v2MessageOnModified","4_27":"v2MessageSyncModified","4_28":"v2MessageSuperTeamSyncModified","4_5":"v2BatchMarkRead","4_12":"syncP2PMessagReceipts","4_32":"syncP2pMessagReceiptsV2","30_11":"v2SendP2PMessageReceipt","31_28":"v2SendTeamMessageReceipts","32_2":"v2SendSuperTeamMessage","7_12":"onP2PMessageReceipts","8_31":"onTeamMessageReceipts","31_29":"v2GetTeamMessageReceipts","31_30":"v2GetTeamMessageReceiptDetail","30_35":"v2GetP2PMessageReceipts","7_2":"onMsg","8_3":"onMsg","7_101":"onMsg","8_102":"onMsg","21_3":"onMsg","21_102":"onMsg","4_4":"syncOfflineMsgs","4_9":"syncRoamingMsgs","4_17":"syncRoamingMsgs","30_13":"v2RevokeMessage","32_17":"v2RevokeSuperTeamMessage","7_14":"onRevokeMessage","7_15":"syncRevokeMessage","21_18":"onRevokeMessage","21_117":"onRevokeMessage","30_23":"v2DeleteMessage","30_24":"v2DeleteMessages","4_21":"syncOnDeleteMessages","7_123":"onDeleteMessage","7_124":"onDeleteMessages","29_17":"v2DownloadLocalAntiSpamVocabs"};var Sh={conversationType:{id:0,converter:conversationTypeV2ToV1,retConverter:conversationTypeV1ToV2},receiverId:1,senderId:2,fromClientType:{id:4,retType:"number"},fromDeviceId:5,fromNick:6,createTime:{id:7,retType:"number"},messageType:{id:8,retType:"number"},text:9,attachment:{id:10,converter:function converter(t,i){return attachmentToRaw(i.messageType,t)},retConverter:function retConverter(t,i){return rawToAttachment(t,Number(i[8]))}},messageClientId:11,messageServerId:12,resend:{id:13,converter:boolToInt,retType:"boolean"},userUpdateTime:{id:14,retType:"number"},serverExtension:15,pushPayload:{id:16,access:"pushConfig.pushPayload"},pushContent:{id:17,access:"pushConfig.pushContent"},forcePushAccountIds:{id:18,access:"pushConfig.forcePushAccountIds",def:function def(t){if(t["pushConfig.forcePush"])return"#%@all@%#"},converter:function converter(t,i){if(i["pushConfig.forcePush"])return t?Un(t):"#%@all@%#"},retConverter:function retConverter(t){if("#%@all@%#"!==t&&t)try{return JSON.parse(t)}catch(t){return[]}}},forcePushContent:{id:19,access:"pushConfig.forcePushContent"},forcePush:{id:20,access:"pushConfig.forcePush",converter:boolToInt,retType:"boolean"},antispamCustomMessageEnabled:{id:21,def:function def(t){return get(t,"antispamConfig.antispamCustomMessage")?1:void 0},retConverter:function retConverter(){}},antispamCustomMessage:{id:22,access:"antispamConfig.antispamCustomMessage"},antispamBusinessId:{id:23,access:"antispamConfig.antispamBusinessId"},clientAntispamHit:{id:24,access:"clientAntispamHit",converter:boolToInt,retType:"boolean"},antispamEnabled:{id:25,access:"antispamConfig.antispamEnabled",converter:boolToInt,retType:"boolean"},needAck:{id:26,access:"messageConfig.readReceiptEnabled",converter:boolToInt,retType:"boolean"},lastMessageUpdateEnabled:{id:28,access:"messageConfig.lastMessageUpdateEnabled",converter:boolToInt,retType:"boolean"},threadReplySenderId:{id:29,access:"threadReply.senderId"},threadReplyReceiverId:{id:30,access:"threadReply.receiverId"},threadReplyTime:{id:31,access:"threadReply.createTime",retType:"number"},threadReplyServerId:{id:32,access:"threadReply.messageServerId"},threadReplyClientId:{id:33,access:"threadReply.messageClientId"},threadRootSenderId:{id:34,access:"threadRoot.senderId"},threadRootReceiverId:{id:35,access:"threadRoot.receiverId"},threadRootTime:{id:36,access:"threadRoot.createTime",retType:"number"},threadRootServerId:{id:37,access:"threadRoot.messageServerId"},threadRootClientId:{id:38,access:"threadRoot.messageClientId"},isDeleted:{id:39,converter:boolToInt,retType:"boolean"},callbackExtension:40,subType:{id:41,retType:"number"},antispamCheating:{id:42,access:"antispamConfig.antispamCheating"},routeEnvironment:{id:43,access:"routeConfig.routeEnvironment"},antispamExtension:{id:44,access:"antispamConfig.antispamExtension"},antispamResult:45,__clientExt:{id:46,converter:objectToJSONString,retConverter:stringToJSONObject},robotFunction:{id:47,access:"robotConfig.function"},robotTopic:{id:48,access:"robotConfig.topic"},robotCustomContent:{id:49,access:"robotConfig.customContent"},robotAccount:{id:50,access:"robotConfig.accountId"},_conversationOnlineSyncNotify:{id:51},_conversationOnlineSyncData:{id:52},aiAgentMsgDirection:{id:55,access:"aiConfig.aiStatus",retAccess:"aiConfig.aiStatus",retType:"number"},aiAgentAccount:{id:56,access:"aiConfig.accountId",retAccess:"aiConfig.accountId"},aiAgentContent:{id:57,access:"aiConfig.content",converter:objectToJSONString,retConverter:emptyFunc},aiAgentMessages:{id:58,access:"aiConfig.messages",converter:objectToJSONString,retConverter:emptyFunc},aiAgentPromptVariables:{id:59,access:"aiConfig.promptVariables",retConverter:emptyFunc},aiAgentModelConfigParams:{id:60,access:"aiConfig.modelConfigParams",converter:objectToJSONString,retConverter:emptyFunc},errorCode:{id:61,access:"messageStatus.errorCode",converter:emptyFunc,retType:"number"},modifyTime:{id:62,retType:"number"},modifyAccountId:63,aiStream:{id:65,access:"aiConfig.aiStream",retAccess:"streamConfig.isStream",converter:boolToInt,retConverter:intToBool},aiRAGs:{id:66,access:"aiConfig.aiRAGs",retConverter:function aiAgentStreamAIRAGsRetConverter$1(t){try{var i=JSON.parse(t);return i&&i.length>0?map$6(i).call(i,(function(t){return t.desc&&(t.description=t.desc,delete t.desc),t})):[]}catch(t){return[]}}},aiStreamStatus:{id:67,access:"streamConfig.status",retType:"number"},historyEnabled:{id:100,access:"messageConfig.historyEnabled",converter:boolToInt,retType:"boolean"},roamingEnabled:{id:101,access:"messageConfig.roamingEnabled",converter:boolToInt,retType:"boolean"},onlineSyncEnabled:{id:102,access:"messageConfig.onlineSyncEnabled",converter:boolToInt,retType:"boolean"},routeEnabled:{id:105,access:"routeConfig.routeEnabled",converter:boolToInt,retType:"boolean"},isInBlackList:{id:106,access:"isInBlackList",converter:boolToInt,retType:"boolean"},pushEnable:{id:107,access:"pushConfig.pushEnabled",converter:boolToInt,retType:"boolean"},offlineEnabled:{id:108,access:"messageConfig.offlineEnabled",converter:boolToInt,retType:"boolean"},unreadEnabled:{id:109,access:"messageConfig.unreadEnabled",converter:boolToInt,retType:"boolean"},pushNickEnabled:{id:110,access:"pushConfig.pushNickEnabled",converter:boolToInt,retType:"boolean"},msgAckSnapshot:{id:112,retType:"number"},receiverIds:{id:154,access:"targetConfig.receiverIds",converter:objectToJSONString,retConverter:function retConverter(){}},inclusive:{id:155,access:"targetConfig.inclusive",converter:function converter(t){return t?1:2},retConverter:function retConverter(){}},newMemberVisible:{id:156,access:"targetConfig.newMemberVisible",converter:function converter(t){return t?1:2},retConverter:function retConverter(){}},actionTime:{id:163,retType:"number"}},Th=invertSerializeItem(Sh),Ch={conversationType:{id:1,access:"messageRefer.conversationType",retType:"number"},senderId:{id:2,access:"messageRefer.senderId"},receiverId:{id:3,access:"messageRefer.receiverId"},messageServerId:{id:4,access:"messageRefer.messageServerId"},messageClientId:{id:5,access:"messageRefer.messageClientId"},createTime:{id:6,access:"messageRefer.createTime",retType:"number"},deleteTime:{id:7,retType:"number"},serverExtension:8};invertSerializeItem(Ch);var bh={version:1,md5:2,nosurl:3,thesaurus:4},Eh={createTime:{id:0,retType:"number"},sysMsgType:1,receiverId:2,senderId:3,postscript:4,attach:5,pushContent:8,pushPayload:9,messageClientId:10,messageServerId:11,deleteMsgCreatetime:{id:14,retType:"number"},opeAccount:16,env:21,callbackExtension:22},Ah={receiverId:0,messageServerId:1,readCount:{id:100,retType:"number"},unreadCount:{id:101,retType:"number"},messageClientId:102,latestReadAccount:103},kh={v2BatchMarkRead:{sid:4,cid:5,service:Ih,hasPacketResponse:!1,params:[{type:"Byte",name:"sid"},{type:"Byte",name:"cid"},{type:"LongArray",name:"ids"}]},v2SendP2pMessage:{sid:30,cid:1,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},onMsg:{sid:7,cid:2,service:Ih,response:[{type:"Property",name:"msg",reflectMapper:invertSerializeItem(Sh)}]},syncOfflineMsgs:{sid:4,cid:4,service:Ih,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Sh)}]},syncRoamingMsgs:{sid:4,cid:9,service:Ih,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Sh)}]},v2SendP2PMessageReceipt:{sid:30,cid:11,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem({actionTime:{id:163,retType:"number"}})}]},v2RevokeMessage:{sid:30,cid:13,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Eh}]},v2DeleteMessage:{sid:30,cid:23,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Ch}],response:[{type:"Long",name:"timetag"}]},v2DeleteMessages:{sid:30,cid:24,service:Ih,params:[{type:"PropertyArray",name:"tag",reflectMapper:Ch}],response:[{type:"Long",name:"timetag"}]},v2SendTeamMessage:{sid:31,cid:2,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2SendTeamMessageReceipts:{sid:31,cid:28,service:Ih,params:[{type:"PropertyArray",name:"tag",reflectMapper:Ah}],response:[{type:"PropertyArray",name:"tag",reflectMapper:invertSerializeItem(Ah)}]},v2SendSuperTeamMessage:{sid:32,cid:2,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2RevokeSuperTeamMessage:{sid:32,cid:17,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Eh}]},syncP2PMessagReceipts:{sid:4,cid:12,service:Ih,response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Sh)}]},syncP2pMessagReceiptsV2:{sid:4,cid:32,service:Ih,response:[{type:"Property",name:"ctx",reflectMapper:invertSerializeItem({minTimetag:{id:1,retType:"number"},maxTimetag:{id:2,retType:"number"}})},{type:"PropertyArray",name:"contents",reflectMapper:invertSerializeItem({id:1,msgTime:{id:2,retType:"number"}})}]},onP2PMessageReceipts:{sid:7,cid:12,service:Ih,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2GetTeamMessageReceipts:{sid:31,cid:29,service:Ih,params:[{type:"PropertyArray",name:"tag",reflectMapper:Ah}],response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Ah)}]},v2GetTeamMessageReceiptDetail:{sid:31,cid:30,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Ah,select:["receiverId","messageServerId"]}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ah)},{type:"StrArray",name:"readAccountList"},{type:"StrArray",name:"unreadAccountList"}]},onTeamMessageReceipts:{sid:8,cid:31,service:Ih,response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Ah)}]},onRevokeMessage:{sid:7,cid:14,service:Ih,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Eh)}]},syncRevokeMessage:{sid:7,cid:15,service:Ih,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Eh)}]},syncOnDeleteMessages:{sid:4,cid:21,service:Ih,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Ch)}]},onDeleteMessage:{sid:7,cid:123,service:Ih,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ch)}]},onDeleteMessages:{sid:7,cid:124,service:Ih,response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Ch)}]},v2DownloadLocalAntiSpamVocabs:{sid:29,cid:17,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:bh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(bh)}]},v2MessageP2pModify:{sid:30,cid:31,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2MessageTeamModify:{sid:31,cid:37,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2MessageSuperTeamModify:{sid:32,cid:38,service:Ih,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2MessageOnModified:{sid:7,cid:33,service:Ih,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2MessageSyncModified:{sid:4,cid:27,service:Ih,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Sh)},{type:"Long",name:"time"}]},v2MessageSuperTeamSyncModified:{sid:4,cid:28,service:Ih,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Sh)},{type:"Long",name:"time"}]},v2GetP2PMessageReceipts:{sid:30,cid:35,service:Ih,params:[{type:"PropertyArray",name:"tags",reflectMapper:{type:1,id:2}}],response:[{type:"Long",name:"actionTime"},{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem({type:1,id:2,msgTime:3})}]}};function conversationTypeV2ToV1(t){return 1===t?0:2===t?1:3===t?5:void 0}function conversationTypeV1ToV2(t){var i=Gd(t);return 0===i?1:1===i?2:5===i?3:0}var Rh="V2NIMNotificationService",wh={"30_7":"v2SendCustomNotification","32_16":"v2SendCustomNotificationWithSuperTeam","7_3":"onSysNotification","21_19":"onSysNotification","4_6":"v2SyncOfflineSysNotifications","4_18":"v2SyncOfflineSysNotifications","7_14":"v2NotificationRevoke","21_18":"v2NotificationRevoke","21_117":"v2NotificationRevoke","4_19":"v2NotificationSyncRevoke","7_15":"v2NotificationSyncRevoke","4_16":"syncBroadcastMsg","7_17":"onBroadcastMsg"},Nh={timestamp:{id:0,retType:"number"},type:{id:1,retType:"number"},receiverId:2,senderId:3,postscript:4,content:5,idServer:6,offlineEnabled:{id:7,converter:boolToInt,retConverter:function retConverter(t,i){return"0"!==i[6]&&!!Gd(t)},access:"notificationConfig.offlineEnabled"},pushContent:{id:8,access:"pushConfig.pushContent"},pushPayload:{id:9,access:"pushConfig.pushPayload"},deletedIdClient:10,deletedIdServer:11,antispamEnabled:{id:12,converter:boolToInt,retType:"boolean",access:"antispamConfig.antispamEnabled"},antispamCustomNotification:{id:13,access:"antispamConfig.antispamCustomNotification"},deletedMsgCreateTime:14,deletedMsgFromNick:15,opeAccount:16,forcePushAccountIds:{id:18,access:"pushConfig.forcePushAccountIds",def:function def(t){if(101===t.type&&t["pushConfig.forcePush"])return"#%@all@%#"},converter:function converter(t,i){if(i["pushConfig.forcePush"])return t?Un(t):"#%@all@%#"},retConverter:function retConverter(t){if("#%@all@%#"!==t&&t)try{return JSON.parse(t)}catch(t){return[]}}},forcePushContent:{id:19,access:"pushConfig.forcePushContent"},forcePush:{id:20,converter:boolToInt,retType:"boolean",access:"pushConfig.forcePush"},routeEnvironment:{id:21,access:"routeConfig.routeEnvironment"},callbackExt:22,clientNotificationId:{id:23,access:"notificationConfig.clientNotificationId"},conversationOnlineSyncNotify:24,conversationOnlineSyncData:25,routeEnabled:{id:105,converter:boolToInt,retType:"boolean",access:"routeConfig.routeEnabled"},pushEnabled:{id:107,converter:boolToInt,retType:"boolean",access:"pushConfig.pushEnabled"},unreadEnabled:{id:109,converter:boolToInt,retType:"boolean",access:"notificationConfig.unreadEnabled"},pushNickEnabled:{id:110,converter:boolToInt,retType:"boolean",access:"pushConfig.pushNickEnabled"}},xh={id:1,senderId:2,timestamp:{id:4,retType:"number"},content:5},Oh={v2SendCustomNotification:{sid:30,cid:7,service:Rh,params:[{type:"Property",name:"tag",reflectMapper:Nh}]},v2SendCustomNotificationWithSuperTeam:{sid:32,cid:16,service:Rh,params:[{type:"Property",name:"tag",reflectMapper:Nh}]},onSysNotification:{sid:7,cid:3,service:Rh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Nh)}]},syncBroadcastMsg:{sid:4,cid:16,service:Rh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(xh)}]},onBroadcastMsg:{sid:7,cid:17,service:Rh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(xh)}]},v2SyncOfflineSysNotifications:{sid:4,cid:9,service:Rh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Nh)}]},v2NotificationRevoke:{sid:7,cid:14,service:Rh,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Nh)}]},v2NotificationSyncRevoke:{sid:7,cid:15,service:Rh,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Nh)},{type:"Long",name:"timetag"},{type:"Byte",name:"type"}]}},Ph="YSFService",Lh={"4_5":"ysfBatchMarkRead","101_1":"ysfSendMessage","101_2":"ysfOnMsg","4_100":"ysfSyncOfflineMsgs","101_3":"ysfOnSysNotification","101_7":"ysfSendCustomNotification","4_101":"ysfSyncSysNotification"},Vh={ysfBatchMarkRead:{sid:4,cid:5,service:Ph,hasPacketResponse:!1,params:[{type:"Byte",name:"sid"},{type:"Byte",name:"cid"},{type:"LongArray",name:"ids"}]},ysfSendMessage:{sid:101,cid:1,service:Ph,params:[{type:"Property",name:"tag",reflectMapper:Sh}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},ysfOnMsg:{sid:101,cid:2,service:Ph,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Sh)}]},ysfSyncOfflineMsgs:{sid:4,cid:100,service:Ph,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Sh)}]},ysfOnSysNotification:{sid:101,cid:3,service:Ph,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Nh)}]},ysfSendCustomNotification:{sid:101,cid:7,service:Ph,params:[{type:"Property",name:"tag",reflectMapper:Nh}]},ysfSyncSysNotification:{sid:4,cid:101,service:Ph,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Nh)}]}},Uh={content:{type:"string",allowEmpty:!1},params:{type:"object",required:!1,rules:{notificationConfig:{type:"object",required:!1,rules:{offlineEnabled:{type:"boolean",required:!1},unreadEnabled:{type:"boolean",required:!1}}},pushConfig:{type:"object",required:!1,rules:{pushEnabled:{type:"boolean",required:!1},pushNickEnabled:{type:"boolean",required:!1},pushContent:{type:"string",required:!1},pushPayload:{type:"string",required:!1},forcePush:{type:"boolean",required:!1},forcePushContent:{type:"string",required:!1},forcePushAccountIds:{type:"array",required:!1,itemType:"string"}}},antispamConfig:{type:"object",required:!1,rules:{antispamEnabled:{type:"boolean",required:!1},antispamCustomNotification:{type:"string",required:!1}}},routeConfig:{type:"object",required:!1,rules:{routeEnabled:{type:"boolean",required:!1},routeEnvironment:{type:"string",required:!1}}}}}},Dh=function(){function NotificationUtil(t){this.core=t}return NotificationUtil.prototype.generateNotificationTag=function generateNotificationTag(t,i,u){var m;void 0===u&&(u={});var h=this.core.V2NIMConversationIdUtil.parseConversationType(t),v=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t),M=to(),I=((m={})[1]=100,m[2]=101,m[3]=103,m);return Dt(Dt({},u),{notificationConfig:Dt({unreadEnabled:!0,offlineEnabled:!0},null==u?void 0:u.notificationConfig),pushConfig:Dt({pushEnabled:!0,pushNickEnabled:!0},null==u?void 0:u.pushConfig),antispamConfig:Dt({antispamEnabled:!0},null==u?void 0:u.antispamConfig),routeConfig:Dt({routeEnabled:!0},null==u?void 0:u.routeConfig),timestamp:M,type:I[h],receiverId:v,content:i})},NotificationUtil}();function getFileOrPath(t){var i="object"==typeof t?t:void 0,u="string"==typeof t?t:void 0;if(!i&&!u)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"getFileOrPath::incorrect file and path"}});if("string"==typeof u)if(0===indexOf(u).call(u,"nim-external")){var m=document.getElementById(u);if(!(m&&m.files&&m.files[0]))throw new Yl({code:zl.V2NIM_ERROR_CODE_FILE_NOT_FOUND,detail:{reason:"getFileOrPath::file not exist: "+u}});i=m.files[0]}else if("BROWSER"===pd.platform)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"getFileOrPath::incorrect path: "+u}});if("object"==typeof i&&void 0===i.size)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"getFileOrPath::file no size"}});return{file:i,path:u}}var Bh,qh,Fh={attachment:{type:"object",rules:{url:{type:"string",allowEmpty:!1}}},thumbSize:{type:"object",rules:{width:{type:"number",required:!1,min:0},height:{type:"number",required:!1,min:0}}}},Gh=function(t){function V2NIMStorageUtil(i){var u;return(u=t.call(this,"V2NIMStorageUtil",i)||this).core=i,u}Nt(V2NIMStorageUtil,t);var i=V2NIMStorageUtil.prototype;return i.imageThumbUrl=function imageThumbUrl(t,i){return t+"?imageView&thumbnail="+i+"z"+i},i.videoCoverUrl=function videoCoverUrl(t,i){return t+"?vframe&offset="+i},i.getImageThumbUrl=function getImageThumbUrl(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m;return ud.wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validate(Fh,{attachment:u=t,thumbSize:i},"",!0),i.width=i.width||0,i.height=i.height||0,0===i.width&&0===i.height&&(i.width=150),m=u.url,h.prev=7,h.next=10,this.core.V2NIMStorageService.shortUrlToLong(u.url);case 10:m=h.sent,h.next=16;break;case 13:h.prev=13,h.t0=h.catch(7),this.core.logger.warn("shortUrlToLong error:",h.t0);case 16:return h.abrupt("return",{url:this.core.cloudStorage.getThumbUrl(m,i)});case 17:case"end":return h.stop()}}),_callee,this,[[7,13]])})))},i.getVideoCoverUrl=function getVideoCoverUrl(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u,m;return ud.wrap((function _callee2$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validate(Fh,{attachment:u=t,thumbSize:i},"",!0),i.width=i.width||0,i.height=i.height||0,0===i.width&&0===i.height&&(i.width=150),m=u.url,h.prev=7,h.next=10,this.core.V2NIMStorageService.shortUrlToLong(u.url);case 10:m=h.sent,h.next=16;break;case 13:h.prev=13,h.t0=h.catch(7),this.core.logger.warn("shortUrlToLong error:",h.t0);case 16:return h.abrupt("return",{url:this.core.cloudStorage.getVideoCoverUrl(m,i)});case 17:case"end":return h.stop()}}),_callee2,this,[[7,13]])})))},V2NIMStorageUtil}(hp),Hh={file:{md5:"$(Etag)",size:"$(ObjectSize)"},image:{md5:"$(Etag)",size:"$(ObjectSize)",w:"$(ImageInfo.Width)",h:"$(ImageInfo.Height)",orientation:"$(ImageInfo.Orientation)"},audio:{md5:"$(Etag)",size:"$(ObjectSize)",dur:"$(AVinfo.Audio.Duration)"},video:{md5:"$(Etag)",size:"$(ObjectSize)",dur:"$(AVinfo.Video.Duration)",w:"$(AVinfo.Video.Width)",h:"$(AVinfo.Video.Height)"}},jh={accessKeyId:"",secretAccessKey:"",sessionToken:"",region:"",maxRetries:0,bucket:"",objectName:"",token:"",shortUrl:""};function getUploadResponseFormat(t){return void 0===t&&(t="file"),Un(Hh[t]||{}).replace(/"/gi,'\\"')}!function(t){t[t.nos=1]="nos",t[t.s3=2]="s3"}(Bh||(Bh={})),function(t){t[t.dontNeed=-1]="dontNeed",t[t.time=2]="time",t[t.urls=3]="urls"}(qh||(qh={}));var $h={chunkUploadHost:"https://wannos-web.127.net",chunkUploadHostBackupList:["https://fileup.chatnos.com","https://oss.chatnos.com"],commonUploadHost:"https://fileup.chatnos.com",commonUploadHostBackupList:["https://upload.chatnos.com","https://oss.chatnos.com"],chunkMaxSize:4194304e4,commonMaxSize:104857600,uploadReplaceFormat:"https://{host}/{object}",cdn:{defaultCdnDomain:"nim-nosdn.netease.im",cdnDomain:"",bucket:"nim",objectNamePrefix:""},downloadUrl:"https://{bucket}-nosdn.netease.im/{object}",downloadHostList:["nos.netease.com"],nosCdnEnable:!0,isNeedToGetUploadPolicyFromServer:!0};function pickBy(t,i){t=t||{},i=i||function(){return!0};var u={};for(var m in t)i(t[m])&&(u[m]=t[m]);return u}var zh=function(){function NOS(t,i){this.nosCdnHostTimer=0,this.nosErrorCount=0,this.core=t,this.cloudStorage=i}var t=NOS.prototype;return t.reset=function reset(){this.nosErrorCount=0},t.getNosAccessToken=function getNosAccessToken(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m;return ud.wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.core.sendCmd("getNosAccessToken",{tag:t});case 2:return i=h.sent,u=get(i,"content.nosAccessTokenTag.token"),m=t.url,h.abrupt("return",{token:u,url:-1!==indexOf(m).call(m,"?")?m+"&token="+u:m+"?token="+u});case 6:case"end":return h.stop()}}),_callee,this)})))},t.deleteNosAccessToken=function deleteNosAccessToken(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.core.sendCmd("deleteNosAccessToken",{tag:t});case 2:case"end":return i.stop()}}),_callee2,this)})))},t.nosUpload=function nosUpload(t,i,u){var m,h,v,M,I,S,T,C,E,A;return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var k,R,w,N,x,O,P,L,V,U,D,B,q,G,H,j,$,z,W,K,Y,Q;return ud.wrap((function _callee3$(J){for(;;)switch(J.prev=J.next){case 0:if(k=get(this.core,"config.cdn.bucket"),R={tag:t.nosScenes||k||"nim"},t.nosSurvivalTime&&(R.expireSec=t.nosSurvivalTime),(w=this.core.adapters.getFileUploadInformation(t))&&w.complete&&i.destroy(),!(!u&&!w)){J.next=20;break}return J.prev=7,J.next=10,this.core.sendCmd("getNosToken",{responseBody:getUploadResponseFormat(t.type),nosToken:R});case 10:N=J.sent,J.next=20;break;case 13:if(J.prev=13,J.t0=J.catch(7),this.core.logger.error("uploadFile:: getNosToken error",J.t0),i.destroy(),!(J.t0 instanceof Yl)){J.next=19;break}throw J.t0;case 19:throw new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:400,detail:{reason:"getNosToken error",rawError:J.t0,curProvider:1}});case 20:return x=this.config.uploadReplaceFormat.replace("{bucket}",this.config.cdn.bucket).replace("{host}",this.config.cdn.cdnDomain||this.config.cdn.defaultCdnDomain).replace("{object}",w?null===(m=w.uploadInfo)||void 0===m?void 0:m.objectName:u?null==u?void 0:u.objectName:N.content.nosToken.objectName),O="",u&&u.shortUrl&&(O=u.shortUrl),(null===(M=null===(v=null===(h=null==w?void 0:w.uploadInfo)||void 0===h?void 0:h.payload)||void 0===v?void 0:v.mixStoreToken)||void 0===M?void 0:M.shortUrl)&&(O=w.uploadInfo.payload.mixStoreToken.shortUrl),P=O||x,J.prev=25,V=w?{token:null===(I=null==w?void 0:w.uploadInfo)||void 0===I?void 0:I.token,bucket:null===(S=null==w?void 0:w.uploadInfo)||void 0===S?void 0:S.bucketName,objectName:null===(T=null==w?void 0:w.uploadInfo)||void 0===T?void 0:T.objectName}:u||N.content.nosToken,this.core.logger.log("uploadFile:: uploadFile params",{nosToken:V,chunkUploadHost:this.config.chunkUploadHost,chunkUploadHostBackupList:this.config.chunkUploadHostBackupList,commonUploadHost:this.config.commonUploadHost,commonUploadHostBackupList:this.config.commonUploadHostBackupList,platform:pd.platform}),U="BROWSER"===pd.platform?this.config.chunkUploadHost:this.config.commonUploadHost+"/"+(V&&V.bucket),D="UNIAPP"===pd.platform||"MINIAPP"===(null===(C=pd.getSystemInfo())||void 0===C?void 0:C.libEnv)?4:u?2:0,B=t.filePath?t.filePath:"object"==typeof t.file?t.file.name:"",i.update({remote_addr:U,operation_type:D}),B&&i.update({local_file:B}),J.next=35,this.core.adapters.uploadFile(Dt(Dt(Dt(Dt({},t),{nosToken:V,chunkUploadHost:this.config.chunkUploadHost,chunkUploadHostBackupList:this.config.chunkUploadHostBackupList,commonUploadHost:this.config.commonUploadHost,commonUploadHostBackupList:this.config.commonUploadHostBackupList,maxSize:t.maxSize||this.config.chunkMaxSize}),u?{payload:{mixStoreToken:u}}:{}),{onUploadInfo:function onUploadInfo(t){i.update(Dt({},t))}}),i);case 35:L=J.sent,J.next=70;break;case 38:if(J.prev=38,J.t1=J.catch(25),this.core.logger.error("uploadFile::nos uploadFile error:",J.t1),q="v2"===get(this.core,"options.apiVersion"),J.t1.code!==zl.V2NIM_ERROR_CODE_CANCELLED&&10499!==J.t1.errCode){J.next=44;break}throw new Zl({code:q?zl.V2NIM_ERROR_CODE_CANCELLED:400,detail:{reason:get(J.t1,"message")||"Request abort",rawError:J.t1,curProvider:1}});case 44:if(!q||J.t1.errCode!==zl.V2NIM_ERROR_CODE_FILE_OPEN_FAILED){J.next=46;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_FILE_OPEN_FAILED,detail:{reason:get(J.t1,"message")||"Read file failed",rawError:J.t1,curProvider:1}});case 46:return J.next=48,pd.net.getNetworkStatus();case 48:if(G=J.sent,!1!==G.net_connect){J.next=52;break}throw new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:400,detail:{reason:"No network",rawError:J.t1,curProvider:1}});case 52:if(!u){J.next=69;break}if(!(this.nosErrorCount<=0)){J.next=65;break}J.prev=54,this.cloudStorage.mixStorage._addCircuitTimer(),J.next=61;break;case 58:throw J.prev=58,J.t2=J.catch(54),new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:400,detail:{reason:"All upload attempts failed",rawError:J.t2,curProvider:this.cloudStorage.mixStorage.curProvider,mixStorePolicy:this.cloudStorage.mixStorage.mixStorePolicy,file:t.file||t.filePath}});case 61:return this.nosErrorCount=get(this.cloudStorage,"mixStorePolicy.nosPolicy.uploadConfig.retryPolicy.retry"),J.abrupt("return",this.cloudStorage._uploadFile(t,i));case 65:return this.nosErrorCount--,J.abrupt("return",this.nosUpload(t,i,u));case 67:J.next=70;break;case 69:throw new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:400,detail:{reason:"NOS attempts failed",rawError:J.t1,curProvider:1}});case 70:if(H=null==L?void 0:L.type,(j=H&&indexOf(H).call(H,"/")>-1?slice(H).call(H,0,indexOf(H).call(H,"/")):"")||(j=t.type||""),($={image:"imageInfo",video:"vinfo",audio:"vinfo"})[j]){J.next=78;break}return J.abrupt("return",Dt({url:P},L));case 78:if(!(L.w&&L.h||L.dur)){J.next=80;break}return J.abrupt("return",Dt({url:P},L));case 80:return J.prev=80,J.next=83,this.core.adapters.request(x+"?"+$[j],{method:"GET",dataType:"json",timeout:5e3},{exception_service:3});case 83:z=J.sent,J.next=92;break;case 86:return J.prev=86,J.t3=J.catch(80),W=J.t3,i.update({exception:"Fetch media info failed;url:"+x+"?"+$[j]+";errMsg:"+((null===(E=W.detail)||void 0===E?void 0:E.reason)||W.message),external_code:W.code}),this.core.logger.error("uploadFile:: fetch file info error",J.t3),J.abrupt("return",Dt({url:P},L));case 92:if(!z){J.next=99;break}return K=z.data,Y="imageInfo"===$[j]?K:null===(A=null==K?void 0:K.GetVideoInfo)||void 0===A?void 0:A.VideoInfo,Q={url:P,name:L.name,size:L.size,ext:L.ext,w:null==Y?void 0:Y.Width,h:null==Y?void 0:Y.Height,orientation:null==Y?void 0:Y.Orientation,dur:null==Y?void 0:Y.Duration,audioCodec:null==Y?void 0:Y.AudioCodec,videoCodec:null==Y?void 0:Y.VideoCodec,container:null==Y?void 0:Y.Container},J.abrupt("return",pickBy(Q,(function(t){return void 0!==t})));case 99:return J.abrupt("return",Dt({url:P},L));case 100:case"end":return J.stop()}}),_callee3,this,[[7,13],[25,38],[54,58],[80,86]])})))},t._getNosCdnHost=function _getNosCdnHost(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m,h=this;return ud.wrap((function _callee4$(v){for(;;)switch(v.prev=v.next){case 0:return v.prev=0,v.next=3,this.core.sendCmd("getNosCdnHost");case 3:i=v.sent,v.next=10;break;case 6:return v.prev=6,v.t0=v.catch(0),this.core.logger.error("getNosCdnHost::error",v.t0),v.abrupt("return");case 10:if(i){v.next=12;break}return v.abrupt("return");case 12:u=null===(t=null==i?void 0:i.content)||void 0===t?void 0:t.nosConfigTag,0!==(m=Gd(null==u?void 0:u.expire))&&u.cdnDomain?-1===m?(this.config.cdn.bucket=u.bucket,this.config.cdn.cdnDomain=u.cdnDomain,this.config.cdn.objectNamePrefix=u.objectNamePrefix):(this.config.cdn.bucket=u.bucket,this.config.cdn.cdnDomain=u.cdnDomain,this.config.cdn.objectNamePrefix=u.objectNamePrefix,this.nosCdnHostTimer=this.core.timerManager.addTimer((function(){h._getNosCdnHost()}),1e3*m)):(this.config.cdn.bucket="",this.config.cdn.cdnDomain="",this.config.cdn.objectNamePrefix="");case 15:case"end":return v.stop()}}),_callee4,this,[[0,6]])})))},Qe(NOS,[{key:"config",get:function get(){return this.cloudStorage.config}}]),NOS}(),Wh={"6_2":"getNosToken","6_22":"getOriginUrl","6_24":"getNosAccessToken","6_25":"deleteNosAccessToken","6_26":"getNosCdnHost","6_27":"getGrayscaleConfig","6_28":"getMixStorePolicy","6_29":"getMixStoreToken","6_30":"getFileAuthToken"},Kh={nosToken:{objectName:1,token:2,bucket:3,expireTime:4,expireSec:7,tag:8,shortUrl:9},mixStoreTokenReqTag:{provider:0,tokenCount:1,nosSurvivalTime:2,tag:3,returnBody:4,policyVersion:5},nosConfigTag:{bucket:1,cdnDomain:2,expire:3,objectNamePrefix:4},grayConfigTag:{config:0,ttl:1},mixStorePolicyTag:{providers:0,ttl:1,mixEnable:2,nosPolicy:3,s3Policy:4,policyVersion:5},mixStoreTokenResTag:{provider:0,accessKeyId:1,secretAccessKey:2,sessionToken:3,token:4,expireTime:5,bucket:6,objectName:7,fileExpireSec:8,tag:9,shortUrl:10,region:11},nosSafeUrlTag:{safeUrl:0,originUrl:1},mixStoreAuthTokenReqTag:{type:1,urls:2},mixStoreAuthTokenResTag:{type:1,tokens:2,token:3,ttl:4},nosAccessTokenTag:{token:0,url:1,userAgent:2,ext:3}},Yh={getNosToken:{sid:6,cid:2,service:"cloudStorage",params:[{type:"String",name:"responseBody"},{type:"Property",name:"nosToken",entity:"nosToken",reflectMapper:Kh.nosToken}],response:[{type:"Property",name:"nosToken",reflectMapper:invertSerializeItem(Kh.nosToken)}]},getOriginUrl:{sid:6,cid:22,service:"cloudStorage",params:[{type:"Property",name:"nosSafeUrlTag",reflectMapper:Kh.nosSafeUrlTag}],response:[{type:"Property",name:"nosSafeUrlTag",reflectMapper:invertSerializeItem(Kh.nosSafeUrlTag)}]},getNosCdnHost:{sid:6,cid:26,service:"cloudStorage",response:[{type:"Property",name:"nosConfigTag",reflectMapper:invertSerializeItem(Kh.nosConfigTag)}]},getGrayscaleConfig:{sid:6,cid:27,service:"cloudStorage",params:[{type:"Property",name:"config"}],response:[{type:"Property",name:"grayConfigTag",reflectMapper:invertSerializeItem(Kh.grayConfigTag)}]},getMixStorePolicy:{sid:6,cid:28,service:"cloudStorage",params:[{type:"LongArray",name:"supportType"}],response:[{type:"Property",name:"mixStorePolicyTag",reflectMapper:invertSerializeItem(Kh.mixStorePolicyTag)}]},getMixStoreToken:{sid:6,cid:29,service:"cloudStorage",params:[{type:"Property",name:"mixStoreTokenReqTag",reflectMapper:Kh.mixStoreTokenReqTag}],response:[{type:"Property",name:"mixStoreTokenResTag",reflectMapper:invertSerializeItem(Kh.mixStoreTokenResTag)}]},getFileAuthToken:{sid:6,cid:30,service:"cloudStorage",params:[{type:"Property",name:"mixStoreAuthTokenReqTag",reflectMapper:Kh.mixStoreAuthTokenReqTag}],response:[{type:"Property",name:"mixStoreAuthTokenResTag",reflectMapper:invertSerializeItem(Kh.mixStoreAuthTokenResTag)}]},getNosAccessToken:{sid:6,cid:24,service:"cloudStorage",params:[{type:"Property",name:"tag",reflectMapper:Kh.nosAccessTokenTag}],response:[{type:"Property",name:"tag",reflectMapper:invertSerializeItem(Kh.nosAccessTokenTag)}]},deleteNosAccessToken:{sid:6,cid:25,service:"cloudStorage",params:[{type:"Property",name:"tag",reflectMapper:Kh.nosAccessTokenTag}]}},Qh=function(){function MixStorage(t,i){this.GRAYKEY="AllGrayscaleConfig",this.MIXSTOREKEY="AllMixStorePolicy",this.grayConfig={mixStoreEnable:!1,timeStamp:0,ttl:0},this.mixStorePolicy={providers:[],timeStamp:0,ttl:0,s3Policy:null,nosPolicy:null,policyVersion:void 0},this.curProvider=1,this.mixStoreErrorCount=10,this.circuitTimer=0,this.core=t,this.cloudStorage=i,this.logger=t.logger}var t=MixStorage.prototype;return t.reset=function reset(){this.grayConfig=null,this.mixStorePolicy={providers:[],timeStamp:0,ttl:0,s3Policy:null,nosPolicy:null,policyVersion:void 0},this.curProvider=1,this.mixStoreErrorCount=10},t.getGrayscaleConfig=function getGrayscaleConfig(t,i){var u;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var m,h;return ud.wrap((function _callee$(v){for(;;)switch(v.prev=v.next){case 0:if(pd.localStorage)try{pd.localStorage.getItem&&pd.localStorage.getItem(this.GRAYKEY)&&(this.grayConfig=JSON.parse(pd.localStorage.getItem(this.GRAYKEY))[t])}catch(t){pd.localStorage.getItem(this.GRAYKEY)&&this.core.logger.error("uploadFile:: JSON.parse grayscaleConfig error ",t)}if(this.grayConfig&&!(this.grayConfig.timeStamp+1e3*this.grayConfig.ttl<i)){v.next=17;break}return v.next=4,this.core.sendCmd("getGrayscaleConfig",{config:{}});case 4:if(!(m=v.sent).content||!m.content.grayConfigTag){v.next=16;break}this.logger.log("uploadFile::getAppGrayConfigRequest success ");try{this.grayConfig=JSON.parse(m.content.grayConfigTag.config),this.grayConfig.ttl=JSON.parse(m.content.grayConfigTag.ttl)}catch(t){this.logger.error("getGrayscaleConfig error",t)}if(this.grayConfig){v.next=10;break}return v.abrupt("return");case 10:h=pd.localStorage.getItem(this.GRAYKEY)?JSON.parse(pd.localStorage.getItem(this.GRAYKEY)):{},this.grayConfig.timeStamp=(new Date).getTime(),h[t]=this.grayConfig,pd.localStorage.setItem(this.GRAYKEY,Un(h)),v.next=17;break;case 16:this.logger.log("uploadFile:: result grayConfig:",m.content);case 17:if(!(null===(u=this.grayConfig)||void 0===u?void 0:u.mixStoreEnable)){v.next=20;break}return v.next=20,this._getMixStorePolicy(t);case 20:case"end":return v.stop()}}),_callee,this)})))},t._getMixStorePolicy=function _getMixStorePolicy(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v,M,I;return ud.wrap((function _callee2$(S){for(;;)switch(S.prev=S.next){case 0:if(i=(new Date).getTime(),pd.localStorage)try{this.mixStorePolicy=JSON.parse(pd.localStorage.getItem(this.MIXSTOREKEY))[t],this.curProvider=Gd(this.mixStorePolicy.providers[0]),this.mixStorePolicy.timeStamp&&this.mixStorePolicy.timeStamp+1e3*this.mixStorePolicy.ttl>i&&(m=this.mixStorePolicy.timeStamp+1e3*this.mixStorePolicy.ttl-i,this.core.timerManager.addTimer(bind$1(u=this._getMixStorePolicy).call(u,this,t),m))}catch(i){pd.localStorage.getItem(this.MIXSTOREKEY)&&JSON.parse(pd.localStorage.getItem(this.MIXSTOREKEY))[t]&&this.core.logger.error("uploadFile:: JSON.parse mixStorePolicy error ",i)}if(this.mixStorePolicy&&!(this.mixStorePolicy.timeStamp+1e3*this.mixStorePolicy.ttl<=i)){S.next=31;break}return S.prev=3,S.next=6,this.core.sendCmd("getMixStorePolicy",{supportType:this.cloudStorage.aws.s3?[1,2]:[1]});case 6:v=S.sent,M=v.content.mixStorePolicyTag,this.mixStorePolicy={providers:[],timeStamp:0,ttl:0,s3Policy:null,nosPolicy:null,policyVersion:void 0},this.mixStorePolicy.policyVersion=M.policyVersion,this.mixStorePolicy.ttl=Number(M.ttl),this.mixStorePolicy.providers=M.providers.split(","),this.circuitTimer&&this.core.timerManager.deleteTimer(this.circuitTimer),this.curProvider=Gd(this.mixStorePolicy.providers[0]),this.mixStorePolicy.nosPolicy=M.nosPolicy?JSON.parse(M.nosPolicy):null,this.mixStorePolicy.s3Policy=M.s3Policy?JSON.parse(M.s3Policy):null,null===this.mixStorePolicy.s3Policy?this.mixStorePolicy.providers=["1"]:null===this.mixStorePolicy.nosPolicy?this.mixStorePolicy.providers=["2"]:this.mixStorePolicy.providers=this.mixStorePolicy.s3Policy.priority<this.mixStorePolicy.nosPolicy.priority?["2","1"]:["1","2"],this.core.timerManager.addTimer(bind$1(h=this._getMixStorePolicy).call(h,this,t),1e3*this.mixStorePolicy.ttl),I=pd.localStorage.getItem(this.MIXSTOREKEY)?JSON.parse(pd.localStorage.getItem(this.MIXSTOREKEY)):{},this.mixStorePolicy.timeStamp=(new Date).getTime(),I[t]=this.mixStorePolicy,pd.localStorage.setItem(this.MIXSTOREKEY,Un(I)),S.next=31;break;case 24:if(S.prev=24,S.t0=S.catch(3),this.logger.error("getMixStorePolicy error",S.t0),0!==this.mixStoreErrorCount){S.next=29;break}throw new Error("getMixStorePolicy all count error");case 29:this._getMixStorePolicy(t),this.mixStoreErrorCount--;case 31:this.mixStorePolicy.nosPolicy&&(this.cloudStorage.nos.nosErrorCount=this.mixStorePolicy.nosPolicy.uploadConfig.retryPolicy.retry);case 32:case"end":return S.stop()}}),_callee2,this,[[3,24]])})))},t._addCircuitTimer=function _addCircuitTimer(){var t=this,i=this.mixStorePolicy.providers,u=i[(indexOf(i).call(i,String(this.curProvider))+1)%i.length];if(!u)throw new Error("uploadFile nextProvider error");if(u===i[0])throw new Error("uploadFile all policy fail");if(this.logger.log("uploadFile:: upload policy will change,now policy:"+this.curProvider+" nextProvider:"+u),this.curProvider=Gd(u),this.mixStorePolicy.nosPolicy&&this.mixStorePolicy.s3Policy){var m=this.mixStorePolicy[1===this.curProvider?"nosPolicy":"s3Policy"].uploadConfig.retryPolicy.circuit;if(!m||0===m)throw new Error("uploadFile circuit error");this.circuitTimer=this.core.timerManager.addTimer((function(){t.logger.log("uploadFile:: upload policy will change,now policy:"+t.curProvider+" nextProvider:"+Gd(t.mixStorePolicy.providers[0])),t.curProvider=Gd(t.mixStorePolicy.providers[0]),t.core.timerManager.deleteTimer(t.circuitTimer)}),1e3*m)}throw new Error("uploadFile will not retry again")},t.getFileAuthToken=function getFileAuthToken(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.core.sendCmd("getFileAuthToken",{mixStoreAuthTokenReqTag:t});case 2:return i=u.sent,u.abrupt("return",i.content.mixStoreAuthTokenResTag);case 4:case"end":return u.stop()}}),_callee3,this)})))},MixStorage}(),Jh=wd.trim,Xh=R("".charAt),Zh=h.parseFloat,eg=h.Symbol,tg=eg&&eg.iterator,rg=1/Zh(bd+"-0")!=-1/0||tg&&!fails((function(){Zh(Object(tg))}))?function parseFloat(t){var i=Jh(toString(t)),u=Zh(i);return 0===u&&"-"==Xh(i,0)?-0:u}:Zh;_export({global:!0,forced:parseFloat!=rg},{parseFloat:rg});var ng=$.parseFloat,ag=-1,ig=function(){function AWS(t,i){this.s3=null,this.core=t,this.cloudStorage=i,this.logger=t.logger}var t=AWS.prototype;return t.s3Upload=function s3Upload(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var m,h,v,M,I,S,T,C,E,A,k,R,w,N,x=this;return ud.wrap((function _callee2$(O){for(;;)switch(O.prev=O.next){case 0:if(ag+=1,!t.file){O.next=5;break}m=t.file,O.next=20;break;case 5:if("string"!=typeof t.fileInput){O.next=15;break}if(this.logger.warn("fileInput will abandon,Please use file or filepath"),!((h=document.getElementById(t.fileInput))&&h.files&&h.files[0])){O.next=12;break}m=h.files[0],O.next=13;break;case 12:throw new Error("Can not get file from fileInput");case 13:O.next=20;break;case 15:if(!(t.fileInput&&t.fileInput.files&&t.fileInput.files[0])){O.next=19;break}m=t.fileInput.files[0],O.next=20;break;case 19:throw new Error("Can not get file from fileInput "+t.fileInput);case 20:if(this.mixStorePolicy.s3Policy){O.next=22;break}throw new Error("dont get s3 policy");case 22:return v={accessKeyId:u.accessKeyId,secretAccessKey:u.secretAccessKey,sessionToken:u.sessionToken,region:u.region,maxRetries:this.mixStorePolicy.s3Policy.uploadConfig.retryPolicy.retry},M=this.s3,I=decodeURIComponent(u.bucket),S=decodeURIComponent(u.objectName),T=m,C="https://"+I+".s3.amazonaws.com/"+S,E={},(A=this.mixStorePolicy.s3Policy)&&A.uploadConfig&&Dn(A.uploadConfig.uploadUrl)&&A.uploadConfig.uploadUrl.length>0&&(k=A.uploadConfig.uploadUrl.length,ag%=k,E.endpoint=A.uploadConfig.uploadUrl[ag],E.s3ForcePathStyle=!0,C=E.endpoint+"/"+I+"/"+S),i.update({local_file:m.name,remote_addr:C,operation_type:1}),(R=new M(E)).config.update(v),w={Bucket:I,Key:S,Body:T,Metadata:{token:u.token},ContentType:T.type||"application/octet-stream"},this.core.logger.log("uploadFile:: s3 upload params:",w),(N=R.upload(w)).on("httpUploadProgress",(function(u){i.update({index:u.part});var m=ng((u.loaded/u.total).toFixed(2));t.onUploadProgress&&t.onUploadProgress({total:u.total,loaded:u.loaded,percentage:m,percentageText:Math.round(100*m)+"%"})})),O.abrupt("return",new zi((function(m,h){var v=(new Date).getTime();N.send((function(M,C){return __awaiter(x,void 0,void 0,ud.mark((function _callee(){var E,A,k,R,w,N,x,O;return ud.wrap((function _callee$(P){for(;;)switch(P.prev=P.next){case 0:if(!M||"RequestAbortedError"!==M.code){P.next=6;break}this.logger.error("uploadFile:","api::s3:upload file abort.",M),i.update({http_code:M.statusCode,exception:M}),h(new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_CANCELLED:400,detail:{reason:"S3RequestAbortedError",rawError:M,curProvider:2}})),P.next=43;break;case 6:if(!M){P.next=27;break}return i.update({http_code:M.statusCode,exception:M}),this.core.reporter.reportTraceStart("exceptions",{user_id:this.core.options.account||(null===(A=null===(E=this.core)||void 0===E?void 0:E.auth)||void 0===A?void 0:A.account),trace_id:null===(k=this.core.clientSocket.socket)||void 0===k?void 0:k.sessionId,start_time:v,action:1,exception_service:4}),this.core.reporter.reportTraceUpdateV2("exceptions",{code:"number"==typeof M.status?M.status:"number"==typeof M.code?M.code:0,description:M.message||""+M.code,operation_type:1,target:Un({bucket:I,object:S})},{asyncParams:pd.net.getNetworkStatus()}),this.core.reporter.reportTraceEnd("exceptions",1),P.next=13,pd.net.getNetworkStatus();case 13:if(R=P.sent,!1!==R.net_connect){P.next=17;break}return P.abrupt("return",h(new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:400,detail:{reason:"No network",rawError:M,curProvider:this.cloudStorage.mixStorage.curProvider}})));case 17:P.prev=17,this.cloudStorage.mixStorage._addCircuitTimer(),P.next=24;break;case 21:return P.prev=21,P.t0=P.catch(17),P.abrupt("return",h(new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:400,detail:{reason:"All upload attempts failed",rawError:P.t0,curProvider:this.cloudStorage.mixStorage.curProvider,mixStorePolicy:this.mixStorePolicy,file:t.file||t.filePath}})));case 24:m(this.cloudStorage._uploadFile(t,i)),P.next=43;break;case 27:if(i.update({http_code:200}),w=(w=(w=this.mixStorePolicy.s3Policy.cdnSchema).replace("{cdnDomain}",this.mixStorePolicy.s3Policy.dlcdn)).replace("{objectName}",C.Key),N={size:T.size,name:T.name,url:u.shortUrl?u.shortUrl:w,ext:T.name.split(".")[1]||"unknown"},x=t.type||"",(O={image:"imageInfo"})[x]){P.next=38;break}return P.abrupt("return",m(N));case 38:return P.t1=m,P.next=41,this.getS3FileInfo({url:w,infoSuffix:O[x],s3Result:N});case 41:return P.t2=P.sent,P.abrupt("return",(0,P.t1)(P.t2));case 43:case"end":return P.stop()}}),_callee,this,[[17,21]])})))})),t.onUploadStart&&t.onUploadStart(N)})));case 39:case"end":return O.stop()}}),_callee2,this)})))},t.getS3FileInfo=function getS3FileInfo(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var u,m,h,v,M,I,S;return ud.wrap((function _callee3$(T){for(;;)switch(T.prev=T.next){case 0:return u=t.url,m=t.infoSuffix,h=t.s3Result,T.prev=1,T.next=4,this.core.adapters.request(u+"?"+m,{method:"GET",dataType:"text",timeout:5e3},{exception_service:3});case 4:v=T.sent,T.next=11;break;case 7:return T.prev=7,T.t0=T.catch(1),this.core.logger.error("uploadFile:: fetch file info error",T.t0),T.abrupt("return",h);case 11:if(!v){T.next=18;break}return M=v.data,I="imageInfo"===m?M:null===(i=null==M?void 0:M.GetVideoInfo)||void 0===i?void 0:i.VideoInfo,S=Dt(Dt({},h),{w:null==I?void 0:I.Width,h:null==I?void 0:I.Height,orientation:null==I?void 0:I.Orientation,dur:null==I?void 0:I.Duration,audioCodec:null==I?void 0:I.AudioCodec,videoCodec:null==I?void 0:I.VideoCodec,container:null==I?void 0:I.Container}),T.abrupt("return",pickBy(S,(function(t){return void 0!==t})));case 18:return this.core.logger.error("uploadFile:: fetch s3 file info no result",u+"?"+m),T.abrupt("return",h);case 20:case"end":return T.stop()}}),_callee3,this,[[1,7]])})))},Qe(AWS,[{key:"mixStorePolicy",get:function get(){return this.cloudStorage.mixStorage.mixStorePolicy}}]),AWS}(),og={user_id:"",trace_id:"",action:0,state:0,duration:0,start_time:0,offset:0,full_size:0,transferred_size:0,operation_type:0,remote_addr:"",local_file:"",retry_times:0,index:0,part_size:0,transfer_latency:0,http_code:0,exception:"",req_headers:"",rsp_headers:""},sg="ReporterHook::setMonitorForResources:",cg=function(){function ReporterHookCloudStorage(t,i){this.traceData=og,this.core=t,this.id=Math.round(1e3*Math.random()),this.traceData=Dt({},og,i)}var t=ReporterHookCloudStorage.prototype;return t.start=function start(){var t,i;this.core&&(this.reset(),this.traceData.user_id=this.core.account,this.traceData.trace_id=(null===(i=null===(t=this.core.clientSocket)||void 0===t?void 0:t.socket)||void 0===i?void 0:i.sessionId)||"",this.traceData.start_time="timeOrigin"in this.core?this.core.timeOrigin.getNTPTime():to())},t.update=function update(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(this.core){i.next=2;break}return i.abrupt("return");case 2:if(this.traceData.user_id){i.next=4;break}return i.abrupt("return");case 4:if(t.transferred_size&&this.core.logger.log(this.id+"."+sg+" upload update",t),"object"==typeof t.exception)try{t.exception=Un(t.exception)}catch(i){t.exception="UnknownObject"}if("object"==typeof t.req_headers)try{t.req_headers=Un(t.req_headers)}catch(i){t.req_headers="UnknownObject"}if("object"==typeof t.rsp_headers)try{t.rsp_headers=Un(t.rsp_headers)}catch(i){t.rsp_headers="UnknownObject"}Dt(this.traceData,t);case 9:case"end":return i.stop()}}),_callee,this)})))},t.end=function end(t){this.core&&this.traceData.user_id&&(this.core.logger.log(sg+" upload end cause of "+t),this.traceData.state=t,this.traceData.duration=("timeOrigin"in this.core?this.core.timeOrigin.getNTPTime():to())-(this.traceData.start_time||0),this.core.reporter.report("nim_sdk_resources",this.traceData),this.traceData=og,this.destroy())},t.reset=function reset(){this.traceData=Dt({},og)},t.destroy=function destroy(){this.core=void 0,this.traceData=og},ReporterHookCloudStorage}(),lg=function(){function CloudStorageService(t,i){void 0===i&&(i={}),this.config={},this.uploadTaskMap={},this.name="cloudStorage",this.logger=t.logger,this.core=t,this.nos=new zh(t,this),this.mixStorage=new Qh(t,this),this.aws=new ig(t,this),registerParser({cmdMap:Wh,cmdConfig:Yh}),this.setOptions(i),this.setListeners()}var t=CloudStorageService.prototype;return t.setOptions=function setOptions(t){void 0===t&&(t={});var i=t.storageKeyPrefix||"NIMClient";this.mixStorage.GRAYKEY=i+"-AllGrayscaleConfig",this.mixStorage.MIXSTOREKEY=i+"-AllMixStorePolicy";var u=t.s3,m=__rest(t,["s3"]),h=Dt({},$h,this.config);if(m&&Object.prototype.hasOwnProperty.call(m,"cdn")){var v=Dt(Dt({},h.cdn),m.cdn);this.config=Dt({},h,m),this.config.cdn=v}else this.config=Dt({},h,m);u&&(this.aws.s3=u)},t.setListeners=function setListeners(){var t,i,u,m;this.core.eventBus.on("kicked",bind$1(t=this._clearUnCompleteTask).call(t,this)),this.core.eventBus.on("disconnect",bind$1(i=this._clearUnCompleteTask).call(i,this)),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLogout",bind$1(u=this._clearUnCompleteTask).call(u,this)),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleKicked",bind$1(m=this._clearUnCompleteTask).call(m,this))},t._clearUnCompleteTask=function _clearUnCompleteTask(){var t,i=this;forEach$1(t=Ht(this.uploadTaskMap)).call(t,(function(t){var u=i.uploadTaskMap[t];u&&u.abort&&u.abort()})),this.uploadTaskMap={}},t.init=function init(t){return void 0===t&&(t=to()),__awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(this.mixStorage.reset(),this.nos.reset(),!this.config.isNeedToGetUploadPolicyFromServer){i.next=5;break}return i.next=5,this.mixStorage.getGrayscaleConfig(this.core.options.appkey,t);case 5:return i.next=7,this.nos._getNosCdnHost();case 7:case"end":return i.stop()}}),_callee,this)})))},t.processCallback=function processCallback(t,i,u){var m=this,h=t.onUploadProgress,v=t.onUploadDone,M=t.onUploadStart;return{onUploadStart:"function"==typeof M?function(t){m.uploadTaskMap[i]=t;try{M(t)}catch(t){m.logger.error("CloudStorage::uploadFile:options.onUploadStart execute error",t)}}:function(t){m.uploadTaskMap[i]=t},onUploadProgress:"function"==typeof h?function(t){u.update({transferred_size:t.loaded,full_size:t.total});try{h(t)}catch(t){m.logger.error("CloudStorage::uploadFile:options.onUploadProgress execute error",t)}}:function(t){u.update({transferred_size:t.loaded,full_size:t.total})},onUploadDone:"function"==typeof v?function(t){u.end(0);try{v(t)}catch(t){m.logger.error("CloudStorage::uploadFile:options.onUploadDone execute error",t)}}:function(){u.end(0)},taskKey:i}},t.uploadFile=function uploadFile(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v,M,I,S,T;return ud.wrap((function _callee2$(C){for(;;)switch(C.prev=C.next){case 0:if(validate({maxSize:{type:"number",required:!1},type:{type:"enum",values:["file","image","audio","video"]}},t),t.fileInput||t.file||t.filePath){C.next=3;break}throw new Error("uploadFile needs target file object or a filePath");case 3:if(!t.type||"file"===t.type){C.next=7;break}if(!(i=get(t,"file.type"))||"string"!=typeof i||-1!==indexOf(i).call(i,t.type)){C.next=7;break}throw new Error('The meta type "'+i+'" does not match "'+t.type+'"');case 7:return(u=new cg(this.core)).start(),t.file?u.update({full_size:t.file.size,local_file:t.file.name}):"string"==typeof t.fileInput?(m=document.getElementById(t.fileInput))&&m.files&&m.files[0]&&u.update({full_size:m.files[0].size,local_file:m.files[0].name}):t.fileInput&&t.fileInput.files&&t.fileInput.files[0]&&u.update({full_size:t.fileInput.files[0].size,local_file:t.fileInput.files[0].name}),h=jd(),v=this.processCallback(t,h,u),M=v.onUploadStart,I=v.onUploadProgress,S=v.onUploadDone,t.onUploadStart=M,t.onUploadProgress=I,t.onUploadDone=S,T=null,C.prev=16,C.next=19,this._uploadFile(t,u);case 19:T=C.sent,t.md5&&(T.md5=t.md5),delete this.uploadTaskMap[h],C.next=29;break;case 24:throw C.prev=24,C.t0=C.catch(16),delete this.uploadTaskMap[h],u.end((C.t0&&C.t0.code)===zl.V2NIM_ERROR_CODE_CANCELLED?3:1),C.t0;case 29:return T&&(T.size=void 0===T.size?void 0:Number(T.size),T.w=void 0===T.w?void 0:Number(T.w),T.h=void 0===T.h?void 0:Number(T.h),T.dur=void 0===T.dur?void 0:Number(T.dur)),T.url=decodeURIComponent(T.url),t.onUploadDone({size:T.size,name:T.name,url:T.url,ext:T.name.split(".")[1]||"unknown"}),C.abrupt("return",T);case 33:case"end":return C.stop()}}),_callee2,this,[[16,24]])})))},t._uploadFile=function _uploadFile(t,i){var u,m;return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var h,v,M,I;return ud.wrap((function _callee3$(S){for(;;)switch(S.prev=S.next){case 0:if(get(this.mixStorage,"grayConfig.mixStoreEnable")&&get(this.mixStorage,"mixStorePolicy.providers.length")){S.next=3;break}return this.logger.log("uploadFile:: uploadFile begin, use old nos"),S.abrupt("return",this.nos.nosUpload(t,i));case 3:if(this.logger.log("uploadFile::_uploadFile, grayConfig enable:"+get(this.mixStorage,"grayConfig.mixStoreEnable")+" curProvider:"+get(this.mixStorage,"curProvider")),h=this.core.adapters.getFileUploadInformation(t),v=!0,h?!1===h.complete&&2===this.mixStorage.curProvider?v=!1:h.complete&&i.destroy():v=!1,this.aws.s3||(this.mixStorage.curProvider=1),M=jh,v){S.next=24;break}return S.prev=10,S.next=13,this.core.sendCmd("getMixStoreToken",{mixStoreTokenReqTag:{provider:this.mixStorage.curProvider,tokenCount:1,tag:"qchat",nosSurvivalTime:t.nosSurvivalTime,returnBody:getUploadResponseFormat(t.type),policyVersion:this.mixStorage.mixStorePolicy.policyVersion}});case 13:I=S.sent,M=I.content.mixStoreTokenResTag,S.next=24;break;case 17:if(S.prev=17,S.t0=S.catch(10),this.core.logger.error("uploadFile:: getMixStoreToken error",S.t0),i.destroy(),!(S.t0 instanceof Yl)){S.next=23;break}throw S.t0;case 23:throw new Zl({code:"v2"===get(this.core,"options.apiVersion")?zl.V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED:400,detail:{reason:"getMixStoreToken error",rawError:S.t0,curProvider:this.mixStorage.curProvider,mixStorePolicy:this.mixStorage.mixStorePolicy}});case 24:if(v){S.next=28;break}return S.abrupt("return",2===this.mixStorage.curProvider?this.aws.s3Upload(t,i,M):this.nos.nosUpload(t,i,M));case 28:return S.abrupt("return",this.nos.nosUpload(t,i,null===(m=null===(u=null==h?void 0:h.uploadInfo)||void 0===u?void 0:u.payload)||void 0===m?void 0:m.mixStoreToken));case 29:case"end":return S.stop()}}),_callee3,this,[[10,17]])})))},t.getThumbUrl=function getThumbUrl(t,i){var u,m,h,v,M;if(!new RegExp(/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/).test(t))return this.logger.error("illegal file url:"+t),t;var I=/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/.exec(t);I[0],I[1],I[2],I[3],I[4];var S=I[5];if(I[6],I[7],null===(u=this.grayConfig)||void 0===u?void 0:u.mixStoreEnable){var T=this._getUrlType(t);if(2===T&&this.mixStorePolicy.s3Policy&&get(this.mixStorePolicy,"s3Policy.thumbPolicy.imagethumb"))return(null===(h=null===(m=this.mixStorePolicy.s3Policy)||void 0===m?void 0:m.thumbPolicy)||void 0===h?void 0:h.imagethumb).replace("{cdnDomain}",this.mixStorePolicy.s3Policy.dlcdn).replace("{objectName}",S).replace("{x}",i.width.toString()).replace("{y}",i.height.toString());if(1===T&&this.mixStorePolicy.nosPolicy&&get(this.mixStorePolicy,"nosPolicy.thumbPolicy.imagethumb"))return(null===(M=null===(v=this.mixStorePolicy.nosPolicy)||void 0===v?void 0:v.thumbPolicy)||void 0===M?void 0:M.imagethumb).replace("{cdnDomain}",this.mixStorePolicy.nosPolicy.dlcdn).replace("{objectName}",S).replace("{x}",i.width.toString()).replace("{y}",i.height.toString())}return includes(t).call(t,"?")?t+"&imageView&thumbnail="+i.width+"x"+i.height:t+"?imageView&thumbnail="+i.width+"x"+i.height},t.getVideoCoverUrl=function getVideoCoverUrl(t,i){var u,m,h,v,M;if(!new RegExp(/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/).test(t))return this.logger.error("illegal file url:"+t),t;var I=/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/.exec(t);I[0],I[1],I[2],I[3],I[4];var S=I[5];if(I[6],I[7],null===(u=this.grayConfig)||void 0===u?void 0:u.mixStoreEnable){var T=this._getUrlType(t);if(2===T&&this.mixStorePolicy.s3Policy&&get(this.mixStorePolicy,"s3Policy.thumbPolicy.vframe"))return(null===(h=null===(m=this.mixStorePolicy.s3Policy)||void 0===m?void 0:m.thumbPolicy)||void 0===h?void 0:h.vframe).replace("{cdnDomain}",this.mixStorePolicy.s3Policy.dlcdn).replace("{objectName}",S).replace("{x}",i.width.toString()).replace("{y}",i.height.toString()).replace("{offset}","0").replace("{type}","png");if(1===T&&this.mixStorePolicy.nosPolicy&&get(this.mixStorePolicy,"nosPolicy.thumbPolicy.vframe"))return(null===(M=null===(v=this.mixStorePolicy.nosPolicy)||void 0===v?void 0:v.thumbPolicy)||void 0===M?void 0:M.vframe).replace("{cdnDomain}",this.mixStorePolicy.nosPolicy.dlcdn).replace("{objectName}",S).replace("{x}",i.width.toString()).replace("{y}",i.height.toString()).replace("{offset}","0").replace("{type}","png")}return includes(t).call(t,"?")?t+"&vframe&offset=0&resize="+i.width+"x"+i.height+"&type=png":t+"?vframe&offset=0&resize="+i.width+"x"+i.height+"&type=png"},t.getPrivateUrl=function getPrivateUrl(t){var i;if(!new RegExp(/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/).test(t))return this.logger.error("illegal file url:"+t),"";var u=/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/.exec(t);u[0];var m=u[1],h=u[2],v=u[3];u[4];var M=u[5];if(u[6],u[7],null===(i=this.grayConfig)||void 0===i?void 0:i.mixStoreEnable){var I=this._getUrlType(t);return 2===I&&this.mixStorePolicy.s3Policy&&(t=this.mixStorePolicy.s3Policy.cdnSchema.replace("{cdnDomain}",this.mixStorePolicy.s3Policy.dlcdn).replace("{objectName}",M)),1===I&&this.mixStorePolicy.nosPolicy&&(t=this.mixStorePolicy.nosPolicy.cdnSchema.replace("{cdnDomain}",this.mixStorePolicy.nosPolicy.dlcdn).replace("{objectName}",M)),t}var S=this.config,T=S.downloadUrl,C=S.downloadHostList,E=S.nosCdnEnable,A=this.config.cdn.cdnDomain,k=this.config.cdn.objectNamePrefix?decodeURIComponent(this.config.cdn.objectNamePrefix):"",R=decodeURIComponent(M),w=indexOf(R).call(R,k);if(A&&w>-1&&E)return m+":"+h+A+"/"+slice(R).call(R,w);if(includes(C).call(C,v)&&includes(M).call(M,"/")){var N=indexOf(M).call(M,"/"),x=M.substring(0,N),O=M.substring(N+1);return T.replace("{bucket}",x).replace("{object}",O)}var P=filter(C).call(C,(function(t){return"string"==typeof v&&includes(v).call(v,t)}))[0],L=P?v.replace(P,"").replace(/\W/g,""):null;return L?T.replace("{bucket}",L).replace("{object}",M):t},t.getOriginUrl=function getOriginUrl(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:if("string"==typeof t&&includes(t).call(t,"_im_url=1")){u.next=2;break}return u.abrupt("return",t);case 2:return u.next=4,this.core.sendCmd("getOriginUrl",{nosSafeUrlTag:{safeUrl:t}});case 4:return i=u.sent,u.abrupt("return",i.content.nosSafeUrlTag.originUrl);case 6:case"end":return u.stop()}}),_callee4,this)})))},t.getFileToken=function getFileToken(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i,u,m,h,v,M=this;return ud.wrap((function _callee5$(I){for(;;)switch(I.prev=I.next){case 0:if(validate({type:{type:"number",min:2,max:3},urls:{type:"array",required:!1,itemType:"string"}},t),i=this.mixStorePolicy.nosPolicy?this.mixStorePolicy.nosPolicy.authPolicy.policyType:null,u=this.mixStorePolicy.s3Policy?this.mixStorePolicy.s3Policy.authPolicy.policyType:null,i!==String(-1)||u!==String(-1)){I.next=8;break}throw this.logger.error("don't need token"),new Error("don't need token");case 8:if(2!==t.type){I.next=17;break}if(!(i&&indexOf(i).call(i,String(2))>=0||u&&indexOf(u).call(u,String(2))>0)){I.next=13;break}return I.abrupt("return",this.mixStorage.getFileAuthToken(t));case 13:throw this.logger.error("don't support time token "),new Error("don't support type time token ");case 15:I.next=33;break;case 17:if(t.urls&&t.urls.length){I.next=20;break}throw this.logger.error("urls is required when urls token"),new Error("urls is required when urls token");case 20:if(h=[],v=[],forEach$1(m=t.urls).call(m,(function(t){var i=M._getUrlType(t);1===i&&v.push(t),2===i&&h.push(t)})),(!u||0!==h.length&&indexOf(u).call(u,String(3))<0)&&(this.logger.warn("s3 url don't support url token"),h=[]),(!i||0!==v.length&&indexOf(i).call(i,String(3))<0)&&(this.logger.warn("nos url don't support url token"),v=[]),0!==h.length||0!==v.length){I.next=30;break}throw this.logger.error("not support urls"),new Error("not support urls");case 30:if(0!==h.length&&0!==v.length){I.next=33;break}return t.urls=Un(t.urls),I.abrupt("return",this.mixStorage.getFileAuthToken(t));case 33:case"end":return I.stop()}}),_callee5,this)})))},t._getUrlType=function _getUrlType(t){var i,u;return this.mixStorePolicy.nosPolicy&&some(i=this.mixStorePolicy.nosPolicy.dlcdns).call(i,(function(i){return indexOf(t).call(t,i)>=0}))?1:this.mixStorePolicy.s3Policy&&some(u=this.mixStorePolicy.s3Policy.dlcdns).call(u,(function(i){return indexOf(t).call(t,i)>=0}))?2:null},t.getNosAccessToken=function getNosAccessToken(t){return validate({url:{type:"string",allowEmpty:!1}},t),this.nos.getNosAccessToken(t)},t.deleteNosAccessToken=function deleteNosAccessToken(t){return validate({token:{type:"string",allowEmpty:!1}},t),this.nos.deleteNosAccessToken(t)},t.process=function process(t){var i=get(t,"error.detail.ignore");return t.error&&!i?zi.reject(t.error):zi.resolve(t)},Qe(CloudStorageService,[{key:"grayConfig",get:function get(){return this.mixStorage.grayConfig}},{key:"mixStorePolicy",get:function get(){return this.mixStorage.mixStorePolicy}}]),CloudStorageService}();var dg,ug=function(t){function V2NIMStorageServiceImpl(i){var u;return(u=t.call(this,"V2NIMStorageService",i)||this).sceneMap={nim_default_profile_icon:{sceneName:"nim_default_profile_icon",expireTime:0},nim_default_im:{sceneName:"nim_default_im",expireTime:0},nim_system_nos_scene:{sceneName:"nim_system_nos_scene",expireTime:0},nim_security:{sceneName:"nim_security",expireTime:0}},u.uploadingMessageInfo={},u.core=i,u.core._registerDep(lg,"cloudStorage"),u.core._registerDep(Gh,"V2NIMStorageUtil"),u}Nt(V2NIMStorageServiceImpl,t);var i=V2NIMStorageServiceImpl.prototype;return i.addCustomStorageScene=function addCustomStorageScene(t,i){return this.checkV2(),validate({sceneName:{type:"string",allowEmpty:!1},expireTime:{type:"number",min:0}},{sceneName:t,expireTime:i},"",!0),this.sceneMap[t]={sceneName:t,expireTime:i},{sceneName:t,expireTime:i}},i.getStorageSceneList=function getStorageSceneList(){return this.checkV2(),Xi(this.sceneMap)},i.getStorageScene=function getStorageScene(t){return t&&this.sceneMap[t]||this.sceneMap.nim_default_im},i.hasStorageScene=function hasStorageScene(t){return void 0!==this.sceneMap[t]},i.createUploadFileTask=function createUploadFileTask(t){var i;if(this.checkV2(),"string"==typeof t.fileObj&&0===indexOf(i=t.fileObj).call(i,"nim-external")){var u=document.getElementById(t.fileObj);u&&u.files&&u.files[0]&&(t.fileObj=u.files[0])}return{taskId:jd(),uploadParams:t}},i.uploadFile=function uploadFile(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate({taskId:{type:"string",allowEmpty:!1}},t,"fileTask",!0),m.next=4,this._uploadFile(t,i);case 4:return u=m.sent,m.abrupt("return",u[0]);case 6:case"end":return m.stop()}}),_callee,this)})))},i.uploadFileWithMetaInfo=function uploadFileWithMetaInfo(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate({taskId:{type:"string",allowEmpty:!1}},t,"fileTask",!0),m.next=4,this._uploadFile(t,i);case 4:return u=m.sent,m.abrupt("return",(h=u[1],v=void 0,M=void 0,I=void 0,S=void 0,T=void 0,C=void 0,E=void 0,A=void 0,k=void 0,R=void 0,w=void 0,N=void 0,v=h.url,M=h.name,I=h.size,S=h.ext,T=h.md5,C=h.h,E=h.w,A=h.orientation,k=h.dur,R=h.audioCodec,w=h.videoCodec,N=h.container,JSON.parse(Un({url:v,name:M,size:I,ext:S,md5:T,height:C,width:E,orientation:A,duration:k,audioCodec:R,videoCodec:w,container:N}))));case 6:case"end":return m.stop()}var h,v,M,I,S,T,C,E,A,k,R,w,N}),_callee2,this)})))},i._uploadFile=function _uploadFile(t,i,u){var m;return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var h,v,M,I,S,T,C,E,A,k,R=this;return ud.wrap((function _callee3$(w){for(;;)switch(w.prev=w.next){case 0:if(this.core.cloudStorage&&this.core.cloudStorage.uploadFile){w.next=2;break}throw new Error('Service "cloudStorage" does not exist');case 2:if(h=t.uploadParams,v=t.taskId,M=getFileOrPath(h.fileObj),I=M.file,S=M.path,T=(u||{}).fileType,!this.uploadingMessageInfo[v]){w.next=7;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_ALREADY_EXIST,detail:{reason:"V2NIMStorageService.uploadFile: repeat upload"}});case 7:if(w.prev=7,C={},I?C.file=I:S&&(0===(null==S?void 0:indexOf(S).call(S,"nim-external"))?C.fileInput=S:C.filePath=S),E=this.getStorageScene(h.sceneName),C.nosScenes=E.sceneName,C.nosSurvivalTime=E.expireTime,C.type=1===T?"image":2===T?"audio":3===T?"video":"file",!C.file||!this.core.pluginMap["browser-md5-file"]){w.next=19;break}return w.next=17,this.getFileMd5(this.core.pluginMap["browser-md5-file"],v,C.file);case 17:A=w.sent,C.md5=A;case 19:return C.onUploadProgress=function(t){"function"==typeof i&&i(Math.round(100*t.percentage))},C.onUploadStart=function(t){var i;if(null===(i=R.uploadingMessageInfo[v])||void 0===i?void 0:i.abort)return t.abort(),void delete R.uploadingMessageInfo[v];R.uploadingMessageInfo[v]={abort:!1,task:t}},this.uploadingMessageInfo[v]={abort:!1},w.next=24,this.core.cloudStorage.uploadFile(C);case 24:if(k=w.sent,!(null===(m=this.uploadingMessageInfo[v])||void 0===m?void 0:m.abort)){w.next=27;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_CANCELLED,detail:{reason:"upload file aborted"}});case 27:return delete this.uploadingMessageInfo[v],w.abrupt("return",[k.url,k]);case 31:throw w.prev=31,w.t0=w.catch(7),delete this.uploadingMessageInfo[v],this.core.logger.error("sendFile:: upload File error or abort.",w.t0),w.t0;case 36:case"end":return w.stop()}}),_callee3,this,[[7,31]])})))},i.cancelUploadFile=function cancelUploadFile(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),i.next=3,this._cancelUploadFile(t.taskId);case 3:case"end":return i.stop()}}),_callee4,this)})))},i._cancelUploadFile=function _cancelUploadFile(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i;return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:if(this.checkV2(),!(null==(i=this.uploadingMessageInfo[t])?void 0:i.task)){u.next=16;break}return u.prev=3,this.logger.log("V2NIMStorageService.cancelUploadFile: uploadInfo task exist"),u.next=7,i.task.abort();case 7:delete this.uploadingMessageInfo[t],u.next=14;break;case 10:u.prev=10,u.t0=u.catch(3),delete this.uploadingMessageInfo[t],this.core.logger.error("cancelMessageAttachmentUpload::abort error.",u.t0);case 14:u.next=22;break;case 16:if(!i){u.next=21;break}this.logger.log("V2NIMStorageService.cancelUploadFile: uploadInfo task not exist"),i.abort=!0,u.next=22;break;case 21:throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST,detail:{reason:"V2NIMStorageService.cancelUploadFile: uploadInfo not exist"}});case 22:case"end":return u.stop()}}),_callee5,this,[[3,10]])})))},i.getFileMd5=function getFileMd5(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var m=this;return ud.wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:return h.abrupt("return",new zi((function(h,v){var M,I=new t;(null===(M=m.uploadingMessageInfo[i])||void 0===M?void 0:M.abort)?v(new Yl({code:zl.V2NIM_ERROR_CODE_CANCELLED,detail:{reason:"upload file aborted"}})):m.uploadingMessageInfo[i]={abort:!1,task:I};try{I.md5(u,(function(t,i){"aborted"===t?v(new Yl({code:zl.V2NIM_ERROR_CODE_CANCELLED,detail:{reason:t}})):t?v(new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"md5 calculate error in callback",rawError:t}})):h(i)}))}catch(t){v(new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"md5 calculate error",rawError:t}}))}})));case 1:case"end":return h.stop()}}),_callee6)})))},i.shortUrlToLong=function shortUrlToLong(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),i.abrupt("return",this.core.cloudStorage.getOriginUrl(t));case 2:case"end":return i.stop()}}),_callee7,this)})))},i.getImageThumbUrl=function getImageThumbUrl(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){return ud.wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.core.V2NIMStorageUtil.getImageThumbUrl(t,i));case 1:case"end":return u.stop()}}),_callee8,this)})))},i.getVideoCoverUrl=function getVideoCoverUrl(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){return ud.wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.core.V2NIMStorageUtil.getVideoCoverUrl(t,i));case 1:case"end":return u.stop()}}),_callee9,this)})))},V2NIMStorageServiceImpl}(hp),pg=function(t){function V2NIMMessageCreatorImpl(i){var u;return(u=t.call(this,"V2NIMMessageCreator",i)||this).name="V2NIMMessageCreator",u.defaultNosSceneName="nim_default_im",u.core=i,u}Nt(V2NIMMessageCreatorImpl,t);var i=V2NIMMessageCreatorImpl.prototype;return i.createMessage=function createMessage(t,i){return Dt(Dt(Dt({messageClientId:jd(),messageType:t,createTime:this.core.timeOrigin.getNTPTime(),sendingState:0,messageStatus:{errorCode:200},messageSource:0,fromClientType:16,isSelf:!0},i),i.attachment?{attachment:Dt(Dt({},i.attachment),{raw:attachmentToRaw(t,i.attachment)})}:{}),{senderId:"",receiverId:"",conversationType:0,conversationId:"",messageServerId:"",messageConfig:Dt({unreadEnabled:!0,roamingEnabled:!0,readReceiptEnabled:!1,lastMessageUpdateEnabled:!0,historyEnabled:!0,onlineSyncEnabled:!0,offlineEnabled:!0},i.messageConfig),pushConfig:Dt({pushEnabled:!0,pushNickEnabled:!0,forcePush:!1},i.pushConfig),routeConfig:Dt({routeEnabled:!0},i.routeConfig),antispamConfig:Dt({antispamEnabled:!0},i.antispamConfig)})},i.createTextMessage=function createTextMessage(t){return this.checkV2(),validate({text:{type:"string",allowEmpty:!1}},{text:t},"",!0),this.createMessage(0,{text:t})},i.createImageMessage=function createImageMessage(t,i,u,m,h){this.checkV2(),validate(Zm,{name:i,sceneName:u,width:m,height:h},"",!0);var v=this.createGenericFileMessageAttachment(t,i,u,void 0,m,h,"jpeg");return this.createMessage(1,{attachment:v,attachmentUploadState:0})},i.createAudioMessage=function createAudioMessage(t,i,u,m){this.checkV2(),validate(Jm,{name:i,sceneName:u,duration:m},"",!0);var h=this.createGenericFileMessageAttachment(t,i,u,m,void 0,void 0,"aac");return this.createMessage(2,{attachment:h,attachmentUploadState:0})},i.createVideoMessage=function createVideoMessage(t,i,u,m,h,v){this.checkV2(),validate(Xm,{name:i,sceneName:u,duration:m,width:h,height:v},"",!0);var M=this.createGenericFileMessageAttachment(t,i,u,m,h,v,"mp4");return this.createMessage(3,{attachment:M,attachmentUploadState:0})},i.createFileMessage=function createFileMessage(t,i,u){this.checkV2(),validate(Qm,{name:i,sceneName:u},"",!0);var m=this.createGenericFileMessageAttachment(t,i,u,void 0,void 0,void 0,"txt");return this.createMessage(6,{attachment:m,attachmentUploadState:0})},i.createGenericFileMessageAttachment=function createGenericFileMessageAttachment(t,i,u,m,h,v,M){if(u=u||this.defaultNosSceneName,!this.core.V2NIMStorageService.hasStorageScene)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"V2NIMStorageService not exist"}});if(!this.core.V2NIMStorageService.hasStorageScene(u))throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"sceneName: "+u+" has not been added"}});var I=getFileOrPath(t),S=I.file,T=I.path,C=Dt(Dt(Dt({name:i,uploadState:0,sceneName:u||this.defaultNosSceneName},m?{duration:m}:{}),h?{width:h}:{}),v?{height:v}:{});if(S){var E,A=lastIndexOf(E=S.name).call(E,"."),k=-1===A?S.name:S.name.substring(0,A);C.name=C.name||k,C.size=S.size,C.ext="."+(getFileExtension(S.name)||getFileExtension(i||"")||M)}else if(T){var R=lastIndexOf(T).call(T,"/"),w=lastIndexOf(T).call(T,"."),N=-1===w?T.substring(R+1):T.substring(R+1,w);C.name=C.name||N,C.ext="."+(getFileExtension(T)||getFileExtension(i||"")||M)}return C=JSON.parse(Un(C)),T?C.path=T:S&&(C.file=S),C},i.createLocationMessage=function createLocationMessage(t,i,u){return this.checkV2(),validate({latitude:{type:"number",allowEmpty:!1},longitude:{type:"number",allowEmpty:!1},address:{type:"string",allowEmpty:!1}},{latitude:t,longitude:i,address:u},"",!0),this.createMessage(4,{attachment:{latitude:t,longitude:i,address:u}})},i.createCustomMessage=function createCustomMessage(t,i){return this.checkV2(),validate({text:{type:"string"}},{text:t},"",!0),validate({rawAttachment:{type:"string"}},{rawAttachment:i},"",!0),this.createMessage(100,{text:t,attachment:{raw:i}})},i.createCustomMessageWithAttachment=function createCustomMessageWithAttachment(t,i){return this.checkV2(),validate({raw:{type:"string"}},t,"attachment",!0),validate({subType:{type:"number",min:0,required:!1}},{subType:i},"",!0),this.createMessage(100,i?{attachment:t,subType:i}:{attachment:t})},i.createCallMessage=function createCallMessage(t,i,u,m,h){return this.checkV2(),validate({type:{type:"number",allowEmpty:!1}},{type:t},"",!0),validate({channelId:{type:"string",allowEmpty:!1}},{channelId:i},"",!0),validate({status:{type:"number",allowEmpty:!1}},{status:u},"",!0),validate({durations:{type:"array",allowEmpty:!1}},{durations:m},"",!0),this.createMessage(12,{text:h||"",attachment:{type:t,channelId:i,durations:m,status:u}})},i.createForwardMessage=function createForwardMessage(t){this.checkV2();var i=[11,5,7,10];if(!t||includes(i).call(i,t.messageType))return null;var u={messageClientId:jd(),messageType:t.messageType};return t.text&&(u.text=t.text),t.attachment&&(u.attachment=t.attachment),t.attachment&&"uploadState"in t.attachment&&(u.attachmentUploadState=t.attachment.uploadState),this.createMessage(t.messageType,u)},i.createTipsMessage=function createTipsMessage(t){return this.checkV2(),validate({text:{type:"string",allowEmpty:!1}},{text:t},"",!0),this.createMessage(10,{text:t})},V2NIMMessageCreatorImpl}(hp),mg=function(){function V2NIMMessageAttachmentCreatorImpl(){this.name="V2NIMMessageAttachmentCreator"}var t=V2NIMMessageAttachmentCreatorImpl.prototype;return t.createLocationMessageAttachment=function createLocationMessageAttachment(t,i,u){return{latitude:"number"==typeof t?t:0,longitude:"number"==typeof i?i:0,address:"string"==typeof u?u:""}},t.createCustomMessageAttachment=function createCustomMessageAttachment(t){return{raw:"string"==typeof t?t:""}},V2NIMMessageAttachmentCreatorImpl}(),hg=function(){function V2NIMClientAntispamUtilImpl(t){this.config={enable:!1},this.name="V2NIMClientAntispamUtil",this.core=t}var t=V2NIMClientAntispamUtilImpl.prototype;return t.setOptions=function setOptions(t){this.config=Dt(this.config,t)},t.reset=function reset(t){"destroy"===t&&(this.vocabInfo=void 0)},t.downloadLocalAntiSpamVocabs=function downloadLocalAntiSpamVocabs(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t;return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(this.config.enable){i.next=2;break}return i.abrupt("return");case 2:if(!this.vocabInfo){i.next=4;break}return i.abrupt("return");case 4:return i.prev=4,i.next=7,this.core.sendCmd("v2DownloadLocalAntiSpamVocabs",{tag:{version:0,md5:""}});case 7:(t=i.sent).content.data&&(this.vocabInfo=Dt(Dt({},t.content.data),{thesaurus:t.content.data.thesaurus?JSON.parse(t.content.data.thesaurus).thesaurus:[]})),i.next=14;break;case 11:i.prev=11,i.t0=i.catch(4),this.core.logger.warn("V2NIMLocalAntispamUtil::downloadLocalAntiSpamVocabs error",i.t0);case 14:case"end":return i.stop()}}),_callee,this,[[4,11]])})))},t.checkTextAntispam=function checkTextAntispam(t,i){if(void 0===i&&(i="**"),!this.config.enable)return{operateType:0,replacedText:t};if(validate({text:{type:"string",required:!0,allowEmpty:!1},replace:{type:"string"}},{text:t,replace:i},"",!0),!this.vocabInfo)return{operateType:0,replacedText:t};for(var u=t,m=0;m<this.vocabInfo.thesaurus.length;m++){var h=this.filterContent(u,this.vocabInfo.thesaurus[m],i);if(u=h.replacedText,2===h.operateType||3===h.operateType)return h}return{operateType:u===t?0:1,replacedText:u}},t.filterContent=function filterContent(t,i,u){for(var m=0;m<keys(i).length;m++){var h=keys(i)[m],v=h.match||i.match,M=h.operate||i.operate,I=void 0;try{I=this.matchContent(t,h.key,v,M,u)}catch(t){}if(I&&(t=I.replacedText,2===I.operateType||3===I.operateType))return I}return{operateType:1,replacedText:t}},t.matchContent=function matchContent(t,i,u,m,h){var v=!1,M=null;if(1===u){if(indexOf(t).call(t,i)>=0){v=!0;var I=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");M=new RegExp(I,"g")}}else 2===u&&(M=new RegExp(i,"g")).test(t)&&(v=!0);if(v&&M)switch(m){case 1:return{operateType:1,replacedText:t.replace(M,h)};case 2:return{operateType:2,replacedText:t};case 3:return{operateType:3,replacedText:t}}return{operateType:0,replacedText:t}},V2NIMClientAntispamUtilImpl}(),vg=function(t){function YSFServiceImpl(i){var u;return(u=t.call(this,"YSFService",i)||this).core._registerDep(mm,"V2NIMConversationIdUtil"),u.core._registerDep(pg,"V2NIMMessageCreator"),u.core._registerDep(mg,"V2NIMMessageAttachmentCreator"),u.core._registerDep(hg,"V2NIMClientAntispamUtil"),u.core._registerDep(ug,"V2NIMStorageService"),u.sendUtil=new fg(u.core,Je(u)),u.fileUtil=new Mh(u.core),u.model=new fm,u.notificationUtil=new Dh(u.core),registerParser({cmdMap:Lh,cmdConfig:Vh}),u}Nt(YSFServiceImpl,t);var i=YSFServiceImpl.prototype;return i.emit=function emit(i){for(var u,m,h,v=this.name+"::emit "+i.toString(),M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];if("onSendMessage"===i){var T=I[0];this.logger.log(""+v,T.messageClientId+"/"+T.messageServerId+";createTime:"+T.createTime+";","sendingState:"+T.sendingState+";attachmentUploadState:"+(T.attachmentUploadState||0)+";messageStatus:"+(null===(h=T.messageStatus)||void 0===h?void 0:h.errorCode))}else if("onReceiveMessages"===i){var C=I[0];this.logger.log(""+v,map$6(C).call(C,(function(t){return t.messageClientId+"/"+t.messageServerId+";createTime:"+t.createTime})))}else if("onReceiveCustomNotifications"===i){var E=I[0];this.logger.log(""+v,map$6(E).call(E,(function(t){return"sender:"+t.senderId+";receiver:"+t.receiverId+";ctype:"+t.conversationType+";time:"+t.timestamp})))}else{var A,k;(A=this.logger).log.apply(A,concat(k=[""+v]).call(k,I))}return(u=t.prototype.emit).call.apply(u,concat(m=[this,i]).call(m,I))},i.sendMessage=function sendMessage(t,i,u,m){return void 0===u&&(u={}),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var h,v,M,I,S,T;return ud.wrap((function _callee$(C){for(;;)switch(C.prev=C.next){case 0:return validate({message:{type:"object"}},{message:t},"",!0),t.messageClientId=t.messageClientId||jd(),validate(km,{conversationId:i,message:t,params:u},"",!0),validateConversationId(this.core.account,i),h=this.core.timeOrigin.getTimeNode(),v=this.sendUtil.prepareMessage(t,i,u),M=v.messageBeforeSend,I=v.clientAntispamResult,S=v.hiddenParams,C.next=8,this.sendUtil.doSendMessage({apiCallingTimeNode:h,messageBeforeSend:M,clientAntispamResult:I,hiddenParams:S,progress:m});case 8:return(T=C.sent).message.senderId===T.message.receiverId&&this.markMsgsAck([T.message]),C.abrupt("return",T);case 11:case"end":return C.stop()}}),_callee,this)})))},i.sendCustomNotification=function sendCustomNotification(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var m;return ud.wrap((function _callee2$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validateConversationId(this.core.account,t),validate(Uh,{content:i,params:u},"",!0),(m=this.notificationUtil.generateNotificationTag(t,i,u)).type=100,h.next=7,this.core.sendCmd("ysfSendCustomNotification",{tag:m});case 7:case"end":return h.stop()}}),_callee2,this)})))},i.sendMessageFn=function sendMessageFn(t){},i.cancelMessageAttachmentUpload=function cancelMessageAttachmentUpload(t){return this.fileUtil.cancelMessageAttachmentUpload(t)},i.markMsgsAck=function markMsgsAck(t){var i;if(t&&t.length>0){var u=filter(i=map$6(t).call(t,(function(t){return t.messageServerId}))).call(i,(function(t){return t&&"0"!==t}));0!==u.length&&this.core.sendCmd("ysfBatchMarkRead",{sid:101,cid:2,ids:u})}},i.markNotificationAck=function markNotificationAck(t){var i;if(t&&t.length>0){var u=filter(i=map$6(t).call(t,(function(t){return t.idServer}))).call(i,(function(t){return t&&"0"!==t}));0!==u.length&&this.core.sendCmd("ysfBatchMarkRead",{sid:101,cid:3,ids:u})}},i.ysfOnMsgHandler=function ysfOnMsgHandler(t){var i=fillIdServer(t,t.content.data,"messageServerId"),u=completeMessage(this.core,i);delete u.__clientExt,this.emit("onReceiveMessages",[u]),this.model.upsertMessages([u]),this.markMsgsAck([u])},i.ysfSyncOfflineMsgsHandler=function ysfSyncOfflineMsgsHandler(t){var i=this,u=t.content.datas;u=map$6(u).call(u,(function(t){return completeMessage(i.core,t)})),this.markMsgsAck(u),this.emit("onReceiveMessages",u),this.model.upsertMessages(u)},i.ysfOnSysNotificationHandler=function ysfOnSysNotificationHandler(t){var i=fillIdServer(t,t.content.data,"idServer");this.markNotificationAck([i]);var u=this.processSystemNotification(i);u&&this.emit("onReceiveCustomNotifications",[u])},i.processSystemNotification=function processSystemNotification(t){var i=Dt(Dt({},t),{conversationType:1});return delete i.type,i},i.ysfSyncSysNotificationHandler=function ysfSyncSysNotificationHandler(t){var i,u,m,h=this;this.markNotificationAck(t.content.datas);var v=filter(i=map$6(u=sort(m=t.content.datas).call(m,(function(t,i){return t.timestamp-i.timestamp}))).call(u,(function(t){return h.processSystemNotification(t)}))).call(i,(function(t){return t}));v&&this.emit("onReceiveCustomNotifications",v)},YSFServiceImpl}(hp),fg=function(){function SendUtil(t,i){this.uploadingMessageInfo={},this.core=t,this.service=i}var t=SendUtil.prototype;return t.prepareMessage=function prepareMessage(t,i,u,m){var h=this.checkIfResend(t),v=this.generateSendMessage({message:t,params:u,resend:h,conversationId:i,replyMessage:m}),M=Dt({},u.targetConfig?{targetConfig:u.targetConfig}:{}),I=this.checkIfAntispam(u,v),S=I.clientAntispamResult,T=I.text;return v.text=T,v.clientAntispamHit=!!S&&3===S.operateType,{messageBeforeSend:v,clientAntispamResult:S,hiddenParams:M}},t.checkIfAntispam=function checkIfAntispam(t,i){var u,m=i.text;if(t.clientAntispamEnabled&&(0===i.messageType||10===i.messageType))if(1===(u=this.core.V2NIMClientAntispamUtil.checkTextAntispam?this.core.V2NIMClientAntispamUtil.checkTextAntispam(i.text||"",t.clientAntispamReplace):{operateType:0,replacedText:""}).operateType)m=u.replacedText;else if(2===u.operateType)throw this.service.emit("onSendMessage",Dt(Dt({},i),{sendingState:2,messageStatus:{errorCode:zl.V2NIM_ERROR_CODE_CLIENT_ANTISPAM}})),new Yl({code:zl.V2NIM_ERROR_CODE_CLIENT_ANTISPAM,detail:{reason:"sendMessage: text intercepted by client antispam"}});return{clientAntispamResult:u,text:m}},t.doMsgReceiveReport=function doMsgReceiveReport(t,i){if(t.senderId!==this.core.account){var u=get(t,"__clientExt.statistics.apiCallingTime")||0,m=get(t,"__clientExt.statistics.sendTime")||0,h=get(t,"__clientExt.statistics.attachUploadDuration")||0,v=this.core.timeOrigin.getNTPTime(),M=t.createTime,I=this.core.timeOrigin.checkNodeReliable(i.__receiveTimeNode)?this.core.timeOrigin.getNTPTime(i.__receiveTimeNode):v;this.core.reporter.report("msgReceive",{msgId:t.messageServerId,clientId:t.messageClientId,serverTime:t.createTime,receiveTime:I,fromAccid:t.senderId,toAccid:t.receiverId,type:conversationTypeV2ToV1(t.conversationType),tid:1===t.conversationType?"":t.receiverId,apiCallingTime:u,sendTime:m,attachUploadDuration:h,callbackTime:v,preHandleTime:v,result:200,failReason:"",rt:v-M})}},t.checkIfResend=function checkIfResend(t){var i=this.service.model.getMessageById(t.messageClientId),u=!1;if("messageServerId"in t&&"0"!==t.messageServerId&&""!==t.messageServerId)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"sendMessage: message has already been sent"}});if(i&&"messageServerId"in i&&"0"!==i.messageServerId&&""!==i.messageServerId)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"sendMessage: message has already been sent"}});return i&&(u=!0),u},t.doSendMessage=function doSendMessage(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v,M,I,S,T,C,E,A,k,R;return ud.wrap((function _callee$(w){for(;;)switch(w.prev=w.next){case 0:if(u=t.apiCallingTimeNode,m=t.messageBeforeSend,h=t.clientAntispamResult,v=t.hiddenParams,M=t.progress,I={},!(S=this.service instanceof vg)){w.next=7;break}T="ysfSendMessage",w.next=20;break;case 7:if(1!==m.conversationType){w.next=11;break}T="v2SendP2pMessage",w.next=20;break;case 11:if(2!==m.conversationType){w.next=15;break}T="v2SendTeamMessage",w.next=20;break;case 15:if(3!==m.conversationType){w.next=19;break}T="v2SendSuperTeamMessage",w.next=20;break;case 19:throw new Jl({detail:{reason:"conversationType: "+m.conversationType+" is not supported"}});case 20:if(this.service.sendMessageFn(m),!S&&this.core.eventBus.emit("forwardSend/V2NIMMessageService/sendMsg",m),!m.attachment||!("uploadState"in m.attachment)||m.attachment.url||0!==m.attachment.uploadState&&2!==m.attachment.uploadState){w.next=48;break}return C=to(),w.prev=24,m.attachmentUploadState=3,m.attachment.uploadState=3,this.service.emit("onSendMessage",m),w.next=30,this.service.fileUtil.doSendFile(m,M);case 30:m.attachmentUploadState=1,m.attachment.uploadState=1,this.service.emit("onSendMessage",m),w.next=45;break;case 35:throw w.prev=35,w.t0=w.catch(24),m.attachmentUploadState=2,m.attachment.uploadState=2,m.sendingState=2,m.messageStatus={errorCode:w.t0.code||zl.V2NIM_ERROR_CODE_UNKNOWN},this.service.emit("onSendMessage",m),I.attachUploadDuration=to()-C,this.doSendMessageFailed(u,I,m,w.t0),w.t0;case 45:I.attachUploadDuration=to()-C,w.next=49;break;case 48:this.service.emit("onSendMessage",m);case 49:return this.core.timeOrigin.checkNodeReliable(u)&&(I.apiCallingTime=this.core.timeOrigin.getNTPTime(u),I.sendTime=this.core.timeOrigin.getNTPTime(),m.__clientExt={statistics:I}),w.prev=50,w.next=53,this.core.sendCmd(T,{tag:Dt({},m,v)});case 53:E=w.sent,w.next=63;break;case 56:throw w.prev=56,w.t1=w.catch(50),this.doSendMessageFailed(u,I,m,w.t1),m.sendingState=2,m.messageStatus={errorCode:w.t1.code||zl.V2NIM_ERROR_CODE_UNKNOWN},this.service.emit("onSendMessage",m),w.t1;case 63:return A=get(E,"content.data.errorCode"),k=Dt(Dt(Dt(Dt({},m),E.content.data),m.aiConfig?{aiConfig:Dt(Dt({},m.aiConfig),(null===(i=E.content.data)||void 0===i?void 0:i.aiConfig)||{})}:{}),{sendingState:1,messageStatus:{errorCode:A&&200!==A?A:200}}),this.service.sendMessageFn(k),!S&&this.core.eventBus.emit("forwardSend/V2NIMMessageService/sendMsg",k),this.doMsgSendReport(u,I,k),(R=k.antispamResult)&&(k.messageStatus.errorCode=zl.V2NIM_ERROR_CODE_SERVER_ANTISPAM),delete k.antispamResult,this.service.emit("onSendMessage",k),w.abrupt("return",Dt(Dt({message:k},R?{antispamResult:R}:{}),h?{clientAntispamResult:h}:{}));case 73:case"end":return w.stop()}}),_callee,this,[[24,35],[50,56]])})))},t.doSendMessageFailed=function doSendMessageFailed(t,i,u,m){var h=Dt(Dt({},u),{sendingState:2});this.core.eventBus.emit("forwardSend/V2NIMMessageService/sendMsg",h),this.service.sendMessageFn(h),this.doMsgSendReport(t,i,u,m)},t.doMsgSendReport=function doMsgSendReport(t,i,u,m){i.apiCallingTime=this.core.timeOrigin.getNTPTime(t),i.sendTime=this.core.timeOrigin.getNTPTime();var h=this.core.timeOrigin.getNTPTime(),v=get(m,"detail.reason");this.core.reporter.report("msgSend",{msgId:u.messageServerId,clientId:u.messageClientId,msgTime:u.createTime,fromAccid:u.senderId,toAccid:u.receiverId,type:conversationTypeV2ToV1(u.conversationType),tid:1===u.conversationType?"":u.receiverId,result:m?m.code:200,failReason:v||(null==m?void 0:m.message)||"",rt:h-i.apiCallingTime,apiCallingTime:i.apiCallingTime,sendTime:i.sendTime,attachUploadDuration:i.attachUploadDuration,apiCallbackTime:h})},t.generateSendMessage=function generateSendMessage(t){var i,u,m=t.conversationId,h=t.replyMessage,v=t.resend,M=t.message,I=t.params,S={};if(h){var T=h.threadRoot;S={threadReply:{senderId:h.senderId,receiverId:h.receiverId,messageServerId:h.messageServerId,createTime:h.createTime,messageClientId:h.messageClientId,conversationType:h.conversationType,conversationId:h.conversationId},threadRoot:{senderId:T?T.senderId:h.senderId,receiverId:T?T.receiverId:h.receiverId,messageServerId:T?T.messageServerId:h.messageServerId,createTime:T?T.createTime:h.createTime,messageClientId:T?T.messageClientId:h.messageClientId,conversationType:T?T.conversationType:h.conversationType,conversationId:T?T.conversationId:h.conversationId}}}var C=this.core.V2NIMConversationIdUtil.parseConversationType(m),E=this.core.V2NIMConversationIdUtil.parseConversationTargetId(m);I.pushConfig&&!0!==I.pushConfig.forcePush&&(delete I.pushConfig.forcePushContent,delete I.pushConfig.forcePushAccountIds);var A={},k={};if(I.aiConfig){var R=get(I,"aiConfig.content.msg"),w=get(I,"aiConfig.content.type")||0;R?k={msg:R,type:w}:void 0===R&&0===M.messageType&&(k={msg:M.text||"",type:w}),(A=Dt({aiStreamStatus:0,aiStream:!1},I.aiConfig)).aiStatus=1,void 0!==k.msg&&(A.content=k)}var N=null===(u=null===(i=this.core.V2NIMUserService)||void 0===i?void 0:i.model)||void 0===u?void 0:u.getUser(this.core.account),x=(null==N?void 0:N.updateTime)||0;return Dt(Dt(Dt(Dt(Dt(Dt(Dt(Dt({},M),S),{messageConfig:Dt(Dt({},M.messageConfig),I.messageConfig),routeConfig:Dt(Dt({},M.routeConfig),I.routeConfig),pushConfig:Dt(Dt({},M.pushConfig),I.pushConfig),antispamConfig:Dt(Dt({},M.antispamConfig),I.antispamConfig),robotConfig:Dt(Dt({},M.robotConfig),I.robotConfig)}),A&&A.accountId?{aiConfig:A}:{}),M.attachment?{attachment:Dt({},M.attachment)}:{}),{resend:v,senderId:this.core.account,conversationType:C,receiverId:E,conversationId:this.core.V2NIMConversationIdUtil.messageConversationId({conversationType:C,senderId:this.core.account,receiverId:E})}),x?{userUpdateTime:x}:{}),{sendingState:3})},SendUtil}(),yg=function(){function ModifyUtil(t,i){this.core=t,this.service=i}var t=ModifyUtil.prototype;return t.checkIfModify=function checkIfModify(t,i){var u,m;if("0"===t.messageServerId)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"modifyMessage: messageServerId cannot be empty"}});if(!includes(u=[0,1,2,3,4,6,10,12,100]).call(u,t.messageType))throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"modifyMessage: messageType "+t.messageType+" not correct"}});if(includes(m=[0,1,2,3,6,10,12]).call(m,t.messageType)&&i.attachment)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"modifyMessage: messageType "+t.messageType+" can not modify attachment"}});var h=["subType","text","serverExtension","attachment"];if(!some(h).call(h,(function(t){return void 0!==get(i,t)})))throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"modifyMessage: missing modified params"}});if(every(h).call(h,(function(u){return"attachment"===u?t.attachment&&i.attachment?attachmentToRaw(t.messageType,t.attachment)===attachmentToRaw(t.messageType,i.attachment):!i.attachment:get(t,u)===get(i,u)})))throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"modifyMessage: no change"}})},t.prepareMessage=function prepareMessage(t,i){var u=this.generateSendMessage(t,i),m=this.checkIfAntispam(i,u),h=m.clientAntispamResult,v=m.text;return u.text=v,u.clientAntispamHit=!!h&&3===h.operateType,{messageBeforeSend:u,clientAntispamResult:h}},t.modifyMessage=function modifyMessage(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v,M;return ud.wrap((function _callee$(I){for(;;)switch(I.prev=I.next){case 0:if(1!==t.conversationType){I.next=4;break}u="v2MessageP2pModify",I.next=13;break;case 4:if(2!==t.conversationType){I.next=8;break}u="v2MessageTeamModify",I.next=13;break;case 8:if(3!==t.conversationType){I.next=12;break}u="v2MessageSuperTeamModify",I.next=13;break;case 12:throw new Jl({detail:{reason:"conversationType: "+t.conversationType+" is not supported"}});case 13:return I.next=15,this.core.sendCmd(u,{tag:t});case 15:if(m=I.sent,!i||3!==i.operateType){I.next=18;break}return I.abrupt("return",{errorCode:zl.V2NIM_ERROR_CODE_CLIENT_ANTISPAM,clientAntispamResult:i});case 18:if(h=Dt(Dt({},t),m.content.data),!(v=h.antispamResult)){I.next=22;break}return I.abrupt("return",Dt({errorCode:zl.V2NIM_ERROR_CODE_SERVER_ANTISPAM,antispamResult:v},i?{clientAntispamResult:i}:{}));case 22:return delete h.antispamResult,M=completeMessage(this.core,h),this.service.model.upsertMessages([M]),this.core.eventBus.emit("V2NIMMessageService/modifyMsg",M),this.core.eventBus.emit("forwardSend/V2NIMMessageService/modifyMsg",M),I.abrupt("return",Dt(Dt({errorCode:200,message:M},v?{antispamResult:v}:{}),i?{clientAntispamResult:i}:{}));case 28:case"end":return I.stop()}}),_callee,this)})))},t.checkIfAntispam=function checkIfAntispam(t,i){var u,m=i.text;if(t.clientAntispamEnabled&&(0===i.messageType||10===i.messageType))if(1===(u=this.core.V2NIMClientAntispamUtil.checkTextAntispam?this.core.V2NIMClientAntispamUtil.checkTextAntispam(i.text||"",t.clientAntispamReplace):{operateType:0,replacedText:""}).operateType)m=u.replacedText;else if(2===u.operateType)throw new Yl({code:zl.V2NIM_ERROR_CODE_CLIENT_ANTISPAM,detail:{reason:"sendMessage: text intercepted by client antispam"}});return{clientAntispamResult:u,text:m}},t.generateSendMessage=function generateSendMessage(t,i){var u;return Dt(Dt({messageConfig:{lastMessageUpdateEnabled:null===(u=t.messageConfig)||void 0===u?void 0:u.lastMessageUpdateEnabled},routeConfig:Dt({routeEnabled:!0},i.routeConfig),pushConfig:Dt({pushEnabled:!0,pushNickEnabled:!0,forcePush:!1},i.pushConfig),antispamConfig:Dt({antispamEnabled:!0},i.antispamConfig)},i.attachment?{attachment:i.attachment}:{}),{conversationType:t.conversationType,senderId:t.senderId,receiverId:t.receiverId,createTime:t.createTime,messageClientId:t.messageClientId,messageServerId:t.messageServerId,messageType:t.messageType,subType:i.subType,text:i.text,serverExtension:i.serverExtension})},ModifyUtil}(),Mg=function(){function DeleteUtil(t,i){var u=this;this.emitRevokeMessage=function(t){var i=map$6(t).call(t,(function(t){var i=formatRevokeMessage(u.core,t);return 3===i.messageRefer.conversationType?u.core.eventBus.emit("V2NIMSync/updateTimetag",{deleteSuperTeamMsg:t.createTime}):u.core.eventBus.emit("V2NIMSync/updateTimetag",{recallMsg:t.createTime}),i}));forEach$1(i).call(i,(function(t){u.service.model.deleteMessage(t.messageRefer.messageClientId)})),u.service.emit("onMessageRevokeNotifications",i),u.core.eventBus.emit("V2NIMMessageService/revokeMessages",i)},this.core=t,this.service=i,this.logger=t.logger}var t=DeleteUtil.prototype;return t.revokeMessage=function revokeMessage(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v,M,I,S;return ud.wrap((function _callee$(T){for(;;)switch(T.prev=T.next){case 0:if(validate(Rm,{message:t,params:i},"",!0),validateConversationId(this.core.account,t.conversationId),1!==t.conversationType||t.senderId===this.core.account){T.next=6;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"revokeMessage: p2p message senderId is not current user"}});case 6:if(t.messageServerId&&"0"!==t.messageServerId){T.next=8;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"revokeMessage: cannot revoke message with invalid messageServerId: "+t.messageServerId}});case 8:return h=3===t.conversationType?"v2RevokeSuperTeamMessage":"v2RevokeMessage",(u={})[1]=7,u[2]=8,u[3]=12,v=u,M=Dt(Dt(Dt({},t),i),{attach:i&&i.serverExtension,sysMsgType:v[t.conversationType],opeAccount:this.core.account}),T.next=13,this.core.sendCmd(h,{tag:M});case 13:(m={})[1]=1,m[2]=2,m[3]=3,I=m,S=[JSON.parse(Un({postscript:i&&i.postscript,revokeType:I[t.conversationType],revokeAccountId:this.core.account,serverExtension:i&&i.serverExtension,messageRefer:formatMessageRefer(this.core,t)}))],this.revokeMessagesFn(S),this.core.eventBus.emit("forwardSend/V2NIMMessageService/revokeMessage",M);case 17:case"end":return T.stop()}}),_callee,this)})))},t.deleteMessage=function deleteMessage(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u,m,h,v;return ud.wrap((function _callee2$(M){for(;;)switch(M.prev=M.next){case 0:if(validate(Om,t,"",!0),3!==t.sendingState){M.next=5;break}this.service.fileUtil.cancelMessageAttachmentUpload(t),M.next=7;break;case 5:if(1===t.sendingState||2===t.sendingState){M.next=7;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"deleteMessage: cannot delete message with sendingState: "+t.sendingState}});case 7:if(u={messageRefer:formatMessageRefer(this.core,t),serverExtension:i},m=this.core.timeOrigin.getNTPTime(),!t.messageServerId||"0"===t.messageServerId||1!==t.sendingState){M.next=14;break}return M.next=12,this.core.sendCmd("v2DeleteMessage",{tag:u});case 12:h=M.sent,m=h.content.timetag;case 14:v=[{serverExtension:i,messageRefer:formatMessageRefer(this.core,t),deleteTime:m}],this.core.eventBus.emit("forwardSend/V2NIMMessageService/deleteSelfMsgs",[Dt(Dt({},u),{deleteTime:m})]),this.deleteMessagesFn(v);case 17:case"end":return M.stop()}}),_callee2,this)})))},t.deleteMessages=function deleteMessages(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var u,m,h,v,M,I,S,T,C,E,A=this;return ud.wrap((function _callee3$(k){for(;;)switch(k.prev=k.next){case 0:if(validate(Pm,{messages:t},"",!0),m=[],h=[],0!==t.length){k.next=7;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"deleteMessages: message array length is 0"}});case 7:v=t[0].conversationId,M=0;case 9:if(!(M<t.length)){k.next=22;break}if(3!==t[M].sendingState){k.next=14;break}this.service.fileUtil.cancelMessageAttachmentUpload(t[M]),k.next=16;break;case 14:if(1===t[M].sendingState||2===t[M].sendingState){k.next=16;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"deleteMessages: sendingState incorrect:"+t[M].sendingState+", please check message at index: "+M}});case 16:if(!(M>=1&&t[M].conversationId!==v)){k.next=18;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"deleteMessages: only allow to delete messages from same conversation"}});case 18:t[M].messageServerId&&"0"!==t[M].messageServerId?m.push(t[M]):h.push(t[M]);case 19:M++,k.next=9;break;case 22:if(I=this.core.timeOrigin.getNTPTime(),S=concat(u=[]).call(u,h),k.prev=24,!(m.length>0)){k.next=31;break}return k.next=28,this.core.sendCmd("v2DeleteMessages",{tag:map$6(m).call(m,(function(t){return{messageRefer:t,serverExtension:i}}))});case 28:C=k.sent,I=C.content.timetag,S=concat(T=[]).call(T,S,m);case 31:k.next=40;break;case 33:if(k.prev=33,k.t0=k.catch(24),0!==h.length){k.next=39;break}throw k.t0;case 39:this.logger.warn("V2NIMMessageService:deleteMessages: delete messages with serverId failed");case 40:E=map$6(S).call(S,(function(t){return{serverExtension:i,messageRefer:formatMessageRefer(A.core,t),deleteTime:I}})),this.core.eventBus.emit("forwardSend/V2NIMMessageService/deleteSelfMsgs",map$6(S).call(S,(function(t){return{messageRefer:t,serverExtension:i,deleteTime:I}}))),this.deleteMessagesFn(E);case 43:case"end":return k.stop()}}),_callee3,this,[[24,33]])})))},t.revokeMessagesFn=function revokeMessagesFn(t){var i=this;forEach$1(t).call(t,(function(t){i.service.model.deleteMessage(t.messageRefer.messageClientId)})),this.service.emit("onMessageRevokeNotifications",t),this.core.eventBus.emit("V2NIMMessageService/revokeMessages",t)},t.deleteMessagesFn=function deleteMessagesFn(t){var i=this;forEach$1(t).call(t,(function(t){i.service.model.deleteMessage(t.messageRefer.messageClientId),i.core.eventBus.emit("V2NIMSync/updateTimetag",{deleteSelfMsgs:t.deleteTime})})),this.service.emit("onMessageDeletedNotifications",t),this.core.eventBus.emit("V2NIMMessageService/deleteMessages",t)},DeleteUtil}(),Ig=function(){function AIUtil(t,i){this.core=t,this.service=i,this.logger=t.logger}var t=AIUtil.prototype;return t.stopAIStreamMessage=function stopAIStreamMessage(t,i){var u;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkAI(),m.next=3,this.core.sendCmd("v2AIStopModelStreamCall",{tag:{serverId:t.messageServerId,clientId:t.messageClientId,type:t.conversationType,from:t.senderId,to:t.receiverId,aiAccount:null===(u=t.aiConfig)||void 0===u?void 0:u.accountId,opeType:i.operationType,updateContent:i.updateContent,messageTime:t.createTime}});case 3:this.logger.log("V2AIUtil::streamMessageStop,clientId:"+t.messageClientId),this.core.V2NIMAIService.model.completeAiStream(t.messageClientId);case 5:case"end":return m.stop()}}),_callee,this)})))},t.regenAIMessage=function regenAIMessage(t,i){var u,m,h,v,M,I,S,T;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var C;return ud.wrap((function _callee2$(E){for(;;)switch(E.prev=E.next){case 0:if(this.checkAI(),!(C=this.core.V2NIMAIService.model.getAiStream(t.messageClientId))){E.next=7;break}if(null==C?void 0:C.isComplete){E.next=5;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"msg::regenAIMessage streamCache is not complete, msgId:"+t.messageClientId}});case 5:E.next=9;break;case 7:if(-1!==(null===(u=t.streamConfig)||void 0===u?void 0:u.status)&&1!==(null===(m=t.streamConfig)||void 0===m?void 0:m.status)){E.next=9;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"msg::regenAIMessage message streamConfig.status forbidden "+t.streamConfig.status}});case 9:return E.next=11,this.core.sendCmd("v2AIRegenMessage",{tag:{fromAccount:t.senderId,to:t.receiverId,aiAccount:null===(h=t.aiConfig)||void 0===h?void 0:h.accountId,serverId:t.messageServerId,clientId:t.messageClientId,time:t.createTime,type:t.conversationType,opeType:i.operationType,replyMsgFromAccount:null===(v=t.threadReply)||void 0===v?void 0:v.senderId,replyMsgToAccount:null===(M=t.threadReply)||void 0===M?void 0:M.receiverId,replyMsgTime:null===(I=t.threadReply)||void 0===I?void 0:I.createTime,replyMsgIdServer:null===(S=t.threadReply)||void 0===S?void 0:S.messageServerId,replyMsgIdClient:null===(T=t.threadReply)||void 0===T?void 0:T.messageClientId}});case 11:1===i.operationType&&this.core.V2NIMAIService.model.setAiStream(t.messageClientId,{isComplete:!1,queryStatus:0,chunks:[]});case 12:case"end":return E.stop()}}),_callee2,this)})))},t.checkAI=function checkAI(){if(!this.hasAI())throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"V2NIMAIService is not registered"}})},t.hasAI=function hasAI(){var t;return!!(null===(t=this.core.V2NIMAIService)||void 0===t?void 0:t.name)},AIUtil}(),_g=function(){function V2NIMMMessageHandlerImpl(t,i){this.core=t,this.service=i,this.model=i.model,this.receiptUtil=i.receiptUtil,this.logger=this.core.logger}var t=V2NIMMMessageHandlerImpl.prototype;return t.setAIStreamPlaceholder=function setAIStreamPlaceholder(t){var i=this;this.service.aiUtil.hasAI()&&forEach$1(t).call(t,(function(t){var u;1===(null===(u=t.streamConfig)||void 0===u?void 0:u.status)&&i.core.V2NIMAIService.model.setAiStream(t.messageClientId,{isComplete:!1,queryStatus:0,chunks:[],msg:t},!0)}))},t.onMsgHandler=function onMsgHandler(t){var i=fillIdServer(t,t.content.msg,"messageServerId"),u=i._conversationOnlineSyncNotify,m=i._conversationOnlineSyncData,h=__rest(i,["_conversationOnlineSyncNotify","_conversationOnlineSyncData"]),v=completeMessage(this.core,h,1),M=this.service._filterMessage(v);this.logger.log("v2OnMsgHandler::recvMsg "+v.messageClientId+"/"+v.messageServerId+"/"+v.createTime+";isHitFilter:"+M),3===v.conversationType?this.core.eventBus.emit("V2NIMSync/updateTimetag",{superTeamRoamingMsgs:v.createTime,offlineMsgs:v.createTime}):this.core.eventBus.emit("V2NIMSync/updateTimetag",{roamingMsgs:v.createTime,offlineMsgs:v.createTime}),this.service.config.compatibleWithV1||(this.service.markMsgsAck([v]),this.service.sendUtil.doMsgReceiveReport(v,t)),delete v.__clientExt,this.setAIStreamPlaceholder([v]),5!==v.messageType&&this.core.V2NIMUserService.checkUserUpdate&&this.core.V2NIMUserService.checkUserUpdate(v,v.userUpdateTime),5===v.messageType&&this.core.eventBus.emit("V2NIMTeamService/notification",i),M||(this.service.emit("onReceiveMessages",[v]),this.model.upsertMessages([v]),u&&this.core.eventBus.emit("V2NIMConversationService/conversationOnlineSyncNotify",{content:{info:JSON.parse(u),data:JSON.parse(m)}},v),this.core.eventBus.emit("V2NIMMessageService/onMsg",v))},t.syncOfflineMsgsHandler=function syncOfflineMsgsHandler(t){var i=this,u=t.content.datas;u=map$6(u).call(u,(function(t){return completeMessage(i.core,t,2)})),0!==(u=this.service._filterMessagesByFn(u)).length&&(!this.service.config.compatibleWithV1&&this.service.markMsgsAck(u),this.service.emit("onReceiveMessages",u),this.model.upsertMessages(u),this.core.eventBus.emit("V2NIMMessageService/offlineMsgs",u))},t.syncRoamingMsgsHandler=function syncRoamingMsgsHandler(t){var i=this,u=t.content.datas;u=map$6(u).call(u,(function(t){return completeMessage(i.core,t,3)})),this.setAIStreamPlaceholder(u),0!==(u=this.service._filterMessagesByFn(u)).length&&(this.service.emit("onReceiveMessages",u),this.model.upsertMessages(u),this.core.eventBus.emit("V2NIMMessageService/roamingMsgs",u))},t.onP2PMessageReceiptsHandler=function onP2PMessageReceiptsHandler(t){this.receiptUtil.onP2PMessageReceiptsHandler(t)},t.onTeamMessageReceiptsHandler=function onTeamMessageReceiptsHandler(t){this.receiptUtil.onTeamMessageReceiptsHandler(t)},t.syncP2PMessagReceiptsHandler=function syncP2PMessagReceiptsHandler(t){this.receiptUtil.syncP2PMessagReceiptsHandler(t)},t.syncP2pMessagReceiptsV2Handler=function syncP2pMessagReceiptsV2Handler(t){this.receiptUtil.syncP2pMessagReceiptsV2Handler(t)},t.syncRevokeMessageHandler=function syncRevokeMessageHandler(t){this.service.deleteUtil.emitRevokeMessage(t.content.datas)},t.onRevokeMessageHandler=function onRevokeMessageHandler(t){var i=t.content.data;this.service.deleteUtil.emitRevokeMessage([i])},t.onDeleteMessageHandler=function onDeleteMessageHandler(t){var i=t.content.data,u={serverExtension:i.serverExtension,deleteTime:i.deleteTime,messageRefer:completeMessageRefer(this.core,i.messageRefer)};this.service.deleteUtil.deleteMessagesFn([u])},t.onDeleteMessagesHandler=function onDeleteMessagesHandler(t){var i,u=this,m=map$6(i=t.content.data).call(i,(function(t){return{serverExtension:t.serverExtension,deleteTime:t.deleteTime,messageRefer:completeMessageRefer(u.core,t.messageRefer)}}));this.service.deleteUtil.deleteMessagesFn(m)},t.syncOnDeleteMessagesHandler=function syncOnDeleteMessagesHandler(t){var i=this,u=t.content.datas,m=map$6(u).call(u,(function(t){return{serverExtension:t.serverExtension,deleteTime:t.deleteTime,messageRefer:completeMessageRefer(i.core,t.messageRefer)}}));this.service.emit("onMessageDeletedNotifications",m)},t.v2MessageOnModifiedHandler=function v2MessageOnModifiedHandler(t){var i=completeMessage(this.core,t.content.data);this.model.upsertMessages([i]),this.service.aiUtil.hasAI()&&this.core.V2NIMAIService.model.completeAiStream(i.messageClientId),this.core.eventBus.emit("forwardSend/V2NIMMessageService/modifyMsg",i),this.core.eventBus.emit("V2NIMMessageService/modifyMsg",i),this.core.eventBus.emit("V2NIMSync/updateTimetag",3===i.conversationType?{superTeamModifyMessage:i.modifyTime}:{p2pTeamModifyMessage:i.modifyTime}),this.service.emit("onReceiveMessagesModified",[i])},t.v2MessageSyncModifiedHandler=function v2MessageSyncModifiedHandler(t){var i,u,m=this,h=filter(i=map$6(u=t.content.datas).call(u,(function(t){return completeMessage(m.core,t)}))).call(i,(function(t){var i,u=(null===(i=m.model.getMessageById(t.messageClientId))||void 0===i?void 0:i.modifyTime)||0;return(t.modifyTime||0)>u}));h.length>0&&(this.model.upsertMessages(h),forEach$1(h).call(h,(function(t){m.service.aiUtil.hasAI()&&m.core.V2NIMAIService.model.completeAiStream(t.messageClientId),m.core.eventBus.emit("forwardSend/V2NIMMessageService/modifyMsg",t)})),this.service.emit("onReceiveMessagesModified",h))},t.v2MessageSyncSuperTeamModifiedHandler=function v2MessageSyncSuperTeamModifiedHandler(t){this.v2MessageSyncModifiedHandler(t)},V2NIMMMessageHandlerImpl}(),Sg=function(){function V2NIMMessageEventImpl(t,i){this.core=t,this.service=i,this.logger=this.core.logger}var t=V2NIMMessageEventImpl.prototype;return t.setListener=function setListener(){var t,i,u,m=this;this.core.eventBus.on("forwardReceive/V2NIMMessageService/sendMsg",bind$1(t=this.service.sendMessageFn).call(t,this.service)),this.core.eventBus.on("forwardReceive/V2NIMMessageService/revokeMessages",bind$1(i=this.service.deleteUtil.emitRevokeMessage).call(i,this.service.deleteUtil)),this.core.eventBus.on("forwardReceive/V2NIMMessageService/deleteMessages",bind$1(u=this.service.deleteUtil.deleteMessagesFn).call(u,this.service.deleteUtil)),this.core.eventBus.on("V2NIMConversationService/deleteConversation",(function(t){forEach$1(t).call(t,(function(t){return m.service.model.deleteMessages(t)}))})),this.core.eventBus.on("V2NIMAIService/receiveMessagesModified",(function(t){return m.service.emit("onReceiveMessagesModified",t)}))},t.beforeEmit=function beforeEmit(t){for(var i,u,m,h=this.service.name+"::emit "+t.toString(),v=arguments.length,M=new Array(v>1?v-1:0),I=1;I<v;I++)M[I-1]=arguments[I];if("onSendMessage"===t){var S=M[0];this.logger.log(""+h,S.messageClientId+"/"+S.messageServerId+"/"+S.createTime+";","sendingState:"+S.sendingState+";attachmentUploadState:"+(S.attachmentUploadState||0)+";messageStatus:"+(null===(i=S.messageStatus)||void 0===i?void 0:i.errorCode)+";config.lastMsg:"+(null===(u=S.messageConfig)||void 0===u?void 0:u.lastMessageUpdateEnabled)+";config.unread:"+(null===(m=S.messageConfig)||void 0===m?void 0:m.unreadEnabled))}else if("onReceiveMessages"===t||"onReceiveMessagesModified"===t){var T=M[0];this.logger.log(""+h,map$6(T).call(T,(function(t){var i,u;return t.messageClientId+"/"+t.messageServerId+"/"+t.createTime+";config.lastMsg:"+(null===(i=t.messageConfig)||void 0===i?void 0:i.lastMessageUpdateEnabled)+";config.unread:"+(null===(u=t.messageConfig)||void 0===u?void 0:u.unreadEnabled)})))}else if("onMessageRevokeNotifications"===t){var C=M[0];this.logger.log(""+h,map$6(C).call(C,(function(t){return"msg:"+t.messageRefer.messageClientId+"/"+t.messageRefer.messageServerId+";revokeAccountId:"+t.revokeAccountId})))}else if("onMessageDeletedNotifications"===t){var E=M[0];this.logger.log(""+h,map$6(E).call(E,(function(t){return"msg:"+t.messageRefer.messageClientId+"/"+t.messageRefer.messageServerId+";deleteTime:"+t.deleteTime})))}else{var A,k;(A=this.logger).log.apply(A,concat(k=[""+h]).call(k,M))}},V2NIMMessageEventImpl}(),Tg=function(t){function V2NIMMessageServiceImpl(i,u){var m;return void 0===u&&(u={}),(m=t.call(this,"V2NIMMessageService",i)||this).customAttachmentParsers=[],m.config={compatibleWithV1:!0},m.filterFn=void 0,m.core._registerDep(mm,"V2NIMConversationIdUtil"),m.core._registerDep(pg,"V2NIMMessageCreator"),m.core._registerDep(mg,"V2NIMMessageAttachmentCreator"),m.core._registerDep(hg,"V2NIMClientAntispamUtil"),m.receiptUtil=new oh(m.core,Je(m)),m.fileUtil=new Mh(m.core),m.sendUtil=new fg(m.core,Je(m)),m.modifyUtil=new yg(m.core,Je(m)),m.deleteUtil=new Mg(m.core,Je(m)),m.aiUtil=new Ig(m.core,Je(m)),m.model=new fm,m.event=new Sg(m.core,Je(m)),m.handler=new _g(m.core,Je(m)),"v2"!==m.core.options.apiVersion?Je(m):(registerParser({cmdMap:_h,cmdConfig:kh}),m.setOptions(u),m.setListener(),m)}Nt(V2NIMMessageServiceImpl,t);var i=V2NIMMessageServiceImpl.prototype;return i.setOptions=function setOptions(t){var i;(null===(i=this.core.msg)||void 0===i?void 0:i.name)?this.config.compatibleWithV1=!0:this.config.compatibleWithV1=!1,this.config=Dt(this.config,t)},i.setListener=function setListener(){this.event.setListener()},i.reset=function reset(){this.model.reset(),this.receiptUtil.reset()},i.emit=function emit(i){for(var u,m,h,v,M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];return(u=this.event).beforeEmit.apply(u,concat(m=[i]).call(m,I)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,I))},i.checkExtendUtil=function checkExtendUtil(){var t;if(!(null===(t=this.core.V2NIMMessageExtendUtil)||void 0===t?void 0:t.name))throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"V2NIMMessageLogUtil is not registered"}})},i.checkLogUtil=function checkLogUtil(){var t;if(!(null===(t=this.core.V2NIMMessageLogUtil)||void 0===t?void 0:t.name))throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"V2NIMMessageExtendUtil is not registered"}})},i.getMessageList=function getMessageList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),this.checkLogUtil(),u.next=4,this.core.V2NIMMessageLogUtil.getMessageList(t);case 4:return i=u.sent,i=this._filterMessageByClearTime(t.conversationId,i),i=this._filterMessagesByFn(i),u.abrupt("return",i);case 8:case"end":return u.stop()}}),_callee,this)})))},i.getMessageListEx=function getMessageListEx(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i;return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),this.checkLogUtil(),u.next=4,this.core.V2NIMMessageLogUtil.getMessageList(t);case 4:return i=u.sent,i=this._filterMessageByClearTime(t.conversationId,i),u.abrupt("return",{messages:this._filterMessagesByFn(i),anchorMessage:i.length>0?i[i.length-1]:null});case 7:case"end":return u.stop()}}),_callee2,this)})))},i.getMessageListByRefers=function getMessageListByRefers(t){return this.checkV2(),this.checkLogUtil(),this.core.V2NIMMessageLogUtil.getMessageListByRefers(t)},i.clearHistoryMessage=function clearHistoryMessage(t){return this.checkV2(),this.checkLogUtil(),this.core.V2NIMMessageLogUtil.clearHistoryMessage(t)},i.clearRoamingMessage=function clearRoamingMessage(t){return this.checkV2(),this.checkLogUtil(),this.core.V2NIMMessageLogUtil.clearRoamingMessage(t)},i.pinMessage=function pinMessage(t,i){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.pinMessage(t,i)},i.unpinMessage=function unpinMessage(t,i){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.unpinMessage(t,i)},i.updatePinMessage=function updatePinMessage(t,i){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.updatePinMessage(t,i)},i.voiceToText=function voiceToText(t){return this.checkV2(),this.checkExtendUtil(),"string"==typeof t.duration&&(t.duration=Number(t.duration)),this.core.V2NIMMessageExtendUtil.voiceToText(t)},i.getPinnedMessageList=function getPinnedMessageList(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.getPinnedMessageList(t)},i.addQuickComment=function addQuickComment(t,i,u,m){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.addQuickComment(t,i,u,m)},i.removeQuickComment=function removeQuickComment(t,i,u){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.removeQuickComment(t,i,u)},i.getQuickCommentList=function getQuickCommentList(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.getQuickCommentList(t)},i.addCollection=function addCollection(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.addCollection(t)},i.removeCollections=function removeCollections(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.removeCollections(t)},i.updateCollectionExtension=function updateCollectionExtension(t,i){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.updateCollectionExtension(t,i)},i.getCollectionListByOption=function getCollectionListByOption(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.getCollectionListByOption(t)},i.getCollectionListExByOption=function getCollectionListExByOption(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.getCollectionListExByOption(t)},i.searchCloudMessages=function searchCloudMessages(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.searchCloudMessages(t)},i.searchCloudMessagesEx=function searchCloudMessagesEx(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.searchCloudMessagesEx(t)},i.getThreadMessageList=function getThreadMessageList(t){return this.checkV2(),this.checkExtendUtil(),this.core.V2NIMMessageExtendUtil.getThreadMessageList(t)},i.registerCustomAttachmentParser=function registerCustomAttachmentParser(t){var i;"function"==typeof t&&-1===indexOf(i=this.customAttachmentParsers).call(i,t)&&this.customAttachmentParsers.unshift(t)},i.unregisterCustomAttachmentParser=function unregisterCustomAttachmentParser(t){var i,u,m=indexOf(i=this.customAttachmentParsers).call(i,t);m>-1&&splice(u=this.customAttachmentParsers).call(u,m,1)},i.sendP2PMessageReceipt=function sendP2PMessageReceipt(t){return this.checkV2(),this.receiptUtil.sendP2PMessageReceipt(t)},i.isPeerRead=function isPeerRead(t){return this.checkV2(),this.receiptUtil.isPeerRead(t)},i.getP2PMessageReceipt=function getP2PMessageReceipt(t){return this.checkV2(),this.receiptUtil.getP2PMessageReceipt(t)},i.getTeamMessageReceipts=function getTeamMessageReceipts(t){return this.checkV2(),this.receiptUtil.getTeamMessageReceipts(t)},i.getTeamMessageReceiptDetail=function getTeamMessageReceiptDetail(t){return this.checkV2(),this.receiptUtil.getTeamMessageReceiptDetail(t)},i.sendTeamMessageReceipts=function sendTeamMessageReceipts(t){return this.checkV2(),this.receiptUtil.sendTeamMessageReceipts(t)},i.revokeMessage=function revokeMessage(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),u.abrupt("return",this.deleteUtil.revokeMessage(t,i));case 2:case"end":return u.stop()}}),_callee3,this)})))},i.deleteMessage=function deleteMessage(t,i){return this.checkV2(),this.deleteUtil.deleteMessage(t,i)},i.deleteMessages=function deleteMessages(t,i){return this.checkV2(),this.deleteUtil.deleteMessages(t,i)},i.cancelMessageAttachmentUpload=function cancelMessageAttachmentUpload(t){return this.checkV2(),this.fileUtil.cancelMessageAttachmentUpload(t)},i.markMsgsAck=function markMsgsAck(t){var i=this;if(t&&t.length>0){var u=[],m=[];forEach$1(t).call(t,(function(t){t.senderId===i.core.account&&t.senderId!==t.receiverId||(1===t.conversationType?u.push(t):2===t.conversationType&&m.push(t))})),u.length>0&&this.core.sendCmd("v2BatchMarkRead",{sid:7,cid:2,ids:map$6(u).call(u,(function(t){return t.messageServerId}))}),m.length>0&&this.core.sendCmd("v2BatchMarkRead",{sid:8,cid:3,ids:map$6(m).call(m,(function(t){return t.messageServerId}))})}},i.sendMessage=function sendMessage(t,i,u,m){var h;return void 0===u&&(u={}),__awaiter(this,void 0,void 0,ud.mark((function _callee4(){var v,M,I,S,T,C,E,A,k=this;return ud.wrap((function _callee4$(R){for(;;)switch(R.prev=R.next){case 0:if(this.checkV2(),validate({message:{type:"object"}},{message:t},"",!0),t.messageClientId=t.messageClientId||jd(),!t.conversationId||t.conversationId===i){R.next=5;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"sendMessage: message.conversationId is not equal to conversationId"}});case 5:if(validate(km,{conversationId:i,message:t,params:u},"",!0),validateConversationId(this.core.account,i),2!==(v=this.core.V2NIMConversationIdUtil.parseConversationType(i))&&3!==v||!u.robotConfig||u.robotConfig.accountId){R.next=10;break}throw new Jl({detail:{reason:"When conversationType is team or superTeam, account is required in robotInfo account is required"}});case 10:if(2!==v&&3!==v||!u.targetConfig){R.next=20;break}if(M=u.targetConfig.receiverIds,3!==v||!1!==u.targetConfig.inclusive){R.next=14;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"setting inclusive to false for super teams is not allowed"}});case 14:if(M=filter(M).call(M,(function(t){return t&&t!==k.core.account})),0!==M.length){R.next=17;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"receiverIds cannot be empty or only contain yourself"}});case 17:u.targetConfig.receiverIds=M,R.next=21;break;case 20:u.targetConfig=void 0;case 21:return(null===(h=u.aiConfig)||void 0===h?void 0:h.aiStream)&&this.aiUtil.checkAI(),I=this.core.timeOrigin.getTimeNode(),S=this.sendUtil.prepareMessage(t,i,u),T=S.messageBeforeSend,C=S.clientAntispamResult,E=S.hiddenParams,this.logger.log("V2SendMessage start:"+T.messageClientId+"/"+T.createTime+";conversation:"+i+";","NTPTime:"+this.core.timeOrigin.getNTPTime(I)),R.prev=25,R.next=28,this.sendUtil.doSendMessage({apiCallingTimeNode:I,messageBeforeSend:T,clientAntispamResult:C,hiddenParams:E,progress:m});case 28:A=R.sent,R.next=35;break;case 31:throw R.prev=31,R.t0=R.catch(25),this.logger.warn("V2SendMessage end:"+T.messageClientId+".",R.t0 instanceof Yl?"failed:"+R.t0.code:"failed"),R.t0;case 35:return A.message.senderId===A.message.receiverId&&this.markMsgsAck([A.message]),this.logger.log("V2SendMessage end:"+A.message.messageClientId+"/"+A.message.messageServerId+"/"+A.message.createTime),R.abrupt("return",A);case 38:case"end":return R.stop()}}),_callee4,this,[[25,31]])})))},i.replyMessage=function replyMessage(t,i,u,m){return void 0===u&&(u={}),__awaiter(this,void 0,void 0,ud.mark((function _callee5(){var h,v,M,I,S,T;return ud.wrap((function _callee5$(C){for(;;)switch(C.prev=C.next){case 0:if(this.checkV2(),validate({message:{type:"object"}},{message:t},"",!0),t.messageClientId=t.messageClientId||jd(),validate(Am,{message:t,replyMessage:i,params:u},"",!0),validateConversationId(this.core.account,i.conversationId),2!==t.conversationType&&3!==t.conversationType||!u.robotConfig||u.robotConfig.accountId){C.next=7;break}throw new Jl({detail:{reason:"When conversationType is team or superTeam, account is required in robotInfo account is required"}});case 7:return h=this.core.timeOrigin.getTimeNode(),v=this.sendUtil.prepareMessage(t,i.conversationId,u,i),M=v.messageBeforeSend,I=v.clientAntispamResult,S=v.hiddenParams,C.next=11,this.sendUtil.doSendMessage({apiCallingTimeNode:h,messageBeforeSend:M,clientAntispamResult:I,hiddenParams:S,progress:m});case 11:return(T=C.sent).message.senderId===T.message.receiverId&&this.markMsgsAck([T.message]),C.abrupt("return",T);case 14:case"end":return C.stop()}}),_callee5,this)})))},i.modifyMessage=function modifyMessage(t,i){this.checkV2(),this.checkLogin(),validate(th,t,"message",!0),validate(rh,i,"params",!0),this.modifyUtil.checkIfModify(t,i);var u=this.modifyUtil.prepareMessage(t,i),m=u.messageBeforeSend,h=u.clientAntispamResult;return this.modifyUtil.modifyMessage(m,h)},i.stopAIStreamMessage=function stopAIStreamMessage(t,i){if(this.checkV2(),this.aiUtil.checkAI(),validate(nh,t,"message",!0),validate(ah,i,"params",!0),2===i.operationType&&!i.updateContent)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"V2NIMMessage::stopAIStreamMessage updateContent empty"}});return this.aiUtil.stopAIStreamMessage(t,i)},i.regenAIMessage=function regenAIMessage(t,i){return this.checkV2(),this.aiUtil.checkAI(),validate(nh,t,"message",!0),validate(ih,i,"params",!0),this.aiUtil.regenAIMessage(t,i)},i.sendMessageFn=function sendMessageFn(t){if(t.msgAckSnapshot){var i=t.msgAckSnapshot,u={conversationId:t.conversationId,messageServerId:t.messageServerId,messageClientId:t.messageClientId,readCount:0,unreadCount:Number(i)};delete t.msgAckSnapshot,this.emit("onReceiveTeamMessageReadReceipts",[u])}t=formatMessageAttachment(t,this.core),this.model.upsertMessages([t]),this.core.eventBus.emit("V2NIMMessageService/sendMessage",t,t.sendingState)},i.setMessageFilter=function setMessageFilter(t){null!=t?t&&"function"==typeof t.shouldIgnore&&(this.filterFn=t.shouldIgnore):this.filterFn=void 0},i._filterMessage=function _filterMessage(t){if("function"==typeof this.filterFn)try{return!0===this.filterFn(t)}catch(i){return this.logger.error("V2NIMMessage::triggerMessageFilter "+t.messageClientId+" error:",i),!1}return!1},i._filterMessagesByFn=function _filterMessagesByFn(t){var i=this;return filter(t).call(t,(function(t){return!i._filterMessage(t)}))},i._filterMessageByClearTime=function _filterMessageByClearTime(t,i){var u=pd.localStorage.getItem("nim_"+this.core.account+"_"+t+"_clearTime"),m=u?Gd(u):0;return m>0?filter(i).call(i,(function(t){return t.createTime>=m})):i},V2NIMMessageServiceImpl}(hp),Cg={super_team:3,p2p:1,team:2},bg=((dg={})[3]="super_team",dg[1]="p2p",dg[0]="p2p",dg[2]="team",dg);function getConvInfoFromSessionId(t,i){void 0===i&&(i="|");var u=indexOf(t).call(t,i);if(-1===u)return{target:"",type:0};var m=slice(t).call(t,0,u);return{target:slice(t).call(t,u+1),type:Cg[m]||0}}function getSessionIdFromConvInfo(t,i){return bg[t]+"|"+i}var Eg=function(){function V2NIMLocalConversationModelImpl(){this.map=new Sc,this.capacity=1e4,this.readTimeMap=new Sc,this.stickTopMap=new Sc}var t=V2NIMLocalConversationModelImpl.prototype;return t.reset=function reset(){map$6(this).clear(),this.readTimeMap.clear(),this.stickTopMap.clear()},t.count=function count(){return map$6(this).size},t.sort=function sort$1(){var t,i=this,u=id(values(t=map$6(this)).call(t));sort(u).call(u,(function(t,i){return i.sortOrder-t.sortOrder})),map$6(this).clear(),forEach$1(u).call(u,(function(t){map$6(i).set(t.conversationId,t)}))},t.processConversation=function processConversation(t){return"string"==typeof t.lastMessage&&delete t.lastMessage,void 0===t.localExtension&&(t.localExtension=""),t},t.getById=function getById(t){return map$6(this).get(t)},t.getAll=function getAll(){var t,i=id(values(t=map$6(this)).call(t));return sort(i).call(i,(function(t,i){return i.sortOrder-t.sortOrder}))},t.getStickTopList=function getStickTopList(){var t,i,u=id(values(t=map$6(this)).call(t));return sort(i=filter(u).call(u,(function(t){return t.stickTop}))).call(i,(function(t,i){return i.sortOrder-t.sortOrder}))},t.getByOption=function getByOption(t,i,u){var m,h=u.conversationTypes,v=u.onlyUnread,M=[];forEach$1(m=map$6(this)).call(m,(function(t){h&&h.length>0&&!includes(h).call(h,t.type)||v&&!t.unreadCount||u.ignoreMuted&&t.mute||M.push(t)})),M=sort(M).call(M,(function(t,i){return i.sortOrder-t.sortOrder}));var I=0;t>0&&(I=findIndexWithinTargetValue(M,"sortOrder",t),M[I]&&M[I].sortOrder===t&&(I+=1));var S=slice(M).call(M,I).length;return(M=slice(M).call(M,I,I+i)).length>0?{offset:S>i?M[M.length-1].sortOrder:0,finished:!(S>i),conversationList:M}:{offset:0,finished:!0,conversationList:M}},t.upsert=function upsert(t){var i=t.conversationId,u=map$6(this).get(i);if(!u){var m=this.processConversation(Dt({stickTop:this.getStickTop(i),localExtension:"",lastMessage:null,unreadCount:0,sortOrder:0,createTime:0,updateTime:0},t));return this.setLRU(i,m),m.unreadCount>0}var h=t.unreadCount!==u.unreadCount,v=Dt({},u,t);return v=this.processConversation(v),this.setLRU(i,v),h},t.setLRU=function setLRU(t,i){if(map$6(this).has(t))map$6(this).delete(t);else if(map$6(this).size>=this.capacity){var u,m=keys(u=map$6(this)).call(u).next().value;m&&map$6(this).delete(m)}map$6(this).set(t,i)},t.bulkUpsert=function bulkUpsert(t){var i=this,u=!1;return forEach$1(t).call(t,(function(t){i.upsert(t)&&(u=!0)})),u},t.deleteById=function deleteById(t){var i=this.getById(t);if(i)return map$6(this).delete(t),i},t.updateReadTime=function updateReadTime(t,i){this.readTimeMap.set(t,i)},t.getReadTime=function getReadTime(t){return this.readTimeMap.get(t)||0},t.updateStickTop=function updateStickTop(t,i){i?this.stickTopMap.set(t,!0):this.stickTopMap.delete(t)},t.getStickTop=function getStickTop(t){return this.stickTopMap.get(t)||!1},V2NIMLocalConversationModelImpl}(),Ag={"4_14":"v2LocalConvSyncReadTime","4_20":"v2LocalConvSyncSuperTeamReadTime","4_33":"v2LocalConvSyncP2pReadTimeV2","4_34":"v2LocalConvSyncTeamReadTimeV2","4_35":"v2LocalConvSyncSuperTeamReadTimeV2","4_22":"v2LocalConvSyncMoreRoaming","4_23":"v2LocalConvSyncStickTop","4_25":"v2LocalConvSyncReliableInfo","7_16":"v2LocalConvMarkReadTime","7_25":"v2LocalConvMultiMarkReadTime","7_116":"v2LocalConvMultiSyncReadTime","21_25":"v2LocalConvSuperTeamMarkReadTime","21_32":"v2LocalConvSuperTeamMultiMarkReadTime","21_125":"v2LocalConvSuperTeamMultiSyncReadTime","33_12":"v2LocalConvStickTopAdd","33_13":"v2LocalConvStickTopDelete","23_112":"v2LocalConvStickTopMultiSyncAdd","23_113":"v2LocalConvStickTopMultiSyncDelete","23_114":"v2LocalConvStickTopMultiSyncUpdate"},kg="V2NIMLocalConversationService",Rg={id:1,ext:2,createTime:{id:3,retType:"number"},updateTime:{id:4,retType:"number"}},wg={scene:1,to:2,timetag:3},Ng={actionTime:1},xg={minTimetag:{id:1,retType:"number"},maxTimetag:{id:2,retType:"number"}},Og={id:1,msgTime:{id:2,retType:"number"}},Pg={v2LocalConvSyncReadTime:{sid:4,cid:14,service:kg,response:[{type:"StrLongMap",name:"p2p"},{type:"LongLongMap",name:"team"},{type:"Long",name:"timetag"}]},v2LocalConvSyncSuperTeamReadTime:{sid:4,cid:20,service:kg,response:[{type:"LongLongMap",name:"superTeam"}]},v2LocalConvSyncP2pReadTimeV2:{sid:4,cid:33,service:kg,response:[{type:"Property",name:"ctx",reflectMapper:invertSerializeItem(xg)},{type:"PropertyArray",name:"contents",reflectMapper:invertSerializeItem(Og)}]},v2LocalConvSyncTeamReadTimeV2:{sid:4,cid:34,service:kg,response:[{type:"Property",name:"ctx",reflectMapper:invertSerializeItem(xg)},{type:"PropertyArray",name:"contents",reflectMapper:invertSerializeItem(Og)}]},v2LocalConvSyncSuperTeamReadTimeV2:{sid:4,cid:35,service:kg,response:[{type:"Property",name:"ctx",reflectMapper:invertSerializeItem(xg)},{type:"PropertyArray",name:"contents",reflectMapper:invertSerializeItem(Og)}]},v2LocalConvSyncMoreRoaming:{sid:4,cid:22,service:kg,response:[]},v2LocalConvSyncStickTop:{sid:4,cid:23,service:kg,response:[{type:"Long",name:"timetag"},{type:"Bool",name:"isThereAnyChange"},{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Rg)}]},v2LocalConvSyncReliableInfo:{sid:4,cid:25,service:kg,response:[]},v2LocalConvMarkReadTime:{sid:7,cid:16,service:kg,params:[{type:"Byte",name:"scene"},{type:"String",name:"to"},{type:"Long",name:"timetag"}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ng)}]},v2LocalConvMultiMarkReadTime:{sid:7,cid:25,service:kg,ignoreErrCodes:[700],params:[{type:"PropertyArray",name:"tags",reflectMapper:wg}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(wg)},{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ng)}]},v2LocalConvMultiSyncReadTime:{sid:7,cid:116,service:kg,response:[{type:"Byte",name:"scene"},{type:"String",name:"to"},{type:"Long",name:"timetag"},{type:"Long",name:"actionTime"}]},v2LocalConvSuperTeamMarkReadTime:{sid:21,cid:25,service:kg,params:[{type:"Long",name:"to"},{type:"Long",name:"timetag"}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ng)}]},v2LocalConvSuperTeamMultiMarkReadTime:{sid:21,cid:32,service:kg,ignoreErrCodes:[700],params:[{type:"PropertyArray",name:"tags",reflectMapper:wg}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(wg)},{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ng)}]},v2LocalConvSuperTeamMultiSyncReadTime:{sid:21,cid:125,service:kg,response:[{type:"Long",name:"to"},{type:"Long",name:"timetag"},{type:"Long",name:"actionTime"}]},v2LocalConvStickTopAdd:{sid:33,cid:12,service:kg,params:[{type:"Property",name:"tag",reflectMapper:Rg}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Rg)}]},v2LocalConvStickTopDelete:{sid:33,cid:13,service:kg,params:[{type:"Property",name:"tag",reflectMapper:Rg}],response:[{type:"Long",name:"timetag"}]},v2LocalConvStickTopMultiSyncAdd:{sid:23,cid:112,service:kg,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Rg)}]},v2LocalConvStickTopMultiSyncDelete:{sid:23,cid:113,service:kg,response:[{type:"Long",name:"timetag"},{type:"Property",name:"data",reflectMapper:invertSerializeItem(Rg)}]},v2LocalConvStickTopMultiSyncUpdate:{sid:23,cid:114,service:kg,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Rg)}]}};function chunk(t,i){t=t||[],i=i||1,i=Math.max(Math.floor(i),1);for(var u=[],m=0;m<t.length;m+=i)u.push(slice(t).call(t,m,m+i));return u}function isObject(t){var i=typeof t;return null!=t&&("object"==i||"function"==i)}var Lg=Math.max,Vg=Math.min;function debounce(t,i,u){var m,h,v,M,I,S,T=0,C=!1,E=!1,A=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function invokeFunc(i){var u=m,v=h;return m=h=void 0,T=i,M=t.apply(v,u)}function leadingEdge(t){return T=t,I=mo(timerExpired,i),C?invokeFunc(t):M}function shouldInvoke(t){var u=t-S;return void 0===S||u>=i||u<0||E&&t-T>=v}function timerExpired(){var t=to();if(shouldInvoke(t))return trailingEdge(t);I=mo(timerExpired,function remainingWait(t){var u=i-(t-S);return E?Vg(u,v-(t-T)):u}(t))}function trailingEdge(t){return I=void 0,A&&m?invokeFunc(t):(m=h=void 0,M)}function debounced(){var t=to(),u=shouldInvoke(t);if(m=arguments,h=this,S=t,u){if(void 0===I)return leadingEdge(S);if(E)return clearTimeout(I),I=mo(timerExpired,i),invokeFunc(S)}return void 0===I&&(I=mo(timerExpired,i)),M}return i=Number(i)||0,isObject(u)&&(C=!!u.leading,v=(E="maxWait"in u)?Lg(Number(u.maxWait)||0,i):v,A="trailing"in u?!!u.trailing:A),debounced.cancel=function cancel(){void 0!==I&&clearTimeout(I),T=0,m=S=h=I=void 0},debounced.flush=function flush(){return void 0===I?M:trailingEdge(to())},debounced}function throttle(t,i,u){var m=!0,h=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return isObject(u)&&(m="leading"in u?!!u.leading:m,h="trailing"in u?!!u.trailing:h),debounce(t,i,{leading:m,maxWait:i,trailing:h})}function _createForOfIteratorHelperLoose$8(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$8(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$8(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$8(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$8(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var Ug,Dg=function(){function V2NIMLocalConversationUnreadImpl(t,i){var u=this;this.totalUnreadCount=void 0,this.unreadCountByFilter={},this.currentConversationId=void 0,this._setCurrConvThrottle=throttle((function(){u.currentConversationId&&u._setCurrConv(u.currentConversationId)}),5e3,{leading:!1}),this.core=t,this.service=i,this.model=i.model,this.logger=i.logger}var t=V2NIMLocalConversationUnreadImpl.prototype;return t.reset=function reset(){this.totalUnreadCount=void 0,this.unreadCountByFilter={},this.currentConversationId=void 0,this._setCurrConvThrottle.flush()},t.getTotalUnreadCount=function getTotalUnreadCount(){return this.totalUnreadCount||0},t.resetTotalAfterSyncDone=function resetTotalAfterSyncDone(){var t,i=reduce(t=this.service.model.getAll()).call(t,(function(t,i){return t+(i.unreadCount||0)}),0),u=this.totalUnreadCount;return void 0!==u&&u===i||(this.totalUnreadCount=i,this.service.emit("onTotalUnreadCountChanged",i)),i},t.digestUnreadCountChange=function digestUnreadCountChange(){this._digest()},t._digest=function _digest(){var t,i=this,u=this.totalUnreadCount||0,m=reduce(t=this.service.model.getAll()).call(t,(function(t,i){return t+(i.unreadCount||0)}),0);this.core.logger.log("V2NIMConversation::digestUnreadCountChange:oldUnreadCount "+u+", newUnreadCount "+m),u!==m&&(this.totalUnreadCount=m,this.service.emit("onTotalUnreadCountChanged",m));var h=Ht(this.unreadCountByFilter);forEach$1(h).call(h,(function(t){var u=JSON.parse(t),m=i.getUnreadCountByFilter(u),h=i.unreadCountByFilter[t];i.unreadCountByFilter[t]=m,u.equals=bind$1(equals$1).call(equals$1,u),h!==m&&i.service.emit("onUnreadCountChangedByFilter",u,m)}))},t.clearUnreadCount=function clearUnreadCount(t){var i=this,u=reduce(t).call(t,(function(t,u){return i.service.model.upsert({conversationId:u.conversationId,type:u.type,unreadCount:0})&&t.push(u.conversationId),t}),[]);if(u.length>0){var m=map$6(u).call(u,(function(t){return i.service.model.getById(t)}));this.service.triggerConversationChanged(m),this.digestUnreadCountChange()}},t.getUnreadCountByIds=function getUnreadCountByIds(t){var i=this;return t=uniq(t),reduce(t).call(t,(function(t,u){var m=i.service.model.getById(u);return t+(m&&m.unreadCount||0)}),0)},t.getUnreadCountByFilter=function getUnreadCountByFilter(t){var i,u=this.service.model.count(),m=this.service.model.getByOption(0,u,{conversationTypes:t.conversationTypes,ignoreMuted:t.ignoreMuted});return reduce(i=m.conversationList).call(i,(function(t,i){return t+(i.unreadCount||0)}),0)},t.isMessageUnread=function isMessageUnread(t,i){var u;return void 0===i&&(i=0),t.createTime>i&&t.senderId!==this.core.account&&!1!==(null===(u=t.messageConfig)||void 0===u?void 0:u.unreadEnabled)},t.isMessageReferUnread=function isMessageReferUnread(t,i){void 0===i&&(i=0);var u=this.core.V2NIMMessageService.model.getMessageById(t.messageClientId);return u?this.isMessageUnread(u,i):t.createTime>i&&t.senderId!==this.core.account},t.countUnreadByMessageInMemory=function countUnreadByMessageInMemory(t,i){var u=this;void 0===i&&(i=0);var m=0,h=this.core.V2NIMMessageService.model.getMessagesByConversationId(t);return forEach$1(h).call(h,(function(t){u.isMessageUnread(t,i)&&m++})),m},t.addFilter=function addFilter(t){var i=generateFilterKey$1(t);if(void 0!==this.unreadCountByFilter[i])throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_ALREADY_EXIST});var u=JSON.parse(i),m=this.getUnreadCountByFilter(u);this.unreadCountByFilter[i]=m,this.service.emit("onUnreadCountChangedByFilter",u,m)},t.deleteFilter=function deleteFilter(t){var i=generateFilterKey$1(t);if(void 0===this.unreadCountByFilter[i])throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});delete this.unreadCountByFilter[i]},t.markConversationRead=function markConversationRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h,v;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:if(i=this.model.getById(t),u=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t),m=this.core.V2NIMConversationIdUtil.parseConversationType(t),h=this.model.getReadTime(t),i){M.next=6;break}return M.abrupt("return",h||this.core.timeOrigin.getNTPTime());case 6:if(v=this.service.compute.computeReadTimeForMark(i),!(h>=v)){M.next=10;break}return this.logger.log("V2LocalConv::markConversationRead currentReadTime >= readTime "+t+","+h+","+v),M.abrupt("return",h);case 10:if(3!==m){M.next=15;break}return M.next=13,this.core.sendCmd("v2LocalConvSuperTeamMarkReadTime",{timetag:v,to:u});case 13:M.next=17;break;case 15:return M.next=17,this.core.sendCmd("v2LocalConvMarkReadTime",{scene:1===m?0:2===m?1:2,timetag:v,to:u});case 17:return this.model.updateReadTime(t,v),M.abrupt("return",v);case 19:case"end":return M.stop()}}),_callee,this)})))},t.markMultiConversationRead=function markMultiConversationRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v,M,I,S,T,C,E=this;return ud.wrap((function _callee2$(A){for(;;)switch(A.prev=A.next){case 0:i={cmd:"v2LocalConvSuperTeamMultiMarkReadTime",params:[]},u={cmd:"v2LocalConvMultiMarkReadTime",params:[]},forEach$1(t).call(t,(function(t){var m=E.model.getById(t);if(m){var h=E.core.V2NIMConversationIdUtil.parseConversationTargetId(t),v=E.core.V2NIMConversationIdUtil.parseConversationType(t),M=E.model.getReadTime(t),I=E.service.compute.computeReadTimeForMark(m);if(!(M>=I)){var S={conversationId:t,scene:1===v?0:2===v?1:2,timetag:I,to:h};3===v?i.params.push(S):u.params.push(S)}}})),m=chunk(i.params,50),h=chunk(u.params,50),v=_createForOfIteratorHelperLoose$8(m);case 6:if((M=v()).done){A.next=19;break}return I=M.value,A.prev=8,A.next=11,this.core.sendCmd(i.cmd,{tags:I});case 11:A.next=16;break;case 13:A.prev=13,A.t0=A.catch(8),this.logger.warn("markMultiConversationRead::error:",map$6(I).call(I,(function(t){return t.conversationId})),A.t0);case 16:forEach$1(I).call(I,(function(t){E.model.updateReadTime(t.conversationId,t.timetag)}));case 17:A.next=6;break;case 19:S=_createForOfIteratorHelperLoose$8(h);case 20:if((T=S()).done){A.next=33;break}return C=T.value,A.prev=22,A.next=25,this.core.sendCmd(u.cmd,{tags:C});case 25:A.next=30;break;case 27:A.prev=27,A.t1=A.catch(22),this.logger.warn("markMultiConversationRead::error:",map$6(C).call(C,(function(t){return t.conversationId})),A.t1);case 30:forEach$1(C).call(C,(function(t){E.model.updateReadTime(t.conversationId,t.timetag)}));case 31:A.next=20;break;case 33:case"end":return A.stop()}}),_callee2,this,[[8,13],[22,27]])})))},t.setCurrentConversation=function setCurrentConversation(t){var i=this.currentConversationId;this.currentConversationId=t,this.currentConversationId&&this._setCurrConv(this.currentConversationId),i&&i!==this.currentConversationId&&(this._setCurrConvThrottle.flush(),this._setCurrConv(i))},t._setCurrConv=function _setCurrConv(t){var i=this,u=this.model.getById(t),m=(null==u?void 0:u.unreadCount)||0;u&&(u.unreadCount=0),u&&m>0&&(this.service.triggerConversationChanged([u]),this._digest()),this.markConversationRead(t).catch((function(t){i.logger.warn("_setConv markRead failed",t)}))},V2NIMLocalConversationUnreadImpl}();function generateFilterKey$1(t){var i=t.conversationTypes;return i&&(i=sort(i).call(i)),Un({conversationGroupId:t.conversationGroupId,conversationTypes:i,ignoreMuted:t.ignoreMuted})}function equals$1(t){return Un(this)===generateFilterKey$1(t)}function formatLastMessageFromMessage(t,i,u,m){var h,v;void 0===u&&(u=0);var M=i=formatMessageAttachment(i,t),I=M.messageType,S=M.subType,T=M.text,C=M.attachment,E=M.serverExtension,A="";if(i.senderId!==t.account&&5!==I){A=get(i,"fromNick");var k=null===(v=null===(h=t.V2NIMFriendService)||void 0===h?void 0:h.model)||void 0===v?void 0:v.getFriend(i.senderId);k&&k.alias&&(A=k.alias)}return JSON.parse(Un({lastMessageState:u,messageRefer:formatMessageRefer(t,i),messageType:I,subType:S,text:T,attachment:C,serverExtension:E,callbackExtension:i.callbackExtension,sendingState:m,senderName:A}))}function formatConversationFields(t,i){return i&&i.length>0?map$6(i).call(i,(function(i){return formatConversationField(t,i)})):[]}function formatConversationField(t,i){var u=i;if("string"==typeof u.lastMessage)if(""===u.lastMessage);else if(1===u.lastMessageState){var m=formatRevokeMessage(t,deserialize(JSON.parse(u.lastMessage),invertSerializeItem(Eh)));u.lastMessage=function formatLastMessageFromNotification(t,i){var u=i.messageRefer,m=i.revokeAccountId,h=i.revokeType,v=i.callbackExtension,M=i.serverExtension,I=i.postscript,S=function calcSenderNameFromNotification(t,i,u,m){var h,v,M,I,S,T,C,E;if(i!==t.account){var A=null===(v=null===(h=t.V2NIMFriendService)||void 0===h?void 0:h.model)||void 0===v?void 0:v.getFriend(i);if(A&&A.alias)return A.alias;if(2===u){var k=null===(I=null===(M=t.V2NIMTeamService)||void 0===M?void 0:M.memberModel)||void 0===I?void 0:I.getById(m,1,i);if(k&&k.teamNick)return k.teamNick}else if(3===u){var R=null===(T=null===(S=t.V2NIMTeamService)||void 0===S?void 0:S.memberModel)||void 0===T?void 0:T.getById(m,1,i);if(R&&R.teamNick)return R.teamNick}var w=null===(E=null===(C=t.V2NIMUserService)||void 0===C?void 0:C.model)||void 0===E?void 0:E.getUser(i);return w&&w.name?w.name:void 0}}(t,i.revokeAccountId,i.messageRefer.conversationType,i.messageRefer.receiverId)||"";return JSON.parse(Un({lastMessageState:1,messageRefer:u,revokeAccountId:m,revokeType:h,callbackExtension:v,serverExtension:M,text:I||"",senderName:S}))}(t,m)}else if(0===u.lastMessageState){var h=deserialize(JSON.parse(u.lastMessage),invertSerializeItem(Sh));u.lastMessage=formatLastMessageFromMessage(t,h,u.lastMessageState,h.senderId===t.account?1:void 0)}else 2===u.lastMessageState&&delete u.lastMessage;return u}function formatConversationByField(t){var i=t.version,u=t.deleteFlag;return{conversation:__rest(t,["version","deleteFlag"]),version:i,deleteFlag:u}}!function(t){t[t.createConversation=1]="createConversation",t[t.deleteConversation=2]="deleteConversation",t[t.updateConversation=3]="updateConversation",t[t.setConversationTop=4]="setConversationTop",t[t.clearConversationUnread=5]="clearConversationUnread",t[t.addConversationToGroup=6]="addConversationToGroup",t[t.removeConversationFromGroup=7]="removeConversationFromGroup",t[t.modifyConversationOnSendMessage=8]="modifyConversationOnSendMessage",t[t.modifyConversationOnDeleteMessage=9]="modifyConversationOnDeleteMessage",t[t.modifyConversationOnRecallMessage=10]="modifyConversationOnRecallMessage",t[t.modifyConversationOnClearMessage=11]="modifyConversationOnClearMessage",t[t.oneClickClearConversationUnread=12]="oneClickClearConversationUnread",t[t.modifyConversationOnUpdateMessage=13]="modifyConversationOnUpdateMessage"}(Ug||(Ug={}));var Bg=function(){function V2NIMLocalConversationComputeImpl(t,i){this.core=t,this.service=i}var t=V2NIMLocalConversationComputeImpl.prototype;return t.computeFromExternal=function computeFromExternal(t){var i,u,m;if(0===t.type)return t;var h=this.core.V2NIMConversationIdUtil.parseConversationType(t.conversationId),v=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t.conversationId),M={};if((null===(i=this.core.V2NIMSettingService)||void 0===i?void 0:i.name)&&(M.mute=this.core.V2NIMSettingService.getConversationMuteStatus(t.conversationId)),1===h&&this.hasUserService){var I,S=this.core.V2NIMUserService.model.getUser(v),T=this.hasFriendService?this.core.V2NIMFriendService.model.getFriend(v):void 0;t.conversationId===(null===(u=t.lastMessage)||void 0===u?void 0:u.messageRefer.conversationId)&&(I=null===(m=t.lastMessage)||void 0===m?void 0:m.senderName),M.name=(null==T?void 0:T.alias)||(null==S?void 0:S.name)||I||v,M.avatar=(null==S?void 0:S.avatar)||""}else if(2===h&&this.hasTeamService){var C=this.core.V2NIMTeamService.model.getById(v,1);M.name=(null==C?void 0:C.name)||v,M.avatar=(null==C?void 0:C.avatar)||""}else if(3===h&&this.hasTeamService){var E=this.core.V2NIMTeamService.model.getById(v,2);M.name=(null==E?void 0:E.name)||v,M.avatar=(null==E?void 0:E.avatar)||""}return Dt(t,M),t},t.computeSortOrder=function computeSortOrder(t,i){return i?t?i+1e15:i:t?1e15:0},t.computeReadTimeForMark=function computeReadTimeForMark(t){var i,u,m,h=t.conversationId,v=this.service.model.getReadTime(h);if(null===(u=null===(i=null==t?void 0:t.lastMessage)||void 0===i?void 0:i.messageRefer)||void 0===u?void 0:u.createTime)m=t.lastMessage.messageRefer.createTime;else{if(0===t.unreadCount&&v>0)return v;if(!this.core.timeOrigin.checkNodeReliable())return v||0;m=this.core.timeOrigin.getNTPTime()}return m},t.computeConvWithLastMsg=function computeConvWithLastMsg(t,i){var u,m=i||this.core.V2NIMMessageService.model.getLastMessageOfConversation(t.conversationId);if(m&&!1!==(null===(u=m.messageConfig)||void 0===u?void 0:u.lastMessageUpdateEnabled)){var h=formatLastMessageFromMessage(this.core,m,0,m.sendingState);t.lastMessage=h,t.createTime=t.createTime||m.createTime,t.updateTime=m.createTime,t.sortOrder=this.computeSortOrder(t.stickTop,m.createTime)}return t},t.computeConvWithUnread=function computeConvWithUnread(t,i){var u=this.service.model.getReadTime(t.conversationId),m=this.service.unread.currentConversationId;if(m&&(null==i?void 0:i.conversationId)===m)return t.unreadCount=0,this.service.unread._setCurrConvThrottle(),t;var h=t.unreadCount||0;return i?i&&this.service.unread.isMessageUnread(i)&&(h+=1):h=this.service.unread.countUnreadByMessageInMemory(t.conversationId,u),t.unreadCount=h,t},t.computeConvByMsgsCache=function computeConvByMsgsCache(t,i){var u,m=this.service.model.getById(t),h=this.core.V2NIMConversationIdUtil.parseConversationType(t),v=this.core.V2NIMMessageService.model.getLastMessageOfConversation(t),M=null==i?void 0:i.updateTime,I=0;I=M||(v&&v.createTime?v.createTime:m&&m.updateTime?m.updateTime:this.core.timeOrigin.getNTPTime());var S=this.service.model.getStickTop(t),T=Dt(Dt({conversationId:t,type:h,stickTop:S,localExtension:(null==m?void 0:m.localExtension)||"",lastMessage:null,unreadCount:0},i),{createTime:(null==m?void 0:m.createTime)||I,updateTime:I,sortOrder:this.computeSortOrder(S,I)});if(v&&!1!==(null===(u=v.messageConfig)||void 0===u?void 0:u.lastMessageUpdateEnabled)){var C=formatLastMessageFromMessage(this.core,v,0,v.sendingState);T.lastMessage=C}return T},Qe(V2NIMLocalConversationComputeImpl,[{key:"hasUserService",get:function get(){var t;return!!(null===(t=this.core.V2NIMUserService)||void 0===t?void 0:t.name)}},{key:"hasFriendService",get:function get(){var t;return!!(null===(t=this.core.V2NIMFriendService)||void 0===t?void 0:t.name)}},{key:"hasTeamService",get:function get(){var t;return!!(null===(t=this.core.V2NIMTeamService)||void 0===t?void 0:t.name)}},{key:"hasMessageService",get:function get(){var t;return!!(null===(t=this.core.V2NIMMessageService)||void 0===t?void 0:t.name)}}]),V2NIMLocalConversationComputeImpl}(),qg=function(){function V2NIMLocalConversationHandlerImpl(t,i){this.core=t,this.service=i,this.model=this.service.model,this.unread=this.service.unread,this.logger=this.core.logger}var t=V2NIMLocalConversationHandlerImpl.prototype;return t.v2LocalConvSyncStickTopHandler=function v2LocalConvSyncStickTopHandler(t){var i=this,u=t.content,m=u.timetag,h=u.isThereAnyChange,v=u.datas;if(h){var M=this.model.getAll(),I=map$6(v).call(v,(function(t){var u=getConvInfoFromSessionId(t.id),m=u.target,h=u.type,v=i.core.V2NIMConversationIdUtil.conversationId(h,m);return i.model.updateStickTop(v,!0),v}));forEach$1(M).call(M,(function(t){includes(I).call(I,t.conversationId)?(t.stickTop=!0,t.updateTime=t.updateTime>m?t.updateTime:m):t.stickTop=!1,i.model.updateStickTop(t.conversationId,t.stickTop)})),this.model.bulkUpsert(M)}},t.v2LocalConvSyncReadTimeHandler=function v2LocalConvSyncReadTimeHandler(t){var i,u,m=this,h=t.content.p2p||{},v=t.content.team.m_map||{};this.logger.log("v2SyncLocalConvAck::",h,v),forEach$1(i=Ht(h)).call(i,(function(t){var i=m.core.V2NIMConversationIdUtil.p2pConversationId(t),u=m.model.getReadTime(i);h[t]>u&&(m.model.updateReadTime(i,h[t]),m.service.emit("onConversationReadTimeUpdated",i,h[t]))})),forEach$1(u=Ht(v)).call(u,(function(t){var i=m.core.V2NIMConversationIdUtil.teamConversationId(t),u=m.model.getReadTime(i);v[t]>u&&(m.model.updateReadTime(i,v[t]),m.service.emit("onConversationReadTimeUpdated",i,v[t]))}))},t.v2LocalConvSyncSuperTeamReadTimeHandler=function v2LocalConvSyncSuperTeamReadTimeHandler(t){var i,u=this,m=t.content.superTeam.m_map;this.logger.log("v2SyncLocalSuperTeamConvAck::",m),forEach$1(i=Ht(m)).call(i,(function(t){var i=u.core.V2NIMConversationIdUtil.superTeamConversationId(t),h=u.model.getReadTime(i);m[t]>h&&(u.model.updateReadTime(i,m[t]),u.service.emit("onConversationReadTimeUpdated",i,m[t]))}))},t.v2LocalConvSyncP2pReadTimeV2Handler=function v2LocalConvSyncP2pReadTimeV2Handler(){},t.v2LocalConvSyncTeamReadTimeV2Handler=function v2LocalConvSyncTeamReadTimeV2Handler(){},t.v2LocalConvSyncSuperTeamReadTimeV2Handler=function v2LocalConvSyncSuperTeamReadTimeV2Handler(){},t.v2LocalConvMultiSyncReadTimeHandler=function v2LocalConvMultiSyncReadTimeHandler(t){var i=t.content,u=getConvInfoFromSessionId((0===i.scene?"p2p":1===i.scene?"team":"super_team")+"-"+i.to,"-"),m=u.type,h=u.target,v=this.core.V2NIMConversationIdUtil.conversationId(m,h),M=this.model.getById(v),I=null==M?void 0:M.unreadCount,S=this.model.getReadTime(v);i.timetag<=S?this.logger.warn("v2LocalConvMultiSyncReadTimeHandler: "+v+" do not need update ack "+i.timetag+"/"+S):(this.model.updateReadTime(v,i.timetag),this.service.emit("onConversationReadTimeUpdated",v,i.timetag),M?(M=this.service.compute.computeConvWithUnread(M),this.model.upsert(M),this.service.unread.digestUnreadCountChange(),void 0===I&&M.unreadCount>0?this.service.triggerConversationCreated(M):"number"==typeof I&&M.unreadCount!==I&&this.service.triggerConversationChanged([M])):this.logger.log("v2LocalConvMultiSyncReadTimeHandler: "+v+" not exist"))},t.v2LocalConvSuperTeamMultiSyncReadTimeHandler=function v2LocalConvSuperTeamMultiSyncReadTimeHandler(t){this.v2LocalConvMultiSyncReadTimeHandler(t)},t.v2LocalConvStickTopMultiSyncAddHandler=function v2LocalConvStickTopMultiSyncAddHandler(t){var i=t.content.data,u=getConvInfoFromSessionId(i.id),m=u.target,h=u.type,v=this.core.V2NIMConversationIdUtil.conversationId(h,m);this.model.updateStickTop(v,!0);var M=this.model.getById(v);M&&(M.stickTop=!0,M.updateTime=M.updateTime>i.updateTime?M.updateTime:i.updateTime,M.sortOrder=this.service.compute.computeSortOrder(!0,i.updateTime),this.model.upsert(M),this.service.triggerConversationChanged([M]))},t.v2LocalConvStickTopMultiSyncDeleteHandler=function v2LocalConvStickTopMultiSyncDeleteHandler(t){var i=t.content,u=i.data,m=i.timetag,h=getConvInfoFromSessionId(u.id),v=h.target,M=h.type,I=this.core.V2NIMConversationIdUtil.conversationId(M,v);this.model.updateStickTop(I,!1);var S=this.model.getById(I);S&&(S.stickTop=!1,S.updateTime=S.updateTime>m?S.updateTime:m,S.sortOrder=this.service.compute.computeSortOrder(!1,m),this.model.upsert(S),this.service.triggerConversationChanged([S]))},V2NIMLocalConversationHandlerImpl}();collection("Set",(function(t){return function Set(){return t(this,arguments.length?arguments[0]:void 0)}}),dc);var Fg=$.Set;_export({target:"Set",stat:!0,forced:!0},{from:mc}),_export({target:"Set",stat:!0,forced:!0},{of:hc});_export({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function addAll(){for(var t=anObject(this),i=aCallable(t.add),u=0,m=arguments.length;u<m;u++)x(i,t,arguments[u]);return t}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:gc});var Gg=getIterator;_export({target:"Set",proto:!0,real:!0,forced:!0},{every:function every(t){var i=anObject(this),u=Gg(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);return!iterate(u,(function(t,u){if(!m(t,t,i))return u()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{difference:function difference(t){var i=anObject(this),u=new(speciesConstructor(i,getBuiltIn("Set")))(i),m=aCallable(u.delete);return iterate(t,(function(t){x(m,u,t)})),u}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{filter:function filter(t){var i=anObject(this),u=Gg(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0),h=new(speciesConstructor(i,getBuiltIn("Set"))),v=aCallable(h.add);return iterate(u,(function(t){m(t,t,i)&&x(v,h,t)}),{IS_ITERATOR:!0}),h}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{find:function find(t){var i=anObject(this),u=Gg(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);return iterate(u,(function(t,u){if(m(t,t,i))return u(t)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function intersection(t){var i=anObject(this),u=new(speciesConstructor(i,getBuiltIn("Set"))),m=aCallable(i.has),h=aCallable(u.add);return iterate(t,(function(t){x(m,i,t)&&x(h,u,t)})),u}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function isDisjointFrom(t){var i=anObject(this),u=aCallable(i.has);return!iterate(t,(function(t,m){if(!0===x(u,i,t))return m()}),{INTERRUPTED:!0}).stopped}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function isSubsetOf(t){var i=getIterator(this),u=anObject(t),m=u.has;return isCallable(m)||(u=new(getBuiltIn("Set"))(t),m=aCallable(u.has)),!iterate(i,(function(t,i){if(!1===x(m,u,t))return i()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function isSupersetOf(t){var i=anObject(this),u=aCallable(i.has);return!iterate(t,(function(t,m){if(!1===x(u,i,t))return m()}),{INTERRUPTED:!0}).stopped}});var Hg=R([].join),jg=[].push;_export({target:"Set",proto:!0,real:!0,forced:!0},{join:function join(t){var i=anObject(this),u=Gg(i),m=void 0===t?",":toString(t),h=[];return iterate(u,jg,{that:h,IS_ITERATOR:!0}),Hg(h,m)}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{map:function map(t){var i=anObject(this),u=Gg(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0),h=new(speciesConstructor(i,getBuiltIn("Set"))),v=aCallable(h.add);return iterate(u,(function(t){x(v,h,m(t,t,i))}),{IS_ITERATOR:!0}),h}});var $g=TypeError;_export({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function reduce(t){var i=anObject(this),u=Gg(i),m=arguments.length<2,h=m?void 0:arguments[1];if(aCallable(t),iterate(u,(function(u){m?(m=!1,h=u):h=t(h,u,u,i)}),{IS_ITERATOR:!0}),m)throw $g("Reduce of empty set with no initial value");return h}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{some:function some(t){var i=anObject(this),u=Gg(i),m=functionBindContext(t,arguments.length>1?arguments[1]:void 0);return iterate(u,(function(t,u){if(m(t,t,i))return u()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function symmetricDifference(t){var i=anObject(this),u=new(speciesConstructor(i,getBuiltIn("Set")))(i),m=aCallable(u.delete),h=aCallable(u.add);return iterate(t,(function(t){x(m,u,t)||x(h,u,t)})),u}}),_export({target:"Set",proto:!0,real:!0,forced:!0},{union:function union(t){var i=anObject(this),u=new(speciesConstructor(i,getBuiltIn("Set")))(i);return iterate(t,aCallable(u.add),{that:u}),u}});var zg=Fg,Wg=function(){function V2NIMLocalConversationEventImpl(t,i){this.core=t,this.service=i,this.model=this.service.model,this.compute=this.service.compute,this.logger=this.core.logger}var t=V2NIMLocalConversationEventImpl.prototype;return t.setListener=function setListener(){var t,i,u,m,h,v,M,I,S,T,C=this;this.core.eventBus.on("V2NIMLoginService/syncing",(function(){return C.service.emit("onSyncStarted")})),this.core.eventBus.on("V2NIMLoginService/syncDone",bind$1(t=this.onSyncDone).call(t,this)),this.core.eventBus.on("V2NIMMessageService/sendMessage",bind$1(i=this.sendMsg).call(i,this)),this.core.eventBus.on("V2NIMMessageService/onMsg",bind$1(u=this.recvMsg).call(u,this)),this.core.eventBus.on("V2NIMMessageService/modifyMsg",bind$1(m=this.modifyMsg).call(m,this)),this.core.eventBus.on("V2NIMMessageService/deleteMessages",bind$1(h=this.deleteMessages).call(h,this)),this.core.eventBus.on("V2NIMMessageService/revokeMessages",bind$1(v=this.deleteMessages).call(v,this)),this.core.eventBus.on("V2NIMMessageLogUtil/onClearHistoryNotifications",bind$1(M=this.clearMessages).call(M,this)),this.core.eventBus.on("V2NIMMessageService/roamingMsgs",bind$1(I=this.generateConv).call(I,this)),this.core.eventBus.on("V2NIMMessageService/offlineMsgs",bind$1(S=this.generateConv).call(S,this)),this.core.eventBus.on("V2NIMSettingService/setMute",bind$1(T=this.setMute).call(T,this))},t.beforeEmit=function beforeEmit(t){for(var i,u=this.service.name+"::emit "+t.toString(),m=arguments.length,h=new Array(m>1?m-1:0),v=1;v<m;v++)h[v-1]=arguments[v];if("onConversationCreated"===t){var M=h[0],I=null===(i=M.lastMessage)||void 0===i?void 0:i.messageRefer;this.logger.log(""+u,"id:"+M.conversationId+";unread:"+M.unreadCount+";lastMsg:"+((null==I?void 0:I.messageClientId)||"")+"/"+((null==I?void 0:I.messageServerId)||""))}else if("onConversationChanged"===t){var S=h[0];this.logger.log(""+u,map$6(S).call(S,(function(t){var i,u=null===(i=t.lastMessage)||void 0===i?void 0:i.messageRefer;return"id:"+t.conversationId+";unread:"+t.unreadCount+";lastMsg:"+((null==u?void 0:u.messageClientId)||"")+"/"+((null==u?void 0:u.messageServerId)||"")})))}else{var T,C;(T=this.logger).log.apply(T,concat(C=[""+u]).call(C,h))}},t.onSyncDone=function onSyncDone(t){var i=this;if(t)this.service.emit("onSyncFailed",t);else{var u=this.model.getAll();u=map$6(u).call(u,(function(t){var u=t.conversationId,m=i.compute.computeConvByMsgsCache(u);return m=i.compute.computeConvWithUnread(m),m=i.compute.computeFromExternal(m),i.model.upsert(m),i.model.getById(u)})),u.length>0&&(this.service.triggerConversationChanged(u),this.service.unread.resetTotalAfterSyncDone()),this.service.emit("onSyncFinished")}},t.generateConv=function generateConv(t){var i=this,u=uniq(map$6(t).call(t,(function(t){return t.conversationId})));forEach$1(u).call(u,(function(t){var u=i.compute.computeConvByMsgsCache(t);i.model.upsert(u)}))},t.setMute=function setMute(t,i){var u=this.model.getById(t);u&&u.mute!==i&&(u.mute=i,this.model.upsert(u),this.service.triggerConversationChanged([u]))},t.deleteMessages=function deleteMessages(t){var i=this,u=new zg;forEach$1(t).call(t,(function(t){var m,h=t.messageRefer.conversationId,v=i.model.getById(h);if(v){if(t.messageRefer.messageClientId===(null===(m=v.lastMessage)||void 0===m?void 0:m.messageRefer.messageClientId)){u.add(h);var M=i.core.V2NIMMessageService.model.getLastMessageOfConversation(h);v.lastMessage=M?formatLastMessageFromMessage(i.core,M,0,M.sendingState):void 0}var I=i.model.getReadTime(h);if(v.unreadCount>0&&i.service.unread.isMessageReferUnread(t.messageRefer,I)&&(u.add(h),v.unreadCount--),"deleteTime"in t)t.deleteTime>v.updateTime&&(v.updateTime=t.deleteTime,v.sortOrder=i.compute.computeSortOrder(v.stickTop,v.updateTime));else{var S=i.core.timeOrigin.getNTPTime();v.updateTime=S,v.sortOrder=i.compute.computeSortOrder(v.stickTop,S)}i.model.upsert(v)}}));var m=id(u);!this.core.V2NIMLoginService.dataSync.checkSyncing()&&m.length>0&&(this.service.triggerConversationChanged(map$6(m).call(m,(function(t){return i.model.getById(t)}))),this.service.unread.digestUnreadCountChange())},t.sendMsg=function sendMsg(t){var i=t.conversationId,u=this.model.getById(i);if(u){var m=u.lastMessage,h=this.updateCauseMessage(u,t);m!==h.lastMessage&&this.service.triggerConversationChanged([h])}else{var v=this.createCauseMessage(i,t);if(!v)return;this.service.triggerConversationCreated(v)}},t.recvMsg=function recvMsg(t){var i=t.conversationId,u=this.model.getById(i);if(u){var m=u.lastMessage,h=u.unreadCount,v=this.updateCauseMessage(u,t);v=this.compute.computeConvWithUnread(v,t);var M=m!==(v=this.compute.computeFromExternal(v)).lastMessage,I=h!==v.unreadCount;this.model.upsert(v),(M||I)&&this.service.triggerConversationChanged([v])}else{var S=this.createCauseMessage(i,t);if(!S)return;S=this.compute.computeConvWithUnread(S,t),S=this.compute.computeFromExternal(S),this.model.upsert(S),this.service.triggerConversationCreated(S)}this.service.unread.digestUnreadCountChange()},t.updateCauseMessage=function updateCauseMessage(t,i){return t=this.compute.computeConvWithLastMsg(t,i),this.model.upsert(t),this.model.getById(t.conversationId)},t.createCauseMessage=function createCauseMessage(t,i){var u,m,h;if(!1!==(null===(u=i.messageConfig)||void 0===u?void 0:u.unreadEnabled)||!1!==(null===(m=i.messageConfig)||void 0===m?void 0:m.lastMessageUpdateEnabled)){var v=this.core.V2NIMConversationIdUtil.parseConversationType(t),M=this.model.getStickTop(t),I=!1===(null===(h=i.messageConfig)||void 0===h?void 0:h.lastMessageUpdateEnabled)?void 0:formatLastMessageFromMessage(this.core,i,0,i.sendingState),S=this.core.timeOrigin.getNTPTime(),T={conversationId:t,type:v,createTime:I?i.createTime:S,updateTime:I?i.createTime:S,sortOrder:this.compute.computeSortOrder(M,I?i.createTime:S),stickTop:M,localExtension:"",lastMessage:I,unreadCount:0};return this.model.upsert(T),T}},t.clearMessages=function clearMessages(t){var i=this,u=new zg;forEach$1(t).call(t,(function(t){var m=t.conversationId,h=t.deleteTime,v=i.model.getById(m);v&&(v.unreadCount>0&&(v.unreadCount=0,u.add(m)),v.lastMessage&&v.lastMessage.messageRefer.createTime<=t.deleteTime&&(v.lastMessage=void 0,u.add(m)),h>v.updateTime&&(v.updateTime=h,v.sortOrder=i.compute.computeSortOrder(v.stickTop,v.updateTime)),i.model.upsert(v))}));var m=id(u);!this.core.V2NIMLoginService.dataSync.checkSyncing()&&m.length>0&&(this.service.triggerConversationChanged(map$6(m).call(m,(function(t){return i.model.getById(t)}))),this.service.unread.digestUnreadCountChange())},t.modifyMsg=function modifyMsg(t){var i,u=t.conversationId,m=t.messageClientId,h=this.model.getById(u),v=this.core.V2NIMMessageService.model.getMessageById(m);if(h||v)if(h)t.messageClientId===(null===(i=h.lastMessage)||void 0===i?void 0:i.messageRefer.messageClientId)&&(h.lastMessage=formatLastMessageFromMessage(this.core,t,0,t.sendingState),this.service.triggerConversationChanged([h]));else{var M=this.createCauseMessage(u,t);if(!M)return;this.service.triggerConversationCreated(M)}},V2NIMLocalConversationEventImpl}(),Kg={type:"array",itemRules:{type:"enum",values:[1,2,3]},min:1},Yg=function(t){function V2NIMLocalConversationServiceImpl(i,u){var m;return void 0===u&&(u={}),(m=t.call(this,"V2NIMLocalConversationService",i)||this).config={},m.model=new Eg,m.unread=new Dg(m.core,Je(m)),m.compute=new Bg(m.core,Je(m)),m.event=new Wg(m.core,Je(m)),m.handler=new qg(m.core,Je(m)),m.core._registerDep(mm,"V2NIMConversationIdUtil"),m.core._registerDep(Tg,"V2NIMMessageService"),"v2"!==m.core.options.apiVersion?Je(m):(registerParser({cmdMap:Ag,cmdConfig:Pg}),m.setOptions(u),m.setListener(),m)}Nt(V2NIMLocalConversationServiceImpl,t);var i=V2NIMLocalConversationServiceImpl.prototype;return i.setOptions=function setOptions(t){this.config=Dt(this.config,t)},i.setListener=function setListener(){this.event.setListener()},i.reset=function reset(){this.model.reset(),this.unread.reset()},i.emit=function emit(i){for(var u,m,h,v,M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];return(u=this.event).beforeEmit.apply(u,concat(m=[i]).call(m,I)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,I))},i.getConversationList=function getConversationList(t,i){var u,m=this;this.checkV2(),validate({offset:{type:"number",min:0}},{offset:t},"",!0),validate({limit:{type:"number",min:1}},{limit:i},"",!0),this.core.V2NIMLoginService.checkIllegalState();var h=this.model.getByOption(t,i,{});return h.conversationList=map$6(u=h.conversationList).call(u,(function(t){return m.compute.computeFromExternal(t)})),zi.resolve(h)},i.getConversationListByOption=function getConversationListByOption(t,i,u){var m,h=this;this.checkV2(),validate({offset:{type:"number",min:0}},{offset:t},"",!0),validate({limit:{type:"number",min:1}},{limit:i},"",!0),validate({conversationTypes:{type:"array",itemType:"number",required:!1},onlyUnread:{type:"boolean",required:!1}},u,"option",!0),this.core.V2NIMLoginService.checkIllegalState();var v=this.model.getByOption(t,i,u);return v.conversationList=map$6(m=v.conversationList).call(m,(function(t){return h.compute.computeFromExternal(t)})),zi.resolve(v)},i.getConversation=function getConversation(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:if(this.checkV2(),validateConversationId(this.core.account,t),!(i=this.model.getById(t))){u.next=7;break}return u.abrupt("return",this.compute.computeFromExternal(i));case 7:throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});case 8:case"end":return u.stop()}}),_callee,this)})))},i.getConversationListByIds=function getConversationListByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m=this;return ud.wrap((function _callee2$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0),this.core.V2NIMLoginService.checkIllegalState(),u=filter(i=map$6(t).call(t,(function(t){return m.model.getById(t)}))).call(i,(function(t){return!!t})),u=map$6(u).call(u,(function(t){return m.compute.computeFromExternal(t)})),h.abrupt("return",u);case 6:case"end":return h.stop()}}),_callee2,this)})))},i.createConversation=function createConversation(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:if(this.checkV2(),validateConversationId(this.core.account,t),!(i=this.model.getById(t))){h.next=5;break}return h.abrupt("return",this.compute.computeFromExternal(i));case 5:return u=this.compute.computeConvByMsgsCache(t,{updateTime:this.core.timeOrigin.getNTPTime()}),u=this.compute.computeConvWithUnread(u),u=this.compute.computeFromExternal(u),this.model.upsert(u),m=this.model.getById(t),this.triggerConversationCreated(m),h.abrupt("return",m);case 12:case"end":return h.stop()}}),_callee3,this)})))},i.deleteConversation=function deleteConversation(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var u;return ud.wrap((function _callee4$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validateConversationId(this.core.account,t),validate({clearMessage:{type:"boolean",required:!1}},{clearMessage:i},"",!0),m.next=5,this.unread.markConversationRead(t);case 5:if(u=this.model.deleteById(t)){m.next=8;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});case 8:i&&this.core.V2NIMMessageService.model.deleteMessages(t),!!(u&&u.unreadCount>0)&&this.unread.digestUnreadCountChange(),this.emit("onConversationDeleted",[t]);case 12:case"end":return m.stop()}}),_callee4,this)})))},i.deleteConversationListByIds=function deleteConversationListByIds(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var u,m=this;return ud.wrap((function _callee5$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0),validate({clearMessage:{type:"boolean",required:!1}},{clearMessage:i},"",!0),h.next=5,this.unread.markMultiConversationRead(t);case 5:return u=!1,forEach$1(t).call(t,(function(t){i&&m.core.V2NIMMessageService.model.deleteMessages(t),m.model.deleteById(t)&&(u=!0)})),u&&this.unread.digestUnreadCountChange(),this.emit("onConversationDeleted",t),h.abrupt("return",[]);case 10:case"end":return h.stop()}}),_callee5,this)})))},i.getStickTopConversationList=function getStickTopConversationList(){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),t.abrupt("return",this.model.getStickTopList());case 3:case"end":return t.stop()}}),_callee6,this)})))},i.stickTopConversation=function stickTopConversation(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var u,m,h,v,M,I;return ud.wrap((function _callee7$(S){for(;;)switch(S.prev=S.next){case 0:if(this.checkV2(),validateConversationId(this.core.account,t),validate({stickTop:{type:"boolean"}},{stickTop:i},"",!0),(null==(u=this.model.getById(t))?void 0:u.stickTop)!==i){S.next=6;break}return S.abrupt("return");case 6:return m=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t),h=this.core.V2NIMConversationIdUtil.parseConversationType(t),S.next=10,this.core.sendCmd(i?"v2LocalConvStickTopAdd":"v2LocalConvStickTopDelete",{tag:{id:getSessionIdFromConvInfo(h,m)}});case 10:v=S.sent,this.model.updateStickTop(t,i),M=v.content.timetag||v.content.data.updateTime,this.model.upsert({conversationId:t,type:h,stickTop:i,updateTime:M,sortOrder:this.compute.computeSortOrder(i,M)}),I=[this.model.getById(t)],this.triggerConversationChanged(I);case 16:case"end":return S.stop()}}),_callee7,this)})))},i.updateConversationLocalExtension=function updateConversationLocalExtension(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var u,m;return ud.wrap((function _callee8$(h){for(;;)switch(h.prev=h.next){case 0:if(this.checkV2(),validateConversationId(this.core.account,t),validate({localExtension:{type:"string"}},{localExtension:i},"",!0),u=this.model.getById(t)){h.next=6;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});case 6:if(u.localExtension!==i){h.next=8;break}return h.abrupt("return");case 8:m=Dt(Dt({},u),{localExtension:i}),this.model.upsert(m),this.triggerConversationChanged([m]);case 11:case"end":return h.stop()}}),_callee8,this)})))},i.getTotalUnreadCount=function getTotalUnreadCount(){return this.checkV2(),this.unread.getTotalUnreadCount()||0},i.getUnreadCountByIds=function getUnreadCountByIds(t){this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0);var i=this.unread.getUnreadCountByIds(t);return zi.resolve(i)},i.getUnreadCountByFilter=function getUnreadCountByFilter(t){this.checkV2(),this.valiteFilter(t);var i=this.unread.getUnreadCountByFilter(t);return zi.resolve(i)},i.clearTotalUnreadCount=function clearTotalUnreadCount(){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var t;return ud.wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),this.checkLogin(),t=this.model.getAll(),i.next=5,this.unread.markMultiConversationRead(map$6(t).call(t,(function(t){return t.conversationId})));case 5:this.unread.clearUnreadCount(t);case 6:case"end":return i.stop()}}),_callee9,this)})))},i.clearUnreadCountByIds=function clearUnreadCountByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var i,u,m,h,v,M=this;return ud.wrap((function _callee10$(I){for(;;)switch(I.prev=I.next){case 0:if(this.checkV2(),this.checkLogin(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0),i=[],u=[],m=new RegExp("^"+this.core.account+"\\|[1-3]\\|"),forEach$1(t).call(t,(function(t){m.test(t)?i.push(t):u.push(t)})),!(i.length>0)){I.next=12;break}return v=filter(h=map$6(i).call(i,(function(t){return M.model.getById(t)}))).call(h,(function(t){return!!t})),I.next=11,this.unread.markMultiConversationRead(i);case 11:this.unread.clearUnreadCount(v);case 12:return I.abrupt("return",map$6(u).call(u,(function(t){return{conversationId:t,error:new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST})}})));case 13:case"end":return I.stop()}}),_callee10,this)})))},i.clearUnreadCountByTypes=function clearUnreadCountByTypes(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var i,u;return ud.wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),this.checkLogin(),validate({types:Kg},{types:t},"",!0),u=this.model.getByOption(0,1e3,{conversationTypes:t}),m.next=6,this.unread.markMultiConversationRead(map$6(i=u.conversationList).call(i,(function(t){return t.conversationId})));case 6:this.unread.clearUnreadCount(u.conversationList);case 7:case"end":return m.stop()}}),_callee11,this)})))},i.subscribeUnreadCountByFilter=function subscribeUnreadCountByFilter(t){var i;this.checkV2(),this.checkLogin(),this.valiteFilter(t),0===(null===(i=t.conversationTypes)||void 0===i?void 0:i.length)&&delete t.conversationTypes,this.unread.addFilter(t)},i.unsubscribeUnreadCountByFilter=function unsubscribeUnreadCountByFilter(t){var i;this.checkV2(),this.checkLogin(),this.valiteFilter(t),0===(null===(i=t.conversationTypes)||void 0===i?void 0:i.length)&&delete t.conversationTypes,this.unread.deleteFilter(t)},i.getConversationReadTime=function getConversationReadTime(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),validateConversationId(this.core.account,t),i.abrupt("return",this.model.getReadTime(t));case 3:case"end":return i.stop()}}),_callee12,this)})))},i.markConversationRead=function markConversationRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){return ud.wrap((function _callee13$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),this.checkLogin(),validateConversationId(this.core.account,t),i.abrupt("return",this.unread.markConversationRead(t));case 4:case"end":return i.stop()}}),_callee13,this)})))},i.setCurrentConversation=function setCurrentConversation(t){this.checkV2(),t&&validateConversationId(this.core.account,t),this.unread.setCurrentConversation(t)},i.valiteFilter=function valiteFilter(t){if(validate({filter:{type:"object",required:!0,rules:{conversationTypes:{type:"array",itemType:"number",required:!1},ignoreMuted:{type:"boolean",required:!1}}}},{filter:t},"",!0),void 0===t.conversationTypes&&!0!==t.ignoreMuted)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Filter cannot be empty"}})},i.triggerConversationChanged=function triggerConversationChanged(t){var i=this;t=map$6(t).call(t,(function(t){return i.compute.computeFromExternal(t)})),t=JSON.parse(Un(t)),forEach$1(t).call(t,(function(t){t.lastMessage||(t.lastMessage=void 0),delete t.lastMessageState})),this.emit("onConversationChanged",t)},i.triggerConversationCreated=function triggerConversationCreated(t){t=this.compute.computeFromExternal(t),delete(t=JSON.parse(Un(t))).lastMessageState,this.emit("onConversationCreated",t)},V2NIMLocalConversationServiceImpl}(hp),Qg=function(){function V2NIMConversationModelImpl(){this.map=new Sc,this.readTimeMap=new Sc}var t=V2NIMConversationModelImpl.prototype;return t.set=function set(t){var i=this;forEach$1(t).call(t,(function(t){t=i.processConversation(t),map$6(i).set(t.conversationId,t)}))},t.reset=function reset(){map$6(this).clear(),this.readTimeMap.clear()},t.count=function count(){return map$6(this).size},t.sort=function sort$1(){var t,i=this,u=id(values(t=map$6(this)).call(t));sort(u).call(u,(function(t,i){return i.sortOrder-t.sortOrder})),map$6(this).clear(),forEach$1(u).call(u,(function(t){map$6(i).set(t.conversationId,t)}))},t.processConversation=function processConversation(t){return"string"==typeof t.lastMessage&&delete t.lastMessage,void 0===t.localExtension&&(t.localExtension=""),t},t.getById=function getById(t){return map$6(this).get(t)},t.getStickTopList=function getStickTopList(){var t,i,u=id(values(t=map$6(this)).call(t));return sort(i=filter(u).call(u,(function(t){return t.stickTop}))).call(i,(function(t,i){return i.sortOrder-t.sortOrder}))},t.getAll=function getAll(){var t,i=id(values(t=map$6(this)).call(t));return sort(i).call(i,(function(t,i){return i.sortOrder-t.sortOrder}))},t.getByOption=function getByOption(t,i,u){var m,h=u.conversationTypes,v=u.onlyUnread,M=u.conversationGroupIds,I=[];forEach$1(m=map$6(this)).call(m,(function(t){if((!(h&&h.length>0)||includes(h).call(h,t.type))&&(!v||t.unreadCount)&&(!u.ignoreMuted||!t.mute)){if(M){var i=t.groupIds,m=(null==i?void 0:i.length)||0;if(0===M.length&&m>0)return;if(M.length>0&&0===m)return;if(M.length>0&&m>0&&!some(M).call(M,(function(t){return i&&includes(i).call(i,t)})))return}I.push(t)}})),I=sort(I).call(I,(function(t,i){return i.sortOrder-t.sortOrder}));var S=0;t>0&&(S=findIndexWithinTargetValue(I,"sortOrder",t),I[S]&&I[S].sortOrder===t&&(S+=1));var T=slice(I).call(I,S).length;return(I=slice(I).call(I,S,S+i)).length>0?{offset:T>i?I[I.length-1].sortOrder:0,finished:!(T>i),conversationList:I}:{offset:0,finished:!0,conversationList:I}},t.upsert=function upsert(t){var i=t.conversationId,u=map$6(this).get(i);if(!u)return t=this.processConversation(Dt({},t)),map$6(this).set(i,t),t.unreadCount>0;var m=t.unreadCount!==u.unreadCount,h=Dt({},u,t);return h=this.processConversation(h),map$6(this).set(i,h),m},t.bulkUpsert=function bulkUpsert(t){var i=this,u=!1;return forEach$1(t).call(t,(function(t){i.upsert(t)&&(u=!0)})),u},t.deleteById=function deleteById(t){var i=this.getById(t);if(i)return map$6(this).delete(t),i},t.updateReadTime=function updateReadTime(t,i){this.readTimeMap.set(t,i)},t.getReadTime=function getReadTime(t){return this.readTimeMap.get(t)||0},V2NIMConversationModelImpl}();function isEqual(t,i){var u=typeof t;if(u!==typeof i)return!1;if("object"===u){if(Object.prototype.toString.call(t)!==Object.prototype.toString.call(i))return!1;if(Dn(t)){if(t.length!==i.length)return!1;for(var m=0;m<t.length;m++)if(!isEqual(t[m],i[m]))return!1;return!0}if(t instanceof RegExp&&i instanceof RegExp)return t.toString()===i.toString();if(t instanceof Date&&i instanceof Date)return t.getTime()===i.getTime();if(null===t&&null===i)return!0;if(Ht(t).length!==Ht(i).length)return!1;for(var h in t)if(!isEqual(t[h],i[h]))return!1;return!0}return t===i}var Jg=function(){function V2NIMConversationVersionCacheImpl(t,i){this.fieldVersion={},this.conversationIdsForBackFill={},this.tempPacket=[],this.isSyncing=!1,this.nextCursor=0,this.core=t,this.service=i}var t=V2NIMConversationVersionCacheImpl.prototype;return t.reset=function reset(){this.tempPacket=[],this.fieldVersion={},this.conversationIdsForBackFill={},this.isSyncing=!1,this.nextCursor=0},t.doSync=function doSync(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t,i,u,m;return ud.wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:return this.isSyncing=!0,this.service.emit("onSyncStarted"),this.core.V2NIMLoginService.dataSync.switchDataSync({type:1,state:2,subType:"conversationSync"}),h.prev=3,h.next=6,this.core.sendCmd("v2ConversationSync",{tag:{cursor:this.nextCursor}});case 6:t=h.sent,h.next=19;break;case 9:if(h.prev=9,h.t0=h.catch(3),(i=h.t0).code!==zl.V2NIM_ERROR_CODE_CANCELLED){h.next=14;break}return h.abrupt("return");case 14:return this.isSyncing=!1,this.service.emit("onSyncFailed",i),this.core.V2NIMLoginService.dataSync.switchDataSync({type:1,state:3,error:i,subType:"conversationSync"}),this.processTempPacket(),h.abrupt("return");case 19:u=0===Gd(get(t,"content.info.syncType")),m=get(t,"content.info.nextCursor"),this.doSyncAndSuccess(u,m);case 22:case"end":return h.stop()}}),_callee,this,[[3,9]])})))},t.doSyncAndSuccess=function doSyncAndSuccess(t,i){var u;t&&sort(u=this.service.model).call(u);this.isSyncing=!1,this.nextCursor=Gd(i)||0,this.service.unread.resetTotalAfterSyncDone(),this.service.unread.digestUnreadCountChange(),this.service.emit("onSyncFinished"),this.core.V2NIMLoginService.dataSync.switchDataSync({type:1,state:3,subType:"conversationSync"}),this.processTempPacket()},t.setBackFillIds=function setBackFillIds(t){var i=this;return forEach$1(t).call(t,(function(t){if(2===t.lastMessageState&&i.service.compute.hasMessageService){i.conversationIdsForBackFill[t.conversationId]=!0;var u=i.core.V2NIMMessageService.model.getLastMessageOfConversation(t.conversationId);t.lastMessage=u?formatLastMessageFromMessage(i.core,u,t.lastMessageState,u.sendingState):""}else i.conversationIdsForBackFill[t.conversationId]=!1;delete t.lastMessageState})),t},t.recvConversationFromSyncAction=function recvConversationFromSyncAction(t){var i=this,u=get(t,"content.info").syncType,m=formatConversationFields(this.core,get(t,"content.datas"));0===(u=Gd(u))?(forEach$1(m).call(m,(function(t){i.initFieldVersion(t.conversationId,t.version)})),m=this.setBackFillIds(m),this.setModel(m)):(m=this.setBackFillIds(m),this.recvConversationForCreated(m)<m.length&&this.recvConversationForChanged(m))},t.recvConversation=function recvConversation(t){var i=this;if(this.isSyncing)this.tempPacket.push(t);else{var u=formatConversationFields(this.core,get(t,"content.datas")),m=filter(u).call(u,(function(t){return!!t.conversationId})),h=get(t,"content.info"),v=map$6(m).call(m,(function(t){return"id:"+t.conversationId+", ver:"+t.version})).join(";");if(this.core.logger.getDebugMode()?this.core.logger.debug("V2NIMConversation::recvConversation: "+v+".",h,m):this.core.logger.log("V2NIMConversation::recvConversation: "+v+".",h),2===h.type){var M=map$6(m).call(m,(function(t){return delete i.fieldVersion[t.conversationId],i.service.model.deleteById(t.conversationId),t.conversationId}));return this.service.emit("onConversationDeleted",M),void this.service.unread.digestUnreadCountChange()}if(12!==h.type)h.type,m=this.setBackFillIds(m),this.recvConversationForCreated(m)<m.length&&this.recvConversationForChanged(m);else this.compareAndClearUnreadInModel(h)}},t.recvConversationForCreated=function recvConversationForCreated(t){var i=this,u=filter(t).call(t,(function(t){return!i.fieldVersion[t.conversationId]})),m=reduce(u).call(u,(function(t,u){if(!i.fieldVersion[u.conversationId]){i.initFieldVersion(u.conversationId,u.version),t=!!i.updateModel(u)||t;var m=i.service.model.getById(u.conversationId);return m&&i.service.triggerConversationCreated(m),t}return t}),!1);return m&&this.service.unread.digestUnreadCountChange(),u.length},t.recvConversationForChanged=function recvConversationForChanged(t){var i,u=this,m=this.bulkCompare(t);if(0!==m.length){this.bulkUpdateModel(m);var h=filter(i=map$6(m).call(m,(function(t){return u.service.model.getById(t.conversationId)}))).call(i,(function(t){return!!t}));this.service.triggerConversationChanged(h)}},t.processTempPacket=function processTempPacket(){var t,i=this;forEach$1(t=this.tempPacket).call(t,(function(t){i.recvConversation(t)})),this.tempPacket=[]},t.bulkCompare=function bulkCompare(t){var i,u=this;return filter(i=map$6(t).call(t,(function(t){return u.compare(t)}))).call(i,(function(t){return!!t}))},t.compare=function compare(t){var i=this,u=t.version,m=t.conversationId,h=t.deleteFlag,v=t.type,M=["stickTop","groupIds","serverExtension","localExtension","lastMessage","lastMessageState","unreadCount","sortOrder","createTime","updateTime","lastReadTime"],I={},S=0;return forEach$1(M).call(M,(function(h){var v=h;if(void 0!==t[v]){var M=i.fieldVersion[m];M&&"number"==typeof M[v]&&M[v]>=u||(i.fieldVersion[m]=i.fieldVersion[m]||{},i.fieldVersion[m][v]=u,I[v]=t[v],S+=1)}})),S?Dt(Dt({},I),{conversationId:m,deleteFlag:h,version:u,type:v}):void 0},t.bulkUpdateModel=function bulkUpdateModel(t){var i=this,u=!1;forEach$1(t).call(t,(function(t){i.updateModel(t)&&(u=!0)})),u&&this.service.unread.digestUnreadCountChange()},t.initFieldVersion=function initFieldVersion(t,i){this.fieldVersion[t]={stickTop:i,groupIds:i,serverExtension:i,lastMessage:i,lastMessageState:i,unreadCount:i,sortOrder:i,createTime:i,updateTime:i,lastReadTime:i}},t.initConversation=function initConversation(t,i){var u=to();return Dt({conversationId:t,type:this.core.V2NIMConversationIdUtil.parseConversationType(t),stickTop:!1,localExtension:"",serverExtension:"",unreadCount:0,lastReadTime:0,createTime:u,updateTime:u,sortOrder:u},i)},t.updateModel=function updateModel(t){var i=formatConversationByField(t),u=i.deleteFlag,m=i.conversation;if(u){var h=this.service.model.deleteById(m.conversationId);return!!(h&&h.unreadCount>0)}return this.service.model.upsert(m)},t.setModel=function setModel(t){var i,u=map$6(i=filter(t).call(t,(function(t){return!t.deleteFlag}))).call(i,(function(t){return formatConversationByField(t).conversation}));this.service.model.set(u)},t.updateModelWithLastMessage=function updateModelWithLastMessage(t,i,u,m){var h=this.service.model.getById(t),v=i?formatLastMessageFromMessage(this.core,i,u,m):void 0;if(!isEqual(null==h?void 0:h.lastMessage,v))if(h){var M=Dt(Dt({},h),{sortOrder:v?h.stickTop?v.messageRefer.createTime+1e15:v.messageRefer.createTime:h.sortOrder,lastMessage:v});this.service.model.upsert(M),this.service.triggerConversationChanged([M])}else{this.initFieldVersion(t,-1);var I=this.initConversation(t,{lastMessage:v});this.service.model.upsert(I),this.service.triggerConversationCreated(I)}},t.updateModelByRevoke=function updateModelByRevoke(t){var i=this,u=[];forEach$1(t).call(t,(function(t){var m=t.postscript,h=t.messageRefer,v=__rest(t,["postscript","messageRefer"]),M=h.conversationId,I=i.service.model.getById(M);I&&I.lastMessage&&I.lastMessage.messageRefer.messageClientId===h.messageClientId&&1!==I.lastMessage.lastMessageState&&(I.lastMessage.lastMessageState=1,m&&(I.lastMessage.text=m),Dt(I.lastMessage,v),i.service.model.upsert(I),u.push(I))})),u.length>0&&this.service.triggerConversationChanged(u)},t.compareAndUpdateModel=function compareAndUpdateModel(t){var i=this;this.core.logger.log("V2NIMConversation::compareAndUpdateModel",map$6(t).call(t,(function(t){return t.conversationId})));var u=!1,m=[];forEach$1(t).call(t,(function(t){var h=i.compare(t);if(h){var v=i.service.model.getById(t.conversationId);i.updateModel(h)&&(u=!0);var M=i.service.model.getById(t.conversationId);M&&(v?m.push(M):i.service.triggerConversationCreated(M))}})),m.length>0&&this.service.triggerConversationChanged(m),u&&this.service.unread.digestUnreadCountChange()},t.compareAndDeleteModel=function compareAndDeleteModel(t){var i=this;this.core.logger.log("V2NIMConversation::compareAndDeleteModel",t);var u=reduce(t).call(t,(function(t,u){delete i.fieldVersion[u];var m=i.service.model.deleteById(u);return!!!!(m&&m.unreadCount>0)||t}),!1);this.service.emit("onConversationDeleted",t),u&&this.service.unread.digestUnreadCountChange()},t.compareAndDeleteGroupInModel=function compareAndDeleteGroupInModel(t,i){var u,m=this;this.core.logger.log("V2NIMConversation::compareAndDeleteGroupInModel",t,i);var h=[];forEach$1(u=Ht(this.fieldVersion)).call(u,(function(u){var v=m.fieldVersion[u];if(void 0===v.groupIds||t>v.groupIds){v.groupIds=t;var M=m.service.model.getById(u);if(M&&M.groupIds&&M.groupIds.length>0){var I,S=filter(I=M.groupIds).call(I,(function(t){return t!==i}));if(S.length!==M.groupIds.length){var T=Dt(Dt({},M),{groupIds:S});m.service.model.upsert(T),T&&h.push(T)}}}})),h.length>0&&this.service.triggerConversationChanged(h)},t.compareAndClearUnreadInModel=function compareAndClearUnreadInModel(t){var i=this,u=t.oneClickClearUnreadType,m=t.oneClickClearUnreadVersion,h=t.oneClickClearUnreadLastReadTime,v=t.oneClickClearUnreadConversationType,M=t.oneClickClearUnreadGroupId;this.core.logger.log("V2NIMConversation::compareAndClearUnreadInModel.ver:"+m+";type:"+u+";lastReadTime:"+h+";filter:"+(v||"")+";grounp:"+(M||""));var I=[],S=[];if(1===u)S=this.service.model.getAll();else if(v||M){var T=this.service.model.count();S=this.service.model.getByOption(0,T,{conversationTypes:v,conversationGroupIds:M?[M]:void 0}).conversationList}forEach$1(S).call(S,(function(t){var u=t.conversationId,v=i.fieldVersion[u];if(void 0===v.unreadCount||m>v.unreadCount){v.unreadCount=m,v.lastReadTime=m;var M=t.unreadCount,S=Dt(Dt({},t),{lastReadTime:h,unreadCount:0});i.service.model.upsert(S),M>0&&I.push(S)}})),I.length>0&&this.service.triggerConversationChanged(I),this.service.unread.digestUnreadCountChange()},t.backfillLastMsg=function backfillLastMsg(t,i){var u=this,m=t=uniq(t);(i||(m=filter(t).call(t,(function(t){return u.conversationIdsForBackFill[t]})),0!==m.length))&&forEach$1(m).call(m,(function(t){var i=get(u.service.model.getById(t),"lastMessage.messageRefer.messageClientId"),m=u.service.compute.hasMessageService?u.core.V2NIMMessageService.model.getLastMessageOfConversation(t):void 0;(m&&m.messageClientId)!==i&&(u.conversationIdsForBackFill[t]=!1,m?u.updateModelWithLastMessage(t,m,2,m.sendingState):u.updateModelWithLastMessage(t,void 0,2,0))}))},V2NIMConversationVersionCacheImpl}(),Xg={"28_1":"v2ConversationCreate","28_2":"v2ConversationDelete","28_3":"v2ConversationUpdate","28_4":"v2ConversationSetTop","28_5":"v2ConversationUnreadClear","28_6":"v2ConversationGet","28_7":"v2ConversationGetByIds","28_8":"v2ConversationGetList","28_17":"v2ConversationsDelete","28_18":"v2ConversationsUnreadClear","28_19":"v2ConversationSync","28_20":"v2ConversationNotifySync","28_21":"v2ConversationNotifySyncOnline","28_23":"v2ConversationClearTotalUnread","28_24":"v2ConversationClearTypeUnread","28_25":"v2ConversationClearGroupUnread","4_14":"syncConversationReadTime","4_20":"syncSuperTeamReadTime","4_22":"v2SyncSessionsWithMoreRoaming","4_25":"v2SyncSessionReliableInfo","30_16":"v2MarkConversationReadTime","32_25":"v2MarkSuperTeamReadTime","7_116":"v2MultiDeviceConversationReadTime","21_125":"v2MultiDeviceSuperTeamReadTime"},Zg="V2NIMConversationService",ev={conversationId:1,type:{id:2,retType:"number"},serverExtension:3,groupIds:{id:4,retConverter:function retConverter(t){return t?JSON.parse(t):void 0}},lastMessage:5,lastMessageState:{id:6,retType:"number"},unreadCount:{id:7,retType:"number"},stickTop:{id:8,retType:"boolean"},sortOrder:{id:9,retType:"number"},version:{id:10,retType:"number"},deleteFlag:{id:11,retType:"boolean"},createTime:{id:12,retType:"number"},updateTime:{id:13,retType:"number"},lastReadTime:{id:14,retType:"number"}},tv={type:{id:1,retType:"number"},oneClickClearUnreadType:{id:2,retType:"number"},oneClickClearUnreadConversationType:{id:3,retConverter:stringToJSONObject},oneClickClearUnreadGroupId:{id:4,retType:"string"},oneClickClearUnreadVersion:{id:5,retType:"number"},oneClickClearUnreadLastReadTime:{id:6,retType:"number"}},rv={v2ConversationCreate:{sid:28,cid:1,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationId:1}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ev)}]},v2ConversationDelete:{sid:28,cid:2,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationId:1,clearMessage:2}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ev)}]},v2ConversationUpdate:{sid:28,cid:3,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationId:1,serverExtension:2}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ev)}]},v2ConversationSetTop:{sid:28,cid:4,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationId:1,stickTop:2}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ev)}]},v2ConversationUnreadClear:{sid:28,cid:5,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationId:1}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ev)}]},v2ConversationGet:{sid:28,cid:6,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationId:1}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(ev)}]},v2ConversationGetByIds:{sid:28,cid:7,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationIds:1}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)},{type:"Property",name:"info",reflectMapper:{1:"failedMap"}}]},v2ConversationGetList:{sid:28,cid:8,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{cursor:1,limit:2}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)},{type:"Property",name:"info",reflectMapper:{1:"hasMore",2:"offset"}}]},v2ConversationsDelete:{sid:28,cid:17,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationIds:1,clearMessage:2}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)},{type:"Property",name:"info",reflectMapper:{1:"failedMap"}}]},v2ConversationsUnreadClear:{sid:28,cid:18,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationIds:1}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)},{type:"Property",name:"info",reflectMapper:{1:"failedMap"}}]},v2ConversationSync:{sid:28,cid:19,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{cursor:1}}],response:[{type:"Property",name:"info",reflectMapper:{1:"nextCursor",2:"syncType"}}]},v2ConversationNotifySync:{sid:28,cid:20,service:Zg,response:[{type:"Property",name:"info",reflectMapper:{1:"nextCursor",2:"syncType"}},{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)}]},v2ConversationNotifySyncOnline:{sid:28,cid:21,service:Zg,response:[{type:"Property",name:"info",reflectMapper:invertSerializeItem(tv)},{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)}]},v2ConversationClearTotalUnread:{sid:28,cid:23,service:Zg,response:[{type:"Property",name:"info",reflectMapper:invertSerializeItem(tv)}]},v2ConversationClearTypeUnread:{sid:28,cid:24,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{conversationType:1}}],response:[{type:"Property",name:"info",reflectMapper:invertSerializeItem(tv)}]},v2ConversationClearGroupUnread:{sid:28,cid:25,service:Zg,params:[{type:"Property",name:"tag",reflectMapper:{groupId:1}}],response:[{type:"Property",name:"info",reflectMapper:invertSerializeItem(tv)}]},syncConversationReadTime:{sid:4,cid:14,service:Zg,response:[{type:"StrLongMap",name:"p2p"},{type:"LongLongMap",name:"team"},{type:"Long",name:"timetag"}]},syncSuperTeamReadTime:{sid:4,cid:20,service:Zg,response:[{type:"LongLongMap",name:"superTeam"}]},v2SyncSessionsWithMoreRoaming:{sid:4,cid:22,service:Zg,response:[]},v2SyncSessionReliableInfo:{sid:4,cid:25,service:Zg,response:[]},v2MarkConversationReadTime:{sid:30,cid:16,service:Zg,params:[{type:"Byte",name:"scene"},{type:"String",name:"to"},{type:"Long",name:"timetag"}]},v2MarkSuperTeamReadTime:{sid:32,cid:25,service:Zg,params:[{type:"Long",name:"to"},{type:"Long",name:"timetag"}]},v2MultiDeviceConversationReadTime:{sid:30,cid:116,service:Zg,response:[{type:"Byte",name:"scene"},{type:"String",name:"to"},{type:"Long",name:"timetag"}]},v2MultiDeviceSuperTeamReadTime:{sid:21,cid:125,service:Zg,response:[{type:"Long",name:"to"},{type:"Long",name:"timetag"}]}},nv=function(){function V2NIMConversationUnreadImpl(t,i){this.totalUnreadCount=void 0,this.unreadCountByFilter={},this.core=t,this.service=i}var t=V2NIMConversationUnreadImpl.prototype;return t.reset=function reset(){this.totalUnreadCount=void 0,this.unreadCountByFilter={}},t.getTotalUnreadCount=function getTotalUnreadCount(){return this.totalUnreadCount},t.resetTotalAfterSyncDone=function resetTotalAfterSyncDone(){var t,i=reduce(t=this.service.model.getAll()).call(t,(function(t,i){return t+(i.unreadCount||0)}),0),u=this.totalUnreadCount;return void 0!==u&&u===i||(this.totalUnreadCount=i,this.service.emit("onTotalUnreadCountChanged",i)),i},t.digestUnreadCountChange=function digestUnreadCountChange(){this._digest()},t._digest=function _digest(){var t,i=this,u=this.totalUnreadCount,m=reduce(t=this.service.model.getAll()).call(t,(function(t,i){return t+(i.unreadCount||0)}),0);this.core.logger.log("V2NIMConversation::digestUnreadCountChange:oldUnreadCount "+u+", newUnreadCount "+m),u!==m&&(this.totalUnreadCount=m,this.service.emit("onTotalUnreadCountChanged",m));var h=Ht(this.unreadCountByFilter);forEach$1(h).call(h,(function(t){var u=JSON.parse(t),m=i.getUnreadCountByFilter(u),h=i.unreadCountByFilter[t];i.unreadCountByFilter[t]=m,u.equals=bind$1(equals).call(equals,u),h!==m&&i.service.emit("onUnreadCountChangedByFilter",u,m)}))},t.getUnreadCountByIds=function getUnreadCountByIds(t){var i=this;return reduce(t).call(t,(function(t,u){var m=i.service.model.getById(u);return t+(m&&m.unreadCount||0)}),0)},t.getUnreadCountByFilter=function getUnreadCountByFilter(t){var i,u=this.service.model.count(),m=this.service.model.getByOption(0,u,{conversationTypes:t.conversationTypes,conversationGroupIds:t.conversationGroupId?[t.conversationGroupId]:void 0,ignoreMuted:t.ignoreMuted});return reduce(i=m.conversationList).call(i,(function(t,i){return t+(i.unreadCount||0)}),0)},t.addFilter=function addFilter(t){var i=generateFilterKey(t);if(void 0!==this.unreadCountByFilter[i])throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_ALREADY_EXIST});var u=JSON.parse(i),m=this.getUnreadCountByFilter(u);this.unreadCountByFilter[i]=m,this.service.emit("onUnreadCountChangedByFilter",u,m)},t.deleteFilter=function deleteFilter(t){var i=generateFilterKey(t);if(void 0===this.unreadCountByFilter[i])throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});delete this.unreadCountByFilter[i]},V2NIMConversationUnreadImpl}();function generateFilterKey(t){var i=t.conversationTypes;return i&&(i=sort(i).call(i)),Un({conversationGroupId:t.conversationGroupId,conversationTypes:i,ignoreMuted:t.ignoreMuted})}function equals(t){return Un(this)===generateFilterKey(t)}var av={createTime:{type:"number"},updateTime:{type:"number"}};function formatConversationGroups(t){return t&&t.length>0?map$6(t).call(t,(function(t){return formatConversationGroup(t)})):[]}function formatConversationGroup(t){return format(av,t)}function formatFailedMap(t){var i,u=JSON.parse(t);return map$6(i=Ht(u)).call(i,(function(t){return{conversationId:t,error:new Yl({code:u[t]})}}))}var iv,ov={type:{type:"number"},deleteVersion:{type:"number"},conversationIds:{type:"object"}};function formatConversationGroupNotify(t){return format(ov,t)}!function(t){t[t.createConversationGroup=1]="createConversationGroup",t[t.deleteConversationGroup=2]="deleteConversationGroup",t[t.updateConversationGroup=3]="updateConversationGroup",t[t.addConversationToGroup=4]="addConversationToGroup",t[t.removeConversationFromGroup=5]="removeConversationFromGroup"}(iv||(iv={}));var sv=function(){function V2NIMConversationComputeImpl(t,i){this.core=t,this.service=i}var t=V2NIMConversationComputeImpl.prototype;return t.computeConvs=function computeConvs(t){var i=this;return map$6(t).call(t,(function(t){return i.computeConv(t)}))},t.computeConv=function computeConv(t){var i,u,m,h,v;if(0===t.type)return t;var M=this.core.V2NIMConversationIdUtil.parseConversationType(t.conversationId),I=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t.conversationId),S={};if(t.lastReadTime||(S.lastReadTime=this.service.model.getReadTime(t.conversationId)),(null===(i=this.core.V2NIMSettingService)||void 0===i?void 0:i.name)&&(S.mute=this.core.V2NIMSettingService.getConversationMuteStatus(t.conversationId)),1===M&&this.hasUserService){var T,C=this.core.V2NIMUserService.model.getUser(I),E=this.hasFriendService?this.core.V2NIMFriendService.model.getFriend(I):void 0;t.conversationId!==(null===(u=t.lastMessage)||void 0===u?void 0:u.messageRefer.conversationId)||0!==(null===(m=t.lastMessage)||void 0===m?void 0:m.lastMessageState)&&2!==(null===(h=t.lastMessage)||void 0===h?void 0:h.lastMessageState)||(T=null===(v=t.lastMessage)||void 0===v?void 0:v.senderName),S.name=(null==E?void 0:E.alias)||(null==C?void 0:C.name)||T||I,S.avatar=(null==C?void 0:C.avatar)||""}else if(2===M&&this.hasTeamService){var A=this.core.V2NIMTeamService.model.getById(I,1);S.name=(null==A?void 0:A.name)||I,S.avatar=(null==A?void 0:A.avatar)||""}else if(3===M&&this.hasTeamService){var k=this.core.V2NIMTeamService.model.getById(I,2);S.name=(null==k?void 0:k.name)||I,S.avatar=(null==k?void 0:k.avatar)||""}return Dt(t,S),t},t.computeReadTimeForMark=function computeReadTimeForMark(t){var i,u,m,h=t.conversationId,v=this.service.model.getReadTime(h);if(null===(u=null===(i=null==t?void 0:t.lastMessage)||void 0===i?void 0:i.messageRefer)||void 0===u?void 0:u.createTime)m=t.lastMessage.messageRefer.createTime;else{if(!this.core.timeOrigin.checkNodeReliable())return v||0;m=this.core.timeOrigin.getNTPTime()}return m},Qe(V2NIMConversationComputeImpl,[{key:"hasUserService",get:function get(){var t;return!!(null===(t=this.core.V2NIMUserService)||void 0===t?void 0:t.name)}},{key:"hasFriendService",get:function get(){var t;return!!(null===(t=this.core.V2NIMFriendService)||void 0===t?void 0:t.name)}},{key:"hasTeamService",get:function get(){var t;return!!(null===(t=this.core.V2NIMTeamService)||void 0===t?void 0:t.name)}},{key:"hasMessageService",get:function get(){var t;return!!(null===(t=this.core.V2NIMMessageService)||void 0===t?void 0:t.name)}}]),V2NIMConversationComputeImpl}(),cv=Qi.entries;_export({target:"Object",stat:!0},{entries:function entries(t){return cv(t)}});var lv,dv,uv,pv,mv=$.Object.entries,hv=function(){function V2NIMConversationHandlerImpl(t,i){this.core=t,this.service=i,this.model=this.service.model,this.logger=this.core.logger}var t=V2NIMConversationHandlerImpl.prototype;return t.v2ConversationNotifySyncHandler=function v2ConversationNotifySyncHandler(t){this.ifEnabled&&this.service.versionCache.recvConversationFromSyncAction(t)},t.v2ConversationNotifySyncOnlineHandler=function v2ConversationNotifySyncOnlineHandler(t){this.ifEnabled&&this.service.versionCache.recvConversation(t)},t.syncConversationReadTimeHandler=function syncConversationReadTimeHandler(t){var i,u,m;if(this.ifEnabled){if(null===(i=null==t?void 0:t.content)||void 0===i?void 0:i.p2p)for(var h=0,v=mv(t.content.p2p);h<v.length;h++){var M=v[h],I=M[0],S=M[1];this.model.updateReadTime(this.core.V2NIMConversationIdUtil.p2pConversationId(I),S),this.service.emit("onConversationReadTimeUpdated",this.core.V2NIMConversationIdUtil.p2pConversationId(I),S)}if(null===(m=null===(u=null==t?void 0:t.content)||void 0===u?void 0:u.team)||void 0===m?void 0:m.m_map)for(var T=0,C=mv(t.content.team.m_map);T<C.length;T++){var E=C[T],A=E[0],k=E[1];this.model.updateReadTime(this.core.V2NIMConversationIdUtil.teamConversationId(A),k),this.service.emit("onConversationReadTimeUpdated",this.core.V2NIMConversationIdUtil.teamConversationId(A),k)}}},t.syncSuperTeamReadTimeHandler=function syncSuperTeamReadTimeHandler(t){var i,u;if(this.ifEnabled&&(null===(u=null===(i=null==t?void 0:t.content)||void 0===i?void 0:i.superTeam)||void 0===u?void 0:u.m_map))for(var m=0,h=mv(t.content.superTeam.m_map);m<h.length;m++){var v=h[m],M=v[0],I=v[1];this.model.updateReadTime(this.core.V2NIMConversationIdUtil.superTeamConversationId(M),I),this.service.emit("onConversationReadTimeUpdated",this.core.V2NIMConversationIdUtil.superTeamConversationId(M),I)}},t.v2MultiDeviceConversationReadTimeHandler=function v2MultiDeviceConversationReadTimeHandler(t){var i;this.ifEnabled&&(null===(i=null==t?void 0:t.content)||void 0===i?void 0:i.to)&&(0===t.content.scene?(this.model.updateReadTime(this.core.V2NIMConversationIdUtil.p2pConversationId(t.content.to),t.content.timetag),this.service.emit("onConversationReadTimeUpdated",this.core.V2NIMConversationIdUtil.p2pConversationId(t.content.to),t.content.timetag)):(this.model.updateReadTime(this.core.V2NIMConversationIdUtil.teamConversationId(t.content.to),t.content.timetag),this.service.emit("onConversationReadTimeUpdated",this.core.V2NIMConversationIdUtil.teamConversationId(t.content.to),t.content.timetag)))},t.v2MultiDeviceSuperTeamReadTimeHandler=function v2MultiDeviceSuperTeamReadTimeHandler(t){var i;this.ifEnabled&&(null===(i=null==t?void 0:t.content)||void 0===i?void 0:i.to)&&(this.model.updateReadTime(this.core.V2NIMConversationIdUtil.superTeamConversationId(t.content.to),t.content.timetag),this.service.emit("onConversationReadTimeUpdated",this.core.V2NIMConversationIdUtil.superTeamConversationId(t.content.to),t.content.timetag))},Qe(V2NIMConversationHandlerImpl,[{key:"ifEnabled",get:function get(){return!0===this.core.options.enableV2CloudConversation}}]),V2NIMConversationHandlerImpl}(),gv=function(){function V2NIMConversationEventImpl(t,i){this.core=t,this.service=i,this.model=this.service.model,this.versionCache=this.service.versionCache,this.logger=this.core.logger}var t=V2NIMConversationEventImpl.prototype;return t.setListener=function setListener(){var t,i,u,m,h,v,M,I=this;this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",(function(){return I.versionCache.doSync()})),this.core.eventBus.on("V2NIMConversationService/conversationOnlineSyncNotify",bind$1(t=this.conversationOnlineSyncNotify).call(t,this)),this.core.eventBus.on("V2NIMMessageService/sendMessage",bind$1(i=this.sendMessage).call(i,this)),this.core.eventBus.on("V2NIMMessageService/deleteMessages",bind$1(u=this.deleteMessages).call(u,this)),this.core.eventBus.on("V2NIMMessageService/revokeMessages",bind$1(m=this.revokeMessages).call(m,this)),this.core.eventBus.on("V2NIMMessageService/roamingMsgs",bind$1(h=this.roamingOrOfflineMsgs).call(h,this)),this.core.eventBus.on("V2NIMMessageService/offlineMsgs",bind$1(v=this.roamingOrOfflineMsgs).call(v,this)),this.core.eventBus.on("V2NIMSettingService/setMute",bind$1(M=this.setMute).call(M,this))},t.beforeEmit=function beforeEmit(t){for(var i,u,m=this.service.name+"::emit "+t.toString(),h=arguments.length,v=new Array(h>1?h-1:0),M=1;M<h;M++)v[M-1]=arguments[M];if("onConversationCreated"===t){var I=v[0];this.logger.log(""+m,"id:"+I.conversationId+";unread:"+I.unreadCount+";lastMsg:"+(null===(i=I.lastMessage)||void 0===i?void 0:i.messageRefer.messageClientId)+"/"+(null===(u=I.lastMessage)||void 0===u?void 0:u.messageRefer.messageServerId))}else if("onConversationChanged"===t){var S=v[0];this.logger.log(""+m,map$6(S).call(S,(function(t){var i,u;return"id:"+t.conversationId+";unread:"+t.unreadCount+";lastMsg:"+(null===(i=t.lastMessage)||void 0===i?void 0:i.messageRefer.messageClientId)+"/"+(null===(u=t.lastMessage)||void 0===u?void 0:u.messageRefer.messageServerId)})))}else{var T,C;(T=this.logger).log.apply(T,concat(C=[""+m]).call(C,v))}},t.conversationOnlineSyncNotify=function conversationOnlineSyncNotify(t,i){var u;!1!==(null===(u=null==i?void 0:i.messageConfig)||void 0===u?void 0:u.lastMessageUpdateEnabled)&&(t.content.info=deserialize(t.content.info,invertSerializeItem(tv)),t.content.data=deserialize(t.content.data,invertSerializeItem(ev)),i&&(t.content.data.lastMessage=formatLastMessageFromMessage(this.core,i,0)),t.content.datas=[t.content.data],this.service.handler.v2ConversationNotifySyncOnlineHandler.call(this,t))},t.sendMessage=function sendMessage(t,i){var u,m;1===i&&!0===(null===(u=t.messageConfig)||void 0===u?void 0:u.historyEnabled)||!1!==(null===(m=null==t?void 0:t.messageConfig)||void 0===m?void 0:m.lastMessageUpdateEnabled)&&this.versionCache.updateModelWithLastMessage(t.conversationId,t,2,i)},t.deleteMessages=function deleteMessages(t){var i=map$6(t).call(t,(function(t){return t.messageRefer.conversationId}));this.versionCache.backfillLastMsg(i,!0)},t.revokeMessages=function revokeMessages(t){this.versionCache.updateModelByRevoke(t)},t.roamingOrOfflineMsgs=function roamingOrOfflineMsgs(t){var i=uniq(map$6(t).call(t,(function(t){return t.conversationId})));this.versionCache.backfillLastMsg(i,!1)},t.setMute=function setMute(t,i){var u=this.model.getById(t);u&&u.mute!==i&&(u.mute=i,this.model.upsert(u),this.service.triggerConversationChanged([u]))},V2NIMConversationEventImpl}(),vv=function(t){function V2NIMConversationServiceImpl(i,u){var m;return void 0===u&&(u={}),(m=t.call(this,"V2NIMConversationService",i)||this).config={},m.model=new Qg,m.versionCache=new Jg(m.core,Je(m)),m.unread=new nv(m.core,Je(m)),m.compute=new sv(m.core,Je(m)),m.event=new gv(m.core,Je(m)),m.handler=new hv(m.core,Je(m)),m.core._registerDep(mm,"V2NIMConversationIdUtil"),"v2"!==m.core.options.apiVersion||!0!==m.core.options.enableV2CloudConversation?Je(m):(registerParser({cmdMap:Xg,cmdConfig:rv}),m.setOptions(u),m.setListener(),m)}Nt(V2NIMConversationServiceImpl,t);var i=V2NIMConversationServiceImpl.prototype;return i.setOptions=function setOptions(t){this.config=Dt(this.config,t)},i.setListener=function setListener(){this.event.setListener()},i.reset=function reset(){this.versionCache.reset(),this.model.reset(),this.unread.reset()},i.emit=function emit(i){for(var u,m,h,v,M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];return(u=this.event).beforeEmit.apply(u,concat(m=[i]).call(m,I)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,I))},i.checkEnable=function checkEnable(){if(!0!==this.core.options.enableV2CloudConversation)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"V2CloudConversation is not enabled"}})},i.getConversationList=function getConversationList(t,i){this.checkEnable(),this.checkV2(),validate({offset:{type:"number",min:0}},{offset:t},"",!0),validate({limit:{type:"number",min:1}},{limit:i},"",!0),this.core.V2NIMLoginService.checkIllegalState();var u=this.model.getByOption(t,i,{});return u.conversationList=this.compute.computeConvs(u.conversationList),zi.resolve(u)},i.getConversationListByOption=function getConversationListByOption(t,i,u){this.checkEnable(),this.checkV2(),validate({offset:{type:"number",min:0}},{offset:t},"",!0),validate({limit:{type:"number",min:1}},{limit:i},"",!0),validate({option:{type:"object",required:!0,rules:{conversationTypes:{type:"array",itemType:"number",required:!1},onlyUnread:{type:"boolean",required:!1},conversationGroupIds:{type:"array",itemType:"string",required:!1}}}},{option:u},"",!0),this.core.V2NIMLoginService.checkIllegalState();var m=this.model.getByOption(t,i,u);return m.conversationList=this.compute.computeConvs(m.conversationList),zi.resolve(m)},i.getConversation=function getConversation(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:if(this.checkEnable(),this.checkV2(),validateConversationId(this.core.account,t),!(i=this.model.getById(t))){u.next=8;break}return u.abrupt("return",this.compute.computeConv(i));case 8:throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});case 9:case"end":return u.stop()}}),_callee,this)})))},i.getConversationListByIds=function getConversationListByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m=this;return ud.wrap((function _callee2$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkEnable(),this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0),this.core.V2NIMLoginService.checkIllegalState(),u=filter(i=map$6(t).call(t,(function(t){return m.model.getById(t)}))).call(i,(function(t){return!!t})),u=this.compute.computeConvs(u),h.abrupt("return",u);case 7:case"end":return h.stop()}}),_callee2,this)})))},i.createConversation=function createConversation(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h;return ud.wrap((function _callee3$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkEnable(),this.checkV2(),validateConversationId(this.core.account,t),v.next=5,this.core.sendCmd("v2ConversationCreate",{tag:{conversationId:t}});case 5:if(i=v.sent,u=get(i,"content.data"),m=formatConversationField(this.core,u),this.versionCache.compareAndUpdateModel([m]),!(h=this.model.getById(t))){v.next=14;break}return v.abrupt("return",this.compute.computeConv(h));case 14:throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});case 15:case"end":return v.stop()}}),_callee3,this)})))},i.deleteConversation=function deleteConversation(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkEnable(),this.checkV2(),validateConversationId(this.core.account,t),validate({clearMessage:{type:"boolean",required:!1}},{clearMessage:i},"",!0),u.prev=4,u.next=7,this.core.sendCmd("v2ConversationDelete",{tag:{conversationId:t,clearMessage:Number(i||!1)}});case 7:u.next=12;break;case 9:u.prev=9,u.t0=u.catch(4),this.logger.warn("V2NIMConversationService:deleteConversation: delete conversation failed: "+t);case 12:this.model.getById(t)&&(i&&this.core.eventBus.emit("V2NIMConversationService/deleteConversation",[t]),this.versionCache.compareAndDeleteModel([t]));case 13:case"end":return u.stop()}}),_callee4,this,[[4,9]])})))},i.deleteConversationListByIds=function deleteConversationListByIds(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var u,m,h,v=this;return ud.wrap((function _callee5$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkEnable(),this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0),validate({clearMessage:{type:"boolean",required:!1}},{clearMessage:i},"",!0),M.next=6,this.core.sendCmd("v2ConversationsDelete",{tag:{conversationIds:Un(t),clearMessage:Number(i||!1)}});case 6:return u=M.sent,m=formatFailedMap(get(u,"content.info.failedMap")),(h=filter(m).call(m,(function(t){return t.error.code!==zl.V2NIM_ERROR_CODE_CONVERSATION_NOT_EXIST||!v.model.getById(t.conversationId)}))).length<t.length&&(i&&this.core.eventBus.emit("V2NIMConversationService/deleteConversation",t),this.versionCache.compareAndDeleteModel(t)),M.abrupt("return",h);case 11:case"end":return M.stop()}}),_callee5,this)})))},i.getStickTopConversationList=function getStickTopConversationList(){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),t.abrupt("return",this.model.getStickTopList());case 3:case"end":return t.stop()}}),_callee6,this)})))},i.stickTopConversation=function stickTopConversation(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var u,m,h;return ud.wrap((function _callee7$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkEnable(),this.checkV2(),validateConversationId(this.core.account,t),validate({stickTop:{type:"boolean"}},{stickTop:i},"",!0),v.next=6,this.core.sendCmd("v2ConversationSetTop",{tag:{conversationId:t,stickTop:Number(i)}});case 6:u=v.sent,m=get(u,"content.data"),h=formatConversationField(this.core,m),this.versionCache.compareAndUpdateModel([h]);case 10:case"end":return v.stop()}}),_callee7,this)})))},i.updateConversation=function updateConversation(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var u,m,h;return ud.wrap((function _callee8$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkEnable(),this.checkV2(),validateConversationId(this.core.account,t),validate({updateInfo:{type:"object",required:!0,rules:{serverExtension:{type:"string"}}}},{updateInfo:i},"",!0),v.next=6,this.core.sendCmd("v2ConversationUpdate",{tag:Dt({conversationId:t},i)});case 6:u=v.sent,m=get(u,"content.data"),h=formatConversationField(this.core,m),this.versionCache.compareAndUpdateModel([h]);case 10:case"end":return v.stop()}}),_callee8,this)})))},i.updateConversationLocalExtension=function updateConversationLocalExtension(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var u,m;return ud.wrap((function _callee9$(h){for(;;)switch(h.prev=h.next){case 0:if(this.checkEnable(),this.checkV2(),validateConversationId(this.core.account,t),validate({localExtension:{type:"string"}},{localExtension:i},"",!0),u=this.model.getById(t)){h.next=7;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST});case 7:if(u.localExtension!==i){h.next=9;break}return h.abrupt("return");case 9:m=Dt(Dt({},u),{localExtension:i}),this.model.upsert(m),this.triggerConversationChanged([m]);case 12:case"end":return h.stop()}}),_callee9,this)})))},i.getTotalUnreadCount=function getTotalUnreadCount(){return this.checkEnable(),this.checkV2(),this.unread.getTotalUnreadCount()||0},i.getUnreadCountByIds=function getUnreadCountByIds(t){this.checkEnable(),this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0);var i=this.unread.getUnreadCountByIds(t);return zi.resolve(i)},i.getUnreadCountByFilter=function getUnreadCountByFilter(t){this.checkEnable(),this.checkV2(),this.valiteFilter(t);var i=this.unread.getUnreadCountByFilter(t);return zi.resolve(i)},i.clearTotalUnreadCount=function clearTotalUnreadCount(){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var t,i;return ud.wrap((function _callee10$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkEnable(),this.checkV2(),u.next=4,this.core.sendCmd("v2ConversationClearTotalUnread");case 4:t=u.sent,i=get(t,"content.info"),this.versionCache.compareAndClearUnreadInModel(i);case 7:case"end":return u.stop()}}),_callee10,this)})))},i.clearUnreadCountByIds=function clearUnreadCountByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var i,u,m;return ud.wrap((function _callee11$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkEnable(),this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},"",!0),h.next=5,this.core.sendCmd("v2ConversationsUnreadClear",{tag:{conversationIds:Un(t)}});case 5:return i=h.sent,u=formatConversationFields(this.core,get(i,"content.datas")),m=formatFailedMap(get(i,"content.info.failedMap")),this.versionCache.compareAndUpdateModel(u),h.abrupt("return",m);case 10:case"end":return h.stop()}}),_callee11,this)})))},i.clearUnreadCountByGroupId=function clearUnreadCountByGroupId(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkEnable(),this.checkV2(),validate({groupId:{type:"string"}},{groupId:t},"",!0),i.next=5,this.core.sendCmd("v2ConversationClearGroupUnread",{tag:{groupId:t}});case 5:case"end":return i.stop()}}),_callee12,this)})))},i.clearUnreadCountByTypes=function clearUnreadCountByTypes(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i,u;return ud.wrap((function _callee13$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkEnable(),this.checkV2(),validate({types:Kg},{types:t},"",!0),m.next=5,this.core.sendCmd("v2ConversationClearTypeUnread",{tag:{conversationType:Un(t)}});case 5:i=m.sent,u=get(i,"content.info"),this.versionCache.compareAndClearUnreadInModel(u);case 8:case"end":return m.stop()}}),_callee13,this)})))},i.markConversationRead=function markConversationRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var i,u,m,h,v;return ud.wrap((function _callee14$(M){for(;;)switch(M.prev=M.next){case 0:if(this.checkEnable(),this.checkV2(),this.checkLogin(),validateConversationId(this.core.account,t),i=this.model.getById(t)){M.next=7;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Conversation not exist"}});case 7:if(u=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t),m=this.core.V2NIMConversationIdUtil.parseConversationType(t),h=this.model.getReadTime(t),v=this.compute.computeReadTimeForMark(i),!(h>=v)){M.next=14;break}return this.logger.log("V2Conv::markConversationRead currentReadTime >= readTime "+t+","+h+","+v),M.abrupt("return",h);case 14:if(3!==m){M.next=19;break}return M.next=17,this.core.sendCmd("v2MarkSuperTeamReadTime",{timetag:v,to:u});case 17:M.next=21;break;case 19:return M.next=21,this.core.sendCmd("v2MarkConversationReadTime",{scene:1===m?0:2===m?1:2,timetag:v,to:u});case 21:return this.model.updateReadTime(t,v),M.abrupt("return",v);case 23:case"end":return M.stop()}}),_callee14,this)})))},i.getConversationReadTime=function getConversationReadTime(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){return ud.wrap((function _callee15$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkEnable(),this.checkV2(),validateConversationId(this.core.account,t),i.abrupt("return",this.model.getReadTime(t));case 4:case"end":return i.stop()}}),_callee15,this)})))},i.subscribeUnreadCountByFilter=function subscribeUnreadCountByFilter(t){var i;this.checkEnable(),this.checkV2(),this.checkLogin(),this.valiteFilter(t),0===(null===(i=t.conversationTypes)||void 0===i?void 0:i.length)&&delete t.conversationTypes,this.unread.addFilter(t)},i.unsubscribeUnreadCountByFilter=function unsubscribeUnreadCountByFilter(t){var i;this.checkEnable(),this.checkV2(),this.checkLogin(),this.valiteFilter(t),0===(null===(i=t.conversationTypes)||void 0===i?void 0:i.length)&&delete t.conversationTypes,this.unread.deleteFilter(t)},i.valiteFilter=function valiteFilter(t){if(validate({filter:{type:"object",required:!0,rules:{conversationTypes:{type:"array",itemType:"number",required:!1},conversationGroupId:{type:"string",allowEmpty:!1,required:!1},ignoreMuted:{type:"boolean",required:!1}}}},{filter:t},"",!0),void 0===t.conversationTypes&&void 0===t.conversationGroupId&&!0!==t.ignoreMuted)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Filter cannot be empty"}})},i.triggerConversationChanged=function triggerConversationChanged(t){t=this.compute.computeConvs(t),t=JSON.parse(Un(t)),forEach$1(t).call(t,(function(t){t.lastMessage||(t.lastMessage=void 0),delete t.lastMessageState})),this.emit("onConversationChanged",t)},i.triggerConversationCreated=function triggerConversationCreated(t){t=this.compute.computeConv(t),delete(t=JSON.parse(Un(t))).lastMessageState,this.emit("onConversationCreated",t)},V2NIMConversationServiceImpl}(hp),fv={"28_9":"v2ConversationGroupCreate","28_10":"v2ConversationGroupDelete","28_11":"v2ConversationGroupUpdate","28_12":"v2ConversationGroupGet","28_13":"v2ConversationGroupsGet","28_14":"v2ConversationGroupListGet","28_15":"v2ConversationGroupAddTo","28_16":"v2ConversationGroupRemoveFrom","28_22":"v2ConversationGroupNotifySyncOnline"},yv="V2NIMConversationGroupService",Mv={groupId:1,name:2,serverExtension:3,createTime:4,updateTime:5},Iv={v2ConversationGroupCreate:{sid:28,cid:9,service:yv,params:[{type:"Property",name:"tag",reflectMapper:{conversationIds:1,name:2,serverExtension:3}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Mv)},{type:"PropertyArray",name:"conversations",reflectMapper:invertSerializeItem(ev)},{type:"Property",name:"info",reflectMapper:{1:"failedMap"}}]},v2ConversationGroupDelete:{sid:28,cid:10,service:yv,params:[{type:"Property",name:"tag",reflectMapper:{groupId:1}}],response:[{type:"Property",name:"info",reflectMapper:{1:"type",2:"deleteVersion",3:"groupList"}}]},v2ConversationGroupUpdate:{sid:28,cid:11,service:yv,params:[{type:"Property",name:"tag",reflectMapper:{groupId:1,name:2,serverExtension:3}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Mv)}]},v2ConversationGroupGet:{sid:28,cid:12,service:yv,params:[{type:"Property",name:"tag",reflectMapper:{groupId:1}}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Mv)}]},v2ConversationGroupsGet:{sid:28,cid:13,service:yv,params:[{type:"Property",name:"tag",reflectMapper:{groupIds:1}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Mv)},{type:"Property",name:"info",reflectMapper:{1:"failedMap"}}]},v2ConversationGroupListGet:{sid:28,cid:14,service:yv,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Mv)}]},v2ConversationGroupAddTo:{sid:28,cid:15,service:yv,params:[{type:"Property",name:"tag",reflectMapper:{groupId:1,conversationIds:2}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)},{type:"Property",name:"info",reflectMapper:{1:"failedMap"}}]},v2ConversationGroupRemoveFrom:{sid:28,cid:16,service:yv,params:[{type:"Property",name:"tag",reflectMapper:{groupId:1,conversationIds:2}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(ev)},{type:"Property",name:"info",reflectMapper:{1:"failedMap"}}]},v2ConversationGroupNotifySyncOnline:{sid:28,cid:22,service:yv,response:[{type:"Property",name:"info",reflectMapper:{1:"type",2:"deleteVersion",3:"conversationIds"}},{type:"Property",name:"data",reflectMapper:invertSerializeItem(Mv)}]}},_v=function(t){function V2NIMConversationGroupServiceImpl(i,u){var m;return void 0===u&&(u={}),(m=t.call(this,"V2NIMConversationGroupService",i)||this).config={},m.core._registerDep(vv,"V2NIMConversationService"),"v2"!==m.core.options.apiVersion||!0!==m.core.options.enableV2CloudConversation?Je(m):(registerParser({cmdMap:fv,cmdConfig:Iv}),m.setOptions(u),m)}Nt(V2NIMConversationGroupServiceImpl,t);var i=V2NIMConversationGroupServiceImpl.prototype;return i.setOptions=function setOptions(t){this.config=Dt(this.config,t)},i.emit=function emit(i){for(var u,m,h=this.name+"::emit "+i.toString(),v=arguments.length,M=new Array(v>1?v-1:0),I=1;I<v;I++)M[I-1]=arguments[I];if("onConversationsAddedToGroup"===i){var S=M[0],T=M[1];this.logger.log(""+h,"groupId:"+S,"conversations:"+map$6(T).call(T,(function(t){return t.conversationId})).join(","))}else{var C,E;(C=this.logger).log.apply(C,concat(E=[""+h]).call(E,M))}return(u=t.prototype.emit).call.apply(u,concat(m=[this,i]).call(m,M))},i.checkEnable=function checkEnable(){if(!0!==this.core.options.enableV2CloudConversation)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"V2CloudConversation is not enabled"}})},i.createConversationGroup=function createConversationGroup(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var m,h,v,M,I,S=this;return ud.wrap((function _callee$(T){for(;;)switch(T.prev=T.next){case 0:return this.checkEnable(),this.checkV2(),validate({name:{type:"string",allowEmpty:!1}},{name:t},"",!0),validate({serverExtension:{type:"string",required:!1}},{serverExtension:i},"",!0),validate({conversationIds:{type:"array",itemType:"string",required:!1}},{conversationIds:u},"",!0),T.next=7,this.core.sendCmd("v2ConversationGroupCreate",{tag:{name:t,serverExtension:i||"",conversationIds:u&&Un(u)}});case 7:return m=T.sent,h=formatConversationGroup(get(m,"content.data")),v=formatConversationFields(this.core,get(m,"content.conversations")),M=formatFailedMap(get(m,"content.info.failedMap")),this.emit("onConversationGroupCreated",h),v.length>0&&(this.core.V2NIMConversationService.versionCache.compareAndUpdateModel(v),this.emit("onConversationsAddedToGroup",h.groupId,filter(I=map$6(v).call(v,(function(t){return S.core.V2NIMConversationService.model.getById(t.conversationId)}))).call(I,(function(t){return!!t})))),T.abrupt("return",{group:h,failedList:M});case 14:case"end":return T.stop()}}),_callee,this)})))},i.deleteConversationGroup=function deleteConversationGroup(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkEnable(),this.checkV2(),validate({groupId:{type:"string",allowEmpty:!1}},{groupId:t},"",!0),m.next=5,this.core.sendCmd("v2ConversationGroupDelete",{tag:{groupId:t}});case 5:i=m.sent,u=formatConversationGroupNotify(get(i,"content.info")),this.core.V2NIMConversationService.versionCache.compareAndDeleteGroupInModel(u.deleteVersion,t),this.emit("onConversationGroupDeleted",t);case 9:case"end":return m.stop()}}),_callee2,this)})))},i.updateConversationGroup=function updateConversationGroup(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var m,h;return ud.wrap((function _callee3$(v){for(;;)switch(v.prev=v.next){case 0:if(this.checkEnable(),this.checkV2(),validate({groupId:{type:"string",allowEmpty:!1}},{groupId:t},"",!0),validate({name:{type:"string",required:!1}},{name:i},"",!0),validate({serverExtension:{type:"string",required:!1}},{serverExtension:u},"",!0),void 0!==i||void 0!==u){v.next=7;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER});case 7:return v.next=9,this.core.sendCmd("v2ConversationGroupUpdate",{tag:{groupId:t,name:i,serverExtension:u}});case 9:m=v.sent,h=formatConversationGroup(get(m,"content.data")),this.emit("onConversationGroupChanged",h);case 12:case"end":return v.stop()}}),_callee3,this)})))},i.addConversationsToGroup=function addConversationsToGroup(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var u,m,h,v,M,I,S=this;return ud.wrap((function _callee4$(T){for(;;)switch(T.prev=T.next){case 0:return this.checkEnable(),this.checkV2(),validate({groupId:{type:"string",allowEmpty:!1}},{groupId:t},"",!0),validate({conversationIds:{type:"array",itemType:"string",min:1,allowEmpty:!1}},{conversationIds:i},"",!0),T.next=6,this.core.sendCmd("v2ConversationGroupAddTo",{tag:{groupId:t,conversationIds:Un(i)}});case 6:return m=T.sent,h=get(m,"content.info.failedMap")||"",v=[],h&&(v=formatFailedMap(h)),M=formatConversationFields(this.core,get(m,"content.datas")),this.core.V2NIMConversationService.versionCache.compareAndUpdateModel(M),(I=filter(u=map$6(M).call(M,(function(t){return S.core.V2NIMConversationService.model.getById(t.conversationId)}))).call(u,(function(t){return!!t}))).length>0&&this.emit("onConversationsAddedToGroup",t,I),T.abrupt("return",v);case 15:case"end":return T.stop()}}),_callee4,this)})))},i.removeConversationsFromGroup=function removeConversationsFromGroup(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var u,m,h,v;return ud.wrap((function _callee5$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkEnable(),this.checkV2(),validate({groupId:{type:"string",allowEmpty:!1}},{groupId:t},"",!0),validate({conversationIds:{type:"array",itemType:"string",min:1,allowEmpty:!1}},{conversationIds:i},"",!0),M.next=6,this.core.sendCmd("v2ConversationGroupRemoveFrom",{tag:{groupId:t,conversationIds:Un(i)}});case 6:return u=M.sent,m=get(u,"content.info.failedMap")||"",h=[],m&&(h=formatFailedMap(m)),v=formatConversationFields(this.core,get(u,"content.datas")),this.core.V2NIMConversationService.versionCache.compareAndUpdateModel(v),this.emit("onConversationsRemovedFromGroup",t,map$6(v).call(v,(function(t){return t.conversationId}))),M.abrupt("return",h);case 14:case"end":return M.stop()}}),_callee5,this)})))},i.getConversationGroup=function getConversationGroup(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i;return ud.wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkEnable(),this.checkV2(),validate({groupId:{type:"string",allowEmpty:!1}},{groupId:t},"",!0),u.next=5,this.core.sendCmd("v2ConversationGroupGet",{tag:{groupId:t}});case 5:return i=u.sent,u.abrupt("return",formatConversationGroup(get(i,"content.data")));case 7:case"end":return u.stop()}}),_callee6,this)})))},i.getConversationGroupList=function getConversationGroupList(){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var t;return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkEnable(),this.checkV2(),i.next=4,this.core.sendCmd("v2ConversationGroupListGet");case 4:return t=i.sent,i.abrupt("return",formatConversationGroups(get(t,"content.datas")));case 6:case"end":return i.stop()}}),_callee7,this)})))},i.getConversationGroupListByIds=function getConversationGroupListByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i,u,m;return ud.wrap((function _callee8$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkEnable(),this.checkV2(),validate({groupIds:{type:"array",itemType:"string",min:1}},{groupIds:t},"",!0),h.next=5,this.core.sendCmd("v2ConversationGroupsGet",{tag:{groupIds:t&&Un(t)}});case 5:return u=h.sent,m=formatConversationGroups(get(u,"content.datas")),h.abrupt("return",filter(i=map$6(t).call(t,(function(t){return filter(m).call(m,(function(i){return i.groupId===t}))[0]}))).call(i,(function(t){return!!t})));case 8:case"end":return h.stop()}}),_callee8,this)})))},i.v2ConversationGroupNotifySyncOnlineHandler=function v2ConversationGroupNotifySyncOnlineHandler(t){var i=this;if(this.ifEnabled){var u,m=formatConversationGroupNotify(get(t,"content.info")),h=m.type,v=m.deleteVersion,M=m.conversationIds,I=formatConversationGroup(get(t,"content.data"));if(this.core.logger.log("v2ConversationGroupNotifySyncOnlineHandler",m,I),1===h){if(this.emit("onConversationGroupCreated",I),M&&M.length>0)this.emit("onConversationsAddedToGroup",I.groupId,filter(u=map$6(M).call(M,(function(t){return i.core.V2NIMConversationService.model.getById(t)}))).call(u,(function(t){return!!t})))}else if(2===h)this.emit("onConversationGroupDeleted",I.groupId),this.core.V2NIMConversationService.versionCache.compareAndDeleteGroupInModel(v,I.groupId);else if(3===h)this.emit("onConversationGroupChanged",I);else if(4===h){var S,T=filter(S=map$6(M).call(M,(function(t){return i.core.V2NIMConversationService.model.getById(t)}))).call(S,(function(t){return!!t}));this.emit("onConversationsAddedToGroup",I.groupId,T)}else 5===h&&this.emit("onConversationsRemovedFromGroup",I.groupId,M)}},Qe(V2NIMConversationGroupServiceImpl,[{key:"ifEnabled",get:function get(){return!0===this.core.options.enableV2CloudConversation}}]),V2NIMConversationGroupServiceImpl}(hp),Sv="V2NIMMessageLogUtil",Tv={"30_6":"v2GetMessageList","33_2":"v2GetMessageListByRefers","30_9":"v2ClearRoamingMessage","30_18":"v2ClearHistoryMessage","7_118":"onClearHistoryMessage","4_24":"syncClearHistoryMessage","31_23":"v2GetTeamMessageList","32_14":"v2GetSuperTeamMessageList"},Cv={conversationType:{id:0,retType:"number"},receiverId:1,deleteRoam:{id:2,converter:boolToInt},teamId:3,onlineSync:{id:4,converter:boolToInt},deleteTime:{id:6,retType:"number"},serverExtension:7},bv=[{type:"Long",name:"beginTime"},{type:"Long",name:"endTime"},{type:"Long",name:"lastMsgId"},{type:"Int",name:"limit"},{type:"Bool",name:"direction"},{type:"LongArray",name:"msgTypes"}],Ev={v2GetMessageList:{sid:30,cid:6,service:Sv,params:concat(lv=[{type:"String",name:"to"}]).call(lv,bv),response:[{type:"PropertyArray",name:"msgs",reflectMapper:invertSerializeItem(Sh)}]},v2GetMessageListByRefers:{sid:33,cid:2,service:Sv,params:[{type:"PropertyArray",name:"tag",reflectMapper:Sh,select:["conversationType","senderId","receiverId","createTime","messageServerId"]}],response:[{type:"PropertyArray",name:"msgs",reflectMapper:invertSerializeItem(Sh)}]},v2ClearRoamingMessage:{sid:30,cid:9,service:Sv,params:[{type:"StrArray",name:"conversationIds"}]},v2ClearHistoryMessage:{sid:30,cid:18,service:Sv,params:[{type:"Property",name:"tag",reflectMapper:Cv}],response:[{type:"Long",name:"timetag"}]},v2GetTeamMessageList:{sid:31,cid:23,service:Sv,params:concat(dv=[{type:"Long",name:"to"}]).call(dv,bv),response:[{type:"PropertyArray",name:"msgs",reflectMapper:invertSerializeItem(Sh)}]},v2GetSuperTeamMessageList:{sid:32,cid:14,service:Sv,params:concat(uv=[{type:"Long",name:"to"}]).call(uv,bv),response:[{type:"PropertyArray",name:"msgs",reflectMapper:invertSerializeItem(Sh)}]},onClearHistoryMessage:{sid:7,cid:118,service:Sv,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Cv)}]},syncClearHistoryMessage:{sid:4,cid:24,service:Sv,response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Cv)}]}},Av=function(t){function V2NIMMessageLogUtil(i){var u;return(u=t.call(this,"V2NIMMessageLogUtil",i)||this).clearHistoryMessageFn=function(t){var i=formatClearHistoryNotification(u.core,t);u.emitClearHistoryMessage([i])},u.core=i,u.service=u.core.V2NIMMessageService,"v2"!==u.core.options.apiVersion?Je(u):(registerParser({cmdMap:Tv,cmdConfig:Ev}),u.setListener(),u)}Nt(V2NIMMessageLogUtil,t);var i=V2NIMMessageLogUtil.prototype;return i.setListener=function setListener(){this.core.eventBus.on("forwardReceive/V2NIMMessageLogService/clearHistoryMessage",this.clearHistoryMessageFn)},i.getMessageListByRefers=function getMessageListByRefers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h,v,M=this;return ud.wrap((function _callee$(I){for(;;)switch(I.prev=I.next){case 0:if(this.checkV2(),validate(xm,{messageRefers:t},"",!0),0!==t.length){I.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getMessageListByRefers: messageRefers cannot be an empty array"}});case 4:if(u=[],m=map$6(t).call(t,(function(t){var i=M.service.model.getMessageById(t.messageClientId);return!i&&t.messageServerId&&"0"!==t.messageServerId&&u.push(t),i})),h=[],!(u.length>0)){I.next=12;break}return I.next=10,this.core.sendCmd("v2GetMessageListByRefers",{tag:u});case 10:v=I.sent,h=v.content.msgs;case 12:return m=filter(i=map$6(m).call(m,(function(i,u){if(i)return i;var m=t[u],v=find(h).call(h,(function(t){return t.messageServerId===m.messageServerId}));return v?completeMessage(M.core,v):void 0}))).call(i,(function(t){return void 0!==t&&!M.service._filterMessage(t)})),m=this._fillAIStreamMessages(m),I.abrupt("return",m);case 15:case"end":return I.stop()}}),_callee,this)})))},i.getMessageList=function getMessageList(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u,m,h,v,M,I,S,T,C,E,A,k,R,w=this;return ud.wrap((function _callee2$(N){for(;;)switch(N.prev=N.next){case 0:if(this.checkV2(),validate(wm,t,"",!0),validateConversationId(this.core.account,t.conversationId),h=this.core.V2NIMConversationIdUtil.parseConversationType(t.conversationId),v=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t.conversationId),M=1===h?"v2GetMessageList":2===h?"v2GetTeamMessageList":"v2GetSuperTeamMessageList",I=t.beginTime||0,S=t.endTime||0,!(0!==I&&0!==S&&I>S)){N.next=10;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getMessageList: beginTime cannot be greater than endTime"}});case 10:if(T=void 0===t.direction?0:t.direction,!t.anchorMessage){N.next=27;break}if(0!==T){N.next=21;break}if(0!==S){N.next=17;break}S=t.anchorMessage.createTime,N.next=19;break;case 17:if(S===t.anchorMessage.createTime){N.next=19;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getMessageList: When providing anchorMessage, when sorting in descending order, endTime does not need to be provided, or endTime should be equal to anchorMessage.createTime"}});case 19:N.next=27;break;case 21:if(0!==I){N.next=25;break}I=t.anchorMessage.createTime,N.next=27;break;case 25:if(I===t.anchorMessage.createTime){N.next=27;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getMessageList: When providing anchorMessage, when sorting in ascending order, there is no need to provide beginTime, or beginTime should be equal to anchorMessage.createTime"}});case 27:return C=null===(i=t.anchorMessage)||void 0===i?void 0:i.messageServerId,N.next=30,this.core.sendCmd(M,{beginTime:I,endTime:S,lastMsgId:C||0,limit:t.limit||50,direction:T,msgTypes:t.messageTypes?slice(u=t.messageTypes).call(u):[],to:v});case 30:return E=N.sent,A=E.content,k=map$6(m=A.msgs).call(m,(function(t){return completeMessage(w.core,t)})),C&&(k=filter(k).call(k,(function(t){return t.messageServerId!==C}))),R=this.getMessageListMonkeyPatch(k,t),R=this._fillAIStreamMessages(R),N.abrupt("return",R);case 37:case"end":return N.stop()}}),_callee2,this)})))},i.getMessageListMonkeyPatch=function getMessageListMonkeyPatch(t,i){var u=i.conversationId,m=t,h=reduce(m).call(m,(function(t,i){return t[i.messageClientId]=!0,t}),{}),v=this.service.model.getMessagesByConversationId(u);v=sort(v).call(v,(function(t,u){return 1===i.direction?t.createTime-u.createTime:u.createTime-t.createTime}));var M=0,I=i.beginTime||0,S=i.endTime||0;i.anchorMessage&&(0===i.direction?S=i.anchorMessage.createTime:I=i.anchorMessage.createTime,M=findIndex$1(v).call(v,(function(t){var u;return t.messageClientId===(null===(u=i.anchorMessage)||void 0===u?void 0:u.messageClientId)})),M+=1);for(var T=M;T<v.length;T++){var C,E=v[T],A=!h[E.messageClientId],k=void 0===E.sendingState||1===E.sendingState,R=E.conversationId===u,w=E.createTime>I&&(E.createTime<S||0===S),N=!i.messageTypes||includes(C=i.messageTypes).call(C,E.messageType);A&&k&&R&&w&&N&&m.push(v[T])}return m=sort(m).call(m,(function(t,u){return 1===i.direction?t.createTime-u.createTime:u.createTime-t.createTime})),slice(m).call(m,0,i.limit||50)},i.clearHistoryMessage=function clearHistoryMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h,v,M,I,S,T;return ud.wrap((function _callee3$(C){for(;;)switch(C.prev=C.next){case 0:if(this.checkV2(),validate(Lm,t,"",!0),validateConversationId(this.core.account,t.conversationId),i=t.conversationId,u=t.deleteRoam,m=t.onlineSync,h=t.serverExtension,v=this.core.V2NIMConversationIdUtil.parseConversationType(i),M=this.core.V2NIMConversationIdUtil.parseConversationTargetId(i),I={deleteRoam:u,onlineSync:m,serverExtension:h,conversationType:v},1===v?I.receiverId=M:I.teamId=M,S=this.core.timeOrigin.getNTPTime(),t.clearMode=t.clearMode||0,0!==t.clearMode){C.next=15;break}return C.next=13,this.core.sendCmd("v2ClearHistoryMessage",{tag:I});case 13:T=C.sent,S=T.content.timetag;case 15:2===t.clearMode&&pd.localStorage.setItem("nim_"+this.core.account+"_"+i+"_clearTime",S.toString()),this.core.eventBus.emit("forwardSend/V2NIMMessageLogService/clearHistoryMessage",Dt(Dt({},I),{deleteTime:S})),this.emitClearHistoryMessage([{deleteTime:S,serverExtension:h,conversationId:i}]);case 18:case"end":return C.stop()}}),_callee3,this)})))},i.clearRoamingMessage=function clearRoamingMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u=this;return ud.wrap((function _callee4$(m){for(;;)switch(m.prev=m.next){case 0:this.checkV2(),validate({conversationIds:{type:"array",itemType:"string",min:1}},{conversationIds:t},void 0,!0),i=[],m.prev=3,i=map$6(t).call(t,(function(t){var i=u.core.V2NIMConversationIdUtil.parseConversationTargetId(t);return getSessionIdFromConvInfo(u.core.V2NIMConversationIdUtil.parseConversationType(t),i)})),m.next=11;break;case 7:throw m.prev=7,m.t0=m.catch(3),this.logger.error("V2NIMMessage::clearRoamingMessage with "+t,m.t0),new Yl({code:zl.V2NIM_ERROR_CODE_PARAMETER_ERROR,detail:{reason:"Failed to create session",rawData:""+t}});case 11:return m.next=13,this.core.sendCmd("v2ClearRoamingMessage",{conversationIds:i});case 13:case"end":return m.stop()}}),_callee4,this,[[3,7]])})))},i.syncClearHistoryMessageHandler=function syncClearHistoryMessageHandler(t){var i,u=this,m=map$6(i=t.content.data).call(i,(function(t){return formatClearHistoryNotification(u.core,t)}));this.emitClearHistoryMessage(m)},i.onClearHistoryMessageHandler=function onClearHistoryMessageHandler(t){var i=formatClearHistoryNotification(this.core,t.content.data);this.emitClearHistoryMessage([i])},i.emitClearHistoryMessage=function emitClearHistoryMessage(t){var i=this;forEach$1(t).call(t,(function(t){i.service.model.deleteMessages(t.conversationId,t.deleteTime),i.core.eventBus.emit("V2NIMSync/updateTimetag",{sessionHistoryMsgsDelete:t.deleteTime})})),this.core.eventBus.emit("V2NIMMessageLogUtil/onClearHistoryNotifications",t),this.service.emit("onClearHistoryNotifications",t)},i._fillAIStreamMessages=function _fillAIStreamMessages(t){var i,u=this;return(null===(i=this.core)||void 0===i?void 0:i.V2NIMMessageService.aiUtil.hasAI())?map$6(t).call(t,(function(t){var i,m,h;if(-1===(null===(i=null==t?void 0:t.streamConfig)||void 0===i?void 0:i.status)||1===(null===(m=null==t?void 0:t.streamConfig)||void 0===m?void 0:m.status)){var v=u.core.V2NIMAIService.model.getAiStream(t.messageClientId);t.text=(null===(h=null==v?void 0:v.chunks)||void 0===h?void 0:h.join(""))||t.text||"",(null==v?void 0:v.aiRAGs)&&(t.streamConfig.rags=v.aiRAGs),t.streamConfig.status=-1}return t})):t},V2NIMMessageLogUtil}(hp),kv="V2NIMMessageExtendUtil",Rv={"29_5":"v2VoiceToText","33_15":"v2PinMessage","33_16":"v2UpdatePinMessage","33_17":"v2UnpinMessage","23_18":"onPinMessage","23_19":"onUpdatePinMessage","23_20":"onUnpinMessage","23_115":"onPinMessage","23_116":"onUpdatePinMessage","23_117":"onUnpinMessage","33_21":"v2GetPinMessageList","33_3":"v2AddQuickComment","33_4":"v2RemoveQuickComment","33_7":"v2GetQuickComment","23_5":"onAddQuickComment","23_6":"onRemoveQuickComment","23_103":"onAddQuickComment","23_104":"onRemoveQuickComment","33_8":"v2AddCollection","33_9":"v2RemoveCollections","33_10":"v2UpdateCollectionExtension","33_11":"v2GetCollectionListByOption","30_26":"v2SearchCloudMessagesGroupByConversation","30_27":"v2SearchCloudMessages","30_34":"v2SearchCloudMessagesEx","33_1":"v2GetThreadMessageList"},wv={conversationType:{id:1,converter:conversationTypeV2ToV1,retConverter:conversationTypeV1ToV2,access:"messageRefer.conversationType"},senderId:{id:2,access:"messageRefer.senderId"},receiverId:{id:3,access:"messageRefer.receiverId"},createTime:{id:4,retType:"number",access:"messageRefer.createTime"},messageServerId:{id:5,access:"messageRefer.messageServerId"},messageClientId:{id:6,access:"messageRefer.messageClientId"},detail:7,modify:{id:8,retType:"number"}},Nv={conversationType:{id:1,access:"messageRefer.conversationType",retConverter:conversationTypeV1ToV2},senderId:{id:2,access:"messageRefer.senderId"},receiverId:{id:3,access:"messageRefer.receiverId"},time:{id:4,access:"messageRefer.createTime",converter:boolToInt,retType:"number"},messageServerId:{id:5,access:"messageRefer.messageServerId"},messageClientId:{id:6,access:"messageRefer.messageClientId"},operatorId:7,serverExtension:8,createTime:{id:9,converter:boolToInt,retType:"number"},updateTime:{id:10,converter:boolToInt,retType:"number"}},xv={operatorId:1,index:{id:2,retType:"number"},createTime:{id:3,retType:"number"},serverExtension:4,pushEnabled:{id:5,access:"pushConfig.pushEnabled",converter:boolToInt},needBadge:{id:6,access:"pushConfig.needBadge",converter:boolToInt},title:{id:7,access:"pushConfig.title"},pushContent:{id:8,access:"pushConfig.pushContent"},pushPayload:{id:9,access:"pushConfig.pushPayload"}},Ov={accid:1,serverExtension:2,createTime:{id:3,retType:"number"},updateTime:{id:4,retType:"number"}},Pv={collectionId:1,collectionType:{id:2,retType:"number"},collectionData:3,serverExtension:4,uniqueId:5,createTime:{id:6,retType:"number"},updateTime:{id:7,retType:"number"}},Lv={keyword:1,beginTime:2,endTime:3,messageLimit:5,sortOrder:{id:6,converter:function converter(t){return 0===t?2:1}},p2pAccountIds:{id:7,converter:function converter(t){return t.join(",")}},teamIds:{id:8,converter:function converter(t){return t.join(",")}},senderAccountIds:{id:9,converter:function converter(t){return t.join(",")}},messageTypes:{id:10,converter:function converter(t){return t.join(",")}},messageSubtypes:{id:11,converter:function converter(t){return t.join(",")}}},Vv={keywordList:{id:1,converter:function converter(t){return objectToJSONString(t)}},keywordMatchType:2,searchStartTime:3,searchTimePeriod:4,pageToken:5,limit:7,direction:8,conversationId:9,senderAccountIds:{id:12,converter:function converter(t){return t.join(",")}},messageTypes:{id:13,converter:function converter(t){return t.join(",")}},messageSubtypes:{id:14,converter:function converter(t){return t.join(",")}}},Uv=Dt(Dt({},Lv),{conversationLimit:4}),Dv={v2PinMessage:{sid:33,cid:15,service:kv,params:[{type:"Property",name:"msg",reflectMapper:Sh,select:["conversationType","receiverId","senderId","createTime","messageClientId","messageServerId"]},{type:"Property",name:"msgPin",reflectMapper:Ov}],response:[{type:"Long",name:"timetag"}]},v2UnpinMessage:{sid:33,cid:17,service:kv,params:[{type:"Property",name:"msg",reflectMapper:Sh,select:["conversationType","receiverId","senderId","createTime","messageClientId","messageServerId"]},{type:"Property",name:"msgPin",reflectMapper:Ov}],response:[{type:"Long",name:"timetag"}]},v2UpdatePinMessage:{sid:33,cid:16,service:kv,params:[{type:"Property",name:"msg",reflectMapper:Sh,select:["conversationType","receiverId","senderId","createTime","messageClientId","messageServerId"]},{type:"Property",name:"msgPin",reflectMapper:Ov}],response:[{type:"Long",name:"timetag"}]},v2GetPinMessageList:{sid:33,cid:21,service:kv,params:[{type:"Property",name:"tag",reflectMapper:{conversationId:1,timetag:2}}],response:[{type:"Long",name:"timetag"},{type:"Bool",name:"changed"},{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Nv)}]},v2VoiceToText:{sid:29,cid:5,service:kv,params:[{type:"Property",name:"tag",reflectMapper:{mimeType:0,sampleRate:1,voiceUrl:2,duration:3}}],response:[{type:"String",name:"data"}]},v2AddQuickComment:{sid:33,cid:3,service:kv,params:[{type:"Property",name:"message",reflectMapper:Sh,select:["conversationType","senderId","receiverId","createTime","messageClientId","messageServerId"]},{type:"Property",name:"quickComment",reflectMapper:xv}],response:[{type:"Long",name:"timetag"}]},v2RemoveQuickComment:{sid:33,cid:4,service:kv,params:[{type:"Property",name:"message",reflectMapper:Sh,select:["conversationType","senderId","receiverId","createTime","messageClientId","messageServerId"]},{type:"Property",name:"quickComment",reflectMapper:xv}],response:[{type:"Long",name:"timetag"}]},onAddQuickComment:{sid:23,cid:5,service:kv,response:[{type:"Property",name:"message",reflectMapper:invertSerializeItem(Sh)},{type:"Property",name:"quickComment",reflectMapper:invertSerializeItem(xv)}]},onRemoveQuickComment:{sid:23,cid:6,service:kv,response:[{type:"Property",name:"message",reflectMapper:invertSerializeItem(Sh)},{type:"Property",name:"quickComment",reflectMapper:invertSerializeItem(xv)}]},v2GetQuickComment:{sid:33,cid:7,service:kv,params:[{type:"PropertyArray",name:"tag",reflectMapper:wv}],response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(wv)}]},onPinMessage:{sid:23,cid:18,service:kv,response:[{type:"Property",name:"msg",reflectMapper:invertSerializeItem(Sh)},{type:"Property",name:"pinInfo",reflectMapper:invertSerializeItem(Ov)}]},onUpdatePinMessage:{sid:23,cid:19,service:kv,response:[{type:"Property",name:"msg",reflectMapper:invertSerializeItem(Sh)},{type:"Property",name:"pinInfo",reflectMapper:invertSerializeItem(Ov)}]},onUnpinMessage:{sid:23,cid:20,service:kv,response:[{type:"Property",name:"msg",reflectMapper:invertSerializeItem(Sh)},{type:"Property",name:"pinInfo",reflectMapper:invertSerializeItem(Ov)}]},v2AddCollection:{sid:33,cid:8,service:kv,params:[{type:"Property",name:"tag",reflectMapper:Pv}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Pv)}]},v2RemoveCollections:{sid:33,cid:9,service:kv,params:[{type:"PropertyArray",name:"tag",reflectMapper:Pv,select:["collectionId","createTime"]}],response:[{type:"Int",name:"data"}]},v2UpdateCollectionExtension:{sid:33,cid:10,service:kv,params:[{type:"Property",name:"tag",reflectMapper:Pv}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Pv)}]},v2GetCollectionListByOption:{sid:33,cid:11,service:kv,params:[{type:"Property",name:"tag",reflectMapper:{beginTime:1,endTime:2,excludeId:3,limit:4,direction:5,collectionType:6}}],response:[{type:"Long",name:"total"},{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Pv)}]},v2SearchCloudMessagesGroupByConversation:{sid:30,cid:26,service:kv,params:[{type:"Property",name:"tag",reflectMapper:Uv}],response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2SearchCloudMessages:{sid:30,cid:27,service:kv,params:[{type:"Property",name:"tag",reflectMapper:Lv}],response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Sh)}]},v2SearchCloudMessagesEx:{sid:30,cid:34,service:kv,params:[{type:"Property",name:"tag",reflectMapper:Vv}],response:[{type:"PropertyArray",name:"msgs",reflectMapper:invertSerializeItem(Sh)},{type:"Int",name:"hasMore"},{type:"String",name:"nextPageToken"}]},v2GetThreadMessageList:{sid:33,cid:1,service:kv,params:[{type:"Property",name:"messageRefer",reflectMapper:Sh},{type:"Property",name:"tag",reflectMapper:{beginTime:1,endTime:2,excludeMessageServerId:3,limit:4,reverse:5}}],response:[{type:"Property",name:"message",reflectMapper:invertSerializeItem(Sh)},{type:"Property",name:"replyResult",reflectMapper:invertSerializeItem({total:{id:1,retType:"number"},timestamp:{id:2,retType:"number"}})},{type:"PropertyArray",name:"replyList",reflectMapper:invertSerializeItem(Sh)}]}},Bv=function(t){function V2NIMMessageExtendUtil(i){var u;return(u=t.call(this,"V2NIMMessageExtendUtil",i)||this).core=i,u.service=u.core.V2NIMMessageService,"v2"!==u.core.options.apiVersion?Je(u):(registerParser({cmdMap:Rv,cmdConfig:Dv}),u)}Nt(V2NIMMessageExtendUtil,t);var i=V2NIMMessageExtendUtil.prototype;return i.pinMessage=function pinMessage(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(Nm,t,"message",!0),validate(Vm,{serverExtension:i},"",!0),m.next=5,this.core.sendCmd("v2PinMessage",{msg:t,msgPin:{serverExtension:i}});case 5:u=m.sent,this.emitPinNotification({pinState:1,message:t,serverExtension:i,createTime:u.content.timetag,updateTime:u.content.timetag,operatorId:this.core.account});case 7:case"end":return m.stop()}}),_callee,this)})))},i.unpinMessage=function unpinMessage(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(Nm,t,"messageRefer",!0),validate(Vm,{serverExtension:i},"",!0),m.next=5,this.core.sendCmd("v2UnpinMessage",{msg:t,msgPin:{serverExtension:i}});case 5:u=m.sent,this.emitPinNotification({pinState:0,message:t,serverExtension:i,updateTime:u.content.timetag,operatorId:this.core.account});case 7:case"end":return m.stop()}}),_callee2,this)})))},i.updatePinMessage=function updatePinMessage(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var u;return ud.wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(Nm,t,"message",!0),validate(Vm,{serverExtension:i},"",!0),m.next=5,this.core.sendCmd("v2UpdatePinMessage",{msg:t,msgPin:{serverExtension:i}});case 5:u=m.sent,this.emitPinNotification({pinState:2,message:t,serverExtension:i,updateTime:u.content.timetag,operatorId:this.core.account});case 7:case"end":return m.stop()}}),_callee3,this)})))},i.getPinnedMessageList=function getPinnedMessageList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m,h,v=this;return ud.wrap((function _callee4$(M){for(;;)switch(M.prev=M.next){case 0:if(this.checkV2(),this.core.V2NIMConversationIdUtil&&this.core.V2NIMConversationIdUtil.parseConversationType){M.next=3;break}throw new Error('Service "V2NIMConversationService" does not exist');case 3:return validateConversationId(this.core.account,t),m=(m=this.core.V2NIMConversationIdUtil.convertToV1ConversationId(t)).replace("superTeam","super_team"),M.next=8,this.core.sendCmd("v2GetPinMessageList",{tag:{conversationId:m,timetag:0}});case 8:return h=M.sent,M.abrupt("return",sort(i=map$6(u=h.content.data).call(u,(function(t){return Dt(Dt({},t),{messageRefer:Dt(Dt({},t.messageRefer),{conversationId:v.core.V2NIMConversationIdUtil.messageConversationId(t.messageRefer)})})}))).call(i,(function(t,i){return i.updateTime-t.updateTime})));case 10:case"end":return M.stop()}}),_callee4,this)})))},i.addQuickComment=function addQuickComment(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var h,v;return ud.wrap((function _callee5$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkV2(),validate(qm,{message:t,index:i,serverExtension:u,pushConfig:m},"",!0),M.next=4,this.core.sendCmd("v2AddQuickComment",{message:t,quickComment:{index:i,serverExtension:u,pushConfig:m}});case 4:h=M.sent,v={operationType:1,quickComment:{messageRefer:formatMessageRefer(this.core,t),createTime:h.content.timetag,index:i,serverExtension:u||"",operatorId:this.core.account}},this.core.V2NIMMessageService.emit("onMessageQuickCommentNotification",v);case 7:case"end":return M.stop()}}),_callee5,this)})))},i.removeQuickComment=function removeQuickComment(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var m,h;return ud.wrap((function _callee6$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkV2(),validate(Nm,t,"messageRefer",!0),validate({index:{type:"number",min:1}},{index:i},"",!0),validate({serverExtension:{type:"string",required:!1}},{serverExtension:u},"",!0),v.next=6,this.core.sendCmd("v2RemoveQuickComment",{message:t,quickComment:{index:i,serverExtension:u}});case 6:m=v.sent,h={operationType:2,quickComment:{messageRefer:formatMessageRefer(this.core,t),createTime:m.content.timetag,index:i,serverExtension:u||"",operatorId:this.core.account}},this.core.V2NIMMessageService.emit("onMessageQuickCommentNotification",h);case 9:case"end":return v.stop()}}),_callee6,this)})))},i.getQuickCommentList=function getQuickCommentList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var i,u,m,h=this;return ud.wrap((function _callee7$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkV2(),validate(Fm,{messages:t},"",!0),u={},v.next=5,this.core.sendCmd("v2GetQuickComment",{tag:map$6(t).call(t,(function(t){return{messageRefer:t}}))});case 5:return m=v.sent,forEach$1(i=m.content.data).call(i,(function(t){var i,m;try{if(!t.detail)return void(u[i=t.messageRefer.messageClientId]||(u[i]=[]));var v=JSON.parse(t.detail);u[m=t.messageRefer.messageClientId]||(u[m]=[]),forEach$1(v).call(v,(function(i){u[t.messageRefer.messageClientId].push({messageRefer:Dt(Dt({},t.messageRefer),{conversationId:h.core.V2NIMConversationIdUtil.messageConversationId(t.messageRefer)}),operatorId:i[1],index:Gd(i[2]),createTime:Gd(i[3]),serverExtension:i[4]})}))}catch(i){h.logger.error("getQuickCommentList JSON Parse Error",t.detail,i)}})),v.abrupt("return",u);case 8:case"end":return v.stop()}}),_callee7,this)})))},i.voiceToText=function voiceToText(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i,u,m,h,v,M,I,S,T,C,E;return ud.wrap((function _callee8$(A){for(;;)switch(A.prev=A.next){case 0:if(this.checkV2(),validate(Bm,t,"",!0),t.voicePath||t.voiceUrl||t.file){A.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"voiceToText: voicePath、voiceUrl、file cannot be empty at the same time"}});case 4:if(i=t.voicePath,u=t.file,m=t.mimeType,h=t.sampleRate,v=t.duration,M=t.sceneName,I=M?this.core.V2NIMStorageService.getStorageScene(M):null,S=t.voiceUrl){A.next=14;break}return T={},u?T.file=u:0===(null==i?void 0:indexOf(i).call(i,"nim-external"))?T.fileInput=i:T.filePath=i,A.next=12,this.core.cloudStorage.uploadFile(Dt({type:"audio",nosScenes:I?I.sceneName:void 0,nosSurvivalTime:I?I.expireTime:void 0},T));case 12:C=A.sent,S=C.url;case 14:return A.next=16,this.core.sendCmd("v2VoiceToText",{tag:{voiceUrl:S,mimeType:m,sampleRate:h,duration:v}},{timeout:3e4});case 16:return E=A.sent,A.abrupt("return",E.content.data);case 18:case"end":return A.stop()}}),_callee8,this)})))},i.onPinMessageHandler=function onPinMessageHandler(t){return this.pinMessageChangeHandler(t,1)},i.onUnpinMessageHandler=function onUnpinMessageHandler(t){return this.pinMessageChangeHandler(t,0)},i.onUpdatePinMessageHandler=function onUpdatePinMessageHandler(t){return this.pinMessageChangeHandler(t,2)},i.pinMessageChangeHandler=function pinMessageChangeHandler(t,i){var u=t.content.msg,m=t.content.pinInfo;u.conversationId=this.core.V2NIMConversationIdUtil.messageConversationId(u),this.emitPinNotification({pinState:i,message:u,serverExtension:m.serverExtension,createTime:m.createTime,updateTime:m.updateTime,operatorId:m.accid})},i.emitPinNotification=function emitPinNotification(t){var i={pinState:t.pinState,pin:Dt(Dt({serverExtension:t.serverExtension||"",operatorId:t.operatorId},t.createTime?{createTime:t.createTime}:{}),{updateTime:t.updateTime,messageRefer:formatMessageRefer(this.core,t.message)})};this.core.V2NIMMessageService.emit("onMessagePinNotification",i)},i.onAddQuickCommentHandler=function onAddQuickCommentHandler(t){return this.onQuickCommentNotificationHandler(t,1)},i.onRemoveQuickCommentHandler=function onRemoveQuickCommentHandler(t){return this.onQuickCommentNotificationHandler(t,2)},i.onQuickCommentNotificationHandler=function onQuickCommentNotificationHandler(t,i){var u={operationType:i,quickComment:Dt({messageRefer:Dt(Dt({},t.content.message),{conversationId:this.core.V2NIMConversationIdUtil.messageConversationId(t.content.message)})},t.content.quickComment)};this.core.V2NIMMessageService.emit("onMessageQuickCommentNotification",u)},i.addCollection=function addCollection(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var i;return ud.wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),validate(Gm,{params:t},"",!0),u.next=4,this.core.sendCmd("v2AddCollection",{tag:t});case 4:return i=u.sent,u.abrupt("return",i.content.data);case 6:case"end":return u.stop()}}),_callee9,this)})))},i.removeCollections=function removeCollections(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var i;return ud.wrap((function _callee10$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),validate(Hm,{collections:t},"",!0),u.next=4,this.core.sendCmd("v2RemoveCollections",{tag:t});case 4:return i=u.sent,u.abrupt("return",i.content.data);case 6:case"end":return u.stop()}}),_callee10,this)})))},i.updateCollectionExtension=function updateCollectionExtension(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var u;return ud.wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(jm,{collection:t,serverExtension:i},"",!0),m.next=4,this.core.sendCmd("v2UpdateCollectionExtension",{tag:Dt(Dt({},t),{serverExtension:i})});case 4:return u=m.sent,m.abrupt("return",u.content.data);case 6:case"end":return m.stop()}}),_callee11,this)})))},i.getCollectionListByOption=function getCollectionListByOption(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i;return ud.wrap((function _callee12$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),validate($m,t,"",!0),u.next=4,this.getCollectionListExByOption(t);case 4:return i=u.sent,u.abrupt("return",i.collectionList);case 6:case"end":return u.stop()}}),_callee12,this)})))},i.getCollectionListExByOption=function getCollectionListExByOption(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var m,h,v,M,I;return ud.wrap((function _callee13$(S){for(;;)switch(S.prev=S.next){case 0:if(this.checkV2(),validate($m,t,"",!0),m=t.beginTime||0,h=t.endTime||0,v=void 0===t.direction?0:t.direction,void 0===(null===(i=t.anchorCollection)||void 0===i?void 0:i.collectionId)){S.next=21;break}if(0!==t.direction){S.next=15;break}if(0!==h){S.next=11;break}h=t.anchorCollection.createTime,S.next=13;break;case 11:if(h===t.anchorCollection.createTime){S.next=13;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getCollectionListExByOption: When providing anchorCollection, when sorting in descending order, endTime does not need to be provided, or endTime should be equal to anchorCollection.createTime"}});case 13:S.next=21;break;case 15:if(0!==m){S.next=19;break}m=t.anchorCollection.createTime,S.next=21;break;case 19:if(m===t.anchorCollection.createTime){S.next=21;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getCollectionListExByOption: When providing anchorCollection, when sorting in ascending order, there is no need to provide beginTime, or beginTime should be equal to anchorCollection.createTime"}});case 21:if(!(0!==m&&0!==h&&m>=h)){S.next=23;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getCollectionListExByOption: beginTime cannot be greater than endTime"}});case 23:return(M={beginTime:m,endTime:h,direction:v,limit:t.limit,collectionType:t.collectionType,excludeId:(null===(u=t.anchorCollection)||void 0===u?void 0:u.collectionId)?t.anchorCollection.collectionId:0}).collectionType||delete M.collectionType,S.next=27,this.core.sendCmd("v2GetCollectionListByOption",{tag:M});case 27:return I=S.sent,S.abrupt("return",{totalCount:I.content.total,collectionList:I.content.data});case 29:case"end":return S.stop()}}),_callee13,this)})))},i.searchCloudMessages=function searchCloudMessages(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var i,u,m,h,v,M,I,S,T=this;return ud.wrap((function _callee14$(C){for(;;)switch(C.prev=C.next){case 0:if(this.checkV2(),validate(zm,t,"",!0),u=t.beginTime||0,m=t.endTime||0,!(0!==u&&0!==m&&u>m)){C.next=6;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"searchCloudMessages: beginTime cannot be greater than endTime"}});case 6:return h=void 0===t.sortOrder?0:t.sortOrder,v=t.conversationLimit||0,M=t.messageLimit||10,I=v>0?"v2SearchCloudMessagesGroupByConversation":"v2SearchCloudMessages",C.next=12,this.core.sendCmd(I,{tag:Dt(Dt({},t),{beginTime:u,endTime:m,sortOrder:h,conversationLimit:v,messageLimit:M})});case 12:return S=C.sent,C.abrupt("return",this.service._filterMessagesByFn(map$6(i=S.content.data).call(i,(function(t){return completeMessage(T.core,t)}))));case 14:case"end":return C.stop()}}),_callee14,this)})))},i.searchCloudMessagesEx=function searchCloudMessagesEx(t){var i,u,m;return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){var h,v,M,I,S,T,C,E=this;return ud.wrap((function _callee15$(A){for(;;)switch(A.prev=A.next){case 0:if(this.checkV2(),validate(Wm,t,"",!0),t.conversationId&&validateConversationId(this.core.account,t.conversationId),(null===(i=t.keywordList)||void 0===i?void 0:i.length)||(null===(u=t.senderAccountIds)||void 0===u?void 0:u.length)||(null===(m=t.messageTypes)||void 0===m?void 0:m.length)){A.next=5;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"searchCloudMessagesEx: keywordList senderAccountIds messageTypes cannot be empty at the same time"}});case 5:return 0===t.searchTimePeriod&&delete t.searchTimePeriod,A.next=8,this.core.sendCmd("v2SearchCloudMessagesEx",{tag:Dt({},t)});case 8:return h=A.sent,v=h.content,M=v.msgs,I=v.hasMore,S=v.nextPageToken,T=this.service._filterMessagesByFn(map$6(M).call(M,(function(t){return completeMessage(E.core,t)}))),C=sort(T).call(T,(function(t,i){return i.createTime-t.createTime})),A.abrupt("return",{count:M.length,items:formatSearchCloudMessageListEx(this.core,C),hasMore:intToBool(I),nextPageToken:S});case 13:case"end":return A.stop()}}),_callee15,this)})))},i.getThreadMessageList=function getThreadMessageList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i,u,m,h,v,M,I,S=this;return ud.wrap((function _callee16$(T){for(;;)switch(T.prev=T.next){case 0:if(validate(eh,t,"getThreadMessageList",!0),t.beginTime=t.beginTime||0,!(t.endTime&&t.beginTime>t.endTime)){T.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"getThreadMessageList: beginTime cannot be greater than endTime"}});case 4:return T.next=6,this.core.sendCmd("v2GetThreadMessageList",{messageRefer:t.messageRefer,tag:{beginTime:t.beginTime,endTime:t.endTime,limit:t.limit,reverse:1===t.direction?1:0,excludeMessageServerId:t.excludeMessageServerId}});case 6:return i=T.sent,u=i.content,m=u.message,h=u.replyResult,v=u.replyList,M=completeMessage(this.core,m),I=map$6(v).call(v,(function(t){return completeMessage(S.core,t)})),I=this.service._filterMessagesByFn(I),I=this.service._filterMessageByClearTime(M.conversationId,I),T.abrupt("return",{message:M,timestamp:h.timestamp,replyCount:h.total,replyList:I});case 13:case"end":return T.stop()}}),_callee16,this)})))},V2NIMMessageExtendUtil}(hp),qv={joinMode:{type:"enum",values:[1,0,2],required:!1},agreeMode:{type:"enum",values:[0,1],required:!1},inviteMode:{type:"enum",values:[1,0],required:!1},updateInfoMode:{type:"enum",values:[1,0],required:!1},updateExtensionMode:{type:"enum",values:[1,0],required:!1},chatBannedMode:{type:"enum",values:[0,1],required:!1}},Fv={type:"object",required:!0,rules:Dt({name:{type:"string",allowEmpty:!1},teamType:{type:"enum",values:[1,2]},memberLimit:{type:"number",min:1,required:!1}},qv)},Gv={type:"array",min:1,itemType:"string"},Hv={type:"boolean"},jv={type:"string"},$v={type:"string",allowEmpty:!1},zv={type:"object",rules:{antispamBusinessId:{type:"string",required:!1}},required:!1},Wv={teamId:{type:"string",regExp:/^[1-9]\d*$/,allowEmpty:!1}},Kv={teamIds:{type:"array",itemRules:{type:"string",allowEmpty:!1,regExp:/^[1-9]\d*$/},min:1}},Yv={teamType:{type:"enum",values:[1,2]}},Qv={teamTypes:{type:"array",itemType:"enum",values:[1,2],required:!1}},Jv={inviteeParams:{type:"object",required:!0,rules:{inviteeAccountIds:Gv,postscript:Dt(Dt({},jv),{required:!1}),serverExtension:Dt(Dt({},jv),{required:!1})}}},Xv={updateTeamInfoParams:{type:"object",required:!0,rules:Dt({name:{type:"string",allowEmpty:!1,required:!1},memberLimit:{type:"number",min:1,required:!1}},qv)}},Zv={type:"enum",values:[0,2]},ef={memberInfoParams:{type:"object",rules:{teamNick:{type:"string",required:!1},serverExtension:{type:"string",required:!1},antispamConfig:{type:"object",required:!1,rules:{antispamBusinessId:{type:"string",required:!1}}}}}},tf={chatBannedMode:{type:"enum",values:[0,1]}},rf={queryOption:{type:"object",rules:{roleQueryType:{type:"enum",values:[0,2,1]},onlyChatBanned:{type:"boolean",required:!1},direction:{type:"enum",values:[1,0],required:!1},limit:{type:"number",min:1,required:!1},nextToken:{type:"string",required:!1}}}},nf={teamId:Wv.teamId,teamType:{type:"enum",values:[1,2]},operatorAccountId:{type:"string",allowEmpty:!1}},af={actionType:{type:"enum",values:[0,2,1,3,4,5]}},sf={actionType:{type:"enum",values:[2]}},cf={actionType:{type:"enum",values:[0]}},lf={types:{type:"array",itemType:"enum",values:[0,2,1,3,4,5],required:!1},status:{type:"array",itemType:"enum",values:[1,3,0,2],required:!1},offset:{type:"number",min:0,required:!1},limit:{type:"number",min:1,required:!1}},df={teamId:Wv.teamId,teamType:Yv.teamType,accountIds:Gv},uf={accountId:{type:"string",allowEmpty:!1},teamNick:{type:"string"},antispamConfig:{type:"object",required:!1,rules:{antispamBusinessId:{type:"string",required:!1}}}},pf=function(){function V2NIMTeamModelImpl(){this.teamMap=new Sc,this.superTeamMap=new Sc}var t=V2NIMTeamModelImpl.prototype;return t.set=function set(t){var i=this;forEach$1(t).call(t,(function(t){i.chooseMap(t.teamType).set(t.teamId,t)}))},t.reset=function reset(){this.teamMap.clear(),this.superTeamMap.clear()},t.count=function count(t,i){void 0===i&&(i=!0);var u=this.chooseMap(t),count=0;return forEach$1(u).call(u,(function(t){i&&t.isValidTeam&&count++,i||count++})),count},t.chooseMap=function chooseMap(t){return 2===t?this.superTeamMap:1===t?this.teamMap:new Sc},t.getById=function getById(t,i,u){void 0===u&&(u=!0);var m=this.chooseMap(i).get(t);if(m){if(u&&m.isValidTeam)return m;if(!u)return m}},t.getAll=function getAll(t,i){void 0===i&&(i=!0);var u=this.chooseMap(t),m=id(values(u).call(u)),h=filter(m).call(m,(function(t){return!(!i||!t.isValidTeam)||(!i||void 0)}));return sort(h).call(h,(function(t,i){return i.updateTime-t.updateTime}))},t.upsert=function upsert(t){var i=t.teamId,u=t.teamType,m=this.chooseMap(u),h=m.get(i)||{},v=Dt({},h,t);return m.set(i,v),v},t.deleteById=function deleteById(t,i){var u=this.getById(t,i);if(u)return u.isValidTeam=!1,u},t.searchTeamByKeyword=function searchTeamByKeyword(t){var i,u,m=[];return forEach$1(i=this.teamMap).call(i,(function(i){var u;includes(u=i.name).call(u,t)&&m.push(i)})),forEach$1(u=this.superTeamMap).call(u,(function(i){var u;includes(u=i.name).call(u,t)&&m.push(i)})),m},V2NIMTeamModelImpl}(),mf=function(){function V2NIMTeamMemberModelImpl(){this.teamMembers=[],this.superTeamMembers=[],this.maxSize=11e3}var t=V2NIMTeamMemberModelImpl.prototype;return t.reset=function reset(){this.teamMembers=[],this.superTeamMembers=[]},t.setData=function setData(t){var i=this;forEach$1(t).call(t,(function(t){i.chooseList(t.teamType).push(t)}))},t.chooseList=function chooseList(t){return 2===t?this.superTeamMembers:1===t?this.teamMembers:[]},t.getById=function getById(t,i,u){var m=this.chooseList(i);return find(m).call(m,(function(i){return i.teamId===t&&i.accountId===u}))},t.upsert=function upsert(t){var i=t.teamType,u=t.teamId,m=this.chooseList(i),h=findIndex$1(m).call(m,(function(i){return i.teamId===u&&i.accountId===t.accountId}));-1===h?m.push(t):m[h]=Dt(Dt({},m[h]),t),m.length>this.maxSize&&m.shift()},t.deleteByAccount=function deleteByAccount(t,i,u){var m=this.chooseList(i),h=findIndex$1(m).call(m,(function(i){return i.teamId===t&&i.accountId===u}));if(-1!==h){var v=m[h];return v.inTeam=!1,splice(m).call(m,h,1),v}},t.deleteByTeamId=function deleteByTeamId(t,i){var u=this.chooseList(i),m=filter(u).call(u,(function(i){return i.teamId!==t}));2===i?this.superTeamMembers=m:this.teamMembers=m},V2NIMTeamMemberModelImpl}(),hf=function(){function V2NIMTeamNotificationImpl(t,i){this.core=t,this.service=i}var t=V2NIMTeamNotificationImpl.prototype;return t.processNotification=function processNotification(t){var i=this,u=t.attachment,m=t.senderId,h=t.receiverId,v=t.createTime,M=u.id,I=u.data,S=M>400?2:1,T=formatTeamNotificationAttachData(I,S),C=T.id,E=T.ids,A=T.tinfo,k=T.mute,R=this.service.model.getById(h,S);switch(this.core.logger.log("v2Team::processNotification, notificationType:"+M+", teamId:"+h,I),M){case pv.SUPER_TEAM_INVITATION:case pv.TEAM_INVITATION:includes(E).call(E,this.core.account)&&this.onTeamJoined(A),this.onTeamMembersJoined(A,filter(E).call(E,(function(t){return t!==i.core.account})));break;case pv.SUPER_TEAM_INVITE_ACCEPT:case pv.TEAM_INVITE_ACCEPT:m===this.core.account?(this.onTeamJoined(A),this.service.notificationModel.markExpired(A.teamId,A.teamType,m,v)):this.onTeamMemberJoined(A,m);break;case pv.SUPER_TEAM_APPLY_ACCEPT:case pv.TEAM_APPLY_ACCEPT:C===this.core.account?(this.onTeamJoined(A),this.service.notificationModel.markExpired(A.teamId,A.teamType,C,v)):this.onTeamMemberJoined(A,C);break;case pv.SUPER_TEAM_ADD_MANAGER:case pv.TEAM_ADD_MANAGER:this.updateTeamMemberRole(h,S,E,{memberRole:2,updateTime:v});break;case pv.SUPER_TEAM_REMOVE_MANAGER:case pv.TEAM_REMOVE_MANAGER:this.updateTeamMemberRole(h,S,E,{memberRole:0,updateTime:v});break;case pv.SUPER_TEAM_KICK:case pv.TEAM_KICK:this.onTeamInfoUpdated(A),forEach$1(E).call(E,(function(t){t===i.core.account?i.onTeamLeft(h,S,!0):i.onTeamMemberKicked(m,A.teamId,A.teamType,t)}));break;case pv.SUPER_TEAM_LEAVE:case pv.TEAM_LEAVE:A?this.onTeamInfoUpdated(A):R&&m===this.core.account&&(R.isValidTeam=!1,this.onTeamInfoUpdated(R)),m===this.core.account?this.onTeamLeft(h,S,!1):this.onTeamMemberLeft(h,S,m);break;case pv.SUPER_TEAM_DISMISS:case pv.TEAM_DISMISS:this.onTeamDismissed(h,S);break;case pv.SUPER_TEAM_UPDATE:case pv.TEAM_UPDATED:this.onTeamInfoUpdated(A);break;case pv.SUPER_TEAM_TRANSFER_OWNER:case pv.TEAM_TRANSFER_OWNER:this.onTeamInfoUpdated(A),this.updateTeamMemberRole(h,S,[m,A.ownerAccountId],[{memberRole:0,updateTime:v},{memberRole:1,updateTime:v,joinTime:v}],!1);break;case pv.SUPER_TEAM_MEMBER_MUTE:case pv.TEAM_MEMBER_MUTE:this.service.model.upsert(A),this.updateTeamMemberRole(h,S,C?[C]:E,{chatBanned:0!==k,updateTime:v})}},t.onTeamJoined=function onTeamJoined(t){var i=this;this.service.model.upsert(t),this.service.emit("onTeamJoined",t),this.service.getTeamMemberListByIds(t.teamId,t.teamType,[this.core.account]).catch((function(t){i.core.logger.error("Get Member error after onTeamJoined",t)}))},t.onTeamLeft=function onTeamLeft(t,i,u){var m=this.service.model.deleteById(t,i)||generateTeamByTeamId(t,i,{isValidTeam:!1,isTeamEffective:!0});this.service.memberModel.deleteByAccount(t,i,this.core.account),this.service.emit("onTeamLeft",m,u)},t.onTeamDismissed=function onTeamDismissed(t,i){var u=this.service.model.deleteById(t,i);u||(u=generateTeamByTeamId(t,i,{isValidTeam:!1,isTeamEffective:!1})),u.isTeamEffective=!1,this.service.model.upsert(u),this.service.memberModel.deleteByTeamId(t,i),this.service.emit("onTeamDismissed",u)},t.onTeamInfoUpdated=function onTeamInfoUpdated(t){var i=this.service.model.upsert(t);this.service.emit("onTeamInfoUpdated",i)},t.onTeamMemberJoined=function onTeamMemberJoined(t,i){this.service.model.upsert(t),this.service.emit("onTeamInfoUpdated",t);var u=t.updateTime||t.createTime,m=generateMemberByTeamId(t.teamId,t.teamType,i,{joinTime:u,updateTime:u});this.service.emit("onTeamMemberJoined",[m])},t.onTeamMembersJoined=function onTeamMembersJoined(t,i){var u=t.updateTime||t.createTime,m=map$6(i).call(i,(function(i){return generateMemberByTeamId(t.teamId,t.teamType,i,{joinTime:u,updateTime:u})}));0!==m.length&&(this.service.model.upsert(t),this.service.emit("onTeamInfoUpdated",t),this.service.emit("onTeamMemberJoined",m))},t.onTeamMemberLeft=function onTeamMemberLeft(t,i,u){var m=this.service.memberModel.deleteByAccount(t,i,u);m||(m=generateMemberByTeamId(t,i,u,{inTeam:!1})),this.service.emit("onTeamMemberLeft",[m])},t.onTeamMemberKicked=function onTeamMemberKicked(t,i,u,m){var h=this.service.memberModel.deleteByAccount(i,u,m);h||(h=generateMemberByTeamId(i,u,m,{inTeam:!1})),this.service.emit("onTeamMemberKicked",t,[h])},t.onTeamMemberInfoUpdated=function onTeamMemberInfoUpdated(t){var i=this;forEach$1(t).call(t,(function(t){if(t.accountId===i.core.account&&i.core.V2NIMSettingService.name&&i.core.V2NIMConversationIdUtil.name){var u=1===t.teamType?i.core.V2NIMConversationIdUtil.teamConversationId(t.teamId):i.core.V2NIMConversationIdUtil.superTeamConversationId(t.teamId),m=i.core.V2NIMSettingService.getConversationMuteStatus(u);i.core.eventBus.emit("V2NIMSettingService/setMute",u,m)}})),this.service.emit("onTeamMemberInfoUpdated",t)},t.updateTeamMemberRole=function updateTeamMemberRole(t,i,u,m,h){return void 0===h&&(h=!0),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var v,M,I,S,T=this;return ud.wrap((function _callee$(C){for(;;)switch(C.prev=C.next){case 0:if(M=filter(u).call(u,(function(u,h){var v=T.service.memberModel.getById(t,i,u);return v&&T.service.memberModel.upsert(Dt(Dt({},v),Dn(m)?m[h]:m)),!v})),!(h&&M.length>0)){C.next=12;break}return C.prev=2,C.next=5,this.service.getTeamMemberListByIds(t,i,M);case 5:I=C.sent,forEach$1(I).call(I,(function(t){return T.service.memberModel.upsert(t)})),C.next=12;break;case 9:C.prev=9,C.t0=C.catch(2),this.core.logger.warn("v2Team::processNotification, getTeamMemberListByIds failed",C.t0);case 12:(S=filter(v=map$6(u).call(u,(function(u,v){var M=T.service.memberModel.getById(t,i,u);return M||h?M:generateMemberByTeamId(t,i,u,Dn(m)?m[v]:m)}))).call(v,(function(t){return!!t}))).length>0&&this.onTeamMemberInfoUpdated(S);case 14:case"end":return C.stop()}}),_callee,this,[[2,9]])})))},t.processSysNotification=function processSysNotification(t){if(!this.service.config.enableServerV2TeamJoinActionInfo){var i=t.receiverId,u=t.postscript,m=t.senderId,h=t.timestamp,v=t.content,M={};try{M=JSON.parse(v)}catch(t){this.core.logger.warn("v2Team::processSysNotification, parse content failed",v)}var I={0:0,1:1,2:2,3:3,15:0,16:1,17:2,18:3}[t.type],S=this.core.account,T="",C="";switch(I){case 0:T=m,C="";break;case 1:T=S,C="";break;case 2:T=m,C=S;break;case 3:T=S,C=m}var E={actionType:I,teamId:i,teamType:t.type>=15?2:1,operatorAccountId:m,postscript:u,timestamp:h,actionStatus:0,read:!1,fromAccountId:T,targetAccountId:C,serverId:"",updateTimestamp:h};M.attach&&(E.serverExtension=M.attach),this.core.logger.log("v2Team::processSysNotification, type:",t.type,E),this.service.notificationModelOld.create(E),this.service.emit("onReceiveTeamJoinActionInfo",E)}},t.updateTeamActionStatus=function updateTeamActionStatus(t,i){this.service.notificationModelOld.update({teamId:t.teamId,teamType:t.teamType,operatorAccountId:t.operatorAccountId,actionType:t.actionType,actionStatus:i})},t.checkIfExpired=function checkIfExpired(t){return!!t&&(509===t||!(t>=500&&t<=599)&&!(t>=19e4))},t.setSyncTimestamp=function setSyncTimestamp(t){t&&this.core.eventBus.emit("V2NIMSync/updateTimetag",{teamApplyList:t})},V2NIMTeamNotificationImpl}();!function(t){t[t.TEAM_INVITATION=0]="TEAM_INVITATION",t[t.TEAM_KICK=1]="TEAM_KICK",t[t.TEAM_LEAVE=2]="TEAM_LEAVE",t[t.TEAM_UPDATED=3]="TEAM_UPDATED",t[t.TEAM_DISMISS=4]="TEAM_DISMISS",t[t.TEAM_APPLY_ACCEPT=5]="TEAM_APPLY_ACCEPT",t[t.TEAM_TRANSFER_OWNER=6]="TEAM_TRANSFER_OWNER",t[t.TEAM_ADD_MANAGER=7]="TEAM_ADD_MANAGER",t[t.TEAM_REMOVE_MANAGER=8]="TEAM_REMOVE_MANAGER",t[t.TEAM_INVITE_ACCEPT=9]="TEAM_INVITE_ACCEPT",t[t.TEAM_MEMBER_MUTE=10]="TEAM_MEMBER_MUTE",t[t.SUPER_TEAM_INVITATION=401]="SUPER_TEAM_INVITATION",t[t.SUPER_TEAM_KICK=402]="SUPER_TEAM_KICK",t[t.SUPER_TEAM_LEAVE=403]="SUPER_TEAM_LEAVE",t[t.SUPER_TEAM_UPDATE=404]="SUPER_TEAM_UPDATE",t[t.SUPER_TEAM_DISMISS=405]="SUPER_TEAM_DISMISS",t[t.SUPER_TEAM_TRANSFER_OWNER=406]="SUPER_TEAM_TRANSFER_OWNER",t[t.SUPER_TEAM_ADD_MANAGER=407]="SUPER_TEAM_ADD_MANAGER",t[t.SUPER_TEAM_REMOVE_MANAGER=408]="SUPER_TEAM_REMOVE_MANAGER",t[t.SUPER_TEAM_MEMBER_MUTE=409]="SUPER_TEAM_MEMBER_MUTE",t[t.SUPER_TEAM_APPLY_ACCEPT=410]="SUPER_TEAM_APPLY_ACCEPT",t[t.SUPER_TEAM_INVITE_ACCEPT=411]="SUPER_TEAM_INVITE_ACCEPT"}(pv||(pv={}));var gf="NIM_TEAM_OPERATION_READ_TIME_{ACCOUNT_ID}",vf=function(){function V2NIMTeamNotificationModelImpl(){this.datas=new Sc,this.readTime=0,this.prefix=gf,this.maxCount=1e3}var t=V2NIMTeamNotificationModelImpl.prototype;return t.reset=function reset(){this.datas.clear()},t.setReadTimePrefix=function setReadTimePrefix(t){var i,u=this;this.prefix=gf.replace("{ACCOUNT_ID}",t),this.readTime=Number(pd.localStorage.getItem(this.prefix))||0,this.readTime>0&&forEach$1(i=this.datas).call(i,(function(t){t.updateTimestamp<=u.readTime&&(t.read=!0)}))},t.getReadTime=function getReadTime(){return this.readTime},t.getByOption=function getByOption(t){var i,u,m,h=t.types,v=t.status,M=t.offset,I=void 0===M?0:M,S=t.limit,T=void 0===S?50:S,C=sort(i=filter(u=id(values(m=this.datas).call(m))).call(u,(function(t){return!(h&&h.length>0&&!includes(h).call(h,t.actionType))&&!(v&&v.length>0&&!includes(v).call(v,t.actionStatus))}))).call(i,(function(t,i){return i.updateTimestamp-t.updateTimestamp})),E=slice(C).call(C,I,I+T),A=I+T>=C.length;return{infos:E,finished:A,offset:A?0:I+T}},t.setAllRead=function setAllRead(){var t,i=0;forEach$1(t=this.datas).call(t,(function(t){t.read=!0,i=Math.max(i,t.updateTimestamp)})),i&&(this.readTime=i,pd.localStorage.setItem(this.prefix,i.toString()))},t.setRead=function setRead(t){var i,u=this.datas.get(t.serverId);u&&u.updateTimestamp&&(forEach$1(i=this.datas).call(i,(function(t){t.updateTimestamp<=u.updateTimestamp&&(t.read=!0)})),this.readTime=u.updateTimestamp,pd.localStorage.setItem(this.prefix,u.updateTimestamp.toString()))},t.getUnreadCount=function getUnreadCount(){var t,i=0;return forEach$1(t=this.datas).call(t,(function(t){t.read||i++})),i},t.delete=function _delete(t){this.datas.delete(t)},t.deleteByOption=function deleteByOption(t){var i,u=this,m=t.timestamp,h=t.type;forEach$1(i=this.datas).call(i,(function(t){t.updateTimestamp<=m&&(h===Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL||h===Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_NORMAL&&1===t.teamType||h===Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_SUPER&&2===t.teamType)&&u.datas.delete(t.serverId)}))},t.upsert=function upsert(t){t.serverId&&this.setLRU(t.serverId,t)},t.setLRU=function setLRU(t,i){if(this.datas.has(t))this.datas.delete(t);else if(this.datas.size>=this.maxCount){var u,m=keys(u=this.datas).call(u).next().value;m&&this.datas.delete(m)}this.datas.set(t,i)},t.updateStatus=function updateStatus(t,i){if(0!==i){var u=this.datas.get(t);u&&0===u.actionStatus&&(u.actionStatus=i,this.datas.set(t,u))}},t.markExpired=function markExpired(t,i,u,m){var h,v=this;forEach$1(h=this.datas).call(h,(function(h){h.teamId===t&&h.teamType===i&&(h.fromAccountId===u&&0===h.actionType||h.targetAccountId===u&&2===h.actionType)&&0===h.actionStatus&&(h.actionStatus=3,h.updateTimestamp=m,v.datas.set(h.serverId,h))}))},t.getById=function getById(t){return this.datas.get(t)},V2NIMTeamNotificationModelImpl}();function _createForOfIteratorHelperLoose$7(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$7(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$7(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$7(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$7(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var yf=function(){function V2NIMTeamNotificationModelOldImpl(){this.list=[],this.maxCount=1e3}var t=V2NIMTeamNotificationModelOldImpl.prototype;return t.reset=function reset(){this.list=[]},t.checkSameAction=function checkSameAction(t,i,u){return void 0===u&&(u=!1),t.teamId===i.teamId&&t.teamType===i.teamType&&t.actionType===i.actionType&&t.operatorAccountId===i.operatorAccountId&&(!u||t.timestamp===i.timestamp)},t.create=function create(t){this.list.push(t),this.list.length>this.maxCount&&this.list.shift()},t.update=function update(t){var i,u=this;forEach$1(i=this.list).call(i,(function(i){u.checkSameAction(i,t)&&0===i.actionStatus&&Dt(i,t)}))},t.delete=function _delete(t){var i,u,m=this;this.list=filter(i=map$6(u=this.list).call(u,(function(i){if(!m.checkSameAction(i,t,!1))return i}))).call(i,(function(t){return t}))},t.deleteByOption=function deleteByOption(t){var i,u=t.timestamp,m=t.type;this.list=filter(i=this.list).call(i,(function(t){return!(t.updateTimestamp<=u&&(m===Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL||m===Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_NORMAL&&1===t.teamType||m===Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_SUPER&&2===t.teamType))}))},t.getByOption=function getByOption(t){var i,u=t.types,m=t.status,h=t.offset,v=void 0===h?0:h,M=t.limit,I=void 0===M?50:M,S=[];forEach$1(i=this.list).call(i,(function(t){u&&u.length>0&&!includes(u).call(u,t.actionType)||m&&m.length>0&&!includes(m).call(m,t.actionStatus)||S.push(t)})),S=sort(S).call(S,(function(t,i){return i.timestamp-t.timestamp}));var T=0;v>0&&(T=findIndexWithinTargetValue(S,"timestamp",v),S[T]&&S[T].timestamp===v&&(T+=1));var C=slice(S).call(S,T).length;return(S=slice(S).call(S,T,T+I)).length>0?{offset:C>I?S[S.length-1].timestamp:0,finished:!(C>I),infos:S}:{offset:0,finished:!0,infos:S}},t.setRead=function setRead(t){for(var i,u=_createForOfIteratorHelperLoose$7(this.list);!(i=u()).done;){var m=i.value;this.checkSameAction(m,t)&&(m.read=!0)}},t.setAllRead=function setAllRead(){for(var t,i=_createForOfIteratorHelperLoose$7(this.list);!(t=i()).done;){t.value.read=!0}},t.getUnreadCount=function getUnreadCount(){for(var t,i=new zg,u=_createForOfIteratorHelperLoose$7(this.list);!(t=u()).done;){var m=t.value;m.read||0!==m.actionStatus||0!==m.actionType&&2!==m.actionType||i.add(m.operatorAccountId+"_"+m.teamType+"_"+m.teamId)}return i.size},V2NIMTeamNotificationModelOldImpl}(),Mf=function(){function V2NIMTeamEventImpl(t,i){this.core=t,this.service=i,this.model=i.model,this.memberModel=i.memberModel,this.notification=i.notification,this.logger=this.core.logger}var t=V2NIMTeamEventImpl.prototype;return t.setListener=function setListener(){var t,i,u,m=this;this.core.eventBus.on("V2NIMTeamService/onSyncStarted",(function(){m.service.notificationModel.setReadTimePrefix(m.core.account),m.service.emit("onSyncStarted")})),this.core.eventBus.on("V2NIMTeamService/onSyncFinished",(function(){m.service.emit("onSyncFinished")})),this.core.eventBus.on("V2NIMTeamService/onSyncFailed",(function(t){m.service.emit("onSyncFailed",t)})),this.core.eventBus.on("forwardReceive/V2NIMTeamService/created",(function(t){m.model.upsert(t);var i=generateMemberByTeamId(t.teamId,t.teamType,m.core.account,{memberRole:1});m.memberModel.upsert(i),m.service.emit("onTeamCreated",t)})),this.core.eventBus.on("forwardReceive/V2NIMTeamService/updateSelfTeamMemberInfo",(function(t){m.memberModel.upsert(t),m.service.emit("onTeamInfoUpdated",[t])})),this.core.eventBus.on("forwardReceive/V2NIMTeamService/updateTeamActionStatus",bind$1(t=this.notification.updateTeamActionStatus).call(t,this.notification)),this.core.eventBus.on("V2NIMTeamService/sysNotification",bind$1(i=this.notification.processSysNotification).call(i,this.notification)),this.core.eventBus.on("V2NIMTeamService/notification",bind$1(u=this.notification.processNotification).call(u,this.notification))},t.beforeEmit=function beforeEmit(t){for(var i=this.service.name+"::emit "+t.toString(),u=arguments.length,m=new Array(u>1?u-1:0),h=1;h<u;h++)m[h-1]=arguments[h];if("onTeamCreated"===t||"onTeamDismissed"===t||"onTeamJoined"===t||"onTeamLeft"===t||"onTeamInfoUpdated"===t){var v=m[0];this.logger.log(""+i,"team:"+v.teamId+"_"+v.teamType+";updateTime:"+v.updateTime)}else if("onTeamMemberJoined"===t||"onTeamMemberLeft"===t||"onTeamMemberInfoUpdated"===t){var M=m[0];this.logger.log(""+i,map$6(M).call(M,(function(t){return"team:"+t.teamId+"_"+t.teamType+";account:"+t.accountId})))}else if("onTeamMemberKicked"===t){var I=m[0],S=m[1];this.logger.log(""+i,"operator"+I,map$6(S).call(S,(function(t){return"team:"+t.teamId+"_"+t.teamType+";account:"+t.accountId})))}else{var T,C;(T=this.logger).log.apply(T,concat(C=[""+i]).call(C,m))}},t.onSyncDone=function onSyncDone(t){t?this.service.emit("onSyncFailed",t):this.service.emit("onSyncFinished")},V2NIMTeamEventImpl}(),If={1:2,2:5,3:3,4:0,5:4,6:1},_f={1:0,2:1,3:2,4:0,5:1,6:2},Sf=function(){function V2NIMTeamHandlerImpl(t,i){this.core=t,this.service=i,this.model=i.model,this.memberModel=i.memberModel,this.notificationModel=i.notificationModel,this.notificationModelOld=i.notificationModelOld,this.logger=this.core.logger}var t=V2NIMTeamHandlerImpl.prototype;return t.v2TeamSyncHandler=function v2TeamSyncHandler(t){this.model.set(t.content.datas)},t.v2SuperTeamSyncHandler=function v2SuperTeamSyncHandler(t){this.model.set(t.content.datas)},t.v2TeamCreateMultiSyncHandler=function v2TeamCreateMultiSyncHandler(t){var i=t.content.data;this.model.upsert(i);var u=generateMemberByTeamId(i.teamId,i.teamType,this.core.account,{memberRole:1});this.memberModel.upsert(u),this.service.emit("onTeamCreated",i)},t.v2SuperTeamCreateMultiSyncHandler=function v2SuperTeamCreateMultiSyncHandler(t){var i=t.content.data;this.model.upsert(i);var u=generateMemberByTeamId(i.teamId,i.teamType,this.core.account,{memberRole:1});this.memberModel.upsert(u),this.service.emit("onTeamCreated",i)},t.v2TeamMemberUpdateMultiSyncHandler=function v2TeamMemberUpdateMultiSyncHandler(t){var i=t.content.data;i.teamType=1;var u=this.memberModel.getById(i.teamId,i.teamType,i.accountId);this.service.notification.updateTeamMemberRole(i.teamId,i.teamType,[i.accountId],i),i.accountId===this.core.account&&u&&u.bits!==i.bits&&this.core.eventBus.emit("V2NIMSettingService/updateBits",i.teamId,i.teamType,i.bits)},t.v2SuperTeamMemberUpdateMultiSyncHandler=function v2SuperTeamMemberUpdateMultiSyncHandler(t){var i=t.content.data;i.teamType=2;var u=this.memberModel.getById(i.teamId,i.teamType,i.accountId);this.service.notification.updateTeamMemberRole(i.teamId,i.teamType,[i.accountId],i),i.accountId===this.core.account&&u&&u.bits!==i.bits&&this.core.eventBus.emit("V2NIMSettingService/updateBits",i.teamId,i.teamType,i.bits)},t.v2TeamMembersOfSelfInSyncHandler=function v2TeamMembersOfSelfInSyncHandler(t){var i=this,u=t.content.datas;forEach$1(u).call(u,(function(t){t.teamType=1,i.memberModel.upsert(t),i.service.notificationModel.markExpired(t.teamId,t.teamType,t.accountId,t.joinTime)}))},t.v2SuperTeamMembersOfSelfInSyncHandler=function v2SuperTeamMembersOfSelfInSyncHandler(t){var i=this,u=t.content.datas;forEach$1(u).call(u,(function(t){t.teamType=2,i.memberModel.upsert(t),i.service.notificationModel.markExpired(t.teamId,t.teamType,t.accountId,t.joinTime)}))},t.v2TeamJoinActionDeleteMultiSyncHandler=function v2TeamJoinActionDeleteMultiSyncHandler(t){if(this.useServerNotification){var i=t.content.data;i&&(this.notificationModel.delete(i.serverId),this.service.notification.setSyncTimestamp(i.serverTime))}},t.v2TeamJoinActionClearMultiSyncHandler=function v2TeamJoinActionClearMultiSyncHandler(t){if(this.useServerNotification){var i=t.content.data;this.notificationModel.deleteByOption({timestamp:i.timestamp,type:i.type}),this.service.notification.setSyncTimestamp(i.serverTime)}},t.v2TeamJoinActionListHandler=function v2TeamJoinActionListHandler(t){var i=this;if(this.useServerNotification){var u=t.content.datas,m=t.content.serverTime;forEach$1(u).call(u,(function(t){var u=i.completeTeamJoinAction(t);i.notificationModel.upsert(u),i.triggerEventFromJoinAction(u)})),this.service.notification.setSyncTimestamp(m)}},t.triggerEventFromJoinAction=function triggerEventFromJoinAction(t){this.service.emit("onReceiveTeamJoinActionInfo",t)},t.v2TeamJoinActionListSyncHandler=function v2TeamJoinActionListSyncHandler(t){var i=this;if(this.useServerNotification){var u=t.content.datas,m=t.content.serverTime;forEach$1(u).call(u,(function(t){var u=i.notificationModel.getById(t.serverId),m=i.completeTeamJoinAction(t);i.notificationModel.upsert(m),u&&u.actionStatus!==m.actionStatus?i.triggerEventFromJoinAction(m):u||!1!==m.read||0!==m.actionStatus||i.triggerEventFromJoinAction(m)})),this.service.notification.setSyncTimestamp(m)}},t.completeTeamJoinAction=function completeTeamJoinAction(t){var i=this.notificationModel.getReadTime(),u=this.core.account,m=this.notificationModel.getById(t.serverId),h=!!this.model.getById(t.teamId,t.teamType);if("number"==typeof t.status){t.actionType=If[t.status];var v=t.finished||!1,M=_f[t.status];t.actionStatus=v&&0===M?3:M}return delete t.status,delete t.finished,0===t.actionStatus&&h&&(t.fromAccountId===u&&0===t.actionType||t.targetAccountId===u&&2===t.actionType)&&(t.actionStatus=3),t.updateTimestamp<=i?t.read=!0:t.operatorAccountId===u?t.read="boolean"!=typeof(null==m?void 0:m.read)||m.read:t.operatorAccountId!==u&&(t.read=!1),t.postscriptHistory&&t.postscriptHistory.length>0&&(t.postscript=t.postscriptHistory[t.postscriptHistory.length-1].content),t},t.v2TeamJoinActionClearSyncHandler=function v2TeamJoinActionClearSyncHandler(t){var i=this,u=t.content.datas;forEach$1(u).call(u,(function(t){i.notificationModel.delete(t.serverId),i.notificationModelOld.delete(t)}));var m=t.content.clearInfos;forEach$1(m).call(m,(function(t){var u=t.timestamp,m=t.type,h={timestamp:u||i.core.timeOrigin.getNTPTime(),type:m||Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL};i.notificationModel.deleteByOption(h),i.notificationModelOld.deleteByOption(h)}));var h=t.content.serverTime;this.service.notification.setSyncTimestamp(h)},Qe(V2NIMTeamHandlerImpl,[{key:"useServerNotification",get:function get(){return this.service.config.enableServerV2TeamJoinActionInfo}}]),V2NIMTeamHandlerImpl}(),Tf=function(t){function V2NIMTeamServiceImpl(i){var u;return(u=t.call(this,"V2NIMTeamService",i)||this).config={enableServerV2TeamJoinActionInfo:!1},u.core._registerDep(mm,"V2NIMConversationIdUtil"),u.model=new pf,u.memberModel=new mf,u.notificationModel=new vf,u.notificationModelOld=new yf,u.notification=new hf(i,Je(u)),u.event=new Mf(i,Je(u)),u.handler=new Sf(i,Je(u)),"v2"!==u.core.options.apiVersion?Je(u):(registerParser({cmdMap:sh,cmdConfig:yh}),u.setListener(),u)}Nt(V2NIMTeamServiceImpl,t);var i=V2NIMTeamServiceImpl.prototype;return i.setOptions=function setOptions(t){this.config=Dt(this.config,t)},i.setListener=function setListener(){this.event.setListener()},i.reset=function reset(){this.model.reset(),this.memberModel.reset(),this.notificationModel.reset(),this.notificationModelOld.reset()},i.emit=function emit(i){for(var u,m,h,v,M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];return(u=this.event).beforeEmit.apply(u,concat(m=[i]).call(m,I)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,I))},i.createTeam=function createTeam(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var h,v,M,I=this;return ud.wrap((function _callee$(S){for(;;)switch(S.prev=S.next){case 0:return this.checkV2(),validate({createTeamParams:Fv},{createTeamParams:t},"",!0),validate({inviteeAccountIds:Dt(Dt({},Gv),{min:0,required:!1})},{inviteeAccountIds:i},"",!0),validate({antispamConfig:zv},{antispamConfig:m},"",!0),h=2===t.teamType?"v2SuperTeamCreate":"v2TeamCreate",S.next=7,this.core.sendCmd(h,{team:t,inviteeAccountIds:i||[],postscript:u||"",antispamConfig:m});case 7:return v=S.sent,M=v.content.team,this.model.upsert(M),this.getTeamMemberListByIds(M.teamId,M.teamType,[this.core.account]).catch((function(t){I.core.logger.error("Get Member error after createTeam",t)})),this.emit("onTeamCreated",M),S.abrupt("return",{team:M,failedList:v.content.failedList});case 13:case"end":return S.stop()}}),_callee,this)})))},i.updateTeamInfo=function updateTeamInfo(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var h,v;return ud.wrap((function _callee2$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate(Xv,{updateTeamInfoParams:u},"",!0),validate({antispamConfig:zv},{antispamConfig:m},"",!0),h=Dt({teamId:t,teamType:i},u),v=2===i?"v2SuperTeamUpdateInfo":"v2TeamUpdateInfo",M.next=9,this.core.sendCmd(v,{team:h,antispamConfig:m});case 9:this.model.upsert(h);case 10:case"end":return M.stop()}}),_callee2,this)})))},i.leaveTeam=function leaveTeam(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var u;return ud.wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),u=2===i?"v2SuperTeamLeave":"v2TeamLeave",m.next=6,this.core.sendCmd(u,{teamId:t});case 6:this.model.deleteById(t,i);case 7:case"end":return m.stop()}}),_callee3,this)})))},i.getTeamInfo=function getTeamInfo(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var u,m,h,v;return ud.wrap((function _callee4$(M){for(;;)switch(M.prev=M.next){case 0:if(this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),u=2===i?"v2SuperTeamGetInfo":"v2TeamGetInfo",!(m=this.model.getById(t,i,!1))){M.next=7;break}return M.abrupt("return",m);case 7:return M.next=9,this.core.sendCmd(u,{teamId:t});case 9:return h=M.sent,v=h.content.team,this.model.upsert(v),M.abrupt("return",v);case 13:case"end":return M.stop()}}),_callee4,this)})))},i.getTeamInfoFromCloud=function getTeamInfoFromCloud(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var u,m,h,v,M,I;return ud.wrap((function _callee5$(S){for(;;)switch(S.prev=S.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),u=this.model.getById(t,i,!1),m=2===i?"v2SuperTeamGetInfo":"v2TeamGetInfo",S.next=7,this.core.sendCmd(m,{teamId:t});case 7:return h=S.sent,v=h.content.team,M=!1,u?u.updateTime!==v.updateTime&&(M=!0):M=!0,I=this.model.upsert(v),M&&this.emit("onTeamInfoUpdated",I),S.abrupt("return",v);case 14:case"end":return S.stop()}}),_callee5,this)})))},i.getJoinedTeamList=function getJoinedTeamList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i,u=this;return ud.wrap((function _callee6$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(Qv,{teamTypes:t},"",!0),this.core.V2NIMLoginService.checkIllegalState(),t&&0!==t.length||(t=[1,2]),i=[],forEach$1(t).call(t,(function(t){i=concat(i).call(i,u.model.getAll(t))})),m.abrupt("return",sort(i).call(i,(function(t,i){return t.createTime-i.createTime})));case 7:case"end":return m.stop()}}),_callee6,this)})))},i.getOwnerTeamList=function getOwnerTeamList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var i,u=this;return ud.wrap((function _callee7$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(Qv,{teamTypes:t},"",!0),this.core.V2NIMLoginService.checkIllegalState(),t&&0!==t.length||(t=[1,2]),i=[],forEach$1(t).call(t,(function(t){var m=u.model.getAll(t),h=filter(m).call(m,(function(t){return t.ownerAccountId===u.core.account}));i=concat(i).call(i,h)})),m.abrupt("return",sort(i).call(i,(function(t,i){return t.createTime-i.createTime})));case 7:case"end":return m.stop()}}),_callee7,this)})))},i.getManagerTeamList=function getManagerTeamList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i,u,m,h,v=this;return ud.wrap((function _callee8$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkV2(),validate(Qv,{teamTypes:t},"",!0),this.core.V2NIMLoginService.checkIllegalState(),t&&0!==t.length||(t=[1,2]),u=[],M.next=7,this.getJoinedTeamMembers(t);case 7:return m=M.sent,h=new Sc,forEach$1(i=filter(m).call(m,(function(t){return 1===t.memberRole||2===t.memberRole}))).call(i,(function(t){h.has(t.teamType)||h.set(t.teamType,new zg);var i=h.get(t.teamType);i&&i.add(t.teamId)})),forEach$1(t).call(t,(function(t){var i=h.get(t);if(i&&i.size>0){var m=v.model.getAll(t),M=filter(m).call(m,(function(t){return i.has(t.teamId)}));u=concat(u).call(u,M)}})),M.abrupt("return",sort(u).call(u,(function(t,i){return t.createTime-i.createTime})));case 12:case"end":return M.stop()}}),_callee8,this)})))},i.getJoinedTeamCount=function getJoinedTeamCount(t){var i=this;this.checkV2(),validate(Qv,{teamTypes:t},"",!0),this.core.V2NIMLoginService.checkIllegalState(),t&&0!==t.length||(t=[1,2]);var u=0;return forEach$1(t).call(t,(function(t){u+=i.model.count(t)})),u},i.getJoinedTeamMembers=function getJoinedTeamMembers(t){var i=this;this.checkV2(),validate(Qv,{teamTypes:t},"",!0),this.core.V2NIMLoginService.checkIllegalState(),t&&0!==t.length||(t=[1,2]);var u=[];return forEach$1(t).call(t,(function(t){var m=i.memberModel.chooseList(t),h=filter(m).call(m,(function(t){return t.accountId===i.core.account}));u=concat(u).call(u,h)})),zi.resolve(u)},i.getTeamInfoByIds=function getTeamInfoByIds(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var u,m,h,v,M,I,S=this;return ud.wrap((function _callee9$(T){for(;;)switch(T.prev=T.next){case 0:if(this.checkV2(),validate(Kv,{teamIds:t},"",!0),validate(Yv,{teamType:i},"",!0),m=2===i?"v2SuperTeamGetByIds":"v2TeamGetByIds",h=map$6(t).call(t,(function(t){return S.model.getById(t,i,!1)})),0!==(v=filter(t).call(t,(function(t,i){return!h[i]}))).length){T.next=8;break}return T.abrupt("return",h);case 8:return T.next=10,this.core.sendCmd(m,{teamIds:v});case 10:return M=T.sent,I=M.content.teams,T.abrupt("return",filter(u=map$6(h).call(h,(function(i,u){if(i)return i;var m=t[u],h=find(I).call(I,(function(t){return t.teamId===m}));return h&&S.model.upsert(h),h}))).call(u,(function(t){return!!t})));case 13:case"end":return T.stop()}}),_callee9,this)})))},i.dismissTeam=function dismissTeam(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var u;return ud.wrap((function _callee10$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),u=2===i?"v2SuperTeamDismiss":"v2TeamDismiss",m.next=6,this.core.sendCmd(u,{teamId:t});case 6:case"end":return m.stop()}}),_callee10,this)})))},i.inviteMember=function inviteMember(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var h,v;return ud.wrap((function _callee11$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({inviteeAccountIds:Gv},{inviteeAccountIds:u},"",!0),validate({postscript:Dt(Dt({},jv),{required:!1})},{postscript:m},"",!0),h=2===i?"v2SuperTeamInviteMembers":"v2TeamInviteMembers",M.next=8,this.core.sendCmd(h,{teamId:t,accounts:u,ps:m||""});case 8:return v=M.sent,M.abrupt("return",v.content.abortedAccidList);case 10:case"end":return M.stop()}}),_callee11,this)})))},i.inviteMemberEx=function inviteMemberEx(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var m,h;return ud.wrap((function _callee12$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate(Jv,{inviteeParams:u},"",!0),m=2===i?"v2SuperTeamInviteMembers":"v2TeamInviteMembers",v.next=7,this.core.sendCmd(m,{teamId:t,accounts:u.inviteeAccountIds,ps:u.postscript||"",attach:u.serverExtension});case 7:return h=v.sent,v.abrupt("return",h.content.abortedAccidList);case 9:case"end":return v.stop()}}),_callee12,this)})))},i.acceptInvitation=function acceptInvitation(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i,u,m,h,v,M;return ud.wrap((function _callee13$(I){for(;;)switch(I.prev=I.next){case 0:return this.checkV2(),validate(nf,t,"invitationInfo",!0),validate(sf,t,"invitationInfo",!0),i=t.teamType,u=t.teamId,m=t.operatorAccountId,h=2===i?"v2SuperTeamAcceptInvitation":"v2TeamAcceptInvitation",I.prev=5,I.next=8,this.core.sendCmd(h,{teamId:u,from:m});case 8:return v=I.sent,this.notification.updateTeamActionStatus(t,1),I.abrupt("return",v.content.team);case 13:throw I.prev=13,I.t0=I.catch(5),M=I.t0,this.notification.checkIfExpired(M.code)&&this.notification.updateTeamActionStatus(t,3),I.t0;case 18:case"end":return I.stop()}}),_callee13,this,[[5,13]])})))},i.rejectInvitation=function rejectInvitation(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var u,m,h,v,M;return ud.wrap((function _callee14$(I){for(;;)switch(I.prev=I.next){case 0:return this.checkV2(),validate(nf,t,"invitationInfo",!0),validate(sf,t,"invitationInfo",!0),validate({postscript:Dt(Dt({},jv),{required:!1})},{postscript:i},"",!0),u=t.teamType,m=t.teamId,h=t.operatorAccountId,v=2===u?"v2SuperTeamRejectInvite":"v2TeamRejectInvite",I.prev=6,I.next=9,this.core.sendCmd(v,{teamId:m,from:h,ps:i||""});case 9:this.notification.updateTeamActionStatus(t,2),I.next=17;break;case 12:throw I.prev=12,I.t0=I.catch(6),M=I.t0,this.notification.checkIfExpired(M.code)&&this.notification.updateTeamActionStatus(t,3),I.t0;case 17:case"end":return I.stop()}}),_callee14,this,[[6,12]])})))},i.kickMember=function kickMember(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){var m;return ud.wrap((function _callee15$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({memberAccountIds:Gv},{memberAccountIds:u},"",!0),m=2===i?"v2SuperTeamKickMembers":"v2TeamKickMembers",h.next=7,this.core.sendCmd(m,{teamId:t,accounts:u});case 7:case"end":return h.stop()}}),_callee15,this)})))},i.applyJoinTeam=function applyJoinTeam(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var m,h,v,M;return ud.wrap((function _callee16$(I){for(;;)switch(I.prev=I.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),m=2===i?"v2SuperTeamApplyToJoin":"v2TeamApplyToJoin",I.next=6,this.core.sendCmd(m,{teamId:t,ps:u||""});case 6:return h=I.sent,v=h.content.team,M=h.content.isInTeam,v.isValidTeam=!!v.isValidTeam&&!!M,I.abrupt("return",v);case 11:case"end":return I.stop()}}),_callee16,this)})))},i.acceptJoinApplication=function acceptJoinApplication(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){var i,u,m,h,v;return ud.wrap((function _callee17$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkV2(),validate(nf,t,"applicationInfo",!0),validate(cf,t,"applicationInfo",!0),i=t.teamType,u=t.teamId,m=t.operatorAccountId,h=2===i?"v2SuperTeamAcceptJoinApplication":"v2TeamAcceptJoinApplication",M.prev=5,M.next=8,this.core.sendCmd(h,{teamId:u,from:m});case 8:this.notification.updateTeamActionStatus(t,1),M.next=16;break;case 11:throw M.prev=11,M.t0=M.catch(5),v=M.t0,this.notification.checkIfExpired(v.code)&&this.notification.updateTeamActionStatus(t,3),M.t0;case 16:case"end":return M.stop()}}),_callee17,this,[[5,11]])})))},i.rejectJoinApplication=function rejectJoinApplication(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){var u,m,h,v,M;return ud.wrap((function _callee18$(I){for(;;)switch(I.prev=I.next){case 0:return this.checkV2(),validate(nf,t,"applicationInfo",!0),validate(cf,t,"applicationInfo",!0),validate({postscript:Dt(Dt({},jv),{required:!1})},{postscript:i},"",!0),u=t.teamType,m=t.teamId,h=t.operatorAccountId,v=2===u?"v2SuperTeamRejectJoinApplication":"v2TeamRejectJoinApplication",I.prev=6,I.next=9,this.core.sendCmd(v,{teamId:m,from:h,ps:i||""});case 9:this.notification.updateTeamActionStatus(t,2),I.next=17;break;case 12:throw I.prev=12,I.t0=I.catch(6),M=I.t0,this.notification.checkIfExpired(M.code)&&this.notification.updateTeamActionStatus(t,3),I.t0;case 17:case"end":return I.stop()}}),_callee18,this,[[6,12]])})))},i.updateTeamMemberRole=function updateTeamMemberRole(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){var h;return ud.wrap((function _callee19$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({memberAccountIds:Gv},{memberAccountIds:u},"",!0),validate({memberRole:Zv},{memberRole:m},"",!0),h=2===m?"AddManagers":"RemoveManagers",h=2===i?"v2SuperTeam"+h:"v2Team"+h,v.next=9,this.core.sendCmd(h,{teamId:t,accounts:uniq(u)});case 9:case"end":return v.stop()}}),_callee19,this)})))},i.transferTeamOwner=function transferTeamOwner(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){var h,v;return ud.wrap((function _callee20$(M){for(;;)switch(M.prev=M.next){case 0:if(this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({accountId:$v},{accountId:u},"",!0),validate({leave:{type:"boolean",required:!1}},{leave:m},"",!0),!(h=this.model.getById(t,i))||h.ownerAccountId!==u){M.next=8;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Transfer to self is not allowed"}});case 8:return v=2===i?"v2SuperTeamTransferOwner":"v2TeamTransferOwner",M.next=11,this.core.sendCmd(v,{teamId:t,account:u,leave:m||!1});case 11:case"end":return M.stop()}}),_callee20,this)})))},i.updateSelfTeamMemberInfo=function updateSelfTeamMemberInfo(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){var m,h,v,M,I,S;return ud.wrap((function _callee21$(T){for(;;)switch(T.prev=T.next){case 0:if(this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate(ef,{memberInfoParams:u},"",!0),void 0!==u.teamNick||void 0!==u.serverExtension){T.next=6;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER});case 6:return m=2===i?"v2SuperTeamUpdateSelfMemberInfo":"v2TeamUpdateSelfMemberInfo",h=Dt(Dt({},u),{teamId:t,accountId:this.core.account}),v=u.antispamConfig?{teamMember:h,specialFollowUpdate:{},antispam:u.antispamConfig}:{teamMember:h},T.next=11,this.core.sendCmd(m,v);case 11:return T.next=13,this.notification.updateTeamMemberRole(t,i,[this.core.account],h);case 13:M=this.memberModel.getById(t,i,this.core.account),this.core.V2NIMSettingService.name&&this.core.V2NIMConversationIdUtil.name&&(I=1===i?this.core.V2NIMConversationIdUtil.teamConversationId(t):this.core.V2NIMConversationIdUtil.superTeamConversationId(t),S=this.core.V2NIMSettingService.getConversationMuteStatus(I),this.core.eventBus.emit("V2NIMSettingService/setMute",I,S)),this.core.eventBus.emit("forwardSend/V2NIMTeamService/updateSelfTeamMemberInfo",M);case 16:case"end":return T.stop()}}),_callee21,this)})))},i.updateTeamMemberNick=function updateTeamMemberNick(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee22(){var h;return ud.wrap((function _callee22$(v){for(;;)switch(v.prev=v.next){case 0:if(this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({accountId:$v},{accountId:u},"",!0),validate({nick:jv},{nick:m},"",!0),u!==this.core.account){v.next=7;break}return v.abrupt("return",this.updateSelfTeamMemberInfo(t,i,{teamNick:m}));case 7:return h=2===i?"v2SuperTeamUpdateMember":"v2TeamUpdateMember",v.next=10,this.core.sendCmd(h,{teamMember:{teamNick:m,teamId:t,accountId:u}});case 10:case"end":return v.stop()}}),_callee22,this)})))},i.updateTeamMemberNickEx=function updateTeamMemberNickEx(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee23(){var m;return ud.wrap((function _callee23$(h){for(;;)switch(h.prev=h.next){case 0:if(this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate(uf,u,"",!0),u.accountId!==this.core.account){h.next=6;break}return h.abrupt("return",this.updateSelfTeamMemberInfo(t,i,{teamNick:u.teamNick,antispamConfig:u.antispamConfig}));case 6:return m=2===i?"v2SuperTeamUpdateMember":"v2TeamUpdateMember",h.next=9,this.core.sendCmd(m,{teamMember:{teamNick:u.teamNick,teamId:t,accountId:u.accountId},antispam:u.antispamConfig});case 9:case"end":return h.stop()}}),_callee23,this)})))},i.setTeamChatBannedMode=function setTeamChatBannedMode(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee24(){var m;return ud.wrap((function _callee24$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate(tf,{chatBannedMode:u},"",!0),m=2===i?"v2SuperTeamSetChatBannedMode":"v2TeamSetChatBannedMode",h.next=7,this.core.sendCmd(m,{teamId:t,chatBannedMode:u});case 7:this.model.upsert({teamId:t,teamType:i,chatBannedMode:u});case 8:case"end":return h.stop()}}),_callee24,this)})))},i.setTeamMemberChatBannedStatus=function setTeamMemberChatBannedStatus(t,i,u,m){return __awaiter(this,void 0,void 0,ud.mark((function _callee25(){var h;return ud.wrap((function _callee25$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({accountId:$v},{accountId:u},"",!0),validate({chatBanned:Hv},{chatBanned:m},"",!0),h=2===i?"v2SuperTeamMemberSetChatBannedStatus":"v2TeamMemberSetChatBannedStatus",v.next=8,this.core.sendCmd(h,{teamId:t,accountId:2===i?[u]:u,chatBanned:m?1:0});case 8:case"end":return v.stop()}}),_callee25,this)})))},i.getTeamMemberList=function getTeamMemberList(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee26(){var m,h,v,M;return ud.wrap((function _callee26$(I){for(;;)switch(I.prev=I.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate(rf,{queryOption:u},"",!0),m=0===(m=void 0===u.direction?0:u.direction)?1:0,I.next=8,this.core.sendCmd("v2TeamMemberGetList",{tag:Dt(Dt({teamId:t,teamType:i,onlyChatBanned:!1,nextToken:"",limit:100},u),{direction:m})});case 8:return h=I.sent,v=h.content.datas,M=get(h,"raw.r.0"),2===i&&M&&map$6(M)&&(v=map$6(M).call(M,(function(t){return deserialize(t,invertSerializeItem(ph))}))),I.abrupt("return",{nextToken:h.content.pageInfo.nextToken||"",finished:!+h.content.pageInfo.hasMore,memberList:processTeamMembers(v,i)});case 13:case"end":return I.stop()}}),_callee26,this)})))},i.getTeamMemberListByIds=function getTeamMemberListByIds(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee27(){var m,h,v,M,I,S,T=this;return ud.wrap((function _callee27$(C){for(;;)switch(C.prev=C.next){case 0:this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({accountIds:Gv},{accountIds:u},"",!0),m=2===i?"v2SuperTeamMemberGetListByIds":"v2TeamMemberGetListByIds",h=map$6(u).call(u,(function(i){return t+"|"+i})),v=[],M=0;case 8:if(!(M<h.length)){C.next=18;break}return C.next=11,this.core.sendCmd(m,{tag:slice(h).call(h,M,M+20)});case 11:I=C.sent,S=processTeamMembers(I.content.datas,i),v=concat(v).call(v,S),forEach$1(S).call(S,(function(t){return T.memberModel.upsert(t)}));case 15:M+=20,C.next=8;break;case 18:return C.abrupt("return",v);case 19:case"end":return C.stop()}}),_callee27,this)})))},i.getTeamMemberInvitor=function getTeamMemberInvitor(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee28(){var m,h;return ud.wrap((function _callee28$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate({accountIds:Gv},{accountIds:u},"",!0),m=2===i?"v2SuperTeamGetMemberInvitor":"v2TeamGetMemberInvitor",v.next=7,this.core.sendCmd(m,{teamId:t,accounts:u});case 7:return h=v.sent,v.abrupt("return",h.content.accountsMap);case 9:case"end":return v.stop()}}),_callee28,this)})))},i.searchTeamByKeyword=function searchTeamByKeyword(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee29(){return ud.wrap((function _callee29$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),this.checkLogin(),validate({keyword:$v},{keyword:t},"",!0),i.abrupt("return",this.model.searchTeamByKeyword(t));case 4:case"end":return i.stop()}}),_callee29,this)})))},i.addTeamMembersFollow=function addTeamMembersFollow(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee30(){var m,h,v,M,I;return ud.wrap((function _callee30$(S){for(;;)switch(S.prev=S.next){case 0:return this.checkV2(),validate(df,{teamId:t,teamType:i,accountIds:u},"",!0),m=2===i?"v2SuperTeamUpdateSelfMemberInfo":"v2TeamUpdateSelfMemberInfo",S.next=5,this.getTeamMemberListByIds(t,i,[this.core.account]);case 5:return h=S.sent,v=h[0],S.next=9,this.core.sendCmd(m,{teamMember:{teamId:t},specialFollowUpdate:{accountIds:u,operation:1}});case 9:M=S.sent,I=M.content.data,Ht(I).length>0&&(Dt(v,I),this.emit("onTeamMemberInfoUpdated",[v]),this.memberModel.upsert(v));case 12:case"end":return S.stop()}}),_callee30,this)})))},i.removeTeamMembersFollow=function removeTeamMembersFollow(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee31(){var m,h,v,M,I;return ud.wrap((function _callee31$(S){for(;;)switch(S.prev=S.next){case 0:return this.checkV2(),validate(df,{teamId:t,teamType:i,accountIds:u},"",!0),S.next=4,this.getTeamMemberListByIds(t,i,[this.core.account]);case 4:return m=S.sent,h=m[0],v=2===i?"v2SuperTeamUpdateSelfMemberInfo":"v2TeamUpdateSelfMemberInfo",S.next=9,this.core.sendCmd(v,{teamMember:{teamId:t},specialFollowUpdate:{accountIds:u,operation:0}});case 9:M=S.sent,I=M.content.data,Ht(I).length>0&&(Dt(h,I),this.emit("onTeamMemberInfoUpdated",[h]),this.memberModel.upsert(h));case 12:case"end":return S.stop()}}),_callee31,this)})))},i.getTeamJoinActionInfoList=function getTeamJoinActionInfoList(t){return this.checkV2(),validate(lf,t,"option",!0),this.core.V2NIMLoginService.checkIllegalState(),zi.resolve(this.config.enableServerV2TeamJoinActionInfo?this.notificationModel.getByOption(t):this.notificationModelOld.getByOption(t))},i.clearAllTeamJoinActionInfo=function clearAllTeamJoinActionInfo(){return __awaiter(this,void 0,void 0,ud.mark((function _callee32(){var t;return ud.wrap((function _callee32$(i){for(;;)switch(i.prev=i.next){case 0:if(this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),!this.config.enableServerV2TeamJoinActionInfo){i.next=8;break}return i.next=5,this.core.sendCmd("v2TeamJoinActionClear",{tag:{timestamp:this.core.timeOrigin.getNTPTime(),type:Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL}});case 5:t=i.sent,this.notification.setSyncTimestamp(t.content.serverTime),this.notificationModel.reset();case 8:this.notificationModelOld.reset();case 9:case"end":return i.stop()}}),_callee32,this)})))},i.clearAllTeamJoinActionInfoEx=function clearAllTeamJoinActionInfoEx(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee33(){var i,u;return ud.wrap((function _callee33$(m){for(;;)switch(m.prev=m.next){case 0:if(this.core.V2NIMLoginService.checkIllegalState(),validate({timestamp:{type:"number",required:!1},type:{type:"enum",values:[Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL,Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_NORMAL,Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_SUPER],required:!1}},t,"",!0),i={timestamp:t.timestamp||this.core.timeOrigin.getNTPTime(),type:t.type||Tl.V2NIM_TEAM_JOIN_ACTION_TEAM_TYPE_ALL},!this.config.enableServerV2TeamJoinActionInfo){m.next=9;break}return m.next=6,this.core.sendCmd("v2TeamJoinActionClear",{tag:i});case 6:u=m.sent,this.notification.setSyncTimestamp(u.content.serverTime),this.notificationModel.deleteByOption(i);case 9:this.notificationModelOld.deleteByOption(i);case 10:case"end":return m.stop()}}),_callee33,this)})))},i.deleteTeamJoinActionInfo=function deleteTeamJoinActionInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee34(){var i;return ud.wrap((function _callee34$(u){for(;;)switch(u.prev=u.next){case 0:if(this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),validate(nf,t,"",!0),validate(af,t,"",!0),validate({timestamp:{type:"number",min:1}},t,"",!0),!this.config.enableServerV2TeamJoinActionInfo||!t.serverId){u.next=11;break}return u.next=8,this.core.sendCmd("v2TeamJoinActionDelete",{tag:{serverId:t.serverId,teamType:t.teamType,teamId:t.teamId}});case 8:i=u.sent,this.notification.setSyncTimestamp(i.content.serverTime),this.notificationModel.delete(t.serverId);case 11:this.notificationModelOld.delete(t);case 12:case"end":return u.stop()}}),_callee34,this)})))},i.setTeamJoinActionInfoRead=function setTeamJoinActionInfoRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee35(){return ud.wrap((function _callee35$(i){for(;;)switch(i.prev=i.next){case 0:this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),t?(validate(nf,t,"",!0),validate(af,t,"",!0),this.notificationModel.setRead(t),this.notificationModelOld.setRead(t)):(this.notificationModel.setAllRead(),this.notificationModelOld.setAllRead());case 3:case"end":return i.stop()}}),_callee35,this)})))},i.getTeamJoinActionInfoUnreadCount=function getTeamJoinActionInfoUnreadCount(){return __awaiter(this,void 0,void 0,ud.mark((function _callee36(){return ud.wrap((function _callee36$(t){for(;;)switch(t.prev=t.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),t.abrupt("return",this.config.enableServerV2TeamJoinActionInfo?this.notificationModel.getUnreadCount():this.notificationModelOld.getUnreadCount());case 3:case"end":return t.stop()}}),_callee36,this)})))},V2NIMTeamServiceImpl}(hp),Cf="V2NIMUserService",bf={"34_3":"v2UpdateBlockList","34_7":"v2GetUserList","34_10":"v2UpdateSelfUserProfile","3_109":"v2SyncSelfUserInfo","3_110":"onUpdateUserProfile","3_103":"onUpdateBlockList","3_8":"syncBlockAndMuteList","34_5":"v2SetP2PMessageMuteMode","3_105":"v2OnUpdateMuteList"},Ef={accountId:1,name:3,avatar:4,sign:5,gender:{id:6,retType:"number"},email:7,birthday:8,mobile:9,serverExtension:10,createTime:{id:12,retType:"number"},updateTime:{id:13,retType:"number"}},Af={v2UpdateBlockList:{sid:34,cid:3,service:Cf,params:[{type:"String",name:"accountId"},{type:"Bool",name:"addToBlockList"}]},v2GetUserList:{sid:34,cid:7,service:Cf,params:[{type:"StrArray",name:"accountIds"}],response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(Ef)}]},v2UpdateSelfUserProfile:{sid:34,cid:10,service:Cf,params:[{type:"Property",name:"tag",reflectMapper:Ef}],response:[{type:"Long",name:"updateTime"}]},onUpdateUserProfile:{sid:3,cid:110,service:Cf,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Ef)}]},onUpdateBlockList:{sid:3,cid:103,service:Cf,response:[{type:"String",name:"accountId"},{type:"Bool",name:"addToBlockList"}]},syncBlockAndMuteList:{sid:3,cid:8,service:Cf,response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem({accountId:0,isMute:{id:1,retType:"boolean"},isBlock:{id:2,retType:"boolean"}})},{type:"Long",name:"timetag"}]},v2SyncSelfUserInfo:{sid:3,cid:109,service:Cf,response:[{type:"Property",name:"user",reflectMapper:invertSerializeItem(Ef)}]},v2SetP2PMessageMuteMode:{sid:34,cid:5,service:Cf,params:[{type:"String",name:"accountId"},{type:"Bool",name:"muteMode"}]},v2OnUpdateMuteList:{sid:3,cid:105,service:Cf,response:[{type:"String",name:"accountId"},{type:"Bool",name:"mute"}]}},kf=function(){function V2NIMUserModelImpl(){this.muteList=new zg,this.userMap=new Sc,this.blockList=[]}var t=V2NIMUserModelImpl.prototype;return t.reset=function reset(){this.muteList.clear(),this.userMap.clear(),this.blockList=[]},t.setAccountMuteMode=function setAccountMuteMode(t,i){1===i?this.muteList.add(t):this.muteList.delete(t)},t.setUser=function setUser(t){this.userMap.set(t.accountId,t)},t.getUser=function getUser(t){return this.userMap.get(t)},t.getUserListBySearchOption=function getUserListBySearchOption(t){var i,u;return filter(i=id(values(u=this.userMap).call(u))).call(i,(function(i){var u,m,h;return!(void 0!==t.searchName&&!t.searchName||!includes(u=i.name).call(u,t.keyword))||(!(!t.searchAccountId||!includes(m=i.accountId).call(m,t.keyword))||!!(i.mobile&&t.searchMobile&&includes(h=i.mobile).call(h,t.keyword)))}))},t.addToBlockList=function addToBlockList(t){var i=this;forEach$1(t).call(t,(function(t){var u;includes(u=i.blockList).call(u,t)||i.blockList.push(t)}))},t.removeFromBlockList=function removeFromBlockList(t){var i=this;forEach$1(t).call(t,(function(t){var u,m,h=indexOf(u=i.blockList).call(u,t);-1!==h&&splice(m=i.blockList).call(m,h,1)}))},t.checkBlock=function checkBlock(t){var i=this,u={};return forEach$1(t).call(t,(function(t){var m;u[t]=includes(m=i.blockList).call(m,t)})),u},V2NIMUserModelImpl}(),Rf={type:"string",required:!0,allowEmpty:!1},wf={type:"string",required:!1,allowEmpty:!0},Nf={name:{type:"string",required:!1,allowEmpty:!0},avatar:wf,sign:wf,email:wf,birthday:wf,mobile:wf,gender:{type:"number",required:!1},serverExtension:wf};function _createForOfIteratorHelperLoose$6(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$6(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$6(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$6(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$6(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var xf=function(t){function V2NIMUserServiceImpl(i){var u;return u=t.call(this,"V2NIMUserService",i)||this,registerParser({cmdMap:bf,cmdConfig:Af}),u.model=new kf,"v2"!==u.core.options.apiVersion?Je(u):(u.setListener(),u)}Nt(V2NIMUserServiceImpl,t);var i=V2NIMUserServiceImpl.prototype;return i.reset=function reset(){this.model.reset()},i.setListener=function setListener(){var t=this;this.core.eventBus.on("forwardReceive/V2NIMUserService/updateBlockList",(function(i,u){u?t.model.addToBlockList([i]):t.model.removeFromBlockList([i]),u?t.emitBlockListAdded(i):t.emit("onBlockListRemoved",i)})),this.core.eventBus.on("forwardReceive/V2NIMUserService/updateUserProfile",(function(i){t.updateUserProfileInMemory(i)}))},i.emit=function emit(i){for(var u,m,h=this.name+"::emit "+i.toString(),v=arguments.length,M=new Array(v>1?v-1:0),I=1;I<v;I++)M[I-1]=arguments[I];if("onUserProfileChanged"===i){var S=M[0];this.logger.log(""+h,map$6(S).call(S,(function(t){return"id:"+t.accountId+";name:"+t.name+";updateTime:"+t.updateTime})))}else if("onBlockListAdded"===i){var T=M[0];this.logger.log(""+h,"id:"+T.accountId+";name:"+T.name+";updateTime:"+T.updateTime)}else{var C,E;(C=this.logger).log.apply(C,concat(E=[""+h]).call(E,M))}return(u=t.prototype.emit).call.apply(u,concat(m=[this,i]).call(m,M))},i.getUserList=function getUserList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),i.abrupt("return",this._getUserList(t));case 2:case"end":return i.stop()}}),_callee,this)})))},i._getUserList=function _getUserList(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u,m,h,v,M=this;return ud.wrap((function _callee2$(I){for(;;)switch(I.prev=I.next){case 0:if(validate({accountIds:Gv},{accountIds:t},"",!0),u=[],forEach$1(t).call(t,(function(t){M.model.getUser(t)||u.push(t)})),m=null,!(u.length>0)){I.next=8;break}return I.next=7,this.core.sendCmd("v2GetUserList",{accountIds:u});case 7:m=I.sent;case 8:return h=(null===(i=null==m?void 0:m.content)||void 0===i?void 0:i.data)||[],forEach$1(h).call(h,(function(t){M.model.setUser(t)})),v=[],forEach$1(t).call(t,(function(t){var i=M.model.getUser(t);i&&v.push(i)})),I.abrupt("return",v);case 13:case"end":return I.stop()}}),_callee2,this)})))},i.getUserListFromCloud=function getUserListFromCloud(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h,v=this;return ud.wrap((function _callee3$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkV2(),validate({accountIds:{type:"array",min:1,max:500,itemType:"string"}},{accountIds:t},"",!0),M.next=4,this.core.sendCmd("v2GetUserList",{accountIds:t});case 4:return i=M.sent,u=i.content.data||[],m=[],forEach$1(u).call(u,(function(t){var i=v.model.getUser(t.accountId);v.compareUserForUpdate(i,t)&&m.push(t),v.model.setUser(t)})),h=reduce(t).call(t,(function(t,i){var u=v.model.getUser(i);return u&&t.push(u),t}),[]),m.length>0&&this.emit("onUserProfileChanged",m),M.abrupt("return",h);case 11:case"end":return M.stop()}}),_callee3,this)})))},i.compareUserForUpdate=function compareUserForUpdate(t,i){return!t||!("number"==typeof t.updateTime&&"number"==typeof i.updateTime&&t.updateTime>=i.updateTime)},i.updateSelfUserProfile=function updateSelfUserProfile(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),validate(Nf,t,"",!0),u.next=4,this.core.sendCmd("v2UpdateSelfUserProfile",{tag:Dt(Dt({},t),{accountId:this.core.account})});case 4:return i=u.sent,u.next=7,this.updateUserProfileInMemory(Dt(Dt({},t),{updateTime:i.content.updateTime}));case 7:case"end":return u.stop()}}),_callee4,this)})))},i.addUserToBlockList=function addUserToBlockList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:if(this.checkV2(),t!==this.core.account){i.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Cannot block yourself"}});case 3:return validate({accountId:Rf},{accountId:t},"",!0),i.next=6,this.core.sendCmd("v2UpdateBlockList",{accountId:t,addToBlockList:!0});case 6:this.model.addToBlockList([t]),this.emitBlockListAdded(t);case 8:case"end":return i.stop()}}),_callee5,this)})))},i.removeUserFromBlockList=function removeUserFromBlockList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:if(this.checkV2(),t!==this.core.account){i.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Cannot unblock yourself"}});case 3:return validate({accountId:Rf},{accountId:t},"",!0),i.next=6,this.core.sendCmd("v2UpdateBlockList",{accountId:t,addToBlockList:!1});case 6:this.model.removeFromBlockList([t]),this.emit("onBlockListRemoved",t);case 8:case"end":return i.stop()}}),_callee6,this)})))},i.searchUserByOption=function searchUserByOption(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:if(this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),validate({keyword:{type:"string",allowEmpty:!1},searchName:{type:"boolean",required:!1},searchAccountId:{type:"boolean",required:!1},searchMobile:{type:"boolean",required:!1}},t,"",!0),!1!==(void 0===t.searchName||t.searchName)||t.searchAccountId||t.searchMobile){i.next=6;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"one of searchName, searchAccountId, searchMobile must be true"}});case 6:return i.abrupt("return",this.model.getUserListBySearchOption(t));case 7:case"end":return i.stop()}}),_callee7,this)})))},i.getBlockList=function getBlockList(){return this.checkV2(),zi.resolve(this.model.blockList)},i.checkBlock=function checkBlock(t){return this.checkV2(),validate({accountIds:Gv},{accountIds:t},"",!0),zi.resolve(this.model.checkBlock(t))},i.updateUserProfileInMemory=function updateUserProfileInMemory(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i,u;return ud.wrap((function _callee8$(m){for(;;)switch(m.prev=m.next){case 0:if(!(i=this.model.getUser(this.core.account))){m.next=6;break}Dt(i,t),this.model.setUser(i),m.next=10;break;case 6:return m.next=8,this._getUserList([this.core.account]);case 8:u=m.sent,i=u[0];case 10:i&&this.emit("onUserProfileChanged",[i]);case 11:case"end":return m.stop()}}),_callee8,this)})))},i.onUpdateUserProfileHandler=function onUpdateUserProfileHandler(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var i;return ud.wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return i=t.content.data,u.next=3,this.updateUserProfileInMemory(i);case 3:case"end":return u.stop()}}),_callee9,this)})))},i.onUpdateBlockListHandler=function onUpdateBlockListHandler(t){var i=t.content.accountId;t.content.addToBlockList?(this.model.addToBlockList([i]),this.emitBlockListAdded(i)):(this.model.removeFromBlockList([i]),this.emit("onBlockListRemoved",i))},i.syncBlockAndMuteListHandler=function syncBlockAndMuteListHandler(t){var i=this,u=t.content.data;forEach$1(u).call(u,(function(t){t.isBlock?i.model.addToBlockList([t.accountId]):i.model.setAccountMuteMode(t.accountId,t.isMute?1:0)}))},i.v2SyncSelfUserInfoHandler=function v2SyncSelfUserInfoHandler(t){var i=t.content.user;this.model.setUser(i)},i.checkUserUpdate=function checkUserUpdate(t,i){var u=t.senderId;u!==this.core.account&&this.refreshUserInfo(u,i)},i.refreshUserInfo=function refreshUserInfo(t,i){return void 0===i&&(i=0),__awaiter(this,void 0,void 0,ud.mark((function _callee10(){var u,m,h,v,M,I;return ud.wrap((function _callee10$(S){for(;;)switch(S.prev=S.next){case 0:if(t&&"string"==typeof t){S.next=2;break}return S.abrupt("return");case 2:if(u=this.model.getUser(t),m=[],!(!u||u&&"number"==typeof u.updateTime&&"number"==typeof i&&!isNaN(u.updateTime)&&!isNaN(i)&&u.updateTime<i)){S.next=16;break}return S.prev=5,S.next=8,this.core.sendCmd("v2GetUserList",{accountIds:[t]});case 8:h=S.sent,m=h.content.data,S.next=16;break;case 12:return S.prev=12,S.t0=S.catch(5),this.logger.warn("V2NIMUserService:refreshUserInfo: failed for "+t),S.abrupt("return");case 16:for(v=_createForOfIteratorHelperLoose$6(m);!(M=v()).done;)I=M.value,this.model.setUser(I),this.emit("onUserProfileChanged",[I]);case 17:case"end":return S.stop()}}),_callee10,this,[[5,12]])})))},i.emitBlockListAdded=function emitBlockListAdded(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var i;return ud.wrap((function _callee11$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this._getUserList([t]);case 2:1===(i=u.sent).length&&this.emit("onBlockListAdded",i[0]);case 4:case"end":return u.stop()}}),_callee11,this)})))},i.v2OnUpdateMuteListHandler=function v2OnUpdateMuteListHandler(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i,u,m,h;return ud.wrap((function _callee12$(v){for(;;)switch(v.prev=v.next){case 0:i=t.content,u=i.accountId,m=i.mute,h=m?1:0,this.core.eventBus.emit("v2NIMUserService/updateMuteList",u,h);case 3:case"end":return v.stop()}}),_callee12,this)})))},V2NIMUserServiceImpl}(hp),Of="V2NIMFriendService",Pf={"35_1":"v2AddFriend","35_2":"v2DeleteFriend","35_3":"v2SetFriendInfo","35_4":"v2IncFriendInfo","35_8":"v2FriendOperationDelete","35_9":"v2FriendOperationClear","12_108":"v2FriendOperationDeleteMultiSync","12_109":"v2FriendOperationClearMultiSync","12_101":"v2OnAddFriend","12_102":"v2OnDeleteFriend","12_103":"v2OnUpdateFriendInfo","12_5":"v2SyncFriendList","12_6":"v2SyncFriendUserList","12_107":"v2FriendOperationListSync","4_31":"v2FriendOperationListOnline","4_40":"v2FriendJoinActionClearSync"},Lf={applicantAccountId:1,recipientAccountId:2,operatorAccountId:3,status:{id:4,retConverter:function retConverter(t){switch(t){case"1":return 4;case"2":return 0;case"3":return 1;case"4":return 2}}},timestamp:{id:6,retType:"number"},updateTimestamp:{id:7,retType:"number"},postscriptHistory:{id:8,retConverter:function retConverter(t){if(t&&"string"==typeof t)try{var i=JSON.parse(t);return map$6(i).call(i,(function(t){return{fromAccount:t.accid,time:t.time,content:t.msg}}))}catch(t){return}}},serverId:9},Vf={serverId:1,serverTime:{id:2,retType:"number"}},Uf={serverTime:{id:1,retType:"number"}},Df={timestamp:{id:1,retType:"number"},type:{id:2,retType:"number"},serverTime:{id:3,retType:"number"}},Bf={accountId:4,relationShip:{id:5,retType:"number"},source:{id:7,retType:"number"},alias:8,serverExtension:10,createTime:{id:11,retType:"number"},updateTime:{id:12,retType:"number"},customerExtension:13},qf={v2AddFriend:{sid:35,cid:1,service:Of,params:[{type:"String",name:"accountId"},{type:"Byte",name:"verifyType"},{type:"String",name:"postscript"}],response:[]},v2DeleteFriend:{sid:35,cid:2,service:Of,params:[{type:"String",name:"accountId"},{type:"Property",name:"params",reflectMapper:{deleteAlias:{id:1,converter:boolToInt}}}]},v2SetFriendInfo:{sid:35,cid:3,service:Of,params:[{type:"Property",name:"tag",reflectMapper:Bf}]},v2OnAddFriend:{sid:12,cid:101,service:Of,response:[{type:"String",name:"accountId"},{type:"Byte",name:"verifyType"},{type:"String",name:"postscript"},{type:"Property",name:"ext",reflectMapper:invertSerializeItem({serverExt:1})}]},v2OnDeleteFriend:{sid:12,cid:102,service:Of,response:[{type:"String",name:"accountId"}]},v2OnUpdateFriendInfo:{sid:12,cid:103,service:Of,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Bf)}]},v2SyncFriendList:{sid:12,cid:5,service:Of,response:[{type:"PropertyArray",name:"friends",reflectMapper:invertSerializeItem(Bf)},{type:"Long",name:"timetag"}]},v2SyncFriendUserList:{sid:12,cid:6,service:Of,response:[{type:"PropertyArray",name:"users",reflectMapper:invertSerializeItem(Ef)}]},v2IncFriendInfo:{sid:35,cid:4,service:Of,params:[{type:"Long",name:"timetag"}],response:[{type:"PropertyArray",name:"friends",reflectMapper:invertSerializeItem(Bf)},{type:"Long",name:"timetag"}]},v2FriendOperationListSync:{sid:12,cid:107,service:Of,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Lf)},{type:"Long",name:"serverTime"}]},v2FriendOperationListOnline:{sid:4,cid:31,service:Of,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Lf)}]},v2FriendOperationDelete:{sid:35,cid:8,service:Of,params:[{type:"Property",name:"tag",reflectMapper:Vf}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Uf)}]},v2FriendOperationDeleteMultiSync:{sid:12,cid:108,service:Of,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Vf)}]},v2FriendOperationClearMultiSync:{sid:12,cid:109,service:Of,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Df)}]},v2FriendOperationClear:{sid:35,cid:9,service:Of,params:[{type:"Property",name:"tag",reflectMapper:Df}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(Uf)}]},v2FriendJoinActionClearSync:{sid:4,cid:40,service:Of,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(Lf)},{type:"PropertyArray",name:"clearInfos",reflectMapper:invertSerializeItem(Df)},{type:"Long",name:"serverTime"}]}},Ff={accountId:{type:"string",required:!0,allowEmpty:!1},params:{type:"object",required:!0,rules:{addMode:{type:"enum",required:!0,values:[1,2]},postscript:{type:"string",required:!1,allowEmpty:!0}}}},Gf={accountId:{type:"string",required:!0,allowEmpty:!1},params:{type:"object",required:!1,rules:{deleteAlias:{type:"boolean",required:!1}}}},Hf={accountId:{type:"string",required:!0,allowEmpty:!1},params:{type:"object",required:!1,rules:{alias:{type:"string",required:!1,allowEmpty:!0},serverExtension:{type:"string",required:!1,allowEmpty:!0}}}},jf={applicantAccountId:{type:"string",allowEmpty:!1},recipientAccountId:{type:"string",allowEmpty:!1},operatorAccountId:{type:"string",required:!1,allowEmpty:!1},postscript:{type:"string",required:!1,allowEmpty:!0},status:{type:"enum",values:[1,4,3,0,2]},timestamp:{type:"number",min:1},serverId:{type:"string",required:!1}};function checkApplication(t,i){if(validate(jf,t,"",!0),t&&t.applicantAccountId!==i&&t.recipientAccountId!==i)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Friend application is not your own"}})}var $f={offset:{type:"number",required:!1},limit:{type:"number",required:!1},status:{type:"array",itemType:"enum",required:!1,values:[1,4,3,0,2]}},zf=function(){function V2NIMFriendNotificationImpl(t,i){this.core=t,this.service=i}var t=V2NIMFriendNotificationImpl.prototype;return t.processSysNotification=function processSysNotification(t){if(6===t.type){var i=t.senderId;this.core.V2NIMFriendService.handleDeleteFriend(i,2)}else if(5===t.type&&!this.service.config.enableServerV2FriendAddApplication)try{var u=JSON.parse(t.content);if(1===(null==u?void 0:u.vt)){this.core.V2NIMFriendService.handleAddFriend(t.senderId);var m={applicantAccountId:t.senderId,recipientAccountId:t.receiverId,operatorAccountId:t.senderId,postscript:t.postscript,serverId:"",timestamp:t.timestamp,updateTimestamp:t.timestamp,status:4,read:!1};this.service.notificationModelOld.appendFriendAddApplication(m),this.service.notificationModelOld.updateFriendAddApplicationStatus(m.applicantAccountId,4,m.applicantAccountId)}else if(2===(null==u?void 0:u.vt)){var h={applicantAccountId:t.senderId,recipientAccountId:t.receiverId,operatorAccountId:t.senderId,postscript:t.postscript,timestamp:t.timestamp,serverId:"",updateTimestamp:t.timestamp,status:0,read:!1};this.service.handleApplyFriend(h),this.service.notificationModelOld.appendFriendAddApplication(h)}else if(3===(null==u?void 0:u.vt)){this.core.V2NIMFriendService.handleAddFriend(t.senderId);var v={applicantAccountId:t.receiverId,recipientAccountId:t.senderId,operatorAccountId:t.senderId,timestamp:t.timestamp,serverId:"",updateTimestamp:t.timestamp,postscript:t.postscript,status:1,read:!1};this.service.notificationModelOld.appendFriendAddApplication(v)}else if(4===(null==u?void 0:u.vt)){var M={applicantAccountId:t.receiverId,recipientAccountId:t.senderId,operatorAccountId:t.senderId,timestamp:t.timestamp,serverId:"",updateTimestamp:t.timestamp,postscript:t.postscript,status:2,read:!1};this.service.notificationModelOld.appendFriendAddApplication(M),this.service.emit("onFriendAddRejected",M)}}catch(t){this.core.logger.warn("V2NIMFriendNotificationImpl::processSysNotification, parse content error:",t)}},t.setSyncTimestamp=function setSyncTimestamp(t){t&&this.core.eventBus.emit("V2NIMSync/updateTimetag",{friendOperatorList:t,friendApplyInfoDeleteOrClear:t})},V2NIMFriendNotificationImpl}(),Wf=function(){function V2NIMFriendModelImpl(){this.validFriendIds=new zg,this.friendMap=new Sc,this.friendTimetag=0}var t=V2NIMFriendModelImpl.prototype;return t.reset=function reset(){this.friendMap.clear(),this.validFriendIds.clear()},t.upsertFriend=function upsertFriend(t,i){delete i.relationShip;var u=this.friendMap.get(t)||{},m=Dt({accountId:t},u,i);return this.friendMap.set(t,m),this.validFriendIds.add(t),m},t.addFriend=function addFriend(t){this.validFriendIds.add(t)},t.deleteFriend=function deleteFriend(t){this.validFriendIds.delete(t)},t.getFriend=function getFriend(t){return this.validFriendIds.has(t)?this.friendMap.get(t):void 0},t.getFriendList=function getFriendList(){var t,i,u,m=this;return filter(t=map$6(i=id(values(u=this.validFriendIds).call(u))).call(i,(function(t){return m.getFriend(t)}))).call(t,(function(t){return!!t}))},t.getFriendListBySearchOption=function getFriendListBySearchOption(t){var i,u,m,h=this;return filter(i=map$6(u=id(values(m=this.validFriendIds).call(m))).call(u,(function(t){return h.getFriend(t)}))).call(i,(function(i){var u,m,h=void 0===t.searchAlias||t.searchAlias;return void 0!==i&&(!!(h&&i.alias&&includes(u=i.alias).call(u,t.keyword))||!(!t.searchAccountId||!includes(m=i.accountId).call(m,t.keyword)))}))},t.getFriendByIds=function getFriendByIds(t){var i,u=this;return filter(i=map$6(t).call(t,(function(t){return u.getFriend(t)}))).call(i,(function(t){return!!t}))},t.setFriendTimetag=function setFriendTimetag(t){this.friendTimetag=t},t.getFriendTimetag=function getFriendTimetag(){return this.friendTimetag},V2NIMFriendModelImpl}(),Kf="NIM_FRIEND_OPERATION_READ_TIME_{ACCOUNT_ID}",Yf=function(){function V2NIMFriendNotificationModelImpl(){this.datas=new Sc,this.readTime=0,this.prefix=Kf,this.maxCount=1e3}var t=V2NIMFriendNotificationModelImpl.prototype;return t.reset=function reset(){this.datas.clear()},t.setReadTimePrefix=function setReadTimePrefix(t){var i,u=this;this.prefix=Kf.replace("{ACCOUNT_ID}",t),this.readTime=Number(pd.localStorage.getItem(this.prefix))||0,this.readTime>0&&forEach$1(i=this.datas).call(i,(function(t){t.updateTimestamp<=u.readTime&&(t.read=!0)}))},t.getReadTime=function getReadTime(){return this.readTime},t.getByOption=function getByOption(t,i){var u,m,h=void 0===t.offset?0:t.offset,v=sort(u=id(values(m=this.datas).call(m))).call(u,(function(t,i){return i.updateTimestamp-t.updateTimestamp}));t.status&&t.status.length>0&&(v=filter(v).call(v,(function(i){var u;return null===(u=t.status)||void 0===u?void 0:includes(u).call(u,i.status)})));var M=t.type?t.type:0;v=filter(v).call(v,(function(t){return 0===M?t.operatorAccountId!==i:1===M?t.applicantAccountId===i:2!==M||t.recipientAccountId===i}));var I=t.limit||50,S=slice(v).call(v,h,h+I),T=h+I>=v.length;return{infos:S,finished:T,offset:T?0:h+I}},t.setAllRead=function setAllRead(){var t,i=0;forEach$1(t=this.datas).call(t,(function(t){t.read=!0,i=Math.max(i,t.updateTimestamp)})),i&&(this.readTime=i,pd.localStorage.setItem(this.prefix,i.toString()))},t.setRead=function setRead(t){var i,u=this.datas.get(t.serverId);u&&u.updateTimestamp&&(forEach$1(i=this.datas).call(i,(function(t){t.updateTimestamp<=u.updateTimestamp&&(t.read=!0)})),this.readTime=u.updateTimestamp,pd.localStorage.setItem(this.prefix,u.updateTimestamp.toString()))},t.getUnreadCount=function getUnreadCount(){var t,i=0;return forEach$1(t=this.datas).call(t,(function(t){t.read||i++})),i},t.delete=function _delete(t){this.datas.delete(t)},t.deleteByOption=function deleteByOption(t,i){var u,m=this,h=t.timestamp,v=t.type;forEach$1(u=this.datas).call(u,(function(t){t.updateTimestamp<=h&&(3===v||1===v&&t.applicantAccountId===i||2===v&&t.recipientAccountId===i)&&m.datas.delete(t.serverId)}))},t.upsert=function upsert(t){t.serverId&&this.setLRU(t.serverId,t)},t.setLRU=function setLRU(t,i){if(this.datas.has(t))this.datas.delete(t);else if(this.datas.size>=this.maxCount){var u,m=keys(u=this.datas).call(u).next().value;m&&this.datas.delete(m)}this.datas.set(t,i)},t.clear=function clear(){this.datas.clear()},t.updateStatus=function updateStatus(t,i){if(0!==i){var u=this.datas.get(t);u&&0===u.status&&(u.status=i,this.datas.set(t,u))}},t.getById=function getById(t){return this.datas.get(t)},V2NIMFriendNotificationModelImpl}(),Qf=function(){function V2NIFriendEventImpl(t,i){this.core=t,this.service=i,this.logger=this.core.logger}var t=V2NIFriendEventImpl.prototype;return t.setListener=function setListener(){var t,i;this.core.eventBus.on("V2NIMFriendService/sysNotification",bind$1(t=this.service.notification.processSysNotification).call(t,this.service.notification)),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",bind$1(i=this.setOperationReadTime).call(i,this))},t.beforeEmit=function beforeEmit(t){for(var i=this.service.name+"::emit "+t.toString(),u=arguments.length,m=new Array(u>1?u-1:0),h=1;h<u;h++)m[h-1]=arguments[h];if("onFriendAdded"===t||"onFriendInfoChanged"===t){var v=m[0];this.logger.log(""+i,v.accountId+";updateTime:"+v.updateTime)}else{var M,I;(M=this.logger).log.apply(M,concat(I=[""+i]).call(I,m))}},t.setOperationReadTime=function setOperationReadTime(){this.service.notificationModel.setReadTimePrefix(this.core.account)},V2NIFriendEventImpl}();function completeFriendOperation(t,i,u,m){return t.updateTimestamp<=i?t.read=!0:0!==t.status&&4!==t.status||t.applicantAccountId!==u?(m&&0===m.status&&t.status,t.read=!1):t.read=!0,t.postscriptHistory&&t.postscriptHistory.length>0&&(t.postscript=t.postscriptHistory[t.postscriptHistory.length-1].content),t}var Jf=function(){function V2NIMMFriendHandlerImpl(t,i){this.core=t,this.service=i,this.model=i.model,this.notificationModel=i.notificationModel,this.notificationModelOld=i.notificationModelOld,this.logger=this.core.logger}var t=V2NIMMFriendHandlerImpl.prototype;return t.v2OnAddFriendHandler=function v2OnAddFriendHandler(t){if(!this.useServerNotification){var i=t.content,u=i.accountId,m=i.verifyType,h=i.postscript;if(1===m)this.service.handleAddFriend(u),this.notificationModelOld.updateFriendAddApplicationStatus(u,4,this.core.account);else if(2===m){var v={applicantAccountId:this.core.account,recipientAccountId:u,operatorAccountId:this.core.account,postscript:h,timestamp:this.core.timeOrigin.getNTPTime(),updateTimestamp:this.core.timeOrigin.getNTPTime(),serverId:"",status:0,read:!1};this.service.handleApplyFriend(v)}else if(3===m)this.service.handlePassFriendApply(u);else if(4===m){var M={applicantAccountId:u,recipientAccountId:this.core.account,operatorAccountId:this.core.account,postscript:h,timestamp:this.core.timeOrigin.getNTPTime(),serverId:"",updateTimestamp:this.core.timeOrigin.getNTPTime(),status:2,read:!1};this.service.handleRejectFriendApply(M)}}},t.v2OnDeleteFriendHandler=function v2OnDeleteFriendHandler(t){var i=t.content.accountId;this.service.handleDeleteFriend(i)},t.v2OnUpdateFriendInfoHandler=function v2OnUpdateFriendInfoHandler(t){var i=t.content.data,u=this.model.upsertFriend(i.accountId,i);this.service.emit("onFriendInfoChanged",this.service.computedField(u))},t.v2SyncFriendListHandler=function v2SyncFriendListHandler(t){var i=this,u=t.content,m=u.friends,h=u.timetag;this.model.setFriendTimetag(h),forEach$1(m).call(m,(function(t){t.serverExtension||(t.serverExtension=""),t.customerExtension||(t.customerExtension=""),0===t.relationShip?i.model.deleteFriend(t.accountId):i.model.upsertFriend(t.accountId,t)}))},t.v2SyncFriendUserListHandler=function v2SyncFriendUserListHandler(t){var i=this,u=t.content.users;this.hasUserService&&forEach$1(u).call(u,(function(t){i.core.V2NIMUserService.model.setUser(t)}))},t.v2FriendOperationListSyncHandler=function v2FriendOperationListSyncHandler(t){var i=this;if(this.useServerNotification){var u=t.content.datas,m=t.content.serverTime,h=this.notificationModel.getReadTime(),v=map$6(u).call(u,(function(t){return completeFriendOperation(t,h,i.core.account)}));forEach$1(v).call(v,(function(t){var u=i.notificationModel.getById(t.serverId);u&&u.status!==t.status?i.triggerEventFromOperation(t):u||!1!==t.read||0!==t.status||i.triggerEventFromOperation(t),i.notificationModel.upsert(t)})),this.service.notification.setSyncTimestamp(m)}},t.v2FriendOperationListOnlineHandler=function v2FriendOperationListOnlineHandler(t){if(this.useServerNotification){var i=t.content.data,u=this.notificationModel.getReadTime(),m=this.notificationModel.getById(i.serverId),h=completeFriendOperation(i,u,this.core.account,m);this.notificationModel.upsert(h),this.triggerEventFromOperation(h),this.service.notification.setSyncTimestamp(h.updateTimestamp)}},t.triggerEventFromOperation=function triggerEventFromOperation(t){var i=this.core.account;0===t.status&&t.operatorAccountId!==i?this.service.emit("onFriendAddApplication",t):2===t.status&&t.operatorAccountId!==i?this.service.emit("onFriendAddRejected",t):(1===t.status||4===t.status)&&this.service.handleAddFriend(t.applicantAccountId===this.core.account?t.recipientAccountId:t.applicantAccountId)},t.v2FriendOperationDeleteMultiSyncHandler=function v2FriendOperationDeleteMultiSyncHandler(t){if(this.useServerNotification){var i=t.content.data,u=i.serverTime;this.notificationModel.delete(i.serverId),this.service.notification.setSyncTimestamp(u)}},t.v2FriendOperationClearMultiSyncHandler=function v2FriendOperationClearMultiSyncHandler(t){if(this.useServerNotification){var i=t.content.data,u=i.serverTime;this.notificationModel.deleteByOption({timestamp:i.timestamp,type:i.type},this.core.account),this.service.notification.setSyncTimestamp(u)}},t.v2FriendJoinActionClearSyncHandler=function v2FriendJoinActionClearSyncHandler(t){var i=this,u=t.content.datas;forEach$1(u).call(u,(function(t){i.notificationModel.delete(t.serverId),i.notificationModelOld.deleteApplication(t)}));var m=t.content.clearInfos;forEach$1(m).call(m,(function(t){var u=t.timestamp,m=t.type,h={timestamp:u||i.core.timeOrigin.getNTPTime(),type:m||3};i.notificationModel.deleteByOption(h,i.core.account),i.notificationModelOld.deleteByOption(h,i.core.account)}));var h=t.content.serverTime;this.service.notification.setSyncTimestamp(h)},Qe(V2NIMMFriendHandlerImpl,[{key:"useServerNotification",get:function get(){return this.service.config.enableServerV2FriendAddApplication}},{key:"hasUserService",get:function get(){var t;return!!(null===(t=this.core.V2NIMUserService)||void 0===t?void 0:t.name)}}]),V2NIMMFriendHandlerImpl}();function _createForOfIteratorHelperLoose$5(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$5(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$5(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$5(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$5(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var Xf=function(){function V2NIMFriendNotificationModelOldImpl(){this.list=[],this.maxCount=1e3}var t=V2NIMFriendNotificationModelOldImpl.prototype;return t.reset=function reset(){this.list=[]},t.updateFriendAddApplicationStatus=function updateFriendAddApplicationStatus(t,i,u){if(0!==i)for(var m,h=_createForOfIteratorHelperLoose$5(this.list);!(m=h()).done;){var v=m.value;v.applicantAccountId===t&&0===v.status&&(v.status=i,v.operatorAccountId=u)}},t.getAddApplicationList=function getAddApplicationList(t){var i,u,m=void 0===t.offset?0:t.offset,h=reverse$1(i=filter(u=this.list).call(u,(function(i){var u=t.status||[];return 0===u.length||!!includes(u).call(u,i.status)}))).call(i),v=t.limit||50,M=slice(h).call(h,m,m+v),I=m+v>=h.length;return{infos:M,finished:I,offset:I?0:m+v}},t.checkSameApplication=function checkSameApplication(t,i,u){return void 0===u&&(u=!1),t.applicantAccountId===i.applicantAccountId&&t.recipientAccountId===i.recipientAccountId&&(!u||t.timestamp===i.timestamp)},t.setAllApplicationRead=function setAllApplicationRead(){for(var t,i=_createForOfIteratorHelperLoose$5(this.list);!(t=i()).done;){t.value.read=!0}},t.setApplicationRead=function setApplicationRead(t){for(var i,u=_createForOfIteratorHelperLoose$5(this.list);!(i=u()).done;){var m=i.value;this.checkSameApplication(m,t)&&(m.read=!0)}},t.getAddApplicationUnreadCount=function getAddApplicationUnreadCount(){for(var t,i=new zg,u=_createForOfIteratorHelperLoose$5(this.list);!(t=u()).done;){var m=t.value;m.read||0!==m.status||i.add(m.applicantAccountId)}return i.size},t.appendFriendAddApplication=function appendFriendAddApplication(t){this.list.push(t),this.list.length>this.maxCount&&this.list.shift()},t.clearApplicationList=function clearApplicationList(){this.list=[]},t.deleteApplication=function deleteApplication(t){var i,u,m=this;this.list=filter(i=map$6(u=this.list).call(u,(function(i){if(!m.checkSameApplication(i,t,!1))return i}))).call(i,(function(t){return t}))},t.deleteByOption=function deleteByOption(t,i){var u,m=t.timestamp,h=t.type;this.list=filter(u=this.list).call(u,(function(t){return!(t.timestamp<=m&&(3===h||1===h&&t.applicantAccountId===i||2===h&&t.recipientAccountId===i))}))},V2NIMFriendNotificationModelOldImpl}(),Zf=function(t){function V2NIMFriendServiceImpl(i){var u;return(u=t.call(this,"V2NIMFriendService",i)||this).config={enableServerV2FriendAddApplication:!1},u.notification=new zf(u.core,Je(u)),u.model=new Wf,u.notificationModel=new Yf,u.notificationModelOld=new Xf,u.event=new Qf(u.core,Je(u)),u.handler=new Jf(u.core,Je(u)),u.core._registerDep(xf,"V2NIMUserService"),"v2"!==u.core.options.apiVersion?Je(u):(registerParser({cmdMap:Pf,cmdConfig:qf}),u.setListener(),u)}Nt(V2NIMFriendServiceImpl,t);var i=V2NIMFriendServiceImpl.prototype;return i.reset=function reset(){this.model.reset(),this.notificationModel.reset(),this.notificationModelOld.reset()},i.setListener=function setListener(){this.event.setListener()},i.setOptions=function setOptions(t){this.config=Dt(this.config,t)},i.emit=function emit(i){for(var u,m,h,v,M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];return(u=this.event).beforeEmit.apply(u,concat(m=[i]).call(m,I)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,I))},i.addFriend=function addFriend(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:if(this.checkV2(),t!==this.core.account){u.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Cannot add yourself"}});case 3:return validate(Ff,{accountId:t,params:i},"",!0),u.next=6,this.core.sendCmd("v2AddFriend",{accountId:t,verifyType:i.addMode,postscript:i.postscript||""});case 6:if(1!==i.addMode){u.next=10;break}return u.next=9,this.handleAddFriend(t);case 9:this.notificationModelOld.updateFriendAddApplicationStatus(t,4,this.core.account);case 10:case"end":return u.stop()}}),_callee,this)})))},i.deleteFriend=function deleteFriend(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:if(this.checkV2(),t!==this.core.account){u.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Cannot delete yourself"}});case 3:return validate(Gf,{accountId:t,params:i},"",!0),u.next=6,this.core.sendCmd("v2DeleteFriend",{accountId:t,params:i});case 6:i.deleteAlias&&this.model.upsertFriend(t,{alias:""}),this.handleDeleteFriend(t);case 8:case"end":return u.stop()}}),_callee2,this)})))},i.acceptAddApplication=function acceptAddApplication(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),checkApplication(t,this.core.account),i.prev=2,i.next=5,this.core.sendCmd("v2AddFriend",{accountId:t.applicantAccountId,verifyType:3,postscript:""});case 5:this.handlePassFriendApply(t.applicantAccountId),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(2),this.handlePassFriendApply(t.applicantAccountId,i.t0),i.t0;case 12:case"end":return i.stop()}}),_callee3,this,[[2,8]])})))},i.rejectAddApplication=function rejectAddApplication(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),checkApplication(t,this.core.account),u.prev=2,u.next=5,this.core.sendCmd("v2AddFriend",{accountId:t.applicantAccountId,verifyType:4,postscript:i||""});case 5:this.handleRejectFriendApply(Dt(Dt({},t),{postscript:i||"",operatorAccountId:this.core.account,updateTimestamp:this.core.timeOrigin.getNTPTime(),read:!1,status:2})),u.next=12;break;case 8:throw u.prev=8,u.t0=u.catch(2),this.handleRejectFriendApply({applicantAccountId:t.applicantAccountId,recipientAccountId:t.recipientAccountId,operatorAccountId:this.core.account,postscript:i||"",serverId:"",timestamp:this.core.timeOrigin.getNTPTime(),updateTimestamp:this.core.timeOrigin.getNTPTime(),read:!1,status:3},u.t0),u.t0;case 12:case"end":return u.stop()}}),_callee4,this,[[2,8]])})))},i.setFriendInfo=function setFriendInfo(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:if(this.checkV2(),validate(Hf,{accountId:t,params:i},"",!0),t!==this.core.account){u.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"Cannot set yourself"}});case 4:return u.next=6,this.core.sendCmd("v2SetFriendInfo",{tag:Dt({accountId:t},i)});case 6:this.handleSetFriendInfo(t,i);case 7:case"end":return u.stop()}}),_callee5,this)})))},i.getFriendList=function getFriendList(){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),t.abrupt("return",this.computedFields(this.model.getFriendList()));case 3:case"end":return t.stop()}}),_callee6,this)})))},i.getFriendByIds=function getFriendByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),validate({accountIds:{type:"array",itemType:"string",required:!0,min:1}},{accountIds:t},"",!0),i.abrupt("return",this.computedFields(this.model.getFriendByIds(t)));case 4:case"end":return i.stop()}}),_callee7,this)})))},i.checkFriend=function checkFriend(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i,u=this;return ud.wrap((function _callee8$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),validate({accountIds:{type:"array",itemType:"string",required:!0,min:1}},{accountIds:t},"",!0),i={},forEach$1(t).call(t,(function(t){i[t]=!!u.model.getFriend(t)})),m.abrupt("return",i);case 6:case"end":return m.stop()}}),_callee8,this)})))},i.getAddApplicationList=function getAddApplicationList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){return ud.wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),validate($f,t,"",!0),i.abrupt("return",this.config.enableServerV2FriendAddApplication?this.notificationModel.getByOption(t,this.core.account):this.notificationModelOld.getAddApplicationList(t));case 4:case"end":return i.stop()}}),_callee9,this)})))},i.setAddApplicationRead=function setAddApplicationRead(){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){return ud.wrap((function _callee10$(t){for(;;)switch(t.prev=t.next){case 0:this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),this.notificationModel.setAllRead(),this.notificationModelOld.setAllApplicationRead();case 4:case"end":return t.stop()}}),_callee10,this)})))},i.setAddApplicationReadEx=function setAddApplicationReadEx(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),t?(checkApplication(t,this.core.account),this.notificationModel.setRead(t),this.notificationModelOld.setApplicationRead(t)):(this.notificationModel.setAllRead(),this.notificationModelOld.setAllApplicationRead());case 3:case"end":return i.stop()}}),_callee11,this)})))},i.getAddApplicationUnreadCount=function getAddApplicationUnreadCount(){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(t){for(;;)switch(t.prev=t.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),t.abrupt("return",this.config.enableServerV2FriendAddApplication?this.notificationModel.getUnreadCount():this.notificationModelOld.getAddApplicationUnreadCount());case 3:case"end":return t.stop()}}),_callee12,this)})))},i.clearAllAddApplication=function clearAllAddApplication(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i,u;return ud.wrap((function _callee13$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),m.next=4,this.core.sendCmd("v2FriendOperationClear",{tag:{}});case 4:i=m.sent,(u=null===(t=i.content.data)||void 0===t?void 0:t.serverTime)&&this.core.eventBus.emit("V2NIMSync/updateTimetag",{friendOperatorList:u,friendApplyInfoDeleteOrClear:u}),this.notificationModel.clear(),this.notificationModelOld.clearApplicationList();case 9:case"end":return m.stop()}}),_callee13,this)})))},i.clearAllAddApplicationEx=function clearAllAddApplicationEx(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var u,m,h;return ud.wrap((function _callee14$(v){for(;;)switch(v.prev=v.next){case 0:return this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),validate({timestamp:{type:"number",required:!1},type:{type:"enum",values:[1,2,3],required:!1}},t,"",!0),v.next=5,this.core.sendCmd("v2FriendOperationClear",{tag:t});case 5:u=v.sent,(m=null===(i=u.content.data)||void 0===i?void 0:i.serverTime)&&this.core.eventBus.emit("V2NIMSync/updateTimetag",{friendOperatorList:m,friendApplyInfoDeleteOrClear:m}),h={timestamp:"number"==typeof(null==t?void 0:t.timestamp)?t.timestamp:this.core.timeOrigin.getNTPTime(),type:"number"==typeof(null==t?void 0:t.type)?t.type:3},this.notificationModel.deleteByOption(h,this.core.account),this.notificationModelOld.deleteByOption(h,this.core.account);case 11:case"end":return v.stop()}}),_callee14,this)})))},i.deleteAddApplication=function deleteAddApplication(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){var u;return ud.wrap((function _callee15$(m){for(;;)switch(m.prev=m.next){case 0:if(this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),checkApplication(t,this.core.account),!t.serverId){m.next=8;break}return m.next=6,this.core.sendCmd("v2FriendOperationDelete",{tag:{serverId:t.serverId}});case 6:u=m.sent,this.notification.setSyncTimestamp(null===(i=u.content.data)||void 0===i?void 0:i.serverTime);case 8:this.notificationModel.delete(t.serverId),this.notificationModelOld.deleteApplication(t);case 10:case"end":return m.stop()}}),_callee15,this)})))},i.searchFriendByOption=function searchFriendByOption(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){return ud.wrap((function _callee16$(i){for(;;)switch(i.prev=i.next){case 0:if(this.checkV2(),this.core.V2NIMLoginService.checkIllegalState(),validate({keyword:{type:"string",allowEmpty:!1},searchAccountId:{type:"boolean",required:!1}},t,"",!0),void 0===t.searchAlias||t.searchAlias||t.searchAccountId){i.next=6;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"searchAlias and searchAccountId cannot be false at the same time"}});case 6:return i.abrupt("return",this.computedFields(this.model.getFriendListBySearchOption(t)));case 7:case"end":return i.stop()}}),_callee16,this)})))},i.handleApplyFriend=function handleApplyFriend(t){this.emit("onFriendAddApplication",t)},i.handleAddFriend=function handleAddFriend(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){var i;return ud.wrap((function _callee17$(u){for(;;)switch(u.prev=u.next){case 0:return this.model.addFriend(t),u.next=3,this.incrementSyncFriend();case 3:return u.next=5,this.core.V2NIMUserService.refreshUserInfo(t);case 5:(i=this.model.getFriend(t))&&this.emit("onFriendAdded",this.computedField(i));case 7:case"end":return u.stop()}}),_callee17,this)})))},i.handleDeleteFriend=function handleDeleteFriend(t,i){i=void 0===i?1:i,this.emit("onFriendDeleted",t,i),this.model.deleteFriend(t)},i.handleSetFriendInfo=function handleSetFriendInfo(t,i){var u=this.model.upsertFriend(t,i);this.emit("onFriendInfoChanged",this.computedField(u))},i.handlePassFriendApply=function handlePassFriendApply(t,i){if(!this.config.enableServerV2FriendAddApplication){var u=i?null==i?void 0:i.code:200;if(!(u>=19e4||u===zl.V2NIM_ERROR_CODE_FRIEND_OPERATION_RATE_LIMIT))if(200===u||u===zl.V2NIM_ERROR_CODE_FRIEND_ALREADY_EXIST)this.notificationModelOld.updateFriendAddApplicationStatus(t,1,this.core.account),this.handleAddFriend(t);else{if(u>=500&&u<=599&&509!==u)return;this.notificationModelOld.updateFriendAddApplicationStatus(t,3,this.core.account)}}},i.handleRejectFriendApply=function handleRejectFriendApply(t,i){if(!this.config.enableServerV2FriendAddApplication){var u=i?null==i?void 0:i.code:200;if(!(u>=19e4||u===zl.V2NIM_ERROR_CODE_FRIEND_OPERATION_RATE_LIMIT))if(200===u)this.emit("onFriendAddRejected",t),this.notificationModelOld.updateFriendAddApplicationStatus(t.applicantAccountId,2,this.core.account);else if(u===zl.V2NIM_ERROR_CODE_FRIEND_ALREADY_EXIST)this.notificationModelOld.updateFriendAddApplicationStatus(t.applicantAccountId,1,this.core.account);else{if(u>=500&&u<=599&&509!==u)return;this.notificationModelOld.updateFriendAddApplicationStatus(t.applicantAccountId,3,this.core.account)}}},i.incrementSyncFriend=function incrementSyncFriend(){return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){var t,i,u,m,h=this;return ud.wrap((function _callee18$(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.core.sendCmd("v2IncFriendInfo",{timetag:this.model.getFriendTimetag()});case 2:t=v.sent,i=t.content,u=i.friends,m=i.timetag,this.model.setFriendTimetag(m),forEach$1(u).call(u,(function(t){h.model.upsertFriend(t.accountId,t)}));case 6:case"end":return v.stop()}}),_callee18,this)})))},i.computedFields=function computedFields(t){var i=this;return map$6(t).call(t,(function(t){return i.computedField(t)}))},i.computedField=function computedField(t){var i,u,m=null===(u=null===(i=this.core.V2NIMUserService)||void 0===i?void 0:i.model)||void 0===u?void 0:u.getUser(t.accountId);return m?Dt({},t,{userProfile:m}):t},V2NIMFriendServiceImpl}(hp),ey={muteMode:{type:"enum",values:[2,0,1]}},ty={accountId:{type:"string",required:!0,allowEmpty:!1},muteMode:{type:"enum",required:!0,values:[2,0,1]}},ry={type:"object",required:!1,rules:{certificateName:{type:"string",required:!0,allowEmpty:!1},appId:{type:"string",required:!1,allowEmpty:!1},appKey:{type:"string",required:!1,allowEmpty:!1},secret:{type:"string",required:!1,allowEmpty:!1}}},ny={config:{type:"object",required:!0,rules:{apns:ry,hwPush:ry,miPush:ry,vivoPush:ry,oppoPush:ry,honorPush:ry,fcmPush:ry,mzPush:ry}}},ay="V2NIMSettingService",iy={"34_1":"v2SetDeviceToken","34_2":"v2SetAppBackground","34_15":"v2SetPushMobileOnDesktopOnline","3_115":"v2SettingMutilSyncDonnop","4_13":"v2SettingSyncDonnop"},oy={need:{id:1,converter:function converter(t){return t?2:1},retConverter:function retConverter(t){return"2"===t}}},sy={v2SetDeviceToken:{sid:34,cid:1,service:ay,params:[{type:"String",name:"certificateName"},{type:"String",name:"pushDeviceToken"},{type:"Int",name:"pushkit"}]},v2SetAppBackground:{sid:34,cid:2,service:ay,params:[{type:"Bool",name:"isBackground"},{type:"Int",name:"badge"}]},v2SetPushMobileOnDesktopOnline:{sid:34,cid:15,service:ay,params:[{type:"Property",name:"tag",reflectMapper:oy}]},v2SettingMutilSyncDonnop:{sid:3,cid:115,service:ay,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(oy)},{type:"Long",name:"timetag"}]},v2SettingSyncDonnop:{sid:4,cid:13,service:ay,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(oy)},{type:"Long",name:"timetag"}]}},cy=function(){function V2NIMSettingHandlerImpl(t,i){this.core=t,this.service=i}var t=V2NIMSettingHandlerImpl.prototype;return t.v2SettingMutilSyncDonnopHandler=function v2SettingMutilSyncDonnopHandler(t){var i=t.content.data.need;this.service.needToPushMobileOnDesktopOnline=i,this.service.emit("onPushMobileOnDesktopOnline",i)},t.v2SettingSyncDonnopHandler=function v2SettingSyncDonnopHandler(t){var i=t.content.data.need;this.service.needToPushMobileOnDesktopOnline=i,this.service.emit("onPushMobileOnDesktopOnline",i)},V2NIMSettingHandlerImpl}(),ly=ly||function(t){var i;"undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),void 0!==go&&go.crypto&&(i=go.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&"undefined"!=typeof global&&global.crypto&&(i=global.crypto);var u=function cryptoSecureRandomInt(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},m=ft||function(){function F(){}return function(t){var i;return F.prototype=t,i=new F,F.prototype=null,i}}(),h={},v=h.lib={},M=v.Base={extend:function extend(t){var i=m(this);return t&&i.mixIn(t),i.hasOwnProperty("init")&&this.init!==i.init||(i.init=function(){i.$super.init.apply(this,arguments)}),i.init.prototype=i,i.$super=this,i},create:function create(){var t=this.extend();return t.init.apply(t,arguments),t},init:function init(){},mixIn:function mixIn(t){for(var i in t)t.hasOwnProperty(i)&&(this[i]=t[i]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function clone(){return this.init.prototype.extend(this)}},I=v.WordArray=M.extend({init:function init(t,i){t=this.words=t||[],this.sigBytes=null!=i?i:4*t.length},toString:function toString(t){return(t||T).stringify(this)},concat:function concat(t){var i=this.words,u=t.words,m=this.sigBytes,h=t.sigBytes;if(this.clamp(),m%4)for(var v=0;v<h;v++){var M=u[v>>>2]>>>24-v%4*8&255;i[m+v>>>2]|=M<<24-(m+v)%4*8}else for(var I=0;I<h;I+=4)i[m+I>>>2]=u[I>>>2];return this.sigBytes+=h,this},clamp:function clamp(){var i=this.words,u=this.sigBytes;i[u>>>2]&=4294967295<<32-u%4*8,i.length=t.ceil(u/4)},clone:function clone(){var t,clone=M.clone.call(this);return clone.words=slice(t=this.words).call(t,0),clone},random:function random(t){for(var i=[],m=0;m<t;m+=4)i.push(u());return new I.init(i,t)}}),S=h.enc={},T=S.Hex={stringify:function stringify(t){for(var i=t.words,u=t.sigBytes,m=[],h=0;h<u;h++){var v=i[h>>>2]>>>24-h%4*8&255;m.push((v>>>4).toString(16)),m.push((15&v).toString(16))}return m.join("")},parse:function parse(t){for(var i=t.length,u=[],m=0;m<i;m+=2)u[m>>>3]|=Gd(t.substr(m,2),16)<<24-m%8*4;return new I.init(u,i/2)}},C=S.Latin1={stringify:function stringify(t){for(var i=t.words,u=t.sigBytes,m=[],h=0;h<u;h++){var v=i[h>>>2]>>>24-h%4*8&255;m.push(String.fromCharCode(v))}return m.join("")},parse:function parse(t){for(var i=t.length,u=[],m=0;m<i;m++)u[m>>>2]|=(255&t.charCodeAt(m))<<24-m%4*8;return new I.init(u,i)}},E=S.Utf8={stringify:function stringify(t){try{return decodeURIComponent(escape(C.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function parse(t){return C.parse(unescape(encodeURIComponent(t)))}},A=v.BufferedBlockAlgorithm=M.extend({reset:function reset(){this._data=new I.init,this._nDataBytes=0},_append:function _append(t){var i;"string"==typeof t&&(t=E.parse(t)),concat(i=this._data).call(i,t),this._nDataBytes+=t.sigBytes},_process:function _process(i){var u,m=this._data,h=m.words,v=m.sigBytes,M=this.blockSize,S=v/(4*M),T=(S=i?t.ceil(S):t.max((0|S)-this._minBufferSize,0))*M,C=t.min(4*T,v);if(T){for(var E=0;E<T;E+=M)this._doProcessBlock(h,E);u=splice(h).call(h,0,T),m.sigBytes-=C}return new I.init(u,C)},clone:function clone(){var clone=M.clone.call(this);return clone._data=this._data.clone(),clone},_minBufferSize:0});v.Hasher=A.extend({cfg:M.extend(),init:function init(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function reset(){A.reset.call(this),this._doReset()},update:function update(t){return this._append(t),this._process(),this},finalize:function finalize(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function _createHelper(t){return function(i,u){return new t.init(u).finalize(i)}},_createHmacHelper:function _createHmacHelper(t){return function(i,u){return new k.HMAC.init(t,u).finalize(i)}}});var k=h.algo={};return h}(Math),dy=ly.enc.Utf8,uy=ly,py=uy.lib,my=py.Base,hy=py.WordArray,gy=uy.algo,vy=gy.MD5,fy=gy.EvpKDF=my.extend({cfg:my.extend({keySize:4,hasher:vy,iterations:1}),init:function init(t){this.cfg=this.cfg.extend(t)},compute:function compute(t,i){for(var u,m=this.cfg,h=m.hasher.create(),v=hy.create(),M=v.words,I=m.keySize,S=m.iterations;M.length<I;){u&&h.update(u),u=h.update(t).finalize(i),h.reset();for(var T=1;T<S;T++)u=h.finalize(u),h.reset();concat(v).call(v,u)}return v.sigBytes=4*I,v}});uy.EvpKDF=function(t,i,u){return fy.create(u).compute(t,i)},ly.EvpKDF;var yy=ly,My=yy.lib.WordArray;yy.enc.Base64={stringify:function stringify(t){var i=t.words,u=t.sigBytes,m=this._map;t.clamp();for(var h=[],v=0;v<u;v+=3)for(var M=(i[v>>>2]>>>24-v%4*8&255)<<16|(i[v+1>>>2]>>>24-(v+1)%4*8&255)<<8|i[v+2>>>2]>>>24-(v+2)%4*8&255,I=0;I<4&&v+.75*I<u;I++)h.push(m.charAt(M>>>6*(3-I)&63));var S=m.charAt(64);if(S)for(;h.length%4;)h.push(S);return h.join("")},parse:function parse(t){var i=t.length,u=this._map,m=this._reverseMap;if(!m){m=this._reverseMap=[];for(var h=0;h<u.length;h++)m[u.charCodeAt(h)]=h}var v=u.charAt(64);if(v){var M=indexOf(t).call(t,v);-1!==M&&(i=M)}return function parseLoop(t,i,u){for(var m=[],h=0,v=0;v<i;v++)if(v%4){var M=u[t.charCodeAt(v-1)]<<v%4*2|u[t.charCodeAt(v)]>>>6-v%4*2;m[h>>>2]|=M<<24-h%4*8,h++}return My.create(m,h)}(t,i,m)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},ly.enc.Base64,function(t){t.lib.Cipher||function(){var i=t,u=i.lib,m=u.Base,h=u.WordArray,v=u.BufferedBlockAlgorithm,M=i.enc;M.Utf8;var I=M.Base64,S=i.algo.EvpKDF,T=u.Cipher=v.extend({cfg:m.extend(),createEncryptor:function createEncryptor(t,i){return this.create(this._ENC_XFORM_MODE,t,i)},createDecryptor:function createDecryptor(t,i){return this.create(this._DEC_XFORM_MODE,t,i)},init:function init(t,i,u){this.cfg=this.cfg.extend(u),this._xformMode=t,this._key=i,this.reset()},reset:function reset(){v.reset.call(this),this._doReset()},process:function process(t){return this._append(t),this._process()},finalize:function finalize(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function selectCipherStrategy(t){return"string"==typeof t?O:N}return function(t){return{encrypt:function encrypt(i,u,m){return selectCipherStrategy(u).encrypt(t,i,u,m)},decrypt:function decrypt(i,u,m){return selectCipherStrategy(u).decrypt(t,i,u,m)}}}}()});u.StreamCipher=T.extend({_doFinalize:function _doFinalize(){return this._process(!0)},blockSize:1});var C=i.mode={},E=u.BlockCipherMode=m.extend({createEncryptor:function createEncryptor(t,i){return this.Encryptor.create(t,i)},createDecryptor:function createDecryptor(t,i){return this.Decryptor.create(t,i)},init:function init(t,i){this._cipher=t,this._iv=i}}),A=C.CBC=function(){var t=E.extend();function xorBlock(t,i,u){var m,h=this._iv;h?(m=h,this._iv=void 0):m=this._prevBlock;for(var v=0;v<u;v++)t[i+v]^=m[v]}return t.Encryptor=t.extend({processBlock:function processBlock(t,i){var u=this._cipher,m=u.blockSize;xorBlock.call(this,t,i,m),u.encryptBlock(t,i),this._prevBlock=slice(t).call(t,i,i+m)}}),t.Decryptor=t.extend({processBlock:function processBlock(t,i){var u=this._cipher,m=u.blockSize,h=slice(t).call(t,i,i+m);u.decryptBlock(t,i),xorBlock.call(this,t,i,m),this._prevBlock=h}}),t}(),k=(i.pad={}).Pkcs7={pad:function pad(t,i){for(var u=4*i,m=u-t.sigBytes%u,v=m<<24|m<<16|m<<8|m,M=[],I=0;I<m;I+=4)M.push(v);var S=h.create(M,m);concat(t).call(t,S)},unpad:function unpad(t){var i=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=i}};u.BlockCipher=T.extend({cfg:T.cfg.extend({mode:A,padding:k}),reset:function reset(){var t;T.reset.call(this);var i=this.cfg,u=i.iv,m=i.mode;this._xformMode==this._ENC_XFORM_MODE?t=m.createEncryptor:(t=m.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,u&&u.words):(this._mode=t.call(m,this,u&&u.words),this._mode.__creator=t)},_doProcessBlock:function _doProcessBlock(t,i){this._mode.processBlock(t,i)},_doFinalize:function _doFinalize(){var t,i=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(i.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),i.unpad(t)),t},blockSize:4});var R=u.CipherParams=m.extend({init:function init(t){this.mixIn(t)},toString:function toString(t){return(t||this.formatter).stringify(this)}}),w=(i.format={}).OpenSSL={stringify:function stringify(t){var i,u,m,v=t.ciphertext,M=t.salt;M?i=concat(u=concat(m=h.create([1398893684,1701076831])).call(m,M)).call(u,v):i=v;return i.toString(I)},parse:function parse(t){var i,u=I.parse(t),m=u.words;return 1398893684==m[0]&&1701076831==m[1]&&(i=h.create(slice(m).call(m,2,4)),splice(m).call(m,0,4),u.sigBytes-=16),R.create({ciphertext:u,salt:i})}},N=u.SerializableCipher=m.extend({cfg:m.extend({format:w}),encrypt:function encrypt(t,i,u,m){m=this.cfg.extend(m);var h=t.createEncryptor(u,m),v=h.finalize(i),M=h.cfg;return R.create({ciphertext:v,key:u,iv:M.iv,algorithm:t,mode:M.mode,padding:M.padding,blockSize:t.blockSize,formatter:m.format})},decrypt:function decrypt(t,i,u,m){return m=this.cfg.extend(m),i=this._parse(i,m.format),t.createDecryptor(u,m).finalize(i.ciphertext)},_parse:function _parse(t,i){return"string"==typeof t?i.parse(t,this):t}}),x=(i.kdf={}).OpenSSL={execute:function execute(t,i,u,m){var v;m||(m=h.random(8));var M=S.create({keySize:i+u}).compute(t,m),I=h.create(slice(v=M.words).call(v,i),4*u);return M.sigBytes=4*i,R.create({key:M,iv:I,salt:m})}},O=u.PasswordBasedCipher=N.extend({cfg:N.cfg.extend({kdf:x}),encrypt:function encrypt(t,i,u,m){var h=(m=this.cfg.extend(m)).kdf.execute(u,t.keySize,t.ivSize);m.iv=h.iv;var v=N.encrypt.call(this,t,i,h.key,m);return v.mixIn(h),v},decrypt:function decrypt(t,i,u,m){m=this.cfg.extend(m),i=this._parse(i,m.format);var h=m.kdf.execute(u,t.keySize,t.ivSize,i.salt);return m.iv=h.iv,N.decrypt.call(this,t,i,h.key,m)}})}()}(ly);var Iy=ly,_y=Iy.lib.StreamCipher,Sy=Iy.algo,Ty=Sy.RC4=_y.extend({_doReset:function _doReset(){for(var t=this._key,i=t.words,u=t.sigBytes,m=this._S=[],h=0;h<256;h++)m[h]=h;h=0;for(var v=0;h<256;h++){var M=h%u,I=i[M>>>2]>>>24-M%4*8&255;v=(v+m[h]+I)%256;var S=m[h];m[h]=m[v],m[v]=S}this._i=this._j=0},_doProcessBlock:function _doProcessBlock(t,i){t[i]^=generateKeystreamWord.call(this)},keySize:8,ivSize:0});function generateKeystreamWord(){for(var t=this._S,i=this._i,u=this._j,m=0,h=0;h<4;h++){u=(u+t[i=(i+1)%256])%256;var v=t[i];t[i]=t[u],t[u]=v,m|=t[(t[i]+t[u])%256]<<24-8*h}return this._i=i,this._j=u,m}Iy.RC4=_y._createHelper(Ty);var Cy=Sy.RC4Drop=Ty.extend({cfg:Ty.cfg.extend({drop:192}),_doReset:function _doReset(){Ty._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)generateKeystreamWord.call(this)}});Iy.RC4Drop=_y._createHelper(Cy);var by=ly.RC4,Ey=function(){function V2NIMSettingPushImpl(t,i){var u=this;this.offlinePushPlugin=void 0,this.offlinePushConfig=void 0,this.authConfig=void 0,this.aosPushInfo=void 0,this.appBackgroundOptions={badge:0,isBackground:!1},this.setTokenAndBackgroundStateAfterLogin=function(t){u.aosPushInfo=t,u.logger.log("OfflinePushService: setToken, deviceClientId:",null==t?void 0:t.clientId),u.offlinePushPlugin&&(u.logger.log("OfflinePushService: setToken plugin is provided"),u.logger.log("OfflinePushService: setToken pushType is: ",t&&t.pushType),u.regToken(),u.core.sendCmd("v2SetAppBackground",{isBackground:u.appBackgroundOptions.isBackground,badge:u.appBackgroundOptions.badge||0}))},this.core=t,this.service=i,this.logger=t.logger}var t=V2NIMSettingPushImpl.prototype;return t.getRNDeviceInfo=function getRNDeviceInfo(){var t,i=this;return this.logger.log("OfflinePushService:getDeviceInfo start"),null===(t=this.offlinePushPlugin)||void 0===t||t.init(Un(this.authConfig),(function(t,u,m){if(i.logger.log("OfflinePushService:: type: "+t+", tokenName: "+u+", token: "+m),m){var h="",v=pd.getSystemInfo()||{},M=v.os?v.os.toLowerCase():"";i.aosPushInfo&&i.aosPushInfo.pushType?h=i.aosPushInfo.pushType:"ios"===M?h="":"android"===M&&(h="8"),i.pushTokenToServer(h,m)}else i.logger.warn("OfflinePushService:: token is empty. Please check your parameters")})),new zi((function(t,u){var m;null===(m=i.offlinePushPlugin)||void 0===m||m.getDeviceInfo((function(m){try{i.logger.log("OfflinePushService:getDeviceInfo result "+(m?Un(m):"")),t(JSON.parse(m))}catch(t){u(new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"OfflinePushService:getDeviceInfo error"}}))}})),mo((function(){u(new Yl({code:zl.V2NIM_ERROR_CODE_INTERNAL,detail:{reason:"OfflinePushService:getDeviceInfo timeout"}}))}),2e3)}))},t.pushTokenToServer=function pushTokenToServer(t,i){var u,m,h,v,M,I,S,T,C="",E=this.offlinePushConfig;switch(t){case"5":C=null===(u=null==E?void 0:E.miPush)||void 0===u?void 0:u.certificateName;break;case"6":C=null===(m=null==E?void 0:E.hwPush)||void 0===m?void 0:m.certificateName;break;case"7":C=null===(h=null==E?void 0:E.mzPush)||void 0===h?void 0:h.certificateName;break;case"8":C=null===(v=null==E?void 0:E.fcmPush)||void 0===v?void 0:v.certificateName;break;case"9":C=null===(M=null==E?void 0:E.vivoPush)||void 0===M?void 0:M.certificateName;break;case"10":C=null===(I=null==E?void 0:E.oppoPush)||void 0===I?void 0:I.certificateName;break;case"11":C=null===(S=null==E?void 0:E.honorPush)||void 0===S?void 0:S.certificateName;break;default:C=null===(T=null==E?void 0:E.apns)||void 0===T?void 0:T.certificateName}if(""===C||void 0===C)this.logger.warn("OfflinePushService:: certificate name is empty for push type: ",t);else try{if("UNIAPP"===pd.platform){var A=dy.parse("557d1e3cafa43e2589a588270c53d56f"),k=dy.stringify(by.decrypt(i,A));this.logger.log("OfflinePushService:: token",k),this.core.sendCmd("v2SetDeviceToken",{certificateName:C,pushDeviceToken:k,pushkit:0})}else this.core.sendCmd("v2SetDeviceToken",{certificateName:C,pushDeviceToken:i,pushkit:0})}catch(t){return this.logger.log("OfflinePushService:: decrypt error",t),void this.logger.warn("OfflinePushService:: token before decrypt",i)}},t.regToken=function regToken(){var t=this,i=pd.getSystemInfo()||{},u=i.os?i.os.toLowerCase():"";if(this.logger.log("OfflinePushService: os",u),"ios"===u||"android"===u)if(!this.offlinePushPlugin||"UNIAPP"===pd.platform&&"function"!=typeof this.offlinePushPlugin.getDeviceToken||"React Native"===pd.platform&&"android"===u&&"function"!=typeof this.offlinePushPlugin.init||"React Native"===pd.platform&&"ios"===u&&"function"!=typeof this.offlinePushPlugin.checkPermissions)this.logger.warn("OfflinePushService: plugin is not correct, please check your plugin according to Yunxin Official Documentation");else{var m;if("React Native"===pd.platform&&pd.envPayload.AppState)pd.envPayload.AppState.addEventListener("change",bind$1(m=this.handleRNAppStateChange).call(m,this));var h="";this.aosPushInfo&&this.aosPushInfo.pushType?h=this.aosPushInfo.pushType:"ios"===u?h="":"android"===u&&(h="8"),this.logger.log("OfflinePushService:: prepare to get device token. suggestPushType: "+h),this.logger.log("OfflinePushService push config",Un(this.authConfig,null,2),"platform",pd.platform),"UNIAPP"===pd.platform?this.offlinePushPlugin.getDeviceToken({suggestPushType:h,config:this.authConfig},(function(i){i?(t.logger.log("OfflinePushService:: token is :"+i),t.pushTokenToServer(h,i)):t.logger.warn("OfflinePushService:: token is empty. Please check your parameters")})):"React Native"===pd.platform&&"android"===u?(this.logger.log("OfflinePushService:: onLogin",this.core.account,typeof h,h),this.offlinePushPlugin.onLogin(this.core.account,Gd(h),!1,"")):"React Native"===pd.platform&&"ios"===u?this.offlinePushPlugin.checkPermissions((function(){t.logger.log("OfflinePushService addEventListener requestPermissions");try{t.offlinePushPlugin.requestPermissions()}catch(i){t.logger.log("OfflinePushService:: requestPermissions error",i)}t.offlinePushPlugin.addEventListener("register",(function(i){t.logger.log("OfflinePushService:: ios token: "+i),t.pushTokenToServer(h,i)})),t.offlinePushPlugin.addEventListener("registrationError",(function(i){t.logger.log("OfflinePushService:: ios registerError",i)}))})):this.logger.error("OfflinePushService:: platform is not supported. Please check your parameters. Platform: "+pd.platform+". os: "+u)}else this.logger.warn("OfflinePushService: only Android or IOS support offline push")},t.handleRNAppStateChange=function handleRNAppStateChange(t){this.logger.log("push::handleAppStateChange: pushConfig ios/aos; state: "+t),this.appBackgroundOptions={badge:this.core.V2NIMLocalConversationService.getTotalUnreadCount(),isBackground:"background"===t||"inactive"===t},this.setAppBackground(this.appBackgroundOptions.isBackground,this.appBackgroundOptions.badge)},t.setOfflinePushConfig=function setOfflinePushConfig(t,i){var u,m,h,v,M,I,S,T,C,E,A,k,R,w,N,x,O,P,L,V,U,D,B,q,G,H,j,$,z,W,K,Y,Q,J,X,Z;this.logger.log("setOfflinePushConfig","plugin",t,"config",i),this.offlinePushPlugin=t,this.offlinePushConfig=i,this.authConfig={xmAppId:null===(m=null===(u=this.offlinePushConfig)||void 0===u?void 0:u.miPush)||void 0===m?void 0:m.appId,xmAppKey:null===(v=null===(h=this.offlinePushConfig)||void 0===h?void 0:h.miPush)||void 0===v?void 0:v.appKey,xmCertificateName:null===(I=null===(M=this.offlinePushConfig)||void 0===M?void 0:M.miPush)||void 0===I?void 0:I.certificateName,hwAppId:null===(T=null===(S=this.offlinePushConfig)||void 0===S?void 0:S.hwPush)||void 0===T?void 0:T.appId,hwCertificateName:null===(E=null===(C=this.offlinePushConfig)||void 0===C?void 0:C.hwPush)||void 0===E?void 0:E.certificateName,oppoAppId:null===(k=null===(A=this.offlinePushConfig)||void 0===A?void 0:A.oppoPush)||void 0===k?void 0:k.appId,oppoAppKey:null===(w=null===(R=this.offlinePushConfig)||void 0===R?void 0:R.oppoPush)||void 0===w?void 0:w.appKey,oppoAppSecret:null===(x=null===(N=this.offlinePushConfig)||void 0===N?void 0:N.oppoPush)||void 0===x?void 0:x.secret,oppoCertificateName:null===(P=null===(O=this.offlinePushConfig)||void 0===O?void 0:O.oppoPush)||void 0===P?void 0:P.certificateName,vivoAppId:null===(V=null===(L=this.offlinePushConfig)||void 0===L?void 0:L.vivoPush)||void 0===V?void 0:V.appId,vivoAppKey:null===(D=null===(U=this.offlinePushConfig)||void 0===U?void 0:U.vivoPush)||void 0===D?void 0:D.appKey,vivoCertificateName:null===(q=null===(B=this.offlinePushConfig)||void 0===B?void 0:B.vivoPush)||void 0===q?void 0:q.certificateName,fcmCertificateName:null===(H=null===(G=this.offlinePushConfig)||void 0===G?void 0:G.fcmPush)||void 0===H?void 0:H.certificateName,mzAppId:null===($=null===(j=this.offlinePushConfig)||void 0===j?void 0:j.mzPush)||void 0===$?void 0:$.appId,mzAppKey:null===(W=null===(z=this.offlinePushConfig)||void 0===z?void 0:z.mzPush)||void 0===W?void 0:W.appKey,mzCertificateName:null===(Y=null===(K=this.offlinePushConfig)||void 0===K?void 0:K.mzPush)||void 0===Y?void 0:Y.certificateName,apnsCertificateName:null===(J=null===(Q=this.offlinePushConfig)||void 0===Q?void 0:Q.apns)||void 0===J?void 0:J.certificateName,honorCertificateName:null===(Z=null===(X=this.offlinePushConfig)||void 0===X?void 0:X.honorPush)||void 0===Z?void 0:Z.certificateName}},t.setAppBackground=function setAppBackground(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return this.appBackgroundOptions={isBackground:t,badge:i||0},u.next=3,this.core.sendCmd("v2SetAppBackground",{isBackground:t,badge:i||0});case 3:case"end":return u.stop()}}),_callee,this)})))},V2NIMSettingPushImpl}(),Ay=function(){function V2NIMSettingMuteImpl(t,i){var u=this;this.p2pMessageMuteModeChangeHandler=function(t,i){u.service.emit("onP2PMessageMuteModeChanged",t,i),u.hasUserService&&u.core.V2NIMUserService.model.setAccountMuteMode(t,i);var m=u.core.V2NIMConversationIdUtil.p2pConversationId(t),h=1===i;u.core.eventBus.emit("V2NIMSettingService/setMute",m,h)},this.core=t,this.service=i}var t=V2NIMSettingMuteImpl.prototype;return t.getConversationMuteStatus=function getConversationMuteStatus(t){if("string"!=typeof t)return!1;var i=this.core.V2NIMConversationIdUtil.parseConversationType(t),u=this.core.V2NIMConversationIdUtil.parseConversationTargetId(t);return 3===i?0!==this.getTeamMessageMuteMode(u,2):2===i?0!==this.getTeamMessageMuteMode(u,1):!(1!==i||!this.hasUserService)&&!!this.core.V2NIMUserService.model.muteList.has(u)},t.setTeamMessageMuteMode=function setTeamMessageMuteMode(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var m,h,v,M;return ud.wrap((function _callee$(I){for(;;)switch(I.prev=I.next){case 0:return m=2===i?"v2SuperTeamUpdateSelfMemberInfo":"v2TeamUpdateSelfMemberInfo",h={teamId:t,teamType:i,accountId:this.core.account,bits:u},I.next=4,this.core.sendCmd(m,{teamMember:h});case 4:this.core.V2NIMTeamService.memberModel.upsert(h),this.service.emit("onTeamMessageMuteModeChanged",t,i,u),v=1===i?this.core.V2NIMConversationIdUtil.teamConversationId(t):this.core.V2NIMConversationIdUtil.superTeamConversationId(t),M=this.getConversationMuteStatus(v),this.core.eventBus.emit("V2NIMSettingService/setMute",v,M);case 9:case"end":return I.stop()}}),_callee,this)})))},t.getTeamMessageMuteMode=function getTeamMessageMuteMode(t,i){var u;return"string"!=typeof t||"number"!=typeof i?0:this.hasTeamService?3&((null===(u=this.core.V2NIMTeamService.memberModel.getById(t,i,this.core.account))||void 0===u?void 0:u.bits)||0):0},t.getAllTeamMessageMuteMode=function getAllTeamMessageMuteMode(t){var i=this;if(!this.hasTeamService)return zi.resolve({});var u=this.core.V2NIMTeamService.memberModel.chooseList(t),m={};return forEach$1(u).call(u,(function(t){if(t.accountId===i.core.account){var u=t.bits||0;m[t.teamId]=3&u}})),zi.resolve(m)},t.setP2PMessageMuteMode=function setP2PMessageMuteMode(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.core.sendCmd("v2SetP2PMessageMuteMode",{accountId:t,muteMode:1===i});case 2:this.p2pMessageMuteModeChangeHandler(t,i);case 3:case"end":return u.stop()}}),_callee2,this)})))},t.getP2PMessageMuteMode=function getP2PMessageMuteMode(t){return this.hasUserService&&this.core.V2NIMUserService.model.muteList.has(t)?1:0},t.getP2PMessageMuteList=function getP2PMessageMuteList(){return this.hasUserService?zi.resolve(id(this.core.V2NIMUserService.model.muteList)):zi.resolve([])},Qe(V2NIMSettingMuteImpl,[{key:"hasUserService",get:function get(){var t;return!!(null===(t=this.core.V2NIMUserService)||void 0===t?void 0:t.name)}},{key:"hasTeamService",get:function get(){var t;return!!(null===(t=this.core.V2NIMTeamService)||void 0===t?void 0:t.name)}}]),V2NIMSettingMuteImpl}(),ky=function(){function V2NIMSettingEventImpl(t,i){this.core=t,this.service=i,this.push=i.push,this.mute=i.mute}return V2NIMSettingEventImpl.prototype.setListener=function setListener(){var t,i,u,m=this;this.core.eventBus.on("V2NIMSettingService/updateBits",(function(t,i,u){m.service.emit("onTeamMessageMuteModeChanged",t,i,u)})),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",bind$1(t=this.push.setTokenAndBackgroundStateAfterLogin).call(t,this.push)),this.core.eventBus.on("v2NIMUserService/updateMuteList",bind$1(i=this.mute.p2pMessageMuteModeChangeHandler).call(i,this.mute)),this.core.eventBus.on("forwardReceive/v2NIMSettingService/setP2PMessageMuteMode",bind$1(u=this.mute.p2pMessageMuteModeChangeHandler).call(u,this.mute))},V2NIMSettingEventImpl}(),Ry=function(t){function V2NIMSettingServiceImpl(i){var u;return(u=t.call(this,"V2NIMSettingService",i)||this).needToPushMobileOnDesktopOnline=!0,u.core._registerDep(mm,"V2NIMConversationIdUtil"),u.push=new Ey(i,Je(u)),u.mute=new Ay(i,Je(u)),u.event=new ky(i,Je(u)),u.handler=new cy(i,Je(u)),"v2"!==u.core.options.apiVersion?Je(u):(u.setListener(),registerParser({cmdMap:iy,cmdConfig:sy}),u)}Nt(V2NIMSettingServiceImpl,t);var i=V2NIMSettingServiceImpl.prototype;return i.setListener=function setListener(){this.event.setListener()},i.emit=function emit(i){for(var u,m,h,v,M=this.name+"::emit "+i.toString(),I=arguments.length,S=new Array(I>1?I-1:0),T=1;T<I;T++)S[T-1]=arguments[T];return(u=this.logger).log.apply(u,concat(m=[""+M]).call(m,S)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,S))},i.getConversationMuteStatus=function getConversationMuteStatus(t){return this.mute.getConversationMuteStatus(t)},i.setTeamMessageMuteMode=function setTeamMessageMuteMode(t,i,u){if(!this.hasTeamService)throw new Yl({code:zl.V2NIM_ERROR_CODE_MISUSE,detail:{reason:"setTeamMessageMuteMode: no team service"}});return this.checkV2(),validate(Wv,{teamId:t},"",!0),validate(Yv,{teamType:i},"",!0),validate(ey,{muteMode:u},"",!0),this.mute.setTeamMessageMuteMode(t,i,u)},i.getTeamMessageMuteMode=function getTeamMessageMuteMode(t,i){return this.mute.getTeamMessageMuteMode(t,i)},i.getAllTeamMessageMuteMode=function getAllTeamMessageMuteMode(t){return this.checkV2(),this.checkLogin(),validate(Yv,{teamType:t},"",!0),this.mute.getAllTeamMessageMuteMode(t)},i.setP2PMessageMuteMode=function setP2PMessageMuteMode(t,i){if(this.checkV2(),validate(ty,{accountId:t,muteMode:i},"",!0),t===this.core.account)throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"can not set mute mode for self"}});return this.mute.setP2PMessageMuteMode(t,i)},i.getP2PMessageMuteMode=function getP2PMessageMuteMode(t){return validate({accountId:{type:"string",required:!0,allowEmpty:!1}},{accountId:t},"",!0),this.mute.getP2PMessageMuteMode(t)},i.getP2PMessageMuteList=function getP2PMessageMuteList(){return this.mute.getP2PMessageMuteList()},i.setAppBackground=function setAppBackground(t,i){return this.checkV2(),validate({isBackground:{type:"boolean"},badge:{type:"number",required:!1}},{isBackground:t,badge:i},"",!0),this.push.setAppBackground(t,i)},i.setOfflinePushConfig=function setOfflinePushConfig(t,i){validate(ny,{config:i},"",!0),this.push.setOfflinePushConfig(t,i)},i.setPushMobileOnDesktopOnline=function setPushMobileOnDesktopOnline(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),validate({need:{type:"boolean",required:!1}},{need:t},"",!0),t=void 0===t||t,i.next=5,this.core.sendCmd("v2SetPushMobileOnDesktopOnline",{tag:{need:t}});case 5:this.needToPushMobileOnDesktopOnline=t,this.emit("onPushMobileOnDesktopOnline",t);case 7:case"end":return i.stop()}}),_callee,this)})))},i.getPushMobileOnDesktopOnline=function getPushMobileOnDesktopOnline(){return this.checkLogin(),zi.resolve(this.needToPushMobileOnDesktopOnline)},Qe(V2NIMSettingServiceImpl,[{key:"hasUserService",get:function get(){var t;return!!(null===(t=this.core.V2NIMUserService)||void 0===t?void 0:t.name)}},{key:"hasTeamService",get:function get(){var t;return!!(null===(t=this.core.V2NIMTeamService)||void 0===t?void 0:t.name)}}]),V2NIMSettingServiceImpl}(hp);_export({target:"Number",stat:!0},{isNaN:function isNaN(t){return t!=t}});var wy=$.Number.isNaN;function invert(t){t=t||{};var i={};for(var u in t)i[t[u]]=u;return i}var Ny,xy=invert({none:0,normal:1,all:3}),Oy={normal:0,advanced:1},Py=invert(Oy),Ly=invert({normal:0,owner:1,manager:2}),Vy={noVerify:0,needVerify:1,rejectAll:2},Uy=invert(Vy),Dy={needVerify:0,noVerify:1},By=invert(Dy),qy={manager:0,all:1},Fy=invert(qy),Gy={manager:0,all:1},Hy=invert(Gy),jy={manager:0,all:1},$y=invert(jy);function formatTeam(t){var i,u=["teamId"],m=["level","memberNum","memberUpdateTime","createTime","updateTime"],h=["valid","validToCurrentUser","mute"],v={type:Py,muteType:xy,joinMode:Uy,beInviteMode:By,inviteMode:Fy,updateTeamMode:Hy,updateExtMode:$y};t.bits;var M=__rest(t,["bits"]);return forEach$1(u).call(u,(function(t){M[t]&&(M[t]=M[t].toString())})),forEach$1(m).call(m,(function(t){void 0!==M[t]&&(M[t]=Gd(M[t]))})),forEach$1(h).call(h,(function(t){void 0!==M[t]&&(M[t]=1===Gd(M[t]))})),forEach$1(i=Ht(v)).call(i,(function(t){void 0!==M[t]&&(M[t]=v[t][M[t]]||M[t])})),M}function formatTeams(t){return t&&t.length>0?map$6(t).call(t,(function(t){return formatTeam(t)})):[]}function generateTeam(t){var i,u=Dt({},t),m=["avatar","name","intro","announcement","ext"],h={type:Oy,joinMode:Vy,beInviteMode:Dy,inviteMode:qy,updateTeamMode:Gy,updateExtMode:jy};return forEach$1(m).call(m,(function(t){void 0!==u[t]&&(u[t]=u[t].toString())})),forEach$1(i=Ht(h)).call(i,(function(t){void 0!==u[t]&&(u[t]=h[t][u[t]])})),u}function generatorTeamMemberForCmd(t){var i=["teamId","ext","account","nickInTeam"],u={};return void 0!==t.bitConfigMask&&(u.bits=Gd(t.bitConfigMask)),forEach$1(i).call(i,(function(i){t[i]&&(u[i]=t[i].toString())})),Object.prototype.hasOwnProperty.call(t,"nickInTeam")&&(u.nickInTeam=t.nickInTeam),u}function formatTeamMember(t){var i,u=["teamId"],m=["joinTime","updateTime","bitConfigMask"],h=["active","valid","mute"],v={type:Ly},M=t.bits,I=__rest(t,["bits"]);return void 0!==M&&(I.muteTeam=1===Gd(M),I.bitConfigMask=M),I.id=I.teamId+"-"+I.account,forEach$1(u).call(u,(function(t){I[t]&&(I[t]=I[t].toString())})),forEach$1(m).call(m,(function(t){void 0!==I[t]&&(I[t]=Gd(I[t]))})),forEach$1(h).call(h,(function(t){void 0!==I[t]&&(I[t]=1===Gd(I[t]))})),forEach$1(i=Ht(v)).call(i,(function(t){void 0!==I[t]&&(I[t]=v[t][I[t]]||I[t])})),I}function formatTeamMembers(t){return t&&t.length>0?map$6(t).call(t,(function(t){return formatTeamMember(t)})):[]}function generatorMemberByTeam(t,i,u){return void 0===u&&(u="normal"),{id:t.teamId+"-"+i,teamId:t.teamId,account:i,type:u,nickInTeam:"",muteTeam:!1,mute:!1,joinTime:t.memberUpdateTime,updateTime:t.memberUpdateTime,active:!0,valid:!0}}function generatorMembersByTeam(t,i,u){return void 0===u&&(u="normal"),i&&i.length>0?map$6(i).call(i,(function(i){return generatorMemberByTeam(t,i,u)})):[]}function formatUser(t){var i=Dt({},t);return i.createTime&&(i.createTime=+i.createTime),i.updateTime&&(i.updateTime=+i.updateTime),i.gender&&(i.gender=Ny[+i.gender]),i}!function(t){t[t.unknown=0]="unknown",t[t.male=1]="male",t[t.female=2]="female"}(Ny||(Ny={}));var zy={"8_1":"createTeam","8_5":"addTeamMembers","8_6":"removeTeamMembers","8_7":"updateTeamInfo","8_8":"leaveTeam","8_9":"getTeamInfo","8_10":"getTeams","8_11":"getTeamMembers","8_12":"dismissTeam","8_13":"applyTeam","8_14":"passTeamApply","8_15":"rejectTeamApply","8_16":"addTeamManagers","8_17":"removeTeamManagers","8_18":"transferTeam","8_19":"updateMyMemberInfo","8_20":"updateNickInTeam","8_21":"acceptTeamInvite","8_22":"rejectTeamInvite","8_25":"muteTeamMember","8_27":"getMutedTeamMembers","8_28":"sendTeamMsgReceipt","8_29":"getTeamMsgReads","8_30":"getTeamMsgReadAccounts","8_31":"notifyTeamMsgReceipts","8_32":"muteTeam","8_33":"getTeamMemberInvitorAccid","8_34":"getTeamsById","8_101":"syncCreateTeam","8_109":"syncTeams","8_119":"syncUpdateTeamMember","8_126":"syncMyTeamMembers"},Wy={team:{teamId:1,name:3,type:4,owner:5,level:6,selfCustom:7,valid:8,memberNum:9,memberUpdateTime:10,createTime:11,updateTime:12,validToCurrentUser:13,intro:14,announcement:15,joinMode:16,bits:17,ext:18,serverExt:19,avatar:20,beInviteMode:21,inviteMode:22,updateTeamMode:23,updateExtMode:24,mute:100,muteType:101},teamMsgReceiptTag:{teamId:0,idServer:1,read:100,unread:101,idClient:102,account:103},teamMember:{teamId:1,account:3,type:4,nickInTeam:5,bits:7,active:8,valid:9,joinTime:10,updateTime:11,ext:12,mute:13,invitorAccid:14}},Ky=invertSerializeMap(Wy),Yy={getTeamInfo:{sid:8,cid:9,service:"team",params:[{type:"Long",name:"teamId"}],response:[{type:"Property",name:"team",reflectMapper:Ky.team}]},getTeams:{sid:8,cid:10,service:"team",params:[{type:"Long",name:"timetag"}],response:[{type:"PropertyArray",name:"teams",reflectMapper:Ky.team},{type:"Long",name:"timetag"}],ignoreErrCodes:[803]},createTeam:{sid:8,cid:1,service:"team",params:[{type:"Property",name:"team",reflectMapper:Wy.team},{type:"StrArray",name:"accounts"},{type:"String",name:"ps"}],response:[{type:"Property",name:"team",reflectMapper:Ky.team},{type:"StrArray",name:"abortedAccidList"}]},sendTeamMsgReceipt:{sid:8,cid:28,service:"team",params:[{type:"PropertyArray",name:"teamMsgReceipts",reflectMapper:Wy.teamMsgReceiptTag}],response:[{type:"PropertyArray",name:"teamMsgReceipts",reflectMapper:Ky.teamMsgReceiptTag}]},getTeamMsgReads:{sid:8,cid:29,service:"team",params:[{type:"PropertyArray",name:"teamMsgReceipts",reflectMapper:Wy.teamMsgReceiptTag}],response:[{type:"PropertyArray",name:"teamMsgReceipts",reflectMapper:Ky.teamMsgReceiptTag}]},getTeamMsgReadAccounts:{sid:8,cid:30,service:"team",params:[{type:"Property",name:"teamMsgReceiptTag",reflectMapper:Wy.teamMsgReceiptTag}],response:[{type:"Property",name:"teamMsgReceipt",reflectMapper:Ky.teamMsgReceiptTag},{type:"StrArray",name:"readAccounts"},{type:"StrArray",name:"unreadAccounts"}]},notifyTeamMsgReceipts:{sid:8,cid:31,service:"team",response:[{type:"PropertyArray",name:"teamMsgReceipts",reflectMapper:Ky.teamMsgReceiptTag}]},dismissTeam:{sid:8,cid:12,service:"team",params:[{type:"Long",name:"teamId"}]},leaveTeam:{sid:8,cid:8,service:"team",params:[{type:"Long",name:"teamId"}]},transferTeam:{sid:8,cid:18,service:"team",params:[{type:"Long",name:"teamId"},{type:"String",name:"account"},{type:"Bool",name:"leave"}]},updateTeamInfo:{sid:8,cid:7,service:"team",params:[{type:"Property",name:"team",reflectMapper:Wy.team}],response:[{type:"Long",name:"id"},{type:"Long",name:"time"}]},getTeamsById:{sid:8,cid:34,service:"team",params:[{type:"LongArray",name:"teamIds"}],response:[{type:"PropertyArray",name:"teams",reflectMapper:Ky.team},{type:"LongArray",name:"tids"}],ignoreErrCodes:[816]},getTeamMembers:{sid:8,cid:11,service:"team",params:[{type:"Long",name:"teamId"},{type:"Long",name:"timetag"}],response:[{type:"Long",name:"teamId"},{type:"PropertyArray",name:"teamMembers",reflectMapper:Ky.teamMember},{type:"Long",name:"timetag"}]},getMutedTeamMembers:{sid:8,cid:27,service:"team",params:[{type:"Long",name:"teamId"}],response:[{type:"Long",name:"teamId"},{type:"PropertyArray",name:"teamMembers",reflectMapper:Ky.teamMember}]},addTeamMembers:{sid:8,cid:5,service:"team",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"},{type:"String",name:"ps"},{type:"String",name:"attach"}],response:[{type:"Long",name:"time"},{type:"StrArray",name:"abortedAccidList"}]},removeTeamMembers:{sid:8,cid:6,service:"team",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},applyTeam:{sid:8,cid:13,service:"team",params:[{type:"Long",name:"teamId"},{type:"String",name:"ps"}],response:[{type:"Property",name:"team",reflectMapper:Ky.team}]},addTeamManagers:{sid:8,cid:16,service:"team",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},removeTeamManagers:{sid:8,cid:17,service:"team",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},updateMyMemberInfo:{sid:8,cid:19,service:"team",params:[{type:"Property",name:"teamMember",reflectMapper:Wy.teamMember}]},updateNickInTeam:{sid:8,cid:20,service:"team",params:[{type:"Property",name:"teamMember",reflectMapper:Wy.teamMember}]},muteTeamMember:{sid:8,cid:25,service:"team",params:[{type:"Long",name:"teamId"},{type:"String",name:"account"},{type:"Int",name:"mute"}]},getTeamMemberInvitorAccid:{sid:8,cid:33,service:"team",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}],response:[{type:"StrStrMap",name:"accountsMap"}]},muteTeam:{sid:8,cid:32,service:"team",params:[{type:"Long",name:"teamId"},{type:"Int",name:"mute"}]},passTeamApply:{sid:8,cid:14,service:"team",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}]},rejectTeamApply:{sid:8,cid:15,service:"team",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},acceptTeamInvite:{sid:8,cid:21,service:"team",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}]},rejectTeamInvite:{sid:8,cid:22,service:"team",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},syncTeams:{sid:8,cid:109,service:"team",response:[{type:"Long",name:"timetag"},{type:"PropertyArray",name:"teams",reflectMapper:Ky.team}]},syncCreateTeam:{sid:8,cid:101,service:"team",response:[{type:"Property",name:"team",reflectMapper:Ky.team}]},syncUpdateTeamMember:{sid:8,cid:119,service:"team",response:[{type:"Property",name:"teamMember",reflectMapper:Ky.teamMember}]},syncMyTeamMembers:{sid:8,cid:126,ext:"sync",service:"team",response:[{type:"PropertyArray",name:"teamMembers",entity:"teamMember",reflectMapper:Ky.teamMember},{type:"Long",name:"timetag"}]}},Qy={"3_7":"getUsersNameCardFromServer","3_10":"updateMyNameCard","3_109":"syncMyNameCard","3_110":"onUpdateMyNameCard","3_3":"setBlack","3_103":"onUpdateBlackList","3_5":"setMute","3_105":"onUpdateMuteList","3_8":"syncRelations"},Jy={user:{account:1,nick:3,avatar:4,signature:5,gender:6,email:7,birth:8,tel:9,ext:10,createTime:12,updateTime:13},relationMember:{account:0,isMuted:1,isBlack:2,createTime:3,updateTime:4}},Xy=invertSerializeMap(Jy),Zy={syncMyNameCard:{sid:3,cid:109,service:"user",response:[{type:"Property",name:"user",reflectMapper:Xy.user},{type:"Long",name:"timetag"}]},setBlack:{service:"user",sid:3,cid:3,params:[{type:"String",name:"account"},{type:"Bool",name:"isAdd"}]},onUpdateBlackList:{service:"user",sid:3,cid:103,response:[{type:"String",name:"account"},{type:"Bool",name:"isAdd"}]},setMute:{service:"user",sid:3,cid:5,params:[{type:"String",name:"account"},{type:"Bool",name:"isAdd"}]},onUpdateMuteList:{service:"user",sid:3,cid:105,response:[{type:"String",name:"account"},{type:"Bool",name:"isAdd"}]},syncRelations:{service:"user",sid:3,cid:8,params:[{type:"Long",name:"timetag"}],response:[{type:"PropertyArray",name:"list",reflectMapper:Xy.relationMember},{type:"Long",name:"timetag"}]},getUsersNameCardFromServer:{service:"user",sid:3,cid:7,params:[{type:"StrArray",name:"accounts"}],response:[{type:"PropertyArray",name:"users",reflectMapper:Xy.user}]},updateMyNameCard:{service:"user",sid:3,cid:10,params:[{type:"Property",name:"user",reflectMapper:Jy.user}],response:[{type:"Long",name:"timetag"}]},onUpdateMyNameCard:{service:"user",sid:3,cid:110,response:[{type:"Property",name:"user",reflectMapper:Xy.user}]}},eM={needPush:{type:"boolean",required:!1},needPushBadge:{type:"boolean",required:!1},needPushNick:{type:"boolean",required:!1},pushContent:{type:"string",required:!1},pushPayload:{type:"string",required:!1},needForcePush:{type:"boolean",required:!1},forcePushIDsList:{type:"string",allowEmpty:!1,required:!1},forcePushContent:{type:"string",allowEmpty:!1,required:!1}},tM={function:{type:"string",required:!1},topic:{type:"string",required:!1},customContent:{type:"string",required:!1},account:{type:"string",required:!1}};function _createForOfIteratorHelperLoose$4(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$4(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$4(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$4(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$4(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var rM={subType:{type:"string"},setting:{resendFlag:{type:"boolean"},envConfig:{type:"string"},needSaveHistory:{type:"boolean"},needRoaming:{type:"boolean"},needOffline:{type:"boolean"},needSelfSync:{type:"boolean"},needRouted:{type:"boolean"},needUpdateSession:{type:"boolean"},isMuted:{type:"boolean"}},antiSpamInfo:{needAntiSpam:{type:"boolean"},antiSpamContent:{type:"string"},antiSpamBIZID:{type:"string"},clientAntispamHitting:{type:"boolean"},antiSpamUsingYidun:{type:"boolean"},yidunCallbackURL:{type:"string"},yidunAntiCheating:{type:"string"},yidunAntiSpamExtension:{type:"string"},yidunAntiSpamResult:{type:"string"}},pushInfo:eM,robotInfo:tM,teamSpecializationInfo:{needACK:{type:"boolean"},isACKSent:{type:"boolean"},ackSnapshot:{type:"number"}},threadMessageInfo:{replyMsgFromAccount:{type:"string"},replyMsgToAccount:{type:"string"},replyMsgTime:{type:"number"},replyMsgIdServer:{type:"string"},replyMsgIdClient:{type:"string"},threadMsgFromAccount:{type:"string"},threadMsgToAccount:{type:"string"},threadMsgTime:{type:"number"},threadMsgIdServer:{type:"string"},threadMsgIdClient:{type:"string"}}},nM={0:"addTeamMembers",1:"removeTeamMembers",2:"leaveTeam",3:"updateTeam",4:"dismissTeam",5:"passTeamApply",6:"transferTeam",7:"addTeamManagers",8:"removeTeamManagers",9:"acceptTeamInvite",10:"updateTeamMemberMute",101:"netcallMiss",102:"netcallBill",103:"netcallReject",401:"addSuperTeamMembers",402:"removeSuperTeamMembers",403:"leaveSuperTeam",404:"updateSuperTeam",405:"dismissSuperTeam",406:"transferSuperTeam",407:"addSuperTeamManagers",408:"removeSuperTeamManagers",409:"updateSuperTeamMembersMute",410:"passSuperTeamApply",411:"acceptSuperTeamInvite"};function getSessionId(t,i){return Wu[t.scene]+"-"+(t.to===i?t.from:t.to)}function msgFlow(t,i){return t.from===i?t.to===i?"in":"out":"in"}function formatMsg$1(t,i){var u=i.account,m=i.featureValue,h=i.statusValue,v=i.sessionAck,M=i.msgReceiptTime,I=Wu[t.scene],S=t.to===u?t.from:t.to,T=Qu.default,C=Yu.unread;Gd(t.isInBlackList)>0?(C=Yu.refused,delete t.isInBlackList):C=t.from===u?M&&M>=+t.time?Yu.receipt:Yu.sent:v&&v>=+t.time?Yu.read:Yu.unread;var E=Dt(Dt({},format(rM,t)),{scene:I,type:zu[t.type],fromClientType:Ku[t.fromClientType],flow:msgFlow(t,u),target:S,to:t.to,from:t.from,time:t.time?+t.time:void 0,userUpdateTime:t.userUpdateTime?+t.userUpdateTime:void 0,idClient:t.idClient,sessionId:I+"-"+S,status:Yu[h||C],feature:Qu[m||T]});if("string"==typeof E.attach)try{E.attach=JSON.parse(E.attach)}catch(t){}return"notification"===E.type&&(E.attach=E.attach?function formatNotificationAttach(t){var i,u={};if(u.type=nM[t.id]||t.id,!t.data)return u;var m,h={ids:"accounts",id:"account",attach:"custom",channel:"channelId",calltype:"netcallType",mute:"mute",duration:"duration",time:"time",from:"from",ext:"ext"},v=t.data;return forEach$1(i=Ht(h)).call(i,(function(t){void 0!==v[t]&&(u[h[t]]=v[t])})),v.tinfo&&(u.team=formatTeam(deserialize(v.tinfo,Ky.team))),v.uinfos&&(u.users=map$6(m=v.uinfos).call(m,(function(t){return formatUser(deserialize(t,Xy.user))}))),void 0!==v.mute&&(u.mute=1===Gd(v.mute)),u}(E.attach):{}),E}function formatMsgs$1(t,i){return t&&t.length>0?removeDupMsgsByIdClient(map$6(t).call(t,(function(t){return formatMsg$1(t,i)}))):[]}function removeDupMsgsByIdClient(t){for(var i,u,m={},h=_createForOfIteratorHelperLoose$4(t);!(u=h()).done;){var v=u.value,M=m[v.idClient];M&&M.time>v.time||(m[v.idClient]=v)}return map$6(i=Ht(m)).call(i,(function(t){return m[t]}))}function processPushInfoInMsg(t,i){void 0===i&&(i=!0);var u=Dt({},t);if(u.pushInfo&&i){for(var m in u.pushInfo)"boolean"==typeof u.pushInfo[m]?u[m]=u.pushInfo[m]?1:0:u[m]=u.pushInfo[m];delete u.pushInfo}return u.scene===Wu.team&&u.needForcePush&&(u.forcePushContent=u.forcePushContent||u.pushContent,u.forcePushIDsList=u.forcePushIDsList?u.forcePushIDsList:"#%@all@%#"),u}function generatorMsgForCmd$1(t,i,u,m){t.onSendBefore,t.onUploadStart,t.onUploadDone;var h=t.replyMsg,v=__rest(t,["onSendBefore","onUploadStart","onUploadDone","replyMsg"]),M=Dt(Dt({},formatReverse(rM,v)),{scene:Wu[t.scene],type:zu[t.type],from:i,fromClientType:16,fromDeviceId:u,fromNick:null==m?void 0:m.nick,userUpdateTime:null==m?void 0:m.updateTime,status:Yu[Yu.sending]});if(M.idClient=M.resendFlag?t.idClient:jd(),!M.idClient)throw new Xl("idClient is required to resend a message","idClient","required");return M=processPushInfoInMsg(M,!1),h&&(M.replyMsgFromAccount=h.from,M.replyMsgToAccount=h.to,M.replyMsgTime=+h.time,M.replyMsgIdServer=h.idServer,M.replyMsgIdClient=h.idClient,M.threadMsgFromAccount=h.from,M.threadMsgToAccount=h.to,M.threadMsgTime=+h.time,M.threadMsgIdServer=h.idServer,M.threadMsgIdClient=h.idClient,h.threadMessageInfo&&h.threadMessageInfo.threadMsgIdServer&&(M.threadMsgFromAccount=h.threadMessageInfo.threadMsgFromAccount,M.threadMsgToAccount=h.threadMessageInfo.threadMsgToAccount,M.threadMsgTime=h.threadMessageInfo.threadMsgTime,M.threadMsgIdServer=h.threadMessageInfo.threadMsgIdServer,M.threadMsgIdClient=h.threadMessageInfo.threadMsgIdClient)),M}function formatDeletedMsgs(t,i){return map$6(t).call(t,(function(t){var u;return u=i||(wy(Gd(t.scene))?t.scene:1===Gd(t.scene)?"p2p":"team"),{deletedTime:Gd(t.time),from:t.from,idClient:t.deletedIdClient||t.idClient,idServer:t.deletedIdServer||t.idServer,scene:u,time:Gd(t.deletedMsgCreateTime),to:t.to,ext:"string"==typeof t.ext?t.ext:null}}))}function reverse(t){for(var i=[],u=(t=t||[]).length-1;u>=0;u--)i.push(t[u]);return i}var aM,iM,oM,sM=function(){function ModuleService(t){this.core=t}return ModuleService.prototype.processBroadcastMsg=function processBroadcastMsg(t){var i=map$6(t).call(t,(function(t){return Dt(Dt({},t),{time:Gd(t.time)})}));return this.core.sendCmd("batchMarkRead",{sid:7,cid:17,ids:map$6(i).call(i,(function(t){return t.id}))}),i},ModuleService}(),cM={needPush:{type:"boolean",required:!1},needPushBadge:{type:"boolean",required:!1},needPushNick:{type:"boolean",required:!1},pushContent:{type:"string",allowEmpty:!1,required:!1},pushPayload:{type:"string",allowEmpty:!1,required:!1}},lM={pushContent:8,pushPayload:9,needPush:107,needPushBadge:109,needPushNick:110},dM={"4_4":"syncOfflineMsgs","4_9":"syncRoamingMsgs","4_17":"syncRoamingMsgs","4_21":"syncDeleteSelfMsgs","7_1":"sendMsg","8_23":"getHistoryTeamMsgs","21_14":"getHistorySuperTeamMsgs","8_2":"sendTeamMsg","21_2":"sendSuperTeamMsg","7_11":"sendMsgReceipt","7_13":"recallMsg","7_24":"deleteSelfMsgs","21_17":"recallSuperTeamMsg","7_2":"onMsg","8_3":"onMsg","21_3":"onMsg","7_101":"onMsg","8_102":"onMsg","21_102":"onMsg","8_4":"nimOnTeamMsgs","4_16":"syncBroadcastMsg","7_17":"onBroadcastMsg","7_123":"onDeleteSelfMsg","7_124":"onDeleteSelfMsgs"},uM=Dt(Dt({scene:0,to:1,from:2,fromClientType:4,fromDeviceId:5,fromNick:6,time:7,type:8,body:9,attach:10,idClient:11,idServer:12,resendFlag:13,userUpdateTime:14,ext:15,needAntiSpam:21,antiSpamContent:22,antiSpamBIZID:23,clientAntispamHitting:24,antiSpamUsingYidun:25,needACK:26,yidunCallbackURL:27,needUpdateSession:28,replyMsgFromAccount:29,replyMsgToAccount:30,replyMsgTime:31,replyMsgIdServer:32,replyMsgIdClient:33,threadMsgFromAccount:34,threadMsgToAccount:35,threadMsgTime:36,threadMsgIdServer:37,threadMsgIdClient:38,isDeleted:39,callbackExt:40,subType:41,yidunAntiCheating:42,envConfig:43,yidunAntiSpamExtension:44,yidunAntiSpamResult:45,__clientExt:{id:46,converter:objectToJSONString,retConverter:stringToJSONObject},needSaveHistory:100,needRoaming:101,needSelfSync:102,isMuted:104,needRouted:105,isInBlackList:106,needOffline:108,isReplyMsg:111,ackSnapshot:112},{pushContent:17,pushPayload:16,forcePushIDsList:18,forcePushContent:19,needForcePush:20,needPush:107,needPushBadge:109,needPushNick:110}),{function:47,topic:48,customContent:49,account:50}),pM={msg:uM,recallMsgTag:Dt({time:0,type:1,to:2,from:3,ps:4,attach:5,deletedIdClient:10,deletedIdServer:11,deleteMsgCreatetime:14,opeAccount:16,env:21},lM),deleteSelfMsgTag:{scene:1,from:2,to:3,idServer:4,idClient:5,deletedMsgCreateTime:6,time:7,ext:8},msgReceiptTag:{to:1,from:2,time:7,idClient:11},broadcastMsg:{id:1,fromAccid:2,time:4,body:5}},mM=invertSerializeMap(pM),hM={sendMsg:{sid:7,cid:1,service:"msg",params:[{type:"Property",name:"msg",reflectMapper:pM.msg}],response:[{type:"Property",name:"msg",reflectMapper:mM.msg}],ignoreErrCodes:[7101]},sendTeamMsg:{sid:8,cid:2,service:"msg",params:[{type:"Property",name:"msg",reflectMapper:pM.msg}],response:[{type:"Property",name:"msg",reflectMapper:mM.msg}]},sendSuperTeamMsg:{sid:21,cid:2,service:"msg",params:[{type:"Property",name:"msg",reflectMapper:pM.msg}],response:[{type:"Property",name:"msg",reflectMapper:mM.msg}]},onMsg:{sid:7,cid:2,service:"msg",response:[{type:"Property",name:"msg",reflectMapper:mM.msg}]},nimOnTeamMsgs:{sid:8,cid:4,service:"msg",response:[{type:"PropertyArray",name:"datas",reflectMapper:mM.msg}]},getHistoryTeamMsgs:{sid:8,cid:23,service:"msg",params:[{type:"Long",name:"to"},{type:"Long",name:"beginTime"},{type:"Long",name:"endTime"},{type:"Long",name:"lastMsgId"},{type:"Int",name:"limit"},{type:"Bool",name:"reverse"},{type:"LongArray",name:"msgTypes"}],response:[{type:"PropertyArray",name:"msgs",reflectMapper:mM.msg}]},getHistorySuperTeamMsgs:{sid:21,cid:14,params:[{type:"Long",name:"to"},{type:"Long",name:"beginTime"},{type:"Long",name:"endTime"},{type:"Long",name:"lastMsgId"},{type:"Int",name:"limit"},{type:"Bool",name:"reverse"},{type:"LongArray",name:"msgTypes"}],response:[{type:"PropertyArray",name:"msgs",reflectMapper:mM.msg}],service:"msg"},recallMsg:{sid:7,cid:13,service:"msg",params:[{type:"Property",name:"recallMsgTag",reflectMapper:pM.recallMsgTag}]},deleteSelfMsgs:{sid:7,cid:24,service:"msg",params:[{type:"PropertyArray",name:"deletedMsgs",reflectMapper:pM.deleteSelfMsgTag}],response:[{type:"Long",name:"timetag"}]},recallSuperTeamMsg:{sid:21,cid:17,service:"msg",params:[{type:"Property",name:"recallMsgTag",reflectMapper:pM.recallMsgTag}]},sendMsgReceipt:{sid:7,cid:11,service:"msg",params:[{type:"Property",name:"msgReceiptTag",reflectMapper:pM.msgReceiptTag}],response:[{type:"Property",name:"msgReceiptTag",reflectMapper:mM.msgReceiptTag}]},batchMarkRead:{sid:4,cid:5,service:"msg",hasPacketResponse:!1,params:[{type:"Byte",name:"sid"},{type:"Byte",name:"cid"},{type:"LongArray",name:"ids"}]},syncMsgReceipts:{sid:4,cid:12,service:"msg",response:[{type:"PropertyArray",name:"msgReceipts",reflectMapper:mM.msgReceiptTag},{type:"Long",name:"timetag"}]},syncOfflineMsgs:{sid:4,cid:4,service:"msg",response:[{type:"PropertyArray",name:"msgs",reflectMapper:mM.msg}]},syncRoamingMsgs:{sid:4,cid:9,service:"msg",response:[{type:"PropertyArray",name:"msgs",reflectMapper:mM.msg}]},syncBroadcastMsg:{sid:4,cid:16,service:"msg",response:[{type:"PropertyArray",name:"msgs",reflectMapper:mM.broadcastMsg}]},onBroadcastMsg:{sid:7,cid:17,service:"msg",response:[{type:"Property",name:"msg",reflectMapper:mM.broadcastMsg}]},onDeleteSelfMsg:{sid:7,cid:123,service:"msg",response:[{type:"Property",name:"deletedMsg",reflectMapper:mM.deleteSelfMsgTag}]},onDeleteSelfMsgs:{sid:7,cid:124,service:"msg",response:[{type:"PropertyArray",name:"deletedMsgs",reflectMapper:mM.deleteSelfMsgTag}]},syncDeleteSelfMsgs:{sid:4,cid:21,service:"msg",response:[{type:"PropertyArray",name:"deletedMsgs",reflectMapper:mM.deleteSelfMsgTag}]}};!function(t){t[t.none=0]="none",t[t.pass=1]="pass",t[t.decline=2]="decline",t[t.read=3]="read",t[t.deleted=4]="deleted",t[t.invalid=5]="invalid"}(aM||(aM={})),function(t){t[t.default=0]="default",t[t.leave=1]="leave",t[t.roam=2]="roam"}(iM||(iM={})),function(t){t[t.applyTeam=0]="applyTeam",t[t.rejectTeamApply=1]="rejectTeamApply",t[t.teamInvite=2]="teamInvite",t[t.rejectTeamInvite=3]="rejectTeamInvite",t[t.friendRequest=5]="friendRequest",t[t.deleteFriend=6]="deleteFriend",t[t.recallMsgP2p=7]="recallMsgP2p",t[t.recallMsgTeam=8]="recallMsgTeam",t[t.recallMsgSuperTeam=12]="recallMsgSuperTeam",t[t.deleteMsgP2pOneWay=13]="deleteMsgP2pOneWay",t[t.deleteMsgTeamOneWay=14]="deleteMsgTeamOneWay",t[t.applySuperTeam=15]="applySuperTeam",t[t.rejectSuperTeamApply=16]="rejectSuperTeamApply",t[t.superTeamInvite=17]="superTeamInvite",t[t.rejectSuperTeamInvite=18]="rejectSuperTeamInvite",t[t.customP2p=100]="customP2p",t[t.customTeam=101]="customTeam",t[t.customSuperTeam=103]="customSuperTeam"}(oM||(oM={}));var gM={1:"addFriend",2:"applyFriend",3:"passFriendApply",4:"rejectFriendApply"};var vM={setting:{needSaveOffline:{type:"boolean"},isRoutable:{type:"boolean"},envConfig:{type:"string"}},antiSpamInfo:{needAntiSpam:{type:"boolean"},antiSpamContent:{type:"boolean"}},pushInfo:cM,recallMessageInfo:{idClient:{type:"string",rawKey:"deletedIdClient"},idServer:{type:"string",rawKey:"deletedIdServer"},createTime:{type:"number",rawKey:"deletedMsgCreateTime"},fromNick:{type:"string",rawKey:"deletedMsgFromNick"},opeAccount:{type:"string"}}};function formatSystemMessage(t,i,u){var m=+t.type,h=getEnumKeyByEnumValue(oM,m);u=u||iM.default;var v=Dt(Dt({},format(vM,t)),{type:h,time:+t.time,to:t.to,from:t.from,idServer:t.idServer,state:aM[aM.none],feature:iM[u]});if("0"===v.idServer&&v.setting&&(v.setting.needSaveOffline=!1),"string"==typeof v.attach)try{v.attach=JSON.parse(v.attach)}catch(t){i.error("formatSystemMessage: "+v.idServer+" parse attach error",t&&t.message)}return 5===m&&v.attach?(v.attach.type=gM[+v.attach.vt],"passFriendApply"===v.attach.type?v.state=aM[aM.pass]:"rejectFriendApply"===v.attach.type&&(v.state=aM[aM.decline])):m<=3&&v.attach&&(v.attach=function formatTeamAttach(t){var i=t.attach,u=t.tinfo,m=__rest(t,["attach","tinfo"]);return m.ext=i,void 0!==u&&(m.team=formatTeam(deserialize(t.tinfo,Ky.team))),m}(v.attach)),v}function generatorSysMsgForCmd$1(t){var i=Dt({},t);return Dt(Dt({},formatReverse(vM,i)),{type:oM[i.type],to:i.to,attach:i.attach})}function getSceneFromRecallSysMsg(t){return t===oM.recallMsgP2p?"p2p":t===oM.recallMsgTeam?"team":t===oM.recallMsgSuperTeam?"superTeam":""}var fM=function(t){function MsgService(i){var u;return(u=t.call(this,"msg",i)||this).onV2SendMessage=function(t){var i=formatMsg$1(t,{account:u.core.account,featureValue:Qu.default});i.status=t.status,u.core.eventBus.emit("session/updateForNewMsg",i)},u.onV2ModifyMessage=function(t){var i,m=Wu[t.scene]+"-"+(t.to===u.core.account?t.from:t.to),h=null===(i=u.core.session)||void 0===i?void 0:i.getSessionWithUncomplete({id:m}),v=formatMsg$1(t,h?{account:u.core.account,sessionAck:h.ack,msgReceiptTime:h.msgReceiptTime}:{account:u.core.account});u.core.eventBus.emit("session/updateForModifyMsg",v)},u.onV2RecallMsg=function(t){var i=formatDeletedMsgs([t],getSceneFromRecallSysMsg(+t.type));u.core.eventBus.emit("session/updateForDeletedMsg",i)},u.onV2DeleteSelfMsgs=function(t){var i=formatDeletedMsgs(t);u.core.eventBus.emit("session/updateForDeletedMsg",i)},u.service=new sM(i),registerParser({cmdMap:dM,cmdConfig:hM}),u.registerListener(),u}Nt(MsgService,t);var i=MsgService.prototype;return i.registerListener=function registerListener(){this.core.eventBus.on("forwardReceive/msg/sendMsg",this.onV2SendMessage),this.core.eventBus.on("forwardReceive/msg/modifyMsg",this.onV2ModifyMessage),this.core.eventBus.on("forwardReceive/msg/recallMsg",this.onV2RecallMsg),this.core.eventBus.on("forwardReceive/msg/deleteSelfMsgs",this.onV2DeleteSelfMsgs)},i.sendTextMsg=function sendTextMsg(t){return validate({body:{type:"string",allowEmpty:!1}},t),this.sendMsg(Dt(Dt({},t),{type:"text"}))},i.sendTipMsg=function sendTipMsg(t){return validate({body:{type:"string",allowEmpty:!1}},t),this.sendMsg(Dt(Dt({},t),{type:"tip"}))},i.sendGeoLocationMsg=function sendGeoLocationMsg(t){return validate({attach:{type:"object",rules:{title:{type:"string",allowEmpty:!1},lat:{type:"number"},lng:{type:"number"}}}},t),this.sendMsg(Dt(Dt({},t),{type:"geo",attach:Un(t.attach)}))},i.sendCustomMsg=function sendCustomMsg(t){return validate({attach:{type:"string",allowEmpty:!1}},t),this.sendMsg(Dt(Dt({},t),{type:"custom"}))},i.sendMsg=function sendMsg(t){var i,u=this;if(validate({scene:{type:"enum",values:getEnumKeys(Wu)},type:{type:"enum",values:getEnumKeys(zu)},to:{type:"string",allowEmpty:!1},ext:{type:"string",required:!1},setting:{type:"object",rules:{resendFlag:{type:"boolean",required:!1},needSaveHistory:{type:"boolean",required:!1},needRoaming:{type:"boolean",required:!1},needOffline:{type:"boolean",required:!1},needSelfSync:{type:"boolean",required:!1},needRouted:{type:"boolean",required:!1},needUpdateSession:{type:"boolean",required:!1}},required:!1},antiSpamInfo:{type:"object",required:!1,rules:{clientAntispamHitting:{type:"boolean",required:!1},antiSpamUsingYidun:{type:"boolean",required:!1}}},pushInfo:{type:"object",required:!1,rules:eM},robotInfo:{type:"object",required:!1,rules:tM},teamSpecializationInfo:{type:"object",required:!1,rules:{needACK:{type:"boolean",required:!1}}}},t),"team"===t.scene&&t.robotInfo&&!t.robotInfo.account)throw new Ql('When "scene" equals "team", account is required in robotInfo',{key:"account"},"required");var m,h="p2p"===t.scene?"sendMsg":"team"===t.scene?"sendTeamMsg":"sendSuperTeamMsg",v=generatorMsgForCmd$1(t,this.core.account,this.core.config.deviceId,null===(i=this.core.user)||void 0===i?void 0:i.myInfo),M=formatMsg$1(Dt(Dt({},v),{time:(new Date).getTime()}),{account:this.core.account,featureValue:Qu.default,statusValue:Yu.sending});try{t.onSendBefore&&t.onSendBefore(M)}catch(t){this.logger.error("sendMsg: options.onSendBefore error",t)}return this.core.eventBus.emit("session/updateForNewMsg",M),this.core.eventBus.emit("forwardSend/msg/sendMsg",v),this.core.sendCmd(h,{msg:v}).then((function(i){var h=i.content,I=i.error;if(m=h.msg,I)throw I;var S=formatMsg$1(Dt(Dt({},v),h.msg),{account:u.core.account,featureValue:Qu.default,statusValue:Yu.sent});return S.from===S.to&&u.markMsgsAck([S]),u.core.eventBus.emit("session/updateForNewMsg",S),u.core.eventBus.emit("forwardSend/msg/sendMsg",Dt(Dt({},generatorMsgForCmd$1(S,S.from,S.fromDeviceId)),{idClient:S.idClient,status:"sent"})),u.core.reporter.report("msgSend",{msgId:S.idServer,clientId:S.idClient,msgTime:S.time,fromAccid:"p2p"===t.scene?u.core.account:"",toAccid:S.to,type:Wu[S.scene],roomId:"",tid:"p2p"===t.scene?"":S.to,result:200,failReason:"",rt:to()-M.time}),S})).catch((function(i){var h=formatMsg$1(Dt(Dt(Dt({},v),{time:(new Date).getTime()}),m),{account:u.core.account,featureValue:Qu.default,statusValue:7101===i.code?Yu.refused:Yu.sendFailed});throw i.msg=h,u.core.eventBus.emit("session/updateForNewMsg",h),u.core.eventBus.emit("forwardSend/msg/sendMsg",Dt(Dt({},generatorMsgForCmd$1(h,h.from,h.fromDeviceId)),{status:"sendFailed"})),u.core.reporter.report("msgSend",{msgId:h.idServer,clientId:h.idClient,msgTime:h.time,fromAccid:"p2p"===t.scene?u.core.account:"",toAccid:h.to,type:Wu[h.scene],roomId:"",tid:"p2p"===t.scene?"":h.to,result:null==i?void 0:i.code,failReason:(null==i?void 0:i.message)||"",rt:to()-M.time}),i}))},i.resendMsg=function resendMsg(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:if(validate({msg:{type:"object",rules:{idClient:{type:"string",allowEmpty:!1}}}},t),i=t.msg,u=Dt(Dt({},i),{attach:i.attach?Un(i.attach):void 0,setting:{resendFlag:!0}}),i.from===this.core.account){m.next=5;break}throw new Error("You can only resend messages that you sent: "+i.idClient);case 5:return m.abrupt("return",this.sendMsg(u));case 6:case"end":return m.stop()}}),_callee,this)})))},i.forwardMsg=function forwardMsg(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:return validate({msg:{type:"object",rules:{idClient:{type:"string",allowEmpty:!1}}},scene:{type:"enum",values:getEnumKeys(Wu)},to:{type:"string",allowEmpty:!1}},t),i=t.msg,u=Dt(Dt({},i),{scene:t.scene,to:t.to,attach:i.attach?Un(i.attach):void 0}),m.abrupt("return",this.sendMsg(u));case 4:case"end":return m.stop()}}),_callee2,this)})))},i.sendImageMsg=function sendImageMsg(t){return this.doSendFile(Dt(Dt({},t),{type:"image"}))},i.sendFileMsg=function sendFileMsg(t){return this.doSendFile(Dt(Dt({},t),{type:"file"}))},i.sendAudioMsg=function sendAudioMsg(t){return this.doSendFile(Dt(Dt({},t),{type:"audio"}))},i.sendVideoMsg=function sendVideoMsg(t){return this.doSendFile(Dt(Dt({},t),{type:"video"}))},i.doSendFile=function doSendFile(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:if(validate({scene:{type:"enum",values:getEnumKeys(Wu)},to:{type:"string",allowEmpty:!1},type:{type:"string",allowEmpty:!1},attach:{type:"object",rules:{url:{type:"string",allowEmpty:!1}},required:!1},maxSize:{type:"number",min:1,required:!1}},t),i=t.attach){u.next=15;break}if(this.core.cloudStorage&&this.core.cloudStorage.uploadFile){u.next=5;break}throw new Error('Service "cloudStorage" does not exist');case 5:return u.prev=5,u.next=8,this.core.cloudStorage.uploadFile(t);case 8:i=u.sent,u.next=15;break;case 11:throw u.prev=11,u.t0=u.catch(5),this.logger.error("sendFile:: upload File error or abort.",u.t0),u.t0;case 15:return u.abrupt("return",this.sendMsg(Dt(Dt({},t),{attach:Un(i),type:t.type})));case 16:case"end":return u.stop()}}),_callee3,this,[[5,11]])})))},i.recallMsg=function recallMsg(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m,h,v,M;return ud.wrap((function _callee4$(I){for(;;)switch(I.prev=I.next){case 0:return validate({msg:{type:"object",rules:{idClient:{type:"string",allowEmpty:!1},idServer:{type:"string",allowEmpty:!1},scene:{type:"enum",values:getEnumKeys(Wu)},time:{type:"number"}}},pushInfo:{type:"object",required:!1,rules:cM},ps:{type:"string",allowEmpty:!1,required:!1}},t),i=t.msg,u={p2p:"recallMsg",team:"recallMsg",superTeam:"recallSuperTeamMsg"},m={p2p:7,team:8,superTeam:12},h=processPushInfoInMsg({time:i.time,type:m[i.scene],to:i.to,from:i.from,ps:t.ps,attach:t.attach,deletedIdClient:i.idClient,deletedIdServer:i.idServer,opeAccount:i.from,env:t.env,pushInfo:t.pushInfo}),I.next=7,this.core.sendCmd(u[i.scene],{recallMsgTag:h});case 7:return v=Dt({},i,{deletedMsgCreateTime:i.time}),M=formatDeletedMsgs([v]),this.core.eventBus.emit("session/updateForDeletedMsg",M),this.core.eventBus.emit("forwardSend/msg/recallMsg",h),I.abrupt("return",i);case 12:case"end":return I.stop()}}),_callee4,this)})))},i.deleteSelfMsgs=function deleteSelfMsgs(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i,u,m,h,v;return ud.wrap((function _callee5$(M){for(;;)switch(M.prev=M.next){case 0:return validate({msgs:{type:"array",rules:{scene:{type:"enum",values:["p2p","team"]},from:{type:"string",allowEmpty:!1},to:{type:"string",allowEmpty:!1},idServer:{type:"string",allowEmpty:!1},idClient:{type:"string",allowEmpty:!1},time:{type:"number",allowEmpty:!1}}},ext:{type:"string",allowEmpty:!1,required:!1}},t),i=t.msgs,u=map$6(i).call(i,(function(i){return{scene:"p2p"===i.scene?1:2,from:i.from,to:i.to,idServer:i.idServer,idClient:i.idClient,deletedMsgCreateTime:i.time,ext:t.ext}})),M.next=5,this.core.sendCmd("deleteSelfMsgs",{deletedMsgs:u});case 5:return m=M.sent,h=map$6(u).call(u,(function(t){var i;return Dt({},t,{time:null===(i=null==m?void 0:m.content)||void 0===i?void 0:i.timetag})})),v=formatDeletedMsgs(h),this.core.eventBus.emit("session/updateForDeletedMsg",v),this.core.eventBus.emit("forwardSend/msg/deleteSelfMsgs",map$6(u).call(u,(function(t){var i;return Dt(Dt({},t),{time:null===(i=null==m?void 0:m.content)||void 0===i?void 0:i.timetag})}))),M.abrupt("return",v);case 11:case"end":return M.stop()}}),_callee5,this)})))},i.sendMsgReceipt=function sendMsgReceipt(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var m,h,v,M;return ud.wrap((function _callee6$(I){for(;;)switch(I.prev=I.next){case 0:if(validate({msg:{type:"object",rules:{idClient:{type:"string",allowEmpty:!1},target:{type:"string",allowEmpty:!1},time:{type:"number"}}}},t),"p2p"===(m=t.msg).scene&&"in"===m.flow){I.next=5;break}return this.logger.warn("Msg scene: "+m.scene+", flow: "+m.flow+" is not allowed to send msg receipt"),I.abrupt("return",void 0);case 5:return h={to:m.target,idClient:m.idClient,time:m.time},I.next=8,this.core.sendCmd("sendMsgReceipt",{msgReceiptTag:h});case 8:return v=I.sent,M=Gd(null===(u=null===(i=v.content)||void 0===i?void 0:i.msgReceiptTag)||void 0===u?void 0:u.time),I.abrupt("return",Dt(Dt({},h),{time:M?Math.min(M,h.time):h.time}));case 11:case"end":return I.stop()}}),_callee6,this)})))},i.sendTeamMsgReceipt=function sendTeamMsgReceipt(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var i;return ud.wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamMsgReceipts:{type:"array",rules:{teamId:{type:"string",allowEmpty:!1},idClient:{type:"string",allowEmpty:!1},idServer:{type:"string",allowEmpty:!1}},max:50}},t),i=t.teamMsgReceipts,this.core.sendCmd("sendTeamMsgReceipt",{teamMsgReceipts:i}),u.abrupt("return",void 0);case 4:case"end":return u.stop()}}),_callee7,this)})))},i.getTeamMsgReads=function getTeamMsgReads(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var u,m,h;return ud.wrap((function _callee8$(v){for(;;)switch(v.prev=v.next){case 0:return validate({teamMsgReceipts:{type:"array",rules:{teamId:{type:"string",allowEmpty:!1},idClient:{type:"string",allowEmpty:!1},idServer:{type:"string",allowEmpty:!1}}}},t),u=t.teamMsgReceipts,v.next=4,this.core.sendCmd("getTeamMsgReads",{teamMsgReceipts:u});case 4:return m=v.sent,h=(h=null===(i=m.content)||void 0===i?void 0:i.teamMsgReceipts)?map$6(h).call(h,(function(t){return Dt(Dt({},t),{read:Gd(t.read),unread:Gd(t.unread)})})):[],v.abrupt("return",h);case 8:case"end":return v.stop()}}),_callee8,this)})))},i.getTeamMsgReadAccounts=function getTeamMsgReadAccounts(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var i,u;return ud.wrap((function _callee9$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamMsgReceipt:{type:"object",rules:{teamId:{type:"string",allowEmpty:!1},idClient:{type:"string",allowEmpty:!1},idServer:{type:"string",allowEmpty:!1}}}},t),i=t.teamMsgReceipt,m.next=4,this.core.sendCmd("getTeamMsgReadAccounts",{teamMsgReceiptTag:i});case 4:return u=m.sent,m.abrupt("return",u.content);case 6:case"end":return m.stop()}}),_callee9,this)})))},i.markMsgsAck=function markMsgsAck(t){if(t&&t.length>0){var i=[],u=[];forEach$1(t).call(t,(function(t){"p2p"===t.scene&&"in"===t.flow?i.push(t):"team"===t.scene&&"in"===t.flow&&u.push(t)})),i.length>0&&this.core.sendCmd("batchMarkRead",{sid:7,cid:2,ids:map$6(i).call(i,(function(t){return t.idServer}))}),u.length>0&&this.core.sendCmd("batchMarkRead",{sid:8,cid:3,ids:map$6(u).call(u,(function(t){return t.idServer}))})}},i.onMsgHandler=function onMsgHandler(t){var i;if(t.error)this.logger.error("msgHandler::recvError",t.error);else{var u=fillIdServer(t,t.content.msg,"idServer"),m=getSessionId(u,this.core.account),h=null===(i=this.core.session)||void 0===i?void 0:i.getSessionWithUncomplete({id:m}),v=formatMsg$1(u,h?{account:this.core.account,sessionAck:h.ack,msgReceiptTime:h.msgReceiptTime}:{account:this.core.account});this.logger.getDebugMode()?this.logger.debug("msgHandler::recvMsg",v.idClient,v.idServer,v):this.logger.log("msgHandler::recvMsg",v.idClient,v.idServer),this.markMsgsAck([v]),this.core.eventBus.emit("session/updateForNewMsg",v),"superTeam"===v.scene?this.core.eventBus.emit("sync/updateTimetag",{superTeamRoamingMsgs:v.time}):this.core.eventBus.emit("sync/updateTimetag",{roamingMsgs:v.time}),this.core.emit("msg",v),"notification"===v.type?this.core.eventBus.emit("team/onNotification",v):"out"!==v.flow&&this.doMsgReceiveReport(v,t),"notification"!==v.type&&this.core.user.checkUserUpdate(v)}},i.doMsgReceiveReport=function doMsgReceiveReport(t,i){if(t.from!==this.core.account){var u="p2p"===t.scene,m=get(t,"__clientExt.statistics.apiCallingTime")||0,h=get(t,"__clientExt.statistics.sendTime")||0,v=get(t,"__clientExt.statistics.attachUploadDuration")||0,M=this.core.timeOrigin.getNTPTime(),I=t.time,S=this.core.timeOrigin.checkNodeReliable(i.__receiveTimeNode)?this.core.timeOrigin.getNTPTime(i.__receiveTimeNode):M;this.core.reporter.report("msgReceive",{msgId:t.idServer,clientId:t.idClient,serverTime:I,receiveTime:S,fromAccid:t.from,toAccid:t.to,type:Wu[t.scene],tid:u?"":t.to,apiCallingTime:m,sendTime:h,attachUploadDuration:v,callbackTime:M,preHandleTime:M,result:200,failReason:"",rt:M-I})}},i.nimOnTeamMsgsHandler=function nimOnTeamMsgsHandler(t){var i,u=this;forEach$1(i=t.content.datas).call(i,(function(i){u.onMsgHandler(Dt({},t,{content:{msg:i}}))}))},i.syncRoamingMsgsHandler=function syncRoamingMsgsHandler(t){var i,u,m=t.content.msgs||[];if(0!==m.length){var h=getSessionId(m[0],this.core.account),v=null===(i=this.core.session)||void 0===i?void 0:i.getSessionWithUncomplete({id:h}),M=(m=formatMsgs$1(m,v?{account:this.core.account,featureValue:Qu.roam,sessionAck:v.ack,msgReceiptTime:v.msgReceiptTime}:{account:this.core.account,featureValue:Qu.roam}))[0].time,I={timetag:M,sessionId:h,msgs:reverse(m)};"function"!=typeof(null===(u=this.core.sync)||void 0===u?void 0:u.getSyncDoneFlag)||this.core.sync.getSyncDoneFlag()||this.core.eventBus.emit("session/syncMsgs",I),this.core.emit("syncRoamingMsgs",I),"superTeam"===m[0].scene?this.core.eventBus.emit("sync/updateTimetag",{superTeamRoamingMsgs:M}):this.core.eventBus.emit("sync/updateTimetag",{roamingMsgs:M})}},i.syncOfflineMsgsHandler=function syncOfflineMsgsHandler(t){var i,u=this,m=t.content.msgs||[];if(0!==m.length){var h={},v=[];forEach$1(m).call(m,(function(t){var i=getSessionId(t,u.core.account),m=u.core.session.getSessionWithUncomplete({id:i}),M=formatMsg$1(t,m?{account:u.core.account,featureValue:Qu.leave,sessionAck:m.ack,msgReceiptTime:m.msgReceiptTime}:{account:u.core.account,featureValue:Qu.leave});v.push(M),h[M.sessionId]?h[M.sessionId].push(M):h[M.sessionId]=[M]})),this.markMsgsAck(v);var M=0;forEach$1(i=Ht(h)).call(i,(function(t){var i,m=sort(i=h[t]).call(i,(function(t,i){return i.time-t.time}));(m=removeDupMsgsByIdClient(m))[0].time>M&&(M=m[0].time);var v={timetag:m[0].time,sessionId:t,msgs:m};u.core.eventBus.emit("session/syncMsgs",v),u.core.emit("syncOfflineMsgs",v)})),this.core.eventBus.emit("sync/updateTimetag",{offlineMsgs:M})}},i.syncDeleteSelfMsgsHandler=function syncDeleteSelfMsgsHandler(t){var i,u=null===(i=t.content)||void 0===i?void 0:i.deletedMsgs;u&&u.length>0||this.logger.warn("syncDeleteSelfMsgs:: no msgs");var m=u[u.length-1].time;this.core.eventBus.emit("sync/updateTimetag",{deleteSelfMsgs:m})},i.onDeleteSelfMsgHandler=function onDeleteSelfMsgHandler(t){var i=formatDeletedMsgs([t.content.deletedMsg]);this.core.eventBus.emit("session/updateForDeletedMsg",i),this.core.emit("deleteSelfMsgs",i)},i.onDeleteSelfMsgsHandler=function onDeleteSelfMsgsHandler(t){var i=formatDeletedMsgs(t.content.deletedMsgs);this.core.eventBus.emit("session/updateForDeletedMsg",i),this.core.emit("deleteSelfMsgs",i)},i.onBroadcastMsgHandler=function onBroadcastMsgHandler(t){var i=t.content.msg,u=this.service.processBroadcastMsg([i]);this.core.emit("broadcastMsgs",u)},i.syncBroadcastMsgHandler=function syncBroadcastMsgHandler(t){var i=t.content.msgs,u=this.service.processBroadcastMsg(i);this.core.emit("broadcastMsgs",u)},MsgService}(gp),yM={"5_1":"sync"},MM={sync:{sid:5,cid:1,service:"sync",hasPacketTimer:!1,params:[{type:"Property",name:"sync",reflectMapper:{myInfo:1,offlineMsgs:2,teams:3,roamingMsgs:7,relations:9,friends:11,friendUsers:13,msgReceipts:14,myTeamMembers:15,donnop:16,recallMsg:17,sessionAck:18,broadcastMsgs:20,avSignal:21,superTeams:22,mySuperTeamMembers:23,superTeamRoamingMsgs:24,deleteSuperTeamMsg:25,superTeamSessionAck:26,deleteSelfMsgs:27,stickTopSessions:28,sessionHistoryMsgsDelete:29}}],response:[{type:"Long",name:"timetag"}]}},IM=function(t){function SyncService(i,u){var m;return void 0===u&&(u={}),(m=t.call(this,"sync",i)||this).syncDoneFlag=!1,m.config={myInfo:!!i.user.name,offlineMsgs:!!i.msg.name,teams:!!i.team.name,myTeamMembers:!!i.team.name,roamingMsgs:!!i.msg.name,relations:!!i.user.name,friends:!!i.friend.name,friendUsers:!!i.user.name,msgReceipts:!!i.msg.name,broadcastMsgs:!!i.msg.name,recallMsg:!!i.msg.name,sessionAck:!!i.session.name,superTeamSessionAck:!!i.session.name,superTeams:!!i.superTeam.name,mySuperTeamMembers:!!i.superTeam.name,superTeamRoamingMsgs:!!i.superTeam.name,deleteSuperTeamMsg:!!i.superTeam.name,deleteSelfMsgs:!!i.msg.name,sessionHistoryMsgsDelete:!!i.msgLog.name,avSignal:!!i.signaling.name},m.setOptions(u),m.timetags={},m.initEventListeners(),registerParser({cmdMap:yM,cmdConfig:MM}),m}Nt(SyncService,t);var i=SyncService.prototype;return i.setOptions=function setOptions(t){Dt(this.config,t)},i.reset=function reset(){this.timetags={},this.syncDoneFlag=!1},i.getSyncDoneFlag=function getSyncDoneFlag(){return this.syncDoneFlag},i.doSync=function doSync(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return i=this.genSyncParams(),this.logger.log("sync::doSyncV1: ",i),m.prev=2,m.next=5,this.core.clientSocket.sendCmd("sync",{sync:i});case 5:u=m.sent,this.core.logger.log("sync::doSyncV1 done in",null===(t=u.content)||void 0===t?void 0:t.timetag),this.syncDoneFlag=!0,this.core.emit("syncdone"),m.next=17;break;case 11:return m.prev=11,m.t0=m.catch(2),this.core.logger.error("sync::doSyncV1 error",m.t0),this.syncDoneFlag=!0,this.core.emit("syncdone"),m.abrupt("return");case 17:case"end":return m.stop()}}),_callee,this,[[2,11]])})))},i.initEventListeners=function initEventListeners(){var t=this;this.core.eventBus.on("logined",(function(){t.syncDoneFlag=!1,t.doSync()})),this.core.eventBus.on("sync/updateTimetag",(function(i){var u;forEach$1(u=Ht(i)).call(u,(function(u){i[u]>(t.timetags[u]||0)&&(t.timetags[u]=i[u])}))}))},i.genSyncParams=function genSyncParams(){var t,i,u=this;return reduce(t=filter(i=Ht(this.config)).call(i,(function(t){var i=t;return u.config[i]}))).call(t,(function(t,i){var m=i;return t[m]=u.timetags[m]||0,t}),{})},i.handleImmediate=function handleImmediate(t){return this.core.session&&this.core.session.onSyncDone&&this.core.session.onSyncDone(),zi.resolve(t)},i.delaySyncDone=function delaySyncDone(t){var i=this;return 102===pd.getSystemInfo().hostEnvEnum?(this.core.logger.log("sync: emit ALIAPP sycnHandler, handle later"),new zi((function(u){mo((function(){i.handleImmediate(t).then((function(){u(t)}))}),100)}))):this.handleImmediate(t)},i.syncHandler=function syncHandler(t){return this.delaySyncDone(t)},SyncService}(gp);function _createForOfIteratorHelperLoose$3(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$3(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$3(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$3(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$3(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var _M=function(t){function UserService(i){var u;return(u=t.call(this,"user",i)||this).userInfoMap=new Sc,u.myInfo=formatUser({}),registerParser({cmdMap:Qy,cmdConfig:Zy}),u}Nt(UserService,t);var i=UserService.prototype;return i.setBlack=function setBlack(t){var i=this;return validate({account:{type:"string",allowEmpty:!1},isAdd:{type:"boolean"}},t),this.core.sendCmd("setBlack",t).then((function(){i.core.eventBus.emit("forwardSend/user/updateBlackList",t.account,t.isAdd)}))},i.setMute=function setMute(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return validate({account:{type:"string",allowEmpty:!1},isAdd:{type:"boolean"}},t),i.next=3,this.core.sendCmd("setMute",t).then((function(){}));case 3:this.core.eventBus.emit("forwardSend/user/setMute",t.account,t.isAdd);case 4:case"end":return i.stop()}}),_callee,this)})))},i.getRelations=function getRelations(){return this.core.sendCmd("syncRelations",{timetag:0})},i.getBlackList=function getBlackList(){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var t;return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.core.sendCmd("syncRelations",{timetag:0});case 2:return t=i.sent,i.abrupt("return",t.blackList||[]);case 4:case"end":return i.stop()}}),_callee2,this)})))},i.getMuteList=function getMuteList(){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var t;return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.core.sendCmd("syncRelations",{timetag:0});case 2:return t=i.sent,i.abrupt("return",t.muteList||[]);case 4:case"end":return i.stop()}}),_callee3,this)})))},i.updatePushToken=function updatePushToken(){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:this.logger.error("This function is deprecated, please use nim.offlinePush.setOfflinePushConfig instead");case 1:case"end":return t.stop()}}),_callee4,this)})))},i.updateAppBackground=function updateAppBackground(){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(t){for(;;)switch(t.prev=t.next){case 0:this.logger.error("This function is deprecated, please use nim.offlinePush.setOfflinePushConfig instead");case 1:case"end":return t.stop()}}),_callee5,this)})))},i.getUsersNameCardFromServer=function getUsersNameCardFromServer(t){var i=this;return validate({accounts:{type:"array",max:150,itemType:"string"}},t),this.core.sendCmd("getUsersNameCardFromServer",pick(t,["accounts"])).then((function(u){var m,h=u.content;return i.logger.log("user:: getUsers done",t.accounts),h&&h.users?map$6(m=h.users).call(m,(function(t){return formatUser(t)})):[]}))},i.updateMyNameCard=function updateMyNameCard(t){var i=this;if(validate({nick:{type:"string",required:!1},avatar:{type:"string",required:!1},signature:{type:"string",required:!1},gender:{type:"enum",values:getEnumKeys(Ny),required:!1},email:{type:"string",required:!1},birth:{type:"string",required:!1},tel:{type:"string",required:!1},ext:{type:"string",required:!1}},t),0===Ht(t).length)return zi.resolve(this.myInfo);var u=pick(t,["nick","avatar","signature","email","birth","tel","ext"]);return t.gender&&(u.gender=Ny[t.gender]),this.core.sendCmd("updateMyNameCard",{user:u}).then((function(m){var h=m.content;return h&&h.timetag&&i.core.eventBus.emit("sync/updateTimetag",{myInfo:+h.timetag}),t.gender&&(u.gender=t.gender),i.myInfo=Dt({},i.myInfo,u),i.core.eventBus.emit("forwardSend/user/updateUserInfo",u),i.myInfo}))},i.checkUserUpdate=function checkUserUpdate(t){var i=t.from;if(i!==this.core.account){var u=this.userInfoMap.get(i);if(u){var m=u.updateTime,h=t.userUpdateTime;!isNaN(m)&&!isNaN(h)&&"number"==typeof m&&"number"==typeof h&&m<h&&this.refreshUserInfo(i)}else this.refreshUserInfo(i)}},i.refreshUserInfo=function refreshUserInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i,u,m,h;return ud.wrap((function _callee6$(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.getUsersNameCardFromServer({accounts:[t]});case 2:for(i=v.sent,u=_createForOfIteratorHelperLoose$3(i);!(m=u()).done;)h=m.value,this.userInfoMap.set(h.account,h),this.core.emit("updateUserInfo",h);case 4:case"end":return v.stop()}}),_callee6,this)})))},i.onUpdateBlackListHandler=function onUpdateBlackListHandler(t){var i=t.content;i.account?this.core.emit("updateBlackList",i):this.logger.warn("onUpdateBlackListHandler: no account")},i.onUpdateMuteListHandler=function onUpdateMuteListHandler(t){var i=t.content;i.account?this.core.emit("updateMuteList",i):this.logger.warn("onUpdateBlackListHandler: no account")},i.syncRelationsHandler=function syncRelationsHandler(t){var i=t.content,u=i.list,m=i.timetag,h={blackList:[],muteList:[]};return m&&this.core.eventBus.emit("sync/updateTimetag",{relations:m}),u&&u.length&&forEach$1(u).call(u,(function(t){var i=function formatRelationMember(t){var i={account:t.account,updateTime:+t.updateTime,createTime:+t.createTime};return"1"===t.isMuted&&(i.isMuted=!0),"1"===t.isBlack&&(i.isBlack=!0),i}(t);i.isBlack&&h.blackList.push(i),i.isMuted&&h.muteList.push(i)})),this.core.emit("relations",h),zi.resolve(h)},i.syncMyNameCardHandler=function syncMyNameCardHandler(t){t.content.user&&(this.myInfo=formatUser(t.content.user),this.core.emit("syncMyNameCard",this.myInfo),this.core.eventBus.emit("sync/updateTimetag",{myInfo:t.content.timetag}))},i.onUpdateMyNameCardHandler=function onUpdateMyNameCardHandler(t){var i=t.content.user;i?(Dt(this.myInfo,formatUser(i)),this.core.emit("updateMyNameCard",this.myInfo)):this.logger.warn("onUpdateMyNameCardHandler no user info")},UserService}(gp);var SM={"4_12":"syncMsgReceipts","4_14":"syncSessionAck","4_20":"syncSuperTeamSessionAck","4_22":"nimSyncSessionsWithMoreRoaming","4_25":"syncSessionReliableInfo","7_12":"multiSyncMsgReceipt","7_16":"markSessionAck","7_25":"markMultSessionsAck","7_116":"syncMarkSessionAck","21_25":"markSuperTeamSessionAck","21_32":"markMultSuperTeamSessionsAck","21_125":"syncMarkSuperTeamSessionAck","4_23":"nimSyncStickTopSessions","23_12":"nimAddStickTopSession","23_13":"nimDeleteStickTopSession","23_14":"nimUpdateStickTopSession","23_112":"nimMultiSyncAddStickTopSession","23_113":"nimMultiSyncDeleteStickTopSession","23_114":"nimMultiSyncUpdateStickTopSession"},TM={msgReceiptTag:{to:1,from:2,time:7,idClient:11},stickTopSessionTag:{id:1,ext:2,createTime:3,updateTime:4},sessionAckTag:{scene:1,to:2,timetag:3},sessionReliableSyncTag:{scene:1,sessionId:2,syncStatus:3,syncEndMsgId:4,syncEndMsgidClient:5,syncEndMsgTime:6,syncStartMsgid:7,syncStartMsgidClient:8,syncStartMsgTime:9,nextMsgid:10,nextMsgidClient:11,nextMsgTime:12,roamMsgSync:13,offlineMsgSync:14,netCallOfflineMsgSync:15}},CM=invertSerializeMap(TM),bM={syncMsgReceipts:{sid:4,cid:12,service:"session",response:[{type:"PropertyArray",name:"msgReceipts",reflectMapper:CM.msgReceiptTag},{type:"Long",name:"timetag"}]},syncSessionAck:{sid:4,cid:14,service:"session",response:[{type:"StrLongMap",name:"p2p"},{type:"LongLongMap",name:"team"},{type:"Long",name:"timetag"}]},syncSuperTeamSessionAck:{sid:4,cid:20,service:"session",response:[{type:"LongLongMap",name:"superTeam"},{type:"Long",name:"timetag"}]},multiSyncMsgReceipt:{sid:7,cid:12,service:"session",response:[{type:"Property",name:"msgReceiptTag",reflectMapper:CM.msgReceiptTag}]},markSessionAck:{sid:7,cid:16,service:"session",params:[{type:"Byte",name:"scene"},{type:"String",name:"to"},{type:"Long",name:"timetag"}]},syncMarkSessionAck:{sid:7,cid:116,service:"session",response:[{type:"Byte",name:"scene"},{type:"String",name:"to"},{type:"Long",name:"timetag"}]},syncMarkSuperTeamSessionAck:{sid:21,cid:125,service:"session",response:[{type:"Long",name:"to"},{type:"Long",name:"timetag"}]},markMultSessionsAck:{sid:7,cid:25,service:"session",ignoreErrCodes:[700],params:[{type:"PropertyArray",name:"datas",reflectMapper:TM.sessionAckTag}]},markSuperTeamSessionAck:{sid:21,cid:25,service:"session",params:[{type:"Long",name:"to"},{type:"Long",name:"timetag"}]},nimAddStickTopSession:{sid:23,cid:12,service:"session",params:[{type:"Property",name:"tag",reflectMapper:TM.stickTopSessionTag}],response:[{type:"Property",name:"data",reflectMapper:CM.stickTopSessionTag}]},nimDeleteStickTopSession:{sid:23,cid:13,service:"session",params:[{type:"Property",name:"tag",reflectMapper:TM.stickTopSessionTag}],response:[{type:"Long",name:"timetag"}]},nimUpdateStickTopSession:{sid:23,cid:14,service:"session",params:[{type:"Property",name:"tag",reflectMapper:TM.stickTopSessionTag}],response:[{type:"Property",name:"data",reflectMapper:CM.stickTopSessionTag}]},nimMultiSyncAddStickTopSession:{sid:23,cid:112,service:"session",response:[{type:"Property",name:"data",reflectMapper:CM.stickTopSessionTag}]},nimMultiSyncDeleteStickTopSession:{sid:23,cid:113,service:"session",response:[{type:"Long",name:"timetag"},{type:"Property",name:"data",reflectMapper:CM.stickTopSessionTag}]},nimMultiSyncUpdateStickTopSession:{sid:23,cid:114,service:"session",response:[{type:"Property",name:"data",reflectMapper:CM.stickTopSessionTag}]},nimSyncStickTopSessions:{sid:4,cid:23,service:"session",response:[{type:"Long",name:"timetag"},{type:"Bool",name:"isThereAnyChange"},{type:"PropertyArray",name:"datas",reflectMapper:CM.stickTopSessionTag}]},markMultSuperTeamSessionsAck:{sid:21,cid:32,service:"session",ignoreErrCodes:[700],params:[{type:"PropertyArray",name:"datas",reflectMapper:TM.sessionAckTag}]},nimSyncSessionsWithMoreRoaming:{sid:4,cid:22,service:"session",response:[]},syncSessionReliableInfo:{sid:4,cid:25,service:"session",response:[]}},EM={id:{type:"string"},ext:{type:"string"},createTime:{type:"number"},updateTime:{type:"number"}};function formatStickTop(t,i,u){void 0===u&&(u=!0);var m=format(EM,t);m.isStickOnTop=u,m.id=i.id,u||(m.ext="");var h=Dt(Dt({},i),{stickTopInfo:i.stickTopInfo?Dt({},i.stickTopInfo,m):m});return void 0===h.lastMsg&&(h.lastMsg=null),h}var AM=function(){function StickTopService(t){this.core=t}var t=StickTopService.prototype;return t.getSession=function getSession(t){return this.core.session.getSessionWithUncomplete({id:t})||this.core.session.createSession(t)},t.addStickTopSession=function addStickTopSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h,v,M;return ud.wrap((function _callee$(I){for(;;)switch(I.prev=I.next){case 0:return validate({id:{type:"string",allowEmpty:!1},ext:{type:"string",required:!1}},t),i=getAccountFromSessionId(t.id),u=i.scene,m=i.accid,I.next=4,this.core.sendCmd("nimAddStickTopSession",{tag:{id:("superTeam"===u?"super_team":u)+"|"+m,ext:t.ext||""}});case 4:return h=I.sent,v=this.getSession(t.id),M=formatStickTop(h.content.data,v),I.abrupt("return",M);case 8:case"end":return I.stop()}}),_callee,this)})))},t.deleteStickTopSession=function deleteStickTopSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v,M;return ud.wrap((function _callee2$(I){for(;;)switch(I.prev=I.next){case 0:return validate({id:{type:"string",allowEmpty:!1}},t),i=getAccountFromSessionId(t.id),u=i.scene,m=i.accid,I.next=4,this.core.sendCmd("nimDeleteStickTopSession",{tag:{id:("superTeam"===u?"super_team":u)+"|"+m}});case 4:return h=I.sent,v=this.getSession(t.id),M=formatStickTop({updateTime:h.content.timetag,ext:""},v,!1),I.abrupt("return",M);case 8:case"end":return I.stop()}}),_callee2,this)})))},t.updateStickTopSession=function updateStickTopSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m,h,v,M;return ud.wrap((function _callee3$(I){for(;;)switch(I.prev=I.next){case 0:return validate({id:{type:"string",allowEmpty:!1},ext:{type:"string",required:!1}},t),i=getAccountFromSessionId(t.id),u=i.scene,m=i.accid,I.next=4,this.core.sendCmd("nimUpdateStickTopSession",{tag:{id:("superTeam"===u?"super_team":u)+"|"+m,ext:t.ext||""}});case 4:return h=I.sent,v=this.getSession(t.id),M=formatStickTop(h.content.data,v),I.abrupt("return",M);case 8:case"end":return I.stop()}}),_callee3,this)})))},t.stickTopSessionHandler=function stickTopSessionHandler(t,i){void 0===i&&(i=!0);var u=getAccountFromSessionId(t.id,"|"),m=u.scene+"-"+u.accid;return formatStickTop(t,this.getSession(m),i)},StickTopService}(),kM=function(){function UnreadModuleService(t){this.core=t,this.logger=t.logger}var t=UnreadModuleService.prototype;return t.canSessionResetUnreadCount=function canSessionResetUnreadCount(t){var i=t.id;if(void 0===t.lastMsg)throw new Error("Session::canSessionResetUnreadCount: session "+i+" is not completly, lastMsg undefined");return null!==t.lastMsg||t.unread>0?!(t.ack&&t.lastMsg&&t.ack>=t.lastMsg.time)||(this.logger.log("Session::canSessionResetUnreadCount: session "+i+" reset failed, ack time is greater than last message time"),!1):(this.logger.log("Session::canSessionResetUnreadCount: session "+i+" doesn't need to be updated, lastMsg null and unread 0"),!1)},t.filterSessionForResetUnreadCount=function filterSessionForResetUnreadCount(t){var i=this,u={cmd:"markMultSuperTeamSessionsAck",params:[]},m={cmd:"markMultSessionsAck",params:[]};return forEach$1(t).call(t,(function(t){var h;try{if(!i.canSessionResetUnreadCount(t))return;var v=getAccountFromSessionId(t.id),M=v.accid,I=v.scene,S={to:M,sessionId:t.id,timetag:(null===(h=null==t?void 0:t.lastMsg)||void 0===h?void 0:h.time)||t.updateTime||0},T=function generateSceneForCmd(t){return formatReverse({scene:{type:"enum",values:Wu}},t)}({scene:I});"superTeam"===I?u.params.push(S):m.params.push(Dt(Dt({},S),T))}catch(t){i.logger.warn(t)}})),{superTeam:u,p2pOrTeam:m}},UnreadModuleService}();function _createForOfIteratorHelperLoose$2(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$2(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$2(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$2(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$2(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var RM=function(t){function SessionService(i,u){var m;return(m=t.call(this,"session",i)||this).list=new Sc,m.unreadCountFilterFn=function(t){return!0},m.lastMessageFilterFn=function(t){return!0},m.initEventListeners(),registerParser({cmdMap:SM,cmdConfig:bM}),m.stickTopService=new AM(i),m.unreadModule=new kM(i),u&&m.setOptions(u),m}Nt(SessionService,t);var i=SessionService.prototype;return i.setOptions=function setOptions(t){"function"==typeof(null==t?void 0:t.unreadCountFilterFn)&&(this.unreadCountFilterFn=t.unreadCountFilterFn),"function"==typeof(null==t?void 0:t.lastMessageFilterFn)&&(this.lastMessageFilterFn=t.lastMessageFilterFn)},i.reset=function reset(){var t;forEach$1(t=this.list).call(t,(function(t){t.unreadMsgs=[]})),this.list.clear()},i.initEventListeners=function initEventListeners(){var t,i,u,m,h=this;this.core.eventBus.on("session/syncMsgs",bind$1(t=this.onSyncMsgs).call(t,this)),this.core.eventBus.on("session/updateForNewMsg",bind$1(i=this.updateSessionWithMsg).call(i,this)),this.core.eventBus.on("session/updateForModifyMsg",bind$1(u=this.updateSessionByModifyMsg).call(u,this)),this.core.eventBus.on("session/updateForClearMsg",(function(t,i){void 0===i&&(i=!0),t&&t.length>0&&forEach$1(t).call(t,(function(t){h.updateSession({id:t.sessionId,lastMsg:null,unread:0,unreadMsgs:[]},i)}))})),this.core.eventBus.on("session/updateForDeletedMsg",bind$1(m=this.updateSessionForDeletedMsg).call(m,this))},i.createSession=function createSession(t,i){try{var u=getAccountFromSessionId(t);return{id:t,scene:u.scene,to:u.accid,lastMsg:i,updateTime:i?i.time:0,unread:0,unreadMsgs:[],ack:0}}catch(i){throw this.logger.error("Failed to create session with "+t,i),new Error("Failed to create session with "+t)}},i.getSession=function getSession(t){validate({id:{type:"string",allowEmpty:!1}},t);var i=this.list.get(t.id);if(this.isSessionComplete(i))return i},i.getSessionWithUncomplete=function getSessionWithUncomplete(t){return this.list.get(t.id)},i.getAllSessions=function getAllSessions(){for(var t,i=[],u=_createForOfIteratorHelperLoose$2(this.list);!(t=u()).done;){var m=t.value;m[0];var h=m[1];this.isSessionComplete(h)&&i.push(h)}return i},i.getSessions=function getSessions(t){validate({limit:{type:"number",required:!1},lastSessionId:{type:"string",allowEmpty:!1,required:!1},desc:{type:"boolean",required:!1}},t);var i=[],u=t.limit,m=void 0===u?100:u,h=t.desc,v=void 0===h||h,M=t.lastSessionId,I=0;if(v){for(var S,T,C=_createForOfIteratorHelperLoose$2(this.list);!(T=C()).done;){var E=T.value,A=E[0],k=E[1];if(M===A)break;this.isSessionComplete(k)&&i.push(k)}return reverse$1(S=slice(i).call(i,-m)).call(S)}for(var R,w=_createForOfIteratorHelperLoose$2(this.list);!(R=w()).done;){var N=R.value,x=N[0],O=N[1];if(M)x===M&&(M=void 0);else if(this.isSessionComplete(O)){if(++I>m)break;i.push(O)}}return i},i.resetSessionUnreadCount=function resetSessionUnreadCount(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v,M,I,S,T,C=this;return ud.wrap((function _callee$(E){for(;;)switch(E.prev=E.next){case 0:if(validate({id:{type:"string",allowEmpty:!1}},t),validate({id:{type:"string",allowEmpty:!1}},t),u=t.id,m=this.list.get(u)){E.next=7;break}throw this.logger.warn("resetSessionUnreadCount: can not find session "+u),new Error("Session::canSessionResetUnreadCount: can not find session "+u);case 7:h=!1;try{h=this.unreadModule.canSessionResetUnreadCount(m)}catch(t){this.logger.warn(t)}if(!1!==h){E.next=11;break}return E.abrupt("return");case 11:return v=getAccountFromSessionId(u),M=v.accid,I=v.scene,S={to:M,timetag:(null===(i=null==m?void 0:m.lastMsg)||void 0===i?void 0:i.time)||m.updateTime||0},T="markSuperTeamSessionAck","superTeam"!==I&&(S.scene="p2p"===I?0:1,T="markSessionAck"),E.abrupt("return",this.core.sendCmd(T,S).then((function(){var t=C.storeUnreadByAck(u,S.timetag);t&&C.core.emit("updateSession",t)})));case 16:case"end":return E.stop()}}),_callee,this)})))},i.resetMultiSessionUnreadCount=function resetMultiSessionUnreadCount(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v,M,I,S,T,C,E,A,k,R,w=this;return ud.wrap((function _callee2$(N){for(;;)switch(N.prev=N.next){case 0:validate({ids:{type:"array",itemType:"string",min:1}},t),m=filter(i=map$6(u=t.ids).call(u,(function(t){return w.list.get(t)}))).call(i,(function(i,u){return!!i||(w.logger.warn("Session::canSessionResetUnreadCount: can not find session "+t.ids[u]),!1)})),h=this.unreadModule.filterSessionForResetUnreadCount(m),v=h.superTeam,M=h.p2pOrTeam,I=chunk(v.params,50),S=chunk(M.params,50),T=_createForOfIteratorHelperLoose$2(I);case 6:if((C=T()).done){N.next=13;break}return E=C.value,N.next=10,this.core.sendCmd(v.cmd,{datas:E});case 10:forEach$1(E).call(E,(function(t){var i=w.storeUnreadByAck(t.sessionId,t.timetag);i&&w.core.emit("updateSession",i)}));case 11:N.next=6;break;case 13:A=_createForOfIteratorHelperLoose$2(S);case 14:if((k=A()).done){N.next=21;break}return R=k.value,N.next=18,this.core.sendCmd(M.cmd,{datas:R});case 18:forEach$1(R).call(R,(function(t){var i=w.storeUnreadByAck(t.sessionId,t.timetag);i&&w.core.emit("updateSession",i)}));case 19:N.next=14;break;case 21:case"end":return N.stop()}}),_callee2,this)})))},i.resetAllSessionsUnreadCount=function resetAllSessionsUnreadCount(){var t,i=[];return forEach$1(t=this.list).call(t,(function(t){i.push(t.id)})),0===i.length?zi.resolve():this.resetMultiSessionUnreadCount({ids:i})},i.deleteSession=function deleteSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:if(validate({id:{type:"string",allowEmpty:!1},isSyncToServer:{type:"boolean",required:!1}},t),this.list.delete(t.id),!this.core.msgLog||!t.isSyncToServer){i.next=5;break}return i.next=5,this.core.msgLog.deleteRoamingMsgs({ids:[t.id]});case 5:case"end":return i.stop()}}),_callee3,this)})))},i.deleteAllSessionsFromLocal=function deleteAllSessionsFromLocal(){this.list.clear()},i.addStickTopSession=function addStickTopSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.stickTopService.addStickTopSession(t);case 2:return i=u.sent,this.list.set(i.id,i),u.abrupt("return",i);case 5:case"end":return u.stop()}}),_callee4,this)})))},i.deleteStickTopSession=function deleteStickTopSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i;return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.stickTopService.deleteStickTopSession(t);case 2:return i=u.sent,this.list.set(i.id,i),u.abrupt("return",i);case 5:case"end":return u.stop()}}),_callee5,this)})))},i.updateStickTopSession=function updateStickTopSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i;return ud.wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.stickTopService.updateStickTopSession(t);case 2:return i=u.sent,this.list.set(i.id,i),u.abrupt("return",i);case 5:case"end":return u.stop()}}),_callee6,this)})))},i.nimMultiSyncAddStickTopSessionHandler=function nimMultiSyncAddStickTopSessionHandler(t){var i=this.stickTopService.stickTopSessionHandler(t.content.data);this.list.set(i.id,i),this.core.emit("updateSession",i)},i.nimMultiSyncDeleteStickTopSessionHandler=function nimMultiSyncDeleteStickTopSessionHandler(t){var i=this.stickTopService.stickTopSessionHandler({id:t.content.data.id,updateTime:t.content.timetag,ext:""},!1);this.list.set(i.id,i),this.core.emit("updateSession",i)},i.nimMultiSyncUpdateStickTopSessionHandler=function nimMultiSyncUpdateStickTopSessionHandler(t){var i=this.stickTopService.stickTopSessionHandler(t.content.data);this.list.set(i.id,i),this.core.emit("updateSession",i)},i.nimSyncStickTopSessionsHandler=function nimSyncStickTopSessionsHandler(t){var i,u=this;if(this.core.eventBus.emit("sync/updateTimetag",{stickTopSessions:t.content.timetag}),t.content.isThereAnyChange){var m=t.content.datas,h=[];forEach$1(i=this.list).call(i,(function(t){var i;t&&(null===(i=null==t?void 0:t.stickTopInfo)||void 0===i?void 0:i.isStickOnTop)&&h.push(t)})),forEach$1(h).call(h,(function(t){var i=t.id;if(!find(m).call(m,(function(t){var u=getAccountFromSessionId(t.id,"|");return u.scene+"-"+u.accid===i}))){var u={},h=getAccountFromSessionId(i,"-"),v=h.scene,M=h.accid;u.id=v+"|"+M,u.ext="",u.isTop=!1,m.push(u)}})),forEach$1(m).call(m,(function(t){var i;!1===t.isTop?(delete t.isTop,i=u.stickTopService.stickTopSessionHandler(t,!1)):i=u.stickTopService.stickTopSessionHandler(t),u.list.set(i.id,i)}))}},i.updateSessionWithMsg=function updateSessionWithMsg(t){var i,u,m=!0,h=!0,v="boolean"!=typeof(null===(i=t.pushInfo)||void 0===i?void 0:i.needPushBadge)||(null===(u=t.pushInfo)||void 0===u?void 0:u.needPushBadge);try{m=!!this.unreadCountFilterFn(t)}catch(t){this.logger.error("session:updateSessionWithMsg, unreadCountFilterFn error",t)}try{h=!!this.lastMessageFilterFn(t)}catch(t){this.logger.error("session:updateSessionWithMsg, lastMessageFilterFn error",t)}var M=this.list.get(t.sessionId)||this.createSession(t.sessionId),I=!1;if(this.logger.log("session:updateSessionWithMsg, pending ",t.sessionId,t.idClient,t.idServer,h,m),h&&(!M.lastMsg||M.lastMsg.time<t.time||t.status===Yu[Yu.sending]||M.lastMsg.status===Yu[Yu.sending])&&(M.lastMsg=t,M.updateTime=t.time,I=!0),m&&v&&t.status===Yu[Yu.unread]&&t.time>(M.ack||0)){M.unread++;var S=M.unreadMsgs||[];S.unshift(t),sort(S).call(S,(function(t,i){return i.time-t.time})),M.unreadMsgs=S,I=!0}I&&(this.logger.log("session:updateSessionWithMsg updating ",M.id,M.unread,M.lastMsg&&M.lastMsg.idClient),this.list.set(M.id,M),this.core.emit("updateSession",M))},i.updateSessionByModifyMsg=function updateSessionByModifyMsg(t){var i=this.list.get(t.sessionId)||this.createSession(t.sessionId),u=i.unreadMsgs||[],m=findIndex$1(u).call(u,(function(i){return i.idClient===t.idClient}));m>-1&&(u[m]=t),i.unreadMsgs=u,this.list.set(i.id,i);var h=!0;try{h=!!this.lastMessageFilterFn(t)}catch(t){this.logger.error("session:updateSessionByModifyMsg, lastMessageFilterFn error",t)}h&&(i.lastMsg&&i.lastMsg.idClient!==t.idClient||(i.lastMsg=t,i.updateTime=t.time,this.logger.log("session:updateSessionByModifyMsg updating ",i.id,i.unread,i.lastMsg&&i.lastMsg.idClient),this.list.set(i.id,i),this.core.emit("updateSession",i)))},i.storeUnreadByAck=function storeUnreadByAck(t,i){var u=this.list.get(t)||this.createSession(t);if(!(u.ack&&i<u.ack)){var m=u.unreadMsgs||[],h=[],v=[],M=0;return u.unreadMsgs=[],m.length>0&&(forEach$1(m).call(m,(function(t){includes(v).call(v,t.idClient)||t.time>i&&(M++,v.push(t.idClient),h.push(t))})),u.unreadMsgs=sort(h).call(h,(function(t,i){return i.time-t.time}))),u.ack=i,u.unread=M,u.lastMsg&&"unread"===u.lastMsg.status&&i>=u.lastMsg.time&&(u.lastMsg.status="read"),this.list.set(t,u),u}this.logger.warn("storeUnreadByAck: not need update ack",t,i,u.ack)},i.updateSession=function updateSession(t,i){void 0===i&&(i=!0);var u=t.id,m=this.list.get(u)||this.createSession(t.id),h=Dt(m,t);return this.list.set(u,h),this.logger.log("updateSession: update",i,pick(t,["id","ack","unread"]),h.lastMsg&&h.lastMsg.idClient),i&&this.core.emit("updateSession",h),h},i.isSessionComplete=function isSessionComplete(t){return!!t&&(!!(t.id&&t.scene&&t.to)&&void 0!==t.lastMsg)},i.syncSessionAckHandler=function syncSessionAckHandler(t){var i,u,m=this,h=t.content.p2p||{},v=t.content.team.m_map||{};this.logger.log("syncSessionAck::",h,v),forEach$1(i=Ht(h)).call(i,(function(t){m.updateSession({id:"p2p-"+t,ack:h[t]},!1)})),forEach$1(u=Ht(v)).call(u,(function(t){m.updateSession({id:"team-"+t,ack:v[t]},!1)}))},i.syncSuperTeamSessionAckHandler=function syncSuperTeamSessionAckHandler(t){var i,u=this,m=t.content.superTeam.m_map;this.logger.log("syncSuperTeamSessionAck::",m),forEach$1(i=Ht(m)).call(i,(function(t){u.updateSession({id:"superTeam-"+t,ack:m[t]},!1)}))},i.syncMarkSessionAckHandler=function syncMarkSessionAckHandler(t){var i=t.content,u=(0===i.scene?"p2p":1===i.scene?"team":"superTeam")+"-"+i.to,m=this.list.get(u);if(m&&m.ack&&i.timetag<m.ack)this.logger.warn("syncMarkSessionAckHandler: "+u+" do not need update ack",m.ack,i.timetag);else{var h=this.storeUnreadByAck(u,i.timetag);h&&this.core.emit("updateSession",h)}},i.syncMarkSuperTeamSessionAckHandler=function syncMarkSuperTeamSessionAckHandler(t){t.content.scene=5,this.syncMarkSessionAckHandler(t)},i.onSyncDone=function onSyncDone(){var t,i,u,m=this,h=[];forEach$1(t=this.list).call(t,(function(t,i){h.push(m.storeUnreadByAck(i,t.ack||0))})),this.list.clear(),forEach$1(i=sort(h).call(h,(function(t,i){return t.updateTime-i.updateTime}))).call(i,(function(t){m.list.set(t.id,t)})),(h=sort(u=filter(h).call(h,(function(t){return m.isSessionComplete(t)}))).call(u,(function(t,i){return i.updateTime-t.updateTime}))).length>0&&this.core.emit("sessions",h)},i.onSyncMsgs=function onSyncMsgs(t){var i,u=this,m=this.list.get(t.sessionId),h=[];try{var v;h=filter(v=t.msgs).call(v,(function(t){var i,m,h="boolean"!=typeof(null===(i=t.pushInfo)||void 0===i?void 0:i.needPushBadge)||(null===(m=t.pushInfo)||void 0===m?void 0:m.needPushBadge);return u.unreadCountFilterFn(JSON.parse(Un(t)))&&h}))}catch(t){this.logger.error("session:onSyncMsgs, unreadCountFilterFn error ",t)}var M,I=[];try{var S;I=filter(S=t.msgs).call(S,(function(t){return u.lastMessageFilterFn(JSON.parse(Un(t)))}))}catch(t){this.logger.error("session:onSyncMsgs, lastMessageFilterFn error ",t)}I&&I.length>0&&(M=I[I.length-1],M=I[0].time>M.time?I[0]:M);var T=M?M.time:0;m||(m=M?this.createSession(t.sessionId,M):this.createSession(t.sessionId)),m.unreadMsgs=m.unreadMsgs?filter(i=concat(h).call(h,m.unreadMsgs)).call(i,(function(t){return t.status===Yu[Yu.unread]})):filter(h).call(h,(function(t){return t.status===Yu[Yu.unread]})),m.updateTime&&m.updateTime>=T||(m.updateTime=T),m.lastMsg&&m.lastMsg.time>=T||(m.lastMsg=M),this.list.set(m.id,m)},i.updateSessionForDeletedMsg=function updateSessionForDeletedMsg(t){var i,u=this,m={};forEach$1(t).call(t,(function(t){var i,h=t.to===u.core.account?t.from:t.to,v=t.scene+"-"+h,M=u.list.get(v);if(M){var I=some(i=M.unreadMsgs).call(i,(function(i){return i.idClient===t.idClient})),S=!0;try{S=!!u.unreadCountFilterFn(t)}catch(t){u.logger.error("session:updateSessionForDeletedMsg, unreadCountFilterFn error",t)}var T=M.ack||0;if(S&&I&&T<t.time&&t.from!==u.core.account&&M.unread>0&&(M.unread=M.unread-1,M.unreadMsgs&&M.unreadMsgs.length>0)){var C,E=function findIndex(t,i){t=t||[],i=i||{};for(var u=0;u<t.length;u++){var m=!0;for(var h in i)if(t[u][h]!==i[h]){m=!1;break}if(m)return u}return-1}(M.unreadMsgs,{idClient:t.idClient});E>=0&&splice(C=M.unreadMsgs).call(C,E,1)}M.lastMsg&&M.lastMsg.idClient===t.idClient&&(M.lastMsg=null),m[M.id]=!0}})),forEach$1(i=Ht(m)).call(i,(function(t){var i=u.list.get(t);i&&u.core.emit("updateSession",i)}))},i.multiSyncMsgReceiptHandler=function multiSyncMsgReceiptHandler(t){var i,u=null===(i=t.content)||void 0===i?void 0:i.msgReceiptTag;if(u){this.updateSessionMsgReceiptTime([u],!0),u.msgReceiptTime=u.time,u.sessionId="p2p-"+u.from,u.time,u.from;var m=__rest(u,["time","from"]);this.core.emit("msgReceipts",[m])}},i.syncMsgReceiptsHandler=function syncMsgReceiptsHandler(t){var i,u=null===(i=t.content)||void 0===i?void 0:i.msgReceipts;u&&this.updateSessionMsgReceiptTime(u,!1)},i.updateSessionMsgReceiptTime=function updateSessionMsgReceiptTime(t,i){var u=this;void 0===i&&(i=!0),t&&t.length>0&&forEach$1(t).call(t,(function(t){var m=u.list.get("p2p-"+t.from);m||(m=u.createSession("p2p-"+t.from));var h=Gd(t.time);m.msgReceiptTime&&m.msgReceiptTime>=h||(m.msgReceiptTime=h,m.lastMsg&&"sent"===m.lastMsg.status&&h>=m.lastMsg.time&&(m.lastMsg.status="receipt"),u.logger.log("session: update session "+m.id+" msgReceiptTime: "+m.msgReceiptTime),u.list.set(m.id,m),i&&u.core.emit("updateSession",m))}))},SessionService}(gp),wM=function(){function ModuleService(t){this.core=t}var t=ModuleService.prototype;return t.notifyAddTeamMembers=function notifyAddTeamMembers(t,i){this.core.emit("addTeamMembers",{team:t,accounts:i,members:generatorMembersByTeam(t,i)})},t.notifyUpdateTeamManagers=function notifyUpdateTeamManagers(t,i,u,m){this.core.emit("updateTeamManagers",{team:{teamId:t,memberUpdateTime:m},accounts:i,isManager:u,members:map$6(i).call(i,(function(i){return{id:t+"-"+i,account:i,type:u?"manager":"normal",updateTime:m}}))})},t.notifyRemoveTeamMembers=function notifyRemoveTeamMembers(t,i){this.core.emit("removeTeamMembers",{team:t,accounts:i})},t.notifyTransferTeam=function notifyTransferTeam(t,i,u){this.core.emit("transferTeam",{team:t,from:{id:t.teamId+"-"+i,type:"normal",account:i,updateTime:t.memberUpdateTime},to:{id:t.teamId+"-"+u,type:"owner",account:u,updateTime:t.memberUpdateTime}})},t.notifyUpdateTeamMembersMute=function notifyUpdateTeamMembersMute(t,i,u){this.core.emit("updateTeamMembersMute",{team:t,accounts:i,members:map$6(i).call(i,(function(i){return{id:t.teamId+"-"+i,account:i,teamId:t.teamId,mute:u,updateTime:t.memberUpdateTime}})),mute:u})},ModuleService}();function cloneDeep(t,i){if((i=new Sc).get(t))return t;if(t instanceof RegExp)return new RegExp(t);if(t instanceof Date)return new Date(t.getTime());if(Dn(t))return i.set(t,!0),map$6(t).call(t,(function(t){return cloneDeep(t,i)}));if("object"==typeof t&&null!==t){var u;i.set(t,!0);var m={};return forEach$1(u=Ht(t)).call(u,(function(u){m[u]=cloneDeep(t[u],i)})),m}return t}var NM=function(t){function TeamService(i){var u;return(u=t.call(this,"team",i)||this).myTeamMembersMap=new Sc,u.service=new wM(i),u.setListeners(),registerParser({cmdMap:zy,cmdConfig:Yy}),u}Nt(TeamService,t);var i=TeamService.prototype;return i.setListeners=function setListeners(){var t=this;this.core.eventBus.on("forwardReceive/team/updateMyMemberInfo",(function(i){t.emitMemberUpdate(i)})),this.core.eventBus.on("team/onNotification",(function(i){return t.notificationHandler(i)}))},i.reset=function reset(){this.myTeamMembersMap.clear()},i.mergeMyTeamMembers=function mergeMyTeamMembers(t){var i=this;forEach$1(t).call(t,(function(t){var u=t.teamId,m=i.myTeamMembersMap.get(u),h=Dt({},m,t);i.myTeamMembersMap.set(u,h)}))},i.getTeamInfo=function getTeamInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1}},t),m.next=3,this.core.sendCmd("getTeamInfo",{teamId:t.teamId});case 3:return i=m.sent,u=i.content.team,m.abrupt("return",formatTeam(u));case 6:case"end":return m.stop()}}),_callee,this)})))},i.getTeams=function getTeams(){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var t,i;return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.core.sendCmd("getTeams",{timetag:0});case 2:return t=u.sent,i=t.content.teams,u.abrupt("return",formatTeams(i));case 5:case"end":return u.stop()}}),_callee2,this)})))},i.getTeamsById=function getTeamsById(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u;return ud.wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamIds:{type:"array",itemType:"string"}},t),m.next=3,this.core.sendCmd("getTeamsById",{teamIds:t.teamIds});case 3:return i=m.sent,u=formatTeams(i.content.teams),m.abrupt("return",{teams:u,tids:i.content.tids});case 6:case"end":return m.stop()}}),_callee3,this)})))},i.createTeam=function createTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m;return ud.wrap((function _callee4$(h){for(;;)switch(h.prev=h.next){case 0:return validate({type:{type:"enum",values:["advanced","normal"]},name:{type:"string",allowEmpty:!1},level:{type:"number",required:!1},accounts:{type:"array",itemType:"string",required:!1},ps:{type:"string",allowEmpty:!0,max:5e3,required:!1},joinMode:{type:"enum",values:["noVerify","needVerify","rejectAll"],required:!1},beInviteMode:{type:"enum",values:["noVerify","needVerify"],required:!1},inviteMode:{type:"enum",values:["manager","all"],required:!1},updateTeamMode:{type:"enum",values:["manager","all"],required:!1},updateExtMode:{type:"enum",values:["manager","all"],required:!1},intro:{type:"string",allowEmpty:!0,required:!1},announcement:{type:"string",allowEmpty:!0,required:!1},avatar:{type:"string",allowEmpty:!0,required:!1},ext:{type:"string",allowEmpty:!0,required:!1}},t),i=generateTeam(t),h.next=4,this.core.sendCmd("createTeam",{team:i,accounts:t.accounts||[],ps:t.ps||""});case 4:return u=h.sent,m=formatTeam(u.content.team),this.core.eventBus.emit("forwardSend/team/created",m),h.abrupt("return",m);case 8:case"end":return h.stop()}}),_callee4,this)})))},i.dismissTeam=function dismissTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1}},t),i.next=3,this.core.sendCmd("dismissTeam",{teamId:t.teamId});case 3:case"end":return i.stop()}}),_callee5,this)})))},i.leaveTeam=function leaveTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1}},t),i.next=3,this.core.sendCmd("leaveTeam",{teamId:t.teamId});case 3:case"end":return i.stop()}}),_callee6,this)})))},i.transferTeam=function transferTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},account:{type:"string",allowEmpty:!1},leave:{type:"boolean"}},t),i.next=3,this.core.sendCmd("transferTeam",t);case 3:case"end":return i.stop()}}),_callee7,this)})))},i.updateTeamInfo=function updateTeamInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i;return ud.wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},joinMode:{type:"enum",values:["noVerify","needVerify","rejectAll"],required:!1},beInviteMode:{type:"enum",values:["noVerify","needVerify"],required:!1},inviteMode:{type:"enum",values:["manager","all"],required:!1},updateTeamMode:{type:"enum",values:["manager","all"],required:!1},updateExtMode:{type:"enum",values:["manager","all"],required:!1},intro:{type:"string",allowEmpty:!0,required:!1},announcement:{type:"string",allowEmpty:!0,required:!1},avatar:{type:"string",allowEmpty:!0,required:!1},ext:{type:"string",allowEmpty:!0,required:!1}},t),i=generateTeam(t),u.next=4,this.core.sendCmd("updateTeamInfo",{team:i});case 4:return u.abrupt("return",formatTeam(i));case 5:case"end":return u.stop()}}),_callee8,this)})))},i.getTeamMembers=function getTeamMembers(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var u,m;return ud.wrap((function _callee9$(h){for(;;)switch(h.prev=h.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string",required:!1}},t),h.next=3,this.core.sendCmd("getTeamMembers",{teamId:t.teamId,timetag:0});case 3:if(u=h.sent,m=formatTeamMembers(null===(i=u.content)||void 0===i?void 0:i.teamMembers),t.accounts&&t.accounts.length>0){h.next=7;break}return h.abrupt("return",m);case 7:return h.abrupt("return",filter(m).call(m,(function(i){var u;return null===(u=t.accounts)||void 0===u?void 0:includes(u).call(u,i.account)})));case 8:case"end":return h.stop()}}),_callee9,this)})))},i.getMutedTeamMembers=function getMutedTeamMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var i,u;return ud.wrap((function _callee10$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1}},t),m.next=3,this.core.sendCmd("getMutedTeamMembers",{teamId:t.teamId});case 3:return i=m.sent,u=i.content,m.abrupt("return",formatTeamMembers(u.teamMembers));case 6:case"end":return m.stop()}}),_callee10,this)})))},i.addTeamMembers=function addTeamMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string",min:1},ps:{type:"string",allowEmpty:!0,max:5e3,required:!1}},t),i.next=3,this.core.sendCmd("addTeamMembers",{teamId:t.teamId,accounts:t.accounts,ps:t.ps||"",attach:t.ext||""});case 3:case"end":return i.stop()}}),_callee11,this)})))},i.removeTeamMembers=function removeTeamMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string",min:1}},t),i.next=3,this.core.sendCmd("removeTeamMembers",{teamId:t.teamId,accounts:t.accounts});case 3:case"end":return i.stop()}}),_callee12,this)})))},i.applyTeam=function applyTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i;return ud.wrap((function _callee13$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},ps:{type:"string",allowEmpty:!0,max:5e3,required:!1}},t),u.next=3,this.core.sendCmd("applyTeam",{teamId:t.teamId,ps:t.ps||""});case 3:return i=u.sent,u.abrupt("return",formatTeam(i.content.team));case 5:case"end":return u.stop()}}),_callee13,this)})))},i.addTeamManagers=function addTeamManagers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){return ud.wrap((function _callee14$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",min:1,itemType:"string"}},t),i.next=3,this.core.sendCmd("addTeamManagers",t);case 3:case"end":return i.stop()}}),_callee14,this)})))},i.removeTeamManagers=function removeTeamManagers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){return ud.wrap((function _callee15$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",min:1,itemType:"string"}},t),i.next=3,this.core.sendCmd("removeTeamManagers",t);case 3:case"end":return i.stop()}}),_callee15,this)})))},i.updateMyMemberInfo=function updateMyMemberInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i,u,m;return ud.wrap((function _callee16$(h){for(;;)switch(h.prev=h.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},nickInTeam:{type:"string",allowEmpty:!0,required:!1},bitConfigMask:{type:"number",min:0,max:2,required:!1},ext:{type:"string",required:!1}},t),i=generatorTeamMemberForCmd({teamId:t.teamId,nickInTeam:t.nickInTeam,bitConfigMask:t.bitConfigMask,ext:t.ext}),h.next=4,this.core.sendCmd("updateMyMemberInfo",{teamMember:i});case 4:return u=formatTeamMember(Dt({updateTime:(new Date).getTime(),account:this.core.account},i)),m=this.emitMemberUpdate(u),this.core.eventBus.emit("forwardSend/team/updateMyMemberInfo",m),h.abrupt("return",u);case 8:case"end":return h.stop()}}),_callee16,this)})))},i.emitMemberUpdate=function emitMemberUpdate(t){t=formatTeamMember(t),this.mergeMyTeamMembers([t]),this.core.emit("updateTeamMember",t);var i=cloneDeep(this.myTeamMembersMap.get(t.teamId));return this.core.emit("myTeamMembers",[i]),i},i.updateMemberNick=function updateMemberNick(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){var i,u;return ud.wrap((function _callee17$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},account:{type:"string",allowEmpty:!1},nickInTeam:{type:"string",allowEmpty:!0}},t),i=generatorTeamMemberForCmd({teamId:t.teamId,nickInTeam:t.nickInTeam,account:t.account}),m.next=4,this.core.sendCmd("updateNickInTeam",{teamMember:i});case 4:return u=formatTeamMember(Dt({updateTime:(new Date).getTime()},i)),m.abrupt("return",u);case 6:case"end":return m.stop()}}),_callee17,this)})))},i.muteTeamMember=function muteTeamMember(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){return ud.wrap((function _callee18$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},account:{type:"string",allowEmpty:!1},mute:{type:"boolean"}},t),i.next=3,this.core.sendCmd("muteTeamMember",{teamId:t.teamId,account:t.account,mute:t.mute?1:0});case 3:case"end":return i.stop()}}),_callee18,this)})))},i.getTeamMemberInvitorAccid=function getTeamMemberInvitorAccid(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){var u,m;return ud.wrap((function _callee19$(h){for(;;)switch(h.prev=h.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string",max:200}},t),u={teamId:t.teamId},t.accounts&&t.accounts.length>0&&(u.accounts=t.accounts),h.next=5,this.core.sendCmd("getTeamMemberInvitorAccid",u);case 5:return m=h.sent,h.abrupt("return",(null===(i=m.content)||void 0===i?void 0:i.accountsMap)||{});case 7:case"end":return h.stop()}}),_callee19,this)})))},i.muteTeam=function muteTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){return ud.wrap((function _callee20$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},mute:{type:"boolean"}},t),i.next=3,this.core.sendCmd("muteTeam",{teamId:t.teamId,mute:t.mute?1:0});case 3:case"end":return i.stop()}}),_callee20,this)})))},i.passTeamApply=function passTeamApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){var i;return ud.wrap((function _callee21$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("passTeamApply",t);case 4:this.core.eventBus.emit("forwardSend/team/passTeamApply",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/team/passTeamApply",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee21,this,[[1,7]])})))},i.rejectTeamApply=function rejectTeamApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee22(){var i;return ud.wrap((function _callee22$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1},ps:{type:"string",max:5e3,required:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("rejectTeamApply",{teamId:t.teamId,from:t.from,ps:t.ps||""});case 4:this.core.eventBus.emit("forwardSend/team/rejectTeamApply",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/team/rejectTeamApply",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee22,this,[[1,7]])})))},i.acceptTeamInvite=function acceptTeamInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee23(){var i;return ud.wrap((function _callee23$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("acceptTeamInvite",t);case 4:this.core.eventBus.emit("forwardSend/team/acceptTeamInvite",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/team/acceptTeamInvite",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee23,this,[[1,7]])})))},i.rejectTeamInvite=function rejectTeamInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee24(){var i;return ud.wrap((function _callee24$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1},ps:{type:"string",max:5e3,required:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("rejectTeamInvite",{teamId:t.teamId,from:t.from,ps:t.ps||""});case 4:this.core.eventBus.emit("forwardSend/team/rejectTeamInvite",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/team/rejectTeamInvite",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee24,this,[[1,7]])})))},i.notifyTeamMsgReceiptsHandler=function notifyTeamMsgReceiptsHandler(t){var i,u=null===(i=t.content)||void 0===i?void 0:i.teamMsgReceipts;u&&u.length>0&&(this.core.emit("teamMsgReceipts",u),this.core.emit("msgReceipts",u))},i.syncTeamsHandler=function syncTeamsHandler(t){var i=t.content;this.core.eventBus.emit("sync/updateTimetag",{teams:Gd(i.timetag)});var u=null==i?void 0:i.teams;if(u&&u.length){var m=formatTeams(u);this.core.emit("teams",m)}},i.syncCreateTeamHandler=function syncCreateTeamHandler(t){var i=t.content,u=formatTeam(null==i?void 0:i.team),m=generatorMemberByTeam(u,u.owner,"owner");this.core.emit("createTeam",u,m)},i.syncUpdateTeamMemberHandler=function syncUpdateTeamMemberHandler(t){var i=t.content,u=formatTeamMember(null==i?void 0:i.teamMember);u.updateTime||(u.updateTime=(new Date).getTime()),this.mergeMyTeamMembers([u]),this.core.emit("updateTeamMember",u);var m=cloneDeep(this.myTeamMembersMap.get(u.teamId));this.core.emit("myTeamMembers",[m])},i.syncMyTeamMembersHandler=function syncMyTeamMembersHandler(t){var i,u=t.content;this.core.eventBus.emit("sync/updateTimetag",{myTeamMembers:Gd(u.timetag)});var m=null==u?void 0:map$6(i=u.teamMembers).call(i,(function(t){return formatTeamMember(t)}));this.mergeMyTeamMembers(m),this.core.emit("myTeamMembers",cloneDeep(m))},i.notificationHandler=function notificationHandler(t){var i=t.attach,u=t.scene,m=t.from,h=t.to,v=t.time,M=t.idServer,I=t.idClient,S=i.team,T=i.account,C=i.accounts,E=i.type;if("team"===u)switch(this.logger.getDebugMode()?this.logger.debug("team::recvNotification",M,I,i):this.logger.log("team::recvNotification",M,I,h,E,T,C),E){case"updateTeam":S.updateTime=v,this.core.emit("updateTeam",S);break;case"addTeamMembers":this.service.notifyAddTeamMembers(S,C);break;case"acceptTeamInvite":this.service.notifyAddTeamMembers(S,[m]);break;case"passTeamApply":this.service.notifyAddTeamMembers(S,[T]);break;case"addTeamManagers":this.service.notifyUpdateTeamManagers(h,C,!0,v);break;case"removeTeamManagers":this.service.notifyUpdateTeamManagers(h,C,!1,v);break;case"removeTeamMembers":this.service.notifyRemoveTeamMembers(S,C);break;case"leaveTeam":this.service.notifyRemoveTeamMembers(S,[m]);break;case"dismissTeam":this.core.emit("dismissTeam",{teamId:h});break;case"transferTeam":this.service.notifyTransferTeam(S,m,T);break;case"updateTeamMemberMute":this.service.notifyUpdateTeamMembersMute(S,[T],i.mute)}},TeamService}(gp),xM={"4_6":"syncOfflineSysMsgs","4_18":"syncOfflineSysMsgs","4_19":"syncRecallMsgOfflineAndRoaming","7_3":"onSysMsg","7_7":"sendCustomSysMsg","7_14":"onRecallMsg","21_18":"onRecallMsg","21_117":"onRecallMsg","7_15":"syncRecallMsgOfflineAndRoaming","21_19":"onSysMsg","21_16":"sendSuperTeamCustomSysMsg"},OM={sysMsg:Dt({time:0,type:1,to:2,from:3,content:4,attach:5,idServer:6,needSaveOffline:7,deletedIdClient:10,deletedIdServer:11,needcAntiSpam:12,antiSpamContent:13,deletedMsgCreateTime:14,deletedMsgFromNick:15,opeAccount:16,envConfig:21,callbackExt:22,isRoutable:105},lM)},PM=invertSerializeMap(OM),LM={onSysMsg:{service:"systemMessage",sid:7,cid:3,response:[{type:"Property",name:"sysMsg",reflectMapper:PM.sysMsg}]},sendCustomSysMsg:{service:"systemMessage",sid:7,cid:7,params:[{type:"Property",name:"sysMsg",reflectMapper:OM.sysMsg}]},sendSuperTeamCustomSysMsg:{service:"systemMessage",sid:21,cid:16,params:[{type:"Property",name:"sysMsg",reflectMapper:OM.sysMsg}]},sendFilterCustomSysMsg:{service:"systemMessage",sid:101,cid:7,params:[{type:"Property",name:"sysMsg",reflectMapper:OM.sysMsg}]},batchMarkRead:{service:"systemMessage",sid:4,cid:5,hasPacketResponse:!1,params:[{type:"Byte",name:"sid"},{type:"Byte",name:"cid"},{type:"LongArray",name:"ids"}]},onRecallMsg:{sid:7,cid:14,service:"systemMessage",response:[{type:"Property",name:"sysMsg",reflectMapper:PM.sysMsg}]},syncRecallMsgOfflineAndRoaming:{sid:7,cid:15,service:"systemMessage",response:[{type:"PropertyArray",name:"sysMsgs",reflectMapper:PM.sysMsg},{type:"Long",name:"timetag"},{type:"Byte",name:"type"}]},syncOfflineSysMsgs:{sid:4,cid:9,service:"systemMessage",response:[{type:"PropertyArray",name:"sysMsgs",reflectMapper:PM.sysMsg}]}},VM=function(t){function SystemMessageService(i){var u;return(u=t.call(this,"systemMessage",i)||this).sysMsgUnread={total:0,friend:0,msg:0,team:0,superTeam:0},u.core.eventBus.on("logined",(function(){u.initEventListeners()})),registerParser({cmdMap:xM,cmdConfig:LM}),u}Nt(SystemMessageService,t);var i=SystemMessageService.prototype;return i.initEventListeners=function initEventListeners(){var t=this;this.core.eventBus.on("systemMessage/passFriendApply",(function(i){t.core.emit("updateSystemMessages",[{idServer:i.idServer,from:i.account,state:"pass",type:"friendRequest"}])})),this.core.eventBus.on("systemMessage/rejectFriendApply",(function(i){t.core.emit("updateSystemMessages",[{idServer:i.idServer,from:i.account,state:"decline",type:"friendRequest"}])}))},i.doMarkSysMsgAck=function doMarkSysMsgAck(t){var i=[],u=[],m=["customSuperTeam"];forEach$1(t).call(t,(function(t){t.idServer&&(includes(m).call(m,t.type)?u.push(t.idServer):i.push(t.idServer))})),i.length>0&&this.core.sendCmd("batchMarkRead",{sid:"7",cid:"3",ids:i}),u.length>0&&this.core.sendCmd("batchMarkRead",{sid:"21",cid:"19",ids:u})},i.sendCustomSysMsg=function sendCustomSysMsg(t){var i=this;validate({to:{type:"string",allowEmpty:!1},type:{type:"enum",values:["customP2p","customTeam","customSuperTeam"]},attach:{type:"string",allowEmpty:!1},setting:{type:"object",rules:{needSaveOffline:{type:"boolean",required:!1},env:{type:"string",allowEmpty:!1,required:!1}},required:!1},pushInfo:{type:"object",required:!1,rules:cM}},t);var u="customSuperTeam"===t.type?"sendSuperTeamCustomSysMsg":"sendCustomSysMsg";return this.core.sendCmd(u,{sysMsg:generatorSysMsgForCmd$1(t)}).then((function(){i.logger.log("sendCustomSysMsg success")})).catch((function(t){throw i.logger.error("sendCustomSysMsg failed",t.message),t}))},i.onSysMsgHandler=function onSysMsgHandler(t){var i,u=null===(i=t.content)||void 0===i?void 0:i.sysMsg;if(u){var m=formatSystemMessage(u=fillIdServer(t,t.content.sysMsg,"idServer"),this.logger,iM.default);this.core.emit("sysMsg",m),this.doMarkSysMsgAck([m])}else this.logger.warn("onSysMsg no content.sysMsg")},i.syncOfflineSysMsgsHandler=function syncOfflineSysMsgsHandler(t){var i,u=this;if(t.content.sysMsgs&&t.content.sysMsgs.length>0){var m=map$6(i=t.content.sysMsgs).call(i,(function(t){return formatSystemMessage(t,u.logger,iM.leave)}));this.core.emit("syncSysMsgs",m),this.doMarkSysMsgAck(m)}},i.onRecallMsgHandler=function onRecallMsgHandler(t){var i,u=null===(i=t.content)||void 0===i?void 0:i.sysMsg;if(u){var m=formatDeletedMsgs([u=fillIdServer(t,t.content.sysMsg,"idServer")],getSceneFromRecallSysMsg(+u.type));this.core.eventBus.emit("session/updateForDeletedMsg",m);var h=formatSystemMessage(u,this.logger,iM.default);this.core.emit("sysMsg",h),this.doMarkSysMsgAck([h])}else this.logger.warn("onSysMsg no content.sysMsg")},i.syncRecallMsgOfflineAndRoamingHandler=function syncRecallMsgOfflineAndRoamingHandler(t){var i=this,u=t.content,m=u.timetag,h=u.type,v=u.sysMsgs,M=Gd(h),I=1===M?iM.leave:iM.roam,S=map$6(v).call(v,(function(t){return formatSystemMessage(t,i.logger,I)}));1===M&&this.doMarkSysMsgAck(S),this.core.eventBus.emit("sync/updateTimetag",{recallMsg:m}),this.core.emit("syncSysMsgs",S)},SystemMessageService}(gp);function reverseFriend(t){var i=["bitsExtension","createTime","updateTime","passRelationShip","relationShip","source"],u=Dt({},t);return forEach$1(i).call(i,(function(t){void 0!==u[t]&&(u[t]=Gd(u[t]))})),void 0!==u.relationShip&&(u.valid=1===u.relationShip),u}var UM={1:"addFriend",2:"applyFriend",3:"passFriendApply",4:"rejectFriendApply"};var DM={"12_4":"getFriends","12_1":"friendReuqest","12_2":"deleteFriend","12_3":"updateFriend","12_5":"syncFriends","12_6":"syncFriendUsers","12_101":"syncFriendRequest","12_102":"syncDeleteFriend","12_103":"syncUpdateFriend"},BM={updateFriendTag:{account:4,alias:8,ext:10},delFriendParams:{delAlias:1},friendTag:{account:4,relationShip:5,passRelationShip:6,source:7,alias:8,bitsExtension:9,ext:10,createTime:11,updateTime:12,serverex:13},userTag:{account:1,nick:3,avatar:4,sign:5,gender:6,email:7,birth:8,tel:9,ext:10,createTime:12,updateTime:13}},qM=invertSerializeMap(BM),FM={getFriends:{sid:12,cid:4,service:"friend",params:[{type:"Long",name:"timetag"}],response:[{type:"PropertyArray",name:"friends",reflectMapper:qM.friendTag},{type:"Long",name:"timetag"}]},friendReuqest:{sid:12,cid:1,service:"friend",params:[{type:"String",name:"account"},{type:"Byte",name:"type"},{type:"String",name:"ps"}]},deleteFriend:{sid:12,cid:2,service:"friend",params:[{type:"String",name:"account"},{type:"Property",name:"delFriendParams",reflectMapper:BM.delFriendParams}]},updateFriend:{sid:12,cid:3,service:"friend",params:[{type:"Property",name:"updateFriendTag",reflectMapper:BM.updateFriendTag}]},syncFriends:{sid:12,cid:5,service:"friend",response:[{type:"PropertyArray",name:"friends",entity:"friendTag",reflectMapper:qM.friendTag},{type:"Long",name:"timetag"}]},syncFriendUsers:{sid:12,cid:6,service:"friend",response:[{type:"PropertyArray",name:"users",entity:"userTag",reflectMapper:qM.userTag},{type:"Long",name:"timetag"}]},syncFriendRequest:{sid:12,cid:101,service:"friend",params:[{type:"String",name:"account"},{type:"Byte",name:"type"},{type:"String",name:"ps"}],response:[{type:"String",name:"account"},{type:"Byte",name:"type"},{type:"String",name:"ps"}]},syncDeleteFriend:{sid:12,cid:102,service:"friend",response:[{type:"String",name:"account"}]},syncUpdateFriend:{sid:12,cid:103,service:"friend",response:[{type:"Property",name:"friend",reflectMapper:qM.friendTag}]}},GM=function(t){function FriendService(i){var u;return u=t.call(this,"friend",i)||this,registerParser({cmdMap:DM,cmdConfig:FM}),u}Nt(FriendService,t);var i=FriendService.prototype;return i.getFriends=function getFriends(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.core.sendCmd("getFriends",{timetag:0});case 2:return i=m.sent,u=(null===(t=i.content)||void 0===t?void 0:t.friends)||[],u=map$6(u).call(u,(function(t){return reverseFriend(t)})),m.abrupt("return",u);case 6:case"end":return m.stop()}}),_callee,this)})))},i.addFriend=function addFriend(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i;return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:return validate({account:{type:"string",allowEmpty:!1},ps:{type:"string",allowEmpty:!1,required:!1}},t),u.next=3,this.core.sendCmd("friendReuqest",{account:t.account,type:1,ps:t.ps||""});case 3:return i=(new Date).getTime(),this.core.eventBus.emit("forwardSend/friend/addFriend",t.account),u.abrupt("return",{account:t.account,createTime:i,updateTime:i,valid:!0,source:0,passRelationShip:1,relationShip:1,bitsExtension:0});case 6:case"end":return u.stop()}}),_callee2,this)})))},i.applyFriend=function applyFriend(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return validate({account:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("friendReuqest",{account:t.account,type:2,ps:t.ps||""});case 3:case"end":return i.stop()}}),_callee3,this)})))},i.passFriendApply=function passFriendApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i=this;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return validate({account:{type:"string",allowEmpty:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("friendReuqest",{account:t.account,type:3,ps:t.ps||""}).then((function(u){return i.core.eventBus.emit("systemMessage/passFriendApply",t),u}));case 4:this.core.eventBus.emit("forwardSend/friend/passFriendApply",t.account),u.next=11;break;case 7:throw u.prev=7,u.t0=u.catch(1),this.core.eventBus.emit("forwardSend/friend/passFriendApply",t.account,u.t0),u.t0;case 11:case"end":return u.stop()}}),_callee4,this,[[1,7]])})))},i.rejectFriendApply=function rejectFriendApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i=this;return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:return validate({account:{type:"string",allowEmpty:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("friendReuqest",{account:t.account,type:4,ps:t.ps||""}).then((function(u){return i.core.eventBus.emit("systemMessage/rejectFriendApply",t),u}));case 4:this.core.eventBus.emit("forwardSend/friend/rejectFriendApply",t.account,t.ps),u.next=11;break;case 7:throw u.prev=7,u.t0=u.catch(1),this.core.eventBus.emit("forwardSend/friend/rejectFriendApply",t.account,t.ps,u.t0),u.t0;case 11:case"end":return u.stop()}}),_callee5,this,[[1,7]])})))},i.deleteFriend=function deleteFriend(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:return validate({account:{type:"string",allowEmpty:!1},delAlias:{type:"boolean"}},t),i.next=3,this.core.sendCmd("deleteFriend",{account:t.account,delFriendParams:{delAlias:!0===t.delAlias?1:0}});case 3:this.core.eventBus.emit("forwardSend/friend/deleteFriend",t.account);case 4:case"end":return i.stop()}}),_callee6,this)})))},i.updateFriend=function updateFriend(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return validate({account:{type:"string",allowEmpty:!1},alias:{type:"string"},ext:{type:"string",required:!1}},t),i.next=3,this.core.sendCmd("updateFriend",{updateFriendTag:t});case 3:this.core.eventBus.emit("forwardSend/friend/updateFriend",t);case 4:case"end":return i.stop()}}),_callee7,this)})))},i.syncFriendRequestHandler=function syncFriendRequestHandler(t){var i=function formatFriendRequest(t){var i=Dt({},t);try{i.ps=i.ps&&JSON.parse(i.ps)}catch(t){}if(i.type=UM[i.type],"addFriend"===i.type||"passFriendApply"===i.type){var u=(new Date).getTime();i.friend={account:t.account,alias:"",createTime:u,ext:"",updateTime:u,valid:!0}}return i}(t.content);this.core.emit("syncFriend",i)},i.syncDeleteFriendHandler=function syncDeleteFriendHandler(t){var i=t.content.account;this.logger.log("friend::emit syncFriendAction: deleteFriend "+i),this.core.emit("syncFriend",{type:"deleteFriend",account:i})},i.syncUpdateFriendHandler=function syncUpdateFriendHandler(t){var i=reverseFriend(t.content.friend);this.logger.log("friend::emit syncFriendAction: updateFriend, ",null==i?void 0:i.account),this.core.emit("syncFriend",{type:"updateFriend",friend:i})},i.syncFriendsHandler=function syncFriendsHandler(t){var i=t.content;this.core.eventBus.emit("sync/updateTimetag",{friends:Gd(i.timetag)});var u=null==i?void 0:i.friends;if(u&&u.length){var m=map$6(u).call(u,(function(t){return reverseFriend(t)}));this.core.emit("friends",m)}},i.syncFriendUsersHandler=function syncFriendUsersHandler(t){var i=t.content;this.core.eventBus.emit("sync/updateTimetag",{friendUsers:Gd(i.timetag)});var u=null==i?void 0:i.users;if(u&&u.length){var m=map$6(u).call(u,(function(t){return formatUser(t)}));this.core.emit("users",m)}},FriendService}(gp);function formatSubscribes(t){return t&&t.length>0?map$6(t).call(t,(function(t){return function formatSubscribe(t){var i=Dt({},t),u=["subscribeTime","time"];return forEach$1(u).call(u,(function(t){i[t]&&(i[t]=Gd(i[t]))})),i}(t)})):[]}function formatEvent(t){if(!t)return t;var i=t.serverExt,u=__rest(t,["serverExt"]),m=["time","type","value"];if(forEach$1(m).call(m,(function(t){u[t]&&(u[t]=Gd(u[t]))})),u.clientType&&(u.clientType=getEnumKeyByEnumValue(Ku,u.clientType)||""),i)try{u.ext=JSON.parse(i),"string"==typeof u.ext[0]&&(u.ext=u.ext[0])}catch(t){}return u}var HM={"14_1":"publishEvent","14_2":"pushEvent","14_3":"subscribeEvent","14_4":"unSubscribeEventsByAccounts","14_5":"unSubscribeEventsByType","14_6":"querySubscribeEventsByAccounts","14_7":"querySubscribeEventsByType","14_9":"pushEvents"},jM={msgEvent:{type:1,value:2,idClient:3,ext:4,validTime:5,broadcastType:6,sync:7,validTimeType:8,durable:9,time:10,idServer:11,clientType:12,serverConfig:13,serverExt:14,appid:101,account:103,enableMultiClient:104,consid:106},msgEventSubscribe:{type:1,subscribeTime:2,sync:3,to:102,from:104,time:105}},$M=invertSerializeMap(jM),zM={publishEvent:{sid:14,cid:1,service:"event",params:[{type:"Property",name:"msgEvent",reflectMapper:jM.msgEvent}],response:[{type:"Property",name:"msgEvent",reflectMapper:$M.msgEvent}]},pushEvent:{sid:14,cid:2,service:"event",response:[{type:"Property",name:"msgEvent",reflectMapper:$M.msgEvent}]},subscribeEvent:{sid:14,cid:3,service:"event",params:[{type:"Property",name:"msgEventSubscribe",reflectMapper:jM.msgEventSubscribe},{type:"StrArray",name:"accounts"}],response:[{type:"StrArray",name:"accounts"}]},unSubscribeEventsByAccounts:{sid:14,cid:4,service:"event",params:[{type:"Property",name:"msgEventSubscribe",reflectMapper:jM.msgEventSubscribe},{type:"StrArray",name:"accounts"}],response:[{type:"StrArray",name:"accounts"}]},unSubscribeEventsByType:{sid:14,cid:5,service:"event",params:[{type:"Property",name:"msgEventSubscribe",reflectMapper:jM.msgEventSubscribe}]},querySubscribeEventsByAccounts:{sid:14,cid:6,service:"event",params:[{type:"Property",name:"msgEventSubscribe",reflectMapper:jM.msgEventSubscribe},{type:"StrArray",name:"accounts"}],response:[{type:"PropertyArray",name:"msgEventSubscribes",reflectMapper:$M.msgEventSubscribe}]},querySubscribeEventsByType:{sid:14,cid:7,service:"event",params:[{type:"Property",name:"msgEventSubscribe",reflectMapper:jM.msgEventSubscribe}],response:[{type:"PropertyArray",name:"msgEventSubscribes",reflectMapper:$M.msgEventSubscribe}]},pushEvents:{sid:14,cid:9,service:"event",response:[{type:"PropertyArray",name:"msgEvents",reflectMapper:$M.msgEvent}]}},WM=function(t){function EventService(i){var u;return u=t.call(this,"event",i)||this,registerParser({cmdMap:HM,cmdConfig:zM}),u}Nt(EventService,t);var i=EventService.prototype;return i.publishEvent=function publishEvent(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h;return ud.wrap((function _callee$(v){for(;;)switch(v.prev=v.next){case 0:return validate({type:{type:"number"},value:{type:"number"},ext:{type:"string",required:!1},validTime:{type:"number",min:60,max:2592e3,required:!1},broadcastType:{type:"number",required:!1},sync:{type:"boolean",required:!1}},t),u=Dt(Dt({validTime:t.validTime||604800,broadcastType:t.broadcastType||2},t),{idClient:jd(),sync:!0===t.sync?1:0}),v.next=4,this.core.sendCmd("publishEvent",{msgEvent:u});case 4:return m=v.sent,h=(null===(i=m.content)||void 0===i?void 0:i.msgEvent)||{},v.abrupt("return",formatEvent(h));case 7:case"end":return v.stop()}}),_callee,this)})))},i.subscribeEvent=function subscribeEvent(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u,m,h;return ud.wrap((function _callee2$(v){for(;;)switch(v.prev=v.next){case 0:return validate({type:{type:"number"},accounts:{type:"array",itemType:"string",max:100},subscribeTime:{type:"number",min:60,max:2592e3,required:!1}},t),u=Dt(Dt({subscribeTime:2592e3},t),{sync:!0===t.sync?1:0}),v.next=4,this.core.sendCmd("subscribeEvent",{msgEventSubscribe:u,accounts:t.accounts});case 4:return m=v.sent,h=(null===(i=m.content)||void 0===i?void 0:i.accounts)||[],v.abrupt("return",{failedAccounts:h});case 7:case"end":return v.stop()}}),_callee2,this)})))},i.unSubscribeEvents=function unSubscribeEvents(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var u,m,h;return ud.wrap((function _callee3$(v){for(;;)switch(v.prev=v.next){case 0:if(validate({type:{type:"number"},accounts:{type:"array",itemType:"string",max:100,required:!1}},t),u={type:t.type},!(t.accounts&&t.accounts.length>0)){v.next=9;break}return v.next=5,this.core.sendCmd("unSubscribeEventsByAccounts",{msgEventSubscribe:u,accounts:t.accounts});case 5:h=v.sent,m=(null===(i=h.content)||void 0===i?void 0:i.accounts)||[],v.next=12;break;case 9:return v.next=11,this.core.sendCmd("unSubscribeEventsByType",{msgEventSubscribe:u});case 11:m=[];case 12:return v.abrupt("return",{failedAccounts:m});case 13:case"end":return v.stop()}}),_callee3,this)})))},i.querySubscribeEvents=function querySubscribeEvents(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var u;return ud.wrap((function _callee4$(m){for(;;)switch(m.prev=m.next){case 0:if(validate({type:{type:"number"},accounts:{type:"array",itemType:"string",max:100,required:!1}},t),!(t.accounts&&t.accounts.length>0)){m.next=7;break}return m.next=4,this.core.sendCmd("querySubscribeEventsByAccounts",{msgEventSubscribe:{type:t.type},accounts:t.accounts});case 4:u=m.sent,m.next=10;break;case 7:return m.next=9,this.core.sendCmd("querySubscribeEventsByType",{msgEventSubscribe:{type:t.type}});case 9:u=m.sent;case 10:return m.abrupt("return",formatSubscribes(null===(i=u.content)||void 0===i?void 0:i.msgEventSubscribes));case 11:case"end":return m.stop()}}),_callee4,this)})))},i.pushEventHandler=function pushEventHandler(t){var i,u=(null===(i=t.content)||void 0===i?void 0:i.msgEvent)||{};this.core.emit("pushEvents",[formatEvent(u)])},i.pushEventsHandler=function pushEventsHandler(t){var i,u=(null===(i=t.content)||void 0===i?void 0:i.msgEvents)||{};this.core.emit("pushEvents",function formatEvents(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatEvent(t)})):[]}(u))},EventService}(gp);function generateThreadMsgsParams(t){var i={scene:Wu[t.scene],from:t.threadMsgFromAccount,to:t.threadMsgToAccount,time:t.threadMsgTime,idServer:t.threadMsgIdServer},u={limit:t.limit<100?t.limit:100,beginTime:"number"==typeof t.beginTime?t.beginTime:0,reverse:!0===reverse$1(t)?1:0};return t.lastMsgId&&(u.lastMsgId=t.lastMsgId),{msg:i,threadMsgReq:u}}var KM,YM={"23_1":"getThreadMsgs","23_2":"getMsgsByIdServer"},QM={msg:uM,threadMsgReq:{beginTime:1,endTime:2,lastMsgId:3,limit:4,reverse:5},threadMsgsMeta:{total:1,lastMsgTime:2}},JM=invertSerializeMap(QM),XM={getThreadMsgs:{sid:23,cid:1,service:"msgExtend",params:[{type:"Property",name:"msg",reflectMapper:QM.msg},{type:"Property",name:"threadMsgReq",reflectMapper:QM.threadMsgReq}],response:[{type:"Property",name:"threadMsg",reflectMapper:JM.msg},{type:"Property",name:"threadMsgsMeta",reflectMapper:JM.threadMsgsMeta},{type:"PropertyArray",name:"msgs",reflectMapper:JM.msg}]},getMsgsByIdServer:{sid:23,cid:2,service:"msgExtend",params:[{type:"PropertyArray",name:"reqMsgs",reflectMapper:QM.msg}],response:[{type:"PropertyArray",name:"msgs",reflectMapper:JM.msg}]}},ZM=function(t){function MsgExtendService(i){var u;return u=t.call(this,"msgExtend",i)||this,registerParser({cmdMap:YM,cmdConfig:XM}),u}Nt(MsgExtendService,t);var i=MsgExtendService.prototype;return i.getThreadMsgs=function getThreadMsgs(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v,M,I,S;return ud.wrap((function _callee$(T){for(;;)switch(T.prev=T.next){case 0:return validate({scene:{type:"enum",values:getEnumKeys(Wu)},threadMsgFromAccount:{type:"string",allowEmpty:!1},threadMsgIdServer:{type:"string",allowEmpty:!1},threadMsgTime:{type:"number"},threadMsgToAccount:{type:"string",allowEmpty:!1},beginTime:{type:"number",required:!1},endTime:{type:"number",required:!1},lastMsgId:{type:"string",allowEmpty:!1,required:!1},limit:{type:"number",min:1,max:100,required:!1},reverse:{type:"boolean",required:!1}},t),T.next=3,this.core.sendCmd("getThreadMsgs",generateThreadMsgsParams(t));case 3:return u=T.sent,m=u.content,h=m.msgs,v=m.threadMsg,M=u.content.threadMsgsMeta,I=getSessionId(v,this.core.account),S=null===(i=this.core.session)||void 0===i?void 0:i.getSessionWithUncomplete({id:I}),h=formatMsgs$1(h,S?{account:this.core.account,sessionAck:S.ack,msgReceiptTime:S.msgReceiptTime}:{account:this.core.account}),v=formatMsg$1(v,S?{account:this.core.account,sessionAck:S.ack,msgReceiptTime:S.msgReceiptTime}:{account:this.core.account}),T.abrupt("return",{msgs:h,threadMsg:v,total:Gd(M.total),timetag:Gd(M.lastMsgTime)});case 11:case"end":return T.stop()}}),_callee,this)})))},i.getMsgsByIdServer=function getMsgsByIdServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v=this;return ud.wrap((function _callee2$(M){for(;;)switch(M.prev=M.next){case 0:return validate({reqMsgs:{type:"array",rules:{scene:{type:"enum",values:getEnumKeys(Wu)},from:{type:"string",allowEmpty:!1},to:{type:"string",allowEmpty:!1},idServer:{type:"string",allowEmpty:!1},time:{type:"number"}},min:1,max:100}},t),M.next=3,this.core.sendCmd("getMsgsByIdServer",{reqMsgs:map$6(i=t.reqMsgs).call(i,(function(t){return Dt(Dt({},t),{scene:getEnumKeyByEnumValue(Wu,t.scene)})}))});case 3:return m=M.sent,h=map$6(u=m.content.msgs).call(u,(function(t){var i,u=getSessionId(t,v.core.account),m=null===(i=v.core.session)||void 0===i?void 0:i.getSessionWithUncomplete({id:u});return formatMsg$1(t,m?{account:v.core.account,sessionAck:m.ack,msgReceiptTime:m.msgReceiptTime}:{account:v.core.account})})),M.abrupt("return",h);case 6:case"end":return M.stop()}}),_callee2,this)})))},MsgExtendService}(gp);!function(t){t[t.ASC=1]="ASC",t[t.DESC=2]="DESC"}(KM||(KM={}));var eI,tI={"7_6":"getHistoryMsgs","7_9":"deleteRoamingMsgs","4_24":"syncClearServerHistoryMsgs","7_18":"clearHistoryMsgsFromServer","7_118":"multiSyncClearServerHistoryMsgs","7_26":"nimFtsCloudMsgLogsAggWithSession","7_27":"nimFtsCloudMsgLogs"},rI={msg:uM,clearHistoryMsgsFromServerReqTag:{type:0,otherAccid:1,isDeleteRoam:2,toTid:3,isSyncSelf:4,time:6,ext:7},clearMsgsParamsWithSync:{type:0,otherAccid:1,isDeleteRoam:2,toTid:3,isSyncSelf:4,fromAccid:5,time:6,ext:7},ftsReqTag:{keyword:1,fromTime:2,toTime:3,sessionLimit:4,msglogsLimit:5,orderRule:6,p2pSessionList:7,teamSessionList:8,senderList:9,msgTypeList:10,msgSubTypeList:11}},nI=invertSerializeMap(rI),aI={deleteRoamingMsgs:{sid:7,cid:9,service:"msgLog",params:[{type:"StrArray",name:"ids"}]},getHistoryMsgs:{sid:7,cid:6,params:[{type:"String",name:"to"},{type:"Long",name:"beginTime"},{type:"Long",name:"endTime"},{type:"Long",name:"lastMsgId"},{type:"Int",name:"limit"},{type:"Bool",name:"reverse"},{type:"LongArray",name:"msgTypes"}],response:[{type:"PropertyArray",name:"msgs",reflectMapper:nI.msg}],service:"msgLog"},clearHistoryMsgsFromServer:{sid:7,cid:18,params:[{type:"Property",name:"clearHistoryMsgsFromServerReqTag",reflectMapper:rI.clearHistoryMsgsFromServerReqTag}],response:[{type:"Long",name:"timetag"}],service:"msgLog"},multiSyncClearServerHistoryMsgs:{sid:7,cid:118,response:[{type:"Property",name:"data",reflectMapper:nI.clearMsgsParamsWithSync}],service:"msgLog"},syncClearServerHistoryMsgs:{sid:4,cid:24,service:"msgLog",response:[{type:"PropertyArray",name:"datas",reflectMapper:nI.clearMsgsParamsWithSync}]},nimFtsCloudMsgLogsAggWithSession:{sid:7,cid:26,service:"msgLog",params:[{type:"Property",name:"tag",reflectMapper:rI.ftsReqTag}],response:[{type:"PropertyArray",name:"datas",reflectMapper:nI.msg}]},nimFtsCloudMsgLogs:{sid:7,cid:27,service:"msgLog",params:[{type:"Property",name:"tag",reflectMapper:rI.ftsReqTag}],response:[{type:"PropertyArray",name:"datas",reflectMapper:nI.msg}]}};!function(t){t[t.p2p=1]="p2p",t[t.team=2]="team"}(eI||(eI={}));var iI={type:{type:"enum",values:eI},isDeleteRoam:{type:"boolean"},isSyncSelf:{type:"boolean"},time:{type:"number"}};function formatClearResult(t){var i=format(iI,t);return{sessionId:"p2p"===i.type?"p2p-"+i.otherAccid:"team-"+i.toTid,time:i.time}}var oI={orderRule:{type:"enum",values:KM}};function generateFtsTagForCmd(t){var i,u=format(oI,t);Dn(u.msgTypeList)&&(u.msgTypeList=map$6(i=u.msgTypeList).call(i,(function(t){return zu[t]})).join(","));var m=["p2pSessionList","teamSessionList","senderList","msgSubTypeList"];return forEach$1(m).call(m,(function(t){Dn(u[t])&&(u[t]=u[t].join(","))})),u}var sI=function(t){function MsgLogService(i){var u;return(u=t.call(this,"msgLog",i)||this).onV2ClearHistoryMessage=function(t){var i=formatClearResult(t);u.core.eventBus.emit("session/updateForClearMsg",[i],!0)},registerParser({cmdMap:tI,cmdConfig:aI}),u.registerListener(),u}Nt(MsgLogService,t);var i=MsgLogService.prototype;return i.registerListener=function registerListener(){this.core.eventBus.on("forwardReceive/msgLog/clearHistoryMsgsFromServer",this.onV2ClearHistoryMessage)},i.deleteRoamingMsgs=function deleteRoamingMsgs(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:validate({ids:{type:"array",itemType:"string"}},t),i=[],m.prev=2,i=map$6(u=t.ids).call(u,(function(t){var i=getAccountFromSessionId(t);return i.scene+"|"+i.accid})),m.next=10;break;case 6:throw m.prev=6,m.t0=m.catch(2),this.logger.error("Failed to delete roaming msgs with "+t.ids,m.t0),new Error("Failed to create session with "+t.ids);case 10:return m.next=12,this.core.sendCmd("deleteRoamingMsgs",{ids:i});case 12:case"end":return m.stop()}}),_callee,this,[[2,6]])})))},i.getHistoryMsgs=function getHistoryMsgs(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var m,h,v,M,I,S,T;return ud.wrap((function _callee2$(C){for(;;)switch(C.prev=C.next){case 0:return"function"!=typeof(null===(i=this.core.sync)||void 0===i?void 0:i.getSyncDoneFlag)||this.core.sync.getSyncDoneFlag()||this.logger.warn("Please call getHistoryMsgs after syncdone event"),validate({scene:{type:"enum",values:getEnumKeys(Wu)},to:{type:"string",allowEmpty:!1},beginTime:{type:"number",required:!1},endTime:{type:"number",required:!1},limit:{type:"number",min:1,max:100,required:!1},reverse:{type:"boolean",required:!1},lastMsgId:{type:"string",required:!1,allowEmpty:!1},asc:{type:"boolean",required:!1},msgTypes:{type:"array",itemType:"string",required:!1}},t),h="p2p"===t.scene?"getHistoryMsgs":"team"===t.scene?"getHistoryTeamMsgs":"getHistorySuperTeamMsgs",C.next=5,this.core.sendCmd(h,assignOptions({beginTime:0,endTime:0,lastMsgId:0,limit:100,reverse:!1},Dt(Dt({},t),{msgTypes:t.msgTypes?map$6(m=t.msgTypes).call(m,(function(t){return zu[t]})):[]})));case 5:if(v=C.sent,(M=v.content).msgs&&M.msgs.length>0){C.next=9;break}return C.abrupt("return",[]);case 9:if(I=getSessionId(M.msgs[0],this.core.account),S=null===(u=this.core.session)||void 0===u?void 0:u.getSessionWithUncomplete({id:I}),T=formatMsgs$1(M.msgs,S?{account:this.core.account,sessionAck:S.ack,msgReceiptTime:S.msgReceiptTime}:{account:this.core.account}),!0!==t.asc){C.next=14;break}return C.abrupt("return",sort(T).call(T,(function(t,i){return t.time-i.time})));case 14:return C.abrupt("return",T);case 15:case"end":return C.stop()}}),_callee2,this)})))},i.clearHistoryMsgsFromServer=function clearHistoryMsgsFromServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:return validate({scene:{type:"enum",values:["p2p","team"]},to:{type:"string",allowEmpty:!1},ext:{type:"string",required:!1},isSyncSelf:{type:"boolean",required:!1}},t),(i=Dt(Dt({isDeleteRoam:1},t),{type:"team"===t.scene?2:1,isSyncSelf:!0===t.isSyncSelf?1:0}))[2===i.type?"toTid":"otherAccid"]=t.to,h.next=5,this.core.sendCmd("clearHistoryMsgsFromServer",{clearHistoryMsgsFromServerReqTag:i});case 5:return u=h.sent,m=u.content,this.core.eventBus.emit("session/updateForClearMsg",[{sessionId:t.scene+"-"+t.to}],!0),this.core.eventBus.emit("forwardSend/msgLog/clearHistoryMsgsFromServer",Dt(Dt({},i),{time:m.timetag})),h.abrupt("return",m);case 10:case"end":return h.stop()}}),_callee3,this)})))},i.multiSyncClearServerHistoryMsgsHandler=function multiSyncClearServerHistoryMsgsHandler(t){var i=formatClearResult(t.content.data);this.core.eventBus.emit("session/updateForClearMsg",[i],!0),this.core.emit("clearServerHistoryMsgs",[i])},i.ftsCloudMsgLogs=function ftsCloudMsgLogs(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return i.abrupt("return",this.baseFtsCloudMsgLogs(t,"nimFtsCloudMsgLogs"));case 1:case"end":return i.stop()}}),_callee4,this)})))},i.ftsCloudMsgLogsAggWithSession=function ftsCloudMsgLogsAggWithSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return i.abrupt("return",this.baseFtsCloudMsgLogs(t,"nimFtsCloudMsgLogsAggWithSession"));case 1:case"end":return i.stop()}}),_callee5,this)})))},i.baseFtsCloudMsgLogs=function baseFtsCloudMsgLogs(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var u,m,h,v=this;return ud.wrap((function _callee6$(M){for(;;)switch(M.prev=M.next){case 0:if(validate({keyword:{type:"string",allowEmpty:!1},fromTime:{type:"number",required:!1},toTime:{type:"number",required:!1},sessionLimit:{type:"number",required:!1},msglogsLimit:{type:"number",required:!1},orderRule:{type:"enum",values:getEnumKeys(KM),required:!1},p2pSessionList:{type:"array",itemType:"string",required:!1},teamSessionList:{type:"array",itemType:"string",required:!1},senderList:{type:"array",itemType:"string",required:!1},msgTypeList:{type:"array",itemType:"enum",values:getEnumKeys(zu),required:!1},msgSubTypeList:{type:"array",itemType:"number",required:!1}},t),!(t.fromTime&&t.toTime&&t.toTime<t.fromTime)){M.next=3;break}throw new Ql("Request parameter error: toTime should be greater than fromTime",t,"");case 3:return m=generateFtsTagForCmd(t),M.next=6,this.core.sendCmd(i,{tag:m});case 6:return h=M.sent,M.abrupt("return",map$6(u=h.content.datas).call(u,(function(t){var i,u=getSessionId(t,v.core.account),m=null===(i=v.core.session)||void 0===i?void 0:i.getSessionWithUncomplete({id:u});return formatMsg$1(t,m?{account:v.core.account,sessionAck:m.ack,msgReceiptTime:m.msgReceiptTime}:{account:v.core.account})})));case 8:case"end":return M.stop()}}),_callee6,this)})))},i.syncClearServerHistoryMsgsHandler=function syncClearServerHistoryMsgsHandler(t){var i=function formatClearResults(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatClearResult(t)})):[]}(t.content.datas);this.core.emit("clearServerHistoryMsgs",i)},MsgLogService}(gp),cI={"22_1":"requestProxy","22_2":"onRequestProxy"},lI={requestProxyTag:{zone:1,path:2,method:3,header:4,body:5},requestProxyMsgTag:{from:1,body:2,time:3}},dI=invertSerializeMap(lI),uI={requestProxy:{sid:22,cid:1,service:"passThrough",params:[{type:"Property",name:"requestProxyTag",reflectMapper:lI.requestProxyTag}],response:[{type:"Property",name:"requestProxyTag",reflectMapper:dI.requestProxyTag}]},onRequestProxy:{sid:22,cid:2,service:"passThrough",response:[{type:"Property",name:"proxyMsg",reflectMapper:dI.requestProxyMsgTag}]}},pI=function(t){function PassThroughService(i){var u;return(u=t.call(this,"passThrough",i)||this).core=i,registerParser({cmdMap:cI,cmdConfig:uI}),u}Nt(PassThroughService,t);var i=PassThroughService.prototype;return i.request=function request(t){return validate({path:{type:"string",allowEmpty:!1}},t),this.core.sendCmd("requestProxy",{requestProxyTag:t}).then((function(t){return t.content.requestProxyTag}))},i.onRequestProxyHandler=function onRequestProxyHandler(t){var i=t.content.proxyMsg;i&&i.time&&(i.time=+i.time),this.core.emit("proxyMsg",i)},PassThroughService}(gp),mI=invert({none:0,normal:1,all:3}),hI=invert({normal:0,advanced:1}),gI=invert({normal:0,owner:1,manager:2}),vI={noVerify:0,needVerify:1,rejectAll:2},fI=invert(vI),yI={needVerify:0,noVerify:1},MI=invert(yI),II={manager:0,all:1},_I=invert(II),SI={manager:0,all:1},TI=invert(SI),CI={manager:0,all:1},bI=invert(CI);function formatSuperTeam(t){var i,u=["teamId"],m=["level","memberNum","memberUpdateTime","createTime","updateTime"],h=["valid","validToCurrentUser","mute"],v={type:hI,muteType:mI,joinMode:fI,beInviteMode:MI,inviteMode:_I,updateTeamMode:TI,updateExtMode:bI};t.bits;var M=__rest(t,["bits"]);return forEach$1(u).call(u,(function(t){M[t]&&(M[t]=M[t].toString())})),forEach$1(m).call(m,(function(t){void 0!==M[t]&&(M[t]=Gd(M[t]))})),forEach$1(h).call(h,(function(t){void 0!==M[t]&&(M[t]=1===Gd(M[t]))})),forEach$1(i=Ht(v)).call(i,(function(t){void 0!==M[t]&&(M[t]=v[t][M[t]]||M[t])})),M}function formatSuperTeams(t){return t&&t.length>0?map$6(t).call(t,(function(t){return formatSuperTeam(t)})):[]}function generateSuperTeam(t){var i,u=Dt({},t),m=["avatar","name","intro","announcement","ext"],h={joinMode:vI,beInviteMode:yI,inviteMode:II,updateTeamMode:SI,updateExtMode:CI};return forEach$1(m).call(m,(function(t){void 0!==u[t]&&(u[t]=u[t].toString())})),forEach$1(i=Ht(h)).call(i,(function(t){void 0!==u[t]&&(u[t]=h[t][u[t]])})),u}function generatorSuperTeamMemberForCmd(t){var i=["teamId","ext","account","nickInTeam"],u={};return void 0!==t.bitConfigMask&&(u.bits=Gd(t.bitConfigMask)),forEach$1(i).call(i,(function(i){t[i]&&(u[i]=t[i].toString())})),Object.prototype.hasOwnProperty.call(t,"nickInTeam")&&(u.nickInTeam=t.nickInTeam),u}function formatSuperTeamMember(t){var i,u=["teamId"],m=["joinTime","updateTime","bitConfigMask"],h=["active","valid","mute"],v={type:gI},M=t.bits,I=__rest(t,["bits"]);return void 0!==M&&(I.muteTeam=1===Gd(M),I.bitConfigMask=M),I.id=I.teamId+"-"+I.account,forEach$1(u).call(u,(function(t){I[t]&&(I[t]=I[t].toString())})),forEach$1(m).call(m,(function(t){void 0!==I[t]&&(I[t]=Gd(I[t]))})),forEach$1(h).call(h,(function(t){void 0!==I[t]&&(I[t]=1===Gd(I[t]))})),forEach$1(i=Ht(v)).call(i,(function(t){void 0!==I[t]&&(I[t]=v[t][I[t]]||I[t])})),I}function formatSuperTeamMembers(t){return t&&t.length>0?map$6(t).call(t,(function(t){return formatSuperTeamMember(t)})):[]}function generatorMemberBySuperTeam(t,i,u){return void 0===u&&(u="normal"),{id:t.teamId+"-"+i,teamId:t.teamId,account:i,type:u,nickInTeam:"",muteTeam:!1,mute:!1,joinTime:t.memberUpdateTime,updateTime:t.memberUpdateTime,active:!0,valid:!0}}function generatorMembersBySuperTeam(t,i,u){return void 0===u&&(u="normal"),i&&i.length>0?map$6(i).call(i,(function(i){return generatorMemberBySuperTeam(t,i,u)})):[]}var EI=function(){function ModuleService(t){this.core=t}var t=ModuleService.prototype;return t.notifyAddSuperTeamMembers=function notifyAddSuperTeamMembers(t,i){this.core.emit("addSuperTeamMembers",{team:t,accounts:i,members:generatorMembersBySuperTeam(t,i)})},t.notifyUpdateSuperTeamManagers=function notifyUpdateSuperTeamManagers(t,i,u,m){this.core.emit("updateSuperTeamManagers",{team:{teamId:t,memberUpdateTime:m},accounts:i,isManager:u,members:map$6(i).call(i,(function(i){return{id:t+"-"+i,type:u?"manager":"normal",account:i,updateTime:m}}))})},t.notifyRemoveSuperTeamMembers=function notifyRemoveSuperTeamMembers(t,i){this.core.emit("removeSuperTeamMembers",{team:t,accounts:i})},t.notifyTransferSuperTeam=function notifyTransferSuperTeam(t,i,u){this.core.emit("transferSuperTeam",{team:t,from:{id:t.teamId+"-"+i,account:i,type:"normal",updateTime:t.memberUpdateTime},to:{id:t.teamId+"-"+u,account:u,type:"owner",updateTime:t.memberUpdateTime}})},t.notifyUpdateSuperTeamMembersMute=function notifyUpdateSuperTeamMembersMute(t,i,u){this.core.emit("updateSuperTeamMembersMute",{team:t,accounts:i,members:map$6(i).call(i,(function(i){return{id:t.teamId+"-"+i,account:i,teamId:t.teamId,mute:u,updateTime:t.memberUpdateTime}})),mute:u})},ModuleService}(),AI={"21_5":"addSuperTeamMembers","21_6":"removeSuperTeamMembers","21_7":"leaveSuperTeam","21_8":"updateSuperTeamInfo","21_9":"getSuperTeamInfo","21_12":"getSuperTeams","21_15":"getSuperTeamMembers","21_10":"updateMySuperTeamMemberInfo","21_20":"applySuperTeam","21_21":"passSuperTeamApply","21_22":"rejectSuperTeamApply","21_23":"acceptSuperTeamInvite","21_24":"rejectSuperTeamInvite","21_26":"addSuperTeamManagers","21_27":"removeSuperTeamManagers","21_28":"muteSuperTeam","21_29":"muteSuperTeamMembers","21_30":"updateSuperTeamMemberNick","21_31":"transferSuperTeam","21_33":"getSuperTeamMembersByAccounts","21_34":"queryMuteSuperTeamMembers","21_101":"syncCreateSuperTeam","21_109":"syncSuperTeams","21_110":"syncUpdateSuperTeamMember","21_111":"syncMySuperTeamMembers"},kI={superTeam:{teamId:1,name:3,type:4,owner:5,level:6,selfCustom:7,valid:8,memberNum:9,memberUpdateTime:10,createTime:11,updateTime:12,validToCurrentUser:13,intro:14,announcement:15,joinMode:16,bits:17,ext:18,serverExt:19,avatar:20,beInviteMode:21,inviteMode:22,updateTeamMode:23,updateExtMode:24,mute:100,muteType:101},superTeamMember:{teamId:1,account:3,type:4,nickInTeam:5,bits:7,active:8,valid:9,updateTime:11,ext:12,mute:13,invitorAccid:14,joinTime:15}},RI=invertSerializeMap(kI),wI={getSuperTeamInfo:{sid:21,cid:9,service:"superTeam",params:[{type:"Long",name:"teamId"}],response:[{type:"Property",name:"superTeam",reflectMapper:RI.superTeam}]},getSuperTeams:{sid:21,cid:12,service:"superTeam",params:[{type:"Long",name:"timetag"}],response:[{type:"PropertyArray",name:"superTeams",reflectMapper:RI.superTeam},{type:"Bool",name:"isAll"},{type:"Long",name:"timetag"}]},updateSuperTeamInfo:{sid:21,cid:8,service:"superTeam",params:[{type:"Property",name:"superTeam",reflectMapper:kI.superTeam}],response:[{type:"Long",name:"time"}]},addSuperTeamMembers:{sid:21,cid:5,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"},{type:"String",name:"ps"}],response:[{type:"StrArray",name:"abortedAccidList"},{type:"Long",name:"time"}]},removeSuperTeamMembers:{sid:21,cid:6,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},addSuperTeamManagers:{sid:21,cid:26,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},removeSuperTeamManagers:{sid:21,cid:27,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"}]},applySuperTeam:{sid:21,cid:20,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"String",name:"ps"}],response:[{type:"Property",name:"superTeam",reflectMapper:RI.superTeam}]},transferSuperTeam:{sid:21,cid:31,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"String",name:"account"},{type:"Bool",name:"leave"}]},muteSuperTeam:{sid:21,cid:28,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"Int",name:"mute"}]},muteSuperTeamMembers:{sid:21,cid:29,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"StrArray",name:"accounts"},{type:"Int",name:"mute"}]},updateSuperTeamMemberNick:{sid:21,cid:30,service:"superTeam",params:[{type:"Property",name:"teamMember",reflectMapper:kI.superTeamMember}]},updateMySuperTeamMemberInfo:{sid:21,cid:10,service:"superTeam",params:[{type:"Property",name:"teamMember",reflectMapper:kI.superTeamMember}]},getSuperTeamMembersByAccounts:{sid:21,cid:33,service:"superTeam",params:[{type:"StrArray",name:"memberIds"}],response:[{type:"PropertyArray",name:"superTeamMembers",reflectMapper:RI.superTeamMember}]},getSuperTeamMembers:{sid:21,cid:15,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"Long",name:"joinTime"},{type:"Int",name:"limit"},{type:"Bool",name:"reverse"}],response:[{type:"PropertyArray",name:"superTeamMembers",reflectMapper:RI.superTeamMember}]},queryMuteSuperTeamMembers:{sid:21,cid:34,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"Long",name:"joinTime"},{type:"Int",name:"limit"},{type:"Bool",name:"reverse"}],response:[{type:"PropertyArray",name:"superTeamMembers",reflectMapper:RI.superTeamMember}]},leaveSuperTeam:{sid:21,cid:7,service:"superTeam",params:[{type:"Long",name:"teamId"}]},passSuperTeamApply:{sid:21,cid:21,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}]},rejectSuperTeamApply:{sid:21,cid:22,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},acceptSuperTeamInvite:{sid:21,cid:23,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"}]},rejectSuperTeamInvite:{sid:21,cid:24,service:"superTeam",params:[{type:"Long",name:"teamId"},{type:"String",name:"from"},{type:"String",name:"ps"}]},syncSuperTeams:{sid:21,cid:109,service:"superTeam",response:[{type:"PropertyArray",name:"teams",reflectMapper:RI.superTeam},{type:"Bool",name:"isAll"},{type:"Long",name:"timetag"}]},syncCreateSuperTeam:{sid:21,cid:101,service:"superTeam",response:[{type:"Property",name:"superTeam",reflectMapper:RI.superTeam}]},syncUpdateSuperTeamMember:{sid:21,cid:110,service:"superTeam",response:[{type:"Property",name:"teamMember",reflectMapper:RI.superTeamMember}]},syncMySuperTeamMembers:{sid:21,cid:111,ext:"sync",service:"superTeam",response:[{type:"PropertyArray",name:"teamMembers",reflectMapper:RI.superTeamMember},{type:"Long",name:"timetag"}]}},NI=function(t){function SuperTeamService(i){var u;return(u=t.call(this,"superTeam",i)||this).mySuperTeamMembersMap=new Sc,u.service=new EI(i),registerParser({cmdMap:AI,cmdConfig:wI}),u.setListeners(),u}Nt(SuperTeamService,t);var i=SuperTeamService.prototype;return i.setListeners=function setListeners(){var t=this;this.core.eventBus.on("forwardReceive/superTeam/updateMyMemberInfo",(function(i){t.emitMemberUpdate(i)})),this.core.eventBus.on("team/onNotification",(function(i){return t.notificationHandler(i)}))},i.reset=function reset(){this.mySuperTeamMembersMap.clear()},i.mergeMySuperTeamMembers=function mergeMySuperTeamMembers(t){var i=this;forEach$1(t).call(t,(function(t){var u=t.teamId,m=i.mySuperTeamMembersMap.get(u),h=Dt({},m,t);i.mySuperTeamMembersMap.set(u,h)}))},i.getSuperTeamInfo=function getSuperTeamInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1}},t),m.next=3,this.core.sendCmd("getSuperTeamInfo",{teamId:t.teamId});case 3:return i=m.sent,u=i.content.superTeam,m.abrupt("return",formatSuperTeam(u));case 6:case"end":return m.stop()}}),_callee,this)})))},i.getSuperTeams=function getSuperTeams(){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var t,i;return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.core.sendCmd("getSuperTeams",{timetag:0});case 2:return t=u.sent,i=t.content.superTeams,u.abrupt("return",formatSuperTeams(i));case 5:case"end":return u.stop()}}),_callee2,this)})))},i.updateSuperTeamInfo=function updateSuperTeamInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},name:{type:"string",allowEmpty:!1,required:!1},joinMode:{type:"enum",values:["noVerify","needVerify","rejectAll"],required:!1},beInviteMode:{type:"enum",values:["noVerify","needVerify"],required:!1},inviteMode:{type:"enum",values:["manager","all"],required:!1},updateTeamMode:{type:"enum",values:["manager","all"],required:!1},updateExtMode:{type:"enum",values:["manager","all"],required:!1},intro:{type:"string",allowEmpty:!0,required:!1},announcement:{type:"string",allowEmpty:!0,required:!1},avatar:{type:"string",allowEmpty:!0,required:!1},ext:{type:"string",allowEmpty:!0,required:!1}},t),i=generateSuperTeam(t),u.next=4,this.core.sendCmd("updateSuperTeamInfo",{superTeam:i});case 4:return u.abrupt("return",formatSuperTeam(i));case 5:case"end":return u.stop()}}),_callee3,this)})))},i.addSuperTeamMembers=function addSuperTeamMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string",min:1},ps:{type:"string",allowEmpty:!0,max:5e3,required:!1}},t),i.next=3,this.core.sendCmd("addSuperTeamMembers",{teamId:t.teamId,accounts:t.accounts,ps:t.ps||"",attach:t.ext||""});case 3:case"end":return i.stop()}}),_callee4,this)})))},i.removeSuperTeamMembers=function removeSuperTeamMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string",min:1}},t),i.next=3,this.core.sendCmd("removeSuperTeamMembers",{teamId:t.teamId,accounts:t.accounts});case 3:case"end":return i.stop()}}),_callee5,this)})))},i.addSuperTeamManagers=function addSuperTeamManagers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",min:1,itemType:"string"}},t),i.next=3,this.core.sendCmd("addSuperTeamManagers",t);case 3:case"end":return i.stop()}}),_callee6,this)})))},i.removeSuperTeamManagers=function removeSuperTeamManagers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",min:1,itemType:"string"}},t),i.next=3,this.core.sendCmd("removeSuperTeamManagers",t);case 3:case"end":return i.stop()}}),_callee7,this)})))},i.applySuperTeam=function applySuperTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i;return ud.wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},ps:{type:"string",allowEmpty:!0,max:5e3,required:!1}},t),u.next=3,this.core.sendCmd("applySuperTeam",{teamId:t.teamId,ps:t.ps||""});case 3:return i=u.sent,u.abrupt("return",formatSuperTeam(i.content.superTeam));case 5:case"end":return u.stop()}}),_callee8,this)})))},i.transferSuperTeam=function transferSuperTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){return ud.wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},account:{type:"string",allowEmpty:!1},leave:{type:"boolean"}},t),i.next=3,this.core.sendCmd("transferSuperTeam",t);case 3:case"end":return i.stop()}}),_callee9,this)})))},i.muteSuperTeam=function muteSuperTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){return ud.wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},mute:{type:"boolean"}},t),i.next=3,this.core.sendCmd("muteSuperTeam",{teamId:t.teamId,mute:t.mute?1:0});case 3:case"end":return i.stop()}}),_callee10,this)})))},i.muteSuperTeamMembers=function muteSuperTeamMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string"},mute:{type:"boolean"}},t),i.next=3,this.core.sendCmd("muteSuperTeamMembers",{teamId:t.teamId,accounts:t.accounts,mute:t.mute?1:0});case 3:case"end":return i.stop()}}),_callee11,this)})))},i.updateMemberNick=function updateMemberNick(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i,u;return ud.wrap((function _callee12$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},account:{type:"string",allowEmpty:!1},nickInTeam:{type:"string",allowEmpty:!0}},t),i=generatorSuperTeamMemberForCmd({teamId:t.teamId,nickInTeam:t.nickInTeam,account:t.account}),m.next=4,this.core.sendCmd("updateSuperTeamMemberNick",{teamMember:i});case 4:return u=formatSuperTeamMember(Dt({updateTime:(new Date).getTime()},i)),m.abrupt("return",u);case 6:case"end":return m.stop()}}),_callee12,this)})))},i.updateMyMemberInfo=function updateMyMemberInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i,u,m;return ud.wrap((function _callee13$(h){for(;;)switch(h.prev=h.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},nickInTeam:{type:"string",allowEmpty:!0,required:!1},bitConfigMask:{type:"number",min:0,max:2,required:!1},ext:{type:"string",required:!1}},t),i=generatorSuperTeamMemberForCmd({teamId:t.teamId,nickInTeam:t.nickInTeam,bitConfigMask:t.bitConfigMask,ext:t.ext}),h.next=4,this.core.sendCmd("updateMySuperTeamMemberInfo",{teamMember:i});case 4:return u=formatSuperTeamMember(Dt({updateTime:(new Date).getTime(),account:this.core.account},i)),m=this.emitMemberUpdate(u),this.core.eventBus.emit("forwardSend/superTeam/updateMyMemberInfo",m),h.abrupt("return",u);case 8:case"end":return h.stop()}}),_callee13,this)})))},i.getSuperTeamMembersByAccounts=function getSuperTeamMembersByAccounts(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var u,m,h;return ud.wrap((function _callee14$(v){for(;;)switch(v.prev=v.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},accounts:{type:"array",itemType:"string",max:20,min:1}},t),m=map$6(u=t.accounts).call(u,(function(i){return t.teamId+"|"+i})),v.next=4,this.core.sendCmd("getSuperTeamMembersByAccounts",{memberIds:m});case 4:return h=v.sent,v.abrupt("return",formatSuperTeamMembers(null===(i=h.content)||void 0===i?void 0:i.superTeamMembers));case 6:case"end":return v.stop()}}),_callee14,this)})))},i.getSuperTeamMembers=function getSuperTeamMembers(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){var u;return ud.wrap((function _callee15$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},joinTime:{type:"number",min:0,required:!1},limit:{type:"number",min:1,max:1e3,required:!1},reverse:{type:"boolean",required:!1}},t),m.next=3,this.core.sendCmd("getSuperTeamMembers",Dt({joinTime:0,limit:100,reverse:!1},t));case 3:return u=m.sent,m.abrupt("return",formatSuperTeamMembers(null===(i=u.content)||void 0===i?void 0:i.superTeamMembers));case 5:case"end":return m.stop()}}),_callee15,this)})))},i.queryMuteMembers=function queryMuteMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i,u;return ud.wrap((function _callee16$(m){for(;;)switch(m.prev=m.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},joinTime:{type:"number",min:0,required:!1},limit:{type:"number",min:1,required:!1},reverse:{type:"boolean",required:!1}},t),m.next=3,this.core.sendCmd("queryMuteSuperTeamMembers",Dt({limit:100,joinTime:0,reverse:!1},t));case 3:return i=m.sent,u=i.content,m.abrupt("return",formatSuperTeamMembers(u.superTeamMembers));case 6:case"end":return m.stop()}}),_callee16,this)})))},i.leaveSuperTeam=function leaveSuperTeam(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){return ud.wrap((function _callee17$(i){for(;;)switch(i.prev=i.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1}},t),i.next=3,this.core.sendCmd("leaveSuperTeam",{teamId:t.teamId});case 3:case"end":return i.stop()}}),_callee17,this)})))},i.passSuperTeamApply=function passSuperTeamApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){var i;return ud.wrap((function _callee18$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("passSuperTeamApply",t);case 4:this.core.eventBus.emit("forwardSend/superTeam/passTeamApply",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/superTeam/passTeamApply",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee18,this,[[1,7]])})))},i.rejectSuperTeamApply=function rejectSuperTeamApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){var i;return ud.wrap((function _callee19$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1},ps:{type:"string",max:5e3,required:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("rejectSuperTeamApply",{teamId:t.teamId,from:t.from,ps:t.ps||""});case 4:this.core.eventBus.emit("forwardSend/superTeam/rejectSuperTeamApply",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/superTeam/rejectSuperTeamApply",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee19,this,[[1,7]])})))},i.acceptSuperTeamInvite=function acceptSuperTeamInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){var i;return ud.wrap((function _callee20$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("acceptSuperTeamInvite",t);case 4:this.core.eventBus.emit("forwardSend/superTeam/acceptSuperTeamInvite",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/superTeam/acceptSuperTeamInvite",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee20,this,[[1,7]])})))},i.rejectSuperTeamInvite=function rejectSuperTeamInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){var i;return ud.wrap((function _callee21$(u){for(;;)switch(u.prev=u.next){case 0:return validate({teamId:{type:"string",regExp:/\d+/,allowEmpty:!1},from:{type:"string",allowEmpty:!1},ps:{type:"string",max:5e3,required:!1}},t),u.prev=1,u.next=4,this.core.sendCmd("rejectSuperTeamInvite",{teamId:t.teamId,from:t.from,ps:t.ps||""});case 4:this.core.eventBus.emit("forwardSend/superTeam/rejectSuperTeamInvite",t),u.next=12;break;case 7:throw u.prev=7,u.t0=u.catch(1),i=u.t0,this.core.eventBus.emit("forwardSend/superTeam/rejectSuperTeamInvite",t,null==i?void 0:i.code),u.t0;case 12:case"end":return u.stop()}}),_callee21,this,[[1,7]])})))},i.emitMemberUpdate=function emitMemberUpdate(t){t=formatSuperTeamMember(t),this.mergeMyTeamMembers([t]),this.core.emit("updateTeamMember",t);var i=cloneDeep(this.mySuperTeamMembersMap.get(t.teamId));return this.core.emit("myTeamMembers",[i]),i},i.mergeMyTeamMembers=function mergeMyTeamMembers(t){var i=this;forEach$1(t).call(t,(function(t){var u=t.teamId,m=i.mySuperTeamMembersMap.get(u),h=Dt({},m,t);i.mySuperTeamMembersMap.set(u,h)}))},i.syncSuperTeamsHandler=function syncSuperTeamsHandler(t){var i=t.content;this.core.eventBus.emit("sync/updateTimetag",{superTeams:Gd(i.timetag)});var u=null==i?void 0:i.teams;if(u&&u.length){var m=formatSuperTeams(u);this.core.emit("superTeams",m)}},i.syncCreateSuperTeamHandler=function syncCreateSuperTeamHandler(t){var i=t.content,u=formatSuperTeam(null==i?void 0:i.superTeam),m=generatorMemberBySuperTeam(u,u.owner,"owner");this.core.emit("createSuperTeam",u,m)},i.syncUpdateSuperTeamMemberHandler=function syncUpdateSuperTeamMemberHandler(t){var i=t.content,u=formatSuperTeamMember(null==i?void 0:i.teamMember);u.updateTime||(u.updateTime=(new Date).getTime()),this.mergeMySuperTeamMembers([u]),this.core.emit("updateSuperTeamMember",u);var m=cloneDeep(this.mySuperTeamMembersMap.get(u.teamId));this.core.emit("mySuperTeamMembers",[m])},i.syncMySuperTeamMembersHandler=function syncMySuperTeamMembersHandler(t){var i,u=t.content;this.core.eventBus.emit("sync/updateTimetag",{mySuperTeamMembers:Gd(u.timetag)});var m=null==u?void 0:map$6(i=u.teamMembers).call(i,(function(t){return formatSuperTeamMember(t)}));this.mergeMySuperTeamMembers(m),this.core.emit("mySuperTeamMembers",cloneDeep(m))},i.notificationHandler=function notificationHandler(t){var i=t.attach,u=t.scene,m=t.from,h=t.to,v=t.time,M=t.idServer,I=t.idClient,S=i.team,T=i.account,C=i.accounts,E=i.type;if("superTeam"===u)switch(this.logger.getDebugMode()?this.logger.debug("superTeam::recvNotification",M,I,i):this.logger.log("superTeam::recvNotification",M,I,h,E,T,C),E){case"updateSuperTeam":S.updateTime=v,this.core.emit("updateSuperTeam",S);break;case"addSuperTeamMembers":this.service.notifyAddSuperTeamMembers(S,C);break;case"acceptSuperTeamInvite":this.service.notifyAddSuperTeamMembers(S,[m]);break;case"passSuperTeamApply":this.service.notifyAddSuperTeamMembers(S,[T]);break;case"addSuperTeamManagers":this.service.notifyUpdateSuperTeamManagers(h,C,!0,v);break;case"removeSuperTeamManagers":this.service.notifyUpdateSuperTeamManagers(h,C,!1,v);break;case"removeSuperTeamMembers":this.service.notifyRemoveSuperTeamMembers(S,C);break;case"leaveSuperTeam":this.service.notifyRemoveSuperTeamMembers(S,[m]);break;case"dismissSuperTeam":this.core.emit("dismissSuperTeam",{teamId:h});break;case"transferSuperTeam":this.service.notifyTransferSuperTeam(S,m,T);break;case"updateSuperTeamMembersMute":this.service.notifyUpdateSuperTeamMembersMute(S,C,i.mute)}},SuperTeamService}(gp),xI={"13_1":"getChatroomAddress","24_1":"getQChatAddress"},OI={getChatroomAddress:{sid:13,cid:1,service:"plugin",params:[{type:"Long",name:"chatroomId"},{type:"Bool",name:"isWeixinApp"},{type:"Int",name:"ipType"}],response:[{type:"StrArray",name:"address"}]},getQChatAddress:{sid:24,cid:1,service:"plugin",params:[{type:"Property",name:"getQChatAddressTag",reflectMapper:{ipType:1}}],response:[{type:"StrArray",name:"address"}]}},PI=function(t){function PluginService(i){var u;return(u=t.call(this,"plugin",i)||this).core=i,registerParser({cmdMap:xI,cmdConfig:OI}),u}Nt(PluginService,t);var i=PluginService.prototype;return i.getChatroomAddress=function getChatroomAddress(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return validate({chatroomId:{type:"string",allowEmpty:!1},ipType:{type:"number",required:!1}},t),u.next=3,this.core.sendCmd("getChatroomAddress",{chatroomId:t.chatroomId,isWeixinApp:"WXAPP"===pd.platform,ipType:t.ipType||0});case 3:return i=u.sent,u.abrupt("return",i.content.address);case 5:case"end":return u.stop()}}),_callee,this)})))},i.getQChatAddress=function getQChatAddress(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i;return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:return validate({ipType:{type:"number",required:!1}},t),u.next=3,this.core.sendCmd("getQChatAddress",{getQChatAddressTag:{ipType:(null==t?void 0:t.ipType)||0}});case 3:return i=u.sent,u.abrupt("return",i.content.address);case 5:case"end":return u.stop()}}),_callee2,this)})))},PluginService}(gp),LI={"7_19":"nimQueryCloudSessionList","7_20":"nimQueryCloudSession","7_21":"nimUpdateCloudSession","7_22":"nimDeleteCloudSessionList","7_121":"nimMultiSyncUpdateCloudSession"},VI={sessionReqTag:{minTimestamp:1,maxTimestamp:2,includedLastMsg:3,limit:4,hasMore:5},sessionTag:{sessionId:1,updateTime:2,ext:3,lastMsg:4,lastMsgType:5}},UI=invertSerializeMap(VI),DI={nimQueryCloudSessionList:{sid:7,cid:19,service:"cloudSession",params:[{type:"Property",name:"tag",reflectMapper:VI.sessionReqTag}],response:[{type:"Property",name:"tag",reflectMapper:UI.sessionReqTag},{type:"PropertyArray",name:"sessions",reflectMapper:UI.sessionTag}]},nimQueryCloudSession:{sid:7,cid:20,service:"cloudSession",params:[{type:"Property",name:"tag",reflectMapper:VI.sessionTag}],response:[{type:"Property",name:"session",reflectMapper:UI.sessionTag}]},nimUpdateCloudSession:{sid:7,cid:21,service:"cloudSession",params:[{type:"Property",name:"tag",reflectMapper:VI.sessionTag}]},nimDeleteCloudSessionList:{sid:7,cid:22,service:"cloudSession",params:[{type:"PropertyArray",name:"tags",reflectMapper:VI.sessionTag}]},nimMultiSyncUpdateCloudSession:{sid:7,cid:121,service:"cloudSession",response:[{type:"Property",name:"session",reflectMapper:UI.sessionTag}]}},BI={sessionId:{type:"string"},updateTime:{type:"number"},ext:{type:"string"},lastMsg:{type:"object"},lastMsgType:{type:"number"}};function formatCloudSession(t,i,u){var m=format(BI,t),h=getAccountFromSessionId(m.sessionId,"|"),v=h.accid,M=h.scene;if(m.sessionId=M+"-"+v,m.lastMsg){var I=1===m.lastMsgType;m.lastMsgInfo=I?{isLastMsgRecalled:I,revokedMsg:formatSystemMessage(deserialize(m.lastMsg,PM.sysMsg),u)}:{isLastMsgRecalled:I,lastMsg:formatMsg$1(deserialize(m.lastMsg,mM.msg),{account:i})}}return delete m.lastMsg,delete m.lastMsgType,m}function formatCloudSessions(t,i,u){return t&&t.length>0?map$6(t).call(t,(function(t){return formatCloudSession(t,i,u)})):[]}var qI=function(t){function CloudSessionService(i){var u;return u=t.call(this,"cloudSession",i)||this,registerParser({cmdMap:LI,cmdConfig:DI}),u}Nt(CloudSessionService,t);var i=CloudSessionService.prototype;return i.queryCloudSessionList=function queryCloudSessionList(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:return validate({minTimestamp:{type:"number",min:0,required:!1},maxTimestamp:{type:"number",min:0,required:!1},limit:{type:"number",min:1,required:!1},includedLastMsg:{type:"boolean",required:!1}},t),(u=Dt({limit:100,includedLastMsg:!0},t)).includedLastMsg=np.boolean(t,"includedLastMsg"),M.next=5,this.core.sendCmd("nimQueryCloudSessionList",{tag:u});case 5:return m=M.sent,h=(null===(i=m.content)||void 0===i?void 0:i.tag)||{},v=m.content.sessions,M.abrupt("return",{hasMore:+h.hasMore>0,sessionList:formatCloudSessions(v,this.core.account,this.logger)});case 9:case"end":return M.stop()}}),_callee,this)})))},i.queryCloudSession=function queryCloudSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h;return ud.wrap((function _callee2$(v){for(;;)switch(v.prev=v.next){case 0:return validate({sessionId:{type:"string",allowEmpty:!1}},t),i=getAccountFromSessionId(t.sessionId,"-"),u=i.accid,m=i.scene,v.next=4,this.core.sendCmd("nimQueryCloudSession",{tag:{sessionId:"superTeam"===m?"super_team|"+u:m+"|"+u}});case 4:return h=v.sent,v.abrupt("return",formatCloudSession(h.content.session,this.core.account,this.logger));case 6:case"end":return v.stop()}}),_callee2,this)})))},i.updateCloudSession=function updateCloudSession(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u,m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:return validate({sessionId:{type:"string",allowEmpty:!1},ext:{type:"string",allowEmpty:!1,required:!1}},t),i=getAccountFromSessionId(t.sessionId,"-"),u=i.accid,m=i.scene,h.next=4,this.core.sendCmd("nimUpdateCloudSession",{tag:{sessionId:"superTeam"===m?"super_team|"+u:m+"|"+u,ext:t.ext}});case 4:case"end":return h.stop()}}),_callee3,this)})))},i.deleteCloudSessionList=function deleteCloudSessionList(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u;return ud.wrap((function _callee4$(m){for(;;)switch(m.prev=m.next){case 0:return validate({sessionIdList:{type:"array",itemType:"string"}},t),u=map$6(i=t.sessionIdList).call(i,(function(t){var i=getAccountFromSessionId(t,"-"),u=i.accid,m=i.scene;return{sessionId:"superTeam"===m?"super_team|"+u:m+"|"+u}})),m.next=4,this.core.sendCmd("nimDeleteCloudSessionList",{tags:u});case 4:case"end":return m.stop()}}),_callee4,this)})))},i.nimMultiSyncUpdateCloudSessionHandler=function nimMultiSyncUpdateCloudSessionHandler(t){var i=formatCloudSession(t.content.session,this.core.account,this.logger);this.core.emit("multiSyncUpdateCloudSession",i)},CloudSessionService}(gp),FI={needPush:{type:"boolean",required:!1},pushTitle:{type:"string",required:!1},pushContent:{type:"string",required:!1},pushPayload:{type:"string",required:!1},needPushBadge:{type:"boolean",required:!1}},GI={"15_1":"signalingCreate","15_2":"signalingDelay","15_3":"signalingClose","15_4":"signalingJoin","15_5":"signalingLeave","15_6":"signalingInvite","15_7":"signalingCancelInvite","15_8":"signalingReject","15_9":"signalingAccept","15_10":"signalingSendCustomCommand","15_11":"signalingRecvNotification","15_12":"signalingMultiSyncNotification","15_13":"signalingSyncNotification","15_14":"singalingSyncChannels","15_15":"signalingQueryInfo","15_16":"signalingCallEx","15_17":"signalingJoinAndAccept"},HI={avSignalTag:Dt({type:1,name:2,channelId:3,createTime:4,expireTime:5,creatorAccid:6,ext:7,invalid:8,fromAccid:10,toAccid:11,requestId:12,members:18,attach:19,attachExt:20,needOffline:21,msgId:22,uid:23,time:24,nertcChannelName:25,nertcTokenTtl:26,nertcToken:27,nertcJoinRoomQueryParamMap:28,nertcJoinRoomResponse:29,callStatus:30},{needPush:13,pushTitle:14,pushContent:15,pushPayload:16,needPushBadge:17})},jI=invertSerializeMap(HI),$I={signalingCreate:{sid:15,cid:1,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}],response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingDelay:{sid:15,cid:2,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}],response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingClose:{sid:15,cid:3,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}],response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingJoin:{sid:15,cid:4,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}],response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingLeave:{sid:15,cid:5,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}]},signalingInvite:{sid:15,cid:6,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}]},signalingCancelInvite:{sid:15,cid:7,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}]},signalingReject:{sid:15,cid:8,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}]},signalingAccept:{sid:15,cid:9,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}]},signalingSendCustomCommand:{sid:15,cid:10,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}]},signalingRecvNotification:{sid:15,cid:11,service:"signaling",response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingMultiSyncNotification:{sid:15,cid:12,service:"signaling",response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingSyncNotification:{sid:15,cid:13,service:"signaling",response:[{type:"PropertyArray",name:"datas",reflectMapper:jI.avSignalTag}]},singalingSyncChannels:{sid:15,cid:14,service:"signaling",response:[{type:"PropertyArray",name:"datas",reflectMapper:jI.avSignalTag}]},signalingQueryInfo:{sid:15,cid:15,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}],response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingCallEx:{sid:15,cid:16,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}],response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingJoinAndAccept:{sid:15,cid:17,service:"signaling",params:[{type:"Property",name:"tag",reflectMapper:HI.avSignalTag}],response:[{type:"Property",name:"data",reflectMapper:jI.avSignalTag}]},signalingBatchMarkRead:{sid:4,cid:5,hasPacketResponse:!1,service:"signaling",params:[{type:"Byte",name:"sid"},{type:"Byte",name:"cid"},{type:"LongArray",name:"ids"}]}},zI={type:{type:"number"},createTime:{type:"number"},expireTime:{type:"number"},invalid:{type:"boolean"},pushInfo:FI,pluginSetting:{nertcInfo:{nertcChannelName:{type:"string"},nertcTokenTtl:{type:"number"},nertcToken:{type:"string"},nertcJoinRoomQueryParamMap:{type:"string"},callStatus:{type:"number"}}},callStatus:{type:"number"},attach:{type:"object"},members:{type:"object"},needOffline:{type:"boolean"},uid:{type:"number"},time:{type:"number"}};function formatSignalingChannelMember(t){return format(zI,deserialize(t,{1:"accid",2:"uid",3:"createTime",4:"expireTime"}))}function formatSignaling(t){var i,u=format(zI,t),m=[];u.members&&u.members.length>0&&(m=map$6(i=u.members).call(i,(function(t){return formatSignalingChannelMember(t)})),delete u.members);return m.length>0?{channelInfo:u,memberList:m}:{channelInfo:u}}function formatSignalingWithCallStatus(t){var i,u=format(zI,t),m=[];u.members&&u.members.length>0&&(m=map$6(i=u.members).call(i,(function(t){return formatSignalingChannelMember(t)})),delete u.members);var h=200;return t.callStatus&&(h=Number(t.callStatus)),m.length>0?{channelInfo:u,memberList:m,callStatus:h}:{channelInfo:u,callStatus:h}}function generateSignalingForCmd(t){return formatReverse(zI,t)}var WI,KI,YI,QI,JI,XI,ZI,e_=function(t){function SignalingService(i){var u;return(u=t.call(this)||this).timer=0,u.pollingInterval=12e4,u.name="signaling",u.logger=i.logger,u.core=i,u.channels={},registerParser({cmdMap:GI,cmdConfig:$I}),u}Nt(SignalingService,t);var i=SignalingService.prototype;return i.callEx=function callEx(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:return validate({type:{type:"number"},toAccid:{type:"string",allowEmpty:!1},requestId:{type:"string",allowEmpty:!1},needOffline:{type:"boolean",required:!1},pushInfo:{type:"object",required:!1,rules:FI},pluginSetting:{type:"object",required:!1,rules:{nertcInfo:{type:"object",required:!1}}}},t),M.next=3,this.core.sendCmd("signalingCallEx",{tag:generateSignalingForCmd(t)});case 3:return u=M.sent,m=(null===(i=u.content)||void 0===i?void 0:i.data)||{},h=formatSignalingWithCallStatus(m),this.channels[h.channelInfo.channelId]=cloneDeep(h.channelInfo),this.timer||(this.timer=this.core.timerManager.addTimer(bind$1(v=this.aotoDelay).call(v,this),this.pollingInterval,-1)),M.abrupt("return",h);case 9:case"end":return M.stop()}}),_callee,this)})))},i.joinAndAccept=function joinAndAccept(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u,m,h,v,M,I;return ud.wrap((function _callee2$(S){for(;;)switch(S.prev=S.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},fromAccid:{type:"string",allowEmpty:!1},requestId:{type:"string",required:!1},needOffline:{type:"boolean",required:!1},uid:{type:"number",required:!1},pluginSetting:{type:"object",required:!1,rules:{nertcInfo:{type:"object",required:!1}}}},t),u=t.fromAccid,(m=__rest(t,["fromAccid"])).toAccid=u,S.next=5,this.core.sendCmd("signalingJoinAndAccept",{tag:generateSignalingForCmd(m)});case 5:return h=S.sent,v=(null===(i=h.content)||void 0===i?void 0:i.data)||{},M=formatSignalingWithCallStatus(v),this.channels[M.channelInfo.channelId]=cloneDeep(M.channelInfo),this.timer||(this.timer=this.core.timerManager.addTimer(bind$1(I=this.aotoDelay).call(I,this),this.pollingInterval,-1)),S.abrupt("return",M);case 11:case"end":return S.stop()}}),_callee2,this)})))},i.create=function create(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var u,m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:return validate({type:{type:"number"},ext:{type:"string",required:!1}},t),h.next=3,this.core.sendCmd("signalingCreate",{tag:generateSignalingForCmd(t)});case 3:return u=h.sent,m=(null===(i=u.content)||void 0===i?void 0:i.data)||{},h.abrupt("return",formatSignaling(m));case 6:case"end":return h.stop()}}),_callee3,this)})))},i.close=function close(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},attachExt:{type:"string",required:!1},needOffline:{type:"boolean",required:!1}},t),i.next=3,this.core.sendCmd("signalingClose",{tag:generateSignalingForCmd(t)});case 3:case"end":return i.stop()}}),_callee4,this)})))},i.queryInfo=function queryInfo(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var u,m;return ud.wrap((function _callee5$(h){for(;;)switch(h.prev=h.next){case 0:return validate({name:{type:"string",allowEmpty:!1}},t),h.next=3,this.core.sendCmd("signalingQueryInfo",{tag:t});case 3:return u=h.sent,m=(null===(i=u.content)||void 0===i?void 0:i.data)||{},h.abrupt("return",formatSignaling(m));case 6:case"end":return h.stop()}}),_callee5,this)})))},i.join=function join(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var u,m,h,v;return ud.wrap((function _callee6$(M){for(;;)switch(M.prev=M.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},attachExt:{type:"string",required:!1},uid:{type:"number",min:0,required:!1},needOffline:{type:"boolean",required:!1}},t),M.next=3,this.core.sendCmd("signalingJoin",{tag:generateSignalingForCmd(t)});case 3:return u=M.sent,m=(null===(i=u.content)||void 0===i?void 0:i.data)||{},h=formatSignaling(m),this.channels[h.channelInfo.channelId]=cloneDeep(h.channelInfo),this.timer||(this.timer=this.core.timerManager.addTimer(bind$1(v=this.aotoDelay).call(v,this),this.pollingInterval,-1)),M.abrupt("return",h);case 9:case"end":return M.stop()}}),_callee6,this)})))},i.aotoDelay=function aotoDelay(){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var t,i,u,m,h;return ud.wrap((function _callee7$(v){for(;;)switch(v.prev=v.next){case 0:if(0!==(t=Ht(this.channels)).length){v.next=5;break}return this.timer&&this.core.timerManager.deleteTimer(this.timer),this.timer=0,v.abrupt("return");case 5:this.logger.log("signling:autoDelay",t),i=0;case 7:if(!(i<t.length)){v.next=24;break}return u=t[i],v.prev=9,v.next=12,this.core.sendCmd("signalingDelay",{tag:{channelId:u}});case 12:m=v.sent,h=formatSignaling(m.content.data),this.channels[u]=h.channelInfo,v.next=21;break;case 17:v.prev=17,v.t0=v.catch(9),this.logger.warn("signling:autoDelay "+u+" failed",v.t0),delete this.channels[u];case 21:i++,v.next=7;break;case 24:case"end":return v.stop()}}),_callee7,this,[[9,17]])})))},i.leave=function leave(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){return ud.wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},attachExt:{type:"string",required:!1},needOffline:{type:"boolean",required:!1}},t),i.next=3,this.core.sendCmd("signalingLeave",{tag:generateSignalingForCmd(t)});case 3:delete this.channels[t.channelId];case 4:case"end":return i.stop()}}),_callee8,this)})))},i.invite=function invite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){return ud.wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},toAccid:{type:"string",allowEmpty:!1},requestId:{type:"string",allowEmpty:!1},attachExt:{type:"string",required:!1},needOffline:{type:"boolean",required:!1},pushInfo:{type:"object",required:!1,rules:FI}},t),i.next=3,this.core.sendCmd("signalingInvite",{tag:generateSignalingForCmd(t)});case 3:case"end":return i.stop()}}),_callee9,this)})))},i.cancelInvite=function cancelInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){return ud.wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},toAccid:{type:"string",allowEmpty:!1},requestId:{type:"string",allowEmpty:!1},attachExt:{type:"string",required:!1},needOffline:{type:"boolean",required:!1}},t),i.next=3,this.core.sendCmd("signalingCancelInvite",{tag:generateSignalingForCmd(t)});case 3:case"end":return i.stop()}}),_callee10,this)})))},i.reject=function reject(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var i,u;return ud.wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},fromAccid:{type:"string",allowEmpty:!1},requestId:{type:"string",allowEmpty:!1},attachExt:{type:"string",required:!1},needOffline:{type:"boolean",required:!1}},t),i=t.fromAccid,(u=__rest(t,["fromAccid"])).toAccid=i,m.next=5,this.core.sendCmd("signalingReject",{tag:generateSignalingForCmd(u)});case 5:case"end":return m.stop()}}),_callee11,this)})))},i.accept=function accept(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i,u,m,h,v;return ud.wrap((function _callee12$(M){for(;;)switch(M.prev=M.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},fromAccid:{type:"string",allowEmpty:!1},requestId:{type:"string",allowEmpty:!1},attachExt:{type:"string",required:!1},needOffline:{type:"boolean",required:!1},autoJoin:{type:"boolean",required:!1},uid:{type:"number",min:0,required:!1},joinAttachExt:{type:"string",required:!1}},t),i=t.autoJoin,u=t.joinAttachExt,m=t.fromAccid,(h=__rest(t,["autoJoin","joinAttachExt","fromAccid"])).toAccid=m,M.next=5,this.core.sendCmd("signalingAccept",{tag:generateSignalingForCmd(h)});case 5:if(this.logger.log("Signaling:accept, accept success, autoJoin "+t.autoJoin),!i){M.next=10;break}return v={channelId:t.channelId,needOffline:t.needOffline,attachExt:u,uid:t.uid},M.next=10,this.join(v);case 10:case"end":return M.stop()}}),_callee12,this)})))},i.sendCustomCommand=function sendCustomCommand(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){return ud.wrap((function _callee13$(i){for(;;)switch(i.prev=i.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1},fromAccid:{type:"string",allowEmpty:!1,required:!1},attachExt:{type:"string",required:!1}},t),i.next=3,this.core.sendCmd("signalingSendCustomCommand",{tag:generateSignalingForCmd(t)});case 3:case"end":return i.stop()}}),_callee13,this)})))},i.signalingRecvNotificationHandler=function signalingRecvNotificationHandler(t){var i=fillIdServer(t,t.content.data,"msgId","0"),u=i.msgId;this.doNotify(i),u&&Gd(u)&&this.core.sendCmd("signalingBatchMarkRead",{sid:15,cid:11,ids:[u]})},i.signalingMultiSyncNotificationHandler=function signalingMultiSyncNotificationHandler(t){this.doNotify(t.content.data,3)},i.doNotify=function doNotify(t,i){void 0===i&&(i=0);var u=function formatSignalingNotification(t,i){void 0===i&&(i=0);var u=format(zI,t),m=u.attach,h=u.attachExt,v=u.time,M=u.msgId;u.fromAccid,u.toAccid,u.members,u.requestId,u.pushInfo;var I=__rest(u,["attach","attachExt","time","msgId","fromAccid","toAccid","members","requestId","pushInfo"]);if(2===m.type)try{u.member={accid:u.attach.member[1],uid:Number(u.attach.member[2]),createTime:Number(u.attach.member[3]),expireTime:Number(u.attach.member[4])}}catch(t){delete u.member}var S=m.type;return delete u.attach,{metaData:{eventType:S,channelInfo:I,feature:i,ext:h||"",time:v,msgId:M},rawData:u}}(t,i),m=u.metaData,h=u.rawData,v=h.fromAccid,M=h.toAccid,I=h.requestId,S=h.pushInfo,T=h.msgId,C=h.member;switch(m.eventType){case 1:this.emit("signalingClose",{fromAccid:v,metaData:m});break;case 2:this.emit("signalingJoin",{fromAccid:v,metaData:m,member:C});break;case 3:this.emit("signalingInvite",{fromAccid:v,toAccid:M,requestId:I,pushInfo:S,metaData:m});break;case 4:this.emit("signalingCancelInvite",{fromAccid:v,toAccid:M,requestId:I,metaData:m});break;case 5:this.emit("signalingReject",{fromAccid:v,toAccid:M,requestId:I,metaData:m});break;case 6:this.emit("signalingAccept",{fromAccid:v,toAccid:M,requestId:I,metaData:m});break;case 7:this.emit("signalingLeave",{fromAccid:v,metaData:m});break;case 8:this.emit("signalingCustomCommand",{fromAccid:v,metaData:m});break;default:this.logger.warn("signaling:notification, no such a type "+m.eventType,h)}return T},i.signalingSyncNotificationHandler=function signalingSyncNotificationHandler(t){var i,u,m=this;if(t.content.datas&&t.content.datas.length>0){var h=filter(i=map$6(u=t.content.datas).call(u,(function(t){return m.doNotify(t,1)}))).call(i,(function(t){return t}));h.length>0&&this.core.sendCmd("signalingBatchMarkRead",{sid:15,cid:11,ids:h})}},i.singalingSyncChannelsHandler=function singalingSyncChannelsHandler(t){var i,u=this;if(this.timer=0,this.channels={},t.content.datas&&t.content.datas.length>0){var m=map$6(i=t.content.datas).call(i,(function(t){return formatSignaling(t)}));forEach$1(m).call(m,(function(t){var i=t.channelInfo.channelId;u.channels[i]=cloneDeep(t.channelInfo)})),this.emit("singalingSyncChannels",m)}},i.process=function process(t){var i=this[t.cmd+"Handler"];if("function"==typeof i)return i.call(this,t),zi.resolve(t);var u=get(t,"error.detail.ignore");return t.error&&!u?zi.reject(t.error):zi.resolve(t)},SignalingService}(ho.EventEmitter),t_=function(t){function Service(i,u){var m;return(m=t.call(this)||this).name=i,m.core=u,m.name=i,m.logger=u.logger,m.core=u,m}Nt(Service,t);var i=Service.prototype;return i.emit=function emit(i){var u=this;try{for(var m,h,v=arguments.length,M=new Array(v>1?v-1:0),I=1;I<v;I++)M[I-1]=arguments[I];var S=(m=t.prototype.emit).call.apply(m,concat(h=[this,i]).call(h,M));return S}catch(t){return mo((function(){throw u.logger.error(u.name+"::emit throw error in setTimeout. event: "+i.toString()+". Error",t),t}),0),!1}},i.process=function process(t){var i=this[t.cmd+"Handler"];if("function"==typeof i)return i.call(this,t);var u=get(t,"error.detail.ignore");return t.error&&!u?zi.reject(t.error):zi.resolve(t)},Service}(ho),r_={"24_15":"qchatSubscribe","24_27":"qchatGetUnreadInfo","24_48":"qchatCreateChannel","24_49":"qchatDeleteChannel","24_50":"qchatUpdateChannel","24_51":"qchatGetChannels","24_52":"qchatGetChannelsByPage","24_53":"qchatGetMembersByPage","24_54":"qchatUpdateWhiteBlackRole","24_55":"qchatGetWhiteBlackRolesPage","24_56":"qchatUpdateWhiteBlackMembers","24_57":"qchatGetWhiteBlackMembersPage","24_58":"qchatGetExistingWhiteBlackRoles","24_59":"qchatGetExistingWhiteBlackMembers","24_60":"qchatUpdateCategoryInfoOfChannel","24_109":"qchatCreateChannelCategory","24_110":"qchatRemoveChannelCategory","24_111":"qchatUpdateChannelCategory","24_112":"qchatGetChannelCategoriesByID","24_113":"qchatUpdateChannelCategoryWhiteBlackRole","24_114":"qchatGetChannelCategoryWhiteBlackRolesPage","24_115":"qchatUpdateChannelCategoryWhiteBlackMembers","24_116":"qchatGetChannelCategoryWhiteBlackMembersPage","24_117":"qchatGetChannelCategoryWhiteBlackRoles","24_118":"qchatGetChannelCategoryWhiteBlackMembers","24_119":"qchatGetChannelCategoriesPage","24_120":"qchatGetChannelCategoryChannelsPage","24_93":"qchatGetChannelSearchByPage","24_95":"qchatChannelMemberSearch","25_8":"qchatGetRoleIdsByServerId","25_9":"qchatSubscribeAsVisitor","25_12":"qchatAutoSubscribe","25_13":"qchatAutoSubscribeNotification"},n_={serverId:1,channelId:2,ackTimestamp:3,unreadCount:4,mentionedCount:5,maxCount:6,lastMsgTime:7},a_={channelInfo:{channelId:1,serverId:2,name:4,topic:5,ext:6,type:7,validFlag:8,createTime:9,updateTime:10,owner:11,viewMode:12,categoryId:13,syncMode:14,reorderWeight:15,visitorMode:16},antispamTag:{antiSpamBusinessId:1},memberInfo:{serverId:1,accid:3,nick:4,avatar:5,ext:6,type:7,joinTime:8,inviter:9,validFlag:10,createTime:11,updateTime:12},serverRole:{serverId:1,roleId:2,name:3,icon:4,ext:5,auths:6,type:7,memberCount:8,priority:9,createTime:10,updateTime:11},qchatSubReqTag:{type:1,opeType:2},qchatChannelIdInfoTag:{serverId:1,channelId:2},unreadInfo:n_,qchatGetChannelListPageTag:{serverId:1,timetag:2,limit:3},qchatGetMembersByPageTag:{serverId:1,channelId:2,timetag:3,limit:4},qchatUpdateWhiteBlackRoleTag:{serverId:1,channelId:2,type:3,opeType:4,roleId:5},qchatGetWhiteBlackRolesPageTag:{serverId:1,channelId:2,type:3,timetag:4,limit:5},qchatUpdateWhiteBlackMembersTag:{serverId:1,channelId:2,type:3,opeType:4,toAccids:5},qchatGetWhiteBlackMembersPageTag:{serverId:1,channelId:2,type:3,timetag:4,limit:5},qchatGetExistingWhiteBlackRolesTag:{serverId:1,channelId:2,type:3,roleIds:4},qchatGetExistingWhiteBlackMembersTag:{serverId:1,channelId:2,type:3,accids:4},QChatChannelCategoryInfo:{categoryId:1,serverId:2,name:4,ext:5,owner:6,viewMode:7,validFlag:8,createTime:9,updateTime:10,channelNumber:11},qchatUpdateChannelCategoryWhiteBlackRoleTag:{serverId:1,categoryId:2,type:3,opeType:4,roleId:5},qchatGetChannelCategoryWhiteBlackRolesPageTag:{serverId:1,categoryId:2,type:3,timetag:4,limit:5},qchatUpdateChannelCategoryWhiteBlackMembersTag:{serverId:1,categoryId:2,type:3,opeType:4,toAccids:5},qchatGetChannelCategoryWhiteBlackMembersPageTag:{serverId:1,categoryId:2,type:3,timetag:4,limit:5},qchatGetChannelCategoryWhiteBlackRolesTag:{serverId:1,categoryId:2,type:3,roleIds:4},qchatGetChannelCategoryWhiteBlackMembersTag:{serverId:1,categoryId:2,type:3,accids:4},qchatGetChannelCategoriesPageTag:{serverId:1,timetag:2,limit:3},qchatGetChannelCategoryChannelsPageTag:{serverId:1,categoryId:2,timetag:3,limit:4},qchatGetChannelSearchByPageTag:{keyword:1,startTime:2,endTime:3,order:4,limit:5,serverId:6,sort:7,cursor:8},qchatUpdateChannelTag:{channelId:1,name:4,topic:5,ext:6,viewMode:12,visitorMode:16},serverRoles:{serverId:1,roleIds:2,timeTag:3},qchatChannelMemberSearchTag:{serverId:1,channelId:2,keyword:3,limit:4},qchatChannelMemberInfo:{serverId:1,channelId:2,avatar:3,accid:4,nick:5,createTime:6,updateTime:7}},i_=function getDeserializeTag(){return invertSerializeMap(a_)},o_=function getCmdConfig(){var t=i_();return{qchatCreateChannel:{sid:24,cid:48,service:"qchatChannel",params:[{type:"Property",name:"channelInfo",reflectMapper:a_.channelInfo},{type:"Property",name:"antispamTag",reflectMapper:a_.antispamTag}],response:[{type:"Property",name:"channelInfo",reflectMapper:t.channelInfo}]},qchatDeleteChannel:{sid:24,cid:49,service:"qchatChannel",params:[{type:"Long",name:"channelId"}]},qchatUpdateChannel:{sid:24,cid:50,service:"qchatChannel",params:[{type:"Property",name:"channelInfo",reflectMapper:a_.qchatUpdateChannelTag},{type:"Property",name:"antispamTag",reflectMapper:a_.antispamTag}],response:[{type:"Property",name:"channelInfo",reflectMapper:t.channelInfo}]},qchatGetChannels:{sid:24,cid:51,service:"qchatChannel",params:[{type:"LongArray",name:"channelIds"}],response:[{type:"PropertyArray",name:"channelList",reflectMapper:t.channelInfo}]},qchatGetChannelsByPage:{sid:24,cid:52,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelListPageTag",reflectMapper:a_.qchatGetChannelListPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.channelInfo}]},qchatGetMembersByPage:{sid:24,cid:53,service:"qchatChannel",params:[{type:"Property",name:"qchatGetMembersByPageTag",reflectMapper:a_.qchatGetMembersByPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.memberInfo}]},qchatUpdateWhiteBlackRole:{sid:24,cid:54,service:"qchatChannel",params:[{type:"Property",name:"qchatUpdateWhiteBlackRoleTag",reflectMapper:a_.qchatUpdateWhiteBlackRoleTag}]},qchatGetWhiteBlackRolesPage:{sid:24,cid:55,service:"qchatChannel",params:[{type:"Property",name:"qchatGetWhiteBlackRolesPageTag",reflectMapper:a_.qchatGetWhiteBlackRolesPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.serverRole}]},qchatUpdateWhiteBlackMembers:{sid:24,cid:56,service:"qchatChannel",params:[{type:"Property",name:"qchatUpdateWhiteBlackMembersTag",reflectMapper:a_.qchatUpdateWhiteBlackMembersTag}]},qchatGetWhiteBlackMembersPage:{sid:24,cid:57,service:"qchatChannel",params:[{type:"Property",name:"qchatGetWhiteBlackMembersPageTag",reflectMapper:a_.qchatGetWhiteBlackMembersPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.memberInfo}]},qchatGetExistingWhiteBlackRoles:{sid:24,cid:58,service:"qchatChannel",params:[{type:"Property",name:"qchatGetExistingWhiteBlackRolesTag",reflectMapper:a_.qchatGetExistingWhiteBlackRolesTag}],response:[{type:"PropertyArray",name:"datas",reflectMapper:t.serverRole}]},qchatGetExistingWhiteBlackMembers:{sid:24,cid:59,service:"qchatChannel",params:[{type:"Property",name:"qchatGetExistingWhiteBlackMembersTag",reflectMapper:a_.qchatGetExistingWhiteBlackMembersTag}],response:[{type:"PropertyArray",name:"datas",reflectMapper:t.memberInfo}]},qchatUpdateCategoryInfoOfChannel:{sid:24,cid:60,service:"qchatChannel",params:[{type:"Property",name:"qchatUpdateCategoryInfoOfChannelTag",reflectMapper:a_.channelInfo}],response:[{type:"Property",name:"channelInfo",reflectMapper:t.channelInfo}]},qchatCreateChannelCategory:{sid:24,cid:109,service:"qchatChannel",params:[{type:"Property",name:"qchatCreateChannelCategoryTag",reflectMapper:a_.QChatChannelCategoryInfo}],response:[{type:"Property",name:"QChatChannelCategoryInfo",reflectMapper:t.QChatChannelCategoryInfo}]},qchatRemoveChannelCategory:{sid:24,cid:110,service:"qchatChannel",params:[{type:"Long",name:"categoryId"}]},qchatUpdateChannelCategory:{sid:24,cid:111,service:"qchatChannel",params:[{type:"Property",name:"qchatUpdateChannelCategoryTag",reflectMapper:a_.QChatChannelCategoryInfo}],response:[{type:"Property",name:"QChatChannelCategoryInfo",reflectMapper:t.QChatChannelCategoryInfo}]},qchatGetChannelCategoriesByID:{sid:24,cid:112,service:"qchatChannel",params:[{type:"LongArray",name:"categoryIds"}],response:[{type:"PropertyArray",name:"channelCategoryList",reflectMapper:t.QChatChannelCategoryInfo}]},qchatUpdateChannelCategoryWhiteBlackRole:{sid:24,cid:113,service:"qchatChannel",params:[{type:"Property",name:"qchatUpdateChannelCategoryWhiteBlackRoleTag",reflectMapper:a_.qchatUpdateChannelCategoryWhiteBlackRoleTag}]},qchatGetChannelCategoryWhiteBlackRolesPage:{sid:24,cid:114,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelCategoryWhiteBlackRolesPageTag",reflectMapper:a_.qchatGetChannelCategoryWhiteBlackRolesPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.serverRole}]},qchatUpdateChannelCategoryWhiteBlackMembers:{sid:24,cid:115,service:"qchatChannel",params:[{type:"Property",name:"qchatUpdateChannelCategoryWhiteBlackMembersTag",reflectMapper:a_.qchatUpdateChannelCategoryWhiteBlackMembersTag}]},qchatGetChannelCategoryWhiteBlackMembersPage:{sid:24,cid:116,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelCategoryWhiteBlackMembersPageTag",reflectMapper:a_.qchatGetChannelCategoryWhiteBlackMembersPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.memberInfo}]},qchatGetChannelCategoryWhiteBlackRoles:{sid:24,cid:117,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelCategoryWhiteBlackRolesTag",reflectMapper:a_.qchatGetChannelCategoryWhiteBlackRolesTag}],response:[{type:"PropertyArray",name:"datas",reflectMapper:t.serverRole}]},qchatGetChannelCategoryWhiteBlackMembers:{sid:24,cid:118,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelCategoryWhiteBlackMembersTag",reflectMapper:a_.qchatGetChannelCategoryWhiteBlackMembersTag}],response:[{type:"PropertyArray",name:"datas",reflectMapper:t.memberInfo}]},qchatGetChannelCategoriesPage:{sid:24,cid:119,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelCategoriesPageTag",reflectMapper:a_.qchatGetChannelCategoriesPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.QChatChannelCategoryInfo}]},qchatGetChannelCategoryChannelsPage:{sid:24,cid:120,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelCategoryChannelsPageTag",reflectMapper:a_.qchatGetChannelCategoryChannelsPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.channelInfo}]},qchatSubscribe:{sid:24,cid:15,service:"qchatChannel",params:[{type:"Property",name:"qchatSubReqTag",reflectMapper:a_.qchatSubReqTag},{type:"PropertyArray",name:"channels",reflectMapper:a_.qchatChannelIdInfoTag}],response:[{type:"PropertyArray",name:"unreadInfos",reflectMapper:t.unreadInfo},{type:"PropertyArray",name:"failedChannels",reflectMapper:t.qchatChannelIdInfoTag}]},qchatAutoSubscribe:{sid:25,cid:12,service:"qchatChannel",hasPacketTimer:!1,params:[{type:"Property",name:"qchatAutoSubReqTag"}],response:[{type:"Property",name:"qchatAutoSubInfo",reflectMapper:{1:"time"}}]},qchatAutoSubscribeNotification:{service:"qchatChannel",sid:25,cid:13,response:[{type:"PropertyArray",name:"serverIds",reflectMapper:t.unreadInfo},{type:"PropertyArray",name:"unreadInfos",reflectMapper:t.unreadInfo}]},qchatGetUnreadInfo:{sid:24,cid:27,service:"qchatChannel",params:[{type:"PropertyArray",name:"channels",reflectMapper:a_.qchatChannelIdInfoTag}],response:[{type:"PropertyArray",name:"unreadInfos",reflectMapper:t.unreadInfo}]},qchatGetChannelSearchByPage:{sid:24,cid:93,service:"qchatChannel",params:[{type:"Property",name:"qchatGetChannelSearchByPageTag",reflectMapper:a_.qchatGetChannelSearchByPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag",3:"cursor"}},{type:"PropertyArray",name:"datas",reflectMapper:t.channelInfo}]},qchatGetRoleIdsByServerId:{sid:25,cid:8,service:"qchatChannel",params:[{type:"Property",name:"qchatGetRoleIdsByServerIdTag",reflectMapper:{serverIdTimeTags:1}}],response:[{type:"PropertyArray",name:"serverRoles",reflectMapper:t.serverRoles},{type:"String",name:"failServerIds"}]},qchatChannelMemberSearch:{sid:24,cid:95,service:"qchatChannel",params:[{type:"Property",name:"qchatChannelMemberSearchTag",reflectMapper:a_.qchatChannelMemberSearchTag}],response:[{type:"PropertyArray",name:"datas",reflectMapper:t.qchatChannelMemberInfo}]},qchatSubscribeAsVisitor:{sid:25,cid:9,service:"qchatChannel",params:[{type:"Property",name:"tag",reflectMapper:a_.qchatSubReqTag},{type:"PropertyArray",name:"datas",reflectMapper:a_.qchatChannelIdInfoTag}],response:[{type:"PropertyArray",name:"failedArr",reflectMapper:t.qchatChannelIdInfoTag}]}}};!function(t){t[t.reorderWeight=0]="reorderWeight",t[t.createTime=1]="createTime"}(WI||(WI={})),function(t){t[t.white=1]="white",t[t.black=2]="black"}(KI||(KI={})),function(t){t[t.add=1]="add",t[t.remove=2]="remove"}(YI||(YI={})),function(t){t[t.message=0]="message",t[t.media=1]="media",t[t.ext=100]="ext"}(QI||(QI={})),function(t){t[t.ASC=1]="ASC",t[t.DESC=2]="DESC"}(JI||(JI={})),function(t){t[t.reorderWeight=0]="reorderWeight",t[t.createTime=1]="createTime",t[t.totalMember=2]="totalMember"}(XI||(XI={})),function(t){t[t.square=1]="square",t[t.person=2]="person"}(ZI||(ZI={}));var s_={channelId:{type:"string"},serverId:{type:"string"},name:{type:"string"},topic:{type:"string"},ext:{type:"string"},type:{type:"enum",values:QI},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"},viewMode:{type:"number"},categoryId:{type:"string"},syncMode:{type:"number"},visitorMode:{type:"number"},reorderWeight:{type:"string"}},c_={serverId:{type:"string"},channelId:{type:"string"},ackTimestamp:{type:"number"},unreadCount:{type:"number"},mentionedCount:{type:"number"},maxCount:{type:"number"},lastMsgTime:{type:"number"}},l_={serverId:{type:"string"},channelId:{type:"string"},type:{type:"enum",values:KI},opeType:{type:"enum",values:YI},toAccids:{type:"object"}},d_={serverId:{type:"string"},channelId:{type:"string"},type:{type:"enum",values:KI},opeType:{type:"enum",values:YI},roleId:{type:"string"}},u_={categoryId:{type:"string"},serverId:{type:"string"},name:{type:"string"},ext:{type:"string"},owner:{type:"string"},viewMode:{type:"number"},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"},channelNumber:{type:"number"}},p_={serverId:{type:"string"},channelId:{type:"string"},accid:{type:"string"},avatar:{type:"string"},nick:{type:"string"},createTime:{type:"number"},updateTime:{type:"number"}};function formatUpdateWhiteBlackRole(t){return format(d_,t)}function formatChannel(t){return format(s_,t)}function formatChannels(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatChannel(t)})):[]}function formatUnreadInfo(t){return format(c_,t)}function formatUnreadInfos(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatUnreadInfo(t)})):[]}function formatChannelCategory(t){return format(u_,t)}function formatChannelCategorys(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatChannelCategory(t)})):[]}function formatChannelMembers(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return function formatChannelMember(t){return format(p_,t)}(t)})):[]}function formatFailServerIds(t){try{return JSON.parse(t)}catch(t){return[]}}var m_={serverId:{type:"string"},name:{type:"string"},icon:{type:"string"},ext:{type:"string"},owner:{type:"string"},memberNumber:{type:"number"},inviteMode:{type:"number"},applyMode:{type:"number"},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"},channelNumber:{type:"number"},categoryNumber:{type:"number"},searchType:{type:"number"},searchEnable:{type:"boolean"},reorderWeight:{type:"string"}},h_={serverId:{type:"string"},uid:{type:"string"},accid:{type:"string"},nick:{type:"string"},avatar:{type:"string"},ext:{type:"string"},type:{type:"number"},joinTime:{type:"number"},inviter:{type:"string"},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"}},g_={serverId:{type:"string"},appid:{type:"string"},accid:{type:"string"},ext:{type:"string"},banTime:{type:"number"},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"}};function formatServer(t){return format(m_,t)}function formatServers(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatServer(t)})):[]}function formatMember$1(t){return format(h_,t)}function formatMembers$1(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatMember$1(t)})):[]}function formatServerMemberBanInfos(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return function formatServerMemberBanInfo(t){return format(g_,t)}(t)})):[]}function generateAntispamTag(t){var i,u,m;if(!t.antispamTag)return{};var h=Dt({},t.antispamTag);return(null===(i=t.antispamTag)||void 0===i?void 0:i.antiSpamBusinessId)&&"string"!=typeof(null===(u=t.antispamTag)||void 0===u?void 0:u.antiSpamBusinessId)&&(h.antiSpamBusinessId=Un(null===(m=t.antispamTag)||void 0===m?void 0:m.antiSpamBusinessId)),h}var v_={accid:{type:"string"},type:{type:"number"},serverId:{type:"string"},status:{type:"number"},requestId:{type:"string"},createTime:{type:"number"},updateTime:{type:"number"},expireTime:{type:"number"},data:{type:"object"}};function formatInviteApplyRecord(t){return format(v_,t)}function formatInviteApplyRecords(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatInviteApplyRecord(t)})):[]}var f_,y_,M_,I_,__={successServerIds:{type:"object"},failServerIds:{type:"object"},ackTimestamp:{type:"number"}};function formatClearServersUnread(t){return format(__,t)}!function(t){t[t.everyone=1]="everyone",t[t.custom=2]="custom"}(f_||(f_={})),function(t){t[t.normal=0]="normal",t[t.owner=1]="owner"}(y_||(y_={})),function(t){t[t.ignore=0]="ignore",t[t.deny=-1]="deny",t[t.allow=1]="allow"}(M_||(M_={})),function(t){t[t.manageServer=1]="manageServer",t[t.manageChannel=2]="manageChannel",t[t.manageRole=3]="manageRole",t[t.sendMsg=4]="sendMsg",t[t.accountInfoSelf=5]="accountInfoSelf",t[t.inviteServer=6]="inviteServer",t[t.kickServer=7]="kickServer",t[t.accountInfoOther=8]="accountInfoOther",t[t.recallMsg=9]="recallMsg",t[t.deleteMsg=10]="deleteMsg",t[t.remindOther=11]="remindOther",t[t.remindEveryone=12]="remindEveryone",t[t.manageBlackWhiteList=13]="manageBlackWhiteList",t[t.banServerMember=14]="banServerMember",t[t.RTCChannelConnect=15]="RTCChannelConnect",t[t.RTCChannelDisconnectOther=16]="RTCChannelDisconnectOther",t[t.RTCChannelOpenMicrophone=17]="RTCChannelOpenMicrophone",t[t.RTCChannelOpenCamera=18]="RTCChannelOpenCamera",t[t.RTCChannelOpenCloseOtherMicrophone=19]="RTCChannelOpenCloseOtherMicrophone",t[t.RTCChannelOpenCloseOtherCamera=20]="RTCChannelOpenCloseOtherCamera",t[t.RTCChannelOpenCloseEveryoneMicrophone=21]="RTCChannelOpenCloseEveryoneMicrophone",t[t.RTCChannelOpenCloseEveryoneCamera=22]="RTCChannelOpenCloseEveryoneCamera",t[t.RTCChannelOpenShareScreen=23]="RTCChannelOpenShareScreen",t[t.RTCChannelCloseOtherShareScreen=24]="RTCChannelCloseOtherShareScreen",t[t.manageInviteApply=25]="manageInviteApply",t[t.manageInviteApplyHistory=26]="manageInviteApplyHistory",t[t.mentionedRole=27]="mentionedRole"}(I_||(I_={}));var S_,T_,C_,b_,E_,A_,k_,R_,w_,N_={type:{type:"enum",values:f_},memberType:{type:"enum",values:y_},createTime:{type:"number"},updateTime:{type:"number"},priority:{type:"number"},memberCount:{type:"number"},joinTime:{type:"number"}},x_={roleId:{type:"string"},categoryId:{type:"string"},serverId:{type:"string"},type:{type:"enum",values:f_},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"},name:{type:"string"},icon:{type:"string"},ext:{type:"string"}},O_={id:{type:"string"},accid:{type:"string"},categoryId:{type:"string"},serverId:{type:"string"},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"},nick:{type:"string"},avatar:{type:"string"},ext:{type:"string"},memberType:{type:"enum",values:y_},joinTime:{type:"number"},inviter:{type:"string"}};function generatorRoleForCmd(t){var i=Dt({},t),u=formatReverse(N_,i);return u.auths&&(u.auths=function generateRoleAuthsForCmd(t){var i,u=reduce(i=Ht(t)).call(i,(function(i,u){var m=I_[u];return m?i[m]=M_[t[u]]:i[u]=M_[t[u]],i}),{});return Un(u)}(u.auths)),u}function formatRoleAuths(t){var i;return reduce(i=Ht(t)).call(i,(function(i,u){var m=getEnumKeyByEnumValue(I_,u);m?i[m]=M_[t[u]]:i[Gd(u)]=M_[t[u]];return i}),{})}function formatRole(t){var i=format(N_,t);return t.auths&&(i.auths=formatRoleAuths(JSON.parse(i.auths))),i.isMember&&delete i.isMember,i}function formatRoles(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return formatRole(t)})):[]}function formatChannelCategoryRole(t){return t.auths&&(t.auths=formatRoleAuths(JSON.parse(t.auths))),format(x_,t)}function formatChannelCategoryMemberRole(t){return t.auths&&(t.auths=formatRoleAuths(JSON.parse(t.auths))),format(O_,t)}!function(t){t[t.default=1]="default",t[t.sync=2]="sync"}(S_||(S_={})),function(t){t[t.sendTime=1]="sendTime"}(T_||(T_={})),function(t){t[t.text=0]="text",t[t.image=1]="image",t[t.audio=2]="audio",t[t.video=3]="video",t[t.geo=4]="geo",t[t.notification=5]="notification",t[t.file=6]="file",t[t.tip=10]="tip",t[t.robot=11]="robot",t[t.g2=12]="g2",t[t.custom=100]="custom"}(C_||(C_={})),function(t){t[t.sending=1]="sending",t[t.success=2]="success",t[t.failed=3]="failed"}(b_||(b_={})),function(t){t[t.notifyAll=1]="notifyAll",t[t.notifySubscribe=2]="notifySubscribe"}(E_||(E_={})),function(t){t[t.unknown=0]="unknown",t[t.server=1]="server",t[t.channel=2]="channel",t[t.serverAccids=3]="serverAccids",t[t.channelAccids=4]="channelAccids",t[t.accids=5]="accids"}(A_||(A_={})),function(t){t[t.serverMemberInvite=1]="serverMemberInvite",t[t.serverMemberInviteReject=2]="serverMemberInviteReject",t[t.serverMemberApply=3]="serverMemberApply",t[t.serverMemberApplyReject=4]="serverMemberApplyReject",t[t.serverCreate=5]="serverCreate",t[t.serverRemove=6]="serverRemove",t[t.serverUpdate=7]="serverUpdate",t[t.serverMemberInviteDone=8]="serverMemberInviteDone",t[t.serverMemberInviteAccept=9]="serverMemberInviteAccept",t[t.serverMemberApplyDone=10]="serverMemberApplyDone",t[t.serverMemberApplyAccept=11]="serverMemberApplyAccept",t[t.serverMemberKick=12]="serverMemberKick",t[t.serverMemberLeave=13]="serverMemberLeave",t[t.serverMemberUpdate=14]="serverMemberUpdate",t[t.channelCreate=15]="channelCreate",t[t.channelRemove=16]="channelRemove",t[t.channelUpdate=17]="channelUpdate",t[t.channelUpdateWhiteBlackIdentify=18]="channelUpdateWhiteBlackIdentify",t[t.channelUpdateWhiteBlackIdentifyUser=19]="channelUpdateWhiteBlackIdentifyUser",t[t.updateQuickComment=20]="updateQuickComment",t[t.channelCategoryCreate=21]="channelCategoryCreate",t[t.channelCategoryRemove=22]="channelCategoryRemove",t[t.channelCategoryUpdate=23]="channelCategoryUpdate",t[t.channelCategoryUpdateWhiteBlackIdentify=24]="channelCategoryUpdateWhiteBlackIdentify",t[t.channelCategoryUpdateWhiteBlackIdentifyUser=25]="channelCategoryUpdateWhiteBlackIdentifyUser",t[t.serverIdentifyAdd=26]="serverIdentifyAdd",t[t.serverIdentifyRemove=27]="serverIdentifyRemove",t[t.serverIdentifyUpdate=28]="serverIdentifyUpdate",t[t.channelIdentifyUpdate=29]="channelIdentifyUpdate",t[t.userIdentifyUpdate=30]="userIdentifyUpdate",t[t.channelVisibilityUpdate=31]="channelVisibilityUpdate",t[t.serverEnterLeave=32]="serverEnterLeave",t[t.serverMemberJoinByInviteCode=33]="serverMemberJoinByInviteCode",t[t.channelVisibilityToVisitorUpdate=34]="channelVisibilityToVisitorUpdate",t[t.myMemberInfoUpdated=35]="myMemberInfoUpdated",t[t.custom=100]="custom",t[t.msgTyping=101]="msgTyping"}(k_||(k_={})),function(t){t[t.reply=1]="reply",t[t.thread=2]="thread",t[t.all=3]="all"}(R_||(R_={})),function(t){t[t.sub=1]="sub",t[t.unSub=2]="unSub"}(w_||(w_={}));var P_=function(){function UnreadInfoModuleService(t){var i=this;this.unreadCount={},this.manualSubscribeUnreadMap={},this.manualSubscribeServerMap={},this.manualSubscribeTypingMap={},this.unreadServerCount={},this.serverRoleIdsMap={},this.autoSubscribeUnreadMap={},this.autoSubscribeServerMap={},this._serverUnreadInfo=throttle((function(t){i.core.emit("serverUnreadInfo",i.getServerUnreadInfo(t)),get(i.core,"qchatServer.emit")&&i.core.qchatServer.emit("serverUnreadInfo",i.getServerUnreadInfo(t))}),100),this.core=t}var t=UnreadInfoModuleService.prototype;return t.changeCacheServerRoleIds=function changeCacheServerRoleIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h,v,M,I,S=this;return ud.wrap((function _callee$(T){for(;;)switch(T.prev=T.next){case 0:if(u=t.attach.serverIdentifyInfo,m=u.serverId,h=u.roleId,this.serverRoleIdsMap[m]){T.next=4;break}return T.next=4,this.getRoleIdsByServerId([m]);case 4:if(v=this.serverRoleIdsMap[m],!(t.time<v.timeTag)){T.next=7;break}return T.abrupt("return");case 7:if(t.type===k_[k_.serverIdentifyAdd]?v.roleIds.add(h):v.roleIds.delete(h),this.core.logger.debug("QChatChannel::qchatChannel/serverIdentifyChange::now "+m+" roleIds is",concat(i=[]).call(i,v.roleIds)),M=this.unreadServerCount[m]){T.next=12;break}return T.abrupt("return");case 12:I=chunk(Ht(M),100),forEach$1(I).call(I,(function(t){S.core.qchatChannel.getChannelUnreadInfos({channels:map$6(t).call(t,(function(t){return{serverId:m,channelId:t}}))})}));case 14:case"end":return T.stop()}}),_callee,this)})))},t.getRoleIdsByServerId=function getRoleIdsByServerId(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v=this;return ud.wrap((function _callee2$(M){for(;;)switch(M.prev=M.next){case 0:if((u=filter(t).call(t,(function(t){return!v.serverRoleIdsMap[t]}))).length){M.next=3;break}return M.abrupt("return");case 3:return m={serverIdTimeTags:u},M.next=6,this.core.sendCmd("qchatGetRoleIdsByServerId",{qchatGetRoleIdsByServerIdTag:m});case 6:h=M.sent,this.core.logger.debug("QChatChannel:: getRoleIdsByServerId, params is ",m,"result is",h),forEach$1(i=h.content.serverRoles).call(i,(function(t){try{t.roleIds=JSON.parse(t.roleIds)}catch(t){v.core.logger.error("QChatChannel:: getRoleIdsByServerId JSON parse roleIds error",t)}v.serverRoleIdsMap[t.serverId]={roleIds:new zg(t.roleIds),timeTag:t.timeTag}}));case 9:case"end":return M.stop()}}),_callee2,this)})))},t._unSubscribeChannel=function _unSubscribeChannel(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var u,m,h,v,M;return ud.wrap((function _callee3$(I){for(;;)switch(I.prev=I.next){case 0:if(u=t+"_"+i,m=[],this.manualSubscribeUnreadMap[u]?m.push(this.manualSubscribeUnreadMap[u]):this.autoSubscribeUnreadMap[u]&&m.push(this.autoSubscribeUnreadMap[u]),this.manualSubscribeTypingMap[u]&&m.push(this.manualSubscribeTypingMap[u]),0!==m.length){I.next=6;break}return I.abrupt("return");case 6:for(h=0,v=m;h<v.length;h++)M=v[h],this.subscribe({opeType:w_.unSub,type:M,channels:[{serverId:t,channelId:i}]});this.manualSubscribeUnreadMap[u]?this.manualSubscribeUnreadMap[u]=void 0:this.autoSubscribeUnreadMap[u]&&(this.autoSubscribeUnreadMap[u]=void 0),this.manualSubscribeTypingMap[u]&&(this.manualSubscribeTypingMap[u]=void 0);case 9:case"end":return I.stop()}}),_callee3,this)})))},t._unSubscribeServer=function _unSubscribeServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u;return ud.wrap((function _callee4$(m){for(;;)switch(m.prev=m.next){case 0:if(i=t,u=this.manualSubscribeServerMap[i]||this.autoSubscribeServerMap[i]){m.next=4;break}return m.abrupt("return");case 4:this.subscribe({opeType:w_.unSub,type:u,channels:[{serverId:t,channelId:""}]}),this.manualSubscribeServerMap[i]?this.manualSubscribeServerMap[i]=void 0:this.autoSubscribeServerMap[i]&&(this.autoSubscribeServerMap[i]=void 0);case 6:case"end":return m.stop()}}),_callee4,this)})))},t.subscribe=function subscribe(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i,u,m,h,v=this;return ud.wrap((function _callee6$(M){for(;;)switch(M.prev=M.next){case 0:return validate({type:{type:"number",min:1,max:5},opeType:{type:"number",min:1,max:2}},t),M.next=3,this.core.sendCmd("qchatSubscribe",{qchatSubReqTag:{type:t.type,opeType:t.opeType},channels:t.channels});case 3:return u=M.sent,m=new zg,forEach$1(i=t.channels).call(i,(function(t){return __awaiter(v,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:this.serverRoleIdsMap[t.serverId]||m.add(t.serverId);case 1:case"end":return i.stop()}}),_callee5,this)})))})),h=chunk(id(m),10),forEach$1(h).call(h,(function(t){v.getRoleIdsByServerId(t)})),M.abrupt("return",u.content);case 9:case"end":return M.stop()}}),_callee6,this)})))},t.autoSubscribe=function autoSubscribe(){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.core.sendCmd("qchatAutoSubscribe",{qchatAutoSubReqTag:{}});case 2:case"end":return t.stop()}}),_callee7,this)})))},t.resumeSubscribe=function resumeSubscribe(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var i,u,m,h,v,M,I,S=this;return ud.wrap((function _callee10$(T){for(;;)switch(T.prev=T.next){case 0:if(this.serverRoleIdsMap={},v=100,t){T.next=6;break}return this.unreadServerCount={},this.unreadCount={},T.abrupt("return");case 6:return M={},forEach$1(i=Ht(this.manualSubscribeUnreadMap)).call(i,(function(t){var i=S.manualSubscribeUnreadMap[t];if(i){var u=t.split("_"),m={serverId:u[0],channelId:u[1]};M[i]=M[i]||[],M[i].push(m)}})),M[5]=[],forEach$1(u=Ht(this.manualSubscribeTypingMap)).call(u,(function(t){return __awaiter(S,void 0,void 0,ud.mark((function _callee8(){var i,u,m,h;return ud.wrap((function _callee8$(v){for(;;)switch(v.prev=v.next){case 0:this.manualSubscribeTypingMap[t]&&(i=t.split("_"),u=i[0],m=i[1],h={serverId:u,channelId:m},M[5].push(h));case 2:case"end":return v.stop()}}),_callee8,this)})))})),M[4]=[],forEach$1(m=Ht(this.manualSubscribeServerMap)).call(m,(function(t){return __awaiter(S,void 0,void 0,ud.mark((function _callee9(){var i;return ud.wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:this.manualSubscribeServerMap[t]&&(i={serverId:t},M[4].push(i));case 2:case"end":return u.stop()}}),_callee9,this)})))})),I=[],forEach$1(h=Ht(M)).call(h,(function(t){var i=M[t];if(i&&0===i.length)return zi.resolve();if(i.length>v){var u=chunk(i,100);return forEach$1(u).call(u,(function(i){I.push(S.createSubscribePromise(i,t))}))}I.push(S.createSubscribePromise(i,t))})),T.next=16,zi.all(I);case 16:case"end":return T.stop()}}),_callee10,this)})))},t.createSubscribePromise=function createSubscribePromise(t,i){var u=this,m={type:Gd(i),opeType:1,channels:t};return this.core.logger.debug("qchatChannel:: autoSubscribeUnread params",m),this.subscribe(m).then((function(t){var i=t.unreadInfos;i&&i.length>0&&(i=formatUnreadInfos(i),u.updateUnreads(i))})).catch((function(t){u.core.logger.error("qchatChannel:: autoSubscribeUnread error ",t)}))},t.cacheSubscribe=function cacheSubscribe(t){var i,u=this;forEach$1(i=t.channels).call(i,(function(i){var m=i.channelId?i.serverId+"_"+i.channelId:""+i.serverId,h=5===t.type?u.manualSubscribeTypingMap:4===t.type?u.manualSubscribeServerMap:u.manualSubscribeUnreadMap;t.opeType===w_.sub?h[m]=t.type:t.opeType===w_.unSub&&(h[m]=void 0)}))},t.cacheAutoSubscribe=function cacheAutoSubscribe(t){var i,u=this;forEach$1(i=t.channels).call(i,(function(i){var m=i.channelId?i.serverId+"_"+i.channelId:""+i.serverId,h=4===t.type?u.autoSubscribeServerMap:u.autoSubscribeUnreadMap;t.opeType===w_.sub?h[m]=t.type:t.opeType===w_.unSub&&(h[m]=void 0)}))},t.cacheUnreadCount=function cacheUnreadCount(t){var i=this;forEach$1(t).call(t,(function(t){var u=t.serverId+"_"+t.channelId;i.unreadCount[u]=Dt({},t),i.unreadServerCount[t.serverId]||(i.unreadServerCount[t.serverId]={}),i.unreadServerCount[t.serverId][t.channelId]=!0}))},t.getServerUnreadInfo=function getServerUnreadInfo(t){var i,u=this,m={serverId:t,unreadCount:0,mentionedCount:0,maxCount:0},h=this.unreadServerCount[t];h&&(forEach$1(i=Ht(h)).call(i,(function(i){var h=t+"_"+i,v=u.unreadCount[h];m.unreadCount+=v.unreadCount,m.mentionedCount+=v.mentionedCount,void 0!==v.maxCount&&(m.maxCount=v.maxCount)})),m.unreadCount=m.unreadCount>m.maxCount?m.maxCount:m.unreadCount,m.mentionedCount=m.mentionedCount>m.maxCount?m.maxCount:m.mentionedCount);return m},t.getUnreadInfo=function getUnreadInfo(t){validate({serverId:{type:"string"},channelId:{type:"string"}},t);var i=t.serverId+"_"+t.channelId;return this.unreadCount[i]?this.unreadCount[i]:null},t.shouldChangeUnread=function shouldChangeUnread(t,i){if(!t.serverId||!t.channelId)return!1;if(this.core.qchatChannel.subscribeForVisitorService.isInSubscribeChannels(t.serverId,t.channelId))return!1;if(!1===t.historyEnable)return!1;if(!1===t.needBadge)return!1;if(t.fromAccount===this.core.account)return!1;if(i&&2!==(null==t?void 0:t.status))return!1;if(t.notifyReason&&t.notifyReason===getEnumKeyByEnumValue(E_,E_.notifySubscribe)){if(!t.serverId||!t.channelId)return!1;var u=this.getUnreadInfo({serverId:t.serverId,channelId:t.channelId}),m=i?"ackTimestamp":"lastMsgTime";if(!u)return!1;if(t.time&&u[m]&&u[m]>t.time)return!1}return!0},t.shouldChangeMentionedUnread=function shouldChangeMentionedUnread(t,i){return void 0===i&&(i=!1),__awaiter(this,void 0,void 0,ud.mark((function _callee11(){var u,m;return ud.wrap((function _callee11$(h){for(;;)switch(h.prev=h.next){case 0:if(!t.accidsOfMentionedRoles||!includes(u=t.accidsOfMentionedRoles).call(u,this.core.account)){h.next=2;break}return h.abrupt("return",!0);case 2:if(!t.mentionRoleIds||!t.serverId){h.next=16;break}if(this.serverRoleIdsMap[t.serverId]){h.next=9;break}if(i){h.next=7;break}return this.handledRoleMsg(t),h.abrupt("return",!1);case 7:return h.next=9,this.getRoleIdsByServerId([t.serverId]);case 9:m=0;case 10:if(!(m<t.mentionRoleIds.length)){h.next=16;break}if(!this.serverRoleIdsMap[t.serverId].roleIds.has(t.mentionRoleIds[m])){h.next=13;break}return h.abrupt("return",!0);case 13:m++,h.next=10;break;case 16:return h.abrupt("return",!1);case 17:case"end":return h.stop()}}),_callee11,this)})))},t.handledRoleMsg=function handledRoleMsg(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i,u,m,h,v,M=this;return ud.wrap((function _callee12$(I){for(;;)switch(I.prev=I.next){case 0:if(t.mentionRoleIds){I.next=2;break}return I.abrupt("return");case 2:if(this.serverRoleIdsMap[t.serverId]){I.next=5;break}return I.next=5,this.getRoleIdsByServerId([t.serverId]);case 5:if(this.serverRoleIdsMap[t.serverId]){I.next=8;break}return this.core.logger.warn("QChatChannel::handledRoleMsg::can not get serverRoleIds,server id",t.serverId),I.abrupt("return");case 8:if(u=!1,forEach$1(i=t.mentionRoleIds).call(i,(function(i){M.serverRoleIdsMap[t.serverId].roleIds.has(i)&&(u=!0,M.core.logger.debug("QChatChannel::handledRoleMsg::will update message mentionedCount,message is ",t))})),u){I.next=12;break}return I.abrupt("return");case 12:if(m=this.unreadCount[t.serverId+"_"+t.channelId],h=2===(null==t?void 0:t.status),m.mentionedCount=h?m.mentionedCount?m.mentionedCount-1:0:m.mentionedCount?m.mentionedCount+1:1,"number"!=typeof m.maxCount){I.next=25;break}if(!((v=(v=m.mentionedCount)>m.maxCount?m.maxCount:v)>m.maxCount)){I.next=21;break}return this.core.logger.debug("QChatChannel::handledRoleMsg::tempUnreadCount more than maxCount"),I.abrupt("return");case 21:this.core.emit("unreadInfo",Dt(Dt({},m),{mentionedCount:v})),this.core.emit("unreadInfos",[Dt(Dt({},m),{mentionedCount:v})]),this.core.qchatChannel.emit("unreadInfos",[Dt(Dt({},m),{mentionedCount:v})]),this._serverUnreadInfo(t.serverId);case 25:case"end":return I.stop()}}),_callee12,this)})))},t.getMentionedFlag=function getMentionedFlag(t,i){return void 0===i&&(i=!1),__awaiter(this,void 0,void 0,ud.mark((function _callee13(){var u;return ud.wrap((function _callee13$(m){for(;;)switch(m.prev=m.next){case 0:if(!t.mentionAll){m.next=4;break}return m.abrupt("return",!0);case 4:if(!t.mentionRoleIds&&!t.accidsOfMentionedRoles){m.next=10;break}return m.next=7,this.shouldChangeMentionedUnread(t,i);case 7:return m.abrupt("return",m.sent);case 10:if(!t.mentionAccids||!includes(u=t.mentionAccids).call(u,this.core.account)){m.next=12;break}return m.abrupt("return",!0);case 12:return m.abrupt("return",!1);case 13:case"end":return m.stop()}}),_callee13,this)})))},t.changeUnread=function changeUnread(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var u,m,h,v,M,I,S;return ud.wrap((function _callee14$(T){for(;;)switch(T.prev=T.next){case 0:if(u=t.serverId,m=t.channelId,h=u+"_"+m,this.shouldChangeUnread(t,i)){T.next=6;break}return this.core.logger.debug("changeUnread: "+h+" does not need to update unreadInfo"),T.abrupt("return");case 6:if(this.unreadCount[h]){T.next=11;break}return T.next=9,this.core.qchatChannel.getChannelUnreadInfos({channels:[{serverId:u,channelId:m}]});case 9:return!this.serverRoleIdsMap[u]&&t.mentionRoleIds&&this.getRoleIdsByServerId([u]),T.abrupt("return");case 11:return v=this.unreadCount[h],M=2===(null==t?void 0:t.status),T.next=15,this.getMentionedFlag(t);case 15:if(I=T.sent,M?(v.unreadCount=v.unreadCount?v.unreadCount-1:0,I&&(v.mentionedCount=v.mentionedCount?v.mentionedCount-1:0),delete v.lastMsgTime,this.core.logger.debug("changeUnread: "+h+" unread reduce ",v)):(v.unreadCount=v.unreadCount?v.unreadCount+1:1,I&&(v.mentionedCount=v.mentionedCount?v.mentionedCount+1:1),t.time&&(v.lastMsgTime=t.time),this.core.logger.debug("changeUnread: "+h+" unread add ",v)),S="number"==typeof v.maxCount?v.maxCount:100,!(v.unreadCount>S)){T.next=21;break}return this.core.logger.debug("QChatChannel::subscribe::tempUnreadCount more than maxCount"),T.abrupt("return");case 21:this.core.logger.warn("unreadInfo event will abandon,please use unreadInfos"),this.core.emit("unreadInfo",Dt(Dt({},v),{mentionedCount:v.mentionedCount>S?S:v.mentionedCount,unreadCount:v.unreadCount>S?S:v.unreadCount})),this.core.emit("unreadInfos",[Dt(Dt({},v),{mentionedCount:v.mentionedCount>S?S:v.mentionedCount,unreadCount:v.unreadCount>S?S:v.unreadCount})]),this.core.qchatChannel.emit("unreadInfos",[Dt(Dt({},v),{mentionedCount:v.mentionedCount>S?S:v.mentionedCount,unreadCount:v.unreadCount>S?S:v.unreadCount})]),this._serverUnreadInfo(u);case 26:case"end":return T.stop()}}),_callee14,this)})))},t.updateUnreads=function updateUnreads(t){var i,u,m=this;if(t&&t.length>0){var h=[],v=[],M=map$6(i=filter(t).call(t,(function(t){var i=t.serverId+"_"+t.channelId,u=m.unreadCount[i],h=get(u,"ackTimestamp"),v=get(t,"ackTimestamp");return!(h&&v&&v<h)&&(get(u,"unreadCount")!==get(t,"unreadCount")||get(u,"mentionedCount")!==get(t,"mentionedCount"))}))).call(i,(function(t){h.push(m.getServerUnreadInfo(t.serverId)),v.push(m.unreadServerCount[t.serverId]);var i=t.serverId,u=t.channelId,M=i+"_"+u;return m.core.logger.debug("qchat channel updateUnread: ",t),m.unreadCount[M]=Dt({},t),m.unreadServerCount[i]||(m.unreadServerCount[i]={}),m.unreadServerCount[i][u]=!0,t}));if(0!==M.length){this.core.emit("unreadInfos",M),this.core.qchatChannel.emit("unreadInfos",M);var I={};forEach$1(M).call(M,(function(t,i){m.core.emit("unreadInfo",t);var u=h[i],M=v[i],S=m.getServerUnreadInfo(t.serverId),T=m.unreadServerCount[t.serverId],C=u.unreadCount!==S.unreadCount,E=!M||0===Ht(M).length,A=T&&Ht(T).length>0,k=u.mentionedCount!==S.mentionedCount;(C||k||E&&A)&&(I[t.serverId]=!0)})),forEach$1(u=Ht(I)).call(u,(function(t){m.core.emit("serverUnreadInfo",m.getServerUnreadInfo(t)),get(m.core,"qchatServer.emit")&&m.core.qchatServer.emit("serverUnreadInfo",m.getServerUnreadInfo(t))}))}}},t.clearUnreadCountByServers=function clearUnreadCountByServers(t,i){var u=this,m=[];forEach$1(t).call(t,(function(t){var i;u.unreadServerCount[t]&&forEach$1(i=Ht(u.unreadServerCount[t])).call(i,(function(i){m.push(t+"_"+i)}))}));var h=[];forEach$1(m).call(m,(function(t){h.push(Dt(Dt({},u.unreadCount[t]),{unreadCount:0,mentionedCount:0,ackTimestamp:i}))})),this.updateUnreads(h)},UnreadInfoModuleService}(),L_=function(){function SubscribeForVisitorService(t){this.limitForBatchEnter=10,this.limitForBatchSubscribe=100,this.autoServers=new zg,this.autoVisitorSubscribeServer=new zg,this.autoVisitorSubscribeChannel=new zg,this.core=t}var t=SubscribeForVisitorService.prototype;return t.subscribeChannelAsVisitor=function subscribeChannelAsVisitor(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u,m,h,v=this;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,this.core.sendCmd("qchatSubscribeAsVisitor",{tag:{type:t.type||6,opeType:t.opeType},datas:t.channels});case 2:return u=M.sent,m=u.content.failedArr,h=filter(i=t.channels).call(i,(function(t){return!some(m).call(m,(function(i){return i.channelId===t.channelId&&i.serverId===t.serverId}))})),forEach$1(h).call(h,(function(i){1===t.opeType?v.autoVisitorSubscribeChannel.add(i.serverId+"&"+i.channelId):v.autoVisitorSubscribeChannel.delete(i.serverId+"&"+i.channelId)})),M.abrupt("return",{failedChannels:m});case 7:case"end":return M.stop()}}),_callee,this)})))},t.subscribeServerAsVisitor=function subscribeServerAsVisitor(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v,M,I=this;return ud.wrap((function _callee2$(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this.core.sendCmd("qchatSubscribeAsVisitor",{tag:{type:t.type||7,opeType:t.opeType},datas:map$6(i=t.serverIds).call(i,(function(t){return{serverId:t}}))});case 2:return h=S.sent,v=h.content.failedArr,M=filter(u=t.serverIds).call(u,(function(t){return!some(v).call(v,(function(i){return i.serverId===t}))})),forEach$1(M).call(M,(function(i){1===t.opeType?I.autoVisitorSubscribeServer.add(i):I.autoVisitorSubscribeServer.delete(i)})),S.abrupt("return",{failedServers:map$6(m=h.content.failedArr).call(m,(function(t){return t.serverId}))});case 7:case"end":return S.stop()}}),_callee2,this)})))},t.deleteServer=function deleteServer(t){var i;this.autoServers.delete(t),this.autoVisitorSubscribeServer.has(t)&&this.subscribeServerAsVisitor({opeType:2,serverIds:[t]});var u=[];forEach$1(i=this.autoVisitorSubscribeChannel).call(i,(function(i){if(0===indexOf(i).call(i,t)){var m=i.replace(t+"&","");u.push({serverId:t,channelId:m})}})),u.length>0&&this.subscribeChannelAsVisitor({opeType:2,channels:u})},t.deleteAutoSetInServerId=function deleteAutoSetInServerId(t){var i,u=this;this.autoServers.delete(t),this.autoVisitorSubscribeServer.delete(t),forEach$1(i=this.autoVisitorSubscribeChannel).call(i,(function(i){0===indexOf(i).call(i,t)&&u.autoVisitorSubscribeChannel.delete(i)}))},t.deleteAutoSetInChannel=function deleteAutoSetInChannel(t,i){this.autoVisitorSubscribeChannel.delete(t+"&"+i)},t.unSubscribeChannel=function unSubscribeChannel(t,i){this.subscribeChannelAsVisitor({opeType:2,channels:[{serverId:t,channelId:i}]})},t.isInSubscribeChannels=function isInSubscribeChannels(t,i){return this.autoVisitorSubscribeChannel.has(t+"&"+i)},t.isInAutoServers=function isInAutoServers(t){return this.autoServers.has(t)},t.doAutoSubscribe=function doAutoSubscribe(){var t=this,i=[],u=chunk(id(this.autoVisitorSubscribeServer),this.limitForBatchSubscribe);forEach$1(u).call(u,(function(u){i.push(t.subscribeServerAsVisitor({opeType:1,serverIds:u}))}));var m=chunk(id(this.autoVisitorSubscribeChannel),this.limitForBatchSubscribe);return forEach$1(m).call(m,(function(u){i.push(t.subscribeChannelAsVisitor({opeType:1,channels:map$6(u).call(u,(function(t){var i=indexOf(t).call(t,"&");return{serverId:slice(t).call(t,0,i),channelId:slice(t).call(t,i+1)}}))}))})),zi.all(i)},t.doAutoEnterServer=function doAutoEnterServer(){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var t,i,u,m=this;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:return t=chunk(id(this.autoServers),this.limitForBatchEnter),i=[],forEach$1(t).call(t,(function(t){i.push(m.core.qchatServer.enterAsVisitor({serverIds:t}))})),h.next=5,zi.all(i);case 5:u=h.sent,forEach$1(u).call(u,(function(t){var i;forEach$1(i=t.failedServers).call(i,(function(t){m.deleteAutoSetInServerId(t)}))}));case 7:case"end":return h.stop()}}),_callee3,this)})))},t.resumeSubscribe=function resumeSubscribe(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:if(!t){i.next=7;break}return i.next=3,this.doAutoEnterServer();case 3:return i.next=5,this.doAutoSubscribe();case 5:i.next=10;break;case 7:this.autoServers.clear(),this.autoVisitorSubscribeChannel.clear(),this.autoVisitorSubscribeServer.clear();case 10:case"end":return i.stop()}}),_callee4,this)})))},t.cacheServer=function cacheServer(t){var i=this;forEach$1(t).call(t,(function(t){return i.autoServers.add(t)}))},SubscribeForVisitorService}();function _createForOfIteratorHelperLoose$1(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray$1(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray$1(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray$1(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray$1(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var V_=function(t){function QChatChannelService(i,u){var m;return(m=t.call(this,"qchatChannel",i)||this).config={autoSubscribe:!1},m.core=i,registerParser({cmdMap:r_,cmdConfig:o_()}),u&&m.setOptions(u),m.subscribeModuleService=new P_(i),m.subscribeForVisitorService=new L_(i),m.setListener(),m}Nt(QChatChannelService,t);var i=QChatChannelService.prototype;return i.setOptions=function setOptions(t){t&&(this.config=Dt(this.config,t))},i.setListener=function setListener(){var t,i,u,m,h,v=this;this.core.eventBus.on("logined",(function(t){v.subscribeModuleService.resumeSubscribe(t.isAutoReconnect),v.subscribeForVisitorService.resumeSubscribe(t.isAutoReconnect),v.config.autoSubscribe&&(v.subscribeModuleService.autoSubscribeServerMap={},v.subscribeModuleService.autoSubscribeUnreadMap={},v.subscribeModuleService.autoSubscribe())})),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",(function(t){v.subscribeModuleService.resumeSubscribe(t.isReconnect),v.subscribeForVisitorService.resumeSubscribe(t.isReconnect),v.config.autoSubscribe&&(v.subscribeModuleService.autoSubscribeServerMap={},v.subscribeModuleService.autoSubscribeUnreadMap={},v.subscribeModuleService.autoSubscribe())})),this.core.eventBus.on("qchatChannel/changeUnread",bind$1(t=this.subscribeModuleService.changeUnread).call(t,this.subscribeModuleService)),this.core.eventBus.on("qchatChannel/updateUnreads",bind$1(i=this.subscribeModuleService.updateUnreads).call(i,this.subscribeModuleService)),this.core.eventBus.on("qchatChannel/cacheSubscribe",bind$1(u=this.subscribeModuleService.cacheSubscribe).call(u,this.subscribeModuleService)),this.core.eventBus.on("qchatChannel/clearUnreadCountByServers",bind$1(m=this.subscribeModuleService.clearUnreadCountByServers).call(m,this.subscribeModuleService)),this.core.eventBus.on("qchatChannel/getRoleIdsByServerId",bind$1(h=this.subscribeModuleService.getRoleIdsByServerId).call(h,this.subscribeModuleService)),this.core.eventBus.on("qchatChannel/autoUnSubscribe",(function(t){if(v.logger.log("QChatChannel::enter autoUnSubscribe sysMsg is",t),t.type===k_[k_.channelVisibilityUpdate])v.logger.log("QChatChannel::begin autoUnSubscribe channel key is",t.serverId+"_"+t.channelId),v.subscribeModuleService._unSubscribeChannel(t.serverId,t.channelId),v.logger.log("QChatChannel::autoUnSubscribe channel done key is",t.serverId+"_"+t.channelId);else if(t.type===k_[k_.serverEnterLeave]){var i;(v.subscribeModuleService.manualSubscribeServerMap[t.serverId]||v.subscribeModuleService.autoSubscribeServerMap[t.serverId])&&(v.logger.log("QChatChannel::begin autoUnSubscribe server key is",t.serverId),v.subscribeModuleService._unSubscribeServer(t.serverId),v.logger.log("QChatChannel::autoUnSubscribe server done key is",t.serverId));var u=v.subscribeModuleService.unreadServerCount[t.serverId];if(!u)return;v.logger.log("QChatChannel::begin autoUnSubscribe channels key is",Ht(u)),forEach$1(i=Ht(u)).call(i,(function(i){v.subscribeModuleService._unSubscribeChannel(t.serverId,i)})),v.logger.log("QChatChannel::autoUnSubscribe channels done key is",Ht(u))}})),this.core.eventBus.on("qchatChannel/serverIdentifyChange",(function(t){v.subscribeModuleService.changeCacheServerRoleIds(t)}))},i.createChannel=function createChannel(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",min:1},type:{type:"enum",values:getEnumKeys(QI)},name:{type:"string",required:!1},topic:{type:"string",required:!1},ext:{type:"string",required:!1},visitorMode:{type:"number",required:!1}},t),u.next=3,this.core.sendCmd("qchatCreateChannel",{channelInfo:Dt(Dt({},t),{type:QI[t.type]}),antispamTag:generateAntispamTag(t)});case 3:return i=u.sent,u.abrupt("return",formatChannel(i.content.channelInfo));case 5:case"end":return u.stop()}}),_callee,this)})))},i.deleteChannel=function deleteChannel(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:return validate({channelId:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatDeleteChannel",t);case 3:case"end":return i.stop()}}),_callee2,this)})))},i.updateChannel=function updateChannel(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i,u;return ud.wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:return validate({channelId:{type:"string",min:1},serverId:{type:"string",required:!1},type:{type:"enum",values:getEnumKeys(QI),required:!1},name:{type:"string",required:!1},topic:{type:"string",required:!1},ext:{type:"string",required:!1},visitorMode:{type:"number",required:!1}},t),i=t,t.type&&(i.type=QI[t.type]),m.next=5,this.core.sendCmd("qchatUpdateChannel",{channelInfo:i,antispamTag:generateAntispamTag(t)});case 5:return u=m.sent,m.abrupt("return",formatChannel(u.content.channelInfo));case 7:case"end":return m.stop()}}),_callee3,this)})))},i.getChannels=function getChannels(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return validate({channelIds:{type:"array",itemType:"string",min:1}},t),u.next=3,this.core.sendCmd("qchatGetChannels",t);case 3:return i=u.sent,u.abrupt("return",formatChannels(i.content.channelList));case 5:case"end":return u.stop()}}),_callee4,this)})))},i.getChannelsByPage=function getChannelsByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i,u,m,h;return ud.wrap((function _callee5$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",min:1},timetag:{type:"number"},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetChannelsByPage",{qchatGetChannelListPageTag:Dt({limit:100},t)});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatChannels(m)});case 6:case"end":return v.stop()}}),_callee5,this)})))},i.getMembersByPage=function getMembersByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i,u,m,h;return ud.wrap((function _callee6$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",min:1},channelId:{type:"string",min:1},timetag:{type:"number"},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetMembersByPage",{qchatGetMembersByPageTag:t});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatMembers$1(m)});case 6:case"end":return v.stop()}}),_callee6,this)})))},i.updateWhiteBlackRole=function updateWhiteBlackRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1},channelId:{type:"string",min:1},roleId:{type:"string",min:1},type:{type:"enum",values:getEnumKeys(KI)},opeType:{type:"enum",values:getEnumKeys(YI)}},t),i.next=3,this.core.sendCmd("qchatUpdateWhiteBlackRole",{qchatUpdateWhiteBlackRoleTag:Dt(Dt({},t),{type:KI[t.type],opeType:YI[t.opeType]})});case 3:case"end":return i.stop()}}),_callee7,this)})))},i.getWhiteBlackRolesPage=function getWhiteBlackRolesPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i,u,m,h;return ud.wrap((function _callee8$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",min:1},channelId:{type:"string",min:1},type:{type:"enum",values:getEnumKeys(KI)},timetag:{type:"number"},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetWhiteBlackRolesPage",{qchatGetWhiteBlackRolesPageTag:Dt(Dt({},t),{type:KI[t.type]})});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatRoles(m)});case 6:case"end":return v.stop()}}),_callee8,this)})))},i.updateWhiteBlackMembers=function updateWhiteBlackMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){return ud.wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1},channelId:{type:"string",min:1},type:{type:"enum",values:getEnumKeys(KI)},opeType:{type:"enum",values:getEnumKeys(YI)},toAccids:{type:"array",itemType:"string",min:1}},t),i.next=3,this.core.sendCmd("qchatUpdateWhiteBlackMembers",{qchatUpdateWhiteBlackMembersTag:Dt(Dt({},t),{type:KI[t.type],opeType:YI[t.opeType],toAccids:Un(t.toAccids)})});case 3:case"end":return i.stop()}}),_callee9,this)})))},i.getWhiteBlackMembersPage=function getWhiteBlackMembersPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var i,u,m,h;return ud.wrap((function _callee10$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",min:1},channelId:{type:"string",min:1},type:{type:"enum",values:getEnumKeys(KI)},timetag:{type:"number"},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetWhiteBlackMembersPage",{qchatGetWhiteBlackMembersPageTag:Dt(Dt({limit:100},t),{type:KI[t.type]})});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatMembers$1(m)});case 6:case"end":return v.stop()}}),_callee10,this)})))},i.getExistingWhiteBlackRoles=function getExistingWhiteBlackRoles(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var i,u;return ud.wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:return validate({serverId:{type:"string",min:1},channelId:{type:"string",min:1},type:{type:"enum",values:getEnumKeys(KI)},roleIds:{type:"array",itemType:"string",min:1}},t),m.next=3,this.core.sendCmd("qchatGetExistingWhiteBlackRoles",{qchatGetExistingWhiteBlackRolesTag:Dt(Dt({},t),{type:KI[t.type],roleIds:Un(t.roleIds)})});case 3:return i=m.sent,u=i.content.datas,m.abrupt("return",{datas:formatRoles(u)});case 6:case"end":return m.stop()}}),_callee11,this)})))},i.getExistingWhiteBlackMembers=function getExistingWhiteBlackMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i,u;return ud.wrap((function _callee12$(m){for(;;)switch(m.prev=m.next){case 0:return validate({serverId:{type:"string",min:1},channelId:{type:"string",min:1},type:{type:"enum",values:getEnumKeys(KI)},accids:{type:"array",itemType:"string",min:1}},t),m.next=3,this.core.sendCmd("qchatGetExistingWhiteBlackMembers",{qchatGetExistingWhiteBlackMembersTag:Dt(Dt({},t),{type:KI[t.type],accids:Un(t.accids)})});case 3:return i=m.sent,u=i.content.datas,m.abrupt("return",{datas:formatMembers$1(u)});case 6:case"end":return m.stop()}}),_callee12,this)})))},i.updateCategoryInfoOfChannel=function updateCategoryInfoOfChannel(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i;return ud.wrap((function _callee13$(u){for(;;)switch(u.prev=u.next){case 0:return validate({channelId:{type:"string",min:1},categoryId:{type:"string",allowEmpty:!1,required:!1},syncMode:{type:"number",min:0,max:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateCategoryInfoOfChannel",{qchatUpdateCategoryInfoOfChannelTag:t});case 3:return i=u.sent,u.abrupt("return",formatChannel(i.content.channelInfo));case 5:case"end":return u.stop()}}),_callee13,this)})))},i.createChannelCategory=function createChannelCategory(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var i;return ud.wrap((function _callee14$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},name:{type:"string",allowEmpty:!1,required:!1},ext:{type:"string",required:!1},viewMode:{type:"number",min:0,max:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatCreateChannelCategory",{qchatCreateChannelCategoryTag:t});case 3:return i=u.sent,u.abrupt("return",formatChannelCategory(i.content.QChatChannelCategoryInfo));case 5:case"end":return u.stop()}}),_callee14,this)})))},i.removeChannelCategory=function removeChannelCategory(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){return ud.wrap((function _callee15$(i){for(;;)switch(i.prev=i.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatRemoveChannelCategory",t);case 3:case"end":return i.stop()}}),_callee15,this)})))},i.updateChannelCategory=function updateChannelCategory(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i;return ud.wrap((function _callee16$(u){for(;;)switch(u.prev=u.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1},name:{type:"string",allowEmpty:!1,required:!1},ext:{type:"string",required:!1},viewMode:{type:"number",min:0,max:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateChannelCategory",{qchatUpdateChannelCategoryTag:t});case 3:return i=u.sent,u.abrupt("return",formatChannelCategory(i.content.QChatChannelCategoryInfo));case 5:case"end":return u.stop()}}),_callee16,this)})))},i.getChannelCategoriesByID=function getChannelCategoriesByID(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){var i;return ud.wrap((function _callee17$(u){for(;;)switch(u.prev=u.next){case 0:return validate({categoryIds:{type:"array",itemType:"string",min:1}},t),u.next=3,this.core.sendCmd("qchatGetChannelCategoriesByID",t);case 3:return i=u.sent,u.abrupt("return",formatChannelCategorys(i.content.channelCategoryList));case 5:case"end":return u.stop()}}),_callee17,this)})))},i.updateChannelCategoryWhiteBlackRole=function updateChannelCategoryWhiteBlackRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){return ud.wrap((function _callee18$(i){for(;;)switch(i.prev=i.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1},serverId:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(KI)},opeType:{type:"enum",values:getEnumKeys(YI)},roleId:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatUpdateChannelCategoryWhiteBlackRole",{qchatUpdateChannelCategoryWhiteBlackRoleTag:Dt(Dt({},t),{type:KI[t.type],opeType:YI[t.opeType]})});case 3:case"end":return i.stop()}}),_callee18,this)})))},i.getChannelCategoryWhiteBlackRolesPage=function getChannelCategoryWhiteBlackRolesPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){var i,u,m,h;return ud.wrap((function _callee19$(v){for(;;)switch(v.prev=v.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1},serverId:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(KI)},timetag:{type:"number",min:0},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetChannelCategoryWhiteBlackRolesPage",{qchatGetChannelCategoryWhiteBlackRolesPageTag:Dt(Dt({},t),{type:KI[t.type]})});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatRoles(m)});case 6:case"end":return v.stop()}}),_callee19,this)})))},i.updateChannelCategoryWhiteBlackMembers=function updateChannelCategoryWhiteBlackMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){return ud.wrap((function _callee20$(i){for(;;)switch(i.prev=i.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1},serverId:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(KI)},opeType:{type:"enum",values:getEnumKeys(YI)},toAccids:{type:"array",itemType:"string",min:1}},t),i.next=3,this.core.sendCmd("qchatUpdateChannelCategoryWhiteBlackMembers",{qchatUpdateChannelCategoryWhiteBlackMembersTag:Dt(Dt({},t),{type:KI[t.type],opeType:YI[t.opeType],toAccids:Un(t.toAccids)})});case 3:case"end":return i.stop()}}),_callee20,this)})))},i.getChannelCategoryWhiteBlackMembersPage=function getChannelCategoryWhiteBlackMembersPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){var i,u,m,h;return ud.wrap((function _callee21$(v){for(;;)switch(v.prev=v.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1},serverId:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(KI)},timetag:{type:"number",min:0},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetChannelCategoryWhiteBlackMembersPage",{qchatGetChannelCategoryWhiteBlackMembersPageTag:Dt(Dt({},t),{type:KI[t.type]})});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatMembers$1(m)});case 6:case"end":return v.stop()}}),_callee21,this)})))},i.getChannelCategoryWhiteBlackRoles=function getChannelCategoryWhiteBlackRoles(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee22(){var i,u;return ud.wrap((function _callee22$(m){for(;;)switch(m.prev=m.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1},serverId:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(KI)},roleIds:{type:"array",itemType:"string",min:1}},t),m.next=3,this.core.sendCmd("qchatGetChannelCategoryWhiteBlackRoles",{qchatGetChannelCategoryWhiteBlackRolesTag:Dt(Dt({},t),{type:KI[t.type],roleIds:Un(t.roleIds)})});case 3:return i=m.sent,u=i.content.datas,m.abrupt("return",formatRoles(u));case 6:case"end":return m.stop()}}),_callee22,this)})))},i.getChannelCategoryWhiteBlackMembers=function getChannelCategoryWhiteBlackMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee23(){var i,u;return ud.wrap((function _callee23$(m){for(;;)switch(m.prev=m.next){case 0:return validate({categoryId:{type:"string",allowEmpty:!1},serverId:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(KI)},accids:{type:"array",itemType:"string",min:1}},t),m.next=3,this.core.sendCmd("qchatGetChannelCategoryWhiteBlackMembers",{qchatGetChannelCategoryWhiteBlackMembersTag:Dt(Dt({},t),{type:KI[t.type],accids:Un(t.accids)})});case 3:return i=m.sent,u=i.content.datas,m.abrupt("return",formatMembers$1(u));case 6:case"end":return m.stop()}}),_callee23,this)})))},i.getChannelCategoriesPage=function getChannelCategoriesPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee24(){var i,u,m,h;return ud.wrap((function _callee24$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},timetag:{type:"number",min:0},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetChannelCategoriesPage",{qchatGetChannelCategoriesPageTag:t});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatChannelCategorys(m)});case 6:case"end":return v.stop()}}),_callee24,this)})))},i.getChannelCategoryChannelsPage=function getChannelCategoryChannelsPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee25(){var i,u,m,h;return ud.wrap((function _callee25$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},timetag:{type:"number",min:0},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetChannelCategoryChannelsPage",{qchatGetChannelCategoryChannelsPageTag:t});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatChannels(m)});case 6:case"end":return v.stop()}}),_callee25,this)})))},i.subscribeChannel=function subscribeChannel(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee26(){var i,u;return ud.wrap((function _callee26$(m){for(;;)switch(m.prev=m.next){case 0:if(validate({type:{type:"number",min:1,max:5},opeType:{type:"number",min:1,max:2}},t),!this.config.autoSubscribe||t.isInternalTrigger||5===t.type){m.next=3;break}throw new ed("subscribe server failed, manual subscribe is not allowed in auto subscribe mode",{},403);case 3:return m.next=5,this.subscribeModuleService.subscribe(t);case 5:if((i=m.sent).unreadInfos=formatUnreadInfos(i.unreadInfos),5!==t.type){m.next=10;break}return this.subscribeModuleService.cacheSubscribe(t),m.abrupt("return");case 10:return 1===t.opeType&&(t.channels=map$6(u=i.unreadInfos).call(u,(function(t){return{serverId:t.serverId,channelId:t.channelId}}))),this.logger.debug("QChatChannel::subscribeChannel:: cacheSubscribe ",t),this.config.autoSubscribe?this.subscribeModuleService.cacheAutoSubscribe(t):this.subscribeModuleService.cacheSubscribe(t),this.subscribeModuleService.updateUnreads(i.unreadInfos),m.abrupt("return",i);case 15:case"end":return m.stop()}}),_callee26,this)})))},i.getChannelUnreadInfos=function getChannelUnreadInfos(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee27(){var i,u;return ud.wrap((function _callee27$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.core.sendCmd("qchatGetUnreadInfo",t);case 2:return i=m.sent,u=formatUnreadInfos(i.content.unreadInfos),this.subscribeModuleService.updateUnreads(u),m.abrupt("return",u);case 6:case"end":return m.stop()}}),_callee27,this)})))},i.getChannelSearchByPage=function getChannelSearchByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee28(){var i,u,m,h;return ud.wrap((function _callee28$(v){for(;;)switch(v.prev=v.next){case 0:if(validate({keyword:{type:"string",allowEmpty:!1},startTime:{type:"number",min:0,required:!1},endTime:{type:"number",min:1,required:!1},order:{type:"enum",values:getEnumKeys(JI),required:!1},limit:{type:"number",min:1,required:!1},serverId:{type:"string",required:!1},sort:{type:"enum",values:getEnumKeys(WI),required:!1},cursor:{type:"string",allowEmpty:!1,required:!1}},t),!(t.startTime&&t.endTime&&t.startTime>=t.endTime)){v.next=3;break}throw new Ql("startTime more than endTime",t,"timeRule");case 3:return v.next=5,this.core.sendCmd("qchatGetChannelSearchByPage",{qchatGetChannelSearchByPageTag:Dt(Dt({},t),{order:t.order&&JI[t.order],sort:sort(t)&&WI[sort(t)]})});case 5:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag),cursor:h.cursor},datas:formatChannels(m)});case 8:case"end":return v.stop()}}),_callee28,this)})))},i.channelMemberSearch=function channelMemberSearch(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee29(){var i;return ud.wrap((function _callee29$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},keyword:{type:"string",allowEmpty:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatChannelMemberSearch",{qchatChannelMemberSearchTag:t});case 3:return i=u.sent,u.abrupt("return",formatChannelMembers(i.content.datas));case 5:case"end":return u.stop()}}),_callee29,this)})))},i.subscribeAsVisitor=function subscribeAsVisitor(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee30(){return ud.wrap((function _callee30$(i){for(;;)switch(i.prev=i.next){case 0:return validate({opeType:{type:"number",min:1,max:2},type:{type:"number",required:!1},channels:{type:"array",rules:{serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1}},min:1}},t),i.next=3,this.subscribeForVisitorService.subscribeChannelAsVisitor(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee30,this)})))},i.qchatAutoSubscribeNotificationHandler=function qchatAutoSubscribeNotificationHandler(t){var i=formatUnreadInfos(t.content.unreadInfos),u=t.content.serverIds;this.subscribeModuleService.updateUnreads(i);var m=[];if(u.length){var h={opeType:1};h.channels=map$6(u).call(u,(function(t){return{serverId:t.serverId,channelId:""}})),h.type=4,m.push(h)}if(i.length){var v={opeType:1};v.channels=map$6(i).call(i,(function(t){return{serverId:t.serverId,channelId:t.channelId}})),v.type=1,m.push(v)}if(m.length)for(var M,I=_createForOfIteratorHelperLoose$1(m);!(M=I()).done;){var S=M.value;this.subscribeModuleService.cacheAutoSubscribe(S)}},QChatChannelService}(t_),U_={serverId:{type:"string"},uid:{type:"string"},accid:{type:"string"},nick:{type:"string"},avatar:{type:"string"},ext:{type:"string"},type:{type:"number"},joinTime:{type:"number"},inviter:{type:"string"},validFlag:{type:"boolean"},createTime:{type:"number"},updateTime:{type:"number"}},D_={limit:{type:"number"}};function formatMembers(t){return Dn(t)&&t.length>0?map$6(t).call(t,(function(t){return function formatMember(t){return format(U_,t)}(t)})):[]}function formatRTCChannelConfig(t){try{t.audio&&(t.audio=JSON.parse(t.audio))}catch(t){throw new Ql('result "audio" JSON parse error',{key:"audio"},"JSON parse error")}try{t.video&&(t.video=JSON.parse(t.video))}catch(t){throw new Ql('result "video" JSON parse error',{key:"video"},"JSON parse error")}return format(D_,t)}var B_,q_={"25_1":"qchatGetNeroomToken","25_2":"qchatUpdateRTCChannelConfig","25_3":"qchatGetRTCChannelConfig","25_4":"qchatGetRTCChannelMembers"},F_={QChatRTCChannelConfigTag:{serverId:1,channelId:2,limit:3,audio:4,video:5},QChatRTCChannelConfigResultTag:{limit:1,audio:2,video:3},QChatGetRTCParams:{serverId:1,channelId:2},qchatGetRTCChannelMembersTag:{serverId:1,channelId:2},memberInfo:{serverId:1,accid:3,nick:4,avatar:5,ext:6,type:7,joinTime:8,inviter:9,validFlag:10,createTime:11,updateTime:12},QChatGetNeroomTokenResultTag:{token:1,expire:2},QChatGetNeroomTokenParams:{neroomDeviceId:1}},G_=function getCmdConfig(){var t=function getDeserializeTag(){return invertSerializeMap(F_)}();return{qchatGetNeroomToken:{sid:25,cid:1,service:"qchatMedia",params:[{type:"Property",name:"qchatGetNeroomTokenTag",reflectMapper:F_.QChatGetNeroomTokenParams}],response:[{type:"Property",name:"neroomToken",reflectMapper:t.QChatGetNeroomTokenResultTag}]},qchatUpdateRTCChannelConfig:{sid:25,cid:2,service:"qchatMedia",params:[{type:"Property",name:"RTCChannelConfig",reflectMapper:F_.QChatRTCChannelConfigTag}]},qchatGetRTCChannelConfig:{sid:25,cid:3,service:"qchatMedia",params:[{type:"Property",name:"qchatGetRTCChannelConfigTag",reflectMapper:F_.QChatGetRTCParams}],response:[{type:"Property",name:"RTCChannelConfig",reflectMapper:t.QChatRTCChannelConfigResultTag}]},qchatGetRTCChannelMembers:{sid:25,cid:4,service:"qchatMedia",params:[{type:"Property",name:"qchatGetRTCChannelMembersTag",reflectMapper:F_.QChatGetRTCParams}],response:[{type:"PropertyArray",name:"memberList",reflectMapper:t.memberInfo}]}}},H_=function(t){function QChatMediaService(i,u){var m;return(m=t.call(this,"qchatMedia",i)||this).config={},m.tokenExpireTime=24e4,m.getTokenState=!1,m.core=i,registerParser({cmdMap:q_,cmdConfig:G_()}),u&&m.setOptions(u),m.setListener(),m.tokenExpireTime=24e4,m.channelId="",m.serverId="",m}Nt(QChatMediaService,t);var i=QChatMediaService.prototype;return i.setOptions=function setOptions(t){t&&(this.config=Dt(this.config,t),(null==t?void 0:t.neroom)&&this.setNeroom(t.neroom))},i.setNeroom=function setNeroom(t){this.neroom=new t},i.setListener=function setListener(){var t,i,u,m,h=this;this.core.eventBus.on("disconnect",bind$1(t=this._existRomm).call(t,this)),this.core.eventBus.on("kicked",bind$1(i=this._existRomm).call(i,this)),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLogout",bind$1(u=this._existRomm).call(u,this)),this.core.eventBus.on("V2NIMLoginService/loginLifeCycleKicked",bind$1(m=this._existRomm).call(m,this)),this.core.eventBus.on("qchatMedia/serverOrChannelLeave",(function(t){return __awaiter(h,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(!(t.type===k_[k_.channelVisibilityUpdate]&&t.channelId===this.channelId||t.type===k_[k_.serverEnterLeave]&&t.serverId===this.serverId)){i.next=4;break}if(!this.roomContext||!this.roomContext.roomUuid){i.next=4;break}return i.next=4,this.disconnectChannel();case 4:case"end":return i.stop()}}),_callee,this)})))}))},i._existRomm=function _existRomm(){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(!this.roomContext){t.next=3;break}return t.next=3,this.disconnectChannel();case 3:this.tokenTimer&&(this.core.timerManager.deleteTimer(this.tokenTimer),this.tokenTimer=void 0);case 4:case"end":return t.stop()}}),_callee2,this)})))},i._checkPermission=function _checkPermission(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.core.qchatRole.checkPermission(t);case 2:return i=u.sent,u.abrupt("return",i);case 4:case"end":return u.stop()}}),_callee3,this)})))},i._checkConnectState=function _checkConnectState(){if("connect"!==this.state)throw new ed("QChatMedia::you should connect first")},i.kickMemberOut=function kickMemberOut(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),u.prev=2,u.next=5,null===(i=this.roomContext)||void 0===i?void 0:i.kickMemberOut(t.accid);case 5:u.next=11;break;case 7:throw u.prev=7,u.t0=u.catch(2),this.logger.error("QChatMedia::kickMemberOut error params is "+Un(t),u.t0),new ed("QChatMedia::kickMemberOut error",u.t0);case 11:case"end":return u.stop()}}),_callee4,this,[[2,7]])})))},i.disconnectChannel=function disconnectChannel(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return this.logger.debug("QChatMedia::disconnect begin disconnect"),i.prev=1,i.next=4,null===(t=this.roomContext)||void 0===t?void 0:t.leaveRoom();case 4:i.next=9;break;case 6:i.prev=6,i.t0=i.catch(1),this.logger.error("QChatMedia::disconnect error",i.t0);case 9:if(!this.authService){i.next=12;break}return i.next=12,this.authService.logout();case 12:this._setStateInit(),this.core.emit("qchatMediaDisconnect"),this.core.qchatMedia.emit("qchatMediaDisconnect");case 15:case"end":return i.stop()}}),_callee5,this,[[1,6]])})))},i._setStateInit=function _setStateInit(){this.logger.debug("QChatMedia::disconnect end"),this.roomContext=void 0,this.rtcController=void 0,this.state="init",this.tokenTimer&&(this.core.timerManager.deleteTimer(this.tokenTimer),this.tokenTimer=void 0),this.channelId="",this.serverId=""},i.muteAudio=function muteAudio(t){var i,u,m,h,v;return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var M;return ud.wrap((function _callee6$(I){for(;;)switch(I.prev=I.next){case 0:if(this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),(null===(i=this.roomContext)||void 0===i?void 0:i.localMember.uuid)!==t.accid){I.next=14;break}return I.prev=3,I.next=6,null===(u=this.rtcController)||void 0===u?void 0:u.muteMyAudio();case 6:I.next=12;break;case 8:throw I.prev=8,I.t0=I.catch(3),this.logger.error("QChatMedia::muteAudio error",I.t0),new ed("QChatMedia::muteAudio error",I.t0);case 12:case 25:I.next=31;break;case 14:if(I.prev=14,!(M=null===(m=this.roomContext)||void 0===m?void 0:m.roomProperties.audioOff)||"offNotAllowSelfOn"!==(null===(h=M.value)||void 0===h?void 0:h.split("_")[0])){I.next=23;break}return I.next=19,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneMicrophone"});case 19:if(I.sent){I.next=23;break}return this.logger.error("QChatMedia::unMuteAudio not allow open auido"),I.abrupt("return");case 23:return I.next=25,null===(v=this.rtcController)||void 0===v?void 0:v.muteMemberAudio(t.accid);case 27:throw I.prev=27,I.t1=I.catch(14),this.logger.error("QChatMedia::muteAudio error params is "+Un(t),I.t1),new ed("QChatMedia::muteAudio error",I.t1);case 31:case"end":return I.stop()}}),_callee6,this,[[3,8],[14,27]])})))},i.unMuteAudio=function unMuteAudio(t){var i,u,m,h,v;return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var M;return ud.wrap((function _callee7$(I){for(;;)switch(I.prev=I.next){case 0:if(this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),!(M=null===(i=this.roomContext)||void 0===i?void 0:i.roomProperties.audioOff)||"offNotAllowSelfOn"!==(null===(u=M.value)||void 0===u?void 0:u.split("_")[0])){I.next=10;break}return I.next=6,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneMicrophone"});case 6:if(I.sent){I.next=10;break}return this.logger.error("QChatMedia::unMuteAudio not allow open auido"),I.abrupt("return");case 10:if((null===(m=this.roomContext)||void 0===m?void 0:m.localMember.uuid)!==t.accid){I.next=22;break}return I.prev=11,I.next=14,null===(h=this.rtcController)||void 0===h?void 0:h.unmuteMyAudio();case 14:I.next=20;break;case 16:throw I.prev=16,I.t0=I.catch(11),this.logger.error("QChatMedia::unMuteAudio error",I.t0),new ed("QChatMedia::unMuteAudio error",I.t0);case 20:case 25:I.next=31;break;case 22:return I.prev=22,I.next=25,null===(v=this.rtcController)||void 0===v?void 0:v.unmuteMemberAudio(t.accid);case 27:throw I.prev=27,I.t1=I.catch(22),this.logger.error("QChatMedia::unMuteAudio error params is "+Un(t),I.t1),new ed("QChatMedia::unMuteAudio error",I.t1);case 31:case"end":return I.stop()}}),_callee7,this,[[11,16],[22,27]])})))},i.muteVideo=function muteVideo(t){var i,u,m,h,v;return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var M;return ud.wrap((function _callee8$(I){for(;;)switch(I.prev=I.next){case 0:if(this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),(null===(i=this.roomContext)||void 0===i?void 0:i.localMember.uuid)!==t.accid){I.next=14;break}return I.prev=3,I.next=6,null===(u=this.rtcController)||void 0===u?void 0:u.muteMyVideo();case 6:I.next=12;break;case 8:throw I.prev=8,I.t0=I.catch(3),this.logger.error("QChatMedia::muteVideo error",I.t0),new ed("QChatMedia::muteVideo error",I.t0);case 12:case 25:I.next=31;break;case 14:if(I.prev=14,!(M=null===(m=this.roomContext)||void 0===m?void 0:m.roomProperties.videoOff)||"offNotAllowSelfOn"!==(null===(h=M.value)||void 0===h?void 0:h.split("_")[0])){I.next=23;break}return I.next=19,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneCamera"});case 19:if(I.sent){I.next=23;break}return this.logger.error("QChatMedia::unMuteVideo not allow open video"),I.abrupt("return");case 23:return I.next=25,null===(v=this.rtcController)||void 0===v?void 0:v.muteMemberVideo(t.accid);case 27:throw I.prev=27,I.t1=I.catch(14),this.logger.error("QChatMedia::muteVideo error params is "+Un(t),I.t1),new ed("QChatMedia::muteVideo error",I.t1);case 31:case"end":return I.stop()}}),_callee8,this,[[3,8],[14,27]])})))},i.unMuteVideo=function unMuteVideo(t){var i,u,m,h,v;return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var M;return ud.wrap((function _callee9$(I){for(;;)switch(I.prev=I.next){case 0:if(this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),!(M=null===(i=this.roomContext)||void 0===i?void 0:i.roomProperties.videoOff)||"offNotAllowSelfOn"!==(null===(u=M.value)||void 0===u?void 0:u.split("_")[0])){I.next=10;break}return I.next=6,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneCamera"});case 6:if(I.sent){I.next=10;break}return this.logger.error("QChatMedia::unMuteVideo not allow open video"),I.abrupt("return");case 10:if((null===(m=this.roomContext)||void 0===m?void 0:m.localMember.uuid)!==t.accid){I.next=22;break}return I.prev=11,I.next=14,null===(h=this.rtcController)||void 0===h?void 0:h.unmuteMyVideo();case 14:I.next=20;break;case 16:throw I.prev=16,I.t0=I.catch(11),this.logger.error("QChatMedia::unMuteVideo error",I.t0),new ed("QChatMedia::unMuteVideo error",I.t0);case 20:I.next=30;break;case 22:I.prev=22,null===(v=this.rtcController)||void 0===v||v.unmuteMemberVideo(t.accid),I.next=30;break;case 26:throw I.prev=26,I.t1=I.catch(22),this.logger.error("QChatMedia::unMuteVideo error",I.t1),new ed("QChatMedia::unMuteVideo error",I.t1);case 30:case"end":return I.stop()}}),_callee9,this,[[11,16],[22,26]])})))},i.startScreenShare=function startScreenShare(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){return ud.wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:this._checkConnectState(),i.prev=1,null===(t=this.rtcController)||void 0===t||t.startScreenShare(),i.next=9;break;case 5:throw i.prev=5,i.t0=i.catch(1),this.logger.error("QChatMedia::startScreenShare error",i.t0),new ed("QChatMedia::startScreenShare error",i.t0);case 9:case"end":return i.stop()}}),_callee10,this,[[1,5]])})))},i.stopScreenShare=function stopScreenShare(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:this._checkConnectState(),i.prev=1,null===(t=this.rtcController)||void 0===t||t.stopScreenShare(),i.next=9;break;case 5:throw i.prev=5,i.t0=i.catch(1),this.logger.error("QChatMedia::stopScreenShare error",i.t0),new ed("QChatMedia::stopScreenShare error",i.t0);case 9:case"end":return i.stop()}}),_callee11,this,[[1,5]])})))},i.stopMemberScreenShare=function stopMemberScreenShare(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(u){for(;;)switch(u.prev=u.next){case 0:this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),u.prev=2,null===(i=this.rtcController)||void 0===i||i.stopMemberScreenShare(t.accid),u.next=10;break;case 6:throw u.prev=6,u.t0=u.catch(2),this.logger.error("QChatMedia::stopMemberScreenShare error",u.t0),new ed("QChatMedia::stopMemberScreenShare error",u.t0);case 10:case"end":return u.stop()}}),_callee12,this,[[2,6]])})))},i.subscribeRemoteVideoStream=function subscribeRemoteVideoStream(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){return ud.wrap((function _callee13$(u){for(;;)switch(u.prev=u.next){case 0:this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1},streamType:{type:"number",allowEmpty:!1,min:0,max:1}},t),u.prev=2,null===(i=this.rtcController)||void 0===i||i.subscribeRemoteVideoStream(t.accid,t.streamType),u.next=10;break;case 6:throw u.prev=6,u.t0=u.catch(2),this.logger.error("QChatMedia::subscribeRemoteVideoStream error",u.t0),new ed("QChatMedia::subscribeRemoteVideoStream error",u.t0);case 10:case"end":return u.stop()}}),_callee13,this,[[2,6]])})))},i.unSubscribeRemoteVideoStream=function unSubscribeRemoteVideoStream(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){return ud.wrap((function _callee14$(u){for(;;)switch(u.prev=u.next){case 0:this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1},streamType:{type:"number",allowEmpty:!1,min:0,max:1}},t),u.prev=2,null===(i=this.rtcController)||void 0===i||i.unsubscribeRemoteVideoStream(t.accid,t.streamType),u.next=10;break;case 6:throw u.prev=6,u.t0=u.catch(2),this.logger.error("QChatMedia::unSubscribeRemoteVideoStream error",u.t0),new ed("QChatMedia::unSubscribeRemoteVideoStream error",u.t0);case 10:case"end":return u.stop()}}),_callee14,this,[[2,6]])})))},i.setupVideoCanvas=function setupVideoCanvas(t){var i;if(this._checkConnectState(),(null===(i=this.roomContext)||void 0===i?void 0:i.localMember.uuid)===t.accid)try{return this.rtcController.setupLocalVideoCanvas(t.videoView)}catch(t){throw this.logger.error("QChatMedia::setupVideoCanvas error",t),new ed("QChatMedia::setupVideoCanvas error",t)}else try{return this.rtcController.setupRemoteVideoCanvas(t.videoView,t.accid)}catch(t){throw this.logger.error("QChatMedia::setupVideoCanvas error",t),new ed("QChatMedia::setupVideoCanvas error",t)}},i.setupRemoteVideoSubStreamCanvas=function setupRemoteVideoSubStreamCanvas(t){this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t);try{return this.rtcController.setupRemoteVideoSubStreamCanvas(t.videoView,t.accid)}catch(t){throw this.logger.error("QChatMedia::setupRemoteVideoSubStreamCanvas error",t),new ed("QChatMedia::setupRemoteVideoSubStreamCanvas error",t)}},i.getScreenSharingUserUuid=function getScreenSharingUserUuid(){this._checkConnectState();try{return this.rtcController.getScreenSharingUserUuid()}catch(t){throw this.logger.error("QChatMedia::getScreenSharingUserUuid error",t),new ed("QChatMedia::getScreenSharingUserUuid error",t)}},i.initQChatMedia=function initQChatMedia(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){return ud.wrap((function _callee15$(i){for(;;)switch(i.prev=i.next){case 0:if(this.neroom){i.next=3;break}return this.logger.warn("QChatMedia::init::you should import neroom SDK"),i.abrupt("return");case 3:if(void 0===this.state){i.next=6;break}return this.logger.error("QChatMedia::init::you already init QChatMedia"),i.abrupt("return");case 6:i.prev=6,this.neroom.initialize({appKey:this.core.options.appkey,serverConfig:t.serverConfig}),i.next=14;break;case 10:throw i.prev=10,i.t0=i.catch(6),this.logger.error("QChatMedia::initQChatMedia error",i.t0),new ed("QChatMedia::initQChatMedia error",i.t0);case 14:this.authService=this.neroom.authService,this.roomService=this.neroom.roomService,this.messageChannelService=this.neroom.messageChannelService,this.state="init";case 18:case"end":return i.stop()}}),_callee15,this,[[6,10]])})))},i.loginByIM=function loginByIM(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i,u;return ud.wrap((function _callee16$(m){for(;;)switch(m.prev=m.next){case 0:if("init"===this.state){m.next=3;break}return this.logger.error("QChatMedia::connect::you should init before login"),m.abrupt("return");case 3:return m.next=5,this._getToken();case 5:return i=m.sent,u=get(this.core,"options.token")||get(this.core,"V2NIMLoginService.token"),m.prev=7,m.next=10,null===(t=this.authService)||void 0===t?void 0:t.loginByIM(this.core.account,i,u);case 10:m.next=16;break;case 12:throw m.prev=12,m.t0=m.catch(7),this.logger.error("QChatMedia::loginByIM error",m.t0),new ed("QChatMedia::loginByIM error",m.t0);case 16:this.state="login";case 17:case"end":return m.stop()}}),_callee16,this,[[7,12]])})))},i._getToken=function _getToken(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){var i,u,m,h,v=this;return ud.wrap((function _callee18$(M){for(;;)switch(M.prev=M.next){case 0:return this.logger.log("QChatMedia::getToken begin getToken"),M.next=3,this.core.sendCmd("qchatGetNeroomToken",{qchatGetNeroomTokenTag:{neroomDeviceId:null===(t=this.neroom)||void 0===t?void 0:t.deviceId}});case 3:return i=M.sent,u=i.content.neroomToken,m=u.token,h=u.expire,this.logger.log("QChatMedia::getToken success token is "+m+",expire is "+h+" "),this.tokenTimer||(this.logger.debug("QChatMedia::getToken set token timer,expire is "+(1e3*h-this.tokenExpireTime)+" "),this.tokenTimer=this.core.timerManager.addTimer((function(){return __awaiter(v,void 0,void 0,ud.mark((function _callee17(){var t;return ud.wrap((function _callee17$(i){for(;;)switch(i.prev=i.next){case 0:return this.tokenTimer&&this.core.timerManager.deleteTimer(this.tokenTimer),this.tokenTimer=void 0,i.next=4,this._getToken();case 4:t=i.sent,this.authService&&this.authService.renewToken(t);case 6:case"end":return i.stop()}}),_callee17,this)})))}),1e3*h-this.tokenExpireTime)),M.abrupt("return",m);case 8:case"end":return M.stop()}}),_callee18,this)})))},i.connectChannel=function connectChannel(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){var m;return ud.wrap((function _callee19$(h){for(;;)switch(h.prev=h.next){case 0:if(void 0!==this.state){h.next=3;break}return this.logger.error("QChatMedia::connect::you should init before login"),h.abrupt("return");case 3:if("init"!==this.state){h.next=6;break}return h.next=6,this.loginByIM();case 6:return this.serverId=t.serverId,this.channelId=t.channelId,h.prev=8,h.next=11,null===(i=this.roomService)||void 0===i?void 0:i.joinRoom({roomUuid:t.channelId,role:"qchatAudience",userName:this.core.account,initialProperties:{}},{});case 11:h.next=17;break;case 13:throw h.prev=13,h.t0=h.catch(8),this.logger.error("QChatMedia::connectChannel error",h.t0),new ed("QChatMedia::connectChannel error",h.t0);case 17:if(!(m=null===(u=this.roomService)||void 0===u?void 0:u.getRoomContext(t.channelId))){h.next=28;break}return this.roomContext=m,this.rtcController=this.roomContext.rtcController,this.state="connect",h.next=24,this.rtcController.joinRtcChannel();case 24:this.core.emit("connectChannel"),this.core.qchatMedia.emit("connectChannel"),h.next=29;break;case 28:this.logger.error("QChatMedia::connect room not exited");case 29:case"end":return h.stop()}}),_callee19,this,[[8,13]])})))},i.updateRTCChannelInfo=function updateRTCChannelInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){return ud.wrap((function _callee20$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},limit:{type:"number",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatUpdateRTCChannelConfig",{RTCChannelConfig:Dt(Dt({},t),{audio:Un(t.audio),video:Un(t.video)})});case 3:case"end":return i.stop()}}),_callee20,this)})))},i.getRTCChannelInfo=function getRTCChannelInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){var i;return ud.wrap((function _callee21$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1}},t),u.next=3,this.core.sendCmd("qchatGetRTCChannelConfig",{qchatGetRTCChannelConfigTag:t});case 3:return i=u.sent,u.abrupt("return",formatRTCChannelConfig(i.content.RTCChannelConfig));case 5:case"end":return u.stop()}}),_callee21,this)})))},i.getRTCChannelOnlineMembers=function getRTCChannelOnlineMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee22(){var i;return ud.wrap((function _callee22$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1}},t),u.next=3,this.core.sendCmd("qchatGetRTCChannelMembers",{qchatGetRTCChannelMembersTag:t});case 3:return i=u.sent,u.abrupt("return",formatMembers(i.content.memberList));case 5:case"end":return u.stop()}}),_callee22,this)})))},i.addRTCChannelListener=function addRTCChannelListener(){var t,i,u=this;this._checkConnectState();try{null===(t=this.authService)||void 0===t||t.addAuthListener({onAuthEvent:function onAuthEvent(t){return __awaiter(u,void 0,void 0,ud.mark((function _callee23(){var i;return ud.wrap((function _callee23$(u){for(;;)switch(u.prev=u.next){case 0:if(1026!==t||this.getTokenState){u.next=10;break}return this.logger.log("QChatMedia::loginByIM token expire,begin get new token "),this.getTokenState=!0,u.next=5,this._getToken();case 5:if(i=u.sent,!this.authService){u.next=9;break}return u.next=9,this.authService.renewToken(i);case 9:this.getTokenState=!1;case 10:case"end":return u.stop()}}),_callee23,this)})))}})}catch(t){throw this.getTokenState=!1,this.logger.error("QChatMedia::loginByIM addAuthListener error",t),new ed("QChatMedia::loginByIM addAuthListener error",t)}null===(i=this.roomContext)||void 0===i||i.addRoomListener({onRoomPropertiesChanged:function onRoomPropertiesChanged(t){var i,m,h,v,M,I;if(u.logger.log("QChatMedia::addRTCChannelListener::onRoomPropertiesChanged",t),t.audioOff){var S=null===(i=t.audioOff.value)||void 0===i?void 0:i.split("_")[0];"offNotAllowSelfOn"!==S&&"offAllowSelfOn"!==S||(null===(m=u.roomContext)||void 0===m?void 0:m.localMember.isAudioOn)&&(null===(h=u.rtcController)||void 0===h||h.muteMyAudio())}else if(t.videoOff){var T=null===(v=t.videoOff.value)||void 0===v?void 0:v.split("_")[0];"offNotAllowSelfOn"!==T&&"offAllowSelfOn"!==T||(null===(M=u.roomContext)||void 0===M?void 0:M.localMember.isVideoOn)&&(null===(I=u.rtcController)||void 0===I||I.muteMyVideo())}},onRoomPropertiesDeleted:function onRoomPropertiesDeleted(t){u.logger.log("QChatMedia::addRTCChannelListener::onRoomPropertiesDeleted",t)},onMemberJoinRtcChannel:function onMemberJoinRtcChannel(t){u.logger.log("QChatMedia::addRTCChannelListener::onMemberJoinRTCChannel",t);var i=map$6(t).call(t,(function(t){return t.uuid}));u.core.emit("memberJoinRTCChannel",i),u.core.qchatMedia.emit("memberJoinRTCChannel",i)},onMemberLeaveRoom:function onMemberLeaveRoom(t){u.logger.log("QChatMedia::addRTCChannelListener::onMemberLeaveRoom",t);var i=map$6(t).call(t,(function(t){return t.uuid}));u.core.emit("memberLeaveRTCChannel",i),u.core.qchatMedia.emit("memberLeaveRTCChannel",i)},onRoomEnded:function onRoomEnded(t){u.authService&&u.authService.logout(),u._setStateInit(),u.logger.log("QChatMedia::addRTCChannelListener::onRoomEnded",t),u.core.emit("RTCChannelEnded",t),u.core.qchatMedia.emit("RTCChannelEnded",t)},onRtcChannelError:function onRtcChannelError(t){u.logger.log("QChatMedia::addRTCChannelListener::onRtcChannelError",t),"SOCKET_ERROR"===t&&u.disconnectChannel(),u.core.emit("RTCChannelError",t),u.core.qchatMedia.emit("RTCChannelError",t)},onRtcAudioVolumeIndication:function onRtcAudioVolumeIndication(t){u.logger.log("QChatMedia::addRTCChannelListener::onRtcAudioVolumeIndication",t),u.core.emit("onRtcAudioVolumeIndication",t),u.core.qchatMedia.emit("onRtcAudioVolumeIndication",t)},onMemberAudioMuteChanged:function onMemberAudioMuteChanged(t,i,m){u.logger.log("QChatMedia::addRTCChannelListener::onMemberAudioMuteChanged",t,i),u.core.emit("memberAudioMuteChanged",{memberAccId:t.uuid,mute:i,operateByAccId:m.uuid}),u.core.qchatMedia.emit("memberAudioMuteChanged",{memberAccId:t.uuid,mute:i,operateByAccId:m.uuid})},onMemberScreenShareStateChanged:function onMemberScreenShareStateChanged(t,i,m){u.logger.log("QChatMedia::addRTCChannelListener::onMemberScreenShareStateChanged",t,i),u.core.emit("memberScreenShareStateChanged",{memberAccId:t.uuid,isSharing:i,operateByAccId:m.uuid}),u.core.qchatMedia.emit("memberScreenShareStateChanged",{memberAccId:t.uuid,isSharing:i,operateByAccId:m.uuid})},onMemberVideoMuteChanged:function onMemberVideoMuteChanged(t,i,m){u.logger.log("QChatMedia::addRTCChannelListener::onMemberVideoMuteChanged",t,i),u.core.emit("memberVideoMuteChanged",{memberAccId:t.uuid,mute:i,operateByAccId:m.uuid}),u.core.qchatMedia.emit("memberVideoMuteChanged",{memberAccId:t.uuid,mute:i,operateByAccId:m.uuid})}})},i.enumCameraDevices=function enumCameraDevices(){var t=this;return this._checkConnectState(),this.rtcController.enumCameraDevices().then((function(t){return t.data}),(function(i){throw t.logger.error("QChatMedia::enumCameraDevices error",i),new ed("QChatMedia::enumCameraDevices error",i)}))},i.enumPlayoutDevices=function enumPlayoutDevices(){var t=this;return this._checkConnectState(),this.rtcController.enumPlayoutDevices().then((function(t){return t.data}),(function(i){throw t.logger.error("QChatMedia::enumPlayoutDevices error",i),new ed("QChatMedia::enumPlayoutDevices error",i)}))},i.enumRecordDevices=function enumRecordDevices(){var t=this;return this._checkConnectState(),this.rtcController.enumRecordDevices().then((function(t){return t.data}),(function(i){throw t.logger.error("QChatMedia::enumRecordDevices error",i),new ed("QChatMedia::enumRecordDevices error",i)}))},i.removeRTCChannelListener=function removeRTCChannelListener(){var t,i;this._checkConnectState(),null===(t=this.roomContext)||void 0===t||t.removeRoomListener({}),null===(i=this.authService)||void 0===i||i.removeAuthListener({})},i.setSelectedCameraDevice=function setSelectedCameraDevice(t){var i=this;return this._checkConnectState(),validate({deviceId:{type:"string",allowEmpty:!1}},t),this.rtcController.setSelectedCameraDevice(t.deviceId).then((function(t){return t.data}),(function(t){throw i.logger.error("QChatMedia::setSelectedCameraDevice error",t),new ed("QChatMedia::setSelectedCameraDevice error",t)}))},i.setSelectedPlayoutDevice=function setSelectedPlayoutDevice(t){var i=this;return this._checkConnectState(),validate({deviceId:{type:"string",allowEmpty:!1}},t),this.rtcController.setSelectedPlayoutDevice(t.deviceId).then((function(t){return t.data}),(function(t){throw i.logger.error("QChatMedia::setSelectedPlayoutDevice error",t),new ed("QChatMedia::setSelectedPlayoutDevice error",t)}))},i.setSelectedRecordDevice=function setSelectedRecordDevice(t){var i=this;return this._checkConnectState(),validate({deviceId:{type:"string",allowEmpty:!1}},t),this.rtcController.setSelectedRecordDevice(t.deviceId).then((function(t){return t.data}),(function(t){throw i.logger.error("QChatMedia::setSelectedRecordDevice error",t),new ed("QChatMedia::setSelectedRecordDevice error",t)}))},i.getRTCMembers=function getRTCMembers(){var t,i;return this._checkConnectState(),map$6(t=filter(i=this.roomContext.remoteMembers).call(i,(function(t){return t.isInRtcChannel}))).call(t,(function(t){return{accid:t.uuid,isAudioOn:!!t.isAudioOn,isVideoOn:!!t.isVideoOn,isSharingScreen:!!t.isSharingScreen,properties:t.properties}}))},i.subscribeRemoteVideoSubStream=function subscribeRemoteVideoSubStream(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee24(){return ud.wrap((function _callee24$(u){for(;;)switch(u.prev=u.next){case 0:this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),u.prev=2,null===(i=this.rtcController)||void 0===i||i.subscribeRemoteVideoSubStream(t.accid),u.next=10;break;case 6:throw u.prev=6,u.t0=u.catch(2),this.logger.error("QChatMedia::subscribeRemoteVideoSubStream error",u.t0),new ed("QChatMedia::subscribeRemoteVideoSubStream error",u.t0);case 10:case"end":return u.stop()}}),_callee24,this,[[2,6]])})))},i.unsubscribeRemoteVideoSubStream=function unsubscribeRemoteVideoSubStream(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee25(){return ud.wrap((function _callee25$(u){for(;;)switch(u.prev=u.next){case 0:this._checkConnectState(),validate({accid:{type:"string",allowEmpty:!1}},t),u.prev=2,null===(i=this.rtcController)||void 0===i||i.unsubscribeRemoteVideoSubStream(t.accid),u.next=10;break;case 6:throw u.prev=6,u.t0=u.catch(2),this.logger.error("QChatMedia::unsubscribeRemoteVideoSubStream error",u.t0),new ed("QChatMedia::unsubscribeRemoteVideoSubStream error",u.t0);case 10:case"end":return u.stop()}}),_callee25,this,[[2,6]])})))},i.muteAllAudio=function muteAllAudio(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee26(){return ud.wrap((function _callee26$(i){for(;;)switch(i.prev=i.next){case 0:return this._checkConnectState(),i.next=3,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneMicrophone"});case 3:if(i.sent){i.next=7;break}return this.logger.error("QChatMedia::connect::auth your have not RTCChannelOpenCloseEveryoneMicrophone auth"),i.abrupt("return");case 7:i.prev=7,null===(t=this.roomContext)||void 0===t||t.updateRoomProperty("audioOff",Un({value:"offNotAllowSelfOn_"+(new Date).getTime()})),i.next=15;break;case 11:throw i.prev=11,i.t0=i.catch(7),this.logger.error("QChatMedia::muteAllAudio error",i.t0),new ed("QChatMedia::muteAllAudio error",i.t0);case 15:case"end":return i.stop()}}),_callee26,this,[[7,11]])})))},i.muteAllVideo=function muteAllVideo(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee27(){return ud.wrap((function _callee27$(i){for(;;)switch(i.prev=i.next){case 0:return this._checkConnectState(),i.next=3,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneCamera"});case 3:if(i.sent){i.next=7;break}return this.logger.error("QChatMedia::connect::auth your have not RTCChannelOpenCloseEveryoneCamera auth"),i.abrupt("return");case 7:i.prev=7,null===(t=this.roomContext)||void 0===t||t.updateRoomProperty("videoOff",Un({value:"offNotAllowSelfOn_"+(new Date).getTime()})),i.next=15;break;case 11:throw i.prev=11,i.t0=i.catch(7),this.logger.error("QChatMedia::muteAllVideo error",i.t0),new ed("QChatMedia::muteAllVideo error",i.t0);case 15:case"end":return i.stop()}}),_callee27,this,[[7,11]])})))},i.unMuteAllAudio=function unMuteAllAudio(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee28(){return ud.wrap((function _callee28$(i){for(;;)switch(i.prev=i.next){case 0:return this._checkConnectState(),i.next=3,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneMicrophone"});case 3:if(i.sent){i.next=7;break}return this.logger.error("QChatMedia::connect::auth your have not RTCChannelOpenCloseEveryoneMicrophone auth"),i.abrupt("return");case 7:i.prev=7,null===(t=this.roomContext)||void 0===t||t.updateRoomProperty("audioOff",Un({value:"disable_"+(new Date).getTime()})),i.next=15;break;case 11:throw i.prev=11,i.t0=i.catch(7),this.logger.error("QChatMedia::unMuteAllAudio error",i.t0),new ed("QChatMedia::unMuteAllAudio error",i.t0);case 15:case"end":return i.stop()}}),_callee28,this,[[7,11]])})))},i.unMuteAllVideo=function unMuteAllVideo(){var t;return __awaiter(this,void 0,void 0,ud.mark((function _callee29(){return ud.wrap((function _callee29$(i){for(;;)switch(i.prev=i.next){case 0:return this._checkConnectState(),i.next=3,this._checkPermission({serverId:this.serverId,channelId:this.channelId,auth:"RTCChannelOpenCloseEveryoneCamera"});case 3:if(i.sent){i.next=7;break}return this.logger.error("QChatMedia::connect::auth your have not RTCChannelOpenCloseEveryoneCamera auth"),i.abrupt("return");case 7:i.prev=7,null===(t=this.roomContext)||void 0===t||t.updateRoomProperty("videoOff",Un({value:"disable_"+(new Date).getTime()})),i.next=15;break;case 11:throw i.prev=11,i.t0=i.catch(7),this.logger.error("QChatMedia::unMuteAllVideo error",i.t0),new ed("QChatMedia::unMuteAllVideo error",i.t0);case 15:case"end":return i.stop()}}),_callee29,this,[[7,11]])})))},QChatMediaService}(t_),j_={"24_10":"qchatSendMsg","24_11":"qchatOnMsg","24_12":"qchatOnRecvUnreadInfo","24_13":"qchatSendCustomSysMsg","24_14":"qchatOnSysMsg","24_16":"qchatGetHistoryMsg","24_17":"qchatMarkMessageRead","24_18":"qchatMultiSyncMessageRead","24_22":"qchatUpdateSystemNotification","24_23":"qchatMultiSyncSystemNotificationUpdate","24_24":"qchatSyncSystemNotification","24_25":"qchatUpdateMessage","24_26":"qchatRecvMessageUpdate","24_28":"qchatMarkSysMsgRead","24_94":"qchatMessageSearchByPage","24_100":"qchatGetMessageHistoryByIds","24_101":"qchatGetThreadMessages","24_102":"qchatUpdateQuickComment","24_103":"qchatGetQuickComments","24_108":"qchatGetThreadRootMessagesMeta","24_121":"qchatGetLastMessageOfChannels","24_127":"qchatGetMentionedMeMessages","25_6":"qchatMultiSyncServersMessageRead"},$_={getHistoryMsgTag:{serverId:1,channelId:2,beginTime:3,endTime:4,excludeMsgId:5,limit:6,reverse:7},getThreadHistoryMsgTag:{beginTime:1,endTime:2,excludeMsgId:3,limit:4,reverse:5},qchatMsgTag:{serverId:1,channelId:2,fromAccount:3,fromClientType:4,fromDeviceId:5,fromNick:6,time:7,updateTime:8,type:9,body:10,attach:11,ext:12,msgIdClient:13,msgIdServer:14,resendFlag:15,status:16,pushPayload:17,pushContent:18,mentionAccids:19,mentionAll:20,env:21,callbackExt:22,replyMsgFromAccount:23,replyMsgTime:24,replyMsgIdServer:25,replyMsgIdClient:26,threadMsgFromAccount:27,threadMsgTime:28,threadMsgIdServer:29,threadMsgIdClient:30,useCustomContent:31,antiSpamContent:32,antiSpamBusinessId:33,antiSpamUsingYidun:34,yidunCallback:35,yidunAntiCheating:36,yidunAntiSpamExt:37,yidunAntiSpamRes:38,mentionRoleIds:41,accidsOfMentionedRoles:42,updateContent:39,updateOperatorInfo:40,subType:61,historyEnable:100,pushEnable:101,needBadge:102,needPushNick:103,notifyReason:104,routeEnable:105,isAntispam:106},sysMsg:{toType:1,serverId:2,channelId:3,toAccids:4,fromAccount:5,fromClientType:6,fromDeviceId:7,fromNick:8,time:9,updateTime:10,type:11,msgIdClient:12,msgIdServer:13,body:14,attach:15,ext:16,resendFlag:17,status:18,pushPayload:19,pushContent:20,env:21,callbackExt:22,persistEnable:100,pushEnable:101,needBadge:102,needPushNick:103,routeEnable:104},qchatMsgUpdateTag:{operatorAccount:1,operatorClientType:2,ps:3,ext:4,pushContent:5,pushPayload:6,env:7,routeEnable:100},markMsgReadTag:{serverId:1,channelId:2,time:3},qchatQuickCommentRequestTag:{serverId:1,channelId:2,fromAccount:3,msgIdServer:4,time:5,type:6,opeType:7,opeAccid:8},qchatQuickCommentQueryTag:{serverId:1,channelId:2,msgIdServerList:3},qchatGetLastMessageOfChannelsTag:{serverId:1,channelIdList:2},qchatMultiSyncServersMessageReadTag:{successServerIds:1,failServerIds:2,ackTimestamp:3},qchatMessageSearchByPageTag:{keyword:1,serverId:2,channelId:3,fromAccid:4,fromTime:5,toTime:6,msgTypes:7,subTypes:8,includeSelf:9,order:10,limit:11,sort:12,cursor:13},qchatPageQueryTag:{hasMore:1,nextTimetag:2,cursor:3},unreadInfo:n_},z_=function getDeserializeTag(){return invertSerializeMap($_)},W_=function getCmdConfig(){var t=z_();return{qchatSendMsg:{service:"qchatMsg",sid:24,cid:10,params:[{type:"Property",name:"qchatMsg",reflectMapper:$_.qchatMsgTag}],response:[{type:"Property",name:"qchatMsg",reflectMapper:t.qchatMsgTag}]},qchatOnMsg:{service:"qchatMsg",sid:24,cid:11,response:[{type:"Property",name:"qchatMsg",reflectMapper:t.qchatMsgTag}]},qchatOnRecvUnreadInfo:{service:"qchatMsg",sid:24,cid:12,response:[{type:"Property",name:"qchatMsg",reflectMapper:t.qchatMsgTag}]},qchatSendCustomSysMsg:{service:"qchatMsg",sid:24,cid:13,params:[{type:"Property",name:"sysMsg",reflectMapper:$_.sysMsg}],response:[{type:"Property",name:"sysMsg",reflectMapper:t.sysMsg}]},qchatOnSysMsg:{service:"qchatMsg",sid:24,cid:14,response:[{type:"Property",name:"sysMsg",reflectMapper:t.sysMsg}]},qchatGetHistoryMsg:{service:"qchatMsg",sid:24,cid:16,params:[{type:"Property",name:"getHistoryMsgTag",reflectMapper:$_.getHistoryMsgTag}],response:[{type:"PropertyArray",name:"qchatMsgs",reflectMapper:t.qchatMsgTag}]},qchatUpdateMessage:{service:"qchatMsg",sid:24,cid:25,params:[{type:"Property",name:"qchatMsgUpdateTag",reflectMapper:$_.qchatMsgUpdateTag},{type:"Property",name:"qchatMsg",reflectMapper:$_.qchatMsgTag}],response:[{type:"Property",name:"qchatMsg",reflectMapper:t.qchatMsgTag}]},qchatRecvMessageUpdate:{service:"qchatMsg",sid:24,cid:26,response:[{type:"Property",name:"qchatMsgUpdateInfo",reflectMapper:t.qchatMsgUpdateTag},{type:"Property",name:"qchatMsg",reflectMapper:t.qchatMsgTag}]},qchatMarkMessageRead:{sid:24,cid:17,service:"qchatMsg",params:[{type:"Property",name:"markMsgReadTag",reflectMapper:$_.markMsgReadTag}],response:[{type:"Property",name:"unreadInfo",reflectMapper:t.unreadInfo}]},qchatMultiSyncMessageRead:{sid:24,cid:18,service:"qchatMsg",response:[{type:"Property",name:"unreadInfo",reflectMapper:t.unreadInfo}]},qchatUpdateSystemNotification:{service:"qchatMsg",sid:24,cid:22,params:[{type:"Property",name:"qchatMsgUpdateTag",reflectMapper:$_.qchatMsgUpdateTag},{type:"Property",name:"sysMsg",reflectMapper:$_.sysMsg}],response:[{type:"Property",name:"sysMsg",reflectMapper:t.sysMsg}]},qchatMultiSyncSystemNotificationUpdate:{service:"qchatMsg",sid:24,cid:23,response:[{type:"Property",name:"qchatMsgUpdateTag",reflectMapper:t.qchatMsgUpdateTag},{type:"Property",name:"sysMsg",reflectMapper:t.sysMsg}]},qchatSyncSystemNotification:{service:"qchatMsg",sid:24,cid:24,response:[{type:"PropertyArray",name:"systemNotifications",reflectMapper:t.sysMsg}]},qchatMarkSysMsgRead:{service:"qchatMsg",sid:24,cid:28,params:[{type:"PropertyArray",name:"sysMsgs",reflectMapper:$_.sysMsg}]},qchatMessageSearchByPage:{service:"qchatMsg",sid:24,cid:94,params:[{type:"Property",name:"qchatMessageSearchByPageTag",reflectMapper:$_.qchatMessageSearchByPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:t.qchatPageQueryTag},{type:"PropertyArray",name:"datas",reflectMapper:t.qchatMsgTag}]},qchatGetMessageHistoryByIds:{service:"qchatMsg",sid:24,cid:100,params:[{type:"Property",name:"channelInfo",reflectMapper:{serverId:1,channelId:2}},{type:"PropertyArray",name:"messageReferList",reflectMapper:{msgIdServer:1,time:2}}],response:[{type:"PropertyArray",name:"qchatMsgs",reflectMapper:t.qchatMsgTag}]},qchatGetThreadMessages:{service:"qchatMsg",sid:24,cid:101,params:[{type:"Property",name:"qchatMsg",reflectMapper:$_.qchatMsgTag},{type:"Property",name:"getThreadHistoryMsgTag",reflectMapper:$_.getThreadHistoryMsgTag}],response:[{type:"Property",name:"thread",reflectMapper:t.qchatMsgTag},{type:"Property",name:"threadInfo",reflectMapper:{1:"messageCount",2:"lastMessageTimestamp"}},{type:"PropertyArray",name:"qchatMsgs",reflectMapper:t.qchatMsgTag}]},qchatUpdateQuickComment:{service:"qchatMsg",sid:24,cid:102,params:[{type:"Property",name:"tag",reflectMapper:$_.qchatQuickCommentRequestTag}]},qchatGetQuickComments:{service:"qchatMsg",sid:24,cid:103,params:[{type:"Property",name:"tag",reflectMapper:$_.qchatQuickCommentQueryTag}],response:[{type:"PropertyArray",name:"quickCommentResponse",reflectMapper:{1:"serverId",2:"channelId",3:"msgIdServer",4:"totalCount",5:"lastUpdateTime",6:"details"}}]},qchatGetThreadRootMessagesMeta:{service:"qchatMsg",sid:24,cid:108,params:[{type:"Property",name:"tag",reflectMapper:{serverId:1,channelId:2}},{type:"PropertyArray",name:"qchatMsgs",reflectMapper:{time:7,msgIdServer:14}}],response:[{type:"PropertyArray",name:"metas",reflectMapper:{1:"total",2:"timestamp",3:"msgIdServer",4:"msgTime"}}]},qchatGetLastMessageOfChannels:{service:"qchatMsg",sid:24,cid:121,params:[{type:"Property",name:"tag",reflectMapper:$_.qchatGetLastMessageOfChannelsTag}],response:[{type:"PropertyArray",name:"msgs",reflectMapper:t.qchatMsgTag}]},qchatMultiSyncServersMessageRead:{service:"qchatMsg",sid:25,cid:6,response:[{type:"Property",name:"qchatMultiSyncServersMessageReadTag",reflectMapper:t.qchatMultiSyncServersMessageReadTag}]},qchatGetMentionedMeMessages:{service:"qchatMsg",sid:24,cid:127,params:[{type:"Property",name:"tag",reflectMapper:{serverId:1,channelId:2,timestamp:3,limit:4}}],response:[{type:"Property",name:"page",reflectMapper:t.qchatPageQueryTag},{type:"PropertyArray",name:"datas",reflectMapper:t.qchatMsgTag}]}}};!function(t){t[t.Android=1]="Android",t[t.iOS=2]="iOS",t[t.PC=4]="PC",t[t.WindowsPhone=8]="WindowsPhone",t[t.Web=16]="Web",t[t.Server=32]="Server",t[t.Mac=64]="Mac",t[t.HarmonyOS=65]="HarmonyOS"}(B_||(B_={}));var K_,Y_={"24_31":"qchatCreateServer","24_32":"qchatDeleteServer","24_33":"qchatUpdateServer","24_34":"qchatGetServers","24_35":"qchatGetServersByPage","24_36":"qchatInviteServerMembers","24_37":"qchatAcceptServerInvite","24_38":"qchatRejectInviteServer","24_39":"qchatApplyServerJoin","24_40":"qchatAcceptServerApply","24_41":"qchatRejectServerApply","24_42":"qchatKickServerMembers","24_43":"qchatLeaveServer","24_44":"qchatUpdateMyMemberInfo","24_45":"qchatUpdateServerMemberInfo","24_46":"qchatGetServerMembers","24_47":"qchatGetServerMembersByPage","24_104":"qchatUpdateServerMemberBan","24_105":"qchatGetBannedMembersByPage","24_91":"qchatServerSearchByPage","24_92":"qchatServerMemberSearchByPage","24_122":"qchatGenerateInviteCode","24_123":"qchatJoinByInviteCode","24_124":"qchatGetInviteApplyRecordOfServer","24_125":"qchatGetInviteApplyRecordOfSelf","25_5":"qchatClearServersUnread","25_7":"qchatSubscribeChannelsByServers","25_10":"qchatEnterAsVisitor","25_11":"qchatLeaveAsVisitor"},Q_={serverInfo:{serverId:1,name:3,icon:4,ext:5,owner:6,memberNumber:7,inviteMode:8,applyMode:9,validFlag:10,createTime:11,updateTime:12,channelNumber:13,categoryNumber:14,searchType:15,searchEnable:16,reorderWeight:17},antispamTag:{antiSpamBusinessId:1},memberInfo:{serverId:1,accid:3,nick:4,avatar:5,ext:6,type:7,joinTime:8,inviter:9,validFlag:10,createTime:11,updateTime:12},otherMemberInfo:{serverId:1,accid:3,nick:4,avatar:5,type:7,joinTime:8,inviter:9,validFlag:10,createTime:11,updateTime:12},getServerListPageTag:{timestamp:1,limit:2},getServerMemberListPageTag:{serverId:1,timetag:2,limit:3},updateServerMemberBanTag:{serverId:1,opeType:2,accid:3,ext:4},getBannedMembersByPageTag:{serverId:1,timetag:2,limit:3},serverMemberBanInfo:{serverId:1,appid:2,accid:3,ext:4,banTime:5,validFlag:6,createTime:7,updateTime:8},serverSearchByPageTag:{keyword:1,startTime:2,endTime:3,order:4,limit:5,serverType:6,searchType:7,sort:8,cursor:9},serverMemberSearchByPageTag:{serverId:1,keyword:3,limit:4},inviteRespParamTag:{requestId:1},applyRespParamTag:{requestId:1,expireTime:2},inviteApplyRecord:{accid:1,type:2,serverId:3,status:4,requestId:5,createTime:6,updateTime:7,expireTime:8,data:9,recordId:10},clearServersUnreadTag:{successServerIds:1,failServerIds:2,ackTimestamp:3},unreadInfo:n_},J_=function getDeserializeTag(){return invertSerializeMap(Q_)},X_=function getCmdConfig(){var t=J_();return{qchatCreateServer:{sid:24,cid:31,service:"qchatServer",params:[{type:"Property",name:"serverInfo",reflectMapper:Q_.serverInfo},{type:"Property",name:"antispamTag",reflectMapper:Q_.antispamTag}],response:[{type:"Property",name:"serverInfo",reflectMapper:t.serverInfo}]},qchatDeleteServer:{sid:24,cid:32,service:"qchatServer",params:[{type:"Long",name:"serverId"}]},qchatUpdateServer:{sid:24,cid:33,service:"qchatServer",params:[{type:"Property",name:"serverInfo",reflectMapper:Q_.serverInfo},{type:"Property",name:"antispamTag",reflectMapper:Q_.antispamTag}],response:[{type:"Property",name:"serverInfo",reflectMapper:t.serverInfo}]},qchatGetServers:{sid:24,cid:34,service:"qchatServer",params:[{type:"LongArray",name:"serverIds"}],response:[{type:"PropertyArray",name:"serverList",reflectMapper:t.serverInfo}]},qchatGetServersByPage:{sid:24,cid:35,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:Q_.getServerListPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.serverInfo}]},qchatInviteServerMembers:{sid:24,cid:36,service:"qchatServer",params:[{type:"Long",name:"serverId"},{type:"StrArray",name:"accids"},{type:"String",name:"ps"},{type:"Property",name:"params",reflectMapper:{ttl:1}}],response:[{type:"StrArray",name:"failByOverAccids"},{type:"StrArray",name:"failByBanAccids"},{type:"Property",name:"record",reflectMapper:t.applyRespParamTag}]},qchatAcceptServerInvite:{sid:24,cid:37,service:"qchatServer",params:[{type:"Long",name:"serverId"},{type:"String",name:"accid"},{type:"Property",name:"recordInfo",reflectMapper:Q_.inviteRespParamTag}]},qchatRejectInviteServer:{sid:24,cid:38,service:"qchatServer",params:[{type:"Long",name:"serverId"},{type:"String",name:"accid"},{type:"String",name:"ps"},{type:"Property",name:"recordInfo",reflectMapper:Q_.inviteRespParamTag}]},qchatApplyServerJoin:{sid:24,cid:39,service:"qchatServer",params:[{type:"Long",name:"serverId"},{type:"String",name:"ps"},{type:"Property",name:"params",reflectMapper:{ttl:1}}],response:[{type:"Property",name:"data",reflectMapper:t.applyRespParamTag}]},qchatAcceptServerApply:{sid:24,cid:40,service:"qchatServer",params:[{type:"Long",name:"serverId"},{type:"String",name:"accid"},{type:"Property",name:"recordInfo",reflectMapper:Q_.applyRespParamTag}]},qchatRejectServerApply:{sid:24,cid:41,service:"qchatServer",params:[{type:"Long",name:"serverId"},{type:"String",name:"accid"},{type:"String",name:"ps"},{type:"Property",name:"recordInfo",reflectMapper:Q_.applyRespParamTag}]},qchatKickServerMembers:{sid:24,cid:42,service:"qchatServer",params:[{type:"Long",name:"serverId"},{type:"StrArray",name:"accids"}]},qchatLeaveServer:{sid:24,cid:43,service:"qchatServer",params:[{type:"Long",name:"serverId"}]},qchatUpdateMyMemberInfo:{sid:24,cid:44,service:"qchatServer",params:[{type:"Property",name:"memberInfo",reflectMapper:Q_.memberInfo},{type:"Property",name:"antispamTag",reflectMapper:Q_.antispamTag}],response:[{type:"Property",name:"memberInfo",reflectMapper:t.memberInfo}]},qchatUpdateServerMemberInfo:{sid:24,cid:45,service:"qchatServer",params:[{type:"Property",name:"memberInfo",reflectMapper:Q_.otherMemberInfo},{type:"Property",name:"antispamTag",reflectMapper:Q_.antispamTag}],response:[{type:"Property",name:"memberInfo",reflectMapper:t.memberInfo}]},qchatGetServerMembers:{sid:24,cid:46,service:"qchatServer",params:[{type:"StrArray",name:"accids"}],response:[{type:"PropertyArray",name:"accidList",reflectMapper:t.memberInfo}]},qchatGetServerMembersByPage:{sid:24,cid:47,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:Q_.getServerMemberListPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.memberInfo}]},qchatUpdateServerMemberBan:{sid:24,cid:104,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:Q_.updateServerMemberBanTag}]},qchatGetBannedMembersByPage:{sid:24,cid:105,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:Q_.getBannedMembersByPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag"}},{type:"PropertyArray",name:"datas",reflectMapper:t.serverMemberBanInfo}]},qchatServerSearchByPage:{sid:24,cid:91,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:Q_.serverSearchByPageTag}],response:[{type:"Property",name:"listQueryTag",reflectMapper:{1:"hasMore",2:"nextTimetag",3:"cursor"}},{type:"PropertyArray",name:"datas",reflectMapper:t.serverInfo}]},qchatServerMemberSearchByPage:{sid:24,cid:92,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:Q_.serverMemberSearchByPageTag}],response:[{type:"PropertyArray",name:"members",reflectMapper:t.memberInfo}]},qchatGenerateInviteCode:{sid:24,cid:122,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:{serverId:1,ttl:2}}],response:[{type:"Property",name:"data",reflectMapper:{1:"serverId",2:"requestId",3:"inviteCode",4:"expireTime"}}]},qchatJoinByInviteCode:{sid:24,cid:123,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:{serverId:1,inviteCode:2,ps:3}}]},qchatGetInviteApplyRecordOfServer:{sid:24,cid:124,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:{serverId:1,fromTime:2,toTime:3,reverse:4,limit:5,cursor:6}}],response:[{type:"PropertyArray",name:"data",reflectMapper:t.inviteApplyRecord}]},qchatGetInviteApplyRecordOfSelf:{sid:24,cid:125,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:{fromTime:1,toTime:2,reverse:3,limit:4,cursor:5}}],response:[{type:"PropertyArray",name:"data",reflectMapper:t.inviteApplyRecord}]},qchatClearServersUnread:{sid:25,cid:5,service:"qchatServer",params:[{type:"LongArray",name:"serverIds"}],response:[{type:"Property",name:"clearServersUnreadTag",reflectMapper:t.clearServersUnreadTag}]},qchatSubscribeChannelsByServers:{sid:25,cid:7,service:"qchatServer",params:[{type:"Int",name:"type"},{type:"LongArray",name:"serverIds"}],response:[{type:"PropertyArray",name:"unreadInfos",reflectMapper:t.unreadInfo},{type:"String",name:"failServerIds"}]},qchatEnterAsVisitor:{sid:25,cid:10,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:{serverIds:1}}],response:[{type:"String",name:"failServerIds"}]},qchatLeaveAsVisitor:{sid:25,cid:11,service:"qchatServer",params:[{type:"Property",name:"tag",reflectMapper:{serverIds:1}}],response:[{type:"String",name:"failServerIds"}]}}},Z_={"24_61":"qchatCreateServerRole","24_62":"qchatDeleteServerRole","24_63":"qchatUpdateServerRole","24_64":"qchatGetServerRoles","24_65":"qchatAddChannelRole","24_66":"qchatRemoveChannelRole","24_67":"qchatUpdateChannelRole","24_68":"qchatGetChannelRoles","24_69":"qchatAddMemberRole","24_70":"qchatRemoveMemberRole","24_71":"qchatUpdateMemberRole","24_72":"qchatGetMemberRoles","24_73":"qchatAddMembersToServerRole","24_74":"qchatRemoveMembersFromServerRole","24_75":"qchatGetMembersFromServerRole","24_76":"qchatGetServerRolesByAccid","24_77":"qchatGetExistingServerRolesByAccids","24_78":"qchatGetExistingChannelRolesByServerRoleIds","24_79":"qchatGetExistingAccidsOfMemberRoles","24_80":"qchatUpdateServerRolePriorities","24_81":"qchatGetExistingAccidsInServerRole","24_82":"qchatCheckPermission","24_83":"qchatAddChannelCategoryRole","24_84":"qchatRemoveChannelCategoryRole","24_85":"qchatUpdateChannelCategoryRole","24_86":"qchatGetChannelCategoryRole","24_87":"qchatAddChannelCategoryMemberRole","24_88":"qchatRemoveChannelCategoryMemberRole","24_89":"qchatUpdateChannelCategoryMemberRole","24_90":"qchatGetChannelCategoryMemberRole","24_126":"qchatCheckPermissions"},eS={channelRole:{serverId:1,roleId:2,parentRoleId:3,channelId:4,name:5,icon:6,ext:7,auths:8,type:9,createTime:10,updateTime:11},memberRole:{serverId:1,id:2,accid:3,channelId:4,auths:5,createTime:6,updateTime:7,nick:8,avatar:9,ext:10,memberType:11,joinTime:12,inviter:13},antispamTag:{antiSpamBusinessId:1},serverRole:{serverId:1,roleId:2,name:3,icon:4,ext:5,auths:6,type:7,memberCount:8,priority:9,createTime:10,updateTime:11,isMember:12},getRoleByPagesTag:{serverId:1,channelId:2,time:3,limit:4},checkPermissionTag:{serverId:1,channelId:2,auth:3},member:{serverId:1,roleId:2,accid:3,createTime:4,updateTime:5,nick:6,avatar:7,ext:8,type:9,joinTime:10,inviter:11},qchatAddChannelCategoryRoleTag:{categoryId:3,serverId:4,parentRoleId:5},channelCategoryRole:{roleId:1,categoryId:3,serverId:4,parentRoleId:5,type:6,validFlag:7,createTime:8,updateTime:9,auths:10,name:11,icon:12,ext:13},qchatGetChannelCategoryRoleTag:{serverId:1,categoryId:2,timetag:3,limit:4},channelCategoryMemberRole:{id:1,accid:3,categoryId:4,serverId:5,validFlag:6,createTime:7,updateTime:8,auths:9,nick:10,avatar:11,ext:12,memberType:13,joinTime:14,inviter:15},qchatGetChannelCategoryMemberRoleTag:{serverId:1,categoryId:2,timetag:3,limit:4},checkPermissionsTag:{serverId:1,channelId:2,auths:3}},tS=function getDeserializeTag(){return invertSerializeMap(eS)},rS=function getCmdConfig(){var t=tS();return{qchatCreateServerRole:{service:"qchatRole",sid:24,cid:61,params:[{type:"Property",name:"serverRole",reflectMapper:eS.serverRole},{type:"Property",name:"antispamTag",reflectMapper:eS.antispamTag}],response:[{type:"Property",name:"serverRole",reflectMapper:t.serverRole}]},qchatDeleteServerRole:{service:"qchatRole",sid:24,cid:62,params:[{type:"Long",name:"serverId"},{type:"Long",name:"roleId"}]},qchatUpdateServerRole:{service:"qchatRole",sid:24,cid:63,params:[{type:"Property",name:"updateServerRoleTag",reflectMapper:{serverId:1,roleId:2,name:3,icon:4,ext:5,auths:6,priority:7}},{type:"Property",name:"antispamTag",reflectMapper:eS.antispamTag}],response:[{type:"Property",name:"serverRole",reflectMapper:t.serverRole}]},qchatGetServerRoles:{service:"qchatRole",sid:24,cid:64,params:[{type:"Property",name:"getServerRolesTag",reflectMapper:{serverId:1,timetag:2,limit:3,priority:4,channelId:5,categoryId:6}}],response:[{type:"PropertyArray",name:"serverRoles",reflectMapper:t.serverRole}]},qchatAddChannelRole:{service:"qchatRole",sid:24,cid:65,params:[{type:"Property",name:"channelRole",reflectMapper:eS.channelRole}],response:[{type:"Property",name:"channelRole",reflectMapper:t.channelRole}]},qchatRemoveChannelRole:{service:"qchatRole",sid:24,cid:66,params:[{type:"Long",name:"serverId"},{type:"Long",name:"channelId"},{type:"Long",name:"roleId"}]},qchatUpdateChannelRole:{service:"qchatRole",sid:24,cid:67,params:[{type:"Property",name:"updateChannelRoleTag",reflectMapper:{serverId:1,roleId:2,channelId:3,auths:4}}],response:[{type:"Property",name:"channelRole",reflectMapper:t.channelRole}]},qchatGetChannelRoles:{service:"qchatRole",sid:24,cid:68,params:[{type:"Property",name:"getChannelRolesTag",reflectMapper:{serverId:1,channelId:2,timetag:3,limit:4}}],response:[{type:"PropertyArray",name:"channelRoles",reflectMapper:t.channelRole}]},qchatAddMemberRole:{service:"qchatRole",sid:24,cid:69,params:[{type:"Property",name:"memberRole",reflectMapper:eS.memberRole}],response:[{type:"Property",name:"memberRole",reflectMapper:t.memberRole}]},qchatRemoveMemberRole:{service:"qchatRole",sid:24,cid:70,params:[{type:"Property",name:"memberRole",reflectMapper:eS.memberRole}]},qchatUpdateMemberRole:{service:"qchatRole",sid:24,cid:71,params:[{type:"Property",name:"updateMemberRoleTag",reflectMapper:{serverId:1,accid:2,channelId:3,auths:4}}],response:[{type:"Property",name:"memberRole",reflectMapper:t.memberRole}]},qchatGetMemberRoles:{service:"qchatRole",sid:24,cid:72,params:[{type:"Property",name:"getMemberRolesTag",reflectMapper:{serverId:1,channelId:2,timetag:3,limit:4}}],response:[{type:"PropertyArray",name:"memberRoles",reflectMapper:t.memberRole}]},qchatAddMembersToServerRole:{service:"qchatRole",sid:24,cid:73,params:[{type:"Long",name:"serverId"},{type:"Long",name:"roleId"},{type:"String",name:"accids"}],response:[{type:"Property",name:"accids",reflectMapper:{1:"successAccids",2:"failedAccids"}}]},qchatRemoveMembersFromServerRole:{service:"qchatRole",sid:24,cid:74,params:[{type:"Long",name:"serverId"},{type:"Long",name:"roleId"},{type:"String",name:"accids"}],response:[{type:"Property",name:"accids",reflectMapper:{1:"successAccids",2:"failedAccids"}}]},qchatGetMembersFromServerRole:{service:"qchatRole",sid:24,cid:75,params:[{type:"Property",name:"getMembersFromServerRoleTag",reflectMapper:{serverId:1,roleId:2,timetag:3,accid:4,limit:5}}],response:[{type:"PropertyArray",name:"members",reflectMapper:t.member}]},qchatGetServerRolesByAccid:{service:"qchatRole",sid:24,cid:76,params:[{type:"Property",name:"getServerRolesByAccidTag",reflectMapper:{serverId:1,accid:2,timetag:3,limit:4}}],response:[{type:"PropertyArray",name:"serverRoles",reflectMapper:t.serverRole}]},qchatGetExistingServerRolesByAccids:{service:"qchatRole",sid:24,cid:77,params:[{type:"Long",name:"serverId"},{type:"String",name:"accids"}],response:[{type:"String",name:"serverRoles"}]},qchatGetExistingChannelRolesByServerRoleIds:{service:"qchatRole",sid:24,cid:78,params:[{type:"Long",name:"serverId"},{type:"Long",name:"channelId"},{type:"String",name:"roleIds"}],response:[{type:"PropertyArray",name:"channelRoles",reflectMapper:t.channelRole}]},qchatGetExistingAccidsOfMemberRoles:{service:"qchatRole",sid:24,cid:79,params:[{type:"Long",name:"serverId"},{type:"Long",name:"channelId"},{type:"String",name:"accids"}],response:[{type:"PropertyArray",name:"memberRoles",reflectMapper:t.memberRole}]},qchatUpdateServerRolePriorities:{service:"qchatRole",sid:24,cid:80,params:[{type:"Long",name:"serverId"},{type:"PropertyArray",name:"serverRoles",reflectMapper:{serverId:1,roleId:2,priority:7}}],response:[{type:"PropertyArray",name:"serverRoles",reflectMapper:t.serverRole}]},qchatGetExistingAccidsInServerRole:{service:"qchatRole",sid:24,cid:81,params:[{type:"Long",name:"serverId"},{type:"Long",name:"roleId"},{type:"String",name:"accids"}],response:[{type:"PropertyArray",name:"members",reflectMapper:t.member}]},qchatCheckPermission:{service:"qchatRole",sid:24,cid:82,params:[{type:"Property",name:"checkPermissionTag",reflectMapper:eS.checkPermissionTag}],response:[{type:"Bool",name:"checked"}]},qchatAddChannelCategoryRole:{service:"qchatRole",sid:24,cid:83,params:[{type:"Property",name:"qchatAddChannelCategoryRoleTag",reflectMapper:eS.channelCategoryRole}],response:[{type:"Property",name:"channelCategoryRole",reflectMapper:t.channelCategoryRole}]},qchatRemoveChannelCategoryRole:{service:"qchatRole",sid:24,cid:84,params:[{type:"Long",name:"serverId"},{type:"Long",name:"categoryId"},{type:"Long",name:"roleId"}]},qchatUpdateChannelCategoryRole:{service:"qchatRole",sid:24,cid:85,params:[{type:"Property",name:"qchatUpdateChannelCategoryRoleTag",reflectMapper:eS.channelCategoryRole}],response:[{type:"Property",name:"channelCategoryRole",reflectMapper:t.channelCategoryRole}]},qchatGetChannelCategoryRole:{service:"qchatRole",sid:24,cid:86,params:[{type:"Property",name:"qchatGetChannelCategoryRoleTag",reflectMapper:eS.qchatGetChannelCategoryRoleTag}],response:[{type:"PropertyArray",name:"list",reflectMapper:t.channelCategoryRole}]},qchatAddChannelCategoryMemberRole:{service:"qchatRole",sid:24,cid:87,params:[{type:"Property",name:"qchatAddChannelCategoryMemberRoleTag",reflectMapper:eS.channelCategoryMemberRole}],response:[{type:"Property",name:"channelCategoryMemberRole",reflectMapper:t.channelCategoryMemberRole}]},qchatRemoveChannelCategoryMemberRole:{service:"qchatRole",sid:24,cid:88,params:[{type:"Long",name:"serverId"},{type:"Long",name:"categoryId"},{type:"String",name:"accid"}]},qchatUpdateChannelCategoryMemberRole:{service:"qchatRole",sid:24,cid:89,params:[{type:"Property",name:"qchatUpdateChannelCategoryMemberRoleTag",reflectMapper:eS.channelCategoryMemberRole}],response:[{type:"Property",name:"channelCategoryMemberRole",reflectMapper:t.channelCategoryMemberRole}]},qchatGetChannelCategoryMemberRole:{service:"qchatRole",sid:24,cid:90,params:[{type:"Property",name:"qchatGetChannelCategoryMemberRoleTag",reflectMapper:eS.qchatGetChannelCategoryMemberRoleTag}],response:[{type:"PropertyArray",name:"list",reflectMapper:t.channelCategoryMemberRole}]},qchatCheckPermissions:{service:"qchatRole",sid:24,cid:126,params:[{type:"Property",name:"checkPermissionsTag",reflectMapper:eS.checkPermissionsTag}],response:[{type:"PropertyArray",name:"checkPermissionsResult",reflectMapper:{1:"auth",2:"isAllow"}}]}}},nS=["image","audio","video","file"],aS={time:{type:"number"},updateTime:{type:"number"},resendFlag:{type:"boolean"},persistEnable:{type:"boolean"},routeEnable:{type:"boolean"},pushEnable:{type:"boolean"},needBadge:{type:"boolean"},needPushNick:{type:"boolean"},type:{type:"enum",values:k_},fromClientType:{type:"enum",values:B_},status:{type:"number"},toAccids:{type:"object"},toType:{type:"number"},attach:{type:"object"},pushPayload:{type:"object"}};function generatorSysMsgForCmd(t,i){var u=Dt({},t),m=Dt({type:i||k_.custom},formatReverse(aS,u));return m.serverId&&m.channelId&&m.toAccids?m.toType=4:m.serverId&&m.toAccids?m.toType=3:m.serverId&&m.channelId?m.toType=2:m.serverId?m.toType=1:m.toAccids?m.toType=5:m.toType=0,m}function generatorSysMsgMarkersForCmd(t){var i=pick(t,["msgIdServer","type"]);return formatReverse(aS,i)}var iS=((K_={})[k_.channelUpdateWhiteBlackIdentify]=function(t){var i=i_();return t.notify=formatUpdateWhiteBlackRole(deserialize(t.notify,i.qchatUpdateWhiteBlackRoleTag)),t},K_[k_.channelUpdateWhiteBlackIdentifyUser]=function(t){var i=i_();return t.notify=function formatUpdateWhiteBlackMembers(t){return format(l_,t)}(deserialize(t.notify,i.qchatUpdateWhiteBlackMembersTag)),t},K_[k_.updateQuickComment]=function(t){var i=z_();return t.notify=function formatQuickCommentRequest(t){return format(cS,t)}(deserialize(t.notify,i.qchatQuickCommentRequestTag)),t},K_[k_.channelCategoryCreate]=function(t){var i=i_();return t.categoryInfo=formatChannelCategory(deserialize(t.categoryInfo,i.QChatChannelCategoryInfo)),t},K_[k_.channelCategoryUpdate]=function(t){var i=i_();return t.categoryInfo=formatChannelCategory(deserialize(t.categoryInfo,i.QChatChannelCategoryInfo)),t},K_[k_.channelCategoryUpdateWhiteBlackIdentify]=function(t){var i=i_();return t.notify=formatUpdateWhiteBlackRole(deserialize(t.notify,i.qchatUpdateChannelCategoryWhiteBlackRoleTag)),t},K_[k_.channelCategoryUpdateWhiteBlackIdentifyUser]=function(t){var i=i_();return t.notify=formatUpdateWhiteBlackRole(deserialize(t.notify,i.qchatUpdateChannelCategoryWhiteBlackMembersTag)),t},K_[k_.serverIdentifyAdd]=function(t){var i=tS();return t.serverIdentifyInfo=formatRole(deserialize(t.serverIdentifyInfo,i.serverRole)),t},K_[k_.serverIdentifyRemove]=function(t){var i=tS();return t.serverIdentifyInfo=formatRole(deserialize(t.serverIdentifyInfo,i.serverRole)),t},K_[k_.serverIdentifyUpdate]=function(t){var i=tS();return t.serverIdentifyInfo=formatRole(deserialize(t.serverIdentifyInfo,i.serverRole)),t},K_[k_.channelIdentifyUpdate]=function(t){var i=tS();return t.channelIdentifyInfo=formatRole(deserialize(t.channelIdentifyInfo,i.channelRole)),t},K_[k_.userIdentifyUpdate]=function(t){var i=tS();return t.userIdentifyInfo=formatRole(deserialize(t.userIdentifyInfo,i.memberRole)),t},K_[k_.myMemberInfoUpdated]=function(t){var i,u=get(t,"userInfo.name"),m=get(t,"userInfo.icon");return t.updatedInfos=map$6(i=t.reuseServers).call(i,(function(t){var i={serverId:t.serverId};return 1==(1&t.bits)&&"string"==typeof u&&Dt(i,{nickChanged:!0,nick:u}),2==(2&t.bits)&&"string"==typeof m&&Dt(i,{avatarChanged:!0,avatar:m}),i})),delete t.userInfo,delete t.reuseServers,t},K_);function formatSystemNotification(t,i){var u=format(aS,t);if(!u.attach)return u;var m=J_(),h=i_();if(u.attach.serverInfo&&(u.attach.serverInfo=formatServer(deserialize(u.attach.serverInfo,m.serverInfo))),u.attach.channelInfo&&(u.attach.channelInfo=formatChannel(deserialize(u.attach.channelInfo,h.channelInfo))),u.attach.serverMember&&(u.attach.serverMember=formatMember$1(deserialize(u.attach.serverMember,m.memberInfo))),iS[u.attach.type]&&(u.attach=iS[u.attach.type](u.attach)),u.attach.updateAuths)try{u.attach.updateAuths=formatRoleAuths(JSON.parse(u.attach.updateAuths))}catch(t){i.error("formatSystemNotification:JSON parse updateAuths error: ",t)}return u.attach.type&&(u.attach.rawType=u.attach.type,u.attach.type=k_[u.attach.type]),u}var oS={type:{type:"enum",values:C_},fromClientType:{type:"enum",values:B_},status:{type:"number"},resendFlag:{type:"boolean"},mentionAll:{type:"boolean"},notifyReason:{type:"enum",values:E_},pushEnable:{type:"boolean"},historyEnable:{type:"boolean"},needBadge:{type:"boolean"},needPushNick:{type:"boolean"},routeEnable:{type:"boolean"},time:{type:"number"},updateTime:{type:"number"},mentionAccids:{type:"object"},mentionRoleIds:{type:"object"},accidsOfMentionedRoles:{type:"object"},attach:{type:"object"},pushPayload:{type:"object"},isAntispam:{type:"boolean"},antiSpamInfo:{useCustomContent:{type:"boolean"},antiSpamContent:{type:"string"},antiSpamBusinessId:{type:"string"},antiSpamUsingYidun:{type:"boolean"},yidunCallback:{type:"string"},yidunAntiCheating:{type:"object"},yidunAntiSpamExt:{type:"object"},yidunAntiSpamRes:{type:"string"}},replyRefer:{fromAccount:{type:"string",rawKey:"replyMsgFromAccount"},time:{type:"number",rawKey:"replyMsgTime"},msgIdServer:{type:"string",rawKey:"replyMsgIdServer"},msgIdClient:{type:"string",rawKey:"replyMsgIdClient"}},threadRefer:{fromAccount:{type:"string",rawKey:"threadMsgFromAccount"},time:{type:"number",rawKey:"threadMsgTime"},msgIdServer:{type:"string",rawKey:"threadMsgIdServer"},msgIdClient:{type:"string",rawKey:"threadMsgIdClient"}}};function generatorMsgForCmd(t){t.onSendBefore,t.onUploadStart,t.onUploadDone,t.onUploadProgress;var i=__rest(t,["onSendBefore","onUploadStart","onUploadDone","onUploadProgress"]),u=formatReverse(oS,i);if(u.msgIdClient=t.resendFlag?t.msgIdClient:jd(),!u.msgIdClient)throw new Xl("msgIdClient is required for resend a message","msgIdClient","required");return t.replyMessage&&t.replyMessage.msgIdServer&&(u.replyMsgFromAccount=t.replyMessage.fromAccount,u.replyMsgTime=+t.replyMessage.time,u.replyMsgIdServer=t.replyMessage.msgIdServer,u.replyMsgIdClient=t.replyMessage.msgIdClient,t.replyMessage.threadRefer&&t.replyMessage.threadRefer.msgIdServer?(u.threadMsgFromAccount=t.replyMessage.threadRefer.fromAccount,u.threadMsgTime=+t.replyMessage.threadRefer.time,u.threadMsgIdServer=t.replyMessage.threadRefer.msgIdServer,u.threadMsgIdClient=t.replyMessage.threadRefer.msgIdClient):(u.threadMsgFromAccount=t.replyMessage.fromAccount,u.threadMsgTime=+t.replyMessage.time,u.threadMsgIdServer=t.replyMessage.msgIdServer,u.threadMsgIdClient=t.replyMessage.msgIdClient),delete u.replyMessage),u}function formatMsgOperatorInfo(t){return format({operatorClientType:{type:"enum",values:B_},pushPayload:{type:"object"}},t)}function formatMsg(t,i,u){var m,h;return void 0===i&&(i={}),__awaiter(this,void 0,void 0,ud.mark((function _callee(){var v,M,I,S;return ud.wrap((function _callee$(T){for(;;)switch(T.prev=T.next){case 0:return(v=format(oS,t)).deliveryStatus=i.deliveryStatus?b_[i.deliveryStatus]:b_[b_.success],i.time&&(v.time=i.time),M=z_(),v.updateContent&&(I=format({status:{type:"number"}},I=deserialize(I=JSON.parse(v.updateContent),M.qchatMsgTag)),v.updateContent=I),v.updateOperatorInfo&&(S=formatMsgOperatorInfo(deserialize(S=JSON.parse(v.updateOperatorInfo),M.qchatMsgUpdateTag)),v.updateOperatorInfo=S),""===(null===(m=null==v?void 0:v.threadRefer)||void 0===m?void 0:m.fromAccount)&&delete v.threadRefer,""===(null===(h=null==v?void 0:v.replyRefer)||void 0===h?void 0:h.fromAccount)&&delete v.replyRefer,v.attach&&i.attachUrl&&(v.attach.url=i.attachUrl),T.next=11,formatMsgAttach(v,u);case 11:return T.abrupt("return",T.sent);case 12:case"end":return T.stop()}}),_callee)})))}function formatMsgAttach(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:if(includes(nS).call(nS,t.type)&&t.attach&&t.attach.url){m.next=2;break}return m.abrupt("return",t);case 2:if(i&&i.cloudStorage&&"function"==typeof i.cloudStorage.getPrivateUrl&&"function"==typeof i.cloudStorage.getOriginUrl){m.next=4;break}return m.abrupt("return",t);case 4:if(!(indexOf(u=t.attach.url).call(u,"_im_url=1")<0)){m.next=7;break}return t.attach.url=i.cloudStorage.getPrivateUrl(t.attach.url),m.abrupt("return",t);case 7:return m.prev=7,m.next=10,i.cloudStorage.getOriginUrl(t.attach.url);case 10:t.attach.url=m.sent,m.next=16;break;case 13:throw m.prev=13,m.t0=m.catch(7),new Xl('url "'+t.attach.url+'" parse error',"message.attach.url","parse error");case 16:return m.abrupt("return",t);case 17:case"end":return m.stop()}}),_callee2,null,[[7,13]])})))}function formatMsgs(t,i,u){return void 0===i&&(i={}),__awaiter(this,void 0,void 0,ud.mark((function _callee3(){var m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:if(Dn(t)&&t.length>0){h.next=2;break}return h.abrupt("return",[]);case 2:return m=map$6(t).call(t,(function(t){return formatMsg(t,i,u)})),h.next=5,zi.all(m);case 5:return h.abrupt("return",h.sent);case 6:case"end":return h.stop()}}),_callee3)})))}var sS={totalCount:{type:"number"},lastUpdateTime:{type:"number"},details:{type:"object"}};function formatQuickComments(t){var i=map$6(t).call(t,(function(t){var i,u=format(sS,t);return u.details=map$6(i=u.details).call(i,(function(t){var i=t.createTime?Gd(t.createTime):0;return i=isNaN(i)?0:i,{count:t.count,hasSelf:t.self,severalAccids:t.topN,type:t.type,createTime:i}})),u})),u={};return forEach$1(i).call(i,(function(t){return u[t.msgIdServer]=t})),u}var cS={type:{type:"number"},time:{type:"number"},opeType:{type:"number"}};var lS={includeSelf:{type:"number"},order:{type:"enum",values:JI},sort:{type:"enum",values:T_},msgTypes:{type:"object"},subTypes:{type:"object"}};var dS={hasMore:{type:"boolean"},nextTimetag:{type:"number"},cursor:{type:"string"}};var uS={6:function _(t){return this.core.qchatChannel.subscribeForVisitorService.deleteAutoSetInServerId(t.serverId),!0},16:function _(t){return this.core.qchatChannel.subscribeForVisitorService.deleteAutoSetInChannel(t.serverId,t.channelId),!0},26:function _(t){var i=get(t,"attach.addAccids");return i&&includes(i).call(i,this.core.account)&&this.core.eventBus.emit("qchatChannel/serverIdentifyChange",t),!0},27:function _(t){var i=get(t,"attach.deleteAccids");return i&&includes(i).call(i,this.core.account)&&this.core.eventBus.emit("qchatChannel/serverIdentifyChange",t),!0},31:function _(t){var i,u;return 1===t.attach.event?(null===(u=null===(i=this.core.qchatChannel)||void 0===i?void 0:i.config)||void 0===u?void 0:u.autoSubscribe)&&this.core.qchatChannel.subscribeChannel({type:1,opeType:1,channels:[{serverId:t.serverId,channelId:t.channelId}],isInternalTrigger:!0}):2===t.attach.event&&(this.core.eventBus.emit("qchatChannel/autoUnSubscribe",t),this.core.eventBus.emit("qchatMedia/serverOrChannelLeave",t)),!0},32:function _(t){var i,u;return 2===t.attach.event?(this.core.eventBus.emit("qchatChannel/autoUnSubscribe",t),this.core.eventBus.emit("qchatMedia/serverOrChannelLeave",t)):1===t.attach.event&&(this.core.qchatChannel.subscribeForVisitorService.deleteServer(t.serverId),(null===(u=null===(i=this.core.qchatChannel)||void 0===i?void 0:i.config)||void 0===u?void 0:u.autoSubscribe)&&this.core.qchatServer.subscribeServer({type:4,opeType:1,servers:[{serverId:t.serverId}],isInternalTrigger:!0})),!0},34:function _(t){return 2===t.attach.event&&this.core.qchatChannel.subscribeForVisitorService.unSubscribeChannel(t.serverId,t.channelId),!0},101:function _(t){var i=pick(t,["serverId","channelId","ext","fromAccount","fromNick","time"]);return this.logger.log("qchat on recvTypingEvent: ",i),this.core.emit("recvTypingEvent",i),this.core.qchatMsg.emit("recvTypingEvent",i),!1}},pS=function(){function NotificationModuleService(t){this.core=t,this.logger=t.logger}var t=NotificationModuleService.prototype;return t.sendSystemNotification=function sendSystemNotification(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.core.sendCmd("qchatSendCustomSysMsg",{sysMsg:generatorSysMsgForCmd(t)});case 2:return i=m.sent,u=formatSystemNotification(i.content.sysMsg,this.logger),this.logger.getDebugMode()?this.logger.debug("sendCustomSysMsg success",u):this.logger.log("sendCustomSysMsg success",u.serverId,u.channelId,u.msgIdServer),m.abrupt("return",u);case 6:case"end":return m.stop()}}),_callee,this)})))},t.updateSystemNotification=function updateSystemNotification(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u,m,h,v;return ud.wrap((function _callee2$(M){for(;;)switch(M.prev=M.next){case 0:return i=t.systemNotification,u=__rest(t,["systemNotification"]),m=pick(i,["msgIdServer","type","body","ext","status"]),h=generatorSysMsgForCmd(m),M.next=5,this.core.sendCmd("qchatUpdateSystemNotification",{sysMsg:h,qchatMsgUpdateTag:Dt(Dt({},u),{operatorAccount:this.core.account,operatorClientType:B_.Web,pushPayload:Un(t.pushPayload),routeEnable:np.boolean(t,"routeEnable")})});case 5:return v=M.sent,M.abrupt("return",formatSystemNotification(v.content.sysMsg,this.logger));case 7:case"end":return M.stop()}}),_callee2,this)})))},t.markSystemNotificationsRead=function markSystemNotificationsRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.core.sendCmd("qchatMarkSysMsgRead",{sysMsgs:map$6(i=t.systemNotifications).call(i,(function(t){return generatorSysMsgMarkersForCmd(t)}))});case 2:case"end":return u.stop()}}),_callee3,this)})))},t.onSysMsg=function onSysMsg(t){var i=t.content.sysMsg;if(i){var u=formatSystemNotification(i,this.core.logger),m=uS[k_[u.type]];if(m)if(!1===m.call(this,u))return;var h={feature:"default",systemNotifications:[u]};this.logger.log("qchat on systemNotification: ",h),this.core.emit("systemNotification",h),this.core.qchatMsg.emit("systemNotification",h)}else this.core.logger.warn("No sysMsg in onSysMsg packet")},t.onMultiSysMsg=function onMultiSysMsg(t){var i=t.content.sysMsg;if(i){var u=formatSystemNotification(i,this.logger);this.core.emit("systemNotificationUpdate",u),this.core.qchatMsg.emit("systemNotificationUpdate",u)}},t.onSyncSysMsg=function onSyncSysMsg(t){var i=this,u=t.content.systemNotifications;if(u&&u.length>0){var m=map$6(u).call(u,(function(t){return formatSystemNotification(t,i.logger)}));this.core.emit("systemNotification",{feature:"sync",systemNotifications:m}),this.core.qchatMsg.emit("systemNotification",{feature:"sync",systemNotifications:m})}else this.logger.warn("sync system notification not exist")},NotificationModuleService}(),mS=["image","audio","video","file"],hS=function(){function MessageModuleService(t){var i=this;this.markMessageRead=throttle((function(t){return __awaiter(i,void 0,void 0,ud.mark((function _callee(){var i,u;return ud.wrap((function _callee$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.core.sendCmd("qchatMarkMessageRead",{markMsgReadTag:t});case 2:i=m.sent,u=formatUnreadInfo(i.content.unreadInfo),this.core.eventBus.emit("qchatChannel/updateUnreads",[u]);case 5:case"end":return m.stop()}}),_callee,this)})))}),200),this.core=t,this.logger=t.logger}var t=MessageModuleService.prototype;return t.sendMessage=function sendMessage(t){var i,u,m,h;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var v,M,I,S,T,C;return ud.wrap((function _callee2$(E){for(;;)switch(E.prev=E.next){case 0:if(!(indexOf(mS).call(mS,t.type)>-1)){E.next=4;break}return E.next=3,this.doSendFile(t);case 3:t.attach=E.sent;case 4:return v=generatorMsgForCmd(Dt({fromAccount:this.core.account},t)),E.next=7,formatMsg(v,{time:(new Date).getTime(),deliveryStatus:b_.sending},this.core);case 7:M=E.sent;try{t.onSendBefore&&t.onSendBefore(M)}catch(t){this.logger.error("sendMsg: options.onSendBefore error",t)}return E.prev=9,E.next=12,this.core.sendCmd("qchatSendMsg",{qchatMsg:v});case 12:I=E.sent,E.next=22;break;case 15:return E.prev=15,E.t0=E.catch(9),E.next=19,formatMsg(v,{time:(new Date).getTime(),deliveryStatus:b_.failed,attachUrl:null===(i=M.attach)||void 0===i?void 0:i.url},this.core);case 19:throw S=E.sent,E.t0.msg=S,E.t0;case 22:return T=I.content,E.next=25,formatMsg(Dt({},T.qchatMsg),{deliveryStatus:b_.success,attachUrl:null===(u=M.attach)||void 0===u?void 0:u.url},this.core);case 25:if(!(C=E.sent).isAntispam){E.next=29;break}throw{code:10403,msg:C,message:(null===(m=null==C?void 0:C.antiSpamInfo)||void 0===m?void 0:m.yidunAntiSpamRes)||"message has be antispam",isAntispam:!0,yidunAntiSpamRes:(null===(h=null==C?void 0:C.antiSpamInfo)||void 0===h?void 0:h.yidunAntiSpamRes)||""};case 29:return E.abrupt("return",C);case 30:case"end":return E.stop()}}),_callee2,this,[[9,15]])})))},t.doSendFile=function doSendFile(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:if(validate({type:{type:"enum",values:["image","audio","video","file"]},attach:{type:"object",rules:{url:{type:"string",allowEmpty:!1}},required:!1},maxSize:{type:"number",min:1,required:!1}},t),i=t.attach){u.next=15;break}if(this.core.cloudStorage&&this.core.cloudStorage.uploadFile){u.next=5;break}throw new Error('Service "cloudStorage" does not exist');case 5:return u.prev=5,u.next=8,this.core.cloudStorage.uploadFile(t);case 8:i=u.sent,u.next=15;break;case 11:throw u.prev=11,u.t0=u.catch(5),this.logger.error("sendFile:: upload File error or abort.",u.t0),u.t0;case 15:return u.abrupt("return",i);case 16:case"end":return u.stop()}}),_callee3,this,[[5,11]])})))},t.resendMessage=function resendMessage(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var m,h,v,M,I;return ud.wrap((function _callee4$(S){for(;;)switch(S.prev=S.next){case 0:return(m=generatorMsgForCmd(Dt(Dt({},t),{resendFlag:!0}))).deliveryStatus=b_.sending,S.prev=2,S.next=5,this.core.sendCmd("qchatSendMsg",{qchatMsg:m});case 5:h=S.sent,S.next=15;break;case 8:return S.prev=8,S.t0=S.catch(2),S.next=12,formatMsg(m,{time:(new Date).getTime(),deliveryStatus:b_.failed},this.core);case 12:throw v=S.sent,S.t0.msg=v,S.t0;case 15:return M=h.content,S.next=18,formatMsg(Dt({},M.qchatMsg),{deliveryStatus:b_.success},this.core);case 18:if(!(I=S.sent).isAntispam){S.next=22;break}throw{code:10403,msg:I,message:(null===(i=null==I?void 0:I.antiSpamInfo)||void 0===i?void 0:i.yidunAntiSpamRes)||"message has be antispam",isAntispam:!0,yidunAntiSpamRes:(null===(u=null==I?void 0:I.antiSpamInfo)||void 0===u?void 0:u.yidunAntiSpamRes)||""};case 22:return S.abrupt("return",I);case 23:case"end":return S.stop()}}),_callee4,this,[[2,8]])})))},t.doUpdateMessage=function doUpdateMessage(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var m,h,v,M,I;return ud.wrap((function _callee5$(S){for(;;)switch(S.prev=S.next){case 0:return m=t.message,h=__rest(t,["message"]),(v=generatorMsgForCmd(m)).msgIdClient=void 0,v.time=m.time,S.next=6,this.core.sendCmd("qchatUpdateMessage",{qchatMsg:v,qchatMsgUpdateTag:Dt(Dt({},h),{operatorAccount:this.core.account,operatorClientType:B_.Web,pushPayload:Un(t.pushPayload),routeEnable:np.boolean(t,"routeEnable")})});case 6:return M=S.sent,S.next=9,formatMsg(M.content.qchatMsg,{},this.core);case 9:if(I=S.sent,this.core.eventBus.emit("qchatChannel/changeUnread",I,!0),!M.content.qchatMsg.isAntispam){S.next=14;break}throw{code:10403,msg:v,message:(null===(i=M.content.qchatMsg)||void 0===i?void 0:i.yidunAntiSpamRes)||"message has be antispam",isAntispam:!0,yidunAntiSpamRes:(null===(u=M.content.qchatMsg)||void 0===u?void 0:u.yidunAntiSpamRes)||""};case 14:return S.abrupt("return",I);case 15:case"end":return S.stop()}}),_callee5,this)})))},t.getHistoryMessage=function getHistoryMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i,u,m,h=this;return ud.wrap((function _callee6$(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.core.sendCmd("qchatGetHistoryMsg",{getHistoryMsgTag:Dt(Dt({},t),{reverse:reverse$1(t)?1:0})});case 2:return u=v.sent,m=u.content,v.next=6,zi.all(map$6(i=m.qchatMsgs).call(i,(function(t){return formatMsg(t,{},h.core)})));case 6:return v.abrupt("return",v.sent);case 7:case"end":return v.stop()}}),_callee6,this)})))},t.getMentionedMeMessages=function getMentionedMeMessages(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var i,u,m,h,v,M=this;return ud.wrap((function _callee7$(I){for(;;)switch(I.prev=I.next){case 0:return I.next=2,this.core.sendCmd("qchatGetMentionedMeMessages",{tag:t});case 2:return u=I.sent,m=u.content,S=m.page,h=format(dS,S),I.next=7,zi.all(map$6(i=m.datas).call(i,(function(t){return formatMsg(t,{},M.core)})));case 7:return v=I.sent,I.abrupt("return",{pageInfo:h,messages:v});case 9:case"end":return I.stop()}var S}),_callee7,this)})))},t.areMentionedMeMessages=function areMentionedMeMessages(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i,u,m;return ud.wrap((function _callee8$(h){for(;;)switch(h.prev=h.next){case 0:i={},u=0;case 2:if(!(u<t.length)){h.next=13;break}if((m=t[u]).fromAccount!==this.core.account){h.next=7;break}return i[m.msgIdClient]=!1,h.abrupt("continue",10);case 7:return h.next=9,this.core.qchatChannel.subscribeModuleService.getMentionedFlag(m,!0);case 9:i[m.msgIdClient]=h.sent;case 10:u++,h.next=2;break;case 13:return h.abrupt("return",i);case 14:case"end":return h.stop()}}),_callee8,this)})))},t.getLastMessageOfChannels=function getLastMessageOfChannels(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var i,u,m;return ud.wrap((function _callee9$(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.core.sendCmd("qchatGetLastMessageOfChannels",{tag:t});case 2:return i=h.sent,u=i.content.msgs,h.next=6,formatMsgs(u,{},this.core);case 6:return m=h.sent,h.abrupt("return",reduce(m).call(m,(function(t,i){return t[i.channelId]=i,t}),{}));case 8:case"end":return h.stop()}}),_callee9,this)})))},t.messageSearchByPage=function messageSearchByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var i,u,m,h,v;return ud.wrap((function _callee10$(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,this.core.sendCmd("qchatMessageSearchByPage",{qchatMessageSearchByPageTag:Dt(Dt({},(I=t,formatReverse(lS,I))),{includeSelf:t.includeSelf?1:""})});case 2:return i=M.sent,u=i.content,m=u.datas,h=u.listQueryTag,M.next=6,formatMsgs(m,{},this.core);case 6:return v=M.sent,M.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:h.nextTimetag?Gd(h.nextTimetag):0,cursor:h.cursor},datas:v});case 8:case"end":return M.stop()}var I}),_callee10,this)})))},t.onMsg=function onMsg(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){var i,u;return ud.wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:if(i=t.content.qchatMsg){m.next=4;break}return this.logger.warn("No qchatMsg in qchatMsg packet"),m.abrupt("return");case 4:return m.next=6,formatMsg(i,{},this.core);case 6:u=m.sent,this.core.eventBus.emit("qchatChannel/changeUnread",u,!1),this.core.emit("message",u),this.core.qchatMsg.emit("message",u);case 10:case"end":return m.stop()}}),_callee11,this)})))},t.onRecvUnreadInfo=function onRecvUnreadInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i,u;return ud.wrap((function _callee12$(m){for(;;)switch(m.prev=m.next){case 0:if(i=t.content.qchatMsg){m.next=3;break}return m.abrupt("return");case 3:return m.next=5,formatMsg(i);case 5:u=m.sent,this.core.eventBus.emit("qchatChannel/changeUnread",u,!1);case 7:case"end":return m.stop()}}),_callee12,this)})))},t.onMultiSyncRead=function onMultiSyncRead(t){var i=t.content.unreadInfo;if(i){var u=formatUnreadInfo(i);this.core.eventBus.emit("qchatChannel/updateUnreads",[u])}},t.onMultiSyncServersRead=function onMultiSyncServersRead(t){var i=t.content.qchatMultiSyncServersMessageReadTag;if(i){var u=formatClearServersUnread(i),m=u.successServerIds,h=u.ackTimestamp;this.core.eventBus.emit("qchatChannel/clearUnreadCountByServers",m,h)}},t.onRecvMsgUpdate=function onRecvMsgUpdate(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i,u,m,h;return ud.wrap((function _callee13$(v){for(;;)switch(v.prev=v.next){case 0:if(i=t.content.qchatMsg,u=t.content.qchatMsgUpdateInfo,i){v.next=4;break}return v.abrupt("return");case 4:return v.next=6,formatMsg(i,{},this.core);case 6:m=v.sent,h=formatMsgOperatorInfo(u),this.core.eventBus.emit("qchatChannel/changeUnread",m,!0),this.core.emit("messageUpdate",m,h),this.core.qchatMsg.emit("messageUpdate",m,h);case 11:case"end":return v.stop()}}),_callee13,this)})))},MessageModuleService}(),gS=function(){function ExtendModuleService(t){var i=this;this._sendTypingEvent=throttle((function(t){return __awaiter(i,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.core.sendCmd("qchatSendCustomSysMsg",{sysMsg:generatorSysMsgForCmd(Dt(Dt({},t),{resendFlag:!1,persistEnable:!1,routeEnable:!1,pushEnable:!1,needBadge:!1,needPushNick:!1}),k_.msgTyping)});case 2:case"end":return i.stop()}}),_callee,this)})))}),3e3),this.core=t,this.logger=t.logger,this.lastChannelIdInTyping=""}var t=ExtendModuleService.prototype;return t.getMessageHistoryByIds=function getMessageHistoryByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.core.sendCmd("qchatGetMessageHistoryByIds",{channelInfo:{serverId:t.serverId,channelId:t.channelId},messageReferList:t.messageReferList});case 2:return u=m.sent,m.abrupt("return",zi.all(map$6(i=u.content.qchatMsgs).call(i,(function(t){return formatMsg(t)}))));case 4:case"end":return m.stop()}}),_callee2,this)})))},t.getReferMessages=function getReferMessages(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:if((null===(i=t.message.replyRefer)||void 0===i?void 0:i.msgIdServer)&&(null===(u=t.message.threadRefer)||void 0===u?void 0:u.msgIdServer)){h.next=2;break}throw new Error("Message has no reply");case 2:return h.next=4,this.getMessageHistoryByIds({serverId:t.message.serverId,channelId:t.message.channelId,messageReferList:[t.message.replyRefer,t.message.threadRefer]});case 4:if(m=h.sent,t.referType!==R_[R_.all]){h.next=9;break}return h.abrupt("return",{replyMessage:m[0],threadMessage:m[1]});case 9:if(t.referType!==R_[R_.reply]){h.next=13;break}return h.abrupt("return",{replyMessage:m[0]});case 13:if(t.referType!==R_[R_.thread]){h.next=15;break}return h.abrupt("return",{threadMessage:m[1]});case 15:return h.abrupt("return",{replyMessage:m[0],threadMessage:m[1]});case 16:case"end":return h.stop()}}),_callee3,this)})))},t.getThreadMessages=function getThreadMessages(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var u,m,h,v,M;return ud.wrap((function _callee4$(I){for(;;)switch(I.prev=I.next){case 0:return m=(null===(i=t.message.threadRefer)||void 0===i?void 0:i.msgIdServer)?Dt({serverId:t.message.serverId,channelId:t.message.channelId},t.message.threadRefer):t.message,I.next=3,this.core.sendCmd("qchatGetThreadMessages",{qchatMsg:m,getThreadHistoryMsgTag:Dt(Dt({},t.messageQueryOption),{reverse:np.boolean(t.messageQueryOption,"reverse")})});case 3:return h=I.sent,I.next=6,formatMsg(h.content.thread);case 6:return v=I.sent,I.next=9,zi.all(map$6(u=h.content.qchatMsgs).call(u,(function(t){return formatMsg(t)})));case 9:return M=I.sent,I.abrupt("return",{thread:v,threadInfo:{messageCount:+h.content.threadInfo.messageCount,lastMessageTimestamp:+h.content.threadInfo.lastMessageTimestamp},messages:M});case 11:case"end":return I.stop()}}),_callee4,this)})))},t.getThreadRootMessagesMeta=function getThreadRootMessagesMeta(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i,u,m,h;return ud.wrap((function _callee5$(v){for(;;)switch(v.prev=v.next){case 0:return i=t.threadRootMessages,u=__rest(t,["threadRootMessages"]),v.next=3,this.core.sendCmd("qchatGetThreadRootMessagesMeta",{qchatMsgs:i,tag:u});case 3:if(m=v.sent,!((h=m.content.metas)&&h.length>0)){v.next=7;break}return v.abrupt("return",map$6(h).call(h,(function(t){return Dt(Dt({},t),{total:Gd(t.total),timestamp:Gd(t.timestamp),msgTime:Gd(t.msgTime)})})));case 7:return v.abrupt("return",[]);case 8:case"end":return v.stop()}}),_callee5,this)})))},t.getQuickComments=function getQuickComments(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i,u,m;return ud.wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.core.sendCmd("qchatGetQuickComments",{tag:{serverId:t.serverId,channelId:t.channelId,msgIdServerList:Un(map$6(i=t.msgList).call(i,(function(t){return t.msgIdServer})))}});case 2:return u=h.sent,m=u.content.quickCommentResponse,h.abrupt("return",formatQuickComments(m));case 5:case"end":return h.stop()}}),_callee6,this)})))},t.updateQuickComment=function updateQuickComment(t,i){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var u,m,h,v,M,I;return ud.wrap((function _callee7$(S){for(;;)switch(S.prev=S.next){case 0:return validate({type:{type:"number"},commentMessage:{type:"object",rules:{msgIdServer:{type:"string",allowEmpty:!1}}}},t),u=t.commentMessage,m=u.serverId,h=u.channelId,v=u.fromAccount,M=u.msgIdServer,I=u.time,S.next=4,this.core.sendCmd("qchatUpdateQuickComment",{tag:{serverId:m,channelId:h,fromAccount:v,msgIdServer:M,time:I,type:t.type,opeType:i,opeAccid:this.core.account}});case 4:case"end":return S.stop()}}),_callee7,this)})))},t.sendTypingEvent=function sendTypingEvent(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){return ud.wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:if(t.channelId!==this.lastChannelIdInTyping){i.next=4;break}return this.logger.log("qchatMsg sendTypingEvent throttle"),this._sendTypingEvent(t),i.abrupt("return");case 4:this.lastChannelIdInTyping=t.channelId,this._sendTypingEvent.flush(),this._sendTypingEvent(t);case 7:case"end":return i.stop()}}),_callee8,this)})))},ExtendModuleService}(),vS=function(t){function QChatMsgService(i){var u;return(u=t.call(this,"qchatMsg",i)||this).core=i,u.lastChannelIdInMark="",registerParser({cmdMap:j_,cmdConfig:W_()}),u.notificationModuleService=new pS(i),u.messageModuleService=new hS(i),u.extendModuleService=new gS(i),u}Nt(QChatMsgService,t);var i=QChatMsgService.prototype;return i.sendMessage=function sendMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(C_)},ext:{type:"string",required:!1},mentionAll:{type:"boolean",required:!1},mentionAccids:{type:"array",itemType:"string",required:!1},mentionRoleIds:{type:"array",itemType:"string",required:!1,min:1},historyEnable:{type:"boolean",required:!1},pushEnable:{type:"boolean",required:!1}},t),i.next=3,this.messageModuleService.sendMessage(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee,this)})))},i.updateMessage=function updateMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:if(validate({message:{type:"object",rules:{serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},msgIdServer:{type:"string",allowEmpty:!1},time:{type:"number",min:0},body:{type:"string",required:!1},ext:{type:"string",required:!1}}}},t),!("number"==typeof t.message.status&&t.message.status<1e4)){i.next=3;break}throw new ed("Status should be greater than or equal to 10000");case 3:return i.next=5,this.messageModuleService.doUpdateMessage(t);case 5:return i.abrupt("return",i.sent);case 6:case"end":return i.stop()}}),_callee2,this)})))},i.resendMessage=function resendMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},msgIdClient:{type:"string",allowEmpty:!1}},t),i.next=3,this.messageModuleService.resendMessage(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee3,this)})))},i.deleteMessage=function deleteMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return validate({message:{type:"object",rules:{serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},msgIdServer:{type:"string",allowEmpty:!1},time:{type:"number",min:0}}}},t),(i=JSON.parse(Un(t))).message.status=2,u.next=5,this.messageModuleService.doUpdateMessage(i);case 5:return u.abrupt("return",u.sent);case 6:case"end":return u.stop()}}),_callee4,this)})))},i.revokeMessage=function revokeMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i;return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:return validate({message:{type:"object",rules:{serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},msgIdServer:{type:"string",allowEmpty:!1},time:{type:"number",min:0}}}},t),(i=JSON.parse(Un(t))).message=pick(i.message,["serverId","channelId","msgIdServer","time"]),i.message.status=1,u.next=6,this.messageModuleService.doUpdateMessage(i);case 6:return u.abrupt("return",u.sent);case 7:case"end":return u.stop()}}),_callee5,this)})))},i.markMessageRead=function markMessageRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:validate({serverId:{type:"string"},channelId:{type:"string"},time:{type:"number",min:0}},t),t.channelId!==this.lastChannelIdInMark&&this.messageModuleService.markMessageRead.flush(),this.lastChannelIdInMark=t.channelId,this.messageModuleService.markMessageRead(t);case 4:case"end":return i.stop()}}),_callee6,this)})))},i.replyMessage=function replyMessage(t){validate({replyMessage:{type:"object",rules:{msgIdServer:{type:"string",allowEmpty:!1}}}},t);var replyMessage=t.replyMessage;if(t.serverId!==replyMessage.serverId||t.channelId!==replyMessage.channelId)throw new ed("Forbid replying to message from other server, channel");return this.sendMessage(t)},i.getMessageHistoryByIds=function getMessageHistoryByIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},messageReferList:{type:"array",rules:{msgIdServer:{type:"string",allowEmpty:!1},time:{type:"number"}}}},t),i.next=3,this.extendModuleService.getMessageHistoryByIds(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee7,this)})))},i.getReferMessages=function getReferMessages(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){return ud.wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:return validate({message:{type:"object",rules:{msgIdServer:{type:"string",allowEmpty:!1},time:{type:"number"}}},referType:{type:"enum",values:getEnumKeys(R_),required:!1}},t),i.next=3,this.extendModuleService.getReferMessages(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee8,this)})))},i.getThreadMessages=function getThreadMessages(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){return ud.wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:return validate({message:{type:"object",rules:{msgIdServer:{type:"string",allowEmpty:!1},time:{type:"number"}}},messageQueryOption:{type:"object",rules:{beginTime:{type:"number",required:!1},endTime:{type:"number",required:!1},excludeMsgId:{type:"string",required:!1},limit:{type:"number",required:!1},reverse:{type:"boolean",required:!1}}}},t),i.next=3,this.extendModuleService.getThreadMessages(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee9,this)})))},i.getThreadRootMessagesMeta=function getThreadRootMessagesMeta(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){return ud.wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},threadRootMessages:{type:"array",rules:{msgIdServer:{type:"string",allowEmpty:!1},time:{type:"number"}}}},t),i.next=3,this.extendModuleService.getThreadRootMessagesMeta(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee10,this)})))},i.sendSystemNotification=function sendSystemNotification(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1,required:!1},attach:{type:"object",required:!1}},t),i.next=3,this.notificationModuleService.sendSystemNotification(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee11,this)})))},i.updateSystemNotification=function updateSystemNotification(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(i){for(;;)switch(i.prev=i.next){case 0:return validate({systemNotification:{type:"object",rules:{msgIdServer:{type:"string",allowEmpty:!1},type:{type:"enum",values:getEnumKeys(k_)},body:{type:"string",required:!1},ext:{type:"string",required:!1},status:{type:"number",required:!1}}}},t),i.next=3,this.notificationModuleService.updateSystemNotification(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee12,this)})))},i.markSystemNotificationsRead=function markSystemNotificationsRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){return ud.wrap((function _callee13$(i){for(;;)switch(i.prev=i.next){case 0:return validate({systemNotifications:{type:"array",rules:{msgIdServer:{type:"string",allowEmpty:!1},type:{type:"string",allowEmpty:!1}},min:1}},t),i.next=3,this.notificationModuleService.markSystemNotificationsRead(t);case 3:case"end":return i.stop()}}),_callee13,this)})))},i.getHistoryMessage=function getHistoryMessage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){return ud.wrap((function _callee14$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},beginTime:{type:"number",min:0,required:!1},endTime:{type:"number",min:0,required:!1},excludeMsgId:{type:"string",allowEmpty:!1,required:!1},limit:{type:"number",min:1,required:!1},reverse:{type:"boolean",required:!1}},t),i.next=3,this.messageModuleService.getHistoryMessage(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee14,this)})))},i.getMentionedMeMessages=function getMentionedMeMessages(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){return ud.wrap((function _callee15$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},timestamp:{type:"number",min:0,required:!1},limit:{type:"number",min:1,required:!1}},t),i.next=3,this.messageModuleService.getMentionedMeMessages(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee15,this)})))},i.areMentionedMeMessages=function areMentionedMeMessages(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i;return ud.wrap((function _callee16$(u){for(;;)switch(u.prev=u.next){case 0:if(validate({messages:{type:"array",rules:{serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},msgIdServer:{type:"string",allowEmpty:!1}},min:1}},t),every(i=t.messages).call(i,(function(i){return t.messages[0].serverId===i.serverId}))){u.next=4;break}throw new ed("Different serverId",t,10414);case 4:if(!this.core.qchatChannel.subscribeForVisitorService.isInAutoServers(t.messages[0].serverId)){u.next=7;break}throw new ed("Not allowed for visitor",t,10403);case 7:return u.next=9,this.messageModuleService.areMentionedMeMessages(t.messages);case 9:return u.abrupt("return",u.sent);case 10:case"end":return u.stop()}}),_callee16,this)})))},i.addQuickComment=function addQuickComment(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){return ud.wrap((function _callee17$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.extendModuleService.updateQuickComment(t,1);case 2:case"end":return i.stop()}}),_callee17,this)})))},i.removeQuickComment=function removeQuickComment(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){return ud.wrap((function _callee18$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.extendModuleService.updateQuickComment(t,2);case 2:case"end":return i.stop()}}),_callee18,this)})))},i.getQuickComments=function getQuickComments(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){return ud.wrap((function _callee19$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},msgList:{type:"array",rules:{msgIdServer:{type:"string",allowEmpty:!1}},min:1}},t),i.next=3,this.extendModuleService.getQuickComments(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee19,this)})))},i.sendTypingEvent=function sendTypingEvent(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){return ud.wrap((function _callee20$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},ext:{type:"string",required:!1}},t),i.next=3,this.extendModuleService.sendTypingEvent(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee20,this)})))},i.getLastMessageOfChannels=function getLastMessageOfChannels(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){return ud.wrap((function _callee21$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelIdList:{type:"array",itemType:"string"}},t),i.next=3,this.messageModuleService.getLastMessageOfChannels(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee21,this)})))},i.qchatOnMsgHandler=function qchatOnMsgHandler(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee22(){return ud.wrap((function _callee22$(i){for(;;)switch(i.prev=i.next){case 0:this.messageModuleService.onMsg(t);case 1:case"end":return i.stop()}}),_callee22,this)})))},i.qchatOnRecvUnreadInfoHandler=function qchatOnRecvUnreadInfoHandler(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee23(){return ud.wrap((function _callee23$(i){for(;;)switch(i.prev=i.next){case 0:this.messageModuleService.onRecvUnreadInfo(t);case 1:case"end":return i.stop()}}),_callee23,this)})))},i.qchatOnSysMsgHandler=function qchatOnSysMsgHandler(t){this.notificationModuleService.onSysMsg(t)},i.qchatMultiSyncMessageReadHandler=function qchatMultiSyncMessageReadHandler(t){this.messageModuleService.onMultiSyncRead(t)},i.qchatMultiSyncSystemNotificationUpdateHandler=function qchatMultiSyncSystemNotificationUpdateHandler(t){this.notificationModuleService.onMultiSysMsg(t)},i.qchatSyncSystemNotificationHandler=function qchatSyncSystemNotificationHandler(t){this.notificationModuleService.onSyncSysMsg(t)},i.qchatRecvMessageUpdateHandler=function qchatRecvMessageUpdateHandler(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee24(){return ud.wrap((function _callee24$(i){for(;;)switch(i.prev=i.next){case 0:this.messageModuleService.onRecvMsgUpdate(t);case 1:case"end":return i.stop()}}),_callee24,this)})))},i.searchMsgByPage=function searchMsgByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee25(){return ud.wrap((function _callee25$(i){for(;;)switch(i.prev=i.next){case 0:return validate({keyword:{type:"string",allowEmpty:!1,required:!1},serverId:{type:"string",allowEmpty:!1,required:!0},channelId:{type:"string",allowEmpty:!1,required:!1},fromAccid:{type:"string",allowEmpty:!1,required:!1},fromTime:{type:"number",allowEmpty:!1,required:!1},toTime:{type:"number",allowEmpty:!1,required:!1},msgTypes:{type:"array",itemType:"string",allowEmpty:!1,required:!0},subTypes:{type:"array",itemType:"string",allowEmpty:!1,required:!1},includeSelf:{type:"boolean",allowEmpty:!1,required:!1},order:{type:"enum",values:getEnumKeys(JI),required:!1},limit:{type:"number",min:0,required:!1},sort:{type:"enum",values:getEnumKeys(T_),required:!1},cursor:{type:"string",allowEmpty:!1,required:!1}},t),i.next=3,this.messageModuleService.messageSearchByPage(t);case 3:return i.abrupt("return",i.sent);case 4:case"end":return i.stop()}}),_callee25,this)})))},i.qchatMultiSyncServersMessageReadHandler=function qchatMultiSyncServersMessageReadHandler(t){this.messageModuleService.onMultiSyncServersRead(t)},QChatMsgService}(t_),fS=function(){function CategoryModuleService(t){this.core=t}var t=CategoryModuleService.prototype;return t.addChannelCategoryRole=function addChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},parentRoleId:{type:"string",allowEmpty:!1}},t),u.next=3,this.core.sendCmd("qchatAddChannelCategoryRole",{qchatAddChannelCategoryRoleTag:t});case 3:return i=u.sent,u.abrupt("return",formatChannelCategoryRole(i.content.channelCategoryRole));case 5:case"end":return u.stop()}}),_callee,this)})))},t.removeChannelCategoryRole=function removeChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatRemoveChannelCategoryRole",t);case 3:case"end":return i.stop()}}),_callee2,this)})))},t.updateChannelCategoryRole=function updateChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1},auths:{type:"object"}},t),u.next=3,this.core.sendCmd("qchatUpdateChannelCategoryRole",{qchatUpdateChannelCategoryRoleTag:generatorRoleForCmd(t)});case 3:if(406!==(i=u.sent).raw.code){u.next=6;break}throw new ed("No update required",{},406);case 6:return u.abrupt("return",formatChannelCategoryRole(i.content.channelCategoryRole));case 7:case"end":return u.stop()}}),_callee3,this)})))},t.getChannelCategoryRole=function getChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},timetag:{type:"number",min:0,required:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetChannelCategoryRole",{qchatGetChannelCategoryRoleTag:t});case 3:return i=u.sent,u.abrupt("return",(m=i.content.list,Dn(m)&&m.length>0?map$6(m).call(m,(function(t){return formatChannelCategoryRole(t)})):[]));case 5:case"end":return u.stop()}var m}),_callee4,this)})))},t.addChannelCategoryMemberRole=function addChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i;return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1}},t),u.next=3,this.core.sendCmd("qchatAddChannelCategoryMemberRole",{qchatAddChannelCategoryMemberRoleTag:t});case 3:return i=u.sent,u.abrupt("return",formatChannelCategoryMemberRole(i.content.channelCategoryMemberRole));case 5:case"end":return u.stop()}}),_callee5,this)})))},t.removeChannelCategoryMemberRole=function removeChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){return ud.wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatRemoveChannelCategoryMemberRole",t);case 3:case"end":return i.stop()}}),_callee6,this)})))},t.updateChannelCategoryMemberRole=function updateChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){var i;return ud.wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1},auths:{type:"object"}},t),u.next=3,this.core.sendCmd("qchatUpdateChannelCategoryMemberRole",{qchatUpdateChannelCategoryMemberRoleTag:generatorRoleForCmd(t)});case 3:if(406!==(i=u.sent).raw.code){u.next=6;break}throw new ed("No update required",{},406);case 6:return u.abrupt("return",formatChannelCategoryMemberRole(i.content.channelCategoryMemberRole));case 7:case"end":return u.stop()}}),_callee7,this)})))},t.getChannelCategoryMemberRole=function getChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i;return ud.wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},categoryId:{type:"string",allowEmpty:!1},timetag:{type:"number",min:0,required:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetChannelCategoryMemberRole",{qchatGetChannelCategoryMemberRoleTag:t});case 3:return i=u.sent,u.abrupt("return",(m=i.content.list,Dn(m)&&m.length>0?map$6(m).call(m,(function(t){return formatChannelCategoryMemberRole(t)})):[]));case 5:case"end":return u.stop()}var m}),_callee8,this)})))},CategoryModuleService}(),yS=function(t){function QChatRoleService(i){var u;return(u=t.call(this,"qchatRole",i)||this).core=i,registerParser({cmdMap:Z_,cmdConfig:rS()}),u.category=new fS(i),u}Nt(QChatRoleService,t);var i=QChatRoleService.prototype;return i.createServerRole=function createServerRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},name:{type:"string",allowEmpty:!1},priority:{type:"number",min:1},icon:{type:"string",required:!1},ext:{type:"string",required:!1}},t),u.next=3,this.core.sendCmd("qchatCreateServerRole",{serverRole:Dt(Dt({},generatorRoleForCmd(t)),{type:f_.custom}),antispamTag:generateAntispamTag(t)});case 3:return i=u.sent,u.abrupt("return",formatRole(i.content.serverRole));case 5:case"end":return u.stop()}}),_callee,this)})))},i.updateServerRole=function updateServerRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i;return ud.wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1},name:{type:"string",required:!1},icon:{type:"string",required:!1},ext:{type:"string",required:!1},priority:{type:"number",required:!1},auths:{type:"object",required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateServerRole",{updateServerRoleTag:generatorRoleForCmd(t),antispamTag:generateAntispamTag(t)});case 3:return i=u.sent,u.abrupt("return",formatRole(i.content.serverRole));case 5:case"end":return u.stop()}}),_callee2,this)})))},i.deleteServerRole=function deleteServerRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatDeleteServerRole",t);case 3:case"end":return i.stop()}}),_callee3,this)})))},i.getServerRoles=function getServerRoles(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m;return ud.wrap((function _callee4$(h){for(;;)switch(h.prev=h.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1,required:!1},categoryId:{type:"string",allowEmpty:!1,required:!1},limit:{type:"number",min:1,required:!1},priority:{type:"number",required:!1}},t),h.next=3,this.core.sendCmd("qchatGetServerRoles",{getServerRolesTag:generatorRoleForCmd(t)});case 3:return u=h.sent,m=filter(i=u.content.serverRoles).call(i,(function(t){return 1===Gd(t.isMember)})),m=map$6(m).call(m,(function(t){return t.roleId})),h.abrupt("return",{roles:formatRoles(u.content.serverRoles),isMemberRoles:m});case 7:case"end":return h.stop()}}),_callee4,this)})))},i.addChannelRole=function addChannelRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i;return ud.wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},parentRoleId:{type:"string",allowEmpty:!1}},t),u.next=3,this.core.sendCmd("qchatAddChannelRole",{channelRole:generatorRoleForCmd(t)});case 3:return i=u.sent,u.abrupt("return",formatRole(i.content.channelRole));case 5:case"end":return u.stop()}}),_callee5,this)})))},i.getChannelRoles=function getChannelRoles(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i;return ud.wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},timetag:{type:"number",required:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetChannelRoles",{getChannelRolesTag:t});case 3:return i=u.sent,u.abrupt("return",formatRoles(i.content.channelRoles));case 5:case"end":return u.stop()}}),_callee6,this)})))},i.removeChannelRole=function removeChannelRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatRemoveChannelRole",t);case 3:case"end":return i.stop()}}),_callee7,this)})))},i.updateChannelRole=function updateChannelRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var i;return ud.wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1},auths:{type:"object",required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateChannelRole",{updateChannelRoleTag:generatorRoleForCmd(t)});case 3:if(406!==(i=u.sent).raw.code){u.next=6;break}throw new ed("No update required",{},406);case 6:return u.abrupt("return",formatRole(i.content.channelRole));case 7:case"end":return u.stop()}}),_callee8,this)})))},i.addMemberRole=function addMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var i;return ud.wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1}},t),u.next=3,this.core.sendCmd("qchatAddMemberRole",{memberRole:t});case 3:return i=u.sent,u.abrupt("return",formatRole(i.content.memberRole));case 5:case"end":return u.stop()}}),_callee9,this)})))},i.getMemberRoles=function getMemberRoles(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){var i;return ud.wrap((function _callee10$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},timetag:{type:"number",required:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetMemberRoles",{getMemberRolesTag:t});case 3:return i=u.sent,u.abrupt("return",formatRoles(i.content.memberRoles));case 5:case"end":return u.stop()}}),_callee10,this)})))},i.removeMemberRole=function removeMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1}},t),i.next=3,this.core.sendCmd("qchatRemoveMemberRole",{memberRole:t});case 3:case"end":return i.stop()}}),_callee11,this)})))},i.updateMemberRole=function updateMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){var i;return ud.wrap((function _callee12$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1},auths:{type:"object",required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateMemberRole",{updateMemberRoleTag:generatorRoleForCmd(t)});case 3:if(406!==(i=u.sent).raw.code){u.next=6;break}throw new ed("No update required",{},406);case 6:return u.abrupt("return",formatRole(i.content.memberRole));case 7:case"end":return u.stop()}}),_callee12,this)})))},i.addMembersToServerRole=function addMembersToServerRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i,u,m;return ud.wrap((function _callee13$(h){for(;;)switch(h.prev=h.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1},accids:{type:"array",itemType:"string",min:1}},t),h.next=3,this.core.sendCmd("qchatAddMembersToServerRole",Dt(Dt({},t),{accids:Un(t.accids)}));case 3:return i=h.sent,u=get(i,"content.accids.successAccids"),m=get(i,"content.accids.failedAccids"),h.abrupt("return",{successAccids:u?JSON.parse(u):[],failedAccids:m?JSON.parse(m):[]});case 7:case"end":return h.stop()}}),_callee13,this)})))},i.removeMembersFromServerRole=function removeMembersFromServerRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var i,u,m;return ud.wrap((function _callee14$(h){for(;;)switch(h.prev=h.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1},accids:{type:"array",itemType:"string",min:1}},t),h.next=3,this.core.sendCmd("qchatRemoveMembersFromServerRole",Dt(Dt({},t),{accids:Un(t.accids)}));case 3:return i=h.sent,u=get(i,"content.accids.successAccids"),m=get(i,"content.accids.failedAccids"),h.abrupt("return",{successAccids:u?JSON.parse(u):[],failedAccids:m?JSON.parse(m):[]});case 7:case"end":return h.stop()}}),_callee14,this)})))},i.getMembersFromServerRole=function getMembersFromServerRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){var i;return ud.wrap((function _callee15$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1},timetag:{type:"number",required:!1},accid:{type:"string",allowEmpty:!1,required:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetMembersFromServerRole",{getMembersFromServerRoleTag:t});case 3:return i=u.sent,u.abrupt("return",formatRoles(i.content.members));case 5:case"end":return u.stop()}}),_callee15,this)})))},i.getServerRolesByAccid=function getServerRolesByAccid(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i;return ud.wrap((function _callee16$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1},timetag:{type:"number",required:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetServerRolesByAccid",{getServerRolesByAccidTag:t});case 3:return i=u.sent,u.abrupt("return",formatRoles(i.content.serverRoles));case 5:case"end":return u.stop()}}),_callee16,this)})))},i.getExistingServerRolesByAccids=function getExistingServerRolesByAccids(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){var i,u,m;return ud.wrap((function _callee17$(h){for(;;)switch(h.prev=h.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},accids:{type:"array",itemType:"string"}},t),h.next=3,this.core.sendCmd("qchatGetExistingServerRolesByAccids",{serverId:t.serverId,accids:Un(t.accids)});case 3:return i=h.sent,h.prev=4,m=JSON.parse(i.content.serverRoles),forEach$1(u=Ht(m)).call(u,(function(t){var i;forEach$1(i=m[t]).call(i,(function(i,u){m[t][u]=deserialize(i,tS().serverRole)})),m[t]=formatRoles(m[t])})),h.abrupt("return",m);case 10:throw h.prev=10,h.t0=h.catch(4),this.logger.error("can not parse serverRolesGroupByAccid from "+t.serverId+" and "+t.accids,i.content.serverRoles),h.t0;case 14:case"end":return h.stop()}}),_callee17,this,[[4,10]])})))},i.getExistingChannelRolesByServerRoleIds=function getExistingChannelRolesByServerRoleIds(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){var i;return ud.wrap((function _callee18$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},roleIds:{type:"array",itemType:"string"}},t),u.next=3,this.core.sendCmd("qchatGetExistingChannelRolesByServerRoleIds",{serverId:t.serverId,channelId:t.channelId,roleIds:Un(t.roleIds)});case 3:return i=u.sent,u.abrupt("return",formatRoles(i.content.channelRoles));case 5:case"end":return u.stop()}}),_callee18,this)})))},i.getExistingAccidsOfMemberRoles=function getExistingAccidsOfMemberRoles(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){var i,u;return ud.wrap((function _callee19$(m){for(;;)switch(m.prev=m.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1},accids:{type:"array",itemType:"string"}},t),m.next=3,this.core.sendCmd("qchatGetExistingAccidsOfMemberRoles",{serverId:t.serverId,channelId:t.channelId,accids:Un(t.accids)});case 3:return i=m.sent,u=i.content.memberRoles,m.abrupt("return",u&&u.length>0?map$6(u).call(u,(function(t){return t.accid})):[]);case 6:case"end":return m.stop()}}),_callee19,this)})))},i.getExistingAccidsInServerRole=function getExistingAccidsInServerRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){var i,u;return ud.wrap((function _callee20$(m){for(;;)switch(m.prev=m.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},roleId:{type:"string",allowEmpty:!1},accids:{type:"array",itemType:"string"}},t),m.next=3,this.core.sendCmd("qchatGetExistingAccidsInServerRole",{serverId:t.serverId,roleId:t.roleId,accids:Un(t.accids)});case 3:return i=m.sent,u=i.content.members,m.abrupt("return",u&&u.length>0?map$6(u).call(u,(function(t){return t.accid})):[]);case 6:case"end":return m.stop()}}),_callee20,this)})))},i.updateServerRolePriorities=function updateServerRolePriorities(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){var i,u;return ud.wrap((function _callee21$(m){for(;;)switch(m.prev=m.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},serverRoles:{type:"array"}},t),m.next=3,this.core.sendCmd("qchatUpdateServerRolePriorities",{serverId:t.serverId,serverRoles:map$6(i=t.serverRoles).call(i,(function(t){return{serverId:t.serverId,roleId:t.roleId,priority:t.priority}}))});case 3:return u=m.sent,m.abrupt("return",formatRoles(u.content.serverRoles));case 5:case"end":return m.stop()}}),_callee21,this)})))},i.checkPermission=function checkPermission(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee22(){var i;return ud.wrap((function _callee22$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1,required:!1},auth:{type:"string"}},t),u.next=3,this.core.sendCmd("qchatCheckPermission",{checkPermissionTag:Dt(Dt({},t),{auth:I_[t.auth]||t.auth})});case 3:return i=u.sent,u.abrupt("return",i.content.checked);case 5:case"end":return u.stop()}}),_callee22,this)})))},i.addChannelCategoryRole=function addChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee23(){return ud.wrap((function _callee23$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.addChannelCategoryRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee23,this)})))},i.removeChannelCategoryRole=function removeChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee24(){return ud.wrap((function _callee24$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.removeChannelCategoryRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee24,this)})))},i.updateChannelCategoryRole=function updateChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee25(){return ud.wrap((function _callee25$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.updateChannelCategoryRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee25,this)})))},i.getChannelCategoryRole=function getChannelCategoryRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee26(){return ud.wrap((function _callee26$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.getChannelCategoryRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee26,this)})))},i.addChannelCategoryMemberRole=function addChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee27(){return ud.wrap((function _callee27$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.addChannelCategoryMemberRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee27,this)})))},i.removeChannelCategoryMemberRole=function removeChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee28(){return ud.wrap((function _callee28$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.removeChannelCategoryMemberRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee28,this)})))},i.updateChannelCategoryMemberRole=function updateChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee29(){return ud.wrap((function _callee29$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.updateChannelCategoryMemberRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee29,this)})))},i.getChannelCategoryMemberRole=function getChannelCategoryMemberRole(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee30(){return ud.wrap((function _callee30$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.category.getChannelCategoryMemberRole(t);case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),_callee30,this)})))},i.checkPermissions=function checkPermissions(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee31(){var i,u,m,h;return ud.wrap((function _callee31$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},channelId:{type:"string",allowEmpty:!1,required:!1},auths:{type:"array",itemType:"string"}},t),this.core.logger.log("qchatRole::checkPermission options is",t),v.next=4,this.core.sendCmd("qchatCheckPermissions",{checkPermissionsTag:Dt(Dt({},t),{auths:Un(map$6(i=t.auths).call(i,(function(t){return I_[t]||t})))})});case 4:return m=v.sent,this.core.logger.log("qchatRole::checkPermission result is",m.content),h={},forEach$1(u=m.content.checkPermissionsResult).call(u,(function(t){h[t.auth]=t.isAllow})),this.core.logger.log("qchatRole::checkPermission auths is",h),v.abrupt("return",formatRoleAuths(h));case 10:case"end":return v.stop()}}),_callee31,this)})))},QChatRoleService}(t_);function _createForOfIteratorHelperLoose(t,i){var u,m=void 0!==es&&od(t)||t["@@iterator"];if(m)return bind$1(u=(m=m.call(t)).next).call(u,m);if(Dn(t)||(m=function _unsupportedIterableToArray(t,i){if(t){var u;if("string"==typeof t)return _arrayLikeToArray(t,i);var m=slice(u={}.toString.call(t)).call(u,8,-1);return"Object"===m&&t.constructor&&(m=t.constructor.name),"Map"===m||"Set"===m?id(t):"Arguments"===m||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m)?_arrayLikeToArray(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){m&&(t=m);var h=0;return function(){return h>=t.length?{done:!0}:{done:!1,value:t[h++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _arrayLikeToArray(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,m=Array(i);u<i;u++)m[u]=t[u];return m}var MS=function(t){function QChatServerService(i){var u;return(u=t.call(this,"qchatServer",i)||this).core=i,registerParser({cmdMap:Y_,cmdConfig:X_()}),u}Nt(QChatServerService,t);var i=QChatServerService.prototype;return i.createServer=function createServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return validate({icon:{type:"string",required:!1},name:{type:"string",required:!1},ext:{type:"string",required:!1},searchType:{type:"number",required:!1,min:0},searchEnable:{type:"boolean",required:!1},inviteMode:{type:"number",min:0,max:1,required:!1},applyMode:{type:"number",min:0,max:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatCreateServer",{serverInfo:Dt(Dt({},t),{searchEnable:!1===t.searchEnable?0:1}),antispamTag:generateAntispamTag(t)});case 3:return i=u.sent,u.abrupt("return",formatServer(i.content.serverInfo));case 5:case"end":return u.stop()}}),_callee,this)})))},i.deleteServer=function deleteServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1}},t),i.next=3,this.core.sendCmd("qchatDeleteServer",t);case 3:case"end":return i.stop()}}),_callee2,this)})))},i.updateServer=function updateServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",min:1},icon:{type:"string",required:!1},name:{type:"string",required:!1},ext:{type:"string",required:!1},searchType:{type:"number",required:!1,min:0},searchEnable:{type:"boolean",required:!1},inviteMode:{type:"number",min:0,max:1,required:!1},applyMode:{type:"number",min:0,max:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateServer",{serverInfo:Dt(Dt({},t),{searchEnable:!1===t.searchEnable?0:1}),antispamTag:generateAntispamTag(t)});case 3:return i=u.sent,u.abrupt("return",formatServer(i.content.serverInfo));case 5:case"end":return u.stop()}}),_callee3,this)})))},i.getServers=function getServers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverIds:{type:"array",itemType:"string",min:1}},t),u.next=3,this.core.sendCmd("qchatGetServers",t);case 3:return i=u.sent,u.abrupt("return",formatServers(i.content.serverList));case 5:case"end":return u.stop()}}),_callee4,this)})))},i.getServersByPage=function getServersByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){var i,u,m,h;return ud.wrap((function _callee5$(v){for(;;)switch(v.prev=v.next){case 0:return validate({timestamp:{type:"number"},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetServersByPage",{tag:t});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatServers(m)});case 6:case"end":return v.stop()}}),_callee5,this)})))},i.inviteServerMembers=function inviteServerMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var i,u;return ud.wrap((function _callee6$(m){for(;;)switch(m.prev=m.next){case 0:return validate({serverId:{type:"string",min:1},accids:{type:"array",itemType:"string",min:1},ps:{type:"string"},params:{type:"object",rules:{ttl:{type:"number"}},required:!1}},t),m.next=3,this.core.sendCmd("qchatInviteServerMembers",t);case 3:return i=m.sent,u=i.content.record||{},m.abrupt("return",{failByOverAccids:i.content.failByOverAccids,failByBanAccids:i.content.failByBanAccids,recordInfo:formatInviteApplyRecord(u)});case 6:case"end":return m.stop()}}),_callee6,this)})))},i.acceptServerInvite=function acceptServerInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1},recordInfo:{type:"object",rules:{requestId:{type:"string",allowEmpty:!1}}}},t),i.next=3,this.core.sendCmd("qchatAcceptServerInvite",t);case 3:case"end":return i.stop()}}),_callee7,this)})))},i.rejectInviteServer=function rejectInviteServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){return ud.wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1},accid:{type:"string",min:1},ps:{type:"string"},recordInfo:{type:"object",rules:{requestId:{type:"string",allowEmpty:!1}}}},t),i.next=3,this.core.sendCmd("qchatRejectInviteServer",t);case 3:case"end":return i.stop()}}),_callee8,this)})))},i.applyServerJoin=function applyServerJoin(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var i;return ud.wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",min:1},ps:{type:"string"},params:{type:"object",rules:{ttl:{type:"number"}},required:!1}},t),u.next=3,this.core.sendCmd("qchatApplyServerJoin",t);case 3:return i=u.sent,u.abrupt("return",formatInviteApplyRecord(i.content.data));case 5:case"end":return u.stop()}}),_callee9,this)})))},i.acceptServerApply=function acceptServerApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){return ud.wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1},accid:{type:"string",min:1},recordInfo:{type:"object",rules:{requestId:{type:"string",allowEmpty:!1}}}},t),i.next=3,this.core.sendCmd("qchatAcceptServerApply",t);case 3:case"end":return i.stop()}}),_callee10,this)})))},i.rejectServerApply=function rejectServerApply(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1},accid:{type:"string",min:1},ps:{type:"string"},recordInfo:{type:"object",rules:{requestId:{type:"string",allowEmpty:!1}}}},t),i.next=3,this.core.sendCmd("qchatRejectServerApply",t);case 3:case"end":return i.stop()}}),_callee11,this)})))},i.kickServerMembers=function kickServerMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1},accids:{type:"array",itemType:"string",min:1}},t),i.next=3,this.core.sendCmd("qchatKickServerMembers",t);case 3:case"end":return i.stop()}}),_callee12,this)})))},i.leaveServer=function leaveServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){return ud.wrap((function _callee13$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",min:1}},t),i.next=3,this.core.sendCmd("qchatLeaveServer",t);case 3:case"end":return i.stop()}}),_callee13,this)})))},i.updateMyMemberInfo=function updateMyMemberInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var i;return ud.wrap((function _callee14$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",min:1},accid:{type:"string",required:!1},nick:{type:"string",allowEmpty:!0,required:!1},avatar:{type:"string",required:!1},ext:{type:"string",required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateMyMemberInfo",{memberInfo:t,antispamTag:generateAntispamTag(t)});case 3:return i=u.sent,u.abrupt("return",formatMember$1(i.content.memberInfo));case 5:case"end":return u.stop()}}),_callee14,this)})))},i.updateServerMemberInfo=function updateServerMemberInfo(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee15(){var i;return ud.wrap((function _callee15$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",min:1},accid:{type:"string",min:1},nick:{type:"string",required:!1},avatar:{type:"string",required:!1}},t),u.next=3,this.core.sendCmd("qchatUpdateServerMemberInfo",{memberInfo:t,antispamTag:generateAntispamTag(t)});case 3:return i=u.sent,u.abrupt("return",formatMember$1(i.content.memberInfo));case 5:case"end":return u.stop()}}),_callee15,this)})))},i.getServerMembers=function getServerMembers(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee16(){var i,u,m,h,v;return ud.wrap((function _callee16$(M){for(;;)switch(M.prev=M.next){case 0:if(validate({accids:{type:"array"}},t),i=[],t.accids.length)for(u=_createForOfIteratorHelperLoose(t.accids);!(m=u()).done;)h=m.value,i.push(h.serverId+"|"+h.accid);return M.next=5,this.core.sendCmd("qchatGetServerMembers",{accids:i});case 5:return v=M.sent,M.abrupt("return",formatMembers$1(v.content.accidList));case 7:case"end":return M.stop()}}),_callee16,this)})))},i.getServerMembersByPage=function getServerMembersByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee17(){var i,u,m,h;return ud.wrap((function _callee17$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",min:1},timetag:{type:"number"},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetServerMembersByPage",{tag:t});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatMembers$1(m)});case 6:case"end":return v.stop()}}),_callee17,this)})))},i.subscribeServer=function subscribeServer(t){var i,u,m,h;return __awaiter(this,void 0,void 0,ud.mark((function _callee18(){var v,M,I,S;return ud.wrap((function _callee18$(T){for(;;)switch(T.prev=T.next){case 0:if(validate({type:{type:"number",min:4,max:4,required:!1},opeType:{type:"number",min:1,max:2}},t),!(null===(u=null===(i=this.core.qchatChannel)||void 0===i?void 0:i.config)||void 0===u?void 0:u.autoSubscribe)||t.isInternalTrigger){T.next=3;break}throw new ed("subscribe server failed, manual subscribe is not allowed in auto subscribe mode",{},403);case 3:if(t.type||(t.type=4),!t.servers.length){T.next=12;break}return M=Dt(Dt({},t),{channels:map$6(v=t.servers).call(v,(function(t){return{serverId:t.serverId,channelId:""}}))}),T.next=8,this.core.qchatChannel.subscribeModuleService.subscribe(M);case 8:return I=T.sent,S=I.failedChannels,(null===(h=null===(m=this.core.qchatChannel)||void 0===m?void 0:m.config)||void 0===h?void 0:h.autoSubscribe)?this.core.qchatChannel.subscribeModuleService.cacheAutoSubscribe(M):this.core.qchatChannel.subscribeModuleService.cacheSubscribe(M),T.abrupt("return",{failedServers:S});case 12:case"end":return T.stop()}}),_callee18,this)})))},i.banServerMember=function banServerMember(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee19(){return ud.wrap((function _callee19$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1},ext:{type:"string",required:!1}},t),i.next=3,this.core.sendCmd("qchatUpdateServerMemberBan",{tag:Dt(Dt({},t),{opeType:1})});case 3:case"end":return i.stop()}}),_callee19,this)})))},i.unbanServerMember=function unbanServerMember(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee20(){return ud.wrap((function _callee20$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},accid:{type:"string",allowEmpty:!1},ext:{type:"string",required:!1}},t),i.next=3,this.core.sendCmd("qchatUpdateServerMemberBan",{tag:Dt(Dt({},t),{opeType:2})});case 3:case"end":return i.stop()}}),_callee20,this)})))},i.getBannedMembersByPage=function getBannedMembersByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee21(){var i,u,m,h;return ud.wrap((function _callee21$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},timetag:{type:"number",min:0},limit:{type:"number",min:1,required:!1}},t),v.next=3,this.core.sendCmd("qchatGetBannedMembersByPage",{tag:t});case 3:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag)},datas:formatServerMemberBanInfos(m)});case 6:case"end":return v.stop()}}),_callee21,this)})))},i.serverSearchByPage=function serverSearchByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee22(){var i,u,m,h;return ud.wrap((function _callee22$(v){for(;;)switch(v.prev=v.next){case 0:if(validate({keyword:{type:"string",allowEmpty:!1},startTime:{type:"number",min:0,required:!1},endTime:{type:"number",min:0,required:!1},limit:{type:"number",min:1,required:!1},serverType:{type:"array",itemType:"number",min:0,required:!1},order:{type:"enum",values:getEnumKeys(JI),required:!1},searchType:{type:"enum",values:getEnumKeys(ZI)},sort:{type:"enum",values:getEnumKeys(XI),required:!1},cursor:{type:"string",allowEmpty:!1,required:!1}},t),!(t.startTime&&t.endTime&&t.startTime>=t.endTime)){v.next=3;break}throw new Ql("startTime more than endTime",t,"timeRule");case 3:return v.next=5,this.core.sendCmd("qchatServerSearchByPage",{tag:Dt(Dt({},t),{order:t.order&&JI[t.order],searchType:ZI[t.searchType],sort:sort(t)&&XI[sort(t)],serverType:Un(t.serverType)})});case 5:return i=v.sent,u=i.content,m=u.datas,h=u.listQueryTag,v.abrupt("return",{listQueryTag:{hasMore:1==+h.hasMore,nextTimetag:Gd(h.nextTimetag),cursor:h.cursor},datas:formatServers(m)});case 8:case"end":return v.stop()}}),_callee22,this)})))},i.serverMemberSearchByPage=function serverMemberSearchByPage(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee23(){var i;return ud.wrap((function _callee23$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},keyword:{type:"string",allowEmpty:!1},limit:{type:"number",min:1,required:!1}},t),u.next=3,this.core.sendCmd("qchatServerMemberSearchByPage",{tag:t});case 3:return i=u.sent,u.abrupt("return",formatMembers$1(i.content.members));case 5:case"end":return u.stop()}}),_callee23,this)})))},i.generateInviteCode=function generateInviteCode(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee24(){var i;return ud.wrap((function _callee24$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},ttl:{type:"number",min:0,required:!1}},t),u.next=3,this.core.sendCmd("qchatGenerateInviteCode",{tag:t});case 3:return i=u.sent,u.abrupt("return",format({expireTime:{type:"number"}},i.content.data));case 5:case"end":return u.stop()}}),_callee24,this)})))},i.joinByInviteCode=function joinByInviteCode(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee25(){return ud.wrap((function _callee25$(i){for(;;)switch(i.prev=i.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},inviteCode:{type:"string",allowEmpty:!1},ps:{type:"string",required:!1}},t),i.next=3,this.core.sendCmd("qchatJoinByInviteCode",{tag:t});case 3:case"end":return i.stop()}}),_callee25,this)})))},i.getInviteApplyRecordOfServer=function getInviteApplyRecordOfServer(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee26(){var i;return ud.wrap((function _callee26$(u){for(;;)switch(u.prev=u.next){case 0:return validate({serverId:{type:"string",allowEmpty:!1},fromTime:{type:"number",min:0},toTime:{type:"number",min:0},reverse:{type:"boolean",required:!1},limit:{type:"number",min:1,required:!1},cursor:{type:"string",allowEmpty:!1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetInviteApplyRecordOfServer",{tag:Dt(Dt({},t),{reverse:reverse$1(t)?1:0})});case 3:return i=u.sent,u.abrupt("return",formatInviteApplyRecords(i.content.data));case 5:case"end":return u.stop()}}),_callee26,this)})))},i.getInviteApplyRecordOfSelf=function getInviteApplyRecordOfSelf(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee27(){var i;return ud.wrap((function _callee27$(u){for(;;)switch(u.prev=u.next){case 0:return validate({fromTime:{type:"number",min:0},toTime:{type:"number",min:0},reverse:{type:"boolean",required:!1},limit:{type:"number",min:1,required:!1},cursor:{type:"string",allowEmpty:!1,required:!1}},t),u.next=3,this.core.sendCmd("qchatGetInviteApplyRecordOfSelf",{tag:Dt(Dt({},t),{reverse:reverse$1(t)?1:0})});case 3:return i=u.sent,u.abrupt("return",formatInviteApplyRecords(i.content.data));case 5:case"end":return u.stop()}}),_callee27,this)})))},i.markRead=function markRead(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee28(){var i,u,m,h;return ud.wrap((function _callee28$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverIds:{type:"array",itemType:"string",required:!0}},t),v.next=3,this.core.sendCmd("qchatClearServersUnread",t);case 3:return i=v.sent,u=formatClearServersUnread(i.content.clearServersUnreadTag),m=u.successServerIds,h=u.ackTimestamp,this.logger.log("qchatServer::clearServersUnread:: begin auto clear servers unreadInfo"),this.core.eventBus.emit("qchatChannel/clearUnreadCountByServers",m,h),v.abrupt("return",u);case 9:case"end":return v.stop()}}),_callee28,this)})))},i.subscribeAllChannel=function subscribeAllChannel(t){var i,u;return __awaiter(this,void 0,void 0,ud.mark((function _callee29(){var m,h,v;return ud.wrap((function _callee29$(M){for(;;)switch(M.prev=M.next){case 0:if(validate({type:{type:"number",required:!0},serverIds:{type:"array",itemType:"string",required:!0,max:10}},t),!(null===(u=null===(i=this.core.qchatChannel)||void 0===i?void 0:i.config)||void 0===u?void 0:u.autoSubscribe)){M.next=3;break}throw new ed("subscribe channel failed, manual subscribe is not allowed in auto subscribe mode.",{},403);case 3:return M.next=5,this.core.sendCmd("qchatSubscribeChannelsByServers",t,{timeout:3e4});case 5:return(h=M.sent).content.unreadInfos=formatUnreadInfos(h.content.unreadInfos),h.content.failServerIds=formatFailServerIds(h.content.failServerIds),v={type:t.type,opeType:1,channels:map$6(m=h.content.unreadInfos).call(m,(function(t){return{serverId:t.serverId,channelId:t.channelId}}))},this.core.eventBus.emit("qchatChannel/cacheSubscribe",v),this.core.eventBus.emit("qchatChannel/getRoleIdsByServerId",t.serverIds),this.core.eventBus.emit("qchatChannel/updateUnreads",h.content.unreadInfos),M.abrupt("return",h.content);case 13:case"end":return M.stop()}}),_callee29,this)})))},i.enterAsVisitor=function enterAsVisitor(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee30(){var i,u,m;return ud.wrap((function _callee30$(h){for(;;)switch(h.prev=h.next){case 0:return validate({serverIds:{type:"array",itemType:"string",min:1}},t),h.next=3,this.core.sendCmd("qchatEnterAsVisitor",{tag:{serverIds:Un(t.serverIds)}});case 3:return i=h.sent,u=formatFailServerIds(i.content.failServerIds),m=difference(t.serverIds,u),this.core.qchatChannel.subscribeForVisitorService.cacheServer(m),h.abrupt("return",{failedServers:u});case 8:case"end":return h.stop()}}),_callee30,this)})))},i.leaveAsVisitor=function leaveAsVisitor(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee31(){var i,u,m,h=this;return ud.wrap((function _callee31$(v){for(;;)switch(v.prev=v.next){case 0:return validate({serverIds:{type:"array",itemType:"string",min:1}},t),v.next=3,this.core.sendCmd("qchatLeaveAsVisitor",{tag:{serverIds:Un(t.serverIds)}});case 3:return i=v.sent,u=formatFailServerIds(i.content.failServerIds),m=difference(t.serverIds,u),forEach$1(m).call(m,(function(t){h.core.qchatChannel.subscribeForVisitorService.deleteServer(t)})),v.abrupt("return",{failedServers:u});case 8:case"end":return v.stop()}}),_callee31,this)})))},i.subscribeAsVisitor=function subscribeAsVisitor(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee32(){return ud.wrap((function _callee32$(i){for(;;)switch(i.prev=i.next){case 0:if(validate({opeType:{type:"number",min:1,max:2},type:{type:"number",required:!1},serverIds:{type:"array",itemType:"string",min:1}},t),!t.serverIds.length){i.next=5;break}return i.next=4,this.core.qchatChannel.subscribeForVisitorService.subscribeServerAsVisitor(t);case 4:return i.abrupt("return",i.sent);case 5:return i.abrupt("return",{failedServers:[]});case 6:case"end":return i.stop()}}),_callee32,this)})))},QChatServerService}(t_),IS=function(t){function V2NIMNotificationServiceImpl(i,u){var m;return(m=t.call(this,"V2NIMNotificationService",i)||this).config={compatibleWithV1:!0},m.notificationUtil=new Dh(m.core),m.core._registerDep(mm,"V2NIMConversationIdUtil"),"v2"!==m.core.options.apiVersion?Je(m):(registerParser({cmdMap:wh,cmdConfig:Oh}),m.setOptions(u),m)}Nt(V2NIMNotificationServiceImpl,t);var i=V2NIMNotificationServiceImpl.prototype;return i.setOptions=function setOptions(t){var i;(null===(i=this.core.systemMessage)||void 0===i?void 0:i.name)?this.config.compatibleWithV1=!0:this.config.compatibleWithV1=!1,this.config=Dt(this.config,t)},i.emit=function emit(i){for(var u,m,h=this.name+"::emit "+i.toString(),v=arguments.length,M=new Array(v>1?v-1:0),I=1;I<v;I++)M[I-1]=arguments[I];if("onReceiveCustomNotifications"===i){var S=M[0];this.logger.log(""+h,map$6(S).call(S,(function(t){return"sender:"+t.senderId+";receiver:"+t.receiverId+";ctype:"+t.conversationType+";time:"+t.timestamp})))}else if("onReceiveBroadcastNotifications"===i){var T=M[0];this.logger.log(""+h,map$6(T).call(T,(function(t){return"id:"+t.id+";sender:"+t.senderId+";time:"+t.timestamp})))}else{var C,E;(C=this.logger).log.apply(C,concat(E=[""+h]).call(E,M))}return(u=t.prototype.emit).call.apply(u,concat(m=[this,i]).call(m,M))},i.sendCustomNotification=function sendCustomNotification(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var m,h,v;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:return this.checkV2(),validateConversationId(this.core.account,t),validate(Uh,{content:i,params:u},"",!0),m=this.core.V2NIMConversationIdUtil.parseConversationType(t),h=3===m?"v2SendCustomNotificationWithSuperTeam":"v2SendCustomNotification",v=this.notificationUtil.generateNotificationTag(t,i,u),M.next=8,this.core.sendCmd(h,{tag:v});case 8:case"end":return M.stop()}}),_callee,this)})))},i.processSystemNotification=function processSystemNotification(t){var i=[0,1,2,3,4,15,16,17,18],u=[5,6],m=t.type;if(includes(i).call(i,m))this.core.eventBus.emit("V2NIMTeamService/sysNotification",t);else{if(!includes(u).call(u,m)){var h=Dt(Dt({},t),{conversationType:{100:1,101:2,102:1,103:3}[m]});return delete h.type,h}this.core.eventBus.emit("V2NIMFriendService/sysNotification",t)}},i.markBroadcastMsgAck=function markBroadcastMsgAck(t){this.config.compatibleWithV1||this.core.sendCmd("v2BatchMarkRead",{sid:7,cid:17,ids:map$6(t).call(t,(function(t){return t.id}))})},i.syncBroadcastMsgHandler=function syncBroadcastMsgHandler(t){var i=this,u=t.content.datas;this.markBroadcastMsgAck(u),forEach$1(u).call(u,(function(t){i.core.eventBus.emit("V2NIMSync/updateTimetag",{broadcastMsgs:Gd(t.id)})})),this.emit("onReceiveBroadcastNotifications",u)},i.onBroadcastMsgHandler=function onBroadcastMsgHandler(t){var i=t.content.data;this.markBroadcastMsgAck([i]),this.core.eventBus.emit("V2NIMSync/updateTimetag",{broadcastMsgs:Gd(i.id)}),this.emit("onReceiveBroadcastNotifications",[i])},i.onSysNotificationHandler=function onSysNotificationHandler(t){var i=fillIdServer(t,t.content.data,"idServer");this.markSysNotificationAck([i]);var u=this.processSystemNotification(i);u&&this.emit("onReceiveCustomNotifications",[u])},i.v2SyncOfflineSysNotificationsHandler=function v2SyncOfflineSysNotificationsHandler(t){var i,u,m,h=this;this.markSysNotificationAck(t.content.datas);var v=filter(i=map$6(u=sort(m=t.content.datas).call(m,(function(t,i){return t.timestamp-i.timestamp}))).call(u,(function(t){return h.processSystemNotification(t)}))).call(i,(function(t){return t}));v&&this.emit("onReceiveCustomNotifications",v)},i.v2NotificationRevokeHandler=function v2NotificationRevokeHandler(t){var i=fillIdServer(t,t.content.data,"idServer");this.markSysNotificationAck([i])},i.v2NotificationSyncRevokeHandler=function v2NotificationSyncRevokeHandler(t){var i=t.content.type;1===Gd(i)&&this.markSysNotificationAck(t.content.datas)},i.markSysNotificationAck=function markSysNotificationAck(t){if(!this.config.compatibleWithV1){var i=[],u=[],m=[15,16,17,18,103];forEach$1(t).call(t,(function(t){t.idServer&&(includes(m).call(m,t.type)?u.push(t.idServer):i.push(t.idServer))})),i.length>0&&this.core.sendCmd("v2BatchMarkRead",{sid:"7",cid:"3",ids:i}),u.length>0&&this.core.sendCmd("v2BatchMarkRead",{sid:"21",cid:"19",ids:u})}},V2NIMNotificationServiceImpl}(hp),_S={"27_1":"v2NIMSync","27_10":"v2QChatSync"},SS={v2NIMSync:{sid:27,cid:1,service:"V2NIMSyncService",hasPacketTimer:!1,params:[{type:"Property",name:"tag",reflectMapper:{myInfo:1,offlineMsgs:2,teams:3,roamingMsgs:7,relations:9,friends:11,friendUsers:13,msgReceipts:14,myTeamMembers:15,donnop:16,recallMsg:17,sessionAck:18,broadcastMsgs:20,avSignal:21,superTeams:22,mySuperTeamMembers:23,superTeamRoamingMsgs:24,deleteSuperTeamMsg:25,superTeamSessionAck:26,deleteSelfMsgs:27,stickTopSessions:28,sessionHistoryMsgsDelete:29,p2pTeamModifyMessage:30,superTeamModifyMessage:31,friendOperatorList:32,p2pMsgReceiptV2:33,p2pSessionAckV2:34,teamSessionAckV2:35,superTeamSessionAckV2:36,teamApplyList:38,friendApplyInfoDeleteOrClear:39,filterMsgs:100}}],response:[{type:"Long",name:"timetag"}]},v2QChatSync:{sid:27,cid:10,service:"V2NIMSyncService",hasPacketTimer:!1,params:[{type:"Property",name:"tag",reflectMapper:{systemNotification:1,pushConfig:2}}],response:[{type:"Long",name:"timetag"}]}},TS=function(t){function V2NIMSyncServiceImpl(i){var u;return(u=t.call(this,"V2NIMSyncService",i)||this).teamKey=["teams","superTeams","myTeamMembers","mySuperTeamMembers","teamApplyList"],u.config={},u.timetags={},"v2"!==u.core.options.apiVersion?Je(u):(registerParser({cmdMap:_S,cmdConfig:SS}),u.setListener(),u)}Nt(V2NIMSyncServiceImpl,t);var i=V2NIMSyncServiceImpl.prototype;return i.reset=function reset(){this.timetags={}},i.setListener=function setListener(){var t=this;this.core.eventBus.on("V2NIMLoginService/loginLifeCycleLoginSucc",(function(){t.doSync()})),this.core.eventBus.on("V2NIMSync/updateTimetag",(function(i){var u;forEach$1(u=Ht(i)).call(u,(function(u){i[u]>(t.timetags[u]||0)&&(t.timetags[u]=i[u])}))}))},i.setOptions=function setOptions(t){var i=this.core,u=!(!i.V2NIMConversationService.name&&!i.V2NIMLocalConversationService.name),m=!!i.V2NIMFriendService.name&&get(i.otherOptions,"V2NIMFriendServiceConfig.enableServerV2FriendAddApplication"),h=!!i.V2NIMTeamService.name&&get(i.otherOptions,"V2NIMTeamServiceConfig.enableServerV2TeamJoinActionInfo");return this.config=Dt({myInfo:!!i.V2NIMUserService.name,offlineMsgs:!!i.V2NIMMessageService.name,roamingMsgs:!!i.V2NIMMessageService.name,relations:!!i.V2NIMUserService.name,friends:!!i.V2NIMFriendService.name,friendUsers:!!i.V2NIMUserService.name,friendOperatorList:m,friendApplyInfoDeleteOrClear:m,msgReceipts:!!i.V2NIMMessageService.name,p2pMsgReceiptV2:!!i.V2NIMMessageService.name,broadcastMsgs:!!i.V2NIMNotificationService.name,recallMsg:!!i.V2NIMMessageService.name,sessionAck:u,superTeamSessionAck:u,stickTopSessions:u,superTeamRoamingMsgs:!!i.V2NIMTeamService.name,deleteSuperTeamMsg:!!i.V2NIMTeamService.name,deleteSelfMsgs:!!i.V2NIMMessageService.name,sessionHistoryMsgsDelete:!!i.V2NIMMessageService.name,avSignal:!!i.V2NIMSignallingService.name,teams:!!i.V2NIMTeamService.name,superTeams:!!i.V2NIMTeamService.name,teamApplyList:h,myTeamMembers:!!i.V2NIMTeamService.name,mySuperTeamMembers:!!i.V2NIMTeamService.name,donnop:!!i.V2NIMSettingService.name,p2pTeamModifyMessage:!!i.V2NIMMessageService.name,superTeamModifyMessage:!!i.V2NIMMessageService.name},t),this.config},i.doBasicSync=function doBasicSync(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t,i,u,m,h,v=this;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:return t=Ht(this.config),i=filter(t).call(t,(function(t){var i;return!includes(i=v.teamKey).call(i,t)&&v.config[t]})),u=this.genSyncParams(i),this.logger.log("V2Sync:basic",u),M.next=6,this.core.clientSocket.sendCmd("v2NIMSync",{tag:u});case 6:return m=M.sent,h=m.content.timetag,this.setTimetags(h,filter(i).call(i,(function(t){return"broadcastMsgs"!==t}))),M.next=11,this.delaySyncDone();case 11:return M.next=13,this.handleImmediate();case 13:this.core.logger.log("sync::basic sync complete in",h);case 14:case"end":return M.stop()}}),_callee,this)})))},i.doTeamSync=function doTeamSync(){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var t,i,u,m,h,v=this;return ud.wrap((function _callee2$(M){for(;;)switch(M.prev=M.next){case 0:if(0!==(i=filter(t=this.teamKey).call(t,(function(t){return v.config[t]}))).length){M.next=3;break}return M.abrupt("return");case 3:return u=this.genSyncParams(i),this.core.eventBus.emit("V2NIMTeamService/onSyncStarted"),this.logger.log("V2Sync:team",u),m=null,M.prev=7,M.next=10,this.core.clientSocket.sendCmd("v2NIMSync",{tag:u});case 10:m=M.sent,M.next=17;break;case 13:throw M.prev=13,M.t0=M.catch(7),this.core.eventBus.emit("V2NIMTeamService/onSyncFailed",M.t0),M.t0;case 17:this.core.eventBus.emit("V2NIMTeamService/onSyncFinished"),h=m.content.timetag,this.setTimetags(h,this.teamKey),this.core.logger.log("sync::team sync complete in",h);case 21:case"end":return M.stop()}}),_callee2,this,[[7,13]])})))},i.doQchatSync=function doQchatSync(){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var t;return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.core.clientSocket.sendCmd("v2QChatSync",{tag:{systemNotification:0}});case 2:t=i.sent,this.core.logger.log("sync::qchat sync complete in",t.content.timetag);case 4:case"end":return i.stop()}}),_callee3,this)})))},i.doSync=function doSync(){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var t;return ud.wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==(t=get(this.core,"V2NIMLoginService.authenticator.loginClientOfThisConnection.loginType"))){i.next=4;break}return this.logger.warn("sync::doSync: no loginType, stop sync"),i.abrupt("return");case 4:if(this.logger.log("sync::doSync:type "+t),this.core.V2NIMLoginService.dataSync.switchDataSync({type:1,state:2,subType:"mainSync"}),1!==t){i.next=20;break}return i.prev=7,i.next=10,this.doBasicSync();case 10:return i.next=12,this.doTeamSync();case 12:i.next=18;break;case 14:return i.prev=14,i.t0=i.catch(7),this.doSyncComplete(i.t0),i.abrupt("return");case 18:i.next=49;break;case 20:if(2!==t){i.next=32;break}return i.prev=21,i.next=24,this.doQchatSync();case 24:i.next=30;break;case 26:return i.prev=26,i.t1=i.catch(21),this.doSyncComplete(i.t1),i.abrupt("return");case 30:i.next=49;break;case 32:if(3!==t){i.next=48;break}return i.prev=33,i.next=36,this.doBasicSync();case 36:return i.next=38,this.doTeamSync();case 38:return i.next=40,this.doQchatSync();case 40:i.next=46;break;case 42:return i.prev=42,i.t2=i.catch(33),this.doSyncComplete(i.t2),i.abrupt("return");case 46:i.next=49;break;case 48:return i.abrupt("return");case 49:this.doSyncComplete();case 50:case"end":return i.stop()}}),_callee4,this,[[7,14],[21,26],[33,42]])})))},i.doSyncComplete=function doSyncComplete(t){t&&this.core.logger.log("sync::doSync complete but got error",t),this.core.V2NIMLoginService.dataSync.switchDataSync({type:1,state:3,error:t,subType:"mainSync"})},i.genSyncParams=function genSyncParams(t){var i=this;return reduce(t).call(t,(function(t,u){var m=u;return t[m]=i.timetags[m]||0,t}),{})},i.setTimetags=function setTimetags(t,i){var u=this;forEach$1(i).call(i,(function(i){u.timetags[i]=t}))},i.handleImmediate=function handleImmediate(){return this.core.session&&this.core.session.onSyncDone&&this.core.session.onSyncDone(),zi.resolve()},i.delaySyncDone=function delaySyncDone(){return 102===pd.getSystemInfo().hostEnvEnum?(this.core.logger.log("sync: emit ALIAPP sycnHandler, handle later"),new zi((function(t){mo((function(){t()}),100)}))):zi.resolve()},V2NIMSyncServiceImpl}(hp),CS=function(){function V2NIMAIModelImpl(){this.aiStreamMap=new Sc}var t=V2NIMAIModelImpl.prototype;return t.reset=function reset(){this.aiStreamMap.clear()},t.getAiStream=function getAiStream(t){return this.aiStreamMap.get(t)},t.getAiStreamIsComplete=function getAiStreamIsComplete(t){var i=this.aiStreamMap.get(t);return!i||i.isComplete},t.getAiStreamQueryStatus=function getAiStreamQueryStatus(t){var i=this.aiStreamMap.get(t);return i?i.queryStatus:0},t.upsertAiStreamChunks=function upsertAiStreamChunks(t,i,u){var m=this.aiStreamMap.get(t);return m&&!m.isComplete&&(m.chunks[i]=u),m||{isComplete:!1,queryStatus:0,chunks:[]}},t.setAiStream=function setAiStream(t,i,u){void 0===u&&(u=!1);var m=this.aiStreamMap.get(t);return m?this.aiStreamMap.set(t,Dt(Dt({},m),i)):u&&this.aiStreamMap.set(t,Dt({isComplete:!1,queryStatus:0,chunks:[]},i)),this.aiStreamMap.get(t)||{isComplete:!1,queryStatus:0,chunks:[]}},t.completeAiStream=function completeAiStream(t){var i=this.aiStreamMap.get(t);i&&this.aiStreamMap.set(t,Dt(Dt({},i),{isComplete:!0,queryStatus:0,chunks:[],aiRAGs:void 0}))},V2NIMAIModelImpl}();var bS="V2NIMAIService",ES={"4_26":"v2AIChatNotify","29_35":"v2AIProxyModelCall","29_36":"v2AIGetUserList","4_29":"v2AIOnStreamMessageChunk","4_30":"v2AIChatStreamNotify","29_38":"v2AIStopModelStreamCall","29_39":"v2AIStreamQuery","29_40":"v2AIRegenMessage"},AS={accountId:1,messages:{id:2,converter:objectToJSONString,retConverter:stringToJSONObject},requestId:3,content:{id:4,converter:objectToJSONString,retConverter:stringToJSONObject},promptVariables:5,modelConfigParams:{id:6,converter:objectToJSONString,retConverter:stringToJSONObject},antispamBusinessId:7,antispamEnabled:{id:8,converter:boolToInt},aiStream:{id:9,converter:boolToInt}},kS={accountId:1,name:3,avatar:4,sign:5,gender:{id:6,retType:"number"},email:7,birthday:8,mobile:9,serverExtension:10,aiModelType:{id:11,retType:"number"},modelConfig:{id:12,retConverter:function retConverter(t){if(t=stringToJSONObject(t)){var i=Ht(t),u=reduce(i).call(i,(function(i,u){var m=function camelCase(t){var i;return map$6(i=(t=t||"").split("_")).call(i,(function(t,i){return 0===i?t:t[0].toUpperCase()+slice(t).call(t,1)})).join("")}(u);return i[m]=t[u],i}),{});if("string"==typeof u.promptKeys)try{u.promptKeys=JSON.parse(u.promptKeys)}catch(t){}return u}}},yunxinConfig:{id:13,retConverter:function retConverter(t){if(t=stringToJSONObject(t))return t}},valid:{id:14,retType:"boolean"},createTime:{id:15,retType:"number"},updateTime:{id:16,retType:"number"}};function aiAgentStreamContentRetConverter(t){try{var i=JSON.parse(t);return"number"==typeof i.index?{msg:i.msg||"",type:i.type,lastChunk:{content:i.msg,chunkTime:Gd(i.timestamp),type:i.type,index:Gd(i.index)}}:i}catch(t){return}}function aiAgentStreamAIRAGsRetConverter(t){try{var i=JSON.parse(t);return i&&i.length>0?map$6(i).call(i,(function(t){return t.description=t.desc,delete t.desc,t})):[]}catch(t){return[]}}var RS={code:{id:1,retType:"number"},accountId:2,requestId:3,content:{id:4,retConverter:aiAgentStreamContentRetConverter},aiRAGs:{id:5,retConverter:aiAgentStreamAIRAGsRetConverter},timestamp:{id:6,retType:"number"},aiStreamStatus:{id:7,retType:"number"},aiStream:{id:8,retType:"boolean"}},wS={serverId:1,clientId:2,type:{id:3,retType:"number"},from:4,to:5,aiAccount:6,startIndex:{id:7,retType:"number"},endIndex:{id:8,retType:"number"},excludeIndex:{id:9,converter:objectToJSONString}},NS={serverId:1,clientId:2,type:{id:3,retType:"number"},content:{id:4,retConverter:aiAgentStreamContentRetConverter},aiRAGs:{id:6,retConverter:aiAgentStreamAIRAGsRetConverter}},xS={v2AIChatNotify:{sid:4,cid:26,service:bS,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(RS)}]},v2AIProxyModelCall:{sid:29,cid:35,service:bS,params:[{type:"Property",name:"tag",reflectMapper:AS}]},v2AIGetUserList:{sid:29,cid:36,service:bS,params:[{type:"Property",name:"tag",reflectMapper:{pageToken:1,limit:2}}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(kS)},{type:"Property",name:"queryTag",reflectMapper:invertSerializeItem({hasMore:{id:16,retType:"boolean"},nextToken:2})}]},v2AIOnStreamMessageChunk:{sid:4,cid:29,service:bS,response:[{type:"Property",name:"msg",reflectMapper:invertSerializeItem(Sh)}]},v2AIChatStreamNotify:{sid:4,cid:30,service:bS,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(RS)}]},v2AIStopModelStreamCall:{sid:29,cid:38,service:bS,params:[{type:"Property",name:"tag",reflectMapper:{serverId:1,clientId:2,type:{id:3,retType:"number"},from:4,to:5,aiAccount:6,opeType:{id:7,retType:"number"},updateContent:{id:8},messageTime:{id:11,retType:"number"}}}]},v2AIStreamQuery:{sid:29,cid:39,service:bS,params:[{type:"Property",name:"tag",reflectMapper:wS}],response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(NS)}]},v2AIRegenMessage:{sid:29,cid:40,service:bS,params:[{type:"Property",name:"tag",reflectMapper:{fromAccount:1,to:2,aiAccount:3,serverId:4,clientId:5,time:{id:6,retType:"number"},type:{id:7,retType:"number"},opeType:{id:8,retType:"number"},replyMsgFromAccount:9,replyMsgToAccount:10,replyMsgTime:{id:11,retType:"number"},replyMsgIdServer:12,replyMsgIdClient:13}}]}},OS=function(){function V2NIMAIEventImpl(t,i){this.core=t,this.service=i,this.logger=this.core.logger}var t=V2NIMAIEventImpl.prototype;return t.setListener=function setListener(){},t.beforeEmit=function beforeEmit(t){for(var i,u,m=this.service.name+"::emit "+t.toString(),h=arguments.length,v=new Array(h>1?h-1:0),M=1;M<h;M++)v[M-1]=arguments[M];if("onProxyAIModelCall"===t){var I=v[0];this.logger.log(""+m,"requestId:"+I.requestId+";aiStreamStatus:"+I.aiStreamStatus)}else if("onProxyAIModelStreamCall"===t){var S=v[0];this.logger.log(""+m,"requestId:"+S.requestId+";chunkIndex:"+(null===(i=S.content)||void 0===i?void 0:i.lastChunk.index)+";chunkTime:"+(null===(u=S.content)||void 0===u?void 0:u.lastChunk.chunkTime))}else{var T,C;(T=this.logger).log.apply(T,concat(C=[""+m]).call(C,v))}},V2NIMAIEventImpl}(),PS=function(){function V2NIMAIHandlerImpl(t,i){this.core=t,this.service=i,this.model=i.model,this.logger=this.core.logger}var t=V2NIMAIHandlerImpl.prototype;return t.v2AIChatNotifyHandler=function v2AIChatNotifyHandler(t){var i=t.content.data;i&&i.requestId&&(this.model.completeAiStream(i.requestId),i.aiStreamStatus=i.aiStreamStatus||0,i.aiStream=i.aiStream||!1,i.content&&(i.content.msg=i.content.msg||""),this.service.emit("onProxyAIModelCall",i))},t.v2AIChatStreamNotifyHandler=function v2AIChatStreamNotifyHandler(t){var i=t.content.data;if(i&&i.requestId&&i.content&&i.content.msg){var u=this.model.getAiStream(i.requestId);if(u||(u=this.model.setAiStream(i.requestId,{isComplete:!1,queryStatus:0,chunks:[]},!0)),!u.isComplete){var m=i.content.lastChunk;if(0===m.index&&i.aiRAGs&&(u=this.model.setAiStream(i.requestId,{aiRAGs:i.aiRAGs})),this.logger.log("V2AI::streamNotify requestId:"+i.requestId+";index:"+m.index+";cacheChunkLength:"+u.chunks.length+";chunkTime:"+m.chunkTime+"."),0===u.chunks.length&&m.index>0)this.logger.log("V2AI::streamNotify requestId:"+i.requestId+";chunks missing 0,currentIdx:"+m.index+",needQuery:"+(0===u.queryStatus)+"."),0===u.queryStatus&&(u=this.model.setAiStream(i.requestId,{queryStatus:1}),this.service._queryAiStream({clientId:i.requestId,type:4,from:this.core.account,aiAccount:i.accountId,startIndex:0,endIndex:m.index-1}));else if(m.index>0&&u.chunks.length>0&&void 0===u.chunks[m.index-1]){var h,v=reduce(h=u.chunks).call(h,(function(t,i,u){return void 0!==i&&t.push(u),t}),[]);this.logger.log("V2AI::streamNotify requestId:"+i.requestId+";out of order,currenIdx:"+m.index+",cacheIdx:["+v.join(",")+"],needReport:"+!u.hasReported+"."),u.hasReported||(u=this.model.setAiStream(i.requestId,{hasReported:!0}),this.reportOutOfOrder({requestId:i.requestId,cacheIds:v,targetIndex:m.index,target:"4-30"}))}(u=this.model.upsertAiStreamChunks(i.requestId,m.index,m.content)).chunks[0]||1!==u.queryStatus?(i.content.msg=u.chunks.join(""),u.aiRAGs&&(i.aiRAGs=u.aiRAGs),this.service.emit("onProxyAIModelStreamCall",i)):this.logger.log("V2AI::streamNotify requestId:"+i.requestId+";chunks ignore index:"+m.index+";queryStatus:"+u.queryStatus+".")}}},t.v2AIOnStreamMessageChunkHandler=function v2AIOnStreamMessageChunkHandler(t){var i,u,m;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var h,v,M,I,S,T,C,E,A,k,R;return ud.wrap((function _callee$(w){for(;;)switch(w.prev=w.next){case 0:if((h=completeMessage(this.core,t.content.msg)).streamConfig&&h.streamConfig.lastChunk){w.next=3;break}return w.abrupt("return");case 3:if(!(v=this.model.getAiStream(h.messageClientId))||!v.isComplete){w.next=6;break}return w.abrupt("return");case 6:if(v||(v=this.model.setAiStream(h.messageClientId,{isComplete:!1,queryStatus:0,chunks:[]},!0)),M=h.streamConfig.lastChunk,I=h.messageClientId,(S=(null===(i=h.aiConfig)||void 0===i?void 0:i.aiRAGs)||h.streamConfig.rags)&&(v.aiRAGs&&(S=concat(T=[]).call(T,v.aiRAGs,S)),v=this.model.setAiStream(I,{aiRAGs:S})),this.logger.log("V2AI::aiStream requestId:"+I+";index:"+M.index+";cacheChunkLength:"+v.chunks.length+";chunkTime:"+M.chunkTime+"."),0===v.chunks.length&&M.index>0?(this.logger.log("V2AI::msg:aiStream requestId:"+I+";chunks missing 0,currentIdx:"+M.index+",needQuery:"+(0===v.queryStatus)+"."),0===v.queryStatus&&(v=this.model.setAiStream(I,{queryStatus:1}),(C={})[0]=0,C[1]=5,C[2]=6,C[3]=7,E=C,A=(null===(u=h.aiConfig)||void 0===u?void 0:u.accountId)?h.conversationType:E[h.conversationType],this.service._queryAiStream({serverId:h.messageServerId,clientId:I,type:A,from:h.senderId,to:h.receiverId,aiAccount:null===(m=h.aiConfig)||void 0===m?void 0:m.accountId,startIndex:0,endIndex:M.index-1}))):M.index>0&&v.chunks.length>0&&void 0===v.chunks[M.index-1]&&(R=reduce(k=v.chunks).call(k,(function(t,i,u){return void 0!==i&&t.push(u),t}),[]),this.logger.log("V2AI::msg:aiStream requestId:"+I+";out of order,currenIdx:"+M.index+";streamCache.chunks:"+Un(v.chunks)+",cacheIdx:["+R.join(",")+"],needReport:"+!v.hasReported+"."),v.hasReported||(v=this.model.setAiStream(I,{hasReported:!0}),this.reportOutOfOrder({requestId:I,cacheIds:R,targetIndex:M.index,target:"4-29"}))),(v=this.model.upsertAiStreamChunks(I,M.index,M.content)).chunks[0]||1!==v.queryStatus){w.next=17;break}return this.logger.log("V2AI::msg:callStream requestId:"+I+";chunks ignore index:"+M.index+";queryStatus:"+v.queryStatus+"."),w.abrupt("return");case 17:h.streamConfig.status=-1,h.aiConfig&&(h.aiConfig.aiStreamStatus=-1),h.text=v.chunks.join(""),v.aiRAGs&&h.aiConfig&&(h.aiConfig.aiRAGs=v.aiRAGs),v.aiRAGs&&h.streamConfig&&(h.streamConfig.rags=v.aiRAGs),v.msg&&(h=Dt({},v.msg,Dt({text:h.text,modifyTime:M.chunkTime,modifyAccountId:v.msg.senderId,streamConfig:h.streamConfig},h.aiConfig?{aiConfig:h.aiConfig}:{}))),this.core.eventBus.emit("V2NIMAIService/receiveMessagesModified",[h]);case 24:case"end":return w.stop()}}),_callee,this)})))},t.reportOutOfOrder=function reportOutOfOrder(t){this.core.reporter.reportTraceStart("exceptions",{user_id:this.core.account,trace_id:get(this.core,"clientSocket.socket.sessionId"),action:2,exception_service:0}),this.core.reporter.reportTraceUpdateV2("exceptions",{code:0,context:t.requestId,description:"["+t.cacheIds.join(",")+"],"+t.targetIndex,operation_type:2,target:t.target,net_connect:!0}),this.core.reporter.reportTraceEnd("exceptions",4)},V2NIMAIHandlerImpl}();var LS=function(t){function V2NIMAIServiceImpl(i){var u;return(u=t.call(this,"V2NIMAIService",i)||this).model=new CS,u.event=new OS(u.core,Je(u)),u.handler=new PS(u.core,Je(u)),registerParser({cmdMap:ES,cmdConfig:xS}),u}Nt(V2NIMAIServiceImpl,t);var i=V2NIMAIServiceImpl.prototype;return i.setListener=function setListener(){this.event.setListener()},i.reset=function reset(){this.model.reset()},i.emit=function emit(i){for(var u,m,h,v,M=arguments.length,I=new Array(M>1?M-1:0),S=1;S<M;S++)I[S-1]=arguments[S];return(u=this.event).beforeEmit.apply(u,concat(m=[i]).call(m,I)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,I))},i.getAIUserList=function getAIUserList(){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var t;return ud.wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:return this.checkV2(),i.next=3,this.core.sendCmd("v2AIGetUserList",{tag:{}});case 3:return t=i.sent,i.abrupt("return",(u=t.content.datas)&&u.length>0?map$6(u).call(u,(function(t){return t.modelType=t.aiModelType,t})):[]);case 5:case"end":return i.stop()}var u}),_callee,this)})))},i.proxyAIModelCall=function proxyAIModelCall(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){return ud.wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:if(validate(Mm,t,"",!0),!this.model.getAiStream(t.requestId)){i.next=6;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,desc:"Same requestId",detail:{rawData:t.requestId}});case 6:this.model.setAiStream(t.requestId,{isComplete:!1,queryStatus:0,chunks:[]},!0);case 7:return i.next=9,this.core.sendCmd("v2AIProxyModelCall",{tag:t});case 9:case"end":return i.stop()}}),_callee2,this)})))},i.stopAIModelStreamCall=function stopAIModelStreamCall(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){return ud.wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return validate(Im,t,"",!0),i.next=3,this.core.sendCmd("v2AIStopModelStreamCall",{tag:{clientId:t.requestId,aiAccount:t.accountId,type:4,from:this.core.account}});case 3:this.logger.log("V2AI::streamCallStop,requestId:"+t.requestId),this.model.completeAiStream(t.requestId);case 5:case"end":return i.stop()}}),_callee3,this)})))},i._queryAiStream=function _queryAiStream(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m=this;return ud.wrap((function _callee4$(h){for(;;)switch(h.prev=h.next){case 0:return this.model.setAiStream(t.clientId,{queryStatus:1}),h.prev=1,h.next=4,this.core.sendCmd("v2AIStreamQuery",{tag:t});case 4:if(i=h.sent,this.model.setAiStream(t.clientId,{queryStatus:2}),(u=i.content.datas)&&u.length>0){h.next=9;break}return h.abrupt("return");case 9:forEach$1(u).call(u,(function(t){var i=t.clientId,u=m.model.getAiStream(i);if(u&&(!u||!u.isComplete)&&t.content&&t.content.lastChunk){var h=t.content.lastChunk;m.model.upsertAiStreamChunks(i,h.index,h.content),0===h.index&&t.aiRAGs&&m.model.setAiStream(i,{aiRAGs:t.aiRAGs}),m.logger.log("V2AI::queryAiStream requestId:"+i+";index:"+h.index+";cacheChunkLength:"+u.chunks.length+";chunkTime:"+h.chunkTime+".")}})),h.next=16;break;case 12:h.prev=12,h.t0=h.catch(1),this.logger.warn("V2AI::queryAiStream requestId:"+t.clientId+";error:",h.t0),this.model.setAiStream(t.clientId,{queryStatus:2});case 16:case"end":return h.stop()}}),_callee4,this,[[1,12]])})))},V2NIMAIServiceImpl}(hp),VS={"18_1":"v2SignallingCreateRoom","18_2":"v2SignallingDelayRoom","18_3":"v2SignallingCloseRoom","18_4":"v2SignallingJoinRoom","18_5":"v2SignallingLeaveRoom","18_6":"v2SignallingInvite","18_7":"v2SignallingCancelInvite","18_16":"v2SignallingCall","18_17":"v2SignallingCallSetup","18_8":"v2SignallingRejectInvite","18_9":"v2SignallingAcceptInvite","18_10":"v2SignallingSendControl","15_11":"v2SignallingOnlineEvent","15_12":"v2SignallingMultiClientEvent","15_13":"v2SignallingOfflineEvent","15_14":"v2SignallingSyncChannels","18_15":"v2SignallingGetRoomInfo"},US="V2NIMSignallingService",DS={accountId:1,uid:{id:2,retType:"number"},joinTime:{id:3,retType:"number"},expireTime:{id:4,retType:"number"},deviceId:5},BS={channelType:{id:1,retType:"number",retAccess:"channelInfo.channelType"},channelName:{id:2,retAccess:"channelInfo.channelName"},channelId:{id:3,retAccess:"channelInfo.channelId"},createTime:{id:4,retType:"number",retAccess:"channelInfo.createTime"},expireTime:{id:5,retType:"number",retAccess:"channelInfo.expireTime"},creatorAccountId:{id:6,retAccess:"channelInfo.creatorAccountId"},channelExtension:{id:7,retAccess:"channelInfo.channelExtension"},channelValid:{id:8,retDef:!0,retAccess:"channelInfo.channelValid",retConverter:function retConverter(t){return 1!==Gd(t)}},fromAccid:10,toAccid:11,requestId:12,pushEnabled:{id:13,access:"pushConfig.pushEnabled",converter:boolToInt,retType:"boolean"},pushTitle:{id:14,access:"pushConfig.pushTitle"},pushContent:{id:15,access:"pushConfig.pushContent"},pushPayload:{id:16,access:"pushConfig.pushPayload"},unreadEnabled:{id:17,access:"signallingConfig.unreadEnabled",converter:boolToInt,retType:"boolean",def:1},members:{id:18,retAccess:"members",retConverter:function retConverter(t){try{var i=JSON.parse(t);return map$6(i).call(i,(function(t){return deserialize(t,invertSerializeItem(DS))}))}catch(t){return}}},attach:{id:19,retConverter:stringToJSONObject},serverExtension:{id:20,retDef:""},offlineEnabled:{id:21,converter:boolToInt,retType:"boolean",def:1},msgId:22,selfUid:{id:23,retType:"number",access:"signallingConfig.selfUid"},time:{id:24,retType:"number"},rtcChannelName:{id:25,access:"rtcConfig.rtcChannelName"},rtcTokenTtl:{id:26,retType:"number",access:"rtcConfig.rtcTokenTtl",retAccess:"rtcInfo.rtcTokenTtl"},rtcToken:{id:27,retAccess:"rtcInfo.rtcToken"},rtcParams:{id:28,access:"rtcConfig.rtcParams",retAccess:"rtcInfo.rtcParams"},callStatus:{id:30,retType:"number"}},qS={v2SignallingCall:{sid:18,cid:16,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingCallSetup:{sid:18,cid:17,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingCreateRoom:{sid:18,cid:1,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingDelayRoom:{sid:18,cid:2,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingCloseRoom:{sid:18,cid:3,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingJoinRoom:{sid:18,cid:4,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingLeaveRoom:{sid:18,cid:5,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingInvite:{sid:18,cid:6,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingCancelInvite:{sid:18,cid:7,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingRejectInvite:{sid:18,cid:8,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}]},v2SignallingAcceptInvite:{sid:18,cid:9,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}]},v2SignallingSendControl:{sid:18,cid:10,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}]},v2SignallingOnlineEvent:{sid:15,cid:11,service:US,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingMultiClientEvent:{sid:15,cid:12,service:US,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingOfflineEvent:{sid:15,cid:13,service:US,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(BS)}]},v2SignallingSyncChannels:{sid:15,cid:14,service:US,response:[{type:"PropertyArray",name:"datas",reflectMapper:invertSerializeItem(BS)}]},v2SignallingGetRoomInfo:{sid:18,cid:15,service:US,params:[{type:"Property",name:"tag",reflectMapper:BS}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(BS)}]},v2SignallingBatchMarkRead:{sid:4,cid:5,hasPacketResponse:!1,service:US,params:[{type:"Byte",name:"sid"},{type:"Byte",name:"cid"},{type:"LongArray",name:"ids"}]}},FS={calleeAccountId:{type:"string",required:!0,allowEmpty:!1},requestId:{type:"string",required:!0,allowEmpty:!1},channelType:{type:"enum",values:[1,3,2]},channelName:{type:"string",required:!1,allowEmpty:!0},channelExtension:{type:"string",required:!1,allowEmpty:!0},serverExtension:{type:"string",required:!1,allowEmpty:!0},signallingConfig:{type:"object",required:!1,rules:{offlineEnabled:{type:"boolean",required:!1},unreadEnabled:{type:"boolean",required:!1},selfUid:{type:"number",required:!1}}},pushConfig:{type:"object",required:!1,rules:{pushEnabled:{type:"boolean",required:!1},pushTitle:{type:"string",required:!1,allowEmpty:!0},pushContent:{type:"string",required:!1,allowEmpty:!0},pushPayload:{type:"string",required:!1,allowEmpty:!0}}},rtcConfig:{type:"object",required:!1,rules:{rtcChannelName:{type:"string",required:!1,allowEmpty:!0},rtcTokenTtl:{type:"number",required:!1},rtcParams:{type:"string",required:!1,allowEmpty:!0}}}},GS={channelId:{type:"string",required:!0,allowEmpty:!1},callerAccountId:{type:"string",required:!0,allowEmpty:!1},requestId:{type:"string",required:!0,allowEmpty:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0},signallingConfig:{type:"object",required:!1,rules:{offlineEnabled:{type:"boolean",required:!1},unreadEnabled:{type:"boolean",required:!1},selfUid:{type:"number",required:!1}}},rtcConfig:{type:"object",required:!1,rules:{rtcChannelName:{type:"string",required:!1,allowEmpty:!0},rtcTokenTtl:{type:"number",required:!1},rtcParams:{type:"string",required:!1,allowEmpty:!0}}}},HS={channelType:{type:"enum",values:[1,3,2]},channelName:{type:"string",required:!1,allowEmpty:!0},channelExtension:{type:"string",required:!1,allowEmpty:!0}},jS={channelId:{type:"string",required:!0,allowEmpty:!1},offlineEnabled:{type:"boolean",required:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0}},$S={channelId:{type:"string",required:!0,allowEmpty:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0},signallingConfig:{type:"object",required:!1,rules:{offlineEnabled:{type:"boolean",required:!1},unreadEnabled:{type:"boolean",required:!1},selfUid:{type:"number",required:!1}}},rtcConfig:{type:"object",required:!1,rules:{rtcChannelName:{type:"string",required:!1,allowEmpty:!0},rtcTokenTtl:{type:"number",required:!1},rtcParams:{type:"string",required:!1,allowEmpty:!0}}}},zS={channelId:{type:"string",required:!0,allowEmpty:!1},offlineEnabled:{type:"boolean",required:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0}},WS={channelId:{type:"string",required:!0,allowEmpty:!1},inviteeAccountId:{type:"string",required:!0,allowEmpty:!1},requestId:{type:"string",required:!0,allowEmpty:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0},signallingConfig:{type:"object",required:!1,rules:{offlineEnabled:{type:"boolean",required:!1},unreadEnabled:{type:"boolean",required:!1},selfUid:{type:"number",required:!1}}},pushConfig:{type:"object",required:!1,rules:{pushEnabled:{type:"boolean",required:!1},pushTitle:{type:"string",required:!1,allowEmpty:!0},pushContent:{type:"string",required:!1,allowEmpty:!0},pushPayload:{type:"string",required:!1,allowEmpty:!0}}}},KS={channelId:{type:"string",required:!0,allowEmpty:!1},inviteeAccountId:{type:"string",required:!0,allowEmpty:!1},requestId:{type:"string",required:!0,allowEmpty:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0},offlineEnabled:{type:"boolean",required:!1},pushConfig:{type:"object",required:!1,rules:{pushEnabled:{type:"boolean",required:!1},pushTitle:{type:"string",required:!1,allowEmpty:!0},pushContent:{type:"string",required:!1,allowEmpty:!0},pushPayload:{type:"string",required:!1,allowEmpty:!0}}}},YS={channelId:{type:"string",allowEmpty:!1},receiverAccountId:{type:"string",required:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0}},QS={channelId:{type:"string",allowEmpty:!1},inviterAccountId:{type:"string",allowEmpty:!1},requestId:{type:"string",allowEmpty:!1},serverExtension:{type:"string",required:!1,allowEmpty:!0},offlineEnabled:{type:"boolean",required:!1}},JS=QS;function formatSignalingEvent(t){var i,u=t.attach,m={eventType:u.type,channelInfo:t.channelInfo,operatorAccountId:t.fromAccid,time:t.time,serverExtension:t.serverExtension,requestId:t.requestId,pushConfig:t.pushConfig,unreadEnabled:null===(i=t.signallingConfig)||void 0===i?void 0:i.unreadEnabled},h=t.fromAccid,v=t.toAccid;switch(m.eventType){case 1:break;case 2:m.member={accountId:u.member[1],uid:Number(u.member[2]),joinTime:Number(u.member[3]),expireTime:Number(u.member[4]),deviceId:u.member[5]};break;case 3:case 4:m.operatorAccountId=h,m.inviteeAccountId=v,m.inviterAccountId=h;break;case 5:case 6:m.operatorAccountId=h,m.inviterAccountId=v,m.inviteeAccountId=h}return JSON.parse(Un(m))}var XS,ZS=function(t){function V2NIMSignallingServiceImpl(i,u){var m;return void 0===u&&(u={}),(m=t.call(this,"V2NIMSignallingService",i)||this).config={compatibleWithV1:!0},m.channels={},m.timer=0,m.pollingInterval=12e4,"v2"!==m.core.options.apiVersion?Je(m):(registerParser({cmdMap:VS,cmdConfig:qS}),m.setOptions(u),m)}Nt(V2NIMSignallingServiceImpl,t);var i=V2NIMSignallingServiceImpl.prototype;return i.reset=function reset(){this.timer=0,this.channels={}},i.setOptions=function setOptions(t){var i;(null===(i=this.core.signaling)||void 0===i?void 0:i.name)?this.config.compatibleWithV1=!0:this.config.compatibleWithV1=!1,this.config=Dt(this.config,t)},i.emit=function emit(i){for(var u,m,h,v,M=this.name+"::emit "+i.toString(),I=arguments.length,S=new Array(I>1?I-1:0),T=1;T<I;T++)S[T-1]=arguments[T];return(u=this.logger).log.apply(u,concat(m=[""+M]).call(m,S)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,S))},i.call=function call(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var u,m,h,v;return ud.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:if(this.checkV2(),validate(FS,t,"",!0),t.calleeAccountId!==this.core.account){M.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"You cannot call yourself"}});case 4:return u=void 0!==t.pushConfig&&(void 0!==t.pushConfig.pushEnabled&&t.pushConfig.pushEnabled),M.next=7,this.core.sendCmd("v2SignallingCall",{tag:Dt(Dt({},t),{toAccid:t.calleeAccountId,offlineEnabled:void 0===(null===(i=t.signallingConfig)||void 0===i?void 0:i.offlineEnabled)||t.signallingConfig.offlineEnabled,pushConfig:Dt(Dt({},t.pushConfig||{}),{pushEnabled:u})})});case 7:return m=M.sent,h=m.content.data,this.channels[h.channelInfo.channelId]=cloneDeep(h.channelInfo),this.timer||(this.timer=this.core.timerManager.addTimer(bind$1(v=this.aotoDelay).call(v,this),this.pollingInterval,-1)),M.abrupt("return",{callStatus:h.callStatus,rtcInfo:h.rtcInfo,roomInfo:{channelInfo:h.channelInfo,members:h.members}});case 12:case"end":return M.stop()}}),_callee,this)})))},i.callSetup=function callSetup(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var u,m,h;return ud.wrap((function _callee2$(v){for(;;)switch(v.prev=v.next){case 0:if(this.checkV2(),validate(GS,t,"",!0),t.callerAccountId!==this.core.account){v.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"callSetup: cannot be yourself"}});case 4:return v.next=6,this.core.sendCmd("v2SignallingCallSetup",{tag:Dt(Dt({},t),{toAccid:t.callerAccountId,offlineEnabled:void 0===(null===(i=t.signallingConfig)||void 0===i?void 0:i.offlineEnabled)||t.signallingConfig.offlineEnabled})});case 6:return u=v.sent,m=u.content.data,this.channels[m.channelInfo.channelId]=cloneDeep(m.channelInfo),this.timer||(this.timer=this.core.timerManager.addTimer(bind$1(h=this.aotoDelay).call(h,this),this.pollingInterval,-1)),v.abrupt("return",{callStatus:m.callStatus,rtcInfo:m.rtcInfo,roomInfo:{channelInfo:m.channelInfo,members:m.members}});case 11:case"end":return v.stop()}}),_callee2,this)})))},i.createRoom=function createRoom(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var m;return ud.wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:return this.checkV2(),validate(HS,{channelType:t,channelName:i,channelExtension:u},"",!0),h.next=4,this.core.sendCmd("v2SignallingCreateRoom",{tag:{channelType:t,channelName:i,channelExtension:u}});case 4:return m=h.sent,h.abrupt("return",m.content.data.channelInfo);case 6:case"end":return h.stop()}}),_callee3,this)})))},i.delayRoom=function delayRoom(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i;return ud.wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),u.next=3,this.core.sendCmd("v2SignallingDelayRoom",{tag:{channelId:t}});case 3:return i=u.sent,u.abrupt("return",{channelInfo:i.content.data.channelInfo,members:i.content.data.members});case 5:case"end":return u.stop()}}),_callee4,this)})))},i.closeRoom=function closeRoom(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee5(){return ud.wrap((function _callee5$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(jS,{channelId:t,offlineEnabled:i,serverExtension:u},"",!0),m.next=4,this.core.sendCmd("v2SignallingCloseRoom",{tag:{channelId:t,offlineEnabled:void 0!==i&&i,serverExtension:u}});case 4:case"end":return m.stop()}}),_callee5,this)})))},i.joinRoom=function joinRoom(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee6(){var u,m,h,v,M,I;return ud.wrap((function _callee6$(S){for(;;)switch(S.prev=S.next){case 0:return this.checkV2(),validate($S,t,"",!0),S.next=4,this.core.sendCmd("v2SignallingJoinRoom",{tag:Dt(Dt({},t),{offlineEnabled:void 0===(null===(i=t.signallingConfig)||void 0===i?void 0:i.offlineEnabled)||t.signallingConfig.offlineEnabled})});case 4:return u=S.sent,m=u.content.data,this.channels[m.channelInfo.channelId]=cloneDeep(m.channelInfo),this.timer||(this.timer=this.core.timerManager.addTimer(bind$1(h=this.aotoDelay).call(h,this),this.pollingInterval,-1)),v=m.channelInfo,M=m.members,I=m.rtcInfo,S.abrupt("return",{roomInfo:{channelInfo:v,members:M},rtcInfo:I});case 10:case"end":return S.stop()}}),_callee6,this)})))},i.leaveRoom=function leaveRoom(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee7(){return ud.wrap((function _callee7$(m){for(;;)switch(m.prev=m.next){case 0:return this.checkV2(),validate(zS,{channelId:t,offlineEnabled:i,serverExtension:u},"",!0),m.next=4,this.core.sendCmd("v2SignallingLeaveRoom",{tag:{channelId:t,offlineEnabled:void 0!==i&&i,serverExtension:u}});case 4:delete this.channels[t];case 5:case"end":return m.stop()}}),_callee7,this)})))},i.invite=function invite(t){var i;return __awaiter(this,void 0,void 0,ud.mark((function _callee8(){var u,m;return ud.wrap((function _callee8$(h){for(;;)switch(h.prev=h.next){case 0:if(this.checkV2(),validate(WS,t,"",!0),t.inviteeAccountId!==this.core.account){h.next=4;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"invite: cannot be yourself"}});case 4:return u=void 0!==t.pushConfig&&(void 0!==t.pushConfig.pushEnabled&&t.pushConfig.pushEnabled),h.next=7,this.core.sendCmd("v2SignallingInvite",{tag:Dt(Dt({},t),{toAccid:t.inviteeAccountId,offlineEnabled:void 0===(null===(i=t.signallingConfig)||void 0===i?void 0:i.offlineEnabled)||t.signallingConfig.offlineEnabled,pushConfig:Dt(Dt({},t.pushConfig||{}),{pushEnabled:u})})});case 7:return m=h.sent,h.abrupt("return",m.content.data);case 9:case"end":return h.stop()}}),_callee8,this)})))},i.cancelInvite=function cancelInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee9(){var i;return ud.wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkV2(),validate(KS,t,"",!0),u.next=4,this.core.sendCmd("v2SignallingCancelInvite",{tag:Dt(Dt({},t),{toAccid:t.inviteeAccountId})});case 4:return i=u.sent,u.abrupt("return",i.content.data);case 6:case"end":return u.stop()}}),_callee9,this)})))},i.rejectInvite=function rejectInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee10(){return ud.wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:if(validate(QS,t,"",!0),t.inviterAccountId!==this.core.account){i.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"rejectInvite: cannot be yourself"}});case 3:return i.next=5,this.core.sendCmd("v2SignallingRejectInvite",{tag:Dt(Dt({},t),{toAccid:t.inviterAccountId})});case 5:case"end":return i.stop()}}),_callee10,this)})))},i.acceptInvite=function acceptInvite(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee11(){return ud.wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:if(validate(JS,t,"",!0),t.inviterAccountId!==this.core.account){i.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"acceptInvite: cannot be yourself"}});case 3:return i.next=5,this.core.sendCmd("v2SignallingAcceptInvite",{tag:Dt(Dt({},t),{toAccid:t.inviterAccountId})});case 5:case"end":return i.stop()}}),_callee11,this)})))},i.sendControl=function sendControl(t,i,u){return __awaiter(this,void 0,void 0,ud.mark((function _callee12(){return ud.wrap((function _callee12$(m){for(;;)switch(m.prev=m.next){case 0:return validate(YS,{channelId:t,receiverAccountId:i,serverExtension:u},"",!0),m.next=3,this.core.sendCmd("v2SignallingSendControl",{tag:{channelId:t,toAccid:i,serverExtension:u}});case 3:case"end":return m.stop()}}),_callee12,this)})))},i.getRoomInfoByChannelName=function getRoomInfoByChannelName(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee13(){var i,u,m,h;return ud.wrap((function _callee13$(v){for(;;)switch(v.prev=v.next){case 0:return validate({channelName:{type:"string",allowEmpty:!1}},{channelName:t},"",!0),v.next=3,this.core.sendCmd("v2SignallingGetRoomInfo",{tag:{channelName:t}});case 3:return i=v.sent,u=i.content.data,m=u.members,h=u.channelInfo,v.abrupt("return",{channelInfo:h,members:m||[]});case 6:case"end":return v.stop()}}),_callee13,this)})))},i.aotoDelay=function aotoDelay(){return __awaiter(this,void 0,void 0,ud.mark((function _callee14(){var t,i,u,m;return ud.wrap((function _callee14$(h){for(;;)switch(h.prev=h.next){case 0:if(0!==(t=Ht(this.channels)).length){h.next=5;break}return this.timer&&this.core.timerManager.deleteTimer(this.timer),this.timer=0,h.abrupt("return");case 5:this.logger.log("v2Signlling:autoDelay",t),i=0;case 7:if(!(i<t.length)){h.next=23;break}return u=t[i],h.prev=9,h.next=12,this.core.sendCmd("v2SignallingDelayRoom",{tag:{channelId:u}});case 12:m=h.sent,this.channels[u]=m.content.data.channelInfo,h.next=20;break;case 16:h.prev=16,h.t0=h.catch(9),this.logger.warn("signling:autoDelay "+u+" failed",h.t0),delete this.channels[u];case 20:i++,h.next=7;break;case 23:case"end":return h.stop()}}),_callee14,this,[[9,16]])})))},i.v2SignallingOnlineEventHandler=function v2SignallingOnlineEventHandler(t){var i=fillIdServer(t,t.content.data,"msgId","0"),u=i.msgId;!this.config.compatibleWithV1&&u&&Gd(u)&&this.core.sendCmd("v2SignallingBatchMarkRead",{sid:15,cid:11,ids:[u]}),this.handleLeaveRoom(i),this.emit("onOnlineEvent",formatSignalingEvent(i))},i.v2SignallingMultiClientEventHandler=function v2SignallingMultiClientEventHandler(t){this.handleLeaveRoom(t.content.data),this.emit("onMultiClientEvent",formatSignalingEvent(t.content.data))},i.v2SignallingOfflineEventHandler=function v2SignallingOfflineEventHandler(t){var i,u=this;if(t.content.datas&&t.content.datas.length>0){if(!this.config.compatibleWithV1){var m,h=map$6(m=t.content.datas).call(m,(function(t){return t.msgId}));h.length>0&&this.core.sendCmd("v2SignallingBatchMarkRead",{sid:15,cid:11,ids:h})}var v=map$6(i=t.content.datas).call(i,(function(t){return u.handleLeaveRoom(t),formatSignalingEvent(t)}));this.emit("onOfflineEvent",v)}},i.v2SignallingSyncChannelsHandler=function v2SignallingSyncChannelsHandler(t){var i=this;if(this.timer=0,this.channels={},t.content.datas&&t.content.datas.length>0){var u,m=t.content.datas;if(forEach$1(m).call(m,(function(t){var u=t.channelInfo.channelId;i.channels[u]=cloneDeep(t.channelInfo)})),!this.timer)this.timer=this.core.timerManager.addTimer(bind$1(u=this.aotoDelay).call(u,this),this.pollingInterval,-1);this.emit("onSyncRoomInfoList",m)}},i.handleLeaveRoom=function handleLeaveRoom(t){switch(t.attach.type){case 1:case 7:case 9:delete this.channels[t.channelInfo.channelId]}},V2NIMSignallingServiceImpl}(hp),eT={"19_1":"v2PublishEvent","14_2":"v2OnUserStatusChange","19_3":"v2SubscribeUserStatus","19_4":"v2UnsubscribeUserStatus","19_5":"v2UnsubscribeAllUserStatus","19_6":"v2QuerySubscribeEvent","19_7":"v2QueryAllSubscribeEvent","14_9":"v2OnMultiUserStatusChange"},tT="V2NIMSubscriptionService",rT={eventType:{id:1,retType:"number"},statusType:{id:2,retType:"number"},uniqueId:3,extension:4,duration:{id:5,retType:"number"},onlineOnly:{id:6,retType:"boolean",converter:function converter(t){return t?1:2}},multiSync:{id:7,retType:"boolean",converter:boolToInt},publishTime:{id:10,retType:"number"},serverId:11,clientType:{id:12,retType:"number"},serverExtension:13,extensionReceived:14,accountId:103},nT={eventType:{id:1,retType:"number"},duration:{id:2,retType:"number"},immediateSync:{id:3,retType:"number",converter:boolToInt},accountId:102,subscribeTime:{id:105,retType:"number"}},aT={v2PublishEvent:{sid:19,cid:1,service:tT,params:[{type:"Property",name:"tag",reflectMapper:rT}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(rT)}]},v2OnUserStatusChange:{sid:14,cid:2,service:tT,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(rT)}]},v2SubscribeUserStatus:{sid:19,cid:3,service:tT,params:[{type:"Property",name:"tag",reflectMapper:nT},{type:"StrArray",name:"accountIds"}],response:[{type:"StrArray",name:"failedList"}]},v2UnsubscribeUserStatus:{sid:19,cid:4,service:tT,params:[{type:"Property",name:"tag",reflectMapper:nT},{type:"StrArray",name:"accountIds"}],response:[{type:"StrArray",name:"failedList"}]},v2UnsubscribeAllUserStatus:{sid:19,cid:5,service:tT,params:[{type:"Property",name:"tag",reflectMapper:nT}]},v2QuerySubscribeEvent:{sid:19,cid:6,service:tT,params:[{type:"Property",name:"tag",reflectMapper:nT},{type:"StrArray",name:"accountIds"}],response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(nT)}]},v2QueryAllSubscribeEvent:{sid:19,cid:7,service:tT,params:[{type:"Property",name:"tag",reflectMapper:nT}],response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(nT)}]},v2OnMultiUserStatusChange:{sid:14,cid:9,service:tT,response:[{type:"PropertyArray",name:"data",reflectMapper:invertSerializeItem(rT)}]}},iT={accountIds:{type:"array",required:!0,itemType:"string",min:1,max:100},duration:{type:"number",required:!1,min:60,max:2592e3},immediateSync:{type:"boolean",required:!1}},oT={accountIds:{type:"array",required:!1,itemType:"string",max:100}},sT={statusType:{type:"number",required:!0,min:1e4,max:2147483647},duration:{type:"number",required:!1,min:60,max:604800},extension:{type:"jsonstr",required:!1},onlineOnly:{type:"boolean",required:!1},multiSync:{type:"boolean",required:!1}},cT=function(t){function V2NIMSubscriptionServiceImpl(i){var u;return"v2"!==(u=t.call(this,"V2NIMSubscriptionService",i)||this).core.options.apiVersion?Je(u):(registerParser({cmdMap:eT,cmdConfig:aT}),u)}Nt(V2NIMSubscriptionServiceImpl,t);var i=V2NIMSubscriptionServiceImpl.prototype;return i.emit=function emit(i){for(var u,m,h,v,M=this.name+"::emit "+i.toString(),I=arguments.length,S=new Array(I>1?I-1:0),T=1;T<I;T++)S[T-1]=arguments[T];return(u=this.logger).log.apply(u,concat(m=[""+M]).call(m,S)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,S))},i.subscribeUserStatus=function subscribeUserStatus(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkLogin(),this.checkV2(),validate(iT,t,"",!0),u.next=5,this.core.sendCmd("v2SubscribeUserStatus",{tag:{eventType:1,duration:t.duration||60,immediateSync:void 0!==t.immediateSync&&t.immediateSync},accountIds:t.accountIds});case 5:return i=u.sent,u.abrupt("return",i.content.failedList);case 7:case"end":return u.stop()}}),_callee,this)})))},i.unsubscribeUserStatus=function unsubscribeUserStatus(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee2(){var i,u;return ud.wrap((function _callee2$(m){for(;;)switch(m.prev=m.next){case 0:if(this.checkLogin(),this.checkV2(),validate(oT,t,"",!0),i=[],!(t.accountIds.length>0)){m.next=11;break}return m.next=7,this.core.sendCmd("v2UnsubscribeUserStatus",{tag:{eventType:1},accountIds:t.accountIds});case 7:u=m.sent,i=u.content.failedList,m.next=15;break;case 11:return m.next=14,this.core.sendCmd("v2UnsubscribeAllUserStatus",{tag:{eventType:1}});case 14:i=[];case 15:return m.abrupt("return",i);case 16:case"end":return m.stop()}}),_callee2,this)})))},i.publishCustomUserStatus=function publishCustomUserStatus(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee3(){var i;return ud.wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return this.checkLogin(),this.checkV2(),validate(sT,t,"",!0),u.next=5,this.core.sendCmd("v2PublishEvent",{tag:Dt(Dt({},t),{eventType:1,uniqueId:jd(),duration:t.duration||60,onlineOnly:void 0===t.onlineOnly||t.onlineOnly,multiSync:void 0!==t.multiSync&&t.multiSync})});case 5:return i=u.sent,u.abrupt("return",i.content.data);case 7:case"end":return u.stop()}}),_callee3,this)})))},i.queryUserStatusSubscriptions=function queryUserStatusSubscriptions(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee4(){var i,u,m,h,v,M;return ud.wrap((function _callee4$(I){for(;;)switch(I.prev=I.next){case 0:if(this.checkLogin(),this.checkV2(),validate({accountIds:{type:"array",required:!0,itemType:"string",max:3e3}},{accountIds:t},"",!0),i=[],!(t.length>0)){I.next=16;break}u=0;case 6:if(!(u<t.length)){I.next=14;break}return I.next=9,this.core.sendCmd("v2QuerySubscribeEvent",{tag:{eventType:1},accountIds:slice(t).call(t,u,u+100)});case 9:h=I.sent,i=concat(i).call(i,map$6(m=h.content.data).call(m,(function(t){return{accountId:t.accountId,subscribeTime:t.subscribeTime,duration:t.duration}})));case 11:u+=100,I.next=6;break;case 14:I.next=20;break;case 16:return I.next=18,this.core.sendCmd("v2QueryAllSubscribeEvent",{tag:{eventType:1}});case 18:M=I.sent,i=concat(i).call(i,map$6(v=M.content.data).call(v,(function(t){return{accountId:t.accountId,subscribeTime:t.subscribeTime,duration:t.duration}})));case 20:return I.abrupt("return",i);case 21:case"end":return I.stop()}}),_callee4,this)})))},i.v2OnUserStatusChangeHandler=function v2OnUserStatusChangeHandler(t){var i=t.content.data,u=i.eventType,m=i.extensionReceived,h=__rest(i,["eventType","extensionReceived"]);1===u?this.emit("onUserStatusChanged",[Dt(Dt({},h),{extension:m})]):this.logger.log("v2OnUserStatusChangeHandler eventType = ",u,"msgEvent = ",i)},i.v2OnMultiUserStatusChangeHandler=function v2OnMultiUserStatusChangeHandler(t){var i,u=t.content.data,m=map$6(i=filter(u).call(u,(function(t){return 1===t.eventType}))).call(i,(function(t){t.eventType;var i=t.extensionReceived,u=__rest(t,["eventType","extensionReceived"]);return Dt(Dt({},u),{extension:i})}));m.length>0&&this.emit("onUserStatusChanged",m)},V2NIMSubscriptionServiceImpl}(hp);!function(t){t[t.V2NIM_PROXY_REQUEST_METHOD_GET=1]="V2NIM_PROXY_REQUEST_METHOD_GET",t[t.V2NIM_PROXY_REQUEST_METHOD_POST=2]="V2NIM_PROXY_REQUEST_METHOD_POST",t[t.V2NIM_PROXY_REQUEST_METHOD_PUT=3]="V2NIM_PROXY_REQUEST_METHOD_PUT",t[t.V2NIM_PROXY_REQUEST_METHOD_DELETE=4]="V2NIM_PROXY_REQUEST_METHOD_DELETE"}(XS||(XS={}));var lT="V2NIMPassthroughService",dT={"22_1":"v2ProxyRequest","22_2":"v2ProxyOnRequest"},uT={zone:1,path:2,method:3,header:4,body:5},pT={v2ProxyRequest:{sid:22,cid:1,service:lT,params:[{type:"Property",name:"tag",reflectMapper:uT}],response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem(uT)}]},v2ProxyOnRequest:{sid:22,cid:2,service:lT,response:[{type:"Property",name:"data",reflectMapper:invertSerializeItem({fromAccountId:1,body:2,time:{id:3,retType:"number"}})}]}},mT={path:{type:"string",allowEmpty:!1},zone:{type:"string",required:!1},method:{type:"enum",values:[XS.V2NIM_PROXY_REQUEST_METHOD_DELETE,XS.V2NIM_PROXY_REQUEST_METHOD_GET,XS.V2NIM_PROXY_REQUEST_METHOD_POST,XS.V2NIM_PROXY_REQUEST_METHOD_PUT],required:!1},header:{type:"jsonstr",required:!1},body:{type:"string",required:!1}},hT=function(t){function V2NIMPassthroughServiceImpl(i){var u;return u=t.call(this,"V2NIMPassthroughService",i)||this,registerParser({cmdMap:dT,cmdConfig:pT}),u}Nt(V2NIMPassthroughServiceImpl,t);var i=V2NIMPassthroughServiceImpl.prototype;return i.emit=function emit(i){for(var u,m,h,v,M=this.name+"::emit "+i.toString(),I=arguments.length,S=new Array(I>1?I-1:0),T=1;T<I;T++)S[T-1]=arguments[T];return(u=this.logger).log.apply(u,concat(m=[""+M]).call(m,S)),(h=t.prototype.emit).call.apply(h,concat(v=[this,i]).call(v,S))},i.httpProxy=function httpProxy(t){return __awaiter(this,void 0,void 0,ud.mark((function _callee(){var i;return ud.wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:if(validate(mT,t,"",!0),!(t.method===XS.V2NIM_PROXY_REQUEST_METHOD_GET&&t.body||t.method===XS.V2NIM_PROXY_REQUEST_METHOD_POST&&!t.body||t.method===XS.V2NIM_PROXY_REQUEST_METHOD_PUT&&!t.body)){u.next=3;break}throw new Yl({code:zl.V2NIM_ERROR_CODE_INVALID_PARAMETER,detail:{reason:"method "+t.method+", incorrect body"}});case 3:return u.next=5,this.core.sendCmd("v2ProxyRequest",{tag:t});case 5:return i=u.sent,u.abrupt("return",i.content.data);case 7:case"end":return u.stop()}}),_callee,this)})))},i.v2ProxyOnRequestHandler=function v2ProxyOnRequestHandler(t){var i=t.content.data;this.emit("onProxyNotify",i)},V2NIMPassthroughServiceImpl}(hp),gT=createCommonjsModule((function(t,i){t.exports=function(t){var add32=function(t,i){return t+i&4294967295},i=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function cmn(t,i,u,m,h,v){return i=add32(add32(i,t),add32(m,v)),add32(i<<h|i>>>32-h,u)}function ff(t,i,u,m,h,v,M){return cmn(i&u|~i&m,t,i,h,v,M)}function gg(t,i,u,m,h,v,M){return cmn(i&m|u&~m,t,i,h,v,M)}function hh(t,i,u,m,h,v,M){return cmn(i^u^m,t,i,h,v,M)}function ii(t,i,u,m,h,v,M){return cmn(u^(i|~m),t,i,h,v,M)}function md5cycle(t,i){var u=t[0],m=t[1],h=t[2],v=t[3];u=ff(u,m,h,v,i[0],7,-680876936),v=ff(v,u,m,h,i[1],12,-389564586),h=ff(h,v,u,m,i[2],17,606105819),m=ff(m,h,v,u,i[3],22,-1044525330),u=ff(u,m,h,v,i[4],7,-176418897),v=ff(v,u,m,h,i[5],12,1200080426),h=ff(h,v,u,m,i[6],17,-1473231341),m=ff(m,h,v,u,i[7],22,-45705983),u=ff(u,m,h,v,i[8],7,1770035416),v=ff(v,u,m,h,i[9],12,-1958414417),h=ff(h,v,u,m,i[10],17,-42063),m=ff(m,h,v,u,i[11],22,-1990404162),u=ff(u,m,h,v,i[12],7,1804603682),v=ff(v,u,m,h,i[13],12,-40341101),h=ff(h,v,u,m,i[14],17,-1502002290),u=gg(u,m=ff(m,h,v,u,i[15],22,1236535329),h,v,i[1],5,-165796510),v=gg(v,u,m,h,i[6],9,-1069501632),h=gg(h,v,u,m,i[11],14,643717713),m=gg(m,h,v,u,i[0],20,-373897302),u=gg(u,m,h,v,i[5],5,-701558691),v=gg(v,u,m,h,i[10],9,38016083),h=gg(h,v,u,m,i[15],14,-660478335),m=gg(m,h,v,u,i[4],20,-405537848),u=gg(u,m,h,v,i[9],5,568446438),v=gg(v,u,m,h,i[14],9,-1019803690),h=gg(h,v,u,m,i[3],14,-187363961),m=gg(m,h,v,u,i[8],20,1163531501),u=gg(u,m,h,v,i[13],5,-1444681467),v=gg(v,u,m,h,i[2],9,-51403784),h=gg(h,v,u,m,i[7],14,1735328473),u=hh(u,m=gg(m,h,v,u,i[12],20,-1926607734),h,v,i[5],4,-378558),v=hh(v,u,m,h,i[8],11,-2022574463),h=hh(h,v,u,m,i[11],16,1839030562),m=hh(m,h,v,u,i[14],23,-35309556),u=hh(u,m,h,v,i[1],4,-1530992060),v=hh(v,u,m,h,i[4],11,1272893353),h=hh(h,v,u,m,i[7],16,-155497632),m=hh(m,h,v,u,i[10],23,-1094730640),u=hh(u,m,h,v,i[13],4,681279174),v=hh(v,u,m,h,i[0],11,-358537222),h=hh(h,v,u,m,i[3],16,-722521979),m=hh(m,h,v,u,i[6],23,76029189),u=hh(u,m,h,v,i[9],4,-640364487),v=hh(v,u,m,h,i[12],11,-421815835),h=hh(h,v,u,m,i[15],16,530742520),u=ii(u,m=hh(m,h,v,u,i[2],23,-995338651),h,v,i[0],6,-198630844),v=ii(v,u,m,h,i[7],10,1126891415),h=ii(h,v,u,m,i[14],15,-1416354905),m=ii(m,h,v,u,i[5],21,-57434055),u=ii(u,m,h,v,i[12],6,1700485571),v=ii(v,u,m,h,i[3],10,-1894986606),h=ii(h,v,u,m,i[10],15,-1051523),m=ii(m,h,v,u,i[1],21,-2054922799),u=ii(u,m,h,v,i[8],6,1873313359),v=ii(v,u,m,h,i[15],10,-30611744),h=ii(h,v,u,m,i[6],15,-1560198380),m=ii(m,h,v,u,i[13],21,1309151649),u=ii(u,m,h,v,i[4],6,-145523070),v=ii(v,u,m,h,i[11],10,-1120210379),h=ii(h,v,u,m,i[2],15,718787259),m=ii(m,h,v,u,i[9],21,-343485551),t[0]=add32(u,t[0]),t[1]=add32(m,t[1]),t[2]=add32(h,t[2]),t[3]=add32(v,t[3])}function md5blk(t){var i,u=[];for(i=0;i<64;i+=4)u[i>>2]=t.charCodeAt(i)+(t.charCodeAt(i+1)<<8)+(t.charCodeAt(i+2)<<16)+(t.charCodeAt(i+3)<<24);return u}function md5blk_array(t){var i,u=[];for(i=0;i<64;i+=4)u[i>>2]=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+(t[i+3]<<24);return u}function md51(t){var i,u,m,h,v,M,I=t.length,S=[1732584193,-271733879,-1732584194,271733878];for(i=64;i<=I;i+=64)md5cycle(S,md5blk(t.substring(i-64,i)));for(u=(t=t.substring(i-64)).length,m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=0;i<u;i+=1)m[i>>2]|=t.charCodeAt(i)<<(i%4<<3);if(m[i>>2]|=128<<(i%4<<3),i>55)for(md5cycle(S,m),i=0;i<16;i+=1)m[i]=0;return h=(h=8*I).toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(h[2],16),M=parseInt(h[1],16)||0,m[14]=v,m[15]=M,md5cycle(S,m),S}function md51_array(t){var i,u,m,h,v,M,I=t.length,S=[1732584193,-271733879,-1732584194,271733878];for(i=64;i<=I;i+=64)md5cycle(S,md5blk_array(t.subarray(i-64,i)));for(u=(t=i-64<I?t.subarray(i-64):new Uint8Array(0)).length,m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=0;i<u;i+=1)m[i>>2]|=t[i]<<(i%4<<3);if(m[i>>2]|=128<<(i%4<<3),i>55)for(md5cycle(S,m),i=0;i<16;i+=1)m[i]=0;return h=(h=8*I).toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(h[2],16),M=parseInt(h[1],16)||0,m[14]=v,m[15]=M,md5cycle(S,m),S}function rhex(t){var u,m="";for(u=0;u<4;u+=1)m+=i[t>>8*u+4&15]+i[t>>8*u&15];return m}function hex(t){var i;for(i=0;i<t.length;i+=1)t[i]=rhex(t[i]);return t.join("")}function toUtf8(t){return/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t))),t}function utf8Str2ArrayBuffer(t,i){var u,m=t.length,h=new ArrayBuffer(m),v=new Uint8Array(h);for(u=0;u<m;u+=1)v[u]=t.charCodeAt(u);return i?v:h}function arrayBuffer2Utf8Str(t){return String.fromCharCode.apply(null,new Uint8Array(t))}function concatenateArrayBuffers(t,i,u){var m=new Uint8Array(t.byteLength+i.byteLength);return m.set(new Uint8Array(t)),m.set(new Uint8Array(i),t.byteLength),u?m:m.buffer}function hexToBinaryString(t){var i,u=[],m=t.length;for(i=0;i<m-1;i+=2)u.push(parseInt(t.substr(i,2),16));return String.fromCharCode.apply(String,u)}function SparkMD5(){this.reset()}return"5d41402abc4b2a76b9719d911017c592"!==hex(md51("hello"))&&(add32=function(t,i){var u=(65535&t)+(65535&i);return(t>>16)+(i>>16)+(u>>16)<<16|65535&u}),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function clamp(t,i){return(t=0|t||0)<0?Math.max(t+i,0):Math.min(t,i)}ArrayBuffer.prototype.slice=function(i,u){var m,h,v,M,I=this.byteLength,S=clamp(i,I),T=I;return u!==t&&(T=clamp(u,I)),S>T?new ArrayBuffer(0):(m=T-S,h=new ArrayBuffer(m),v=new Uint8Array(h),M=new Uint8Array(this,S,m),v.set(M),h)}}(),SparkMD5.prototype.append=function(t){return this.appendBinary(toUtf8(t)),this},SparkMD5.prototype.appendBinary=function(t){this._buff+=t,this._length+=t.length;var i,u=this._buff.length;for(i=64;i<=u;i+=64)md5cycle(this._hash,md5blk(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},SparkMD5.prototype.end=function(t){var i,u,m=this._buff,h=m.length,v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<h;i+=1)v[i>>2]|=m.charCodeAt(i)<<(i%4<<3);return this._finish(v,h),u=hex(this._hash),t&&(u=hexToBinaryString(u)),this.reset(),u},SparkMD5.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},SparkMD5.prototype.setState=function(t){return this._buff=t.buff,this._length=t.length,this._hash=t.hash,this},SparkMD5.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},SparkMD5.prototype._finish=function(t,i){var u,m,h,v=i;if(t[v>>2]|=128<<(v%4<<3),v>55)for(md5cycle(this._hash,t),v=0;v<16;v+=1)t[v]=0;u=(u=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),m=parseInt(u[2],16),h=parseInt(u[1],16)||0,t[14]=m,t[15]=h,md5cycle(this._hash,t)},SparkMD5.hash=function(t,i){return SparkMD5.hashBinary(toUtf8(t),i)},SparkMD5.hashBinary=function(t,i){var u=hex(md51(t));return i?hexToBinaryString(u):u},SparkMD5.ArrayBuffer=function(){this.reset()},SparkMD5.ArrayBuffer.prototype.append=function(t){var i,u=concatenateArrayBuffers(this._buff.buffer,t,!0),m=u.length;for(this._length+=t.byteLength,i=64;i<=m;i+=64)md5cycle(this._hash,md5blk_array(u.subarray(i-64,i)));return this._buff=i-64<m?new Uint8Array(u.buffer.slice(i-64)):new Uint8Array(0),this},SparkMD5.ArrayBuffer.prototype.end=function(t){var i,u,m=this._buff,h=m.length,v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<h;i+=1)v[i>>2]|=m[i]<<(i%4<<3);return this._finish(v,h),u=hex(this._hash),t&&(u=hexToBinaryString(u)),this.reset(),u},SparkMD5.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},SparkMD5.ArrayBuffer.prototype.getState=function(){var t=SparkMD5.prototype.getState.call(this);return t.buff=arrayBuffer2Utf8Str(t.buff),t},SparkMD5.ArrayBuffer.prototype.setState=function(t){return t.buff=utf8Str2ArrayBuffer(t.buff,!0),SparkMD5.prototype.setState.call(this,t)},SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy,SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish,SparkMD5.ArrayBuffer.hash=function(t,i){var u=hex(md51_array(new Uint8Array(t)));return i?hexToBinaryString(u):u},SparkMD5}()}));var vT=function _interopDefault$1(t){return t&&"object"==typeof t&&"default"in t?t.default:t}(gT);var fT=class BMF{md5(t,i,u){this.aborted=!1,this.progress=0;let m=0;const h=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,v=2097152,M=Math.ceil(t.size/v),I=new vT.ArrayBuffer,S=new FileReader;function loadNext(){const i=m*v,u=i+v>=t.size?t.size:i+v;S.readAsArrayBuffer(h.call(t,i,u))}loadNext(),S.onloadend=t=>{I.append(t.target.result),m++,this.progress=m/M,u&&"function"==typeof u&&u(this.progress),this.aborted?i("aborted"):m<M?loadNext():i(null,I.end())}}abort(){this.aborted=!0}},yT=function(){function DataStructureConverterImpl(t){this.name="DataStructureConverter",this.core=t}var t=DataStructureConverterImpl.prototype;return t.messageConvertToV1=function messageConvertToV1(t){var i,u=deserialize(serialize(t,Sh),invertSerializeItem(uM)),m=getSessionId(u,this.core.account),h=null===(i=this.core.session)||void 0===i?void 0:i.getSessionWithUncomplete({id:m});return formatMsg$1(u,h?{account:this.core.account,sessionAck:h.ack,msgReceiptTime:h.msgReceiptTime}:{account:this.core.account})},t.messageConvertToV2=function messageConvertToV2(t){var i=deserialize(serialize(generatorMsgForCmd$1(t,t.from,t.fromDeviceId),uM),Th);return(i=completeMessage(this.core,i)).sendingState="sending"===t.status?3:"sendFailed"===t.status?2:1,i},DataStructureConverterImpl}(),MT=function(){function V2NIMMessageConverterImpl(t){this.name="V2NIMMessageConverter",this.core=t}var t=V2NIMMessageConverterImpl.prototype;return t.messageSerialization=function messageSerialization(t){if(!t)return null;var i=serialize(t,Sh);return Un(i)},t.messageDeserialization=function messageDeserialization(t){var i,u,m,h,v,M,I,S,T,C,E,A,k,R,w,N,x,O,P,L,V,U,D;if(!t)return null;try{var B,q,G,H,j=deserialize(JSON.parse(t),Th);return j.sendingState=0,1!==j.conversationType||j.senderId!==this.core.account&&j.receiverId!==this.core.account?2===j.conversationType?j.conversationId=this.core.V2NIMConversationIdUtil.teamConversationId(j.receiverId):3===j.conversationType&&(j.conversationId=this.core.V2NIMConversationIdUtil.superTeamConversationId(j.receiverId)):j.conversationId=this.core.V2NIMConversationIdUtil.p2pConversationId(j.senderId===this.core.account?j.receiverId:j.senderId),j.threadReply&&(j.threadReply.conversationType=j.conversationType,j.threadReply=completeMessageRefer(this.core,j.threadReply)),j.threadRoot&&(j.threadRoot.conversationType=j.conversationType,j.threadRoot=completeMessageRefer(this.core,j.threadRoot)),includes(B=[1,3,2,0]).call(B,j.conversationType)||this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid conversationType(enum): "+j.conversationType),j.senderId&&"string"!=typeof j.senderId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid senderId(string): "+j.senderId),j.receiverId&&"string"!=typeof j.receiverId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid receiverId(string): "+j.receiverId),"createTime"in j&&isNaN(j.createTime)&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid createTime(number): "+j.createTime),includes(q=[2,7,12,100,6,1,-1,4,5,11,0,10,3]).call(q,j.messageType)||this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid messageType(enum): "+j.messageType),"subType"in j&&isNaN(j.subType)&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid subType(number): "+j.subType),j.messageClientId&&"string"!=typeof j.messageClientId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid messageClientId(string): "+j.messageClientId),j.messageServerId&&"string"!=typeof j.messageServerId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid messageServerId(string): "+j.messageServerId),j.attachment&&"object"!=typeof j.attachment&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid attachment(object): "+j.attachment),j.text&&"string"!=typeof j.text&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid text(string): "+j.text),j.serverExtension&&"string"!=typeof j.serverExtension&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid serverExtension(string): "+j.serverExtension),j.callbackExtension&&"string"!=typeof j.callbackExtension&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid callbackExtension(string): "+j.callbackExtension),(null===(i=j.pushConfig)||void 0===i?void 0:i.pushContent)&&"string"!=typeof j.pushConfig.pushContent&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid pushContent(string): "+j.pushConfig.pushContent),(null===(u=j.pushConfig)||void 0===u?void 0:u.pushPayload)&&"string"!=typeof j.pushConfig.pushPayload&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid pushPayload(string): "+j.pushConfig.pushPayload),(null===(m=j.pushConfig)||void 0===m?void 0:m.forcePushContent)&&"string"!=typeof j.pushConfig.forcePushContent&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid forcePushContent(string): "+j.pushConfig.forcePushContent),(null===(h=j.pushConfig)||void 0===h?void 0:h.forcePushAccountIds)&&!Dn(j.pushConfig.forcePushAccountIds)&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid forcePushAccountIds(array): "+j.pushConfig.forcePushAccountIds),(null===(v=j.routeConfig)||void 0===v?void 0:v.routeEnvironment)&&"string"!=typeof j.routeConfig.routeEnvironment&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid routeEnvironment(string): "+j.routeConfig.routeEnvironment),(null===(M=j.antispamConfig)||void 0===M?void 0:M.antispamBusinessId)&&"string"!=typeof j.antispamConfig.antispamBusinessId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid antispamBusinessId(string): "+j.antispamConfig.antispamBusinessId),(null===(I=j.antispamConfig)||void 0===I?void 0:I.antispamCustomMessage)&&"string"!=typeof j.antispamConfig.antispamCustomMessage&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid antispamCustomMessage(string): "+j.antispamConfig.antispamCustomMessage),(null===(S=j.antispamConfig)||void 0===S?void 0:S.antispamCheating)&&"string"!=typeof j.antispamConfig.antispamCheating&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid antispamCheating(string): "+j.antispamConfig.antispamCheating),(null===(T=j.antispamConfig)||void 0===T?void 0:T.antispamExtension)&&"string"!=typeof j.antispamConfig.antispamExtension&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid antispamExtension(string): "+j.antispamConfig.antispamExtension),(null===(C=j.robotConfig)||void 0===C?void 0:C.accountId)&&"string"!=typeof j.robotConfig.accountId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid accountId(string): "+j.robotConfig.accountId),(null===(E=j.robotConfig)||void 0===E?void 0:E.topic)&&"string"!=typeof j.robotConfig.topic&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid topic(string): "+j.robotConfig.topic),(null===(A=j.robotConfig)||void 0===A?void 0:A.function)&&"string"!=typeof j.robotConfig.function&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid function(string): "+j.robotConfig.function),(null===(k=j.robotConfig)||void 0===k?void 0:k.customContent)&&"string"!=typeof j.robotConfig.customContent&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid customContent(string): "+j.robotConfig.customContent),(null===(R=j.threadRoot)||void 0===R?void 0:R.senderId)&&"string"!=typeof j.threadRoot.senderId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid senderId(string): "+j.threadRoot.senderId),(null===(w=j.threadRoot)||void 0===w?void 0:w.receiverId)&&"string"!=typeof j.threadRoot.receiverId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid receiverId(string): "+j.threadRoot.receiverId),(null===(N=j.threadRoot)||void 0===N?void 0:N.messageClientId)&&"string"!=typeof j.threadRoot.messageClientId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid messageClientId(string): "+j.threadRoot.messageClientId),(null===(x=j.threadRoot)||void 0===x?void 0:x.messageServerId)&&"string"!=typeof j.threadRoot.messageServerId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid messageServerId(string): "+j.threadRoot.messageServerId),j.threadRoot&&"createTime"in j.threadRoot&&isNaN(j.threadRoot.createTime)&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid createTime(number): "+j.threadRoot.createTime),j.threadRoot&&!includes(G=[1,3,2,0]).call(G,j.threadRoot.conversationType)&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid conversationType(enum): "+j.threadRoot.conversationType),(null===(O=j.threadRoot)||void 0===O?void 0:O.conversationId)&&"string"!=typeof j.threadRoot.conversationId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid conversationId(string): "+j.threadRoot.conversationId),(null===(P=j.threadReply)||void 0===P?void 0:P.senderId)&&"string"!=typeof j.threadReply.senderId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid senderId(string): "+j.threadReply.senderId),(null===(L=j.threadReply)||void 0===L?void 0:L.receiverId)&&"string"!=typeof j.threadReply.receiverId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid receiverId(string): "+j.threadReply.receiverId),(null===(V=j.threadReply)||void 0===V?void 0:V.messageClientId)&&"string"!=typeof j.threadReply.messageClientId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid messageClientId(string): "+j.threadReply.messageClientId),(null===(U=j.threadReply)||void 0===U?void 0:U.messageServerId)&&"string"!=typeof j.threadReply.messageServerId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid messageServerId(string): "+j.threadReply.messageServerId),j.threadReply&&"createTime"in j.threadReply&&isNaN(j.threadReply.createTime)&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid createTime(number): "+j.threadReply.createTime),j.threadReply&&!includes(H=[1,3,2,0]).call(H,j.threadReply.conversationType)&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid conversationType(enum): "+j.threadReply.conversationType),(null===(D=j.threadReply)||void 0===D?void 0:D.conversationId)&&"string"!=typeof j.threadReply.conversationId&&this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid conversationId(string): "+j.threadReply.conversationId),delete j.__clientExt,delete j.userUpdateTime,j}catch(i){return this.core.logger.error("V2NIMMessageConverterImpl.messageDeserialization: invalid message string: "+t),null}},V2NIMMessageConverterImpl}();!function setAdapters(t){merge$1(pd,t())}((function getAdapter(){return{setLogger:setLogger,platform:"BROWSER",localStorage:window.localStorage,request:du,WebSocket:window.WebSocket,uploadFile:uploadFileFn,getFileUploadInformation:getFileUploadInformationFn,getSystemInfo:getSystemInfoFn,net:Vu,powerMonitor:new Bu,logStorage:Hu}})),lu.registerService(Tp,"V1NIMLoginService"),lu.registerService(fM,"msg"),lu.registerService(_M,"user"),lu.registerService(RM,"session"),lu.registerService(NM,"team"),lu.registerService(VM,"systemMessage"),lu.registerService(GM,"friend"),lu.registerService(WM,"event"),lu.registerService(ZM,"msgExtend"),lu.registerService(sI,"msgLog"),lu.registerService(pI,"passThrough"),lu.registerService(lg,"cloudStorage"),lu.registerService(NI,"superTeam"),lu.registerService(IM,"sync"),lu.registerService(PI,"plugin"),lu.registerService(qI,"cloudSession"),lu.registerService(e_,"signaling"),lu.registerService(om,"V2NIMLoginService"),lu.registerService(Yg,"V2NIMLocalConversationService"),lu.registerService(vv,"V2NIMConversationService"),lu.registerService(Tg,"V2NIMMessageService"),lu.registerService(IS,"V2NIMNotificationService"),lu.registerService(ug,"V2NIMStorageService"),lu.registerService(Gh,"V2NIMStorageUtil"),lu.registerService(_v,"V2NIMConversationGroupService"),lu.registerService(Tf,"V2NIMTeamService"),lu.registerService(xf,"V2NIMUserService"),lu.registerService(Zf,"V2NIMFriendService"),lu.registerService(Ry,"V2NIMSettingService"),lu.registerService(TS,"V2NIMSyncService"),lu.registerService(LS,"V2NIMAIService"),lu.registerService(yT,"DataStructureConverter"),lu.registerService(MT,"V2NIMMessageConverter"),lu.registerService(Av,"V2NIMMessageLogUtil"),lu.registerService(Bv,"V2NIMMessageExtendUtil"),lu.registerService(ZS,"V2NIMSignallingService"),lu.registerService(cT,"V2NIMSubscriptionService"),lu.registerService(hT,"V2NIMPassthroughService"),lu.registerService(vg,"YSFService"),lu.registerService(V_,"qchatChannel"),lu.registerService(H_,"qchatMedia"),lu.registerService(vS,"qchatMsg"),lu.registerService(yS,"qchatRole"),lu.registerService(MS,"qchatServer"),lu.registerPlugin(fT,"browser-md5-file"),lu.registerPrivateService((function EventForwardCenter(t){var i=this;this.bindEvents=function(){i.core.eventBus.on("forwardSend/msg/sendMsg",i.onV1SendMsg),i.core.eventBus.on("forwardSend/msg/recallMsg",i.onV1RecallMsg),i.core.eventBus.on("forwardSend/msg/deleteSelfMsgs",i.onV1DeleteSelfMsgs),i.core.eventBus.on("forwardSend/msgLog/clearHistoryMsgsFromServer",i.onV1ClearHistoryMessage),i.core.eventBus.on("forwardSend/V2NIMMessageService/sendMsg",i.onV2SendMsg),i.core.eventBus.on("forwardSend/V2NIMMessageService/modifyMsg",i.onV2ModifyMsg),i.core.eventBus.on("forwardSend/V2NIMMessageService/revokeMessage",i.onV2RevokeMessage),i.core.eventBus.on("forwardSend/V2NIMMessageService/deleteSelfMsgs",i.onV2DeleteSelfMsgs),i.core.eventBus.on("forwardSend/V2NIMMessageLogService/clearHistoryMessage",i.onV2ClearHistoryMessage),i.core.eventBus.on("forwardSend/team/created",i.onV1TeamCreated),i.core.eventBus.on("forwardSend/team/updateMyMemberInfo",i.onV1TeamMemberUpdate),i.core.eventBus.on("forwardSend/superTeam/updateMyMemberInfo",i.onV1SuperTeamMemberUpdate),i.core.eventBus.on("forwardSend/V2NIMTeamService/updateSelfTeamMemberInfo",i.onV2TeamMemberUpdate),i.core.eventBus.on("forwardSend/team/passTeamApply",(function(t,u){return i.onV1TeamApply(t,1,1,u)})),i.core.eventBus.on("forwardSend/superTeam/passSuperTeamApply",(function(t,u){i.onV1TeamApply(t,2,1,u)})),i.core.eventBus.on("forwardSend/team/rejectTeamApply",(function(t,u){i.onV1TeamApply(t,1,2,u)})),i.core.eventBus.on("forwardSend/superTeam/rejectSuperTeamApply",(function(t,u){i.onV1TeamApply(t,2,2,u)})),i.core.eventBus.on("forwardSend/team/acceptTeamInvite",(function(t,u){i.onV1TeamInvite(t,1,1,u)})),i.core.eventBus.on("forwardSend/superTeam/acceptSuperTeamInvite",(function(t,u){i.onV1TeamInvite(t,2,1,u)})),i.core.eventBus.on("forwardSend/team/rejectTeamInvite",(function(t,u){i.onV1TeamInvite(t,1,2,u)})),i.core.eventBus.on("forwardSend/superTeam/rejectSuperTeamInvite",(function(t,u){i.onV1TeamInvite(t,2,2,u)})),i.core.eventBus.on("forwardSend/user/updateBlackList",i.onV1UpdateBlackList),i.core.eventBus.on("forwardSend/user/updateUserInfo",i.onV1UpdateUserInfo),i.core.eventBus.on("forwardSend/user/setMute",i.onV1SetMute),i.core.eventBus.on("forwardSend/friend/addFriend",i.onV1AddFriend),i.core.eventBus.on("forwardSend/friend/deleteFriend",i.onV1DeleteFriend),i.core.eventBus.on("forwardSend/friend/updateFriend",i.onV1UpdateFriend),i.core.eventBus.on("forwardSend/friend/passFriendApply",i.onV1PassFriendApply),i.core.eventBus.on("forwardSend/friend/rejectFriendApply",i.onV1RejectFriendApply)},this.onV1TeamApply=function(t,u,m,h){if(h){if(!i.core.V2NIMTeamService.notification.checkIfExpired(h))return;m=3}i.core.eventBus.emit("forwardReceive/V2NIMTeamService/updateTeamActionStatus",{teamId:t.teamId,teamType:u,operatorAccountId:t.from,actionType:0},m)},this.onV1TeamInvite=function(t,u,m,h){if(h){if(!i.core.V2NIMTeamService.notification.checkIfExpired(h.code))return;m=3}i.core.eventBus.emit("forwardReceive/V2NIMTeamService/updateTeamActionStatus",{teamId:t.teamId,teamType:u,operatorAccountId:t.from,actionType:2},m)},this.onV1PassFriendApply=function(t,u){i.core.eventBus.emit("forwardReceive/V2NIMFriendService/acceptAddApplication",t,u)},this.onV1RejectFriendApply=function(t,u,m){i.core.eventBus.emit("forwardReceive/V2NIMFriendService/rejectAddApplication",{applicantAccountId:t,recipientAccountId:i.core.account,operatorAccountId:i.core.account,postscript:u||"",timestamp:i.core.timeOrigin.getNTPTime(),read:!0,status:3},m)},this.onV1SetMute=function(t,u){i.core.eventBus.emit("forwardReceive/v2NIMSettingService/setP2PMessageMuteMode",t,u?1:0)},this.onV1UpdateFriend=function(t){i.core.eventBus.emit("forwardReceive/V2NIMFriendService/setFriendInfo",t.account,Dt(Dt({},"alias"in t?{alias:t.alias}:{}),"ext"in t?{serverExtension:t.ext}:{}))},this.onV1AddFriend=function(t){i.core.eventBus.emit("forwardReceive/V2NIMFriendService/addFriend",t)},this.onV1DeleteFriend=function(t){i.core.eventBus.emit("forwardReceive/V2NIMFriendService/deleteFriend",t)},this.onV1UpdateUserInfo=function(t){var u=deserialize(serialize(t,Jy.user),invertSerializeItem(Ef));i.core.eventBus.emit("forwardReceive/V2NIMUserService/updateUserProfile",u)},this.onV1UpdateBlackList=function(t,u){i.core.eventBus.emit("forwardReceive/V2NIMUserService/updateBlockList",t,u)},this.onV1TeamCreated=function(t){var u=deserialize(serialize(generateTeam(t),Wy.team),invertSerializeItem(dh));i.core.eventBus.emit("forwardReceive/V2NIMTeamService/created",u)},this.onV1TeamMemberUpdate=function(t){(t=Dt({},t)).type&&(t.type={normal:0,owner:1,manager:2}[t.type]);var u=deserialize(serialize(t,Wy.teamMember),invertSerializeItem(uh));u.teamType=1,i.core.eventBus.emit("forwardReceive/V2NIMTeamService/updateSelfTeamMemberInfo",u)},this.onV1SuperTeamMemberUpdate=function(t){(t=Dt({},t)).type&&(t.type={normal:0,owner:1,manager:2}[t.type]);var u=deserialize(serialize(t,kI.superTeamMember),invertSerializeItem(ph));u.teamType=2,i.core.eventBus.emit("forwardReceive/V2NIMTeamService/updateSelfTeamMemberInfo",u)},this.onV2TeamMemberUpdate=function(t){var u=t.teamType,m=serialize(t,uh);if(2===u){var h=deserialize(m,invertSerializeItem(kI.superTeamMember));i.core.eventBus.emit("forwardReceive/superTeam/updateMyMemberInfo",h)}else{var v=deserialize(m,invertSerializeItem(Wy.teamMember));i.core.eventBus.emit("forwardReceive/team/updateMyMemberInfo",v)}},this.onV1SendMsg=function(t){var u=deserialize(serialize(t,uM),Th);(u=completeMessage(i.core,u)).sendingState="sending"===t.status?3:"sent"===t.status?1:2,i.core.eventBus.emit("forwardReceive/V2NIMMessageService/sendMsg",u)},this.onV2SendMsg=function(t){var u=deserialize(serialize(t,Sh),invertSerializeItem(uM));u.status=3===t.sendingState?"sending":1===t.sendingState?"sent":"sendFailed",i.core.eventBus.emit("forwardReceive/msg/sendMsg",u)},this.onV2ModifyMsg=function(t){var u=deserialize(serialize(t,Sh),invertSerializeItem(uM));i.core.eventBus.emit("forwardReceive/msg/modifyMsg",u)},this.onV1RecallMsg=function(t){t.deleteMsgCreatetime=t.time;var u=deserialize(serialize(t,pM.recallMsgTag),invertSerializeItem(Eh));i.core.eventBus.emit("forwardReceive/V2NIMMessageService/revokeMessages",[u])},this.onV2RevokeMessage=function(t){var u=deserialize(serialize(t,Eh),mM.recallMsgTag);i.core.eventBus.emit("forwardReceive/msg/recallMsg",u)},this.onV1DeleteSelfMsgs=function(t){var u=map$6(t).call(t,(function(t){return deserialize(serialize(t,pM.deleteSelfMsgTag),invertSerializeItem(Ch))}));forEach$1(u).call(u,(function(t){t.messageRefer=formatMessageRefer(i.core,t.messageRefer)})),i.core.eventBus.emit("forwardReceive/V2NIMMessageService/deleteMessages",u)},this.onV2DeleteSelfMsgs=function(t){var u=map$6(t).call(t,(function(t){return deserialize(serialize(t,Ch),mM.deleteSelfMsgTag)}));i.core.eventBus.emit("forwardReceive/msg/deleteSelfMsgs",u)},this.onV1ClearHistoryMessage=function(t){var u=deserialize(serialize(t,rI.clearHistoryMsgsFromServerReqTag),invertSerializeItem(Cv));i.core.eventBus.emit("forwardReceive/V2NIMMessageLogService/clearHistoryMessage",u)},this.onV2ClearHistoryMessage=function(t){var u=deserialize(serialize(t,Cv),nI.clearHistoryMsgsFromServerReqTag);i.core.eventBus.emit("forwardReceive/msgLog/clearHistoryMsgsFromServer",u)},this.core=t,this.bindEvents()}),"eventForwardCenter"),t.V2NIMConst=Kl,t.default=lu,Object.defineProperty(t,"__esModule",{value:!0})}));