var ku=Object.defineProperty,xu=Object.defineProperties;var Vu=Object.getOwnPropertyDescriptors;var Yn=Object.getOwnPropertySymbols;var Ms=Object.prototype.hasOwnProperty,As=Object.prototype.propertyIsEnumerable;var bs=(n,t,e)=>t in n?ku(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,oe=(n,t)=>{for(var e in t||(t={}))Ms.call(t,e)&&bs(n,e,t[e]);if(Yn)for(var e of Yn(t))As.call(t,e)&&bs(n,e,t[e]);return n},Ve=(n,t)=>xu(n,Vu(t));var ws=(n,t)=>{var e={};for(var r in n)Ms.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&Yn)for(var r of Yn(n))t.indexOf(r)<0&&As.call(n,r)&&(e[r]=n[r]);return e};import{d as Ya,q as Se,c as Ls,w as Us,u as Ds,E as Bu,r as Fu,o as ks,a as wi,b as Hu,z as $u,e as Gu,f as Ku,m as ju,g as qu,h as za,i as Yu,j as zu,k as Ja,l as ve,n as Ju,s as Wu,p as Zu}from"./vendor.65bdc0e9.js";function Xh(){import("data:text/javascript,")}const Qu=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function e(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerpolicy&&(o.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?o.credentials="include":i.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=e(i);fetch(i.href,o)}};Qu();if(typeof window!="undefined"){let n=function(){var t=document.body,e=document.getElementById("__svg__icons__dom__");e||(e=document.createElementNS("http://www.w3.org/2000/svg","svg"),e.style.position="absolute",e.style.width="0",e.style.height="0",e.id="__svg__icons__dom__",e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:link","http://www.w3.org/1999/xlink")),e.innerHTML='',t.insertBefore(e,t.lastChild)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n):n()}const Xu=Ya({setup(n){const t=Se.parse(location.search),e=location.href.split("#/")[1],r=Se.parse(e.split("?")[1]),i=t.roomUid||r.roomUid||"";return i&&sessionStorage.setItem("roomUid",i),(o,s)=>{const c=Fu("router-view");return ks(),Ls(Ds(Bu),{locale:Ds($u),message:{max:1}},{default:Us(()=>[wi(c,null,{default:Us(({Component:d})=>[(ks(),Ls(Hu(d)))]),_:1})]),_:1},8,["locale"])}}}),td="modulepreload",xs={},ed="./",hi=function(t,e){return!e||e.length===0?t():Promise.all(e.map(r=>{if(r=`${ed}${r}`,r in xs)return;xs[r]=!0;const i=r.endsWith(".css"),o=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${r}"]${o}`))return;const s=document.createElement("link");if(s.rel=i?"stylesheet":td,i||(s.as="script",s.crossOrigin=""),s.href=r,document.head.appendChild(s),i)return new Promise((c,d)=>{s.addEventListener("load",c),s.addEventListener("error",d)})})).then(()=>t())};function nd(n){switch(n){case"../src/pages/404/index.tsx":return hi(()=>import("./index.11b3d4cf.js"),["assets/index.11b3d4cf.js","assets/index.49150f4c.css","assets/vendor.65bdc0e9.js"]);case"../src/pages/home/index.tsx":return hi(()=>import("./index.6503e10f.js"),["assets/index.6503e10f.js","assets/index.b94cb86f.css","assets/vendor.65bdc0e9.js"]);case"../src/pages/login/index.tsx":return hi(()=>import("./index.d4a9a691.js"),["assets/index.d4a9a691.js","assets/index.526ec19c.css","assets/vendor.65bdc0e9.js"]);default:return new Promise(function(t,e){(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(e.bind(null,new Error("Unknown variable dynamic import: "+n)))})}}const zn=n=>async()=>{let t=Promise.resolve(null);try{t=await nd(`../src/pages/${n}/index.tsx`)}catch{t=Promise.reject()}return t};var rd=[{path:"/",component:zn("home")},{path:"/home",component:zn("home")},{path:"/login",component:zn("login")},{path:"/:pathMatch(.*)*",component:zn("404"),meta:{title:"404 Not Fund"}}],Gr=Gu({history:Ku(),routes:rd}),id=Ya({name:"SvgIcon",props:{prefix:{type:String,default:"icon"},name:{type:String,required:!0},color:{type:String,default:"#333"},onClick:{type:Function,default:()=>{}}},render(){const{name:n,prefix:t,color:e}=this,r=`#${t}-${n}`;return wi("svg",ju(this.$attrs,{onClick:this.onClick,"aria-hidden":"true",style:{color:e}}),[wi("use",{href:r,fill:e},null)])}}),od={install(n){n.component("SvgIcon",id)}};const vo="live_admin_token",Wa=()=>sessionStorage.getItem(vo);function ep(n){return sessionStorage.setItem(vo,n)}function Za(){return sessionStorage.removeItem(vo)}let In=0,Qa;const sd=n=>{if(In===0){const t=Object.assign({lock:!0,text:"\u52A0\u8F7D\u4E2D...",background:"rgba(0, 0, 0, 0.7)"},n);Qa=qu.service(oe({},t))}In++},ad=()=>{In<=0||(In--,In===0&&Qa.close())};var Pi;(function(n){n[n.READ=1]="READ",n[n.LISTENED=2]="LISTENED",n[n.DOWNLOADED=4]="DOWNLOADED",n[n.RETRIEVED=8]="RETRIEVED",n[n.UNREAD=0]="UNREAD"})(Pi||(Pi={}));var me,pi,Un=Pi,cd=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],ud=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],dd=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],Vs={"RC:TxtMsg":{isCounted:!0,isPersited:!0},"RC:ImgMsg":{isCounted:!0,isPersited:!0},"RC:VcMsg":{isCounted:!0,isPersited:!0},"RC:ImgTextMsg":{isCounted:!0,isPersited:!0},"RC:FileMsg":{isCounted:!0,isPersited:!0},"RC:HQVCMsg":{isCounted:!0,isPersited:!0},"RC:LBSMsg":{isCounted:!0,isPersited:!0},"RC:PSImgTxtMsg":{isCounted:!0,isPersited:!0},"RC:PSMultiImgTxtMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpOpendMsg":{isCounted:!0,isPersited:!0},"RC:CombineMsg":{isCounted:!0,isPersited:!0},"RC:ReferenceMsg":{isCounted:!0,isPersited:!0},"RC:SightMsg":{isCounted:!0,isPersited:!0},"RC:GIFMsg":{isCounted:!0,isPersited:!0},"RC:InfoNtf":{isCounted:!1,isPersited:!0},"RC:ContactNtf":{isCounted:!1,isPersited:!0},"RC:ProfileNtf":{isCounted:!1,isPersited:!0},"RC:CmdNtf":{isCounted:!1,isPersited:!0},"RC:GrpNtf":{isCounted:!1,isPersited:!0},"RC:RcCmd":{isCounted:!1,isPersited:!0},"RC:CmdMsg":{isCounted:!1,isPersited:!1},"RC:TypSts":{isCounted:!1,isPersited:!1},"RC:PSCmd":{isCounted:!1,isPersited:!1},"RC:SRSMsg":{isCounted:!1,isPersited:!1},"RC:RRReqMsg":{isCounted:!1,isPersited:!1},"RC:RRRspMsg":{isCounted:!1,isPersited:!1},"RC:CsChaR":{isCounted:!1,isPersited:!1},"RC:CSCha":{isCounted:!1,isPersited:!1},"RC:CsEva":{isCounted:!1,isPersited:!1},"RC:CsContact":{isCounted:!1,isPersited:!1},"RC:CsHs":{isCounted:!1,isPersited:!1},"RC:CsHsR":{isCounted:!1,isPersited:!1},"RC:CsSp":{isCounted:!1,isPersited:!1},"RC:CsEnd":{isCounted:!1,isPersited:!1},"RC:CsUpdate":{isCounted:!1,isPersited:!1},"RC:ReadNtf":{isCounted:!1,isPersited:!1},"RC:chrmKVNotiMsg":{isCounted:!1,isPersited:!1},"RC:VCAccept":{isCounted:!1,isPersited:!1},"RC:VCRinging":{isCounted:!1,isPersited:!1},"RC:VCSummary":{isCounted:!1,isPersited:!1},"RC:VCHangup":{isCounted:!1,isPersited:!1},"RC:VCInvite":{isCounted:!1,isPersited:!1},"RC:VCModifyMedia":{isCounted:!1,isPersited:!1},"RC:VCModifyMem":{isCounted:!1,isPersited:!1},"RC:MsgExMsg":{isCounted:!1,isPersited:!1},"RC:RRMsg":{isCounted:!1,isPersited:!1},"RC:LogCmdMsg":{isCounted:!1,isPersited:!1},"RC:InterceptMsg":{isCounted:!1,isPersited:!1}},ld=["RC:TypSts","RC:InterceptMsg"];(function(n){n.WEBSOCKET="websocket",n.COMET="comet"})(me||(me={}));var Kr=function(n){return pi||(pi={set:function(t,e){n.localStorage.setItem(t,JSON.stringify(e))},get:function(t){var e;try{e=JSON.parse(n.localStorage.getItem(t))}catch{e=null}return e},remove:function(t){return n.localStorage.removeItem(t)},getKeys:function(){var t=[];for(var e in n.localStorage)t.push(e);return t}}),pi},hd=function(){function n(t){this._caches={},t&&(this._caches=t)}return n.prototype.set=function(t,e){this._caches[t]=e},n.prototype.remove=function(t){var e=this.get(t);return delete this._caches[t],e},n.prototype.get=function(t){return this._caches[t]},n.prototype.getKeys=function(){var t=[];for(var e in this._caches)t.push(e);return t},n}(),Li=function(){function n(t,e){var r,i=e?"".concat("RCV4-").concat(e):"RCV4-";this._rootStorage=Kr(t);var o=this._rootStorage.get(i)||{};this._cache=new hd(((r={})[i]=o,r)),this._storageKey=i}return n.prototype._get=function(){var t=this._storageKey;return this._cache.get(t)||{}},n.prototype._set=function(t){var e=this._storageKey;t=t||{},this._cache.set(e,t),this._rootStorage.set(e,t)},n.prototype.set=function(t,e){var r=this._get();r[t]=e,this._set(r)},n.prototype.remove=function(t){var e=this._get();delete e[t],this._set(e)},n.prototype.clear=function(){var t=this._storageKey;this._rootStorage.remove(t),this._cache.remove(t)},n.prototype.get=function(t){return this._get()[t]},n.prototype.getKeys=function(){var t=this._get(),e=[];for(var r in t)e.push(r);return e},n.prototype.getValues=function(){return this._get()||{}},n}(),Ui=function(n,t){return Ui=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},Ui(n,t)};function It(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=n}Ui(n,t),n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var pt=function(){return pt=Object.assign||function(n){for(var t,e=1,r=arguments.length;e0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1] ".concat(e))||this}return It(t,n),t})(Error);var Bs=function(n,t,e){if(t===void 0||e===void 0)return n.toUpperCase();var r=n.slice(t,e);return n=n.replace(r,function(i){return i.toUpperCase()})},Xa=function(n,t){t===void 0&&(t="utf-8");var e,r=0;if(t==="utf-16")for(var i=0,o=n.length;i22&&(n=n.slice(0,22)),n.length<22)for(var t=22-n.length,e=0;e0&&i.indexs.forEach(function(c){o.createIndex(c.indexName,c.key,{unique:c.unique})})}}(t,We,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}var Nt,Ye,$t,yr,ki,yo=function(){function n(){}return n.init=function(){if(typeof window!="undefined"&&window&&window.indexedDB){var t=window.indexedDB.open("RC_ENGINE_DB",2);t.onerror=function(e){console.warn("open indexDB request failed "+e.target.error)},t.onsuccess=function(e){n._db=e.target.result,n._db&&(n._db.onclose=function(r){var i;console.warn("The database ".concat((i=n._db)===null||i===void 0?void 0:i.name," has unexpectedly closed."),r),n._db=null,n._instance=null},n._db.onerror=function(r){var i;console.warn("The database ".concat((i=n._db)===null||i===void 0?void 0:i.name," has opening error."),r),n._db=null,n._instance=null},n._db.onabort=function(r){var i;console.warn("The database ".concat((i=n._db)===null||i===void 0?void 0:i.name," has opening aborted."),r),n._db=null,n._instance=null}),n._instance=new n},t.onupgradeneeded=function(e){n._db=e.target.result,pd(e)}}else console.debug("IndexDB is not currently supported in the environment!")},n.getInstance=function(){return n._instance},n.prototype.addList=function(t,e){return new Promise(function(r){if(n._db){var i=n._db.transaction([t],"readwrite"),o=i.objectStore(t);e.forEach(function(s){o==null||o.add(s)}),i.oncomplete=function(s){r(!0)},i.onerror=function(s){r(!1)}}else r(!1)})},n.prototype.getRangeData=function(t,e,r,i){return new Promise(function(o){if(n._db){var s=n._db.transaction([t],"readwrite").objectStore(t),c=IDBKeyRange.bound(r,i),d=s.index(e),l=[],h=d.openCursor(c);h.onsuccess=function(a){var u=a.target.result;u?(l.push(u.value),u.continue()):o(l)},h.onerror=function(a){console.error(a),o([])}}else o([])})},n.prototype.getCount=function(t,e){return new Promise(function(r){if(n._db){var i=n._db.transaction([t],"readonly").objectStore(t).count();i.onsuccess=function(){r(i.result)},i.onerror=function(o){console.error(o),r(0)}}else r(0)})},n.prototype.removeFirstData=function(t,e,r){return new Promise(function(i){if(n._db){var o=n._db.transaction([t],"readwrite").objectStore(t),s=o.getAllKeys(IDBKeyRange.lowerBound(0),r);s.onsuccess=function(){var c=s.result;c.length>0&&(o.delete(IDBKeyRange.bound(c[0],c[c.length-1])).onsuccess=function(){i(!0)})}}else i(!1)})},n._db=null,n}(),Hs=function(){function n(){}return n.compress=function(t){for(var e=this,r={},i=0;i0){var _=c.join("");if(c=[],_.length>26){var v=e.numberEncode(_.length),T=String.fromCharCode(e.dataType.NormalExt|v.length);s.push(T+v)}else{var y=String.fromCharCode(e.dataType.Normal|_.length);s.push(y)}s.push(_)}},l=0;l=h.length)c.push(t.substr(l,h.length)),l+=h.length;else{d();var p=String.fromCharCode(e.dataType.Compressed|a.length<<2|u.length);s.push(p+a+u),l+=h.length}}}d();var f=e.numberEncode(t.length),m=String.fromCharCode(e.dataType.Tail|f.length);return s.push(m+f),s.join("")},n.uncompress=function(t){var e=this,r=0,i="";t:do{var o=t.charCodeAt(r++),s=o&e.dataType.Mark,c=15&o,d=void 0;switch(s){case e.dataType.Compressed:var l=c>>2,h=3&c;if(l===0||h===0)throw new Error("Data parsing error,at "+r);var a=e.numberDecode(t.substr(r,l)),u=e.numberDecode(t.substr(r+=l,h));if((a=i.length-a)+u>i.length)throw new Error("Data parsing error,at "+r);r+=h,i+=i.substr(a,u);break;case e.dataType.Tail:if((d=e.numberDecode(t.substr(r,c)))!==i.length)throw console.log(i.length),console.log(d),new Error("Data parsing error,at "+r);r+=c;break t;case e.dataType.NormalExt:d=e.numberDecode(t.substr(r,c)),i+=t.substr(r+=c,d),r+=d;break;case e.dataType.Normal:i+=t.substr(r,c),r+=c;break;case e.dataType.Mark:if(c>10)throw new Error("Data parsing error,at "+r);i+=t.substr(r,16+c),r+=16+c;break;default:throw new Error("Data parsing error,at "+r+" header:"+s)}}while(r=e.length-1)return i;var o=t[e.charAt(r)+e.charAt(r+1)];if(o[0]===r)return i;for(var s=e.length-r,c=0,d=o.length;cthis.max)){var a=Math.min(s,h);if(a<=i.length)break;if(!(i.length>2&&e.charAt(l+i.length-1)!==e.charAt(r+i.length-1))){for(var u=2,p=u;p=i.length&&(i.length=u,i.offset=l)}}}return i},n.numberEncode=function(t){var e=this,r=[],i=0;do i=t%e.scale,r.push(e.chars.charAt(i)),t=(t-i)/e.scale;while(t>0);return r.join("")},n.numberDecode=function(t){for(var e=0,r=0,i=t.length-1;i>=0;i--){if((r=this.chars.indexOf(t.charAt(i)))===-1)throw new Error('decode number error, data is "'+t+'"');e=e*this.scale+r}return e},n.dataType={Tail:48,Compressed:64,NormalExt:80,Normal:96,Mark:112},n.chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n.scale=n.chars.length,n.max=238327,n}(),_e=function(){function n(t){this.info=t,this.logUrl="logcollection.ronghub.com",this.level=1,this.itv=30,this.times=5,this.deviceId="",this.deviceInfo="",this.logSwitch=0,this.logUrl=t.logPolicy.url||this.logUrl,this.level=t.logPolicy.level||this.level,this.itv=t.logPolicy.itv||this.itv,this.times=t.logPolicy.times||this.times,this.deviceId=Di(t.runtime),this.logSwitch=t.logSwitch;var e=Fs(t.runtime);this.deviceInfo="".concat(e.type,"|").concat(e.version,"|").concat(t==null?void 0:t.sessionId)}return n.prototype.updateUploadLogAttr=function(t){var e=t.logPolicy,r=t.logSwitch,i=t.runtime,o=t.sessionId,s=o===void 0?"":o,c=t.userId;if(e){var d=e.url,l=e.level,h=e.itv,a=e.times;this.logUrl=d||this.logUrl,this.level=l||this.level,this.itv=h||this.itv,this.times=a||this.times}if(r&&(this.logSwitch=r),i){this.deviceId=Di(i);var u=Fs(i);this.deviceInfo="".concat(u.type,"|").concat(u.version,"|").concat(s)}c&&(this.info.userId=c)},n.init=function(t){return n.reportSwitch=!0,n._instance||(n._instance=new n(t)),n._instance},n.getInstance=function(){return n._instance},n.prototype.reportRealtimeLog=function(t){var e=this;if(t.length===0||!this.logUrl)return Promise.resolve();var r=Hs.compress(t.map(function(s){return s.content}).join("")),i=Ue(this.logUrl)?"":"https://",o="".concat(i).concat(this.logUrl,"?version=").concat(this.info.version,"&appkey=").concat(this.info.appkey,"&userId=").concat(this.info.userId,"&deviceId=").concat(this.deviceId,"&deviceInfo=").concat(this.deviceInfo,"&platform=Web");return this.info.runtime.httpReq({method:"POST",url:o,body:r}).then(function(s){var c=s.data;c&&(c=JSON.parse(c),e.itv=c.nextTime,e.level=c.level,e.logSwitch=c.logSwitch,n.currentRTTimes=1)})},n.prototype.reportFullLog=function(t){return V(this,void 0,void 0,function(){var e,r,i,o,s,c,d,l,h,a,u=this;return B(this,function(p){switch(p.label){case 0:return e=t.startTime,r=t.endTime,i=t.platform,o=t.logId,s=t.uri,c=yo.getInstance(),i.toLowerCase()==="web"&&c?e>r?[2]:[4,c.getRangeData(We,"time",e,r)]:[2];case 1:return d=(d=p.sent()).filter(function(f){return!f.userId||f.userId===u.info.userId}),l=Hs.compress(d.map(function(f){return f.content}).join("")||"no data"),h=1,[2,(a=function(){if(h>3||!n.reportSwitch)return Promise.resolve();var f=s||u.logUrl,m=Ue(f)?"":"https://",_="".concat(m).concat(f,"?version=").concat(u.info.version,"&appkey=").concat(u.info.appkey,"&userId=").concat(u.info.userId,"&logId=").concat(o,"&deviceId=").concat(u.deviceId,"&deviceInfo=").concat(u.deviceInfo,"&platform=Web"),v=5e3*(h-1);return h++,new Promise(function(T,y){setTimeout(function(){n.reportSwitch&&u.info.runtime.httpReq({url:_,method:"POST",body:l}).then(function(){T()}).catch(function(w){y(w),a()})},v)})})()]}})})},n.prototype.distroy=function(){n.currentRTTimes=1,n.reportSwitch=!1},n.currentRTTimes=1,n.reportSwitch=!1,n}();(function(n){n[n.LOG=0]="LOG",n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR",n[n.FATAL=4]="FATAL",n[n.STATISTICS=6]="STATISTICS",n[n.NONE=1e3]="NONE"})(Nt||(Nt={})),function(n){n.IM="IM",n.RTC="RTC"}(Ye||(Ye={})),function(n){n[n.PRIVATE=1]="PRIVATE",n[n.OPEN=0]="OPEN"}($t||($t={})),function(n){n[n.NAVI=1]="NAVI",n[n.TCP=2]="TCP",n[n.WS=3]="WS"}(yr||(yr={})),function(n){n[n.NONE=0]="NONE",n[n.PRIVATE=1]="PRIVATE",n[n.DISCUSSION=2]="DISCUSSION",n[n.GROUP=3]="GROUP",n[n.CHATROOM=4]="CHATROOM",n[n.CUSTOMER_SERVICE=5]="CUSTOMER_SERVICE",n[n.SYSTEM=6]="SYSTEM",n[n.APP_PUBLIC_SERVICE=7]="APP_PUBLIC_SERVICE",n[n.PUBLIC_SERVICE=8]="PUBLIC_SERVICE",n[n.ULTRA_GROUP=10]="ULTRA_GROUP",n[n.RTC_ROOM=12]="RTC_ROOM"}(ki||(ki={}));var xi,Y=ki;(function(n){n[n.IMAGE=1]="IMAGE",n[n.AUDIO=2]="AUDIO",n[n.VIDEO=3]="VIDEO",n[n.FILE=4]="FILE",n[n.SIGHT=5]="SIGHT",n[n.COMBINE_HTML=6]="COMBINE_HTML"})(xi||(xi={}));var Be,wt=xi,Bt=function(n){return typeof n=="string"},Er=function(n){return typeof n=="boolean"},mt=function(n){return typeof n=="number"&&!isNaN(n)},Ht=function(n){return Object.prototype.toString.call(n).indexOf("Array")!==-1},nc=function(n){return Object.prototype.toString.call(n)==="[object ArrayBuffer]"},Ft=function(n){return Bt(n)&&n.length>0},Rt=function(n){return Object.prototype.toString.call(n)==="[object Object]"},Cr=function(n){return Object.prototype.toString.call(n)==="[object Function]"},ct=function(n){return n===void 0||Object.prototype.toString.call(n)==="[object Undefined]"},$s=function(n){return Object.prototype.toString.call(n)==="[object Null]"},Ue=function(n){return Bt(n)&&/https?:\/\//.test(n)},Ze=function(n){for(var t in n)return!0;return!1},fd=function(n){return mt(n)&&Object.prototype.hasOwnProperty.call(wt,n)},fi=function(n){var t=!1,e=!1,r=!1;if(Rt(n)){var i=Object.keys(n).length;for(var o in t=i>20,n)if(e||(e=Bt(o)&&!/^[A-Za-z0-9_=+-]+$/.test(o)),!r){var s=n[o];r=o.length>32||s.length>4096}}return{isExceedLimit:t,isIllgalEx:e,isExKeyOrValLengthExceedLimit:r}},pr={};console&&((Be={})[Nt.DEBUG]=console.debug.bind(console),Be[Nt.INFO]=console.info.bind(console),Be[Nt.WARN]=console.warn.bind(console),Be[Nt.ERROR]=console.error.bind(console),Be[Nt.FATAL]=console.log.bind(console),pr=Be);var Vi,Gs=function(n){return Bt(n)||mt(n)||ct(n)||Er(n)?n:n instanceof Error?JSON.stringify({name:n.name,message:n.message,stack:n.stack}):JSON.stringify(n)},Le=function(){function n(t,e,r){this.tag=t,this.type=e,this.initiator=r,this._outLevel=Nt.WARN,this.debug=this.log.bind(this,Nt.DEBUG),this.info=this.log.bind(this,Nt.INFO),this.warn=this.log.bind(this,Nt.WARN),this.error=this.log.bind(this,Nt.ERROR),this.fatal=this.log.bind(this,Nt.FATAL),this.statisticsCaches={},this.baseStatisData={sdkPrivate:$t.OPEN,serverPrivate:$t.OPEN,bundleId:"lib-next"}}return n.init=function(t){n.userId=t},n.reset=function(){n.userId=""},n.prototype._defaultStdout=function(t,e){for(var r=[],i=2;i=1e3&&(e=function(l,h,a){if(a===void 0&&(a="utf-8"),!l||!h)return"";var u=a==="utf-8"?3:2,p=0,f=0,m="";for(f=0;f255?p+=u:p++,p>h)return m;m+=l.charAt(f)}return l}(e,1e3));var s=JSON.stringify({message:e,userId:n.userId}).replace(/"/g,'""'),c=/^[\w]+-[\w]+-[\w]+?/.test(r)?r:"".concat(this.initiator||"L","-").concat(r,"-O"),d={sessionId:n.sessionId,time:o,level:4-t,content:"".concat(n.sessionId,",").concat(Date.now(),",").concat(i,",").concat(4-t,",").concat(c,',"').concat(s,`" `),userId:n.userId};n.databaseLogList.push(d),(n.databaseLogList.length>=100||t===Nt.FATAL)&&this.__insertLogIntoDatabase()},n.prototype.__insertLogIntoDatabase=function(){return V(this,void 0,void 0,function(){var t,e,r;return B(this,function(i){switch(i.label){case 0:return t=Pe([],n.databaseLogList,!0),n.databaseLogList=[],(e=yo.getInstance())?[4,e.addList(We,t)]:[3,3];case 1:return r=i.sent(),[4,e.getCount(We,"time")];case 2:return i.sent()>1e5&&e.removeFirstData(We,"time",2e3),[2,r];case 3:return[2,!1]}})})},n.prototype.setLogLevel=function(t){this._outLevel=typeof t!="number"?Nt.WARN:t},n.prototype.setLogStdout=function(t){this._logStdout=t},n.prototype.log=function(t){for(var e=[],r=1;rNt.DEBUG&&this.__pushLocalLog(t,e.map(Gs).join(" "),this.tag),!(t=600&&(n.realTimeLogList=n.realTimeLogList.slice(-500))},n.prototype.set=function(t,e){this.warn("logger.set has being deprecated!")},n.prototype.setStdout=function(t){this._stdout=t},n.prototype.__clearRealTimeLog=function(){n.realTimeLogList=[]},n.prototype.initReportLog=function(t){n._reportLog=_e.init(pt(pt({},t),{sessionId:n.sessionId})),this.startReport()},n.prototype.updateUploadLogAttr=function(t){n._reportLog&&n._reportLog.updateUploadLogAttr(t)},n.prototype.startReport=function(){var t=this;if(n._reportLog&&n._reportLog.logSwitch&&_e.reportSwitch){var e=n._reportLog.itv*Math.pow(2,_e.currentRTTimes-1);_e.currentRTTimes "+i),t.startReport()})},1e3*e)}},n.prototype.reportStatisticsLog=function(t,e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d=this;return B(this,function(l){return t&&n._reportLog?(e=Rt(e)?JSON.stringify(e):e,r=4-Nt.STATISTICS,this.__pushLocalLog(r,String(e),t),i=JSON.stringify({message:e}).replace(/"/g,'""'),i='"'.concat(i,'"'),o=this.type,this.type||(o=["RCRTCLog","RCCall","RCRTC","RTC-A"].includes(this.tag)?Ye.RTC:Ye.IM),s={level:r,content:[n.sessionId,Date.now(),o,r,t,i].join()+` `},n.realTimeLogList.push(s),c=n.realTimeLogList.filter(function(h){return h.level<=n._reportLog.level}),this.__clearRealTimeLog(),n._reportLog.reportRealtimeLog(c).then(function(){d.debug("report\xA0real-time\xA0log\xA0success")}).catch(function(h){d.debug("report real-time log error -> "+h)}),[2]):[2]})})},n.prototype.updateStatisticsBaseData=function(t){this.baseStatisData.sdkPrivate=t.sdkPrivate===$t.PRIVATE?$t.PRIVATE:$t.OPEN,this.baseStatisData.serverPrivate=t.serverPrivate===$t.PRIVATE?$t.PRIVATE:$t.OPEN,t.bundleId&&(this.baseStatisData.bundleId=t.bundleId)},n.prototype.getStatisticsBaseData=function(){return this.baseStatisData},n.prototype.setStatisticsData=function(t,e,r){e===void 0&&(e={}),r===void 0&&(r=!1),Rt(e)&&t&&(this.statisticsCaches[t]&&!r||(this.statisticsCaches[t]={}),this.statisticsCaches[t]=pt(pt({},this.statisticsCaches[t]),e))},n.prototype.getStatisticsData=function(t){return this.statisticsCaches[t]||{}},n.databaseLogList=[],n.realTimeLogList=[],n.sessionId=ec(),n.userId="",n}(),H=new Le("RCLog"),Fn=function(){function n(){this._map={}}return n.prototype.on=function(t,e,r){var i=this._map[t]||(this._map[t]=[]);i.some(function(o){return o.listener===e&&o.target===r})||i.push({listener:e,target:r})},n.prototype.once=function(t,e,r){var i=this._map[t]||(this._map[t]=[]);i.some(function(o){return o.listener===e&&o.target===r})||i.push({listener:e,target:r,once:!0})},n.prototype.off=function(t,e,r){var i=this._map[t];i&&((i=i.filter(function(o){return o.listener!==e||o.target!==r})).length?this._map[t]=i:delete this._map[t])},n.prototype.emit=function(t){for(var e=[],r=1;r=0;o-=1){var s=i[o],c=s.target,d=s.once,l=s.listener;d&&i.splice(o,1);try{l.call.apply(l,Pe([c],e,!1))}catch(h){H.error(h)}}},n.prototype.removeAll=function(t){delete this._map[t]},n.prototype.clear=function(){Object.keys(this._map).forEach(this.removeAll,this)},n}();(function(n){n[n.SEND=1]="SEND",n[n.RECEIVE=2]="RECEIVE"})(Vi||(Vi={}));var Bi,zt=Vi;(function(n){n[n.TIMEOUT=-1]="TIMEOUT",n[n.UNKNOWN=-2]="UNKNOWN",n[n.PARAMETER_ERROR=-3]="PARAMETER_ERROR",n[n.EXTRA_METHOD_UNDEFINED=-4]="EXTRA_METHOD_UNDEFINED",n[n.MAIN_PROCESS_ERROR=-5]="MAIN_PROCESS_ERROR",n[n.PARAMETER_CHANGED=-6]="PARAMETER_CHANGED",n[n.SUCCESS=0]="SUCCESS",n[n.RC_MSG_UNAUTHORIZED=20406]="RC_MSG_UNAUTHORIZED",n[n.RC_DISCUSSION_GROUP_ID_INVALID=20407]="RC_DISCUSSION_GROUP_ID_INVALID",n[n.SEND_FREQUENCY_TOO_FAST=20604]="SEND_FREQUENCY_TOO_FAST",n[n.NOT_IN_DISCUSSION=21406]="NOT_IN_DISCUSSION",n[n.FORBIDDEN_IN_GROUP=22408]="FORBIDDEN_IN_GROUP",n[n.RECALL_MESSAGE=25101]="RECALL_MESSAGE",n[n.NOT_IN_GROUP=22406]="NOT_IN_GROUP",n[n.NOT_IN_CHATROOM=23406]="NOT_IN_CHATROOM",n[n.FORBIDDEN_IN_CHATROOM=23408]="FORBIDDEN_IN_CHATROOM",n[n.RC_CHATROOM_USER_KICKED=23409]="RC_CHATROOM_USER_KICKED",n[n.RC_CHATROOM_NOT_EXIST=23410]="RC_CHATROOM_NOT_EXIST",n[n.RC_CHATROOM_IS_FULL=23411]="RC_CHATROOM_IS_FULL",n[n.RC_CHATROOM_PATAMETER_INVALID=23412]="RC_CHATROOM_PATAMETER_INVALID",n[n.CHATROOM_GET_HISTORYMSG_ERROR=23413]="CHATROOM_GET_HISTORYMSG_ERROR",n[n.CHATROOM_NOT_OPEN_HISTORYMSG_STORE=23414]="CHATROOM_NOT_OPEN_HISTORYMSG_STORE",n[n.CHATROOM_KV_EXCEED=23423]="CHATROOM_KV_EXCEED",n[n.CHATROOM_KV_OVERWRITE_INVALID=23424]="CHATROOM_KV_OVERWRITE_INVALID",n[n.CHATROOM_KV_STORE_NOT_OPEN=23426]="CHATROOM_KV_STORE_NOT_OPEN",n[n.CHATROOM_KEY_NOT_EXIST=23427]="CHATROOM_KEY_NOT_EXIST",n[n.CHATROOM_KV_SET_ERROR=23431]="CHATROOM_KV_SET_ERROR",n[n.SENSITIVE_SHIELD=21501]="SENSITIVE_SHIELD",n[n.SENSITIVE_REPLACE=21502]="SENSITIVE_REPLACE",n[n.JOIN_IN_DISCUSSION=21407]="JOIN_IN_DISCUSSION",n[n.CREATE_DISCUSSION=21408]="CREATE_DISCUSSION",n[n.INVITE_DICUSSION=21409]="INVITE_DICUSSION",n[n.GET_USERINFO_ERROR=23407]="GET_USERINFO_ERROR",n[n.REJECTED_BY_BLACKLIST=405]="REJECTED_BY_BLACKLIST",n[n.RC_NET_CHANNEL_INVALID=30001]="RC_NET_CHANNEL_INVALID",n[n.RC_NET_UNAVAILABLE=30002]="RC_NET_UNAVAILABLE",n[n.RC_MSG_RESP_TIMEOUT=30003]="RC_MSG_RESP_TIMEOUT",n[n.RC_HTTP_SEND_FAIL=30004]="RC_HTTP_SEND_FAIL",n[n.RC_HTTP_REQ_TIMEOUT=30005]="RC_HTTP_REQ_TIMEOUT",n[n.RC_HTTP_RECV_FAIL=30006]="RC_HTTP_RECV_FAIL",n[n.RC_NAVI_RESOURCE_ERROR=30007]="RC_NAVI_RESOURCE_ERROR",n[n.RC_NODE_NOT_FOUND=30008]="RC_NODE_NOT_FOUND",n[n.RC_DOMAIN_NOT_RESOLVE=30009]="RC_DOMAIN_NOT_RESOLVE",n[n.RC_SOCKET_NOT_CREATED=30010]="RC_SOCKET_NOT_CREATED",n[n.RC_SOCKET_DISCONNECTED=30011]="RC_SOCKET_DISCONNECTED",n[n.RC_PING_SEND_FAIL=30012]="RC_PING_SEND_FAIL",n[n.RC_PONG_RECV_FAIL=30013]="RC_PONG_RECV_FAIL",n[n.RC_MSG_SEND_FAIL=30014]="RC_MSG_SEND_FAIL",n[n.RC_MSG_CONTENT_EXCEED_LIMIT=30016]="RC_MSG_CONTENT_EXCEED_LIMIT",n[n.RC_CONN_ACK_TIMEOUT=31e3]="RC_CONN_ACK_TIMEOUT",n[n.RC_CONN_PROTO_VERSION_ERROR=31001]="RC_CONN_PROTO_VERSION_ERROR",n[n.RC_CONN_ID_REJECT=31002]="RC_CONN_ID_REJECT",n[n.RC_CONN_SERVER_UNAVAILABLE=31003]="RC_CONN_SERVER_UNAVAILABLE",n[n.RC_CONN_USER_OR_PASSWD_ERROR=31004]="RC_CONN_USER_OR_PASSWD_ERROR",n[n.RC_CONN_NOT_AUTHRORIZED=31005]="RC_CONN_NOT_AUTHRORIZED",n[n.RC_CONN_REDIRECTED=31006]="RC_CONN_REDIRECTED",n[n.RC_CONN_PACKAGE_NAME_INVALID=31007]="RC_CONN_PACKAGE_NAME_INVALID",n[n.RC_CONN_APP_BLOCKED_OR_DELETED=31008]="RC_CONN_APP_BLOCKED_OR_DELETED",n[n.RC_CONN_USER_BLOCKED=31009]="RC_CONN_USER_BLOCKED",n[n.RC_DISCONN_KICK=31010]="RC_DISCONN_KICK",n[n.RC_DISCONN_EXCEPTION=31011]="RC_DISCONN_EXCEPTION",n[n.RC_APP_AUTH_NOT_PASS=31026]="RC_APP_AUTH_NOT_PASS",n[n.RC_OTP_USED=31027]="RC_OTP_USED",n[n.RC_PLATFORM_ERROR=31028]="RC_PLATFORM_ERROR",n[n.RC_QUERY_ACK_NO_DATA=32001]="RC_QUERY_ACK_NO_DATA",n[n.RC_MSG_DATA_INCOMPLETE=32002]="RC_MSG_DATA_INCOMPLETE",n[n.BIZ_ERROR_CLIENT_NOT_INIT=33001]="BIZ_ERROR_CLIENT_NOT_INIT",n[n.BIZ_ERROR_DATABASE_ERROR=33002]="BIZ_ERROR_DATABASE_ERROR",n[n.BIZ_ERROR_INVALID_PARAMETER=33003]="BIZ_ERROR_INVALID_PARAMETER",n[n.BIZ_ERROR_NO_CHANNEL=33004]="BIZ_ERROR_NO_CHANNEL",n[n.BIZ_ERROR_RECONNECT_SUCCESS=33005]="BIZ_ERROR_RECONNECT_SUCCESS",n[n.BIZ_ERROR_CONNECTING=33006]="BIZ_ERROR_CONNECTING",n[n.MSG_ROAMING_SERVICE_UNAVAILABLE=33007]="MSG_ROAMING_SERVICE_UNAVAILABLE",n[n.MSG_INSERT_ERROR=33008]="MSG_INSERT_ERROR",n[n.MSG_DEL_ERROR=33009]="MSG_DEL_ERROR",n[n.TAG_EXISTS=33101]="TAG_EXISTS",n[n.TAG_NOT_EXIST=33100]="TAG_NOT_EXIST",n[n.NO_TAG_IN_CONVER=33102]="NO_TAG_IN_CONVER",n[n.CONVER_REMOVE_ERROR=34001]="CONVER_REMOVE_ERROR",n[n.CONVER_GETLIST_ERROR=34002]="CONVER_GETLIST_ERROR",n[n.CONVER_SETOP_ERROR=34003]="CONVER_SETOP_ERROR",n[n.CONVER_TOTAL_UNREAD_ERROR=34004]="CONVER_TOTAL_UNREAD_ERROR",n[n.CONVER_TYPE_UNREAD_ERROR=34005]="CONVER_TYPE_UNREAD_ERROR",n[n.CONVER_ID_TYPE_UNREAD_ERROR=34006]="CONVER_ID_TYPE_UNREAD_ERROR",n[n.CONVER_CLEAR_ERROR=34007]="CONVER_CLEAR_ERROR",n[n.EXPANSION_LIMIT_EXCEET=34010]="EXPANSION_LIMIT_EXCEET",n[n.MESSAGE_KV_NOT_SUPPORT=34008]="MESSAGE_KV_NOT_SUPPORT",n[n.CLEAR_HIS_TIME_ERROR=34011]="CLEAR_HIS_TIME_ERROR",n[n.CONVER_OUT_LIMIT_ERROR=34013]="CONVER_OUT_LIMIT_ERROR",n[n.CONVER_GET_ERROR=35021]="CONVER_GET_ERROR",n[n.GROUP_SYNC_ERROR=35001]="GROUP_SYNC_ERROR",n[n.GROUP_MATCH_ERROR=35002]="GROUP_MATCH_ERROR",n[n.READ_RECEIPT_ERROR=35003]="READ_RECEIPT_ERROR",n[n.PACKAGE_ENVIRONMENT_ERROR=35006]="PACKAGE_ENVIRONMENT_ERROR",n[n.CAN_NOT_RECONNECT=35007]="CAN_NOT_RECONNECT",n[n.SERVER_UNAVAILABLE=35008]="SERVER_UNAVAILABLE",n[n.HOSTNAME_ERROR=35009]="HOSTNAME_ERROR",n[n.HAS_OHTER_SAME_CLIENT_ON_LINE=35010]="HAS_OHTER_SAME_CLIENT_ON_LINE",n[n.METHOD_NOT_AVAILABLE=35011]="METHOD_NOT_AVAILABLE",n[n.METHOD_NOT_SUPPORT=35012]="METHOD_NOT_SUPPORT",n[n.MSG_LIMIT_ERROR=35013]="MSG_LIMIT_ERROR",n[n.METHOD_ONLY_SUPPORT_ULTRA_GROUP=35014]="METHOD_ONLY_SUPPORT_ULTRA_GROUP",n[n.UPLOAD_FILE_FAILED=35020]="UPLOAD_FILE_FAILED",n[n.CHATROOM_ID_ISNULL=36001]="CHATROOM_ID_ISNULL",n[n.CHARTOOM_JOIN_ERROR=36002]="CHARTOOM_JOIN_ERROR",n[n.CHATROOM_HISMESSAGE_ERROR=36003]="CHATROOM_HISMESSAGE_ERROR",n[n.CHATROOM_KV_NOT_FOUND=36004]="CHATROOM_KV_NOT_FOUND",n[n.BLACK_ADD_ERROR=37001]="BLACK_ADD_ERROR",n[n.BLACK_GETSTATUS_ERROR=37002]="BLACK_GETSTATUS_ERROR",n[n.BLACK_REMOVE_ERROR=37003]="BLACK_REMOVE_ERROR",n[n.DRAF_GET_ERROR=38001]="DRAF_GET_ERROR",n[n.DRAF_SAVE_ERROR=38002]="DRAF_SAVE_ERROR",n[n.DRAF_REMOVE_ERROR=38003]="DRAF_REMOVE_ERROR",n[n.SUBSCRIBE_ERROR=39001]="SUBSCRIBE_ERROR",n[n.NOT_SUPPORT=39002]="NOT_SUPPORT",n[n.QNTKN_FILETYPE_ERROR=41001]="QNTKN_FILETYPE_ERROR",n[n.QNTKN_GET_ERROR=41002]="QNTKN_GET_ERROR",n[n.COOKIE_ENABLE=51001]="COOKIE_ENABLE",n[n.GET_MESSAGE_BY_ID_ERROR=61001]="GET_MESSAGE_BY_ID_ERROR",n[n.HAVNODEVICEID=24001]="HAVNODEVICEID",n[n.DEVICEIDISHAVE=24002]="DEVICEIDISHAVE",n[n.FEILD=24009]="FEILD",n[n.VOIPISNULL=24013]="VOIPISNULL",n[n.NOENGINETYPE=24010]="NOENGINETYPE",n[n.NULLCHANNELNAME=24011]="NULLCHANNELNAME",n[n.VOIPDYANMICERROR=24012]="VOIPDYANMICERROR",n[n.NOVOIP=24014]="NOVOIP",n[n.INTERNALERRROR=24015]="INTERNALERRROR",n[n.VOIPCLOSE=24016]="VOIPCLOSE",n[n.CLOSE_BEFORE_OPEN=51001]="CLOSE_BEFORE_OPEN",n[n.ALREADY_IN_USE=51002]="ALREADY_IN_USE",n[n.INVALID_CHANNEL_NAME=51003]="INVALID_CHANNEL_NAME",n[n.VIDEO_CONTAINER_IS_NULL=51004]="VIDEO_CONTAINER_IS_NULL",n[n.DELETE_MESSAGE_ID_IS_NULL=61001]="DELETE_MESSAGE_ID_IS_NULL",n[n.CANCEL=1]="CANCEL",n[n.REJECT=2]="REJECT",n[n.HANGUP=3]="HANGUP",n[n.BUSYLINE=4]="BUSYLINE",n[n.NO_RESPONSE=5]="NO_RESPONSE",n[n.ENGINE_UN_SUPPORTED=6]="ENGINE_UN_SUPPORTED",n[n.NETWORK_ERROR=7]="NETWORK_ERROR",n[n.REMOTE_CANCEL=11]="REMOTE_CANCEL",n[n.REMOTE_REJECT=12]="REMOTE_REJECT",n[n.REMOTE_HANGUP=13]="REMOTE_HANGUP",n[n.REMOTE_BUSYLINE=14]="REMOTE_BUSYLINE",n[n.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",n[n.REMOTE_ENGINE_UN_SUPPORTED=16]="REMOTE_ENGINE_UN_SUPPORTED",n[n.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",n[n.VOIP_NOT_AVALIABLE=18]="VOIP_NOT_AVALIABLE",n[n.CHATROOM_KV_STORE_NOT_ALL_SUCCESS=23428]="CHATROOM_KV_STORE_NOT_ALL_SUCCESS",n[n.CHATROOM_KV_STORE_OUT_LIMIT=23429]="CHATROOM_KV_STORE_OUT_LIMIT"})(Bi||(Bi={}));var Fi,R=Bi;(function(n){n[n.CONNECTED=0]="CONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.DISCONNECTED=2]="DISCONNECTED",n[n.NETWORK_UNAVAILABLE=3]="NETWORK_UNAVAILABLE",n[n.CONNECTION_CLOSED=4]="CONNECTION_CLOSED",n[n.KICKED_OFFLINE_BY_OTHER_CLIENT=6]="KICKED_OFFLINE_BY_OTHER_CLIENT",n[n.WEBSOCKET_UNAVAILABLE=7]="WEBSOCKET_UNAVAILABLE",n[n.WEBSOCKET_ERROR=8]="WEBSOCKET_ERROR",n[n.BLOCKED=9]="BLOCKED",n[n.DOMAIN_INCORRECT=12]="DOMAIN_INCORRECT",n[n.DISCONNECT_BY_SERVER=13]="DISCONNECT_BY_SERVER",n[n.REDIRECT=14]="REDIRECT",n[n.APPKEY_IS_FAKE=20]="APPKEY_IS_FAKE",n[n.ULTRALIMIT=1101]="ULTRALIMIT",n[n.REQUEST_NAVI=201]="REQUEST_NAVI",n[n.RESPONSE_NAVI=202]="RESPONSE_NAVI",n[n.RESPONSE_NAVI_ERROR=203]="RESPONSE_NAVI_ERROR",n[n.RESPONSE_NAVI_TIMEOUT=204]="RESPONSE_NAVI_TIMEOUT"})(Fi||(Fi={}));var Hi,Z=Fi,Mt={ACCEPTED:0,UNACCEPTABLE_PROTOCOL_VERSION:1,IDENTIFIER_REJECTED:2,SERVER_UNAVAILABLE:3,TOKEN_INCORRECT:4,NOT_AUTHORIZED:5,REDIRECT:6,PACKAGE_ERROR:7,APP_BLOCK_OR_DELETE:8,BLOCK:9,TOKEN_EXPIRE:10,DEVICE_ERROR:11,HOSTNAME_ERROR:12,HASOHTERSAMECLIENTONLINE:13,IN_OTHER_CLUSTER:15,APP_AUTH_NOT_PASS:16,OTP_USED:17,PLATFORM_ERROR:18};(function(n){n.TextMessage="RC:TxtMsg",n.VOICE="RC:VcMsg",n.HQ_VOICE="RC:HQVCMsg",n.IMAGE="RC:ImgMsg",n.GIF="RC:GIFMsg",n.RICH_CONTENT="RC:ImgTextMsg",n.LOCATION="RC:LBSMsg",n.FILE="RC:FileMsg",n.SIGHT="RC:SightMsg",n.COMBINE="RC:CombineMsg",n.CHRM_KV_NOTIFY="RC:chrmKVNotiMsg",n.LOG_COMMAND="RC:LogCmdMsg",n.EXPANSION_NOTIFY="RC:MsgExMsg",n.REFERENCE="RC:ReferenceMsg",n.RECALL="RC:RcCmd",n.READ_RECEIPT="RC:ReadNtf",n.READ_RECEIPT_REQUEST="RC:RRReqMsg",n.READ_RECEIPT_RESPONSE="RC:RRRspMsg",n.SYNC_READ_STATUS="RC:SRSMsg",n.GROUP_READ_RECEIPT_REQUEST="RC:RRMsg",n.CHATROOM_JOIN="RC:ChrmJoinNtf",n.CHATROOM_LEFT="RC:ChrmQuitNtf",n.CHATROOM_MERGE_CHANGE="RC:ChrmMemChange",n.TYPING_STATUS="RC:TypSts",n.INTERCEPT="RC:InterceptMsg"})(Hi||(Hi={}));var $i,Ut=Hi;(function(n){n[n.OPEN=1]="OPEN",n[n.CLOSE=2]="CLOSE"})($i||($i={}));var Gi,Yt=$i;(function(n){n[n.ALL_MESSAGE=-1]="ALL_MESSAGE",n[n.NOT_SET=0]="NOT_SET",n[n.AT_MESSAGE_NOTIFICATION=1]="AT_MESSAGE_NOTIFICATION",n[n.AT_USER_NOTIFICATION=2]="AT_USER_NOTIFICATION",n[n.AT_GROUP_ALL_USER_NOTIFICATION=4]="AT_GROUP_ALL_USER_NOTIFICATION",n[n.NOT_MESSAGE_NOTIFICATION=5]="NOT_MESSAGE_NOTIFICATION"})(Gi||(Gi={}));var Ki,ce=Gi;(function(n){n[n.ALL=1]="ALL",n[n.SINGAL=2]="SINGAL"})(Ki||(Ki={}));var ji,qr=Ki;(function(n){n[n.QINIU=1]="QINIU",n[n.ALI=2]="ALI",n[n.AWS=3]="AWS",n[n.STC=4]="STC"})(ji||(ji={}));var qi,Kt=ji;(function(n){n[n.UPDATE=1]="UPDATE",n[n.DELETE=2]="DELETE"})(qi||(qi={}));var Yi,Gt=qi;(function(n){n[n.QUIT=0]="QUIT",n[n.JOIN=1]="JOIN"})(Yi||(Yi={}));var Ks,js=Yi;(function(n){/*! 全局敏感词:命中了融云内置的全局敏感词 */n[n.GLOBAL=1]="GLOBAL",n[n.CUSTOM=2]="CUSTOM",n[n.THIRD_PARTY=3]="THIRD_PARTY"})(Ks||(Ks={}));var qs;(function(n){n[n.typing=0]="typing"})(qs||(qs={}));var Vt,Ys,zs;(function(n){n[n.RTC=0]="RTC",n[n.LIVE=2]="LIVE"})(Vt||(Vt={})),function(n){n[n.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",n[n.AUDIO=1]="AUDIO"}(Ys||(Ys={})),function(n){n[n.ANCHOR=1]="ANCHOR",n[n.AUDIENCE=2]="AUDIENCE"}(zs||(zs={}));var ae,Rr,zi,gd={"RC:VCAccept":"RC:VCAccept","RC:VCRinging":"RC:VCRinging","RC:VCSummary":"RC:VCSummary","RC:VCHangup":"RC:VCHangup","RC:VCInvite":"RC:VCInvite","RC:VCModifyMedia":"RC:VCModifyMedia","RC:VCModifyMem":"RC:VCModifyMem"};(function(n){n[n.ROOM=1]="ROOM",n[n.PERSON=2]="PERSON"})(ae||(ae={})),function(n){n[n.AnchorToViewer=1]="AnchorToViewer",n[n.ViewerToAnchor=2]="ViewerToAnchor"}(Rr||(Rr={})),function(n){n[n.KICK=0]="KICK",n[n.REFUSE=1]="REFUSE",n[n.COEXIST=2]="COEXIST"}(zi||(zi={}));var fr=typeof window!="undefined"&&window?(window.__RCVersionInfo||(window.__RCVersionInfo={}),window.__RCVersionInfo):{};fr.engine="5.3.1";var se,ut,Sn=function(){function n(){}return n.add=function(t,e){fr[t]=e},n.validEngine=function(t){var e=t.match(/\d+\.\d+\.\d+/);if(!e)return H.warn("The validation engine version '".concat(t,"' is invalid!")),!1;var r=e[0].split(".").map(function(i){return i.padStart(3,"0")}).join("");return fr.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map(function(i){return i.padStart(3,"0")}).join("")>=r},n.getInfo=function(){return fr},n}();(function(n){n[n.STRING=0]="STRING",n[n.ONLY_STRING=1]="ONLY_STRING",n[n.NUMBER=2]="NUMBER",n[n.BOOLEAN=3]="BOOLEAN",n[n.OBJECT=4]="OBJECT",n[n.ARRAY=5]="ARRAY",n[n.CALLBACK=6]="CALLBACK",n[n.CHANNEL_ID=7]="CHANNEL_ID"})(ut||(ut={}));var At,xt,jt,De,Me,md=((se={})[ut.STRING]=Ft,se[ut.ONLY_STRING]=Bt,se[ut.NUMBER]=mt,se[ut.BOOLEAN]=function(n){return typeof n=="boolean"},se[ut.OBJECT]=Rt,se[ut.ARRAY]=Ht,se[ut.CALLBACK]=function(n){var t=!0;return Rt(n)||(t=!1),(n=n||{}).onSuccess&&!Cr(n.onSuccess)&&(t=!1),n.onError&&!Cr(n.onError)&&(t=!1),t},se[ut.CHANNEL_ID]=function(n){var t=!1;return Bt(n)&&!/_/g.test(n)&&n.length<=20&&(t=!0),t},se),_d=function(n){function t(e){var r=n.call(this,e)||this;return r.name="RCAssertError",r}return It(t,n),t}(Error),dt=function(n,t,e,r){if(r===void 0&&(r=!1),!_t(n,t,e,r))throw new _d("'".concat(n,"' is invalid: ").concat(JSON.stringify(t)))},_t=function(n,t,e,r){r===void 0&&(r=!1),e=md[e]||e;var i=r&&!e(t)||!r&&!(ct(t)||t===null||e(t));return i&&H.error("'".concat(n,"' is invalid: ").concat(JSON.stringify(t))),!i},St=function(n){if(!Rt(n)||n.low===void 0||n.high===void 0)return n;var t=n.low;return t<0&&(t+=4294967296),t=t.toString(16),parseInt(n.high.toString(16)+"00000000".replace(new RegExp("0{"+t.length+"}$"),t),16)},vd=function(n,t){var e=Math.floor(1e3*Math.random()%1e4),r=tc(),i=function(d){d=d||"-";var l=new Date,h=l.getFullYear(),a=l.getMonth()+1,u=l.getDate();return"".concat(h).concat(d).concat(a).concat(d).concat(u)}(),o=new Date().getTime(),s="";if(t){var c=t.split(".");s="."+c[c.length-1]}return"".concat(n,"__RC-").concat(i,"_").concat(e,"_").concat(o).concat(r).concat(s)},Td=function(n,t){n===void 0&&(n={}),t===void 0&&(t={});var e=n.threadId,r=n.apnsCollapseId,i=n.category,o=n.richMediaUri,s=t.channelIdMi,c=t.channelIdHW,d=t.channelIdOPPO,l=t.typeVivo,h=t.googleConfig,a={};a["thread-id"]=e||"",a["apns-collapse-id"]=r||"",a.category=i||"",a.richMediaUri=o||"";var u={};u.collapse_key=h==null?void 0:h.collapseKey,u.imageUrl=h==null?void 0:h.imageUrl;var p=h==null?void 0:h.priority;p&&!["high","normal"].includes(p)&&(p="normal"),u.priority=p;var f=[{HW:{channelId:c||""}},{MI:{channelId:s||""}},{OPPO:{channelId:d||""}},{VIVO:{classification:l||""}},{APNS:a},{FCM:u}];return JSON.stringify(f)},Js=function(n,t){var e={},r={notificationId:t||""};if(!n)return{iOSConfig:e,androidConfig:r};try{var i=JSON.parse(n);i==null||i.forEach(function(o){var s,c,d,l,h=Object.keys(o);if(h.length!==0){var a=h[0];switch(a){case"HW":return void(r.channelIdHW=(s=o[a])===null||s===void 0?void 0:s.channelId);case"MI":return void(r.channelIdMi=(c=o[a])===null||c===void 0?void 0:c.channelId);case"OPPO":return void(r.channelIdOPPO=(d=o[a])===null||d===void 0?void 0:d.channelId);case"VIVO":return void(r.typeVivo=(l=o[a])===null||l===void 0?void 0:l.classification);case"APNS":return e.threadId=o[a]["thread-id"],e.apnsCollapseId=o[a]["apns-collapse-id"],e.category=o[a].category,void(e.richMediaUri=o[a].richMediaUri);case"FCM":r.googleConfig={collapseKey:o[a].collapse_key||"",imageUrl:o[a].imageUrl||"",priority:o[a].priority||""}}}})}catch{H.error("Wrong format for pushConfigs field! content: "+n)}return{iOSConfig:e,androidConfig:r}},Fe=function(n){var t=/^[A-Za-z0-9_=+-]+$/.test(n),e=n.length;return t&&e<=128&&e>=1},gi=function(n){var t=n.length;return t<=4096&&t>=1},Ot=function(n,t,e){t=t||function(){};var r=(e=e||{}).isReverse;Rt(n)&&function(){for(var i in n)t(n[i],i,n)}(),(Ht(n)||Bt(n))&&function(){if(r)for(var i=n.length-1;i>=0;i--)t(n[i],i);else for(var o=0,s=n.length;o0;t&&o&&arguments.length===1?(this._retain=(1&t)>0,this.qos=(6&t)>>1,this._dup=(8&t)>0,this.type=t>>4&15,this.syncMsg=(8&t)==8):(this.type=t,this._retain=e,this.qos=r,this._dup=i)}return n.prototype.encode=function(){var t=this.type<<4;return t|=this._retain?1:0,t|=this.qos<<1,t|=this._dup?8:0},n}(),Hn=function(){function n(){}return n.writeUTF=function(t,e){var r=[],i=0;if(Bt(t))for(var o=0,s=t.length;o=0&&c<=127?(i+=1,r.push(c)):c>=128&&c<=2047?(i+=2,r.push(192|31&c>>6),r.push(128|63&c)):c>=2048&&c<=65535&&(i+=3,r.push(224|15&c>>12),r.push(128|63&c>>6),r.push(128|63&c))}for(o=0,s=r.length;o255&&(r[o]&=255);return e?r:i<=255?[0,i].concat(r):[i>>8,255&i].concat(r)},n.readUTF=function(t){for(var e,r,i=[],o=-1,s=t,c="";++o1114111||Math.floor(d)!==d)throw RangeError("Invalid code point: "+d);d<=65535?i.push(d):(e=(d-=65536)>>10|55296,r=d%1024|56320,i.push(e,r)),(o+1===s.length||i.length>16384)&&(c+=String.fromCharCode.apply(null,i),i.length=0)}return c},n}(),Cd=function(){function n(t){this._position=0,this._poolLen=0,this._pool=t,this._poolLen=t.length}return n.prototype.check=function(){return this._position>=this._pool.length},n.prototype.read2Byte=function(){var t=this;if(t.check())return-1;for(var e="",r=0;r<2;r++){var i=t._pool[t._position++].toString(16);i.length===1&&(i="0"+i),e+=i.toString()}return parseInt(e,16)},n.prototype.readInt=function(){var t=this;if(t.check())return-1;for(var e="",r=0;r<4;r++){var i=t._pool[t._position++].toString(16);i.length===1&&(i="0"+i),e+=i.toString()}return parseInt(e,16)},n.prototype.readLong=function(){var t=this;if(t.check())return-1;for(var e="",r=0;r<8;r++){var i=t._pool[t._position++].toString(16);i.length===1&&(i="0"+i),e+=i}return parseInt(e,16)},n.prototype.readByte=function(){if(this.check())return-1;var t=this._pool[this._position++];return t>255&&(t&=255),t},n.prototype.readUTF=function(){if(this.check())return"";var t=this.readByte()<<8|this.readByte(),e=this._pool.subarray(this._position,this._position+=t);return Hn.readUTF(e)},n.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},n}(),Rd=function(){function n(){this._pool=[],this._position=0,this._writen=0}return n.prototype.write=function(t){return Object.prototype.toString.call(t).indexOf("Array")!==-1?this._pool=this._pool.concat(t):t>=0&&(t>255&&(t&=255),this._pool.push(t),this._writen++),t},n.prototype.writeArr=function(t){return this._pool=this._pool.concat(t),t},n.prototype.writeUTF=function(t){var e=Hn.writeUTF(t);this._pool=this._pool.concat(e),this._writen+=e.length},n.prototype.getBytesArray=function(){return this._pool},n}(),Dn="UpStreamMessage",Co="PushExtra",Yr="DownStreamMessage",Qe="DownStreamMessages",Ro="SessionsAttQryInput",rc="SessionsAttOutput",Io="SyncRequestMsg",So="ChrmPullMsg",Sr="NotifyMsg",Oo="HistoryMsgInput",Xe="HistoryMsgOuput",Or="RelationQryInput",tn="RelationsOutput",No="DeleteSessionsInput",bo="SessionInfo",ic="DeleteSessionsOutput",Mo="RelationsInput",Ao="DeleteMsgInput",wo="CleanHisMsgInput",zr="SessionMsgReadInput",Po="ChrmInput",kn="ChrmOutput",Lo="QueryChatRoomInfoInput",Jr="QueryChatRoomInfoOutput",Nr="RtcInput",Ae="RtcUserListOutput",Uo="SetUserStatusInput",Do="RtcSetDataInput",br="RtcUserSetDataInput",Mr="RtcDataInput",ko="RtcSetOutDataInput",xo="MCFollowInput",Wr="RtcTokenOutput",Zr="RtcQryOutput",Vo="RtcQryUserOutDataInput",oc="RtcUserOutDataOutput",Bo="RtcQueryListInput",sc="RtcRoomInfoOutput",Lt="RtcValueInfo",Fo="RtcKeyDeleteInput",Ho="GetQNupTokenInput",$o="GetQNupTokenOutput",Go="GetQNdownloadUrlInput",Ko="GetDownloadUrlInput",jo="GetQNdownloadUrlOutput",qo="GetDownloadUrlOutput",Id="ChrmKVEntity",Yo="SetChrmKV",zo="SetChrmKVS",ac="DeleteChrmKVS",en="ChrmKVOutput",Jo="ChrmKVSOutput",Sd="ChrmKVSVersionEntity",cc="ChrmKVSOutputEntity",Wo="QueryChrmKV",uc="SetUserSettingInput",nn="SetUserSettingOutput",Zo="PullUserSettingInput",Qr="PullUserSettingOutput",Xr="UserSettingNotification",Qo="SessionReq",ti="SessionStates",Ar="SessionState",wr="SessionStateItem",Pr="SessionStateModifyReq",Xo="SessionStateModifyResp",ts="GroupUnpushQuery",es="GroupUnpushSet",ns="GroupUnpushResult",Lr="GrpReadReceiptMsg",dc="GrpReadReceiptQryReq",ei="GrpReadReceiptQryResp",lc="GrpMsgReadUser",rs="SessionTagAddInput",Nn="SessionTagItem",is="SessionTagDelInput",os="SessionDisTagReq",ss="ReportSDKInput",hc="ReportSDKOutput",as="UltraGrpPullSes",cs="UltraGrpPullMsg",Ur="MsgChangeReq",us="QueryMsgChange",Od="MsgChange",ni="MsgChangeList",ds="MsgQuery",Nd="MessageQueryInfo",xn="MsgQueryAck",ls="OperateStatus",ri="OperateStatusNotify",pc="OperateInfo",fc="OperateSummary",hs="RtcNotifyMsg",ps="RtcPullKV",ii="RtcKVOutput",fs="RtcQueryUserJoinedInput",oi="RtcQueryUserJoinedOutput",gc="RtcViewerJoinedOutput",gs="RtcInviteInput",ms="RtcCancelInviteInput",_s="RtcInviteAnswerInput",vs="RtcEndInviteInput",Ts="SetRtcRoomIdInput",mc="SetRtcRoomIdOutput",_c=((K={})[Dn]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],K[Qe]=["list","syncTime","finished","broadcastSyncTime"],K[Yr]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel","extStatus","toUserId","groupUnpush"],K[Co]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],K[Ro]=["nothing"],K[rc]=["inboxTime","sendboxTime","totalUnreadCount"],K[Io]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime","broadcastSyncTime"],K[So]=["syncTime","count"],K[Sr]=["type","time","chrmId"],K[Oo]=["targetId","time","count","order","busChannel"],K[Xe]=["list","syncTime","hasMsg"],K[Or]=["type","count","startTime","order"],K[tn]=["info","isFinished"],K[No]=["sessions"],K[bo]=["type","channelId","busChannel"],K[ic]=["nothing"],K[Mo]=["type","msg","count","busChannel","startTime","endTime"],K[Ao]=["type","conversationId","msgs","busChannel"],K[wo]=["targetId","dataTime","conversationType","busChannel"],K[zr]=["type","msgTime","channelId","busChannel"],K[Po]=["nothing"],K[kn]=["nothing","sessionId","joinTime"],K[Lo]=["count","order"],K[Jr]=["userTotalNums","userInfos"],K[Ho]=["type","key","httpMethod","queryString"],K[Go]=["type","key","fileName"],K[Ko]=["type","key","fileName"],K[$o]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],K[jo]=["downloadUrl"],K[qo]=["downloadUrl"],K[Id]=["key","value","status","timestamp","uid","version"],K[Yo]=["entry","bNotify","notification","type"],K[zo]=["entry","bNotify","notification","type"],K[ac]=["entry","bNotify","notification","type"],K[en]=["entries","bFullUpdate","syncTime"],K[Jo]=["timestamp","errorKeys","keysVersion"],K[Sd]=["version","key"],K[cc]=["key","errorCode"],K[Wo]=["timestamp"],K[uc]=["version","value"],K[nn]=["version","reserve"],K[Zo]=["version","reserve"],K[Qr]=["items","version"],K.UserSettingItem=["targetId","type","key","value","version","status","tags"],K[Qo]=["time"],K[ti]=["version","state"],K[Ar]=["type","channelId","time","stateItem","busChannel"],K[wr]=["sessionStateType","value","tags"],K[Pr]=["version","state"],K[Xo]=["version"],K[es]=["busChannel","unpushLevel"],K[ts]=["busChannel"],K[ns]=["groupId","busChannel","unpushLevel"],K[Lr]=["msgId","busChannel"],K[dc]=["msgId","busChannel"],K[ei]=["totalMemberNum","list"],K[lc]=["readTime","userId"],K[rs]=["version","tags"],K[Nn]=["tagId","name","createdTime","isTop"],K[is]=["version","tags"],K[os]=["tagId"],K[Xr]=["version","reserve"],K[ss]=["sdkInfo"],K[hc]=["nothing"],K[as]=["syncTime","isEraseMsgContent"],K[cs]=["syncTime"],K[Ur]=["fromUserId","targetId","type","busChannel","msgUID","msgTime","content"],K[us]=["syncTime"],K[ni]=["list","syncTime","hasNext"],K[Od]=["targetId","type","time","changeType","msgUID","msgTime","busChannel","isAdmin","isDel","operatorId"],K[ds]=["targetId","type","query"],K[Nd]=["msgTime","msgUID","busChannel"],K[xn]=["list"],K[ls]=["targetId","type","opType","busChannel"],K[ri]=["type","notifyType","info","summary"],K[pc]=["targetId","busChannel","userId","opType","optime"],K[fc]=["targetId","busChannel","count","opType"],K[Nr]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],K[Ae]=["users","token","sessionId","roomInfo"],K[Uo]=["status"],K[Do]=["interior","target","key","value","objectName","content"],K[br]=["valueInfo","objectName","content"],K[Mr]=["interior","target","key","objectName","content"],K[ko]=["target","valueInfo","objectName","content"],K[xo]=["state"],K[Wr]=["rtcToken"],K[Zr]=["outInfo"],K[Vo]=["userId"],K[oc]=["user"],K[Bo]=["order"],K[sc]=["roomId","roomData","userCount","list"],K[Lt]=["key","value"],K[Fo]=["key"],K[hs]=["type","time","roomId"],K[ps]=["timestamp","roomId"],K[ii]=["entries","bFullUpdate","syncTime"],K[fs]=["userId"],K[oi]=["info"],K[gs]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],K[ms]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],K[_s]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],K[vs]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],K[Ts]=["rtcRoomId"],K[mc]=["nothing"],K),Vn={},bd=function(n){var t=_c[n];Vn[n]=function(){for(var e={},r={getArrayData:function(){return e}},i=function(s){var c=t[s],d="set".concat(Bs(c,0,1));r[d]=function(l){e[c]=l}},o=0;o>>=0)>=0&&C<256)&&(G=d[C])?G:(F=i(C,(0|C)<0?-1:0,!0),E&&(d[C]=F),F):(E=(C|=0)>=-128&&C<128)&&(G=c[C])?G:(F=i(C,C<0?-1:0,!1),E&&(c[C]=F),F)}function r(C,A){if(isNaN(C)||!isFinite(C))return A?m:f;if(A){if(C<0)return m;if(C>=a)return w}else{if(-u>=C)return L;if(C+1>=u)return y}return C<0?r(-C,A).neg():i(0|C%h,0|C/h,A)}function i(C,A,F){return new n(C,A,F)}function o(C,A,F){var G,E,S,I,N,b,k;if(C.length===0)throw Error("empty string");if(C==="NaN"||C==="Infinity"||C==="+Infinity"||C==="-Infinity")return f;if(typeof A=="number"?(F=A,A=!1):A=!!A,(F=F||10)<2||F>36)throw RangeError("radix");if((G=C.indexOf("-"))>0)throw Error("interior hyphen");if(G===0)return o(C.substring(1),A,F).neg();for(E=r(l(F,8)),S=f,I=0;I>>0:this.low},M.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},M.toString=function(C){var A,F,G,E,S,I,N,b;if((C=C||10)<2||C>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(L)?(A=r(C),G=(F=this.div(A)).mul(A).sub(this),F.toString(C)+G.toInt().toString(C)):"-"+this.neg().toString(C);for(E=r(l(C,6),this.unsigned),S=this,I="";;){if(N=S.div(E),b=(S.sub(N.mul(E)).toInt()>>>0).toString(C),(S=N).isZero())return b+I;for(;b.length<6;)b="0"+b;I=""+b+I}},M.getHighBits=function(){return this.high},M.getHighBitsUnsigned=function(){return this.high>>>0},M.getLowBits=function(){return this.low},M.getLowBitsUnsigned=function(){return this.low>>>0},M.getNumBitsAbs=function(){var C,A;if(this.isNegative())return this.eq(L)?64:this.neg().getNumBitsAbs();for(C=this.high!=0?this.high:this.low,A=31;A>0&&(C&1<=0},M.isOdd=function(){return(1&this.low)==1},M.isEven=function(){return(1&this.low)==0},M.equals=function(C){return t(C)||(C=s(C)),(this.unsigned===C.unsigned||this.high>>>31!=1||C.high>>>31!=1)&&this.high===C.high&&this.low===C.low},M.eq=M.equals,M.notEquals=function(C){return!this.eq(C)},M.neq=M.notEquals,M.lessThan=function(C){return this.comp(C)<0},M.lt=M.lessThan,M.lessThanOrEqual=function(C){return this.comp(C)<=0},M.lte=M.lessThanOrEqual,M.greaterThan=function(C){return this.comp(C)>0},M.gt=M.greaterThan,M.greaterThanOrEqual=function(C){return this.comp(C)>=0},M.gte=M.greaterThanOrEqual,M.compare=function(C){if(t(C)||(C=s(C)),this.eq(C))return 0;var A=this.isNegative(),F=C.isNegative();return A&&!F?-1:!A&&F?1:this.unsigned?C.high>>>0>this.high>>>0||C.high===this.high&&C.low>>>0>this.low>>>0?-1:1:this.sub(C).isNegative()?-1:1},M.comp=M.compare,M.negate=function(){return!this.unsigned&&this.eq(L)?L:this.not().add(_)},M.neg=M.negate,M.add=function(C){var A,F,G,E,S,I,N,b,k,U,$;return t(C)||(C=s(C)),A=this.high>>>16,F=65535&this.high,G=this.low>>>16,E=65535&this.low,S=C.high>>>16,I=65535&C.high,N=C.low>>>16,b=0,k=0,U=0,$=0,U+=($+=E+(65535&C.low))>>>16,k+=(U+=G+N)>>>16,b+=(k+=F+I)>>>16,b+=A+S,i((U&=65535)<<16|($&=65535),(b&=65535)<<16|(k&=65535),this.unsigned)},M.subtract=function(C){return t(C)||(C=s(C)),this.add(C.neg())},M.sub=M.subtract,M.multiply=function(C){var A,F,G,E,S,I,N,b,k,U,$,q;return this.isZero()?f:(t(C)||(C=s(C)),C.isZero()?f:this.eq(L)?C.isOdd()?L:f:C.eq(L)?this.isOdd()?L:f:this.isNegative()?C.isNegative()?this.neg().mul(C.neg()):this.neg().mul(C).neg():C.isNegative()?this.mul(C.neg()).neg():this.lt(p)&&C.lt(p)?r(this.toNumber()*C.toNumber(),this.unsigned):(A=this.high>>>16,F=65535&this.high,G=this.low>>>16,E=65535&this.low,S=C.high>>>16,I=65535&C.high,N=C.low>>>16,k=0,U=0,$=0,q=0,$+=(q+=E*(b=65535&C.low))>>>16,U+=($+=G*b)>>>16,$&=65535,U+=($+=E*N)>>>16,k+=(U+=F*b)>>>16,U&=65535,k+=(U+=G*N)>>>16,U&=65535,k+=(U+=E*I)>>>16,k+=A*b+F*N+G*I+E*S,i(($&=65535)<<16|(q&=65535),(k&=65535)<<16|(U&=65535),this.unsigned)))},M.mul=M.multiply,M.divide=function(C){var A,F,G,E,S,I,N;if(t(C)||(C=s(C)),C.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:f;if(this.unsigned){if(C.unsigned||(C=C.toUnsigned()),C.gt(this))return m;if(C.gt(this.shru(1)))return v;G=m}else{if(this.eq(L))return C.eq(_)||C.eq(T)?L:C.eq(L)?_:(A=this.shr(1).div(C).shl(1)).eq(f)?C.isNegative()?_:T:(F=this.sub(C.mul(A)),G=A.add(F.div(C)));if(C.eq(L))return this.unsigned?m:f;if(this.isNegative())return C.isNegative()?this.neg().div(C.neg()):this.neg().div(C).neg();if(C.isNegative())return this.div(C.neg()).neg();G=f}for(F=this;F.gte(C);){for(A=Math.max(1,Math.floor(F.toNumber()/C.toNumber())),S=(E=Math.ceil(Math.log(A)/Math.LN2))<=48?1:l(2,E-48),N=(I=r(A)).mul(C);N.isNegative()||N.gt(F);)N=(I=r(A-=S,this.unsigned)).mul(C);I.isZero()&&(I=_),G=G.add(I),F=F.sub(N)}return G},M.div=M.divide,M.modulo=function(C){return t(C)||(C=s(C)),this.sub(this.div(C).mul(C))},M.mod=M.modulo,M.not=function(){return i(~this.low,~this.high,this.unsigned)},M.and=function(C){return t(C)||(C=s(C)),i(this.low&C.low,this.high&C.high,this.unsigned)},M.or=function(C){return t(C)||(C=s(C)),i(this.low|C.low,this.high|C.high,this.unsigned)},M.xor=function(C){return t(C)||(C=s(C)),i(this.low^C.low,this.high^C.high,this.unsigned)},M.shiftLeft=function(C){return t(C)&&(C=C.toInt()),(C&=63)==0?this:C<32?i(this.low<>>32-C,this.unsigned):i(0,this.low<>>C|this.high<<32-C,this.high>>C,this.unsigned):i(this.high>>C-32,this.high>=0?0:-1,this.unsigned)},M.shr=M.shiftRight,M.shiftRightUnsigned=function(C){var A;return t(C)&&(C=C.toInt()),(C&=63)==0?this:(A=this.high,C<32?i(this.low>>>C|A<<32-C,A>>>C,this.unsigned):i(C===32?A:A>>>C-32,0,this.unsigned))},M.shru=M.shiftRightUnsigned,M.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},M.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},M.toBytes=function(C){return C?this.toBytesLE():this.toBytesBE()},M.toBytesLE=function(){var C=this.high,A=this.low;return[255&A,255&A>>>8,255&A>>>16,255&A>>>24,255&C,255&C>>>8,255&C>>>16,255&C>>>24]},M.toBytesBE=function(){var C=this.high,A=this.low;return[255&C>>>24,255&C>>>16,255&C>>>8,255&C,255&A>>>24,255&A>>>16,255&A>>>8,255&A]},n}(),ta=function(n){function t(a){var u=0;return function(){return u1024&&(u.push(c.apply(String,a)),a.length=0),void Array.prototype.push.apply(a,arguments))}}function r(a,u,p,f,m){var _,v,T=8*m-f-1,y=(1<>1,L=-7,M=p?m-1:0,C=p?-1:1,A=a[u+M];for(M+=C,_=A&(1<<-L)-1,A>>=-L,L+=T;L>0;_=256*_+a[u+M],M+=C,L-=8);for(v=_&(1<<-L)-1,_>>=-L,L+=f;L>0;v=256*v+a[u+M],M+=C,L-=8);if(_===0)_=1-w;else{if(_===y)return v?NaN:1/0*(A?-1:1);v+=Math.pow(2,f),_-=w}return(A?-1:1)*v*Math.pow(2,_-f)}function i(a,u,p,f,m,_){var v,T,y,w=8*_-m-1,L=(1<>1,C=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=f?0:_-1,F=f?1:-1,G=u<0||u===0&&1/u<0?1:0;for(u=Math.abs(u),isNaN(u)||1/0===u?(T=isNaN(u)?1:0,v=L):(v=Math.floor(Math.log(u)/Math.LN2),u*(y=Math.pow(2,-v))<1&&(v--,y*=2),(u+=v+M>=1?C/y:C*Math.pow(2,1-M))*y>=2&&(v++,y/=2),v+M>=L?(T=0,v=L):v+M>=1?(T=(u*y-1)*Math.pow(2,m),v+=M):(T=u*Math.pow(2,M-1)*Math.pow(2,m),v=0));m>=8;a[p+A]=255&T,A+=F,T/=256,m-=8);for(v=v<0;a[p+A]=255&v,A+=F,v/=256,w-=8);a[p+A-F]|=128*G}var o,s,c,d,l,h=function(a,u,p){if(a===void 0&&(a=h.DEFAULT_CAPACITY),u===void 0&&(u=h.DEFAULT_ENDIAN),p===void 0&&(p=h.DEFAULT_NOASSERT),!p){if((a|=0)<0)throw RangeError("Illegal capacity");u=!!u,p=!!p}this.buffer=a===0?s:new ArrayBuffer(a),this.view=a===0?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=a,this.littleEndian=u,this.noAssert=p};return h.VERSION="5.0.1",h.LITTLE_ENDIAN=!0,h.BIG_ENDIAN=!1,h.DEFAULT_CAPACITY=16,h.DEFAULT_ENDIAN=h.BIG_ENDIAN,h.DEFAULT_NOASSERT=!1,h.Long=n||null,(o=h.prototype).__isByteBuffer__,Object.defineProperty(o,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),s=new ArrayBuffer(0),c=String.fromCharCode,h.accessor=function(){return Uint8Array},h.allocate=function(a,u,p){return new h(a,u,p)},h.concat=function(a,u,p,f){var m,_,v,T,y,w;for((typeof u=="boolean"||typeof u!="string")&&(f=p,p=u,u=void 0),m=0,v=0,T=a.length;T>v;++v)h.isByteBuffer(a[v])||(a[v]=h.wrap(a[v],u)),(_=a[v].limit-a[v].offset)>0&&(m+=_);if(m===0)return new h(0,p,f);for(w=new h(m,p,f),v=0;T>v;)(_=(y=a[v++]).limit-y.offset)<=0||(w.view.set(y.view.subarray(y.offset,y.limit),w.offset),w.offset+=_);return w.limit=w.offset,w.offset=0,w},h.isByteBuffer=function(a){return(a&&a.__isByteBuffer__)===!0},h.type=function(){return ArrayBuffer},h.wrap=function(a,u,p,f){var m,_;if(typeof u!="string"&&(f=p,p=u,u=void 0),typeof a=="string")switch(u===void 0&&(u="utf8"),u){case"base64":return h.fromBase64(a,p);case"hex":return h.fromHex(a,p);case"binary":return h.fromBinary(a,p);case"utf8":return h.fromUTF8(a,p);case"debug":return h.fromDebug(a,p);default:throw Error("Unsupported encoding: "+u)}if(a===null||typeof a!="object")throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return(m=o.clone.call(a)).markedOffset=-1,m;if(a instanceof Uint8Array)m=new h(0,p,f),a.length>0&&(m.buffer=a.buffer,m.offset=a.byteOffset,m.limit=a.byteOffset+a.byteLength,m.view=new Uint8Array(a.buffer));else if(a instanceof ArrayBuffer)m=new h(0,p,f),a.byteLength>0&&(m.buffer=a,m.offset=0,m.limit=a.byteLength,m.view=a.byteLength>0?new Uint8Array(a):null);else{if(Object.prototype.toString.call(a)!=="[object Array]")throw TypeError("Illegal buffer");for((m=new h(a.length,p,f)).limit=a.length,_=0;_>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for(f=u,_=(m=a.length)>>3,v=0,u+=this.writeVarint32(m,u);_--;)p=1&!!a[v++]|(1&!!a[v++])<<1|(1&!!a[v++])<<2|(1&!!a[v++])<<3|(1&!!a[v++])<<4|(1&!!a[v++])<<5|(1&!!a[v++])<<6|(1&!!a[v++])<<7,this.writeByte(p,u++);if(m>v){for(T=0,p=0;m>v;)p|=(1&!!a[v++])<>3,_=0,v=[],a+=p.length;m--;)u=this.readByte(a++),v[_++]=!!(1&u),v[_++]=!!(2&u),v[_++]=!!(4&u),v[_++]=!!(8&u),v[_++]=!!(16&u),v[_++]=!!(32&u),v[_++]=!!(64&u),v[_++]=!!(128&u);if(f>_)for(T=0,u=this.readByte(a++);f>_;)v[_++]=!!(1&u>>T++);return y&&(this.offset=a),v},o.readBytes=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+"+a+") <= "+this.buffer.byteLength)}return p=this.slice(u,u+a),f&&(this.offset+=a),p},o.writeBytes=o.append,o.writeInt8=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=1,this.view[u]=a,f&&(this.offset+=1),this},o.writeByte=o.writeInt8,o.readInt8=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return(128&(u=this.view[a]))==128&&(u=-(255-u+1)),p&&(this.offset+=1),u},o.readByte=o.readInt8,o.writeUint8=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=1,this.view[u]=a,f&&(this.offset+=1),this},o.writeUInt8=o.writeUint8,o.readUint8=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=this.view[a],p&&(this.offset+=1),u},o.readUInt8=o.readUint8,o.writeInt16=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),f&&(this.offset+=2),this},o.writeShort=o.writeInt16,o.readInt16=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),(32768&u)==32768&&(u=-(65535-u+1)),p&&(this.offset+=2),u},o.readShort=o.readInt16,o.writeUint16=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),f&&(this.offset+=2),this},o.writeUInt16=o.writeUint16,o.readUint16=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),p&&(this.offset+=2),u},o.readUInt16=o.readUint16,o.writeInt32=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),f&&(this.offset+=4),this},o.writeInt=o.writeInt32,o.readInt32=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),u|=0,p&&(this.offset+=4),u},o.readInt=o.readInt32,o.writeUint32=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),f&&(this.offset+=4),this},o.writeUInt32=o.writeUint32,o.readUint32=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p&&(this.offset+=4),u},o.readUInt32=o.readUint32,n&&(o.writeInt64=function(a,u){var p,f,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=n.fromNumber(a);else if(typeof a=="string")a=n.fromString(a);else if(!(a&&a instanceof n))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(u+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=8,f=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&f>>>24,this.view[u+2]=255&f>>>16,this.view[u+1]=255&f>>>8,this.view[u]=255&f,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&f>>>24,this.view[u+1]=255&f>>>16,this.view[u+2]=255&f>>>8,this.view[u+3]=255&f),_&&(this.offset+=8),this},o.writeLong=o.writeInt64,o.readInt64=function(a){var u,p,f,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,p=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,p=this.view[a+2]<<16,p|=this.view[a+1]<<8,p|=this.view[a],p+=this.view[a+3]<<24>>>0):(p=this.view[a+1]<<16,p|=this.view[a+2]<<8,p|=this.view[a+3],p+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),f=new n(u,p,!1),m&&(this.offset+=8),f},o.readLong=o.readInt64,o.writeUint64=function(a,u){var p,f,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=n.fromNumber(a);else if(typeof a=="string")a=n.fromString(a);else if(!(a&&a instanceof n))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(u+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=8,f=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&f>>>24,this.view[u+2]=255&f>>>16,this.view[u+1]=255&f>>>8,this.view[u]=255&f,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&f>>>24,this.view[u+1]=255&f>>>16,this.view[u+2]=255&f>>>8,this.view[u+3]=255&f),_&&(this.offset+=8),this},o.writeUInt64=o.writeUint64,o.readUint64=function(a){var u,p,f,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,p=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,p=this.view[a+2]<<16,p|=this.view[a+1]<<8,p|=this.view[a],p+=this.view[a+3]<<24>>>0):(p=this.view[a+1]<<16,p|=this.view[a+2]<<8,p|=this.view[a+3],p+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),f=new n(u,p,!0),m&&(this.offset+=8),f},o.readUInt64=o.readUint64),o.writeFloat32=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=4,i(this.view,a,u,this.littleEndian,23,4),f&&(this.offset+=4),this},o.writeFloat=o.writeFloat32,o.readFloat32=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,23,4),p&&(this.offset+=4),u},o.readFloat=o.readFloat32,o.writeFloat64=function(a,u){var p,f=u===void 0;if(f&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>u?p:u),u-=8,i(this.view,a,u,this.littleEndian,52,8),f&&(this.offset+=8),this},o.writeDouble=o.writeFloat64,o.readFloat64=function(a){var u,p=a===void 0;if(p&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,52,8),p&&(this.offset+=8),u},o.readDouble=o.readFloat64,h.MAX_VARINT32_BYTES=5,h.calculateVarint32=function(a){return(a>>>=0)<128?1:a<16384?2:1<<21>a?3:1<<28>a?4:5},h.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0},h.zigZagDecode32=function(a){return 0|a>>>1^-(1&a)},o.writeVarint32=function(a,u){var p,f,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for((u+=f=h.calculateVarint32(a))>(m=this.buffer.byteLength)&&this.resize((m*=2)>u?m:u),u-=f,a>>>=0;a>=128;)p=128|127&a,this.view[u++]=p,a>>>=7;return this.view[u++]=a,_?(this.offset=u,this):f},o.writeVarint32ZigZag=function(a,u){return this.writeVarint32(h.zigZagEncode32(a),u)},o.readVarint32=function(a){var u,p,f,m,_=a===void 0;if(_&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}p=0,f=0;do{if(!this.noAssert&&a>this.limit)throw(m=Error("Truncated")).truncated=!0,m;u=this.view[a++],p<5&&(f|=(127&u)<<7*p),++p}while((128&u)!=0);return f|=0,_?(this.offset=a,f):{value:f,length:p}},o.readVarint32ZigZag=function(a){var u=this.readVarint32(a);return typeof u=="object"?u.value=h.zigZagDecode32(u.value):u=h.zigZagDecode32(u),u},n&&(h.MAX_VARINT64_BYTES=10,h.calculateVarint64=function(a){typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a));var u=a.toInt()>>>0,p=a.shiftRightUnsigned(28).toInt()>>>0,f=a.shiftRightUnsigned(56).toInt()>>>0;return f==0?p==0?u<16384?u<128?1:2:1<<21>u?3:4:p<16384?p<128?5:6:1<<21>p?7:8:f<128?9:10},h.zigZagEncode64=function(a){return typeof a=="number"?a=n.fromNumber(a,!1):typeof a=="string"?a=n.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},h.zigZagDecode64=function(a){return typeof a=="number"?a=n.fromNumber(a,!1):typeof a=="string"?a=n.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftRightUnsigned(1).xor(a.and(n.ONE).toSigned().negate()).toSigned()},o.writeVarint64=function(a,u){var p,f,m,_,v,T=u===void 0;if(T&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=n.fromNumber(a);else if(typeof a=="string")a=n.fromString(a);else if(!(a&&a instanceof n))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}switch(typeof a=="number"?a=n.fromNumber(a,!1):typeof a=="string"?a=n.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),p=h.calculateVarint64(a),f=a.toInt()>>>0,m=a.shiftRightUnsigned(28).toInt()>>>0,_=a.shiftRightUnsigned(56).toInt()>>>0,(u+=p)>(v=this.buffer.byteLength)&&this.resize((v*=2)>u?v:u),u-=p,p){case 10:this.view[u+9]=1&_>>>7;case 9:this.view[u+8]=p!==9?128|_:127&_;case 8:this.view[u+7]=p!==8?128|m>>>21:127&m>>>21;case 7:this.view[u+6]=p!==7?128|m>>>14:127&m>>>14;case 6:this.view[u+5]=p!==6?128|m>>>7:127&m>>>7;case 5:this.view[u+4]=p!==5?128|m:127&m;case 4:this.view[u+3]=p!==4?128|f>>>21:127&f>>>21;case 3:this.view[u+2]=p!==3?128|f>>>14:127&f>>>14;case 2:this.view[u+1]=p!==2?128|f>>>7:127&f>>>7;case 1:this.view[u]=p!==1?128|f:127&f}return T?(this.offset+=p,this):p},o.writeVarint64ZigZag=function(a,u){return this.writeVarint64(h.zigZagEncode64(a),u)},o.readVarint64=function(a){var u,p,f,m,_,v,T=a===void 0;if(T&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}if(u=a,p=0,f=0,m=0,_=0,p=127&(_=this.view[a++]),128&_&&(p|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(f=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(m=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(m|=(127&(_=this.view[a++]))<<7,128&_||this.noAssert&&_===void 0))))))))))throw Error("Buffer overrun");return v=n.fromBits(p|f<<28,f>>>4|m<<24,!1),T?(this.offset=a,v):{value:v,length:a-u}},o.readVarint64ZigZag=function(a){var u=this.readVarint64(a);return u&&u.value instanceof n?u.value=h.zigZagDecode64(u.value):u=h.zigZagDecode64(u),u}),o.writeCString=function(a,u){var p,f,m,_=u===void 0;if(_&&(u=this.offset),f=a.length,!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");for(p=0;f>p;++p)if(a.charCodeAt(p)===0)throw RangeError("Illegal str: Contains NULL-characters");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return f=l.calculateUTF16asUTF8(t(a))[1],u+=f+1,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=f+1,l.encodeUTF16toUTF8(t(a),function(v){this.view[u++]=v}.bind(this)),this.view[u++]=0,_?(this.offset=u,this):f},o.readCString=function(a){var u,p,f,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,f=-1,l.decodeUTF8toUTF16(function(){if(f===0)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return(f=this.view[a++])===0?null:f}.bind(this),p=e(),!0),m?(this.offset=a,p()):{string:p(),length:a-u}},o.writeIString=function(a,u){var p,f,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(f=u,p=l.calculateUTF16asUTF8(t(a),this.noAssert)[1],u+=4+p,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=4+p,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p):(this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),u+=4,l.encodeUTF16toUTF8(t(a),function(v){this.view[u++]=v}.bind(this)),u!==f+4+p)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+4+p));return _?(this.offset=u,this):u-f},o.readIString=function(a){var u,p,f,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=a,p=this.readUint32(a),f=this.readUTF8String(p,h.METRICS_BYTES,a+=4),a+=f.length,m?(this.offset=a,f.string):{string:f.string,length:a-u}},h.METRICS_CHARS="c",h.METRICS_BYTES="b",o.writeUTF8String=function(a,u){var p,f,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return f=u,p=l.calculateUTF16asUTF8(t(a))[1],u+=p,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=p,l.encodeUTF16toUTF8(t(a),function(v){this.view[u++]=v}.bind(this)),_?(this.offset=u,this):u-f},o.writeString=o.writeUTF8String,h.calculateUTF8Chars=function(a){return l.calculateUTF16asUTF8(t(a))[0]},h.calculateUTF8Bytes=function(a){return l.calculateUTF16asUTF8(t(a))[1]},h.calculateString=h.calculateUTF8Bytes,o.readUTF8String=function(a,u,p){var f,m,_,v,T;if(typeof u=="number"&&(p=u,u=void 0),(f=p===void 0)&&(p=this.offset),u===void 0&&(u=h.METRICS_CHARS),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");if(a|=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: "+p+" (not an integer)");if((p>>>=0)<0||p+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+0) <= "+this.buffer.byteLength)}if(_=0,v=p,u===h.METRICS_CHARS){if(m=e(),l.decodeUTF8(function(){return a>_&&p>>=0)<0||p+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+"+a+") <= "+this.buffer.byteLength)}if(T=p+a,l.decodeUTF8toUTF16(function(){return T>p?this.view[p++]:null}.bind(this),m=e(),this.noAssert),p!==T)throw RangeError("Illegal range: Truncated data, "+p+" == "+T);return f?(this.offset=p,m()):{string:m(),length:p-v}}throw TypeError("Unsupported metrics: "+u)},o.readString=o.readUTF8String,o.writeVString=function(a,u){var p,f,m,_,v=u===void 0;if(v&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(m=u,p=l.calculateUTF16asUTF8(t(a),this.noAssert)[1],f=h.calculateVarint32(p),u+=f+p,_=this.buffer.byteLength,u>_&&this.resize((_*=2)>u?_:u),u-=f+p,u+=this.writeVarint32(p,u),l.encodeUTF16toUTF8(t(a),function(T){this.view[u++]=T}.bind(this)),u!==m+p+f)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+p+f));return v?(this.offset=u,this):u-m},o.readVString=function(a){var u,p,f,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,p=this.readVarint32(a),f=this.readUTF8String(p.value,h.METRICS_BYTES,a+=p.length),a+=f.length,m?(this.offset=a,f.string):{string:f.string,length:a-u}},o.append=function(a,u,p){var f,m,_;if((typeof u=="number"||typeof u!="string")&&(p=u,u=void 0),(f=p===void 0)&&(p=this.offset),!this.noAssert){if(typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: "+p+" (not an integer)");if((p>>>=0)<0||p+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((p+=m)>(_=this.buffer.byteLength)&&this.resize((_*=2)>p?_:p),p-=m,this.view.set(a.view.subarray(a.offset,a.limit),p),a.offset+=m,f&&(this.offset+=m)),this},o.appendTo=function(a,u){return a.append(this,u),this},o.assert=function(a){return this.noAssert=!a,this},o.capacity=function(){return this.buffer.byteLength},o.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},o.clone=function(a){var u=new h(0,this.littleEndian,this.noAssert);return a?(u.buffer=new ArrayBuffer(this.buffer.byteLength),u.view=new Uint8Array(u.buffer)):(u.buffer=this.buffer,u.view=this.view),u.offset=this.offset,u.markedOffset=this.markedOffset,u.limit=this.limit,u},o.compact=function(a,u){var p,f,m;if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===0&&u===this.buffer.byteLength?this:(p=u-a)==0?(this.buffer=s,this.view=null,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=0,this):(f=new ArrayBuffer(p),(m=new Uint8Array(f)).set(this.view.subarray(a,u)),this.buffer=f,this.view=m,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=p,this)},o.copy=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}if(a===u)return new h(0,this.littleEndian,this.noAssert);var p=u-a,f=new h(p,this.littleEndian,this.noAssert);return f.offset=0,f.limit=p,f.markedOffset>=0&&(f.markedOffset-=a),this.copyTo(f,0,a,u),f},o.copyTo=function(a,u,p,f){var m,_,v;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");if(u=(_=u===void 0)?a.offset:0|u,p=(m=p===void 0)?this.offset:0|p,f=f===void 0?this.limit:0|f,u<0||u>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+u+" <= "+a.buffer.byteLength);if(p<0||f>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+p+" <= "+this.buffer.byteLength);return(v=f-p)==0?a:(a.ensureCapacity(u+v),a.view.set(this.view.subarray(p,f),u),m&&(this.offset+=v),_&&(a.offset+=v),this)},o.ensureCapacity=function(a){var u=this.buffer.byteLength;return a>u?this.resize((u*=2)>a?u:a):this},o.fill=function(a,u,p){var f=u===void 0;if(f&&(u=this.offset),typeof a=="string"&&a.length>0&&(a=a.charCodeAt(0)),u===void 0&&(u=this.offset),p===void 0&&(p=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal begin: Not an integer");if(u>>>=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal end: Not an integer");if(p>>>=0,u<0||u>p||p>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+u+" <= "+p+" <= "+this.buffer.byteLength)}if(u>=p)return this;for(;p>u;)this.view[u++]=a;return f&&(this.offset=u),this},o.flip=function(){return this.limit=this.offset,this.offset=0,this},o.mark=function(a){if(a=a===void 0?this.offset:a,!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=a,this},o.order=function(a){if(!this.noAssert&&typeof a!="boolean")throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!a,this},o.LE=function(a){return this.littleEndian=a===void 0||!!a,this},o.BE=function(a){return this.littleEndian=a!==void 0&&!a,this},o.prepend=function(a,u,p){var f,m,_,v,T;if((typeof u=="number"||typeof u!="string")&&(p=u,u=void 0),(f=p===void 0)&&(p=this.offset),!this.noAssert){if(typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: "+p+" (not an integer)");if((p>>>=0)<0||p+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((_=m-p)>0?(v=new ArrayBuffer(this.buffer.byteLength+_),(T=new Uint8Array(v)).set(this.view.subarray(p,this.buffer.byteLength),m),this.buffer=v,this.view=T,this.offset+=_,this.markedOffset>=0&&(this.markedOffset+=_),this.limit+=_,p+=_):new Uint8Array(this.buffer),this.view.set(a.view.subarray(a.offset,a.limit),p-m),a.offset=a.limit,f&&(this.offset-=m)),this},o.prependTo=function(a,u){return a.prepend(this,u),this},o.printDebug=function(a){typeof a!="function"&&(a=console.log.bind(console)),a(this.toString()+` ------------------------------------------------------------------- `+this.toDebug(!0))},o.remaining=function(){return this.limit-this.offset},o.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},o.resize=function(a){var u,p;if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal capacity: "+a+" (not an integer)");if((a|=0)<0)throw RangeError("Illegal capacity: 0 <= "+a)}return this.buffer.byteLength>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===u||Array.prototype.reverse.call(this.view.subarray(a,u)),this},o.skip=function(a){if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var u=this.offset+a;if(!this.noAssert&&(u<0||u>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);return this.offset=u,this},o.slice=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var p=this.clone();return p.offset=a,p.limit=u,p},o.toBuffer=function(a){var u,p=this.offset,f=this.limit;if(!this.noAssert){if(typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: Not an integer");if(p>>>=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal limit: Not an integer");if(f>>>=0,p<0||p>f||f>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+p+" <= "+f+" <= "+this.buffer.byteLength)}return a||p!==0||f!==this.buffer.byteLength?p===f?s:(u=new ArrayBuffer(f-p),new Uint8Array(u).set(new Uint8Array(this.buffer).subarray(p,f),0),u):this.buffer},o.toArrayBuffer=o.toBuffer,o.toString=function(a,u,p){if(a===void 0)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch(typeof a=="number"&&(p=u=a="utf8"),a){case"utf8":return this.toUTF8(u,p);case"base64":return this.toBase64(u,p);case"hex":return this.toHex(u,p);case"binary":return this.toBinary(u,p);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a)}},d=function(){var a,u,p={},f=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],m=[];for(a=0,u=f.length;u>a;++a)m[f[a]]=a;return p.encode=function(_,v){for(var T,y;(T=_())!==null;)v(f[63&T>>2]),y=(3&T)<<4,(T=_())!==null?(v(f[63&((y|=15&T>>4)|15&T>>4)]),y=(15&T)<<2,(T=_())!==null?(v(f[63&(y|3&T>>6)]),v(f[63&T])):(v(f[63&y]),v(61))):(v(f[63&y]),v(61),v(61))},p.decode=function(_,v){function T(M){throw Error("Illegal character code: "+M)}for(var y,w,L;(y=_())!==null;)if((w=m[y])===void 0&&T(y),(y=_())!==null&&((L=m[y])===void 0&&T(y),v(w<<2>>>0|(48&L)>>4),(y=_())!==null)){if((w=m[y])===void 0){if(y===61)break;T(y)}if(v((15&L)<<4>>>0|(60&w)>>2),(y=_())!==null){if((L=m[y])===void 0){if(y===61)break;T(y)}v((3&w)<<6>>>0|L)}}},p.test=function(_){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(_)},p}(),o.toBase64=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity||a>u)throw RangeError("begin, end");var p;return d.encode(function(){return u>a?this.view[a++]:null}.bind(this),p=e()),p()},h.fromBase64=function(a,u){if(typeof a!="string")throw TypeError("str");var p=new h(a.length/4*3,u),f=0;return d.decode(t(a),function(m){p.view[f++]=m}),p.limit=f,p},h.btoa=function(a){return h.fromBinary(a).toBase64()},h.atob=function(a){return h.fromBase64(a).toBinary()},o.toBinary=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity()||a>u)throw RangeError("begin, end");if(a===u)return"";for(var p=[],f=[];u>a;)p.push(this.view[a++]),p.length>=1024&&(f.push(String.fromCharCode.apply(String,p)),p=[]);return f.join("")+String.fromCharCode.apply(String,p)},h.fromBinary=function(a,u){if(typeof a!="string")throw TypeError("str");for(var p,f=0,m=a.length,_=new h(m,u);m>f;){if((p=a.charCodeAt(f))>255)throw RangeError("illegal char code: "+p);_.view[f++]=p}return _.limit=m,_},o.toDebug=function(a){for(var u,p=-1,f=this.buffer.byteLength,m="",_="",v="";f>p;){if(p!==-1&&(m+=(u=this.view[p])<16?"0"+u.toString(16).toUpperCase():u.toString(16).toUpperCase(),a&&(_+=u>32&&u<127?String.fromCharCode(u):".")),++p,a&&p>0&&p%16==0&&p!==f){for(;m.length<51;)m+=" ";v+=m+_+` `,m=_=""}m+=p===this.offset&&p===this.limit?p===this.markedOffset?"!":"|":p===this.offset?p===this.markedOffset?"[":"<":p===this.limit?p===this.markedOffset?"]":">":p===this.markedOffset?"'":a||p!==0&&p!==f?" ":""}if(a&&m!==" "){for(;m.length<51;)m+=" ";v+=m+_+` `}return a?v:m},h.fromDebug=function(a,u,p){for(var f,m,_=a.length,v=new h(0|(_+1)/3,u,p),T=0,y=0,w=!1,L=!1,M=!1,C=!1,A=!1;_>T;){switch(f=a.charAt(T++)){case"!":if(!p){if(L||M||C){A=!0;break}L=M=C=!0}v.offset=v.markedOffset=v.limit=y,w=!1;break;case"|":if(!p){if(L||C){A=!0;break}L=C=!0}v.offset=v.limit=y,w=!1;break;case"[":if(!p){if(L||M){A=!0;break}L=M=!0}v.offset=v.markedOffset=y,w=!1;break;case"<":if(!p){if(L){A=!0;break}L=!0}v.offset=y,w=!1;break;case"]":if(!p){if(C||M){A=!0;break}C=M=!0}v.limit=v.markedOffset=y,w=!1;break;case">":if(!p){if(C){A=!0;break}C=!0}v.limit=y,w=!1;break;case"'":if(!p){if(M){A=!0;break}M=!0}v.markedOffset=y,w=!1;break;case" ":w=!1;break;default:if(!p&&w){A=!0;break}if(m=parseInt(f+a.charAt(T++),16),!p&&(isNaN(m)||m<0||m>255))throw TypeError("Illegal str: Not a debug encoded string");v.view[y++]=m,w=!0}if(A)throw TypeError("Illegal str: Invalid symbol at "+T)}if(!p){if(!L||!C)throw TypeError("Illegal str: Missing offset or limit");if(y>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}for(var p,f=new Array(u-a);u>a;)(p=this.view[a++])<16?f.push("0",p.toString(16)):f.push(p.toString(16));return f.join("")},h.fromHex=function(a,u,p){var f,m,_,v,T;if(!p){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(a.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(m=a.length,_=new h(0|m/2,u),v=0,T=0;m>v;v+=2){if(f=parseInt(a.substring(v,v+2),16),!p&&(!isFinite(f)||f<0||f>255))throw TypeError("Illegal str: Contains non-hex characters");_.view[T++]=f}return _.limit=T,_},l=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(u,p){var f=null;for(typeof u=="number"&&(f=u,u=function(){return null});f!==null||(f=u())!==null;)f<128?p(127&f):f<2048?(p(192|31&f>>6),p(128|63&f)):f<65536?(p(224|15&f>>12),p(128|63&f>>6),p(128|63&f)):(p(240|7&f>>18),p(128|63&f>>12),p(128|63&f>>6),p(128|63&f)),f=null},decodeUTF8:function(u,p){for(var f,m,_,v,T=function(y){y=y.slice(0,y.indexOf(null));var w=Error(y.toString());throw w.name="TruncatedError",w.bytes=y,w};(f=u())!==null;)if((128&f)==0)p(f);else if((224&f)==192)(m=u())===null&&T([f,m]),p((31&f)<<6|63&m);else if((240&f)==224)((m=u())===null||(_=u())===null)&&T([f,m,_]),p((15&f)<<12|(63&m)<<6|63&_);else{if((248&f)!=240)throw RangeError("Illegal starting byte: "+f);((m=u())===null||(_=u())===null||(v=u())===null)&&T([f,m,_,v]),p((7&f)<<18|(63&m)<<12|(63&_)<<6|63&v)}},UTF16toUTF8:function(u,p){for(var f,m=null;(f=m!==null?m:u())!==null;)f>=55296&&f<=57343&&(m=u())!==null&&m>=56320&&m<=57343?(p(1024*(f-55296)+m-56320+65536),m=null):p(f);m!==null&&p(m)},UTF8toUTF16:function(u,p){var f=null;for(typeof u=="number"&&(f=u,u=function(){return null});f!==null||(f=u())!==null;)f<=65535?p(f):(p(55296+((f-=65536)>>10)),p(f%1024+56320)),f=null},encodeUTF16toUTF8:function(u,p){a.UTF16toUTF8(u,function(f){a.encodeUTF8(f,p)})},decodeUTF8toUTF16:function(u,p){a.decodeUTF8(u,function(f){a.UTF8toUTF16(f,p)})},calculateCodePoint:function(u){return u<128?1:u<2048?2:u<65536?3:4},calculateUTF8:function(u){for(var p,f=0;(p=u())!==null;)f+=p<128?1:p<2048?2:p<65536?3:4;return f},calculateUTF16asUTF8:function(u){var p=0,f=0;return a.UTF16toUTF8(u,function(m){++p,f+=m<128?1:m<2048?2:m<65536?3:4}),[p,f]}};return a}(),o.toUTF8=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var p;try{l.decodeUTF8toUTF16(function(){return u>a?this.view[a++]:null}.bind(this),p=e())}catch{if(a!==u)throw RangeError("Illegal range: Truncated data, "+a+" != "+u)}return p()},h.fromUTF8=function(a,u,p){if(!p&&typeof a!="string")throw TypeError("Illegal str: Not a string");var f=new h(l.calculateUTF16asUTF8(t(a),!0)[1],u,p),m=0;return l.encodeUTF16toUTF8(t(a),function(_){f.view[m++]=_}),f.limit=m,f},h}(mi),ea=function(n,t){var e,r,i={};return i.ByteBuffer=n,i.c=n,e=n,i.Long=t||null,i.VERSION="5.0.1",i.WIRE_TYPES={},i.WIRE_TYPES.VARINT=0,i.WIRE_TYPES.BITS64=1,i.WIRE_TYPES.LDELIM=2,i.WIRE_TYPES.STARTGROUP=3,i.WIRE_TYPES.ENDGROUP=4,i.WIRE_TYPES.BITS32=5,i.PACKABLE_WIRE_TYPES=[i.WIRE_TYPES.VARINT,i.WIRE_TYPES.BITS64,i.WIRE_TYPES.BITS32],i.TYPES={int32:{name:"int32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},uint64:{name:"uint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.UZERO:void 0},sint64:{name:"sint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},bool:{name:"bool",wireType:i.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:i.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:i.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.ZERO:void 0},float:{name:"float",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:i.WIRE_TYPES.STARTGROUP,defaultValue:null}},i.MAP_KEY_TYPES=[i.TYPES.int32,i.TYPES.sint32,i.TYPES.sfixed32,i.TYPES.uint32,i.TYPES.fixed32,i.TYPES.int64,i.TYPES.sint64,i.TYPES.sfixed64,i.TYPES.uint64,i.TYPES.fixed64,i.TYPES.bool,i.TYPES.string,i.TYPES.bytes],i.ID_MIN=1,i.ID_MAX=536870911,i.convertFieldsToCamelCase=!1,i.populateAccessors=!0,i.populateDefaults=!0,i.Util=function(){var o={};return o.IS_NODE=!(typeof process!="object"||process+""!="[object process]"||process.browser),o.XHR=function(){var s,c=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],d=null;for(s=0;s]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,FQTYPEREF:/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},i.DotProto=function(o,s){function c(m,_){var v=-1,T=1;if(m.charAt(0)=="-"&&(T=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))v=parseInt(m);else if(s.NUMBER_HEX.test(m))v=parseInt(m.substring(2),16);else{if(!s.NUMBER_OCT.test(m))throw Error("illegal id value: "+(T<0?"-":"")+m);v=parseInt(m.substring(1),8)}if(v=0|T*v,!_&&v<0)throw Error("illegal id value: "+(T<0?"-":"")+m);return v}function d(m){var _=1;if(m.charAt(0)=="-"&&(_=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))return _*parseInt(m,10);if(s.NUMBER_HEX.test(m))return _*parseInt(m.substring(2),16);if(s.NUMBER_OCT.test(m))return _*parseInt(m.substring(1),8);if(m==="inf")return 1/0*_;if(m==="nan")return NaN;if(s.NUMBER_FLT.test(m))return _*parseFloat(m);throw Error("illegal number value: "+(_<0?"-":"")+m)}function l(m,_,v){m[_]===void 0?m[_]=v:(Array.isArray(m[_])||(m[_]=[m[_]]),m[_].push(v))}var h,a,u={},p=function(m){this.source=m+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},f=p.prototype;return f._readString=function(){var m,_=this._stringOpen==='"'?s.STRING_DQ:s.STRING_SQ;if(_.lastIndex=this.index-1,!(m=_.exec(this.source)))throw Error("unterminated string");return this.index=_.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,m[1]},f.next=function(){var m,_,v,T,y;if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(this._stringOpen!==null)return this._readString();do{for(m=!1;s.WHITESPACE.test(v=this.source.charAt(this.index));)if(v===` `&&++this.line,++this.index===this.source.length)return null;if(this.source.charAt(this.index)==="/")if(++this.index,this.source.charAt(this.index)==="/"){for(;this.source.charAt(++this.index)!==` `;)if(this.index==this.source.length)return null;++this.index,++this.line,m=!0}else{if((v=this.source.charAt(this.index))!=="*")return"/";do{if(v===` `&&++this.line,++this.index===this.source.length)return null;_=v,v=this.source.charAt(this.index)}while(_!=="*"||v!=="/");++this.index,m=!0}}while(m);if(this.index===this.source.length)return null;if(T=this.index,s.DELIM.lastIndex=0,!s.DELIM.test(this.source.charAt(T++)))for(;T"),y=this.tn.next(),!s.NAME.test(y))throw Error("illegal message field name: "+y);T.name=y,this.tn.skip("="),T.id=c(this.tn.next()),(y=this.tn.peek())==="["&&this._parseFieldOptions(T),this.tn.skip(";")}else if((v=v!==void 0?v:this.tn.next())==="group"){if(w=this._parseMessage(m,T),!/^[A-Z]/.test(w.name))throw Error("illegal group name: "+w.name);T.type=w.name,T.name=w.name.toLowerCase(),this.tn.omit(";")}else{if(!s.TYPE.test(v)&&!s.TYPEREF.test(v))throw Error("illegal message field type: "+v);if(T.type=v,y=this.tn.next(),!s.NAME.test(y))throw Error("illegal message field name: "+y);T.name=y,this.tn.skip("="),T.id=c(this.tn.next()),(y=this.tn.peek())==="["&&this._parseFieldOptions(T),this.tn.skip(";")}return m.fields.push(T),T},a._parseMessageOneOf=function(m){var _,v,T,y=this.tn.next();if(!s.NAME.test(y))throw Error("illegal oneof name: "+y);for(v=y,T=[],this.tn.skip("{");(y=this.tn.next())!=="}";)(_=this._parseMessageField(m,"optional",y)).oneof=v,T.push(_.id);this.tn.omit(";"),m.oneofs[v]=T},a._parseFieldOptions=function(m){this.tn.skip("[");for(var _=!0;this.tn.peek()!=="]";)_||this.tn.skip(","),this._parseOption(m,!0),_=!1;this.tn.next()},a._parseEnum=function(m){var _,v={name:"",values:[],options:{}},T=this.tn.next();if(!s.NAME.test(T))throw Error("illegal name: "+T);for(v.name=T,this.tn.skip("{");(T=this.tn.next())!=="}";)if(T==="option")this._parseOption(v);else{if(!s.NAME.test(T))throw Error("illegal name: "+T);this.tn.skip("="),_={name:T,id:c(this.tn.next(),!0)},(T=this.tn.peek())==="["&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),v.values.push(_)}this.tn.omit(";"),m.enums.push(v)},a._parseExtensionRanges=function(){var m,_,v,T=[];do{for(_=[];;){switch(m=this.tn.next()){case"min":v=o.ID_MIN;break;case"max":v=o.ID_MAX;break;default:v=d(m)}if(_.push(v),_.length===2)break;if(this.tn.peek()!=="to"){_.push(v);break}this.tn.next()}T.push(_)}while(this.tn.omit(","));return this.tn.skip(";"),T},a._parseExtend=function(m){var _,v=this.tn.next();if(!s.TYPEREF.test(v))throw Error("illegal extend reference: "+v);for(_={ref:v,fields:[]},this.tn.skip("{");(v=this.tn.next())!=="}";)if(s.RULE.test(v))this._parseMessageField(_,v);else{if(!s.TYPEREF.test(v))throw Error("illegal extend token: "+v);if(!this.proto3)throw Error("illegal field rule: "+v);this._parseMessageField(_,"optional",v)}return this.tn.omit(";"),m.messages.push(_),_},a.toString=function(){return"Parser at line "+this.tn.line},u.Parser=h,u}(i,i.Lang),i.Reflect=function(o){function s(E,S){if(E&&typeof E.low=="number"&&typeof E.high=="number"&&typeof E.unsigned=="boolean"&&E.low==E.low&&E.high==E.high)return new o.Long(E.low,E.high,S===void 0?E.unsigned:S);if(typeof E=="string")return o.Long.fromString(E,S||!1,10);if(typeof E=="number")return o.Long.fromNumber(E,S||!1);throw Error("not convertible to Long")}function c(E,S){var I=S.readVarint32(),N=7&I,b=I>>>3;switch(N){case o.WIRE_TYPES.VARINT:do I=S.readUint8();while((128&I)==128);break;case o.WIRE_TYPES.BITS64:S.offset+=8;break;case o.WIRE_TYPES.LDELIM:I=S.readVarint32(),S.offset+=I;break;case o.WIRE_TYPES.STARTGROUP:c(b,S);break;case o.WIRE_TYPES.ENDGROUP:if(b===E)return!1;throw Error("Illegal GROUPEND after unknown group: "+b+" ("+E+" expected)");case o.WIRE_TYPES.BITS32:S.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+E+": "+N)}return!0}var d,l,h,a,u,p,f,m,_,v,T,y,w,L,M,C,A={},F=function(E,S,I){this.builder=E,this.parent=S,this.name=I,this.className},G=F.prototype;return G.fqn=function(){for(var E=this.name,S=this;(S=S.parent)!=null;)E=S.name+"."+E;return E},G.toString=function(E){return(E?this.className+" ":"")+this.fqn()},G.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},A.T=F,d=function(E,S,I,N,b){F.call(this,E,S,I),this.className="Namespace",this.children=[],this.options=N||{},this.syntax=b||"proto2"},(l=d.prototype=Object.create(F.prototype)).getChildren=function(E){var S,I,N;if((E=E||null)==null)return this.children.slice();for(S=[],I=0,N=this.children.length;N>I;++I)this.children[I]instanceof E&&S.push(this.children[I]);return S},l.addChild=function(E){var S;if(S=this.getChild(E.name))if(S instanceof u.Field&&S.name!==S.originalName&&this.getChild(S.originalName)===null)S.name=S.originalName;else{if(!(E instanceof u.Field&&E.name!==E.originalName&&this.getChild(E.originalName)===null))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+E.name);E.name=E.originalName}this.children.push(E)},l.getChild=function(E){var S,I,N=typeof E=="number"?"id":"name";for(S=0,I=this.children.length;I>S;++S)if(this.children[S][N]===E)return this.children[S];return null},l.resolve=function(E,S){var I,N=typeof E=="string"?E.split("."):E,b=this,k=0;if(N[k]===""){for(;b.parent!==null;)b=b.parent;k++}do{do{if(!(b instanceof A.Namespace)){b=null;break}if(!((I=b.getChild(N[k]))&&I instanceof A.T&&(!S||I instanceof A.Namespace))){b=null;break}b=I,k++}while(kS;++S)(E=b[S])instanceof d&&(N[E.name]=E.build());return Object.defineProperty&&Object.defineProperty(N,"$options",{value:this.buildOpt()}),N},l.buildOpt=function(){var E,S,I,N,b={},k=Object.keys(this.options);for(E=0,S=k.length;S>E;++E)I=k[E],N=this.options[k[E]],b[I]=N;return b},l.getOption=function(E){return E===void 0?this.options:this.options[E]!==void 0?this.options[E]:null},A.Namespace=d,h=function(E,S,I,N){if(this.type=E,this.resolvedType=S,this.isMapKey=I,this.syntax=N,I&&o.MAP_KEY_TYPES.indexOf(E)<0)throw Error("Invalid map key type: "+E.name)},a=h.prototype,h.defaultFieldValue=function(E){if(typeof E=="string"&&(E=o.TYPES[E]),E.defaultValue===void 0)throw Error("default value for type "+E.name+" is not supported");return E==o.TYPES.bytes?new e(0):E.defaultValue},a.verifyValue=function(E){var S,I,N,b=function(k,U){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+k+" ("+U+")")}.bind(this);switch(this.type){case o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:return(typeof E!="number"||E==E&&E%1!=0)&&b(typeof E,"not an integer"),E>4294967295?0|E:E;case o.TYPES.uint32:case o.TYPES.fixed32:return(typeof E!="number"||E==E&&E%1!=0)&&b(typeof E,"not an integer"),E<0?E>>>0:E;case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:if(o.Long)try{return s(E,!1)}catch(k){b(typeof E,k.message)}else b(typeof E,"requires Long.js");case o.TYPES.uint64:case o.TYPES.fixed64:if(o.Long)try{return s(E,!0)}catch(k){b(typeof E,k.message)}else b(typeof E,"requires Long.js");case o.TYPES.bool:return typeof E!="boolean"&&b(typeof E,"not a boolean"),E;case o.TYPES.float:case o.TYPES.double:return typeof E!="number"&&b(typeof E,"not a number"),E;case o.TYPES.string:return typeof E=="string"||E&&E instanceof String||b(typeof E,"not a string"),""+E;case o.TYPES.bytes:return n.isByteBuffer(E)?E:n.wrap(E);case o.TYPES.enum:for(S=this.resolvedType.getChildren(o.Reflect.Enum.Value),N=0;N4294967295||E<0)&&b(typeof E,"not in range for uint32"),E;b(E,"not a valid enum value");case o.TYPES.group:case o.TYPES.message:if(E&&typeof E=="object"||b(typeof E,"object expected"),E instanceof this.resolvedType.clazz)return E;if(E instanceof o.Builder.Message){for(N in I={},E)E.hasOwnProperty(N)&&(I[N]=E[N]);E=I}return new this.resolvedType.clazz(E)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+E+" (undefined type "+this.type+")")},a.calculateLength=function(E,S){if(S===null)return 0;var I;switch(this.type){case o.TYPES.int32:return S<0?e.calculateVarint64(S):e.calculateVarint32(S);case o.TYPES.uint32:return e.calculateVarint32(S);case o.TYPES.sint32:return e.calculateVarint32(e.zigZagEncode32(S));case o.TYPES.fixed32:case o.TYPES.sfixed32:case o.TYPES.float:return 4;case o.TYPES.int64:case o.TYPES.uint64:return e.calculateVarint64(S);case o.TYPES.sint64:return e.calculateVarint64(e.zigZagEncode64(S));case o.TYPES.fixed64:case o.TYPES.sfixed64:return 8;case o.TYPES.bool:return 1;case o.TYPES.enum:return e.calculateVarint32(S);case o.TYPES.double:return 8;case o.TYPES.string:return I=e.calculateUTF8Bytes(S),e.calculateVarint32(I)+I;case o.TYPES.bytes:if(S.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+S.remaining()+" bytes remaining");return e.calculateVarint32(S.remaining())+S.remaining();case o.TYPES.message:return I=this.resolvedType.calculate(S),e.calculateVarint32(I)+I;case o.TYPES.group:return(I=this.resolvedType.calculate(S))+e.calculateVarint32(E<<3|o.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+S+" (unknown type)")},a.encodeValue=function(E,S,I){var N,b;if(S===null)return I;switch(this.type){case o.TYPES.int32:S<0?I.writeVarint64(S):I.writeVarint32(S);break;case o.TYPES.uint32:I.writeVarint32(S);break;case o.TYPES.sint32:I.writeVarint32ZigZag(S);break;case o.TYPES.fixed32:I.writeUint32(S);break;case o.TYPES.sfixed32:I.writeInt32(S);break;case o.TYPES.int64:case o.TYPES.uint64:I.writeVarint64(S);break;case o.TYPES.sint64:I.writeVarint64ZigZag(S);break;case o.TYPES.fixed64:I.writeUint64(S);break;case o.TYPES.sfixed64:I.writeInt64(S);break;case o.TYPES.bool:typeof S=="string"?I.writeVarint32(S.toLowerCase()==="false"?0:!!S):I.writeVarint32(S?1:0);break;case o.TYPES.enum:I.writeVarint32(S);break;case o.TYPES.float:I.writeFloat32(S);break;case o.TYPES.double:I.writeFloat64(S);break;case o.TYPES.string:I.writeVString(S);break;case o.TYPES.bytes:if(S.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+S.remaining()+" bytes remaining");N=S.offset,I.writeVarint32(S.remaining()),I.append(S),S.offset=N;break;case o.TYPES.message:b=new e().LE(),this.resolvedType.encode(S,b),I.writeVarint32(b.offset),I.append(b.flip());break;case o.TYPES.group:this.resolvedType.encode(S,I),I.writeVarint32(E<<3|o.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+S+" (unknown type)")}return I},a.decode=function(E,S,I){if(S!=this.type.wireType)throw Error("Unexpected wire type for element");var N,b;switch(this.type){case o.TYPES.int32:return 0|E.readVarint32();case o.TYPES.uint32:return E.readVarint32()>>>0;case o.TYPES.sint32:return 0|E.readVarint32ZigZag();case o.TYPES.fixed32:return E.readUint32()>>>0;case o.TYPES.sfixed32:return 0|E.readInt32();case o.TYPES.int64:return E.readVarint64();case o.TYPES.uint64:return E.readVarint64().toUnsigned();case o.TYPES.sint64:return E.readVarint64ZigZag();case o.TYPES.fixed64:return E.readUint64();case o.TYPES.sfixed64:return E.readInt64();case o.TYPES.bool:return!!E.readVarint32();case o.TYPES.enum:return E.readVarint32();case o.TYPES.float:return E.readFloat();case o.TYPES.double:return E.readDouble();case o.TYPES.string:return E.readVString();case o.TYPES.bytes:if(b=E.readVarint32(),E.remaining()J;++J)this[at[J].name]=null;for(J=0,W=nt.length;W>J;++J)this[(it=nt[J]).name]=it.repeated?[]:it.map?new k.Map(it):null,!it.required&&U.syntax!=="proto3"||it.defaultValue===null||(this[it.name]=it.defaultValue);if(arguments.length>0)if(arguments.length!==1||D===null||typeof D!="object"||!(typeof D.encode!="function"||D instanceof et)||Array.isArray(D)||D instanceof k.Map||e.isByteBuffer(D)||D instanceof ArrayBuffer||k.Long&&D instanceof k.Long)for(J=0,W=arguments.length;W>J;++J)(st=arguments[J])!==void 0&&this.$set(nt[J].name,st);else this.$set(D)},rt=et.prototype=Object.create(k.Builder.Message.prototype);for(rt.add=function(D,J,W){var it=U._fieldsByName[D];if(!W){if(!it)throw Error(this+"#"+D+" is undefined");if(!(it instanceof k.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: "+it.toString(!0));if(!it.repeated)throw Error(this+"#"+D+" is not a repeated field");J=it.verifyValue(J,!0)}return this[D]===null&&(this[D]=[]),this[D].push(J),this},rt.$add=rt.add,rt.set=function(D,J,W){var it,st,ht;if(D&&typeof D=="object"){for(it in W=J,D)D.hasOwnProperty(it)&&(J=D[it])!==void 0&&this.$set(it,J,W);return this}if(st=U._fieldsByName[D],W)this[D]=J;else{if(!st)throw Error(this+"#"+D+" is not a field: undefined");if(!(st instanceof k.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: "+st.toString(!0));this[st.name]=J=st.verifyValue(J)}return st&&st.oneof&&(ht=this[st.oneof.name],J!==null?(ht!==null&&ht!==st.name&&(this[ht]=null),this[st.oneof.name]=st.name):ht===D&&(this[st.oneof.name]=null)),this},rt.$set=rt.set,rt.get=function(D,J){if(J)return this[D];var W=U._fieldsByName[D];if(!(W&&W instanceof k.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: undefined");if(!(W instanceof k.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: "+W.toString(!0));return this[W.name]},rt.$get=rt.get,q=0;qN;N++)if((I=this.children[N])instanceof T||I instanceof u||I instanceof L){if(S.hasOwnProperty(I.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+I.toString(!0)+" cannot override static property '"+I.name+"'");S[I.name]=I.build()}else if(I instanceof u.Field)I.build(),this._fields.push(I),this._fieldsById[I.id]=I,this._fieldsByName[I.name]=I;else if(!(I instanceof u.OneOf||I instanceof w))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[N].toString(!0));return this.clazz=S},p.encode=function(E,S,I){var N,b,k,U,$,q=null;for(k=0,U=this._fields.length;U>k;++k)b=E[(N=this._fields[k]).name],N.required&&b===null?q===null&&(q=N):N.encode(I?b:N.verifyValue(b),S,E);if(q!==null)throw($=Error("Missing at least one required field for "+this.toString(!0)+": "+q)).encoded=S,$;return S},p.calculate=function(E){for(var S,I,N=0,b=0,k=this._fields.length;k>b;++b){if(I=E[(S=this._fields[b]).name],S.required&&I===null)throw Error("Missing at least one required field for "+this.toString(!0)+": "+S);N+=S.calculate(I,E)}return N},p.decode=function(E,S,I){var N,b,k,U,$,q,X,nt,at,et,rt,D;for(S=typeof S=="number"?S:-1,$=E.offset,q=new this.clazz;E.offset<$+S||S===-1&&E.remaining()>0;){if(k=(N=E.readVarint32())>>>3,(b=7&N)===o.WIRE_TYPES.ENDGROUP){if(k!==I)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(I?I+" expected":"not a group")+")");break}if(U=this._fieldsById[k])U.repeated&&!U.options.packed?q[U.name].push(U.decode(b,E)):U.map?(nt=U.decode(b,E),q[U.name].set(nt[0],nt[1])):(q[U.name]=U.decode(b,E),U.oneof&&((at=q[U.oneof.name])!==null&&at!==U.name&&(q[at]=null),q[U.oneof.name]=U.name));else switch(b){case o.WIRE_TYPES.VARINT:E.readVarint32();break;case o.WIRE_TYPES.BITS32:E.offset+=4;break;case o.WIRE_TYPES.BITS64:E.offset+=8;break;case o.WIRE_TYPES.LDELIM:X=E.readVarint32(),E.offset+=X;break;case o.WIRE_TYPES.STARTGROUP:for(;c(k,E););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+b)}}for(et=0,rt=this._fields.length;rt>et;++et)if(q[(U=this._fields[et]).name]===null)if(this.syntax==="proto3")q[U.name]=U.defaultValue;else{if(U.required)throw(D=Error("Missing at least one required field for "+this.toString(!0)+": "+U.name)).decoded=q,D;o.populateDefaults&&U.defaultValue!==null&&(q[U.name]=U.defaultValue)}return q},A.Message=u,f=function(E,S,I,N,b,k,U,$,q,X){F.call(this,E,S,k),this.className="Message.Field",this.required=I==="required",this.repeated=I==="repeated",this.map=I==="map",this.keyType=N||null,this.type=b,this.resolvedType=null,this.id=U,this.options=$||{},this.defaultValue=null,this.oneof=q||null,this.syntax=X||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof u.ExtensionField||(this.name=o.Util.toCamelCase(this.name))},(m=f.prototype=Object.create(F.prototype)).build=function(){this.element=new h(this.type,this.resolvedType,!1,this.syntax),this.map&&(this.keyElement=new h(this.keyType,void 0,!0,this.syntax)),this.syntax!=="proto3"||this.repeated||this.map?this.options.default!==void 0&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=h.defaultFieldValue(this.type)},m.verifyValue=function(E,S){var I,N,b;if(S=S||!1,I=function(k,U){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+k+" ("+U+")")}.bind(this),E===null)return this.required&&I(typeof E,"required"),this.syntax==="proto3"&&this.type!==o.TYPES.message&&I(typeof E,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!S){for(Array.isArray(E)||(E=[E]),b=[],N=0;N0;case o.TYPES.bytes:return E.remaining()>0;case o.TYPES.enum:return E!==0;case o.TYPES.message:return E!==null;default:return!0}},m.encode=function(E,S,I){var N,b,k,U,$;if(this.type===null||typeof this.type!="object")throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(E===null||this.repeated&&E.length==0)return S;try{if(this.repeated)if(this.options.packed&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(S.writeVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),S.ensureCapacity(S.offset+=1),b=S.offset,N=0;N1&&($=S.slice(b,S.offset),b+=U-1,S.offset=b,S.append($)),S.writeVarint32(k,b-U)}else for(N=0;N=0){for(I+=e.calculateVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),b=0,N=0;N=0&&!I){for(b=S.readVarint32(),b=S.offset+b,k=[];S.offset0;)if(E=7&(q=$.readVarint32()),(X=q>>>3)==1)U=this.keyElement.decode($,E,X);else{if(X!==2)throw Error("Unexpected tag in map field key/value submessage");N=this.element.decode($,E,X)}return[U,N]}return this.element.decode(S,E,this.id)},A.Message.Field=f,_=function(E,S,I,N,b,k,U){f.call(this,E,S,I,null,N,b,k,U),this.extension},_.prototype=Object.create(f.prototype),A.Message.ExtensionField=_,v=function(E,S,I){F.call(this,E,S,I),this.fields=[]},A.Message.OneOf=v,T=function(E,S,I,N,b){d.call(this,E,S,I,N,b),this.className="Enum",this.object=null},T.getName=function(E,S){var I,N,b=Object.keys(E);for(N=0;NN;++N)S[I[N].name]=I[N].id;return Object.defineProperty&&Object.defineProperty(S,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=S},A.Enum=T,y=function(E,S,I,N){F.call(this,E,S,I),this.className="Enum.Value",this.id=N},y.prototype=Object.create(F.prototype),A.Enum.Value=y,w=function(E,S,I,N){F.call(this,E,S,I),this.field=N},w.prototype=Object.create(F.prototype),A.Extension=w,L=function(E,S,I,N){d.call(this,E,S,I,N),this.className="Service",this.clazz=null},(L.prototype=Object.create(d.prototype)).build=function(E){return this.clazz&&!E?this.clazz:this.clazz=function(S,I){var N,b=function($){S.Builder.Service.call(this),this.rpcImpl=$||function(q,X,nt){setTimeout(nt.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},k=b.prototype=Object.create(S.Builder.Service.prototype),U=I.getChildren(S.Reflect.Service.RPCMethod);for(N=0;N0;){if(a=u.pop(),!Array.isArray(a))throw Error("not a valid namespace: "+JSON.stringify(a));for(;a.length>0;){if(p=a.shift(),l.isMessage(p)){if(f=new c.Message(this,this.ptr,p.name,p.options,p.isGroup,p.syntax),m={},p.oneofs&&Object.keys(p.oneofs).forEach(function(v){f.addChild(m[v]=new c.Message.OneOf(this,f,v))},this),p.fields&&p.fields.forEach(function(v){if(f.getChild(0|v.id)!==null)throw Error("duplicate or invalid field id in "+f.name+": "+v.id);if(v.options&&typeof v.options!="object")throw Error("illegal field options in "+f.name+"#"+v.name);var T=null;if(typeof v.oneof=="string"&&!(T=m[v.oneof]))throw Error("illegal oneof in "+f.name+"#"+v.name+": "+v.oneof);v=new c.Message.Field(this,f,v.rule,v.keytype,v.type,v.name,v.id,v.options,T,p.syntax),T&&T.fields.push(v),f.addChild(v)},this),_=[],p.enums&&p.enums.forEach(function(v){_.push(v)}),p.messages&&p.messages.forEach(function(v){_.push(v)}),p.services&&p.services.forEach(function(v){_.push(v)}),p.extensions&&(f.extensions=typeof p.extensions[0]=="number"?[p.extensions]:p.extensions),this.ptr.addChild(f),_.length>0){u.push(a),a=_,_=null,this.ptr=f,f=null;continue}_=null}else if(l.isEnum(p))f=new c.Enum(this,this.ptr,p.name,p.options,p.syntax),p.values.forEach(function(v){f.addChild(new c.Enum.Value(this,f,v.name,v.id))},this),this.ptr.addChild(f);else if(l.isService(p))f=new c.Service(this,this.ptr,p.name,p.options),Object.keys(p.rpc).forEach(function(v){var T=p.rpc[v];f.addChild(new c.Service.RPCMethod(this,f,v,T.request,T.response,!!T.request_stream,!!T.response_stream,T.options))},this),this.ptr.addChild(f);else{if(!l.isExtend(p))throw Error("not a valid definition: "+JSON.stringify(p));if(f=this.ptr.resolve(p.ref,!0))p.fields.forEach(function(v){var T,y,w,L;if(f.getChild(0|v.id)!==null)throw Error("duplicate extended field id in "+f.name+": "+v.id);if(f.extensions&&(T=!1,f.extensions.forEach(function(M){v.id>=M[0]&&v.id<=M[1]&&(T=!0)}),!T))throw Error("illegal extended field id in "+f.name+": "+v.id+" (not within valid ranges)");y=v.name,this.options.convertFieldsToCamelCase&&(y=o.Util.toCamelCase(y)),w=new c.Message.ExtensionField(this,f,v.rule,v.type,this.ptr.fqn()+"."+y,v.id,v.options),L=new c.Extension(this,this.ptr,v.name,w),w.extension=L,this.ptr.addChild(L),f.addChild(w)},this);else if(!/\.?google\.protobuf\./.test(p.ref))throw Error("extended message "+p.ref+" is not defined")}p=null,f=null}a=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},h.import=function(a,u){var p,f,m,_,v,T,y,w,L="/";if(typeof u=="string"){if(o.Util.IS_NODE,this.files[u]===!0)return this.reset();this.files[u]=!0}else if(typeof u=="object"){if(p=u.root,o.Util.IS_NODE,(p.indexOf("\\")>=0||u.file.indexOf("\\")>=0)&&(L="\\"),f=p+L+u.file,this.files[f]===!0)return this.reset();this.files[f]=!0}if(a.imports&&a.imports.length>0){for(_=!1,typeof u=="object"?(this.importRoot=u.root,_=!0,m=this.importRoot,u=u.file,(m.indexOf("\\")>=0||u.indexOf("\\")>=0)&&(L="\\")):typeof u=="string"?this.importRoot?m=this.importRoot:u.indexOf("/")>=0?(m=u.replace(/\/[^\/]*$/,""))===""&&(m="/"):u.indexOf("\\")>=0?(m=u.replace(/\\[^\\]*$/,""),L="\\"):m=".":m=null,v=0;v0&&o._codec[e].decode(t),Rt(s)&&(s=function(d){for(var l in d)Rt(d[l])&&(d[l]=St(d[l]));return d}(s)),Cr(c)&&(s=c.call(this,s,r))}catch(d){H.error(`PB parse error `,d,t,e)}return s},n.prototype._readBytes=function(t){var e=t.offset,r=t.buffer,i=t.limit;if(e)try{var o=nc(r)?new Uint8Array(r):r;return Hn.readUTF(o.subarray(e,i))}catch(s){H.info(`readBytes error `,s)}return t},n.prototype._formatBytes=function(t){if(!t)return t;var e=this._readBytes(t);try{e=JSON.parse(e)}catch(r){H.info(`formatBytes error `,r)}return e||t},n.prototype._formatSyncMessages=function(t,e){e=e||{};var r=this,i=t.list,o=t.syncTime,s=t.finished;return(ct(s)||s===null)&&(t.finished=!0),t.syncTime=St(o),t.list=Jn(i,function(c){return r._formatReceivedMessage(c,e)}),t},n.prototype._formatReceivedMessage=function(t,e){if(!t)return t;var r=(e=e||{}).currentUserId,i=e.connectedTime,o=t.content,s=t.fromUserId,c=t.type,d=t.groupId,l=t.status,h=t.dataTime,a=t.classname,u=t.msgId,p=t.extraContent,f=t.pushContent,m=t.pushExt,_=t.configFlag,v=t.extStatus;t.toUserId,t.groupUnpush;var T=(t.direction||zt.RECEIVE)===zt.SEND,y=function(W){var it=Un.READ;return{isPersited:!!(16&W),isCounted:!!(32&W),isMentioned:!!(64&W),disableNotification:!!(512&W),receivedStatus:it=2&W?Un.RETRIEVED:it,canIncludeExpansion:!!(1024&W)}}(l),w=y.isPersited,L=y.isCounted,M=y.isMentioned,C=y.disableNotification,A=y.receivedStatus,F=y.canIncludeExpansion,G=!!(2&(v||0)),E=!!(4&(v||0)),S=[Y.GROUP,Y.CHATROOM,Y.RTC_ROOM,Y.ULTRA_GROUP].indexOf(c)>-1?d:s,I=T?r:s,N=St(h),b=N "+s),this.timestamp=e.readLong()}return{stream:e,length:r}},t.MESSAGE_LENGTH=2,t}($n),ys=function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name=jt.DISCONNECT,e.status=0,e}return It(t,n),t.prototype.readMessage=function(e,r){return e.readByte(),this.status=+e.readByte(),{stream:e,length:r}},t.MESSAGE_LENGTH=2,t}($n),Xd=function(n){function t(){var e=n.call(this,xt.PING_REQ)||this;return e._name=jt.PING_REQ,e}return It(t,n),t.prototype.writeMessage=function(e){},t}(Cc),Ic=function(n){function t(e){var r=n.call(this,e)||this;return r._name=jt.PING_RESP,r}return It(t,n),t}($n),Es=function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.messageId=0,e}return It(t,n),t.prototype.readMessage=function(e,r){var i=256*e.readByte()+e.readByte();return this.messageId=parseInt(i.toString(),10),{stream:e,length:r}},t}($n),si=function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.messageId=0,e}return It(t,n),t.prototype.writeMessage=function(e){var r=this.messageId,i=255&r,o=(65280&r)>>8;e.write(o),e.write(i)},t}(Cc),Bn=function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name=jt.PUBLISH,e.topic="",e.targetId="",e.syncMsg=!1,e.identifier=De.PUB,e}return It(t,n),t.prototype.readMessage=function(e,r){return this.date=e.readInt(),this.topic=e.readUTF(),this.targetId=e.readUTF(),n.prototype.readMessage.call(this,e,r),this.data=e.readAll(),{stream:e,length:r}},t}(Es),qt=function(n){function t(e,r,i){var o=n.call(this,xt.PUBLISH)||this;return o._name=jt.PUBLISH,o.syncMsg=!1,o.identifier=De.PUB,o.topic=e,o.data=Bt(r)?Hn.writeUTF(r):r,o.targetId=i,o}return It(t,n),t.prototype.writeMessage=function(e){e.writeUTF(this.topic),e.writeUTF(this.targetId),n.prototype.writeMessage.call(this,e),e.write(this.data)},t}(si),Qi=function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name=jt.PUB_ACK,e.status=0,e.date=0,e.millisecond=0,e.messageUId="",e.timestamp=0,e.identifier=De.PUB,e.topic="",e.targetId="",e}return It(t,n),t.prototype.readMessage=function(e,r){return n.prototype.readMessage.call(this,e,r),this.date=e.readInt(),this.status=256*e.readByte()+e.readByte(),this.millisecond=256*e.readByte()+e.readByte(),this.timestamp=1e3*this.date+this.millisecond,this.messageUId=e.readUTF(),{stream:e,length:r}},t}(Es),Sc=function(n){function t(e){var r=n.call(this,xt.PUB_ACK)||this;return r._name=jt.PUB_ACK,r.status=0,r.date=0,r.millisecond=0,r.messageUId="",r.timestamp=0,r.messageId=e,r}return It(t,n),t.prototype.writeMessage=function(e){n.prototype.writeMessage.call(this,e)},t}(si),Q=function(n){function t(e,r,i){var o=n.call(this,xt.QUERY)||this;return o.name=jt.QUERY,o.identifier=De.QUERY,o.topic=e,o.data=Bt(r)?Hn.writeUTF(r):r,o.targetId=i,o}return It(t,n),t.prototype.writeMessage=function(e){e.writeUTF(this.topic),e.writeUTF(this.targetId),n.prototype.writeMessage.call(this,e),e.write(this.data)},t}(si),Oc=function(n){function t(e){var r=n.call(this,xt.QUERY_CONFIRM)||this;return r._name=jt.QUERY_CON,r.messageId=e,r}return It(t,n),t}(si),bn=function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name=jt.QUERY_ACK,e.status=0,e.identifier=De.QUERY,e.topic="",e.targetId="",e}return It(t,n),t.prototype.readMessage=function(e,r){return n.prototype.readMessage.call(this,e,r),this.date=e.readInt(),this.status=256*e.readByte()+e.readByte(),this.data=e.readAll(),{stream:e,length:r}},t}(Es),Nc=function(n){var t,e=n.type;switch(e){case xt.CONN_ACK:t=new Rc(n);break;case xt.PUBLISH:(t=new Bn(n)).syncMsg=n.syncMsg;break;case xt.PUB_ACK:t=new Qi(n);break;case xt.QUERY_ACK:t=new bn(n);break;case xt.SUB_ACK:case xt.UNSUB_ACK:case xt.PING_RESP:t=new Ic(n);break;case xt.DISCONNECT:t=new ys(n);break;default:t=new $n(n),H.error("No support for deserializing "+e+" messages")}return t};(function(n){n[n.ppMsgP=1]="ppMsgP",n[n.ppMsgN=2]="ppMsgN",n[n.ppMsgS=3]="ppMsgS",n[n.pgMsgP=4]="pgMsgP",n[n.chatMsg=5]="chatMsg",n[n.pcMsgP=6]="pcMsgP",n[n.qryPMsg=7]="qryPMsg",n[n.qryGMsg=8]="qryGMsg",n[n.qryCHMsg=9]="qryCHMsg",n[n.qryCMsg=10]="qryCMsg",n[n.qrySMsg=11]="qrySMsg",n[n.recallMsg=12]="recallMsg",n[n.prMsgS=13]="prMsgS",n[n.rrMsg=14]="rrMsg",n[n.rrList=15]="rrList",n[n.s_ntf=16]="s_ntf",n[n.s_msg=17]="s_msg",n[n.s_stat=18]="s_stat",n[n.s_cmd=19]="s_cmd",n[n.s_us=20]="s_us",n[n.pullUS=21]="pullUS",n[n.pgMsgS=22]="pgMsgS",n[n.chatMsgS=23]="chatMsgS",n[n.qrySessionsAtt=24]="qrySessionsAtt",n[n.pullMsg=25]="pullMsg",n[n.qrySessions=26]="qrySessions",n[n.delSessions=27]="delSessions",n[n.delMsg=28]="delMsg",n[n.updRRTime=29]="updRRTime",n[n.chrmPull=30]="chrmPull",n[n.joinChrm=31]="joinChrm",n[n.joinChrmR=32]="joinChrmR",n[n.exitChrm=33]="exitChrm",n[n.queryChrmI=34]="queryChrmI",n[n.setKV=35]="setKV",n[n.delKV=36]="delKV",n[n.pullKV=37]="pullKV",n[n.qryRelation=38]="qryRelation",n[n.delRelation=39]="delRelation",n[n.pullSeAtts=40]="pullSeAtts",n[n.setSeAtt=41]="setSeAtt",n[n.qnTkn=42]="qnTkn",n[n.qnUrl=43]="qnUrl",n[n.aliUrl=44]="aliUrl",n[n.s3Url=45]="s3Url",n[n.stcUrl=46]="stcUrl",n[n.cleanPMsg=47]="cleanPMsg",n[n.cleanGMsg=48]="cleanGMsg",n[n.cleanCMsg=49]="cleanCMsg",n[n.cleanSMsg=50]="cleanSMsg",n[n.rtcRJoin_data=51]="rtcRJoin_data",n[n.rtcRExit=52]="rtcRExit",n[n.rtcPing=53]="rtcPing",n[n.rtcSetData=54]="rtcSetData",n[n.rtc_ntf=55]="rtc_ntf",n[n.viewerJoinR=56]="viewerJoinR",n[n.viewerExitR=57]="viewerExitR",n[n.rtcPullKv=58]="rtcPullKv",n[n.rtcIdentityChange=59]="rtcIdentityChange",n[n.userSetData=60]="userSetData",n[n.rtcQryData=61]="rtcQryData",n[n.rtcDelData=62]="rtcDelData",n[n.rtcSetOutData=63]="rtcSetOutData",n[n.rtcQryUserOutData=64]="rtcQryUserOutData",n[n.rtcToken=65]="rtcToken",n[n.rtcUserState=66]="rtcUserState",n[n.rtcRInfo=67]="rtcRInfo",n[n.rtcUData=68]="rtcUData",n[n.rtcUPut=69]="rtcUPut",n[n.rtcUDel=70]="rtcUDel",n[n.rtcUList=71]="rtcUList",n[n.rtcQueryJoined=72]="rtcQueryJoined",n[n.rtcInvite=73]="rtcInvite",n[n.rtcCancelInvite=74]="rtcCancelInvite",n[n.rtcInviteAnswer=75]="rtcInviteAnswer",n[n.rtcEndInvite=76]="rtcEndInvite",n[n.addSeTag=77]="addSeTag",n[n.delSeTag=78]="delSeTag",n[n.addTag=79]="addTag",n[n.delTag=80]="delTag",n[n.disTag=81]="disTag",n[n.reportsdk=82]="reportsdk",n[n.pullUgSes=83]="pullUgSes",n[n.pullUgMsg=84]="pullUgMsg",n[n.ugMsg=85]="ugMsg",n[n.qryUgMsg=86]="qryUgMsg",n[n.updUgRTime=87]="updUgRTime",n[n.upMsgEx=88]="upMsgEx",n[n.modifyMsg=89]="modifyMsg",n[n.qryMsgChange=90]="qryMsgChange",n[n.qryMsg=91]="qryMsg",n[n.operate=92]="operate",n[n.s_opNtf=93]="s_opNtf",n[n.ugUnpushQuery=94]="ugUnpushQuery",n[n.ugUnpushSet=95]="ugUnpushSet",n[n.setRtcRoomId=96]="setRtcRoomId"})(Zi||(Zi={}));var Jt,kt,x=Zi,bc=function(n,t,e,r,i,o,s,c){return"".concat(n,"://").concat(t,"/websocket?appId=").concat(e,"&token=").concat(encodeURIComponent(r),"&sdkVer=").concat(o,"&pid=").concat(s,"&apiVer=").concat(i.isFromUniapp?"uniapp":"normal").concat(i.connectPlatform?"&platform="+i.connectPlatform:"").concat(c?"&protocolVer="+c:"")},Mc=function(n){return[x.ppMsgS,x.pgMsgS,x.chatMsgS].map(function(t){return x[t]}).indexOf(n)>=0};(function(n){n[n.REDIRECT=0]="REDIRECT",n[n.OTHER_DEVICE_LOGIN=1]="OTHER_DEVICE_LOGIN",n[n.BLOCK=2]="BLOCK",n[n.REMOTE_CLOSE=3]="REMOTE_CLOSE",n[n.LOGOUT=4]="LOGOUT",n[n.BLOCK_NEW=5]="BLOCK_NEW",n[n.REDIRECT_NEW=6]="REDIRECT_NEW"})(Jt||(Jt={})),function(n){n.IM_NAVI="IM-stats_navi-S",n.IM_WEBSOCKET="IM-stats_websocket-S",n.IM_COMET="IM-stats_comet-S",n.IM_CONNECTION_DURATION="IM-stats_con_dur-S"}(kt||(kt={}));var oa=function(n,t){H.info("websocket send -> messageId: ".concat(n.messageId," topic: ").concat(n.topic));var e=n.getBufferData();t.send(e.buffer)},ln=function(n){function t(e,r){var i=n.call(this,"websocket",r)||this;return i._runtime=e,i._socket=null,i._messageIds={},i._syncMessageIds={},i._failedCount=0,i.ALLOW_FAILED_TIMES=2,i._timer=null,i._idCount=0,i._generateMessageId=function(){return i._idCount>=65535&&(i._idCount=0),++i._idCount},i}return It(t,n),t.prototype.connect=function(e,r,i,o,s,c){return V(this,void 0,void 0,function(){var d=this;return B(this,function(l){return[2,new Promise(function(h){var a=i.slice(),u=!1,p=function(){return V(d,void 0,void 0,function(){var f,m,_;return B(this,function(v){switch(v.label){case 0:return a.length===0||u?[2]:(u=!0,f=a.shift(),H.setStatisticsData(kt.IM_WEBSOCKET,{startTime:new Date().getTime(),host:f,protocol:yr.WS}),[4,this._connect(e,r,f,o,s,c)]);case 1:if(m=v.sent(),_=m===R.SUCCESS||m===Mt.REDIRECT?m:Ir(m),H.setStatisticsData(kt.IM_WEBSOCKET,{endTime:new Date().getTime(),code:_}),function(T){V(this,void 0,void 0,function(){var y,w,L,M,C,A,F,G,E,S,I,N,b,k,U;return B(this,function($){switch($.label){case 0:y=kt.IM_WEBSOCKET,w=H.getStatisticsBaseData(),L=w.sdkPrivate,M=w.serverPrivate,C=w.bundleId,A=H.getStatisticsData(y),F=A.protocol,G=A.startTime,E=A.endTime,S=A.code,I=A.host,N=Zt.UNKONWN,$.label=1;case 1:return $.trys.push([1,3,,4]),[4,T.getNetworkType()];case 2:return N=$.sent(),[3,4];case 3:return b=$.sent(),H.info(b.message),[3,4];case 4:return k=0,mt(G)&&mt(E)&&E>G&&G&&(k=E-G),U={spr:L,pr:M,bid:C,ptc:F,dur:k,cod:S,hos:I,net:N},H.reportStatisticsLog(y,U),[2]}})})}(this._runtime),m===R.SUCCESS)this._checkAlive(),h(m);else if(m===Mt.REDIRECT)h(m);else{if(a.length===0)return h(Ir(m)),[2];u=!1,p()}return[2]}})})};s=To(s),d._watcher.status(Z.CONNECTING),p()})]})})},t.prototype._connect=function(e,r,i,o,s,c){return V(this,void 0,void 0,function(){var d,l,h,a,u,p=this;return B(this,function(f){switch(f.label){case 0:return d=o.replace("http","ws"),l=bc(d,i,e,r,this._runtime,s,"",c),H.info("conenct start -> ".concat(l)),this.sendConnectTime=Date.now(),h=this._runtime.createWebSocket(l),a=function(m){p._timer&&(clearTimeout(p._timer),p._timer=null),p._socket===h&&(p._socket=null,p._watcher.status(m))},[4,new Promise(function(m){h.onMessage(function(_){if(Object.prototype.toString.call(_)==="[object ArrayBuffer]"){var v=function(y,w){var L=new Uint8Array(y),M=new Cd(L),C=M.readByte(),A=new Eo(C),F=Nc(A);return F.read(M,L.length-1,w),F}(_,c);if(v instanceof Ic&&p._pingResolve)return p._pingResolve(R.SUCCESS),void(p._pingResolve=void 0);if(v instanceof Rc)return H.info("recv connect ack -> ".concat(v.status)),v.status!==Mt.ACCEPTED?(H.warn("connect failed: ".concat(v.status)),void m(v.status)):(H.info("connect success -> ".concat(l)),p.connectedTime=v.timestamp,p.userId=v.userId||"",p._idCount=v.messageId,void m(R.SUCCESS));if(v instanceof ys){var T=v.status;switch(H.warn("recv disconnect signal -> status: ".concat(T)),T){case Jt.BLOCK_NEW:case Jt.BLOCK:p._watcher.status(Z.BLOCKED);break;case Jt.OTHER_DEVICE_LOGIN:p._watcher.status(Z.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case Jt.REDIRECT_NEW:case Jt.REDIRECT:p._watcher.status(Z.REDIRECT);break;default:p._watcher.status(Z.DISCONNECT_BY_SERVER)}}else p._onReceiveSignal(v)}else H.error("Socket received invalid data:",_)}),h.onClose(function(_,v){for(var T in H.warn("websocket closed! code:",_,"reason:",v),a(Z.CONNECTION_CLOSED),p._messageIds){var y=p._messageIds[T];delete p._messageIds[T],y(R.RC_NET_CHANNEL_INVALID)}m(_)}),h.onError(function(_){for(var v in H.error("websocket error!",_==null?void 0:_.stack),a(Z.WEBSOCKET_ERROR),p._messageIds){var T=p._messageIds[v];delete p._messageIds[v],T(R.RC_NET_CHANNEL_INVALID)}m(R.NETWORK_ERROR)}),h.onOpen(function(){return H.info("websocket open =>",l)}),setTimeout(function(){m(R.TIMEOUT)},5e3)})];case 1:return(u=f.sent())===R.SUCCESS?this._socket=h:(H.warn("connect result -> code: ".concat(u,", url: ").concat(l)),h.close()),[2,u]}})})},t.prototype._checkAlive=function(){var e;return V(this,void 0,void 0,function(){var r,i=this;return B(this,function(o){switch(o.label){case 0:return this._socket?(H.info("send ping ->"),this.sendOnly(new Xd),[4,new Promise(function(s){i._pingResolve=s,i._timer&&clearTimeout(i._timer),i._timer=setTimeout(function(){i._pingResolve=void 0,s(R.TIMEOUT)},15e3)})]):[2];case 1:return(r=o.sent())!==R.SUCCESS?(this._failedCount+=1,H.warn("ping failed count: ".concat(this._failedCount,", code: ").concat(r)),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,H.warn("ping timeout, close current websocket to reconnect!"),(e=this._socket)===null||e===void 0||e.close(),this._socket=null,this._watcher.status(Z.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):(H.info("recv pong <-"),this._failedCount=0,setTimeout(function(){return i._checkAlive()},15e3),[2])}})})},t.prototype._onReceiveSignal=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return r=e.messageId,e.header&&e.header.qos!==At.AT_MOST_ONCE&&(e instanceof Bn&&!e.syncMsg&&(H.info("send pubAck -> ".concat(r," ").concat(e.topic)),this.sendOnly(new Sc(r))),e instanceof bn&&(H.info("send queryCon -> ".concat(r," ").concat(e.topic)),this.sendOnly(new Oc(r)))),r>0&&(e instanceof Qi||e instanceof bn)&&(H.info("recv ack -> messageId: ".concat(r," ").concat(e.topic)),(i=this._messageIds[r])&&(i(e),delete this._messageIds[r]),(o=this._syncMessageIds[r])&&(delete this._syncMessageIds[r],o(e))),e instanceof Bn?(s=e.syncMsg,c=e.topic,H.info("recv PublishReader -> messageId: ".concat(r," ").concat(c)),c===x[x.userSetData]?[2]:!s||Mc(c)?(this._watcher.signal(e),[2]):[4,new Promise(function(a){l._syncMessageIds[r]=a})]):[3,2];case 1:d=h.sent(),delete this._syncMessageIds[r],this._watcher.signal(e,d),h.label=2;case 2:return[2]}})})},t.prototype.sendOnly=function(e){this._socket&&((e instanceof qt||e instanceof Q)&&(e.messageId=this._generateMessageId()),oa(e,this._socket))},t.prototype.send=function(e,r,i,o){return o===void 0&&(o=3e4),V(this,void 0,void 0,function(){var s,c,d,l,h=this;return B(this,function(a){switch(a.label){case 0:return this._socket?(s=this._generateMessageId(),e.messageId=s,oa(e,this._socket),[4,new Promise(function(u){h._messageIds[s]=u,setTimeout(function(){h._messageIds[s]&&delete h._messageIds[s],u()},o)})]):[3,2];case 1:return(c=a.sent())?c instanceof bn||c instanceof Qi?(d=r&&c.data&&[R.SUCCESS,R.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(c.status)>=0,l=d?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?(H.warn("send failed -> message: ".concat(s,", respPBName: ").concat(r,", status: ").concat(c.status)),[2,{code:c.status,data:r&&c.data?l:null}]):[2,{code:R.SUCCESS,data:l}]):[2,{code:c}]:(H.warn("send timeout -> message: ".concat(s,", respPBName: ").concat(r,", timeout: ").concat(o)),[2,{code:R.TIMEOUT}]);case 2:return[2,{code:R.RC_NET_CHANNEL_INVALID}]}})})},t.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(Z.DISCONNECTED))},t}(yc),hn=function(n){function t(e,r){var i=n.call(this,"comet",r)||this;return i._runtime=e,i._messageIds={},i._syncMessageIds={},i._idCount=0,i._generateMessageId=function(){return++i._idCount},i._pid=encodeURIComponent(new Date().getTime()+Math.random()+""),i}return It(t,n),t.prototype.handleCometRes=function(e){var r=this;if(e.status!==200&&e.status!==202)return!1;var i=Bt(e.data)?JSON.parse(e.data):e.data;return i?!Ht(i)||(Ot(i,function(o){return V(r,void 0,void 0,function(){var s,c,d,l,h,a,u,p,f,m,_,v=this;return B(this,function(T){switch(T.label){case 0:if((s=o.sessionid)&&(this._sessionid=s),c=function(y){var w=y.headerCode,L=new Eo(w),M=Nc(L);for(var C in y)M[C]=y[C];return M}(o),d=c.messageId,l=c._header,h=c.status,a=l&&l.qos!==At.AT_MOST_ONCE,d&&c.getIdentifier&&((u=this._messageIds[d])&&u(c),this._syncMessageIds[d]&&this._syncMessageIds[d](c)),a&&(c instanceof Bn&&!c.syncMsg&&(p=new Sc(d),this.sendOnly(p)),c instanceof bn&&(p=new Oc(d),this.sendOnly(p))),c instanceof ys){switch(h){case Jt.OTHER_DEVICE_LOGIN:this._watcher.status(Z.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case Jt.BLOCK:case Jt.BLOCK_NEW:this._watcher.status(Z.BLOCKED);break;case Jt.REDIRECT_NEW:case Jt.REDIRECT:this._watcher.status(Z.REDIRECT);break;default:this._watcher.status(Z.DISCONNECT_BY_SERVER)}return[2]}return c instanceof Bn?(f=c.syncMsg,m=c.topic,!f||Mc(m)?(this._watcher.signal(c),[2,!1]):[4,new Promise(function(y){v._syncMessageIds[d]=y})]):[3,2];case 1:_=T.sent(),delete this._syncMessageIds[d],this._watcher.signal(c,_),T.label=2;case 2:return[2]}})})}),!0):(H.error("received data is not a validJson",i),!1)},t.prototype._startPullSignal=function(e){return V(this,void 0,void 0,function(){var r,i,o,s;return B(this,function(c){switch(c.label){case 0:return r=new Date().getTime(),i="".concat(e,"://").concat(this._domain,"/pullmsg.js?sessionid=").concat(this._sessionid,"×trap=").concat(r,"&pid=").concat(this._pid),[4,this._runtime.httpReq({url:i,body:{pid:this._pid},timeout:45e3})];case 1:return o=c.sent(),s=this.handleCometRes(o),this._isDisconnected||(s?this._startPullSignal(e):(this._isDisconnected=!0,this._watcher.status(Z.NETWORK_UNAVAILABLE))),[2]}})})},t.prototype.connect=function(e,r,i,o,s,c){return V(this,void 0,void 0,function(){var d,l,h=this;return B(this,function(a){return s=To(s),this._protocol=o,this._isDisconnected=!1,this._watcher.status(Z.CONNECTING),d=i.slice(),l=!1,[2,new Promise(function(u){var p=function(){return V(h,void 0,void 0,function(){var f,m,_;return B(this,function(v){switch(v.label){case 0:return d.length===0||l?[2]:(l=!0,f=d.shift(),H.setStatisticsData(kt.IM_COMET,{startTime:new Date().getTime(),host:f,protocol:yr.NAVI}),[4,this._connect(e,r,f,o,s)]);case 1:if(m=v.sent(),_=m===R.SUCCESS||m===Mt.REDIRECT?m:Ir(m),H.setStatisticsData(kt.IM_COMET,{endTime:new Date().getTime(),code:_}),function(T){V(this,void 0,void 0,function(){var y,w,L,M,C,A,F,G,E,S,I,N,b,k,U;return B(this,function($){switch($.label){case 0:y=kt.IM_COMET,w=H.getStatisticsBaseData(),L=w.sdkPrivate,M=w.serverPrivate,C=w.bundleId,A=H.getStatisticsData(y),F=A.protocol,G=A.startTime,E=A.endTime,S=A.code,I=A.host,N=Zt.UNKONWN,$.label=1;case 1:return $.trys.push([1,3,,4]),[4,T.getNetworkType()];case 2:return N=$.sent(),[3,4];case 3:return b=$.sent(),H.info(b.message),[3,4];case 4:return k=0,mt(G)&&mt(E)&&E>G&&G&&(k=E-G),U={spr:L,pr:M,bid:C,ptc:F,dur:k,cod:S,hos:I,net:N},H.reportStatisticsLog(y,U),[2]}})})}(this._runtime),m===R.SUCCESS)this._startPullSignal(o),u(m);else if(m===Mt.REDIRECT)u(m);else{if(d.length===0)return u(Ir(m)),[2];l=!1,p()}return[2]}})})};h._watcher.status(Z.CONNECTING),p()})]})})},t.prototype._connect=function(e,r,i,o,s){return V(this,void 0,void 0,function(){var c,d,l,h;return B(this,function(a){switch(a.label){case 0:return c=function(u){return u.status!==200&&u.status!==202?(H.error("handle comet res -> res: ".concat(JSON.stringify(u||{}))),!1):!!u.data&&(function(p){if(Rt(p))return!0;var f=!1;try{var m=JSON.parse(p);f=JSON.stringify(m)===p}catch{f=!1}return f}(u.data)?Rt(u.data)?u.data:JSON.parse(u.data):(H.error("received data is not a validJson",u.data),!1))},d=bc(o,i,e,r,this._runtime,s,this._pid),this.sendConnectTime=Date.now(),H.info("conenct start -> ".concat(d)),[4,this._runtime.httpReq({url:d,body:{pid:this._pid},timeout:5e3})];case 1:return l=a.sent(),h=c(l),this._domain=i,h&&h.status===0?(this._sessionid=h.sessionid,this.userId=h.userId,this.connectedTime=h.timestamp,H.info("connect success -> userId: ".concat(h.userId,", url: ").concat(d))):H.warn("connect result -> code: ".concat(h==null?void 0:h.status,", url: ").concat(d)),[2,h==null?void 0:h.status]}})})},t.prototype.sendCometData=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,p;return B(this,function(f){switch(f.label){case 0:return o=(i=this)._domain,s=i._sessionid,c=i._pid,d=e.messageId,l=e.topic,h=e.targetId,a=e.getHeaderFlag(),u=l?"".concat(this._protocol,"://").concat(o,"/websocket?messageid=").concat(d,"&header=").concat(a,"&sessionid=").concat(s,"&topic=").concat(l,"&targetid=").concat(h,"&pid=").concat(c):"".concat(this._protocol,"://").concat(o,"/websocket?messageid=").concat(d,"&header=").concat(a,"&sessionid=").concat(s,"&pid=").concat(c),[4,this._runtime.httpReq({url:u,method:re.POST,body:e.getCometData()})];case 1:return p=f.sent(),this.handleCometRes(p),[2]}})})},t.prototype.sendOnly=function(e){this.sendCometData(e)},t.prototype.send=function(e,r,i,o){return o===void 0&&(o=3e4),V(this,void 0,void 0,function(){var s,c,d,l,h=this;return B(this,function(a){switch(a.label){case 0:return s=this._generateMessageId(),e.messageId=s,this.sendCometData(e),[4,new Promise(function(u){h._messageIds[s]=u,setTimeout(function(){delete h._messageIds[s],u()},o)})];case 1:return(c=a.sent())?(d=r&&c.data&&[R.SUCCESS,R.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(c.status)>=0,l=d?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?[2,{code:c.status,data:r&&c.data?l:null}]:[2,{code:R.SUCCESS,data:l}]):[2,{code:R.TIMEOUT}]}})})},t.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(Z.DISCONNECTED)},t}(yc),tl=function(n,t,e){this.runtime=n,this._watcher=t,this._options=e,this.currentUserId="",this._appkey=this._options.appkey,this._apiVer=this._options.apiVersion,this.navi=this._createNavi()},vi=function(n){return["navi",n].join("_")},el=function(){function n(t,e){this._runtime=t,this._options=e,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=To(this._options.apiVersion)}return n.prototype.getInfo=function(t,e,r,i){return V(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return r&&this._clear(t),o=function(d,l,h){var a,u,p=vi(d);try{var f=h.getItem(p);u=f?JSON.parse(f):[]}catch{u=[]}var m=Date.now();return u.length>0&&(u=u.filter(function(_){return m-_.timestamp<72e5})),u.length===0?h.removeItem(p):h.setItem(p,JSON.stringify(u)),((a=u.find(function(_){return _.token===l}))===null||a===void 0?void 0:a.naviInfo)||null}(this._appkey,t,this._runtime.localStorage),o?(this._naviInfo=o,[2,o]):(s=this._options.navigators.slice(),e.length&&e.forEach(function(d){s.indexOf(d)<0&&s.unshift(d)}),[4,this._reqNavi(s,this._appkey,t,i)]);case 1:return(o=c.sent())?(this._naviInfo=o,this.setNaviInfo2Cache(t,o),[2,o]):[2,o]}})})},n.prototype.setNaviInfo2Cache=function(t,e){this._naviInfo=e,function(r,i,o,s){var c,d=vi(r);try{var l=s.getItem(d);c=l?JSON.parse(l):[]}catch{c=[]}var h=Date.now();c.length>0&&(c=c.filter(function(a){return h-a.timestamp<72e5&&i!==a.token})),c.push({timestamp:h,naviInfo:o,token:i}),s.setItem(d,JSON.stringify(c))}(this._appkey,t,e,this._runtime.localStorage)},n.prototype.getInfoFromCache=function(t){return pt({},this._naviInfo)},n.prototype._clear=function(t){(function(e,r,i){var o,s=vi(e);try{var c=i.getItem(s);o=c?JSON.parse(c):[]}catch{o=[]}var d=Date.now();o.length>0&&(o=o.filter(function(l){return d-l.timestamp<72e5&&r!==l.token})),o.length===0?i.removeItem(s):i.setItem(s,JSON.stringify(o))})(this._appkey,t,this._runtime.localStorage)},n}(),Ke=function(n,t,e){return[n,t,e].join("_")},nl=function(){function n(t,e){this._runtime=t,this._appkey=e,this._users={}}return n.prototype._getMemData=function(t){return this._users[t]||(this._users[t]={inboxTime:0,outboxTime:0,broadcastSyncTime:0})},n.prototype.setInboxTime=function(t,e){var r=this._getMemData(e);if(!(r.inboxTime>t)){r.inboxTime=t;var i=Ke("inbox",this._appkey,e);this._runtime.localStorage.setItem(i,t.toString())}},n.prototype.getInboxTime=function(t){var e=this._getMemData(t);if(e.inboxTime===0){var r=Ke("inbox",this._appkey,t);e.inboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return e.inboxTime},n.prototype.setBroadcastSyncTime=function(t,e){var r=this._getMemData(e);if(!(r.broadcastSyncTime>=t||ct(t))){r.broadcastSyncTime=t;var i=Ke("broadcastbox",this._appkey,e);this._runtime.localStorage.setItem(i,t.toString())}},n.prototype.getBroadcastSyncTime=function(t){var e=this._getMemData(t);if(!e||e.broadcastSyncTime===0){var r=Ke("broadcastbox",this._appkey,t);e.broadcastSyncTime=parseInt(this._runtime.localStorage.getItem(r))||1}return e.broadcastSyncTime},n.prototype.setOutboxTime=function(t,e){var r=this._getMemData(e);if(!(r.outboxTime>=t)){r.outboxTime=t;var i=Ke("outbox",this._appkey,e);this._runtime.localStorage.setItem(i,t.toString())}},n.prototype.getOutboxTime=function(t){var e=this._getMemData(t);if(e.outboxTime===0){var r=Ke("outbox",this._appkey,t);e.outboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return e.outboxTime},n}(),Ti={_caches:{},set:function(n,t){this._caches[n]=t},get:function(n){return this._caches[n]||0},clear:function(n){this._caches[n]=0}},rl=function(){function n(t,e){this._kvCaches={},this._chatroomId=t,this._currentUserId=e}return n.prototype._add=function(t){var e=t.key;t.isDeleted=!1,this._kvCaches[e]=t},n.prototype._remove=function(t){var e=t.key,r=this._kvCaches[e];r&&(r.isDeleted=!0,this._kvCaches[e]=r)},n.prototype._setEntry=function(t,e){var r=t.key,i=t.type,o=t.isOverwrite,s=t.userId,c=this._getSetUserId(r),d=i===Gt.DELETE,l=c===s,h=!this._isExisted(r),a=d?this._remove:this._add;(e||o||l||h)&&a.call(this,t)},n.prototype.getValue=function(t){var e=this._kvCaches[t]||{};return e.isDeleted?null:e.value},n.prototype.getVersion=function(t){var e=this._kvCaches[t]||{};return e.isDeleted?null:e.version},n.prototype.getAllValue=function(){var t={};for(var e in this._kvCaches)this._kvCaches[e].isDeleted||(t[e]=this._kvCaches[e].value);return t},n.prototype._getSetUserId=function(t){return(this._kvCaches[t]||{}).userId},n.prototype._isExisted=function(t){var e=this._kvCaches[t]||{},r=e.value,i=e.isDeleted;return r&&!i},n.prototype.setEntries=function(t){var e=this,r=t.kvEntries,i=t.isFullUpdate;r=r||[],(i=i||!1)&&this.clear(),r.forEach(function(o){e._setEntry(o,i)}),H.debug("end setEntries")},n.prototype.clear=function(){this._kvCaches={}},n}(),il=function(){function n(t){this._pullQueue=[],this._isPulling=!1,this._storeCaches={},this._engine=t}return n.prototype._startPull=function(){return V(this,void 0,void 0,function(){var t,e,r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,t=this._pullQueue.splice(0,1)[0],e=t.chrmId,r=t.timestamp,(i=Ti.get(e))>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(e,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,this._isPulling=!1,s===R.SUCCESS?(Ti.set(e,c.syncTime||0),this._startPull()):this._startPull(),[2]}})})},n.prototype.reset=function(t){Ti.clear(t);var e=this._storeCaches[t];e&&e.clear()},n.prototype.pullEntry=function(t,e){this._pullQueue.push({chrmId:t,timestamp:e}),this._startPull()},n.prototype.setLocal=function(t,e,r){var i=this._storeCaches[t];Ze(i)||(i=new rl(t,r)),i.setEntries(e),this._storeCaches[t]=i},n.prototype.getValue=function(t,e){var r=this._storeCaches[t];return r?r.getValue(e):null},n.prototype.getVersion=function(t,e){var r=this._storeCaches[t];return r?r.getVersion(e):null},n.prototype.getAll=function(t){var e=this._storeCaches[t],r={};return e&&(r=e.getAllValue()),r},n}(),ol=function(){function n(t,e,r,i){this._runtime=t,this._appkey=e,this._userId=r,this._canJoinMulipleChrm=i,this._sessionKey="",this._joinedChrmsInfo={},this._sessionKey="sync-chrm-".concat(this._appkey,"-").concat(this._userId)}return n.prototype.set=function(t,e){e===void 0&&(e=10),!this._canJoinMulipleChrm&&(this._joinedChrmsInfo={}),this._joinedChrmsInfo[t]=e,this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo))},n.prototype.get=function(){var t,e;try{e=this._runtime.sessionStorage.getItem(this._sessionKey),t=JSON.parse(e||"{}")}catch{H.error("parse rejoined chrm infos error -> ".concat(e)),t={}}return t},n.prototype.remove=function(t){delete this._joinedChrmsInfo[t],Ze(this._joinedChrmsInfo)?this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo)):this.clear()},n.prototype.clear=function(){this._joinedChrmsInfo={},this._runtime.sessionStorage.removeItem(this._sessionKey)},n}(),yi="converStatusChanged",sl=function(){function n(t,e,r){this._eventEmitter=new Fn,this._pullQueue=[],this._isPulling=!1,this._storage=Kr(t.runtime),this._appkey=e,this._currentUserId=r,this._engine=t,this._storagePullTimeKey="con-s-".concat(e,"-").concat(r)}return n.prototype._set=function(t){var e=this;if(!ct(t)&&Array.isArray(t)){var r=this._storage.get(this._storagePullTimeKey)||0,i=t.length;t.forEach(function(o,s){var c=o.updatedTime||0;r=c>r?c:r,o.conversationType=o.type,e._eventEmitter.emit(yi,{statusItem:o,isLastPull:s===i-1})}),this._storage.set(this._storagePullTimeKey,r)}},n.prototype._startPull=function(){return V(this,void 0,void 0,function(){var t,e,r,i;return B(this,function(o){switch(o.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,t=this._pullQueue.splice(0,1)[0],[4,this._engine.pullConversationStatus(t)]);case 1:return e=o.sent(),r=e.code,i=e.data,r===R.SUCCESS?(this._isPulling=!1,this._set(i),this._startPull()):this._startPull(),[2]}})})},n.prototype.pull=function(t){var e=this._storage.get(this._storagePullTimeKey)||0;(t>e||t===0)&&(this._pullQueue.push(e),this._startPull())},n.prototype.watch=function(t){this._eventEmitter.on(yi,function(e){t(e)})},n.prototype.unwatch=function(){this._eventEmitter.off(yi,function(t){})},n}(),be={c:{keyName:"unreadMessageCount",defaultVal:0},hm:{keyName:"hasMentioned",defaultVal:!1},m:{keyName:"mentionedInfo",defaultVal:null},t:{keyName:"lastUnreadTime",defaultVal:0},nc:{keyName:"notificationStatus",defaultVal:2},nl:{keyName:"notificationLevel",defaultVal:0},to:{keyName:"isTop",defaultVal:!1},tg:{keyName:"tags",defaultVal:{}},mc:{keyName:"unreadMentionedCount",defaultVal:0}},gr={};for(var sa in be){var al=be[sa].keyName;gr[al]=sa}var cl=function(){function n(t,e,r){this._appkey=e,this._currentUserId=r;var i="con-".concat(e,"-").concat(r);this.storage=new Li(t,i),this._localStore=new Li(t,"CONVER-".concat(e,"-").concat(r))}return n.prototype._getStoreKey=function(t,e,r){return"".concat(r,"_").concat(t,"_").concat(e)},n.prototype._getConOptionByKey=function(t){var e=(t=t||"").split("_");if(e.length>=2){var r=e.shift(),i=e.shift(),o=e.join("_");return{conversationType:Number(i),targetId:o,channelId:r}}return{conversationType:Y.PRIVATE,targetId:"",channelId:""}},n.prototype.updateMentionedData=function(t){var e=this,r=t.conversationType,i=t.targetId,o=t.messageType,s=t.isMentioned,c=t.content,d=t.senderUserId,l=t.channelId,h=this._getStoreKey(r,i,l),a=this._localStore.get(h)||{},u=gr.mentionedInfo,p=gr.hasMentioned,f=a[u]||{},m=f.userIdList||[],_=c.mentionedInfo;if(_){if(s&&r===Y.GROUP&&((_.userIdList||[]).forEach(function(T){T===e._currentUserId&&m.indexOf(d)<0&&m.push(d)}),_.type===qr.ALL&&m.indexOf(d)<0&&m.push(d)),o===Ut.RECALL&&r===Y.GROUP){var v=m.indexOf(d);v>=0&&m.splice(v,1)}_={userIdList:m,type:(_==null?void 0:_.type)||f.type},m.length!==0?(a[u]=_,a[p]=!0):(delete a[u],delete a[p]),Ze(a)?this._localStore.set(h,a):this._localStore.remove(h)}},n.prototype.set=function(t,e,r,i){var o=this._getStoreKey(t,e,i),s=this._localStore.get(o)||{};for(var c in r){var d=gr[c],l=r[c];if(!ct(d)&&!ct(l)&&c!=="hasMentioned"&&c!=="MentionedInfo"){if(l===be[d].defaultVal||c==="tags"&&!Ze(l))delete s[d];else if(c==="tags"){var h=l;for(var a in h)h[a].isTop||delete h[a].isTop;s[d]=l}else s[d]=l;s.c||(delete s.t,delete s.hm,delete s.m,delete s.mc)}}Ze(s)?this._localStore.set(o,s):this._localStore.remove(o)},n.prototype.get=function(t,e,r){r===void 0&&(r="");var i=this._getStoreKey(t,e,r),o=this._localStore.get(i)||{},s={};for(var c in be){var d=be[c],l=d.keyName,h=d.defaultVal;s[l]=o[c]||On(h)}return s},n.prototype.getValue=function(t){var e=this._localStore.getValues()||{},r=[];for(var i in e){var o=this._getConOptionByKey(i),s={conversationType:o.conversationType,targetId:o.targetId,channelId:o.channelId},c=e[i];for(var d in c){var l=be[d],h=l.keyName,a=l.defaultVal;s[h]=c[d]||On(a)}s=t?t(s):s,r.push(s)}return r},n.prototype.getValueForTag=function(){var t=this._localStore.getValues()||{},e={};for(var r in t){var i=this._getConOptionByKey(r),o=i.conversationType,s=i.targetId,c={},d=t[r];for(var l in d){var h=be[l],a=h.keyName,u=h.defaultVal;c[a]=d[l]||On(u)}for(var p in c.tags){ct(e[p])&&(e[p]=[]);var f=Object.assign({},c,{conversationType:o,targetId:s});delete f.tags,e[p].push(f)}}return e},n.prototype.adaptOldStore=function(){try{var t=this.storage.getValues();if(Object.keys(t).length===0)return;for(var e in t){var r="_".concat(e);this._localStore.set(r,t[e])}}catch(i){H.error("adaptOldStore error: ".concat(i.message))}},n}(),ul=[Y.PRIVATE,Y.GROUP,Y.SYSTEM,Y.PUBLIC_SERVICE,Y.APP_PUBLIC_SERVICE],aa="conversationChanged",ca="conTagStatusChanged",dl=function(){function n(t,e,r,i,o){var s=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new Fn,this._draftMap={},this._appkey=e,this._loginUserId=r,this._store=new cl(t.runtime,e,r),this._statusManager=new sl(t,e,r),this._statusManager.watch(function(c){var d=c.statusItem,l=c.isLastPull;s.addStatus(d,l)}),this._eventEmitter.on(aa,function(c){i(c)}),this._eventEmitter.on(ca,function(){o()})}return n.prototype._calcUnreadCount=function(t,e){var r=t.content,i=t.messageType,o=t.sentTime,s=t.isCounted,c=t.messageDirection,d=t.senderUserId,l=c===zt.SEND&&d===this._loginUserId,h=i===Ut.RECALL,a=Rt(r),u=!1,p={},f=e.lastUnreadTime||0,m=e.unreadMessageCount||0;return f>o||l?{hasChanged:u,localConversation:e,updateItems:p}:(s&&(e.unreadMessageCount=m+1,e.lastUnreadTime=o,u=!0),h&&a&&f>=r.sentTime&&m&&(e.unreadMessageCount=m-1,u=!0),u&&(p.unreadMessageCount={val:e.unreadMessageCount,time:o}),{hasChanged:u,localConversation:e,updateItems:p})},n.prototype._calcMentionedInfo=function(t,e){var r=t.content,i=(t.messageDirection,t.isMentioned),o=t.sentTime;zt.SEND;var s=Rt(r),c=!1,d={};return i&&s&&r.mentionedInfo&&(e.hasMentioned=!0,c=!0,d.hasMentioned={val:!0,time:o},d.mentionedInfo={val:r.mentionedInfo,time:o}),{hasChanged:c,localConversation:e,updateItems:d}},n.prototype._calcMentionedCount=function(t,e){var r=t.content,i=t.messageDirection,o=!1;if(t.isMentioned&&i===zt.RECEIVE&&(r==null?void 0:r.mentionedInfo)){var s=r.mentionedInfo,c=s.type,d=s.userIdList;if(c===qr.ALL||(d||[]).includes(this._loginUserId)){o=!0;var l=e.unreadMentionedCount||0;e.unreadMentionedCount=l+1}}return{hasChanged:o,localConversation:e}},n.prototype._setUpdatedConversation=function(t){if(Rt(t)){var e=t.conversationType,r=t.targetId,i=t.channelId,o="".concat(e,"_").concat(r),s=this._store.get(e,r,i)||{};this._updatedConversations[o]=Object.assign(s,t)}},n.prototype._setConTagStatusChanged=function(t,e,r,i){var o=(this._store.get(t,e,i)||{}).tags||{};if(Object.keys(o).length===Object.keys(r).length){for(var s in o)if(!r[s]||o[s].isTop!==r[s].isTop)return void(this._conTagStatusChanged=!0)}else this._conTagStatusChanged=!0},n.prototype.addStatus=function(t,e){var r=t.conversationType,i=t.targetId,o=t.updatedTime,s=t.notificationStatus,c=t.notificationLevel,d=t.isTop,l=t.tags,h=t.channelId,a={},u={};r!==Y.ULTRA_GROUP&&(ct(s)||(u.notificationStatus={time:o,val:s}),ct(c)||(u.notificationLevel={time:o,val:c}),ct(d)||(u.isTop={time:o,val:d}),ct(l)||(u.tags={time:o,val:l},l==null||l.forEach(function(p){a[p.tagId]={isTop:p.isTop}})),this._setConTagStatusChanged(r,i,a,h),this._store.set(r,i,{notificationStatus:s,notificationLevel:c,isTop:d,tags:a},h),this._setUpdatedConversation({conversationType:r,targetId:i,updatedItems:u,channelId:h}),e&&this._notifyConversationChanged())},n.prototype._notifyConversationChanged=function(){var t=[];for(var e in this._updatedConversations)t.push(this._updatedConversations[e]);t.length!==0&&(this._eventEmitter.emit(aa,t),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(ca),this._conTagStatusChanged=!1))},n.prototype.setConversationCacheByMessage=function(t,e){var r=this,i=t.conversationType,o=t.isPersited,s=t.targetId,c=t.channelId;if(ul.indexOf(i)>=0){var d=!1,l=this._store.get(i,s,c),h={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach(function(p){var f=p.call(r,t,l),m=f.hasChanged,_=f.localConversation,v=f.updateItems;d=d||m,h=pt(pt({},h),v),l=On(_)}),d&&this._store.set(i,s,l,c),this._store.updateMentionedData(t),o){var a=this._store.get(i,s,c);a.updatedItems=pt({latestMessage:{time:t.sentTime,val:t}},h),a.latestMessage=t;var u=Object.assign(a,{conversationType:i,targetId:s,channelId:c});this._setUpdatedConversation(u)}(d||o)&&this._notifyConversationChanged()}},n.prototype.get=function(t,e,r){return r===void 0&&(r=""),this._store.get(t,e,r)},n.prototype.getAllUnreadCount=function(t,e,r){var i=this._store.getValue(),o=0;return i.forEach(function(s){var c=s.unreadMessageCount,d=s.notificationStatus,l=s.notificationLevel,h=s.conversationType;c=c||0,(r||d!==1||l===ce.NOT_SET||l===ce.ALL_MESSAGE)&&(e.length>0?e.includes(Number(h))&&(o+=Number(c)):o+=Number(c))}),o},n.prototype.getUnreadCountByTag=function(t,e){var r=this._store.getValueForTag()[t]||[],i=0;return r.forEach(function(o){var s=o.unreadMessageCount,c=o.notificationStatus,d=o.notificationLevel;(e||c!==1||d===-1||d===0)&&(s=s||0,i+=Number(s))}),i},n.prototype.getUnreadCount=function(t,e,r){return this._store.get(t,e,r).unreadMessageCount||0},n.prototype.clearUnreadCount=function(t,e,r,i){i===void 0&&(i=!0);var o=this._store.get(t,e,r),s=o.unreadMessageCount,c=o.hasMentioned,d={};if(s&&(o.unreadMessageCount=0,d.unreadMessageCount={val:0,time:Date.now()}),c&&(o.hasMentioned=!1,o.unreadMentionedCount=0,o.mentionedInfo=void 0,d.hasMentioned={val:!1,time:Date.now()},d.mentionedInfo={val:void 0,time:Date.now()}),this._store.set(t,e,o,r),i&&Object.keys(d).length!==0){var l=Object.assign(o,{conversationType:t,targetId:e,channelId:r,updatedItems:d});this._setUpdatedConversation(l),this._notifyConversationChanged()}},n.prototype.clearAllUnreadCount=function(){var t=this;this._store.getValue().forEach(function(e){e.unreadMessageCount&&(e.unreadMessageCount=0,t._store.set(e.conversationType,e.targetId,e,e.channelId))})},n.prototype.startPullConversationStatus=function(t){this._statusManager.pull(t)},n.prototype.setDraft=function(t,e,r,i){var o="".concat(t,"_").concat(e,"_").concat(i);this._draftMap[o]=r},n.prototype.getDraft=function(t,e,r){var i="".concat(t,"_").concat(e,"_").concat(r);return this._draftMap[i]},n.prototype.clearDraft=function(t,e,r){var i="".concat(t,"_").concat(e,"_").concat(r);delete this._draftMap[i]},n.prototype.addTagStatus=function(t,e,r,i){i===void 0&&(i="");var o=this._store.get(t,e,i).tags;o=Object.assign(o,r),this._store.set(t,e,{tags:o},i)},n.prototype.deleteTagStatus=function(t,e,r,i){i===void 0&&(i="");var o=this._store.get(t,e,i).tags;r.forEach(function(s){delete o[s]}),this._store.set(t,e,{tags:o},i)},n.prototype.getConversationListForTag=function(){return this._store.getValueForTag()},n.prototype.getBlockConversationList=function(){return this._store.getValue().filter(function(t){return t.notificationStatus===Yt.OPEN||t.notificationLevel!==-1&&t.notificationLevel!==0}).map(function(t){return{conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId}})},n.prototype.getTopConversationList=function(){return(this._store.getValue()||{}).filter(function(t){return t.isTop}).map(function(t){return{conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId}})},n.prototype.adaptOldStore=function(){this._store.adaptOldStore()},n.prototype.getUnreadMentionedCount=function(t,e,r){return t===void 0&&(t=""),this.get(e,r,t).unreadMentionedCount||0},n.prototype.getAllUnreadMentionedCount=function(){var t=this._store.getValue(),e=0;return t.forEach(function(r){var i=r.unreadMentionedCount;i=i||0,e+=Number(i)}),e},n.prototype.getAllConversationState=function(){return this._store.getValue().filter(function(t){return t.unreadMessageCount||t.unreadMentionedCount}).map(function(t){return{conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId,unreadCount:t.unreadMessageCount||0,unreadMentionedCount:t.unreadMentionedCount||0}})},n}(),ll=function(){function n(t,e,r,i){this._pullQueue=[],this._isPulling=!1,this._storageTagKey="tag-".concat(e,"-").concat(r),this._storagePullTimeKey="us-s-".concat(e,"-").concat(r),this._storage=Kr(t.runtime),this._engine=t,this._tagWatcherFunc=i}return n.prototype._updateTag=function(t){var e=t.tags,r={};e.forEach(function(i){r[i.tagId]={tagName:i.tagName,createdTime:i.createdTime}}),this._storage.set(this._storageTagKey,r),this._tagWatcherFunc()},n.prototype.addTag=function(t,e){var r=this._storage.get(this._storageTagKey)||{};t.forEach(function(i){var o,s=((o=r[i.tagId])===null||o===void 0?void 0:o.createdTime)||i.createdTime||0;r[i.tagId]={tagName:i.tagName,createdTime:s}}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,e)},n.prototype.deleteTag=function(t,e){var r=this._storage.get(this._storageTagKey)||{};t.forEach(function(i){delete r[i]}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,e)},n.prototype.getTagsInfo=function(){return this._storage.get(this._storageTagKey)||{}},n.prototype.getTags=function(){var t=this._storage.get(this._storageTagKey)||{},e=[];for(var r in t)e.push({tagId:r,tagName:t[r].tagName,createdTime:t[r].createdTime,conversationCount:0});return e.sort(function(i,o){return(i.createdTime||0)-(o.createdTime||0)})},n.prototype.getTagById=function(t){var e=this._storage.get(this._storageTagKey)||{};return e[t]?{tagId:t,tagName:e[t].tagName,createdTime:e[t].createdTime,conversationCount:0}:null},n.prototype._startPull=function(){return V(this,void 0,void 0,function(){var t,e,r,i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,t=this._pullQueue.splice(0,1)[0],[4,this._engine.pullUserSettings(t)]);case 1:return e=l.sent(),r=e.code,i=e.data,r!==R.SUCCESS||ct(i)?(this._isPulling=!1,this._startPull()):(s=(o=i).settings,c=o.version,d=s.Tag,ct(d)||this._updateTag(d),this._storage.set(this._storagePullTimeKey,c),this._isPulling=!1,this._startPull()),[2]}})})},n.prototype.pullUserSettings=function(t){var e=this._storage.get(this._storagePullTimeKey)||0;(t>e||t===0)&&(this._pullQueue.push(e),this._startPull())},n.prototype.getVersion=function(){return this._storage.get(this._storagePullTimeKey)||0},n}();function Ei(n){return V(this,void 0,void 0,function(){var t,e,r,i,o,s,c,d,l,h,a,u,p,f,m;return B(this,function(_){switch(_.label){case 0:t=kt.IM_NAVI,e=H.getStatisticsBaseData(),r=e.sdkPrivate,i=e.serverPrivate,o=e.bundleId,s=H.getStatisticsData(t),c=s.protocol,d=s.startTime,l=s.endTime,h=s.code,a=s.host,u=Zt.UNKONWN,_.label=1;case 1:return _.trys.push([1,3,,4]),[4,n.getNetworkType()];case 2:return u=_.sent(),[3,4];case 3:return p=_.sent(),H.debug(p.message),[3,4];case 4:return f=0,mt(d)&&mt(l)&&l>d&&d&&(f=l-d),m={spr:r,pr:i,bid:o,ptc:c,dur:f,cod:h,hos:a,net:u},H.reportStatisticsLog(t,m),[2]}})})}var vn,hl=function(n){function t(e,r){var i=n.call(this,e,r)||this;return i._miniConnectUrl="",i._connectType=r.connectionType,i}return It(t,n),t.prototype._formatJSONPUrl=function(e,r,i,o){var s=this._runtime.isSupportSocket()&&this._connectType==="websocket"?"navi":"cometnavi";return"".concat(e,"/").concat(s,".js?appId=").concat(i,"&token=").concat(encodeURIComponent(r),"&callBack=").concat(o,"&v=").concat(this._apiVersion,"&r=").concat(Date.now())},t.prototype.getInfo=function(e,r,i){var o;return V(this,void 0,void 0,function(){var s;return B(this,function(c){return this._runtime.useNavi||(s=void 0,s=this._runtime.isSupportSocket()&&this._connectType==="websocket"?ud.join(","):dd.join(","),this._miniConnectUrl=((o=this._options.miniCMPProxy)===null||o===void 0?void 0:o.length)?this._options.miniCMPProxy.join(","):s||"",r=[]),[2,n.prototype.getInfo.call(this,e,r,i)]})})},t.prototype._reqNavi=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,p,f,m;return B(this,function(_){switch(_.label){case 0:o="getServerEndpoint",s=0,c=e.length,_.label=1;case 1:return s ".concat(d)),[4,this._runtime.httpReq({url:d,timeout:1e4,dataType:"text"})]):[3,4];case 2:if(l=_.sent(),h=new Date().getTime(),H.setStatisticsData(kt.IM_NAVI,{endTime:h}),l.status!==200)return a=void 0,l.status===403?(a=R.RC_CONN_USER_OR_PASSWD_ERROR,H.error("request navi error: "+a)):l.status===401&&(a=R.RC_CONN_APP_BLOCKED_OR_DELETED,H.error("request navi error: "+a)),H.setStatisticsData(kt.IM_NAVI,{code:a}),Ei(this._runtime),[3,3];try{return u=l.data.match(/{[\d\D]+}/),(p=u&&u[0]?u[0]:"").indexOf('{\\"code\\":')===0&&(p=JSON.parse('"'+p+'"')),m=JSON.parse(p),f=/^https/.test(d)?"https":"http",m.protocol=f,this._runtime.useNavi||(m.server="",m.backupServer=this._miniConnectUrl,m.logSwitch=0),H.updateStatisticsBaseData({serverPrivate:m.type===$t.PRIVATE?$t.PRIVATE:$t.OPEN}),H.setStatisticsData(kt.IM_NAVI,{code:R.SUCCESS}),m.userId&&(H.updateUploadLogAttr({userId:m.userId}),Le.init(m.userId)),Ei(this._runtime),[2,m]}catch(v){H.error("parse navi err =>",v)}_.label=3;case 3:return s+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:(m={code:200,protocol:"https",server:"",voipCallInfo:"",kvStorage:0,openHttpDNS:!1,historyMsg:!1,chatroomMsg:!1,uploadServer:"https://upload.qiniup.com",bosAddr:"https://gz.bcebos.com",location:"",monitor:0,joinMChrm:!1,openMp:0,openUS:0,grpMsgLimit:0,isFormatted:0,gifSize:2048,logSwitch:0,logPolicy:"",compDays:0,msgAck:"",activeServer:"",qnAddr:"",extkitSwitch:0,alone:!1,voipServer:"",offlinelogserver:"",backupServer:this._miniConnectUrl},H.setStatisticsData(kt.IM_NAVI,{code:m.code,startTime:0,endTime:0,host:""}),Ei(this._runtime),[2,m])}})})},t}(el),pl=function(){function n(t){this._pullQueue=[],this._isPulling=!1,this._pullTime=0,this._engine=t}return n.prototype._startPull=function(){return V(this,void 0,void 0,function(){var t,e,r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,t=this._pullQueue.splice(0,1)[0],e=t.roomId,r=t.timestamp,(i=this._pullTime)>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullRTCRoomEntry(e,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,s===R.SUCCESS?(this._isPulling=!1,this._pullTime=c.syncTime||0,this._startPull()):this._startPull(),[2]}})})},n.prototype.pullEntry=function(t,e){this._pullQueue.push({roomId:t,timestamp:e}),this._startPull()},n.prototype.reset=function(){this._pullTime=0,this._isPulling=!1},n}(),Ci=function(n,t){return["send_msg",n,t].join("_")},fl=function(){function n(t,e){this._runtime=t,this._appkey=e,this._sendMessageMap={},this._userId=""}return n.prototype.init=function(t){this._userId=t;var e=Ci(this._appkey,t);this._sendMessageMap=this._getLocalInfo(e)},n.prototype._getLocalInfo=function(t){var e=this._runtime.localStorage.getItem(t);try{return e?JSON.parse(e):{}}catch{return{}}},n.prototype.setMessage=function(t,e){this._sendMessageMap[t]=e;var r=Ci(this._appkey,this._userId),i=this._getLocalInfo(r);i[t]=e,this._runtime.localStorage.setItem(r,JSON.stringify(i))},n.prototype.getSendMessageMap=function(){return this._sendMessageMap},n.prototype.removeByUID=function(t){delete this._sendMessageMap[t]},n.prototype.removeByTimestamp=function(t){var e=Ci(this._appkey,this._userId),r=this._getLocalInfo(e);Object.keys(r).forEach(function(i){r[i] signal.messageId: ".concat(e.messageId)),this._pullMsg(e);break;case x.s_msg:this._receiveMsg(e);break;case x.s_cmd:this._receiveStateNotify(e);break;case x.s_us:this._receiveSettingNotify(e);break;case x.rtc_ntf:this._receiveRtcKv(e);break;case x.s_opNtf:this._pullOperateStatusNotify(e)}else H.error("unknown topic:",o)}},t.prototype._receiveStateNotify=function(e){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(e.data,Sr),o=i.time,s=i.type,c=i.chrmId;switch(s){case 2:this._chrmEntryHandler.pullEntry(c,o);break;case 3:this._conversationManager.startPullConversationStatus(o);break;case 4:this._chrmEntryHandler.reset(c),this._watcher.chatroom({chatroomDestroyed:e.targetId});break;case 6:this._ultraGroupTimeQue.push(o),this._syncUltraMsg(this._lastSyncUltraMsgTimeStamp);break;case 7:this._pullUltraChangeMessageQue.push(o),this._pullUltraChangeMessageList(this._lastPullingUltraChangeMessageTime)}},t.prototype._receiveSettingNotify=function(e){var r,i=((r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(e.data,Xr)).version;this._userSettingManager.pullUserSettings(i)},t.prototype._receiveRtcKv=function(e){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(e.data,hs),o=i.time,s=i.type,c=i.roomId;s===1&&this._rtcKVManager.pullEntry(c,o)},t.prototype._receiveMessageExpansion=function(e){var r=e.content,i=r.put,o=r.del,s=r.mid;i&&this._watcher.expansion({updatedExpansion:{messageUId:s,expansion:i}}),o&&this._watcher.expansion({deletedExpansion:{messageUId:s,deletedKeys:o}})},t.prototype._receiveSyncMsg=function(e,r){var i,o;if(gl.includes(e.topic)){if(e.topic===x[x.updUgRTime]){var s=(i=this._channel)===null||i===void 0?void 0:i.codec.decodeByPBName(e.data,zr),c=s.channelId,d=s.busChannel,l=this._ultraGroupMap[d+"_"+c];return l&&(l.unreadMessageCount=0,l.unreadMentionedCount=0,l.lastReadTime=r.timestamp,this._watcher.conversation(He([l]))),void(r&&(this._ultraMsgMap[r.messageUId]=r.timestamp))}var h=(o=this._channel)===null||o===void 0?void 0:o.codec.decodeByPBName(e.data,Dn,{currentUserId:this.currentUserId,signal:e});h=this._handleMsgProperties(h),r&&(h.sentTime=r.timestamp,h.messageUId=r.messageUId),this._pullingMsg?this._pullQueue.push((r==null?void 0:r.timestamp)||h.sentTime):(r&&this._sendMessageStore.setMessage(r.messageUId,r.timestamp),h.messageType!==Ut.EXPANSION_NOTIFY?(h.messageType===Ut.SYNC_READ_STATUS&&this._conversationManager.clearUnreadCount(h.conversationType,h.targetId,h.channelId),this._conversationManager.setConversationCacheByMessage(h,!0),this._watcher.batchMessage([h])):this._receiveMessageExpansion(h))}},t.prototype._pullMsg=function(e){if(this._channel){var r=this._channel.codec.decodeByPBName(e.data,Sr),i=r.type,o=r.chrmId,s=r.time;if(H.info("s_ntf -> type: ".concat(i,", chrmId: ").concat(o,", time: ").concat(s)),i===2){var c=this._chrmsQueue[o];if(!c)return;c.queue.push(s),this._pullChrmMsg(o)}else this._pullQueue.push(s),this._syncMsg()}},t.prototype._startSyncInterval=function(){var e=this;this._stopSyncInterval(),this._intervalTimer=setInterval(function(){Date.now()-e._latestSyncTimestamp>=18e4&&e._syncMsg()},3e4),this._latestSyncTimestamp=Date.now(),this._syncMsg()},t.prototype._stopSyncInterval=function(){this._intervalTimer!==-1&&(clearInterval(this._intervalTimer),this._intervalTimer=-1)},t.prototype._syncMsg=function(){return V(this,void 0,void 0,function(){var e,r,i,o,s,c,d,l,h,a,u,p,f,m,_,v,T,y=this;return B(this,function(w){switch(w.label){case 0:return this._pullingMsg?[2]:this._channel?(this._pullingMsg=!0,e=this._letterbox.getOutboxTime(this.currentUserId),r=this._letterbox.getInboxTime(this.currentUserId),i=this._letterbox.getBroadcastSyncTime(this.currentUserId),H.info("pullMsg -> sendboxTime: ".concat(e,", inboxTime: ").concat(r,", broadcastSyncTime: ").concat(i)),o=this._channel.codec.encodeSyncMsg({sendboxTime:e,inboxTime:r,broadcastSyncTime:i}),s=new Q(x[x.pullMsg],o,this.currentUserId),[4,this._channel.send(s,Qe,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return c=w.sent(),d=c.code,l=c.data,this._latestSyncTimestamp=Date.now(),d!==R.SUCCESS||!l||ct(l.finished)||ct(l.list)||ct(l.syncTime)?(H.warn("pullMsg failed -> code:",d,", data: ",l),this._pullingMsg=!1,[2]):(h=l.list,a=l.finished,u=l.syncTime,p=l.broadcastSyncTime,f=p===void 0?1:p,H.info("pullMsg success -> syncTime: ".concat(u,", finished: ").concat(a)),m=0,_=[],h.forEach(function(L){if(L.messageDirection===zt.SEND&&(m=Math.max(L.sentTime,m),y._sendMessageStore.getSendMessageMap()[L.messageUId]))return void y._sendMessageStore.removeByUID(L.messageUId);if(L.messageType!==Ut.EXPANSION_NOTIFY){if(L.messageType===Ut.SYNC_READ_STATUS){if(L.senderUserId!==y.currentUserId)return;y._conversationManager.clearUnreadCount(L.conversationType,L.targetId,L.channelId)}var M=y._handleMsgProperties(L);y._conversationManager.setConversationCacheByMessage(M,!0),_.push(M)}else y._receiveMessageExpansion(L)}),this._watcher.batchMessage(_),this._letterbox.setInboxTime(u,this.currentUserId),this._letterbox.setOutboxTime(m,this.currentUserId),this._letterbox.setBroadcastSyncTime(f,this.currentUserId),this._sendMessageStore.removeByTimestamp(m),this._pullingMsg=!1,v=this._pullQueue.filter(function(L){return L>u}),this._pullQueue.length=0,(T=this._pullQueue).push.apply(T,v),a&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!a||v.length>0)&&this._syncMsg(),[2])}})})},t.prototype._receiveMsg=function(e){if(this._channel&&!this._pullingMsg)if(this._pullQueue.length>0)this._syncMsg();else{var r=this._channel.codec.decodeByPBName(e.data,Yr,{currentUserId:this.currentUserId,connectedTime:this._channel.connectedTime});(r=this._handleMsgProperties(r)).senderUserId===this.currentUserId&&this._sendMessageStore.setMessage(r.messageUId,r.sentTime),r.isStatusMessage||r.senderUserId===this.currentUserId||this._letterbox.setInboxTime(r.sentTime,this.currentUserId),r.messageType!==Ut.EXPANSION_NOTIFY?r.messageType===Ut.SYNC_READ_STATUS&&r.senderUserId!==this.currentUserId||(this._conversationManager.setConversationCacheByMessage(r,!0),this._watcher.batchMessage([r])):this._receiveMessageExpansion(r)}},t.prototype._handleMsgProperties=function(e,r){r===void 0&&(r=!1);var i,o=e.messageType,s=e.isCounted,c=e.isPersited,d=e.isStatusMessage,l=o in Vs,h=o in this._customMessageType;if(i=l?pt(pt({},Vs[o]),{isStatusMessage:ld.includes(o)}):h?this._customMessageType[o]:{isCounted:!$s(s)&&s,isPersited:!$s(c)&&c,isStatusMessage:!1},Object.assign(e,i),r&&!ct(d)&&(e.isStatusMessage=d),!r){var a=e.content.user;if(a){var u=a.portrait,p=a.portraitUri,f=u||p;f&&(a.portrait=a.portraitUri=f)}}return e},t.prototype.getHistoryMessage=function(e,r,i,o,s,c){return c===void 0&&(c=""),V(this,void 0,void 0,function(){var d,l,h,a,u,p,f,m,_;return B(this,function(v){switch(v.label){case 0:return l=(d=this).currentUserId,h=d._channel,a=Jd[e]||vc,u=o===1&&i===0,h?(p=h.codec.encodeGetHistoryMsg(r,{timestamp:i,count:u?2:o,order:s,channelId:c}),[4,h.send(new Q(a,p,l),Xe,{currentUserId:l,connectedTime:h.connectedTime,conversation:{targetId:r}})]):[3,2];case 1:return f=v.sent(),(m=f.code)!==R.SUCCESS?[2,{code:m}]:(_=f.data,u&&_.list.length===2&&(_.hasMore=!0,s===0?_.list.shift():_.list.pop()),[2,{code:m,data:{list:_.list,hasMore:_.hasMore}}]);case 2:return[2,{code:R.RC_NET_CHANNEL_INVALID}]}})})},t.prototype.reportSDKInfo=function(e){var r=this.currentUserId,i=this._channel;if(i){H.info("reportSDKInfo ->",e);var o=i.codec.encodeReportSDKInfo(JSON.stringify(e)),s=new Q(x[x.reportsdk],o,r);i.send(s).then(function(c){var d=c.code;d!==R.SUCCESS&&H.warn("reportSDKInfo failed -> code: ".concat(d))})}},t.prototype.deleteRemoteMessage=function(e,r,i,o){return V(this,void 0,void 0,function(){var s,c,d,l,h,a,u;return B(this,function(p){switch(p.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeDeleteMessages(e,r,i,o),h=new Q(Dd,l,c),[4,d.send(h)]):[3,2];case 1:return a=p.sent(),u=a.code,R.SUCCESS,[2,u];case 2:return[2,R.RC_NET_CHANNEL_INVALID]}})})},t.prototype.deleteRemoteMessageByTimestamp=function(e,r,i,o){return V(this,void 0,void 0,function(){var s,c,d,l,h,a,u,p;return B(this,function(f){switch(f.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeClearMessages(r,i,o,e),h=Wd[e],a=new Q(h,l,c),[4,d.send(a)]):[3,2];case 1:return u=f.sent(),p=u.code,R.SUCCESS,[2,p];case 2:return[2,R.RC_NET_CHANNEL_INVALID]}})})},t.prototype.getConversationList=function(e,r,i,o,s){return e===void 0&&(e=300),V(this,void 0,void 0,function(){var c,d,l,h,a,u,p,f,m=this;return B(this,function(_){switch(_.label){case 0:return d=(c=this).currentUserId,l=c._channel,r=r||Y.PRIVATE,l?(h=l.codec.encodeOldConversationList({count:e,type:r,startTime:i,order:o}),a=new Q(na,h,d),[4,l.send(a,tn,{currentUserId:d,connectedTime:l.connectedTime,afterDecode:function(v){var T=v.conversationType,y=v.targetId,w=v.channelId,L=m._conversationManager.get(T,y,w);return Object.assign(v,L),v}})]):[3,2];case 1:return u=_.sent(),p=u.code,f=u.data,p!==R.SUCCESS?[2,{code:p}]:[2,{code:p,data:f==null?void 0:f.list}];case 2:return[2,{code:R.RC_NET_CHANNEL_INVALID}]}})})},t.prototype.removeConversation=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return(o=this._channel)?(s=o.codec.encodeRemoveOldConversationList({conversationType:e,channelId:i,targetId:r}),c=new Q(Gd,s,r),[4,o.send(c)]):[3,2];case 1:return d=h.sent(),H.info("RemoveConversation =>",d),l=d.code,R.SUCCESS,[2,l];case 2:return[2,R.RC_NET_CHANNEL_INVALID]}})})},t.prototype.getConversation=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return e!==Y.ULTRA_GROUP?[3,1]:(o=this._ultraGroupMap[i+"_"+r])?[3,3]:[2,{code:R.CONVER_GET_ERROR}];case 1:return(s=this._conversationManager.get(e,r,i))?[4,this.getHistoryMessage(e,r,0,1,0)]:[2,{code:R.CONVER_GET_ERROR}];case 2:if(c=a.sent(),d=c.code,l=c.data,d!==R.SUCCESS)return[2,{code:R.CONVER_GET_ERROR}];h=(l==null?void 0:l.list[0])||null,o={conversationType:e,targetId:r,channelId:i,unreadMessageCount:s.unreadMessageCount||0,latestMessage:h,notificationStatus:s.notificationStatus||Yt.CLOSE,notificationLevel:s.notificationLevel||ce.NOT_SET,isTop:s.isTop||!1,lastUnreadTime:s.lastUnreadTime||0,unreadMentionedCount:s.unreadMentionedCount||0},a.label=3;case 3:return[2,{code:R.SUCCESS,data:o}]}})})},t.prototype.getAllConversationUnreadCount=function(e,r,i){var o=this._conversationManager.getAllUnreadCount(e,r,i);return Promise.resolve({code:R.SUCCESS,data:o})},t.prototype.getConversationUnreadCount=function(e,r,i){var o,s;return s=e===Y.ULTRA_GROUP?((o=this._ultraGroupMap[i+"_"+r])===null||o===void 0?void 0:o.unreadMessageCount)||0:this._conversationManager.getUnreadCount(e,r,i),Promise.resolve({code:R.SUCCESS,data:s})},t.prototype.clearConversationUnreadCount=function(e,r,i){return this._conversationManager.clearUnreadCount(e,r,i,!1),Promise.resolve(R.SUCCESS)},t.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(R.SUCCESS)},t.prototype.getFirstUnreadMessage=function(e,r){throw new Error("Method not implemented.")},t.prototype.saveConversationMessageDraft=function(e,r,i,o){return this._conversationManager.setDraft(e,r,i,o),Promise.resolve(R.SUCCESS)},t.prototype.getConversationMessageDraft=function(e,r,i){var o=this._conversationManager.getDraft(e,r,i);return Promise.resolve({code:R.SUCCESS,data:o})},t.prototype.clearConversationMessageDraft=function(e,r,i){return this._conversationManager.clearDraft(e,r,i),Promise.resolve(R.SUCCESS)},t.prototype.pullConversationStatus=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u=this;return B(this,function(p){switch(p.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeGetConversationStatus(e),c=new Q(x[x.pullSeAtts],s,o),[4,i.send(c,ti)]):[3,2];case 1:return d=p.sent(),l=d.code,h=d.data,l!==R.SUCCESS?[2,{code:l}]:(a=[],Array.isArray(h)&&h.forEach(function(f){var m=f.conversationType,_=f.targetId,v=f.notificationStatus,T=f.channelId,y=f.isTop,w=f.notificationLevel,L=u._ultraGroupMap[T+"_"+_];m===Y.ULTRA_GROUP?L&&(v!==void 0&&(L.notificationStatus=v),w!==void 0&&(L.notificationLevel=w),w===void 0&&v===void 0||u._ultraGroupManager.addUltraGroupStatus(f),typeof y=="boolean"&&(L.isTop=y)):a.push(f)}),[2,{code:l,data:a}]);case 2:return[2,{code:R.RC_NET_CHANNEL_INVALID}]}})})},t.prototype.batchSetConversationStatus=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u,p,f=this;return B(this,function(m){switch(m.label){case 0:return i=(r=this).currentUserId,(o=r._channel)?(s=o.codec.encodeSetConversationStatus(e),c=new Q(Kd,s,i),[4,o.send(c,Xo)]):[3,2];case 1:return d=m.sent(),l=d.code,h=d.data,l===R.SUCCESS?(a=h,u=[],e.forEach(function(_){var v=_.conversationType,T=_.targetId,y=_.notificationStatus,w=_.notificationLevel,L=_.channelId,M=_.isTop;if(v===Y.ULTRA_GROUP){var C=f._ultraGroupMap[L+"_"+T];C&&(y!==void 0&&(C.notificationStatus=y),w!==void 0&&(C.notificationLevel=w),w===void 0&&y===void 0||f._ultraGroupManager.addUltraGroupStatus(C),M!==void 0&&(C.isTop=M),u.push(C))}else f._conversationManager.addStatus(pt(pt({},_),{updatedTime:a.version}),!0)}),u.length>0&&(p=He(u),p=Qn(p),this._watcher.conversation(p)),[2,l]):[2,l];case 2:return[2,R.RC_NET_CHANNEL_INVALID]}})})},t.prototype._joinChrm=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(o=this._channel)?(s=o.codec.encodeJoinOrQuitChatRoom(),c=new Q(i?xd:kd,s,e),[4,o.send(c,kn)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return d=u.sent(),l=d.code,h=d.data,l===R.SUCCESS&&(a=h.joinTime,this._chrmsQueue[e]||(this._chrmsQueue[e]={pulling:!1,queue:[],timestamp:0}),this._pullChrmMsg(e,r,a),this._naviInfo.kvStorage&&this._chrmEntryHandler.pullEntry(e,0),this._joinedChrmManager.set(e,r)),[2,l]}})})},t.prototype._rejoinChrm=function(){return V(this,void 0,void 0,function(){var e,r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:for(i in e=this._joinedChrmManager.get(),r=[],e)r.push(i);o=0,d.label=1;case 1:return of}),_=[],p.forEach(function(T){T.sentTime0)&&this._pullChrmMsg(e),[2]):(H.warn("pull chatroom msg failed, code:",a,", data:",u),[2])}})})},t.prototype.joinChatroom=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return[2,this._joinChrm(e,r,!1)]})})},t.prototype.joinExistChatroom=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return[2,this._joinChrm(e,r,!0)]})})},t.prototype.quitChatroom=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),o=new Q(Vd,i,e),[4,r.send(o)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return s=d.sent(),(c=s.code)===R.SUCCESS&&(delete this._chrmsQueue[e],this._chrmEntryHandler.reset(e),this._joinedChrmManager.remove(e)),[2,c]}})})},t.prototype.getChatroomInfo=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(o=this._channel)?(s=o.codec.encodeGetChatRoomInfo(r,i),c=new Q(x[x.queryChrmI],s,e),[4,o.send(c,Jr)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l!==R.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}]}})})},t.prototype.getChatroomHistoryMessages=function(e,r,i,o){return V(this,void 0,void 0,function(){var s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(s=this._channel)?(c=s.codec.encodeGetHistoryMsg(e,{timestamp:r,count:i,order:o}),d=new Q(Tc,c,e),[4,s.send(d,Xe,{conversation:{targetId:e}})]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,h!==R.SUCCESS?[2,{code:h}]:[2,{code:h,data:{list:a.list,hasMore:a.hasMore}}]}})})},t.prototype._modifyChatroomKV=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u;return B(this,function(p){switch(p.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=this._chrmEntryHandler.getVersion(e,r.key),r.version=c==null?this.getServerTime():c,d=o.codec.encodeModifyChatRoomKV(e,r,s),l=r.type===Gt.UPDATE?Bd:Fd,h=new Q(l,d,e),[4,o.send(h,kn)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return a=p.sent(),(u=a.code)===R.SUCCESS?(this._chrmEntryHandler.setLocal(e,{kvEntries:[r],syncTime:new Date().getTime()},s),[2,u]):[2,u]}})})},t.prototype._modifyChatroomKVS=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,p,f,m,_=this;return B(this,function(v){switch(v.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(r.entries.forEach(function(T){var y=_._chrmEntryHandler.getVersion(e,T.key);T.version=y==null?_.getServerTime():y}),c=o.codec.encodeModifyChatRoomKVS(e,r,s),d=r.type===Gt.UPDATE?Hd:$d,l=new Q(d,c,e),[4,o.send(l,Jo)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return h=v.sent(),a=h.code,[R.SUCCESS,R.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(a)!==-1&&(p=[],delete(f=Object.assign({},r)).entries,r.entries.forEach(function(T){p.push(Object.assign({},T,f))}),a===R.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(m=h.data,H.warn("\u8BBE\u7F6E\u5931\u8D25\u7684\u5C5E\u6027\uFF1A",m.errorKeys),u=m.errorKeys,m&&Array.isArray(m.errorKeys)&&m.errorKeys.forEach(function(T){var y=p.findIndex(function(w){return T.key===w.key});y!==-1&&p.splice(y,1)})),H.warn("\u8BBE\u7F6E\u6210\u529F\u7684\u5C5E\u6027\uFF1A",p),this._chrmEntryHandler.setLocal(e,{kvEntries:p,syncTime:new Date().getTime()},s)),[2,{code:a,data:u}]}})})},t.prototype.setChatroomEntry=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return r.type=Gt.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(e,r)]})})},t.prototype.setChatroomEntries=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return r.type=Gt.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(e,r)]})})},t.prototype.forceSetChatroomEntry=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return r.type=Gt.UPDATE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(e,r)]})})},t.prototype.removeChatroomEntry=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return r.type=Gt.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(e,r)]})})},t.prototype.removeChatroomEntries=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return r.type=Gt.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(e,r)]})})},t.prototype.forceRemoveChatroomEntry=function(e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return r.type=Gt.DELETE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(e,r)]})})},t.prototype.getChatroomEntry=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(i=this._chrmEntryHandler.getValue(e,r))?[2,Promise.resolve({code:R.SUCCESS,data:i})]:[3,1];case 1:return(o=this._channel)?(s=o.codec.encodePullChatRoomKV(0),c=new Q(x[x.pullKV],s,e),[4,o.send(c,en)]):[2,Promise.reject({code:R.RC_NET_CHANNEL_INVALID})];case 2:return d=a.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&(h=l.kvEntries.find(function(u){return u.key===r}),h!==void 0)?[2,Promise.resolve({code:R.SUCCESS,data:h==null?void 0:h.value})]:[2,Promise.resolve({code:R.CHATROOM_KEY_NOT_EXIST})]}})})},t.prototype.getAllChatroomEntry=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return(r=this._chrmEntryHandler.getAll(e))&&Object.keys(r).length?[2,Promise.resolve({code:R.SUCCESS,data:r})]:[3,1];case 1:return(i=this._channel)?(o={},s=i.codec.encodePullChatRoomKV(0),c=new Q(x[x.pullKV],s,e),[4,i.send(c,en)]):[2,Promise.reject({code:R.RC_NET_CHANNEL_INVALID})];case 2:return d=h.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&l.kvEntries.forEach(function(a){a.key&&(o[a.key]=a.value||"")}),[2,Promise.resolve({code:R.SUCCESS,data:o})]}})})},t.prototype.pullChatroomEntry=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,p,f,m;return B(this,function(_){switch(_.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(r||(r=this._pullChatroomEntryTimestamp),c=o.codec.encodePullChatRoomKV(r),d=new Q(x[x.pullKV],c,e),[4,o.send(d,en)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return l=_.sent(),h=l.code,a=l.data,h===R.SUCCESS?(H.info("Pull success ChrmKV, "+JSON.stringify(l)),this._chrmEntryHandler.setLocal(e,a,s),H.info("Save into cache success!"),p=(u=a).kvEntries,f=u.syncTime,this._pullChatroomEntryTimestamp=f||0,m=[],p.length>0&&(p.forEach(function(v){var T=v.key,y=v.value,w=v.type,L=v.timestamp;m.push({key:T,value:y,type:w,timestamp:L,chatroomId:e})}),this._watcher.chatroom({updatedEntries:m})),[2,{code:h,data:a}]):[2,{code:h}]}})})},t.prototype.sendMessage=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,p,f;return B(this,function(m){switch(m.label){case 0:return this._channel?(i=function(_,v){return _.messageType==="RC:SRSMsg"&&Object.assign(_,{directionalUserIdList:[v]}),_}(i,this.currentUserId),i=this._handleMsgProperties(i,!0),o=!![Y.PRIVATE,Y.GROUP].includes(e)&&i.isStatusMessage,s=o?function(_){var v;return(v={},v[Y.PRIVATE]=x.ppMsgS,v[Y.GROUP]=x.pgMsgS,v)[_]}(e):function(_){var v;return(v={},v[Y.PRIVATE]=x.ppMsgP,v[Y.GROUP]=x.pgMsgP,v[Y.CHATROOM]=x.chatMsg,v[Y.CUSTOMER_SERVICE]=x.pcMsgP,v[Y.RTC_ROOM]=x.prMsgS,v)[_]}(e)||x.ppMsgP,o&&(i.isPersited=!1,i.isCounted=!1),c=this._channel.codec.encodeUpMsg({conversationType:e,targetId:r},i),(d=new qt(x[s],c,r)).setHeaderQos(At.AT_LEAST_ONCE),o?(this._channel.sendOnly(d),[2,{code:R.SUCCESS,data:Zn(e,r,pt({},i),"",0,this.currentUserId)}]):(l=Date.now()-this._localConnectedTime+this._connectedTime,h=Zn(e,r,pt({},i),"",l,this.currentUserId),[4,this._channel.send(d)])):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,p=a.data,u!==R.SUCCESS?[2,{code:u,data:h}]:(f=p,this._sendMessageStore.setMessage(f.messageUId,f.timestamp),h.sentTime=f.timestamp,h.messageUId=f.messageUId,this._conversationManager.setConversationCacheByMessage(h,!0),[2,{code:R.SUCCESS,data:h}])}})})},t.prototype.recallMsg=function(e,r,i,o,s){var c;return V(this,void 0,void 0,function(){var d,l,h,a,u,p,f,m,_,v,T,y,w;return B(this,function(L){switch(L.label){case 0:return this._channel?(d=s.user,l=s.extra,h=s.isDelete,a={conversationType:e,targetId:r,messageUId:i,sentTime:o,channelId:s.channelId||"",isDelete:h||!1},d&&(a.user=d),l&&(a.extra=l),u={content:a,messageType:"RC:RcCmd",disableNotification:s==null?void 0:s.disableNotification,pushConfig:s==null?void 0:s.pushConfig,pushContent:((c=s.pushConfig)===null||c===void 0?void 0:c.pushContent)||s.pushContent||"",channelId:s.channelId},p=x[x.recallMsg],f=this._channel.codec.encodeUpMsg({conversationType:e,targetId:r},u),(m=new qt(p,f,this.currentUserId)).setHeaderQos(At.AT_LEAST_ONCE),[4,this._channel.send(m)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return _=L.sent(),v=_.code,T=_.data,v!==R.SUCCESS?[2,{code:v}]:(y=T,e===Y.ULTRA_GROUP?(this._ultraMsgMap[y.messageUId]=y.timestamp,[2,{code:R.SUCCESS}]):(this._sendMessageStore.setMessage(y.messageUId,y.timestamp),w=Zn(e,r,pt(pt({},u),{isPersited:!0}),y.messageUId,y.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(w,!0),[2,{code:R.SUCCESS,data:w}]))}})})},t.prototype.sendReadReceiptMessage=function(e,r,i){return V(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeReadReceipt(r,i),s=new Q(x[x.rrMsg],o,e),[4,this._channel.send(s)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},t.prototype.getMessageReader=function(e,r,i){return V(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeMessageReader(r,i),s=new Q(x[x.rrList],o,e),[4,this._channel.send(s,ei)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},t.prototype.pullUserSettings=function(e){return V(this,void 0,void 0,function(){var r,i;return B(this,function(o){return this._channel?(r=this._channel.codec.encodePullUserSetting(e),i=new Q(x[x.pullUS],r,this.currentUserId),[2,this._channel.send(i,Qr)]):[2,{code:R.RC_NET_CHANNEL_INVALID}]})})},t.prototype.getFileToken=function(e,r,i,o){return V(this,void 0,void 0,function(){var s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return this._channel?(s=o&&o!=="uploads"?r||"":vd(e,r),c=this._channel.codec.encodeGetFileToken(e,s,i||"",o||""),d=new Q(x[x.qnTkn],c,this.currentUserId),[4,this._channel.send(d,$o)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,a=Object.assign(a,{fileName:s}),h===R.SUCCESS?[2,{code:h,data:a}]:[2,{code:h}]}})})},t.prototype.getFileUrl=function(e,r,i,o){return V(this,void 0,void 0,function(){var s,c,d,l,h,a,u,p,f;return B(this,function(m){switch(m.label){case 0:return this._channel?(s="",c="",d="",r===Kt.QINIU?(c=Go,d=jo):(c=Ko,d=qo),s=r===Kt.QINIU?x[x.qnUrl]:r===Kt.AWS?x[x.s3Url]:r===Kt.STC?x[x.stcUrl]:x[x.aliUrl],l=this._channel.codec.encodeGetFileUrl(c,e,i,o),h=new Q(s,l,this.currentUserId),[4,this._channel.send(h,d)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,p=a.data,f=p,u===R.SUCCESS?[2,{code:u,data:f}]:[2,{code:u}]}})})},t.prototype.disconnect=function(){this._reconnectTimer!==-1&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=-1),this._channel&&(this._channel.close(),this._channel=void 0),this._pullQueue.length=0,this._stopSyncInterval(),this.resetUltraGroupData()},t.prototype.resetUltraGroupData=function(){this._stopUltraSyncInterval(),this._lastSyncUltraMsgTimeStamp=0,this._lastSyncUltraMsgLocalTimeStamp=0,this._isUltraPulling=!1,this._ultraGroupTimeQue=[],this._isUltraGroupListExist=!1,this._ultraGroupMap={}},t.prototype.destroy=function(){throw new Error("JSEngine's method not implemented.")},t.prototype.registerMessageType=function(e,r,i,o,s){this._customMessageType[e]={isPersited:r,isCounted:i,isStatusMessage:s}},t.prototype.getServerTime=function(){return Date.now()-this._localConnectedTime+this._connectedTime},t.prototype.getCurrentUserId=function(){return this.currentUserId},t.prototype.createTag=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([e],r),o=new Q(x[x.addSeTag],i,this.currentUserId),[4,this._channel.send(o,nn)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==R.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([pt(pt({},e),{createdTime:l})],l),[2,{code:R.SUCCESS,data:d}])}})})},t.prototype.removeTag=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeRemoveTag([e],r),o=new Q(x[x.delSeTag],i,this.currentUserId),[4,this._channel.send(o,nn)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==R.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.deleteTag([e],l),[2,{code:R.SUCCESS}])}})})},t.prototype.updateTag=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([e],r),o=new Q(x[x.addSeTag],i,this.currentUserId),[4,this._channel.send(o,nn)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==R.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([e],l),[2,{code:R.SUCCESS,data:d}])}})})},t.prototype.getTagList=function(){return V(this,void 0,void 0,function(){var e,r;return B(this,function(i){return e=this._userSettingManager.getTags(),r=this._conversationManager.getConversationListForTag(),e.forEach(function(o){o.conversationCount=r[o.tagId]?r[o.tagId].length:0}),[2,{code:R.SUCCESS,data:e}]})})},t.prototype.addTagForConversations=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d=this;return B(this,function(l){switch(l.label){case 0:return this._channel?this._userSettingManager.getTagById(e)?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:e}],r),o=new Q(x[x.addTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:R.TAG_NOT_EXIST}]:[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return(s=l.sent().code)!==R.SUCCESS?[2,{code:s}]:((c={})[e]={},r.forEach(function(h){d._conversationManager.addTagStatus(h.conversationType,h.targetId,c,h.channelId)}),[2,{code:R.SUCCESS}])}})})},t.prototype.removeTagForConversations=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c=this;return B(this,function(d){switch(d.label){case 0:return this._channel?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:e}],r),o=new Q(x[x.delTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return(s=d.sent().code)!==R.SUCCESS?[2,{code:s}]:(r.forEach(function(l){c._conversationManager.deleteTagStatus(l.conversationType,l.targetId,[e],l.channelId)}),[2,{code:R.SUCCESS}])}})})},t.prototype.removeTagsForConversation=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return this._channel?(i=e.conversationType,o=e.targetId,s=e.channelId,c=r.map(function(u){return{tagId:u}}),d=this._channel.codec.encodeUpdateConversationTag(c,[e]),l=new Q(x[x.delTag],d,this.currentUserId),[4,this._channel.send(l)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return(h=a.sent().code)!==R.SUCCESS?[2,{code:h}]:(this._conversationManager.deleteTagStatus(i,o,r,s),[2,{code:R.SUCCESS}])}})})},t.prototype.getConversationListByTag=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,p;return B(this,function(f){switch(f.label){case 0:return s=(o=this).currentUserId,(c=o._channel)?(d=c.codec.encodeOldConversationList({count:i,type:Y.PRIVATE,startTime:r}),l=new Q(na,d,s),[4,c.send(l,tn,{currentUserId:s,connectedTime:c.connectedTime})]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return h=f.sent(),a=h.code,u=h.data,p=this._conversationHasTagFilter(e,u==null?void 0:u.list),H.info("GetConversationListByTag",p),a!==R.SUCCESS?[2,{code:a}]:[2,{code:a,data:p}]}})})},t.prototype._conversationHasTagFilter=function(e,r){var i=this,o=[],s=[];function c(d,l){return d.latestMessage&&l.latestMessage?d.latestMessage.sentTime-l.latestMessage.sentTime:0}return r.forEach(function(d){var l=d.conversationType,h=d.targetId,a=d.channelId,u=i._conversationManager.get(l,h,a),p=u.hasMentioned,f=u.mentionedInfo,m=u.lastUnreadTime,_=u.notificationStatus,v=u.isTop,T=u.tags,y=u.unreadMessageCount,w=T&&T[e];if(w){var L=pt(pt({},d),{hasMentioned:p,mentionedInfo:f,lastUnreadTime:m,notificationStatus:_,isTop:v,unreadMessageCount:y});w.isTop?o.push(pt(pt({},L),{isTopInTag:!0})):s.push(pt(pt({},L),{isTopInTag:!1}))}}),Pe(Pe([],o.sort(c),!0),s.sort(c),!0)},t.prototype.getUnreadCountByTag=function(e,r){return V(this,void 0,void 0,function(){var i;return B(this,function(o){return this._channel?(i=this._conversationManager.getUnreadCountByTag(e,r),[2,{code:R.SUCCESS,data:i}]):[2,{code:R.RC_NET_CHANNEL_INVALID}]})})},t.prototype.setConversationStatusInTag=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,p,f;return B(this,function(m){switch(m.label){case 0:return this._channel?(o=r.targetId,s=r.conversationType,c=r.channelId,d=i.isTop,l=[{tagId:e,isTop:d}],(h=this._conversationManager.get(s,o,c)).tags&&Object.hasOwnProperty.call(h.tags,e)?(a=this._channel.codec.encodeUpdateConversationTag(l,[r]),u=new Q(x[x.addTag],a,this.currentUserId),[4,this._channel.send(u)]):[2,{code:R.NO_TAG_IN_CONVER}]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return(p=m.sent().code)!==R.SUCCESS?[2,{code:p}]:((f={})[e]={},d&&(f[e].isTop=!0),this._conversationManager.addTagStatus(s,o,f,c),[2,{code:R.SUCCESS}])}})})},t.prototype.getTagsForConversation=function(e){var r;return V(this,void 0,void 0,function(){var i,o,s,c;return B(this,function(d){if(!this._channel)return[2,{code:R.RC_NET_CHANNEL_INVALID}];if(i=this._conversationManager.get(e.conversationType,e.targetId,e.channelId),o=this._userSettingManager.getTagsInfo(),s=[],i.tags)for(c in i.tags)s.push({tagId:c,tagName:(r=o[c])===null||r===void 0?void 0:r.tagName});return[2,{code:R.SUCCESS,data:s}]})})},t.prototype.getBlockConversationList=function(){var e=this._conversationManager.getBlockConversationList();return Promise.resolve({code:R.SUCCESS,data:e})},t.prototype.getTopConversationList=function(){var e=this._conversationManager.getTopConversationList();return Promise.resolve({code:R.SUCCESS,data:e})},t.prototype.getUnreadMentionedCount=function(e){var r,i;return i=e.conversationType===Y.ULTRA_GROUP?((r=this._ultraGroupMap[e.channelId+"_"+e.targetId])===null||r===void 0?void 0:r.unreadMentionedCount)||0:this._conversationManager.getUnreadMentionedCount(e.channelId,e.conversationType,e.targetId),Promise.resolve({code:R.SUCCESS,data:i})},t.prototype.getAllUnreadMentionedCount=function(){var e=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:R.SUCCESS,data:e})},t.prototype.getUltraGroupList=function(){return V(this,void 0,void 0,function(){var e,r;return B(this,function(i){return this._isUltraGroupListExist?(e=Object.values(this._ultraGroupMap),e=Qn(e),r=He(e),[2,{code:R.SUCCESS,data:r}]):[2,{code:R.METHOD_NOT_AVAILABLE}]})})},t.prototype.getBlockUltraGroupList=function(){if(!this._isUltraGroupListExist)return Promise.resolve({code:R.METHOD_NOT_AVAILABLE});var e=Object.values(this._ultraGroupMap),r=[];return e.forEach(function(i){i.notificationStatus===Yt.OPEN&&r.push({conversationType:Y.ULTRA_GROUP,targetId:i.targetId,channelId:i.channelId})}),Promise.resolve({code:R.SUCCESS,data:r})},t.prototype.getTopUltraGroupList=function(){if(!this._isUltraGroupListExist)return Promise.resolve({code:R.METHOD_NOT_AVAILABLE});var e=Object.values(this._ultraGroupMap),r=[];return e.forEach(function(i){i.isTop===!0&&r.push({conversationType:Y.ULTRA_GROUP,targetId:i.targetId,channelId:i.channelId})}),Promise.resolve({code:R.SUCCESS,data:r})},t.prototype.getUltraGroupUnreadMentionedCountByTargetId=function(e){if(!this._isUltraGroupListExist)return Promise.resolve({code:R.METHOD_NOT_AVAILABLE});var r=0;for(var i in this._ultraGroupMap)i.match(/_.*/g)[0].substring(1)===e&&(r+=this._ultraGroupMap[i].unreadMentionedCount);return Promise.resolve({code:R.SUCCESS,data:r})},t.prototype.getUltraGroupUnreadCountByTargetId=function(e){var r=0;for(var i in this._ultraGroupMap){var o=this._ultraGroupMap[i];o.targetId===e&&(r+=o.unreadMessageCount||0)}return Promise.resolve({code:R.SUCCESS,data:r})},t.prototype.getAllUltraGroupUnreadCount=function(e){if(e===void 0&&(e=!1),!this._isUltraGroupListExist)return Promise.resolve({code:R.METHOD_NOT_AVAILABLE});var r=0;for(var i in this._ultraGroupMap)r+=e?this._ultraGroupMap[i].unreadMentionedCount||0:this._ultraGroupMap[i].unreadMessageCount||0;return Promise.resolve({code:R.SUCCESS,data:r})},t.prototype.clearUltraUnreadcount=function(e,r){return r===void 0&&(r=""),V(this,void 0,void 0,function(){var i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._isUltraGroupListExist?this._channel?this._status!==Z.CONNECTED?[2,R.RC_NET_UNAVAILABLE]:(i=Date.now(),o=this._channel.codec.encodeClearUnreadCount({conversationType:Y.ULTRA_GROUP,targetId:e,channelId:r},{timestamp:i}),(s=new qt(x[x.updUgRTime],o,this.currentUserId)).setHeaderQos(At.AT_LEAST_ONCE),[4,this._channel.send(s)]):[2,R.RC_NET_CHANNEL_INVALID]:[2,Promise.resolve(R.METHOD_NOT_AVAILABLE)];case 1:return(c=l.sent().code)===R.SUCCESS&&(d=this._ultraGroupMap[r+"_"+e])&&(d.unreadMessageCount=0,d.unreadMentionedCount=0,d.lastReadTime=i),[2,c]}})})},t.prototype._getUltraGroupList=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u,p,f,m,_=this;return B(this,function(v){switch(v.label){case 0:return this._channel&&this._status===Z.CONNECTED?(r=this._channel.codec.encodeUltraGroup(e,!1),i=new Q(x[x.pullUgSes],r,this.currentUserId),[4,this._channel.send(i,tn,{currentUserId:this.currentUserId,conversationType:Y.ULTRA_GROUP})]):[2];case 1:return o=v.sent(),s=o.code,c=o.data,s===R.SUCCESS&&c?(l=(c==null?void 0:c.list)||[],h=c==null?void 0:c.isFinished,l.forEach(function(T){T.notificationStatus=Yt.CLOSE,T.notificationLevel=ce.NOT_SET,T.isTop=!1,_._ultraGroupMap[T.channelId+"_"+T.targetId]=T,_._ultraGroupManager.addUltraGroupStatus(T)}),h!==!1?[3,2]:(a=l.length>0&&l[l.length-1].versionTime||0,this._getUltraGroupList(a),[3,4])):(H.warn("pull super conversation failed, code:",s,", data:",c,"retrying..."),d=setTimeout(function(){_._firstPullUltraGroupTime=e,_._getUltraGroupList(e),clearTimeout(d)},3e3),[2]);case 2:return[4,this.pullConversationStatus(this._firstPullUltraGroupTime)];case 3:u=v.sent(),p=u.code,f=u.data,p!==R.SUCCESS&&H.warn("pullConversationStatus fail code: ".concat(p,", data: ").concat(f)),m=Object.values(this._ultraGroupMap),m=Qn(m),this._isUltraGroupListExist=!0,this._watcher.ultraGroupEnable(He(m)),this._firstPullUltraGroupTime===0&&this._syncUltraMsg(this._lastSyncUltraMsgTimeStamp),v.label=4;case 4:return[2]}})})},t.prototype._startUltraSyncInterval=function(){var e=this,r=function(){e._ultraGroupTimer=setTimeout(function(){Date.now()-e._lastSyncUltraMsgLocalTimeStamp>=18e4&&e._syncUltraMsg(e._lastSyncUltraMsgTimeStamp),e._stopUltraSyncInterval(),r()},3e4)};this._lastSyncUltraMsgLocalTimeStamp=Date.now(),this._syncUltraMsg(0),r()},t.prototype._stopUltraSyncInterval=function(){this._ultraGroupTimer!==-1&&(clearTimeout(this._ultraGroupTimer),this._ultraGroupTimer=-1)},t.prototype._syncUltraMsg=function(e){var r;return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,p,f,m,_=this;return B(this,function(v){switch(v.label){case 0:return this._channel&&this._status===Z.CONNECTED?this._isUltraPulling?[2]:(H.info("start pull ultra msg, time: ".concat(e)),this._isUltraPulling=!0,i=this._channel.codec.encodeSuperSyncMsg(e),o=new Q(x[x.pullUgMsg],i,this.currentUserId),[4,this._channel.send(o,Qe,{currentUserId:this.currentUserId,conversation:{conversationType:Y.ULTRA_GROUP}})]):[2];case 1:if(s=v.sent(),c=s.code,d=s.data,H.info("end pull ultra msg, code: ".concat(c,", syncTime: ").concat(d==null?void 0:d.syncTime,", count: ").concat((r=d==null?void 0:d.list)===null||r===void 0?void 0:r.length)),this._lastSyncUltraMsgLocalTimeStamp=Date.now(),c!==R.SUCCESS||!d)return H.warn("sync super message failed, code:",c,", data:",d),this._isUltraPulling=!1,[2];if(this._isUltraPulling=!1,l=d.list,h=d.syncTime,a=d.finished,!this._isUltraGroupListExist)return H.info("init getUltraGroupList"),this._firstPullUltraGroupTime=0,this._getUltraGroupList(0),this._lastSyncUltraMsgTimeStamp=h,[2];for(m in u={},p=[],l.forEach(function(T){var y,w,L,M=T.targetId,C=T.content,A=T.messageType,F=T.messageUId,G=T.channelId,E=T.isCounted;if(_._ultraMsgMap[F])delete _._ultraMsgMap[F];else{var S=0;(((y=C==null?void 0:C.mentionedInfo)===null||y===void 0?void 0:y.type)===qr.ALL||((L=(w=C==null?void 0:C.mentionedInfo)===null||w===void 0?void 0:w.userIdList)===null||L===void 0?void 0:L.includes(_.currentUserId)))&&(S=1);var I=_._ultraGroupMap[G+"_"+M];if(I)E&&(A===Ut.RECALL?I.unreadMessageCount>0&&(I.unreadMessageCount-=1):(I.unreadMessageCount+=1,I.unreadMentionedCount+=S)),I.versionTime=h,I.latestMessage=T,u[G+"_"+M]=I,_._ultraGroupManager.addUltraGroupStatus(I);else{var N={conversationType:Y.ULTRA_GROUP,targetId:M,channelId:G,unreadMessageCount:1,unreadMentionedCount:S,versionTime:h,latestMessage:T,notificationStatus:Yt.CLOSE,notificationLevel:ce.NOT_SET,isTop:!1};_._ultraGroupMap[G+"_"+M]=N,u[G+"_"+M]=N,_._ultraGroupManager.addUltraGroupStatus(N)}p.push(T)}}),Object.keys(u).length>0&&(H.info("notice ultragroups"),f=Object.values(u),f=Qn(f),this._watcher.conversation(He(f))),H.info("notice ultragroup message"),this._watcher.batchMessage(p),this._ultraGroupTimeQue=this._ultraGroupTimeQue.filter(function(T){return T>h}),this._ultraMsgMap)this._ultraMsgMap[m]0&&(this._lastSyncUltraMsgTimeStamp=h),this._ultraGroupTimeQue.length>0&&this._syncUltraMsg(this._lastSyncUltraMsgTimeStamp),[2]}})})},t.prototype.sendUltraMessage=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,p;return B(this,function(f){switch(f.label){case 0:return this._channel?this._status!==Z.CONNECTED?[2,{code:R.RC_NET_UNAVAILABLE}]:(r.messageType==="RC:SRSMsg"&&H.warn("ultra group -> direction message convert to message"),r=this._handleMsgProperties(r,!0),i=this._channel.codec.encodeUpMsg({conversationType:Y.ULTRA_GROUP,targetId:e},r),(o=new qt(x[x.ugMsg],i,e)).setHeaderQos(At.AT_LEAST_ONCE),s=Date.now()-this._localConnectedTime+this._connectedTime,c=Zn(Y.ULTRA_GROUP,e,pt({},r),"",s,this.currentUserId),[4,this._channel.send(o)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return d=f.sent(),l=d.code,h=d.data,l!==R.SUCCESS?[2,{code:l,data:c}]:(a=h,c.sentTime=a.timestamp,c.messageUId=a.messageUId,this._ultraMsgMap[a.messageUId]=a.timestamp,u=r.channelId||"",(p=this._ultraGroupMap[u+"_"+e])?p.latestMessage=c:(p={conversationType:Y.ULTRA_GROUP,targetId:e,channelId:u,unreadMessageCount:0,unreadMentionedCount:0,versionTime:c.sentTime,latestMessage:c,notificationStatus:Yt.CLOSE,notificationLevel:ce.NOT_SET,isTop:!1},this._ultraGroupMap[u+"_"+e]=p,this._ultraGroupManager.addUltraGroupStatus(p)),this._watcher.conversation(He([p])),[2,{code:l,data:c}])}})})},t.prototype.sendUltraGroupTypingStatus=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?this._status!==Z.CONNECTED?[2,{code:R.RC_NET_UNAVAILABLE}]:(i=e.conversationType,o=e.channelId,s=e.targetId,c=this._channel.codec.encodeOperateStatus(s,i,o||"",r||0),(d=new qt(x[x.operate],c,s)).setHeaderQos(At.AT_LEAST_ONCE),[4,this._channel.send(d)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return(l=h.sent().code)!==R.SUCCESS?[2,{code:l,msg:R[l]}]:[2,{code:l}]}})})},t.prototype.getUltraGroupMessageListByMessageUId=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?this._status!==Z.CONNECTED?[2,{code:R.RC_NET_UNAVAILABLE}]:e.messages&&e.messages.length<1||e.messages&&e.messages.length>20?[2,{code:R.MSG_LIMIT_ERROR}]:(r={},e.messages.forEach(function(a){r[a.messageUId]=void 0}),i=this._channel.codec.encodeMsgQuery(e),(o=new Q(x[x.qryMsg],i,this.currentUserId)).setHeaderQos(At.AT_LEAST_ONCE),[4,this._channel.send(o,xn)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==R.SUCCESS?[2,{code:c,msg:R[c]}]:(l=(d||{}).list,Array.isArray(l)&&l.forEach(function(a){var u=a.messageUId;r[u]=a}),[2,{code:0,data:r}])}})})},t.prototype._pullOperateStatusNotify=function(e){if(this._channel){var r=this._channel.codec.decodeByPBName(e.data,ri),i=r.conversationType,o=r.info,s=r.summary;H.info("s_opNtf -> type: ".concat(i,", info: ").concat(o,", summary: ").concat(s)),this._watcher.operateStatus(r)}},t.prototype.expandUltraMessage=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?this._status!==Z.CONNECTED?[2,{code:R.RC_NET_UNAVAILABLE}]:(r=this._channel.codec.encodeExpandUltraMessage(e,this.currentUserId),(i=new qt(x[x.upMsgEx],r,e.targetId)).setHeaderQos(At.AT_LEAST_ONCE),[4,this._channel.send(i)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return o=l.sent(),s=o.code,c=o.data,s!==R.SUCCESS?[2,{code:s,msg:R[s]}]:(d=c,this._ultraMsgMap[d.messageUId]=d.timestamp,[2,{code:s}])}})})},t.prototype.modifyMessage=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?this._status!==Z.CONNECTED?[2,{code:R.RC_NET_UNAVAILABLE}]:(r=this._channel.codec.encodemodifyMessage(e,this.currentUserId),(i=new qt(x[x.modifyMsg],r,e.targetId)).setHeaderQos(At.AT_LEAST_ONCE),[4,this._channel.send(i)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return o=l.sent(),s=o.code,c=o.data,s!==R.SUCCESS?[2,{code:s,msg:R[s]}]:(d=c,this._ultraMsgMap[d.messageUId]=d.timestamp,[2,{code:s}])}})})},t.prototype._pullUltraChangeMessageList=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u,p,f,m,_,v,T,y,w=this;return B(this,function(L){switch(L.label){case 0:return this._channel?this._status!==Z.CONNECTED||this._isPullingUltraChangeMessage?[2]:(this._isPullingUltraChangeMessage=!0,r=this._channel.codec.encodeQueryMsgChange(e),(i=new qt(x[x.qryMsgChange],r,this.currentUserId)).setHeaderQos(At.AT_LEAST_ONCE),[4,this._channel.send(i,ni)]):[2];case 1:if(o=L.sent(),s=o.code,c=o.data,this._isPullingUltraChangeMessage=!1,s!==R.SUCCESS)return[2];for(_ in l=(d=c||{}).hasNext,h=d.list,a=(c==null?void 0:c.syncTime)||0,u=[],p={},Array.isArray(h)&&h.forEach(function(M){var C=M,A=C.targetId,F=C.conversationType,G=C.sendTime,E=C.messageUId,S=C.changeType,I=C.operatorId,N=M.channelId||"",b=F+"_"+A,k=E+"_"+N+"_"+G,U=p[b];if(U)U.add(k);else{var $=new Set([k]);p[b]=$}S!==3?w._ultraMsgChangeMap[E]=S:u.push({targetId:A,conversationType:F,sendTime:G,messageUId:E,senderUserId:I,channelId:N})}),Array.isArray(u)&&u.length>0&&this._watcher.ultraGroupMessageRecalled(u),f=function(M){var C=M.split("_"),A=C.shift(),F=C.join("_"),G=p[M],E=[];G.forEach(function(I){var N=I.split("_"),b=N[0],k=N[1],U=N[2];E.push({sendTime:Number(U),messageUId:b,channelId:k})});var S={targetId:F,conversationType:Number(A),messages:E};m._pullUltraMessageList(S)},m=this,p)f(_);for(T in v=this._pullUltraChangeMessageQue.filter(function(M){return M>a}),this._pullUltraChangeMessageQue.length=0,(y=this._pullUltraChangeMessageQue).push.apply(y,v),this._ultraMsgMap)this._ultraMsgMap[T]0&&this._watcher.ultraGroupMessageExpansionUpdated(l||[]),h.length>0&&this._watcher.ultraGroupMessageModified(h||[]),[2])}})})},t.prototype.getUltraHistoryMsg=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?this._status!==Z.CONNECTED?[2,{code:R.RC_NET_UNAVAILABLE}]:(i=this._channel.codec.encodeGetHistoryMsg(e,r),o=new Q(x[x.qryUgMsg],i,this.currentUserId),[4,this._channel.send(o,Xe,{currentUserId:this.currentUserId,conversation:{conversationType:Y.ULTRA_GROUP,targetId:e}})]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return s=l.sent(),c=s.code,d=s.data,c===R.SUCCESS&&d?[2,{code:c,data:d}]:(H.warn("get super history message failed, code:",c,", data:",d),[2,{code:c}])}})})},t.prototype.searchUltraGroupMessages=function(e){return V(this,void 0,void 0,function(){return B(this,function(r){return this._channel?this._status!==Z.CONNECTED?[2,{code:R.RC_NET_UNAVAILABLE}]:[2,{code:R.SUCCESS}]:[2,{code:R.RC_NET_CHANNEL_INVALID}]})})},t.prototype.getAllConversationState=function(){return Promise.resolve({code:R.SUCCESS,data:this._conversationManager.getAllConversationState()})},t.prototype.joinRTCRoom=function(e,r,i,o,s,c){return V(this,void 0,void 0,function(){var d,l;return B(this,function(h){return this._channel?(d=this._channel.codec.encodeJoinRTCRoom(r,i,o,s,c),l=new Q(x[x.rtcRJoin_data],d,e),[2,this._channel.send(l,Ae)]):[2,{code:R.RC_NET_CHANNEL_INVALID}]})})},t.prototype.quitRTCRoom=function(e){return V(this,void 0,void 0,function(){var r,i;return B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(x[x.rtcRExit],r,e),[4,this._channel.send(i)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},t.prototype.rtcPing=function(e,r,i){return V(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new Q(x[x.rtcPing],o,e),[4,this._channel.send(s)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},t.prototype.getRTCRoomInfo=function(e){return V(this,void 0,void 0,function(){var r,i;return B(this,function(o){return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(x[x.rtcRInfo],r,e),[2,this._channel.send(i,sc)]):[2,{code:R.RC_NET_CHANNEL_INVALID}]})})},t.prototype.getRTCUserInfoList=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(x[x.rtcUData],r,e),[4,this._channel.send(i,Ae)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return o=d.sent(),s=o.code,c=o.data,[2,{code:s,data:c&&{users:c.users}}]}})})},t.prototype.setRTCUserInfo=function(e,r,i){return V(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeSetRTCUserInfo(r,i),s=new Q(x[x.rtcUPut],o,e),[4,this._channel.send(s)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},t.prototype.removeRTCUserInfo=function(e,r){return V(this,void 0,void 0,function(){var i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeRemoveRTCUserInfo(r),o=new qt(x[x.rtcUDel],i,e),[4,this._channel.send(o)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},t.prototype.setRTCData=function(e,r,i,o,s,c){return V(this,void 0,void 0,function(){var d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(d=this._channel.codec.encodeSetRTCData(r,i,o,s,c),l=new qt(x[x.rtcSetData],d,e),[4,this._channel.send(l)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,h.sent().code]}})})},t.prototype.setRTCTotalRes=function(e,r,i,o,s){return V(this,void 0,void 0,function(){var c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeUserSetRTCData(r,i,o,s),d=new Q(x[x.userSetData],c,e),[4,this._channel.send(d)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},t.prototype.setRTCCDNUris=function(e,r,i){return V(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeUserSetRTCCDNUris(r,i),s=new Q(x[x.userSetData],o,e),[4,this._channel.send(s)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},t.prototype.getRTCData=function(e,r,i,o){if(!this._channel)return Promise.resolve({code:R.RC_NET_CHANNEL_INVALID});var s=this._channel.codec.encodeGetRTCData(r,i,o),c=new Q(x[x.rtcQryData],s,e);return this._channel.send(c,Zr)},t.prototype.removeRTCData=function(e,r,i,o,s){return V(this,void 0,void 0,function(){var c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeRemoveRTCData(r,i,o,s),d=new qt(x[x.rtcDelData],c,e),[4,this._channel.send(d)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},t.prototype.setRTCOutData=function(e,r,i,o){throw new Error("JSEngine's method not implemented.")},t.prototype.getRTCOutData=function(e,r){throw new Error("JSEngine's method not implemented.")},t.prototype.getRTCToken=function(e,r,i){return V(this,void 0,void 0,function(){var o,s;return B(this,function(c){return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new Q(x[x.rtcToken],o,e),[2,this._channel.send(s,Wr)]):[2,{code:R.RC_NET_CHANNEL_INVALID}]})})},t.prototype.setRTCState=function(e,r){return V(this,void 0,void 0,function(){var i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeSetRTCState(r),o=new Q(x[x.rtcUserState],i,e),[4,this._channel.send(o)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},t.prototype.getRTCUserInfo=function(e){return V(this,void 0,void 0,function(){return B(this,function(r){throw new Error("Method not implemented.")})})},t.prototype.getRTCUserList=function(e){if(!this._channel)return Promise.resolve({code:R.RC_NET_CHANNEL_INVALID});var r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(x[x.rtcUList],r,e);return this._channel.send(i,Ae)},t.prototype.joinLivingRoomAsAudience=function(e,r,i){return r===void 0&&(r=Vt.LIVE),V(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u;return B(this,function(p){switch(p.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new Q(x[x.viewerJoinR],o,e),[4,this._channel.send(s,gc)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return c=p.sent(),d=c.code,l=c.data,d!==R.SUCCESS?[2,{code:d}]:(a=(h=l).rtcToken,u=h.entries,[2,{code:d,data:{token:a,kvEntries:u}}])}})})},t.prototype.quitLivingRoomAsAudience=function(e){return V(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(x[x.viewerExitR],r,e),[4,this._channel.send(i)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},t.prototype.rtcIdentityChange=function(e,r,i){return V(this,void 0,void 0,function(){var o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(o=this._channel.codec.encodeIdentityChangeInfo(r,i),s=new Q(x[x.rtcIdentityChange],o,e),[4,this._channel.send(s,Ae)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return c=h.sent(),d=c.code,l=c.data,d!==R.SUCCESS?[2,{code:d}]:[2,{code:d,data:l}]}})})},t.prototype.pullRTCRoomEntry=function(e,r){return V(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u;return B(this,function(p){switch(p.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(H.info("audience in room start pull KV"),c=o.codec.encodePullRTCRoomKV(e,0),d=new Q(x[x.rtcPullKv],c,s),[4,o.send(d,ii)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return l=p.sent(),h=l.code,a=l.data,H.info("audience in room end pull KV, code: ".concat(h,", data: ").concat(JSON.stringify(a||{}))),h===R.SUCCESS?(u=a.kvEntries,this._watcher.onRTCDataChange(u,e),[2,{code:h,data:a}]):[2,{code:h}]}})})},t.prototype.getRTCJoinedUserInfo=function(e){return V(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeQueryUserJoinedInfo(e),c=new Q(x[x.rtcQueryJoined],s,o),[4,i.send(c,oi)]):[2,{code:R.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l===R.SUCCESS?[2,{code:l,data:h}]:[2,{code:l}]}})})},t.prototype.getDeviceId=function(){return Di(this.runtime)},t.prototype.requestRoomPK=function(e){return V(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeRequestRoomPK(e),i=new Q(x[x.rtcInvite],r,e.roomId),[4,this._channel.send(i)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},t.prototype.cancelRoomPK=function(e){return V(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeCancelRoomPK(e),i=new Q(x[x.rtcCancelInvite],r,e.roomId),[4,this._channel.send(i)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},t.prototype.responseRoomPK=function(e){return V(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeResponseRoomPK(e),i=new Q(x[x.rtcInviteAnswer],r,e.roomId),[4,this._channel.send(i)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},t.prototype.endRoomPK=function(e){return V(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeEndRoomPK(e),i=new Q(x[x.rtcEndInvite],r,e.roomId),[4,this._channel.send(i)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},t.prototype.bindRTCRoomForChatroom=function(e){return V(this,void 0,void 0,function(){var r,i,o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(r=e.chatRoomId,i=this._channel.codec.encodebindRTCRoomForChatroom(e),o=new Q(x[x.setRtcRoomId],i,r),[4,this._channel.send(o)]):[2,R.RC_NET_CHANNEL_INVALID];case 1:return s=c.sent(),[2,s.code]}})})},t.prototype.callExtra=function(e){for(var r=[],i=1;i6e3?this._typingExpireTime=6e3:this._typingExpireTime=this._options.typingExpireTime),this._options.navigators=this._options.navigators.filter(function(o){return/^https?:\/\//.test(o)}),this._options.navigators=this._options.navigators.map(function(o){return o.replace(/\/$/g,"")}),this._options.navigators.length===0&&(r=this._options.navigators).push.apply(r,cd),H.updateStatisticsBaseData({bundleId:this.apiPKGName}),H.initReportLog({runtime:this._runtime,logSwitch:1,logPolicy:JSON.parse("{}"),appkey:this.appkey,version:this.apiVersion});var i={status:this._connectionStatusListener.bind(this),batchMessage:this._batchMessageReceiver.bind(this),chatroom:this._chatroomInfoListener.bind(this),conversation:this._conversationInfoListener.bind(this),expansion:this._expansionInfoListener.bind(this),tag:this._tagListener.bind(this),conversationTag:this._conversationTagListener.bind(this),onRTCDataChange:this._rtcDataChange.bind(this),pullFinished:this._pullFinishedListener.bind(this),ultraGroupEnable:this._ultraGroupEnableListener.bind(this),operateStatus:this._operateStatusListener.bind(this),ultraGroupMessageExpansionUpdated:this._ultraGroupMessageExpansionUpdatedListener.bind(this),ultraGroupMessageModified:this._ultraGroupMessageModifiedListener.bind(this),ultraGroupMessageRecalled:this._ultraGroupMessageRecalledListener.bind(this)};this._engine=Ws()?new RCCppEngine(t,i,this._options):new Tl(t,i,this._options)}return n.init=function(t,e){return H.setLogLevel(e.logLevel),H.setLogStdout(e.logStdout),(e.indexDBSwitch||ct(e.indexDBSwitch))&&yo.init(),H.debug("APIContext.init =>",e.appkey,e.navigators),this._context?(H.error("Repeat initialize!"),this._context):(H.warn("RCEngine Commit:","55870c2344845f2c11a49f895f963e33d57c6123"),this._context=new n(t,e),H.__insertLogIntoDatabase(),this._context)},n.destroy=function(){this._context&&(this._context._destroy(),this._context=void 0)},n.prototype.install=function(t,e){if(this._pluginInstanseMap[t.tag])return H.warn("Repeat install plugin: ".concat(t.tag)),this._pluginInstanseMap[t.tag];var r=t.tag==="RCRTC"?new yl(this):new wc(this),i=null;try{if(!t.verify(this._runtime))return null;i=t.setup(r,this._runtime,e)}catch(o){H.error(`install plugin error! `,o)}return["RCRTC","RCCall"].includes(t.tag)&&t.version&&t.name&&(this._versionInfo[t.name]=t.version),i&&this._pluginContextQueue.push(r),i&&(this._pluginInstanseMap[t.tag]=i),i},n.prototype._handleRedirect=function(){return V(this,void 0,void 0,function(){var t,e=this;return B(this,function(r){switch(r.label){case 0:return H.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return(t=r.sent().code)!==R.SUCCESS&&this._canRedirectConnect&&(this._handleSuspend(t),setTimeout(function(){e._handleRedirect()},5e3)),[2]}})})},n.prototype._connectionStatusListener=function(t){var e;return V(this,void 0,void 0,function(){return B(this,function(r){return[Z.REDIRECT,Z.BLOCKED,Z.KICKED_OFFLINE_BY_OTHER_CLIENT,Z.DISCONNECT_BY_SERVER,Z.DISCONNECTED,Z.NETWORK_UNAVAILABLE].includes(t)&&(H.setStatisticsData(kt.IM_CONNECTION_DURATION,{endTime:new Date().getTime(),code:t}),function(i){V(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,p,f;return B(this,function(m){switch(m.label){case 0:o=kt.IM_CONNECTION_DURATION,s=H.getStatisticsBaseData().bundleId,c=H.getStatisticsData(o),d=c.startTime,l=c.endTime,h=c.code,a=Zt.UNKONWN,m.label=1;case 1:return m.trys.push([1,3,,4]),[4,i.getNetworkType()];case 2:return a=m.sent(),[3,4];case 3:return u=m.sent(),H.debug(u.message),[3,4];case 4:return p=0,mt(d)&&mt(l)&&l>d&&d&&(p=l-d),f={bid:s,cod:h,dur:p,net:a},H.reportStatisticsLog(o,f),[2]}})})}(this._runtime)),t===Z.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(t),this._handleRedirect()):t===Z.BLOCKED||t===Z.KICKED_OFFLINE_BY_OTHER_CLIENT||t===Z.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect(t)):t===Z.CONNECTING?this._handleConnecting():t===Z.CONNECTED?this._handleConnected():t===Z.DISCONNECTED?this._handleDisconnect(t):t===Z.NETWORK_UNAVAILABLE&&this._handleSuspend(t),this._connectionStatus=t,((e=this._watcher.rtcInnerWatcher)===null||e===void 0?void 0:e.status)&&this._watcher.rtcInnerWatcher.status(t),this._pluginContextQueue.forEach(function(i){i.onconnectionstatechange&&i.onconnectionstatechange(t)}),this._watcher.connectionState&&this._watcher.connectionState(t),[2]})})},n.prototype._handleConnecting=function(){this._watcher.onConnecting&&this._watcher.onConnecting()},n.prototype._handleConnected=function(){this._watcher.onConnected&&this._watcher.onConnected()},n.prototype._handleDisconnect=function(t){this._watcher.onDisconnect&&this._watcher.onDisconnect(t)},n.prototype._handleSuspend=function(t){this._watcher.onSuspend&&this._watcher.onSuspend(t)},n.prototype._messageReceiver=function(t,e,r){var i,o,s;if((t.conversationType===Y.RTC_ROOM||Object.prototype.hasOwnProperty.call(gd,t.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(Xn(t));else if(["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(t.messageType)===-1||typeof this._watcher.chatroomState!="function"){if(t.messageType!=="RC:ChrmMemChange"){if(t.messageType!==Ut.TYPING_STATUS||(this._addTypingInfo(Xn(t)),!this._watcher.typingState))if(t.messageType!==Ut.LOG_COMMAND||t.senderUserId!=="rongcloudsystem")if(t.messageType!==Ut.INTERCEPT){if(!this._pluginContextQueue.some(function(v){if(!v.onmessage)return!1;try{return v.onmessage(Xn(t))}catch(T){return H.error("plugin error =>",T),!1}}))if(this._watcher.message&&this._watcher.message(Xn(t),e,r),t.messageType!=="RC:ReadNtf")if(t.messageType!=="RC:RRReqMsg"){if(t.messageType!=="RC:RRRspMsg")return t;var c=(s=t.content)===null||s===void 0?void 0:s.receiptMessageDic;c&&Array.isArray(c[this._engine.currentUserId])&&typeof this._watcher.messageReceiptResponse=="function"&&this._watcher.messageReceiptResponse({conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId},t.senderUserId,c[this._engine.currentUserId])}else typeof this._watcher.messageReceiptRequest=="function"&&this._watcher.messageReceiptRequest({conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId},t.content.messageUId,t.senderUserId);else typeof this._watcher.readReceiptReceived=="function"&&this._watcher.readReceiptReceived({conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId},t.content.messageUId,t.content.lastMessageSendTime)}else this._MessageBlockedListener({conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId||"",blockType:t.content.interceptType,blockedMessageUId:t.content.msgUId});else{var d=t.content,l=d.startTime,h=d.endTime,a=d.platform,u=d.logId,p=d.uri,f=d.packageName,m={startTime:parseInt(l),endTime:parseInt(h),platform:a,logId:u,uri:p,packageName:f};(o=_e.getInstance())===null||o===void 0||o.reportFullLog(m)}}else if(typeof this._watcher.chatroomState=="function"){var _={};Array.isArray(t.content.userList)&&t.content.userList.forEach(function(v){_[v.userId]=v.status}),this._watcher.chatroomState({userChange:{users:_,chatroomId:t.targetId}})}}else this._watcher.chatroomState({userChange:{users:(i={},i[t.senderUserId]=t.messageType==="RC:ChrmQuitNtf"?js.QUIT:js.JOIN,i),chatroomId:t.targetId}})},n.prototype._batchMessageReceiver=function(t,e,r){var i=this,o=[];t.forEach(function(s){var c=i._messageReceiver(s,e,r);c&&o.push(c)}),o.length&&this._watcher.batchMessage&&this._watcher.batchMessage(o)},n.prototype._chatroomInfoListener=function(t){this._watcher.chatroomState&&this._watcher.chatroomState(t)},n.prototype._conversationInfoListener=function(t){this._watcher.conversationState&&this._watcher.conversationState(t)},n.prototype._expansionInfoListener=function(t){this._watcher.expansion&&this._watcher.expansion(t)},n.prototype._tagListener=function(){this._watcher.tag&&this._watcher.tag()},n.prototype._conversationTagListener=function(){this._watcher.conversationTagChanged&&this._watcher.conversationTagChanged()},n.prototype._typingStatusListener=function(t){this._watcher.typingState&&this._watcher.typingState(t)},n.prototype._pullFinishedListener=function(){this._watcher.pullFinished&&this._watcher.pullFinished()},n.prototype._MessageBlockedListener=function(t){this._watcher.messageBlocked&&this._watcher.messageBlocked(t)},n.prototype._ultraGroupEnableListener=function(t){this._watcher.ultraGroupEnable&&this._watcher.ultraGroupEnable(t)},n.prototype._operateStatusListener=function(t){this._watcher.operateStatus&&this._watcher.operateStatus(t)},n.prototype._ultraGroupMessageExpansionUpdatedListener=function(t){this._watcher.ultraGroupMessageExpansionUpdated&&this._watcher.ultraGroupMessageExpansionUpdated(t)},n.prototype._ultraGroupMessageModifiedListener=function(t){this._watcher.ultraGroupMessageModified&&this._watcher.ultraGroupMessageModified(t)},n.prototype._ultraGroupMessageRecalledListener=function(t){this._watcher.ultraGroupMessageRecalled&&this._watcher.ultraGroupMessageRecalled(t)},n.prototype._rtcDataChange=function(t,e){this._pluginContextQueue.forEach(function(r){r.onrtcdatachange&&r.onrtcdatachange(t,e)})},n.prototype.assignWatcher=function(t){var e=this;Object.keys(this._watcher).forEach(function(r){if(Object.prototype.hasOwnProperty.call(t,r)){var i=t[r];e._watcher[r]=Cr(i)||Rt(i)?i:void 0}})},n.prototype.resetWatcher=function(){var t=this;Object.keys(this._watcher).forEach(function(e){t._watcher[e]=void 0})},n.prototype._addTypingInfo=function(t){var e=t.senderUserId,r=t.conversationType,i=t.targetId,o=t.content,s=t.channelId,c=o.typingContentType,d=s||"",l="".concat(r,"#").concat(i,"#").concat(d);this._typingInfo[l]||(this._typingInfo[l]=[]);var h=this._typingInfo[l].findIndex(function(a){return a.userId===e});h>=0&&this._typingInfo[l][h].messageType===c?this._typingInfo[l][h].timestamp=Date.now():(h>=0&&this._typingInfo[l].splice(h,1),this._typingInfo[l].push({userId:e,messageType:c,timestamp:Date.now()}),this._typingChangedList.includes(l)||this._typingChangedList.push(l),this._startCheckTypingInfo())},n.prototype._startCheckTypingInfo=function(){var t=this;this._typingInternalTimer===-1&&Object.keys(this._typingInfo).length!==0&&(this._typingInternalTimer=setInterval(function(){for(var e in t._typingInfo){var r=t._typingInfo[e].length;t._typingInfo[e]=t._typingInfo[e].filter(function(o){return Date.now()-o.timestamp0){var i=t._typingChangedList.map(function(o){return{conversationType:Number(o.split("#")[0]),targetId:o.split("#")[1],channelId:o.split("#")[2],list:t._typingInfo[o]||[]}});t._typingStatusListener(i),t._typingChangedList=[]}Object.keys(t._typingInfo).length===0&&(clearInterval(t._typingInternalTimer),t._typingInternalTimer=-1)},500))},n.prototype.getConnectedTime=function(){return this._engine.getConnectedTime()},n.prototype.getServerTime=function(){return this._engine.getServerTime()},n.prototype.getDeviceId=function(){return this._engine.getDeviceId()},n.prototype.getCurrentUserId=function(){return this._engine.currentUserId},n.prototype.getConnectionStatus=function(){return this._connectionStatus},Object.defineProperty(n.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),n.prototype.connect=function(t,e,r){return e===void 0&&(e=!1),V(this,void 0,void 0,function(){var i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._connectionStatus===Z.CONNECTED?[2,{code:R.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===Z.CONNECTING?[2,{code:R.BIZ_ERROR_CONNECTING}]:typeof t!="string"||t.length===0?[2,{code:R.RC_CONN_USER_OR_PASSWD_ERROR}]:(this._token=t,i=t.split("@"),o=i[1],s=o?o.split(";").map(function(a){return/^https?:/.test(a)?a:"https://".concat(a)}):[],[4,this._engine.navi.getInfo(this._getTokenWithoutNavi(),s,e,this._options.checkCA)]);case 1:return(c=h.sent())?(c==null?void 0:c.type)===1?[2,{code:R.PACKAGE_ENVIRONMENT_ERROR}]:(d=Sn.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),c,r)]):[2,{code:R.RC_NAVI_RESOURCE_ERROR}];case 2:return l=h.sent(),H.__insertLogIntoDatabase(),l!==Mt.REDIRECT?[3,4]:(this._connectionStatus=Z.REDIRECT,[4,this.connect(t,!0)]);case 3:return[2,h.sent()];case 4:return l===R.SUCCESS&&(H.setStatisticsData(kt.IM_CONNECTION_DURATION,{startTime:new Date().getTime()},!0),H.info("connect success, userId: ".concat(this._engine.currentUserId)),(c==null?void 0:c.type)!==1&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(d),H.updateUploadLogAttr({runtime:this._runtime,logSwitch:(c==null?void 0:c.logSwitch)||0,logPolicy:JSON.parse((c==null?void 0:c.logPolicy)||"{}"),appkey:this.appkey,version:this.apiVersion,userId:this._engine.currentUserId}),Le.init(this._engine.currentUserId),this._isInternalConnected=!0),l!==R.SUCCESS||Ws()||c.openUS===1&&this._pullUserSettings(),l!==R.SUCCESS&&(this._connectionStatus=Z.CONNECTION_CLOSED),[2,{code:l,userId:this._engine.currentUserId}]}})})},n.prototype._pullUserSettings=function(){return V(this,void 0,void 0,function(){return B(this,function(t){return[2]})})},n.prototype.disconnect=function(){var t;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,this._typingInfo={},(t=_e.getInstance())===null||t===void 0||t.distroy(),H.__insertLogIntoDatabase(),Le.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach(function(e){if(e.ondisconnect)try{e.ondisconnect()}catch(r){H.error("plugin error =>",r)}}),Promise.resolve()},n.prototype.reconnect=function(t){return this._isInternalConnected?Promise.resolve({code:R.CAN_NOT_RECONNECT}):this.connect(this._getTokenWithoutNavi(),!1,t)},n.prototype._getTokenWithoutNavi=function(){return this._token.replace(/@.+$/,"@")},n.prototype.getInfoFromCache=function(){return this._engine.navi.getInfoFromCache(this._getTokenWithoutNavi())},n.prototype.registerMessageType=function(t,e,r,i,o){i===void 0&&(i=[]),o===void 0&&(o=!1),this._engine.registerMessageType(t,e,r,i,o)},n.prototype.sendMessage=function(t,e,r,i){if(t!==Y.ULTRA_GROUP){var o=this.getInfoFromCache();if(((o==null?void 0:o.grpRRVer)||0)===1&&r.messageType===Ut.READ_RECEIPT_RESPONSE)return Promise.resolve({code:R.READ_RECEIPT_ERROR})}var s=r.canIncludeExpansion,c=s!==void 0&&s,d=r.expansion;if(c){var l=fi(d),h=l.isIllgalEx,a=l.isExKeyOrValLengthExceedLimit;if(l.isExceedLimit||a)return Promise.resolve({code:R.EXPANSION_LIMIT_EXCEET});if(h)return Promise.resolve({code:R.BIZ_ERROR_INVALID_PARAMETER})}var u=JSON.stringify(r.content);return Xa(u)>131072?Promise.resolve({code:R.RC_MSG_CONTENT_EXCEED_LIMIT}):t===Y.ULTRA_GROUP?this._engine.sendUltraMessage(e,r):this._engine.sendMessage(t,e,r,i)},n.prototype.sendExpansionMessage=function(t){return V(this,void 0,void 0,function(){var e,r,i,o,s,c,d,l,h,a,u;return B(this,function(p){switch(p.label){case 0:return e=t.channelId,r=t.conversationType,i=t.targetId,o=t.messageUId,s=t.keys,c=t.expansion,d=t.removeAll,t.canIncludeExpansion?(l=fi(c),h=l.isIllgalEx,a=l.isExKeyOrValLengthExceedLimit,l.isExceedLimit||a?[2,Promise.resolve({code:R.EXPANSION_LIMIT_EXCEET})]:h?[2,Promise.resolve({code:R.BIZ_ERROR_INVALID_PARAMETER})]:(u={mid:o},c&&(u.put=c),s&&(u.del=s),d&&(u.removeAll=1),[4,this._engine.sendMessage(r,i,{content:u,messageType:Ut.EXPANSION_NOTIFY,channelId:e})])):[2,{code:R.MESSAGE_KV_NOT_SUPPORT}];case 1:return[2,{code:p.sent().code}]}})})},n.prototype.sendReadReceiptMessage=function(t,e,r){return V(this,void 0,void 0,function(){var i;return B(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:R.READ_RECEIPT_ERROR,data:"The read receipt switch is not on, please call the sendMessage method!"}]:[2,this._engine.sendReadReceiptMessage(t,e,r)]})})},n.prototype.getMessageReader=function(t,e,r){return V(this,void 0,void 0,function(){var i;return B(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:R.READ_RECEIPT_ERROR}]:[2,this._engine.getMessageReader(t,e,r)]})})},n.prototype._destroy=function(){var t;this._isInternalConnected=!1,this._watcher={batchMessage:void 0,message:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,typingState:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0},this._engine.disconnect(),this._pluginContextQueue.forEach(function(e){if(e.ondestroy)try{e.ondestroy()}catch(r){H.error("plugin error =>",r)}}),this._pluginContextQueue.length=0,this._pluginInstanseMap={},(t=_e.getInstance())===null||t===void 0||t.distroy(),Le.reset()},n.prototype.getHistoryMessage=function(t,e,r,i,o,s,c){if(r===void 0&&(r=0),i===void 0&&(i=20),o===void 0&&(o=0),s===void 0&&(s=""),c===void 0&&(c=""),t===Y.ULTRA_GROUP){var d={timestamp:r,count:i,order:o,channelId:s};return this._engine.getUltraHistoryMsg(e,d)}return this._engine.getHistoryMessage(t,e,r,i,o,s,c||"")},n.prototype.getConversationList=function(t,e,r,i,o){if(t===void 0&&(t=300),o===void 0&&(o=""),e===Y.ULTRA_GROUP){var s=R.METHOD_NOT_SUPPORT;return Promise.resolve({code:s,msg:R[s]})}return this._engine.getConversationList(t,e,r,i,o)},n.prototype.getConversation=function(t,e,r){return this._engine.getConversation(t,e,r)},n.prototype.removeConversation=function(t,e,r){return r===void 0&&(r=""),t===Y.ULTRA_GROUP?Promise.resolve(R.METHOD_NOT_SUPPORT):this._engine.removeConversation(t,e,r)},n.prototype.getUltraGroupList=function(){return this._engine.getUltraGroupList()},n.prototype.getBlockUltraGroupList=function(){return this._engine.getBlockUltraGroupList()},n.prototype.getTopUltraGroupList=function(){return this._engine.getTopUltraGroupList()},n.prototype.clearUnreadCount=function(t,e,r){return r===void 0&&(r=""),t===Y.ULTRA_GROUP?this._engine.clearUltraUnreadcount(e,r):this._engine.clearConversationUnreadCount(t,e,r)},n.prototype.clearAllUnreadCount=function(){return this._engine.clearAllUnreadCount()},n.prototype.getUnreadCount=function(t,e,r){return r===void 0&&(r=""),this._engine.getConversationUnreadCount(t,e,r)},n.prototype.getTotalUnreadCount=function(t,e,r){if(e&&e.includes(Y.ULTRA_GROUP)){var i=R.METHOD_NOT_SUPPORT;return Promise.resolve({code:i,msg:R[i]})}return this._engine.getAllConversationUnreadCount(t,e&&e.length>0?e:[Y.PRIVATE,Y.GROUP,Y.SYSTEM,Y.PUBLIC_SERVICE],!!r)},n.prototype.getFirstUnreadMessage=function(t,e,r){return r===void 0&&(r=""),this._engine.getFirstUnreadMessage(t,e,r)},n.prototype.setConversationNotificationLevel=function(t,e,r,i){return i===void 0&&(i=""),V(this,void 0,void 0,function(){var o;return B(this,function(s){return o=[{conversationType:t,targetId:e,notificationLevel:r,channelId:i}],[2,this._engine.batchSetConversationStatus(o)]})})},n.prototype.setConversationStatus=function(t,e,r,i,o){if(o===void 0&&(o=""),t===Y.ULTRA_GROUP&&r!==void 0)return Promise.resolve(R.METHOD_NOT_SUPPORT);var s=[{conversationType:t,targetId:e,isTop:r,notificationStatus:i,channelId:o}];return this._engine.batchSetConversationStatus(s)},n.prototype.saveConversationMessageDraft=function(t,e,r,i){return i===void 0&&(i=""),this._engine.saveConversationMessageDraft(t,e,r,i)},n.prototype.getConversationMessageDraft=function(t,e,r){return r===void 0&&(r=""),this._engine.getConversationMessageDraft(t,e,r)},n.prototype.clearConversationMessageDraft=function(t,e,r){return r===void 0&&(r=""),this._engine.clearConversationMessageDraft(t,e,r)},n.prototype.recallMessage=function(t,e,r,i,o){return this._engine.recallMsg(t,e,r,i,o)},n.prototype.deleteRemoteMessage=function(t,e,r,i){return i===void 0&&(i=""),t===Y.ULTRA_GROUP?Promise.resolve(R.METHOD_NOT_SUPPORT):this._engine.deleteRemoteMessage(t,e,r,i)},n.prototype.deleteRemoteMessageByTimestamp=function(t,e,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessageByTimestamp(t,e,r,i)},n.prototype.joinChatroom=function(t,e){return e===void 0&&(e=10),this._engine.joinChatroom(t,e)},n.prototype.joinExistChatroom=function(t,e){return e===void 0&&(e=10),this._engine.joinExistChatroom(t,e)},n.prototype.quitChatroom=function(t){return this._engine.quitChatroom(t)},n.prototype.getChatroomInfo=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=0),this._engine.getChatroomInfo(t,e,r)},n.prototype.setChatroomEntry=function(t,e){var r=e.key,i=e.value;return Fe(r)&&gi(i)?this._engine.setChatroomEntry(t,e):Promise.resolve(R.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.setChatroomEntries=function(t,e){for(var r=0;r1e3?[2,Promise.reject(R.CONVER_OUT_LIMIT_ERROR)]:[2,this._engine.addTagForConversations(t,e)]})})},n.prototype.removeTagForConversations=function(t,e){return V(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.removeTagForConversations(t,e)]})})},n.prototype.removeTagsForConversation=function(t,e){return V(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.removeTagsForConversation(t,e)]})})},n.prototype.getConversationListByTag=function(t,e,r,i){return V(this,void 0,void 0,function(){return B(this,function(o){return[2,this._engine.getConversationListByTag(t,e,r,i)]})})},n.prototype.getUnreadCountByTag=function(t,e){return V(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.getUnreadCountByTag(t,e)]})})},n.prototype.setConversationStatusInTag=function(t,e,r){return V(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setConversationStatusInTag(t,e,r)]})})},n.prototype.getTagsForConversation=function(t){return V(this,void 0,void 0,function(){return B(this,function(e){return[2,this._engine.getTagsForConversation(t)]})})},n.prototype.getBlockConversationList=function(){return this._engine.getBlockConversationList()},n.prototype.getTopConversationList=function(){return this._engine.getTopConversationList()},n.prototype.getUnreadMentionedCount=function(t){return this._engine.getUnreadMentionedCount(t)},n.prototype.getAllUnreadMentionedCount=function(){return this._engine.getAllUnreadMentionedCount()},n.prototype.sendUltraGroupTypingStatus=function(t){if(t.conversationType!==Y.ULTRA_GROUP){var e=R.METHOD_ONLY_SUPPORT_ULTRA_GROUP;return Promise.resolve({code:e,msg:R[e]})}return this._engine.sendUltraGroupTypingStatus(t)},n.prototype.getUltraGroupMessageListByMessageUId=function(t){return this._engine.getUltraGroupMessageListByMessageUId(t)},n.prototype.expandUltraMessage=function(t){return V(this,void 0,void 0,function(){var e,r,i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return e=t.conversationType,r=t.expansion,i=t.canIncludeExpansion,e!==Y.ULTRA_GROUP?[2,{code:o=R.METHOD_ONLY_SUPPORT_ULTRA_GROUP,msg:R[o]}]:i?(s=fi(r),c=s.isIllgalEx,d=s.isExKeyOrValLengthExceedLimit,s.isExceedLimit||d?[2,{code:R.EXPANSION_LIMIT_EXCEET}]:c?[2,{code:R.BIZ_ERROR_INVALID_PARAMETER}]:[4,this._engine.expandUltraMessage(t)]):[2,{code:R.MESSAGE_KV_NOT_SUPPORT}];case 1:return[2,{code:l.sent().code}]}})})},n.prototype.modifyMessage=function(t){return V(this,void 0,void 0,function(){var e;return B(this,function(r){switch(r.label){case 0:return t.conversationType!==Y.ULTRA_GROUP?[2,{code:e=R.METHOD_ONLY_SUPPORT_ULTRA_GROUP,msg:R[e]}]:[4,this._engine.modifyMessage(t)];case 1:return[2,{code:r.sent().code}]}})})},n.prototype.getUltraGroupUnreadMentionedCountByTargetId=function(t){return this._engine.getUltraGroupUnreadMentionedCountByTargetId(t)},n.prototype.getUltraGroupUnreadCountByTargetId=function(t){return this._engine.getUltraGroupUnreadCountByTargetId(t)},n.prototype.getAllUltraGroupUnreadCount=function(t){return t===void 0&&(t=!1),this._engine.getAllUltraGroupUnreadCount(t)},n.prototype.getAllConversationState=function(){return this._engine.getAllConversationState()},n.prototype.callExtra=function(t){for(var e,r=[],i=1;i0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]"+e),[4,ee.imClient.context.joinChatroom(n,t.count)];case 1:return(r=i.sent())!==R.SUCCESS?(Ie.warn("join chatroom fail ->code+:"+cn[r]+","+e),[2,{code:r,msg:cn[r]}]):[2,{code:r}]}})})}var Pc=function(n,t,e,r){e===void 0&&(e=!0),r===void 0&&(r=!0),this.messageType=n,this.content=t,this.isPersited=e,this.isCounted=r};function Qt(n,t,e){return t===void 0&&(t=!0),e===void 0&&(e=!0),function(r){return new Pc(n,r,t,e)}}var Lc,eo,Dl=Qt("RC:ImgMsg"),kl=Qt("RC:HQVCMsg"),xl=Qt("RC:SightMsg"),Vl=Qt("RC:TxtMsg"),Bl=Qt("RC:CombineMsg"),Fl=Qt("RC:FileMsg");Qt("RC:GIFMsg");Qt("RC:VcMsg");Qt("RC:LBSMsg");Qt("RC:ReferenceMsg");Qt("RC:ImgTextMsg");var qe={qiniu:function(n,t,e,r){var i,o="https://"+t.uploadHost.qiniu;i=or()+Tt[0][1]||o,Tt.shift();var s=new XMLHttpRequest;s.upload&&t.support_options&&(s.upload.onprogress=function(c){e.onProgress(c.loaded,c.total)}),s.onreadystatechange=function(){if(s.readyState===4){var c=JSON.parse(s.responseText||"{}");c.filename=t.uniqueValue,c.uploadMethod=Kt?Kt.QINIU:"",s.status===200?e.onCompleted(c):Tt.length?qe[Tt[0][0]](n,t,e,r):e.onError("upload fail")}},t.isChunk&&(i=function(c,d){var l="";return Sa(d,function(h,a){h!=="token"&&(l+=(l?"&":"")+encodeURIComponent(h)+"="+encodeURIComponent(a))}),l&&(c+=(c.indexOf("?")>0?"&":"?")+l),c}(i+="/mkblk/"+n.size,t.multi_parmas)),s.open(t.method,i,!0),e.onOpen(s),t.stream&&s.setRequestHeader("authorization","UpToken "+t.multi_parmas.token),Sa(t.headers,function(c,d){s.setRequestHeader(c,d)}),s.send(n)},baidu:function(n,t,e,r){if(r.size>Ia)throw new Error("the file size is over 5GB!");var i=t||{};t=t||eo;var o=new XMLHttpRequest,s=or();if(!(!i.uploadHost.bos&&!i.bosUploadPath)){var c=s+Tt[0][1]+i.bosUploadPath;Tt.shift();var d=i.bosHeader||{},l={filename:t.uniqueValue||r.uniqueName,name:r.name,downloadUrl:c,isBosRes:!0};o.upload&&t.support_options&&(o.upload.onprogress=function(h){e.onProgress(h.loaded,h.total,!0)}),o.onreadystatechange=function(){o.readyState===4&&(JSON.parse(o.responseText||"{}").filename=t.uniqueValue,o.status===200?e.onCompleted(l,!0):Tt.length?qe[Tt[0][0]](n,t,e,r):e.onError("upload fail"))},o.open(t.method,c,!0),o.setRequestHeader("authorization",d.bosToken),o.setRequestHeader("x-bce-date",d.bosDate),o.send(r)}},aliyun:function(n,t,e,r){if(r.size>Ia)throw new Error("the file size is over 5GB!");var i=new FormData;i.set("file",n.get("file")),i.set("key",n.get("key")),i.set("token",n.get("token"));var o=Tt[0][1];Tt.shift(),n=n||Lc,t=(t=t||{})||eo;var s=new XMLHttpRequest,c=or()+t.ossBucketName+"."+o;s.upload&&t.support_options&&(s.upload.onprogress=function(l){e.onProgress(l.loaded,l.total)}),s.onreadystatechange=function(){if(s.readyState===4){var l=JSON.parse(s.responseText||"{}");l.name=t.uniqueValue,l.filename=t.uploadFileName,l.uploadMethod=Kt?Kt.ALI:"",s.status===200?e.onCompleted(l):Tt.length?qe[Tt[0][0]](i,t,e,r):e.onError("upload fail")}},s.open(t.method,c,!0),console.log("ali:url",c);var d=t.aliHeader||{};n.set("OSSAccessKeyId",d.osskeyId),n.set("policy",d.ossPolicy),n.set("Signature",d.ossSign),n.set("success_action_status",200),n.delete("key"),n.append("key",t.uploadFileName),n.delete("file"),n.append("file",r),s.send(n)},s3:function(n,t,e,r){var i=new FormData,o=new XMLHttpRequest,s=or(),c=t.contentDisposition,d=Tt[0][1],l=s+t.s3BucketName+"."+d;console.log("uploadS3:url",l),Tt.shift(),o.upload&&t.support_options&&(o.upload.onprogress=function(u){e.onProgress(u.loaded,u.total)}),o.onreadystatechange=function(){if(o.readyState===4){var u=JSON.parse(o.responseText||"{}");if(u.name=t.uniqueValue,u.filename=t.uploadFileName,u.uploadMethod=Kt.AWS,o.status===200||o.status===204)e.onCompleted(u);else if(Tt.length){var p=new FormData;p.set("file",n.get("file")),p.set("key",n.get("key")),p.set("token",n.get("token")),qe[Tt[0][0]](p,t,e,r)}else e.onError("upload fail")}},o.open(t.method,l,!0);var h=t?t.s3Header:{},a=r&&r.type;c?i.set("Content-Disposition",c+";"):i.set("Content-Disposition",a==="text/html"?"inline;":"attachment;"),i.set("Content-Type",a),i.set("x-amz-credential",h.s3Credential),i.set("x-amz-algorithm",h.s3Algorithm),i.set("x-amz-date",h.s3Date),i.set("policy",h.s3Policy),i.set("x-amz-signature",h.s3Signature),i.set("key",t.uploadFileName),i.set("file",r),o.send(i)},stc:function(n,t,e,r){var i=new XMLHttpRequest,o=t.contentDisposition,s="https://"+Tt[0][1]+"/"+t.stcBucketName+"/"+t.uploadFileName;Tt.shift(),i.upload&&t.support_options&&(i.upload.onprogress=function(d){e.onProgress(d.loaded,d.total)}),i.onreadystatechange=function(){if(i.readyState===4){var d=JSON.parse(i.responseText||"{}");if(d.name=t.uniqueValue,d.filename=t.uploadFileName,d.uploadMethod=Kt?Kt.STC:"",i.status===200||i.status===204)e.onCompleted(d);else if(Tt.length){var l=new FormData;l.set("file",n.get("file")),l.set("key",n.get("key")),l.set("token",n.get("token")),qe[Tt[0][0]](l,t,e,r)}else e.onError("upload fail")}},i.open("PUT",s,!0);var c=t?t.stcHeader:{};i.setRequestHeader("Content-Type",r.type),o?i.setRequestHeader("Content-Disposition",o+";"):i.setRequestHeader("Content-Disposition",r.type==="text/html"?"inline;":"attachment;"),i.setRequestHeader("Authorization",c.stcAuthorization),i.setRequestHeader("x-amz-content-sha256",c.stcContentSha256),i.setRequestHeader("x-amz-date",c.stcDate),i.send(r)}},Tt=[],Ia=5368709120;function Sa(n,t){for(var e in n)t(e,n[e])}function or(){var n="https://";return location.protocol!=="http:"&&location.protocol!=="file:"||(n="http://"),n}function Hl(n,t,e){var r,i,o=n&&n.type||"text/plain",s=o.indexOf("image")>-1?1:4,c=t.contentDisposition,d=Math.ceil(n.size/t.stc_chunk_size),l=t&&JSON.parse(t.ossConfig?t.ossConfig:"");Array.isArray(l)||(l=[]);var h=l.find(function(_){return Object.keys(_).includes("stc")}),a="uploads";ee.imClient.context.getFileToken(s,r,"POST",a).then(function(_){r=_.fileName,i="https://"+h.stc+"/"+t.stcBucketName+"/"+r,console.log("uploadStcMultipart:url",i);var v=new XMLHttpRequest;v.open("POST",i+"?"+a,!0),c?v.setRequestHeader("Content-Disposition",c+";"):v.setRequestHeader("Content-Disposition",n.type==="text/html"?"inline;":"attachment;"),v.setRequestHeader("Authorization",_&&_.stcAuthorization),v.setRequestHeader("x-amz-content-sha256",_&&_.stcContentSha256),v.setRequestHeader("x-amz-date",_&&_.stcDate),v.setRequestHeader("Content-Type",o),v.send(),v.onreadystatechange=function(){if(v.readyState===4){var T=v.response.match(/(?:)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",T),v.status===200||v.status===204?function(y){for(var w=[],L=1;L<=d;L++)w.push(m(y,L));f(y,w)}(Array.isArray(T)&&T[1]):e.onError("uploadStcMultipart:did not get uploadId")}}},function(_){e.onError("uploadStcMultipart:"+_)});var u=[],p=new Map;function f(_,v){v&&Array.isArray(v)&&v.length!==0&&Promise.all(v).then(function(){var T="uploadId="+_;if(p.size===d)ee.imClient.context.getFileToken(s,r,"POST",T).then(function(C){console.log("onSuccess",C),console.log("onSuccess:uploadId",_);var A=new XMLHttpRequest;A.open("POST",i+"?"+T,!0),A.setRequestHeader("Authorization",C&&C.stcAuthorization),A.setRequestHeader("x-amz-content-sha256",C&&C.stcContentSha256),A.setRequestHeader("x-amz-date",C&&C.stcDate),A.setRequestHeader("Content-Type",o);var F="",G=Array.from(p.keys()||[]).sort(function(E,S){return E-S});console.log("keys",G),G.forEach(function(E){F+="".concat(p.get(E),"").concat(E,"")}),F+="",A.send(F),console.log("xml",F),A.onreadystatechange=function(){if(A.readyState===4)if(A.status===200||A.status===204){var E={name:n.name,filename:t.uploadFileName,uploadMethod:Kt.STC};e.onCompleted(E)}else e.onError("uploadStcMultipart:upload does not end")}},function(C){e.onError("uploadStcMultipart:"+C)});else{for(var y=[],w=0,L=u;w=4194304)Hl(i,o,s);else{var f=o.data(i,o);qe[Tt[0][0]](f,o,s,i)}})(t,this.options,{onProgress:function(i,o,s){sr=i,s?sr=Ri+i/o*(o-Ri):Ri=sr,e.onProgress(sr,o)},onCompleted:function(i){e.onCompleted(i)},onError:function(i){e.onError(i)},onOpen:function(i){r.xhr=i}})}else e.onError("upload file is null.")},n.prototype.cancel=function(){this.xhr&&this.xhr.abort()},n}(),Ii,ar,Oa={init:function(n){return new $l(n)},dataType:Uc,resize:function(n,t,e){n.type;var r=document.createElement("canvas"),i=new FileReader;i.readAsDataURL(n),i.onload=function(o){var s=o.target.result,c=new Image;c.src=s;var d=c.width,l=c.height,h=function(u,p){var f=1,m=u.width,_=p.maxWidth||0;_>0&&m>_&&(f=_/m);var v=u.height,T=p.maxHeight||0;if(T>0&&v>T){var y=T/v;f=Math.min(f,y)}var w=p.maxSize||0,L=Math.ceil(u.size/1e3);if(L>w){var M=w/L;f=Math.min(f,M)}return f}({width:d,height:l,size:o.total},t),a=s;h<1&&(a=function(u,p,f){return r.width=p,r.height=f,r.getContext("2d").drawImage(u,0,0,p,f),r.toDataURL("image/jpg")}(c,d*h,l*h)),e(a)}}},Gl=function(n,t,e){var r=document.createElement("canvas"),i=r.getContext("2d"),o=new Image,s=typeof n=="string";o.onload=function(c){var d=function(h,a,u){var p,f,m,_=hu.scale?(_?(f=100,T=((m=a/(p=h/100))-u.maxHeight)/2):(m=100,v=((f=h/(p=a/100))-u.maxWidth)/2),{w:f,h:m,x:-v,y:-T}):(_?(p=a/u.maxHeight,m=u.maxHeight,f=h/p):(p=h/u.maxWidth,f=u.maxWidth,m=a/p),{w:f,h:m,x:-v,y:-T})}(o.width,o.height,t);r.width=d.w>t.maxWidth?t.maxWidth:d.w,r.height=d.h>t.maxHeight?t.maxHeight:d.h,i.drawImage(o,d.x,d.y,d.w,d.h);var l=r.toDataURL(typeof n=="string"?"image/jpg":n.type,t.quality);l=l.replace(/data:image\/[^;]+;base64,/,""),e(l)},o.src=s?"data:image/jpg;base64,"+n:function(c){var d=window.URL||window.webkitURL;return d?d.createObjectURL(c):""}(n)},Kl=function(n,t){var e=n.file,r=n.compress;Gl(e,r,t)},Dc=function(n,t){if(n.getToken)n.getToken(function(r,i){i=i||{},n.multi_parmas||(n.multi_parmas={}),n.multi_parmas.token=r,n.uploadHost||(n.uploadHost={}),n.uploadHost.bos=i.bos,n.ossConfig=i.ossConfig,n.bosHeader||(n.bosHeader={}),n.bosHeader.bosDate=i.bosDate,n.bosHeader.bosToken=i.bosToken,n.bosUploadPath=i.path,n.aliHeader={},n.aliHeader.osskeyId=i.osskeyId,n.aliHeader.ossPolicy=i.ossPolicy,n.aliHeader.ossSign=i.ossSign,n.ossBucketName=i.ossBucketName,n.uploadFileName=i.fileName,n.s3Header={},n.s3Header.s3Credential=i.s3Credential,n.s3Header.s3Algorithm=i.s3Algorithm,n.s3Header.s3Date=i.s3Date,n.s3Header.s3Policy=i.s3Policy,n.s3Header.s3Signature=i.s3Signature,n.s3BucketName=i.s3BucketName,n.stcHeader={},n.stcHeader.stcAuthorization=i.stcAuthorization,n.stcHeader.stcContentSha256=i.stcContentSha256,n.stcHeader.stcDate=i.stcDate,n.stcBucketName=i.stcBucketName,n.headers||(n.headers={}),n.base64&&(n.headers["Content-type"]="application/octet-stream",n.headers.Authorization="UpToken "+r),console.log("data",i);var o=Oa.init(n);t(o)});else{n.headers||(n.headers={}),n.base64&&(n.headers["Content-type"]="application/octet-stream");var e=Oa.init(n);t(e)}},kc=function(n,t,e){t.upload(n.file,{onError:function(r){e.onError(r)},onProgress:function(r,i){e.onProgress(r,i)},onCompleted:function(r){r.filename||(r.filename=r.hash);var i=n.compressThumbnail||Kl;n.compress?i(n,function(o){r.thumbnail=o,e.onCompleted(r)}):e.onCompleted(r)}})},jl=function(){function n(t){this.instance=t}return n.prototype.upload=function(t,e){kc({file:t},this.instance,e)},n.prototype.cancel=function(){this.instance.cancel()},n}(),ql=function(){function n(t,e){this.instance=t,this.cfg=e}return n.prototype.upload=function(t,e){var r={file:t,compress:this.cfg};kc(r,this.instance,e)},n.prototype.cancel=function(){this.instance.cancel()},n}(),Yl=function(n,t){Dc(n,function(e){var r,i,o,s,c={maxHeight:((r=n.thumbnailConfig)===null||r===void 0?void 0:r.maxHeight)||160,maxWidth:((i=n.thumbnailConfig)===null||i===void 0?void 0:i.maxWidth)||160,quality:((o=n.thumbnailConfig)===null||o===void 0?void 0:o.quality)||.5,scale:((s=n.thumbnailConfig)===null||s===void 0?void 0:s.scale)||2.4},d=new ql(e,c);t(d)})},zl=function(n,t){Dc(n,function(e){var r=new jl(e);t(r)})},Jl=Yl;function Na(n){return Ii=Ii||new AudioContext,new Promise(function(t,e){Ii.decodeAudioData(n,function(r){t({duration:r.duration,length:r.length})},e)})}function Wl(n,t,e,r,i){return dt("fileType",n,fd,!0),dt("filename",t,ut.STRING),dt("saveName",e,ut.STRING),dt("serverType",i,ut.NUMBER),new Promise(function(o){ee.imClient.context.getFileUrl(n,t,e,r,i).then(function(s){o({code:R.SUCCESS,data:s})}).catch(function(s){o({code:s})})})}function xc(n,t,e){return sn(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u;return an(this,function(p){switch(p.label){case 0:return e=e||{},t instanceof Pc?(dt("conversation",n,ut.OBJECT,!0),r=n.conversationType,i=n.targetId,o=n.channelId,dt("conversation.targetId",i,ut.STRING,!0),dt("conversation.conversationType",r,ut.NUMBER),dt("conversation.channelId",o,ut.CHANNEL_ID),dt("options.isStatusMessage",e==null?void 0:e.isStatusMessage,ut.BOOLEAN),dt("options.disableNotification",e==null?void 0:e.disableNotification,ut.BOOLEAN),dt("options.pushContent",e==null?void 0:e.pushContent,ut.STRING),dt("options.pushData",e==null?void 0:e.pushData,ut.STRING),dt("options.isMentioned",e==null?void 0:e.isMentioned,ut.BOOLEAN),dt("options.mentionedType",e==null?void 0:e.mentionedType,ut.NUMBER),dt("options.mentionedUserIdList",e==null?void 0:e.mentionedUserIdList,ut.ARRAY),dt("options.directionalUserIdList",e==null?void 0:e.directionalUserIdList,ut.ARRAY),dt("options.isVoipPush",e==null?void 0:e.isVoipPush,ut.BOOLEAN),dt("options.canIncludeExpansion",e==null?void 0:e.canIncludeExpansion,ut.BOOLEAN),dt("options.expansion",e==null?void 0:e.expansion,ut.OBJECT),dt("options.pushConfig",e==null?void 0:e.pushConfig,ut.OBJECT),s="conversationType:"+r+",targetId:"+i,Ie.debug("send message ->"+s),(c=Object.assign(e,t)).channelId=o||"",[4,ee.imClient.context.sendMessage(r,i,c)]):(Ie.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,Dr.ILLGAL_PARAMS]);case 1:return d=p.sent(),l=d.code,h=d.data,l===R.SUCCESS?(a=An(h),[2,{code:l,data:a}]):(Ie.warn("send message fail ->"+l+":"+cn[l]+","+s),u={isMentioned:!!e.isMentioned,content:t.content,messageType:t.messageType,isPersited:t.isPersited||!1,isCounted:t.isCounted||!1,disableNotification:!!(e==null?void 0:e.disableNotification),canIncludeExpansion:!!(e==null?void 0:e.canIncludeExpansion),expansion:(e==null?void 0:e.expansion)||null,conversationType:n.conversationType,targetId:n.targetId,channelId:n.channelId,senderUserId:ee.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:zt.SEND,sentTime:(h==null?void 0:h.sentTime)||0,receivedTime:0,isStatusMessage:e.isStatusMessage||!1,receivedStatus:Un.UNREAD,isOffLineMessage:!1},r!==Y.ULTRA_GROUP&&(u.isOffLineMessage=!1),[2,{code:l,msg:cn[l],data:An(u)}])}})})}function jn(n,t){return function(e,r,i,o){dt("sendOptions.contentDisposition",o==null?void 0:o.contentDisposition,function(d){return["inline","attachment"].includes(d)});var s={contentDisposition:o==null?void 0:o.contentDisposition};if(o&&"thumbnailConfig"in o){var c=o==null?void 0:o.thumbnailConfig;dt("sendOptions.maxHeight",c==null?void 0:c.maxHeight,ut.NUMBER),dt("sendOptions.maxWidth",c==null?void 0:c.maxWidth,ut.NUMBER),dt("sendOptions.quality",c==null?void 0:c.quality,ut.NUMBER),dt("sendOptions.scale",c==null?void 0:c.scale,ut.NUMBER),s.thumbnailConfig=c}return new Promise(function(d){(function(l,h,a,u){var p,f=this;if(h===void 0&&(h=wt.FILE),p=h===wt.IMAGE?wt.IMAGE:wt.FILE,!ar){ar="upload.qiniup.com";var m=ee.imClient.context.getInfoFromCache();if(m&&m.ossConfig)try{var _=JSON.parse(m.ossConfig).find(function(T){return T.qiniu!==void 0});_&&(ar=_.qiniu)}catch{}}var v=to({domain:ar,getToken:function(T){ee.imClient.context.getFileToken(p).then(function(y){T(y.token,y)}).catch(function(y){a.onFail(y)})}},u);(p===wt.IMAGE?Jl:zl)(v,function(T){T.upload(l,{onProgress:function(y,w){var L,M=Math.floor(y/w*100);(L=a.onProgress)===null||L===void 0||L.call(a,M)},onCompleted:function(y){return sn(f,void 0,void 0,function(){var w=this;return an(this,function(L){return Wl(p,y.filename,y.name,y,y.uploadMethod).then(function(M){return sn(w,void 0,void 0,function(){var C,A;return an(this,function(F){return M.code!==0?(a.onFail(M),[2]):((C=M.data).type=l.type,C.name=y.name||y.filename,h===wt.AUDIO?(typeof l.arrayBuffer=="function"?l.arrayBuffer().then(Na).then(function(G){Object.assign(C,G),a.onSuccess(C)},function(){a.onSuccess(C)}):((A=new FileReader).onload=function(){A.result?Na(A.result).then(function(G){Object.assign(C,G),a.onSuccess(C)},function(){a.onSuccess(C)}):a.onSuccess(C)},A.onerror=function(){C.duration=0,a.onSuccess(C)},A.readAsArrayBuffer(l)),[2]):(p===wt.IMAGE&&(C.thumbnail=y.thumbnail),a.onSuccess(C),[2]))})})}).catch(function(M){a.onFail(M)}),[2]})})},onError:function(y){a.onFail(y)}})})})(r.file,n,{onProgress:i==null?void 0:i.onProgress,onSuccess:function(l){var h,a=((h=i==null?void 0:i.onComplete)===null||h===void 0?void 0:h.call(i,{url:l.downloadUrl}))||t(l,r);xc(e,a,o).then(d)},onFail:function(l){d({code:R.UPLOAD_FILE_FAILED,msg:l||R[R.UPLOAD_FILE_FAILED]})}},s)})}}jn(wt.FILE,function(n,t){return new Fl({name:n.name,size:t.file.size,type:t.file.type,fileUrl:n.downloadUrl,user:t.user,extra:t.extra})});jn(wt.IMAGE,function(n,t){return new Dl({content:n.thumbnail,imageUri:n.downloadUrl,user:t.user,extra:t.extra})});jn(wt.AUDIO,function(n,t){return new kl({remoteUrl:n.downloadUrl,duration:n.duration,type:n.type,user:t.user,extra:t.extra})});jn(wt.SIGHT,function(n,t){return new xl({sightUrl:n.downloadUrl,content:t.thumbnail,duration:t.duration,size:t.file.size||n.size,name:t.name||n.name,user:t.user,extra:t.extra})});function pe(n,t,e,r,i){return dt("messageType",n,ut.STRING,!0),dt("isPersited",t,ut.BOOLEAN,!0),dt("isCounted",e,ut.BOOLEAN,!0),dt("isStatusMessage",i,ut.BOOLEAN,!1),ee.imClient.context.registerMessageType(n,t,e,r,i),Qt(n,t,e)}jn(wt.COMBINE_HTML,function(n,t){return new Bl({remoteUrl:n.downloadUrl,nameList:t.nameList,summaryList:t.summaryList,conversationType:t.conversationType,user:t.user,extra:t.extra})});Sn.add("imlib-next","5.3.3");/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function j(n,t,e,r){return new(e||(e=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof e?h:new e(function(a){a(h)})).then(s,c)}d((r=r.apply(n,t||[])).next())})}const O=new Le("RCRTC");var P,io;(function(n){n[n.SUCCESS=1e4]="SUCCESS",n[n.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",n[n.PARAMS_ERROR=50001]="PARAMS_ERROR",n[n.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",n[n.NOT_IN_ROOM=50003]="NOT_IN_ROOM",n[n.SERVICE_INVALID=50004]="SERVICE_INVALID",n[n.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",n[n.SIGNAL_ERROR=53001]="SIGNAL_ERROR",n[n.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",n[n.REQUEST_FAILED=53004]="REQUEST_FAILED",n[n.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",n[n.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",n[n.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",n[n.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",n[n.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",n[n.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",n[n.PERMISSION_DENIED=53012]="PERMISSION_DENIED",n[n.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",n[n.INVALID_TAGS=53014]="INVALID_TAGS",n[n.INVALID_USER_ID=53015]="INVALID_USER_ID",n[n.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",n[n.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",n[n.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",n[n.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",n[n.TRACK_NOT_READY=53020]="TRACK_NOT_READY",n[n.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",n[n.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",n[n.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",n[n.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",n[n.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",n[n.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",n[n.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",n[n.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",n[n.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",n[n.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM"})(P||(P={})),function(n){n[n.JOIN_REFUSED=40032]="JOIN_REFUSED"}(io||(io={}));class Vc{constructor(){this.queue=[],this.locked=!1}checkToStart(){return j(this,void 0,void 0,function*(){if(this.queue.length===0||this.locked)return;this.locked=!0;const{resolve:t,task:e,reject:r}=this.queue.shift();let i;try{i=yield e(),t(i)}catch(o){r(o)}this.locked=!1,this.checkToStart()})}push(t){const e=new Promise((r,i)=>{this.queue.push({resolve:r,task:t,reject:i})});return this.checkToStart(),e}}const Zl=new Vc,Ct=n=>Zl.push(n);let Bc=!0,Fc=!0;function yn(n,t,e){const r=n.match(t);return r&&r.length>=e&&parseInt(r[e],10)}function pn(n,t,e){if(!n.RTCPeerConnection)return;const r=n.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(s,c){if(s!==t)return i.apply(this,arguments);const d=l=>{const h=e(l);h&&(c.handleEvent?c.handleEvent(h):c(h))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(c,d),i.apply(this,[s,d])};const o=r.removeEventListener;r.removeEventListener=function(s,c){if(s!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(c))return o.apply(this,arguments);const d=this._eventMap[t].get(c);return this._eventMap[t].delete(c),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[s,d])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(s){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),s&&this.addEventListener(t,this["_on"+t]=s)},enumerable:!0,configurable:!0})}function Ql(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Bc=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function Xl(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Fc=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function Cs(){if(typeof window=="object"){if(Bc)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function ai(n,t){Fc&&console.warn(n+" is deprecated, please use "+t+" instead.")}function ba(n){return Object.prototype.toString.call(n)==="[object Object]"}function Hc(n){return ba(n)?Object.keys(n).reduce(function(t,e){const r=ba(n[e]),i=r?Hc(n[e]):n[e],o=r&&!Object.keys(i).length;return i===void 0||o?t:Object.assign(t,{[e]:i})},{}):n}function oo(n,t,e){t&&!e.has(t.id)&&(e.set(t.id,t),Object.keys(t).forEach(r=>{r.endsWith("Id")?oo(n,n.get(t[r]),e):r.endsWith("Ids")&&t[r].forEach(i=>{oo(n,n.get(i),e)})}))}function Ma(n,t,e){const r=e?"outbound-rtp":"inbound-rtp",i=new Map;if(t===null)return i;const o=[];return n.forEach(s=>{s.type==="track"&&s.trackIdentifier===t.id&&o.push(s)}),o.forEach(s=>{n.forEach(c=>{c.type===r&&c.trackId===s.id&&oo(n,c,i)})}),i}const Aa=Cs;function $c(n,t){const e=n&&n.navigator;if(!e.mediaDevices)return;const r=function(s){if(typeof s!="object"||s.mandatory||s.optional)return s;const c={};return Object.keys(s).forEach(d=>{if(d==="require"||d==="advanced"||d==="mediaSource")return;const l=typeof s[d]=="object"?s[d]:{ideal:s[d]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(a,u){return a?a+u.charAt(0).toUpperCase()+u.slice(1):u==="deviceId"?"sourceId":u};if(l.ideal!==void 0){c.optional=c.optional||[];let a={};typeof l.ideal=="number"?(a[h("min",d)]=l.ideal,c.optional.push(a),a={},a[h("max",d)]=l.ideal,c.optional.push(a)):(a[h("",d)]=l.ideal,c.optional.push(a))}l.exact!==void 0&&typeof l.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",d)]=l.exact):["min","max"].forEach(a=>{l[a]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(a,d)]=l[a])})}),s.advanced&&(c.optional=(c.optional||[]).concat(s.advanced)),c},i=function(s,c){if(t.version>=61)return c(s);if((s=JSON.parse(JSON.stringify(s)))&&typeof s.audio=="object"){const d=function(l,h,a){h in l&&!(a in l)&&(l[a]=l[h],delete l[h])};d((s=JSON.parse(JSON.stringify(s))).audio,"autoGainControl","googAutoGainControl"),d(s.audio,"noiseSuppression","googNoiseSuppression"),s.audio=r(s.audio)}if(s&&typeof s.video=="object"){let d=s.video.facingMode;d=d&&(typeof d=="object"?d:{ideal:d});const l=t.version<66;if(d&&(d.exact==="user"||d.exact==="environment"||d.ideal==="user"||d.ideal==="environment")&&(!e.mediaDevices.getSupportedConstraints||!e.mediaDevices.getSupportedConstraints().facingMode||l)){let h;if(delete s.video.facingMode,d.exact==="environment"||d.ideal==="environment"?h=["back","rear"]:d.exact!=="user"&&d.ideal!=="user"||(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(a=>{let u=(a=a.filter(p=>p.kind==="videoinput")).find(p=>h.some(f=>p.label.toLowerCase().includes(f)));return!u&&a.length&&h.includes("back")&&(u=a[a.length-1]),u&&(s.video.deviceId=d.exact?{exact:u.deviceId}:{ideal:u.deviceId}),s.video=r(s.video),Aa("chrome: "+JSON.stringify(s)),c(s)})}s.video=r(s.video)}return Aa("chrome: "+JSON.stringify(s)),c(s)},o=function(s){return t.version>=64?s:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[s.name]||s.name,message:s.message,constraint:s.constraint||s.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(e.getUserMedia=function(s,c,d){i(s,l=>{e.webkitGetUserMedia(l,c,h=>{d&&d(o(h))})})}.bind(e),e.mediaDevices.getUserMedia){const s=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(c){return i(c,d=>s(d).then(l=>{if(d.audio&&!l.getAudioTracks().length||d.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(o(l))))}}}function Gc(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function Kc(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=e=>{e.stream.addEventListener("addtrack",r=>{let i;i=n.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.track.id):{track:r.track};const o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[e.stream],this.dispatchEvent(o)}),e.stream.getTracks().forEach(r=>{let i;i=n.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.id):{track:r};const o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[e.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else pn(n,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function jc(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const t=function(i,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=i.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:i}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(s,c){let d=i.apply(this,arguments);return d||(d=t(this,s),this._senders.push(d)),d};const o=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(s){o.apply(this,arguments);const c=this._senders.indexOf(s);c!==-1&&this._senders.splice(c,1)}}const e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],e.apply(this,[i]),i.getTracks().forEach(o=>{this._senders.push(t(this,o))})};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(o=>{const s=this._senders.find(c=>c.track===o);s&&this._senders.splice(this._senders.indexOf(s),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(r=>r._pc=this),e},Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function qc(n){if(!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[e,r,i]=arguments;if(arguments.length>0&&typeof e=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof e!="function"))return t.apply(this,[]);const o=function(c){const d={};return c.result().forEach(l=>{const h={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(a=>{h[a]=l.stat(a)}),d[h.id]=h}),d},s=function(c){return new Map(Object.keys(c).map(d=>[d,c[d]]))};if(arguments.length>=2){const c=function(d){r(s(o(d)))};return t.apply(this,[c,e])}return new Promise((c,d)=>{t.apply(this,[function(l){c(s(o(l)))},d])}).then(r,i)}}function Yc(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(o=>o._pc=this),i});const r=n.RTCPeerConnection.prototype.addTrack;r&&(n.RTCPeerConnection.prototype.addTrack=function(){const i=r.apply(this,arguments);return i._pc=this,i}),n.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(o=>Ma(o,i.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r}),pn(n,"track",r=>(r.receiver._pc=r.srcElement,r)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>Ma(i,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype)||!("getStats"in n.RTCRtpReceiver.prototype))return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const e=arguments[0];let r,i,o;return this.getSenders().forEach(s=>{s.track===e&&(r?o=!0:r=s)}),this.getReceivers().forEach(s=>(s.track===e&&(i?o=!0:i=s),s.track===e)),o||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function zc(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};const t=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(o,s){if(!s)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=t.apply(this,arguments);return this._shimmedLocalStreams[s.id]?this._shimmedLocalStreams[s.id].indexOf(c)===-1&&this._shimmedLocalStreams[s.id].push(c):this._shimmedLocalStreams[s.id]=[s,c],c};const e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(d=>{if(this.getSenders().find(l=>l.track===d))throw new DOMException("Track already exists.","InvalidAccessError")});const s=this.getSenders();e.apply(this,arguments);const c=this.getSenders().filter(d=>s.indexOf(d)===-1);this._shimmedLocalStreams[o.id]=[o].concat(c)};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],r.apply(this,arguments)};const i=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(s=>{const c=this._shimmedLocalStreams[s].indexOf(o);c!==-1&&this._shimmedLocalStreams[s].splice(c,1),this._shimmedLocalStreams[s].length===1&&delete this._shimmedLocalStreams[s]}),i.apply(this,arguments)}}function Jc(n,t){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&t.version>=65)return zc(n);const e=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const l=e.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const r=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(a=>a.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const h=new n.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}r.apply(this,[l])};const i=n.RTCPeerConnection.prototype.removeStream;function o(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const p=l._reverseStreams[u],f=l._streams[p.id];a=a.replace(new RegExp(f.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:a})}function s(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const p=l._reverseStreams[u],f=l._streams[p.id];a=a.replace(new RegExp(p.id,"g"),f.id)}),new RTCSessionDescription({type:h.type,sdp:a})}n.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},n.RTCPeerConnection.prototype.addTrack=function(l,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const a=[].slice.call(arguments,1);if(a.length!==1||!a[0].getTracks().find(f=>f===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(f=>f.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const p=this._streams[h.id];if(p)p.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const f=new n.MediaStream([l]);this._streams[h.id]=f,this._reverseStreams[f.id]=h,this.addStream(f)}return this.getSenders().find(f=>f.track===l)},["createOffer","createAnswer"].forEach(function(l){const h=n.RTCPeerConnection.prototype[l],a={[l](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[p=>{const f=o(this,p);u[0].apply(null,[f])},p=>{u[1]&&u[1].apply(null,p)},arguments[2]]):h.apply(this,arguments).then(p=>o(this,p))}};n.RTCPeerConnection.prototype[l]=a[l]});const c=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=s(this,arguments[0]),c.apply(this,arguments)):c.apply(this,arguments)};const d=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=d.get.apply(this);return l.type===""?l:o(this,l)}}),n.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let h;this._streams=this._streams||{},Object.keys(this._streams).forEach(a=>{this._streams[a].getTracks().find(u=>l.track===u)&&(h=this._streams[a])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function so(n,t){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const r=n.RTCPeerConnection.prototype[e],i={[e](){return arguments[0]=new(e==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};n.RTCPeerConnection.prototype[e]=i[e]})}function Wc(n,t){pn(n,"negotiationneeded",e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return e})}var wa=Object.freeze({__proto__:null,shimMediaStream:Gc,shimOnTrack:Kc,shimGetSendersWithDtmf:jc,shimGetStats:qc,shimSenderReceiverGetStats:Yc,shimAddTrackRemoveTrackWithNative:zc,shimAddTrackRemoveTrack:Jc,shimPeerConnection:so,fixNegotiationNeeded:Wc,shimGetUserMedia:$c,shimGetDisplayMedia:function(n,t){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(typeof t=="function"?n.navigator.mediaDevices.getDisplayMedia=function(e){return t(e).then(r=>{const i=e.video&&e.video.width,o=e.video&&e.video.height,s=e.video&&e.video.frameRate;return e.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:s||3}},i&&(e.video.mandatory.maxWidth=i),o&&(e.video.mandatory.maxHeight=o),n.navigator.mediaDevices.getUserMedia(e)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),Pa,Si,ot=(Pa=function(n){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(` `).map(function(r){return r.trim()})},t.splitSections=function(e){return e.split(` m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r `})},t.getDescription=function(e){var r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter(function(i){return i.indexOf(r)===0})},t.parseCandidate=function(e){for(var r,i={foundation:(r=e.indexOf("a=candidate:")===0?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(r[1],10),protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]},o=8;o0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&e.direction!=="sendrecv"?"/"+e.direction:"")+" "+e.uri+`\r `},t.parseFmtp=function(e){for(var r,i={},o=e.substr(e.indexOf(" ")+1).split(";"),s=0;s-1?(i.attribute=e.substr(r+1,o-r-1),i.value=e.substr(o+1)):i.attribute=e.substr(r+1),i},t.parseSsrcGroup=function(e){var r=e.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},t.getMid=function(e){var r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var r=e.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,r){var i="a=setup:"+r+`\r `;return e.fingerprints.forEach(function(o){i+="a=fingerprint:"+o.algorithm+" "+o.value+`\r `}),i},t.parseCryptoLine=function(e){var r=e.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+(typeof e.keyParams=="object"?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+`\r `},t.parseCryptoKeyParams=function(e){if(e.indexOf("inline:")!==0)return null;var r=e.substr(7).split("|");return{keyMethod:"inline",keySalt:r[0],lifeTime:r[1],mkiValue:r[2]?r[2].split(":")[0]:void 0,mkiLength:r[2]?r[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var i=t.matchPrefix(e+r,"a=ice-ufrag:")[0],o=t.matchPrefix(e+r,"a=ice-pwd:")[0];return i&&o?{usernameFragment:i.substr(12),password:o.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+`\r a=ice-pwd:`+e.password+`\r `},t.parseRtpParameters=function(e){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(e)[0].split(" "),o=3;o0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(s){return s.preferredPayloadType!==void 0?s.preferredPayloadType:s.payloadType}).join(" ")+`\r `,i+=`c=IN IP4 0.0.0.0\r `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r `,r.codecs.forEach(function(s){i+=t.writeRtpMap(s),i+=t.writeFmtp(s),i+=t.writeRtcpFb(s)});var o=0;return r.codecs.forEach(function(s){s.maxptime>o&&(o=s.maxptime)}),o>0&&(i+="a=maxptime:"+o+`\r `),i+=`a=rtcp-mux\r `,r.headerExtensions&&r.headerExtensions.forEach(function(s){i+=t.writeExtmap(s)}),i},t.parseRtpEncodingParameters=function(e){var r,i=[],o=t.parseRtpParameters(e),s=o.fecMechanisms.indexOf("RED")!==-1,c=o.fecMechanisms.indexOf("ULPFEC")!==-1,d=t.matchPrefix(e,"a=ssrc:").map(function(u){return t.parseSsrcMedia(u)}).filter(function(u){return u.attribute==="cname"}),l=d.length>0&&d[0].ssrc,h=t.matchPrefix(e,"a=ssrc-group:FID").map(function(u){return u.substr(17).split(" ").map(function(p){return parseInt(p,10)})});h.length>0&&h[0].length>1&&h[0][0]===l&&(r=h[0][1]),o.codecs.forEach(function(u){if(u.name.toUpperCase()==="RTX"&&u.parameters.apt){var p={ssrc:l,codecPayloadType:parseInt(u.parameters.apt,10)};l&&r&&(p.rtx={ssrc:r}),i.push(p),s&&((p=JSON.parse(JSON.stringify(p))).fec={ssrc:l,mechanism:c?"red+ulpfec":"red"},i.push(p))}}),i.length===0&&l&&i.push({ssrc:l});var a=t.matchPrefix(e,"b=");return a.length&&(a=a[0].indexOf("b=TIAS:")===0?parseInt(a[0].substr(7),10):a[0].indexOf("b=AS:")===0?1e3*parseInt(a[0].substr(5),10)*.95-16e3:void 0,i.forEach(function(u){u.maxBitrate=a})),i},t.parseRtcpParameters=function(e){var r={},i=t.matchPrefix(e,"a=ssrc:").map(function(c){return t.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var o=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=o.length>0,r.compound=o.length===0;var s=t.matchPrefix(e,"a=rtcp-mux");return r.mux=s.length>0,r},t.parseMsid=function(e){var r,i=t.matchPrefix(e,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var o=t.matchPrefix(e,"a=ssrc:").map(function(s){return t.parseSsrcMedia(s)}).filter(function(s){return s.attribute==="msid"});return o.length>0?{stream:(r=o[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,i=t.parseMLine(e),o=t.matchPrefix(e,"a=max-message-size:");o.length>0&&(r=parseInt(o[0].substr(19),10)),isNaN(r)&&(r=65536);var s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(t.matchPrefix(e,"a=sctpmap:").length>0){var c=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,r){var i=[];return i=e.protocol!=="DTLS/SCTP"?["m="+e.kind+" 9 "+e.protocol+" "+r.protocol+`\r `,`c=IN IP4 0.0.0.0\r `,"a=sctp-port:"+r.port+`\r `]:["m="+e.kind+" 9 "+e.protocol+" "+r.port+`\r `,`c=IN IP4 0.0.0.0\r `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r `),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,i){var o=r!==void 0?r:2;return`v=0\r o=`+(i||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+o+` IN IP4 127.0.0.1\r s=-\r t=0 0\r `},t.writeMediaSection=function(e,r,i,o){var s=t.writeRtpDescription(e.kind,r);if(s+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),s+="a=mid:"+e.mid+`\r `,e.direction?s+="a="+e.direction+`\r `:e.rtpSender&&e.rtpReceiver?s+=`a=sendrecv\r `:e.rtpSender?s+=`a=sendonly\r `:e.rtpReceiver?s+=`a=recvonly\r `:s+=`a=inactive\r `,e.rtpSender){var c="msid:"+o.id+" "+e.rtpSender.track.id+`\r `;s+="a="+c,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+`\r `)}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+`\r `,e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+`\r `),s},t.getDirection=function(e,r){for(var i=t.splitLines(e),o=0;o=14393&&_.indexOf("?transport=udp")===-1:(u=!0,!0)}),delete p.url,p.urls=m?f[0]:f,!!f.length}})}(s.iceServers||[],t),this._iceGatherers=[],s.iceCandidatePoolSize)for(var l=s.iceCandidatePoolSize;l>0;l--)this._iceGatherers.push(new n.RTCIceGatherer({iceServers:s.iceServers,gatherPolicy:s.iceTransportPolicy}));else s.iceCandidatePoolSize=0;this._config=s,this.transceivers=[],this._sdpSessionId=ot.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(s,c){this._isClosed||(this.dispatchEvent(c),typeof this["on"+s]=="function"&&this["on"+s](c))},i.prototype._emitGatheringStateChange=function(){var s=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",s)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(s,c){var d=this.transceivers.length>0,l={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:s,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&d)l.iceTransport=this.transceivers[0].iceTransport,l.dtlsTransport=this.transceivers[0].dtlsTransport;else{var h=this._createIceAndDtlsTransports();l.iceTransport=h.iceTransport,l.dtlsTransport=h.dtlsTransport}return c||this.transceivers.push(l),l},i.prototype.addTrack=function(s,c){if(this._isClosed)throw Pt("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d;if(this.transceivers.find(function(h){return h.track===s}))throw Pt("InvalidAccessError","Track already exists.");for(var l=0;l=15025)s.getTracks().forEach(function(l){c.addTrack(l,s)});else{var d=s.clone();s.getTracks().forEach(function(l,h){var a=d.getTracks()[h];l.addEventListener("enabled",function(u){a.enabled=u.enabled})}),d.getTracks().forEach(function(l){c.addTrack(l,d)})}},i.prototype.removeTrack=function(s){if(this._isClosed)throw Pt("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(s instanceof n.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var c=this.transceivers.find(function(l){return l.rtpSender===s});if(!c)throw Pt("InvalidAccessError","Sender was not created by this connection.");var d=c.stream;c.rtpSender.stop(),c.rtpSender=null,c.track=null,c.stream=null,this.transceivers.map(function(l){return l.stream}).indexOf(d)===-1&&this.localStreams.indexOf(d)>-1&&this.localStreams.splice(this.localStreams.indexOf(d),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(s){var c=this;s.getTracks().forEach(function(d){var l=c.getSenders().find(function(h){return h.track===d});l&&c.removeTrack(l)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(s){return!!s.rtpSender}).map(function(s){return s.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(s){return!!s.rtpReceiver}).map(function(s){return s.rtpReceiver})},i.prototype._createIceGatherer=function(s,c){var d=this;if(c&&s>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var l=new n.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(l,"state",{value:"new",writable:!0}),this.transceivers[s].bufferedCandidateEvents=[],this.transceivers[s].bufferCandidates=function(h){var a=!h.candidate||Object.keys(h.candidate).length===0;l.state=a?"completed":"gathering",d.transceivers[s].bufferedCandidateEvents!==null&&d.transceivers[s].bufferedCandidateEvents.push(h)},l.addEventListener("localcandidate",this.transceivers[s].bufferCandidates),l},i.prototype._gather=function(s,c){var d=this,l=this.transceivers[c].iceGatherer;if(!l.onlocalcandidate){var h=this.transceivers[c].bufferedCandidateEvents;this.transceivers[c].bufferedCandidateEvents=null,l.removeEventListener("localcandidate",this.transceivers[c].bufferCandidates),l.onlocalcandidate=function(a){if(!(d.usingBundle&&c>0)){var u=new Event("icecandidate");u.candidate={sdpMid:s,sdpMLineIndex:c};var p=a.candidate,f=!p||Object.keys(p).length===0;if(f)l.state!=="new"&&l.state!=="gathering"||(l.state="completed");else{l.state==="new"&&(l.state="gathering"),p.component=1,p.ufrag=l.getLocalParameters().usernameFragment;var m=ot.writeCandidate(p);u.candidate=Object.assign(u.candidate,ot.parseCandidate(m)),u.candidate.candidate=m,u.candidate.toJSON=function(){return{candidate:u.candidate.candidate,sdpMid:u.candidate.sdpMid,sdpMLineIndex:u.candidate.sdpMLineIndex,usernameFragment:u.candidate.usernameFragment}}}var _=ot.getMediaSections(d._localDescription.sdp);_[u.candidate.sdpMLineIndex]+=f?`a=end-of-candidates\r `:"a="+u.candidate.candidate+`\r `,d._localDescription.sdp=ot.getDescription(d._localDescription.sdp)+_.join("");var v=d.transceivers.every(function(T){return T.iceGatherer&&T.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),f||d._dispatchEvent("icecandidate",u),v&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},n.setTimeout(function(){h.forEach(function(a){l.onlocalcandidate(a)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var s=this,c=new n.RTCIceTransport(null);c.onicestatechange=function(){s._updateIceConnectionState(),s._updateConnectionState()};var d=new n.RTCDtlsTransport(c);return d.ondtlsstatechange=function(){s._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),s._updateConnectionState()},{iceTransport:c,dtlsTransport:d}},i.prototype._disposeIceAndDtlsTransports=function(s){var c=this.transceivers[s].iceGatherer;c&&(delete c.onlocalcandidate,delete this.transceivers[s].iceGatherer);var d=this.transceivers[s].iceTransport;d&&(delete d.onicestatechange,delete this.transceivers[s].iceTransport);var l=this.transceivers[s].dtlsTransport;l&&(delete l.ondtlsstatechange,delete l.onerror,delete this.transceivers[s].dtlsTransport)},i.prototype._transceive=function(s,c,d){var l=cr(s.localCapabilities,s.remoteCapabilities);c&&s.rtpSender&&(l.encodings=s.sendEncodingParameters,l.rtcp={cname:ot.localCName,compound:s.rtcpParameters.compound},s.recvEncodingParameters.length&&(l.rtcp.ssrc=s.recvEncodingParameters[0].ssrc),s.rtpSender.send(l)),d&&s.rtpReceiver&&l.codecs.length>0&&(s.kind==="video"&&s.recvEncodingParameters&&t<15019&&s.recvEncodingParameters.forEach(function(h){delete h.rtx}),s.recvEncodingParameters.length?l.encodings=s.recvEncodingParameters:l.encodings=[{}],l.rtcp={compound:s.rtcpParameters.compound},s.rtcpParameters.cname&&(l.rtcp.cname=s.rtcpParameters.cname),s.sendEncodingParameters.length&&(l.rtcp.ssrc=s.sendEncodingParameters[0].ssrc),s.rtpReceiver.receive(l))},i.prototype.setLocalDescription=function(s){var c,d,l=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(Pt("TypeError",'Unsupported type "'+s.type+'"'));if(!Ua("setLocalDescription",s.type,l.signalingState)||l._isClosed)return Promise.reject(Pt("InvalidStateError","Can not set local "+s.type+" in state "+l.signalingState));if(s.type==="offer")c=ot.splitSections(s.sdp),d=c.shift(),c.forEach(function(a,u){var p=ot.parseRtpParameters(a);l.transceivers[u].localCapabilities=p}),l.transceivers.forEach(function(a,u){l._gather(a.mid,u)});else if(s.type==="answer"){c=ot.splitSections(l._remoteDescription.sdp),d=c.shift();var h=ot.matchPrefix(d,"a=ice-lite").length>0;c.forEach(function(a,u){var p=l.transceivers[u],f=p.iceGatherer,m=p.iceTransport,_=p.dtlsTransport,v=p.localCapabilities,T=p.remoteCapabilities;if(!(ot.isRejected(a)&&ot.matchPrefix(a,"a=bundle-only").length===0)&&!p.rejected){var y=ot.getIceParameters(a,d),w=ot.getDtlsParameters(a,d);h&&(w.role="server"),l.usingBundle&&u!==0||(l._gather(p.mid,u),m.state==="new"&&m.start(f,y,h?"controlling":"controlled"),_.state==="new"&&_.start(w));var L=cr(v,T);l._transceive(p,L.codecs.length>0,!1)}})}return l._localDescription={type:s.type,sdp:s.sdp},s.type==="offer"?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(s){var c=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(Pt("TypeError",'Unsupported type "'+s.type+'"'));if(!Ua("setRemoteDescription",s.type,c.signalingState)||c._isClosed)return Promise.reject(Pt("InvalidStateError","Can not set remote "+s.type+" in state "+c.signalingState));var d={};c.remoteStreams.forEach(function(m){d[m.id]=m});var l=[],h=ot.splitSections(s.sdp),a=h.shift(),u=ot.matchPrefix(a,"a=ice-lite").length>0,p=ot.matchPrefix(a,"a=group:BUNDLE ").length>0;c.usingBundle=p;var f=ot.matchPrefix(a,"a=ice-options:")[0];return c.canTrickleIceCandidates=!!f&&f.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(m,_){var v=ot.splitLines(m),T=ot.getKind(m),y=ot.isRejected(m)&&ot.matchPrefix(m,"a=bundle-only").length===0,w=v[0].substr(2).split(" ")[2],L=ot.getDirection(m,a),M=ot.parseMsid(m),C=ot.getMid(m)||ot.generateIdentifier();if(y||T==="application"&&(w==="DTLS/SCTP"||w==="UDP/DTLS/SCTP"))c.transceivers[_]={mid:C,kind:T,protocol:w,rejected:!0};else{var A,F,G,E,S,I,N,b,k;!y&&c.transceivers[_]&&c.transceivers[_].rejected&&(c.transceivers[_]=c._createTransceiver(T,!0));var U,$,q=ot.parseRtpParameters(m);y||(U=ot.getIceParameters(m,a),($=ot.getDtlsParameters(m,a)).role="client"),N=ot.parseRtpEncodingParameters(m);var X=ot.parseRtcpParameters(m),nt=ot.matchPrefix(m,"a=end-of-candidates",a).length>0,at=ot.matchPrefix(m,"a=candidate:").map(function(D){return ot.parseCandidate(D)}).filter(function(D){return D.component===1});if((s.type==="offer"||s.type==="answer")&&!y&&p&&_>0&&c.transceivers[_]&&(c._disposeIceAndDtlsTransports(_),c.transceivers[_].iceGatherer=c.transceivers[0].iceGatherer,c.transceivers[_].iceTransport=c.transceivers[0].iceTransport,c.transceivers[_].dtlsTransport=c.transceivers[0].dtlsTransport,c.transceivers[_].rtpSender&&c.transceivers[_].rtpSender.setTransport(c.transceivers[0].dtlsTransport),c.transceivers[_].rtpReceiver&&c.transceivers[_].rtpReceiver.setTransport(c.transceivers[0].dtlsTransport)),s.type!=="offer"||y)s.type==="answer"&&!y&&(F=(A=c.transceivers[_]).iceGatherer,G=A.iceTransport,E=A.dtlsTransport,S=A.rtpReceiver,I=A.sendEncodingParameters,b=A.localCapabilities,c.transceivers[_].recvEncodingParameters=N,c.transceivers[_].remoteCapabilities=q,c.transceivers[_].rtcpParameters=X,at.length&&G.state==="new"&&(!u&&!nt||p&&_!==0?at.forEach(function(D){Oi(A.iceTransport,D)}):G.setRemoteCandidates(at)),p&&_!==0||(G.state==="new"&&G.start(F,U,"controlling"),E.state==="new"&&E.start($)),!cr(A.localCapabilities,A.remoteCapabilities).codecs.filter(function(D){return D.name.toLowerCase()==="rtx"}).length&&A.sendEncodingParameters[0].rtx&&delete A.sendEncodingParameters[0].rtx,c._transceive(A,L==="sendrecv"||L==="recvonly",L==="sendrecv"||L==="sendonly"),!S||L!=="sendrecv"&&L!=="sendonly"?delete A.rtpReceiver:(k=S.track,M?(d[M.stream]||(d[M.stream]=new n.MediaStream),e(k,d[M.stream]),l.push([k,S,d[M.stream]])):(d.default||(d.default=new n.MediaStream),e(k,d.default),l.push([k,S,d.default]))));else{(A=c.transceivers[_]||c._createTransceiver(T)).mid=C,A.iceGatherer||(A.iceGatherer=c._createIceGatherer(_,p)),at.length&&A.iceTransport.state==="new"&&(!nt||p&&_!==0?at.forEach(function(D){Oi(A.iceTransport,D)}):A.iceTransport.setRemoteCandidates(at)),b=n.RTCRtpReceiver.getCapabilities(T),t<15019&&(b.codecs=b.codecs.filter(function(D){return D.name!=="rtx"})),I=A.sendEncodingParameters||[{ssrc:1001*(2*_+2)}];var et,rt=!1;L==="sendrecv"||L==="sendonly"?(rt=!A.rtpReceiver,S=A.rtpReceiver||new n.RTCRtpReceiver(A.dtlsTransport,T),rt&&(k=S.track,M&&M.stream==="-"||(M?(d[M.stream]||(d[M.stream]=new n.MediaStream,Object.defineProperty(d[M.stream],"id",{get:function(){return M.stream}})),Object.defineProperty(k,"id",{get:function(){return M.track}}),et=d[M.stream]):(d.default||(d.default=new n.MediaStream),et=d.default)),et&&(e(k,et),A.associatedRemoteMediaStreams.push(et)),l.push([k,S,et]))):A.rtpReceiver&&A.rtpReceiver.track&&(A.associatedRemoteMediaStreams.forEach(function(D){var J=D.getTracks().find(function(W){return W.id===A.rtpReceiver.track.id});J&&function(W,it){it.removeTrack(W),it.dispatchEvent(new n.MediaStreamTrackEvent("removetrack",{track:W}))}(J,D)}),A.associatedRemoteMediaStreams=[]),A.localCapabilities=b,A.remoteCapabilities=q,A.rtpReceiver=S,A.rtcpParameters=X,A.sendEncodingParameters=I,A.recvEncodingParameters=N,c._transceive(c.transceivers[_],!1,rt)}}}),c._dtlsRole===void 0&&(c._dtlsRole=s.type==="offer"?"active":"passive"),c._remoteDescription={type:s.type,sdp:s.sdp},s.type==="offer"?c._updateSignalingState("have-remote-offer"):c._updateSignalingState("stable"),Object.keys(d).forEach(function(m){var _=d[m];if(_.getTracks().length){if(c.remoteStreams.indexOf(_)===-1){c.remoteStreams.push(_);var v=new Event("addstream");v.stream=_,n.setTimeout(function(){c._dispatchEvent("addstream",v)})}l.forEach(function(T){var y=T[0],w=T[1];_.id===T[2].id&&r(c,y,w,[_])})}}),l.forEach(function(m){m[2]||r(c,m[0],m[1],[])}),n.setTimeout(function(){c&&c.transceivers&&c.transceivers.forEach(function(m){m.iceTransport&&m.iceTransport.state==="new"&&m.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),m.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(s){s.iceTransport&&s.iceTransport.stop(),s.dtlsTransport&&s.dtlsTransport.stop(),s.rtpSender&&s.rtpSender.stop(),s.rtpReceiver&&s.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(s){this.signalingState=s;var c=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",c)},i.prototype._maybeFireNegotiationNeeded=function(){var s=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,n.setTimeout(function(){if(s.needNegotiation){s.needNegotiation=!1;var c=new Event("negotiationneeded");s._dispatchEvent("negotiationneeded",c)}},0))},i.prototype._updateIceConnectionState=function(){var s,c={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&!l.rejected&&c[l.iceTransport.state]++}),s="new",c.failed>0?s="failed":c.checking>0?s="checking":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0?s="connected":c.completed>0&&(s="completed"),s!==this.iceConnectionState){this.iceConnectionState=s;var d=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",d)}},i.prototype._updateConnectionState=function(){var s,c={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&l.dtlsTransport&&!l.rejected&&(c[l.iceTransport.state]++,c[l.dtlsTransport.state]++)}),c.connected+=c.completed,s="new",c.failed>0?s="failed":c.connecting>0?s="connecting":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0&&(s="connected"),s!==this.connectionState){this.connectionState=s;var d=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",d)}},i.prototype.createOffer=function(){var s=this;if(s._isClosed)return Promise.reject(Pt("InvalidStateError","Can not call createOffer after close"));var c=s.transceivers.filter(function(u){return u.kind==="audio"}).length,d=s.transceivers.filter(function(u){return u.kind==="video"}).length,l=arguments[0];if(l){if(l.mandatory||l.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");l.offerToReceiveAudio!==void 0&&(c=l.offerToReceiveAudio===!0?1:l.offerToReceiveAudio===!1?0:l.offerToReceiveAudio),l.offerToReceiveVideo!==void 0&&(d=l.offerToReceiveVideo===!0?1:l.offerToReceiveVideo===!1?0:l.offerToReceiveVideo)}for(s.transceivers.forEach(function(u){u.kind==="audio"?--c<0&&(u.wantReceive=!1):u.kind==="video"&&--d<0&&(u.wantReceive=!1)});c>0||d>0;)c>0&&(s._createTransceiver("audio"),c--),d>0&&(s._createTransceiver("video"),d--);var h=ot.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.transceivers.forEach(function(u,p){var f=u.track,m=u.kind,_=u.mid||ot.generateIdentifier();u.mid=_,u.iceGatherer||(u.iceGatherer=s._createIceGatherer(p,s.usingBundle));var v=n.RTCRtpSender.getCapabilities(m);t<15019&&(v.codecs=v.codecs.filter(function(y){return y.name!=="rtx"})),v.codecs.forEach(function(y){y.name==="H264"&&y.parameters["level-asymmetry-allowed"]===void 0&&(y.parameters["level-asymmetry-allowed"]="1"),u.remoteCapabilities&&u.remoteCapabilities.codecs&&u.remoteCapabilities.codecs.forEach(function(w){y.name.toLowerCase()===w.name.toLowerCase()&&y.clockRate===w.clockRate&&(y.preferredPayloadType=w.payloadType)})}),v.headerExtensions.forEach(function(y){(u.remoteCapabilities&&u.remoteCapabilities.headerExtensions||[]).forEach(function(w){y.uri===w.uri&&(y.id=w.id)})});var T=u.sendEncodingParameters||[{ssrc:1001*(2*p+1)}];f&&t>=15019&&m==="video"&&!T[0].rtx&&(T[0].rtx={ssrc:T[0].ssrc+1}),u.wantReceive&&(u.rtpReceiver=new n.RTCRtpReceiver(u.dtlsTransport,m)),u.localCapabilities=v,u.sendEncodingParameters=T}),s._config.bundlePolicy!=="max-compat"&&(h+="a=group:BUNDLE "+s.transceivers.map(function(u){return u.mid}).join(" ")+`\r `),h+=`a=ice-options:trickle\r `,s.transceivers.forEach(function(u,p){h+=La(u,u.localCapabilities,"offer",u.stream,s._dtlsRole),h+=`a=rtcp-rsize\r `,!u.iceGatherer||s.iceGatheringState==="new"||p!==0&&s.usingBundle||(u.iceGatherer.getLocalCandidates().forEach(function(f){f.component=1,h+="a="+ot.writeCandidate(f)+`\r `}),u.iceGatherer.state==="completed"&&(h+=`a=end-of-candidates\r `))});var a=new n.RTCSessionDescription({type:"offer",sdp:h});return Promise.resolve(a)},i.prototype.createAnswer=function(){var s=this;if(s._isClosed)return Promise.reject(Pt("InvalidStateError","Can not call createAnswer after close"));if(s.signalingState!=="have-remote-offer"&&s.signalingState!=="have-local-pranswer")return Promise.reject(Pt("InvalidStateError","Can not call createAnswer in signalingState "+s.signalingState));var c=ot.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.usingBundle&&(c+="a=group:BUNDLE "+s.transceivers.map(function(h){return h.mid}).join(" ")+`\r `),c+=`a=ice-options:trickle\r `;var d=ot.getMediaSections(s._remoteDescription.sdp).length;s.transceivers.forEach(function(h,a){if(!(a+1>d)){if(h.rejected)return h.kind==="application"?h.protocol==="DTLS/SCTP"?c+=`m=application 0 DTLS/SCTP 5000\r `:c+="m=application 0 "+h.protocol+` webrtc-datachannel\r `:h.kind==="audio"?c+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r a=rtpmap:0 PCMU/8000\r `:h.kind==="video"&&(c+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r a=rtpmap:120 VP8/90000\r `),void(c+=`c=IN IP4 0.0.0.0\r a=inactive\r a=mid:`+h.mid+`\r `);var u;h.stream&&(h.kind==="audio"?u=h.stream.getAudioTracks()[0]:h.kind==="video"&&(u=h.stream.getVideoTracks()[0]),u&&t>=15019&&h.kind==="video"&&!h.sendEncodingParameters[0].rtx&&(h.sendEncodingParameters[0].rtx={ssrc:h.sendEncodingParameters[0].ssrc+1}));var p=cr(h.localCapabilities,h.remoteCapabilities);!p.codecs.filter(function(f){return f.name.toLowerCase()==="rtx"}).length&&h.sendEncodingParameters[0].rtx&&delete h.sendEncodingParameters[0].rtx,c+=La(h,p,"answer",h.stream,s._dtlsRole),h.rtcpParameters&&h.rtcpParameters.reducedSize&&(c+=`a=rtcp-rsize\r `)}});var l=new n.RTCSessionDescription({type:"answer",sdp:c});return Promise.resolve(l)},i.prototype.addIceCandidate=function(s){var c,d=this;return s&&s.sdpMLineIndex===void 0&&!s.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(l,h){if(!d._remoteDescription)return h(Pt("InvalidStateError","Can not add ICE candidate without a remote description"));if(s&&s.candidate!==""){var a=s.sdpMLineIndex;if(s.sdpMid){for(var u=0;u0?ot.parseCandidate(s.candidate):{};if(f.protocol==="tcp"&&(f.port===0||f.port===9)||f.component&&f.component!==1)return l();if((a===0||a>0&&p.iceTransport!==d.transceivers[0].iceTransport)&&!Oi(p.iceTransport,f))return h(Pt("OperationError","Can not add ICE candidate"));var m=s.candidate.trim();m.indexOf("a=")===0&&(m=m.substr(2)),(c=ot.getMediaSections(d._remoteDescription.sdp))[a]+="a="+(f.type?m:"end-of-candidates")+`\r `,d._remoteDescription.sdp=ot.getDescription(d._remoteDescription.sdp)+c.join("")}else for(var _=0;_Promise.reject(function(o){return{name:{PermissionDeniedError:"NotAllowedError"}[o.name]||o.name,message:o.message,constraint:o.constraint,toString(){return this.name}}}(i)))}}function Qc(n){"getDisplayMedia"in n.navigator&&n.navigator.mediaDevices&&(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||(n.navigator.mediaDevices.getDisplayMedia=n.navigator.getDisplayMedia.bind(n.navigator)))}function ao(n,t){if(n.RTCIceGatherer&&(n.RTCIceCandidate||(n.RTCIceCandidate=function(r){return r}),n.RTCSessionDescription||(n.RTCSessionDescription=function(r){return r}),t.version<15025)){const r=Object.getOwnPropertyDescriptor(n.MediaStreamTrack.prototype,"enabled");Object.defineProperty(n.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);const o=new Event("enabled");o.enabled=i,this.dispatchEvent(o)}})}n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)&&Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new n.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),n.RTCDtmfSender&&!n.RTCDTMFSender&&(n.RTCDTMFSender=n.RTCDtmfSender);const e=th(n,t.version);n.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,o){let s=!1;return(i=JSON.parse(JSON.stringify(i))).filter(c=>{if(c&&(c.urls||c.url)){let d=c.urls||c.url;c.url&&!c.urls&&ai("RTCIceServer.url","RTCIceServer.urls");const l=typeof d=="string";return l&&(d=[d]),d=d.filter(h=>{if(h.indexOf("stun:")===0)return!1;const a=h.startsWith("turn")&&!h.startsWith("turn:[")&&h.includes("transport=udp");return a&&!s?(s=!0,!0):a&&!s}),delete c.url,c.urls=l?d[0]:d,!!d.length}})}(r.iceServers,t.version),Cs("ICE servers after filtering:",r.iceServers)),new e(r)},n.RTCPeerConnection.prototype=e.prototype}function Xc(n){n.RTCRtpSender&&!("replaceTrack"in n.RTCRtpSender.prototype)&&(n.RTCRtpSender.prototype.replaceTrack=n.RTCRtpSender.prototype.setTrack)}var Da=Object.freeze({__proto__:null,shimPeerConnection:ao,shimReplaceTrack:Xc,shimGetUserMedia:Zc,shimGetDisplayMedia:Qc});function tu(n,t){const e=n&&n.navigator,r=n&&n.MediaStreamTrack;if(e.getUserMedia=function(i,o,s){ai("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),e.mediaDevices.getUserMedia(i).then(o,s)},!(t.version>55&&"autoGainControl"in e.mediaDevices.getSupportedConstraints())){const i=function(s,c,d){c in s&&!(d in s)&&(s[d]=s[c],delete s[c])},o=e.mediaDevices.getUserMedia.bind(e.mediaDevices);if(e.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s.audio,"autoGainControl","mozAutoGainControl"),i(s.audio,"noiseSuppression","mozNoiseSuppression")),o(s)},r&&r.prototype.getSettings){const s=r.prototype.getSettings;r.prototype.getSettings=function(){const c=s.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(r&&r.prototype.applyConstraints){const s=r.prototype.applyConstraints;r.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[c])}}}}function eu(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function co(n,t){if(typeof n!="object"||!n.RTCPeerConnection&&!n.mozRTCPeerConnection)return;!n.RTCPeerConnection&&n.mozRTCPeerConnection&&(n.RTCPeerConnection=n.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const o=n.RTCPeerConnection.prototype[i],s={[i](){return arguments[0]=new(i==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};n.RTCPeerConnection.prototype[i]=s[i]});const e={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[i,o,s]=arguments;return r.apply(this,[i||null]).then(c=>{if(t.version<53&&!o)try{c.forEach(d=>{d.type=e[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;c.forEach((l,h)=>{c.set(h,Object.assign({},l,{type:e[l.type]||l.type}))})}return c}).then(o,s)}}function nu(n){if(typeof n!="object"||!n.RTCPeerConnection||!n.RTCRtpSender||n.RTCRtpSender&&"getStats"in n.RTCRtpSender.prototype)return;const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const r=t.apply(this,[]);return r.forEach(i=>i._pc=this),r});const e=n.RTCPeerConnection.prototype.addTrack;e&&(n.RTCPeerConnection.prototype.addTrack=function(){const r=e.apply(this,arguments);return r._pc=this,r}),n.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function ru(n){if(typeof n!="object"||!n.RTCPeerConnection||!n.RTCRtpSender||n.RTCRtpSender&&"getStats"in n.RTCRtpReceiver.prototype)return;const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(r=>r._pc=this),e}),pn(n,"track",e=>(e.receiver._pc=e.srcElement,e)),n.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function iu(n){n.RTCPeerConnection&&!("removeStream"in n.RTCPeerConnection.prototype)&&(n.RTCPeerConnection.prototype.removeStream=function(t){ai("removeStream","removeTrack"),this.getSenders().forEach(e=>{e.track&&t.getTracks().includes(e.track)&&this.removeTrack(e)})})}function ou(n){n.DataChannel&&!n.RTCDataChannel&&(n.RTCDataChannel=n.DataChannel)}function su(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype.addTransceiver;t&&(n.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=t.apply(this,arguments);if(r){const{sender:o}=i,s=o.getParameters();(!("encodings"in s)||s.encodings.length===1&&Object.keys(s.encodings[0]).length===0)&&(s.encodings=e.sendEncodings,o.sendEncodings=e.sendEncodings,this.setParametersPromises.push(o.setParameters(s).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return i})}function au(n){if(typeof n!="object"||!n.RTCRtpSender)return;const t=n.RTCRtpSender.prototype.getParameters;t&&(n.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function cu(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function uu(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype.createAnswer;n.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}var ka=Object.freeze({__proto__:null,shimOnTrack:eu,shimPeerConnection:co,shimSenderGetStats:nu,shimReceiverGetStats:ru,shimRemoveStream:iu,shimRTCDataChannel:ou,shimAddTransceiver:su,shimGetParameters:au,shimCreateOffer:cu,shimCreateAnswer:uu,shimGetUserMedia:tu,shimGetDisplayMedia:function(n,t){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(n.navigator.mediaDevices.getDisplayMedia=function(e){if(!e||!e.video){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return e.video===!0?e.video={mediaSource:t}:e.video.mediaSource=t,n.navigator.mediaDevices.getUserMedia(e)})}});function du(n){if(typeof n=="object"&&n.RTCPeerConnection){if("getLocalStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in n.RTCPeerConnection.prototype)){const t=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e))},n.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),t.apply(this,arguments)}}"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const e=this._localStreams.indexOf(t);if(e===-1)return;this._localStreams.splice(e,1);const r=t.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function lu(n){if(typeof n=="object"&&n.RTCPeerConnection&&("getRemoteStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in n.RTCPeerConnection.prototype))){Object.defineProperty(n.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,this.dispatchEvent(o)})})}});const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(i)>=0)return;e._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,e.dispatchEvent(o)})}),t.apply(e,arguments)}}}function hu(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype,e=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=e.apply(this,[h]);return l?(a.then(d,l),Promise.resolve()):a},t.createAnswer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=r.apply(this,[h]);return l?(a.then(d,l),Promise.resolve()):a};let c=function(d,l,h){const a=i.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a};t.setLocalDescription=c,c=function(d,l,h){const a=o.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},t.setRemoteDescription=c,c=function(d,l,h){const a=s.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},t.addIceCandidate=c}function pu(n){const t=n&&n.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=i=>r(fu(i))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,i){t.mediaDevices.getUserMedia(e).then(r,i)}.bind(t))}function fu(n){return n&&n.video!==void 0?Object.assign({},n,{video:Hc(n.video)}):n}function gu(n){if(!n.RTCPeerConnection)return;const t=n.RTCPeerConnection;n.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const i=[];for(let o=0;ot.generateCertificate})}function mu(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function _u(n){const t=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(e){if(e){e.offerToReceiveAudio!==void 0&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const r=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");e.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):e.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),e.offerToReceiveVideo!==void 0&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find(o=>o.receiver.track.kind==="video");e.offerToReceiveVideo===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):e.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return t.apply(this,arguments)}}function vu(n){typeof n!="object"||n.AudioContext||(n.AudioContext=n.webkitAudioContext)}var xa=Object.freeze({__proto__:null,shimLocalStreamsAPI:du,shimRemoteStreamsAPI:lu,shimCallbacksAPI:hu,shimGetUserMedia:pu,shimConstraints:fu,shimRTCIceServerUrls:gu,shimTrackEventTransceiver:mu,shimCreateOfferLegacy:_u,shimAudioContext:vu});function mr(n){if(!n.RTCIceCandidate||n.RTCIceCandidate&&"foundation"in n.RTCIceCandidate.prototype)return;const t=n.RTCIceCandidate;n.RTCIceCandidate=function(e){if(typeof e=="object"&&e.candidate&&e.candidate.indexOf("a=")===0&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),i=ot.parseCandidate(e.candidate),o=Object.assign(r,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},n.RTCIceCandidate.prototype=t.prototype,pn(n,"icecandidate",e=>(e.candidate&&Object.defineProperty(e,"candidate",{value:new n.RTCIceCandidate(e.candidate),writable:"false"}),e))}function Cn(n,t){if(!n.RTCPeerConnection)return;"sctp"in n.RTCPeerConnection.prototype||Object.defineProperty(n.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});const e=function(c){if(!c||!c.sdp)return!1;const d=ot.splitSections(c.sdp);return d.shift(),d.some(l=>{const h=ot.parseMLine(l);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},r=function(c){const d=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(d===null||d.length<2)return-1;const l=parseInt(d[1],10);return l!=l?-1:l},i=function(c){let d=65536;return t.browser==="firefox"&&(d=t.version<57?c===-1?16384:2147483637:t.version<60?t.version===57?65535:65536:2147483637),d},o=function(c,d){let l=65536;t.browser==="firefox"&&t.version===57&&(l=65535);const h=ot.matchPrefix(c.sdp,"a=max-message-size:");return h.length>0?l=parseInt(h[0].substr(19),10):t.browser==="firefox"&&d!==-1&&(l=2147483637),l},s=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser==="chrome"&&t.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(e(arguments[0])){const c=r(arguments[0]),d=i(c),l=o(arguments[0],c);let h;h=d===0&&l===0?Number.POSITIVE_INFINITY:d===0||l===0?Math.max(d,l):Math.min(d,l);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>h}),this._sctp=a}return s.apply(this,arguments)}}function Rn(n){if(!n.RTCPeerConnection||!("createDataChannel"in n.RTCPeerConnection.prototype))return;function t(r,i){const o=r.send;r.send=function(){const s=arguments[0],c=s.length||s.size||s.byteLength;if(r.readyState==="open"&&i.sctp&&c>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return o.apply(r,arguments)}}const e=n.RTCPeerConnection.prototype.createDataChannel;n.RTCPeerConnection.prototype.createDataChannel=function(){const r=e.apply(this,arguments);return t(r,this),r},pn(n,"datachannel",r=>(t(r.channel,r.target),r))}function uo(n){if(!n.RTCPeerConnection||"connectionState"in n.RTCPeerConnection.prototype)return;const t=n.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const o=i.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;const s=new Event("connectionstatechange",i);o.dispatchEvent(s)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function lo(n,t){if(!n.RTCPeerConnection||t.browser==="chrome"&&t.version>=71||t.browser==="safari"&&t.version>=605)return;const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(` a=extmap-allow-mixed`)!==-1){const i=r.sdp.split(` `).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(` `);n.RTCSessionDescription&&r instanceof n.RTCSessionDescription?arguments[0]=new n.RTCSessionDescription({type:r.type,sdp:i}):r.sdp=i}return e.apply(this,arguments)}}function _r(n,t){if(!n.RTCPeerConnection||!n.RTCPeerConnection.prototype)return;const e=n.RTCPeerConnection.prototype.addIceCandidate;e&&e.length!==0&&(n.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(t.browser==="chrome"&&t.version<78||t.browser==="firefox"&&t.version<68||t.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():e.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var eh=Object.freeze({__proto__:null,shimRTCIceCandidate:mr,shimMaxMessageSize:Cn,shimSendThrowTypeError:Rn,shimConnectionState:uo,removeExtmapAllowMixed:lo,shimAddIceCandidateNullOrEmpty:_r});const nh=function({window:n}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const e=Cs,r=function(o){const s={browser:null,version:null};if(o===void 0||!o.navigator)return s.browser="Not a browser.",s;const{navigator:c}=o;if(c.mozGetUserMedia)s.browser="firefox",s.version=yn(c.userAgent,/Firefox\/(\d+)\./,1);else if(c.webkitGetUserMedia||o.isSecureContext===!1&&o.webkitRTCPeerConnection&&!o.RTCIceGatherer)s.browser="chrome",s.version=yn(c.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(c.mediaDevices&&c.userAgent.match(/Edge\/(\d+).(\d+)$/))s.browser="edge",s.version=yn(c.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!o.RTCPeerConnection||!c.userAgent.match(/AppleWebKit\/(\d+)\./))return s.browser="Not a supported browser.",s;s.browser="safari",s.version=yn(c.userAgent,/AppleWebKit\/(\d+)\./,1),s.supportsUnifiedPlan=o.RTCRtpTransceiver&&"currentDirection"in o.RTCRtpTransceiver.prototype}return s}(n),i={browserDetails:r,commonShim:eh,extractVersion:yn,disableLog:Ql,disableWarnings:Xl};switch(r.browser){case"chrome":if(!wa||!so||!t.shimChrome)return e("Chrome shim is not included in this adapter release."),i;if(r.version===null)return e("Chrome shim can not determine version, not shimming."),i;e("adapter.js shimming chrome."),i.browserShim=wa,_r(n,r),$c(n,r),Gc(n),so(n,r),Kc(n),Jc(n,r),jc(n),qc(n),Yc(n),Wc(n,r),mr(n),uo(n),Cn(n,r),Rn(n),lo(n,r);break;case"firefox":if(!ka||!co||!t.shimFirefox)return e("Firefox shim is not included in this adapter release."),i;e("adapter.js shimming firefox."),i.browserShim=ka,_r(n,r),tu(n,r),co(n,r),eu(n),iu(n),nu(n),ru(n),ou(n),su(n),au(n),cu(n),uu(n),mr(n),uo(n),Cn(n,r),Rn(n);break;case"edge":if(!Da||!ao||!t.shimEdge)return e("MS edge shim is not included in this adapter release."),i;e("adapter.js shimming edge."),i.browserShim=Da,Zc(n),Qc(n),ao(n,r),Xc(n),Cn(n,r),Rn(n);break;case"safari":if(!xa||!t.shimSafari)return e("Safari shim is not included in this adapter release."),i;e("adapter.js shimming safari."),i.browserShim=xa,_r(n,r),gu(n),_u(n),hu(n),du(n),lu(n),mu(n),pu(n),vu(n),mr(n),Cn(n,r),Rn(n),lo(n,r);break;default:e("Unsupported browser!")}return i}({window:typeof window=="undefined"?void 0:window});var ie,Et,vt;(function(n){n.FPS_10="FPS_10",n.FPS_15="FPS_15",n.FPS_24="FPS_24",n.FPS_30="FPS_30"})(ie||(ie={})),function(n){n.W176_H132="W176_H132",n.W176_H144="W176_H144",n.W256_H144="W256_H144",n.W320_H180="W320_H180",n.W240_H240="W240_H240",n.W320_H240="W320_H240",n.W480_H360="W480_H360",n.W640_H360="W640_H360",n.W480_H480="W480_H480",n.W640_H480="W640_H480",n.W720_H480="W720_H480",n.W1280_H720="W1280_H720",n.W1920_H1080="W1920_H1080"}(Et||(Et={})),function(n){n[n.AUDIO_ONLY=0]="AUDIO_ONLY",n[n.VIDEO_ONLY=1]="VIDEO_ONLY",n[n.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(vt||(vt={}));const ur={[Et.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Et.W176_H144]:{width:176,height:144,maxBitrate:160,minBitrate:80},[Et.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Et.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Et.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Et.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Et.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Et.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Et.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Et.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Et.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Et.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Et.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}},Tu=(n,t)=>{const e=ur[`W${n}_H${t}`];if(e)return e;const r=n*t;return Object.keys(ur).map(i=>ur[i]).sort((i,o)=>i.height*i.width-o.width*o.height).filter(i=>i.height*i.width>=r)[0]||ur.W1920_H1080},Va={10:1,15:1,24:1.5,30:1.5},yu=n=>{let t=Number.MAX_VALUE,e=1;for(const r in Va){const i=Math.abs(n-parseInt(r));ij(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="videoinput")}),getMicrophones:()=>j(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audioinput")}),getSpeakers:()=>j(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audiooutput")})};class Is extends Fn{constructor(t,e,r,i,o){super(),this._tag=t,this._userId=e,this._kind=r,this._isLocalTrack=i,this._roomId=o,this._localMuted=!1,this._remoteMuted=!1,this._streamId=[this._userId||this._roomId,this._tag].join("_"),this._id=[this._streamId,this.isAudioTrack()?0:1].join("_")}getStreamId(){return this._streamId}getTrackId(){return this._id}getUserId(){return this._userId}__innerGetMediaStreamTrack(){return this._msTrack}getTag(){return this._tag}isLocalTrack(){return this._isLocalTrack}isVideoTrack(){return this._kind==="video"}isAudioTrack(){return this._kind==="audio"}isReady(){var t;return((t=this._msTrack)===null||t===void 0?void 0:t.readyState)==="live"}__innerSetMediaStreamTrack(t){this._msTrack=t,this._setLocalMuted(this._localMuted);const e=this._msStream=this._msStream||new MediaStream,r=e.getTracks()[0];r&&e.removeTrack(r),t?e.addTrack(t):this._element&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(t){this._msTrack&&(this._msTrack.enabled=!t),this._localMuted=t}mute(){O.info(`set ${this._id} enabled: false`),this._setLocalMuted(!0)}unmute(){O.info(`set ${this._id} enabled: true`),this._setLocalMuted(!1)}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}play(t,e){return j(this,void 0,void 0,function*(){if(!this._msTrack)return O.warn(`the track is not ready to play -> id: ${this._id}`),{code:P.TRACK_NOT_READY};if(this._msTrack.readyState==="ended"&&O.warn(`the track's readyState is 'ended' -> id: ${this._id}`),e==null?void 0:e.volume){if(!mt(e==null?void 0:e.volume))return O.error(`${e==null?void 0:e.volume} is not a number, the valid range of options.volume is 0-100`),{code:P.PARAMS_ERROR};(e==null?void 0:e.volume)<0&&(e.volume=0,O.warn("the valid range of options.volume is 0-100, the value of volume has been set 0")),(e==null?void 0:e.volume)>100&&(e.volume=100,O.warn("the valid range of options.volume is 0-100, the value of volume has been set 100"))}if((e==null?void 0:e.audioDeviceId)&&!(yield Rs.getSpeakers()).map(i=>i.deviceId).includes(e.audioDeviceId))return O.error(`the options.audioDeviceId is invalid --> ${e.audioDeviceId}`),{code:P.PARAMS_ERROR};const r=this.isVideoTrack();if(r&&(!t||!(t instanceof HTMLVideoElement)))return O.error(`the video track need an