123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927 |
- var Iu=Object.defineProperty,bu=Object.defineProperties;var Ou=Object.getOwnPropertyDescriptors;var Xn=Object.getOwnPropertySymbols;var vo=Object.prototype.hasOwnProperty,Ro=Object.prototype.propertyIsEnumerable;var _o=(n,e,t)=>e in n?Iu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Et=(n,e)=>{for(var t in e||(e={}))vo.call(e,t)&&_o(n,t,e[t]);if(Xn)for(var t of Xn(e))Ro.call(e,t)&&_o(n,t,e[t]);return n},ln=(n,e)=>bu(n,Ou(e));var Eo=(n,e)=>{var t={};for(var r in n)vo.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&Xn)for(var r of Xn(n))e.indexOf(r)<0&&Ro.call(n,r)&&(t[r]=n[r]);return t};import{s as ge,r as $n,a as Nu}from"./index.8ea5a330.js";import{j as Ha,n as $a,d as Je,E as wu,f as L,l as se,p as gr,q as Ai,t as Mi,u as yo,v as _t,x as Au,y as Mu,z as ui,A as pt,r as Ne,B as Yt,C as Pu,D as Lu,F as ku,G as yr,H as Uu,I as Du,J as xu,K as di,L as li}from"./vendor.2b18510b.js";const Vu="_liveHeader_8nata_1",Bu="_liveLogo_8nata_12",Fu="_liveHeaderLeft_8nata_17",Hu="_liveHeaderLeftIcon_8nata_23",$u="_liveHeaderLeftText_8nata_27",ju="_avatarWrapper_8nata_30",Ku="_userAvatar_8nata_37";var At={liveHeader:Vu,liveLogo:Bu,liveHeaderLeft:Fu,liveHeaderLeftIcon:Hu,liveHeaderLeftText:$u,avatarWrapper:ju,userAvatar:Ku},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 yt,hi,Mn=Pi,qu=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],Gu=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],Yu=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],To={"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}},Ju=["RC:TypSts","RC:InterceptMsg"];(function(n){n.WEBSOCKET="websocket",n.COMET="comet"})(yt||(yt={}));var Gr=function(n){return hi||(hi={set:function(e,t){n.localStorage.setItem(e,JSON.stringify(t))},get:function(e){var t;try{t=JSON.parse(n.localStorage.getItem(e))}catch{t=null}return t},remove:function(e){return n.localStorage.removeItem(e)},getKeys:function(){var e=[];for(var t in n.localStorage)e.push(t);return e}}),hi},Wu=function(){function n(e){this._caches={},e&&(this._caches=e)}return n.prototype.set=function(e,t){this._caches[e]=t},n.prototype.remove=function(e){var t=this.get(e);return delete this._caches[e],t},n.prototype.get=function(e){return this._caches[e]},n.prototype.getKeys=function(){var e=[];for(var t in this._caches)e.push(t);return e},n}(),So=function(){function n(e,t){var r,i=t?"RCV4-"+t:"RCV4-";this._rootStorage=Gr(e);var s=this._rootStorage.get(i)||{};this._cache=new Wu(((r={})[i]=s,r)),this._storageKey=i}return n.prototype._get=function(){var e=this._storageKey;return this._cache.get(e)||{}},n.prototype._set=function(e){var t=this._storageKey;e=e||{},this._cache.set(t,e),this._rootStorage.set(t,e)},n.prototype.set=function(e,t){var r=this._get();r[e]=t,this._set(r)},n.prototype.remove=function(e){var t=this._get();delete t[e],this._set(t)},n.prototype.clear=function(){var e=this._storageKey;this._rootStorage.remove(e),this._cache.remove(e)},n.prototype.get=function(e){return this._get()[e]},n.prototype.getKeys=function(){var e=this._get(),t=[];for(var r in e)t.push(r);return t},n.prototype.getValues=function(){return this._get()||{}},n}(),ja=function(n,e){return(ja=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])})(n,e)};function Ie(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=n}ja(n,e),n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Re=function(){return(Re=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n}).apply(this,arguments)};function x(n,e,t,r){return new(t||(t=Promise))(function(i,s){function o(l){try{d(r.next(l))}catch(h){s(h)}}function u(l){try{d(r.throw(l))}catch(h){s(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof t?h:new t(function(a){a(h)})).then(o,u)}d((r=r.apply(n,e||[])).next())})}function V(n,e){var t,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(d){return function(l){return function(h){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,r&&(i=2&h[0]?r.return:h[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,h[1])).done)return i;switch(r=0,i&&(h=[2&h[0],i.value]),h[0]){case 0:case 1:i=h;break;case 4:return o.label++,{value:h[1],done:!1};case 5:o.label++,r=h[1],h=[0];continue;case 7:h=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){o=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){o.label=h[1];break}if(h[0]===6&&o.label<i[1]){o.label=i[1],i=h;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(h);break}i[2]&&o.ops.pop(),o.trys.pop();continue}h=e.call(n,o)}catch(a){h=[6,a],r=0}finally{t=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}function Ut(n,e){for(var t=0,r=e.length,i=n.length;t<r;t++,i++)n[i]=e[t];return n}var Pe,Tr;(function(n){function e(t){return n.call(this,"TODO => "+t)||this}return Ie(e,n),e})(Error);var Io=function(n,e,t){if(e===void 0||t===void 0)return n.toUpperCase();var r=n.slice(e,t);return n=n.replace(r,function(i){return i.toUpperCase()})},Ka=function(n,e){e===void 0&&(e="utf-8");var t,r=0;if(e==="utf-16")for(var i=0,s=n.length;i<s;i++)r+=(t=n.charCodeAt(i))<=65535?2:4;else for(i=0,s=n.length;i<s;i++)r+=(t=n.charCodeAt(i))<127?1:t<=2047?2:t<=65535?3:4;return r},Yr=function(n,e){if(n=n.replace(/\?$/,""),!e)return n;var t=Object.keys(e).map(function(r){return r+"="+e[r]}).filter(function(r){return!!r});return t.length?[n,t.join("&")].join("?"):n},hs=function(n){return n.match(/\d+(\.\d+){2}/)[0]};(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.NONE=1e3]="NONE"})(Pe||(Pe={})),function(n){n.IM="IM",n.RTC="RTC"}(Tr||(Tr={}));var Jt="RC_Logs";function zu(n){var e=n.target.result;n.oldVersion===1&&e.deleteObjectStore(Jt),function(t,r,i){var s;if(!t.objectStoreNames.contains(r)){var o=Re({},i.objectStoreParams);s=t.createObjectStore(r,o),i.indexs&&i.indexs.length>0&&i.indexs.forEach(function(u){s.createIndex(u.indexName,u.key,{unique:u.unique})})}}(e,Jt,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}var Li,ps=function(){function n(){}return n.init=function(){if(typeof window!="undefined"&&window&&window.indexedDB){var e=window.indexedDB.open("RC_ENGINE_DB",2);e.onerror=function(t){console.warn("open indexDB request failed "+t.target.error)},e.onsuccess=function(t){n._db=t.target.result,n._db&&(n._db.onclose=function(r){var i;console.warn("The database "+((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 "+((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 "+((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},e.onupgradeneeded=function(t){n._db=t.target.result,zu(t)}}else console.debug("IndexDB is not currently supported in the environment!")},n.getInstance=function(){return n._instance},n.prototype.addList=function(e,t){return new Promise(function(r){if(n._db){var i=n._db.transaction([e],"readwrite"),s=i.objectStore(e);t.forEach(function(o){s==null||s.add(o)}),i.oncomplete=function(o){r(!0)},i.onerror=function(o){r(!1)}}else r(!1)})},n.prototype.getRangeData=function(e,t,r,i){return new Promise(function(s){if(n._db){var o=n._db.transaction([e],"readwrite").objectStore(e),u=IDBKeyRange.bound(r,i),d=o.index(t),l=[],h=d.openCursor(u);h.onsuccess=function(a){var c=a.target.result;c?(l.push(c.value),c.continue()):s(l)},h.onerror=function(a){console.error(a),s([])}}else s([])})},n.prototype.getCount=function(e,t){return new Promise(function(r){if(n._db){var i=n._db.transaction([e],"readonly").objectStore(e).count();i.onsuccess=function(){r(i.result)},i.onerror=function(s){console.error(s),r(0)}}else r(0)})},n.prototype.removeFirstData=function(e,t,r){return new Promise(function(i){if(n._db){var s=n._db.transaction([e],"readwrite").objectStore(e),o=s.getAllKeys(IDBKeyRange.lowerBound(0),r);o.onsuccess=function(){var u=o.result;u.length>0&&(s.delete(IDBKeyRange.bound(u[0],u[u.length-1])).onsuccess=function(){i(!0)})}}else i(!1)})},n._db=null,n}(),qa=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var e=16*Math.random()|0;return(n==="x"?e:3&e|8).toString(16)})},Ga=function(){var n=qa();if(n=n.replace(/-/g,"")+"a",(n=function(r){var i="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZa0".split(""),s=i.length+1,o=+r,u=[];do{var d=o%s;o=(o-d)/s,u.unshift(i[d])}while(o);return u.join("")}(n=parseInt(n,16))).length>22&&(n=n.slice(0,22)),n.length<22)for(var e=22-n.length,t=0;t<e;t++)n+="0";return n};(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.RTC_ROOM=12]="RTC_ROOM"})(Li||(Li={}));var ki,z=Li;(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"})(ki||(ki={}));var Ft,Ui,ke=ki,Qe=function(n){return typeof n=="string"},Sr=function(n){return typeof n=="boolean"},Te=function(n){return typeof n=="number"&&!isNaN(n)},Ye=function(n){return Object.prototype.toString.call(n).indexOf("Array")!==-1},Ya=function(n){return Object.prototype.toString.call(n)==="[object ArrayBuffer]"},ze=function(n){return Qe(n)&&n.length>0},Ve=function(n){return Object.prototype.toString.call(n)==="[object Object]"},Ir=function(n){return Object.prototype.toString.call(n)==="[object Function]"},fe=function(n){return n===void 0||Object.prototype.toString.call(n)==="[object Undefined]"},bo=function(n){return Object.prototype.toString.call(n)==="[object Null]"},Pn=function(n){return Qe(n)&&/https?:\/\//.test(n)},Sn=function(n){for(var e in n)return!0;return!1},Qu=function(n){return Te(n)&&Object.prototype.hasOwnProperty.call(ke,n)},Oo=((Ft={})[Pe.DEBUG]=console.debug.bind(console),Ft[Pe.INFO]=console.info.bind(console),Ft[Pe.WARN]=console.warn.bind(console),Ft[Pe.ERROR]=console.error.bind(console),Ft[Pe.FATAL]=console.log.bind(console),Ft),No=function(n){return Qe(n)||Te(n)||fe(n)||Sr(n)?n:n instanceof Error?JSON.stringify({name:n.name,message:n.message,stack:n.stack}):JSON.stringify(n)},wt=function(){function n(e,t,r){this.tag=e,this.type=t,this.initiator=r,this._outLevel=Pe.WARN,this.debug=this.log.bind(this,Pe.DEBUG),this.info=this.log.bind(this,Pe.INFO),this.warn=this.log.bind(this,Pe.WARN),this.error=this.log.bind(this,Pe.ERROR),this.fatal=this.log.bind(this,Pe.FATAL)}return n.init=function(e){n.userId=e},n.reset=function(){n.userId=""},n.prototype._defaultStdout=function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];Oo[e].apply(Oo,Ut([t+":"],r))},n.prototype.__pushLocalLog=function(e,t,r){var i;i=this.type?this.type:["RCRTCLog","RCCall","RCRTC","RTC-A"].includes(this.tag)?Tr.RTC:Tr.IM;var s=Date.now();Ka(t)>=1e3&&(t=function(l,h,a){if(a===void 0&&(a="utf-8"),!l||!h)return"";var c=a==="utf-8"?3:2,p=0,f=0,m="";for(f=0;f<l.length;f++){if(l.charCodeAt(f)>255?p+=c:p++,p>h)return m;m+=l.charAt(f)}return l}(t,1e3));var o=JSON.stringify({message:t,userId:n.userId}).replace(/"/g,'""'),u=/^[\w]+-[\w]+-[\w]+?/.test(r)?r:(this.initiator||"L")+"-"+r+"-O",d={sessionId:n.sessionId,time:s,level:4-e,content:n.sessionId+","+Date.now()+","+i+","+(4-e)+","+u+',"'+o+`"
- `,userId:n.userId};n.databaseLogList.push(d),(n.databaseLogList.length>=100||e===Pe.FATAL)&&this.__insertLogIntoDatabase()},n.prototype.__insertLogIntoDatabase=function(){return x(this,void 0,void 0,function(){var e,t,r;return V(this,function(i){switch(i.label){case 0:return e=Ut([],n.databaseLogList),n.databaseLogList=[],(t=ps.getInstance())?[4,t.addList(Jt,e)]:[3,3];case 1:return r=i.sent(),[4,t.getCount(Jt,"time")];case 2:return i.sent()>1e5&&t.removeFirstData(Jt,"time",2e3),[2,r];case 3:return[2,!1]}})})},n.prototype.setLogLevel=function(e){this._outLevel=typeof e!="number"?Pe.WARN:e},n.prototype.setLogStdout=function(e){this._logStdout=e},n.prototype.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(e>Pe.DEBUG&&this.__pushLocalLog(e,t.map(No).join(" "),this.tag),!(e<this._outLevel)){var i=new Date().toISOString()+"["+this.tag+"]["+Pe[e]+"]",s=i+" - "+t.map(No).join(" ");this._logStdout?this._logStdout(e,s):this._stdout?this._stdout(e,s):this._defaultStdout.apply(this,Ut([e,i],t))}},n.prototype.reportLog=function(e,t,r){this.__pushLocalLog(4-e,r,t);var i=JSON.stringify({message:r}).replace(/"/g,'""');i='"'+i+'"';var s={level:e,content:[n.sessionId,Date.now(),this.type,e,t,i].join()+`
- `};n.realTimeLogList.push(s),n.realTimeLogList.length>=600&&(n.realTimeLogList=n.realTimeLogList.slice(-500))},n.prototype.set=function(e,t){this.warn("logger.set has being deprecated!")},n.prototype.setStdout=function(e){this._stdout=e},n.prototype.__clearRealTimeLog=function(){n.realTimeLogList=[]},n.databaseLogList=[],n.realTimeLogList=[],n.sessionId=Ga(),n.userId="",n}(),j=new wt("RCLog"),jn=function(){function n(){this._map={}}return n.prototype.on=function(e,t,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(s){return s.listener===t&&s.target===r})||i.push({listener:t,target:r})},n.prototype.once=function(e,t,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(s){return s.listener===t&&s.target===r})||i.push({listener:t,target:r,once:!0})},n.prototype.off=function(e,t,r){var i=this._map[e];i&&((i=i.filter(function(s){return s.listener!==t||s.target!==r})).length?this._map[e]=i:delete this._map[e])},n.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var i=this._map[e];if(i)for(var s=i.length-1;s>=0;s-=1){var o=i[s],u=o.target,d=o.once,l=o.listener;d&&i.splice(s,1);try{l.call.apply(l,Ut([u],t))}catch(h){j.error(h)}}},n.prototype.removeAll=function(e){delete this._map[e]},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"})(Ui||(Ui={}));var Di,nt=Ui;(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.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.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"})(Di||(Di={}));var xi,S=Di;(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"})(xi||(xi={}));var Vi,te=xi,Be={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"})(Vi||(Vi={}));var Bi,He=Vi;(function(n){n[n.OPEN=1]="OPEN",n[n.CLOSE=2]="CLOSE"})(Bi||(Bi={}));var Fi,Kt=Bi;(function(n){n[n.ALL=1]="ALL",n[n.SINGAL=2]="SINGAL"})(Fi||(Fi={}));var Hi,fs=Fi;(function(n){n[n.QINIU=1]="QINIU",n[n.ALI=2]="ALI",n[n.AWS=3]="AWS",n[n.STC=4]="STC"})(Hi||(Hi={}));var $i,Ge=Hi;(function(n){n[n.UPDATE=1]="UPDATE",n[n.DELETE=2]="DELETE"})($i||($i={}));var ji,We=$i;(function(n){n[n.QUIT=0]="QUIT",n[n.JOIN=1]="JOIN"})(ji||(ji={}));var wo,Ao=ji;(function(n){/*!
- 全局敏感词:命中了融云内置的全局敏感词
- */n[n.GLOBAL=1]="GLOBAL",n[n.CUSTOM=2]="CUSTOM",n[n.THIRD_PARTY=3]="THIRD_PARTY"})(wo||(wo={}));var je,Mo,Po;(function(n){n[n.RTC=0]="RTC",n[n.LIVE=2]="LIVE"})(je||(je={})),function(n){n[n.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",n[n.AUDIO=1]="AUDIO"}(Mo||(Mo={})),function(n){n[n.ANCHOR=1]="ANCHOR",n[n.AUDIENCE=2]="AUDIENCE"}(Po||(Po={}));var ht,br,Ki,Xu={"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"})(ht||(ht={})),function(n){n[n.AnchorToViewer=1]="AnchorToViewer",n[n.ViewerToAnchor=2]="ViewerToAnchor"}(br||(br={})),function(n){n[n.KICK=0]="KICK",n[n.REFUSE=1]="REFUSE",n[n.COEXIST=2]="COEXIST"}(Ki||(Ki={}));var dt,we,pi={engine:"5.1.1"},Dt=function(){function n(){}return n.add=function(e,t){pi[e]=t},n.validEngine=function(e){var t=e.match(/\d+\.\d+\.\d+/);if(!t)return j.warn("The validation engine version '"+e+"' is invalid!"),!1;var r=t[0].split(".").map(function(i){return i.padStart(3,"0")}).join("");return pi.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map(function(i){return i.padStart(3,"0")}).join("")>=r},n.getInfo=function(){return pi},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"})(we||(we={}));var vt,Fe,Xe,xt,Lt,Zu=((dt={})[we.STRING]=ze,dt[we.ONLY_STRING]=Qe,dt[we.NUMBER]=Te,dt[we.BOOLEAN]=function(n){return typeof n=="boolean"},dt[we.OBJECT]=Ve,dt[we.ARRAY]=Ye,dt[we.CALLBACK]=function(n){var e=!0;return Ve(n)||(e=!1),(n=n||{}).onSuccess&&!Ir(n.onSuccess)&&(e=!1),n.onError&&!Ir(n.onError)&&(e=!1),e},dt[we.CHANNEL_ID]=function(n){var e=!1;return Qe(n)&&!/_/g.test(n)&&n.length<=20&&(e=!0),e},dt),ed=function(n){function e(t){var r=n.call(this,t)||this;return r.name="RCAssertError",r}return Ie(e,n),e}(Error),Ue=function(n,e,t,r){if(r===void 0&&(r=!1),!Ee(n,e,t,r))throw new ed("'"+n+"' is invalid: "+JSON.stringify(e))},Ee=function(n,e,t,r){r===void 0&&(r=!1),t=Zu[t]||t;var i=r&&!t(e)||!r&&!(fe(e)||e===null||t(e));return i&&j.error("'"+n+"' is invalid: "+JSON.stringify(e)),!i},Ze=function(n){if(!Ve(n)||n.low===void 0||n.high===void 0)return n;var e=n.low;return e<0&&(e+=4294967296),e=e.toString(16),parseInt(n.high.toString(16)+"00000000".replace(new RegExp("0{"+e.length+"}$"),e),16)},td=function(n,e){var t=Math.floor(1e3*Math.random()%1e4),r=qa(),i=function(d){d=d||"-";var l=new Date;return""+l.getFullYear()+d+(l.getMonth()+1)+d+l.getDate()}(),s=new Date().getTime(),o="";if(e){var u=e.split(".");o="."+u[u.length-1]}return n+"__RC-"+i+"_"+t+"_"+s+r+o},nd=function(n,e){n===void 0&&(n={}),e===void 0&&(e={});var t=n.threadId,r=n.apnsCollapseId,i=n.category,s=n.richMediaUri,o=e.channelIdMi,u=e.channelIdHW,d=e.channelIdOPPO,l=e.typeVivo,h=e.googleConfig,a={};a["thread-id"]=t||"",a["apns-collapse-id"]=r||"",a.category=i||"",a.richMediaUri=s||"";var c={};c.collapse_key=h==null?void 0:h.collapseKey,c.imageUrl=h==null?void 0:h.imageUrl;var p=h==null?void 0:h.priority;p&&!["high","normal"].includes(p)&&(p="normal"),c.priority=p;var f=[{HW:{channelId:u||""}},{MI:{channelId:o||""}},{OPPO:{channelId:d||""}},{VIVO:{classification:l||""}},{APNS:a},{FCM:c}];return JSON.stringify(f)},Lo=function(n,e){var t={},r={notificationId:e||""};if(!n)return{iOSConfig:t,androidConfig:r};try{var i=JSON.parse(n);i==null||i.forEach(function(s){var o,u,d,l,h=Object.keys(s);if(h.length!==0){var a=h[0];switch(a){case"HW":return void(r.channelIdHW=(o=s[a])===null||o===void 0?void 0:o.channelId);case"MI":return void(r.channelIdMi=(u=s[a])===null||u===void 0?void 0:u.channelId);case"OPPO":return void(r.channelIdOPPO=(d=s[a])===null||d===void 0?void 0:d.channelId);case"VIVO":return void(r.typeVivo=(l=s[a])===null||l===void 0?void 0:l.classification);case"APNS":return t.threadId=s[a]["thread-id"],t.apnsCollapseId=s[a]["apns-collapse-id"],t.category=s[a].category,void(t.richMediaUri=s[a].richMediaUri);case"FCM":r.googleConfig={collapseKey:s[a].collapse_key||"",imageUrl:s[a].imageUrl||"",priority:s[a].priority||""}}}})}catch{j.error("Wrong format for pushConfigs field! content: "+n)}return{iOSConfig:t,androidConfig:r}},Ht=function(n){var e=/^[A-Za-z0-9_=+-]+$/.test(n),t=n.length;return e&&t<=128&&t>=1},fi=function(n){var e=n.length;return e<=4096&&e>=1},Oe=function(n,e,t){e=e||function(){};var r=(t=t||{}).isReverse;Ve(n)&&function(){for(var i in n)e(n[i],i,n)}(),(Ye(n)||Qe(n))&&function(){if(r)for(var i=n.length-1;i>=0;i--)e(n[i],i);else for(var s=0,o=n.length;s<o;s++)e(n[s],s)}()},Zn=function(n,e){return Oe(n,function(t,r){n[r]=e(t,r)}),n},rd=function(n,e){if(n.indexOf)return n.indexOf(e);var t=-1;return Oe(n,function(r,i){e===r&&(t=i)}),t},id=function(n,e){var t=[];return Oe(n,function(r){t.push(r)}),rd(t,e)!==-1},mr=function(n){return JSON.parse(JSON.stringify(n))},ko=function(){return typeof RCCppEngine!="undefined"},sd=function(n){if(n.tag!=="browser")return{type:n.tag,version:"UnKonw"};var e,t,r=navigator.userAgent,i={IE:/rv:([\d.]+)\) like Gecko|MSIE ([\d.]+)/,Edge:/Edge\/([\d.]+)/,Firefox:/Firefox\/([\d.]+)/,Opera:/(?:OPERA|OPR).([\d.]+)/,WeChat:/MicroMessenger\/([\d.]+)/,QQBrowser:/QQBrowser\/([\d.]+)/,Chrome:/Chrome\/([\d.]+)/,Safari:/Version\/([\d.]+).*Safari/,iOSChrome:/Mobile\/([\d.]+).*Safari/};for(var s in i)if(i.hasOwnProperty(s)){var o=r.match(i[s]);if(o){t=s,e=o[1]||o[2];break}}return{type:t||"UnKonw",version:e||"UnKonw"}},Ja=function(n){switch(n){case Be.SERVER_UNAVAILABLE:return S.SERVER_UNAVAILABLE;case Be.TOKEN_INCORRECT:return S.RC_CONN_USER_OR_PASSWD_ERROR;case Be.REDIRECT:return S.RC_CONN_REDIRECTED;case Be.APP_BLOCK_OR_DELETE:return S.RC_CONN_APP_BLOCKED_OR_DELETED;case Be.BLOCK:return S.RC_CONN_USER_BLOCKED;case Be.TOKEN_EXPIRE:return S.RC_CONN_USER_OR_PASSWD_ERROR;case Be.HOSTNAME_ERROR:return S.HOSTNAME_ERROR;case Be.HASOHTERSAMECLIENTONLINE:return S.HAS_OHTER_SAME_CLIENT_ON_LINE;case Be.APP_AUTH_NOT_PASS:return S.RC_APP_AUTH_NOT_PASS;case Be.OTP_USED:return S.RC_OTP_USED;case Be.PLATFORM_ERROR:return S.RC_PLATFORM_ERROR;default:return S.RC_NET_UNAVAILABLE}},Uo=function(n){var e={},t=JSON.parse(n);return Oe(t,function(r,i){e[i]=r.v}),e},qt={_delayTime:0,setTime:function(n){var e=new Date().getTime();qt._delayTime=e-n},getTime:function(){var n=qt._delayTime;return new Date().getTime()-n}},Do=function(n,e){var t=0;return n.isAutoDelete&&(t|=1),n.isOverwrite&&(t|=2),e===2&&(t|=4),t};(function(n){n[n.AT_MOST_ONCE=0]="AT_MOST_ONCE",n[n.AT_LEAST_ONCE=1]="AT_LEAST_ONCE",n[n.EXACTLY_ONCE=2]="EXACTLY_ONCE",n[n.DEFAULT=3]="DEFAULT"})(vt||(vt={})),function(n){n[n.SYMMETRIC=0]="SYMMETRIC",n[n.CONNECT=1]="CONNECT",n[n.CONN_ACK=2]="CONN_ACK",n[n.PUBLISH=3]="PUBLISH",n[n.PUB_ACK=4]="PUB_ACK",n[n.QUERY=5]="QUERY",n[n.QUERY_ACK=6]="QUERY_ACK",n[n.QUERY_CONFIRM=7]="QUERY_CONFIRM",n[n.SUBSCRIBE=8]="SUBSCRIBE",n[n.SUB_ACK=9]="SUB_ACK",n[n.UNSUBSCRIBE=10]="UNSUBSCRIBE",n[n.UNSUB_ACK=11]="UNSUB_ACK",n[n.PING_REQ=12]="PING_REQ",n[n.PING_RESP=13]="PING_RESP",n[n.DISCONNECT=14]="DISCONNECT",n[n.RESERVER2=15]="RESERVER2"}(Fe||(Fe={})),function(n){n.CONN_ACK="ConnAckMessage",n.DISCONNECT="DisconnectMessage",n.PING_REQ="PingReqMessage",n.PING_RESP="PingRespMessage",n.PUBLISH="PublishMessage",n.PUB_ACK="PubAckMessage",n.QUERY="QueryMessage",n.QUERY_CON="QueryConMessage",n.QUERY_ACK="QueryAckMessage"}(Xe||(Xe={})),function(n){n.PUB="pub",n.QUERY="qry"}(xt||(xt={})),function(n){n[n.V4=4]="V4",n[n.V3=3]="V3"}(Lt||(Lt={}));var K,gs=function(){function n(e,t,r,i){t===void 0&&(t=!1),r===void 0&&(r=vt.AT_LEAST_ONCE),i===void 0&&(i=!1),this._retain=!1,this.qos=vt.AT_LEAST_ONCE,this._dup=!1,this.syncMsg=!1;var s=e>0;e&&s&&arguments.length===1?(this._retain=(1&e)>0,this.qos=(6&e)>>1,this._dup=(8&e)>0,this.type=e>>4&15,this.syncMsg=(8&e)==8):(this.type=e,this._retain=t,this.qos=r,this._dup=i)}return n.prototype.encode=function(){var e=this.type<<4;return e|=this._retain?1:0,e|=this.qos<<1,e|=this._dup?8:0},n}(),Kn=function(){function n(){}return n.writeUTF=function(e,t){var r=[],i=0;if(Qe(e))for(var s=0,o=e.length;s<o;s++){var u=e.charCodeAt(s);u>=0&&u<=127?(i+=1,r.push(u)):u>=128&&u<=2047?(i+=2,r.push(192|31&u>>6),r.push(128|63&u)):u>=2048&&u<=65535&&(i+=3,r.push(224|15&u>>12),r.push(128|63&u>>6),r.push(128|63&u))}for(s=0,o=r.length;s<o;s++)r[s]>255&&(r[s]&=255);return t?r:i<=255?[0,i].concat(r):[i>>8,255&i].concat(r)},n.readUTF=function(e){for(var t,r,i=[],s=-1,o=e,u="";++s<o.length;){var d=Number(o[s]);if(d===(127&d)||((240&d)==240?d=(d=(d=(d^=240)<<6|128^o[++s])<<6|128^o[++s])<<6|128^o[++s]:(224&d)==224?d=(d=(d^=224)<<6|128^o[++s])<<6|128^o[++s]:(192&d)==192&&(d=(d^=192)<<6|128^o[++s])),!isFinite(d)||d<0||d>1114111||Math.floor(d)!==d)throw RangeError("Invalid code point: "+d);d<=65535?i.push(d):(t=(d-=65536)>>10|55296,r=d%1024|56320,i.push(t,r)),(s+1===o.length||i.length>16384)&&(u+=String.fromCharCode.apply(null,i),i.length=0)}return u},n}(),od=function(){function n(e){this._position=0,this._poolLen=0,this._pool=e,this._poolLen=e.length}return n.prototype.check=function(){return this._position>=this._pool.length},n.prototype.read2Byte=function(){var e=this;if(e.check())return-1;for(var t="",r=0;r<2;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),t+=i.toString()}return parseInt(t,16)},n.prototype.readInt=function(){var e=this;if(e.check())return-1;for(var t="",r=0;r<4;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),t+=i.toString()}return parseInt(t,16)},n.prototype.readLong=function(){var e=this;if(e.check())return-1;for(var t="",r=0;r<8;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),t+=i}return parseInt(t,16)},n.prototype.readByte=function(){if(this.check())return-1;var e=this._pool[this._position++];return e>255&&(e&=255),e},n.prototype.readUTF=function(){if(this.check())return"";var e=this.readByte()<<8|this.readByte(),t=this._pool.subarray(this._position,this._position+=e);return Kn.readUTF(t)},n.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},n}(),ad=function(){function n(){this._pool=[],this._position=0,this._writen=0}return n.prototype.write=function(e){return Object.prototype.toString.call(e).indexOf("Array")!==-1?this._pool=this._pool.concat(e):e>=0&&(e>255&&(e&=255),this._pool.push(e),this._writen++),e},n.prototype.writeArr=function(e){return this._pool=this._pool.concat(e),e},n.prototype.writeUTF=function(e){var t=Kn.writeUTF(e);this._pool=this._pool.concat(t),this._writen+=t.length},n.prototype.getBytesArray=function(){return this._pool},n}(),Ln="UpStreamMessage",ms="PushExtra",Jr="DownStreamMessage",kn="DownStreamMessages",_s="SessionsAttQryInput",Wa="SessionsAttOutput",vs="SyncRequestMsg",Rs="ChrmPullMsg",Or="NotifyMsg",Es="HistoryMsgInput",Un="HistoryMsgOuput",Nr="RelationQryInput",Dn="RelationsOutput",Cs="DeleteSessionsInput",ys="SessionInfo",za="DeleteSessionsOutput",Ts="RelationsInput",Ss="DeleteMsgInput",Is="CleanHisMsgInput",bs="SessionMsgReadInput",Os="ChrmInput",Ns="ChrmOutput",ws="QueryChatRoomInfoInput",Wr="QueryChatRoomInfoOutput",wr="RtcInput",kt="RtcUserListOutput",As="SetUserStatusInput",Ms="RtcSetDataInput",Ar="RtcUserSetDataInput",Mr="RtcDataInput",Ps="RtcSetOutDataInput",Ls="MCFollowInput",zr="RtcTokenOutput",Qr="RtcQryOutput",ks="RtcQryUserOutDataInput",Qa="RtcUserOutDataOutput",Us="RtcQueryListInput",Xa="RtcRoomInfoOutput",et="RtcValueInfo",Ds="RtcKeyDeleteInput",xs="GetQNupTokenInput",Vs="GetQNupTokenOutput",Bs="GetQNdownloadUrlInput",Fs="GetDownloadUrlInput",Hs="GetQNdownloadUrlOutput",$s="GetDownloadUrlOutput",js="SetChrmKV",Ks="SetChrmKVS",Za="DeleteChrmKVS",Wt="ChrmKVOutput",qs="ChrmKVSOutput",ec="ChrmKVSOutputEntity",Gs="QueryChrmKV",tc="SetUserSettingInput",zt="SetUserSettingOutput",Ys="PullUserSettingInput",Xr="PullUserSettingOutput",Zr="UserSettingNotification",Js="SessionReq",ei="SessionStates",Pr="SessionState",Lr="SessionStateItem",kr="SessionStateModifyReq",Ws="SessionStateModifyResp",Ur="GrpReadReceiptMsg",nc="GrpReadReceiptQryReq",ti="GrpReadReceiptQryResp",rc="GrpMsgReadUser",zs="SessionTagAddInput",In="SessionTagItem",Qs="SessionTagDelInput",Xs="SessionDisTagReq",Zs="ReportSDKInput",ic="ReportSDKOutput",eo="RtcNotifyMsg",to="RtcPullKV",ni="RtcKVOutput",no="RtcQueryUserJoinedInput",ri="RtcQueryUserJoinedOutput",sc="RtcViewerJoinedOutput",ro="RtcInviteInput",io="RtcCancelInviteInput",so="RtcInviteAnswerInput",oo="RtcEndInviteInput",oc=((K={})[Ln]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],K[kn]=["list","syncTime","finished"],K[Jr]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel"],K[ms]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],K[_s]=["nothing"],K[Wa]=["inboxTime","sendboxTime","totalUnreadCount"],K[vs]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime"],K[Rs]=["syncTime","count"],K[Or]=["type","time","chrmId"],K[Es]=["targetId","time","count","order","busChannel"],K[Un]=["list","syncTime","hasMsg"],K[Nr]=["type","count","startTime","order"],K[Dn]=["info"],K[Cs]=["sessions"],K[ys]=["type","channelId","busChannel"],K[za]=["nothing"],K[Ts]=["type","msg","count","busChannel","startTime","endTime"],K[Ss]=["type","conversationId","msgs","busChannel"],K[Is]=["targetId","dataTime","conversationType","busChannel"],K[bs]=["type","msgTime","channelId"],K[Os]=["nothing"],K[Ns]=["nothing","sessionId","joinTime"],K[ws]=["count","order"],K[Wr]=["userTotalNums","userInfos"],K[xs]=["type","key","httpMethod","queryString"],K[Bs]=["type","key","fileName"],K[Fs]=["type","key","fileName"],K[Vs]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],K[Hs]=["downloadUrl"],K[$s]=["downloadUrl"],K[js]=["entry","bNotify","notification","type"],K[Ks]=["entry","bNotify","notification","type"],K[Za]=["entry","bNotify","notification","type"],K[Wt]=["entries","bFullUpdate","syncTime"],K[qs]=["timestamp","errorKeys"],K[ec]=["key","errorCode"],K[Gs]=["timestamp"],K[tc]=["version","value"],K[zt]=["version","reserve"],K[Ys]=["version","reserve"],K[Xr]=["items","version"],K.UserSettingItem=["targetId","type","key","value","version","status","tags"],K[Js]=["time"],K[ei]=["version","state"],K[Pr]=["type","channelId","time","stateItem","busChannel"],K[Lr]=["sessionStateType","value","tags"],K[kr]=["version","state"],K[Ws]=["version"],K[Ur]=["msgId","busChannel"],K[nc]=["msgId","busChannel"],K[ti]=["totalMemberNum","list"],K[rc]=["readTime","userId"],K[zs]=["version","tags"],K[In]=["tagId","name","createdTime","isTop"],K[Qs]=["version","tags"],K[Xs]=["tagId"],K[Zr]=["version","reserve"],K[Zs]=["sdkInfo"],K[ic]=["nothing"],K[wr]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],K[kt]=["users","token","sessionId","roomInfo"],K[As]=["status"],K[Ms]=["interior","target","key","value","objectName","content"],K[Ar]=["valueInfo","objectName","content"],K[Mr]=["interior","target","key","objectName","content"],K[Ps]=["target","valueInfo","objectName","content"],K[Ls]=["state"],K[zr]=["rtcToken"],K[Qr]=["outInfo"],K[ks]=["userId"],K[Qa]=["user"],K[Us]=["order"],K[Xa]=["roomId","roomData","userCount","list"],K[et]=["key","value"],K[Ds]=["key"],K[eo]=["type","time","roomId"],K[to]=["timestamp","roomId"],K[ni]=["entries","bFullUpdate","syncTime"],K[no]=["userId"],K[ri]=["info"],K[ro]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],K[io]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],K[so]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],K[oo]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],K),xn={},cd=function(n){var e=oc[n];xn[n]=function(){for(var t={},r={getArrayData:function(){return t}},i=function(o){var u=e[o],d="set"+Io(u,0,1);r[d]=function(l){t[u]=l}},s=0;s<e.length;s++)i(s);return r},xn[n].decode=function(t){var r={};Qe(t)&&(t=JSON.parse(t));var i=function(o){var u="get"+Io(o,0,1);r[o]=t[o],r[u]=function(){return t[o]}};for(var s in t)i(s);return r}};for(var ud in oc)cd(ud);xn.getModule=function(n){return xn[n]()};var dd=`
- package Modules;
- message probuf {
- message `+As+`
- {
- optional int32 status=1;
- }
- message SetUserStatusOutput
- {
- optional int32 nothing=1;
- }
- message GetUserStatusInput
- {
- optional int32 nothing=1;
- }
- message GetUserStatusOutput
- {
- optional string status=1;
- optional string subUserId=2;
- }
- message SubUserStatusInput
- {
- repeated string userid =1;
- }
- message SubUserStatusOutput
- {
- optional int32 nothing=1;
- }
- message VoipDynamicInput
- {
- required int32 engineType = 1;
- required string channelName = 2;
- optional string channelExtra = 3;
- }
- message VoipDynamicOutput
- {
- required string dynamicKey=1;
- }
- message `+Or+` {
- required int32 type = 1;
- optional int64 time = 2;
- optional string chrmId=3;
- }
- message `+vs+` {
- required int64 syncTime = 1;
- required bool ispolling = 2;
- optional bool isweb=3;
- optional bool isPullSend=4;
- optional bool isKeeping=5;
- optional int64 sendBoxSyncTime=6;
- }
- message `+Ln+` {
- required int32 sessionId = 1;
- required string classname = 2;
- required bytes content = 3;
- optional string pushText = 4;
- optional string appData = 5;
- repeated string userId = 6;
- optional int64 delMsgTime = 7;
- optional string delMsgId = 8;
- optional int32 configFlag = 9;
- optional int64 clientUniqueId = 10;
- optional string extraContent = 11;
- optional PushExtra pushExt = 12;
- optional string busChannel = 13; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+ms+` {
- optional string title = 1;
- optional int32 templateIdNoUse= 2;
- optional string pushId = 3;
- optional string pushConfigs = 4;
- optional string templateId = 5;
- }
- message `+kn+` {
- repeated DownStreamMessage list = 1;
- required int64 syncTime = 2;
- optional bool finished = 3;
- }
- message `+Jr+` {
- required string fromUserId = 1;
- required ChannelType type = 2;
- optional string groupId = 3;
- required string classname = 4;
- required bytes content = 5;
- required int64 dataTime = 6;
- required int64 status = 7;
- optional int64 extra = 8;
- optional string msgId = 9;
- optional int32 direction = 10;
- optional int32 plantform =11;
- optional int32 isRemoved = 12;
- optional string source = 13;
- optional int64 clientUniqueId = 14;
- optional string extraContent = 15;
- optional string pushContent = 16;
- optional int32 configFlag = 17;
- optional PushExtra pushExt = 18;
- optional string busChannel = 19; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- enum ChannelType {
- PERSON = 1;
- PERSONS = 2;
- GROUP = 3;
- TEMPGROUP = 4;
- CUSTOMERSERVICE = 5;
- NOTIFY = 6;
- MC=7;
- MP=8;
- }
- message CreateDiscussionInput {
- optional string name = 1;
- }
- message CreateDiscussionOutput {
- required string id = 1;
- }
- message ChannelInvitationInput {
- repeated string users = 1;
- }
- message LeaveChannelInput {
- required int32 nothing = 1;
- }
- message ChannelEvictionInput {
- required string user = 1;
- }
- message RenameChannelInput {
- required string name = 1;
- }
- message ChannelInfoInput {
- required int32 nothing = 1;
- }
- message ChannelInfoOutput {
- required ChannelType type = 1;
- required string channelId = 2;
- required string channelName = 3;
- required string adminUserId = 4;
- repeated string firstTenUserIds = 5;
- required int32 openStatus = 6;
- }
- message ChannelInfosInput {
- required int32 page = 1;
- optional int32 number = 2;
- }
- message ChannelInfosOutput {
- repeated ChannelInfoOutput channels = 1;
- required int32 total = 2;
- }
- message MemberInfo {
- required string userId = 1;
- required string userName = 2;
- required string userPortrait = 3;
- required string extension = 4;
- }
- message GroupMembersInput {
- required int32 page = 1;
- optional int32 number = 2;
- }
- message GroupMembersOutput {
- repeated MemberInfo members = 1;
- required int32 total = 2;
- }
- message GetUserInfoInput {
- required int32 nothing = 1;
- }
- message GetUserInfoOutput {
- required string userId = 1;
- required string userName = 2;
- required string userPortrait = 3;
- }
- message GetSessionIdInput {
- required int32 nothing = 1;
- }
- message GetSessionIdOutput {
- required int32 sessionId = 1;
- }
- enum FileType {
- image = `+ke.IMAGE+`;
- audio = `+ke.AUDIO+`;
- video = `+ke.VIDEO+`;
- file = `+ke.FILE+`;
- }
- message `+xs+` {
- required FileType type = 1;
- optional string key = 2;
- optional string httpMethod = 3;
- optional string queryString = 4;
- }
- message `+Bs+` {
- required FileType type = 1;
- required string key = 2;
- optional string fileName = 3;
- }
- message `+Fs+` {
- required FileType type = 1;
- required string key = 2;
- optional string fileName = 3;
- }
- message `+Vs+` {
- required int64 deadline = 1;
- required string token = 2;
- optional string bosToken = 3;
- optional string bosDate = 4;
- optional string path = 5;
- optional string osskeyId = 6;
- optional string ossPolicy = 7;
- optional string ossSign = 8;
- optional string ossBucketName = 9;
- optional string s3Credential = 10;
- optional string s3Algorithm = 11;
- optional string s3Date = 12;
- optional string s3Policy = 13;
- optional string s3Signature = 14;
- optional string s3BucketName = 15;
- optional string stcAuthorization = 16;
- optional string stcContentSha256 = 17;
- optional string stcDate = 18;
- optional string stcBucketName = 19;
- }
- message `+Hs+` {
- required string downloadUrl = 1;
- }
- message `+$s+` {
- required string downloadUrl = 1;
- }
- message Add2BlackListInput {
- required string userId = 1;
- }
- message RemoveFromBlackListInput {
- required string userId = 1;
- }
- message QueryBlackListInput {
- required int32 nothing = 1;
- }
- message QueryBlackListOutput {
- repeated string userIds = 1;
- }
- message BlackListStatusInput {
- required string userId = 1;
- }
- message BlockPushInput {
- required string blockeeId = 1;
- }
- message ModifyPermissionInput {
- required int32 openStatus = 1;
- }
- message GroupInput {
- repeated GroupInfo groupInfo = 1;
- }
- message GroupOutput {
- required int32 nothing = 1;
- }
- message GroupInfo {
- required string id = 1;
- required string name = 2;
- }
- message GroupHashInput {
- required string userId = 1;
- required string groupHashCode = 2;
- }
- message GroupHashOutput {
- required GroupHashType result = 1;
- }
- enum GroupHashType {
- group_success = 0x00;
- group_failure = 0x01;
- }
- message `+Os+` {
- required int32 nothing = 1;
- }
- message `+Ns+` {
- required int32 nothing = 1;
- optional string sessionId = 2;
- optional int64 joinTime = 3;
- }
- message `+Rs+` {
- required int64 syncTime = 1;
- required int32 count = 2;
- }
- message ChrmPullMsgNew
- {
- required int32 count = 1;
- required int64 syncTime = 2;
- optional string chrmId=3;
- }
- message `+Nr+`
- {
- optional ChannelType type = 1;
- optional int32 count = 2;
- optional int64 startTime = 3;
- optional int32 order = 4;
- }
- message `+Ts+`
- {
- required ChannelType type = 1;
- optional DownStreamMessage msg =2;
- optional int32 count = 3;
- optional string busChannel = 4;
- optional int64 startTime = 5;
- optional int64 endTime = 6;
- }
- message `+Dn+`
- {
- repeated RelationInfo info = 1;
- }
- message RelationInfo
- {
- required ChannelType type = 1;
- required string userId = 2;
- optional DownStreamMessage msg =3;
- optional int64 readMsgTime= 4;
- optional int64 unreadCount= 5;
- optional string busChannel = 6;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message RelationInfoReadTime
- {
- required ChannelType type = 1;
- required int64 readMsgTime= 2;
- required string targetId = 3;
- }
- message `+Is+`
- {
- required string targetId = 1;
- required int64 dataTime = 2;
- optional int32 conversationType= 3;
- optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- message HistoryMessageInput
- {
- required string targetId = 1;
- required int64 dataTime =2;
- required int32 size = 3;
- }
- message HistoryMessagesOuput
- {
- repeated DownStreamMessage list = 1;
- required int64 syncTime = 2;
- required int32 hasMsg = 3;
- }
- message `+ws+`
- {
- required int32 count= 1;
- optional int32 order= 2;
- }
- message `+Wr+`
- {
- optional int32 userTotalNums = 1;
- repeated ChrmMember userInfos = 2;
- }
- message ChrmMember
- {
- required int64 time = 1;
- required string id = 2;
- }
- message MPFollowInput
- {
- required string id = 1;
- }
- message MPFollowOutput
- {
- required int32 nothing = 1;
- optional MpInfo info =2;
- }
- message `+Ls+`
- {
- required string state = 1;
- }
- message MCFollowOutput
- {
- required int32 nothing = 1;
- optional MpInfo info =2;
- }
- message MpInfo
- {
- required string mpid=1;
- required string name = 2;
- required string type = 3;
- required int64 time=4;
- optional string portraitUrl=5;
- optional string extra =6;
- }
- message SearchMpInput
- {
- required int32 type=1;
- required string id=2;
- }
- message SearchMpOutput
- {
- required int32 nothing=1;
- repeated MpInfo info = 2;
- }
- message PullMpInput
- {
- required int64 time=1;
- required string mpid=2;
- }
- message PullMpOutput
- {
- required int32 status=1;
- repeated MpInfo info = 2;
- }
- message `+Es+`
- {
- optional string targetId = 1;
- optional int64 time = 2;
- optional int32 count = 3;
- optional int32 order = 4;
- optional string busChannel = 5; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- message `+Un+`
- {
- repeated DownStreamMessage list=1;
- required int64 syncTime=2;
- required int32 hasMsg=3;
- }
- message `+Us+`{
- optional int32 order=1;
- }
- message `+Ds+`{
- repeated string key=1;
- }
- message `+et+`{
- required string key=1;
- required string value=2;
- }
- message RtcUserInfo{
- required string userId=1;
- repeated `+et+` userData=2; //\u7528\u6237\u8D44\u6E90\u4FE1\u606F
- }
- message `+kt+`{
- repeated RtcUserInfo users=1;
- optional string token=2;
- optional string sessionId=3;
- repeated RtcValueInfo roomInfo = 4; //\u623F\u95F4key value
- repeated RtcKVEntity entries = 5;//\u76F4\u64ADKV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
- optional int64 syncTime = 6;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
- optional int32 offlineKickTime = 7;//server\u8D85\u65F6\u8E22\u4EBA\u65F6\u95F4\uFF0C\u9ED8\u8BA460s
- }
- message RtcRoomInfoOutput{
- optional string roomId = 1;
- repeated `+et+` roomData = 2;
- optional int32 userCount = 3;
- repeated RtcUserInfo list=4;
- }
- message `+wr+`{
- required int32 roomType=1;
- optional int32 broadcastType=2;
- optional RtcValueInfo extraInnerData = 3;
- optional bool needSysChatroom = 4; //\u662F\u5426\u9700\u8981\u540C\u6B65\u804A\u5929\u5BA4
- optional IdentityChangeType identityChangeType = 5; //\u8EAB\u4EFD\u53D8\u66F4\u7C7B\u578B
- optional JoinType joinType = 6; // \u52A0\u5165\u623F\u95F4\u7C7B\u578B
- }
- enum JoinType {
- KICK = 0; //\u8E22\u524D\u4E00\u4E2A\u8BBE\u5907
- REFUSE = 1; //\u5F53\u524D\u52A0\u5165\u62D2\u7EDD
- COEXIST = 2; //\u4E24\u4E2A\u8BBE\u5907\u5171\u5B58
- }
- message RtcQryInput{
- required bool isInterior=1;
- required targetType target=2;
- repeated string key=3;
- }
- message `+Qr+`{
- repeated `+et+` outInfo=1;
- }
- message RtcDelDataInput{
- repeated string key=1;
- required bool isInterior=2;
- required targetType target=3;
- }
- message `+Mr+`{
- required bool interior=1;
- required targetType target=2;
- repeated string key=3;
- optional string objectName=4;
- optional string content=5;
- }
- message `+Ms+`{
- required bool interior=1;
- required targetType target=2;
- required string key=3;
- required string value=4;
- optional string objectName=5;
- optional string content=6;
- }
- message `+Ar+` {
- repeated `+et+` valueInfo = 1;
- required string objectName = 2;
- repeated `+et+` content = 3;
- }
- message RtcOutput
- {
- optional int32 nothing=1;
- }
- message `+zr+`{
- required string rtcToken=1;
- }
- enum targetType {
- ROOM =1 ;
- PERSON = 2;
- }
- message `+Ps+`{
- required targetType target=1;
- repeated `+et+` valueInfo=2;
- optional string objectName=3;
- optional string content=4;
- }
- message `+ks+`{
- repeated string userId = 1;
- }
- message `+Qa+`{
- repeated RtcUserInfo user = 1;
- }
- message `+_s+`{
- required int32 nothing = 1;
- }
- message `+Wa+`{
- required int64 inboxTime = 1;
- required int64 sendboxTime = 2;
- required int64 totalUnreadCount = 3;
- }
- message `+bs+`
- {
- required ChannelType type = 1;
- required int64 msgTime = 2;
- required string channelId = 3;
- }
- message SessionMsgReadOutput
- {
- optional int32 nothing=1;
- }
- message `+Cs+`
- {
- repeated SessionInfo sessions = 1;
- }
- message `+ys+`
- {
- required ChannelType type = 1;
- required string channelId = 2;
- optional string busChannel = 3;//\u6240\u5C5E\u4F1A\u8BDD\u4E1A\u52A1\u6807\u8BC6
- }
- message `+za+`
- {
- optional int32 nothing=1;
- }
- message `+Ss+`
- {
- optional ChannelType type = 1;
- optional string conversationId = 2;
- repeated DeleteMsg msgs = 3;
- optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- message DeleteMsg
- {
- optional string msgId = 1;
- optional int64 msgDataTime = 2;
- optional int32 direct = 3;
- }
- message ChrmKVEntity {
- required string key = 1;
- required string value = 2;
- optional int32 status = 3;
- optional int64 timestamp = 4;
- optional string uid = 5;
- }
- message `+js+` {
- required ChrmKVEntity entry = 1;
- optional bool bNotify = 2;
- optional UpStreamMessage notification = 3;
- optional ChannelType type = 4;
- }
- message `+Ks+` {
- repeated ChrmKVEntity entry = 1;
- optional bool bNotify = 2;
- optional UpStreamMessage notification = 3;
- optional ChannelType type = 4;
- }
- message `+Za+` {
- repeated ChrmKVEntity entry = 1;
- optional bool bNotify = 2;
- optional UpStreamMessage notification = 3;
- optional ChannelType type = 4;
- }
- message `+Wt+` {
- repeated ChrmKVEntity entries = 1;
- optional bool bFullUpdate = 2;
- optional int64 syncTime = 3;
- }
- message `+qs+` {
- repeated ChrmKVSOutputEntity errorKeys = 1;
- }
- message `+ec+`
- {
- optional string key = 1;
- optional int32 errorCode = 2;
- }
- message `+Gs+` {
- required int64 timestamp = 1;
- }
- message `+tc+` {
- required int64 version=1;
- required string value=2;
- }
- message `+zt+` {
- required int64 version=1;
- required bool reserve=2;
- }
- message `+Ys+` {
- required int64 version=1;
- optional bool reserve=2;
- }
- message `+Xr+` {
- repeated UserSettingItem items = 1;
- required int64 version=2;
- }
- message UserSettingItem {
- required string targetId= 1;
- required ChannelType type = 2;
- required string key = 4;
- required bytes value = 5;
- required int64 version=6;
- required int32 status=7;
- repeated SessionTagItem tags= 8;
- }
- message `+Js+` {
- required int64 time = 1;
- }
- message `+ei+` {
- required int64 version=1;
- repeated SessionState state= 2;
- }
- message `+Pr+` {
- required ChannelType type = 1;
- required string channelId = 2;
- optional int64 time = 3;
- repeated SessionStateItem stateItem = 4;
- optional string busChannel = 5;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+Lr+` {
- required SessionStateType sessionStateType = 1;
- required string value = 2;
- repeated SessionTagItem tags = 3;
- }
- enum SessionStateType {
- IsSilent = 1;
- IsTop = 2;
- Tags = 3;
- }
- message `+kr+` {
- required int64 version=1;
- repeated SessionState state= 2;
- }
- message `+Ws+` {
- required int64 version=1;
- }
- message `+Ur+` {
- repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
- optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+nc+` {
- repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
- optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+ti+` {
- required int32 totalMemberNum = 1;//\u7FA4\u5185\u603B\u4EBA\u6570
- repeated GrpMsgReadUser list = 2;//\u5DF2\u8BFB\u7528\u6237\u5217\u8868\uFF08list\u590D\u7C7B\u578B\uFF09
- }
- message `+rc+` {
- required int64 readTime = 1;//\u5DF2\u8BFB\u65F6\u95F4
- required string userId = 2;//\u5DF2\u8BFB\u7528\u6237id
- }
- message `+zs+` {
- required int64 version=1;
- repeated SessionTagItem tags=2;
- }
- message `+In+` {
- required string tagId=1;
- optional string name=2;
- optional int64 createdTime=3;
- optional bool isTop=4;
- }
- message `+Qs+` {
- required int64 version=1;
- repeated SessionTagItem tags=2;
- }
- message `+Xs+` {
- repeated string tagId=1;
- }
- message `+Zr+` {
- required int64 version=1;
- required bool reserve=2;
- }
- message `+Zs+` {
- required string sdkInfo=1; // \u7528\u6237\u96C6\u6210\u7684 sdk \u4FE1\u606F,json \u683C\u5F0F {"web-rtc": "4.0.3.7"}
- }
- message `+ic+`
- {
- optional int32 nothing=1; //\u5360\u4F4D
- }
- message `+eo+`
- {
- required int32 type= 1; //(\u901A\u77E5\u7C7B\u578B 1:rtc\u623F\u95F4\u72B6\u6001KV\u53D8\u66F4\u901A\u77E5)
- optional int64 time= 2; //\u6D88\u606F\u4EA7\u751F\u65F6\u95F4
- optional string roomId=3; //\u4E3B\u64AD\u623F\u95F4id
- }
- message `+to+`
- {
- required int64 timestamp = 1;
- required string roomId = 2;
- }
- message `+ni+`
- {
- repeated RtcKVEntity entries = 1;
- optional bool bFullUpdate = 2;
- optional int64 syncTime = 3;
- }
- message RtcKVEntity
- {
- required string key = 1;
- required string value = 2;
- optional int32 status = 3;
- optional int64 timestamp = 4;
- optional string uid = 5;
- }
- enum IdentityChangeType
- {
- AnchorToViewer = 1; //1\u4E3A\u4E3B\u64AD\u53D8\u89C2\u4F17
- ViewerToAnchor = 2; //2\u4E3A\u89C2\u4F17\u53D8\u4E3B\u64AD
- }
- message `+no+`
- {
- required string userId = 1;
- }
- message `+ri+`
- {
- repeated RtcJoinedInfo info = 1;
- }
- message RtcJoinedInfo
- {
- required string deviceId = 1; //\u8BBE\u5907ID
- required string roomId = 2; //\u52A0\u5165\u7684\u623F\u95F4ID
- optional int64 joinTime = 3; //\u52A0\u5165\u7684\u65F6\u95F4
- }
- message `+sc+`
- {
- required string rtcToken=1;
- repeated RtcKVEntity entries = 2;//KV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
- optional int64 syncTime = 3;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
- }
- message `+ro+`
- {
- required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
- optional int32 timeoutTime=2; //\u9080\u8BF7\u8D85\u65F6\u65F6\u95F4(\u79D2),\u9ED8\u8BA4\u4E09\u5341\u79D2
- required string invitedRoomId=3; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
- required string inviteInfo=4; //\u9080\u8BF7\u7684\u4FE1\u606F(\u5305\u542B\u9080\u8BF7\u4EBA,\u88AB\u9080\u8BF7\u4EBA,\u5404\u81EAuserid)\u5BA2\u6237\u7AEF\u5B9A\u4E49\u597D.\u534F\u8BAE\u6808\u548Cserver\u900F\u4F20
- required string inviteSessionId= 5; //\u5BA2\u6237\u7AEF\u4FDD\u8BC1\u552F\u4E00\u6027(\u5EFA\u8BAEroomid_userid_\u65F6\u95F4\u6233_\u968F\u673A\u6570)
- }
- message `+io+`
- {
- required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
- required string invitedRoomId=2; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
- required string inviteInfo=3; //\u53D6\u6D88\u9080\u8BF7\u7684\u4FE1\u606F(\u5305\u542B\u9080\u8BF7\u4EBA,\u88AB\u9080\u8BF7\u4EBA,\u5404\u81EAuserid)\u5BA2\u6237\u7AEF\u5B9A\u4E49\u597D.\u534F\u8BAE\u6808\u548Cserver\u900F\u4F20
- required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId,\u5BA2\u6237\u7AEF\u53D1\u8D77\u9080\u8BF7\u65F6\u4EA7\u751F
- }
- message `+so+`
- {
- required string inviteUserId=1; //\u9080\u8BF7\u7684\u4EBA\u7684uid
- required int32 answerCode=2; //\u662F\u5426\u63A5\u53D7\u8FDE\u9EA6\u9080\u8BF7.0\u4E3A\u62D2\u7EDD,1\u4E3A\u63A5\u53D7
- required string inviteRoomId=3; //\u9080\u8BF7\u7684\u623F\u95F4
- required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId
- required string content=5; //\u9700\u8981\u8F6C\u53D1\u7684content
- optional string key=6; //\u5982\u679C\u63A5\u53D7\u7684\u8BDD,\u9700\u8981\u52A0\u8FD9\u4E2A\u5B57\u6BB5,\u653E\u5728room\u7EA7\u522B\u7684k\u548Cv,\u65B0\u52A0\u5165\u623F\u95F4\u7684\u80FD\u62C9\u53D6\u5230
- optional string value=7; //\u5982\u679C\u63A5\u53D7\u7684\u8BDD,\u9700\u8981\u52A0\u8FD9\u4E2A\u5B57\u6BB5,\u653E\u5728room\u7EA7\u522B\u7684k\u548Cv,\u65B0\u52A0\u5165\u623F\u95F4\u7684\u80FD\u62C9\u53D6\u5230
- }
- message `+oo+`
- {
- required string inviteRoomId=1; //\u9080\u8BF7\u7684\u623F\u95F4
- required string inviteSessionId=2; //\u9080\u8BF7\u7684sessionId
- required string inviteContent=3; //\u7ED3\u675F\u8FDE\u9EA6\u7684\u4FE1\u606F(\u9700\u8981\u900F\u4F20\u7ED9\u623F\u95F4\u5185\u5176\u4ED6\u4EBA)
- repeated string inviteRoomKeys=4; //\u9700\u8981\u5220\u9664\u8FDE\u9EA6\u7684\u4FE1\u606F\u7684key
- }
- }
- `,xo,Vo,hn,$t,pn,qi=(xo=dd,function(n,e){var t,r,i={};return i.ByteBuffer=n,i.c=n,t=n,i.Long=e||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 s={};return s.IS_NODE=!(typeof process!="object"||process+""!="[object process]"||process.browser),s.XHR=function(){var o,u=[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(o=0;o<u.length;o++){try{d=u[o]()}catch{continue}break}if(!d)throw Error("XMLHttpRequest is not supported");return d},s.fetch=function(o,u){if(u&&typeof u!="function"&&(u=null),s.IS_NODE)if(u)g.readFile(o,function(l,h){u(l?null:""+h)});else try{return g.readFileSync(o)}catch{return null}else{var d=s.XHR();if(d.open("GET",o,!!u),d.setRequestHeader("Accept","text/plain"),typeof d.overrideMimeType=="function"&&d.overrideMimeType("text/plain"),!u)return d.send(null),d.status==200||d.status==0&&typeof d.responseText=="string"?d.responseText:null;if(d.onreadystatechange=function(){d.readyState==4&&(d.status==200||d.status==0&&typeof d.responseText=="string"?u(d.responseText):u(null))},d.readyState==4)return;d.send(null)}},s.toCamelCase=function(o){return o.replace(/_([a-zA-Z])/g,function(u,d){return d.toUpperCase()})},s}(),i.Lang={DELIM:/[\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(s,o){function u(m,_){var v=-1,R=1;if(m.charAt(0)=="-"&&(R=-1,m=m.substring(1)),o.NUMBER_DEC.test(m))v=parseInt(m);else if(o.NUMBER_HEX.test(m))v=parseInt(m.substring(2),16);else{if(!o.NUMBER_OCT.test(m))throw Error("illegal id value: "+(R<0?"-":"")+m);v=parseInt(m.substring(1),8)}if(v=0|R*v,!_&&v<0)throw Error("illegal id value: "+(R<0?"-":"")+m);return v}function d(m){var _=1;if(m.charAt(0)=="-"&&(_=-1,m=m.substring(1)),o.NUMBER_DEC.test(m))return _*parseInt(m,10);if(o.NUMBER_HEX.test(m))return _*parseInt(m.substring(2),16);if(o.NUMBER_OCT.test(m))return _*parseInt(m.substring(1),8);if(m==="inf")return 1/0*_;if(m==="nan")return NaN;if(o.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,c={},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==='"'?o.STRING_DQ:o.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,R,C;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;o.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(R=this.index,o.DELIM.lastIndex=0,!o.DELIM.test(this.source.charAt(R++)))for(;R<this.source.length&&!o.DELIM.test(this.source.charAt(R));)++R;return((C=this.source.substring(this.index,this.index=R))==='"'||C==="'")&&(this._stringOpen=C),C},f.peek=function(){if(this.stack.length===0){var m=this.next();if(m===null)return null;this.stack.push(m)}return this.stack[0]},f.skip=function(m){var _=this.next();if(_!==m)throw Error("illegal '"+_+"', '"+m+"' expected")},f.omit=function(m){return this.peek()===m&&(this.next(),!0)},f.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"},c.Tokenizer=p,(a=(h=function(m){this.tn=new p(m),this.proto3=!1}).prototype).parse=function(){var m,_={name:"[ROOT]",package:null,messages:[],enums:[],imports:[],options:{},services:[]},v=!0;try{for(;m=this.tn.next();)switch(m){case"package":if(!v||_.package!==null)throw Error("unexpected 'package'");if(m=this.tn.next(),!o.TYPEREF.test(m))throw Error("illegal package name: "+m);this.tn.skip(";"),_.package=m;break;case"import":if(!v)throw Error("unexpected 'import'");(m=this.tn.peek())==="public"&&this.tn.next(),m=this._readString(),this.tn.skip(";"),_.imports.push(m);break;case"syntax":if(!v)throw Error("unexpected 'syntax'");this.tn.skip("="),(_.syntax=this._readString())==="proto3"&&(this.proto3=!0),this.tn.skip(";");break;case"message":this._parseMessage(_,null),v=!1;break;case"enum":this._parseEnum(_),v=!1;break;case"option":this._parseOption(_);break;case"service":this._parseService(_);break;case"extend":this._parseExtend(_);break;default:throw Error("unexpected '"+m+"'")}}catch(R){throw R.message="Parse error at line "+this.tn.line+": "+R.message,R}return delete _.name,_},h.parse=function(m){return new h(m).parse()},a._readString=function(){var m,_,v="";do{if((_=this.tn.next())!=="'"&&_!=='"')throw Error("illegal string delimiter: "+_);v+=this.tn.next(),this.tn.skip(_),m=this.tn.peek()}while(m==='"'||m==='"');return v},a._readValue=function(m){var _=this.tn.peek();if(_==='"'||_==="'")return this._readString();if(this.tn.next(),o.NUMBER.test(_))return d(_);if(o.BOOL.test(_))return _.toLowerCase()==="true";if(m&&o.TYPEREF.test(_))return _;throw Error("illegal value: "+_)},a._parseOption=function(m,_){var v,R=this.tn.next(),C=!1;if(R==="("&&(C=!0,R=this.tn.next()),!o.TYPEREF.test(R))throw Error("illegal option name: "+R);v=R,C&&(this.tn.skip(")"),v="("+v+")",R=this.tn.peek(),o.FQTYPEREF.test(R)&&(v+=R,this.tn.next())),this.tn.skip("="),this._parseOptionValue(m,v),_||this.tn.skip(";")},a._parseOptionValue=function(m,_){var v=this.tn.peek();if(v!=="{")l(m.options,_,this._readValue(!0));else for(this.tn.skip("{");(v=this.tn.next())!=="}";){if(!o.NAME.test(v))throw Error("illegal option name: "+_+"."+v);this.tn.omit(":")?l(m.options,_+"."+v,this._readValue(!0)):this._parseOptionValue(m,_+"."+v)}},a._parseService=function(m){var _,v=this.tn.next();if(!o.NAME.test(v))throw Error("illegal service name at line "+this.tn.line+": "+v);for(_={name:v,rpc:{},options:{}},this.tn.skip("{");(v=this.tn.next())!=="}";)if(v==="option")this._parseOption(_);else{if(v!=="rpc")throw Error("illegal service token: "+v);this._parseServiceRPC(_)}this.tn.omit(";"),m.services.push(_)},a._parseServiceRPC=function(m){var _,v,R="rpc",C=this.tn.next();if(!o.NAME.test(C))throw Error("illegal rpc service method name: "+C);if(_=C,v={request:null,response:null,request_stream:!1,response_stream:!1,options:{}},this.tn.skip("("),(C=this.tn.next()).toLowerCase()==="stream"&&(v.request_stream=!0,C=this.tn.next()),!o.TYPEREF.test(C))throw Error("illegal rpc service request type: "+C);if(v.request=C,this.tn.skip(")"),(C=this.tn.next()).toLowerCase()!=="returns")throw Error("illegal rpc service request type delimiter: "+C);if(this.tn.skip("("),(C=this.tn.next()).toLowerCase()==="stream"&&(v.response_stream=!0,C=this.tn.next()),v.response=C,this.tn.skip(")"),(C=this.tn.peek())==="{"){for(this.tn.next();(C=this.tn.next())!=="}";){if(C!=="option")throw Error("illegal rpc service token: "+C);this._parseOption(v)}this.tn.omit(";")}else this.tn.skip(";");m[R]===void 0&&(m[R]={}),m[R][_]=v},a._parseMessage=function(m,_){var v=!!_,R=this.tn.next(),C={name:"",fields:[],enums:[],messages:[],options:{},services:[],oneofs:{}};if(!o.NAME.test(R))throw Error("illegal "+(v?"group":"message")+" name: "+R);for(C.name=R,v&&(this.tn.skip("="),_.id=u(this.tn.next()),C.isGroup=!0),(R=this.tn.peek())==="["&&_&&this._parseFieldOptions(_),this.tn.skip("{");(R=this.tn.next())!=="}";)if(o.RULE.test(R))this._parseMessageField(C,R);else if(R==="oneof")this._parseMessageOneOf(C);else if(R==="enum")this._parseEnum(C);else if(R==="message")this._parseMessage(C);else if(R==="option")this._parseOption(C);else if(R==="service")this._parseService(C);else if(R==="extensions")C.extensions=this._parseExtensionRanges();else if(R==="reserved")this._parseIgnored();else if(R==="extend")this._parseExtend(C);else{if(!o.TYPEREF.test(R))throw Error("illegal message token: "+R);if(!this.proto3)throw Error("illegal field rule: "+R);this._parseMessageField(C,"optional",R)}return this.tn.omit(";"),m.messages.push(C),C},a._parseIgnored=function(){for(;this.tn.peek()!==";";)this.tn.next();this.tn.skip(";")},a._parseMessageField=function(m,_,v){var R,C,A;if(!o.RULE.test(_))throw Error("illegal message field rule: "+_);if(R={rule:_,type:"",name:"",options:{},id:0},_==="map"){if(v)throw Error("illegal type: "+v);if(this.tn.skip("<"),C=this.tn.next(),!o.TYPE.test(C)&&!o.TYPEREF.test(C))throw Error("illegal message field type: "+C);if(R.keytype=C,this.tn.skip(","),C=this.tn.next(),!o.TYPE.test(C)&&!o.TYPEREF.test(C))throw Error("illegal message field: "+C);if(R.type=C,this.tn.skip(">"),C=this.tn.next(),!o.NAME.test(C))throw Error("illegal message field name: "+C);R.name=C,this.tn.skip("="),R.id=u(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(R),this.tn.skip(";")}else if((v=v!==void 0?v:this.tn.next())==="group"){if(A=this._parseMessage(m,R),!/^[A-Z]/.test(A.name))throw Error("illegal group name: "+A.name);R.type=A.name,R.name=A.name.toLowerCase(),this.tn.omit(";")}else{if(!o.TYPE.test(v)&&!o.TYPEREF.test(v))throw Error("illegal message field type: "+v);if(R.type=v,C=this.tn.next(),!o.NAME.test(C))throw Error("illegal message field name: "+C);R.name=C,this.tn.skip("="),R.id=u(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(R),this.tn.skip(";")}return m.fields.push(R),R},a._parseMessageOneOf=function(m){var _,v,R,C=this.tn.next();if(!o.NAME.test(C))throw Error("illegal oneof name: "+C);for(v=C,R=[],this.tn.skip("{");(C=this.tn.next())!=="}";)(_=this._parseMessageField(m,"optional",C)).oneof=v,R.push(_.id);this.tn.omit(";"),m.oneofs[v]=R},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:{}},R=this.tn.next();if(!o.NAME.test(R))throw Error("illegal name: "+R);for(v.name=R,this.tn.skip("{");(R=this.tn.next())!=="}";)if(R==="option")this._parseOption(v);else{if(!o.NAME.test(R))throw Error("illegal name: "+R);this.tn.skip("="),_={name:R,id:u(this.tn.next(),!0)},(R=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,R=[];do{for(_=[];;){switch(m=this.tn.next()){case"min":v=s.ID_MIN;break;case"max":v=s.ID_MAX;break;default:v=d(m)}if(_.push(v),_.length===2)break;if(this.tn.peek()!=="to"){_.push(v);break}this.tn.next()}R.push(_)}while(this.tn.omit(","));return this.tn.skip(";"),R},a._parseExtend=function(m){var _,v=this.tn.next();if(!o.TYPEREF.test(v))throw Error("illegal extend reference: "+v);for(_={ref:v,fields:[]},this.tn.skip("{");(v=this.tn.next())!=="}";)if(o.RULE.test(v))this._parseMessageField(_,v);else{if(!o.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},c.Parser=h,c}(i,i.Lang),i.Reflect=function(s){function o(E,T){if(E&&typeof E.low=="number"&&typeof E.high=="number"&&typeof E.unsigned=="boolean"&&E.low==E.low&&E.high==E.high)return new s.Long(E.low,E.high,T===void 0?E.unsigned:T);if(typeof E=="string")return s.Long.fromString(E,T||!1,10);if(typeof E=="number")return s.Long.fromNumber(E,T||!1);throw Error("not convertible to Long")}function u(E,T){var N=T.readVarint32(),P=7&N,k=N>>>3;switch(P){case s.WIRE_TYPES.VARINT:do N=T.readUint8();while((128&N)==128);break;case s.WIRE_TYPES.BITS64:T.offset+=8;break;case s.WIRE_TYPES.LDELIM:N=T.readVarint32(),T.offset+=N;break;case s.WIRE_TYPES.STARTGROUP:u(k,T);break;case s.WIRE_TYPES.ENDGROUP:if(k===E)return!1;throw Error("Illegal GROUPEND after unknown group: "+k+" ("+E+" expected)");case s.WIRE_TYPES.BITS32:T.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+E+": "+P)}return!0}var d,l,h,a,c,p,f,m,_,v,R,C,A,M,O,y,w={},$=function(E,T,N){this.builder=E,this.parent=T,this.name=N,this.className},Y=$.prototype;return Y.fqn=function(){for(var E=this.name,T=this;(T=T.parent)!=null;)E=T.name+"."+E;return E},Y.toString=function(E){return(E?this.className+" ":"")+this.fqn()},Y.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},w.T=$,(l=(d=function(E,T,N,P,k){$.call(this,E,T,N),this.className="Namespace",this.children=[],this.options=P||{},this.syntax=k||"proto2"}).prototype=Object.create($.prototype)).getChildren=function(E){var T,N,P;if((E=E||null)==null)return this.children.slice();for(T=[],N=0,P=this.children.length;P>N;++N)this.children[N]instanceof E&&T.push(this.children[N]);return T},l.addChild=function(E){var T;if(T=this.getChild(E.name))if(T instanceof c.Field&&T.name!==T.originalName&&this.getChild(T.originalName)===null)T.name=T.originalName;else{if(!(E instanceof c.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 T,N,P=typeof E=="number"?"id":"name";for(T=0,N=this.children.length;N>T;++T)if(this.children[T][P]===E)return this.children[T];return null},l.resolve=function(E,T){var N,P=typeof E=="string"?E.split("."):E,k=this,B=0;if(P[B]===""){for(;k.parent!==null;)k=k.parent;B++}do{do{if(!(k instanceof w.Namespace)){k=null;break}if(!((N=k.getChild(P[B]))&&N instanceof w.T&&(!T||N instanceof w.Namespace))){k=null;break}k=N,B++}while(B<P.length);if(k!=null)break;if(this.parent!==null)return this.parent.resolve(E,T)}while(k!=null);return k},l.qn=function(E){var T,N,P=[],k=E;do P.unshift(k.name),k=k.parent;while(k!==null);for(T=1;T<=P.length;T++)if(N=P.slice(P.length-T),E===this.resolve(N,E instanceof w.Namespace))return N.join(".");return E.fqn()},l.build=function(){var E,T,N,P={},k=this.children;for(T=0,N=k.length;N>T;++T)(E=k[T])instanceof d&&(P[E.name]=E.build());return Object.defineProperty&&Object.defineProperty(P,"$options",{value:this.buildOpt()}),P},l.buildOpt=function(){var E,T,N,P,k={},B=Object.keys(this.options);for(E=0,T=B.length;T>E;++E)N=B[E],P=this.options[B[E]],k[N]=P;return k},l.getOption=function(E){return E===void 0?this.options:this.options[E]!==void 0?this.options[E]:null},w.Namespace=d,a=(h=function(E,T,N,P){if(this.type=E,this.resolvedType=T,this.isMapKey=N,this.syntax=P,N&&s.MAP_KEY_TYPES.indexOf(E)<0)throw Error("Invalid map key type: "+E.name)}).prototype,h.defaultFieldValue=function(E){if(typeof E=="string"&&(E=s.TYPES[E]),E.defaultValue===void 0)throw Error("default value for type "+E.name+" is not supported");return E==s.TYPES.bytes?new t(0):E.defaultValue},a.verifyValue=function(E){var T,N,P,k=function(B,H){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+B+" ("+H+")")}.bind(this);switch(this.type){case s.TYPES.int32:case s.TYPES.sint32:case s.TYPES.sfixed32:return(typeof E!="number"||E==E&&E%1!=0)&&k(typeof E,"not an integer"),E>4294967295?0|E:E;case s.TYPES.uint32:case s.TYPES.fixed32:return(typeof E!="number"||E==E&&E%1!=0)&&k(typeof E,"not an integer"),E<0?E>>>0:E;case s.TYPES.int64:case s.TYPES.sint64:case s.TYPES.sfixed64:if(s.Long)try{return o(E,!1)}catch(B){k(typeof E,B.message)}else k(typeof E,"requires Long.js");case s.TYPES.uint64:case s.TYPES.fixed64:if(s.Long)try{return o(E,!0)}catch(B){k(typeof E,B.message)}else k(typeof E,"requires Long.js");case s.TYPES.bool:return typeof E!="boolean"&&k(typeof E,"not a boolean"),E;case s.TYPES.float:case s.TYPES.double:return typeof E!="number"&&k(typeof E,"not a number"),E;case s.TYPES.string:return typeof E=="string"||E&&E instanceof String||k(typeof E,"not a string"),""+E;case s.TYPES.bytes:return n.isByteBuffer(E)?E:n.wrap(E);case s.TYPES.enum:for(T=this.resolvedType.getChildren(s.Reflect.Enum.Value),P=0;P<T.length;P++)if(T[P].name==E||T[P].id==E)return T[P].id;if(this.syntax==="proto3")return(typeof E!="number"||E==E&&E%1!=0)&&k(typeof E,"not an integer"),(E>4294967295||E<0)&&k(typeof E,"not in range for uint32"),E;k(E,"not a valid enum value");case s.TYPES.group:case s.TYPES.message:if(E&&typeof E=="object"||k(typeof E,"object expected"),E instanceof this.resolvedType.clazz)return E;if(E instanceof s.Builder.Message){for(P in N={},E)E.hasOwnProperty(P)&&(N[P]=E[P]);E=N}return new this.resolvedType.clazz(E)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+E+" (undefined type "+this.type+")")},a.calculateLength=function(E,T){if(T===null)return 0;var N;switch(this.type){case s.TYPES.int32:return T<0?t.calculateVarint64(T):t.calculateVarint32(T);case s.TYPES.uint32:return t.calculateVarint32(T);case s.TYPES.sint32:return t.calculateVarint32(t.zigZagEncode32(T));case s.TYPES.fixed32:case s.TYPES.sfixed32:case s.TYPES.float:return 4;case s.TYPES.int64:case s.TYPES.uint64:return t.calculateVarint64(T);case s.TYPES.sint64:return t.calculateVarint64(t.zigZagEncode64(T));case s.TYPES.fixed64:case s.TYPES.sfixed64:return 8;case s.TYPES.bool:return 1;case s.TYPES.enum:return t.calculateVarint32(T);case s.TYPES.double:return 8;case s.TYPES.string:return N=t.calculateUTF8Bytes(T),t.calculateVarint32(N)+N;case s.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");return t.calculateVarint32(T.remaining())+T.remaining();case s.TYPES.message:return N=this.resolvedType.calculate(T),t.calculateVarint32(N)+N;case s.TYPES.group:return(N=this.resolvedType.calculate(T))+t.calculateVarint32(E<<3|s.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")},a.encodeValue=function(E,T,N){var P,k;if(T===null)return N;switch(this.type){case s.TYPES.int32:T<0?N.writeVarint64(T):N.writeVarint32(T);break;case s.TYPES.uint32:N.writeVarint32(T);break;case s.TYPES.sint32:N.writeVarint32ZigZag(T);break;case s.TYPES.fixed32:N.writeUint32(T);break;case s.TYPES.sfixed32:N.writeInt32(T);break;case s.TYPES.int64:case s.TYPES.uint64:N.writeVarint64(T);break;case s.TYPES.sint64:N.writeVarint64ZigZag(T);break;case s.TYPES.fixed64:N.writeUint64(T);break;case s.TYPES.sfixed64:N.writeInt64(T);break;case s.TYPES.bool:typeof T=="string"?N.writeVarint32(T.toLowerCase()==="false"?0:!!T):N.writeVarint32(T?1:0);break;case s.TYPES.enum:N.writeVarint32(T);break;case s.TYPES.float:N.writeFloat32(T);break;case s.TYPES.double:N.writeFloat64(T);break;case s.TYPES.string:N.writeVString(T);break;case s.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");P=T.offset,N.writeVarint32(T.remaining()),N.append(T),T.offset=P;break;case s.TYPES.message:k=new t().LE(),this.resolvedType.encode(T,k),N.writeVarint32(k.offset),N.append(k.flip());break;case s.TYPES.group:this.resolvedType.encode(T,N),N.writeVarint32(E<<3|s.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")}return N},a.decode=function(E,T,N){if(T!=this.type.wireType)throw Error("Unexpected wire type for element");var P,k;switch(this.type){case s.TYPES.int32:return 0|E.readVarint32();case s.TYPES.uint32:return E.readVarint32()>>>0;case s.TYPES.sint32:return 0|E.readVarint32ZigZag();case s.TYPES.fixed32:return E.readUint32()>>>0;case s.TYPES.sfixed32:return 0|E.readInt32();case s.TYPES.int64:return E.readVarint64();case s.TYPES.uint64:return E.readVarint64().toUnsigned();case s.TYPES.sint64:return E.readVarint64ZigZag();case s.TYPES.fixed64:return E.readUint64();case s.TYPES.sfixed64:return E.readInt64();case s.TYPES.bool:return!!E.readVarint32();case s.TYPES.enum:return E.readVarint32();case s.TYPES.float:return E.readFloat();case s.TYPES.double:return E.readDouble();case s.TYPES.string:return E.readVString();case s.TYPES.bytes:if(k=E.readVarint32(),E.remaining()<k)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+k+" required but got only "+E.remaining());return(P=E.clone()).limit=P.offset+k,E.offset+=k,P;case s.TYPES.message:return k=E.readVarint32(),this.resolvedType.decode(E,k);case s.TYPES.group:return this.resolvedType.decode(E,-1,N)}throw Error("[INTERNAL] Illegal decode type")},a.valueFromString=function(E){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case s.TYPES.int32:case s.TYPES.sint32:case s.TYPES.sfixed32:case s.TYPES.uint32:case s.TYPES.fixed32:return this.verifyValue(parseInt(E));case s.TYPES.int64:case s.TYPES.sint64:case s.TYPES.sfixed64:case s.TYPES.uint64:case s.TYPES.fixed64:return this.verifyValue(E);case s.TYPES.bool:return E==="true";case s.TYPES.string:return this.verifyValue(E);case s.TYPES.bytes:return t.fromBinary(E)}},a.valueToString=function(E){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===s.TYPES.bytes?E.toString("binary"):E.toString()},w.Element=h,(p=(c=function(E,T,N,P,k,B){d.call(this,E,T,N,P,B),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!k,this._fields=null,this._fieldsById=null,this._fieldsByName=null}).prototype=Object.create(d.prototype)).build=function(E){var T,N,P,k;if(this.clazz&&!E)return this.clazz;for(T=function(B,H){function q(U,G,Z,ne){var ce,ve,Qn,dn,ai,ci,Bt;if(U===null||typeof U!="object")return ne&&ne instanceof B.Reflect.Enum&&(ce=B.Reflect.Enum.getName(ne.object,U))!==null?ce:U;if(t.isByteBuffer(U))return G?U.toBase64():U.toBuffer();if(B.Long.isLong(U))return Z?U.toString():B.Long.fromValue(U);if(Array.isArray(U))return ve=[],U.forEach(function(Tu,Su){ve[Su]=q(Tu,G,Z,ne)}),ve;if(ve={},U instanceof B.Map){for(dn=(Qn=U.entries()).next();!dn.done;dn=Qn.next())ve[U.keyElem.valueToString(dn.value[0])]=q(dn.value[1],G,Z,U.valueElem.resolvedType);return ve}for(Bt in ai=U.$type,ci=void 0,U)U.hasOwnProperty(Bt)&&(ve[Bt]=ai&&(ci=ai.getChild(Bt))?q(U[Bt],G,Z,ci.resolvedType):q(U[Bt],G,Z));return ve}var J,re,de=H.getChildren(B.Reflect.Message.Field),ue=H.getChildren(B.Reflect.Message.OneOf),ie=function(U){var G,Z,ne,ce;for(B.Builder.Message.call(this),G=0,Z=ue.length;Z>G;++G)this[ue[G].name]=null;for(G=0,Z=de.length;Z>G;++G)this[(ne=de[G]).name]=ne.repeated?[]:ne.map?new B.Map(ne):null,!ne.required&&H.syntax!=="proto3"||ne.defaultValue===null||(this[ne.name]=ne.defaultValue);if(arguments.length>0)if(arguments.length!==1||U===null||typeof U!="object"||!(typeof U.encode!="function"||U instanceof ie)||Array.isArray(U)||U instanceof B.Map||t.isByteBuffer(U)||U instanceof ArrayBuffer||B.Long&&U instanceof B.Long)for(G=0,Z=arguments.length;Z>G;++G)(ce=arguments[G])!==void 0&&this.$set(de[G].name,ce);else this.$set(U)},ee=ie.prototype=Object.create(B.Builder.Message.prototype);for(ee.add=function(U,G,Z){var ne=H._fieldsByName[U];if(!Z){if(!ne)throw Error(this+"#"+U+" is undefined");if(!(ne instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ne.toString(!0));if(!ne.repeated)throw Error(this+"#"+U+" is not a repeated field");G=ne.verifyValue(G,!0)}return this[U]===null&&(this[U]=[]),this[U].push(G),this},ee.$add=ee.add,ee.set=function(U,G,Z){var ne,ce,ve;if(U&&typeof U=="object"){for(ne in Z=G,U)U.hasOwnProperty(ne)&&(G=U[ne])!==void 0&&this.$set(ne,G,Z);return this}if(ce=H._fieldsByName[U],Z)this[U]=G;else{if(!ce)throw Error(this+"#"+U+" is not a field: undefined");if(!(ce instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ce.toString(!0));this[ce.name]=G=ce.verifyValue(G)}return ce&&ce.oneof&&(ve=this[ce.oneof.name],G!==null?(ve!==null&&ve!==ce.name&&(this[ve]=null),this[ce.oneof.name]=ce.name):ve===U&&(this[ce.oneof.name]=null)),this},ee.$set=ee.set,ee.get=function(U,G){if(G)return this[U];var Z=H._fieldsByName[U];if(!(Z&&Z instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: undefined");if(!(Z instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+Z.toString(!0));return this[Z.name]},ee.$get=ee.get,J=0;J<de.length;J++)(re=de[J])instanceof B.Reflect.Message.ExtensionField||H.builder.options.populateAccessors&&function(U){var G,Z,ne,ce=U.originalName.replace(/(_[a-zA-Z])/g,function(ve){return ve.toUpperCase().replace("_","")});ce=ce.substring(0,1).toUpperCase()+ce.substring(1),G=U.originalName.replace(/([A-Z])/g,function(ve){return"_"+ve}),Z=function(ve,Qn){return this[U.name]=Qn?ve:U.verifyValue(ve),this},ne=function(){return this[U.name]},H.getChild("set"+ce)===null&&(ee["set"+ce]=Z),H.getChild("set_"+G)===null&&(ee["set_"+G]=Z),H.getChild("get"+ce)===null&&(ee["get"+ce]=ne),H.getChild("get_"+G)===null&&(ee["get_"+G]=ne)}(re);return ee.encode=function(U,G){var Z,ne;typeof U=="boolean"&&(G=U,U=void 0),Z=!1,U||(U=new n,Z=!0),ne=U.littleEndian;try{return H.encode(this,U.LE(),G),(Z?U.flip():U).LE(ne)}catch(ce){throw U.LE(ne),ce}},ie.encode=function(U,G,Z){return new ie(U).encode(G,Z)},ee.calculate=function(){return H.calculate(this)},ee.encodeDelimited=function(U){var G,Z=!1;return U||(U=new t,Z=!0),G=new t().LE(),H.encode(this,G).flip(),U.writeVarint32(G.remaining()),U.append(G),Z?U.flip():U},ee.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toArrayBuffer()),U}},ee.toArrayBuffer=ee.encodeAB,ee.encodeNB=function(){try{return this.encode().toBuffer()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toBuffer()),U}},ee.toBuffer=ee.encodeNB,ee.encode64=function(){try{return this.encode().toBase64()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toBase64()),U}},ee.toBase64=ee.encode64,ee.encodeHex=function(){try{return this.encode().toHex()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toHex()),U}},ee.toHex=ee.encodeHex,ee.toRaw=function(U,G){return q(this,!!U,!!G,this.$type)},ee.encodeJSON=function(){return JSON.stringify(q(this,!0,!0,this.$type))},ie.decode=function(U,G){var Z,ne;typeof U=="string"&&(U=t.wrap(U,G||"base64")),Z=(U=t.isByteBuffer(U)?U:t.wrap(U)).littleEndian;try{return ne=H.decode(U.LE()),U.LE(Z),ne}catch(ce){throw U.LE(Z),ce}},ie.decodeDelimited=function(U,G){var Z,ne,ce;if(typeof U=="string"&&(U=t.wrap(U,G||"base64")),(U=t.isByteBuffer(U)?U:t.wrap(U)).remaining()<1)return null;if(Z=U.offset,ne=U.readVarint32(),U.remaining()<ne)return U.offset=Z,null;try{return ce=H.decode(U.slice(U.offset,U.offset+ne).LE()),U.offset+=ne,ce}catch(ve){throw U.offset+=ne,ve}},ie.decode64=function(U){return ie.decode(U,"base64")},ie.decodeHex=function(U){return ie.decode(U,"hex")},ie.decodeJSON=function(U){return new ie(JSON.parse(U))},ee.toString=function(){return H.toString()},Object.defineProperty&&(Object.defineProperty(ie,"$options",{value:H.buildOpt()}),Object.defineProperty(ee,"$options",{value:ie.$options}),Object.defineProperty(ie,"$type",{value:H}),Object.defineProperty(ee,"$type",{value:H})),ie}(s,this),this._fields=[],this._fieldsById={},this._fieldsByName={},P=0,k=this.children.length;k>P;P++)if((N=this.children[P])instanceof R||N instanceof c||N instanceof M){if(T.hasOwnProperty(N.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+N.toString(!0)+" cannot override static property '"+N.name+"'");T[N.name]=N.build()}else if(N instanceof c.Field)N.build(),this._fields.push(N),this._fieldsById[N.id]=N,this._fieldsByName[N.name]=N;else if(!(N instanceof c.OneOf||N instanceof A))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[P].toString(!0));return this.clazz=T},p.encode=function(E,T,N){var P,k,B,H,q,J=null;for(B=0,H=this._fields.length;H>B;++B)k=E[(P=this._fields[B]).name],P.required&&k===null?J===null&&(J=P):P.encode(N?k:P.verifyValue(k),T,E);if(J!==null)throw(q=Error("Missing at least one required field for "+this.toString(!0)+": "+J)).encoded=T,q;return T},p.calculate=function(E){for(var T,N,P=0,k=0,B=this._fields.length;B>k;++k){if(N=E[(T=this._fields[k]).name],T.required&&N===null)throw Error("Missing at least one required field for "+this.toString(!0)+": "+T);P+=T.calculate(N,E)}return P},p.decode=function(E,T,N){var P,k,B,H,q,J,re,de,ue,ie,ee,U;for(T=typeof T=="number"?T:-1,q=E.offset,J=new this.clazz;E.offset<q+T||T===-1&&E.remaining()>0;){if(B=(P=E.readVarint32())>>>3,(k=7&P)===s.WIRE_TYPES.ENDGROUP){if(B!==N)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+B+" ("+(N?N+" expected":"not a group")+")");break}if(H=this._fieldsById[B])H.repeated&&!H.options.packed?J[H.name].push(H.decode(k,E)):H.map?(de=H.decode(k,E),J[H.name].set(de[0],de[1])):(J[H.name]=H.decode(k,E),H.oneof&&((ue=J[H.oneof.name])!==null&&ue!==H.name&&(J[ue]=null),J[H.oneof.name]=H.name));else switch(k){case s.WIRE_TYPES.VARINT:E.readVarint32();break;case s.WIRE_TYPES.BITS32:E.offset+=4;break;case s.WIRE_TYPES.BITS64:E.offset+=8;break;case s.WIRE_TYPES.LDELIM:re=E.readVarint32(),E.offset+=re;break;case s.WIRE_TYPES.STARTGROUP:for(;u(B,E););break;default:throw Error("Illegal wire type for unknown field "+B+" in "+this.toString(!0)+"#decode: "+k)}}for(ie=0,ee=this._fields.length;ee>ie;++ie)if(J[(H=this._fields[ie]).name]===null)if(this.syntax==="proto3")J[H.name]=H.defaultValue;else{if(H.required)throw(U=Error("Missing at least one required field for "+this.toString(!0)+": "+H.name)).decoded=J,U;s.populateDefaults&&H.defaultValue!==null&&(J[H.name]=H.defaultValue)}return J},w.Message=c,(m=(f=function(E,T,N,P,k,B,H,q,J,re){$.call(this,E,T,B),this.className="Message.Field",this.required=N==="required",this.repeated=N==="repeated",this.map=N==="map",this.keyType=P||null,this.type=k,this.resolvedType=null,this.id=H,this.options=q||{},this.defaultValue=null,this.oneof=J||null,this.syntax=re||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof c.ExtensionField||(this.name=s.Util.toCamelCase(this.name))}).prototype=Object.create($.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,T){var N,P,k;if(T=T||!1,N=function(B,H){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+B+" ("+H+")")}.bind(this),E===null)return this.required&&N(typeof E,"required"),this.syntax==="proto3"&&this.type!==s.TYPES.message&&N(typeof E,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!T){for(Array.isArray(E)||(E=[E]),k=[],P=0;P<E.length;P++)k.push(this.element.verifyValue(E[P]));return k}return this.map&&!T?E instanceof s.Map?E:(E instanceof Object||N(typeof E,"expected ProtoBuf.Map or raw object for map field"),new s.Map(this,E)):(!this.repeated&&Array.isArray(E)&&N(typeof E,"no array expected"),this.element.verifyValue(E))},m.hasWirePresence=function(E,T){if(this.syntax!=="proto3")return E!==null;if(this.oneof&&T[this.oneof.name]===this.name)return!0;switch(this.type){case s.TYPES.int32:case s.TYPES.sint32:case s.TYPES.sfixed32:case s.TYPES.uint32:case s.TYPES.fixed32:return E!==0;case s.TYPES.int64:case s.TYPES.sint64:case s.TYPES.sfixed64:case s.TYPES.uint64:case s.TYPES.fixed64:return E.low!==0||E.high!==0;case s.TYPES.bool:return E;case s.TYPES.float:case s.TYPES.double:return E!==0;case s.TYPES.string:return E.length>0;case s.TYPES.bytes:return E.remaining()>0;case s.TYPES.enum:return E!==0;case s.TYPES.message:return E!==null;default:return!0}},m.encode=function(E,T,N){var P,k,B,H,q;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 T;try{if(this.repeated)if(this.options.packed&&s.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(T.writeVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),T.ensureCapacity(T.offset+=1),k=T.offset,P=0;P<E.length;P++)this.element.encodeValue(this.id,E[P],T);B=T.offset-k,(H=t.calculateVarint32(B))>1&&(q=T.slice(k,T.offset),k+=H-1,T.offset=k,T.append(q)),T.writeVarint32(B,k-H)}else for(P=0;P<E.length;P++)T.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,E[P],T);else this.map?E.forEach(function(J,re){var de=t.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,re)+t.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,J);T.writeVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),T.writeVarint32(de),T.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,re,T),T.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,J,T)},this):this.hasWirePresence(E,N)&&(T.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,E,T))}catch(J){throw Error("Illegal value for "+this.toString(!0)+": "+E+" ("+J+")")}return T},m.calculate=function(E,T){var N,P,k;if(E=this.verifyValue(E),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 0;N=0;try{if(this.repeated)if(this.options.packed&&s.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(N+=t.calculateVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),k=0,P=0;P<E.length;P++)k+=this.element.calculateLength(this.id,E[P]);N+=t.calculateVarint32(k),N+=k}else for(P=0;P<E.length;P++)N+=t.calculateVarint32(this.id<<3|this.type.wireType),N+=this.element.calculateLength(this.id,E[P]);else this.map?E.forEach(function(B,H){var q=t.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,H)+t.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,B);N+=t.calculateVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),N+=t.calculateVarint32(q),N+=q},this):this.hasWirePresence(E,T)&&(N+=t.calculateVarint32(this.id<<3|this.type.wireType),N+=this.element.calculateLength(this.id,E))}catch(B){throw Error("Illegal value for "+this.toString(!0)+": "+E+" ("+B+")")}return N},m.decode=function(E,T,N){var P,k,B,H,q,J,re;if(!(!this.map&&E==this.type.wireType||!N&&this.repeated&&this.options.packed&&E==s.WIRE_TYPES.LDELIM||this.map&&E==s.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+E+" ("+this.type.wireType+" expected)");if(E==s.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&s.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!N){for(k=T.readVarint32(),k=T.offset+k,B=[];T.offset<k;)B.push(this.decode(this.type.wireType,T,!0));return B}if(this.map){if(H=h.defaultFieldValue(this.keyType),P=h.defaultFieldValue(this.type),k=T.readVarint32(),T.remaining()<k)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+k+" required but got only "+T.remaining());for((q=T.clone()).limit=q.offset+k,T.offset+=k;q.remaining()>0;)if(E=7&(J=q.readVarint32()),(re=J>>>3)==1)H=this.keyElement.decode(q,E,re);else{if(re!==2)throw Error("Unexpected tag in map field key/value submessage");P=this.element.decode(q,E,re)}return[H,P]}return this.element.decode(T,E,this.id)},w.Message.Field=f,(_=function(E,T,N,P,k,B,H){f.call(this,E,T,N,null,P,k,B,H),this.extension}).prototype=Object.create(f.prototype),w.Message.ExtensionField=_,v=function(E,T,N){$.call(this,E,T,N),this.fields=[]},w.Message.OneOf=v,(R=function(E,T,N,P,k){d.call(this,E,T,N,P,k),this.className="Enum",this.object=null}).getName=function(E,T){var N,P,k=Object.keys(E);for(P=0;P<k.length;++P)if(E[N=k[P]]===T)return N;return null},(R.prototype=Object.create(d.prototype)).build=function(E){var T,N,P,k;if(this.object&&!E)return this.object;for(T=new s.Builder.Enum,P=0,k=(N=this.getChildren(R.Value)).length;k>P;++P)T[N[P].name]=N[P].id;return Object.defineProperty&&Object.defineProperty(T,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=T},w.Enum=R,(C=function(E,T,N,P){$.call(this,E,T,N),this.className="Enum.Value",this.id=P}).prototype=Object.create($.prototype),w.Enum.Value=C,(A=function(E,T,N,P){$.call(this,E,T,N),this.field=P}).prototype=Object.create($.prototype),w.Extension=A,((M=function(E,T,N,P){d.call(this,E,T,N,P),this.className="Service",this.clazz=null}).prototype=Object.create(d.prototype)).build=function(E){return this.clazz&&!E?this.clazz:this.clazz=function(T,N){var P,k=function(q){T.Builder.Service.call(this),this.rpcImpl=q||function(J,re,de){setTimeout(de.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},B=k.prototype=Object.create(T.Builder.Service.prototype),H=N.getChildren(T.Reflect.Service.RPCMethod);for(P=0;P<H.length;P++)(function(q){B[q.name]=function(J,re){try{try{J=q.resolvedRequestType.clazz.decode(t.wrap(J))}catch(de){if(!(de instanceof TypeError))throw de}if(J===null||typeof J!="object")throw Error("Illegal arguments");J instanceof q.resolvedRequestType.clazz||(J=new q.resolvedRequestType.clazz(J)),this.rpcImpl(q.fqn(),J,function(de,ue){if(!de){try{ue=q.resolvedResponseType.clazz.decode(ue)}catch{}return ue&&ue instanceof q.resolvedResponseType.clazz?void re(null,ue):void re(Error("Illegal response type received in service method "+N.name+"#"+q.name))}re(de)})}catch(de){setTimeout(re.bind(this,de),0)}},k[q.name]=function(J,re,de){new k(J)[q.name](re,de)},Object.defineProperty&&(Object.defineProperty(k[q.name],"$options",{value:q.buildOpt()}),Object.defineProperty(B[q.name],"$options",{value:k[q.name].$options}))})(H[P]);return Object.defineProperty&&(Object.defineProperty(k,"$options",{value:N.buildOpt()}),Object.defineProperty(B,"$options",{value:k.$options}),Object.defineProperty(k,"$type",{value:N}),Object.defineProperty(B,"$type",{value:N})),k}(s,this)},w.Service=M,((O=function(E,T,N,P){$.call(this,E,T,N),this.className="Service.Method",this.options=P||{}}).prototype=Object.create($.prototype)).buildOpt=l.buildOpt,w.Service.Method=O,(y=function(E,T,N,P,k,B,H,q){O.call(this,E,T,N,q),this.className="Service.RPCMethod",this.requestName=P,this.responseName=k,this.requestStream=B,this.responseStream=H,this.resolvedRequestType=null,this.resolvedResponseType=null}).prototype=Object.create(O.prototype),w.Service.RPCMethod=y,w}(i),i.Builder=function(s,o,u){function d(a){a.messages&&a.messages.forEach(function(c){c.syntax=a.syntax,d(c)}),a.enums&&a.enums.forEach(function(c){c.syntax=a.syntax})}var l=function(a){this.ns=new u.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=a||{}},h=l.prototype;return l.isMessage=function(a){return typeof a.name=="string"&&a.values===void 0&&a.rpc===void 0},l.isMessageField=function(a){return typeof a.rule=="string"&&typeof a.name=="string"&&typeof a.type=="string"&&a.id!==void 0},l.isEnum=function(a){return typeof a.name=="string"&&!(a.values===void 0||!Array.isArray(a.values)||a.values.length===0)},l.isService=function(a){return!(typeof a.name!="string"||typeof a.rpc!="object"||!a.rpc)},l.isExtend=function(a){return typeof a.ref=="string"},h.reset=function(){return this.ptr=this.ns,this},h.define=function(a){if(typeof a!="string"||!o.TYPEREF.test(a))throw Error("illegal namespace: "+a);return a.split(".").forEach(function(c){var p=this.ptr.getChild(c);p===null&&this.ptr.addChild(p=new u.Namespace(this,this.ptr,c)),this.ptr=p},this),this},h.create=function(a){var c,p,f,m,_;if(!a)return this;if(Array.isArray(a)){if(a.length===0)return this;a=a.slice()}else a=[a];for(c=[a];c.length>0;){if(a=c.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 u.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 u.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 R=null;if(typeof v.oneof=="string"&&!(R=m[v.oneof]))throw Error("illegal oneof in "+f.name+"#"+v.name+": "+v.oneof);v=new u.Message.Field(this,f,v.rule,v.keytype,v.type,v.name,v.id,v.options,R,p.syntax),R&&R.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){c.push(a),a=_,_=null,this.ptr=f,f=null;continue}_=null}else if(l.isEnum(p))f=new u.Enum(this,this.ptr,p.name,p.options,p.syntax),p.values.forEach(function(v){f.addChild(new u.Enum.Value(this,f,v.name,v.id))},this),this.ptr.addChild(f);else if(l.isService(p))f=new u.Service(this,this.ptr,p.name,p.options),Object.keys(p.rpc).forEach(function(v){var R=p.rpc[v];f.addChild(new u.Service.RPCMethod(this,f,v,R.request,R.response,!!R.request_stream,!!R.response_stream,R.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 R,C,A,M;if(f.getChild(0|v.id)!==null)throw Error("duplicate extended field id in "+f.name+": "+v.id);if(f.extensions&&(R=!1,f.extensions.forEach(function(O){v.id>=O[0]&&v.id<=O[1]&&(R=!0)}),!R))throw Error("illegal extended field id in "+f.name+": "+v.id+" (not within valid ranges)");C=v.name,this.options.convertFieldsToCamelCase&&(C=s.Util.toCamelCase(C)),A=new u.Message.ExtensionField(this,f,v.rule,v.type,this.ptr.fqn()+"."+C,v.id,v.options),M=new u.Extension(this,this.ptr,v.name,A),A.extension=M,this.ptr.addChild(M),f.addChild(A)},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,c){var p,f,m,_,v,R,C,A,M="/";if(typeof c=="string"){if(s.Util.IS_NODE,this.files[c]===!0)return this.reset();this.files[c]=!0}else if(typeof c=="object"){if(p=c.root,s.Util.IS_NODE,(p.indexOf("\\")>=0||c.file.indexOf("\\")>=0)&&(M="\\"),f=p+M+c.file,this.files[f]===!0)return this.reset();this.files[f]=!0}if(a.imports&&a.imports.length>0){for(_=!1,typeof c=="object"?(this.importRoot=c.root,_=!0,m=this.importRoot,c=c.file,(m.indexOf("\\")>=0||c.indexOf("\\")>=0)&&(M="\\")):typeof c=="string"?this.importRoot?m=this.importRoot:c.indexOf("/")>=0?(m=c.replace(/\/[^\/]*$/,""))===""&&(m="/"):c.indexOf("\\")>=0?(m=c.replace(/\\[^\\]*$/,""),M="\\"):m=".":m=null,v=0;v<a.imports.length;v++)if(typeof a.imports[v]=="string"){if(!m)throw Error("cannot determine import root");if((R=a.imports[v])==="google/protobuf/descriptor.proto"||(R=m+M+R,this.files[R]===!0))continue;if(/\.proto$/i.test(R)&&!s.DotProto&&(R=R.replace(/\.proto$/,".json")),(C=s.Util.fetch(R))===null)throw Error("failed to import '"+R+"' in '"+c+"': file not found");/\.json$/i.test(R)?this.import(JSON.parse(C+""),R):this.import(s.DotProto.Parser.parse(C),R)}else c?/\.(\w+)$/.test(c)?this.import(a.imports[v],c.replace(/^(.+)\.(\w+)$/,function(O,y,w){return y+"_import"+v+"."+w})):this.import(a.imports[v],c+"_import"+v):this.import(a.imports[v]);_&&(this.importRoot=null)}return a.package&&this.define(a.package),a.syntax&&d(a),A=this.ptr,a.options&&Object.keys(a.options).forEach(function(O){A.options[O]=a.options[O]}),a.messages&&(this.create(a.messages),this.ptr=A),a.enums&&(this.create(a.enums),this.ptr=A),a.services&&(this.create(a.services),this.ptr=A),a.extends&&this.create(a.extends),this.reset()},h.resolveAll=function(){var a;if(this.ptr==null||typeof this.ptr.type=="object")return this;if(this.ptr instanceof u.Namespace)this.ptr.children.forEach(function(c){this.ptr=c,this.resolveAll()},this);else if(this.ptr instanceof u.Message.Field){if(o.TYPE.test(this.ptr.type))this.ptr.type=s.TYPES[this.ptr.type];else{if(!o.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(a=(this.ptr instanceof u.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0)))throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(this.ptr.resolvedType=a,a instanceof u.Enum){if(this.ptr.type=s.TYPES.enum,this.ptr.syntax==="proto3"&&a.syntax!=="proto3")throw Error("proto3 message cannot reference proto2 enum")}else{if(!(a instanceof u.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=a.isGroup?s.TYPES.group:s.TYPES.message}}if(this.ptr.map){if(!o.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=s.TYPES[this.ptr.keyType]}}else if(this.ptr instanceof s.Reflect.Service.Method){if(!(this.ptr instanceof s.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((a=this.ptr.parent.resolve(this.ptr.requestName,!0))&&a instanceof s.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=a,!((a=this.ptr.parent.resolve(this.ptr.responseName,!0))&&a instanceof s.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=a}else if(!(this.ptr instanceof s.Reflect.Message.OneOf||this.ptr instanceof s.Reflect.Extension||this.ptr instanceof s.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},h.build=function(a){var c,p,f;if(this.reset(),this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null),this.result===null&&(this.result=this.ns.build()),!a)return this.result;for(c=typeof a=="string"?a.split("."):a,p=this.result,f=0;f<c.length;f++){if(!p[c[f]]){p=null;break}p=p[c[f]]}return p},h.lookup=function(a,c){return a?this.ns.resolve(a,c):this.ns},h.toString=function(){return"Builder"},l.Message=function(){},l.Enum=function(){},l.Service=function(){},l}(i,i.Lang,i.Reflect),i.Map=function(s,o){function u(h){var a=0;return{next:function(){return a<h.length?{done:!1,value:h[a++]}:{done:!0}}}}var d=function(h,a){var c,p,f,m;if(!h.map)throw Error("field is not a map");if(this.field=h,this.keyElem=new o.Element(h.keyType,null,!0,h.syntax),this.valueElem=new o.Element(h.type,h.resolvedType,!1,h.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),a)for(c=Object.keys(a),p=0;p<c.length;p++)f=this.keyElem.valueFromString(c[p]),m=this.valueElem.verifyValue(a[c[p]]),this.map[this.keyElem.valueToString(f)]={key:f,value:m}},l=d.prototype;return l.clear=function(){this.map={}},l.delete=function(h){var a=this.keyElem.valueToString(this.keyElem.verifyValue(h)),c=a in this.map;return delete this.map[a],c},l.entries=function(){var h,a,c=[],p=Object.keys(this.map);for(a=0;a<p.length;a++)c.push([(h=this.map[p[a]]).key,h.value]);return u(c)},l.keys=function(){var h,a=[],c=Object.keys(this.map);for(h=0;h<c.length;h++)a.push(this.map[c[h]].key);return u(a)},l.values=function(){var h,a=[],c=Object.keys(this.map);for(h=0;h<c.length;h++)a.push(this.map[c[h]].value);return u(a)},l.forEach=function(h,a){var c,p,f=Object.keys(this.map);for(p=0;p<f.length;p++)h.call(a,(c=this.map[f[p]]).value,c.key,this)},l.set=function(h,a){var c=this.keyElem.verifyValue(h),p=this.valueElem.verifyValue(a);return this.map[this.keyElem.valueToString(c)]={key:c,value:p},this},l.get=function(h){var a=this.keyElem.valueToString(this.keyElem.verifyValue(h));return a in this.map?this.map[a].value:void 0},l.has=function(h){return this.keyElem.valueToString(this.keyElem.verifyValue(h))in this.map},d}(0,i.Reflect),i.loadProto=function(s,o,u){return(typeof o=="string"||o&&typeof o.file=="string"&&typeof o.root=="string")&&(u=o,o=void 0),i.loadJson(i.DotProto.Parser.parse(s),o,u)},i.protoFromString=i.loadProto,i.loadProtoFile=function(s,o,u){if(o&&typeof o=="object"?(u=o,o=null):o&&typeof o=="function"||(o=null),o)return i.Util.fetch(typeof s=="string"?s:s.root+"/"+s.file,function(l){if(l!==null)try{o(null,i.loadProto(l,u,s))}catch(h){o(h)}else o(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof s=="object"?s.root+"/"+s.file:s);return d===null?null:i.loadProto(d,u,s)},i.protoFromFile=i.loadProtoFile,i.newBuilder=function(s){return(s=s||{}).convertFieldsToCamelCase===void 0&&(s.convertFieldsToCamelCase=i.convertFieldsToCamelCase),s.populateAccessors===void 0&&(s.populateAccessors=i.populateAccessors),new i.Builder(s)},i.loadJson=function(s,o,u){return(typeof o=="string"||o&&typeof o.file=="string"&&typeof o.root=="string")&&(u=o,o=null),o&&typeof o=="object"||(o=i.newBuilder()),typeof s=="string"&&(s=JSON.parse(s)),o.import(s,u),o.resolveAll(),o},i.loadJsonFile=function(s,o,u){if(o&&typeof o=="object"?(u=o,o=null):o&&typeof o=="function"||(o=null),o)return i.Util.fetch(typeof s=="string"?s:s.root+"/"+s.file,function(l){if(l!==null)try{o(null,i.loadJson(JSON.parse(l),u,s))}catch(h){o(h)}else o(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof s=="object"?s.root+"/"+s.file:s);return d===null?null:i.loadJson(JSON.parse(d),u,s)},r=xo,i.loadProto(r,void 0,"").build("Modules").probuf}(function(n){function e(a){var c=0;return function(){return c<a.length?a.charCodeAt(c++):null}}function t(){var a=[],c=[];return function(){return arguments.length===0?c.join("")+u.apply(String,a):(a.length+arguments.length>1024&&(c.push(u.apply(String,a)),a.length=0),void Array.prototype.push.apply(a,arguments))}}function r(a,c,p,f,m){var _,v,R=8*m-f-1,C=(1<<R)-1,A=C>>1,M=-7,O=p?m-1:0,y=p?-1:1,w=a[c+O];for(O+=y,_=w&(1<<-M)-1,w>>=-M,M+=R;M>0;_=256*_+a[c+O],O+=y,M-=8);for(v=_&(1<<-M)-1,_>>=-M,M+=f;M>0;v=256*v+a[c+O],O+=y,M-=8);if(_===0)_=1-A;else{if(_===C)return v?NaN:1/0*(w?-1:1);v+=Math.pow(2,f),_-=A}return(w?-1:1)*v*Math.pow(2,_-f)}function i(a,c,p,f,m,_){var v,R,C,A=8*_-m-1,M=(1<<A)-1,O=M>>1,y=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=f?0:_-1,$=f?1:-1,Y=c<0||c===0&&1/c<0?1:0;for(c=Math.abs(c),isNaN(c)||1/0===c?(R=isNaN(c)?1:0,v=M):(v=Math.floor(Math.log(c)/Math.LN2),c*(C=Math.pow(2,-v))<1&&(v--,C*=2),(c+=v+O>=1?y/C:y*Math.pow(2,1-O))*C>=2&&(v++,C/=2),v+O>=M?(R=0,v=M):v+O>=1?(R=(c*C-1)*Math.pow(2,m),v+=O):(R=c*Math.pow(2,O-1)*Math.pow(2,m),v=0));m>=8;a[p+w]=255&R,w+=$,R/=256,m-=8);for(v=v<<m|R,A+=m;A>0;a[p+w]=255&v,w+=$,v/=256,A-=8);a[p+w-$]|=128*Y}var s,o,u,d,l,h=function(a,c,p){if(a===void 0&&(a=h.DEFAULT_CAPACITY),c===void 0&&(c=h.DEFAULT_ENDIAN),p===void 0&&(p=h.DEFAULT_NOASSERT),!p){if((a|=0)<0)throw RangeError("Illegal capacity");c=!!c,p=!!p}this.buffer=a===0?o:new ArrayBuffer(a),this.view=a===0?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=a,this.littleEndian=c,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,(s=h.prototype).__isByteBuffer__,Object.defineProperty(s,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),o=new ArrayBuffer(0),u=String.fromCharCode,h.accessor=function(){return Uint8Array},h.allocate=function(a,c,p){return new h(a,c,p)},h.concat=function(a,c,p,f){var m,_,v,R,C,A;for((typeof c=="boolean"||typeof c!="string")&&(f=p,p=c,c=void 0),m=0,v=0,R=a.length;R>v;++v)h.isByteBuffer(a[v])||(a[v]=h.wrap(a[v],c)),(_=a[v].limit-a[v].offset)>0&&(m+=_);if(m===0)return new h(0,p,f);for(A=new h(m,p,f),v=0;R>v;)(_=(C=a[v++]).limit-C.offset)<=0||(A.view.set(C.view.subarray(C.offset,C.limit),A.offset),A.offset+=_);return A.limit=A.offset,A.offset=0,A},h.isByteBuffer=function(a){return(a&&a.__isByteBuffer__)===!0},h.type=function(){return ArrayBuffer},h.wrap=function(a,c,p,f){var m,_;if(typeof c!="string"&&(f=p,p=c,c=void 0),typeof a=="string")switch(c===void 0&&(c="utf8"),c){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: "+c)}if(a===null||typeof a!="object")throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return(m=s.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;_<a.length;++_)m.view[_]=a[_]}return m},s.writeBitSet=function(a,c){var p,f,m,_,v,R,C=c===void 0;if(C&&(c=this.offset),!this.noAssert){if(!(a instanceof Array))throw TypeError("Illegal BitSet: Not an array");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}for(f=c,_=(m=a.length)>>3,v=0,c+=this.writeVarint32(m,c);_--;)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,c++);if(m>v){for(R=0,p=0;m>v;)p|=(1&!!a[v++])<<R++;this.writeByte(p,c++)}return C?(this.offset=c,this):c-f},s.readBitSet=function(a){var c,p,f,m,_,v,R,C=a===void 0;for(C&&(a=this.offset),m=(f=(p=this.readVarint32(a)).value)>>3,_=0,v=[],a+=p.length;m--;)c=this.readByte(a++),v[_++]=!!(1&c),v[_++]=!!(2&c),v[_++]=!!(4&c),v[_++]=!!(8&c),v[_++]=!!(16&c),v[_++]=!!(32&c),v[_++]=!!(64&c),v[_++]=!!(128&c);if(f>_)for(R=0,c=this.readByte(a++);f>_;)v[_++]=!!(1&c>>R++);return C&&(this.offset=a),v},s.readBytes=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+"+a+") <= "+this.buffer.byteLength)}return p=this.slice(c,c+a),f&&(this.offset+=a),p},s.writeBytes=s.append,s.writeInt8=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=1)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=1,this.view[c]=a,f&&(this.offset+=1),this},s.writeByte=s.writeInt8,s.readInt8=function(a){var c,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&(c=this.view[a]))==128&&(c=-(255-c+1)),p&&(this.offset+=1),c},s.readByte=s.readInt8,s.writeUint8=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=1)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=1,this.view[c]=a,f&&(this.offset+=1),this},s.writeUInt8=s.writeUint8,s.readUint8=function(a){var c,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 c=this.view[a],p&&(this.offset+=1),c},s.readUInt8=s.readUint8,s.writeInt16=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=2)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=2,this.littleEndian?(this.view[c+1]=(65280&a)>>>8,this.view[c]=255&a):(this.view[c]=(65280&a)>>>8,this.view[c+1]=255&a),f&&(this.offset+=2),this},s.writeShort=s.writeInt16,s.readInt16=function(a){var c,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 c=0,this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]),(32768&c)==32768&&(c=-(65535-c+1)),p&&(this.offset+=2),c},s.readShort=s.readInt16,s.writeUint16=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=2)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=2,this.littleEndian?(this.view[c+1]=(65280&a)>>>8,this.view[c]=255&a):(this.view[c]=(65280&a)>>>8,this.view[c+1]=255&a),f&&(this.offset+=2),this},s.writeUInt16=s.writeUint16,s.readUint16=function(a){var c,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 c=0,this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]),p&&(this.offset+=2),c},s.readUInt16=s.readUint16,s.writeInt32=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=4,this.littleEndian?(this.view[c+3]=255&a>>>24,this.view[c+2]=255&a>>>16,this.view[c+1]=255&a>>>8,this.view[c]=255&a):(this.view[c]=255&a>>>24,this.view[c+1]=255&a>>>16,this.view[c+2]=255&a>>>8,this.view[c+3]=255&a),f&&(this.offset+=4),this},s.writeInt=s.writeInt32,s.readInt32=function(a){var c,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 c=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),c|=0,p&&(this.offset+=4),c},s.readInt=s.readInt32,s.writeUint32=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=4,this.littleEndian?(this.view[c+3]=255&a>>>24,this.view[c+2]=255&a>>>16,this.view[c+1]=255&a>>>8,this.view[c]=255&a):(this.view[c]=255&a>>>24,this.view[c+1]=255&a>>>16,this.view[c+2]=255&a>>>8,this.view[c+3]=255&a),f&&(this.offset+=4),this},s.writeUInt32=s.writeUint32,s.readUint32=function(a){var c,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 c=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),p&&(this.offset+=4),c},s.readUInt32=s.readUint32,n&&(s.writeInt64=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=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 c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(c+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=8,f=a.low,m=a.high,this.littleEndian?(this.view[c+3]=255&f>>>24,this.view[c+2]=255&f>>>16,this.view[c+1]=255&f>>>8,this.view[c]=255&f,c+=4,this.view[c+3]=255&m>>>24,this.view[c+2]=255&m>>>16,this.view[c+1]=255&m>>>8,this.view[c]=255&m):(this.view[c]=255&m>>>24,this.view[c+1]=255&m>>>16,this.view[c+2]=255&m>>>8,this.view[c+3]=255&m,c+=4,this.view[c]=255&f>>>24,this.view[c+1]=255&f>>>16,this.view[c+2]=255&f>>>8,this.view[c+3]=255&f),_&&(this.offset+=8),this},s.writeLong=s.writeInt64,s.readInt64=function(a){var c,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 c=0,p=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=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,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),f=new n(c,p,!1),m&&(this.offset+=8),f},s.readLong=s.readInt64,s.writeUint64=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=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 c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(c+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=8,f=a.low,m=a.high,this.littleEndian?(this.view[c+3]=255&f>>>24,this.view[c+2]=255&f>>>16,this.view[c+1]=255&f>>>8,this.view[c]=255&f,c+=4,this.view[c+3]=255&m>>>24,this.view[c+2]=255&m>>>16,this.view[c+1]=255&m>>>8,this.view[c]=255&m):(this.view[c]=255&m>>>24,this.view[c+1]=255&m>>>16,this.view[c+2]=255&m>>>8,this.view[c+3]=255&m,c+=4,this.view[c]=255&f>>>24,this.view[c+1]=255&f>>>16,this.view[c+2]=255&f>>>8,this.view[c+3]=255&f),_&&(this.offset+=8),this},s.writeUInt64=s.writeUint64,s.readUint64=function(a){var c,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 c=0,p=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=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,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),f=new n(c,p,!0),m&&(this.offset+=8),f},s.readUInt64=s.readUint64),s.writeFloat32=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=4,i(this.view,a,c,this.littleEndian,23,4),f&&(this.offset+=4),this},s.writeFloat=s.writeFloat32,s.readFloat32=function(a){var c,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 c=r(this.view,a,this.littleEndian,23,4),p&&(this.offset+=4),c},s.readFloat=s.readFloat32,s.writeFloat64=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=8,i(this.view,a,c,this.littleEndian,52,8),f&&(this.offset+=8),this},s.writeDouble=s.writeFloat64,s.readFloat64=function(a){var c,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 c=r(this.view,a,this.littleEndian,52,8),p&&(this.offset+=8),c},s.readDouble=s.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)},s.writeVarint32=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}for((c+=f=h.calculateVarint32(a))>(m=this.buffer.byteLength)&&this.resize((m*=2)>c?m:c),c-=f,a>>>=0;a>=128;)p=128|127&a,this.view[c++]=p,a>>>=7;return this.view[c++]=a,_?(this.offset=c,this):f},s.writeVarint32ZigZag=function(a,c){return this.writeVarint32(h.zigZagEncode32(a),c)},s.readVarint32=function(a){var c,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;c=this.view[a++],p<5&&(f|=(127&c)<<7*p),++p}while((128&c)!=0);return f|=0,_?(this.offset=a,f):{value:f,length:p}},s.readVarint32ZigZag=function(a){var c=this.readVarint32(a);return typeof c=="object"?c.value=h.zigZagDecode32(c.value):c=h.zigZagDecode32(c),c},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 c=a.toInt()>>>0,p=a.shiftRightUnsigned(28).toInt()>>>0,f=a.shiftRightUnsigned(56).toInt()>>>0;return f==0?p==0?c<16384?c<128?1:2:1<<21>c?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()},s.writeVarint64=function(a,c){var p,f,m,_,v,R=c===void 0;if(R&&(c=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 c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+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,(c+=p)>(v=this.buffer.byteLength)&&this.resize((v*=2)>c?v:c),c-=p,p){case 10:this.view[c+9]=1&_>>>7;case 9:this.view[c+8]=p!==9?128|_:127&_;case 8:this.view[c+7]=p!==8?128|m>>>21:127&m>>>21;case 7:this.view[c+6]=p!==7?128|m>>>14:127&m>>>14;case 6:this.view[c+5]=p!==6?128|m>>>7:127&m>>>7;case 5:this.view[c+4]=p!==5?128|m:127&m;case 4:this.view[c+3]=p!==4?128|f>>>21:127&f>>>21;case 3:this.view[c+2]=p!==3?128|f>>>14:127&f>>>14;case 2:this.view[c+1]=p!==2?128|f>>>7:127&f>>>7;case 1:this.view[c]=p!==1?128|f:127&f}return R?(this.offset+=p,this):p},s.writeVarint64ZigZag=function(a,c){return this.writeVarint64(h.zigZagEncode64(a),c)},s.readVarint64=function(a){var c,p,f,m,_,v,R=a===void 0;if(R&&(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(c=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),R?(this.offset=a,v):{value:v,length:a-c}},s.readVarint64ZigZag=function(a){var c=this.readVarint64(a);return c&&c.value instanceof n?c.value=h.zigZagDecode64(c.value):c=h.zigZagDecode64(c),c}),s.writeCString=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=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 c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return f=l.calculateUTF16asUTF8(e(a))[1],c+=f+1,m=this.buffer.byteLength,c>m&&this.resize((m*=2)>c?m:c),c-=f+1,l.encodeUTF16toUTF8(e(a),function(v){this.view[c++]=v}.bind(this)),this.view[c++]=0,_?(this.offset=c,this):f},s.readCString=function(a){var c,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 c=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=t(),!0),m?(this.offset=a,p()):{string:p(),length:a-c}},s.writeIString=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}if(f=c,p=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],c+=4+p,m=this.buffer.byteLength,c>m&&this.resize((m*=2)>c?m:c),c-=4+p,this.littleEndian?(this.view[c+3]=255&p>>>24,this.view[c+2]=255&p>>>16,this.view[c+1]=255&p>>>8,this.view[c]=255&p):(this.view[c]=255&p>>>24,this.view[c+1]=255&p>>>16,this.view[c+2]=255&p>>>8,this.view[c+3]=255&p),c+=4,l.encodeUTF16toUTF8(e(a),function(v){this.view[c++]=v}.bind(this)),c!==f+4+p)throw RangeError("Illegal range: Truncated data, "+c+" == "+(c+4+p));return _?(this.offset=c,this):c-f},s.readIString=function(a){var c,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 c=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-c}},h.METRICS_CHARS="c",h.METRICS_BYTES="b",s.writeUTF8String=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return f=c,p=l.calculateUTF16asUTF8(e(a))[1],c+=p,m=this.buffer.byteLength,c>m&&this.resize((m*=2)>c?m:c),c-=p,l.encodeUTF16toUTF8(e(a),function(v){this.view[c++]=v}.bind(this)),_?(this.offset=c,this):c-f},s.writeString=s.writeUTF8String,h.calculateUTF8Chars=function(a){return l.calculateUTF16asUTF8(e(a))[0]},h.calculateUTF8Bytes=function(a){return l.calculateUTF16asUTF8(e(a))[1]},h.calculateString=h.calculateUTF8Bytes,s.readUTF8String=function(a,c,p){var f,m,_,v,R;if(typeof c=="number"&&(p=c,c=void 0),(f=p===void 0)&&(p=this.offset),c===void 0&&(c=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,c===h.METRICS_CHARS){if(m=t(),l.decodeUTF8(function(){return a>_&&p<this.limit?this.view[p++]:null}.bind(this),function(C){++_,l.UTF8toUTF16(C,m)}),_!==a)throw RangeError("Illegal range: Truncated data, "+_+" == "+a);return f?(this.offset=p,m()):{string:m(),length:p-v}}if(c===h.METRICS_BYTES){if(!this.noAssert){if(typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: "+p+" (not an integer)");if((p>>>=0)<0||p+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+"+a+") <= "+this.buffer.byteLength)}if(R=p+a,l.decodeUTF8toUTF16(function(){return R>p?this.view[p++]:null}.bind(this),m=t(),this.noAssert),p!==R)throw RangeError("Illegal range: Truncated data, "+p+" == "+R);return f?(this.offset=p,m()):{string:m(),length:p-v}}throw TypeError("Unsupported metrics: "+c)},s.readString=s.readUTF8String,s.writeVString=function(a,c){var p,f,m,_,v=c===void 0;if(v&&(c=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}if(m=c,p=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],f=h.calculateVarint32(p),c+=f+p,_=this.buffer.byteLength,c>_&&this.resize((_*=2)>c?_:c),c-=f+p,c+=this.writeVarint32(p,c),l.encodeUTF16toUTF8(e(a),function(R){this.view[c++]=R}.bind(this)),c!==m+p+f)throw RangeError("Illegal range: Truncated data, "+c+" == "+(c+p+f));return v?(this.offset=c,this):c-m},s.readVString=function(a){var c,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 c=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-c}},s.append=function(a,c,p){var f,m,_;if((typeof c=="number"||typeof c!="string")&&(p=c,c=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,c)),(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},s.appendTo=function(a,c){return a.append(this,c),this},s.assert=function(a){return this.noAssert=!a,this},s.capacity=function(){return this.buffer.byteLength},s.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},s.clone=function(a){var c=new h(0,this.littleEndian,this.noAssert);return a?(c.buffer=new ArrayBuffer(this.buffer.byteLength),c.view=new Uint8Array(c.buffer)):(c.buffer=this.buffer,c.view=this.view),c.offset=this.offset,c.markedOffset=this.markedOffset,c.limit=this.limit,c},s.compact=function(a,c){var p,f,m;if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}return a===0&&c===this.buffer.byteLength?this:(p=c-a)==0?(this.buffer=o,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,c)),this.buffer=f,this.view=m,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=p,this)},s.copy=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}if(a===c)return new h(0,this.littleEndian,this.noAssert);var p=c-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,c),f},s.copyTo=function(a,c,p,f){var m,_,v;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");if(c=(_=c===void 0)?a.offset:0|c,p=(m=p===void 0)?this.offset:0|p,f=f===void 0?this.limit:0|f,c<0||c>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+c+" <= "+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(c+v),a.view.set(this.view.subarray(p,f),c),m&&(this.offset+=v),_&&(a.offset+=v),this)},s.ensureCapacity=function(a){var c=this.buffer.byteLength;return a>c?this.resize((c*=2)>a?c:a):this},s.fill=function(a,c,p){var f=c===void 0;if(f&&(c=this.offset),typeof a=="string"&&a.length>0&&(a=a.charCodeAt(0)),c===void 0&&(c=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 c!="number"||c%1!=0)throw TypeError("Illegal begin: Not an integer");if(c>>>=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal end: Not an integer");if(p>>>=0,c<0||c>p||p>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+c+" <= "+p+" <= "+this.buffer.byteLength)}if(c>=p)return this;for(;p>c;)this.view[c++]=a;return f&&(this.offset=c),this},s.flip=function(){return this.limit=this.offset,this.offset=0,this},s.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},s.order=function(a){if(!this.noAssert&&typeof a!="boolean")throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!a,this},s.LE=function(a){return this.littleEndian=a===void 0||!!a,this},s.BE=function(a){return this.littleEndian=a!==void 0&&!a,this},s.prepend=function(a,c,p){var f,m,_,v,R;if((typeof c=="number"||typeof c!="string")&&(p=c,c=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,c)),(m=a.limit-a.offset)<=0||((_=m-p)>0?(v=new ArrayBuffer(this.buffer.byteLength+_),(R=new Uint8Array(v)).set(this.view.subarray(p,this.buffer.byteLength),m),this.buffer=v,this.view=R,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},s.prependTo=function(a,c){return a.prepend(this,c),this},s.printDebug=function(a){typeof a!="function"&&(a=console.log.bind(console)),a(this.toString()+`
- -------------------------------------------------------------------
- `+this.toDebug(!0))},s.remaining=function(){return this.limit-this.offset},s.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},s.resize=function(a){var c,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<a&&(c=new ArrayBuffer(a),(p=new Uint8Array(c)).set(this.view),this.buffer=c,this.view=p),this},s.reverse=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}return a===c||Array.prototype.reverse.call(this.view.subarray(a,c)),this},s.skip=function(a){if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var c=this.offset+a;if(!this.noAssert&&(c<0||c>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);return this.offset=c,this},s.slice=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}var p=this.clone();return p.offset=a,p.limit=c,p},s.toBuffer=function(a){var c,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?o:(c=new ArrayBuffer(f-p),new Uint8Array(c).set(new Uint8Array(this.buffer).subarray(p,f),0),c):this.buffer},s.toArrayBuffer=s.toBuffer,s.toString=function(a,c,p){if(a===void 0)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch(typeof a=="number"&&(p=c=a="utf8"),a){case"utf8":return this.toUTF8(c,p);case"base64":return this.toBase64(c,p);case"hex":return this.toHex(c,p);case"binary":return this.toBinary(c,p);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a)}},d=function(){var a,c,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,c=f.length;c>a;++a)m[f[a]]=a;return p.encode=function(_,v){for(var R,C;(R=_())!==null;)v(f[63&R>>2]),C=(3&R)<<4,(R=_())!==null?(v(f[63&((C|=15&R>>4)|15&R>>4)]),C=(15&R)<<2,(R=_())!==null?(v(f[63&(C|3&R>>6)]),v(f[63&R])):(v(f[63&C]),v(61))):(v(f[63&C]),v(61),v(61))},p.decode=function(_,v){function R(O){throw Error("Illegal character code: "+O)}for(var C,A,M;(C=_())!==null;)if((A=m[C])===void 0&&R(C),(C=_())!==null&&((M=m[C])===void 0&&R(C),v(A<<2>>>0|(48&M)>>4),(C=_())!==null)){if((A=m[C])===void 0){if(C===61)break;R(C)}if(v((15&M)<<4>>>0|(60&A)>>2),(C=_())!==null){if((M=m[C])===void 0){if(C===61)break;R(C)}v((3&A)<<6>>>0|M)}}},p.test=function(_){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(_)},p}(),s.toBase64=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),c|=0,(a|=0)<0||c>this.capacity||a>c)throw RangeError("begin, end");var p;return d.encode(function(){return c>a?this.view[a++]:null}.bind(this),p=t()),p()},h.fromBase64=function(a,c){if(typeof a!="string")throw TypeError("str");var p=new h(a.length/4*3,c),f=0;return d.decode(e(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()},s.toBinary=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),c|=0,(a|=0)<0||c>this.capacity()||a>c)throw RangeError("begin, end");if(a===c)return"";for(var p=[],f=[];c>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,c){if(typeof a!="string")throw TypeError("str");for(var p,f=0,m=a.length,_=new h(m,c);m>f;){if((p=a.charCodeAt(f))>255)throw RangeError("illegal char code: "+p);_.view[f++]=p}return _.limit=m,_},s.toDebug=function(a){for(var c,p=-1,f=this.buffer.byteLength,m="",_="",v="";f>p;){if(p!==-1&&(m+=(c=this.view[p])<16?"0"+c.toString(16).toUpperCase():c.toString(16).toUpperCase(),a&&(_+=c>32&&c<127?String.fromCharCode(c):".")),++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,c,p){for(var f,m,_=a.length,v=new h(0|(_+1)/3,c,p),R=0,C=0,A=!1,M=!1,O=!1,y=!1,w=!1;_>R;){switch(f=a.charAt(R++)){case"!":if(!p){if(M||O||y){w=!0;break}M=O=y=!0}v.offset=v.markedOffset=v.limit=C,A=!1;break;case"|":if(!p){if(M||y){w=!0;break}M=y=!0}v.offset=v.limit=C,A=!1;break;case"[":if(!p){if(M||O){w=!0;break}M=O=!0}v.offset=v.markedOffset=C,A=!1;break;case"<":if(!p){if(M){w=!0;break}M=!0}v.offset=C,A=!1;break;case"]":if(!p){if(y||O){w=!0;break}y=O=!0}v.limit=v.markedOffset=C,A=!1;break;case">":if(!p){if(y){w=!0;break}y=!0}v.limit=C,A=!1;break;case"'":if(!p){if(O){w=!0;break}O=!0}v.markedOffset=C,A=!1;break;case" ":A=!1;break;default:if(!p&&A){w=!0;break}if(m=parseInt(f+a.charAt(R++),16),!p&&(isNaN(m)||m<0||m>255))throw TypeError("Illegal str: Not a debug encoded string");v.view[C++]=m,A=!0}if(w)throw TypeError("Illegal str: Invalid symbol at "+R)}if(!p){if(!M||!y)throw TypeError("Illegal str: Missing offset or limit");if(C<v.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+C+" < "+_)}return v},s.toHex=function(a,c){if(a=a===void 0?this.offset:a,c=c===void 0?this.limit:c,!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}for(var p,f=new Array(c-a);c>a;)(p=this.view[a++])<16?f.push("0",p.toString(16)):f.push(p.toString(16));return f.join("")},h.fromHex=function(a,c,p){var f,m,_,v,R;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,c),v=0,R=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[R++]=f}return _.limit=R,_},l=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(c,p){var f=null;for(typeof c=="number"&&(f=c,c=function(){return null});f!==null||(f=c())!==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(c,p){for(var f,m,_,v,R=function(C){C=C.slice(0,C.indexOf(null));var A=Error(C.toString());throw A.name="TruncatedError",A.bytes=C,A};(f=c())!==null;)if((128&f)==0)p(f);else if((224&f)==192)(m=c())===null&&R([f,m]),p((31&f)<<6|63&m);else if((240&f)==224)((m=c())===null||(_=c())===null)&&R([f,m,_]),p((15&f)<<12|(63&m)<<6|63&_);else{if((248&f)!=240)throw RangeError("Illegal starting byte: "+f);((m=c())===null||(_=c())===null||(v=c())===null)&&R([f,m,_,v]),p((7&f)<<18|(63&m)<<12|(63&_)<<6|63&v)}},UTF16toUTF8:function(c,p){for(var f,m=null;(f=m!==null?m:c())!==null;)f>=55296&&f<=57343&&(m=c())!==null&&m>=56320&&m<=57343?(p(1024*(f-55296)+m-56320+65536),m=null):p(f);m!==null&&p(m)},UTF8toUTF16:function(c,p){var f=null;for(typeof c=="number"&&(f=c,c=function(){return null});f!==null||(f=c())!==null;)f<=65535?p(f):(p(55296+((f-=65536)>>10)),p(f%1024+56320)),f=null},encodeUTF16toUTF8:function(c,p){a.UTF16toUTF8(c,function(f){a.encodeUTF8(f,p)})},decodeUTF8toUTF16:function(c,p){a.decodeUTF8(c,function(f){a.UTF8toUTF16(f,p)})},calculateCodePoint:function(c){return c<128?1:c<2048?2:c<65536?3:4},calculateUTF8:function(c){for(var p,f=0;(p=c())!==null;)f+=p<128?1:p<2048?2:p<65536?3:4;return f},calculateUTF16asUTF8:function(c){var p=0,f=0;return a.UTF16toUTF8(c,function(m){++p,f+=m<128?1:m<2048?2:m<65536?3:4}),[p,f]}};return a}(),s.toUTF8=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}var p;try{l.decodeUTF8toUTF16(function(){return c>a?this.view[a++]:null}.bind(this),p=t())}catch{if(a!==c)throw RangeError("Illegal range: Truncated data, "+a+" != "+c)}return p()},h.fromUTF8=function(a,c,p){if(!p&&typeof a!="string")throw TypeError("Illegal str: Not a string");var f=new h(l.calculateUTF16asUTF8(e(a),!0)[1],c,p),m=0;return l.encodeUTF16toUTF8(e(a),function(_){f.view[m++]=_}),f.limit=m,f},h}(Vo=function(){function n(y,w,$){this.low=0|y,this.high=0|w,this.unsigned=!!$}function e(y){return(y&&y.__isLong__)===!0}function t(y,w){var $,Y,E;return w?(E=(y>>>=0)>=0&&y<256)&&(Y=d[y])?Y:($=i(y,(0|y)<0?-1:0,!0),E&&(d[y]=$),$):(E=(y|=0)>=-128&&y<128)&&(Y=u[y])?Y:($=i(y,y<0?-1:0,!1),E&&(u[y]=$),$)}function r(y,w){if(isNaN(y)||!isFinite(y))return w?m:f;if(w){if(y<0)return m;if(y>=a)return A}else{if(-c>=y)return M;if(y+1>=c)return C}return y<0?r(-y,w).neg():i(0|y%h,0|y/h,w)}function i(y,w,$){return new n(y,w,$)}function s(y,w,$){var Y,E,T,N,P,k,B;if(y.length===0)throw Error("empty string");if(y==="NaN"||y==="Infinity"||y==="+Infinity"||y==="-Infinity")return f;if(typeof w=="number"?($=w,w=!1):w=!!w,($=$||10)<2||$>36)throw RangeError("radix");if((Y=y.indexOf("-"))>0)throw Error("interior hyphen");if(Y===0)return s(y.substring(1),w,$).neg();for(E=r(l($,8)),T=f,N=0;N<y.length;N+=8)P=Math.min(8,y.length-N),k=parseInt(y.substring(N,N+P),$),P<8?(B=r(l($,P)),T=T.mul(B).add(r(k))):T=(T=T.mul(E)).add(r(k));return T.unsigned=w,T}function o(y){return y instanceof n?y:typeof y=="number"?r(y):typeof y=="string"?s(y):i(y.low,y.high,y.unsigned)}var u,d,l,h,a,c,p,f,m,_,v,R,C,A,M,O;return n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),n.isLong=e,u={},d={},n.fromInt=t,n.fromNumber=r,n.fromBits=i,l=Math.pow,n.fromString=s,n.fromValue=o,c=(a=(h=4294967296)*h)/2,p=t(16777216),f=t(0),n.ZERO=f,m=t(0,!0),n.UZERO=m,_=t(1),n.ONE=_,v=t(1,!0),n.UONE=v,R=t(-1),n.NEG_ONE=R,C=i(-1,2147483647,!1),n.MAX_VALUE=C,A=i(-1,-1,!0),n.MAX_UNSIGNED_VALUE=A,M=i(0,-2147483648,!1),n.MIN_VALUE=M,(O=n.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},O.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},O.toString=function(y){var w,$,Y,E,T,N,P,k;if((y=y||10)<2||y>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(M)?(w=r(y),Y=($=this.div(w)).mul(w).sub(this),$.toString(y)+Y.toInt().toString(y)):"-"+this.neg().toString(y);for(E=r(l(y,6),this.unsigned),T=this,N="";;){if(P=T.div(E),k=(T.sub(P.mul(E)).toInt()>>>0).toString(y),(T=P).isZero())return k+N;for(;k.length<6;)k="0"+k;N=""+k+N}},O.getHighBits=function(){return this.high},O.getHighBitsUnsigned=function(){return this.high>>>0},O.getLowBits=function(){return this.low},O.getLowBitsUnsigned=function(){return this.low>>>0},O.getNumBitsAbs=function(){var y,w;if(this.isNegative())return this.eq(M)?64:this.neg().getNumBitsAbs();for(y=this.high!=0?this.high:this.low,w=31;w>0&&(y&1<<w)==0;w--);return this.high!=0?w+33:w+1},O.isZero=function(){return this.high===0&&this.low===0},O.isNegative=function(){return!this.unsigned&&this.high<0},O.isPositive=function(){return this.unsigned||this.high>=0},O.isOdd=function(){return(1&this.low)==1},O.isEven=function(){return(1&this.low)==0},O.equals=function(y){return e(y)||(y=o(y)),(this.unsigned===y.unsigned||this.high>>>31!=1||y.high>>>31!=1)&&this.high===y.high&&this.low===y.low},O.eq=O.equals,O.notEquals=function(y){return!this.eq(y)},O.neq=O.notEquals,O.lessThan=function(y){return this.comp(y)<0},O.lt=O.lessThan,O.lessThanOrEqual=function(y){return this.comp(y)<=0},O.lte=O.lessThanOrEqual,O.greaterThan=function(y){return this.comp(y)>0},O.gt=O.greaterThan,O.greaterThanOrEqual=function(y){return this.comp(y)>=0},O.gte=O.greaterThanOrEqual,O.compare=function(y){if(e(y)||(y=o(y)),this.eq(y))return 0;var w=this.isNegative(),$=y.isNegative();return w&&!$?-1:!w&&$?1:this.unsigned?y.high>>>0>this.high>>>0||y.high===this.high&&y.low>>>0>this.low>>>0?-1:1:this.sub(y).isNegative()?-1:1},O.comp=O.compare,O.negate=function(){return!this.unsigned&&this.eq(M)?M:this.not().add(_)},O.neg=O.negate,O.add=function(y){var w,$,Y,E,T,N,P,k,B,H,q;return e(y)||(y=o(y)),w=this.high>>>16,$=65535&this.high,Y=this.low>>>16,E=65535&this.low,T=y.high>>>16,N=65535&y.high,P=y.low>>>16,k=0,B=0,H=0,q=0,H+=(q+=E+(65535&y.low))>>>16,B+=(H+=Y+P)>>>16,k+=(B+=$+N)>>>16,k+=w+T,i((H&=65535)<<16|(q&=65535),(k&=65535)<<16|(B&=65535),this.unsigned)},O.subtract=function(y){return e(y)||(y=o(y)),this.add(y.neg())},O.sub=O.subtract,O.multiply=function(y){var w,$,Y,E,T,N,P,k,B,H,q,J;return this.isZero()?f:(e(y)||(y=o(y)),y.isZero()?f:this.eq(M)?y.isOdd()?M:f:y.eq(M)?this.isOdd()?M:f:this.isNegative()?y.isNegative()?this.neg().mul(y.neg()):this.neg().mul(y).neg():y.isNegative()?this.mul(y.neg()).neg():this.lt(p)&&y.lt(p)?r(this.toNumber()*y.toNumber(),this.unsigned):(w=this.high>>>16,$=65535&this.high,Y=this.low>>>16,E=65535&this.low,T=y.high>>>16,N=65535&y.high,P=y.low>>>16,B=0,H=0,q=0,J=0,q+=(J+=E*(k=65535&y.low))>>>16,H+=(q+=Y*k)>>>16,q&=65535,H+=(q+=E*P)>>>16,B+=(H+=$*k)>>>16,H&=65535,B+=(H+=Y*P)>>>16,H&=65535,B+=(H+=E*N)>>>16,B+=w*k+$*P+Y*N+E*T,i((q&=65535)<<16|(J&=65535),(B&=65535)<<16|(H&=65535),this.unsigned)))},O.mul=O.multiply,O.divide=function(y){var w,$,Y,E,T,N,P;if(e(y)||(y=o(y)),y.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:f;if(this.unsigned){if(y.unsigned||(y=y.toUnsigned()),y.gt(this))return m;if(y.gt(this.shru(1)))return v;Y=m}else{if(this.eq(M))return y.eq(_)||y.eq(R)?M:y.eq(M)?_:(w=this.shr(1).div(y).shl(1)).eq(f)?y.isNegative()?_:R:($=this.sub(y.mul(w)),Y=w.add($.div(y)));if(y.eq(M))return this.unsigned?m:f;if(this.isNegative())return y.isNegative()?this.neg().div(y.neg()):this.neg().div(y).neg();if(y.isNegative())return this.div(y.neg()).neg();Y=f}for($=this;$.gte(y);){for(w=Math.max(1,Math.floor($.toNumber()/y.toNumber())),T=(E=Math.ceil(Math.log(w)/Math.LN2))<=48?1:l(2,E-48),P=(N=r(w)).mul(y);P.isNegative()||P.gt($);)P=(N=r(w-=T,this.unsigned)).mul(y);N.isZero()&&(N=_),Y=Y.add(N),$=$.sub(P)}return Y},O.div=O.divide,O.modulo=function(y){return e(y)||(y=o(y)),this.sub(this.div(y).mul(y))},O.mod=O.modulo,O.not=function(){return i(~this.low,~this.high,this.unsigned)},O.and=function(y){return e(y)||(y=o(y)),i(this.low&y.low,this.high&y.high,this.unsigned)},O.or=function(y){return e(y)||(y=o(y)),i(this.low|y.low,this.high|y.high,this.unsigned)},O.xor=function(y){return e(y)||(y=o(y)),i(this.low^y.low,this.high^y.high,this.unsigned)},O.shiftLeft=function(y){return e(y)&&(y=y.toInt()),(y&=63)==0?this:y<32?i(this.low<<y,this.high<<y|this.low>>>32-y,this.unsigned):i(0,this.low<<y-32,this.unsigned)},O.shl=O.shiftLeft,O.shiftRight=function(y){return e(y)&&(y=y.toInt()),(y&=63)==0?this:y<32?i(this.low>>>y|this.high<<32-y,this.high>>y,this.unsigned):i(this.high>>y-32,this.high>=0?0:-1,this.unsigned)},O.shr=O.shiftRight,O.shiftRightUnsigned=function(y){var w;return e(y)&&(y=y.toInt()),(y&=63)==0?this:(w=this.high,y<32?i(this.low>>>y|w<<32-y,w>>>y,this.unsigned):i(y===32?w:w>>>y-32,0,this.unsigned))},O.shru=O.shiftRightUnsigned,O.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},O.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},O.toBytes=function(y){return y?this.toBytesLE():this.toBytesBE()},O.toBytesLE=function(){var y=this.high,w=this.low;return[255&w,255&w>>>8,255&w>>>16,255&w>>>24,255&y,255&y>>>8,255&y>>>16,255&y>>>24]},O.toBytesBE=function(){var y=this.high,w=this.low;return[255&y>>>24,255&y>>>16,255&y>>>8,255&y,255&w>>>24,255&w>>>16,255&w>>>8,255&w]},n}()),Vo));qi.getModule=function(n){var e=new qi[n];return e.getArrayData=function(){var t=e.toArrayBuffer();return t=Ya(t)?[].slice.call(new Int8Array(t)):t},e};var Gi,ld="pgMsgP",hd="chatMsg",pd="pcMsgP",fd={PRIVATE:"ppMsgS",GROUP:"pgMsgS",CHATROOM:"chatMsgS"},gd="delMsg",md="joinChrm",_d="joinChrmR",vd="exitChrm",Rd="setKV",Ed="delKV",Cd="setKVS",yd="delKVS",Bo="qryRelationR",Td="delRelation",Sd="setSeAtt",er={PRIVATE:"cleanPMsg",GROUP:"cleanGMsg",CUSTOMER_SERVICE:"cleanCMsg",SYSTEM:"cleanSMsg"},ac="qryPMsg",Id="qryGMsg",cc="qryCHMsg",bd="qryCMsg",Od="qrySMsg",Nd=((hn={}).ppMsgP=z.PRIVATE,hn[ld]=z.GROUP,hn[hd]=z.CHATROOM,hn[pd]=z.CUSTOMER_SERVICE,hn),wd=(($t={})[z.PRIVATE]=ac,$t[z.GROUP]=Id,$t[z.CHATROOM]=cc,$t[z.CUSTOMER_SERVICE]=bd,$t[z.SYSTEM]=Od,$t),Ad=((pn={})[z.PRIVATE]=er.PRIVATE,pn[z.GROUP]=er.GROUP,pn[z.CUSTOMER_SERVICE]=er.CUSTOMER_SERVICE,pn[z.SYSTEM]=er.SYSTEM,pn),gi="1",Md="0",Fo=1,Ho=2,$o=3,Pd=function(){function n(e){this._codec=e==="websocket"?qi:xn,this._connectType=e}return n.prototype.decodeByPBName=function(e,t,r){var i,s=this,o=e,u=((i={})[kn]=s._formatSyncMessages,i[Jr]=s._formatReceivedMessage,i[Ln]=s._formatSentMessage,i[Un]=s._formatHistoryMessages,i[Dn]=s._formatConversationList,i[Wr]=s._formatChatRoomInfos,i[kt]=s._formatRTCUserList,i[Qr]=s._formatRTCData,i[Wt]=s._formatChatRoomKVList,i[Xr]=s._formatUserSetting,i[ei]=s._formatConversationStatus,i[ti]=s._formatGrpReadReceiptQryResp,i[zt]=s._formatSetUserSettingOutput,i[Zr]=s._formatUserSettingNotification,i[ni]=s._formatRTCRoomKVList,i[zr]=s._formatRTCAuidenceJoinRoomData,i[ri]=s._formatRTCJoinedUserInfo,i)[t];try{o=e.length>0&&s._codec[t].decode(e),Ve(o)&&(o=function(d){for(var l in d)Ve(d[l])&&(d[l]=Ze(d[l]));return d}(o)),Ir(u)&&(o=u.call(this,o,r))}catch(d){j.error(`PB parse error
- `,d,e,t)}return o},n.prototype._readBytes=function(e){var t=e.offset,r=e.buffer,i=e.limit;if(t)try{var s=Ya(r)?new Uint8Array(r):r;return Kn.readUTF(s.subarray(t,i))}catch(o){j.info(`readBytes error
- `,o)}return e},n.prototype._formatBytes=function(e){var t=this._readBytes(e);try{t=JSON.parse(t)}catch(r){j.info(`formatBytes error
- `,r)}return t||e},n.prototype._formatSyncMessages=function(e,t){t=t||{};var r=this,i=e.list,s=e.syncTime,o=e.finished;return(fe(o)||o===null)&&(e.finished=!0),e.syncTime=Ze(s),e.list=Zn(i,function(u){return r._formatReceivedMessage(u,t)}),e},n.prototype._formatReceivedMessage=function(e,t){var r=(t=t||{}).currentUserId,i=t.connectedTime,s=e.content,o=e.fromUserId,u=e.type,d=e.groupId,l=e.status,h=e.dataTime,a=e.classname,c=e.msgId,p=e.extraContent,f=e.pushContent,m=e.pushExt,_=e.configFlag,v=(e.direction||nt.RECEIVE)===nt.SEND,R=function(ie){var ee=Mn.READ;return{isPersited:!!(16&ie),isCounted:!!(32&ie),isMentioned:!!(64&ie),disableNotification:!!(512&ie),receivedStatus:ee=2&ie?Mn.RETRIEVED:ee,canIncludeExpansion:!!(1024&ie)}}(l),C=R.isPersited,A=R.isCounted,M=R.isMentioned,O=R.disableNotification,y=R.receivedStatus,w=R.canIncludeExpansion,$=[z.GROUP,z.CHATROOM,z.RTC_ROOM].indexOf(u)>-1?d:o,Y=v?r:o,E=Ze(h),T=E<i,N=u===z.CHATROOM,P=this._formatBytes(s),k={};if(m&&(k=Lo(m.pushConfigs,m.pushId)),P.user){var B=P.user,H=B.portrait,q=B.portraitUri,J=H||q;J&&(P.user.portrait=P.user.portraitUri=J)}var re,de=Re(Re({},k),{pushTitle:m==null?void 0:m.title,pushContent:f,pushData:f,disablePushTitle:!!_&&Boolean(4&_),forceShowDetailContent:!!_&&Boolean(8&_),templateId:m==null?void 0:m.templateId}),ue=v?nt.SEND:nt.RECEIVE;return N&&o===r&&(ue=nt.SEND),p&&(re={},re=Uo(p)),{conversationType:u,targetId:$,senderUserId:Y,messageType:a,messageUId:c,isPersited:C,isCounted:A,isMentioned:M,sentTime:E,isOffLineMessage:T,messageDirection:ue,receivedTime:qt.getTime(),disableNotification:O,receivedStatus:y,canIncludeExpansion:w,content:P,expansion:re,configFlag:_,pushConfig:de,channelId:e.busChannel||""}},n.prototype._formatSentMessage=function(e,t){var r,i=e.content,s=e.classname,o=e.sessionId,u=e.msgId,d=e.extraContent,l=e.pushExt,h=e.pushContent,a=e.configFlag,c=t.signal,p=t.currentUserId,f=c.date,m=c.topic,_=c.targetId,v=function(T){return{isPersited:!!(1&T),isCounted:!!(2&T),disableNotification:!!(32&T),canIncludeExpansion:!!(64&T)}}(o),R=v.isPersited,C=v.isCounted,A=v.disableNotification,M=v.canIncludeExpansion,O=Nd[m]||z.PRIVATE,y=id(fd,m),w=this._formatBytes(i),$=_;s===He.RECALL&&(O=w.conversationType||O,$=w.targetId||_),d&&(r={},r=Uo(d));var Y={};l&&(Y=Lo(l.pushConfigs,l.pushId));var E=Re(Re({},Y),{pushTitle:l==null?void 0:l.title,pushContent:h,pushData:h,disablePushTitle:!!a&&Boolean(4&a),forceShowDetailContent:!!a&&Boolean(8&a),templateId:l==null?void 0:l.templateId});return{conversationType:O,targetId:$,messageType:s,messageUId:u,isPersited:R,isCounted:C,isStatusMessage:y,senderUserId:p,content:this._formatBytes(i),sentTime:1e3*f,receivedTime:qt.getTime(),messageDirection:nt.SEND,isOffLineMessage:!1,disableNotification:A,canIncludeExpansion:M,expansion:r,pushConfig:E,channelId:e.busChannel||""}},n.prototype._formatHistoryMessages=function(e,t){var r=this,i=t.conversation||{},s=e.list,o=e.hasMsg,u=i.targetId,d=Ze(e.syncTime),l=[];return Oe(s,function(h){var a=r._formatReceivedMessage(h,t);a.targetId=u,l.push(a)},{isReverse:!0}),{syncTime:d,list:l,hasMore:!!o}},n.prototype._formatConversationList=function(e,t){var r=this,i=e.info,s=t.afterDecode||function(){};return(i=Zn(i,function(o){var u=o.msg,d=o.userId,l=o.type,h=o.unreadCount,a=o.busChannel,c=null;u&&((c=r._formatReceivedMessage(u,t)).targetId=d);var p={targetId:d,conversationType:l,unreadMessageCount:h,latestMessage:c,channelId:a||""};return s(p)||p}))||[]},n.prototype._formatSetUserSettingOutput=function(e){return e},n.prototype._formatChatRoomInfos=function(e){var t=e.userTotalNums,r=e.userInfos;return{userCount:t,userInfos:Zn(r,function(i){var s=i.id,o=i.time;return{id:s,time:Ze(o)}})}},n.prototype._formatChatRoomKVList=function(e){var t=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:t=Zn(t=t||[],function(s){var o=s.key,u=s.value,d=s.status,l=s.timestamp,h=s.uid,a=function(c){return{isAutoDelete:!!(1&c),isOverwrite:!!(2&c),type:4&c?We.DELETE:We.UPDATE}}(d);return{key:o,value:u,isAutoDelete:a.isAutoDelete,isOverwrite:a.isOverwrite,type:a.type,userId:h,timestamp:Ze(l)}}),isFullUpdate:r,syncTime:i}},n.prototype._formatUserSetting=function(e){var t=this,r=e.items,i=e.version,s={};return Oe(r||[],function(o){var u=o.key,d=o.version,l=o.value;o.version=Ze(d),o.value=t._readBytes(l),u==="Tag"&&o.tags.forEach(function(h){h.createdTime=Ze(h.createdTime),h.tagName=h.name}),s[u]=o}),{settings:s,version:i}},n.prototype._formatConversationStatus=function(e){var t=e.state,r=[];return Oe(t,function(i){var s=i.type,o=i.channelId,u=i.time,d=i.stateItem,l=i.busChannel,h=Kt.CLOSE,a=!1,c=[];Oe(d,function(p){var f=p.sessionStateType,m=p.value,_=p.tags;switch(f){case Fo:h=m===gi?Kt.OPEN:Kt.CLOSE;break;case Ho:a=m===gi;break;case $o:c=_}}),r.push({conversationType:s,type:s,targetId:o,notificationStatus:h,isTop:a,updatedTime:Ze(u),tags:c,channelId:l||""})}),r},n.prototype._formatRTCUserList=function(e){var t=e.users,r=e.token,i=e.sessionId,s=e.roomInfo,o=e.entries,u={};return Oe(t,function(d){var l=d.userId,h=d.userData,a={};Oe(h,function(c){var p=c.key,f=c.value;a[p]=f}),u[l]=a}),{users:u,token:r,sessionId:i,roomInfo:s,kvEntries:o}},n.prototype._formatRTCData=function(e){var t=e.outInfo,r={};return Oe(t,function(i){r[i.key]=i.value}),r},n.prototype._formatRTCRoomInfo=function(e){var t=e.roomId,r=e.userCount,i=e.roomData,s={id:t,total:r};return Oe(i,function(o){s[o.key]=o.value}),s},n.prototype._formatGrpReadReceiptQryResp=function(e){var t=e.totalMemberNum,r=e.list;return r.forEach(function(i){i.readTime=Ze(i.readTime)}),{totalMemberCount:t,list:r}},n.prototype._formatUserSettingNotification=function(e){return e},n.prototype._formatRTCRoomKVList=function(e){var t=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:t=(t=t||[]).map(function(s){var o=s.timestamp;return Object.assign(s,{timestamp:Ze(o)})}),isFullUpdate:r,syncTime:i}},n.prototype._formatRTCAuidenceJoinRoomData=function(e){return e},n.prototype._formatRTCJoinedUserInfo=function(e){return(e.info||[]).map(function(t){return{deviceId:t.deviceId,roomId:t.roomId,joinTime:Ze(t.joinTime)}})},n.prototype.encodeServerConfParams=function(){var e=this._codec.getModule(_s);return e.setNothing(1),e.getArrayData()},n.prototype._getUpMsgModule=function(e,t){var r,i,s,o=this._connectType==="comet",u=(e.conversationType,t.messageType),d=t.isMentioned,l=t.mentionedType,h=t.mentionedUserIdList,a=t.content,c=t.pushContent,p=t.pushData,f=t.directionalUserIdList,m=t.isFilerWhiteBlacklist,_=t.isVoipPush,v=t.canIncludeExpansion,R=t.expansion,C=t.pushConfig,A=t.channelId;z.GROUP;var M=this._codec.getModule(Ln),O=function(ue){var ie=ue.isStatusMessage,ee=ue.isPersited,U=ue.isCounted;ie&&(ee=U=!1);var G=0;return ee&&(G|=1),U&&(G|=2),ue.isMentioned&&(G|=4),ue.disableNotification&&(G|=32),ue.canIncludeExpansion&&(G|=64),G}(t),y=C||{},w=y.pushTitle,$=y.pushContent,Y=y.pushData,E=y.iOSConfig,T=y.androidConfig,N=y.templateId,P=y.disablePushTitle,k=y.forceShowDetailContent,B=0;M.setSessionId(O),d&&a&&(a.mentionedInfo={userIdList:((r=a.mentionedInfo)===null||r===void 0?void 0:r.userIdList)||h||[],type:((i=a.mentionedInfo)===null||i===void 0?void 0:i.type)||l||fs.ALL,mentionedContent:((s=a.mentionedInfo)===null||s===void 0?void 0:s.mentionedContent)||""});var H=$||c||"",q=Y||p||"";if(H&&M.setPushText(H),q&&M.setAppData(q),f&&M.setUserId(f),B|=_?1:0,B|=m?2:0,B|=P?4:0,B|=k?8:0,M.setConfigFlag(B),M.setClassname(u),a.user&&a.user.portraitUri&&(a.user.portrait=a.user.portraitUri),M.setContent(JSON.stringify(a)),v&&R){var J={};Oe(R,function(ue,ie){J[ie]={v:ue}}),M.setExtraContent(JSON.stringify(J))}if(C){var re=this._codec.getModule(ms);if(w&&re.setTitle(w),E&&T){var de=nd(E,T);re.setPushConfigs(de)}(T==null?void 0:T.notificationId)&&re.setPushId(T==null?void 0:T.notificationId),re.setTemplateId(N||""),M.setPushExt(o?re.getArrayData():re)}return fe(A)||M.setBusChannel(A),M},n.prototype.encodeUpMsg=function(e,t){return this._getUpMsgModule(e,t).getArrayData()},n.prototype.encodeSyncMsg=function(e){var t=e.sendboxTime,r=e.inboxTime,i=this._codec.getModule(vs);return i.setIspolling(!1),i.setIsPullSend(!0),i.setSendBoxSyncTime(t),i.setSyncTime(r),i.getArrayData()},n.prototype.encodeChrmSyncMsg=function(e,t){e=e||0,t=t||0;var r=this._codec.getModule(Rs);return r.setCount(t),r.setSyncTime(e),r.getArrayData()},n.prototype.encodeGetHistoryMsg=function(e,t){var r=t.count,i=t.order,s=t.timestamp,o=t.channelId,u=this._codec.getModule(Es);return u.setTargetId(e),u.setTime(s),u.setCount(r),u.setOrder(i),u.setBusChannel(o||""),u.getArrayData()},n.prototype.encodeGetConversationList=function(e){var t=(e=e||{}).count,r=e.startTime,i=this._codec.getModule(Nr);return i.setType(1),i.setCount(t),i.setStartTime(r),i.getArrayData()},n.prototype.encodeOldConversationList=function(e){var t=(e=e||{}).count,r=e.type,i=e.startTime,s=e.order;t=t||0,i=i||0,s=s||0;var o=this._codec.getModule(Nr);return o.setType(r),o.setCount(t),o.setStartTime(i),o.setOrder(s),o.getArrayData()},n.prototype.encodeRemoveOldConversationList=function(e){var t=(e=e||{}).conversationType,r=e.channelId,i=this._codec.getModule(Ts);return i.setType(t),i.setBusChannel(r),i.getArrayData()},n.prototype.encodeRemoveConversationList=function(e){var t=this,r=this._codec.getModule(Cs),i=[];return Oe(e,function(s){var o=s.conversationType,u=s.targetId,d=t._codec.getModule(ys);d.setType(o),d.setChannelId(u),i.push(d)}),r.setSessions(i),r.getArrayData()},n.prototype.encodeDeleteMessages=function(e,t,r,i){var s=this._codec.getModule(Ss),o=[];return Oe(r,function(u){o.push({msgId:u.messageUId,msgDataTime:u.sentTime,direct:u.messageDirection})}),s.setType(e),s.setConversationId(t),s.setMsgs(o),s.setBusChannel(i),s.getArrayData()},n.prototype.encodeClearMessages=function(e,t,r){var i=this._codec.getModule(Is);return t=t||new Date().getTime(),i.setDataTime(t),i.setTargetId(e),i.setBusChannel(r),i.getArrayData()},n.prototype.encodeClearUnreadCount=function(e,t){var r=e.conversationType,i=e.targetId,s=t.timestamp,o=this._codec.getModule(bs);return s=s||+new Date,o.setType(r),o.setChannelId(i),o.setMsgTime(s),o.getArrayData()},n.prototype.encodeJoinOrQuitChatRoom=function(){var e=this._codec.getModule(Os);return e.setNothing(1),e.getArrayData()},n.prototype.encodeGetChatRoomInfo=function(e,t){var r=this._codec.getModule(ws);return r.setCount(e),r.setOrder(t),r.getArrayData()},n.prototype.encodeGetFileToken=function(e,t,r,i){var s=this._codec.getModule(xs);return s.setType(e),s.setKey(t),s.setHttpMethod(r),s.setQueryString(i),s.getArrayData()},n.prototype.encodeGetFileUrl=function(e,t,r,i){var s=this._codec.getModule(e);return s.setType(t),s.setKey(r),i&&s.setFileName(i),s.getArrayData()},n.prototype.encodeModifyChatRoomKV=function(e,t,r){var i=this._connectType==="comet",s=this._codec.getModule(js),o=t.key,u=t.value,d=t.notificationExtra,l=t.isSendNotification,h=t.type||We.UPDATE,a=Do(t,h),c={key:o,value:u||"",uid:r};if(fe(a)||(c.status=a),s.setEntry(c),l){var p={conversationType:z.CHATROOM,targetId:e},f={key:o,value:u,extra:d,type:h},m=this._getUpMsgModule(p,{messageType:He.CHRM_KV_NOTIFY,content:f,isPersited:!1,isCounted:!1});i?s.setNotification(m.getArrayData()):s.setNotification(m),s.setBNotify(!0),s.setType(z.CHATROOM)}return s.getArrayData()},n.prototype.encodeModifyChatRoomKVS=function(e,t,r){this._connectType;var i=this._codec.getModule(Ks),s=t.entries,o=t.type||We.UPDATE,u=Do(t,o),d=[];return s.forEach(function(l){var h={key:l.key,value:l.value||"",uid:r};fe(u)||(h.status=u),d.push(h)}),i.setEntry(d),i.getArrayData()},n.prototype.encodePullChatRoomKV=function(e){var t=this._codec.getModule(Gs);return t.setTimestamp(e),t.getArrayData()},n.prototype.encodePullUserSetting=function(e){var t=this._codec.getModule(Ys);return t.setVersion(e),t.getArrayData()},n.prototype.encodeGetConversationStatus=function(e){var t=this._codec.getModule(Js);return t.setTime(e),t.getArrayData()},n.prototype.encodeSetConversationStatus=function(e){var t=this,r=this._connectType==="comet",i=this._codec.getModule(kr),s=qt.getTime(),o=[];return Oe(e,function(u){var d=t._codec.getModule(Pr),l=u.conversationType,h=u.targetId,a=u.notificationStatus,c=u.isTop,p=u.channelId,f=[];d.setType(l),d.setChannelId(h),d.setTime(s),d.setBusChannel(p);var m=a===Kt.OPEN,_={};fe(a)||(_[Fo]=m),fe(c)||(_[Ho]=c),Oe(_,function(R,C){if(!fe(R)){var A=t._codec.getModule(Lr);R=R?gi:Md,A.setSessionStateType(Number(C)),A.setValue(R);var M=r?A.getArrayData():A;f.push(M)}}),d.setStateItem(f);var v=r?d.getArrayData():d;o.push(v)}),i.setVersion(s),i.setState(o),i.getArrayData()},n.prototype.encodeReadReceipt=function(e,t){var r=this._codec.getModule(Ur);return r.setMsgId(e),t&&r.setChannelId(t),r.getArrayData()},n.prototype.encodeCreateTag=function(e,t){var r=this,i=this._connectType==="comet",s=this._codec.getModule(zs),o=[];return e.forEach(function(u){var d=r._codec.getModule(In);d.setTagId(u.tagId),d.setName(u.tagName),o.push(i?d.getArrayData():d)}),s.setTags(o),s.setVersion(t),s.getArrayData()},n.prototype.encodeMessageReader=function(e,t){var r=this._codec.getModule(Ur);return r.setMsgId(e),t&&r.setChannelId(t),r.getArrayData()},n.prototype.encodeRemoveTag=function(e,t){var r=this,i=this._connectType==="comet",s=this._codec.getModule(Qs),o=[];return e.forEach(function(u){var d=r._codec.getModule(In);d.setTagId(u),o.push(i?d.getArrayData():d)}),s.setTags(o),s.setVersion(t),s.getArrayData()},n.prototype.encodeDisConversationTag=function(e){var t=this._codec.getModule(Xs);return t.setTagId(e),t.getArrayData()},n.prototype.encodeUpdateConversationTag=function(e,t){var r=this,i=this._connectType==="comet",s=this._codec.getModule(kr),o=[];return t.forEach(function(u){var d=r._codec.getModule(Pr),l=r._codec.getModule(Lr),h=[];e.forEach(function(a){var c=r._codec.getModule(In);c.setTagId(a.tagId),fe(a.isTop)||c.setIsTop(a.isTop),h.push(i?c.getArrayData():c)}),l.setSessionStateType($o),l.setValue(JSON.stringify(h)),l.setTags(h),d.setType(u.conversationType),d.setChannelId(u.targetId),d.setTime(Date.now()),d.setStateItem([i?l.getArrayData():l]),o.push(i?d.getArrayData():d)}),s.setState(o),s.setVersion(qt.getTime()),s.getArrayData()},n.prototype.encodeReportSDKInfo=function(e){var t=this._codec.getModule(Zs);return t.setSdkInfo(e),t.getArrayData()},n.prototype.encodeJoinRTCRoom=function(e,t,r){var i=this._codec.getModule(wr);return e=e||0,i.setRoomType(e),fe(t)||i.setBroadcastType(t),fe(r)||i.setJoinType(r),i.getArrayData()},n.prototype.encodeQuitRTCRoom=function(){return this._codec.getModule(As).getArrayData()},n.prototype.encodeSetRTCData=function(e,t,r,i,s){var o=this._codec.getModule(Ms);if(o.setInterior(r),o.setTarget(i),o.setKey(e),o.setValue(t),s){s.name&&o.setObjectName(s.name);var u=s.content;u&&(Ve(u)&&(u=JSON.stringify(u)),o.setContent(u))}return o.getArrayData()},n.prototype.encodeUserSetRTCData=function(e,t,r,i){var s=this,o=this._connectType==="comet",u=this._codec.getModule(Ar);u.setObjectName(r);var d=this._codec.getModule(et);d.setKey(e.name),d.setValue(e.content),o?u.setContent([d.getArrayData()]):u.setContent(d);var l=[];return["uris","mcu_uris"].forEach(function(h){var a=s._codec.getModule(et);a.setKey(h);var c=h==="uris"?t:i;a.setValue(c),o?l.push(a.getArrayData()):l.push(a)}),u.setValueInfo(l),u.getArrayData()},n.prototype.encodeUserSetRTCCDNUris=function(e,t){this._connectType;var r=this._codec.getModule(Ar);r.setObjectName(e);var i=this._codec.getModule(et);return i.setKey("cdn_uris"),i.setValue(t),r.setValueInfo(i),r.getArrayData()},n.prototype.encodeGetRTCData=function(e,t,r){var i=this._codec.getModule(Mr);return i.setInterior(t),i.setTarget(r),i.setKey(e),i.getArrayData()},n.prototype.encodeRemoveRTCData=function(e,t,r,i){var s=this._codec.getModule(Mr);s.setInterior(t),s.setTarget(r),s.setKey(e);var o=(i=i||{}).name,u=i.content;return!fe(o)&&s.setObjectName(o),fe(u)||(Ve(u)&&(u=JSON.stringify(u)),s.setContent(u)),s.getArrayData()},n.prototype.encodeSetRTCOutData=function(e,t,r){var i=this._codec.getModule(Ps);i.setTarget(t),Ye(e)||(e=[e]),Oe(e,function(u,d){u.key=u.key?u.key.toString():u.key,u.value=u.value?u.value.toString():u.value,e[d]=u}),i.setValueInfo(e);var s=(r=r||{}).name,o=r.content;return!fe(s)&&i.setObjectName(s),fe(o)||(Ve(o)&&(o=JSON.stringify(o)),i.setContent(o)),i.getArrayData()},n.prototype.ecnodeGetRTCOutData=function(e){var t=this._codec.getModule(ks);return t.setUserId(e),t.getArrayData()},n.prototype.encodeSetRTCState=function(e){var t=this._codec.getModule(Ls);return t.setState(e),t.getArrayData()},n.prototype.encodeGetRTCRoomInfo=function(){var e=this._codec.getModule(Us);return e.setOrder(2),e.getArrayData()},n.prototype.encodeSetRTCUserInfo=function(e,t){var r=this._codec.getModule(et);return r.setKey(e),r.setValue(t),r.getArrayData()},n.prototype.encodeRemoveRTCUserInfo=function(e){var t=this._codec.getModule(Ds);return t.setKey(e),t.getArrayData()},n.prototype.encodeIdentityChangeInfo=function(e,t,r){r===void 0&&(r=!1);var i=this._codec.getModule(wr);return i.setRoomType(je.LIVE),t&&i.setBroadcastType(t),i.setIdentityChangeType(e),i.setNeedSysChatroom(r),i.getArrayData()},n.prototype.encodePullRTCRoomKV=function(e,t){var r=this._codec.getModule(to);return r.setTimestamp(t),r.setRoomId(e),r.getArrayData()},n.prototype.encodeQueryUserJoinedInfo=function(e){var t=this._codec.getModule(no);return t.setUserId(e),t.getArrayData()},n.prototype.encodeRequestRoomPK=function(e){var t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,s=e.inviteTimeout,o=e.inviteInfo,u=this._codec.getModule(ro);return u.setInvitedRoomId(t),u.setInvitedUserId(r),u.setInviteSessionId(i),u.setTimeoutTime(s),u.setInviteInfo(o),u.getArrayData()},n.prototype.encodeCancelRoomPK=function(e){var t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,s=e.inviteInfo,o=this._codec.getModule(io);return o.setInvitedRoomId(t),o.setInvitedUserId(r),o.setInviteSessionId(i),o.setInviteInfo(s),o.getArrayData()},n.prototype.encodeResponseRoomPK=function(e){var t=e.inviteUserId,r=e.inviteRoomId,i=e.inviteSessionId,s=e.content,o=e.key,u=e.value,d=e.agree?1:0,l=this._codec.getModule(so);return l.setInviteUserId(t),l.setInviteRoomId(r),l.setInviteSessionId(i),l.setContent(s),l.setKey(o),l.setValue(u),l.setAnswerCode(d),l.getArrayData()},n.prototype.encodeEndRoomPK=function(e){var t=e.endRoomId,r=e.sessionId,i=e.content,s=e.keys,o=this._codec.getModule(oo);return o.setInviteRoomId(t),o.setInviteSessionId(r),o.setInviteContent(i),o.setInviteRoomKeys(s),o.getArrayData()},n}(),uc=function(n,e){this._watcher=e,this.codec=new Pd(n)},dc=function(n,e){return n&&e?e+"_"+n:n||Date.now()},qn=function(){function n(e){this.header=e,this._name=null,this.lengthSize=0,this.messageId=0,this.timestamp=0,this.syncMsg=!1,this.identifier=""}return n.prototype.getIdentifier=function(){var e=this.messageId,t=this.identifier;return dc(e,t)},n.prototype.read=function(e,t,r){this.readMessage(e,t,r)},n.prototype.readMessage=function(e,t,r){return{stream:e,length:t}},n}(),lc=function(){function n(e){this.lengthSize=0,this.messageId=0,this.topic="",this.targetId="",this.identifier="",this._header=new gs(e,!1,vt.AT_MOST_ONCE,!1)}return n.prototype.getIdentifier=function(){var e=this.messageId,t=this.identifier;return dc(e,t)},n.prototype.write=function(e){var t=this.getHeaderFlag();e.write(t),this.writeMessage(e)},n.prototype.setHeaderQos=function(e){this._header.qos=e},n.prototype.getHeaderFlag=function(){return this._header.encode()},n.prototype.getLengthSize=function(){return this.lengthSize},n.prototype.getBufferData=function(){var e=new ad;this.write(e);var t=e.getBytesArray();return new Int8Array(t)},n.prototype.getCometData=function(){var e=this.data||{};return JSON.stringify(e)},n}(),hc=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.CONN_ACK,t.status=null,t.userId=null,t.timestamp=0,t}return Ie(e,n),e.prototype.readMessage=function(t,r,i){if(t.readByte(),this.status=+t.readByte(),r<=e.MESSAGE_LENGTH)return{stream:t,length:r};if(i===Lt.V4){var s=t.readByte();1&s&&(this.userId=t.readUTF()),2&s&&t.readUTF(),4&s&&(this.timestamp=t.readLong()),8&s&&(this.messageId=t.read2Byte())}else{this.userId=t.readUTF();var o=t.readUTF();j.debug("server sessionId -> "+o),this.timestamp=t.readLong()}return{stream:t,length:r}},e.MESSAGE_LENGTH=2,e}(qn),ao=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.DISCONNECT,t.status=0,t}return Ie(e,n),e.prototype.readMessage=function(t,r){return t.readByte(),this.status=+t.readByte(),{stream:t,length:r}},e.MESSAGE_LENGTH=2,e}(qn),Ld=function(n){function e(){var t=n.call(this,Fe.PING_REQ)||this;return t._name=Xe.PING_REQ,t}return Ie(e,n),e.prototype.writeMessage=function(t){},e}(lc),pc=function(n){function e(t){var r=n.call(this,t)||this;return r._name=Xe.PING_RESP,r}return Ie(e,n),e}(qn),co=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t.messageId=0,t}return Ie(e,n),e.prototype.readMessage=function(t,r){var i=256*t.readByte()+t.readByte();return this.messageId=parseInt(i.toString(),10),{stream:t,length:r}},e}(qn),ii=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t.messageId=0,t}return Ie(e,n),e.prototype.writeMessage=function(t){var r=this.messageId,i=255&r,s=(65280&r)>>8;t.write(s),t.write(i)},e}(lc),Vn=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.PUBLISH,t.topic="",t.targetId="",t.syncMsg=!1,t.identifier=xt.PUB,t}return Ie(e,n),e.prototype.readMessage=function(t,r){return this.date=t.readInt(),this.topic=t.readUTF(),this.targetId=t.readUTF(),n.prototype.readMessage.call(this,t,r),this.data=t.readAll(),{stream:t,length:r}},e}(co),fn=function(n){function e(t,r,i){var s=n.call(this,Fe.PUBLISH)||this;return s._name=Xe.PUBLISH,s.syncMsg=!1,s.identifier=xt.PUB,s.topic=t,s.data=Qe(r)?Kn.writeUTF(r):r,s.targetId=i,s}return Ie(e,n),e.prototype.writeMessage=function(t){t.writeUTF(this.topic),t.writeUTF(this.targetId),n.prototype.writeMessage.call(this,t),t.write(this.data)},e}(ii),Yi=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.PUB_ACK,t.status=0,t.date=0,t.millisecond=0,t.messageUId="",t.timestamp=0,t.identifier=xt.PUB,t.topic="",t.targetId="",t}return Ie(e,n),e.prototype.readMessage=function(t,r){return n.prototype.readMessage.call(this,t,r),this.date=t.readInt(),this.status=256*t.readByte()+t.readByte(),this.millisecond=256*t.readByte()+t.readByte(),this.timestamp=1e3*this.date+this.millisecond,this.messageUId=t.readUTF(),{stream:t,length:r}},e}(co),fc=function(n){function e(t){var r=n.call(this,Fe.PUB_ACK)||this;return r._name=Xe.PUB_ACK,r.status=0,r.date=0,r.millisecond=0,r.messageUId="",r.timestamp=0,r.messageId=t,r}return Ie(e,n),e.prototype.writeMessage=function(t){n.prototype.writeMessage.call(this,t)},e}(ii),Q=function(n){function e(t,r,i){var s=n.call(this,Fe.QUERY)||this;return s.name=Xe.QUERY,s.identifier=xt.QUERY,s.topic=t,s.data=Qe(r)?Kn.writeUTF(r):r,s.targetId=i,s}return Ie(e,n),e.prototype.writeMessage=function(t){t.writeUTF(this.topic),t.writeUTF(this.targetId),n.prototype.writeMessage.call(this,t),t.write(this.data)},e}(ii),gc=function(n){function e(t){var r=n.call(this,Fe.QUERY_CONFIRM)||this;return r._name=Xe.QUERY_CON,r.messageId=t,r}return Ie(e,n),e}(ii),bn=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.QUERY_ACK,t.status=0,t.identifier=xt.QUERY,t.topic="",t.targetId="",t}return Ie(e,n),e.prototype.readMessage=function(t,r){return n.prototype.readMessage.call(this,t,r),this.date=t.readInt(),this.status=256*t.readByte()+t.readByte(),this.data=t.readAll(),{stream:t,length:r}},e}(co),mc=function(n){var e,t=n.type;switch(t){case Fe.CONN_ACK:e=new hc(n);break;case Fe.PUBLISH:(e=new Vn(n)).syncMsg=n.syncMsg;break;case Fe.PUB_ACK:e=new Yi(n);break;case Fe.QUERY_ACK:e=new bn(n);break;case Fe.SUB_ACK:case Fe.UNSUB_ACK:case Fe.PING_RESP:e=new pc(n);break;case Fe.DISCONNECT:e=new ao(n);break;default:e=new qn(n),j.error("No support for deserializing "+t+" messages")}return e};(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.addSeTag=73]="addSeTag",n[n.delSeTag=74]="delSeTag",n[n.addTag=75]="addTag",n[n.delTag=76]="delTag",n[n.disTag=77]="disTag",n[n.reportsdk=78]="reportsdk",n[n.rtcInvite=79]="rtcInvite",n[n.rtcCancelInvite=80]="rtcCancelInvite",n[n.rtcInviteAnswer=81]="rtcInviteAnswer",n[n.rtcEndInvite=82]="rtcEndInvite"})(Gi||(Gi={}));var at,D=Gi,_c=function(n,e,t,r){return x(void 0,void 0,void 0,function(){var i;return V(this,function(s){return i=0,n.forEach(function(o){return x(void 0,void 0,void 0,function(){var u,d;return V(this,function(l){switch(l.label){case 0:return u=e+"://"+o+"/ping?r="+(a=9999,(h=1e3)+Math.floor(Math.random()*(a-h))),j.debug("start ping",u),[4,t.httpReq({url:u,timeout:5e3})];case 1:return d=l.sent(),j.debug("end ping",i,u,d.status),i++,r({finished:i===n.length,code:d.status,host:o}),[2]}var h,a})})}),[2]})})},vc=function(n,e,t,r,i,s,o,u){return n+"://"+e+"/websocket?appId="+t+"&token="+encodeURIComponent(r)+"&sdkVer="+s+"&pid="+o+"&apiVer="+(i.isFromUniapp?"uniapp":"normal")+(i.connectPlatform?"&platform="+i.connectPlatform:"")+(u?"&protocolVer="+u:"")},Rc=function(n){return[D.ppMsgS,D.pgMsgS,D.chatMsgS].map(function(e){return D[e]}).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"})(at||(at={}));var ut,jo=function(n,e){j.info("websocket send -> messageId: "+n.messageId);var t=n.getBufferData();e.send(t.buffer)},on=function(n){function e(t,r){var i=n.call(this,"websocket",r)||this;return i._runtime=t,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 Ie(e,n),e.prototype.connect=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d=this;return V(this,function(l){return[2,new Promise(function(h){var a=[],c=0,p=!1,f=!1,m=function(){return x(d,void 0,void 0,function(){var _;return V(this,function(v){switch(v.label){case 0:return a.length===0||p?[2]:(p=!0,[4,this._connect(t,r,a.shift(),s,o,u)]);case 1:if((_=v.sent())===S.SUCCESS)this._checkAlive(),h(_);else if(_===Be.REDIRECT)h(_);else{if(f&&a.length===0)return h(Ja(_)),[2];p=!1,m()}return[2]}})})};o=hs(o),d._watcher.status(te.CONNECTING),_c(i,s,d._runtime,function(_){var v=_.code,R=_.finished,C=_.host;f=R,v===200&&(a.push(C),c++,m()),R&&c===0&&(j.error("No valid websocket server hosts!"),h(S.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d,l,h,a,c,p=this;return V(this,function(f){switch(f.label){case 0:return d=s.replace("http","ws"),l=vc(d,i,t,r,this._runtime,o,"",u),j.debug("conenct start -> "+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(C,A){var M=new Uint8Array(C),O=new od(M),y=O.readByte(),w=new gs(y),$=mc(w);return $.read(O,M.length-1,A),$}(_,u);if(v instanceof pc&&p._pingResolve)return p._pingResolve(S.SUCCESS),void(p._pingResolve=void 0);if(v instanceof hc)return j.debug("recv connect ack -> "+v.status),v.status!==Be.ACCEPTED?(j.warn("connect failed: "+v.status),void m(v.status)):(j.info("connect success -> "+l),p.connectedTime=v.timestamp,p.userId=v.userId||"",p._idCount=v.messageId,void m(S.SUCCESS));if(v instanceof ao){var R=v.status;switch(j.warn("recv disconnect signal -> status: "+R),R){case at.BLOCK:p._watcher.status(te.BLOCKED);break;case at.OTHER_DEVICE_LOGIN:p._watcher.status(te.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case at.REDIRECT_NEW:case at.REDIRECT:p._watcher.status(te.REDIRECT);break;default:p._watcher.status(te.DISCONNECT_BY_SERVER)}}else p._onReceiveSignal(v)}else j.error("Socket received invalid data:",_)}),h.onClose(function(_,v){for(var R in j.warn("websocket closed! code:",_,"reason:",v),a(te.CONNECTION_CLOSED),p._messageIds){var C=p._messageIds[R];delete p._messageIds[R],C(S.RC_NET_CHANNEL_INVALID)}m(_)}),h.onError(function(_){var v;for(var R in j.error("websocket error!",(v=_)===null||v===void 0?void 0:v.stack),a(te.WEBSOCKET_ERROR),p._messageIds){var C=p._messageIds[R];delete p._messageIds[R],C(S.RC_NET_CHANNEL_INVALID)}m(S.NETWORK_ERROR)}),h.onOpen(function(){return j.debug("websocket open =>",l)}),setTimeout(function(){m(S.TIMEOUT)},5e3)})];case 1:return(c=f.sent())===S.SUCCESS?this._socket=h:(j.warn("connect result -> code: "+c+", url: "+l),h.close()),[2,c]}})})},e.prototype._checkAlive=function(){var t;return x(this,void 0,void 0,function(){var r,i=this;return V(this,function(s){switch(s.label){case 0:return this._socket?(j.debug("send ping ->"),this.sendOnly(new Ld),[4,new Promise(function(o){i._pingResolve=o,i._timer&&clearTimeout(i._timer),i._timer=setTimeout(function(){i._pingResolve=void 0,o(S.TIMEOUT)},15e3)})]):[2];case 1:return(r=s.sent())!==S.SUCCESS?(this._failedCount+=1,j.warn("ping failed count: "+this._failedCount+", code: "+r),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,j.warn("ping timeout, close current websocket to reconnect!"),(t=this._socket)===null||t===void 0||t.close(),this._watcher.status(te.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):(j.debug("recv pong <-"),this._failedCount=0,setTimeout(function(){return i._checkAlive()},15e3),[2])}})})},e.prototype._onReceiveSignal=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l=this;return V(this,function(h){switch(h.label){case 0:return r=t.messageId,t.header&&t.header.qos!==vt.AT_MOST_ONCE&&(t instanceof Vn&&!t.syncMsg&&(j.debug("send pubAck -> "+r),this.sendOnly(new fc(r))),t instanceof bn&&(j.debug("send queryCon -> "+r),this.sendOnly(new gc(r)))),r>0&&(t instanceof Yi||t instanceof bn)&&(j.debug("recv ack -> messageId: "+r),(i=this._messageIds[r])&&(i(t),delete this._messageIds[r]),(s=this._syncMessageIds[r])&&(delete this._syncMessageIds[r],s(t))),t instanceof Vn?(o=t.syncMsg,(u=t.topic)===D[D.userSetData]?[2]:!o||Rc(u)?(this._watcher.signal(t),[2]):[4,new Promise(function(a){l._syncMessageIds[r]=a})]):[3,2];case 1:d=h.sent(),delete this._syncMessageIds[r],this._watcher.signal(t,d),h.label=2;case 2:return[2]}})})},e.prototype.sendOnly=function(t){this._socket&&jo(t,this._socket)},e.prototype.send=function(t,r,i,s){return s===void 0&&(s=3e4),x(this,void 0,void 0,function(){var o,u,d,l=this;return V(this,function(h){switch(h.label){case 0:return this._socket?(o=this._generateMessageId(),t.messageId=o,jo(t,this._socket),[4,new Promise(function(a){l._messageIds[o]=a,setTimeout(function(){l._messageIds[o]&&delete l._messageIds[o],a()},s)})]):[3,2];case 1:return(u=h.sent())?u instanceof bn||u instanceof Yi?(d=r&&u.data?this.codec.decodeByPBName(u.data,r,i):u,u.status!==0?(j.warn("send failed -> message: "+o+", respPBName: "+r+", status: "+u.status),[2,{code:u.status,data:r&&u.data?d:null}]):[2,{code:S.SUCCESS,data:d}]):[2,{code:u}]:(j.warn("send timeout -> message: "+o+", respPBName: "+r+", timeout: "+s),[2,{code:S.TIMEOUT}]);case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(te.DISCONNECTED))},e}(uc);(function(n){n.GET="GET",n.POST="POST"})(ut||(ut={}));var an=function(n){function e(t,r){var i=n.call(this,"comet",r)||this;return i._runtime=t,i._messageIds={},i._syncMessageIds={},i._idCount=0,i._generateMessageId=function(){return++i._idCount},i._pid=encodeURIComponent(new Date().getTime()+Math.random()+""),i}return Ie(e,n),e.prototype.handleCometRes=function(t){var r=this;if(t.status!==200&&t.status!==202)return!1;var i=Qe(t.data)?JSON.parse(t.data):t.data;return i?!Ye(i)||(Oe(i,function(s){return x(r,void 0,void 0,function(){var o,u,d,l,h,a,c,p,f,m,_,v=this;return V(this,function(R){switch(R.label){case 0:if((o=s.sessionid)&&(this._sessionid=o),u=function(C){var A=C.headerCode,M=new gs(A),O=mc(M);for(var y in C)O[y]=C[y];return O}(s),d=u.messageId,l=u._header,h=u.status,u.identifier,a=l&&l.qos!==vt.AT_MOST_ONCE,d&&u.getIdentifier&&((c=this._messageIds[d])&&c(u),this._syncMessageIds[d]&&this._syncMessageIds[d](u)),a&&(u instanceof Vn&&!u.syncMsg&&(p=new fc(d),this.sendOnly(p)),u instanceof bn&&(p=new gc(d),this.sendOnly(p))),u instanceof ao){switch(h){case at.OTHER_DEVICE_LOGIN:this._watcher.status(te.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case at.BLOCK:this._watcher.status(te.BLOCKED);break;case at.REDIRECT_NEW:case at.REDIRECT:this._watcher.status(te.REDIRECT);break;default:this._watcher.status(te.DISCONNECT_BY_SERVER)}return[2]}return u instanceof Vn?(f=u.syncMsg,m=u.topic,!f||Rc(m)?(this._watcher.signal(u),[2,!1]):[4,new Promise(function(C){v._syncMessageIds[d]=C})]):[3,2];case 1:_=R.sent(),delete this._syncMessageIds[d],this._watcher.signal(u,_),R.label=2;case 2:return[2]}})})}),!0):(j.error("received data is not a validJson",i),!1)},e.prototype._startPullSignal=function(t){return x(this,void 0,void 0,function(){var r,i,s,o;return V(this,function(u){switch(u.label){case 0:return r=new Date().getTime(),i=t+"://"+this._domain+"/pullmsg.js?sessionid="+this._sessionid+"×trap="+r+"&pid="+this._pid,[4,this._runtime.httpReq({url:i,body:{pid:this._pid},timeout:45e3})];case 1:return s=u.sent(),o=this.handleCometRes(s),this._isDisconnected||(o?this._startPullSignal(t):(this._isDisconnected=!0,this._watcher.status(te.NETWORK_UNAVAILABLE))),[2]}})})},e.prototype.connect=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d,l,h,a,c=this;return V(this,function(p){return o=hs(o),this._protocol=s,this._isDisconnected=!1,this._watcher.status(te.CONNECTING),d=[],l=0,h=!1,a=!1,[2,new Promise(function(f){var m=function(){return x(c,void 0,void 0,function(){var _;return V(this,function(v){switch(v.label){case 0:return d.length===0||h?[2]:(h=!0,[4,this._connect(t,r,d.shift(),s,o)]);case 1:if((_=v.sent())===S.SUCCESS)this._startPullSignal(s),f(_);else if(_===Be.REDIRECT)f(_);else{if(a&&d.length===0)return f(Ja(_)),[2];h=!1,m()}return[2]}})})};c._watcher.status(te.CONNECTING),_c(i,s,c._runtime,function(_){var v=_.code,R=_.finished,C=_.host;a=R,v===200&&(d.push(C),l++,m()),R&&l===0&&(j.error("No valid websocket server hosts!"),f(S.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var u,d,l,h;return V(this,function(a){switch(a.label){case 0:return u=function(c){return c.status!==200&&c.status!==202?(j.error("handle comet res -> res: "+JSON.stringify(c||{})),!1):!!c.data&&(function(p){if(Ve(p))return!0;var f=!1;try{var m=JSON.parse(p);f=JSON.stringify(m)===p}catch{f=!1}return f}(c.data)?Ve(c.data)?c.data:JSON.parse(c.data):(j.error("received data is not a validJson",c.data),!1))},d=vc(s,i,t,r,this._runtime,o,this._pid),this.sendConnectTime=Date.now(),j.debug("conenct start -> "+d),[4,this._runtime.httpReq({url:d,body:{pid:this._pid},timeout:5e3})];case 1:return l=a.sent(),h=u(l),this._domain=i,h&&h.status===0?(this._sessionid=h.sessionid,this.userId=h.userId,this.connectedTime=h.timestamp):j.warn("connect result -> code: "+(h==null?void 0:h.status)+", url: "+d),[2,h==null?void 0:h.status]}})})},e.prototype.sendCometData=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return s=(i=this)._domain,o=i._sessionid,u=i._pid,d=t.messageId,l=t.topic,h=t.targetId,t.identifier,a=t.getHeaderFlag(),c=l?this._protocol+"://"+s+"/websocket?messageid="+d+"&header="+a+"&sessionid="+o+"&topic="+l+"&targetid="+h+"&pid="+u:this._protocol+"://"+s+"/websocket?messageid="+d+"&header="+a+"&sessionid="+o+"&pid="+u,[4,this._runtime.httpReq({url:c,method:ut.POST,body:t.getCometData()})];case 1:return p=f.sent(),this.handleCometRes(p),[2]}})})},e.prototype.sendOnly=function(t){this.sendCometData(t)},e.prototype.send=function(t,r,i,s){return s===void 0&&(s=3e4),x(this,void 0,void 0,function(){var o,u,d,l=this;return V(this,function(h){switch(h.label){case 0:return o=this._generateMessageId(),t.messageId=o,this.sendCometData(t),[4,new Promise(function(a){l._messageIds[o]=a,setTimeout(function(){delete l._messageIds[o],a()},s)})];case 1:return(u=h.sent())?(d=r&&u.data?this.codec.decodeByPBName(u.data,r,i):u,u.status!==0?[2,{code:u.status,data:r&&u.data?d:null}]:[2,{code:S.SUCCESS,data:d}]):[2,{code:S.TIMEOUT}]}})})},e.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(te.DISCONNECTED)},e}(uc),kd=function(n,e,t){this.runtime=n,this._watcher=e,this._options=t,this.currentUserId="",this._appkey=this._options.appkey,this._apiVer=this._options.apiVersion,this.navi=this._createNavi()},mi=function(n){return["navi",n].join("_")},Ud=function(){function n(e,t){this._runtime=e,this._options=t,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=hs(this._options.apiVersion)}return n.prototype.getInfo=function(e,t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return r&&this._clear(e),(s=function(d,l,h){var a,c,p=mi(d);try{var f=h.getItem(p);c=f?JSON.parse(f):[]}catch{c=[]}var m=Date.now();return c.length>0&&(c=c.filter(function(_){return m-_.timestamp<72e5})),c.length===0?h.removeItem(p):h.setItem(p,JSON.stringify(c)),((a=c.find(function(_){return _.token===l}))===null||a===void 0?void 0:a.naviInfo)||null}(this._appkey,e,this._runtime.localStorage))?(this._naviInfo=s,[2,s]):(o=this._options.navigators.slice(),t.length&&t.forEach(function(d){o.indexOf(d)<0&&o.unshift(d)}),[4,this._reqNavi(o,this._appkey,e,i)]);case 1:return(s=u.sent())?(this._naviInfo=s,this.setNaviInfo2Cache(e,s),[2,s]):[2,s]}})})},n.prototype.setNaviInfo2Cache=function(e,t){this._naviInfo=t,function(r,i,s,o){var u,d=mi(r);try{var l=o.getItem(d);u=l?JSON.parse(l):[]}catch{u=[]}var h=Date.now();u.length>0&&(u=u.filter(function(a){return h-a.timestamp<72e5&&i!==a.token})),u.push({timestamp:h,naviInfo:s,token:i}),o.setItem(d,JSON.stringify(u))}(this._appkey,e,t,this._runtime.localStorage)},n.prototype.getInfoFromCache=function(e){return this._naviInfo},n.prototype._clear=function(e){(function(t,r,i){var s,o=mi(t);try{var u=i.getItem(o);s=u?JSON.parse(u):[]}catch{s=[]}var d=Date.now();s.length>0&&(s=s.filter(function(l){return d-l.timestamp<72e5&&r!==l.token})),s.length===0?i.removeItem(o):i.setItem(o,JSON.stringify(s))})(this._appkey,e,this._runtime.localStorage)},n}(),tr=function(n,e,t){return[n,e,t].join("_")},Dd=function(){function n(e,t){this._runtime=e,this._appkey=t,this._users={}}return n.prototype._getMemData=function(e){return this._users[e]||(this._users[e]={inboxTime:0,outboxTime:0})},n.prototype.setInboxTime=function(e,t){var r=this._getMemData(t);if(!(r.inboxTime>e)){r.inboxTime=e;var i=tr("inbox",this._appkey,t);this._runtime.localStorage.setItem(i,e.toString())}},n.prototype.getInboxTime=function(e){var t=this._getMemData(e);if(t.inboxTime===0){var r=tr("inbox",this._appkey,e);t.inboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return t.inboxTime},n.prototype.setOutboxTime=function(e,t){var r=this._getMemData(t);if(!(r.outboxTime>=e)){r.outboxTime=e;var i=tr("outbox",this._appkey,t);this._runtime.localStorage.setItem(i,e.toString())}},n.prototype.getOutboxTime=function(e){var t=this._getMemData(e);if(t.outboxTime===0){var r=tr("outbox",this._appkey,e);t.outboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return t.outboxTime},n}(),_i={_caches:{},set:function(n,e){this._caches[n]=e},get:function(n){return this._caches[n]||0},clear:function(n){this._caches[n]=0}},xd=function(){function n(e,t){this._kvCaches={},this._chatroomId=e,this._currentUserId=t}return n.prototype._add=function(e){var t=e.key;e.isDeleted=!1,this._kvCaches[t]=e},n.prototype._remove=function(e){var t=e.key,r=this._kvCaches[t];r&&(r.isDeleted=!0,this._kvCaches[t]=r)},n.prototype._setEntry=function(e,t){var r=e.key,i=e.type,s=e.isOverwrite,o=e.userId,u=this._getSetUserId(r),d=i===We.DELETE,l=u===o,h=!this._isExisted(r),a=d?this._remove:this._add;(t||s||l||h)&&a.call(this,e)},n.prototype.getValue=function(e){var t=this._kvCaches[e]||{};return t.isDeleted?null:t.value},n.prototype.getAllValue=function(){var e={};for(var t in this._kvCaches)this._kvCaches[t].isDeleted||(e[t]=this._kvCaches[t].value);return e},n.prototype._getSetUserId=function(e){return(this._kvCaches[e]||{}).userId},n.prototype._isExisted=function(e){var t=this._kvCaches[e]||{},r=t.value,i=t.isDeleted;return r&&!i},n.prototype.setEntries=function(e){var t=this,r=e.kvEntries,i=e.isFullUpdate;r=r||[],(i=i||!1)&&this.clear(),r.forEach(function(s){t._setEntry(s,i)}),j.debug("end setEntries")},n.prototype.clear=function(){this._kvCaches={}},n}(),Vd=function(){function n(e){this._pullQueue=[],this._isPulling=!1,this._storeCaches={},this._engine=e}return n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],t=e.chrmId,r=e.timestamp,(i=_i.get(t))>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(t,i)]);case 1:return s=d.sent(),o=s.code,u=s.data,this._isPulling=!1,o===S.SUCCESS?(_i.set(t,u.syncTime||0),this._startPull()):this._startPull(),[2]}})})},n.prototype.reset=function(e){_i.clear(e);var t=this._storeCaches[e];t&&t.clear()},n.prototype.pullEntry=function(e,t){this._pullQueue.push({chrmId:e,timestamp:t}),this._startPull()},n.prototype.setLocal=function(e,t,r){var i=this._storeCaches[e];Sn(i)||(i=new xd(e,r)),i.setEntries(t),this._storeCaches[e]=i},n.prototype.getValue=function(e,t){var r=this._storeCaches[e];return r?r.getValue(t):null},n.prototype.getAll=function(e){var t=this._storeCaches[e],r={};return t&&(r=t.getAllValue()),r},n}(),Bd=function(){function n(e,t,r,i){this._runtime=e,this._appkey=t,this._userId=r,this._canJoinMulipleChrm=i,this._sessionKey="",this._joinedChrmsInfo={},this._sessionKey="sync-chrm-"+this._appkey+"-"+this._userId}return n.prototype.set=function(e,t){t===void 0&&(t=10),!this._canJoinMulipleChrm&&(this._joinedChrmsInfo={}),this._joinedChrmsInfo[e]=t,this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo))},n.prototype.get=function(){var e,t;try{t=this._runtime.sessionStorage.getItem(this._sessionKey),e=JSON.parse(t||"{}")}catch{j.error("parse rejoined chrm infos error -> "+t),e={}}return e},n.prototype.remove=function(e){delete this._joinedChrmsInfo[e],Sn(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}(),vi="converStatusChanged",Fd=function(){function n(e,t,r){this._eventEmitter=new jn,this._pullQueue=[],this._isPulling=!1,this._storage=Gr(e.runtime),this._appkey=t,this._currentUserId=r,this._engine=e,this._storagePullTimeKey="con-s-"+t+"-"+r}return n.prototype._set=function(e){var t=this;if(!fe(e)&&Array.isArray(e)){var r=this._storage.get(this._storagePullTimeKey)||0,i=e.length;e.forEach(function(s,o){var u=s.updatedTime||0;r=u>r?u:r,s.conversationType=s.type,t._eventEmitter.emit(vi,{statusItem:s,isLastPull:o===i-1})}),this._storage.set(this._storagePullTimeKey,r)}},n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i;return V(this,function(s){switch(s.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullConversationStatus(e)]);case 1:return t=s.sent(),r=t.code,i=t.data,r===S.SUCCESS?(this._isPulling=!1,this._set(i),this._startPull()):this._startPull(),[2]}})})},n.prototype.pull=function(e){var t=this._storage.get(this._storagePullTimeKey)||0;(e>t||e===0)&&(this._pullQueue.push(t),this._startPull())},n.prototype.watch=function(e){this._eventEmitter.on(vi,function(t){e(t)})},n.prototype.unwatch=function(){this._eventEmitter.off(vi,function(e){})},n}(),Pt={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},to:{keyName:"isTop",defaultVal:!1},tg:{keyName:"tags",defaultVal:{}},mc:{keyName:"unreadMentionedCount",defaultVal:0}},_r={};for(var Ko in Pt){var Hd=Pt[Ko].keyName;_r[Hd]=Ko}var gn,$d=function(){function n(e,t,r){this._appkey=t,this._currentUserId=r;var i="con-"+t+"-"+r;this.storage=new So(e,i),this._localStore=new So(e,"CONVER-"+t+"-"+r)}return n.prototype._getStoreKey=function(e,t,r){return r+"_"+e+"_"+t},n.prototype._getConOptionByKey=function(e){var t=(e=e||"").split("_");if(t.length>=2){var r=t.shift(),i=t.shift(),s=t.join("_");return{conversationType:Number(i),targetId:s,channelId:r}}return{conversationType:z.PRIVATE,targetId:"",channelId:""}},n.prototype.updateMentionedData=function(e){var t=this,r=e.conversationType,i=e.targetId,s=e.messageType,o=e.isMentioned,u=e.content,d=e.senderUserId,l=e.channelId,h=this._getStoreKey(r,i,l),a=this._localStore.get(h)||{},c=_r.mentionedInfo,p=_r.hasMentioned,f=a[c]||{},m=f.userIdList||[],_=u.mentionedInfo;if(_){if(o&&r===z.GROUP&&((_.userIdList||[]).forEach(function(R){R===t._currentUserId&&m.indexOf(d)<0&&m.push(d)}),_.type===fs.ALL&&m.indexOf(d)<0&&m.push(d)),s===He.RECALL&&r===z.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[c]=_,a[p]=!0):(delete a[c],delete a[p]),Sn(a)?this._localStore.set(h,a):this._localStore.remove(h)}},n.prototype.set=function(e,t,r,i){var s=this._getStoreKey(e,t,i),o=this._localStore.get(s)||{};for(var u in r){var d=_r[u],l=r[u];if(!fe(d)&&!fe(l)&&u!=="hasMentioned"&&u!=="MentionedInfo"){if(l===Pt[d].defaultVal||u==="tags"&&!Sn(l))delete o[d];else if(u==="tags"){var h=l;for(var a in h)h[a].isTop||delete h[a].isTop;o[d]=l}else o[d]=l;o.c||(delete o.t,delete o.hm,delete o.m,delete o.mc)}}Sn(o)?this._localStore.set(s,o):this._localStore.remove(s)},n.prototype.get=function(e,t,r){r===void 0&&(r="");var i=this._getStoreKey(e,t,r),s=this._localStore.get(i)||{},o={};for(var u in Pt){var d=Pt[u],l=d.keyName,h=d.defaultVal;o[l]=s[u]||mr(h)}return o},n.prototype.getValue=function(e){var t=this._localStore.getValues()||{},r=[];for(var i in t){var s=this._getConOptionByKey(i),o={conversationType:s.conversationType,targetId:s.targetId,channelId:s.channelId},u=t[i];for(var d in u){var l=Pt[d],h=l.keyName,a=l.defaultVal;o[h]=u[d]||mr(a)}o=e?e(o):o,r.push(o)}return r},n.prototype.getValueForTag=function(){var e=this._localStore.getValues()||{},t={};for(var r in e){var i=this._getConOptionByKey(r),s=i.conversationType,o=i.targetId,u={},d=e[r];for(var l in d){var h=Pt[l],a=h.keyName,c=h.defaultVal;u[a]=d[l]||mr(c)}for(var p in u.tags){fe(t[p])&&(t[p]=[]);var f=Object.assign({},u,{conversationType:s,targetId:o});delete f.tags,t[p].push(f)}}return t},n.prototype.adaptOldStore=function(){try{var e=this.storage.getValues();if(Object.keys(e).length===0)return;for(var t in e){var r="_"+t;this._localStore.set(r,e[t])}}catch(i){j.error("adaptOldStore error: "+i.message)}},n}(),jd=[z.PRIVATE,z.GROUP,z.SYSTEM,z.PUBLIC_SERVICE,z.APP_PUBLIC_SERVICE],qo="conversationChanged",Go="conTagStatusChanged",Kd=function(){function n(e,t,r,i,s){var o=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new jn,this._draftMap={},this._appkey=t,this._loginUserId=r,this._store=new $d(e.runtime,t,r),this._statusManager=new Fd(e,t,r),this._statusManager.watch(function(u){var d=u.statusItem,l=u.isLastPull;o.addStatus(d,l)}),this._eventEmitter.on(qo,function(u){i(u)}),this._eventEmitter.on(Go,function(){s()})}return n.prototype._calcUnreadCount=function(e,t){var r=e.content,i=e.messageType,s=e.sentTime,o=e.isCounted,u=e.messageDirection,d=e.senderUserId,l=u===nt.SEND&&d===this._loginUserId,h=i===He.RECALL,a=Ve(r),c=!1,p={},f=t.lastUnreadTime||0,m=t.unreadMessageCount||0;return f>s||l?{hasChanged:c,localConversation:t,updateItems:p}:(o&&(t.unreadMessageCount=m+1,t.lastUnreadTime=s,c=!0),h&&a&&f>=r.sentTime&&m&&(t.unreadMessageCount=m-1,c=!0),c&&(p.unreadMessageCount={val:t.unreadMessageCount,time:s}),{hasChanged:c,localConversation:t,updateItems:p})},n.prototype._calcMentionedInfo=function(e,t){var r=e.content,i=(e.messageDirection,e.isMentioned),s=e.sentTime;nt.SEND;var o=Ve(r),u=!1,d={};return i&&o&&r.mentionedInfo&&(t.hasMentioned=!0,u=!0,d.hasMentioned={val:!0,time:s},d.mentionedInfo={val:r.mentionedInfo,time:s}),{hasChanged:u,localConversation:t,updateItems:d}},n.prototype._calcMentionedCount=function(e,t){var r=e.content,i=e.messageDirection,s=!1;if(e.isMentioned&&i===nt.RECEIVE&&(r==null?void 0:r.mentionedInfo)){var o=r.mentionedInfo,u=o.type,d=o.userIdList;if(u===fs.ALL||(d||[]).includes(this._loginUserId)){s=!0;var l=t.unreadMentionedCount||0;t.unreadMentionedCount=l+1}}return{hasChanged:s,localConversation:t}},n.prototype._setUpdatedConversation=function(e){if(Ve(e)){var t=e.conversationType,r=e.targetId,i=e.channelId,s=t+"_"+r,o=this._store.get(t,r,i)||{};this._updatedConversations[s]=Object.assign(o,e)}},n.prototype._setConTagStatusChanged=function(e,t,r,i){var s=(this._store.get(e,t,i)||{}).tags||{};if(Object.keys(s).length===Object.keys(r).length){for(var o in s)if(!r[o]||s[o].isTop!==r[o].isTop)return void(this._conTagStatusChanged=!0)}else this._conTagStatusChanged=!0},n.prototype.addStatus=function(e,t){var r=e.conversationType,i=e.targetId,s=e.updatedTime,o=e.notificationStatus,u=e.isTop,d=e.tags,l=e.channelId,h={},a={};fe(o)||(a.notificationStatus={time:s,val:o}),fe(u)||(a.isTop={time:s,val:u}),fe(d)||(a.tags={time:s,val:d},d==null||d.forEach(function(c){h[c.tagId]={isTop:c.isTop}})),this._setConTagStatusChanged(r,i,h,l),this._store.set(r,i,{notificationStatus:o,isTop:u,tags:h},l),this._setUpdatedConversation({conversationType:r,targetId:i,updatedItems:a,channelId:l}),t&&this._notifyConversationChanged()},n.prototype._notifyConversationChanged=function(){var e=[];for(var t in this._updatedConversations)e.push(this._updatedConversations[t]);e.length!==0&&(this._eventEmitter.emit(qo,e),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(Go),this._conTagStatusChanged=!1))},n.prototype.setConversationCacheByMessage=function(e,t){var r=this,i=e.conversationType,s=e.isPersited,o=e.targetId,u=e.channelId;if(jd.indexOf(i)>=0){var d=!1,l=this._store.get(i,o,u),h={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach(function(p){var f=p.call(r,e,l),m=f.hasChanged,_=f.localConversation,v=f.updateItems;d=d||m,h=Re(Re({},h),v),l=mr(_)}),d&&this._store.set(i,o,l,u),this._store.updateMentionedData(e),s){var a=this._store.get(i,o,u);a.updatedItems=Re({latestMessage:{time:e.sentTime,val:e}},h),a.latestMessage=e;var c=Object.assign(a,{conversationType:i,targetId:o,channelId:u});this._setUpdatedConversation(c)}(d||s)&&this._notifyConversationChanged()}},n.prototype.get=function(e,t,r){return r===void 0&&(r=""),this._store.get(e,t,r)},n.prototype.getAllUnreadCount=function(e,t,r){var i=this._store.getValue(),s=0;return i.forEach(function(o){var u=o.unreadMessageCount,d=o.notificationStatus,l=o.conversationType;u=u||0,(r||d!==1)&&(t.length>0?t.includes(Number(l))&&(s+=Number(u)):s+=Number(u))}),s},n.prototype.getUnreadCountByTag=function(e,t){var r=this._store.getValueForTag()[e]||[],i=0;return r.forEach(function(s){var o=s.unreadMessageCount,u=s.notificationStatus;(t||u!==1)&&(o=o||0,i+=Number(o))}),i},n.prototype.getUnreadCount=function(e,t,r){return this._store.get(e,t,r).unreadMessageCount||0},n.prototype.clearUnreadCount=function(e,t,r,i){i===void 0&&(i=!0);var s=this._store.get(e,t,r),o=s.unreadMessageCount,u=s.hasMentioned,d={};if(o&&(s.unreadMessageCount=0,d.unreadMessageCount={val:0,time:Date.now()}),u&&(s.hasMentioned=!1,s.unreadMentionedCount=0,s.mentionedInfo=void 0,d.hasMentioned={val:!1,time:Date.now()},d.mentionedInfo={val:void 0,time:Date.now()}),this._store.set(e,t,s,r),i&&Object.keys(d).length!==0){var l=Object.assign(s,{conversationType:e,targetId:t,channelId:r,updatedItems:d});this._setUpdatedConversation(l),this._notifyConversationChanged()}},n.prototype.clearAllUnreadCount=function(){var e=this;this._store.getValue().forEach(function(t){t.unreadMessageCount&&(t.unreadMessageCount=0,e._store.set(t.conversationType,t.targetId,t,t.channelId))})},n.prototype.startPullConversationStatus=function(e){this._statusManager.pull(e)},n.prototype.setDraft=function(e,t,r,i){var s=e+"_"+t+"_"+i;this._draftMap[s]=r},n.prototype.getDraft=function(e,t,r){var i=e+"_"+t+"_"+r;return this._draftMap[i]},n.prototype.clearDraft=function(e,t,r){var i=e+"_"+t+"_"+r;delete this._draftMap[i]},n.prototype.addTagStatus=function(e,t,r,i){i===void 0&&(i="");var s=this._store.get(e,t,i).tags;s=Object.assign(s,r),this._store.set(e,t,{tags:s},i)},n.prototype.deleteTagStatus=function(e,t,r,i){i===void 0&&(i="");var s=this._store.get(e,t,i).tags;r.forEach(function(o){delete s[o]}),this._store.set(e,t,{tags:s},i)},n.prototype.getConversationListForTag=function(){return this._store.getValueForTag()},n.prototype.getBlockConversationList=function(){return this._store.getValue().filter(function(e){return e.notificationStatus===Kt.OPEN}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},n.prototype.getTopConversationList=function(){return(this._store.getValue()||{}).filter(function(e){return e.isTop}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},n.prototype.adaptOldStore=function(){this._store.adaptOldStore()},n.prototype.getUnreadMentionedCount=function(e,t,r){return e===void 0&&(e=""),this.get(t,r,e).unreadMentionedCount||0},n.prototype.getAllUnreadMentionedCount=function(){var e=this._store.getValue(),t=0;return e.forEach(function(r){var i=r.unreadMentionedCount;i=i||0,t+=Number(i)}),t},n}(),qd=function(){function n(e,t,r,i){this._pullQueue=[],this._isPulling=!1,this._storageTagKey="tag-"+t+"-"+r,this._storagePullTimeKey="us-s-"+t+"-"+r,this._storage=Gr(e.runtime),this._engine=e,this._tagWatcherFunc=i}return n.prototype._updateTag=function(e){var t=e.tags,r={};t.forEach(function(i){r[i.tagId]={tagName:i.tagName,createdTime:i.createdTime}}),this._storage.set(this._storageTagKey,r),this._tagWatcherFunc()},n.prototype.addTag=function(e,t){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){var s,o=((s=r[i.tagId])===null||s===void 0?void 0:s.createdTime)||i.createdTime||0;r[i.tagId]={tagName:i.tagName,createdTime:o}}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,t)},n.prototype.deleteTag=function(e,t){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){delete r[i]}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,t)},n.prototype.getTagsInfo=function(){return this._storage.get(this._storageTagKey)||{}},n.prototype.getTags=function(){var e=this._storage.get(this._storageTagKey)||{},t=[];for(var r in e)t.push({tagId:r,tagName:e[r].tagName,createdTime:e[r].createdTime,conversationCount:0});return t.sort(function(i,s){return(i.createdTime||0)-(s.createdTime||0)})},n.prototype.getTagById=function(e){var t=this._storage.get(this._storageTagKey)||{};return t[e]?{tagId:e,tagName:t[e].tagName,createdTime:t[e].createdTime,conversationCount:0}:null},n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i,s,o,u,d;return V(this,function(l){switch(l.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullUserSettings(e)]);case 1:return t=l.sent(),r=t.code,i=t.data,r!==S.SUCCESS||fe(i)?(this._isPulling=!1,this._startPull()):(o=(s=i).settings,u=s.version,d=o.Tag,fe(d)||this._updateTag(d),this._storage.set(this._storagePullTimeKey,u),this._isPulling=!1,this._startPull()),[2]}})})},n.prototype.pullUserSettings=function(e){var t=this._storage.get(this._storagePullTimeKey)||0;(e>t||e===0)&&(this._pullQueue.push(t),this._startPull())},n.prototype.getVersion=function(){return this._storage.get(this._storagePullTimeKey)||0},n}(),Gd=function(n){function e(t,r){var i=n.call(this,t,r)||this;return i._miniConnectUrl="",i._connectType=r.connectionType,i}return Ie(e,n),e.prototype._formatJSONPUrl=function(t,r,i,s){return t+"/"+(this._runtime.isSupportSocket()&&this._connectType==="websocket"?"navi":"cometnavi")+".js?appId="+i+"&token="+encodeURIComponent(r)+"&callBack="+s+"&v="+this._apiVersion+"&r="+Date.now()},e.prototype.getInfo=function(t,r,i){var s;return x(this,void 0,void 0,function(){var o;return V(this,function(u){return this._runtime.useNavi||(o=void 0,o=this._runtime.isSupportSocket()&&this._connectType==="websocket"?Gu.join(","):Yu.join(","),this._miniConnectUrl=((s=this._options.miniCMPProxy)===null||s===void 0?void 0:s.length)?this._options.miniCMPProxy.join(","):o||"",r=[]),[2,n.prototype.getInfo.call(this,t,r,i)]})})},e.prototype._reqNavi=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:s="getServerEndpoint",o=0,u=t.length,f.label=1;case 1:return o<u?(d=this._formatJSONPUrl(t[o],i,r,s),j.debug("req navi => "+d),[4,this._runtime.httpReq({url:d,timeout:1e4,dataType:"text"})]):[3,4];case 2:if((l=f.sent()).status!==200)return l.status===403?j.error("request navi error: "+S.RC_CONN_USER_OR_PASSWD_ERROR):l.status===401&&j.error("request navi error: "+S.RC_CONN_APP_BLOCKED_OR_DELETED),[3,3];try{return h=l.data.match(/{[\d\D]+}/),(a=h&&h[0]?h[0]:"").indexOf('{\\"code\\":')===0&&(a=JSON.parse('"'+a+'"')),p=JSON.parse(a),c=/^https/.test(d)?"https":"http",p.protocol=c,this._runtime.useNavi||(p.server="",p.backupServer=this._miniConnectUrl,p.logSwitch=0),[2,p]}catch(m){j.error("parse navi err =>",m)}f.label=3;case 3:return o+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:[2,p={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}]}})})},e}(Ud),Yd=function(){function n(e){this._pullQueue=[],this._isPulling=!1,this._pullTime=0,this._engine=e}return n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],t=e.roomId,r=e.timestamp,(i=this._pullTime)>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullRTCRoomEntry(t,i)]);case 1:return s=d.sent(),o=s.code,u=s.data,o===S.SUCCESS?(this._isPulling=!1,this._pullTime=u.syncTime||0,this._startPull()):this._startPull(),[2]}})})},n.prototype.pullEntry=function(e,t){this._pullQueue.push({roomId:e,timestamp:t}),this._startPull()},n.prototype.reset=function(){this._pullTime=0,this._isPulling=!1},n}(),Ri=function(n,e){return["send_msg",n,e].join("_")},Jd=function(){function n(e,t){this._runtime=e,this._appkey=t,this._sendMessageMap={},this._userId=""}return n.prototype.init=function(e){this._userId=e;var t=Ri(this._appkey,e);this._sendMessageMap=this._getLocalInfo(t)},n.prototype._getLocalInfo=function(e){var t=this._runtime.localStorage.getItem(e);try{return t?JSON.parse(t):{}}catch{return{}}},n.prototype.setMessage=function(e,t){this._sendMessageMap[e]=t;var r=Ri(this._appkey,this._userId),i=this._getLocalInfo(r);i[e]=t,this._runtime.localStorage.setItem(r,JSON.stringify(i))},n.prototype.getSendMessageMap=function(){return this._sendMessageMap},n.prototype.removeByUID=function(e){delete this._sendMessageMap[e]},n.prototype.removeByTimestamp=function(e){var t=Ri(this._appkey,this._userId),r=this._getLocalInfo(t);Object.keys(r).forEach(function(i){r[i]<e&&delete r[i]}),this._runtime.localStorage.setItem(t,JSON.stringify(r))},n}(),Ec=function(n){var e="RCDeviceId",t=Gr(n),r="",i=t.get(e);return i?r=i:(r=Ga(),t.set(e,r)),r};(gn={})[z.PRIVATE]=D.qryPMsg,gn[z.GROUP]=D.qryGMsg,gn[z.CHATROOM]=D.qryCHMsg,gn[z.CUSTOMER_SERVICE]=D.qryCMsg,gn[z.SYSTEM]=D.qrySMsg;var Wd=[D[D.recallMsg],D[D.ppMsgS],D[D.pgMsgS],D[D.ppMsgP],D[D.pgMsgP],D[D.chatMsg],D[D.pcMsgP],D[D.prMsgS]],Ei=function(n,e,t,r,i,s){return{conversationType:n,targetId:e,senderUserId:s,messageDirection:nt.SEND,isCounted:!!t.isCounted,isMentioned:!!t.isMentioned,content:t.content,messageType:t.messageType,isOffLineMessage:!1,isPersited:!!t.isPersited,messageUId:r,sentTime:i,receivedTime:0,disableNotification:!!t.disableNotification,isStatusMessage:!!t.isStatusMessage,canIncludeExpansion:!!t.canIncludeExpansion,expansion:t.canIncludeExpansion?t.expansion:null,receivedStatus:Mn.UNREAD,pushConfig:t.pushConfig,channelId:t.channelId}},zd=function(n){function e(t,r,i){var s=n.call(this,t,r,i)||this;return s._customMessageType={},s._reconnectTimer=-1,s._pullOfflineFinished=!1,s._connectedTime=0,s._localConnectedTime=0,s._pullingMsg=!1,s._pullQueue=[],s._chrmsQueue={},s._latestSyncTimestamp=0,s._intervalTimer=-1,s._letterbox=new Dd(t,i.appkey),s._sendMessageStore=new Jd(t,i.appkey),s._chrmEntryHandler=new Vd(s),s}return Ie(e,n),e.prototype._createNavi=function(){return new Gd(this.runtime,this._options)},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.connect=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l=this;return V(this,function(h){switch(h.label){case 0:return i=[],this._naviInfo=r,r.server?i.push(r.server):j.warn("navi.server is invalid"),(s=r.backupServer)&&s.split(",").forEach(function(a){i.indexOf(a)<0&&i.push(a)}),i.length===0?(j.error("navi invaild.",i),[2,S.UNKNOWN]):(o=this.runtime.createDataChannel({status:function(a){l._connectionStatusHandler(a,t,i,r.protocol)},signal:this._signalHandler.bind(this)},this._options.connectionType),u=Lt.V3,r.openAnti===1&&(u=Lt.V4),[4,o.connect(this._appkey,t,i,r.protocol,this._apiVer,u)]);case 1:return(d=h.sent())===S.SUCCESS?(this._channel=o,this.currentUserId=o.userId,this._connectedTime=o.connectedTime,this._localConnectedTime=Math.floor((Date.now()+o.sendConnectTime)/2),this._watcher.status(te.CONNECTED),this._pullOfflineFinished=!1,this._conversationManager=new Kd(this,this._appkey,this.currentUserId,this._watcher.conversation,this._watcher.conversationTag),this._conversationManager.startPullConversationStatus(0),this._userSettingManager=new qd(this,this._appkey,this.currentUserId,this._watcher.tag),this._userSettingManager.pullUserSettings(0),this._sendMessageStore.init(this.currentUserId),this._conversationManager.adaptOldStore(),this._rtcKVManager=new Yd(this),this._joinedChrmManager=new Bd(this.runtime,this._appkey,this.currentUserId,r.joinMChrm),this._startSyncInterval()):o.close(),[2,d]}})})},e.prototype._connectionStatusHandler=function(t,r,i,s){if(j.warn("connection status changed:",t),t!==te.CONNECTING)if(t!==te.CONNECTED){if(this._channel&&t!==te.DISCONNECTED)return t===te.BLOCKED||t===te.KICKED_OFFLINE_BY_OTHER_CLIENT||t===te.DISCONNECT_BY_SERVER?(this.disconnect(),void this._watcher.status(t)):void(t!==te.REDIRECT?(this._watcher.status(t),this._try2Reconnect(r,i,s)):this._watcher.status(t));this._watcher.status(t)}else this._watcher.status(t);else this._watcher.status(t)},e.prototype._try2Reconnect=function(t,r,i){return x(this,void 0,void 0,function(){var s,o=this;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=Lt.V3,this._naviInfo.openAnti===1&&(s=Lt.V4),[4,this._channel.connect(this._appkey,t,r,i,this._apiVer,s)]):[2];case 1:return u.sent()===S.SUCCESS?(this._pullOfflineFinished=!1,this._startSyncInterval(),this._watcher.status(te.CONNECTED),this._rejoinChrm(),j.__insertLogIntoDatabase(),[2]):(this._watcher.status(te.WEBSOCKET_UNAVAILABLE),this._reconnectTimer=setTimeout(function(){o._reconnectTimer=-1,o._try2Reconnect(t,r,i)},5e3),[2])}})})},e.prototype._signalHandler=function(t,r){var i=t.syncMsg,s=t.topic;if(i)this._receiveSyncMsg(t,r);else{var o=D[s];if(o)switch(o){case D.s_ntf:j.info("recv s_ntf -> signal.messageId: "+t.messageId),this._pullMsg(t);break;case D.s_msg:this._receiveMsg(t);break;case D.s_cmd:this._receiveStateNotify(t);break;case D.s_us:this._receiveSettingNotify(t);break;case D.rtc_ntf:this._receiveRtcKv(t)}else j.error("unknown topic:",s)}},e.prototype._receiveStateNotify=function(t){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(t.data,Or),s=i.time,o=i.type,u=i.chrmId;switch(o){case 2:this._chrmEntryHandler.pullEntry(u,s);break;case 3:this._conversationManager.startPullConversationStatus(s);break;case 4:this._chrmEntryHandler.reset(u),this._watcher.chatroom({chatroomDestroyed:t.targetId})}},e.prototype._receiveSettingNotify=function(t){var r,i=((r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(t.data,Zr)).version;this._userSettingManager.pullUserSettings(i)},e.prototype._receiveRtcKv=function(t){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(t.data,eo),s=i.time,o=i.type,u=i.roomId;switch(o){case 1:this._rtcKVManager.pullEntry(u,s)}},e.prototype._receiveMessageExpansion=function(t){var r=t.content,i=r.put,s=r.del,o=r.mid;i&&this._watcher.expansion({updatedExpansion:{messageUId:o,expansion:i}}),s&&this._watcher.expansion({deletedExpansion:{messageUId:o,deletedKeys:s}})},e.prototype._receiveSyncMsg=function(t,r){var i;if(Wd.includes(t.topic)){var s=(i=this._channel)===null||i===void 0?void 0:i.codec.decodeByPBName(t.data,Ln,{currentUserId:this.currentUserId,signal:t});s=this._handleMsgProperties(s),r&&(s.sentTime=r.timestamp,s.messageUId=r.messageUId),this._pullingMsg?this._pullQueue.push((r==null?void 0:r.timestamp)||s.sentTime):(r&&this._sendMessageStore.setMessage(r.messageUId,r.timestamp),s.messageType!==He.EXPANSION_NOTIFY?(s.messageType===He.SYNC_READ_STATUS&&this._conversationManager.clearUnreadCount(s.conversationType,s.targetId,s.channelId),this._conversationManager.setConversationCacheByMessage(s,!0),this._watcher.batchMessage([s])):this._receiveMessageExpansion(s))}},e.prototype._pullMsg=function(t){if(this._channel){var r=this._channel.codec.decodeByPBName(t.data,Or),i=r.type,s=r.chrmId,o=r.time;if(j.info("s_ntf -> type: "+i+", chrmId: "+s+", time: "+o),i===2){var u=this._chrmsQueue[s];if(!u)return;u.queue.push(o),this._pullChrmMsg(s)}else this._pullQueue.push(o),this._syncMsg()}},e.prototype._startSyncInterval=function(){var t=this;this._stopSyncInterval(),this._intervalTimer=setInterval(function(){Date.now()-t._latestSyncTimestamp>=18e4&&t._syncMsg()},3e4),this._latestSyncTimestamp=Date.now(),this._syncMsg()},e.prototype._stopSyncInterval=function(){this._intervalTimer!==-1&&(clearInterval(this._intervalTimer),this._intervalTimer=-1)},e.prototype._syncMsg=function(){return x(this,void 0,void 0,function(){var t,r,i,s,o,u,d,l,h,a,c,p,f,m,_=this;return V(this,function(v){switch(v.label){case 0:return this._pullingMsg?[2]:this._channel?(this._pullingMsg=!0,t=this._letterbox.getOutboxTime(this.currentUserId),r=this._letterbox.getInboxTime(this.currentUserId),j.info("pullMsg -> sendboxTime: "+t+", inboxTime: "+r),i=this._channel.codec.encodeSyncMsg({sendboxTime:t,inboxTime:r}),s=new Q(D[D.pullMsg],i,this.currentUserId),[4,this._channel.send(s,kn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return o=v.sent(),u=o.code,d=o.data,this._latestSyncTimestamp=Date.now(),u===S.SUCCESS&&d?(l=d.list,h=d.finished,a=d.syncTime,j.info("pullMsg success -> syncTime: "+a+", finished: "+h),c=0,p=[],l.forEach(function(R){if(R.messageDirection===nt.SEND&&(c=Math.max(R.sentTime,c),_._sendMessageStore.getSendMessageMap()[R.messageUId]))return void _._sendMessageStore.removeByUID(R.messageUId);if(R.messageType!==He.EXPANSION_NOTIFY){if(R.messageType===He.SYNC_READ_STATUS){if(R.senderUserId!==_.currentUserId)return;_._conversationManager.clearUnreadCount(R.conversationType,R.targetId,R.channelId)}var C=_._handleMsgProperties(R);_._conversationManager.setConversationCacheByMessage(C,!0),p.push(C)}else _._receiveMessageExpansion(R)}),this._watcher.batchMessage(p),this._letterbox.setInboxTime(a,this.currentUserId),this._letterbox.setOutboxTime(c,this.currentUserId),this._sendMessageStore.removeByTimestamp(c),this._pullingMsg=!1,f=this._pullQueue.filter(function(R){return R>a}),this._pullQueue.length=0,(m=this._pullQueue).push.apply(m,f),h&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!h||f.length>0)&&this._syncMsg(),[2]):(j.warn("pullMsg failed -> code:",u,", data: ",d),this._pullingMsg=!1,[2])}})})},e.prototype._receiveMsg=function(t){if(this._channel&&!this._pullingMsg)if(this._pullQueue.length>0)this._syncMsg();else{var r=this._channel.codec.decodeByPBName(t.data,Jr,{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!==He.EXPANSION_NOTIFY?r.messageType===He.SYNC_READ_STATUS&&r.senderUserId!==this.currentUserId||(this._conversationManager.setConversationCacheByMessage(r,!0),this._watcher.batchMessage([r])):this._receiveMessageExpansion(r)}},e.prototype._handleMsgProperties=function(t,r){r===void 0&&(r=!1);var i,s=t.messageType,o=t.isCounted,u=t.isPersited,d=t.isStatusMessage,l=s in To,h=s in this._customMessageType;if(i=l?To[s]:h?this._customMessageType[s]:{isCounted:!bo(o)&&o,isPersited:!bo(u)&&u},Object.assign(t,{isCounted:i.isCounted,isPersited:i.isPersited,isStatusMessage:Ju.includes(s)}),r&&(t.isStatusMessage=d),!r){var a=t.content.user;if(a){var c=a.portrait,p=a.portraitUri,f=c||p;f&&(a.portrait=a.portraitUri=f)}}return t},e.prototype.getHistoryMessage=function(t,r,i,s,o,u){return u===void 0&&(u=""),x(this,void 0,void 0,function(){var d,l,h,a,c,p,f,m,_;return V(this,function(v){switch(v.label){case 0:return l=(d=this).currentUserId,h=d._channel,a=wd[t]||ac,c=s===1&&i===0,h?(p=h.codec.encodeGetHistoryMsg(r,{timestamp:i,count:c?2:s,order:o,channelId:u}),[4,h.send(new Q(a,p,l),Un,{currentUserId:l,connectedTime:h.connectedTime,conversation:{targetId:r}})]):[3,2];case 1:return f=v.sent(),(m=f.code)!==S.SUCCESS?[2,{code:m}]:(_=f.data,c&&_.list.length===2&&(_.hasMore=!0,o===0?_.list.shift():_.list.pop()),[2,{code:m,data:{list:_.list,hasMore:_.hasMore}}]);case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.reportSDKInfo=function(t){var r=this.currentUserId,i=this._channel;if(i){j.debug("reportSDKInfo ->",t);var s=i.codec.encodeReportSDKInfo(JSON.stringify(t)),o=new Q(D[D.reportsdk],s,r);i.send(o).then(function(u){var d=u.code;d!==S.SUCCESS&&j.warn("reportSDKInfo failed -> code: "+d)})}},e.prototype.deleteRemoteMessage=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a,c;return V(this,function(p){switch(p.label){case 0:return u=(o=this).currentUserId,(d=o._channel)?(l=d.codec.encodeDeleteMessages(t,r,i,s),h=new Q(gd,l,u),[4,d.send(h)]):[3,2];case 1:return a=p.sent(),c=a.code,S.SUCCESS,[2,c];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype.deleteRemoteMessageByTimestamp=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return u=(o=this).currentUserId,(d=o._channel)?(l=d.codec.encodeClearMessages(r,i,s),h=Ad[t],a=new Q(h,l,u),[4,d.send(a)]):[3,2];case 1:return c=f.sent(),p=c.code,S.SUCCESS,[2,p];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversationList=function(t,r,i,s,o){return t===void 0&&(t=300),x(this,void 0,void 0,function(){var u,d,l,h,a,c,p,f,m=this;return V(this,function(_){switch(_.label){case 0:return d=(u=this).currentUserId,l=u._channel,r=r||z.PRIVATE,l?(h=l.codec.encodeOldConversationList({count:t,type:r,startTime:i,order:s}),a=new Q(Bo,h,d),[4,l.send(a,Dn,{currentUserId:d,connectedTime:l.connectedTime,afterDecode:function(v){var R=v.conversationType,C=v.targetId,A=v.channelId,M=m._conversationManager.get(R,C,A);return Object.assign(v,M),v}})]):[3,2];case 1:return c=_.sent(),p=c.code,f=c.data,p!==S.SUCCESS?[2,{code:p}]:[2,{code:p,data:f}];case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.removeConversation=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return(s=this._channel)?(o=s.codec.encodeRemoveOldConversationList({conversationType:t,channelId:i,targetId:r}),u=new Q(Td,o,r),[4,s.send(u)]):[3,2];case 1:return d=h.sent(),j.info("RemoveConversation =>",d),l=d.code,S.SUCCESS,[2,l];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversation=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return(s=this._conversationManager.get(t,r,i))?[4,this.getHistoryMessage(t,r,0,1,0)]:[2,{code:S.CONVER_GET_ERROR}];case 1:return o=a.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:S.CONVER_GET_ERROR}]:(l=(d==null?void 0:d.list[0])||null,h={conversationType:t,targetId:r,channelId:i,unreadMessageCount:s.unreadMessageCount||0,latestMessage:l,notificationStatus:s.notificationStatus||Kt.CLOSE,isTop:s.isTop||!1,lastUnreadTime:s.lastUnreadTime||0,unreadMentionedCount:s.unreadMentionedCount||0},[2,{code:S.SUCCESS,data:h}])}})})},e.prototype.getAllConversationUnreadCount=function(t,r,i){var s=this._conversationManager.getAllUnreadCount(t,r,i);return Promise.resolve({code:S.SUCCESS,data:s})},e.prototype.getConversationUnreadCount=function(t,r,i){var s=this._conversationManager.getUnreadCount(t,r,i);return Promise.resolve({code:S.SUCCESS,data:s})},e.prototype.clearConversationUnreadCount=function(t,r,i){return this._conversationManager.clearUnreadCount(t,r,i,!1),Promise.resolve(S.SUCCESS)},e.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(S.SUCCESS)},e.prototype.getFirstUnreadMessage=function(t,r){throw new Error("Method not implemented.")},e.prototype.saveConversationMessageDraft=function(t,r,i,s){return this._conversationManager.setDraft(t,r,i,s),Promise.resolve(S.SUCCESS)},e.prototype.getConversationMessageDraft=function(t,r,i){var s=this._conversationManager.getDraft(t,r,i);return Promise.resolve({code:S.SUCCESS,data:s})},e.prototype.clearConversationMessageDraft=function(t,r,i){return this._conversationManager.clearDraft(t,r,i),Promise.resolve(S.SUCCESS)},e.prototype.pullConversationStatus=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,s=r.currentUserId,i?(o=i.codec.encodeGetConversationStatus(t),u=new Q(D[D.pullSeAtts],o,s),[4,i.send(u,ei)]):[3,2];case 1:return d=a.sent(),l=d.code,h=d.data,l!==S.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}];case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.batchSetConversationStatus=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h,a,c=this;return V(this,function(p){switch(p.label){case 0:return i=(r=this).currentUserId,(s=r._channel)?(o=s.codec.encodeSetConversationStatus(t),u=new Q(Sd,o,i),[4,s.send(u,Ws)]):[3,2];case 1:return d=p.sent(),l=d.code,h=d.data,l===S.SUCCESS?(a=h,t.forEach(function(f){c._conversationManager.addStatus(Re(Re({},f),{updatedTime:a.version}),!0)}),[2,l]):[2,l];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype._joinChrm=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return(s=this._channel)?(o=s.codec.encodeJoinOrQuitChatRoom(),u=new Q(i?_d:md,o,t),[4,s.send(u,Ns)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return d=c.sent(),l=d.code,h=d.data,l===S.SUCCESS&&(a=h.joinTime,this._chrmsQueue[t]||(this._chrmsQueue[t]={pulling:!1,queue:[],timestamp:0}),this._pullChrmMsg(t,r,a),this._naviInfo.kvStorage&&this._chrmEntryHandler.pullEntry(t,0),this._joinedChrmManager.set(t,r)),[2,l]}})})},e.prototype._rejoinChrm=function(){return x(this,void 0,void 0,function(){var t,r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:for(i in t=this._joinedChrmManager.get(),r=[],t)r.push(i);s=0,d.label=1;case 1:return s<r.length?(o=r[s],[4,this._joinChrm(o,t[o]||10,!0)]):[3,4];case 2:(u=d.sent())===S.SUCCESS?this._watcher.chatroom({rejoinedRoom:{chatroomId:o,count:t[o]}}):this._watcher.chatroom({rejoinedRoom:{chatroomId:o,errorCode:u}}),d.label=3;case 3:return s++,[3,1];case 4:return[2]}})})},e.prototype._pullChrmMsg=function(t,r,i){return r===void 0&&(r=10),i===void 0&&(i=0),x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p,f,m,_;return V(this,function(v){switch(v.label){case 0:return this._channel?(s=this._chrmsQueue[t],o=s.pulling,u=s.timestamp,o?[2]:(s.pulling=!0,d=this._channel.codec.encodeChrmSyncMsg(u,r),l=new Q(D[D.chrmPull],d,t),[4,this._channel.send(l,kn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})])):[2];case 1:return h=v.sent(),a=h.code,c=h.data,s.pulling=!1,a===S.SUCCESS&&c?(p=c.list,f=c.syncTime,m=c.finished,s.timestamp=i?Math.max(f,i):f,s.queue=s.queue.filter(function(R){return R>f}),_=[],p.forEach(function(R){R.sentTime<u||_.push(R)}),this._watcher.batchMessage(_),(!m||s.queue.length>0)&&this._pullChrmMsg(t),[2]):(j.warn("pull chatroom msg failed, code:",a,", data:",c),[2])}})})},e.prototype.joinChatroom=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._joinChrm(t,r,!1)]})})},e.prototype.joinExistChatroom=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._joinChrm(t,r,!0)]})})},e.prototype.quitChatroom=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),s=new Q(vd,i,t),[4,r.send(s)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return o=d.sent(),(u=o.code)===S.SUCCESS&&(delete this._chrmsQueue[t],this._chrmEntryHandler.reset(t),this._joinedChrmManager.remove(t)),[2,u]}})})},e.prototype.getChatroomInfo=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return(s=this._channel)?(o=s.codec.encodeGetChatRoomInfo(r,i),u=new Q(D[D.queryChrmI],o,t),[4,s.send(u,Wr)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l!==S.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}]}})})},e.prototype.getChatroomHistoryMessages=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return(o=this._channel)?(u=o.codec.encodeGetHistoryMsg(t,{timestamp:r,count:i,order:s}),d=new Q(cc,u,t),[4,o.send(d,Un,{conversation:{targetId:t}})]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=c.sent(),h=l.code,a=l.data,h!==S.SUCCESS?[2,{code:h}]:[2,{code:h,data:{list:a.list,hasMore:a.hasMore}}]}})})},e.prototype._modifyChatroomKV=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(u=s.codec.encodeModifyChatRoomKV(t,r,o),d=r.type===We.UPDATE?Rd:Ed,l=new Q(d,u,t),[4,s.send(l)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return h=c.sent(),(a=h.code)===S.SUCCESS?(this._chrmEntryHandler.setLocal(t,{kvEntries:[r],syncTime:new Date().getTime()},o),[2,a]):[2,a]}})})},e.prototype._modifyChatroomKVS=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c,p,f,m;return V(this,function(_){switch(_.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(u=s.codec.encodeModifyChatRoomKVS(t,r,o),d=r.type===We.UPDATE?Cd:yd,l=new Q(d,u,t),[4,s.send(l,qs)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return h=_.sent(),a=h.code,[S.SUCCESS,S.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(a)!==-1&&(p=[],delete(f=Object.assign({},r)).entries,r.entries.forEach(function(v){p.push(Object.assign({},v,f))}),a===S.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(m=h.data,j.warn("\u8BBE\u7F6E\u5931\u8D25\u7684\u5C5E\u6027\uFF1A",m.errorKeys),c=m.errorKeys,m&&Array.isArray(m.errorKeys)&&m.errorKeys.forEach(function(v){var R=p.findIndex(function(C){return v.key===C.key});R!==-1&&p.splice(R,1)})),j.warn("\u8BBE\u7F6E\u6210\u529F\u7684\u5C5E\u6027\uFF1A",p),this._chrmEntryHandler.setLocal(t,{kvEntries:p,syncTime:new Date().getTime()},o)),[2,{code:a,data:c}]}})})},e.prototype.setChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.setChatroomEntries=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(t,r)]})})},e.prototype.forceSetChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.UPDATE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.removeChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.removeChatroomEntries=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(t,r)]})})},e.prototype.forceRemoveChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.DELETE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.getChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return(i=this._chrmEntryHandler.getValue(t,r))?[2,Promise.resolve({code:S.SUCCESS,data:i})]:[3,1];case 1:return(s=this._channel)?(o=s.codec.encodePullChatRoomKV(0),u=new Q(D[D.pullKV],o,t),[4,s.send(u,Wt)]):[2,Promise.reject({code:S.RC_NET_CHANNEL_INVALID})];case 2:return d=a.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&(h=l.kvEntries.find(function(c){return c.key===r}))!==void 0?[2,Promise.resolve({code:S.SUCCESS,data:h==null?void 0:h.value})]:[2,Promise.resolve({code:S.CHATROOM_KEY_NOT_EXIST})]}})})},e.prototype.getAllChatroomEntry=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return(r=this._chrmEntryHandler.getAll(t))&&Object.keys(r).length?[2,Promise.resolve({code:S.SUCCESS,data:r})]:[3,1];case 1:return(i=this._channel)?(s={},o=i.codec.encodePullChatRoomKV(0),u=new Q(D[D.pullKV],o,t),[4,i.send(u,Wt)]):[2,Promise.reject({code:S.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&&(s[a.key]=a.value||"")}),[2,Promise.resolve({code:S.SUCCESS,data:s})]}})})},e.prototype.pullChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(u=s.codec.encodePullChatRoomKV(r),d=new Q(D[D.pullKV],u,t),[4,s.send(d,Wt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=f.sent(),h=l.code,a=l.data,h===S.SUCCESS?(j.info("Pull success ChrmKV, "+JSON.stringify(l)),this._chrmEntryHandler.setLocal(t,a,o),j.info("Save into cache success!"),c=a.kvEntries,p=[],c.length>0&&(c.forEach(function(m){var _=m.key,v=m.value,R=m.type,C=m.timestamp;p.push({key:_,value:v,type:R,timestamp:C,chatroomId:t})}),this._watcher.chatroom({updatedEntries:p})),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.sendMessage=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p,f;return V(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),s=!![z.PRIVATE,z.GROUP].includes(t)&&i.isStatusMessage,o=s?function(_){var v;return(v={},v[z.PRIVATE]=D.ppMsgS,v[z.GROUP]=D.pgMsgS,v)[_]}(t):function(_){var v;return(v={},v[z.PRIVATE]=D.ppMsgP,v[z.GROUP]=D.pgMsgP,v[z.CHATROOM]=D.chatMsg,v[z.CUSTOMER_SERVICE]=D.pcMsgP,v[z.RTC_ROOM]=D.prMsgS,v)[_]}(t)||D.ppMsgP,s&&(i.isPersited=!1,i.isCounted=!1),u=this._channel.codec.encodeUpMsg({conversationType:t,targetId:r},i),(d=new fn(D[o],u,r)).setHeaderQos(vt.AT_LEAST_ONCE),s?(this._channel.sendOnly(d),[2,{code:S.SUCCESS,data:Ei(t,r,Re({},i),"",0,this.currentUserId)}]):(l=Date.now()-this._localConnectedTime+this._connectedTime,h=Ei(t,r,Re({},i),"",l,this.currentUserId),[4,this._channel.send(d)])):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),c=a.code,p=a.data,c!==S.SUCCESS?[2,{code:c,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:S.SUCCESS,data:h}])}})})},e.prototype.recallMsg=function(t,r,i,s,o){var u;return x(this,void 0,void 0,function(){var d,l,h,a,c,p,f,m,_,v;return V(this,function(R){switch(R.label){case 0:return this._channel?(d=o.user,l={content:{conversationType:t,targetId:r,messageUId:i,sentTime:s,user:d},messageType:"RC:RcCmd",disableNotification:o==null?void 0:o.disableNotification,pushConfig:o==null?void 0:o.pushConfig,pushContent:((u=o.pushConfig)===null||u===void 0?void 0:u.pushContent)||o.pushContent||"",channelId:o.channelId},h=D[D.recallMsg],a=this._channel.codec.encodeUpMsg({conversationType:t,targetId:r},l),(c=new fn(h,a,this.currentUserId)).setHeaderQos(vt.AT_LEAST_ONCE),[4,this._channel.send(c)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return p=R.sent(),f=p.code,m=p.data,f!==S.SUCCESS?[2,{code:f}]:(_=m,this._sendMessageStore.setMessage(_.messageUId,_.timestamp),v=Ei(t,r,Re(Re({},l),{isPersited:!0}),_.messageUId,_.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(v,!0),[2,{code:S.SUCCESS,data:v}])}})})},e.prototype.sendReadReceiptMessage=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeReadReceipt(r,i),o=new Q(D[D.rrMsg],s,t),[4,this._channel.send(o)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return[2,u.sent()]}})})},e.prototype.getMessageReader=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeMessageReader(r,i),o=new Q(D[D.rrList],s,t),[4,this._channel.send(o,ti)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return[2,u.sent()]}})})},e.prototype.pullUserSettings=function(t){return x(this,void 0,void 0,function(){var r,i;return V(this,function(s){return this._channel?(r=this._channel.codec.encodePullUserSetting(t),i=new Q(D[D.pullUS],r,this.currentUserId),[2,this._channel.send(i,Xr)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getFileToken=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return this._channel?(o=s&&s!=="uploads"?r||"":td(t,r),u=this._channel.codec.encodeGetFileToken(t,o,i||"",s||""),d=new Q(D[D.qnTkn],u,this.currentUserId),[4,this._channel.send(d,Vs)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=c.sent(),h=l.code,a=l.data,a=Object.assign(a,{fileName:o}),h===S.SUCCESS?[2,{code:h,data:a}]:[2,{code:h}]}})})},e.prototype.getFileUrl=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a,c,p,f;return V(this,function(m){switch(m.label){case 0:return this._channel?(o="",u="",d="",r===Ge.QINIU?(u=Bs,d=Hs):(u=Fs,d=$s),o=r===Ge.QINIU?D[D.qnUrl]:r===Ge.AWS?D[D.s3Url]:r===Ge.STC?D[D.stcUrl]:D[D.aliUrl],l=this._channel.codec.encodeGetFileUrl(u,t,i,s),h=new Q(o,l,this.currentUserId),[4,this._channel.send(h,d)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),c=a.code,p=a.data,f=p,c===S.SUCCESS?[2,{code:c,data:f}]:[2,{code:c}]}})})},e.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()},e.prototype.destroy=function(){throw new Error("JSEngine's method not implemented.")},e.prototype.registerMessageType=function(t,r,i,s){this._customMessageType[t]={isPersited:r,isCounted:i}},e.prototype.getServerTime=function(){return Date.now()-this._localConnectedTime+this._connectedTime},e.prototype.getCurrentUserId=function(){return this.currentUserId},e.prototype.createTag=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([t],r),s=new Q(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(s,zt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:u}]:(l=d.version,this._userSettingManager.addTag([Re(Re({},t),{createdTime:l})],l),[2,{code:S.SUCCESS,data:d}])}})})},e.prototype.removeTag=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeRemoveTag([t],r),s=new Q(D[D.delSeTag],i,this.currentUserId),[4,this._channel.send(s,zt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:u}]:(l=d.version,this._userSettingManager.deleteTag([t],l),[2,{code:S.SUCCESS}])}})})},e.prototype.updateTag=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([t],r),s=new Q(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(s,zt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:u}]:(l=d.version,this._userSettingManager.addTag([t],l),[2,{code:S.SUCCESS,data:d}])}})})},e.prototype.getTagList=function(){return x(this,void 0,void 0,function(){var t,r;return V(this,function(i){return t=this._userSettingManager.getTags(),r=this._conversationManager.getConversationListForTag(),t.forEach(function(s){s.conversationCount=r[s.tagId]?r[s.tagId].length:0}),[2,{code:S.SUCCESS,data:t}]})})},e.prototype.addTagForConversations=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d=this;return V(this,function(l){switch(l.label){case 0:return this._channel?this._userSettingManager.getTagById(t)?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:t}],r),s=new Q(D[D.addTag],i,this.currentUserId),[4,this._channel.send(s)]):[2,{code:S.TAG_NOT_EXIST}]:[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(o=l.sent().code)!==S.SUCCESS?[2,{code:o}]:((u={})[t]={},r.forEach(function(h){d._conversationManager.addTagStatus(h.conversationType,h.targetId,u,h.channelId)}),[2,{code:S.SUCCESS}])}})})},e.prototype.removeTagForConversations=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u=this;return V(this,function(d){switch(d.label){case 0:return this._channel?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:t}],r),s=new Q(D[D.delTag],i,this.currentUserId),[4,this._channel.send(s)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(o=d.sent().code)!==S.SUCCESS?[2,{code:o}]:(r.forEach(function(l){u._conversationManager.deleteTagStatus(l.conversationType,l.targetId,[t],l.channelId)}),[2,{code:S.SUCCESS}])}})})},e.prototype.removeTagsForConversation=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return this._channel?(i=t.conversationType,s=t.targetId,o=t.channelId,u=r.map(function(c){return{tagId:c}}),d=this._channel.codec.encodeUpdateConversationTag(u,[t]),l=new Q(D[D.delTag],d,this.currentUserId),[4,this._channel.send(l)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(h=a.sent().code)!==S.SUCCESS?[2,{code:h}]:(this._conversationManager.deleteTagStatus(i,s,r,o),[2,{code:S.SUCCESS}])}})})},e.prototype.getConversationListByTag=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return o=(s=this).currentUserId,(u=s._channel)?(d=u.codec.encodeOldConversationList({count:i,type:z.PRIVATE,startTime:r}),l=new Q(Bo,d,o),[4,u.send(l,Dn,{currentUserId:o,connectedTime:u.connectedTime})]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return h=f.sent(),a=h.code,c=h.data,p=this._conversationHasTagFilter(t,c),j.info("GetConversationListByTag",p),a!==S.SUCCESS?[2,{code:a}]:[2,{code:a,data:p}]}})})},e.prototype._conversationHasTagFilter=function(t,r){var i=this,s=[],o=[];function u(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,c=i._conversationManager.get(l,h,a),p=c.hasMentioned,f=c.mentionedInfo,m=c.lastUnreadTime,_=c.notificationStatus,v=c.isTop,R=c.tags,C=c.unreadMessageCount,A=R&&R[t];if(A){var M=Re(Re({},d),{hasMentioned:p,mentionedInfo:f,lastUnreadTime:m,notificationStatus:_,isTop:v,unreadMessageCount:C});A.isTop?s.push(Re(Re({},M),{isTopInTag:!0})):o.push(Re(Re({},M),{isTopInTag:!1}))}}),Ut(Ut([],s.sort(u)),o.sort(u))},e.prototype.getUnreadCountByTag=function(t,r){return x(this,void 0,void 0,function(){var i;return V(this,function(s){return this._channel?(i=this._conversationManager.getUnreadCountByTag(t,r),[2,{code:S.SUCCESS,data:i}]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setConversationStatusInTag=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p,f;return V(this,function(m){switch(m.label){case 0:return this._channel?(s=r.targetId,o=r.conversationType,u=r.channelId,d=i.isTop,l=[{tagId:t,isTop:d}],(h=this._conversationManager.get(o,s,u)).tags&&Object.hasOwnProperty.call(h.tags,t)?(a=this._channel.codec.encodeUpdateConversationTag(l,[r]),c=new Q(D[D.addTag],a,this.currentUserId),[4,this._channel.send(c)]):[2,{code:S.NO_TAG_IN_CONVER}]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(p=m.sent().code)!==S.SUCCESS?[2,{code:p}]:((f={})[t]={},d&&(f[t].isTop=!0),this._conversationManager.addTagStatus(o,s,f,u),[2,{code:S.SUCCESS}])}})})},e.prototype.getTagsForConversation=function(t){var r;return x(this,void 0,void 0,function(){var i,s,o,u;return V(this,function(d){if(!this._channel)return[2,{code:S.RC_NET_CHANNEL_INVALID}];if(i=this._conversationManager.get(t.conversationType,t.targetId,t.channelId),s=this._userSettingManager.getTagsInfo(),o=[],i.tags)for(u in i.tags)o.push({tagId:u,tagName:(r=s[u])===null||r===void 0?void 0:r.tagName});return[2,{code:S.SUCCESS,data:o}]})})},e.prototype.getBlockConversationList=function(){var t=this._conversationManager.getBlockConversationList();return Promise.resolve({code:S.SUCCESS,data:t})},e.prototype.getTopConversationList=function(){var t=this._conversationManager.getTopConversationList();return Promise.resolve({code:S.SUCCESS,data:t})},e.prototype.getUnreadMentionedCount=function(t){var r=this._conversationManager.getUnreadMentionedCount(t.channelId,t.conversationType,t.targetId);return Promise.resolve({code:S.SUCCESS,data:r})},e.prototype.getAllUnreadMentionedCount=function(){var t=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:S.SUCCESS,data:t})},e.prototype.joinRTCRoom=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u;return V(this,function(d){return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i,s),u=new Q(D[D.rtcRJoin_data],o,t),[2,this._channel.send(u,kt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.quitRTCRoom=function(t){return x(this,void 0,void 0,function(){var r,i;return V(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(D[D.rtcRExit],r,t),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.rtcPing=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new Q(D[D.rtcPing],s,t),[4,this._channel.send(o)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,u.sent().code]}})})},e.prototype.getRTCRoomInfo=function(t){return x(this,void 0,void 0,function(){var r,i;return V(this,function(s){return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcRInfo],r,t),[2,this._channel.send(i,Xa)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getRTCUserInfoList=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcUData],r,t),[4,this._channel.send(i,kt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return s=d.sent(),o=s.code,u=s.data,[2,{code:o,data:u&&{users:u.users}}]}})})},e.prototype.setRTCUserInfo=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeSetRTCUserInfo(r,i),o=new Q(D[D.rtcUPut],s,t),[4,this._channel.send(o)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,u.sent().code]}})})},e.prototype.removeRTCUserInfo=function(t,r){return x(this,void 0,void 0,function(){var i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(i=this._channel.codec.encodeRemoveRTCUserInfo(r),s=new fn(D[D.rtcUDel],i,t),[4,this._channel.send(s)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.setRTCData=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(d=this._channel.codec.encodeSetRTCData(r,i,s,o,u),l=new fn(D[D.rtcSetData],d,t),[4,this._channel.send(l)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,h.sent().code]}})})},e.prototype.setRTCTotalRes=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var u,d;return V(this,function(l){switch(l.label){case 0:return this._channel?(u=this._channel.codec.encodeUserSetRTCData(r,i,s,o),d=new Q(D[D.userSetData],u,t),[4,this._channel.send(d)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCCDNUris=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeUserSetRTCCDNUris(r,i),o=new Q(D[D.userSetData],s,t),[4,this._channel.send(o)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,u.sent().code]}})})},e.prototype.getRTCData=function(t,r,i,s){if(!this._channel)return Promise.resolve({code:S.RC_NET_CHANNEL_INVALID});var o=this._channel.codec.encodeGetRTCData(r,i,s),u=new Q(D[D.rtcQryData],o,t);return this._channel.send(u,Qr)},e.prototype.removeRTCData=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var u,d;return V(this,function(l){switch(l.label){case 0:return this._channel?(u=this._channel.codec.encodeRemoveRTCData(r,i,s,o),d=new fn(D[D.rtcDelData],u,t),[4,this._channel.send(d)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCOutData=function(t,r,i,s){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCOutData=function(t,r){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCToken=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new Q(D[D.rtcToken],s,t),[2,this._channel.send(o,zr)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setRTCState=function(t,r){return x(this,void 0,void 0,function(){var i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(i=this._channel.codec.encodeSetRTCState(r),s=new Q(D[D.rtcUserState],i,t),[4,this._channel.send(s)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.getRTCUserInfo=function(t){return x(this,void 0,void 0,function(){return V(this,function(r){throw new Error("Method not implemented.")})})},e.prototype.getRTCUserList=function(t){if(!this._channel)return Promise.resolve({code:S.RC_NET_CHANNEL_INVALID});var r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcUList],r,t);return this._channel.send(i,kt)},e.prototype.joinLivingRoomAsAudience=function(t,r,i){return r===void 0&&(r=je.LIVE),x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c;return V(this,function(p){switch(p.label){case 0:return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new Q(D[D.viewerJoinR],s,t),[4,this._channel.send(o,sc)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return u=p.sent(),d=u.code,l=u.data,d!==S.SUCCESS?[2,{code:d}]:(a=(h=l).rtcToken,c=h.entries,[2,{code:d,data:{token:a,kvEntries:c}}])}})})},e.prototype.quitLivingRoomAsAudience=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(D[D.viewerExitR],r,t),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.rtcIdentityChange=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(s=this._channel.codec.encodeIdentityChangeInfo(r,i),o=new Q(D[D.rtcIdentityChange],s,t),[4,this._channel.send(o,kt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return u=h.sent(),d=u.code,l=u.data,d!==S.SUCCESS?[2,{code:d}]:[2,{code:d,data:l}]}})})},e.prototype.pullRTCRoomEntry=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c;return V(this,function(p){switch(p.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(j.info("audience in room start pull KV"),u=s.codec.encodePullRTCRoomKV(t,0),d=new Q(D[D.rtcPullKv],u,o),[4,s.send(d,ni)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=p.sent(),h=l.code,a=l.data,j.info("audience in room end pull KV, code: "+h+", data: "+JSON.stringify(a||{})),h===S.SUCCESS?(c=a.kvEntries,this._watcher.onRTCDataChange(c,t),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.getRTCJoinedUserInfo=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,s=r.currentUserId,i?(o=i.codec.encodeQueryUserJoinedInfo(t),u=new Q(D[D.rtcQueryJoined],o,s),[4,i.send(u,ri)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l===S.SUCCESS?[2,{code:l,data:h}]:[2,{code:l}]}})})},e.prototype.getDeviceId=function(){return Ec(this.runtime)},e.prototype.requestRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeRequestRoomPK(t),i=new Q(D[D.rtcInvite],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.cancelRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeCancelRoomPK(t),i=new Q(D[D.rtcCancelInvite],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.responseRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeResponseRoomPK(t),i=new Q(D[D.rtcInviteAnswer],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.endRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeEndRoomPK(t),i=new Q(D[D.rtcEndInvite],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.callExtra=function(t){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return Promise.resolve({code:S.EXTRA_METHOD_UNDEFINED})},e.prototype.getConversationListWithAllChannel=function(){throw new Error("Method not implemented.")},e.prototype.getConversationListWithAllChannelByPage=function(t,r){throw new Error("Method not implemented.")},e.prototype.clearConversations=function(){throw new Error("Method not implemented.")},e.prototype.setUserStatusListener=function(t,r){throw new Error("Method not implemented.")},e.prototype.setUserStatus=function(t){throw new Error("Method not implemented.")},e.prototype.subscribeUserStatus=function(t){throw new Error("Method not implemented.")},e.prototype.getUserStatus=function(t){throw new Error("Method not implemented.")},e.prototype.addToBlacklist=function(t){throw new Error("Method not implemented.")},e.prototype.removeFromBlacklist=function(t){throw new Error("Method not implemented.")},e.prototype.getBlacklist=function(){throw new Error("Method not implemented.")},e.prototype.getBlacklistStatus=function(t){throw new Error("Method not implemented.")},e.prototype.insertMessage=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.deleteMessages=function(t){throw new Error("Method not implemented.")},e.prototype.deleteMessagesByTimestamp=function(t,r,i,s,o){throw new Error("Method not implemented.")},e.prototype.clearMessages=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.getMessage=function(t){throw new Error("Method not implemented.")},e.prototype.setMessageContent=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.setMessageSearchField=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.searchConversationByContent=function(t,r,i,s){throw new Error("Method not implemented.")},e.prototype.searchMessageByContent=function(t,r,i,s,o,u){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedMessages=function(t,r){throw new Error("Method not implemented.")},e.prototype.setMessageSentStatus=function(t,r){throw new Error("Method not implemented.")},e.prototype.setMessageReceivedStatus=function(t,r){throw new Error("Method not implemented.")},e.prototype.clearUnreadCountByTimestamp=function(t,r,i,s){throw new Error("Method not implemented.")},e.prototype.getConversationNotificationStatus=function(t,r,i){var s=this._conversationManager.get(t,r,i);return s?Promise.resolve({code:S.SUCCESS,data:s.notificationStatus}):Promise.resolve({code:S.CONVER_GET_ERROR})},e.prototype.getRemoteHistoryMessages=function(t,r,i,s,o,u){return this.getHistoryMessage(t,r,i,s,o,u)},e}(kd),Cc=function(){function n(e){this._context=e}return n.prototype.getCoreVersion=function(){return this._context.coreVersion},n.prototype.getAPIVersion=function(){return this._context.apiVersion},n.prototype.getAppkey=function(){return this._context.appkey},n.prototype.getCurrentId=function(){return this._context.getCurrentUserId()},n.prototype.getConnectionStatus=function(){return this._context.getConnectionStatus()},n.prototype.getDeviceId=function(){return this._context.getDeviceId()},n.prototype.sendMessage=function(e,t,r){return this._context.sendMessage(e,t,r)},n.prototype.registerMessageType=function(e,t,r,i){i===void 0&&(i=[]),this._context.registerMessageType(e,t,r,i)},n.prototype.getServerTime=function(){return this._context.getServerTime()},n.prototype.getRTCJoinedUserInfo=function(e){return this._context.getRTCJoinedUserInfo(e)},n}(),Qd=function(n){function e(){return n!==null&&n.apply(this,arguments)||this}return Ie(e,n),e.prototype.getNaviInfo=function(){return this._context.getInfoFromCache()},e.prototype.joinRTCRoom=function(t,r,i,s){return this._context.joinRTCRoom(t,r,i,s)},e.prototype.quitRTCRoom=function(t){return this._context.quitRTCRoom(t)},e.prototype.rtcPing=function(t,r,i){return this._context.rtcPing(t,r,i)},e.prototype.getRTCRoomInfo=function(t){return this._context.getRTCRoomInfo(t)},e.prototype.getRTCUserInfoList=function(t){return this._context.getRTCUserInfoList(t)},e.prototype.getRTCUserInfo=function(t){return this._context.getRTCUserInfo(t)},e.prototype.setRTCUserInfo=function(t,r,i){return this._context.setRTCUserInfo(t,r,i)},e.prototype.removeRTCUserInfo=function(t,r){return this._context.removeRTCUserInfo(t,r)},e.prototype.setRTCData=function(t,r,i,s,o,u){return this._context.setRTCData(t,r,i,s,o,u)},e.prototype.setRTCTotalRes=function(t,r,i,s,o){return this._context.setRTCTotalRes(t,r,i,s,o)},e.prototype.setRTCCDNUris=function(t,r,i){return this._context.setRTCCDNUris(t,r,i)},e.prototype.getRTCData=function(t,r,i,s){return this._context.getRTCData(t,r,i,s)},e.prototype.removeRTCData=function(t,r,i,s,o){return this._context.removeRTCData(t,r,i,s,o)},e.prototype.setRTCOutData=function(t,r,i,s){return this._context.setRTCOutData(t,r,i,s)},e.prototype.getRTCOutData=function(t,r){return this._context.getRTCOutData(t,r)},e.prototype.getRTCToken=function(t,r,i){return this._context.getRTCToken(t,r,i)},e.prototype.setRTCState=function(t,r){return this._context.setRTCState(t,r)},e.prototype.getRTCUserList=function(t){return this._context.getRTCUserList(t)},e.prototype.joinLivingRoomAsAudience=function(t,r,i){return this._context.joinLivingRoomAsAudience(t,r,i)},e.prototype.quitLivingRoomAsAudience=function(t){return this._context.quitLivingRoomAsAudience(t)},e.prototype.rtcIdentityChange=function(t,r,i){return this._context.rtcIdentityChange(t,r,i)},e.prototype.requestRoomPK=function(t){return this._context.requestRoomPK(t)},e.prototype.cancelRoomPK=function(t){return this._context.cancelRoomPK(t)},e.prototype.responseRoomPK=function(t){return this._context.responseRoomPK(t)},e.prototype.endRoomPK=function(t){return this._context.endRoomPK(t)},e}(Cc),Yo=function(){function n(){}return n.compress=function(e){for(var t=this,r={},i=0;i<e.length-1;i++){var s=e.charAt(i)+e.charAt(i+1);r.hasOwnProperty(s)?r[s].push(i):r[s]=[i]}for(var o=[],u=[],d=function(){if(u.length>0){var _=u.join("");if(u=[],_.length>26){var v=t.numberEncode(_.length),R=String.fromCharCode(t.dataType.NormalExt|v.length);o.push(R+v)}else{var C=String.fromCharCode(t.dataType.Normal|_.length);o.push(C)}o.push(_)}},l=0;l<e.length;){var h=t.indexOf(r,e,l);if(h.length<2)u.push(e.charAt(l++));else if(h.length<4)u.push(e.substr(l,h.length)),l+=h.length;else{var a=t.numberEncode(l-h.offset),c=t.numberEncode(h.length);if(a.length+c.length>=h.length)u.push(e.substr(l,h.length)),l+=h.length;else{d();var p=String.fromCharCode(t.dataType.Compressed|a.length<<2|c.length);o.push(p+a+c),l+=h.length}}}d();var f=t.numberEncode(e.length),m=String.fromCharCode(t.dataType.Tail|f.length);return o.push(m+f),o.join("")},n.uncompress=function(e){var t=this,r=0,i="";e:do{var s=e.charCodeAt(r++),o=s&t.dataType.Mark,u=15&s,d=void 0;switch(o){case t.dataType.Compressed:var l=u>>2,h=3&u;if(l===0||h===0)throw new Error("Data parsing error,at "+r);var a=t.numberDecode(e.substr(r,l)),c=t.numberDecode(e.substr(r+=l,h));if((a=i.length-a)+c>i.length)throw new Error("Data parsing error,at "+r);r+=h,i+=i.substr(a,c);break;case t.dataType.Tail:if((d=t.numberDecode(e.substr(r,u)))!==i.length)throw console.log(i.length),console.log(d),new Error("Data parsing error,at "+r);r+=u;break e;case t.dataType.NormalExt:d=t.numberDecode(e.substr(r,u)),i+=e.substr(r+=u,d),r+=d;break;case t.dataType.Normal:i+=e.substr(r,u),r+=u;break;case t.dataType.Mark:if(u>10)throw new Error("Data parsing error,at "+r);i+=e.substr(r,16+u),r+=16+u;break;default:throw new Error("Data parsing error,at "+r+" header:"+o)}}while(r<e.length);return i},n.indexOf=function(e,t,r){var i={length:0,offset:-1};if(t.length,r>=t.length-1)return i;var s=e[t.charAt(r)+t.charAt(r+1)];if(s[0]===r)return i;for(var o=t.length-r,u=0,d=s.length;u<d;u++){var l=s[u],h=r-l;if(!(h>this.max)){var a=Math.min(o,h);if(a<=i.length)break;if(!(i.length>2&&t.charAt(l+i.length-1)!==t.charAt(r+i.length-1))){for(var c=2,p=c;p<a&&t.charAt(l+p)===t.charAt(r+p);p++)c++;c>=i.length&&(i.length=c,i.offset=l)}}}return i},n.numberEncode=function(e){var t=this,r=[],i=0;do i=e%t.scale,r.push(t.chars.charAt(i)),e=(e-i)/t.scale;while(e>0);return r.join("")},n.numberDecode=function(e){for(var t=0,r=0,i=e.length-1;i>=0;i--){if((r=this.chars.indexOf(e.charAt(i)))===-1)throw new Error('decode number error, data is "'+e+'"');t=t*this.scale+r}return t},n.dataType={Tail:48,Compressed:64,NormalExt:80,Normal:96,Mark:112},n.chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n.scale=n.chars.length,n.max=238327,n}(),mn=1,_n=!1,Jo=typeof location!="undefined"&&location.protocol==="https://"?"https://":"http://",nr=function(){function n(e){this.info=e,this.logUrl="logcollection.ronghub.com",this.level=1,this.itv=30,this.times=5,this.deviceId="",this.deviceInfo="",this.logSwitch=0,this.logUrl=e.logPolicy.url||this.logUrl,this.level=e.logPolicy.level||this.level,this.itv=e.logPolicy.itv||this.itv,this.times=e.logPolicy.times||this.times,this.deviceId=Ec(e.runtime),this.logSwitch=e.logSwitch;var t=sd(e.runtime);this.deviceInfo=t.type+"|"+t.version+"|"+wt.sessionId,this.startReport()}return n.init=function(e){return _n=!0,n._instance||(n._instance=new n(e)),n._instance},n.getInstance=function(){return n._instance},n.prototype.startReport=function(){var e=this;if(this.logSwitch&&_n){var t=this.itv*Math.pow(2,mn-1);mn<this.times&&mn++,setTimeout(function(){e.reportRealtimeLog()},1e3*t)}},n.prototype.reportRealtimeLog=function(){var e=this,t=wt.realTimeLogList.filter(function(s){return s.level<=e.level});if(t.length!==0){var r=Yo.compress(t.map(function(s){return s.content}).join("")),i=""+Jo+this.logUrl+"?version="+this.info.version+"&appkey="+this.info.appkey+"&userId="+this.info.userId+"&deviceId="+this.deviceId+"&deviceInfo="+this.deviceInfo+"&platform=Web";this.info.runtime.httpReq({method:"POST",url:i,body:r}).then(function(s){j.__clearRealTimeLog(),j.debug("report real-time log success");var o=s.data;o&&(o=JSON.parse(o),e.itv=o.nextTime,e.level=o.level,e.logSwitch=o.logSwitch,mn=1),e.startReport()}).catch(function(s){j.debug("report real-time log error -> "+s),e.startReport()})}else this.startReport()},n.prototype.reportFullLog=function(e){return x(this,void 0,void 0,function(){var t,r,i,s,o,u,d,l,h,a,c=this;return V(this,function(p){switch(p.label){case 0:return t=e.startTime,r=e.endTime,i=e.platform,s=e.logId,o=e.uri,u=ps.getInstance(),j.debug("received report log msg, "+i.toLowerCase(),u),i.toLowerCase()==="web"&&u?t>r?(j.warn("report error: The start time("+t+") cannot be greater than the end time("+t+")"),[2]):[4,j.__insertLogIntoDatabase()]:[2];case 1:return p.sent(),[4,u.getRangeData(Jt,"time",t,r)];case 2:return d=(d=p.sent()).filter(function(f){return!f.userId||f.userId===c.info.userId}),l=Yo.compress(d.map(function(f){return f.content}).join("")||"no data"),h=1,(a=function(){if(!(h>3)&&_n){var f=o||c.logUrl,m=""+Jo+f+"?version="+c.info.version+"&appkey="+c.info.appkey+"&userId="+c.info.userId+"&logId="+s+"&deviceId="+c.deviceId+"&deviceInfo="+c.deviceInfo+"&platform=Web",_=5e3*(h-1);h++,setTimeout(function(){_n&&c.info.runtime.httpReq({url:m,method:"POST",body:l}).then(function(){j.debug("report full log success!")}).catch(function(v){a(),j.warn("report full log error -> "+v)})},_)}})(),[2]}})})},n.prototype.distroy=function(){mn=1,_n=!1},n}();function rr(n){return Object.assign({},n)}var Wo,Xd=function(){function n(e,t){var r;this._runtime=e,this._token="",this._pluginContextQueue=[],this._pluginInstanseMap={},this.coreVersion="5.1.1",this._versionInfo={},this._typingInfo={},this._isInternalConnected=!1,this._connectionStatus=te.DISCONNECTED,this._canRedirectConnect=!1,this._watcher={message:void 0,batchMessage:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,readReceiptReceived:void 0,messageReceiptRequest:void 0,messageReceiptResponse:void 0,typingState:void 0,messageBlocked:void 0},this._typingInternalTimer=-1,this._typingExpireTime=2e3,this._typingChangedList=[],this.getChatRoomHistoryMessages=this.getChatroomHistoryMessages,this._options=Object.assign({},t),this.appkey=this._options.appkey,this.apiVersion=this._options.apiVersion,this._options.typingExpireTime&&(this._options.typingExpireTime<2e3?this._typingExpireTime=2e3:this._options.typingExpireTime>6e3?this._typingExpireTime=6e3:this._typingExpireTime=this._options.typingExpireTime),this._options.navigators=this._options.navigators.filter(function(s){return/^https?:\/\//.test(s)}),this._options.navigators=this._options.navigators.map(function(s){return s.replace(/\/$/g,"")}),this._options.navigators.length===0&&(r=this._options.navigators).push.apply(r,qu);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)};this._engine=ko()?new RCCppEngine(e,i,this._options):new zd(e,i,this._options)}return n.init=function(e,t){return j.setLogLevel(t.logLevel),j.setLogStdout(t.logStdout),(t.indexDBSwitch||fe(t.indexDBSwitch))&&ps.init(),j.debug("APIContext.init =>",t.appkey,t.navigators),this._context?(j.error("Repeat initialize!"),this._context):(j.warn("RCEngine Commit:","41dbe38d1b376ca0a791b23ed94be291e3f92e81"),this._context=new n(e,t),j.__insertLogIntoDatabase(),this._context)},n.destroy=function(){this._context&&(this._context._destroy(),this._context=void 0)},n.prototype.install=function(e,t){if(this._pluginInstanseMap[e.tag])return j.warn("Repeat install plugin: "+e.tag),this._pluginInstanseMap[e.tag];var r=e.tag==="RCRTC"?new Qd(this):new Cc(this),i=null;try{if(!e.verify(this._runtime))return null;i=e.setup(r,this._runtime,t)}catch(s){j.error(`install plugin error!
- `,s)}return["RCRTC","RCCall"].includes(e.tag)&&e.version&&e.name&&(this._versionInfo[e.name]=e.version),i&&this._pluginContextQueue.push(r),i&&(this._pluginInstanseMap[e.tag]=i),i},n.prototype._handleRedirect=function(){return x(this,void 0,void 0,function(){var e=this;return V(this,function(t){switch(t.label){case 0:return j.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return t.sent().code!==S.SUCCESS&&this._canRedirectConnect&&(this._handleSuspend(),setTimeout(function(){e._handleRedirect()},5e3)),[2]}})})},n.prototype._connectionStatusListener=function(e){var t;return x(this,void 0,void 0,function(){return V(this,function(r){return e===te.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(),this._handleRedirect()):e===te.BLOCKED||e===te.KICKED_OFFLINE_BY_OTHER_CLIENT||e===te.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect()):e===te.CONNECTING?this._handleConnecting():e===te.CONNECTED?this._handleConnected():e===te.DISCONNECTED?this._handleDisconnect():e===te.NETWORK_UNAVAILABLE&&this._handleSuspend(),this._connectionStatus=e,((t=this._watcher.rtcInnerWatcher)===null||t===void 0?void 0:t.status)&&this._watcher.rtcInnerWatcher.status(e),this._pluginContextQueue.forEach(function(i){i.onconnectionstatechange&&i.onconnectionstatechange(e)}),this._watcher.connectionState&&this._watcher.connectionState(e),[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(){this._watcher.onDisconnect&&this._watcher.onDisconnect()},n.prototype._handleSuspend=function(){this._watcher.onSuspend&&this._watcher.onSuspend()},n.prototype._messageReceiver=function(e,t,r){var i,s,o;if((e.conversationType===z.RTC_ROOM||Object.prototype.hasOwnProperty.call(Xu,e.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(rr(e));else if(["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(e.messageType)===-1||typeof this._watcher.chatroomState!="function"){if(e.messageType!=="RC:ChrmMemChange"){if(e.messageType!==He.TYPING_STATUS||(this._addTypingInfo(rr(e)),!this._watcher.typingState))if(e.messageType!==He.LOG_COMMAND||e.senderUserId!=="rongcloudsystem")if(e.messageType!==He.INTERCEPT){if(!this._pluginContextQueue.some(function(v){if(!v.onmessage)return!1;try{return v.onmessage(rr(e))}catch(R){return j.error("plugin error =>",R),!1}}))if(e.messageType!=="RC:ReadNtf")if(e.messageType!=="RC:RRReqMsg"){if(e.messageType!=="RC:RRRspMsg")return this._watcher.message&&this._watcher.message(rr(e),t,r),e;var u=(o=e.content)===null||o===void 0?void 0:o.receiptMessageDic;u&&Array.isArray(u[this._engine.currentUserId])&&typeof this._watcher.messageReceiptResponse=="function"&&this._watcher.messageReceiptResponse({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.senderUserId,u[this._engine.currentUserId])}else typeof this._watcher.messageReceiptRequest=="function"&&this._watcher.messageReceiptRequest({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.senderUserId);else typeof this._watcher.readReceiptReceived=="function"&&this._watcher.readReceiptReceived({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.content.lastMessageSendTime)}else this._MessageBlockedListener({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId||"",blockType:e.content.interceptType,blockedMessageUId:e.content.msgUId});else{var d=e.content,l=d.startTime,h=d.endTime,a=d.platform,c=d.logId,p=d.uri,f=d.packageName,m={startTime:parseInt(l),endTime:parseInt(h),platform:a,logId:c,uri:p,packageName:f};(s=nr.getInstance())===null||s===void 0||s.reportFullLog(m)}}else if(typeof this._watcher.chatroomState=="function"){var _={};Array.isArray(e.content.userList)&&e.content.userList.forEach(function(v){_[v.userId]=v.status}),this._watcher.chatroomState({userChange:{users:_,chatroomId:e.targetId}})}}else this._watcher.chatroomState({userChange:{users:(i={},i[e.senderUserId]=e.messageType==="RC:ChrmQuitNtf"?Ao.QUIT:Ao.JOIN,i),chatroomId:e.targetId}})},n.prototype._batchMessageReceiver=function(e,t,r){var i=this,s=[];e.forEach(function(o){var u=i._messageReceiver(o,t,r);u&&s.push(u)}),s.length&&this._watcher.batchMessage&&this._watcher.batchMessage(s)},n.prototype._chatroomInfoListener=function(e){this._watcher.chatroomState&&this._watcher.chatroomState(e)},n.prototype._conversationInfoListener=function(e){this._watcher.conversationState&&this._watcher.conversationState(e)},n.prototype._expansionInfoListener=function(e){this._watcher.expansion&&this._watcher.expansion(e)},n.prototype._tagListener=function(){this._watcher.tag&&this._watcher.tag()},n.prototype._conversationTagListener=function(){this._watcher.conversationTagChanged&&this._watcher.conversationTagChanged()},n.prototype._typingStatusListener=function(e){this._watcher.typingState&&this._watcher.typingState(e)},n.prototype._pullFinishedListener=function(){this._watcher.pullFinished&&this._watcher.pullFinished()},n.prototype._MessageBlockedListener=function(e){this._watcher.messageBlocked&&this._watcher.messageBlocked(e)},n.prototype._rtcDataChange=function(e,t){this._pluginContextQueue.forEach(function(r){r.onrtcdatachange&&r.onrtcdatachange(e,t)})},n.prototype.assignWatcher=function(e){var t=this;Object.keys(this._watcher).forEach(function(r){if(Object.prototype.hasOwnProperty.call(e,r)){var i=e[r];t._watcher[r]=Ir(i)||Ve(i)?i:void 0}})},n.prototype.resetWatcher=function(){var e=this;Object.keys(this._watcher).forEach(function(t){e._watcher[t]=void 0})},n.prototype._addTypingInfo=function(e){var t=e.senderUserId,r=e.conversationType,i=e.targetId,s=e.content,o=e.channelId,u=s.typingContentType,d=r+"#"+i+"#"+(o||"");this._typingInfo[d]||(this._typingInfo[d]=[]);var l=this._typingInfo[d].findIndex(function(h){return h.userId===t});l>=0&&this._typingInfo[d][l].messageType===u?this._typingInfo[d][l].timestamp=Date.now():(l>=0&&this._typingInfo[d].splice(l,1),this._typingInfo[d].push({userId:t,messageType:u,timestamp:Date.now()}),this._typingChangedList.includes(d)||this._typingChangedList.push(d),this._startCheckTypingInfo())},n.prototype._startCheckTypingInfo=function(){var e=this;this._typingInternalTimer===-1&&Object.keys(this._typingInfo).length!==0&&(this._typingInternalTimer=setInterval(function(){for(var t in e._typingInfo){var r=e._typingInfo[t].length;e._typingInfo[t]=e._typingInfo[t].filter(function(s){return Date.now()-s.timestamp<e._typingExpireTime}),e._typingInfo[t].length===r||e._typingChangedList.includes(t)||e._typingChangedList.push(t),e._typingInfo[t].length===0&&delete e._typingInfo[t]}if(e._typingChangedList.length>0){var i=e._typingChangedList.map(function(s){return{conversationType:Number(s.split("#")[0]),targetId:s.split("#")[1],channelId:s.split("#")[2],list:e._typingInfo[s]||[]}});e._typingStatusListener(i),e._typingChangedList=[]}Object.keys(e._typingInfo).length===0&&(clearInterval(e._typingInternalTimer),e._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(e,t){return t===void 0&&(t=!1),x(this,void 0,void 0,function(){var r,i,s,o,u,d;return V(this,function(l){switch(l.label){case 0:return this._connectionStatus===te.CONNECTED?[2,{code:S.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===te.CONNECTING?[2,{code:S.BIZ_ERROR_CONNECTING}]:typeof e!="string"||e.length===0?[2,{code:S.RC_CONN_USER_OR_PASSWD_ERROR}]:(this._token=e,r=e.split("@"),i=r[1],s=i?i.split(";").map(function(h){return/^https?:/.test(h)?h:"https://"+h}):[],[4,this._engine.navi.getInfo(this._getTokenWithoutNavi(),s,t,this._options.checkCA)]);case 1:return(o=l.sent())?(o==null?void 0:o.type)===1?[2,{code:S.PACKAGE_ENVIRONMENT_ERROR}]:(u=Dt.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),o)]):[2,{code:S.RC_NAVI_RESOURCE_ERROR}];case 2:return d=l.sent(),j.__insertLogIntoDatabase(),d!==Be.REDIRECT?[3,4]:(this._connectionStatus=te.REDIRECT,[4,this.connect(e,!0)]);case 3:return[2,l.sent()];case 4:return d===S.SUCCESS&&(j.info("connect success, userId: "+this._engine.currentUserId),(o==null?void 0:o.type)!==1&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(u),nr.init({runtime:this._runtime,logSwitch:(o==null?void 0:o.logSwitch)||0,logPolicy:JSON.parse((o==null?void 0:o.logPolicy)||"{}"),appkey:this.appkey,version:this.apiVersion,userId:this._engine.currentUserId}),wt.init(this._engine.currentUserId),this._isInternalConnected=!0),d!==S.SUCCESS||ko()||o.openUS===1&&this._pullUserSettings(),d!==S.SUCCESS&&(this._connectionStatus=te.CONNECTION_CLOSED),[2,{code:d,userId:this._engine.currentUserId}]}})})},n.prototype._pullUserSettings=function(){return x(this,void 0,void 0,function(){return V(this,function(e){return[2]})})},n.prototype.disconnect=function(){var e;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,(e=nr.getInstance())===null||e===void 0||e.distroy(),j.__insertLogIntoDatabase(),wt.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach(function(t){if(t.ondisconnect)try{t.ondisconnect()}catch(r){j.error("plugin error =>",r)}}),Promise.resolve()},n.prototype.reconnect=function(){return this._isInternalConnected?Promise.resolve({code:S.CAN_NOT_RECONNECT}):this.connect(this._getTokenWithoutNavi())},n.prototype._getTokenWithoutNavi=function(){return this._token.replace(/@.+$/,"@")},n.prototype.getInfoFromCache=function(){return this._engine.navi.getInfoFromCache(this._getTokenWithoutNavi())},n.prototype.registerMessageType=function(e,t,r,i){i===void 0&&(i=[]),this._engine.registerMessageType(e,t,r,i)},n.prototype.sendMessage=function(e,t,r,i){var s=this.getInfoFromCache();if(((s==null?void 0:s.grpRRVer)||0)===1&&r.messageType===He.READ_RECEIPT_RESPONSE)return Promise.resolve({code:S.READ_RECEIPT_ERROR});var o=JSON.stringify(r.content);return Ka(o)>131072?Promise.resolve({code:S.RC_MSG_CONTENT_EXCEED_LIMIT}):this._engine.sendMessage(e,t,r,i)},n.prototype.sendExpansionMessage=function(e){return x(this,void 0,void 0,function(){var t,r,i,s,o,u,d,l,h,a,c,p,f,m;return V(this,function(_){switch(_.label){case 0:if(t=e.channelId,r=e.conversationType,i=e.targetId,s=e.messageUId,o=e.keys,u=e.expansion,d=e.removeAll,!e.canIncludeExpansion)return[2,{code:S.MESSAGE_KV_NOT_SUPPORT}];if(l=!1,h=!1,a=!1,Ve(u)){for(p in c=Object.keys(u).length,l=c>20,u)if(f=u[p],h=Qe(p)&&!/^[A-Za-z0-9_=+-]+$/.test(p),(a=p.length>32||f.length>64)||h)break}return l||a?[2,{code:S.EXPANSION_LIMIT_EXCEET}]:h?[2,{code:S.BIZ_ERROR_INVALID_PARAMETER}]:(m={mid:s},u&&(m.put=u),o&&(m.del=o),d&&(m.removeAll=1),[4,this._engine.sendMessage(r,i,{content:m,messageType:He.EXPANSION_NOTIFY,channelId:t})]);case 1:return[2,{code:_.sent().code}]}})})},n.prototype.sendReadReceiptMessage=function(e,t,r){return x(this,void 0,void 0,function(){var i;return V(this,function(s){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:S.READ_RECEIPT_ERROR,data:"The read receipt switch is not on, please call the sendMessage method!"}]:[2,this._engine.sendReadReceiptMessage(e,t,r)]})})},n.prototype.getMessageReader=function(e,t,r){return x(this,void 0,void 0,function(){var i;return V(this,function(s){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:S.READ_RECEIPT_ERROR}]:[2,this._engine.getMessageReader(e,t,r)]})})},n.prototype._destroy=function(){var e;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(t){if(t.ondestroy)try{t.ondestroy()}catch(r){j.error("plugin error =>",r)}}),this._pluginContextQueue.length=0,this._pluginInstanseMap={},(e=nr.getInstance())===null||e===void 0||e.distroy(),wt.reset()},n.prototype.getHistoryMessage=function(e,t,r,i,s,o,u){return r===void 0&&(r=0),i===void 0&&(i=20),s===void 0&&(s=0),o===void 0&&(o=""),u===void 0&&(u=""),this._engine.getHistoryMessage(e,t,r,i,s,o,u||"")},n.prototype.getConversationList=function(e,t,r,i,s){return e===void 0&&(e=300),s===void 0&&(s=""),this._engine.getConversationList(e,t,r,i,s)},n.prototype.getConversation=function(e,t,r){return this._engine.getConversation(e,t,r)},n.prototype.removeConversation=function(e,t,r){return r===void 0&&(r=""),this._engine.removeConversation(e,t,r)},n.prototype.clearUnreadCount=function(e,t,r){return r===void 0&&(r=""),this._engine.clearConversationUnreadCount(e,t,r)},n.prototype.clearAllUnreadCount=function(){return this._engine.clearAllUnreadCount()},n.prototype.getUnreadCount=function(e,t,r){return r===void 0&&(r=""),this._engine.getConversationUnreadCount(e,t,r)},n.prototype.getTotalUnreadCount=function(e,t,r){return this._engine.getAllConversationUnreadCount(e,t&&t.length>0?t:[z.PRIVATE,z.GROUP,z.SYSTEM,z.PUBLIC_SERVICE],!!r)},n.prototype.getFirstUnreadMessage=function(e,t,r){return r===void 0&&(r=""),this._engine.getFirstUnreadMessage(e,t,r)},n.prototype.setConversationStatus=function(e,t,r,i,s){s===void 0&&(s="");var o=[{conversationType:e,targetId:t,isTop:r,notificationStatus:i,channelId:s}];return this._engine.batchSetConversationStatus(o)},n.prototype.saveConversationMessageDraft=function(e,t,r,i){return i===void 0&&(i=""),this._engine.saveConversationMessageDraft(e,t,r,i)},n.prototype.getConversationMessageDraft=function(e,t,r){return r===void 0&&(r=""),this._engine.getConversationMessageDraft(e,t,r)},n.prototype.clearConversationMessageDraft=function(e,t,r){return r===void 0&&(r=""),this._engine.clearConversationMessageDraft(e,t,r)},n.prototype.recallMessage=function(e,t,r,i,s){return this._engine.recallMsg(e,t,r,i,s)},n.prototype.deleteRemoteMessage=function(e,t,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessage(e,t,r,i)},n.prototype.deleteRemoteMessageByTimestamp=function(e,t,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessageByTimestamp(e,t,r,i)},n.prototype.joinChatroom=function(e,t){return t===void 0&&(t=10),this._engine.joinChatroom(e,t)},n.prototype.joinExistChatroom=function(e,t){return t===void 0&&(t=10),this._engine.joinExistChatroom(e,t)},n.prototype.quitChatroom=function(e){return this._engine.quitChatroom(e)},n.prototype.getChatroomInfo=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=0),this._engine.getChatroomInfo(e,t,r)},n.prototype.setChatroomEntry=function(e,t){var r=t.key,i=t.value;return Ht(r)&&fi(i)?this._engine.setChatroomEntry(e,t):Promise.resolve(S.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.setChatroomEntries=function(e,t){for(var r=0;r<t.entries.length;r++){var i=t.entries[r],s=i.key,o=i.value;if(!Ht(s)||!fi(o))return Promise.resolve({code:S.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.setChatroomEntries(e,t)},n.prototype.forceSetChatroomEntry=function(e,t){var r=t.key,i=t.value;return Ht(r)&&fi(i)?this._engine.forceSetChatroomEntry(e,t):Promise.resolve(S.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.removeChatroomEntry=function(e,t){var r=t.key;return Ht(r)?this._engine.removeChatroomEntry(e,t):Promise.resolve(S.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.removeChatroomEntries=function(e,t){for(var r=0;r<t.entries.length;r++){var i=t.entries[r].key;if(!Ht(i))return Promise.resolve({code:S.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.removeChatroomEntries(e,t)},n.prototype.forceRemoveChatroomEntry=function(e,t){var r=t.key;return Ht(r)?this._engine.forceRemoveChatroomEntry(e,t):Promise.resolve(S.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.getChatroomEntry=function(e,t){return this._engine.getChatroomEntry(e,t)},n.prototype.getAllChatroomEntries=function(e){return this._engine.getAllChatroomEntry(e)},n.prototype.getChatroomHistoryMessages=function(e,t,r,i){return t===void 0&&(t=20),r===void 0&&(r=0),i===void 0&&(i=0),this._engine.getChatroomHistoryMessages(e,i,t,r)},n.prototype.getFileToken=function(e,t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return s=this.getInfoFromCache(),o=(s==null?void 0:s.bosAddr)||"",u=(s==null?void 0:s.uploadServer)||"",d=(s==null?void 0:s.ossConfig)||"",[4,this._engine.getFileToken(e,t,r,i)];case 1:return l=c.sent(),h=l.code,a=l.data,h===S.SUCCESS?[2,Promise.resolve(Object.assign(a,{bos:o,qiniu:u,ossConfig:d}))]:[2,Promise.reject(h)]}})})},n.prototype.getFileUrl=function(e,t,r,i,s){return s===void 0&&(s=Ge.QINIU),x(this,void 0,void 0,function(){var o,u,d;return V(this,function(l){switch(l.label){case 0:return(i==null?void 0:i.isBosRes)?[2,Promise.resolve(i)]:[4,this._engine.getFileUrl(e,s,t,r)];case 1:return o=l.sent(),u=o.code,d=o.data,u===S.SUCCESS?[2,Promise.resolve(d)]:[2,Promise.reject(u)]}})})},n.prototype.createTag=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.createTag(e)]})})},n.prototype.removeTag=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.removeTag(e)]})})},n.prototype.updateTag=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.updateTag(e)]})})},n.prototype.getTagList=function(){return x(this,void 0,void 0,function(){return V(this,function(e){return[2,this._engine.getTagList()]})})},n.prototype.addTagForConversations=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return t.length>1e3?[2,Promise.reject(S.CONVER_OUT_LIMIT_ERROR)]:[2,this._engine.addTagForConversations(e,t)]})})},n.prototype.removeTagForConversations=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.removeTagForConversations(e,t)]})})},n.prototype.removeTagsForConversation=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.removeTagsForConversation(e,t)]})})},n.prototype.getConversationListByTag=function(e,t,r,i){return x(this,void 0,void 0,function(){return V(this,function(s){return[2,this._engine.getConversationListByTag(e,t,r,i)]})})},n.prototype.getUnreadCountByTag=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.getUnreadCountByTag(e,t)]})})},n.prototype.setConversationStatusInTag=function(e,t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._engine.setConversationStatusInTag(e,t,r)]})})},n.prototype.getTagsForConversation=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.getTagsForConversation(e)]})})},n.prototype.getBlockConversationList=function(){return this._engine.getBlockConversationList()},n.prototype.getTopConversationList=function(){return this._engine.getTopConversationList()},n.prototype.getUnreadMentionedCount=function(e){return this._engine.getUnreadMentionedCount(e)},n.prototype.getAllUnreadMentionedCount=function(){return this._engine.getAllUnreadMentionedCount()},n.prototype.callExtra=function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(t=this._engine).callExtra.apply(t,Ut([e],r))},n.prototype.clearConversations=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){switch(r.label){case 0:return[4,this._engine.clearConversations(e,t)];case 1:return[2,r.sent()]}})})},n.prototype.setUserStatusListener=function(e,t){return this._engine.setUserStatusListener(e,function(r){try{t(r)}catch(i){j.error(i)}})},n.prototype.addToBlacklist=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.addToBlacklist(e)]})})},n.prototype.removeFromBlacklist=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.removeFromBlacklist(e)]})})},n.prototype.getBlacklist=function(){return x(this,void 0,void 0,function(){return V(this,function(e){return[2,this._engine.getBlacklist()]})})},n.prototype.getBlacklistStatus=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.getBlacklistStatus(e)]})})},n.prototype.insertMessage=function(e,t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._engine.insertMessage(e,t,r)]})})},n.prototype.deleteMessages=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.deleteMessages(e)]})})},n.prototype.deleteMessagesByTimestamp=function(e,t,r,i,s){return s===void 0&&(s=""),x(this,void 0,void 0,function(){return V(this,function(o){return[2,this._engine.deleteMessagesByTimestamp(e,t,r,i,s)]})})},n.prototype.clearMessages=function(e,t,r){return r===void 0&&(r=""),x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._engine.clearMessages(e,t,r)]})})},n.prototype.getMessage=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.getMessage(e)]})})},n.prototype.setMessageContent=function(e,t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._engine.setMessageContent(e,t,r)]})})},n.prototype.setMessageSearchField=function(e,t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._engine.setMessageSearchField(e,t,r)]})})},n.prototype.setMessageSentStatus=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.setMessageSentStatus(e,t)]})})},n.prototype.setMessageReceivedStatus=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.setMessageReceivedStatus(e,t)]})})},n.prototype.setUserStatus=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.setUserStatus(e)]})})},n.prototype.subscribeUserStatus=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.subscribeUserStatus(e)]})})},n.prototype.getUserStatus=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.getUserStatus(e)]})})},n.prototype.searchConversationByContent=function(e,t,r,i){return t===void 0&&(t=[]),r===void 0&&(r=""),x(this,void 0,void 0,function(){return V(this,function(s){return[2,this._engine.searchConversationByContent(e,t,r,i)]})})},n.prototype.searchMessageByContent=function(e,t,r,i,s,o,u){return u===void 0&&(u=""),x(this,void 0,void 0,function(){return V(this,function(d){return[2,this._engine.searchMessageByContent(e,t,r,i,s,o,u)]})})},n.prototype.getUnreadMentionedMessages=function(e,t,r){return r===void 0&&(r=""),this._engine.getUnreadMentionedMessages(e,t,r)},n.prototype.clearUnreadCountByTimestamp=function(e,t,r,i){return i===void 0&&(i=""),this._engine.clearUnreadCountByTimestamp(e,t,r,i)},n.prototype.getConversationNotificationStatus=function(e,t,r){return r===void 0&&(r=""),this._engine.getConversationNotificationStatus(e,t,r)},n.prototype.getRemoteHistoryMessages=function(e,t,r,i,s,o){return this._engine.getRemoteHistoryMessages(e,t,r,i,s,o)},n.prototype.getConversationListWithAllChannel=function(){return this._engine.getConversationListWithAllChannel()},n.prototype.getConversationListWithAllChannelByPage=function(e,t){return this._engine.getConversationListWithAllChannelByPage(e,t)},n.prototype.joinRTCRoom=function(e,t,r,i){return this._engine.joinRTCRoom(e,t,r,i)},n.prototype.quitRTCRoom=function(e){return this._engine.quitRTCRoom(e)},n.prototype.rtcPing=function(e,t,r){return this._engine.rtcPing(e,t,r)},n.prototype.getRTCRoomInfo=function(e){return this._engine.getRTCRoomInfo(e)},n.prototype.getRTCUserInfoList=function(e){return this._engine.getRTCUserInfoList(e)},n.prototype.getRTCUserInfo=function(e){return this._engine.getRTCUserInfo(e)},n.prototype.setRTCUserInfo=function(e,t,r){return this._engine.setRTCUserInfo(e,t,r)},n.prototype.removeRTCUserInfo=function(e,t){return this._engine.removeRTCUserInfo(e,t)},n.prototype.setRTCData=function(e,t,r,i,s,o){return this._engine.setRTCData(e,t,r,i,s,o)},n.prototype.setRTCTotalRes=function(e,t,r,i,s){return s===void 0&&(s=""),this._engine.setRTCTotalRes(e,t,r,i,s)},n.prototype.setRTCCDNUris=function(e,t,r){return this._engine.setRTCCDNUris(e,t,r)},n.prototype.getRTCData=function(e,t,r,i){return this._engine.getRTCData(e,t,r,i)},n.prototype.removeRTCData=function(e,t,r,i,s){return this._engine.removeRTCData(e,t,r,i,s)},n.prototype.setRTCOutData=function(e,t,r,i){return this._engine.setRTCOutData(e,t,r,i)},n.prototype.getRTCOutData=function(e,t){return this._engine.getRTCOutData(e,t)},n.prototype.getRTCToken=function(e,t,r){return this._engine.getRTCToken(e,t,r)},n.prototype.setRTCState=function(e,t){return this._engine.setRTCState(e,t)},n.prototype.getRTCUserList=function(e){return this._engine.getRTCUserList(e)},n.prototype.joinLivingRoomAsAudience=function(e,t,r){return this._engine.joinLivingRoomAsAudience(e,t,r)},n.prototype.quitLivingRoomAsAudience=function(e){return this._engine.quitLivingRoomAsAudience(e)},n.prototype.rtcIdentityChange=function(e,t,r){return this._engine.rtcIdentityChange(e,t,r)},n.prototype.getRTCJoinedUserInfo=function(e){return this._engine.getRTCJoinedUserInfo(e)},n.prototype.requestRoomPK=function(e){return this._engine.requestRoomPK(e)},n.prototype.cancelRoomPK=function(e){return this._engine.cancelRoomPK(e)},n.prototype.responseRoomPK=function(e){return this._engine.responseRoomPK(e)},n.prototype.endRoomPK=function(e){return this._engine.endRoomPK(e)},n}();(function(n){n[n.add=1]="add",n[n.update=2]="update",n[n.delete=3]="delete"})(Wo||(Wo={}));/*! *****************************************************************************
- 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.
- ***************************************************************************** */var Ji=function(n,e){return Ji=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},Ji(n,e)},Wi=function(){return Wi=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},Wi.apply(this,arguments)};function Bn(n,e,t,r){return new(t||(t=Promise))(function(i,s){function o(l){try{d(r.next(l))}catch(h){s(h)}}function u(l){try{d(r.throw(l))}catch(h){s(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof t?h:new t(function(a){a(h)})).then(o,u)}d((r=r.apply(n,e||[])).next())})}function Fn(n,e){var t,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(d){return function(l){return function(h){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,r&&(i=2&h[0]?r.return:h[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,h[1])).done)return i;switch(r=0,i&&(h=[2&h[0],i.value]),h[0]){case 0:case 1:i=h;break;case 4:return o.label++,{value:h[1],done:!1};case 5:o.label++,r=h[1],h=[0];continue;case 7:h=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){o=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){o.label=h[1];break}if(h[0]===6&&o.label<i[1]){o.label=i[1],i=h;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(h);break}i[2]&&o.ops.pop(),o.trys.pop();continue}h=e.call(n,o)}catch(a){h=[6,a],r=0}finally{t=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}var Ke=new wt("RCIM"),Gn=function(){return!(typeof uni=="undefined"||!function(n){for(var e=["canIUse","getSystemInfo"],t=0,r=e.length;t<r;t++)if(!n[e[t]])return!1;return!0}(uni))},Zd=Gn(),be,zo={tag:"browser",httpReq:function(n){var e=n.method||ut.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=Yr(n.url,i);return new Promise(function(u){var d,l=(d=typeof XMLHttpRequest!="undefined"&&"withCredentials"in new XMLHttpRequest,typeof XMLHttpRequest!="undefined"&&d?new XMLHttpRequest:typeof XDomainRequest!="undefined"?new XDomainRequest:new ActiveXObject("Microsoft.XMLHTTP")),h=Object.prototype.toString.call(l)==="[object XDomainRequest]";if(l.open(e,o),r&&l.setRequestHeader)for(var a in r)l.setRequestHeader(a,r[a]);if(h){l.timeout=t,l.onload=function(){u({data:l.responseText,status:l.status||200})},l.onerror=function(){u({status:l.status||0})},l.ontimeout=function(){u({status:l.status||0})};var c=typeof s=="object"?JSON.stringify(s):s;l.send(c)}else l.onreadystatechange=function(){l.readyState===4&&u({data:l.responseText,status:l.status})},l.onerror=function(){u({status:l.status||0})},setTimeout(function(){return u({status:l.status||0})},t),l.send(s)})},localStorage:window==null?void 0:window.localStorage,sessionStorage:window==null?void 0:window.sessionStorage,isSupportSocket:function(){var n=typeof WebSocket!="undefined";return n||Ke.warn("websocket not support"),n},useNavi:!0,connectPlatform:"",isFromUniapp:Zd,createWebSocket:function(n,e){var t=new WebSocket(n,e);return t.binaryType="arraybuffer",{onClose:function(r){t.onclose=function(i){var s=i.code,o=i.reason;r(s,o)}},onError:function(r){t.onerror=r},onMessage:function(r){t.onmessage=function(i){r(i.data)}},onOpen:function(r){t.onopen=r},send:function(r){t.send(r)},close:function(r,i){t.close(r,i)}}},createDataChannel:function(n,e){return this.isSupportSocket()&&e==="websocket"?new on(this,n):new an(this,n)}},el=Gn(),ir=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return wx[n].apply(wx,e)}catch(r){Ke.error(r)}}},Qo={setItem:ir("setStorageSync"),getItem:ir("getStorageSync"),removeItem:ir("removeStorageSync"),clear:ir("clearStorageSync")},Xo={tag:"wechat",httpReq:function(n){var e=n.method||ut.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=Yr(n.url,i);return new Promise(function(u){wx.request({url:o,method:e,headers:r,timeout:t,data:s,success:function(d){u({data:d.data,status:d.statusCode})},fail:function(){u({status:S.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:Qo,sessionStorage:Qo,isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:el,createWebSocket:function(n,e){var t=wx.connectSocket({url:n,protocols:e});return{onClose:function(r){t.onClose(function(i){r(i.code,i.reason)})},onError:function(r){t.onError(function(i){r(i.errMsg)})},onMessage:function(r){t.onMessage(function(i){r(i.data)})},onOpen:function(r){t.onOpen(r)},send:function(r){t.send({data:r})},close:function(r,i){t.close({code:r,reason:i})}}},createDataChannel:function(n,e){return e==="websocket"?new on(this,n):new an(this,n)}},tl=Gn(),sr=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return my[n].apply(my,e)}catch(r){Ke.error(r)}}},Zo={setItem:sr("setStorageSync"),getItem:sr("getStorageSync"),removeItem:sr("removeStorageSync"),clear:sr("clearStorageSync")},ea={tag:"alipay",httpReq:function(n){var e=n.method||ut.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=Yr(n.url,i),u=n.dataType||"json";return new Promise(function(d){my.request({url:o,method:e,headers:r,timeout:t,data:s,dataType:u,success:function(l){d({data:l.data,status:l.status})},fail:function(){d({status:S.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:Zo,sessionStorage:Zo,isSupportSocket:function(){return!1},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:tl,createDataChannel:function(n,e){return e==="websocket"?new on(this,n):new an(this,n)}},nl=Gn(),or=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return console.log("tt",tt),tt[n].apply(tt,e)}catch(r){Ke.error(r)}}},ta={setItem:or("setStorageSync"),getItem:or("getStorageSync"),removeItem:or("removeStorageSync"),clear:or("clearStorageSync")},na={tag:"toutiao",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:nl,localStorage:ta,sessionStorage:ta,httpReq:function(n){return new Promise(function(e,t){tt.request({url:n.url,data:n.body,header:n.headers,method:n.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},s={data:JSON.stringify(i),status:r.statusCode};e(s)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errMsg),t({data:r.errMsg})}})})},createWebSocket:function(n,e){var t=tt.connectSocket({url:n,protocols:e});return{onOpen:function(r){t.onOpen(r)},onClose:function(r){t.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){t.onError(function(i){return r(i.errMsg)})},onMessage:function(r){t.onMessage(function(i){return r(i.data)})},send:function(r){t.send({data:r})},close:function(r,i){t.close({code:r,reason:i})}}},createDataChannel:function(n,e){return e==="websocket"?new on(this,n):new an(this,n)}},rl=Gn(),ar=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return console.log("swan",swan),swan[n].apply(swan,e)}catch(r){Ke.error(r)}}},ra={setItem:ar("setStorageSync"),getItem:ar("getStorageSync"),removeItem:ar("removeStorageSync"),clear:ar("clearStorageSync")},ia={tag:"baidu",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:rl,localStorage:ra,sessionStorage:ra,httpReq:function(n){return new Promise(function(e,t){swan.request({url:n.url,data:n.body,header:n.headers,method:n.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},s={data:JSON.stringify(i),status:r.statusCode};e(s)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errorCode),t({data:r.errorCode})}})})},createWebSocket:function(n,e){var t=swan.connectSocket({url:n,protocols:e});return{onOpen:function(r){t.onOpen(r)},onClose:function(r){t.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){t.onError(function(i){return r(i.errMsg)})},onMessage:function(r){t.onMessage(function(i){return r(i.data)})},send:function(r){t.send({data:r})},close:function(r,i){t.close({code:r,reason:i})}}},createDataChannel:function(n,e){return e==="websocket"?new on(this,n):new an(this,n)}},cr=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return uni[n].apply(uni,e)}catch(r){Ke.error(r)}}},sa={setItem:cr("setStorageSync"),getItem:cr("getStorageSync"),removeItem:cr("removeStorageSync"),clear:cr("clearStorageSync")},il={tag:"uniapp",httpReq:function(n){var e=n.method||ut.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=Yr(n.url,i);return new Promise(function(u){uni.request({url:o,method:e,headers:r,timeout:t,data:s,success:function(d){u({data:d.data,status:d.statusCode})},fail:function(){u({status:S.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:sa,sessionStorage:sa,isSupportSocket:function(){return!0},useNavi:!0,connectPlatform:"",isFromUniapp:!0,createWebSocket:function(n,e){var t={complete:function(){},url:n,protocols:e},r=uni.connectSocket(t);return{onClose:function(i){r.onClose(function(s){i(s.code,s.reason)})},onError:function(i){r.onError(function(s){i(s.errMsg)})},onMessage:function(i){r.onMessage(function(s){i(s.data)})},onOpen:function(i){r.onOpen(i)},send:function(i){r.send({data:i})},close:function(i,s){r.close({code:i,reason:s})}}},createDataChannel:function(n,e){return e==="websocket"?new on(this,n):new an(this,n)}},vn=function(n){return n&&n.canIUse&&n.getSystemInfo},sl=typeof uni!="undefined"&&vn(uni)?function(){switch({}.VUE_APP_PLATFORM){case"app-plus":return il;case"mp-baidu":return ia;case"mp-toutiao":return na;case"mp-alipay":return ea;case"mp-weixin":return Xo;default:return zo}}():typeof wx!="undefined"&&vn(wx)?Xo:typeof my!="undefined"&&vn(my)?ea:typeof tt!="undefined"&&vn(tt)?na:typeof swan!="undefined"&&vn(swan)?ia:zo;function Dr(n){var e=n.conversationType,t=n.channelId,r=n.messageType,i=n.content,s=n.senderUserId,o=n.targetId,u=n.sentTime,d=n.receivedTime,l=n.messageUId,h=n.messageDirection,a=n.isPersited,c=n.isCounted,p=n.isOffLineMessage,f=n.canIncludeExpansion,m=n.expansion,_=n.receivedStatus,v=n.disableNotification,R=n.isMentioned,C=n.isStatusMessage,A=n.readReceiptInfo,M=n.pushConfig,O=n.messageId;return _||(_=Mn.UNREAD),{messageType:r,channelId:t||"",content:i,senderUserId:s,targetId:o,conversationType:e,sentTime:u,receivedTime:d,messageUId:l,messageDirection:h,isPersited:a,isCounted:c,isOffLineMessage:p,isMentioned:R,disableNotification:v,isStatusMessage:C,canIncludeExpansion:f,expansion:m,receivedStatus:_,readReceiptInfo:A,pushConfig:M,messageId:O}}(function(n){n.CONNECTING="CONNECTING",n.CONNECTED="CONNECTED",n.DISCONNECT="DISCONNECT",n.SUSPEND="SUSPEND",n.MESSAGES="MESSAGES",n.READ_RECEIPT_RECEIVED="READ_RECEIPT_RECEIVED",n.MESSAGE_RECEIPT_REQUEST="MESSAGE_RECEIPT_REQUEST",n.MESSAGE_RECEIPT_RESPONSE="MESSAGE_RECEIPT_RESPONSE",n.CONVERSATION="CONVERSATION",n.CHATROOM="CHATROOM",n.EXPANSION="EXPANSION",n.PULL_OFFLINE_MESSAGE_FINISHED="PULL_OFFLINE_MESSAGE_FINISHED",n.TAG="TAG",n.CONVERSATION_TAG="CONVERSATION_TAG",n.TYPING_STATUS="TYPING_STATUS",n.MESSAGE_BLOCKED="MESSAGE_BLOCKED"})(be||(be={}));var Zt,ot=function(n){function e(t){var r=n.call(this)||this;if(e.imClient)return Ke.error("Please do not repeatedly perform the init method"),e.imClient;Ue("options.navigators",t.navigators,function(s){return Ye(s)&&(s.length===0||s.every(Pn))});var i=t==null?void 0:t.connectType;return i?yt.WEBSOCKET!==i&&yt.COMET!==i&&(Ke.warn("RongIMLib connectionType must be "+yt.WEBSOCKET+" or "+yt.COMET),i=yt.WEBSOCKET):i=yt.WEBSOCKET,r._context=Xd.init(sl,{appkey:t.appkey,apiVersion:"5.1.1",navigators:t.navigators||[],miniCMPProxy:t.customCMP||[],connectionType:i,logLevel:t.logLevel,logStdout:t.logStdout,indexDBSwitch:t.indexDBSwitch,checkCA:t.checkCA}),r.watch(),e.imClient=r,r}return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}Ji(t,r),t.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}(e,n),Object.defineProperty(e.prototype,"context",{get:function(){if(!this._context)throw new Error("Please perform the init method!");return this._context},enumerable:!1,configurable:!0}),e.prototype.watch=function(){var t=this,r={onConnecting:function(){t.emit(be.CONNECTING)},onConnected:function(){t.emit(be.CONNECTED)},onDisconnect:function(){t.emit(be.DISCONNECT)},onSuspend:function(){t.emit(be.SUSPEND)},batchMessage:function(i){t.emit(be.MESSAGES,{messages:i.map(function(s){return Dr(s)})})},typingState:function(i){t.emit(be.TYPING_STATUS,{status:i})},readReceiptReceived:function(i,s,o){t.emit(be.READ_RECEIPT_RECEIVED,{conversation:i,messageUId:s,sentTime:o})},messageReceiptRequest:function(i,s,o){t.emit(be.MESSAGE_RECEIPT_REQUEST,{conversation:i,messageUId:s,senderUserId:o})},messageReceiptResponse:function(i,s,o){t.emit(be.MESSAGE_RECEIPT_RESPONSE,{conversation:i,receivedUserId:s,messageUIdList:o})},conversationState:function(i){var s=i.map(function(o){return{conversation:{conversationType:o.conversationType,latestMessage:o.latestMessage?Dr(o.latestMessage):null,targetId:o.targetId,unreadMessageCount:o.unreadMessageCount,hasMentioned:o.hasMentioned,mentionedInfo:o.mentionedInfo,lastUnreadTime:o.lastUnreadTime,notificationStatus:o.notificationStatus,isTop:o.isTop,channelId:o.channelId,unreadMentionedCount:o.unreadMentionedCount},updatedItems:o.updatedItems}});t.emit(be.CONVERSATION,{conversationList:s})},chatroomState:function(i){t.emit(be.CHATROOM,i)},expansion:function(i){t.emit(be.EXPANSION,i)},pullFinished:function(){t.emit(be.PULL_OFFLINE_MESSAGE_FINISHED)},tag:function(){t.emit(be.TAG)},conversationTagChanged:function(){t.emit(be.CONVERSATION_TAG)},messageBlocked:function(i){t.emit(be.MESSAGE_BLOCKED,i)}};this.context.assignWatcher(r)},e}(jn),xr={TIMEOUT:{code:-1,msg:"Network timeout"},SDK_INTERNAL_ERROR:{code:-2,msg:"SDK internal error"},PARAMETER_ERROR:{code:-3,msg:"Please check the parameters, the {param} expected a value of {expect} but received {current}"},REJECTED_BY_BLACKLIST:{code:405,msg:"Blacklisted by the other party"},SEND_TOO_FAST:{code:20604,msg:"Sending messages too quickly"},NOT_IN_GROUP:{code:22406,msg:"Not in group"},FORBIDDEN_IN_GROUP:{code:22408,msg:"Forbbiden from speaking in the group"},NOT_IN_CHATROOM:{code:23406,msg:"Not in chatRoom"},FORBIDDEN_IN_CHATROOM:{code:23408,msg:"Forbbiden from speaking in the chatRoom"},KICKED_FROM_CHATROOM:{code:23409,msg:"Kicked out and forbbiden from joining the chatRoom"},CHATROOM_NOT_EXIST:{code:23410,msg:"ChatRoom does not exist"},CHATROOM_IS_FULL:{code:23411,msg:"ChatRoom members exceeded"},PARAMETER_INVALID_CHATROOM:{code:23412,msg:"Invalid chatRoom parameters"},ROAMING_SERVICE_UNAVAILABLE_CHATROOM:{code:23414,msg:"ChatRoom message roaming service is not open, Please go to the developer to open this service"},RECALLMESSAGE_PARAMETER_INVALID:{code:25101,msg:"Invalid recall message parameter"},ROAMING_SERVICE_UNAVAILABLE_MESSAGE:{code:25102,msg:"Single group chat roaming service is not open, Please go to the developer to open this service"},PUSHSETTING_PARAMETER_INVALID:{code:26001,msg:"Invalid push parameter"},OPERATION_BLOCKED:{code:20605,msg:"Operation is blocked"},OPERATION_NOT_SUPPORT:{code:20606,msg:"Operation is not supported"},MSG_BLOCKED_SENSITIVE_WORD:{code:21501,msg:"The sent message contains sensitive words"},REPLACED_SENSITIVE_WORD:{code:21502,msg:"Sensitive words in the message have been replaced"},NOT_CONNECTED:{code:30001,msg:"Please connect successfully first"},NAVI_REQUEST_ERROR:{code:30007,msg:"Navigation http request failed"},CMP_REQUEST_ERROR:{code:30010,msg:"CMP sniff http request failed"},CONN_APPKEY_FAKE:{code:31002,msg:"Your appkey is fake"},CONN_MINI_SERVICE_NOT_OPEN:{code:31003,msg:"Mini program service is not open, Please go to the developer to open this service"},CONN_ACK_TIMEOUT:{code:31e3,msg:"Connection ACK timeout"},CONN_TOKEN_INCORRECT:{code:31004,msg:"Your token is not valid or expired"},CONN_NOT_AUTHRORIZED:{code:31005,msg:"AppKey and Token do not match"},CONN_REDIRECTED:{code:31006,msg:"Connection redirection"},CONN_APP_BLOCKED_OR_DELETED:{code:31008,msg:"AppKey is banned or deleted"},CONN_USER_BLOCKED:{code:31009,msg:"User blocked"},CONN_DOMAIN_INCORRECT:{code:31012,msg:"Connect domain error, Please check the set security domain"},ROAMING_SERVICE_UNAVAILABLE:{code:33007,msg:"Roaming service cloud is not open, Please go to the developer to open this service"},RC_CONNECTION_EXIST:{code:34001,msg:"Connection already exists"},CHATROOM_KV_EXCEED:{code:23423,msg:"ChatRoom KV setting exceeds maximum"},CHATROOM_KV_OVERWRITE_INVALID:{code:23424,msg:"ChatRoom KV already exists"},CHATROOM_KV_STORE_NOT_OPEN:{code:23426,msg:"ChatRoom KV storage service is not open, Please go to the developer to open this service"},CHATROOM_KEY_NOT_EXIST:{code:23427,msg:"ChatRoom key does not exist"},MSG_KV_NOT_SUPPORT:{code:34008,msg:"The message cannot be extended"},SEND_MESSAGE_KV_FAIL:{code:34009,msg:"Sending RC expansion message fail"},EXPANSION_LIMIT_EXCEET:{code:34010,msg:"The message expansion size is beyond the limit"},ILLGAL_PARAMS:{code:33003,msg:"Incorrect parameters passed in while calling the interface"},UPLOAD_FILE_FAILED:{code:35020,msg:"File upload failed"},CHATROOM_KV_STORE_NOT_ALL_SUCCESS:{code:23428,msg:"Chatroom kv store not all success"},CHATROOM_KV_STORE_OUT_LIMIT:{code:23429,msg:"Chatroom kv's length is out of limit"},TAG_EXISTS:{code:33101,msg:"The tag already exists"},TAG_NOT_EXIST:{code:33100,msg:"The tag does not exist"},NOT_SUPPORT:{code:S.NOT_SUPPORT,msg:"The method is not supported in a browser!"}},en={},ol={};for(var oa in xr){var aa=xr[oa],ca=aa.code;en[ca]=oa,ol[ca]=aa}xr.ROAMING_SERVICE_UNAVAILABLE.code;var al=function(n){Zt=Zt||new ot(n)};function cl(n,e){return Zt==null?void 0:Zt.context.install(n,e)}function ul(n){return Bn(this,void 0,void 0,function(){var e;return Fn(this,function(t){switch(t.label){case 0:return Ue("token",n,we.STRING,!0),Ke.warn("RongIMLib Version: 5.1.1, Commit: 756868a83166be55e30e49e5685b1644456ea30f"),[4,Zt.context.connect(n,!0)];case 1:return(e=t.sent()).code===S.SUCCESS?[2,{code:e.code,data:{userId:e.userId}}]:[2,{code:e.code,msg:en[e.code]}]}})})}function Yn(n,e,t){Zt.on(n,e,t)}function dl(n,e){return Bn(this,void 0,void 0,function(){var t,r;return Fn(this,function(i){switch(i.label){case 0:return Ue("options.count",e.count,we.NUMBER,!0),t="id:"+n,Ke.debug("join chatroom ->"+t),[4,ot.imClient.context.joinChatroom(n,e.count)];case 1:return(r=i.sent())!==S.SUCCESS?(Ke.warn("join chatroom fail ->code+:"+en[r]+","+t),[2,{code:r,msg:en[r]}]):[2,{code:r}]}})})}var yc=function(n,e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!0),this.messageType=n,this.content=e,this.isPersited=t,this.isCounted=r};function it(n,e,t){return e===void 0&&(e=!0),t===void 0&&(t=!0),function(r){return new yc(n,r,e,t)}}var Tc,zi,ll=it("RC:ImgMsg"),hl=it("RC:HQVCMsg"),pl=it("RC:SightMsg"),fl=it("RC:TxtMsg"),gl=it("RC:CombineMsg"),ml=it("RC:FileMsg");it("RC:GIFMsg");it("RC:VcMsg");it("RC:LBSMsg");it("RC:ReferenceMsg");it("RC:ImgTextMsg");var jt={qiniu:function(n,e,t,r){var i,s="https://"+e.uploadHost.qiniu;i=Rn()+_e[0][1]||s,_e.shift();var o=new XMLHttpRequest;o.upload&&e.support_options&&(o.upload.onprogress=function(u){t.onProgress(u.loaded,u.total)}),o.onreadystatechange=function(){if(o.readyState===4){var u=o.responseText||"{}";(u=JSON.parse(u)).filename=e.uniqueValue,u.uploadMethod=Ge?Ge.QINIU:"",o.status===200?t.onCompleted(u):_e.length?jt[_e[0][0]](n,e,t,r):t.onError("upload fail")}},e.isChunk&&(i=function(u,d){var l="";return da(d,function(h,a){h!=="token"&&(l+=(l?"&":"")+encodeURIComponent(h)+"="+encodeURIComponent(a))}),l&&(u+=(u.indexOf("?")>0?"&":"?")+l),u}(i+="/mkblk/"+n.size,e.multi_parmas)),o.open(e.method,i,!0),t.onOpen(o),e.stream&&o.setRequestHeader("authorization","UpToken "+e.multi_parmas.token),da(e.headers,function(u,d){o.setRequestHeader(u,d)}),o.send(n)},baidu:function(n,e,t,r){if(console.log(r,e),r.size>ua)throw new Error("the file size is over 5GB!");var i=e||{};e=e||zi;var s=new XMLHttpRequest,o=Rn();if(!(!i.uploadHost.bos&&!i.bosUploadPath)){var u=o+_e[0][1]+i.bosUploadPath;_e.shift();var d=i.bosHeader||{},l={filename:e.uniqueValue||r.uniqueName,name:r.name,downloadUrl:u,isBosRes:!0};s.upload&&e.support_options&&(s.upload.onprogress=function(h){t.onProgress(h.loaded,h.total,!0)}),s.onreadystatechange=function(){if(s.readyState===4){var h=s.responseText||"{}";(h=JSON.parse(h)).filename=e.uniqueValue,s.status===200?t.onCompleted(l,!0):_e.length?jt[_e[0][0]](n,e,t,r):t.onError("upload fail")}},s.open(e.method,u,!0),s.setRequestHeader("authorization",d.bosToken),s.setRequestHeader("x-bce-date",d.bosDate),s.send(r)}},aliyun:function(n,e,t,r){if(r.size>ua)throw new Error("the file size is over 5GB!");const i=new FormData;i.set("file",n.get("file")),i.set("key",n.get("key")),i.set("token",n.get("token"));const s=_e[0][1];_e.shift(),n=n||Tc,e=(e=e||{})||zi;var o=new XMLHttpRequest,u=Rn()+e.ossBucketName+"."+s;o.upload&&e.support_options&&(o.upload.onprogress=function(l){t.onProgress(l.loaded,l.total)}),o.onreadystatechange=function(){if(o.readyState===4){var l=o.responseText||"{}";(l=JSON.parse(l)).name=e.uniqueValue,l.filename=e.uploadFileName,l.uploadMethod=Ge?Ge.ALI:"",o.status===200?t.onCompleted(l):_e.length?jt[_e[0][0]](i,e,t,r):t.onError("upload fail")}},o.open(e.method,u,!0),console.log("ali:url",u);var d=e.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",e.uploadFileName),n.delete("file"),n.append("file",r),o.send(n)},s3:function(n,e,t,r){var i=new FormData,s=new XMLHttpRequest,o=Rn();const u=_e[0][1];var d=o+e.s3BucketName+"."+u;console.log("uploadS3:url",d),_e.shift(),s.upload&&e.support_options&&(s.upload.onprogress=function(a){t.onProgress(a.loaded,a.total)}),s.onreadystatechange=function(){if(s.readyState===4){var a=s.responseText||"{}";if((a=JSON.parse(a)).name=e.uniqueValue,a.filename=e.uploadFileName,a.uploadMethod=Ge.AWS,console.log("UploadMethod:",Ge),s.status===200||s.status===204)t.onCompleted(a);else if(_e.length){const c=new FormData;c.set("file",n.get("file")),c.set("key",n.get("key")),c.set("token",n.get("token")),jt[_e[0][0]](c,e,t,r)}else t.onError("upload fail")}},s.open(e.method,d,!0);var l=e?e.s3Header:{},h=r&&r.type;h==="text/html"?i.set("Content-Disposition","inline;"):i.set("Content-Disposition","attachment;"),i.set("Content-Type",h),i.set("x-amz-credential",l.s3Credential),i.set("x-amz-algorithm",l.s3Algorithm),i.set("x-amz-date",l.s3Date),i.set("policy",l.s3Policy),i.set("x-amz-signature",l.s3Signature),i.set("key",e.uploadFileName),i.set("file",r),s.send(i)},stc:function(n,e,t,r){new FormData;var i=new XMLHttpRequest;Rn();var s="https://"+_e[0][1]+"/"+e.stcBucketName+"/"+e.uploadFileName;_e.shift(),i.upload&&e.support_options&&(i.upload.onprogress=function(u){t.onProgress(u.loaded,u.total)}),i.onreadystatechange=function(){if(i.readyState===4){var u=i.responseText||"{}";if((u=JSON.parse(u)).name=e.uniqueValue,u.filename=e.uploadFileName,u.uploadMethod=Ge?Ge.STC:"",i.status===200||i.status===204)t.onCompleted(u);else if(_e.length){const d=new FormData;d.set("file",n.get("file")),d.set("key",n.get("key")),d.set("token",n.get("token")),jt[_e[0][0]](d,e,t,r)}else t.onError("upload fail")}},i.open("PUT",s,!0);var o=e?e.stcHeader:{};i.setRequestHeader("Content-Type",r.type),r.type==="text/html"?i.setRequestHeader("Content-Disposition","inline;"):i.setRequestHeader("Content-Disposition","attachment;"),i.setRequestHeader("Authorization",o.stcAuthorization),i.setRequestHeader("x-amz-content-sha256",o.stcContentSha256),i.setRequestHeader("x-amz-date",o.stcDate),i.send(r)}},_e=[],ua=5368709120;function da(n,e){for(var t in n)e(t,n[t])}function Rn(){var n="https://";return location.protocol!=="http:"&&location.protocol!=="file:"||(n="http://"),n}function _l(n,e,t){var r,i,s=n&&n.type||"text/plain",o=s.indexOf("image")>-1?1:4,u=Math.ceil(n.size/e.stc_chunk_size),d=e&&JSON.parse(e.ossConfig?e.ossConfig:"");Array.isArray(d)||(d=[]);var l=d.find(m=>Object.keys(m).includes("stc")),h="uploads";ot.imClient.getFileToken(o,r,"POST",h).then(function(m){r=m.fileName,i="https://"+l.stc+"/"+e.stcBucketName+"/"+r,console.log("uploadStcMultipart:url",i);var _=new XMLHttpRequest;_.open("POST",i+"?"+h,!0),s==="text/html"?_.setRequestHeader("Content-Disposition","inline;"):_.setRequestHeader("Content-Disposition","attacshment;"),_.setRequestHeader("Authorization",m&&m.stcAuthorization),_.setRequestHeader("x-amz-content-sha256",m&&m.stcContentSha256),_.setRequestHeader("x-amz-date",m&&m.stcDate),_.setRequestHeader("Content-Type",s),_.send(),_.onreadystatechange=function(v){if(_.readyState===4){var R=_.response.match(/(?:<UploadId>)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",R),_.status===200||_.status===204?function(C){for(var A=[],M=1;M<=u;M++)A.push(f(C,M));p(C,A)}(Array.isArray(R)&&R[1]):t.onError("uploadStcMultipart:did not get uploadId")}}},function(m){t.onError("uploadStcMultipart:"+m)});var a=[],c=new Map;function p(m,_){_&&Array.isArray(_)&&_.length!==0&&Promise.all(_).then(()=>{var v="uploadId="+m;if(c.size===u)ot.imClient.context.getFileToken(o,r,"POST",v).then(function(A){console.log("onSuccess",A),console.log("onSuccess:uploadId",m);var M=new XMLHttpRequest;M.open("POST",i+"?"+v,!0),M.setRequestHeader("Authorization",A&&A.stcAuthorization),M.setRequestHeader("x-amz-content-sha256",A&&A.stcContentSha256),M.setRequestHeader("x-amz-date",A&&A.stcDate),M.setRequestHeader("Content-Type",s);var O="<CompleteMultipartUpload xmlns='http://s3.amazonaws.com/doc/2006-03-01/'>",y=Array.from(c.keys()||[]).sort((w,$)=>w-$);console.log("keys",y),y.map(w=>{O+=`<Part><ETag>${c.get(w)}</ETag><PartNumber>${w}</PartNumber></Part>`}),O+="</CompleteMultipartUpload>",M.send(O),console.log("xml",O),M.onreadystatechange=function(){if(M.readyState===4)if(M.status===200||M.status===204){var w={};w.name=n.name,w.filename=e.uploadFileName,w.uploadMethod=Ge.STC,t.onCompleted(w)}else t.onError("uploadStcMultipart:upload does not end")}},function(A){t.onError("uploadStcMultipart:"+A)});else{var R=[];for(var C of a)R.push(f(m,C));p(m,R)}},v=>{console.error(v),t.onError("uploadStcMultipart: chunkFiles upload failed and those will reupload");var R=[];for(var C of a)R.push(f(m,C));p(m,R)})}function f(m,_){return new Promise((v,R)=>{var C="partNumber="+_+"&uploadId="+m;ot.imClient.context.getFileToken(o,r,"PUT",C).then(function(A){console.log("signature "+_+" onSuccess",A);var M=n&&n.slice((_-1)*e.stc_chunk_size,_*e.stc_chunk_size);console.log("fileChunk:size",M.size);var O=new XMLHttpRequest;O.open("PUT",i+"?"+C,!0),O.setRequestHeader("Authorization",A&&A.stcAuthorization),O.setRequestHeader("x-amz-content-sha256",A&&A.stcContentSha256),O.setRequestHeader("x-amz-date",A&&A.stcDate),O.setRequestHeader("Content-Type",s),O.send(M),O.onreadystatechange=function(){if(O.readyState===4)if(O.status===200||O.status===204){var y=O.getResponseHeader("etag");console.log("etag:"+_,y),c.set(_,y),v(y)}else a.includes(_)||a.push(_),R(_)}},function(A){console.log("getETags:\u7B7E\u540D\u9A8C\u8BC1\u5931\u8D25"),a.includes(_)||a.push(_),R(_)})})}}var Sc={form:function(n,e){var t=new FormData;if(e.unique_key){var r=n.name.substr(n.name.lastIndexOf(".")),i=Qi()+r;t.append(e.unique_key,i),e.uniqueValue=i}return t.append(e.file_data_name,n),Xi(e.multi_parmas,function(s,o){t.append(s,o)}),t},json:function(n,e){var t={};if(e.unique_key){var r=n.name.substr(n.name.lastIndexOf(".")),i=Qi()+r;t[e.unique_key]=i,e.uniqueValue=i}return t[e.file_data_name]=n,Xi(e.multi_parmas,function(s,o){t[s]=o}),JSON.stringify(t)},data:function(n,e){return n}};function Qi(){var n=new Date().getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),(e==="x"?t:3&t|8).toString(16)})}function Xi(n,e){for(var t in n)e(t,n[t])}var ur,Ci=0;function vl(n){this.options=function(e){var t={domain:"",method:"POST",file_data_name:"file",unique_key:"key",base64_size:4194304,chunk_size:4194304,bos_chunk_size:4294967296,stc_chunk_size:10485760,headers:{},multi_parmas:{},query:{},support_options:!0,data:Sc.form,genUId:Qi};if(!e||!e.domain)throw new Error("domain is null");for(var r in e)t[r]=e[r];return t}(n),this.setOptions=function(e){var t=this;Xi(e,function(r,i){t.options[r]=i})},console.log("options",n),this.upload=function(e,t){if(e){var r=this;(function(i,s,o){if(Tc=i,zi=s,_e=[],s.ossConfig){const h=JSON.parse(s.ossConfig);let a,c,p="";const f=[];h.forEach(m=>{const _=Number(m.p)-1;for(const v in m)v==="aliyun"&&(p=m[v]),v==="s3"&&(a=m[v]),v==="stc"&&(c=m[v]),v!=="p"&&(f[_]=[v,m[v]])}),f.forEach(function(m){m&&_e.push(m)}),h.length!==_e.length&&(_e=[["qiniu",s.domain],["baidu",s.uploadHost.bos],["aliyun",p],["s3",a],["stc",c]])}else _e=[["qiniu",s.domain],["baidu",s.uploadHost.bos]];var u;if(s.ossConfig){var d=s&&JSON.parse(s.ossConfig);Array.isArray(d)||(d=[]),u=d.find(h=>Object.keys(h).includes("stc"))}if(u&&parseInt(u.p)===1&&i.size>=4194304)_l(i,s,o);else{var l=s.data(i,s);jt[_e[0][0]](l,s,o,i)}})(e,this.options,{onProgress:function(i,s,o){ur=i,o?ur=Ci+i/s*(s-Ci):Ci=ur,t.onProgress(ur,s)},onCompleted:function(i){t.onCompleted(i)},onError:function(i){t.onError(i)},onOpen:function(i){r.xhr=i}})}else t.onError("upload file is null.")},this.cancel=function(){this.xhr&&this.xhr.abort()}}var la={init:function(n){return new vl(n)},dataType:Sc,resize:function(n,e,t){n.type;var r=document.createElement("canvas"),i=new FileReader;i.readAsDataURL(n),i.onload=function(s){var o=s.target.result,u=new Image;u.src=o;var d=u.width,l=u.height,h=function(c,p){var f=1,m=c.width,_=p.maxWidth||0;_>0&&m>_&&(f=_/m);var v=c.height,R=p.maxHeight||0;if(R>0&&v>R){var C=R/v;f=Math.min(f,C)}var A=p.maxSize||0,M=Math.ceil(c.size/1e3);if(M>A){var O=A/M;f=Math.min(f,O)}return f}({width:d,height:l,size:s.total},e),a=o;h<1&&(a=function(c,p,f){r.width=p,r.height=f,r.getContext("2d").drawImage(c,0,0,p,f);var m="image/jpg";return r.toDataURL(m)}(u,d*h,l*h)),t(a)}}};const Rl=function(n,e,t){var r=document.createElement("canvas"),i=r.getContext("2d"),s=new Image;s.onload=function(){var o=function(l,h,a){var c,p,f,m=l<h,_=0,v=0;return(m?h/l:l/h)>a.scale?(m?(p=100,v=((f=h/(c=l/100))-a.maxHeight)/2):(f=100,_=((p=l/(c=h/100))-a.maxWidth)/2),{w:p,h:f,x:-_,y:-v}):(m?(c=h/a.maxHeight,f=a.maxHeight,p=l/c):(c=l/a.maxWidth,p=a.maxWidth,f=h/c),{w:p,h:f,x:-_,y:-v})}(s.width,s.height,e);r.width=o.w>e.maxWidth?e.maxWidth:o.w,r.height=o.h>e.maxHeight?e.maxHeight:o.h,i.drawImage(s,o.x,o.y,o.w,o.h);try{var u=r.toDataURL(n.type,e.quality),d=new RegExp("^data:image/[^;]+;base64,");u=u.replace(d,""),t(u)}catch(l){throw new Error(l)}},s.src=typeof n=="string"?"data:image/jpg;base64,"+n:function(o){var u=window.URL||window.webkitURL;return u?u.createObjectURL(o):""}(n)},El=function(n,e){var t=n.file,r=n.compress;Rl(t,r,e)},Ic=function(n,e){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 s=la.init(n);e(s)});else{n.headers||(n.headers={}),n.base64&&(n.headers["Content-type"]="application/octet-stream");var t=la.init(n);e(t)}};var yi,dr,bc=function(n,e,t){e.upload(n.file,{onError:function(r){t.onError(r)},onProgress:function(r,i){t.onProgress(r,i)},onCompleted:function(r){r.filename||(r.filename=r.hash);var i=n.compressThumbnail||El;n.compress?i(n,function(s){r.thumbnail=s,t.onCompleted(r)}):t.onCompleted(r)}})},Cl=function(n){var e=this;this.instance=n,this.upload=function(t,r){bc({file:t},e.instance,r)},this.cancel=function(){e.instance.cancel()}},yl=function(n,e){var t=this;this.cfg=e,this.instance=n,this.upload=function(r,i){var s={file:r,compress:t.cfg};bc(s,t.instance,i)},this.cancel=function(){t.instance.cancel()}},Tl=function(n,e){Ic(n,function(t){var r={maxHeight:n.maxHeight||160,maxWidth:n.maxWidth||160,quality:n.quality||.5,scale:n.scale||2.4},i=new yl(t,r);e(i)})},Sl=function(n,e){Ic(n,function(t){var r=new Cl(t);e(r)})},Il=Tl;function ha(n){return yi=yi||new AudioContext,new Promise(function(e,t){yi.decodeAudioData(n,function(r){e({duration:r.duration,length:r.length})},t)})}function bl(n,e,t,r,i){return Ue("fileType",n,Qu,!0),Ue("filename",e,we.STRING),Ue("saveName",t,we.STRING),Ue("serverType",i,we.NUMBER),new Promise(function(s){ot.imClient.context.getFileUrl(n,e,t,r,i).then(function(o){s({code:S.SUCCESS,data:o})}).catch(function(o){s({code:o})})})}function Oc(n,e,t){return Bn(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h,a;return Fn(this,function(c){switch(c.label){case 0:return t=t||{},e instanceof yc?(Ue("conversation.channelId",n==null?void 0:n.channelId,we.CHANNEL_ID),r=n.conversationType,i=n.targetId,s=n.channelId,o="conversationType:"+r+",targetId:"+i,Ke.debug("send message ->"+o),(u=Object.assign(t,e)).channelId=s||"",[4,ot.imClient.context.sendMessage(r,i,u)]):(Ke.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,xr.ILLGAL_PARAMS]);case 1:return d=c.sent(),l=d.code,h=d.data,l===S.SUCCESS?(a=Dr(h),[2,{code:l,data:a}]):(Ke.warn("send message fail ->"+l+":"+en[l]+","+o),[2,{code:l,msg:en[l],data:Dr({isMentioned:!!t.isMentioned,content:e.content,messageType:e.messageType,isPersited:e.isPersited||!1,isCounted:e.isCounted||!1,disableNotification:!!(t==null?void 0:t.disableNotification),canIncludeExpansion:!!(t==null?void 0:t.canIncludeExpansion),expansion:(t==null?void 0:t.expansion)||null,conversationType:r,targetId:i,channelId:s||"",senderUserId:ot.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:nt.SEND,isOffLineMessage:!1,sentTime:(h==null?void 0:h.sentTime)||0,receivedTime:0,isStatusMessage:t.isStatusMessage||!1,receivedStatus:Mn.UNREAD})}])}})})}function Jn(n,e){return function(t,r,i,s){return new Promise(function(o){var u;(function(d,l,h,a){var c,p=this;if(l===void 0&&(l=ke.FILE),c=l===ke.IMAGE?ke.IMAGE:ke.FILE,!dr){dr="upload.qiniup.com";var f=ot.imClient.context.getInfoFromCache();if(f&&f.ossConfig)try{var m=JSON.parse(f.ossConfig).find(function(v){return v.qiniu!==void 0});m&&(dr=m.qiniu)}catch{}}var _=Wi({domain:dr,getToken:function(v){ot.imClient.context.getFileToken(c).then(function(R){v(R.token,R)}).catch(function(R){h.onFail(R)})}},a);(c===ke.IMAGE?Il:Sl)(_,function(v){v.upload(d,{onProgress:function(R,C){var A,M=Math.floor(R/C*100);(A=h.onProgress)===null||A===void 0||A.call(h,M)},onCompleted:function(R){return Bn(p,void 0,void 0,function(){var C=this;return Fn(this,function(A){return bl(c,R.filename,R.name,R,R.uploadMethod).then(function(M){return Bn(C,void 0,void 0,function(){var O,y;return Fn(this,function(w){return M.code!==0?(h.onFail(M),[2]):((O=M.data).type=d.type,O.name=R.name||R.filename,l===ke.AUDIO?(typeof d.arrayBuffer=="function"?d.arrayBuffer().then(ha).then(function($){Object.assign(O,$),h.onSuccess(O)},function(){h.onSuccess(O)}):((y=new FileReader).onload=function(){y.result?ha(y.result).then(function($){Object.assign(O,$),h.onSuccess(O)},function(){h.onSuccess(O)}):h.onSuccess(O)},y.onerror=function(){O.duration=0,h.onSuccess(O)},y.readAsArrayBuffer(d)),[2]):(c===ke.IMAGE&&(O.thumbnail=R.thumbnail),h.onSuccess(O),[2]))})})}).catch(function(M){h.onFail(M)}),[2]})})},onError:function(R){h.onFail(R)}})})})(r.file,n,{onProgress:i==null?void 0:i.onProgress,onSuccess:function(d){var l,h=((l=i==null?void 0:i.onComplete)===null||l===void 0?void 0:l.call(i,{url:d.downloadUrl}))||e(d,r);Oc(t,h,s).then(o)},onFail:function(d){o({code:S.UPLOAD_FILE_FAILED,msg:d||S[S.UPLOAD_FILE_FAILED]})}},((u=s)===null||u===void 0?void 0:u.thumbnailConfig)||{})})}}Jn(ke.FILE,function(n,e){return new ml({name:n.name,size:e.file.size,type:e.file.type,fileUrl:n.downloadUrl,user:e.user,extra:e.extra})});Jn(ke.IMAGE,function(n,e){return new ll({content:n.thumbnail,imageUri:n.downloadUrl,user:e.user,extra:e.extra})});Jn(ke.AUDIO,function(n,e){return new hl({remoteUrl:n.downloadUrl,duration:n.duration,type:n.type,user:e.user,extra:e.extra})});Jn(ke.SIGHT,function(n,e){return new pl({sightUrl:n.downloadUrl,content:e.thumbnail,duration:e.duration,size:e.file.size||n.size,name:e.name||n.name,user:e.user,extra:e.extra})});function si(n,e,t,r){return Ue("messageType",n,we.STRING,!0),Ue("isPersited",e,we.BOOLEAN,!0),Ue("isCounted",t,we.BOOLEAN,!0),ot.imClient.context.registerMessageType(n,e,t,r),it(n,e,t)}Jn(ke.COMBINE_HTML,function(n,e){return new gl({remoteUrl:n.downloadUrl,nameList:e.nameList,summaryList:e.summaryList,conversationType:e.conversationType,user:e.user,extra:e.extra})});Dt.add("imlib","5.1.1"),Dt.validEngine("~5.1.1")||Ke.error("The current engine version '"+Dt.getInfo().engine+"' error\uFF0Cimlib required engine version at least '~5.1.1'.");/*! *****************************************************************************
- 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 F(n,e,t,r){return new(t||(t=Promise))(function(i,s){function o(l){try{d(r.next(l))}catch(h){s(h)}}function u(l){try{d(r.throw(l))}catch(h){s(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof t?h:new t(function(a){a(h)})).then(o,u)}d((r=r.apply(n,e||[])).next())})}const b=new wt("RCRTC");var I,Zi;(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"})(I||(I={})),function(n){n[n.JOIN_REFUSED=40032]="JOIN_REFUSED"}(Zi||(Zi={}));class Nc{constructor(){this.queue=[],this.locked=!1}checkToStart(){return F(this,void 0,void 0,function*(){if(this.queue.length===0||this.locked)return;this.locked=!0;const{resolve:e,task:t,reject:r}=this.queue.shift();let i;try{i=yield t(),e(i)}catch(s){r(s)}this.locked=!1,this.checkToStart()})}push(e){const t=new Promise((r,i)=>{this.queue.push({resolve:r,task:e,reject:i})});return this.checkToStart(),t}}const Ol=new Nc,Se=n=>Ol.push(n);let wc=!0,Ac=!0;function En(n,e,t){const r=n.match(e);return r&&r.length>=t&&parseInt(r[t],10)}function cn(n,e,t){if(!n.RTCPeerConnection)return;const r=n.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(o,u){if(o!==e)return i.apply(this,arguments);const d=l=>{const h=t(l);h&&(u.handleEvent?u.handleEvent(h):u(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(u,d),i.apply(this,[o,d])};const s=r.removeEventListener;r.removeEventListener=function(o,u){if(o!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(u))return s.apply(this,arguments);const d=this._eventMap[e].get(u);return this._eventMap[e].delete(u),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[o,d])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(o){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),o&&this.addEventListener(e,this["_on"+e]=o)},enumerable:!0,configurable:!0})}function Nl(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(wc=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function wl(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Ac=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function uo(){if(typeof window=="object"){if(wc)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function oi(n,e){Ac&&console.warn(n+" is deprecated, please use "+e+" instead.")}function pa(n){return Object.prototype.toString.call(n)==="[object Object]"}function Mc(n){return pa(n)?Object.keys(n).reduce(function(e,t){const r=pa(n[t]),i=r?Mc(n[t]):n[t],s=r&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):n}function es(n,e,t){e&&!t.has(e.id)&&(t.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?es(n,n.get(e[r]),t):r.endsWith("Ids")&&e[r].forEach(i=>{es(n,n.get(i),t)})}))}function fa(n,e,t){const r=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return n.forEach(o=>{o.type==="track"&&o.trackIdentifier===e.id&&s.push(o)}),s.forEach(o=>{n.forEach(u=>{u.type===r&&u.trackId===o.id&&es(n,u,i)})}),i}const ga=uo;function Pc(n,e){const t=n&&n.navigator;if(!t.mediaDevices)return;const r=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const u={};return Object.keys(o).forEach(d=>{if(d==="require"||d==="advanced"||d==="mediaSource")return;const l=typeof o[d]=="object"?o[d]:{ideal:o[d]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(a,c){return a?a+c.charAt(0).toUpperCase()+c.slice(1):c==="deviceId"?"sourceId":c};if(l.ideal!==void 0){u.optional=u.optional||[];let a={};typeof l.ideal=="number"?(a[h("min",d)]=l.ideal,u.optional.push(a),a={},a[h("max",d)]=l.ideal,u.optional.push(a)):(a[h("",d)]=l.ideal,u.optional.push(a))}l.exact!==void 0&&typeof l.exact!="number"?(u.mandatory=u.mandatory||{},u.mandatory[h("",d)]=l.exact):["min","max"].forEach(a=>{l[a]!==void 0&&(u.mandatory=u.mandatory||{},u.mandatory[h(a,d)]=l[a])})}),o.advanced&&(u.optional=(u.optional||[]).concat(o.advanced)),u},i=function(o,u){if(e.version>=61)return u(o);if((o=JSON.parse(JSON.stringify(o)))&&typeof o.audio=="object"){const d=function(l,h,a){h in l&&!(a in l)&&(l[a]=l[h],delete l[h])};d((o=JSON.parse(JSON.stringify(o))).audio,"autoGainControl","googAutoGainControl"),d(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=r(o.audio)}if(o&&typeof o.video=="object"){let d=o.video.facingMode;d=d&&(typeof d=="object"?d:{ideal:d});const l=e.version<66;if(d&&(d.exact==="user"||d.exact==="environment"||d.ideal==="user"||d.ideal==="environment")&&(!t.mediaDevices.getSupportedConstraints||!t.mediaDevices.getSupportedConstraints().facingMode||l)){let h;if(delete o.video.facingMode,d.exact==="environment"||d.ideal==="environment"?h=["back","rear"]:d.exact!=="user"&&d.ideal!=="user"||(h=["front"]),h)return t.mediaDevices.enumerateDevices().then(a=>{let c=(a=a.filter(p=>p.kind==="videoinput")).find(p=>h.some(f=>p.label.toLowerCase().includes(f)));return!c&&a.length&&h.includes("back")&&(c=a[a.length-1]),c&&(o.video.deviceId=d.exact?{exact:c.deviceId}:{ideal:c.deviceId}),o.video=r(o.video),ga("chrome: "+JSON.stringify(o)),u(o)})}o.video=r(o.video)}return ga("chrome: "+JSON.stringify(o)),u(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(t.getUserMedia=function(o,u,d){i(o,l=>{t.webkitGetUserMedia(l,u,h=>{d&&d(s(h))})})}.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(u){return i(u,d=>o(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(s(l))))}}}function Lc(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(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let i;i=n.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(o=>o.track&&o.track.id===r.track.id):{track:r.track};const s=new Event("track");s.track=r.track,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)}),t.stream.getTracks().forEach(r=>{let i;i=n.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(o=>o.track&&o.track.id===r.id):{track:r};const s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else cn(n,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Uc(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):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(o,u){let d=i.apply(this,arguments);return d||(d=e(this,o),this._senders.push(d)),d};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const u=this._senders.indexOf(o);u!==-1&&this._senders.splice(u,1)}}const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],t.apply(this,[i]),i.getTracks().forEach(s=>{this._senders.push(e(this,s))})};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(s=>{const o=this._senders.find(u=>u.track===s);o&&this._senders.splice(this._senders.indexOf(o),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 e=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const t=e.apply(this,[]);return t.forEach(r=>r._pc=this),t},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 Dc(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[t,r,i]=arguments;if(arguments.length>0&&typeof t=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof t!="function"))return e.apply(this,[]);const s=function(u){const d={};return u.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},o=function(u){return new Map(Object.keys(u).map(d=>[d,u[d]]))};if(arguments.length>=2){const u=function(d){r(o(s(d)))};return e.apply(this,[u,t])}return new Promise((u,d)=>{e.apply(this,[function(l){u(o(s(l)))},d])}).then(r,i)}}function xc(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(s=>s._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(s=>fa(s,i.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=t.apply(this,[]);return r.forEach(i=>i._pc=this),r}),cn(n,"track",r=>(r.receiver._pc=r.srcElement,r)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>fa(i,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype)||!("getStats"in n.RTCRtpReceiver.prototype))return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const t=arguments[0];let r,i,s;return this.getSenders().forEach(o=>{o.track===t&&(r?s=!0:r=o)}),this.getReceivers().forEach(o=>(o.track===t&&(i?s=!0:i=o),o.track===t)),s||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 e.apply(this,arguments)}}function Vc(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(s,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const u=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(u)===-1&&this._shimmedLocalStreams[o.id].push(u):this._shimmedLocalStreams[o.id]=[o,u],u};const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(d=>{if(this.getSenders().find(l=>l.track===d))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const u=this.getSenders().filter(d=>o.indexOf(d)===-1);this._shimmedLocalStreams[s.id]=[s].concat(u)};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],r.apply(this,arguments)};const i=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const u=this._shimmedLocalStreams[o].indexOf(s);u!==-1&&this._shimmedLocalStreams[o].splice(u,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function Bc(n,e){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Vc(n);const t=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.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 s(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(c=>{const p=l._reverseStreams[c],f=l._streams[p.id];a=a.replace(new RegExp(f.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:a})}function o(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(c=>{const p=l._reverseStreams[c],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 c=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[p=>{const f=s(this,p);c[0].apply(null,[f])},p=>{c[1]&&c[1].apply(null,p)},arguments[2]]):h.apply(this,arguments).then(p=>s(this,p))}};n.RTCPeerConnection.prototype[l]=a[l]});const u=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=o(this,arguments[0]),u.apply(this,arguments)):u.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:s(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(c=>l.track===c)&&(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 ts(n,e){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const r=n.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};n.RTCPeerConnection.prototype[t]=i[t]})}function Fc(n,e){cn(n,"negotiationneeded",t=>{const r=t.target;if(!(e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return t})}var ma=Object.freeze({__proto__:null,shimMediaStream:Lc,shimOnTrack:kc,shimGetSendersWithDtmf:Uc,shimGetStats:Dc,shimSenderReceiverGetStats:xc,shimAddTrackRemoveTrackWithNative:Vc,shimAddTrackRemoveTrack:Bc,shimPeerConnection:ts,fixNegotiationNeeded:Fc,shimGetUserMedia:Pc,shimGetDisplayMedia:function(n,e){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(typeof e=="function"?n.navigator.mediaDevices.getDisplayMedia=function(t){return e(t).then(r=>{const i=t.video&&t.video.width,s=t.video&&t.video.height,o=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:o||3}},i&&(t.video.mandatory.maxWidth=i),s&&(t.video.mandatory.maxHeight=s),n.navigator.mediaDevices.getUserMedia(t)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),_a,Ti,X=(_a=function(n){var e={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
- `).map(function(r){return r.trim()})},e.splitSections=function(t){return t.split(`
- m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r
- `})},e.getDescription=function(t){var r=e.splitSections(t);return r&&r[0]},e.getMediaSections=function(t){var r=e.splitSections(t);return r.shift(),r},e.matchPrefix=function(t,r){return e.splitLines(t).filter(function(i){return i.indexOf(r)===0})},e.parseCandidate=function(t){for(var r,i={foundation:(r=t.indexOf("a=candidate:")===0?t.substring(12).split(" "):t.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]},s=8;s<r.length;s+=2)switch(r[s]){case"raddr":i.relatedAddress=r[s+1];break;case"rport":i.relatedPort=parseInt(r[s+1],10);break;case"tcptype":i.tcpType=r[s+1];break;case"ufrag":i.ufrag=r[s+1],i.usernameFragment=r[s+1];break;default:i[r[s]]=r[s+1]}return i},e.writeCandidate=function(t){var r=[];r.push(t.foundation),r.push(t.component),r.push(t.protocol.toUpperCase()),r.push(t.priority),r.push(t.address||t.ip),r.push(t.port);var i=t.type;return r.push("typ"),r.push(i),i!=="host"&&t.relatedAddress&&t.relatedPort&&(r.push("raddr"),r.push(t.relatedAddress),r.push("rport"),r.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(r.push("ufrag"),r.push(t.usernameFragment||t.ufrag)),"candidate:"+r.join(" ")},e.parseIceOptions=function(t){return t.substr(14).split(" ")},e.parseRtpMap=function(t){var r=t.substr(9).split(" "),i={payloadType:parseInt(r.shift(),10)};return r=r[0].split("/"),i.name=r[0],i.clockRate=parseInt(r[1],10),i.channels=r.length===3?parseInt(r[2],10):1,i.numChannels=i.channels,i},e.writeRtpMap=function(t){var r=t.payloadType;t.preferredPayloadType!==void 0&&(r=t.preferredPayloadType);var i=t.channels||t.numChannels||1;return"a=rtpmap:"+r+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
- `},e.parseExtmap=function(t){var r=t.substr(9).split(" ");return{id:parseInt(r[0],10),direction:r[0].indexOf("/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},e.writeExtmap=function(t){return"a=extmap:"+(t.id||t.preferredId)+(t.direction&&t.direction!=="sendrecv"?"/"+t.direction:"")+" "+t.uri+`\r
- `},e.parseFmtp=function(t){for(var r,i={},s=t.substr(t.indexOf(" ")+1).split(";"),o=0;o<s.length;o++)i[(r=s[o].trim().split("="))[0].trim()]=r[1];return i},e.writeFmtp=function(t){var r="",i=t.payloadType;if(t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.parameters&&Object.keys(t.parameters).length){var s=[];Object.keys(t.parameters).forEach(function(o){t.parameters[o]?s.push(o+"="+t.parameters[o]):s.push(o)}),r+="a=fmtp:"+i+" "+s.join(";")+`\r
- `}return r},e.parseRtcpFb=function(t){var r=t.substr(t.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},e.writeRtcpFb=function(t){var r="",i=t.payloadType;return t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.rtcpFeedback&&t.rtcpFeedback.length&&t.rtcpFeedback.forEach(function(s){r+="a=rtcp-fb:"+i+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
- `}),r},e.parseSsrcMedia=function(t){var r=t.indexOf(" "),i={ssrc:parseInt(t.substr(7,r-7),10)},s=t.indexOf(":",r);return s>-1?(i.attribute=t.substr(r+1,s-r-1),i.value=t.substr(s+1)):i.attribute=t.substr(r+1),i},e.parseSsrcGroup=function(t){var r=t.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},e.getMid=function(t){var r=e.matchPrefix(t,"a=mid:")[0];if(r)return r.substr(6)},e.parseFingerprint=function(t){var r=t.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},e.getDtlsParameters=function(t,r){return{role:"auto",fingerprints:e.matchPrefix(t+r,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(t,r){var i="a=setup:"+r+`\r
- `;return t.fingerprints.forEach(function(s){i+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
- `}),i},e.parseCryptoLine=function(t){var r=t.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},e.writeCryptoLine=function(t){return"a=crypto:"+t.tag+" "+t.cryptoSuite+" "+(typeof t.keyParams=="object"?e.writeCryptoKeyParams(t.keyParams):t.keyParams)+(t.sessionParams?" "+t.sessionParams.join(" "):"")+`\r
- `},e.parseCryptoKeyParams=function(t){if(t.indexOf("inline:")!==0)return null;var r=t.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}},e.writeCryptoKeyParams=function(t){return t.keyMethod+":"+t.keySalt+(t.lifeTime?"|"+t.lifeTime:"")+(t.mkiValue&&t.mkiLength?"|"+t.mkiValue+":"+t.mkiLength:"")},e.getCryptoParameters=function(t,r){return e.matchPrefix(t+r,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(t,r){var i=e.matchPrefix(t+r,"a=ice-ufrag:")[0],s=e.matchPrefix(t+r,"a=ice-pwd:")[0];return i&&s?{usernameFragment:i.substr(12),password:s.substr(10)}:null},e.writeIceParameters=function(t){return"a=ice-ufrag:"+t.usernameFragment+`\r
- a=ice-pwd:`+t.password+`\r
- `},e.parseRtpParameters=function(t){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=e.splitLines(t)[0].split(" "),s=3;s<i.length;s++){var o=i[s],u=e.matchPrefix(t,"a=rtpmap:"+o+" ")[0];if(u){var d=e.parseRtpMap(u),l=e.matchPrefix(t,"a=fmtp:"+o+" ");switch(d.parameters=l.length?e.parseFmtp(l[0]):{},d.rtcpFeedback=e.matchPrefix(t,"a=rtcp-fb:"+o+" ").map(e.parseRtcpFb),r.codecs.push(d),d.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(d.name.toUpperCase())}}}return e.matchPrefix(t,"a=extmap:").forEach(function(h){r.headerExtensions.push(e.parseExtmap(h))}),r},e.writeRtpDescription=function(t,r){var i="";i+="m="+t+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(o){return o.preferredPayloadType!==void 0?o.preferredPayloadType:o.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(o){i+=e.writeRtpMap(o),i+=e.writeFmtp(o),i+=e.writeRtcpFb(o)});var s=0;return r.codecs.forEach(function(o){o.maxptime>s&&(s=o.maxptime)}),s>0&&(i+="a=maxptime:"+s+`\r
- `),i+=`a=rtcp-mux\r
- `,r.headerExtensions&&r.headerExtensions.forEach(function(o){i+=e.writeExtmap(o)}),i},e.parseRtpEncodingParameters=function(t){var r,i=[],s=e.parseRtpParameters(t),o=s.fecMechanisms.indexOf("RED")!==-1,u=s.fecMechanisms.indexOf("ULPFEC")!==-1,d=e.matchPrefix(t,"a=ssrc:").map(function(c){return e.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"}),l=d.length>0&&d[0].ssrc,h=e.matchPrefix(t,"a=ssrc-group:FID").map(function(c){return c.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]),s.codecs.forEach(function(c){if(c.name.toUpperCase()==="RTX"&&c.parameters.apt){var p={ssrc:l,codecPayloadType:parseInt(c.parameters.apt,10)};l&&r&&(p.rtx={ssrc:r}),i.push(p),o&&((p=JSON.parse(JSON.stringify(p))).fec={ssrc:l,mechanism:u?"red+ulpfec":"red"},i.push(p))}}),i.length===0&&l&&i.push({ssrc:l});var a=e.matchPrefix(t,"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(c){c.maxBitrate=a})),i},e.parseRtcpParameters=function(t){var r={},i=e.matchPrefix(t,"a=ssrc:").map(function(u){return e.parseSsrcMedia(u)}).filter(function(u){return u.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var s=e.matchPrefix(t,"a=rtcp-rsize");r.reducedSize=s.length>0,r.compound=s.length===0;var o=e.matchPrefix(t,"a=rtcp-mux");return r.mux=o.length>0,r},e.parseMsid=function(t){var r,i=e.matchPrefix(t,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var s=e.matchPrefix(t,"a=ssrc:").map(function(o){return e.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="msid"});return s.length>0?{stream:(r=s[0].value.split(" "))[0],track:r[1]}:void 0},e.parseSctpDescription=function(t){var r,i=e.parseMLine(t),s=e.matchPrefix(t,"a=max-message-size:");s.length>0&&(r=parseInt(s[0].substr(19),10)),isNaN(r)&&(r=65536);var o=e.matchPrefix(t,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(e.matchPrefix(t,"a=sctpmap:").length>0){var u=e.matchPrefix(t,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(u[0],10),protocol:u[1],maxMessageSize:r}}},e.writeSctpDescription=function(t,r){var i=[];return i=t.protocol!=="DTLS/SCTP"?["m="+t.kind+" 9 "+t.protocol+" "+r.protocol+`\r
- `,`c=IN IP4 0.0.0.0\r
- `,"a=sctp-port:"+r.port+`\r
- `]:["m="+t.kind+" 9 "+t.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("")},e.generateSessionId=function(){return Math.random().toString().substr(2,21)},e.writeSessionBoilerplate=function(t,r,i){var s=r!==void 0?r:2;return`v=0\r
- o=`+(i||"thisisadapterortc")+" "+(t||e.generateSessionId())+" "+s+` IN IP4 127.0.0.1\r
- s=-\r
- t=0 0\r
- `},e.writeMediaSection=function(t,r,i,s){var o=e.writeRtpDescription(t.kind,r);if(o+=e.writeIceParameters(t.iceGatherer.getLocalParameters()),o+=e.writeDtlsParameters(t.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),o+="a=mid:"+t.mid+`\r
- `,t.direction?o+="a="+t.direction+`\r
- `:t.rtpSender&&t.rtpReceiver?o+=`a=sendrecv\r
- `:t.rtpSender?o+=`a=sendonly\r
- `:t.rtpReceiver?o+=`a=recvonly\r
- `:o+=`a=inactive\r
- `,t.rtpSender){var u="msid:"+s.id+" "+t.rtpSender.track.id+`\r
- `;o+="a="+u,o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" "+u,t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" "+u,o+="a=ssrc-group:FID "+t.sendEncodingParameters[0].ssrc+" "+t.sendEncodingParameters[0].rtx.ssrc+`\r
- `)}return o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r
- `,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r
- `),o},e.getDirection=function(t,r){for(var i=e.splitLines(t),s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substr(2)}return r?e.getDirection(r):"sendrecv"},e.getKind=function(t){return e.splitLines(t)[0].split(" ")[0].substr(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){var r=e.splitLines(t)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},e.parseOLine=function(t){var r=e.matchPrefix(t,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;for(var r=e.splitLines(t),i=0;i<r.length;i++)if(r[i].length<2||r[i].charAt(1)!=="=")return!1;return!0},n.exports=e},_a(Ti={exports:{}},Ti.exports),Ti.exports);function va(n,e,t,r,i){var s=X.writeRtpDescription(n.kind,e);if(s+=X.writeIceParameters(n.iceGatherer.getLocalParameters()),s+=X.writeDtlsParameters(n.dtlsTransport.getLocalParameters(),t==="offer"?"actpass":i||"active"),s+="a=mid:"+n.mid+`\r
- `,n.rtpSender&&n.rtpReceiver?s+=`a=sendrecv\r
- `:n.rtpSender?s+=`a=sendonly\r
- `:n.rtpReceiver?s+=`a=recvonly\r
- `:s+=`a=inactive\r
- `,n.rtpSender){var o=n.rtpSender._initialTrackId||n.rtpSender.track.id;n.rtpSender._initialTrackId=o;var u="msid:"+(r?r.id:"-")+" "+o+`\r
- `;s+="a="+u,s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" "+u,n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" "+u,s+="a=ssrc-group:FID "+n.sendEncodingParameters[0].ssrc+" "+n.sendEncodingParameters[0].rtx.ssrc+`\r
- `)}return s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" cname:"+X.localCName+`\r
- `,n.rtpSender&&n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" cname:"+X.localCName+`\r
- `),s}function lr(n,e){var t={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(s,o){s=parseInt(s,10);for(var u=0;u<o.length;u++)if(o[u].payloadType===s||o[u].preferredPayloadType===s)return o[u]},i=function(s,o,u,d){var l=r(s.parameters.apt,u),h=r(o.parameters.apt,d);return l&&h&&l.name.toLowerCase()===h.name.toLowerCase()};return n.codecs.forEach(function(s){for(var o=0;o<e.codecs.length;o++){var u=e.codecs[o];if(s.name.toLowerCase()===u.name.toLowerCase()&&s.clockRate===u.clockRate){if(s.name.toLowerCase()==="rtx"&&s.parameters&&u.parameters.apt&&!i(s,u,n.codecs,e.codecs))continue;(u=JSON.parse(JSON.stringify(u))).numChannels=Math.min(s.numChannels,u.numChannels),t.codecs.push(u),u.rtcpFeedback=u.rtcpFeedback.filter(function(d){for(var l=0;l<s.rtcpFeedback.length;l++)if(s.rtcpFeedback[l].type===d.type&&s.rtcpFeedback[l].parameter===d.parameter)return!0;return!1});break}}}),n.headerExtensions.forEach(function(s){for(var o=0;o<e.headerExtensions.length;o++){var u=e.headerExtensions[o];if(s.uri===u.uri){t.headerExtensions.push(u);break}}}),t}function Ra(n,e,t){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[e][n].indexOf(t)!==-1}function Si(n,e){var t=n.getRemoteCandidates().find(function(r){return e.foundation===r.foundation&&e.ip===r.ip&&e.port===r.port&&e.priority===r.priority&&e.protocol===r.protocol&&e.type===r.type});return t||n.addRemoteCandidate(e),!t}function De(n,e){var t=new Error(e);return t.name=n,t.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[n],t}var Al=function(n,e){function t(o,u){u.addTrack(o),u.dispatchEvent(new n.MediaStreamTrackEvent("addtrack",{track:o}))}function r(o,u,d,l){var h=new Event("track");h.track=u,h.receiver=d,h.transceiver={receiver:d},h.streams=l,n.setTimeout(function(){o._dispatchEvent("track",h)})}var i=function(o){var u=this,d=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(h){u[h]=d[h].bind(d)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",o=JSON.parse(JSON.stringify(o||{})),this.usingBundle=o.bundlePolicy==="max-bundle",o.rtcpMuxPolicy==="negotiate")throw De("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(o.rtcpMuxPolicy||(o.rtcpMuxPolicy="require"),o.iceTransportPolicy){case"all":case"relay":break;default:o.iceTransportPolicy="all"}switch(o.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:o.bundlePolicy="balanced"}if(o.iceServers=function(h,a){var c=!1;return(h=JSON.parse(JSON.stringify(h))).filter(function(p){if(p&&(p.urls||p.url)){var f=p.urls||p.url;p.url&&!p.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var m=typeof f=="string";return m&&(f=[f]),f=f.filter(function(_){return _.indexOf("turn:")!==0||_.indexOf("transport=udp")===-1||_.indexOf("turn:[")!==-1||c?_.indexOf("stun:")===0&&a>=14393&&_.indexOf("?transport=udp")===-1:(c=!0,!0)}),delete p.url,p.urls=m?f[0]:f,!!f.length}})}(o.iceServers||[],e),this._iceGatherers=[],o.iceCandidatePoolSize)for(var l=o.iceCandidatePoolSize;l>0;l--)this._iceGatherers.push(new n.RTCIceGatherer({iceServers:o.iceServers,gatherPolicy:o.iceTransportPolicy}));else o.iceCandidatePoolSize=0;this._config=o,this.transceivers=[],this._sdpSessionId=X.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(o,u){this._isClosed||(this.dispatchEvent(u),typeof this["on"+o]=="function"&&this["on"+o](u))},i.prototype._emitGatheringStateChange=function(){var o=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",o)},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(o,u){var d=this.transceivers.length>0,l={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:o,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 u||this.transceivers.push(l),l},i.prototype.addTrack=function(o,u){if(this._isClosed)throw De("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d;if(this.transceivers.find(function(h){return h.track===o}))throw De("InvalidAccessError","Track already exists.");for(var l=0;l<this.transceivers.length;l++)this.transceivers[l].track||this.transceivers[l].kind!==o.kind||(d=this.transceivers[l]);return d||(d=this._createTransceiver(o.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(u)===-1&&this.localStreams.push(u),d.track=o,d.stream=u,d.rtpSender=new n.RTCRtpSender(o,d.dtlsTransport),d.rtpSender},i.prototype.addStream=function(o){var u=this;if(e>=15025)o.getTracks().forEach(function(l){u.addTrack(l,o)});else{var d=o.clone();o.getTracks().forEach(function(l,h){var a=d.getTracks()[h];l.addEventListener("enabled",function(c){a.enabled=c.enabled})}),d.getTracks().forEach(function(l){u.addTrack(l,d)})}},i.prototype.removeTrack=function(o){if(this._isClosed)throw De("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(o instanceof n.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var u=this.transceivers.find(function(l){return l.rtpSender===o});if(!u)throw De("InvalidAccessError","Sender was not created by this connection.");var d=u.stream;u.rtpSender.stop(),u.rtpSender=null,u.track=null,u.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(o){var u=this;o.getTracks().forEach(function(d){var l=u.getSenders().find(function(h){return h.track===d});l&&u.removeTrack(l)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(o){return!!o.rtpSender}).map(function(o){return o.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(o){return!!o.rtpReceiver}).map(function(o){return o.rtpReceiver})},i.prototype._createIceGatherer=function(o,u){var d=this;if(u&&o>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[o].bufferedCandidateEvents=[],this.transceivers[o].bufferCandidates=function(h){var a=!h.candidate||Object.keys(h.candidate).length===0;l.state=a?"completed":"gathering",d.transceivers[o].bufferedCandidateEvents!==null&&d.transceivers[o].bufferedCandidateEvents.push(h)},l.addEventListener("localcandidate",this.transceivers[o].bufferCandidates),l},i.prototype._gather=function(o,u){var d=this,l=this.transceivers[u].iceGatherer;if(!l.onlocalcandidate){var h=this.transceivers[u].bufferedCandidateEvents;this.transceivers[u].bufferedCandidateEvents=null,l.removeEventListener("localcandidate",this.transceivers[u].bufferCandidates),l.onlocalcandidate=function(a){if(!(d.usingBundle&&u>0)){var c=new Event("icecandidate");c.candidate={sdpMid:o,sdpMLineIndex:u};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=X.writeCandidate(p);c.candidate=Object.assign(c.candidate,X.parseCandidate(m)),c.candidate.candidate=m,c.candidate.toJSON=function(){return{candidate:c.candidate.candidate,sdpMid:c.candidate.sdpMid,sdpMLineIndex:c.candidate.sdpMLineIndex,usernameFragment:c.candidate.usernameFragment}}}var _=X.getMediaSections(d._localDescription.sdp);_[c.candidate.sdpMLineIndex]+=f?`a=end-of-candidates\r
- `:"a="+c.candidate.candidate+`\r
- `,d._localDescription.sdp=X.getDescription(d._localDescription.sdp)+_.join("");var v=d.transceivers.every(function(R){return R.iceGatherer&&R.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),f||d._dispatchEvent("icecandidate",c),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 o=this,u=new n.RTCIceTransport(null);u.onicestatechange=function(){o._updateIceConnectionState(),o._updateConnectionState()};var d=new n.RTCDtlsTransport(u);return d.ondtlsstatechange=function(){o._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),o._updateConnectionState()},{iceTransport:u,dtlsTransport:d}},i.prototype._disposeIceAndDtlsTransports=function(o){var u=this.transceivers[o].iceGatherer;u&&(delete u.onlocalcandidate,delete this.transceivers[o].iceGatherer);var d=this.transceivers[o].iceTransport;d&&(delete d.onicestatechange,delete this.transceivers[o].iceTransport);var l=this.transceivers[o].dtlsTransport;l&&(delete l.ondtlsstatechange,delete l.onerror,delete this.transceivers[o].dtlsTransport)},i.prototype._transceive=function(o,u,d){var l=lr(o.localCapabilities,o.remoteCapabilities);u&&o.rtpSender&&(l.encodings=o.sendEncodingParameters,l.rtcp={cname:X.localCName,compound:o.rtcpParameters.compound},o.recvEncodingParameters.length&&(l.rtcp.ssrc=o.recvEncodingParameters[0].ssrc),o.rtpSender.send(l)),d&&o.rtpReceiver&&l.codecs.length>0&&(o.kind==="video"&&o.recvEncodingParameters&&e<15019&&o.recvEncodingParameters.forEach(function(h){delete h.rtx}),o.recvEncodingParameters.length?l.encodings=o.recvEncodingParameters:l.encodings=[{}],l.rtcp={compound:o.rtcpParameters.compound},o.rtcpParameters.cname&&(l.rtcp.cname=o.rtcpParameters.cname),o.sendEncodingParameters.length&&(l.rtcp.ssrc=o.sendEncodingParameters[0].ssrc),o.rtpReceiver.receive(l))},i.prototype.setLocalDescription=function(o){var u,d,l=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(De("TypeError",'Unsupported type "'+o.type+'"'));if(!Ra("setLocalDescription",o.type,l.signalingState)||l._isClosed)return Promise.reject(De("InvalidStateError","Can not set local "+o.type+" in state "+l.signalingState));if(o.type==="offer")u=X.splitSections(o.sdp),d=u.shift(),u.forEach(function(a,c){var p=X.parseRtpParameters(a);l.transceivers[c].localCapabilities=p}),l.transceivers.forEach(function(a,c){l._gather(a.mid,c)});else if(o.type==="answer"){u=X.splitSections(l._remoteDescription.sdp),d=u.shift();var h=X.matchPrefix(d,"a=ice-lite").length>0;u.forEach(function(a,c){var p=l.transceivers[c],f=p.iceGatherer,m=p.iceTransport,_=p.dtlsTransport,v=p.localCapabilities,R=p.remoteCapabilities;if(!(X.isRejected(a)&&X.matchPrefix(a,"a=bundle-only").length===0)&&!p.rejected){var C=X.getIceParameters(a,d),A=X.getDtlsParameters(a,d);h&&(A.role="server"),l.usingBundle&&c!==0||(l._gather(p.mid,c),m.state==="new"&&m.start(f,C,h?"controlling":"controlled"),_.state==="new"&&_.start(A));var M=lr(v,R);l._transceive(p,M.codecs.length>0,!1)}})}return l._localDescription={type:o.type,sdp:o.sdp},o.type==="offer"?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(o){var u=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(De("TypeError",'Unsupported type "'+o.type+'"'));if(!Ra("setRemoteDescription",o.type,u.signalingState)||u._isClosed)return Promise.reject(De("InvalidStateError","Can not set remote "+o.type+" in state "+u.signalingState));var d={};u.remoteStreams.forEach(function(m){d[m.id]=m});var l=[],h=X.splitSections(o.sdp),a=h.shift(),c=X.matchPrefix(a,"a=ice-lite").length>0,p=X.matchPrefix(a,"a=group:BUNDLE ").length>0;u.usingBundle=p;var f=X.matchPrefix(a,"a=ice-options:")[0];return u.canTrickleIceCandidates=!!f&&f.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(m,_){var v=X.splitLines(m),R=X.getKind(m),C=X.isRejected(m)&&X.matchPrefix(m,"a=bundle-only").length===0,A=v[0].substr(2).split(" ")[2],M=X.getDirection(m,a),O=X.parseMsid(m),y=X.getMid(m)||X.generateIdentifier();if(C||R==="application"&&(A==="DTLS/SCTP"||A==="UDP/DTLS/SCTP"))u.transceivers[_]={mid:y,kind:R,protocol:A,rejected:!0};else{var w,$,Y,E,T,N,P,k,B;!C&&u.transceivers[_]&&u.transceivers[_].rejected&&(u.transceivers[_]=u._createTransceiver(R,!0));var H,q,J=X.parseRtpParameters(m);C||(H=X.getIceParameters(m,a),(q=X.getDtlsParameters(m,a)).role="client"),P=X.parseRtpEncodingParameters(m);var re=X.parseRtcpParameters(m),de=X.matchPrefix(m,"a=end-of-candidates",a).length>0,ue=X.matchPrefix(m,"a=candidate:").map(function(U){return X.parseCandidate(U)}).filter(function(U){return U.component===1});if((o.type==="offer"||o.type==="answer")&&!C&&p&&_>0&&u.transceivers[_]&&(u._disposeIceAndDtlsTransports(_),u.transceivers[_].iceGatherer=u.transceivers[0].iceGatherer,u.transceivers[_].iceTransport=u.transceivers[0].iceTransport,u.transceivers[_].dtlsTransport=u.transceivers[0].dtlsTransport,u.transceivers[_].rtpSender&&u.transceivers[_].rtpSender.setTransport(u.transceivers[0].dtlsTransport),u.transceivers[_].rtpReceiver&&u.transceivers[_].rtpReceiver.setTransport(u.transceivers[0].dtlsTransport)),o.type!=="offer"||C)o.type==="answer"&&!C&&($=(w=u.transceivers[_]).iceGatherer,Y=w.iceTransport,E=w.dtlsTransport,T=w.rtpReceiver,N=w.sendEncodingParameters,k=w.localCapabilities,u.transceivers[_].recvEncodingParameters=P,u.transceivers[_].remoteCapabilities=J,u.transceivers[_].rtcpParameters=re,ue.length&&Y.state==="new"&&(!c&&!de||p&&_!==0?ue.forEach(function(U){Si(w.iceTransport,U)}):Y.setRemoteCandidates(ue)),p&&_!==0||(Y.state==="new"&&Y.start($,H,"controlling"),E.state==="new"&&E.start(q)),!lr(w.localCapabilities,w.remoteCapabilities).codecs.filter(function(U){return U.name.toLowerCase()==="rtx"}).length&&w.sendEncodingParameters[0].rtx&&delete w.sendEncodingParameters[0].rtx,u._transceive(w,M==="sendrecv"||M==="recvonly",M==="sendrecv"||M==="sendonly"),!T||M!=="sendrecv"&&M!=="sendonly"?delete w.rtpReceiver:(B=T.track,O?(d[O.stream]||(d[O.stream]=new n.MediaStream),t(B,d[O.stream]),l.push([B,T,d[O.stream]])):(d.default||(d.default=new n.MediaStream),t(B,d.default),l.push([B,T,d.default]))));else{(w=u.transceivers[_]||u._createTransceiver(R)).mid=y,w.iceGatherer||(w.iceGatherer=u._createIceGatherer(_,p)),ue.length&&w.iceTransport.state==="new"&&(!de||p&&_!==0?ue.forEach(function(U){Si(w.iceTransport,U)}):w.iceTransport.setRemoteCandidates(ue)),k=n.RTCRtpReceiver.getCapabilities(R),e<15019&&(k.codecs=k.codecs.filter(function(U){return U.name!=="rtx"})),N=w.sendEncodingParameters||[{ssrc:1001*(2*_+2)}];var ie,ee=!1;M==="sendrecv"||M==="sendonly"?(ee=!w.rtpReceiver,T=w.rtpReceiver||new n.RTCRtpReceiver(w.dtlsTransport,R),ee&&(B=T.track,O&&O.stream==="-"||(O?(d[O.stream]||(d[O.stream]=new n.MediaStream,Object.defineProperty(d[O.stream],"id",{get:function(){return O.stream}})),Object.defineProperty(B,"id",{get:function(){return O.track}}),ie=d[O.stream]):(d.default||(d.default=new n.MediaStream),ie=d.default)),ie&&(t(B,ie),w.associatedRemoteMediaStreams.push(ie)),l.push([B,T,ie]))):w.rtpReceiver&&w.rtpReceiver.track&&(w.associatedRemoteMediaStreams.forEach(function(U){var G=U.getTracks().find(function(Z){return Z.id===w.rtpReceiver.track.id});G&&function(Z,ne){ne.removeTrack(Z),ne.dispatchEvent(new n.MediaStreamTrackEvent("removetrack",{track:Z}))}(G,U)}),w.associatedRemoteMediaStreams=[]),w.localCapabilities=k,w.remoteCapabilities=J,w.rtpReceiver=T,w.rtcpParameters=re,w.sendEncodingParameters=N,w.recvEncodingParameters=P,u._transceive(u.transceivers[_],!1,ee)}}}),u._dtlsRole===void 0&&(u._dtlsRole=o.type==="offer"?"active":"passive"),u._remoteDescription={type:o.type,sdp:o.sdp},o.type==="offer"?u._updateSignalingState("have-remote-offer"):u._updateSignalingState("stable"),Object.keys(d).forEach(function(m){var _=d[m];if(_.getTracks().length){if(u.remoteStreams.indexOf(_)===-1){u.remoteStreams.push(_);var v=new Event("addstream");v.stream=_,n.setTimeout(function(){u._dispatchEvent("addstream",v)})}l.forEach(function(R){var C=R[0],A=R[1];_.id===R[2].id&&r(u,C,A,[_])})}}),l.forEach(function(m){m[2]||r(u,m[0],m[1],[])}),n.setTimeout(function(){u&&u.transceivers&&u.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(o){o.iceTransport&&o.iceTransport.stop(),o.dtlsTransport&&o.dtlsTransport.stop(),o.rtpSender&&o.rtpSender.stop(),o.rtpReceiver&&o.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(o){this.signalingState=o;var u=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",u)},i.prototype._maybeFireNegotiationNeeded=function(){var o=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,n.setTimeout(function(){if(o.needNegotiation){o.needNegotiation=!1;var u=new Event("negotiationneeded");o._dispatchEvent("negotiationneeded",u)}},0))},i.prototype._updateIceConnectionState=function(){var o,u={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&!l.rejected&&u[l.iceTransport.state]++}),o="new",u.failed>0?o="failed":u.checking>0?o="checking":u.disconnected>0?o="disconnected":u.new>0?o="new":u.connected>0?o="connected":u.completed>0&&(o="completed"),o!==this.iceConnectionState){this.iceConnectionState=o;var d=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",d)}},i.prototype._updateConnectionState=function(){var o,u={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&&(u[l.iceTransport.state]++,u[l.dtlsTransport.state]++)}),u.connected+=u.completed,o="new",u.failed>0?o="failed":u.connecting>0?o="connecting":u.disconnected>0?o="disconnected":u.new>0?o="new":u.connected>0&&(o="connected"),o!==this.connectionState){this.connectionState=o;var d=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",d)}},i.prototype.createOffer=function(){var o=this;if(o._isClosed)return Promise.reject(De("InvalidStateError","Can not call createOffer after close"));var u=o.transceivers.filter(function(c){return c.kind==="audio"}).length,d=o.transceivers.filter(function(c){return c.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&&(u=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(o.transceivers.forEach(function(c){c.kind==="audio"?--u<0&&(c.wantReceive=!1):c.kind==="video"&&--d<0&&(c.wantReceive=!1)});u>0||d>0;)u>0&&(o._createTransceiver("audio"),u--),d>0&&(o._createTransceiver("video"),d--);var h=X.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.transceivers.forEach(function(c,p){var f=c.track,m=c.kind,_=c.mid||X.generateIdentifier();c.mid=_,c.iceGatherer||(c.iceGatherer=o._createIceGatherer(p,o.usingBundle));var v=n.RTCRtpSender.getCapabilities(m);e<15019&&(v.codecs=v.codecs.filter(function(C){return C.name!=="rtx"})),v.codecs.forEach(function(C){C.name==="H264"&&C.parameters["level-asymmetry-allowed"]===void 0&&(C.parameters["level-asymmetry-allowed"]="1"),c.remoteCapabilities&&c.remoteCapabilities.codecs&&c.remoteCapabilities.codecs.forEach(function(A){C.name.toLowerCase()===A.name.toLowerCase()&&C.clockRate===A.clockRate&&(C.preferredPayloadType=A.payloadType)})}),v.headerExtensions.forEach(function(C){(c.remoteCapabilities&&c.remoteCapabilities.headerExtensions||[]).forEach(function(A){C.uri===A.uri&&(C.id=A.id)})});var R=c.sendEncodingParameters||[{ssrc:1001*(2*p+1)}];f&&e>=15019&&m==="video"&&!R[0].rtx&&(R[0].rtx={ssrc:R[0].ssrc+1}),c.wantReceive&&(c.rtpReceiver=new n.RTCRtpReceiver(c.dtlsTransport,m)),c.localCapabilities=v,c.sendEncodingParameters=R}),o._config.bundlePolicy!=="max-compat"&&(h+="a=group:BUNDLE "+o.transceivers.map(function(c){return c.mid}).join(" ")+`\r
- `),h+=`a=ice-options:trickle\r
- `,o.transceivers.forEach(function(c,p){h+=va(c,c.localCapabilities,"offer",c.stream,o._dtlsRole),h+=`a=rtcp-rsize\r
- `,!c.iceGatherer||o.iceGatheringState==="new"||p!==0&&o.usingBundle||(c.iceGatherer.getLocalCandidates().forEach(function(f){f.component=1,h+="a="+X.writeCandidate(f)+`\r
- `}),c.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 o=this;if(o._isClosed)return Promise.reject(De("InvalidStateError","Can not call createAnswer after close"));if(o.signalingState!=="have-remote-offer"&&o.signalingState!=="have-local-pranswer")return Promise.reject(De("InvalidStateError","Can not call createAnswer in signalingState "+o.signalingState));var u=X.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.usingBundle&&(u+="a=group:BUNDLE "+o.transceivers.map(function(h){return h.mid}).join(" ")+`\r
- `),u+=`a=ice-options:trickle\r
- `;var d=X.getMediaSections(o._remoteDescription.sdp).length;o.transceivers.forEach(function(h,a){if(!(a+1>d)){if(h.rejected)return h.kind==="application"?h.protocol==="DTLS/SCTP"?u+=`m=application 0 DTLS/SCTP 5000\r
- `:u+="m=application 0 "+h.protocol+` webrtc-datachannel\r
- `:h.kind==="audio"?u+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
- a=rtpmap:0 PCMU/8000\r
- `:h.kind==="video"&&(u+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
- a=rtpmap:120 VP8/90000\r
- `),void(u+=`c=IN IP4 0.0.0.0\r
- a=inactive\r
- a=mid:`+h.mid+`\r
- `);var c;h.stream&&(h.kind==="audio"?c=h.stream.getAudioTracks()[0]:h.kind==="video"&&(c=h.stream.getVideoTracks()[0]),c&&e>=15019&&h.kind==="video"&&!h.sendEncodingParameters[0].rtx&&(h.sendEncodingParameters[0].rtx={ssrc:h.sendEncodingParameters[0].ssrc+1}));var p=lr(h.localCapabilities,h.remoteCapabilities);!p.codecs.filter(function(f){return f.name.toLowerCase()==="rtx"}).length&&h.sendEncodingParameters[0].rtx&&delete h.sendEncodingParameters[0].rtx,u+=va(h,p,"answer",h.stream,o._dtlsRole),h.rtcpParameters&&h.rtcpParameters.reducedSize&&(u+=`a=rtcp-rsize\r
- `)}});var l=new n.RTCSessionDescription({type:"answer",sdp:u});return Promise.resolve(l)},i.prototype.addIceCandidate=function(o){var u,d=this;return o&&o.sdpMLineIndex===void 0&&!o.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(l,h){if(!d._remoteDescription)return h(De("InvalidStateError","Can not add ICE candidate without a remote description"));if(o&&o.candidate!==""){var a=o.sdpMLineIndex;if(o.sdpMid){for(var c=0;c<d.transceivers.length;c++)if(d.transceivers[c].mid===o.sdpMid){a=c;break}}var p=d.transceivers[a];if(!p)return h(De("OperationError","Can not add ICE candidate"));if(p.rejected)return l();var f=Object.keys(o.candidate).length>0?X.parseCandidate(o.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)&&!Si(p.iceTransport,f))return h(De("OperationError","Can not add ICE candidate"));var m=o.candidate.trim();m.indexOf("a=")===0&&(m=m.substr(2)),(u=X.getMediaSections(d._remoteDescription.sdp))[a]+="a="+(f.type?m:"end-of-candidates")+`\r
- `,d._remoteDescription.sdp=X.getDescription(d._remoteDescription.sdp)+u.join("")}else for(var _=0;_<d.transceivers.length&&(d.transceivers[_].rejected||(d.transceivers[_].iceTransport.addRemoteCandidate({}),(u=X.getMediaSections(d._remoteDescription.sdp))[_]+=`a=end-of-candidates\r
- `,d._remoteDescription.sdp=X.getDescription(d._remoteDescription.sdp)+u.join(""),!d.usingBundle));_++);l()})},i.prototype.getStats=function(o){if(o&&o instanceof n.MediaStreamTrack){var u=null;if(this.transceivers.forEach(function(l){l.rtpSender&&l.rtpSender.track===o?u=l.rtpSender:l.rtpReceiver&&l.rtpReceiver.track===o&&(u=l.rtpReceiver)}),!u)throw De("InvalidAccessError","Invalid selector.");return u.getStats()}var d=[];return this.transceivers.forEach(function(l){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(h){l[h]&&d.push(l[h].getStats())})}),Promise.all(d).then(function(l){var h=new Map;return l.forEach(function(a){a.forEach(function(c){h.set(c.id,c)})}),h})},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(o){var u=n[o];if(u&&u.prototype&&u.prototype.getStats){var d=u.prototype.getStats;u.prototype.getStats=function(){return d.apply(this).then(function(l){var h=new Map;return Object.keys(l).forEach(function(a){var c;l[a].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(c=l[a]).type]||c.type,h.set(a,l[a])}),h})}}});var s=["createOffer","createAnswer"];return s.forEach(function(o){var u=i.prototype[o];i.prototype[o]=function(){var d=arguments;return typeof d[0]=="function"||typeof d[1]=="function"?u.apply(this,[arguments[2]]).then(function(l){typeof d[0]=="function"&&d[0].apply(null,[l])},function(l){typeof d[1]=="function"&&d[1].apply(null,[l])}):u.apply(this,arguments)}}),(s=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(o){var u=i.prototype[o];i.prototype[o]=function(){var d=arguments;return typeof d[1]=="function"||typeof d[2]=="function"?u.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)},function(l){typeof d[2]=="function"&&d[2].apply(null,[l])}):u.apply(this,arguments)}}),["getStats"].forEach(function(o){var u=i.prototype[o];i.prototype[o]=function(){var d=arguments;return typeof d[1]=="function"?u.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)}):u.apply(this,arguments)}}),i};function Hc(n){const e=n&&n.navigator,t=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(r){return t(r).catch(i=>Promise.reject(function(s){return{name:{PermissionDeniedError:"NotAllowedError"}[s.name]||s.name,message:s.message,constraint:s.constraint,toString(){return this.name}}}(i)))}}function $c(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 ns(n,e){if(n.RTCIceGatherer&&(n.RTCIceCandidate||(n.RTCIceCandidate=function(r){return r}),n.RTCSessionDescription||(n.RTCSessionDescription=function(r){return r}),e.version<15025)){const r=Object.getOwnPropertyDescriptor(n.MediaStreamTrack.prototype,"enabled");Object.defineProperty(n.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);const s=new Event("enabled");s.enabled=i,this.dispatchEvent(s)}})}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 t=Al(n,e.version);n.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,s){let o=!1;return(i=JSON.parse(JSON.stringify(i))).filter(u=>{if(u&&(u.urls||u.url)){let d=u.urls||u.url;u.url&&!u.urls&&oi("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&&!o?(o=!0,!0):a&&!o}),delete u.url,u.urls=l?d[0]:d,!!d.length}})}(r.iceServers,e.version),uo("ICE servers after filtering:",r.iceServers)),new t(r)},n.RTCPeerConnection.prototype=t.prototype}function jc(n){n.RTCRtpSender&&!("replaceTrack"in n.RTCRtpSender.prototype)&&(n.RTCRtpSender.prototype.replaceTrack=n.RTCRtpSender.prototype.setTrack)}var Ea=Object.freeze({__proto__:null,shimPeerConnection:ns,shimReplaceTrack:jc,shimGetUserMedia:Hc,shimGetDisplayMedia:$c});function Kc(n,e){const t=n&&n.navigator,r=n&&n.MediaStreamTrack;if(t.getUserMedia=function(i,s,o){oi("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(s,o)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(o,u,d){u in o&&!(d in o)&&(o[d]=o[u],delete o[u])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(o){return typeof o=="object"&&typeof o.audio=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o.audio,"autoGainControl","mozAutoGainControl"),i(o.audio,"noiseSuppression","mozNoiseSuppression")),s(o)},r&&r.prototype.getSettings){const o=r.prototype.getSettings;r.prototype.getSettings=function(){const u=o.apply(this,arguments);return i(u,"mozAutoGainControl","autoGainControl"),i(u,"mozNoiseSuppression","noiseSuppression"),u}}if(r&&r.prototype.applyConstraints){const o=r.prototype.applyConstraints;r.prototype.applyConstraints=function(u){return this.kind==="audio"&&typeof u=="object"&&(u=JSON.parse(JSON.stringify(u)),i(u,"autoGainControl","mozAutoGainControl"),i(u,"noiseSuppression","mozNoiseSuppression")),o.apply(this,[u])}}}}function qc(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 rs(n,e){if(typeof n!="object"||!n.RTCPeerConnection&&!n.mozRTCPeerConnection)return;!n.RTCPeerConnection&&n.mozRTCPeerConnection&&(n.RTCPeerConnection=n.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const s=n.RTCPeerConnection.prototype[i],o={[i](){return arguments[0]=new(i==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};n.RTCPeerConnection.prototype[i]=o[i]});const t={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,s,o]=arguments;return r.apply(this,[i||null]).then(u=>{if(e.version<53&&!s)try{u.forEach(d=>{d.type=t[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;u.forEach((l,h)=>{u.set(h,Object.assign({},l,{type:t[l.type]||l.type}))})}return u}).then(s,o)}}function Gc(n){if(typeof n!="object"||!n.RTCPeerConnection||!n.RTCRtpSender||n.RTCRtpSender&&"getStats"in n.RTCRtpSender.prototype)return;const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r});const t=n.RTCPeerConnection.prototype.addTrack;t&&(n.RTCPeerConnection.prototype.addTrack=function(){const r=t.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 Yc(n){if(typeof n!="object"||!n.RTCPeerConnection||!n.RTCRtpSender||n.RTCRtpSender&&"getStats"in n.RTCRtpReceiver.prototype)return;const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const t=e.apply(this,[]);return t.forEach(r=>r._pc=this),t}),cn(n,"track",t=>(t.receiver._pc=t.srcElement,t)),n.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Jc(n){n.RTCPeerConnection&&!("removeStream"in n.RTCPeerConnection.prototype)&&(n.RTCPeerConnection.prototype.removeStream=function(e){oi("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Wc(n){n.DataChannel&&!n.RTCDataChannel&&(n.RTCDataChannel=n.DataChannel)}function zc(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.addTransceiver;e&&(n.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const t=arguments[1],r=t&&"sendEncodings"in t;r&&t.sendEncodings.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(r){const{sender:s}=i,o=s.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=t.sendEncodings,s.sendEncodings=t.sendEncodings,this.setParametersPromises.push(s.setParameters(o).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return i})}function Qc(n){if(typeof n!="object"||!n.RTCRtpSender)return;const e=n.RTCRtpSender.prototype.getParameters;e&&(n.RTCRtpSender.prototype.getParameters=function(){const t=e.apply(this,arguments);return"encodings"in t||(t.encodings=[].concat(this.sendEncodings||[{}])),t})}function Xc(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Zc(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.createAnswer;n.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var Ca=Object.freeze({__proto__:null,shimOnTrack:qc,shimPeerConnection:rs,shimSenderGetStats:Gc,shimReceiverGetStats:Yc,shimRemoveStream:Jc,shimRTCDataChannel:Wc,shimAddTransceiver:zc,shimGetParameters:Qc,shimCreateOffer:Xc,shimCreateAnswer:Zc,shimGetUserMedia:Kc,shimGetDisplayMedia:function(n,e){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(n.navigator.mediaDevices.getDisplayMedia=function(t){if(!t||!t.video){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return t.video===!0?t.video={mediaSource:e}:t.video.mediaSource=e,n.navigator.mediaDevices.getUserMedia(t)})}});function eu(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 e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addStream=function(t){this._localStreams||(this._localStreams=[]),this._localStreams.includes(t)||this._localStreams.push(t),t.getAudioTracks().forEach(r=>e.call(this,r,t)),t.getVideoTracks().forEach(r=>e.call(this,r,t))},n.RTCPeerConnection.prototype.addTrack=function(t,...r){return r&&r.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),e.apply(this,arguments)}}"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(t===-1)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function tu(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(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),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 s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){const t=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(t._remoteStreams||(t._remoteStreams=[]),t._remoteStreams.indexOf(i)>=0)return;t._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,t.dispatchEvent(s)})}),e.apply(t,arguments)}}}function nu(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype,t=e.createOffer,r=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,o=e.addIceCandidate;e.createOffer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=t.apply(this,[h]);return l?(a.then(d,l),Promise.resolve()):a},e.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 u=function(d,l,h){const a=i.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a};e.setLocalDescription=u,u=function(d,l,h){const a=s.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.setRemoteDescription=u,u=function(d,l,h){const a=o.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.addIceCandidate=u}function ru(n){const e=n&&n.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,r=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=i=>r(iu(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(t,r,i){e.mediaDevices.getUserMedia(t).then(r,i)}.bind(e))}function iu(n){return n&&n.video!==void 0?Object.assign({},n,{video:Mc(n.video)}):n}function su(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection;n.RTCPeerConnection=function(t,r){if(t&&t.iceServers){const i=[];for(let s=0;s<t.iceServers.length;s++){let o=t.iceServers[s];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(oi("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,i.push(o)):i.push(t.iceServers[s])}t.iceServers=i}return new e(t,r)},n.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(n.RTCPeerConnection,"generateCertificate",{get:()=>e.generateCertificate})}function ou(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 au(n){const e=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(t){if(t){t.offerToReceiveAudio!==void 0&&(t.offerToReceiveAudio=!!t.offerToReceiveAudio);const r=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");t.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"):t.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),t.offerToReceiveVideo!==void 0&&(t.offerToReceiveVideo=!!t.offerToReceiveVideo);const i=this.getTransceivers().find(s=>s.receiver.track.kind==="video");t.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"):t.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return e.apply(this,arguments)}}function cu(n){typeof n!="object"||n.AudioContext||(n.AudioContext=n.webkitAudioContext)}var ya=Object.freeze({__proto__:null,shimLocalStreamsAPI:eu,shimRemoteStreamsAPI:tu,shimCallbacksAPI:nu,shimGetUserMedia:ru,shimConstraints:iu,shimRTCIceServerUrls:su,shimTrackEventTransceiver:ou,shimCreateOfferLegacy:au,shimAudioContext:cu});function vr(n){if(!n.RTCIceCandidate||n.RTCIceCandidate&&"foundation"in n.RTCIceCandidate.prototype)return;const e=n.RTCIceCandidate;n.RTCIceCandidate=function(t){if(typeof t=="object"&&t.candidate&&t.candidate.indexOf("a=")===0&&((t=JSON.parse(JSON.stringify(t))).candidate=t.candidate.substr(2)),t.candidate&&t.candidate.length){const r=new e(t),i=X.parseCandidate(t.candidate),s=Object.assign(r,i);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new e(t)},n.RTCIceCandidate.prototype=e.prototype,cn(n,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new n.RTCIceCandidate(t.candidate),writable:"false"}),t))}function yn(n,e){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 t=function(u){if(!u||!u.sdp)return!1;const d=X.splitSections(u.sdp);return d.shift(),d.some(l=>{const h=X.parseMLine(l);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},r=function(u){const d=u.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(u){let d=65536;return e.browser==="firefox"&&(d=e.version<57?u===-1?16384:2147483637:e.version<60?e.version===57?65535:65536:2147483637),d},s=function(u,d){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const h=X.matchPrefix(u.sdp,"a=max-message-size:");return h.length>0?l=parseInt(h[0].substr(19),10):e.browser==="firefox"&&d!==-1&&(l=2147483637),l},o=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:u}=this.getConfiguration();u==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const u=r(arguments[0]),d=i(u),l=s(arguments[0],u);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 o.apply(this,arguments)}}function Tn(n){if(!n.RTCPeerConnection||!("createDataChannel"in n.RTCPeerConnection.prototype))return;function e(r,i){const s=r.send;r.send=function(){const o=arguments[0],u=o.length||o.size||o.byteLength;if(r.readyState==="open"&&i.sctp&&u>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return s.apply(r,arguments)}}const t=n.RTCPeerConnection.prototype.createDataChannel;n.RTCPeerConnection.prototype.createDataChannel=function(){const r=t.apply(this,arguments);return e(r,this),r},cn(n,"datachannel",r=>(e(r.channel,r.target),r))}function is(n){if(!n.RTCPeerConnection||"connectionState"in n.RTCPeerConnection.prototype)return;const e=n.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const r=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const o=new Event("connectionstatechange",i);s.dispatchEvent(o)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function ss(n,e){if(!n.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=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(s=>s.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 t.apply(this,arguments)}}function Rr(n,e){if(!n.RTCPeerConnection||!n.RTCPeerConnection.prototype)return;const t=n.RTCPeerConnection.prototype.addIceCandidate;t&&t.length!==0&&(n.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var Ml=Object.freeze({__proto__:null,shimRTCIceCandidate:vr,shimMaxMessageSize:yn,shimSendThrowTypeError:Tn,shimConnectionState:is,removeExtmapAllowMixed:ss,shimAddIceCandidateNullOrEmpty:Rr});const Pl=function({window:n}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const t=uo,r=function(s){const o={browser:null,version:null};if(s===void 0||!s.navigator)return o.browser="Not a browser.",o;const{navigator:u}=s;if(u.mozGetUserMedia)o.browser="firefox",o.version=En(u.userAgent,/Firefox\/(\d+)\./,1);else if(u.webkitGetUserMedia||s.isSecureContext===!1&&s.webkitRTCPeerConnection&&!s.RTCIceGatherer)o.browser="chrome",o.version=En(u.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(u.mediaDevices&&u.userAgent.match(/Edge\/(\d+).(\d+)$/))o.browser="edge",o.version=En(u.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!s.RTCPeerConnection||!u.userAgent.match(/AppleWebKit\/(\d+)\./))return o.browser="Not a supported browser.",o;o.browser="safari",o.version=En(u.userAgent,/AppleWebKit\/(\d+)\./,1),o.supportsUnifiedPlan=s.RTCRtpTransceiver&&"currentDirection"in s.RTCRtpTransceiver.prototype}return o}(n),i={browserDetails:r,commonShim:Ml,extractVersion:En,disableLog:Nl,disableWarnings:wl};switch(r.browser){case"chrome":if(!ma||!ts||!e.shimChrome)return t("Chrome shim is not included in this adapter release."),i;if(r.version===null)return t("Chrome shim can not determine version, not shimming."),i;t("adapter.js shimming chrome."),i.browserShim=ma,Rr(n,r),Pc(n,r),Lc(n),ts(n,r),kc(n),Bc(n,r),Uc(n),Dc(n),xc(n),Fc(n,r),vr(n),is(n),yn(n,r),Tn(n),ss(n,r);break;case"firefox":if(!Ca||!rs||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=Ca,Rr(n,r),Kc(n,r),rs(n,r),qc(n),Jc(n),Gc(n),Yc(n),Wc(n),zc(n),Qc(n),Xc(n),Zc(n),vr(n),is(n),yn(n,r),Tn(n);break;case"edge":if(!Ea||!ns||!e.shimEdge)return t("MS edge shim is not included in this adapter release."),i;t("adapter.js shimming edge."),i.browserShim=Ea,Hc(n),$c(n),ns(n,r),jc(n),yn(n,r),Tn(n);break;case"safari":if(!ya||!e.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=ya,Rr(n,r),su(n),au(n),nu(n),eu(n),tu(n),ou(n),ru(n),cu(n),vr(n),yn(n,r),Tn(n),ss(n,r);break;default:t("Unsupported browser!")}return i}({window:typeof window=="undefined"?void 0:window});var ft,Ce,me;(function(n){n.FPS_10="FPS_10",n.FPS_15="FPS_15",n.FPS_24="FPS_24",n.FPS_30="FPS_30"})(ft||(ft={})),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"}(Ce||(Ce={})),function(n){n[n.AUDIO_ONLY=0]="AUDIO_ONLY",n[n.VIDEO_ONLY=1]="VIDEO_ONLY",n[n.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(me||(me={}));const Ta={[Ce.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Ce.W176_H144]:{width:176,height:144,maxBitrate:160,minBitrate:80},[Ce.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Ce.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Ce.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Ce.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Ce.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Ce.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Ce.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Ce.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Ce.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Ce.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Ce.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}},uu=(n,e)=>{const t=n*e;let r=Number.MAX_VALUE,i=null;for(const s in Ta){const o=Ta[s],u=Math.abs(o.width*o.height-t);u<r&&(i=o,r=u)}return i},Sa={10:1,15:1,24:1.5,30:1.5},du=n=>{let e=Number.MAX_VALUE,t=1;for(const r in Sa){const i=Math.abs(n-parseInt(r));i<e&&(e=i,t=Sa[r])}return t},lo={getCameras:()=>F(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="videoinput")}),getMicrophones:()=>F(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audioinput")}),getSpeakers:()=>F(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audiooutput")})};class ho extends jn{constructor(e,t,r,i,s){super(),this._tag=e,this._userId=t,this._kind=r,this._isLocalTrack=i,this._roomId=s,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 e;return((e=this._msTrack)===null||e===void 0?void 0:e.readyState)==="live"}__innerSetMediaStreamTrack(e){this._msTrack=e,this._setLocalMuted(this._localMuted);const t=this._msStream=this._msStream||new MediaStream,r=t.getTracks()[0];r&&t.removeTrack(r),e?t.addTrack(e):this._element&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e}mute(){b.info(`set ${this._id} enabled: false`),this._setLocalMuted(!0)}unmute(){b.info(`set ${this._id} enabled: true`),this._setLocalMuted(!1)}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}play(e,t){return F(this,void 0,void 0,function*(){if(!this._msTrack)return b.warn(`the track is not ready to play -> id: ${this._id}`),{code:I.TRACK_NOT_READY};if(this._msTrack.readyState==="ended"&&b.warn(`the track's readyState is 'ended' -> id: ${this._id}`),t==null?void 0:t.volume){if(!Te(t==null?void 0:t.volume))return b.error(`${t==null?void 0:t.volume} is not a number, the valid range of options.volume is 0-100`),{code:I.PARAMS_ERROR};(t==null?void 0:t.volume)<0&&(t.volume=0,b.warn("the valid range of options.volume is 0-100, the value of volume has been set 0")),(t==null?void 0:t.volume)>100&&(t.volume=100,b.warn("the valid range of options.volume is 0-100, the value of volume has been set 100"))}if((t==null?void 0:t.audioDeviceId)&&!(yield lo.getSpeakers()).map(i=>i.deviceId).includes(t.audioDeviceId))return b.error(`the options.audioDeviceId is invalid --> ${t.audioDeviceId}`),{code:I.PARAMS_ERROR};const r=this.isVideoTrack();if(r&&(!e||!(e instanceof HTMLVideoElement)))return b.error(`the video track need an <video> to play -> id: ${this._id}`),{code:I.VIDEO_TRACK_MISS_MEDIA_ELEMENT};this._element=r?e:this._element||new Audio,this._localMuted&&this._setLocalMuted(!1),this._element.srcObject&&this._element.srcObject===this._msStream||this._element.pause(),this._element.onloadstart=i=>{var s;b.debug(`HTMLMediaElement onloadstart -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.ondurationchange=i=>{var s;b.debug(`HTMLMediaElement ondurationchange -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onloadedmetadata=i=>{var s;b.debug(`HTMLMediaElement onloadedmetadata -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onloadeddata=i=>{var s;b.debug(`HTMLMediaElement onloadeddata -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onabort=i=>{var s;b.info(`HTMLMediaElement onabort -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.oncanplay=i=>{var s;b.info(`HTMLMediaElement oncanplay -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onvolumechange=i=>{var s;const o=Math.floor(100*((s=i.target)===null||s===void 0?void 0:s.volume));b.info(`HTMLMediaElement onvolumechange -> volume: ${o}, trackId: ${this._id}`)},this._element.srcObject=this._msStream,this._element.autoplay=!0,r&&(this._element.playsInline=!0,this._element.x5PlaysInline=!0,this._element.webkitPlaysInline=!0),r||!(t==null?void 0:t.volume)&&(t==null?void 0:t.volume)!==0||(this._element.volume=(t==null?void 0:t.volume)/100);try{(t==null?void 0:t.audioDeviceId)&&!r?yield this._element.setSinkId(t.audioDeviceId):this._element.play()}catch(i){return i.message==="No permission to use requested device"?(b.error(`setSinkId failed -> ${i.message}`),{code:I.NO_PERMISSION_TO_USE_REQUESTED_DEVICE}):(b.error(i),{code:I.TRACK_PLAY_ERROR})}return{code:I.SUCCESS}})}__innerDestroy(){this.__innerSetMediaStreamTrack(void 0)}__releaseMediaElement(){this._element&&(this._element.remove(),this._element.srcObject=null)}}class pe extends ho{constructor(e,t,r,i){super(e,t,r,!0),this._isPublished=!1,this.__innerSetMediaStreamTrack(i),i.onended=()=>{i.onended=null,this.emit(pe.EVENT_LOCAL_TRACK_END,this),this.removeAll(pe.EVENT_LOCAL_TRACK_END)}}_setLocalMuted(e){const t=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,t&&this.emit(pe.__INNER_EVENT_MUTED_CHANGE__,this)}__innerSetPublished(e){this._isPublished=e}isPublished(){return this._isPublished}destroy(){var e;b.info(`track is destroyed -> trackId: ${this.getTrackId()}`),(e=this._msTrack)===null||e===void 0||e.stop(),super.__innerDestroy(),this.isAudioTrack()&&super.__releaseMediaElement(),this.emit(pe.__INNER_EVENT_DESTROY__,this)}setBitrate(e=0,t=0,r=0){!Te(e)||!Te(t)||!Te(r)||e<=0||t<=0||e<t?b.error("setBitrate params error ->"):this._bitrateInfo={max:e,min:t,start:r}}getBitrate(){var e,t;const{min:r,max:i}=this._msTrack?xl(this._msTrack):{min:0,max:0};return{min:((e=this._bitrateInfo)===null||e===void 0?void 0:e.min)||r,max:((t=this._bitrateInfo)===null||t===void 0?void 0:t.max)||i}}}pe.EVENT_LOCAL_TRACK_END="local-track-end",pe.__INNER_EVENT_MUTED_CHANGE__="inner-muted-change",pe.__INNER_EVENT_DESTROY__="inner-destroy";class os extends pe{constructor(e,t,r){super(e,t,"audio",r)}setBitrate(e,t,r){b.warn("`setBitrate` invalid for audio track")}getBitrate(){return{start:32,max:32,min:32}}}class tn extends pe{constructor(e,t,r,i=!1){super(e,t,"video",r),this._isTiny=i}__isTiny(){return this._isTiny}getStreamId(){const e=super.getStreamId();return this._isTiny?`${e}_tiny`:e}getTrackId(){const e=super.getTrackId();return this._isTiny?`${e}_tiny`:e}}class nn extends pe{constructor(e,t,r,i,s){super(e,t,r,i),this._resource=s,nn.__innerSetMapping(this.getTrackId(),s)}static __innerSetMapping(e,t){const r=this._mapping.get(t)||[];r.push(e),this._mapping.set(t,r)}static __innerRemoveMapping(e,t){var r,i;const s=(r=this._mapping.get(t))===null||r===void 0?void 0:r.filter(o=>o!==e);s&&s.length>0?this._mapping.set(t,s):(this._mapping.delete(t),t.pause(),t.src="",(i=t.parentNode)===null||i===void 0||i.removeChild(t))}destroy(){this.isAudioTrack()&&this.mute(),nn.__innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}nn._mapping=new Map;class Ll extends nn{constructor(e,t,r,i){super(e,t,"video",r,i)}}class kl extends nn{constructor(e,t,r,i){super(e,t,"audio",r,i)}_setLocalMuted(e){this._resource&&(this._resource.muted=e),super._setLocalMuted(e)}play(){return this._setLocalMuted(!1),Promise.resolve({code:I.SUCCESS})}}class Ia extends os{}class ba extends tn{}class Ul extends tn{}class xe extends ho{constructor(e,t,r,i){super(e,t,r,!1,i),this._isSubscribed=!1}__innerSetRemoteMuted(e){this._remoteMuted=e}__innerSetSubscribed(e){this._isSubscribed=e}isSubscribed(){return this._isSubscribed}}class Tt extends xe{constructor(e,t,r){super(e,t,"audio",r)}}class St extends xe{constructor(e,t,r){super(e,t,"video",r)}}const hr=(n,e)=>({name:n,content:JSON.stringify({uris:e,ignore:!0})}),Mt=n=>JSON.stringify(n),Ct=n=>/^[a-zA-Z\d-=]+$/g.test(n),Dl=location.protocol!=="http:"||["localhost","127.0.0.1"].includes(location.hostname),Ii=n=>{if(n===void 0)return 0;if(Te(n))return n;const e=n;return e.exact||e.ideal||e.max||0},po=n=>{const e=n.getConstraints();return{width:Ii(e.width),height:Ii(e.height),frameRate:Ii(e.frameRate)}},xl=n=>{const{width:e,height:t,frameRate:r}=po(n),i=uu(e,t),s=du(r);return{min:i.minBitrate*s,max:i.maxBitrate*s}},he=n=>[n.msid,n.mediaType].join("_"),$e=n=>{const e=n.split("_");return{mediaType:parseInt(e.pop()),tag:e.pop(),userId:e.join("_")}},bi=(n,e)=>[n,e].join("_"),pr=n=>n.map(e=>Object.assign({},e)),Er=(n,e,t=!1)=>{n=n.slice();const r=[],i=[],s=[];return e.forEach(o=>{const u=he(o);let d=n.findIndex(h=>he(h)===u);if(t&&(d=n.findIndex(h=>h.uri===o.uri)),d===-1)return void r.push(o);const l=n[d];l.uri!==o.uri?r.push(o):l.state!==o.state&&s.push(o),n.splice(d,1)}),i.push(...n),{publishedList:r,unpublishedList:i,modifiedList:s}},Vl=()=>{let n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return(e==="x"?t:3&t|8).toString(16)});return n=n.replace(/-/g,"")+"0",n=parseInt(n,16),n=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1;let i=+e;const s=[];do{const o=i%r;i=(i-o)/r,s.unshift(t[o])}while(i);return s.join("")})(n),n.length>22&&(n=n.slice(0,22)),n},gt=n=>{const[e,t]=n.split("_").map(r=>parseInt(r.replace(/[^\d]/g,"")));return{width:e,height:t}},Qt=n=>!!Ce[n],as=n=>!!ft[n],mt=n=>parseInt(n.replace("FPS_","")),st=(()=>{const{browser:n,version:e,supportsUnifiedPlan:t}=Pl.browserDetails;return{browser:n,version:e,supportsUnifiedPlan:t!==!1}})();function lu(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function hu(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const cs=n=>Object.prototype.toString.call(n)==="[object Null]",Cr=n=>n.type===1,us=n=>{const e={},t=Object.keys(n.users);return t.length&&t.forEach(r=>{const i=[],s=n.users[r];if(s.uris)try{i.push(...JSON.parse(s.uris))}catch{b.warn(`invalid user data -> userId: ${r}, userData: ${s}`)}e[r]=i}),e};var oe,Vr;(function(n){n.PUBLISH="RCRTC:PublishResource",n.UNPUBLISH="RCRTC:UnpublishResource",n.MODIFY="RCRTC:ModifyResource",n.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",n.STATE="RCRTC:state",n.ROOM_NOTIFY="RCRTC:RoomNtf",n.USER_NOTIFY="RCRTC:UserNtf",n.KICK="RCRTC:kick",n.PK_INVITE="RCRTC:invite",n.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",n.PK_CANCEL_INVITE="RCRTC:cancelInvite",n.PK_INVITE_ANSWER="RCRTC:answerInvite",n.PK_END="RCRTC:endInvite",n.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline"})(oe||(oe={})),function(n){n.SUCCESS="Success",n.FAIL="Fail"}(Vr||(Vr={}));class Bl{constructor(e,t,r,i=1e4){this._roomId=e,this._roomMode=t,this._context=r,this._gap=i,this._latestTimestamp=Date.now(),this._timer=null}start(){return F(this,void 0,void 0,function*(){this._timer||(this._timer=setInterval(this._loop.bind(this),this._gap))})}_loop(){var e,t,r;return F(this,void 0,void 0,function*(){const i=yield new Promise(o=>{this._context.rtcPing(this._roomId,this._roomMode).then(o).catch(u=>{b.error(`rtcping receive unknown error -> ${u}`),o(S.UNKNOWN)}),setTimeout(o,1e4,S.TIMEOUT)}),s=Date.now();if(i===S.SUCCESS)return this._latestTimestamp=s,void((e=this.onPingResult)===null||e===void 0||e.call(this,Vr.SUCCESS));(t=this.onPingResult)===null||t===void 0||t.call(this,Vr.FAIL),b.warn(`rtcping failed -> code: ${i}`),(i===40003||s-this._latestTimestamp>6e4)&&(this.stop(),(r=this.onFailed)===null||r===void 0||r.call(this,i===40003))})}stop(){this._timer&&(clearInterval(this._timer),this._timer=null)}}var rt;(function(n){n[n.NORMAL=1]="NORMAL",n[n.TINY=2]="TINY"})(rt||(rt={}));const Oa=(n,e)=>Math.round(8*e/n),Na=(n,e=2)=>{const t=10**e;return Math.round(n*t)/t},It=(n,e=2)=>{n>1&&(n/=32767);const t=10**e;return Math.ceil(n*t)},fr=(n,e,t,r)=>{if(e===0)return 0;if(!t||!r)return Na(n/e,3);const i=e-r;if(i===0)return 0;const s=n-t;return s<0||i<0?0:Na(s/i,3)},pu=n=>{const{jitter:e,rtt:t,packetsLostRate:r}=n;return!cs(e)||!cs(t)||r!==0};class fo{constructor(e,t){this._rtcPeerConn=e,this._sdpSemantics=t,this._latestPacketsSent={},this._latestBytesSent={},this._latestBytesRecv={},this._latestPacketsRecv={}}updateBytesSent(e,t,r){let i,s;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:o,timestamp:u}=this._latestBytesSent[e];i=t-o,s=r-u,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else i=t,s=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return Oa(s,i)}updateBytesRecv(e,t,r){let i,s;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:o,timestamp:u}=this._latestBytesRecv[e];i=t-o,s=r-u,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else i=t,s=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return Oa(s,i)}updateSenderPacketsLost(e,t,r){let i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:s,packetsSent:o}=this._latestPacketsSent[e];i=fr(t,r,s,o),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=s===t?o:r}else i=fr(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return i}updateReceiverPacketsLost(e,t,r){let i;if(this._latestPacketsRecv[e]){const{packetsLost:s,packetsRecv:o}=this._latestPacketsRecv[e];i=fr(t,r+t,s,o+s)}else i=fr(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},i}clearLatestpacketsSent(e){e.forEach(t=>{if(parseInt(t.split("_").pop())===me.VIDEO_ONLY){const r=`${t}_tiny`;delete this._latestPacketsSent[r],delete this._latestBytesSent[r]}delete this._latestPacketsSent[t],delete this._latestBytesSent[t]})}clearLatestPacketsRecv(e){e.forEach(t=>{delete this._latestPacketsRecv[t],delete this._latestBytesRecv[t]})}parseRTCStatsReport(e){const t=e.keys(),r={};let i=t.next();for(;!i.done;){const s=i.value,o=e.get(s);/^RTCCodec_/.test(s)||(r[s]=o),i=t.next()}return r}formatRCRTCStateReport(e){return{senders:[],receivers:[]}}getAudioLevelList(e){return[]}getResourceIdByParseSdp(e){var t,r;const i=e.ssrc,s=e.kind||e.mediaType,o=(t=this._rtcPeerConn.currentLocalDescription)===null||t===void 0?void 0:t.sdp,u=(r=this._rtcPeerConn.currentRemoteDescription)===null||r===void 0?void 0:r.sdp;let d;d=this._sdpSemantics==="unified-plan"?new RegExp("a=msid:(.*?) "):new RegExp(`a=ssrc:${i} msid:(.*?) `);const l=o==null?void 0:o.split(`\r
- m=`),h=l==null?void 0:l.filter(_=>_.includes(`a=ssrc:${i}`))[0],a=h==null?void 0:h.match(d);let c=a?a[1]:"";if(c)return`${c}_${s==="video"?1:0}`;const p=u==null?void 0:u.split(`\r
- m=`),f=p==null?void 0:p.filter(_=>_.includes(`a=ssrc:${i}`))[0],m=f==null?void 0:f.match(d);return c=m?m[1]:"",`${c}_${s==="video"?1:0}`}isValidSender(e){var t;const r=(t=this._rtcPeerConn.currentLocalDescription)===null||t===void 0?void 0:t.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
- m=`).some(s=>s.includes(i)&&s.includes("a=inactive")))}isValidReceiver(e){var t;const r=(t=this._rtcPeerConn.currentRemoteDescription)===null||t===void 0?void 0:t.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
- m=`).some(s=>s.includes(i)&&s.includes("a=inactive")))}}class Fl extends fo{formatRCRTCStateReport(e){const t={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);t.timestamp=r;const i=Object.keys(e);let s=0,o=0;i.filter(l=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(h))return;const{id:a,kind:c,transportId:p,mediaSourceId:f,remoteId:m,packetsSent:_,bytesSent:v,trackId:R,encoderImplementation:C,pliCount:A,nackCount:M,firCount:O}=h;if(!R)return;let{framesPerSecond:y,frameWidth:w,frameHeight:$}=h;c!=="video"||w||$||y||(w=e[R].frameWidth,$=e[R].frameHeight,y=f?e[f].framesPerSecond:null);const Y=e[m];let E=null,T=null,N=0;Y&&(E=Y.jitter,T=Y.roundTripTime,N=Y.packetsLost),s+=N;const P=this.getResourceIdByParseSdp(h),k=f?e[f].audioLevel:e[R].audioLevel;let B=null;!this._latestPacketsSent[P]&&(this._latestPacketsSent[P]={}),Y?B=this.updateSenderPacketsLost(P,N,_):this._latestPacketsSent[P].crtPacketsSent=_;let H=this.updateBytesSent(P,v,r);H<0&&(H=0),o+=H,t.senders.push({id:a,trackId:P,kind:c,packetsLostRate:B,remoteResource:!1,audioLevel:k||k===0?It(k):null,frameWidth:w,frameHeight:$,frameRate:y,bitrate:H,jitter:E&&Math.round(1e3*E),rtt:T,encoderImplementation:C,pliCount:A,nackCount:M,googFirsSent:-1,samplingRate:-1,googRenderDelayMs:-1,trackState:-1})}),i.filter(l=>/RTCRemoteInboundRtp(Video|Audio)Stream_/.test(l)).forEach(l=>{const{localId:h,jitter:a,roundTripTime:c,packetsLost:p}=e[l],f=t.senders.filter(m=>m.id===h)[0];if(f&&!pu(f)){const m=this.getResourceIdByParseSdp(e[f.id]);f.jitter=Math.round(1e3*a),f.rtt=c;const _=this._latestPacketsSent[m].crtPacketsSent;f.packetsLostRate=this.updateSenderPacketsLost(m,p,_)}});let u=0;i.filter(l=>/^RTCInboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(h))return;const{trackId:a,packetsLost:c,packetsReceived:p,jitter:f,bytesReceived:m,framesPerSecond:_,kind:v,codecImplementationName:R,nackCount:C,pliCount:A}=h;if(!a)return;let{frameWidth:M,frameHeight:O,audioLevel:y}=h;v==="video"?M||O||(M=e[a].frameWidth,O=e[a].frameHeight):y||(y=e[a].audioLevel),s+=c;const w=this.getResourceIdByParseSdp(h),$=this.updateReceiverPacketsLost(w,c,p);let Y=this.updateBytesRecv(w,m,r);Y<0&&(Y=0),u+=Y,t.receivers.push({trackId:w,kind:v,packetsLostRate:$,remoteResource:!0,audioLevel:y||y===0?It(y):null,frameWidth:M,frameHeight:O,frameRate:_,bitrate:Y,jitter:f?Math.round(1e3*f):0,codecImplementationName:R,nackCount:C,pliCount:A,rtt:null,samplingRate:-1,googFirsReceived:-1,googRenderDelayMs:-1,trackState:-1})});const d=i.filter(l=>/^RTCTransport_/.test(l))[0];if(d){const l=e[d],{selectedCandidatePairId:h}=l;if(h){const a=e[h],{availableOutgoingBitrate:c,availableIncomingBitrate:p,currentRoundTripTime:f,localCandidateId:m,remoteCandidateId:_}=a,v=e[m],{ip:R,port:C,networkType:A}=v,M=e[_],{ip:O,port:y,protocol:w}=M;t.iceCandidatePair={IP:R,port:C,networkType:A,remoteIP:O,remotePort:y,protocol:w,bitrateRecv:u,bitrateSend:o,rtt:1e3*f,availableOutgoingBitrate:c,availableIncomingBitrate:p,totalPacketsLost:s},t.receivers.forEach($=>{$.rtt=f})}}return t}getAudioLevelList(e){const t=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTPAudioStream_/.test(i)).forEach(i=>{var s;const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(o))return;const{mediaSourceId:u,trackId:d}=o,l=this.getResourceIdByParseSdp(o),h=u&&e[u]?e[u].audioLevel:((s=e[d])===null||s===void 0?void 0:s.audioLevel)||null;t.push({trackId:l,audioLevel:h||h===0?It(h):null})}),r.filter(i=>/^RTCInboundRTPAudioStream_/.test(i)).forEach(i=>{const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(s))return;const{trackId:o}=s,u=s.audioLevel||e[o].audioLevel,d=this.getResourceIdByParseSdp(s);t.push({trackId:d,audioLevel:u||u===0?It(u):null})}),t}}class Hl extends fo{formatRCRTCStateReport(e){const t=+new Date,r={senders:[],receivers:[],timestamp:t};let i=0,s=0,o=0;for(const u in e){const d=e[u],l=d.type;if(l==="outbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(d))continue;const{id:h,kind:a,bytesSent:c,packetsSent:p,bitrateMean:f,framerateMean:m,nackCount:_,pliCount:v,remoteId:R}=d,{jitter:C,roundTripTime:A,packetsLost:M}=R?e[R]:{jitter:null,roundTripTime:null,packetsLost:0},O=this.getResourceIdByParseSdp(d);i+=M;let y=null;!this._latestPacketsSent[O]&&(this._latestPacketsSent[O]={}),R?y=this.updateSenderPacketsLost(O,M,p):this._latestPacketsSent[O].crtPacketsSent=p;let w=0;a==="video"?f&&(w=Math.floor(f/1e3)):w=this.updateBytesSent(O,c,t),w<0&&(w=0),s+=w,r.senders.push({trackId:O,kind:a,packetsLostRate:y,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(m),bitrate:w,jitter:C?Math.round(1e3*C):null,rtt:A,encoderImplementation:null,pliCount:v,nackCount:_,googFirsSent:-1,samplingRate:-1,googRenderDelayMs:-1,trackState:-1})}if(l==="remote-inbound-rtp"){const{localId:h}=d,a=this.getResourceIdByParseSdp(e[h]),c=r.senders.filter(p=>p.trackId===a)[0];c&&pu(c)&&(c.jitter=Math.round(1e3*d.jitter),c.rtt=d.rtt,c.packetsLostRate=this.updateSenderPacketsLost(a,d.packetsLost,this._latestPacketsSent[a].crtPacketsSent))}if(l==="inbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(d))continue;const{id:h,packetsLost:a,bytesReceived:c,packetsReceived:p,jitter:f,framerateMean:m,kind:_,bitrateMean:v,nackCount:R,pliCount:C}=d,A=this.getResourceIdByParseSdp(d);i+=a;const M=this.updateReceiverPacketsLost(A,a,p);let O=0;_==="video"?v&&(O=Math.floor(v/1e3)):O=this.updateBytesRecv(A,c,t),O<0&&(O=0),o+=O,r.receivers.push({trackId:A,kind:_,packetsLostRate:M,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(m),bitrate:O,jitter:f?Math.round(1e3*f):null,codecImplementationName:null,nackCount:R,pliCount:C,rtt:null,samplingRate:-1,googFirsReceived:-1,googRenderDelayMs:-1,trackState:-1})}if(l==="candidate-pair"&&d.state==="succeeded"){const h=e[d.localCandidateId],{address:a,port:c}=h,p=e[d.remoteCandidateId],{address:f,port:m,protocol:_}=p;r.iceCandidatePair={IP:a,port:c,networkType:null,remoteIP:f,remotePort:m,protocol:_,bitrateRecv:o,bitrateSend:s,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:i}}}return r.iceCandidatePair&&(r.iceCandidatePair.bitrateSend=s),r.iceCandidatePair&&(r.iceCandidatePair.bitrateRecv=o),r}getAudioLevelList(e){const t=[];for(const r in e){const i=e[r],s=i.type;if(s==="outbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(i))continue;const{kind:o}=i;if(o==="video")continue;const u=this.getResourceIdByParseSdp(i);t.push({trackId:u,audioLevel:null})}if(s==="inbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(i))continue;const{kind:o}=i;if(o==="video")continue;const u=this.getResourceIdByParseSdp(i);t.push({trackId:u,audioLevel:null})}}return t}}class $l extends fo{formatRCRTCStateReport(e){const t={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);t.timestamp=r;const i=Object.keys(e);let s=0,o=0;i.filter(l=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(h))return;const a=this.getResourceIdByParseSdp(h),{mediaType:c,transportId:p,remoteId:f,packetsSent:m,bytesSent:_,trackId:v,encoderImplementation:R,pliCount:C,nackCount:A,firCount:M}=h;if(!v)return;const{audioLevel:O,frameHeight:y,frameWidth:w}=e[v];let $=this.updateBytesSent(a,_,r);$<0&&($=0),o+=$,t.senders.push({trackId:a,kind:c,packetsLostRate:null,remoteResource:!1,audioLevel:O||O===0?It(O):null,frameWidth:w,frameHeight:y,frameRate:null,bitrate:$,jitter:null,rtt:null,encoderImplementation:R,pliCount:C,nackCount:A,googFirsSent:-1,samplingRate:-1,googRenderDelayMs:-1,trackState:-1})});let u=0;i.filter(l=>/^RTCInboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(h))return;const{trackId:a,packetsLost:c,packetsReceived:p,jitter:f,bytesReceived:m,mediaType:_,nackCount:v,pliCount:R}=h,C=this.getResourceIdByParseSdp(h);if(!a)return;const{frameHeight:A,frameWidth:M,audioLevel:O}=e[a];s+=c;const y=this.updateReceiverPacketsLost(C,c,p);let w=this.updateBytesRecv(C,m,r);w<0&&(w=0),u+=w,t.receivers.push({trackId:C,kind:_,packetsLostRate:y,remoteResource:!0,audioLevel:O||O===0?It(O):null,frameWidth:M,frameHeight:A,frameRate:null,bitrate:w,jitter:f,codecImplementationName:null,nackCount:v,pliCount:R,rtt:null,samplingRate:-1,googFirsReceived:-1,googRenderDelayMs:-1,trackState:-1})});const d=i.filter(l=>/^RTCTransport_/.test(l))[0];if(d){const l=e[d],{selectedCandidatePairId:h}=l;if(h){const a=e[h],{availableOutgoingBitrate:c,availableIncomingBitrate:p,currentRoundTripTime:f,localCandidateId:m,remoteCandidateId:_}=a,v=e[m],{address:R,port:C}=v,A=e[_],{address:M,port:O,protocol:y}=A;t.iceCandidatePair={IP:R||null,port:C,networkType:null,remoteIP:M,remotePort:O,protocol:y,bitrateRecv:u,bitrateSend:o,rtt:1e3*f,availableOutgoingBitrate:c,availableIncomingBitrate:p,totalPacketsLost:s},t.receivers.forEach(w=>{w.rtt=f})}}return t}getAudioLevelList(e){const t=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(s))return;const{trackId:o,mediaType:u}=s;if(u==="video")return;const d=this.getResourceIdByParseSdp(s),l=e[o];t.push({trackId:d,audioLevel:l||l===0?It(l):null})}),r.filter(i=>/^RTCInboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(s))return;const{trackId:o,mediaType:u}=s;if(!o||u==="video")return;const{audioLevel:d}=e[o],l=this.getResourceIdByParseSdp(s);t.push({trackId:l,audioLevel:d||d===0?It(d):null})}),t}}class un{constructor(e){this._peer=e,this._outboundStreams={}}static setSdpSemantics(e){const{browser:t,version:r,supportsUnifiedPlan:i}=st;i?/chrome/i.test(t)?this._sdpSemantics=r>92?"unified-plan":r<72?"plan-b":e:/firefox/i.test(t)?this._sdpSemantics="unified-plan":/safari/i.test(t)?this._sdpSemantics=r<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan":this._sdpSemantics="plan-b"}static getSdpSemantics(){return un._sdpSemantics}getOutboundVideoInfo(){const e=[];for(const t in this._outboundStreams){const r=this._outboundStreams[t].getVideoTracks()[0];if(!r)continue;const i=/_tiny$/.test(t),{width:s,height:o}=po(r);e.push({trackId:r.id,simulcast:i?rt.TINY:rt.NORMAL,resolution:`${s}x${o}`})}return e}setRemoteAnswer(e){return F(this,void 0,void 0,function*(){e=e.replace(/\s+\r\n/g,`\r
- `);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(t){return b.error(t),I.SET_REMOTE_DESCRIPTION_FAILED}return I.SUCCESS})}getStatParsr(e,t){return/chrome/i.test(st.browser)?new Fl(e,t):/Firefox/i.test(st.browser)?new Hl(e,t):/Safari/i.test(st.browser)?new $l(e,t):null}}class jl extends un{constructor(){super(...arguments),this.senders={},this._localTracks=[]}addLocalTrack(e){this._localTracks.includes(e)||this._localTracks.push(e);const t=e.getStreamId(),r=e.__innerGetMediaStreamTrack(),i=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);i.getTracks().forEach(u=>{u.kind===r.kind&&i.removeTrack(u)}),i.addTrack(r);const s=e.getTrackId(),o=this.senders[s];o?o.replaceTrack(r):this.senders[s]=this._peer.addTrack(r,i)}removeLocalTrack(e){const t=this._localTracks.findIndex(s=>s===e);t>=0&&this._localTracks.splice(t,1);const r=e.getTrackId(),i=this.senders[r];i&&(i.replaceTrack(null),this._peer.removeTrack(i),delete this.senders[r])}updateSubRemoteTracks(e){}updateRecvTransceiverMap(e,t){}setBitrate(e,t,r){this._maxBitrate=e,this._minBitrate=t,this._startBitrate=r||.7*e}createOffer(e){return F(this,void 0,void 0,function*(){const t=yield this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});for(const r in this._outboundStreams){const i=this._outboundStreams[r].id;t.sdp=t.sdp.replace(new RegExp(i,"g"),r)}return yield this._peer.setLocalDescription(t),{type:"offer",semantics:"plan-b",sdp:t.sdp}})}setRemoteAnswer(e){let t=0,r=0;this._localTracks.forEach(u=>{const{min:d,max:l}=u.getBitrate();r+=d,t+=l}),t=this._maxBitrate&&this._maxBitrate>0?Math.min(t,this._maxBitrate):t,r=this._minBitrate&&this._minBitrate>0?Math.max(r,this._minBitrate):r;const i=this._startBitrate||Math.round(.7*t),s=`b=AS:${t}`;e=e.replace(/[\r\n]+m=video[^\r\n]+/,u=>`${u}\r
- ${s}`);const o=[`;x-google-min-bitrate=${r}`,`;x-google-max-bitrate=${t}`,`;x-google-start-bitrate=${i}`].join("");return e=e.replace(/[\r\n]+[^\r\n]+profile-level-id[^\r\n]+/g,u=>u+o),super.setRemoteAnswer(e)}}class Kl extends un{constructor(){super(...arguments),this._sendTransceiver={},this._localTracks={},this._recvAudio=[],this._recvVideo=[],this._recvTransceiver={},this._subedTracks=[]}setBitrate(e,t,r){b.warn("the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}addLocalTrack(e){const t=e.getTrackId(),r=e.getStreamId(),i=e.__innerGetMediaStreamTrack();this._localTracks[t]=e;const s=this._outboundStreams[r]||(this._outboundStreams[r]=new MediaStream);s.getTracks().forEach(u=>{u.kind===i.kind&&s.removeTrack(u)}),s.addTrack(i);const o=this._sendTransceiver[t];o?(o.sender.replaceTrack(i),o.direction="sendonly"):this._sendTransceiver[t]=this._peer.addTransceiver(i,{direction:"sendonly",streams:[s]})}removeLocalTrack(e){const t=e.getTrackId(),r=e.getStreamId();e.__innerGetMediaStreamTrack(),delete this._localTracks[t];const i=this._sendTransceiver[t];if(!i)return;i.direction="inactive",this._peer.removeTrack(i.sender),i.sender.replaceTrack(null);const s=this._outboundStreams[r];(e.isAudioTrack()?s.getAudioTracks():s.getVideoTracks()).forEach(l=>s.removeTrack(l));const o=this._sendTransceiver[`${t}_tiny`];if(!o||o.direction==="inactive")return;o.direction="inactive";const u=o.sender,d=u.track;this._peer.removeTrack(u),u.replaceTrack(null),this._outboundStreams[`${r}_tiny`].removeTrack(d),d.stop()}updateRecvTransceiverMap(e,t){const{mediaType:r}=$e(e);this._recvTransceiver[e]=t;const i=r===me.AUDIO_ONLY?this._recvAudio:this._recvVideo,s=i.findIndex(o=>o===t);s>=0&&i.splice(s,1)}updateSubRemoteTracks(e){const t=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(let s=t.length-1;s>=0;s-=1){const o=t[s],u=r.findIndex(d=>d===o);u>=0&&(t.splice(s,1),r.splice(u,1))}r.length&&r.forEach(s=>{const o=s.getTrackId();s.__innerSetMediaStreamTrack(void 0);const u=this._recvTransceiver[o];u&&(u.direction="inactive")});const i={audio:0,video:0};t.length&&t.forEach(s=>{const o=s.isAudioTrack()?"audio":"video",u=this._recvTransceiver[s.getTrackId()];u?u.direction="recvonly":i[o]+=1});for(let s=this._recvAudio.length;s<i.audio;s+=1)this._recvAudio.push(this._peer.addTransceiver("audio",{direction:"recvonly"}));for(let s=this._recvVideo.length;s<i.video;s+=1)this._recvVideo.push(this._peer.addTransceiver("video",{direction:"recvonly"}))}createOffer(e){return F(this,void 0,void 0,function*(){const t=yield this._peer.createOffer({iceRestart:e});let r=t.sdp;for(const i in this._outboundStreams){const s=this._outboundStreams[i].id;r=r.replace(new RegExp(s,"g"),i)}return r=(i=>i.split(/\r\n(?=m=)/).map(s=>(o=>/a=(recvonly|inactive)/.test(o)?o.replace(/\r\na=(ssrc|msid)[^\r\n]+/g,""):o)(s)).join(`\r
- `))(r),r=r.replace(/a=ice-options:trickle/g,`a=ice-options:trickle\r
- a=ice-options:renomination`),t.sdp=r,yield this._peer.setLocalDescription(t),{type:"offer",semantics:"unified-plan",sdp:r}})}setRemoteAnswer(e){e=e.split(/\r\n(?=m=)/).map(r=>{var i;const s=r.match(/a=mid:[^\s]+/);if(!s)return r;const o=s[0].replace("a=mid:","");let u="";for(const f in this._sendTransceiver)if(this._sendTransceiver[f].mid===o){u=f;break}if(!u)return r;const d=(i=this._localTracks[u])===null||i===void 0?void 0:i.getBitrate();if(!d)return r;const{max:l,min:h}=d,a=l&&l>0?d.start||.7*l:0,c=[];if(l&&l>0&&c.push(`;x-google-max-bitrate=${l}`),h&&h>0&&c.push(`;x-google-min-bitrate=${h}`),a>0&&c.push(`;x-google-start-bitrate=${a}`),c.length===0)return r;const p=c.join("");return r.replace(/[\r\n]+[^\r\n]+profile-level-id[^\r\n]+/g,f=>f+p)}).join(`\r
- `);const t=/[\r\n]+\r\n[\r\n]+/g;return t.test(e)&&(b.warn(`answer sdp invalid -> ${JSON.stringify(e)}`),e=e.replace(t,`\r
- `)),super.setRemoteAnswer(e)}}class Rt extends jn{constructor(e,t){super(),this._reTryExchange=e,this._polarisReport=t,this.pubLocalTracks={},this._reTryExchangeTimer=null,this._reportStatsTimer=null,this._reportListener=null;const r=un.getSdpSemantics(),i=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:r});this._sdpStrategy=r==="plan-b"?new jl(i):new Kl(i),this._rtcPeerConn.oniceconnectionstatechange=this._onICEConnectionStateChange.bind(this),this._rtcPeerConn.onconnectionstatechange=this._onConnectionStateChange.bind(this),this._rtcPeerConn.ontrack=this._onTrackReady.bind(this),this.reportParser=this._sdpStrategy.getStatParsr(this._rtcPeerConn,r)}getLocalTracks(){return Object.values(this.pubLocalTracks)}_onConnectionStateChange(){b.info(`onconnectionstatechange -> ${this._rtcPeerConn.connectionState}`)}_onICEConnectionStateChange(){var e,t;b.info(`oniceconnectionstatechange -> ${this._rtcPeerConn.iceConnectionState}`),this._rtcPeerConn.iceConnectionState==="connected"&&(this._reportStatsTimer&&clearInterval(this._reportStatsTimer),this._reportStatsTimer=setInterval(this._reportHandle.bind(this),1e3)),this._rtcPeerConn.iceConnectionState!=="failed"&&this._rtcPeerConn.iceConnectionState!=="disconnected"||(b.warn("iceconenction state is `failed`, exchange SDP to try again."),this._reTryExchange(),this._reTryExchangeTimer=setInterval(this._reTryExchange,15e3));try{(t=(e=this._reportListener)===null||e===void 0?void 0:e.onICEConnectionStateChange)===null||t===void 0||t.call(e,this._rtcPeerConn.iceConnectionState)}catch(r){b.error("onICEConnectionStateChange error",r)}}_onTrackReady(e){if(!e.streams.length)return;const t=[e.streams[0].id,e.receiver.track.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY].join("_");this._updateRecvTransceiverMap(t,e.transceiver),this.emit(Rt.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,t,r){return F(this,void 0,void 0,function*(){this._sdpStrategy.setBitrate(e,t,r)})}createOffer(e){return F(this,void 0,void 0,function*(){const t=yield this._sdpStrategy.createOffer(e);return b.debug(`offer -> ${JSON.stringify(t.sdp)}`),t})}setRemoteAnswer(e){return F(this,void 0,void 0,function*(){return b.debug(`answer -> ${JSON.stringify(e)}`),this._sdpStrategy.setRemoteAnswer(e)})}getLocalTrack(e){return this.pubLocalTracks[e]||null}addLocalTrack(e){this.pubLocalTracks[e.getTrackId()]=e,this._sdpStrategy.addLocalTrack(e),e.off(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this)}removeLocalTrackById(e){const t=this.getLocalTrack(e);t&&this.removeLocalTrack(t)}removeAllLocalTrack(){Object.keys(this.pubLocalTracks).forEach(e=>{/_tiny$/.test(e)||this.removeLocalTrackById(e)})}removeLocalTrack(e){const t=e.getTrackId();delete this.pubLocalTracks[t],this._sdpStrategy.removeLocalTrack(e),e.__innerSetPublished(!1),e.off(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const r=`${t}_tiny`,i=this.getLocalTrack(r);i&&(this._sdpStrategy.removeLocalTrack(i),delete this.pubLocalTracks[r],i.destroy())}_updateRecvTransceiverMap(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e){const t=this.getLocalTrack(`${e.getTrackId()}_tiny`);t&&(t.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(pe.__INNER_EVENT_MUTED_CHANGE__,e)}_onLocalTrackDestroied(e){this.emit(pe.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createRCRTCStateReport(e){const{timestamp:t,iceCandidatePair:r,senders:i,receivers:s}=JSON.parse(JSON.stringify(e));r==null||delete r.totalPacketsLost;for(const o in r)cs(r[o])&&delete r[o];return{timestamp:t,iceCandidatePair:r,senders:i.map(o=>{const u={};return o.trackId&&(u.trackId=o.trackId),o.kind&&(u.kind=o.kind),(o.packetsLostRate||o.packetsLostRate===0)&&(u.packetsLostRate=o.packetsLostRate),u.remoteResource=o.remoteResource,(o.audioLevel||o.audioLevel===0)&&(u.audioLevel=o.audioLevel),o.frameWidth&&(u.frameWidth=o.frameWidth),o.frameHeight&&(u.frameHeight=o.frameHeight),o.frameRate&&(u.frameRate=o.frameRate),(o.bitrate||o.bitrate===0)&&(u.bitrate=o.bitrate),o.jitter&&(u.jitter=o.jitter),u}),receivers:s.map(o=>{const u={};return o.trackId&&(u.trackId=o.trackId),o.kind&&(u.kind=o.kind),(o.packetsLostRate||o.packetsLostRate===0)&&(u.packetsLostRate=o.packetsLostRate),u.remoteResource=o.remoteResource,(o.audioLevel||o.audioLevel===0)&&(u.audioLevel=o.audioLevel),o.frameWidth&&(u.frameWidth=o.frameWidth),o.frameHeight&&(u.frameHeight=o.frameHeight),o.frameRate&&(u.frameRate=o.frameRate),(o.bitrate||o.bitrate===0)&&(u.bitrate=o.bitrate),o.jitter&&(u.jitter=o.jitter),u})}}_getStatsData(){var e,t;return F(this,void 0,void 0,function*(){const r=yield this._rtcPeerConn.getStats(),i=(e=this.reportParser)===null||e===void 0?void 0:e.parseRTCStatsReport(r);return(t=this.reportParser)===null||t===void 0?void 0:t.formatRCRTCStateReport(i)})}getAudioLevelReportData(){var e,t;return F(this,void 0,void 0,function*(){const r=yield this._rtcPeerConn.getStats(),i=(e=this.reportParser)===null||e===void 0?void 0:e.parseRTCStatsReport(r);return i?(t=this.reportParser)===null||t===void 0?void 0:t.getAudioLevelList(i):[]})}_reportHandle(){var e,t,r;return F(this,void 0,void 0,function*(){const i=yield this._getStatsData();if(!i)return;(i.senders.length||i.receivers.length)&&((e=this._polarisReport)===null||e===void 0||e.sendR3R4Data(i));const s=this._createRCRTCStateReport(i);(r=(t=this._reportListener)===null||t===void 0?void 0:t.onStateReport)===null||r===void 0||r.call(t,s)})}getRTCPeerConn(){return this._rtcPeerConn}destroy(){this.clear(),this.clearReTryExchangeTimer(),this._reportStatsTimer&&(clearInterval(this._reportStatsTimer),this._reportStatsTimer=null),this.registerReportListener(null),this._rtcPeerConn.close(),this.reportParser=null}clearReTryExchangeTimer(){clearInterval(this._reTryExchangeTimer),this._reTryExchangeTimer=null}}var Gt,Br,bt,Ot,Fr;Rt.__INNER_EVENT_TRACK_READY__="inner-track-ready",function(n){n[n.DISABLE=0]="DISABLE",n[n.ENABLE=1]="ENABLE"}(Gt||(Gt={})),function(n){n[n.MeetingOrAnchor=1]="MeetingOrAnchor",n[n.Audience=2]="Audience"}(Br||(Br={}));class fu{constructor(e,t,r,i,s=Br.MeetingOrAnchor){this._context=e,this._runtime=t,this._roomId=r,this._crtRTCRoom=i,this._userRole=s}_send(e){this._context.getConnectionStatus()===te.CONNECTED&&this._context.setRTCState(this._roomId,e)}_getClientID(){const e="uuid";let t=this._runtime.localStorage.getItem(e);return t||(t=Vl(),this._runtime.localStorage.setItem(e,t)),t}_getRealResourceId(e){let t=e;const r=e.indexOf("_tiny");return r>-1&&(t=e.slice(0,r)),t}_getPolarisTrackId(e){let t="";const r=e.split("_");if(e.includes("_tiny")){const i=r.pop(),s=parseInt(r.pop())===me.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,i,s].join("_")}else{const i=parseInt(r.pop())===me.AUDIO_ONLY?"audio":"video",s=r.pop();t=[r.join("_"),s,i].join("_")}return t}sendR3R4Data(e){const{iceCandidatePair:t,senders:r,receivers:i}=e,s=(t==null?void 0:t.bitrateSend)||-1,o=(t==null?void 0:t.bitrateRecv)||-1,u=(t==null?void 0:t.networkType)||"unknown",d=(t==null?void 0:t.rtt)||-1,l=`${(t==null?void 0:t.IP)||-1}:${t==null?void 0:t.port}`,h=(t==null||t.remoteIP,t==null||t.remotePort,(t==null?void 0:t.availableIncomingBitrate)||-1),a=(t==null?void 0:t.availableOutgoingBitrate)||-1,c=(t==null?void 0:t.totalPacketsLost)||-1,p=this._context.getCurrentId();let f=`R3 ${s} -1 -1 -1 ${u} ${d} ${l} ${h} ${a} ${c} ${p}\r`,m=`R4 ${o} -1 -1 -1 ${u} ${d} ${l} ${h} ${a} ${c} ${p}\r`;const _=r.map(R=>{var C;const{trackId:A,audioLevel:M,samplingRate:O,bitrate:y,packetsLostRate:w,frameRate:$,frameWidth:Y,frameHeight:E,googRenderDelayMs:T,jitter:N,nackCount:P,pliCount:k,rtt:B,googFirsSent:H,encoderImplementation:q}=R,J=this._getPolarisTrackId(A),re=this._getRealResourceId(A);return{trackId:J,googCodecName:q||String(-1),audioLevel:M||M===0?M:-1,bitrate:y||y===0?y:-1,packetsLostRate:w||w===0?w:-1,frameRate:$||-1,resolution:Y&&E?`${Y} * ${E}`:"-1",jitter:N||-1,nackCount:P||P===0?P:-1,pliCount:k||k===0?k:-1,rtt:B||-1,googFirsSent:H,samplingRate:O,googRenderDelayMs:T,encoderImplementation:q||String(-1),trackState:((C=this._crtRTCRoom.getLocalTrack(re))===null||C===void 0?void 0:C.isLocalMuted())?Gt.DISABLE:Gt.ENABLE}}),v=i.filter(R=>!!R.trackId).map(R=>{var C;const{trackId:A,audioLevel:M,samplingRate:O,bitrate:y,packetsLostRate:w,frameRate:$,frameWidth:Y,frameHeight:E,googRenderDelayMs:T,jitter:N,nackCount:P,pliCount:k,rtt:B,googFirsReceived:H,codecImplementationName:q}=R,J=this._getPolarisTrackId(A),re=this._getRealResourceId(A);return{trackId:J,googCodecName:q||String(-1),audioLevel:M||M===0?M:-1,bitrate:y||y===0?y:-1,packetsLostRate:w||w===0?w:-1,frameRate:$||-1,resolution:Y&&E?`${Y} * ${E}`:"-1",jitter:N||-1,nackCount:P||P===0?P:-1,pliCount:k||k===0?k:-1,rtt:B||-1,googFirsReceived:H,samplingRate:O,googRenderDelayMs:T,codecImplementationName:q||String(-1),trackState:((C=this._crtRTCRoom.getRemoteTrack(re))===null||C===void 0?void 0:C.isLocalMuted())?Gt.DISABLE:Gt.ENABLE}});f+=_.map(R=>`${R.trackId} ${R.googCodecName} ${R.audioLevel} ${R.samplingRate} ${R.bitrate} ${R.packetsLostRate} ${R.frameRate} ${R.resolution} ${R.googRenderDelayMs} ${R.jitter} ${R.nackCount} ${R.pliCount} ${R.rtt} ${R.googFirsSent} ${R.encoderImplementation} ${R.trackState}`).join(`
- `),e.senders.length&&this._send(f+`\r${this._userRole}`),m+=v.map(R=>`${R.trackId} ${R.googCodecName} ${R.audioLevel} ${R.samplingRate} ${R.bitrate} ${R.packetsLostRate} ${R.frameRate} ${R.resolution} ${R.googRenderDelayMs} ${R.jitter} ${R.nackCount} ${R.pliCount} ${R.rtt} ${R.googFirsReceived} ${R.codecImplementationName} ${R.trackState}`).join(`
- `),e.receivers.length&&this._send(m+`\r${this._userRole}`)}sendR1(){const e=`R1 5.3.1 ${this._context.getCoreVersion()} web ${navigator.platform} -1 ${st.browser} ${st.version} ${this._getClientID()} ${this._userRole}`;this._send(e)}sendR2(e,t,r){const i=`R2 ${e} ${t} ${this._getClientID()}\r${r.join(" ")}\r${this._userRole}`;this._send(i)}}(function(n){n.PUBLISH="publish",n.SUBSCRIBE="subscribe"})(bt||(bt={})),function(n){n.BEGIN="begin",n.END="end"}(Ot||(Ot={}));class gu{constructor(e){this._room=e,this._audioLevelChangeHandler=null,this._timer=null,this._pc=this._room.__getPC()}_audioLevelReport(){return F(this,void 0,void 0,function*(){if(this._pc.getRTCPeerConn().iceConnectionState==="new"||!this._audioLevelChangeHandler)return;const e=(yield this._pc.getAudioLevelReportData()).map(t=>{const{userId:r}=Xl.parseTrackId(t.trackId);return{track:this._room.getCrtUserId()===r?this._room.getLocalTrack(t.trackId):this._room.getRemoteTrack(t.trackId),audioLevel:t.audioLevel||0}}).filter(t=>t.track);this._audioLevelChangeHandler(e)})}onAudioLevelChange(e,t){t<300||t>1e3?b.error('the valid range of onAudioLevelChange params "gap" is: > 300 && < 1000'):e?(this._audioLevelChangeHandler=e,this._timer=setInterval(this._audioLevelReport.bind(this),t)):this._audioLevelChangeHandler=null}clearAudioLevelReportTimer(){this._timer&&(clearInterval(this._timer),this._timer=null)}}(function(n){n[n.ANCHOR=1]="ANCHOR",n[n.AUDIENCE=2]="AUDIENCE"})(Fr||(Fr={}));const Cn=n=>n instanceof ho?n.getTrackId():n.track.getTrackId();class mu{constructor(e,t,r,i,s,o,u,d,l,h){this._context=e,this._runtime=t,this._roomId=r,this._roomMode=s,this._service=o,this._initOptions=u,this._ntfClearRoomItem=d,this._isMainRoom=h,this._remoteTracks={},this._subscribedList=[],this._destroyed=!1,this.msgTaskQueue=new Nc,this._appListener=null,this._onRecvPKMsg=null,this._token=i.token,this._sessionId=i.sessionId,this._roomResources=l?{}:us(i),this._initRemoteTracks();const a=this._context.getCurrentId(),c=this._roomResources[a]=this._roomResources[a]||[];b.debug(`room data -> ${JSON.stringify(this._roomResources)}`),c.length>0&&Se(()=>this._unpublishPrev(c)),l&&this._afterChangedRole(i),this._pinger=new Bl(r,this._roomMode,e,this._initOptions.pingGap),this._pinger.onFailed=this._kickoff.bind(this),this._pinger.onPingResult=this._handlePingResult.bind(this),this._pinger.start(),this._polarisReport=new fu(this._context,this._runtime,this._roomId,this),this._polarisReport.sendR1(),this._pc=new Rt(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(Rt.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.on(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),this._pc.on(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this)}_initRemoteTracks(){const e=this._context.getCurrentId();for(const t in this._roomResources){const r=this._roomResources[t];t!==e&&r.length!==0&&r.forEach(i=>{const s=he(i),{tag:o,userId:u,mediaType:d}=$e(s),l=d===me.AUDIO_ONLY?new Tt(o,u):new St(o,u);l.__innerSetRemoteMuted(i.state===0),this._remoteTracks[s]=l})}}_handlePingResult(e){this._callAppListener("onPing",e)}setBitrate(e,t,r){b.warn("`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),Ue("max",e,i=>Te(i)&&i>Math.max(t||1,200),!0),Ue("min",t,i=>Te(i)&&i>=1&&(!Te(e)||i<e),!0),Ue("start",r,i=>Te(i)&&i>t&&i<=e),this._pc.setBitrate(e,t,r)}_onTrackReady(e){const t=e.streams[0].id,r=e.receiver.track,i=[t,r.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY].join("_"),s=this._remoteTracks[i];s?(s.__innerSetMediaStreamTrack(r),this._callAppListener("onTrackReady",s)):b.warn(`cannot found remote track ${r.id}`)}_callAppListener(e,...t){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...t)}catch(s){b.error(s)}}_onUserUnpublish(e){return F(this,void 0,void 0,function*(){yield this.unsubscribe(e),e.forEach(t=>{t.__innerDestroy(),delete this._remoteTracks[t.getTrackId()]}),this._onTrackUnpublish(e)})}_onTrackUnpublish(e){this._callAppListener("onTrackUnpublish",e)}_unpublishPrev(e){return F(this,void 0,void 0,function*(){const t=e.slice();e.length=0,b.info(`unpublish uris prev login: ${JSON.stringify(t)}`);const r=yield this._context.setRTCTotalRes(this._roomId,hr(oe.UNPUBLISH,t),Mt([]),oe.TOTAL_CONTENT_RESOURCE,Mt([]));r!==S.SUCCESS?b.error(`unpublish prev uris failed -> code: ${r}`):b.debug("unpublish uris prev login succeed")})}__parseInnerMessage(e){const{targetId:t,conversationType:r}=e;if(r!==z.RTC_ROOM)return!1;if(t!==this._roomId)return!0;b.info(`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`);const i=e.content;switch(e.messageType){case oe.KICK:this._kickoff(!0,i);break;case oe.STATE:this.msgTaskQueue.push(()=>this._stateHandle(i));break;case oe.MODIFY:case oe.PUBLISH:case oe.UNPUBLISH:case oe.TOTAL_CONTENT_RESOURCE:this.msgTaskQueue.push(()=>this._resourceHandle(i,e.messageType,e.senderUserId));break;case oe.ROOM_NOTIFY:this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case oe.USER_NOTIFY:b.warn(`TODO: ${oe.USER_NOTIFY}`);break;case oe.PK_INVITE:case oe.PK_CANCEL_INVITE:case oe.PK_INVITE_TIMEOUT:case oe.PK_INVITE_ANSWER:case oe.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case oe.OTHER_ROOM_OFFLINE:break;default:this._callAppListener("onMessageReceive",e.messageType,e.content,e.senderUserId,e.messageUId)}return!0}_kickoff(e,t){let r;b.warn(`onKickOff -> byServer: ${e}`),this._ntfClearRoomItem(),this._leaveHandle(!e),e&&((t==null?void 0:t.users)||[]).forEach(i=>{i.userId===this._context.getCurrentId()&&(r=i.type)}),this._callAppListener("onKickOff",e,r)}_rtcpeerClosed(){this._ntfClearRoomItem(),this._leaveHandle(!0),this._callAppListener("onRTCPeerConnectionCloseByException")}_resourceHandle(e,t,r){return F(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return void b.warn(`room has been destroyed. -> roomId: ${this._roomId}`);const{uris:i,ignore:s}=e;if(s||!i)return;const o=[],u=[],d=[];let l;const h=this._roomResources[r]||(this._roomResources[r]=[]);switch(t){case oe.MODIFY:d.push(...i);break;case oe.PUBLISH:o.push(...i);break;case oe.UNPUBLISH:u.push(...i);break;case oe.TOTAL_CONTENT_RESOURCE:l=Er(h,i),o.push(...l.publishedList),u.push(...l.unpublishedList),d.push(...l.modifiedList)}if(o.length>0){const a=h.map(he),c=[],p=[];if(o.forEach(f=>{const m=he(f),_=a.indexOf(m),{userId:v,tag:R,mediaType:C}=$e(m);_>-1?h[_]=f:h.push(f);let A=this._remoteTracks[m];A?A.isSubscribed()&&c.push(A):(A=C===me.AUDIO_ONLY?new Tt(R,v):new St(R,v),this._remoteTracks[m]=A,p.push(A)),A.__innerSetRemoteMuted(f.state===0)}),c.length){const f=c.map(_=>_.getTrackId());b.debug(`resub tracks -> ${JSON.stringify(f)}`);const{code:m}=yield Se(()=>this.__subscribe(c,!0));m!==I.SUCCESS&&b.error(`resub tracks failed -> code: ${m}, ids: ${JSON.stringify(f)}`)}this._onTrackPublish(p)}if(u.length>0){const a=u.map(he);for(let p=h.length-1;p>=0;p-=1){const f=h[p];a.includes(he(f))&&h.splice(p,1)}const c=u.map(p=>{const f=he(p);return this._remoteTracks[f]});yield this._onUserUnpublish(c)}if(d.length>0){const a=h.map(he);for(let c=0;c<d.length;c+=1){const p=d[c],f=he(p),m=a.indexOf(f);h[m].state=p.state;const _=this._remoteTracks[f];_.__innerSetRemoteMuted(p.state===0),_.isAudioTrack()?this._onAudioMuteChange(_):this._onVideoMuteChange(_)}}})}_onTrackPublish(e){this._callAppListener("onTrackPublish",e)}_stateHandle(e){var t;return F(this,void 0,void 0,function*(){const{users:r}=e;if(r.length===0)return;const i=[],s=[],o=[],u=[];r.forEach(h=>{+h.state==0?(b.debug(`user joined -> ${h.userId}`),this._roomResources[h.userId]||(h.switchRoleType?o.push(h.userId):i.push(h.userId)),this._roomResources[h.userId]=this._roomResources[h.userId]||[]):(b.debug(`user left -> ${h.userId}`),h.switchRoleType?u.push(h.userId):s.push(h.userId))});const d=[...i,...o],l=[...s,...u];if(l.length){const h=[],a=[];l.forEach(c=>{h.push(...this.getRemoteTracksByUserId(c)),a.push(c)}),h.length&&(yield this.unsubscribe(h),h.forEach(c=>delete this._remoteTracks[c.getTrackId()])),a.length&&a.forEach(c=>delete this._roomResources[c])}if((t=this._appListener)===null||t===void 0?void 0:t.onSwitchRole)return o.length&&o.forEach(h=>this._callAppListener("onSwitchRole",h,Fr.ANCHOR)),u.length&&u.forEach(h=>this._callAppListener("onSwitchRole",h,Fr.AUDIENCE)),i.length&&this._callAppListener("onUserJoin",i),void(s.length&&this._callAppListener("onUserLeave",s));d.length&&this._callAppListener("onUserJoin",d),l.length&&this._callAppListener("onUserLeave",l)})}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}__getPC(){return this._pc}getRemoteUserIds(){const e=this._context.getCurrentId();return Object.keys(this._roomResources).filter(t=>t!==e)}getRemoteTracks(){const e=[];return this.getRemoteUserIds().forEach(t=>{e.push(...this.getRemoteTracksByUserId(t))}),e}getRemoteTracksByUserId(e){const t=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getSessionId(){return this._sessionId}sendMessage(e,t){return F(this,void 0,void 0,function*(){const{code:r}=yield this._context.sendMessage(z.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0});return r!==S.SUCCESS?(b.error(`send message failed -> code: ${r}`),{code:I.SIGNAL_ERROR}):{code:I.SUCCESS}})}setRoomAttribute(e,t,r,i=!1){return F(this,void 0,void 0,function*(){const s=yield this._context.setRTCData(this._roomId,e,t,i,ht.ROOM,r);return s!==S.SUCCESS?(b.error(`SetRoomAttributeValue Failed: ${s}`),{code:I.SIGNAL_ERROR}):{code:I.SUCCESS}})}deleteRoomAttributes(e,t,r=!1){return F(this,void 0,void 0,function*(){const i=yield this._context.removeRTCData(this._roomId,e,r,ht.ROOM,t);return i!==S.SUCCESS?(b.error(`DeleteRoomAttribute Failed: ${i}`),{code:I.SIGNAL_ERROR}):{code:I.SUCCESS}})}getRoomAttributes(e=[],t=!1){return F(this,void 0,void 0,function*(){const{code:r,data:i}=yield this._context.getRTCData(this._roomId,e,t,ht.ROOM);return r!==S.SUCCESS?(b.error(`GetRoomAttributes Failed: ${r}`),{code:I.SIGNAL_ERROR}):{code:I.SUCCESS,data:i}})}_setUserAttributeValue(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,ht.PERSON,r)}_deleteUserAttributes(e,t){return this._context.removeRTCData(this._roomId,e,!1,ht.PERSON,t)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,ht.PERSON)}isDestroyed(){return this._destroyed}__destroy(e){return this._leaveHandle(e)}_leaveHandle(e){var t;return F(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(t=this._audioLevelReport)===null||t===void 0||t.clearAudioLevelReportTimer(),e&&(yield this._context.quitRTCRoom(this._roomId)),this._isMainRoom&&this._quitAllPKRoom(),this._pc.removeAllLocalTrack(),this._pinger.stop(),this._isMainRoom&&(yield this._service.exit(this._getRTCReqestHeaders())),this._pc.destroy(),this._polarisReport=null,this._removeRemoteTracks())})}_onLocalTrackDestroied(e){e instanceof tn&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e){return F(this,void 0,void 0,function*(){const t=e.getTrackId(),r=this._context.getCurrentId(),i=[{resourceId:t,enabled:!e.isLocalMuted()}],s=this._roomResources[r]||[],o=[];for(let d=0;d<s.length;d+=1){const l=s[d],h=he(l),a=i.findIndex(c=>c.resourceId===h);if(a>=0){const{enabled:c}=i[a];l.state=c?1:0,o.push(l);break}}const u=yield Se(()=>this._context.setRTCTotalRes(this._roomId,hr(oe.MODIFY,o),Mt(s),oe.TOTAL_CONTENT_RESOURCE));u!==S.SUCCESS&&b.error("notice `track.enabled` change failed -> code: "+u)})}_removePubFailedTracks(e){e.forEach(t=>{const r=t instanceof pe?t:t.track;b.debug(`remove pub failed track from peerconnection -> trackId: ${r.getTrackId()}`),this._pc.removeLocalTrackById(r.getTrackId())})}publish(e){return F(this,void 0,void 0,function*(){return Se(()=>this.__publish(e))})}__publish(e){return F(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof Nt)return b.error("the `publish` is disabled in PK room "),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(this._assertRoomDestroyed())return b.error(`publish failed, room has been destroyed. -> roomId: ${this._roomId}`),{code:I.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>Ye(e)&&e.length>0&&e.every(C=>C instanceof pe||C.track instanceof pe),!0))return b.error(`publish failed, tracks is invalid -> roomId: ${this._roomId}`),{code:I.PARAMS_ERROR};const t=this._context.getCurrentId();if(this._pc.getLocalTracks().length+(C=>{let A=0;return C.forEach(M=>{M instanceof pe?A++:M.pubTiny&&M.track.isVideoTrack()?A+=2:A++}),A})(e)>10)return b.error(`publish failed, tracks limit exceeded -> roomId: ${this._roomId}`),{code:I.PUBLISH_TRACK_LIMIT_EXCEEDED};b.debug(`publish tracks -> roomId: ${this._roomId}, tracks: ${e.map(Cn)}`),e.forEach(C=>{const{track:A,pubTiny:M}=C instanceof pe?{pubTiny:!1,track:C}:C;if(this._pc.addLocalTrack(A),A.isVideoTrack()&&M){let O;try{O=A.__innerGetMediaStreamTrack().clone();const y=M.frameRate||ft.FPS_15,w=M.resolution||Ce.W176_H144,{width:$,height:Y}=gt(w),E=mt(y);O.applyConstraints({width:$,height:Y,frameRate:E})}catch(y){return O==null||O.stop(),void b.warn(`pubTiny failed -> id: ${A.getTrackId()}, msg: ${y.message}`)}this._pc.addLocalTrack(new tn(A.getTag(),A.getUserId(),O,!0))}}),this._pc.clearReTryExchangeTimer();const r=yield this._createExchangeParams(this._subscribedList,!1),i=this._getPushOtherRoomsParams();i&&(r.pushOtherRooms=i);const s=yield this._exchangeHandle(r);if(s.code!==I.SUCCESS)return b.error(`publish failed -> roomId: ${this._roomId}, code: ${s.code}`),this._removePubFailedTracks(e),{code:s.code};const{publishList:o,sdp:u,resultCode:d,message:l,urls:h,mcuPublishList:a}=s.data;if(d!==I.SUCCESS)return b.error(`publish failed -> roomId: ${this._roomId}, code: ${d}, msg: ${l}`),this._removePubFailedTracks(e),{code:d};const c=yield this._pc.setRemoteAnswer(u.sdp);if(c!==I.SUCCESS)return{code:c};const p=this._roomResources[t],f=o.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:this._getResourceState(he(C))},C)),{publishedList:m}=Er(p,f),_=(a==null?void 0:a.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:1},C)))||[],v=yield this._context.setRTCTotalRes(this._roomId,hr(oe.PUBLISH,m),Mt(f),oe.TOTAL_CONTENT_RESOURCE,Mt(_));if(v!==S.SUCCESS)return b.error(`send publish streams notification failed: ${v}`),{code:I.SIGNAL_ERROR};this._roomResources[t]=f;const R=m.map(C=>he(C));return this._polarisReport&&this._polarisReport.sendR2(bt.PUBLISH,Ot.BEGIN,R),e.forEach(C=>{const{track:A}=C instanceof pe?{track:C}:C;A.__innerSetPublished(!0)}),b.debug(`publish success: ${R.join(",")}`),this._roomMode===je.LIVE?{code:I.SUCCESS,liveUrl:h==null?void 0:h.liveUrl}:{code:I.SUCCESS}})}_getPushOtherRoomsParams(){if(this instanceof Nt){const{code:e,roomPKHandler:t}=this.getRoomPKHandler(),r=[];if(e===I.SUCCESS&&t){const i=t.getJoinedPKRooms();for(const s in i){const o=i[s].getSessionId(),u=t.getPKInfo(s);if(!u)return;const{inviterUserAutoMix:d,inviteeUserAutoMix:l,inviterUserId:h}=u,a=this._context.getCurrentId()===h;r.push({roomId:s,sessionId:o,autoMix:a?!!d:!!l})}}return r}}_reTryExchange(){return F(this,void 0,void 0,function*(){Se(()=>F(this,void 0,void 0,function*(){const e=yield this._createExchangeParams(this._subscribedList,!0),t=this._getPushOtherRoomsParams();t&&(e.pushOtherRooms=t);const r=yield this._exchangeHandle(e);if(r.code!==I.SUCCESS)return b.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:s}=r.data;if(s!==I.SUCCESS)return b.error(`reTryExchange failed: ${s}`),{code:s};this._pc.clearReTryExchangeTimer();const o=yield this._pc.setRemoteAnswer(i.sdp);return o!==I.SUCCESS?{code:o}:void 0}))})}_exchangeHandle(e){return this._service.exchange(this._getRTCReqestHeaders(),e)}_getRTCReqestHeaders(){return{"App-Key":this._context.getAppkey(),RoomId:this._roomId,Token:this._token,RoomType:this._roomMode,UserId:this._context.getCurrentId()}}_createExchangeParams(e,t){return F(this,void 0,void 0,function*(){return{sdp:yield this._pc.createOffer(t),extend:JSON.stringify({resolutionInfo:this._pc.getOutboundVideoInfo()}),subscribeList:e.filter(r=>{const i=r.track.getTrackId(),{userId:s}=$e(i);return this._roomResources[s]?this._roomResources[s].filter(u=>i===`${u.msid}_${u.mediaType}`).length:!1}).map(r=>({simulcast:r.subTiny?rt.TINY:rt.NORMAL,resolution:"",uri:this._getResourceById(r.track.getTrackId()).uri})),switchstream:!1}})}_getResourceState(e){var t;return((t=this.getLocalTrack(e))===null||t===void 0?void 0:t.isLocalMuted())?0:1}unpublish(e){return F(this,void 0,void 0,function*(){return Se(()=>this.__unpublish(e))})}__unpublish(e){var t;return F(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof Nt)return b.error("the `unpublish` is disabled in PK room "),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(this._assertRoomDestroyed())return b.warn(`room has been destroyed, no need to unpublish tracks -> roomId: ${this._roomId}`),{code:I.SUCCESS};const r=this._context.getCurrentId();if(!Ee("tracks",e,()=>e.every(C=>C.getUserId()===r&&C instanceof pe),!0))return b.warn(`unpublish failed, tracks is invalid -> roomId: ${this._roomId}, tracks: ${e.map(Cn)}`),{code:I.PARAMS_ERROR};const i=e.map(C=>C.getTrackId()),s=i.map(this._getResourceById.bind(this)).filter(C=>!!C);if(s.length===0)return{code:I.SUCCESS};const o=this._roomResources[r].filter(C=>!s.includes(C));i.forEach(C=>this._pc.removeLocalTrackById(C)),(t=this._polarisReport)===null||t===void 0||t.sendR2(bt.PUBLISH,Ot.END,i),this._pc.clearReTryExchangeTimer();const u=yield this._createExchangeParams(this._subscribedList,!1),d=this._getPushOtherRoomsParams();d&&(u.pushOtherRooms=d);const l=yield this._exchangeHandle(u);if(l.code!==I.SUCCESS)return b.error(`exchange failed -> code: ${l.code}`),{code:l.code};const{publishList:h,sdp:a,resultCode:c,message:p,mcuPublishList:f}=l.data;c!==I.SUCCESS&&b.error(`unpublish streams failed -> code: ${c}, msg: ${p}`);const m=f?f.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:1},C)):[],_=yield this._context.setRTCTotalRes(this._roomId,hr(oe.UNPUBLISH,s),Mt(o),oe.TOTAL_CONTENT_RESOURCE,Mt(m));if(_!==S.SUCCESS)return b.error("send unpublish notification failed:",_),{code:I.SIGNAL_ERROR};b.debug(`unpublish success -> tracks: ${i.join(",")}`);const v=yield this._pc.setRemoteAnswer(a.sdp);if(v!==I.SUCCESS)return{code:v};const R=h.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:this._getResourceState(he(C))},C));return this._roomResources[r]=R,{code:I.SUCCESS}})}_getResourceById(e){const{userId:t}=$e(e);return this._roomResources[t].find(r=>he(r)===e)}_isValidResourceId(e){var t;const{userId:r}=$e(e);return!!((t=this._roomResources[r])===null||t===void 0?void 0:t.find(i=>he(i)===e))}subscribe(e){return F(this,void 0,void 0,function*(){return Se(()=>this.__subscribe(e,!1))})}__subscribe(e,t=!1){var r;return F(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return b.error(`subscribe failed, room has been destroyed -> roomId: ${this._roomId}`),{code:I.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>Ye(e)&&e.length>0&&e.every(d=>d instanceof xe||d.track instanceof xe),!0))return b.error(`subscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:I.PARAMS_ERROR};b.info(`subscribe -> roomId: ${this._roomId}, tracks: ${e.map(Cn)}`);const i=this._subscribedList.map(d=>Object.assign({},d)),s=e.map(d=>d instanceof xe?{track:d}:d);let o=!1;const u=[];return s.forEach(d=>{const l=d.track.getTrackId();u.push(l);const h=i.find(a=>a.track.getTrackId()===l);h&&h.subTiny===d.subTiny||(h?h.subTiny=d.subTiny:i.push(d),o=!0)}),o||t?((r=this._polarisReport)===null||r===void 0||r.sendR2(bt.SUBSCRIBE,Ot.BEGIN,u),this._updateSubListHandle(i,!0)):{code:I.SUCCESS}})}unsubscribe(e){return F(this,void 0,void 0,function*(){return Se(()=>this.__unsubscribe(e))})}__unsubscribe(e){var t;return F(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return b.warn(`room has beed destroyed, no need to unsubscribe tracks -> roomId: ${this._roomId}`),{code:I.SUCCESS};if(!Ee("tracks",e,()=>Ye(e)&&e.length>0&&e.every(i=>i instanceof xe),!0))return b.error(`unsubscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:I.PARAMS_ERROR};b.info(`unsubscribe -> roomId: ${this._roomId}, tracks: ${e.map(Cn)}`);const r=this._subscribedList.map(i=>Object.assign({},i)).filter(i=>!e.includes(i.track));return(t=this._polarisReport)===null||t===void 0||t.sendR2(bt.SUBSCRIBE,Ot.END,e.map(i=>i.getTrackId())),this._updateSubListHandle(r,!1)})}_assertRoomDestroyed(){if(this._destroyed){const e="This room has been destroyed. Please use `RCRTCClient.joinRTCRoom` or `RCRTCClient.joinLivingRoom` to catch another instance.";return b.warn(e),I.ROOM_HAS_BEEN_DESTROYED}}getLocalTrack(e){return this._pc.getLocalTrack(e)}getLocalTracks(){return this._pc.getLocalTracks()}getRemoteTrack(e){return this._remoteTracks[e]||null}updateSubList(e){return F(this,void 0,void 0,function*(){return Se(()=>this._updateSubListHandle(e,!1))})}_updateSubListHandle(e,t=!1){return F(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:I.ROOM_HAS_BEEN_DESTROYED};if(!Ee("resources",e,()=>Ye(e)&&e.every(R=>R instanceof xe||R.track instanceof xe),!0))return b.error(`update sublist failed, tracks is invalid -> roomId: ${this._roomId}`),{code:I.PARAMS_ERROR};b.info(`update subscribe list -> roomId: ${this._roomId}, forceReq: ${t}, tracks: ${e.map(Cn)}`);let r=e.map(R=>R instanceof xe?{track:R}:Object.assign({},R));const i={};r=r.filter(R=>{const C=R.track.getTrackId();return this._remoteTracks[C]?!i[C]&&(i[C]=!0):(b.warn(`track cannot found in room -> trackId: ${C}`),!1)}).map(R=>Object.assign({},R));const s=this._subscribedList.map(R=>Object.assign({},R));if(!t){let R=!1;if(r.forEach(C=>{const A=s.findIndex(M=>M.track===C.track);if(A===-1)return void(R=!0);s.splice(A,1)[0].subTiny!==C.subTiny&&(R=!0)}),s.length&&(R=!0),!R)return{code:I.SUCCESS}}this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(r.map(R=>R.track));const o=yield this._createExchangeParams(r,!1),u=this._getPushOtherRoomsParams();u&&(o.pushOtherRooms=u);const d=yield this._exchangeHandle(o),l=r.map(R=>R.track.getTrackId());if(d.code!==I.SUCCESS)return{code:d.code};const{sdp:h,resultCode:a,message:c,subscribedList:p}=d.data;if(a!==I.SUCCESS)return b.error(`change subscribe list failed: ${a}`),{code:a};b.debug(`subscribe success: ${l.join(",")}`);const f=yield this._pc.setRemoteAnswer(h.sdp);if(f!==I.SUCCESS)return{code:f};const m=p==null?void 0:p.map(R=>`${R.msid}_${R.mediaType}`),_=r.filter(R=>m==null?void 0:m.includes(R.track.getTrackId())),v=r.filter(R=>!(m==null?void 0:m.includes(R.track.getTrackId())));for(const R in this._remoteTracks){const C=_.some(A=>A.track.getTrackId()===R);this._remoteTracks[R].__innerSetSubscribed(C)}return this._subscribedList.splice(0,this._subscribedList.length,..._),v.length?{code:I.SUCCESS,failedList:v}:{code:I.SUCCESS}})}registerRoomEventListener(e){this._appListener=e}registerReportListener(e){this._pc.registerReportListener(e)}onAudioLevelChange(e,t){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new gu(this),this._audioLevelReport.onAudioLevelChange(e,t||1e3)}__onReconnected(e){return F(this,void 0,void 0,function*(){if(this._pc.getRTCPeerConn().connectionState==="closed")return b.warn("RTCPeerConnection closed. Please rejoin room to restore services."),void this._rtcpeerClosed();const{code:t,data:r}=yield this._context.joinRTCRoom(this._roomId,this._roomMode,e);if(t!==S.SUCCESS)return void b.error(`RTC __onReconnected getRTCRoomInfo failed: ${t}`);b.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(r)}`);const i=[],s={},o={},u={},d=us(r),l=Object.keys(d),h=Object.keys(this._roomResources);for(let a=l.length-1;a>=0;a-=1){const c=l[a],p=h.indexOf(c);if(p===-1){i.push(c),s[c]=pr(d[c]);continue}const f=this._roomResources[c],m=d[c],{publishedList:_,modifiedList:v,unpublishedList:R}=Er(f,m,!0);s[c]=pr(_),o[c]=pr(R),u[c]=pr(v),h.splice(p,1)}h.length&&h.forEach(a=>{delete this._roomResources[a]}),Object.assign(this._roomResources,d),h.length&&this._callAppListener("onUserLeave",h),i.length&&this._callAppListener("onUserJoin",i);for(const a in o){const c=o[a];if(c.length){const p=c.map(f=>this._remoteTracks[he(f)]);yield this._onUserUnpublish(p)}}return Object.keys(s).forEach(a=>{const c=s[a];if(c.length===0)return;const p=c.map(f=>{const m=he(f),{userId:_,tag:v,mediaType:R}=$e(m),C=this._remoteTracks[m]=R===me.AUDIO_ONLY?new Tt(v,_):new St(v,_);return C.__innerSetRemoteMuted(f.state===0),C});this._onTrackPublish(p)}),Object.keys(u).forEach(a=>{u[a].forEach(c=>{const p=he(c),f=this._remoteTracks[p];f.__innerSetRemoteMuted(c.state===0),f.isAudioTrack()?this._onAudioMuteChange(f):this._onVideoMuteChange(f)})}),{data:r}})}_onAudioMuteChange(e){this._callAppListener("onAudioMuteChange",e)}_onVideoMuteChange(e){this._callAppListener("onVideoMuteChange",e)}_afterChangedRole(e){}_removeRemoteTracks(){const e=Object.values(this._remoteTracks);e.length&&(e.forEach(t=>{t.isAudioTrack()&&t.__releaseMediaElement()}),this._remoteTracks={})}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){}}var On,Xt,Hn;(function(n){n[n.CROP=1]="CROP",n[n.WHOLE=2]="WHOLE"})(On||(On={})),function(n){n[n.CUSTOMIZE=1]="CUSTOMIZE",n[n.SUSPENSION=2]="SUSPENSION",n[n.ADAPTATION=3]="ADAPTATION"}(Xt||(Xt={})),function(n){n[n.CROP=1]="CROP",n[n.WHOLE=2]="WHOLE"}(Hn||(Hn={}));const wa=()=>({version:1,mode:Xt.SUSPENSION});class ql{constructor(e,t,r){this._onFlush=e,this._isValidTrackId=t,this._sendCDNInfoSignal=r,this._values=wa()}setHostVideoTrack(e){if(!this._isValidTrackId(e))return b.error(`setHostVideoTrack failed: videoTrackId is invalid -> ${e}`),this;const{mediaType:t,tag:r,userId:i}=$e(e);return t!==me.VIDEO_ONLY?(b.error(`setHostVideoTrack failed: kind of resource is not 'video' -> ${e}`),this):(this._values.host_stream_id=bi(i,r),this)}setMixLayoutMode(e){return[Xt.CUSTOMIZE,Xt.SUSPENSION,Xt.ADAPTATION].includes(e)?(this._values.mode=e,this):(b.error(`layout mode is invalid: ${e}`),this)}_addOutputValue(e,t,r="normal"){const i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if(e==="cdn")return void(i.cdn=t);if(e==="audio")return void(i.audio={bitrate:t});const s=i.video;if(r!=="normal"&&r!=="tiny")if(r!=="backgroundColor")if(r!=="exparams"){if(r==="backgroundPicture"){const o=s.backgroundPicture||(s.backgroundPicture={fillMode:On.CROP,picture:[]});Object.assign(o,t)}}else s.exparams={renderMode:t};else s.backgroundColor=t;else{const o=s[r]||(s[r]={});Object.assign(o,t)}}setOutputVideoResolution(e){if(!Qt(e))return b.warn("setOutputVideoResolution failed: `resolution` is invalid"),this;const{width:t,height:r}=gt(e);return this._addOutputValue("video",{width:t,height:r},"normal"),this}setOutputVideoFPS(e){if(!as(e))return b.warn("setOutputVideoFPS failed: `fps` is invalid"),this;const t=mt(e);return this._addOutputValue("video",{fps:t},"normal"),this}setOutputVideoBitrate(e){return!Te(e)||e<=0?b.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"normal"),this}setOutputTinyVideoResolution(e){if(!Qt(e))return b.warn("setOutputTinyVideoResolution failed: `resolution` is invalid"),this;const{width:t,height:r}=gt(e);return this._addOutputValue("video",{width:t,height:r},"tiny"),this}setOutputTinyVideoFPS(e){if(!as(e))return b.warn("setOutputTinyVideoFPS failed: `fps` is invalid"),this;const t=mt(e);return this._addOutputValue("video",{fps:t},"tiny"),this}setOutputTinyVideoBitrate(e){return!Te(e)||e<=0?b.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"tiny"),this}setOutputVideoRenderMode(e){return[Hn.CROP,Hn.WHOLE].includes(e)?this._addOutputValue("video",e,"exparams"):b.error(`renderMode is invalid: ${e}`),this}setOutputAudioBitrate(e){return Te(e)&&e>0?this._addOutputValue("audio",e):b.error(`bitrate is invalid: ${e}`),this}setOutputBackgroundColor(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?this._addOutputValue("video",e,"backgroundColor"):b.error(`color is invalid: ${e}`),this}addOutputBackgroundPicture(e,t,r,i,s){var o,u,d;if(!Pn(e))return b.error(`uri is invalid: ${e}`),this;if([t,r,i,s].some(h=>!Te(h)||h<0||h>1))return b.error(`some attrs of (x, y, w, h) is invalid: ${t}, ${r}, ${i}, ${s}`),this;const l=((d=(u=(o=this._values.output)===null||o===void 0?void 0:o.video)===null||u===void 0?void 0:u.backgroundPicture)===null||d===void 0?void 0:d.picture)||[];return l.push({uri:e,w:i,h:s,x:t,y:r}),this._addOutputValue("video",{picture:l},"backgroundPicture"),this}removeOutputBackgroundPicture(e){var t,r,i;if(!Pn(e))return b.error(`uri is invalid: ${e}`),this;let s=(i=(r=(t=this._values.output)===null||t===void 0?void 0:t.video)===null||r===void 0?void 0:r.backgroundPicture)===null||i===void 0?void 0:i.picture;return s&&(s=s.filter(o=>o.uri!==e),this._addOutputValue("video",{pictures:s},"backgroundPicture")),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this}setOutputBackgroundPictureFillMode(e){return[On.CROP,On.WHOLE].includes(e)?this._addOutputValue("video",{fillMode:e},"backgroundPicture"):b.error(`fillMode is invalid: ${e}`),this}addPublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!Ye(e)||e.length===0||e.some(u=>!i.test(u)))return b.error(`urls is invalid: ${e}`),this;const s=((r=(t=this._values.output)===null||t===void 0?void 0:t.cdn)===null||r===void 0?void 0:r.concat())||[];let o=!1;return e.forEach(u=>{s.some(d=>d.pushurl===u)||(o=!0,s.push({pushurl:u}))}),s.length>5?(b.error("publish stream url no more than 5"),this):(o&&this._addOutputValue("cdn",s),this)}removePublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!Ye(e)||e.length===0||e.some(o=>!i.test(o)))return b.error(`urls is invalid: ${e}`),this;const s=((r=(t=this._values.output)===null||t===void 0?void 0:t.cdn)===null||r===void 0?void 0:r.concat())||[];for(let o=s.length-1;o>=0;o-=1){const{pushurl:u}=s[o],d=e.indexOf(u);d>=0&&(e.splice(d,1),s.splice(o,1))}return this._addOutputValue("cdn",s),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this}addCustomizeLayoutVideo(e,t,r,i,s){if(!this._isValidTrackId(e))return b.error(`trackId is invalid: ${e}`),this;if(!Te(t)||!Te(r))return b.error(`some attrs of (x, y) is invalid: ${t}, ${r}`),this;if([i,s].some(h=>!Te(h)||h<0))return b.error(`some attrs of (width, height) is invalid: ${i}, ${s}`),this;const{userId:o,tag:u,mediaType:d}=$e(e);if(d!==me.VIDEO_ONLY)return b.error(`kind of resource is not 'video': ${e}`),this;const l=bi(o,u);return(this._values.input||(this._values.input={video:[]})).video.push({user_id:o,stream_id:l,x:t,y:r,width:i,height:s}),this}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return b.error(`trackId is invalid: ${e}`),this;const{userId:t,tag:r,mediaType:i}=$e(e);if(i!==me.VIDEO_ONLY)return b.error(`kind of resource is not 'video': ${e}`),this;const s=bi(t,r),o=this._values.input||(this._values.input={video:[]});return o.video=o.video.filter(u=>u.stream_id===s),this}clearCustomizeLayoutVideo(){return(this._values.input||(this._values.input={video:[]})).video=[],this}flush(){var e,t,r,i;return F(this,void 0,void 0,function*(){const s=JSON.parse(JSON.stringify(this._values)),{code:o}=yield this._onFlush(s);return o===I.SUCCESS&&(((t=(e=this._values.output)===null||e===void 0?void 0:e.video.normal)===null||t===void 0?void 0:t.width)||((i=(r=this._values.output)===null||r===void 0?void 0:r.video.normal)===null||i===void 0?void 0:i.fps))&&this._sendCDNInfoSignal(),this._values=wa(),{code:o}})}}var Hr,$r,jr,ct;(function(n){n[n.OPEN=1]="OPEN",n[n.STOP=2]="STOP"})(Hr||(Hr={})),function(n){n[n.SPREAD=0]="SPREAD",n[n.NO_SPREAD=-1]="NO_SPREAD"}($r||($r={})),function(n){n[n.AUTOMATIC=0]="AUTOMATIC",n[n.MANUAL=1]="MANUAL"}(jr||(jr={})),function(n){n[n.VIDEO=0]="VIDEO",n[n.AUDIO=1]="AUDIO"}(ct||(ct={}));const _u=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){const e=16*Math.random()|0;return(n==="x"?e:3&e|8).toString(16)});class Gl{constructor(e,t,r,i,s,o,u,d){this._context=e,this._runtime=t,this._service=r,this._initOptions=i,this._mainLivingRoom=s,this._registerPKMsgListener=o,this._onJoinedPKRoom=u,this._onLeavePKRoom=d,this._inviteTimeout=30,this._PKInfo={},this._appListener=null,this._joinedPKRooms={},this._registerPKMsgListener(this._onRecvPKMsg.bind(this)),this._mainRoomId=this._mainLivingRoom.getRoomId()}_callAppListener(e,...t){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...t)}catch(s){b.error(s)}}_onInvite(e){const t=e.inviteInfo||{},{inviterRoomId:r,inviterUserId:i,extra:s}=t,o={inviterRoomId:r,inviterUserId:i};s&&Object.assign(o,{extra:s}),this._PKInfo[r]=t,this._callAppListener("onRequestJoinOtherRoom",o)}_onCancelInvite(e){const{inviterRoomId:t,inviterUserId:r,extra:i}=e.inviteInfo||{},s={inviterRoomId:t,inviterUserId:r};i&&Object.assign(s,{extra:i}),delete this._PKInfo[t],this._callAppListener("onCancelRequestOtherRoom",s)}_onInviteTimeout(e){}_onInviteAnswer(e){const{answerCode:t,inviteContent:r,inviteeUserAutoMix:i}=e,{inviterUserId:s,inviterRoomId:o,inviteeUserId:u,inviteeRoomId:d,extra:l}=r,h={agree:t===1,inviterRoomId:o,inviterUserId:s,inviteeRoomId:d,inviteeUserId:u};this._PKInfo[d].inviteeUserAutoMix=i,this._callAppListener("onResponseJoinOtherRoom",h)}_onPKEnd(e){return F(this,void 0,void 0,function*(){const{inviteeRoomId:t,inviterRoomId:r,userId:i}=e.inviteInfo,s=r===this._mainRoomId?t:r,o={endRoomId:s,endUserId:i};yield this.leaveOtherRoom(this._joinedPKRooms[s]),delete this._PKInfo[s],this._callAppListener("onFinishOtherRoom",o)})}_onRecvPKMsg(e){const{targetId:t,content:r,messageType:i}=e;switch(i){case oe.PK_INVITE:this._onInvite(r);break;case oe.PK_CANCEL_INVITE:this._onCancelInvite(r);break;case oe.PK_INVITE_TIMEOUT:this._onInviteTimeout(r);break;case oe.PK_INVITE_ANSWER:this._onInviteAnswer(r);break;case oe.PK_END:this._onPKEnd(r)}}registerRoomPKEventListener(e){this._appListener=e}requestJoinOtherRoom(e,t,r){return F(this,void 0,void 0,function*(){if(!Ee("inviteeRoomId",e,ze,!0)||!Ee("inviteeUserId",t,ze,!0))return{code:I.PARAMS_ERROR};b.debug(`requestRoomPK -> inviteeRoomId: ${e}; inviteeUserId: ${t}; options: ${JSON.stringify(r||{})}`);const i=_u(),s=!Sr(r==null?void 0:r.autoMix)||(r==null?void 0:r.autoMix),o={inviteSessionId:i,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(r==null?void 0:r.extra)||""},u={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(o),inviteSessionId:i};b.debug(`requestRoomPK -> params: ${JSON.stringify(u)}`);const d=yield this._context.requestRoomPK(u);return d!==S.SUCCESS?(b.error(`requestRoomPK failed: ${d}`),{code:d}):(b.debug("requestRoomPK success"),this._PKInfo[e]={inviteSessionId:i,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e},{code:I.SUCCESS})})}cancelRequestJoinOtherRoom(e,t,r){return F(this,void 0,void 0,function*(){if(!Ee("inviteeRoomId",e,ze,!0)||!Ee("inviteeUserId",t,ze,!0))return{code:I.PARAMS_ERROR};if(!this._PKInfo[e])return b.error(`\u672A\u53D1\u8D77\u8FC7\u4E0E ${e} \u623F\u95F4\u5185 ${t} \u8FDE\u9EA6\u7684\u8BF7\u6C42`),{code:I.PARAMS_ERROR};b.debug(`canceRequestJoinPK -> inviteeRoomId: ${e}; inviteeUserId: ${t}; extra: ${r}`);const i={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:r||""},s={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(i)};b.debug(`canceRequestJoinPK -> params: ${JSON.stringify(s)}`);const o=yield this._context.cancelRoomPK(s);return o!==S.SUCCESS?(b.error(`canceRequestJoinPK failed: ${o}`),{code:o}):(b.debug("canceRequestJoinPK success"),delete this._PKInfo[e],{code:I.SUCCESS})})}responseJoinOtherRoom(e,t,r,i){return F(this,void 0,void 0,function*(){if(!Ee("inviterRoomId",e,ze,!0)||!Ee("inviterUserId",t,ze,!0))return{code:I.PARAMS_ERROR};if(!this._PKInfo[e])return b.error(`${e} \u623F\u95F4\u5185\u7684 ${t} \u672A\u53D1\u8D77\u8FC7\u8FDE\u9EA6\u8BF7\u6C42`),{code:I.PARAMS_ERROR};b.debug(`responseRoomPK -> inviterRoomId: ${e}; inviterUserId: ${t}; agree: ${r}; options: ${JSON.stringify(i||{})}`);const{inviteSessionId:s,inviterUserAutoMix:o}=this._PKInfo[e],u=!Sr(i==null?void 0:i.autoMix)||(i==null?void 0:i.autoMix),d={inviteSessionId:s,inviterRoomId:e,inviterUserId:t,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:u},l=Object.assign(d,{inviterUserAutoMix:o}),h=r?Object.assign(d,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(l)}):d;!fe(i==null?void 0:i.extra)&&Object.assign(h,{extra:i.extra});const a={agree:r,roomId:this._mainRoomId,inviteSessionId:s,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(h),key:`${e}|${t}`,value:JSON.stringify(d)};b.debug(`responseRoomPK -> params: ${JSON.stringify(a)}`);const c=yield this._context.responseRoomPK(a);return c!==S.SUCCESS?(b.error(`responseRoomPK failed: ${c}`),{code:c}):(b.debug("responseRoomPK success"),this._PKInfo[e].inviteeUserAutoMix=u,{code:I.SUCCESS})})}_quitRoomPK(e){return F(this,void 0,void 0,function*(){const{inviterRoomId:t,inviteeRoomId:r,inviterUserId:i}=this._PKInfo[e],s={inviteeRoomId:r,inviterRoomId:t,userId:this._context.getCurrentId()},o={roomId:this._mainRoomId,endRoomId:e,sessionId:this._PKInfo[e].inviteSessionId,content:JSON.stringify(s),keys:[`${t}|${i}`]};b.debug(`quitRoomPK -> params: ${JSON.stringify(o)}`);const u=yield this._context.endRoomPK(o);return u!==S.SUCCESS?(b.error(`quitRoomPK failed: ${u}`),{code:I.SIGNAL_ERROR}):(b.debug("quitRoomPK success"),delete this._PKInfo[e],{code:I.SUCCESS})})}_relaseCrtRoom(){}joinOtherRoom(e){return F(this,void 0,void 0,function*(){if(!Ee("roomId",e,ze,!0))return{code:I.PARAMS_ERROR};if(this._context.getConnectionStatus()!==te.CONNECTED)return{code:I.SIGNAL_DISCONNECTED};if(b.debug(`joinPKRoom, roomId: ${e}`),this._joinedPKRooms[e])return{code:I.REPERT_JOIN_ROOM};const t=ct.VIDEO,{code:r,data:i}=yield this._context.joinRTCRoom(e,je.LIVE,t);if(r!==S.SUCCESS)return b.error(`joinRoom failed -> code: ${r}`),{code:r};b.debug(`JoinPKRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const s=new Nt(this._context,this._runtime,e,i,this._service,this._initOptions,this._relaseCrtRoom.bind(this),t,!1,!1);return this._joinedPKRooms[e]=s,this._onJoinedPKRoom(e,s),{room:s,code:I.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()}})}leaveOtherRoom(e,t){return F(this,void 0,void 0,function*(){return Se(()=>F(this,void 0,void 0,function*(){const r=e.getRoomId();return b.debug(`leavePKRoom -> userId: ${this._context.getCurrentId()} , roomId: ${r}`),yield e.__destroy(!0),delete this._joinedPKRooms[r],this._onLeavePKRoom(r),this._PKInfo[r]?(t&&this._quitRoomPK(r),{code:I.SUCCESS}):{code:I.SUCCESS}}))})}getPKInfo(e){return this._PKInfo[e]}getJoinedPKRooms(){return this._joinedPKRooms}}class Nt extends mu{constructor(e,t,r,i,s,o,u,d,l=!1,h){var a;super(e,t,r,i,je.LIVE,s,o,u,l,h),this._livingType=d,this._isMainRoom=h,this._CDNUris=null,this._CDNEnable=!1,this._mcuConfigBuilder=new ql(this._onMCUConfigFlush.bind(this),this._isValidResourceId.bind(this),this._sendCDNInfoSignal.bind(this)),this._isMainRoom&&(this._roomPKHandler=new Gl(e,t,s,o,this,super._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._onLeavePKRoom.bind(this)));const c=(a=i.roomInfo.filter(p=>p.key==="cdn_uris")[0])===null||a===void 0?void 0:a.value;c&&(this._CDNUris=JSON.parse(c)[0])}_isValidResourceId(e){var t;const{userId:r}=$e(e),i=!!((t=this._roomResources[r])===null||t===void 0?void 0:t.find(h=>he(h)===e));let s=!1;const{code:o,roomPKHandler:u}=this.getRoomPKHandler();if(o!==I.SUCCESS||!u)return i;const d=u.getJoinedPKRooms(),l=[];return Object.values(d).map(h=>{l.push(...h.getRemoteTracks())}),s=l.some(h=>e===h.getTrackId()),i||s}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._isMainRoom?this._mcuConfigBuilder:(b.error("the `getMCUConfigBuilder` is disabled in PK room "),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_onMCUConfigFlush(e){return F(this,void 0,void 0,function*(){const t={"App-Key":this._context.getAppkey(),Token:this._token,RoomId:this.getRoomId(),UserId:this._context.getCurrentId(),SessionId:this.getSessionId()},{code:r,res:i}=yield this._service.setMcuConfig(t,e);return r!==I.SUCCESS?(b.error(`set MCU config failed: ${r}`),{code:r}):(b.info("set MCU config success"),i.pull_url&&(this._CDNUris=JSON.parse(i.pull_url)),{code:r,res:i})})}__onReconnected(){const e=Object.create(null,{__onReconnected:{get:()=>super.__onReconnected}});var t,r;return F(this,void 0,void 0,function*(){const i=yield e.__onReconnected.call(this,this._livingType);if(!i||!i.data)return;const s=i.data.roomInfo,o=(t=s.filter(d=>d.key==="cdn_uris")[0])===null||t===void 0?void 0:t.value;if(!o)return;const u=JSON.parse(o);((r=this._CDNUris)===null||r===void 0?void 0:r.enableInnerCDN)!==u.enableInnerCDN&&this._callAppListener("onCDNEnableChange",u.enableInnerCDN),this._CDNUris=u})}enableInnerCDN(e){return F(this,void 0,void 0,function*(){if(!this._isMainRoom)return b.error("the `enableInnerCDN` is disabled in PK room "),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!Sr(e))return b.error("`enable` is invalid"),{code:I.PARAMS_ERROR};this._CDNEnable=e;const t={version:2,output:{inCDNModel:e?Hr.OPEN:Hr.STOP}},{code:r}=yield this._onMCUConfigFlush(t);if(r!==I.SUCCESS)return b.error(`enableInnerCDN failed -> code: ${r}`),{code:I.SIGNAL_ERROR};if(this._CDNUris&&this._CDNUris.broadcast!==$r.SPREAD)return b.info("enableInnerCDN succeed"),{code:I.SUCCESS};const{code:i}=yield Se(()=>F(this,void 0,void 0,function*(){return this._sendCDNInfoSignal()}));return i===I.SUCCESS?(b.info("enableInnerCDN succeed"),{code:I.SUCCESS}):(b.error(`enableInnerCDN failed -> code: ${i}`),{code:i})})}_sendCDNInfoSignal(){return F(this,void 0,void 0,function*(){return this._CDNUris=Object.assign({},this._CDNUris,{enableInnerCDN:this._CDNEnable}),(yield Promise.all([this._spreadCDNInfo(this._CDNUris),this._setRoomCDNInfo(this._CDNUris)])).every(e=>e.code===I.SUCCESS)?{code:I.SUCCESS}:{code:I.SIGNAL_ERROR}})}_spreadCDNInfo(e){return F(this,void 0,void 0,function*(){const t=yield this._context.setRTCCDNUris(this._roomId,oe.TOTAL_CONTENT_RESOURCE,JSON.stringify([e]));return t!==S.SUCCESS?(b.error(`spreadCDNInfo failed -> code: ${t}`),{code:I.SIGNAL_ERROR}):(b.info("spreadCDNInfo succeed"),{code:I.SUCCESS})})}_setRoomCDNInfo(e){return F(this,void 0,void 0,function*(){const t=yield this._context.setRTCData(this._roomId,"cdn_uris",JSON.stringify([e]),!0,ht.ROOM);return t!==S.SUCCESS?(b.error(`setRoomCDNInfo failed -> code: ${t}`),{code:I.SIGNAL_ERROR}):(b.info("setRoomCDNInfo succeed"),{code:I.SUCCESS})})}_resourceHandle(e,t,r){const i=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});var s;return F(this,void 0,void 0,function*(){i._resourceHandle.call(this,e,t,r),e.cdn_uris&&(((s=this._CDNUris)===null||s===void 0?void 0:s.enableInnerCDN)!==e.cdn_uris[0].enableInnerCDN&&this._callAppListener("onCDNEnableChange",!this.__getCDNEnable()),this._CDNUris=e.cdn_uris[0])})}_exchangeHandle(e){var t,r,i;return F(this,void 0,void 0,function*(){const s=yield this._service.exchange(this._getRTCReqestHeaders(),e),o=(r=(t=s.data)===null||t===void 0?void 0:t.urls)===null||r===void 0?void 0:r.pull_url;return s.code===I.SUCCESS&&o&&(this._CDNUris=JSON.parse(o),((i=this._CDNUris)===null||i===void 0?void 0:i.broadcast)===$r.SPREAD&&(this._CDNEnable=!0,this._sendCDNInfoSignal())),s})}_afterChangedRole(e){const t=us(e),r=this._context.getCurrentId(),i=Object.keys(t);setTimeout(()=>{var s,o,u;const d=i.filter(l=>l!==r);d.length>0&&this._callAppListener("onUserJoin",d);for(const l in t)l!==r&&this._resourceHandle({uris:t[l]},oe.TOTAL_CONTENT_RESOURCE,l);((s=e.roomInfo.filter(l=>l.key==="cdn_uris")[0])===null||s===void 0?void 0:s.value)&&((o=this._CDNUris)===null||o===void 0?void 0:o.push_mode)===jr.MANUAL&&this._callAppListener("onCDNEnableChange",(u=this._CDNUris)===null||u===void 0?void 0:u.enableInnerCDN)})}__getCDNEnable(){var e;return(e=this._CDNUris)===null||e===void 0?void 0:e.enableInnerCDN}__getCDNPushMode(){var e;return(e=this._CDNUris)===null||e===void 0?void 0:e.push_mode}_onJoinedPKRoom(e,t){const{code:r,roomPKHandler:i}=this.getRoomPKHandler();if(r===I.SUCCESS&&i){if(!i.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_onLeavePKRoom(e){const{code:t,roomPKHandler:r}=this.getRoomPKHandler();if(t===I.SUCCESS&&r){if(!r.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_exchangeWithPushOtherRoom(){return F(this,void 0,void 0,function*(){if(!this.getLocalTracks().length)return;const e=yield this._createExchangeParams(this._subscribedList,!1),t=this._getPushOtherRoomsParams();t&&(e.pushOtherRooms=t);const r=yield this._exchangeHandle(e);if(r.code!==I.SUCCESS)return b.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:s}=r.data;if(s!==I.SUCCESS)return b.error(`exchange with pushOtherRoom failed: ${s}`),{code:s};const o=yield this._pc.setRemoteAnswer(i.sdp);return o!==I.SUCCESS?{code:o}:void 0})}getRoomPKHandler(){return this._isMainRoom?{code:I.SUCCESS,roomPKHandler:this._roomPKHandler}:(b.error("the `getRoomPKHandler` is disabled in PK room "),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){const e=this._roomPKHandler.getJoinedPKRooms();for(const t in e){const r=e[t];this._roomPKHandler.leaveOtherRoom(r)}}}class Yl extends mu{constructor(e,t,r,i,s,o,u){super(e,t,r,i,je.RTC,s,o,u,!1)}}const Oi=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${st.browser}|${st.version}`,ClientVersion:"5.3.1","Client-Session-Id":_u(),"Request-Id":Date.now().toString()});class go{constructor(e,t,r,i=5e3){this._runtime=e,this._context=t,this._msUrl=r,this._timeout=i,this._msInNavi=[],this._failedMs=[],this._rtcFinger=void 0,this._clusterId="",this._configUrl=""}getNaviMS(){return this._msUrl?[this._msUrl]:this._clusterId?[`https://${this._clusterId}`]:(this._msInNavi.length===0&&(this._failedMs.length===0?this._msInNavi.push(...(e=>{var t;if(!e)return[];let r;try{r=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch{return b.warn("parse `voipCallInfo` of navi failed: "+e.voipCallInfo),[]}if(r.strategy===0)return[];const i=(t=r.callEngine)===null||t===void 0?void 0:t.filter(u=>u.engineType===4);if(!i||i.length===0)return[];const s=i[0],o=[];return s.mediaServer&&o.push(s.mediaServer.replace(/^(https?:\/\/)?/,"https://")),s.backupMediaServer&&s.backupMediaServer.forEach(u=>{o.push(u.replace(/^(https?:\/\/)?/,"https://"))}),o})(this._context.getNaviInfo())):(this._msInNavi.push(...this._failedMs),this._failedMs.length=0)),this._msInNavi.map(e=>e.trim()))}_request(e,t,r){return F(this,void 0,void 0,function*(){const i=this.getNaviMS();if(i.length===0)return{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(r.rtcFinger=this._rtcFinger);for(let s=0;s<i.length;s+=1){const o=`${i[s]}${e}`,u=Oi();b.debug(`request -> Request-Id: ${u["Request-Id"]}, url: ${o}`);const{status:d,data:l}=yield this._runtime.httpReq({url:o,body:JSON.stringify(r),headers:Object.assign(Object.assign({},u),t),method:ut.POST,timeout:this._timeout});if(d===200){const h=JSON.parse(l);return h.rtcFinger&&(this._rtcFinger=h.rtcFinger),h.clusterId&&(this._clusterId=h.clusterId),b.debug(`request success -> Request-Id: ${u["Request-Id"]}`),{code:I.SUCCESS,data:h}}b.warn(`request failed -> Request-Id: ${u["Request-Id"]}, status: ${d}, url: ${o}`),this._failedMs.push(...this._msInNavi.splice(s,1))}return{code:I.REQUEST_FAILED}})}exchange(e,t){var r;return F(this,void 0,void 0,function*(){const i=yield this._request("/exchange",e,t);if(i.code===I.SUCCESS&&((r=i.data)===null||r===void 0?void 0:r.resultCode)===I.SUCCESS){const s=i.data.urls;s&&(this._configUrl=s.configUrl)}return i})}exit(e){return F(this,void 0,void 0,function*(){const{code:t}=yield this._request("/exit",e,{});return t})}broadcastSubscribe(e,t){return this._request("/broadcast/subscribe",e,t)}broadcastExit(e){return F(this,void 0,void 0,function*(){const{code:t}=yield this._request("/broadcast/exit",e,{});return{code:t}})}setMcuConfig(e,t){return F(this,void 0,void 0,function*(){if(!this._configUrl)return{code:I.MCU_SERVER_NOT_FOUND};const r=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,i=Oi();b.debug(`request -> Request-Id: ${i["Request-Id"]}, url: ${r}`);const{status:s,data:o}=yield this._runtime.httpReq({url:r,headers:Object.assign(Object.assign({},i),e),body:JSON.stringify(t),method:ut.POST});if(s===200){b.debug(`request success -> Request-Id: ${i["Request-Id"]}`);const u=JSON.parse(o);return{code:u.resultCode,res:u}}return{code:I.REQUEST_FAILED}})}getCDNResourceInfo(e,t){return F(this,void 0,void 0,function*(){const r=Oi(),{status:i,data:s}=yield this._runtime.httpReq({url:t,headers:Object.assign(Object.assign({},r),e),method:ut.GET});if(i===200){const o=JSON.parse(s);return{code:o.resultCode,res:o}}return b.warn(`request failed -> Request-Id: ${r["Request-Id"]}, status: ${i}, url: ${t}`),{code:I.REQUEST_FAILED}})}}class Jl{constructor(e,t,r){this._context=e,this._rtcToken="",this._liveUrl="",this._subTracks=[],this._livingType=null,this._mediaType=null,this._subTiny=!1,this._fromRetry=!1,this._appListener=null,this._service=new go(t,e,r.mediaServer)}_getReqHeaders(e){return F(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),r=t;if(!this._rtcToken){const{code:i,data:s}=yield this._context.getRTCToken(r,je.LIVE,e);if(i!==S.SUCCESS)return b.error(`getRTCToken failed: ${i}`),{code:I.SIGNAL_ERROR};this._rtcToken=s.rtcToken}return{code:I.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:t,RoomId:r,RoomType:je.LIVE,Token:this._rtcToken}}})}_clearSubscribeInfo(){var e;this._liveUrl="",this._livingType=null,this._mediaType=null,this._subTiny=!1,this._subTracks.length=0,(e=this._pc)===null||e===void 0||e.destroy(),this._pc=null}_reTryExchange(){var e;return F(this,void 0,void 0,function*(){this._fromRetry=!0;const{code:t}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);t===I.SUCCESS&&((e=this._pc)===null||e===void 0||e.clearReTryExchangeTimer())})}subscribe(e,t,r,i=!1){return F(this,void 0,void 0,function*(){return Se(()=>this.__subscribe(e,t,r,i))})}__subscribe(e,t,r,i=!1){var s;return F(this,void 0,void 0,function*(){const o=[];if(Cr(this._context.getNaviInfo()))return{code:I.PACKAGE_ENVIRONMENT_ERROR,tracks:o};if(!this._fromRetry&&((s=this._pc)===null||s===void 0||s.clearReTryExchangeTimer()),this._fromRetry=!1,!Qe(e))return b.error(`liveUrl is invalid: ${e}`),{code:I.PARAMS_ERROR,tracks:o};if(![ct.AUDIO,ct.VIDEO].includes(t))return b.error(`livingType is invalid: ${t}`),{code:I.PARAMS_ERROR,tracks:o};if(![me.AUDIO_ONLY,me.VIDEO_ONLY,me.AUDIO_VIDEO].includes(r))return b.error(`mediaType is invalid: ${r}`),{code:I.PARAMS_ERROR,tracks:o};if(this._liveUrl&&this._liveUrl!==e)return{code:I.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:o};this._pc||(this._pc=new Rt(this._reTryExchange.bind(this)),this._pc.on(Rt.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this.registerReportListener(this._reportListener)),this._liveUrl=e;const{code:u,headers:d}=yield this._getReqHeaders(t);if(u!==I.SUCCESS)return{code:u,tracks:o};const l=`rc_mcu_${Date.now()}`,h="RongCloudRTC";this._subTracks.length===0&&(this._subTracks.push(new Tt(h,l),new St(h,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const a={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:r,simulcast:i?rt.TINY:rt.NORMAL,switchstream:!1},c=yield this._service.broadcastSubscribe(d,a);if(c.code!==I.SUCCESS)return b.error(`andience subscribe failed: ${c.code}`),{code:c.code,tracks:o};const p=c.data;if(p.resultCode!==I.SUCCESS)return b.error(`andience subscribe failed! code: ${p.resultCode}; message: ${p.message}`),{code:p.resultCode,tracks:o};b.debug(`andience subscribe success: ${e}`),this._livingType=t,this._mediaType=r,this._subTiny=i;const{sdp:f,subscribedList:m}=p,_=[];return m.forEach(v=>{const{mediaType:R}=v,C=this._subTracks[R];_.push(C),C.__innerSetRemoteMuted(!0)}),this._pc.setRemoteAnswer(f.sdp),{code:I.SUCCESS,tracks:_}})}unsubscribe(){return F(this,void 0,void 0,function*(){return Se(()=>this.__unsubscribe())})}__unsubscribe(){var e;return F(this,void 0,void 0,function*(){if((e=this._pc)===null||e===void 0||e.clearReTryExchangeTimer(),!this._rtcToken||!this._liveUrl)return{code:I.SUCCESS};const{headers:t}=yield this._getReqHeaders(),{code:r}=yield this._service.broadcastExit(t);return r!==I.SUCCESS?b.error(`broadcast unsubscribe failed: ${r}`):b.debug("broadcast unsubscribe success"),this._clearSubscribeInfo(),{code:r}})}registerReportListener(e){var t;this._reportListener=e,(t=this._pc)===null||t===void 0||t.registerReportListener(e)}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var t,r;const i=e.receiver.track,s=i.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY,o=this._subTracks[s];o.__innerSetMediaStreamTrack(i);try{(r=(t=this._appListener)===null||t===void 0?void 0:t.onTrackReady)===null||r===void 0||r.call(t,o)}catch(u){b.error(u)}}}var ds,Nn;(function(n){n.RTMP="rtmp",n.FLV="flv",n.HLS="hls"})(ds||(ds={})),function(n){n[n.NOT_HTTPS=0]="NOT_HTTPS",n[n.HTTPS=1]="HTTPS"}(Nn||(Nn={}));const Wl=Object.assign(Object.assign({},gt(Ce.W176_H144)),{frameRate:mt(ft.FPS_15)});class Aa{constructor(e,t,r,i,s,o){this._context=e,this._runtime=t,this._initOptions=r,this._roomId=i,this._joinResData=s,this._livingType=o,this._roomAnchorList=[],this._roomRes={},this._roomAnchorRes={},this._remoteTracks={},this._appListener=null,this._subscribedList=[],this._sessionId="",this._destroyed=!1,this._setInitData(),this._service=new go(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout),this._polarisReport=new fu(this._context,this._runtime,this._roomId,this,Br.Audience),this._polarisReport.sendR1(),this._pc=new Rt(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(Rt.__INNER_EVENT_TRACK_READY__,u=>{const d=u.streams[0].id,l=u.receiver.track,h=[d,l.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY].join("_"),a=this._remoteTracks[h];a?(a.__innerSetMediaStreamTrack(l),this._callAppListener("onTrackReady",a)):b.warn("cannot found RCRemoteTrack:",l.id)}),this._context.onrtcdatachange=this.singalDataChange.bind(this)}_setInitData(){const{sessionId:e,remoteUserIds:t,remoteRTCUris:r,remoteMUCUris:i,remoteTracks:s,CDNUris:o}=((u,d)=>{const l=d.filter(R=>R.key==="RC_RTC_SESSIONID")[0],h=l?l.value:"",a=d.filter(R=>R.key==="RC_ANCHOR_LIST").map(R=>JSON.parse(R.value||"[]"))[0],c=d.filter(R=>R.key.includes("RC_RES_")).map(R=>JSON.parse(R.value||"{}")),p=c.length?JSON.parse(c[0].mcu_uris||"[]"):[],f=[];p.forEach(R=>{const{mediaType:C,tag:A}=R,M=C===me.AUDIO_ONLY?new Tt(A,"",u):new St(A,"",u);f.push(M)});const m=[],_=[];c.forEach(R=>{const C=JSON.parse(R.uris||"[]");m.push(...C),C.forEach(A=>{const{mediaType:M,tag:O,msid:y}=A,w=y.split("_")[0],$=M===me.AUDIO_ONLY?new Tt(O,w):new St(O,w);_.push($)})});const v=d.filter(R=>R.key==="RC_CDN").map(R=>{const C=JSON.parse(R.value||"[]");return JSON.parse(C.cdn_uris)[0]})[0];return{sessionId:h,remoteUserIds:a||[],remoteRTCUris:m,remoteMUCUris:p,remoteRTCTracks:_,remoteMCUTracks:f,remoteTracks:[..._,...f],CDNUris:v||{}}})(this._roomId,this._joinResData.kvEntries);this._sessionId=e,this._roomAnchorList=t,s.forEach(u=>{this._remoteTracks[u.getTrackId()]=u}),this._CDNUris=o,r.forEach(u=>{const d=u.msid.split("_")[0];this._roomAnchorRes[d]?this._roomAnchorRes[d].push(u):this._roomAnchorRes[d]=[u]}),i.forEach(u=>{const{mediaType:d,tag:l}=u,h=[this._roomId,l,d].join("_");this._roomRes[h]=u}),r.forEach(u=>{const d=he(u);this._roomRes[d]=u})}_assertRoomDestroyed(){if(this._destroyed){const e="This room has been destroyed. Please use `RCRTCClient.joinLivingRoomAsAudience` to catch another instance.";return b.warn(e),I.ROOM_HAS_BEEN_DESTROYED}}singalDataChange(e,t){var r;if(t!==this._roomId)return void b.warn(`singalDataChange -> not the current room data: data roomId: ${t}, current roomId: ${this._roomId}`);b.debug("singalDataChange -> singalData:",JSON.stringify(e||{}));const i=[],s=(r=e.filter(o=>o.key==="RC_CDN")[0])===null||r===void 0?void 0:r.value;s&&this._diffCDNUris(JSON.parse(JSON.parse(s).cdn_uris)[0]),e.forEach(o=>{const{key:u,value:d,timestamp:l,uid:h}=o;if(u.indexOf("RC_RES_")!==-1){const a=JSON.parse(d||"{}"),c=JSON.parse(a.mcu_uris||"[]"),p=JSON.parse(a.uris||"[]");return i.push(...c),void this._diffAnchorResource(p,h)}if(u==="RC_ANCHOR_LIST"){const a=JSON.parse(d||"[]"),{joinUserIds:c,leftUserIds:p}=this._diffAnchorList(a);c.length>0&&this._handleNewJoinedAnchor(c),p.length>0&&this._handleLeftedAnchor(p)}}),this._diffRoomResource(i)}_diffAnchorList(e){const t=e.filter(r=>this._roomAnchorList.indexOf(r)<0);return{leftUserIds:this._roomAnchorList.filter(r=>e.indexOf(r)<0),joinUserIds:t}}_handleNewJoinedAnchor(e){this._roomAnchorList.push(...e),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e){return F(this,void 0,void 0,function*(){this._roomAnchorList=this._roomAnchorList.filter(r=>!(e.indexOf(r)>-1));const t=[];e.forEach(r=>{t.push(...this.getRemoteTracksByUserId(r)),delete this._roomAnchorRes[r]}),t.length&&(yield this.unsubscribe(t),t.forEach(r=>delete this._remoteTracks[r.getTrackId()])),this._callAppListener("onAnchorLeave",e)})}_diffRoomResource(e){return F(this,void 0,void 0,function*(){const t=[],r=[],i=[];e.forEach(s=>{const o=he(s),{userId:u,tag:d,mediaType:l}=$e(o),h=[this._roomId,d,l].join("_");if(!this._remoteTracks[h]){const a=l===me.AUDIO_ONLY?new Tt(d,"",this._roomId):new St(d,"",this._roomId);t.push(a),this._remoteTracks[h]=a,this._roomRes[a.getTrackId()]=s}i.push(h)}),Object.keys(this._remoteTracks).forEach(s=>{i.indexOf(s)<0&&this._remoteTracks[s].isMCUTrack()&&r.push(this._remoteTracks[s])}),t.length>0&&this._callAppListener("onTrackPublish",t),r.length>0&&this._onUserUnpublish(r,"onTrackUnpublish")})}_diffAnchorResource(e,t){return F(this,void 0,void 0,function*(){const r=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),{publishedList:i,unpublishedList:s,modifiedList:o}=Er(r,e);if(i.length){const u=r.map(he),d=[],l=[];if(i.forEach(h=>{const a=he(h),c=u.indexOf(a),{userId:p,tag:f,mediaType:m}=$e(a);c>-1?r[c]=h:r.push(h);let _=this._remoteTracks[a];this._roomRes[a]=h,_?_.isSubscribed()&&d.push(_):(_=m===me.AUDIO_ONLY?new Tt(f,p):new St(f,p),this._remoteTracks[a]=_,l.push(_)),_.__innerSetRemoteMuted(h.state===0)}),d.length){const h=d.map(c=>c.getTrackId());b.debug(`resub tracks -> ${JSON.stringify(h)}`);const{code:a}=yield Se(()=>this._subscribeHandle(d,!0));a!==I.SUCCESS&&b.error(`resub tracks failed -> code: ${a}, ids: ${JSON.stringify(h)}`)}this._callAppListener("onAnchorTrackPublish",l)}if(s.length){const u=s.map(he);for(let l=r.length-1;l>=0;l-=1){const h=r[l];u.includes(he(h))&&r.splice(l,1)}const d=s.map(l=>{const h=he(l);return this._remoteTracks[h]});yield this._onUserUnpublish(d,"onAnchorTrackUnpublish")}if(o.length){const u=r.map(he);for(let d=0;d<o.length;d++){const l=o[d],h=he(l),a=u.indexOf(h);r[a].state=l.state;const c=this._remoteTracks[h];c.__innerSetRemoteMuted(l.state===0),c.isAudioTrack()?this._callAppListener("onAudioMuteChange",c):this._callAppListener("onVideoMuteChange",c)}}})}_onUserUnpublish(e,t){return F(this,void 0,void 0,function*(){yield this.unsubscribe(e),e.forEach(r=>{this._subscribedList=this._subscribedList.filter(i=>i.track.getTrackId()!==r.getTrackId()),delete this._roomRes[r.getTrackId()],r.__innerDestroy(),delete this._remoteTracks[r.getTrackId()]}),this._callAppListener(t,e)})}_callAppListener(e,...t){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...t)}catch(s){b.error(s)}}_reTryExchange(){return F(this,void 0,void 0,function*(){Se(()=>F(this,void 0,void 0,function*(){var e;const{reqBody:t}=yield this._createSubscribeParams(this._subscribedList,{},!0),r=yield this._exchangeHandle(t);if(r.code!==I.SUCCESS)return b.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:s}=r.data;if(s!==I.SUCCESS)return b.error(`reTryExchange failed: ${s}`),{code:s};this._pc.clearReTryExchangeTimer();const o=this._subscribedList.filter(d=>d.track.isMCUTrack());if(o.length>0){const d=o[0].track.getTrackId(),l=(e=this._roomRes[d])===null||e===void 0?void 0:e.msid,h=[this._roomId,"RongCloudRTC"].join("_");i.sdp=i.sdp.replace(new RegExp(l,"g"),h)}const u=yield this._pc.setRemoteAnswer(i.sdp);return u!==I.SUCCESS?{code:u}:void 0}))})}_createSubscribeParams(e,t,r){return F(this,void 0,void 0,function*(){const i=yield this._pc.createOffer(r),s={resolutionInfo:[]},o={min:0,max:0};return Object.keys(t).forEach(u=>{const{mediaStream:d,tinyStream:l}=t[u];[d,l].forEach((h,a)=>{var c;const p=a===1?[u,"tiny"].join("_"):u;i.sdp=(c=i.sdp)===null||c===void 0?void 0:c.replace(new RegExp(h.id,"g"),p);const f=h.getVideoTracks()[0];if(!f)return;const m=a===0,{width:_,height:v,frameRate:R}=m?po(f):Wl;s.resolutionInfo.push({trackId:f.id,simulcast:m?rt.NORMAL:rt.TINY,resolution:`${_}x${v}`});const C=uu(_,v),A=du(R);o.min+=C.minBitrate*A,o.max+=C.maxBitrate*A})}),{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map(u=>({simulcast:u.subTiny?rt.TINY:rt.NORMAL,resolution:"",uri:this._roomRes[u.track.getTrackId()].uri}))},dynamicBitrate:o,offer:i}})}_subscribeHandle(e,t=!1){var r;return F(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:I.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>Ye(e)&&e.length>0&&e.every(d=>d instanceof xe||d.track instanceof xe),!0))return{code:I.PARAMS_ERROR};const i=this._subscribedList.map(d=>Object.assign({},d)),s=e.map(d=>d instanceof xe?{track:d}:d);let o=!1;const u=[];return s.forEach(d=>{const l=d.track.getTrackId();u.push(l);const h=i.find(a=>a.track.getTrackId()===l);h&&h.subTiny===d.subTiny||(h?h.subTiny=d.subTiny:i.push(d),o=!0)}),o||t?((r=this._polarisReport)===null||r===void 0||r.sendR2(bt.SUBSCRIBE,Ot.BEGIN,u),this._updateSubListHandle(i,!0)):{code:I.SUCCESS}})}_getReqHeaders(){const e=this._context.getCurrentId();return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:je.LIVE,UserId:e,"Session-Id":this._sessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_updateSubListHandle(e,t=!1){var r;return F(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:I.ROOM_HAS_BEEN_DESTROYED};if(!Ee("resources",e,()=>Ye(e)&&e.every(R=>R instanceof xe||R.track instanceof xe),!0))return{code:I.PARAMS_ERROR};let i=e.map(R=>R instanceof xe?{track:R}:Object.assign({},R));const s={};i=i.filter(R=>{const C=R.track.getTrackId();return!s[C]&&(s[C]=!0)}).map(R=>Object.assign({},R));const o=this._subscribedList.map(R=>Object.assign({},R));if(!t){let R=!1;if(i.forEach(C=>{const A=o.findIndex(M=>M.track===C.track);if(A===-1)return void(R=!0);o.splice(A,1)[0].subTiny!==C.subTiny&&(R=!0)}),o.length&&(R=!0),!R)return{code:I.SUCCESS}}this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(i.map(R=>R.track));const{reqBody:u}=yield this._createSubscribeParams(i,{},!1),d=yield this._exchangeHandle(u);if(o.length){const R=[];o.forEach(C=>{R.push(C.track.getTrackId())}),(r=this._pc.reportParser)===null||r===void 0||r.clearLatestPacketsRecv(R)}if(d.code!==I.SUCCESS)return{code:d.code};const{sdp:l,resultCode:h,message:a,subscribedList:c}=d.data;if(h!==I.SUCCESS)return b.error("change subscribe list failed:",a,h),{code:h};i.forEach(R=>{const{track:C}=R;if(C.isMCUTrack()){const A=this._roomRes[C.getTrackId()].msid,{tag:M,userId:O}=$e(C.getTrackId()),y=[O,M].join("_");l.sdp=l.sdp.replace(new RegExp(A,"g"),y)}});const p=yield this._pc.setRemoteAnswer(l.sdp);if(p!==I.SUCCESS)return{code:p};const f=c==null?void 0:c.map(R=>`${R.msid}_${R.mediaType}`),m=i.filter(R=>{if(R.track.isMCUTrack()){const C=this._roomRes[R.track.getTrackId()],A=`${C.msid}_${C.mediaType}`;return f.includes(A)}return f==null?void 0:f.includes(R.track.getTrackId())}),_=m==null?void 0:m.map(R=>`${R.track.getTrackId()}`),v=i.filter(R=>!(_==null?void 0:_.includes(R.track.getTrackId())));for(const R in this._remoteTracks){const C=m.some(A=>A.track.getTrackId()===R);this._remoteTracks[R].__innerSetSubscribed(C)}return this._subscribedList.splice(0,this._subscribedList.length,...m),v.length?{code:I.SUCCESS,failedList:v}:{code:I.SUCCESS}})}_diffCDNUris(e){return F(this,void 0,void 0,function*(){if(this._CDNUris.url&&!e.url)return this._callAppListener("onCDNInfoDisable"),void(this._CDNUris=e);(!this._CDNUris||!this._CDNUris.url&&e.url)&&this._callAppListener("onCDNInfoEnable",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`});const t=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,r=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,i=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps;(t||r||i)&&this._callAppListener("onCDNInfoChange",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),this._CDNUris=e})}_getCDNPlayUrl(e){return F(this,void 0,void 0,function*(){const{w:t,h:r,fps:i}=e,s=this._initOptions.pullInnerCDNProtocol||ds.FLV,o=this._initOptions.pullInnerCDNUseHttps===Nn.NOT_HTTPS?Nn.NOT_HTTPS:Nn.HTTPS;if(!this._CDNUris.url)return b.error(`cdn_uris url is empty, the anchor need to open or push CDN, code: ${I.CDN_RESOURCE_IS_EMPTY}`),{code:I.CDN_RESOURCE_IS_EMPTY};const u={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._context.getCurrentId(),SessionId:this.getSessionId()},d=[];t&&d.push(`w=${t}`),r&&d.push(`h=${r}`),i&&d.push(`fps=${i}`),d.push(`kind=${s}`),d.push(`is_https=${o}`);const l=d.join("&");let h=`${this._CDNUris.url}?`;l&&(h+=l);const{code:a,res:c}=yield this._service.getCDNResourceInfo(u,h);return a!==I.SUCCESS?(b.error(`getCDNPlayUrl failed: ${a}`),{code:a}):(b.info(`getCDNPlayUrl success: ${c==null?void 0:c.data.pull_url}`),{code:a,CDNPlayUrl:c==null?void 0:c.data.pull_url})})}getCDNPlayUrl(e,t){return F(this,void 0,void 0,function*(){if(e&&!Qt(e))return b.error("`resolution` is invalid"),{code:I.PARAMS_ERROR};if(t&&!as(t))return b.error("`fps` is invalid"),{code:I.PARAMS_ERROR};const{width:r,height:i}=e?gt(e):{width:null,height:null},s=t?mt(t):null,o={};return r&&(o.w=r),i&&(o.h=i),s&&(o.fps=s),this._getCDNPlayUrl(o)})}subscribe(e){return F(this,void 0,void 0,function*(){return Se(()=>this._subscribeHandle(e,!1))})}__unsubscribe(e){var t;return F(this,void 0,void 0,function*(){if(!Ee("tracks",e,()=>Ye(e)&&e.length>0&&e.every(i=>i instanceof xe),!0))return b.error(`unsubscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:I.PARAMS_ERROR};const r=this._subscribedList.map(i=>Object.assign({},i)).filter(i=>!e.includes(i.track));return(t=this._polarisReport)===null||t===void 0||t.sendR2(bt.SUBSCRIBE,Ot.END,e.map(i=>i.getTrackId())),this._updateSubListHandle(r,!1)})}unsubscribe(e){return F(this,void 0,void 0,function*(){return Se(()=>this.__unsubscribe(e))})}__destroy(e){var t;return F(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(t=this._audioLevelReport)===null||t===void 0||t.clearAudioLevelReportTimer(),e&&(yield this._context.quitLivingRoomAsAudience(this._roomId)),yield this._service.broadcastExit(this._getReqHeaders()),this._pc.destroy(),this._polarisReport=null,this._context.onrtcdatachange=()=>{})})}getRemoteTrack(e){return this._remoteTracks[e]}__getPC(){return this._pc}getLocalTrack(e){return{}}__onReconnected(){return F(this,void 0,void 0,function*(){const{code:e}=yield this._context.joinLivingRoomAsAudience(this._roomId,je.LIVE);e!==S.SUCCESS&&b.error("join living room error when on reconnected")})}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,t){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new gu(this),this._audioLevelReport.onAudioLevelChange(e,t||1e3)}registerReportListener(e){var t;(t=this._pc)===null||t===void 0||t.registerReportListener(e)}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}getSessionId(){return this._sessionId}getRemoteUserIds(){return this._roomAnchorList}getRemoteTracksByUserId(e){const t=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getRemoteTracks(){const e=[],t=[];for(const r in this._remoteTracks){if(t.length===2)break;const i=this._remoteTracks[r];i.isMCUTrack()&&t.push(i)}return this._roomAnchorList.forEach(r=>{e.push(...this.getRemoteTracksByUserId(r))}),[...t,...e]}getRemoteRTCTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()||e.push(r)}return e}getRemoteMCUTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()&&e.push(r)}return e}getCDNInfo(){return this._CDNUris.w?{resolution:`W${this._CDNUris.w}_H${this._CDNUris.h}`,fps:`FPS_${this._CDNUris.fps}`,CDNEnable:this._CDNUris.enableInnerCDN}:{CDNEnable:!1}}}const Ma=(n,e)=>{const t=[];return t[0]=(e==null?void 0:e.withoutAudio)?void 0:n.getAudioTracks()[0],t[1]=(e==null?void 0:e.withoutVideo)?void 0:n.getVideoTracks()[0],t};class zl{constructor(e,t,r){this._context=e,this._runtime=t,this._options=r,this._crtRoom=null,this._audience=null,this._crtAudienceLivingRoom=null,un.setSdpSemantics(r.sdpSemantics||"plan-b"),this._service=new go(this._runtime,this._context,this._options.mediaServer,this._options.timeout),this._context.onconnectionstatechange=this._onIMStatusChange.bind(this),this._context.ondisconnect=this._onIMDisconnect.bind(this),this._context.ondestroy=this._onIMUninit.bind(this),this._context.onmessage=this._handleMessage.bind(this)}_handleMessage(e){var t;return e.conversationType!==z.RTC_ROOM?!1:(this._crtRoom instanceof Nt&&this._getJoinedPKRoomList().forEach(r=>{r.__parseInnerMessage(e)}),(t=this._crtRoom)===null||t===void 0||t.__parseInnerMessage(e),!0)}_getJoinedPKRoomList(){const{code:e,roomPKHandler:t}=this._crtRoom.getRoomPKHandler();if(e===I.SUCCESS&&t){const r=t.getJoinedPKRooms()||{};return Object.values(r)}return[]}getCurrentId(){return this._context.getCurrentId()}joinRTCRoom(e,t){return Se(()=>this._joinRTCRoom(e,t))}_joinRTCRoom(e,t){return F(this,void 0,void 0,function*(){if(Cr(this._context.getNaviInfo()))return{code:I.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,ze,!0))return{code:I.PARAMS_ERROR};if(this._crtRoom)return{code:I.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==te.CONNECTED)return{code:I.SIGNAL_DISCONNECTED};if(!this._service.getNaviMS().length)return{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};b.debug(`joinRoom -> roomId: ${e}; joinType: ${t||Ki.KICK}`);const{code:r,data:i}=yield this._context.joinRTCRoom(e,je.RTC,void 0,t);if(r!==S.SUCCESS)return b.error(`joinRoom failed -> code: ${r}`),{code:r===Zi.JOIN_REFUSED?I.SIGNAL_JOIN_RTC_ROOM_REFUSED:r};b.debug(`joinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const s=new Yl(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this));return this._crtRoom=s,{room:s,code:I.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()}})}joinLivingRoom(e,t){return Se(()=>this._joinLivingRoom(e,t))}_joinLivingRoom(e,t){return F(this,void 0,void 0,function*(){if(Cr(this._context.getNaviInfo()))return{code:I.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,ze,!0)||!Ee("livingType",t,u=>u===ct.AUDIO||u===ct.VIDEO))return{code:I.PARAMS_ERROR};if(this._crtRoom)return{code:I.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==te.CONNECTED)return{code:I.SIGNAL_DISCONNECTED};if(!this._service.getNaviMS().length)return{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};b.debug(`joinRoom, roomId: ${e}`);const{code:r,data:i}=yield this._context.joinRTCRoom(e,je.LIVE,t);if(r!==S.SUCCESS)return b.error(`joinRoom failed -> code: ${r}`),{code:r};b.debug(`JoinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const s=new Nt(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this),t,!1,!0);this._crtRoom=s;const o={room:s,code:I.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()};return s.__getCDNPushMode()===jr.MANUAL&&Object.assign(o,{CDNEnable:s.__getCDNEnable()}),o})}getAudienceClient(){return this._audience||(this._audience=new Jl(this._context,this._runtime,this._options)),this._audience}_onIMStatusChange(e){b.debug(`signal server connection state change: ${e}`),e===te.CONNECTED&&(this._crtRoom instanceof Nt&&this._getJoinedPKRoomList().forEach(t=>{t.__onReconnected()}),this._crtRoom&&this._crtRoom.__onReconnected())}_onIMDisconnect(){b.debug("TODO -> on IM disconnect")}_onIMUninit(){b.debug("TODO -> on IM client ondestroy")}leaveRoom(e){return Se(()=>this._leaveRoom(e))}_leaveRoom(e){return F(this,void 0,void 0,function*(){return this._crtRoom?(yield this._crtRoom.__destroy(!0),b.debug(`quitRTCRoom -> userId: ${this._context.getCurrentId()} , roomId: ${this._crtRoom.getRoomId()}`),this._crtRoom=null,{code:I.SUCCESS}):{code:I.SUCCESS}})}_releaseCrtRoomObj(){this._crtRoom=null}_getMediaStream(e,t="getUserMedia"){return F(this,void 0,void 0,function*(){try{const r=yield navigator.mediaDevices[t](e);return{code:I.SUCCESS,stream:r}}catch(r){if(r.message==="Permission denied")return{code:I.PERMISSION_DENIED};b.error(`get user media failed -> ${r.message}`)}return{code:t==="getUserMedia"?I.GET_USER_MEDIA_FAILED:I.GET_DISPLAY_MEDIA_FAILED}})}createMicrophoneAudioTrack(e="RongCloudRTC",t){return F(this,void 0,void 0,function*(){if(!Ct(e))return{code:I.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:I.INVALID_USER_ID};const{stream:i,code:s}=yield this._getMediaStream({audio:{deviceId:t==null?void 0:t.micphoneId,sampleRate:t==null?void 0:t.sampleRate}});if(s!==I.SUCCESS)return{code:s};const o=i.getAudioTracks()[0];return{code:s,track:new Ia(e,r,o)}})}createCameraVideoTrack(e="RongCloudRTC",t){return F(this,void 0,void 0,function*(){if(!Ct(e))return{code:I.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:I.INVALID_USER_ID};const i=Qt(t==null?void 0:t.resolution)?t.resolution:Ce.W640_H480,{width:s,height:o}=gt(i),{stream:u,code:d}=yield this._getMediaStream({video:{deviceId:t==null?void 0:t.cameraId,frameRate:mt((t==null?void 0:t.frameRate)||ft.FPS_15),width:s,height:o,facingMode:t==null?void 0:t.faceMode}});if(d!==I.SUCCESS)return{code:d};const l=u.getVideoTracks()[0];return{code:d,track:new ba(e,r,l)}})}createMicrophoneAndCameraTracks(e="RongCloudRTC",t){var r,i,s,o,u,d;return F(this,void 0,void 0,function*(){const l=[];if(!Ct(e))return{code:I.INVALID_TAGS,tracks:l};const h=this._context.getCurrentId();if(!h)return{code:I.INVALID_USER_ID,tracks:l};const a=Qt((r=t==null?void 0:t.video)===null||r===void 0?void 0:r.resolution)?t.video.resolution:Ce.W640_H480,{width:c,height:p}=gt(a),{stream:f,code:m}=yield this._getMediaStream({video:{deviceId:(i=t==null?void 0:t.video)===null||i===void 0?void 0:i.cameraId,frameRate:mt(((s=t==null?void 0:t.video)===null||s===void 0?void 0:s.frameRate)||ft.FPS_15),width:c,height:p,facingMode:(o=t==null?void 0:t.video)===null||o===void 0?void 0:o.faceMode},audio:{deviceId:(u=t==null?void 0:t.audio)===null||u===void 0?void 0:u.micphoneId,sampleRate:(d=t==null?void 0:t.audio)===null||d===void 0?void 0:d.sampleRate}});return m!==I.SUCCESS||f.getTracks().forEach(_=>{_.kind==="video"?l.push(new ba(e,h,_)):l.unshift(new Ia(e,h,_))}),{code:m,tracks:l}})}createScreenVideoTrack(e="screenshare",t){return F(this,void 0,void 0,function*(){if(!Ct(e))return{code:I.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:I.INVALID_USER_ID};if(!hu())return{code:I.BROWSER_NOT_SUPPORT};const i=/Electron/.test(navigator.userAgent);if(i&&!(t==null?void 0:t.chromeMediaSourceId))return{code:I.PARAMS_ERROR};const s=Qt(t==null?void 0:t.resolution)?t.resolution:Ce.W1280_H720,{width:o,height:u}=gt(s),d=i?{mandatory:{chromeMediaSourceId:t.chromeMediaSourceId,chromeMediaSource:"desktop",minWidth:o,maxWidth:o,minHeight:u,maxHeight:u}}:{frameRate:mt((t==null?void 0:t.frameRate)||ft.FPS_15),width:o,height:u},{stream:l,code:h}=yield this._getMediaStream({video:d,audio:!1},i?"getUserMedia":"getDisplayMedia");if(h!==I.SUCCESS)return{code:h};const a=l.getVideoTracks()[0];return{code:h,track:new Ul(e,r,a)}})}createLocalAudioTrack(e,t){return F(this,void 0,void 0,function*(){if(!Ct(e))return{code:I.INVALID_TAGS};if(!t||t.toString()!=="[object MediaStreamTrack]"||t.kind!=="audio")return{code:I.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:I.SUCCESS,track:new os(e,r,t)}:{code:I.INVALID_USER_ID}})}createLocalVideoTrack(e,t){return F(this,void 0,void 0,function*(){if(!Ct(e))return{code:I.INVALID_TAGS};if(!t||t.toString()!=="[object MediaStreamTrack]"||t.kind!=="video")return{code:I.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:I.SUCCESS,track:new tn(e,r,t)}:{code:I.INVALID_USER_ID}})}createLocalFileTracks(e,t,r){return F(this,void 0,void 0,function*(){if(!Ct(e))return{code:I.INVALID_TAGS,tracks:[]};if(!lu())return{code:I.BROWSER_NOT_SUPPORT,tracks:[]};const i=t instanceof File?URL.createObjectURL(t):t;if(!Pn(i)&&!/^blob:/.test(i))return b.warn(`createLocalFileTracks failed: params error -> url: ${i}`),{code:I.PARAMS_ERROR,tracks:[]};const s=this._context.getCurrentId();return s?new Promise(o=>{const u=document.createElement("video");(r==null?void 0:r.withoutAudio)&&(u.muted=!0),u.onloadedmetadata=()=>{const d=[];let l;try{const c=u.mozCaptureStream?"mozCaptureStream":"captureStream";l=u[c]()}catch(c){b.error(`create RCLocalFileTrack failed, captureSteam error. -> url: ${i}`),b.error(c),o({code:I.CREATE_FILE_TRACK_FAILED,tracks:d})}const[h,a]=Ma(l,r);h&&d.push(new kl(e,s,h,u)),a&&d.push(new Ll(e,s,a,u)),d.length===0&&(u.pause(),u.src=""),u.onerror=null,o({code:I.SUCCESS,tracks:d})},u.onerror=()=>{b.error(`create RCLocalFileTrack failed -> url: ${i}`),o({code:I.CREATE_FILE_TRACK_FAILED,tracks:[]})},u.src=i,u.loop=!0,u.play()}):{code:I.INVALID_USER_ID,tracks:[]}})}createLocalTracks(e,t,r){return F(this,void 0,void 0,function*(){const i=[];if(!Ct(e))return{code:I.INVALID_TAGS,tracks:i};if(!(t instanceof MediaStream))return{code:I.PARAMS_ERROR,tracks:i};const s=this._context.getCurrentId();if(!s)return{code:I.INVALID_USER_ID,tracks:i};const[o,u]=Ma(t,r);return o&&i.push(new os(e,s,o)),u&&i.push(new tn(e,s,u)),{code:I.SUCCESS,tracks:i}})}joinLivingRoomAsAudience(e,t){return F(this,void 0,void 0,function*(){if(Cr(this._context.getNaviInfo()))return{code:I.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,ze,!0)||!Ee("livingType",t,o=>o===ct.AUDIO||o===ct.VIDEO))return{code:I.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return{code:I.REPERT_JOIN_ROOM};if(!this._service.getNaviMS().length)return{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:r,data:i}=yield this._context.joinLivingRoomAsAudience(e,je.LIVE,t);if(r!==S.SUCCESS)return b.error("audienceJoinLivingRoomError:",r),{code:I.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};b.info(`joinLivingRoomAsAudience success, room data: ${JSON.stringify(i)}`);const s=new Aa(this._context,this._runtime,this._options,e,i,t);return this._crtAudienceLivingRoom=s,{room:s,code:I.SUCCESS,userIds:s.getRemoteUserIds(),RTCTracks:s.getRemoteRTCTracks(),MCUTracks:s.getRemoteMCUTracks(),CDNUris:s.getCDNInfo()}})}leaveLivingRoomAsAudience(e){return F(this,void 0,void 0,function*(){return this._crtAudienceLivingRoom?this._crtAudienceLivingRoom!==e?{code:I.PARAMS_ERROR}:(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,{code:I.SUCCESS}):{code:I.SUCCESS}})}upgradeToAnchorRoom(e){return F(this,void 0,void 0,function*(){if(!Ee("room._roomId",e._roomId,ze,!0))return{code:I.PARAMS_ERROR};if(this._crtRoom)return{code:I.REPERT_JOIN_ROOM};const{code:t,data:r}=yield this._context.rtcIdentityChange(e._roomId,br.ViewerToAnchor,e._livingType);if(t!==S.SUCCESS)return b.error("change room identity error",t),{code:I.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};yield this._crtAudienceLivingRoom.__destroy(!1);const i=new Nt(this._context,this._runtime,e._roomId,r,this._service,this._options,this._releaseCrtRoomObj.bind(this),e._livingType,!0,!0);return this._crtRoom=i,this._crtAudienceLivingRoom=null,{room:i,code:I.SUCCESS,userIds:e.getRemoteUserIds(),tracks:i.getRemoteTracks()}})}downgradeToAudienceRoom(e){return F(this,void 0,void 0,function*(){if(!Ee("room._roomId",e._roomId,ze,!0))return{code:I.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return{code:I.REPERT_JOIN_ROOM};const{code:t,data:r}=yield this._context.rtcIdentityChange(e._roomId,br.AnchorToViewer,e.getLivingType());if(t!==S.SUCCESS)return b.error("change room identity error",t),{code:I.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};b.info(`downgradeToAudienceRoom success, room data: ${JSON.stringify(r)}`);const i=new Aa(this._context,this._runtime,this._options,e._roomId,r,e.getLivingType());return this._crtAudienceLivingRoom=i,this._crtRoom.__destroy(!1),this._crtRoom=null,{room:i,code:I.SUCCESS,userIds:i.getRemoteUserIds(),RTCTracks:i.getRemoteRTCTracks(),MCUTracks:i.getRemoteMCUTracks(),CDNUris:i.getCDNInfo()}})}getJoinedRoomInfo(){return F(this,void 0,void 0,function*(){const{code:e,data:t}=yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());return e!==S.SUCCESS?(b.error("getJoinedUserInfo error",e),{code:I.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}):{code:I.SUCCESS,data:t}})}}var Pa;(function(n){n[n.SERVER_KICK=1]="SERVER_KICK",n[n.OTHER_KICK=2]="OTHER_KICK"})(Pa||(Pa={}));const Ql={tag:"RCRTC",verify:n=>n.tag!=="browser"?(b.error(`RCRTC Plugin is not support the runtime '${n.tag}'`),!1):Dl?(Dt.add("plugin-rtc","5.3.1"),!!Dt.validEngine("5.1.0")||(b.error(`The current engine version '${Dt.getInfo().engine}' error, plugin-rtc required engine version at least '5.1.0'.`),!1)):(b.error("Please use the https protocol or use `http://localhost` to open the page!"),!1),setup:(n,e,t={})=>(b.setLogLevel(t.logLevel),b.setLogStdout(t.logStdout),b.warn("RCRTC Version: 5.3.1, Commit: e1af0f5ccb06a0084c94e1219d8af54c9793c06b"),b.warn(`browserInfo.browser -> ${st.browser}`),b.warn(`browserInfo.supportsUnifiedPlan -> ${st.supportsUnifiedPlan}`),b.warn(`browserInfo.version -> ${st.version}`),Ue("options.mediaServer",t.mediaServer,r=>!(!Pn(r)||location.protocol==="https:"&&!/^https/.test(r))),Ue("options.timeout",t.timeout,r=>Te(r)&&r>=5e3&&r<=3e4),Ue("options.pingGap",t.pingGap,r=>Te(r)&&r>=3e3&&r<=1e4),new zl(n,e,t))},Xl={transResolution:gt,transFrameRate:mt,parseTrackId:$e,ifSupportLocalFileTrack:lu,ifSupportScreenShare:hu};function Zl(n){return{all:n=n||new Map,on:function(e,t){var r=n.get(e);r?r.push(t):n.set(e,[t])},off:function(e,t){var r=n.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var r=n.get(e);r&&r.slice().map(function(i){i(t)}),(r=n.get("*"))&&r.slice().map(function(i){i(e,t)})}}}const Ae={"RC:Chatroom:Welcome":"Welcome","RC:TxtMsg":"Text","RC:Chatroom:Barrage":"Barrage","RC:Chatroom:Like":"Like","RC:Chatroom:SeatsCtrl":"SeatsCtrl","RC:Chatroom:ChatBan":"ChatBan","RC:Chatroom:SeatApply":"SeatApply","RC:Chatroom:SeatResponse":"SeatResponse","RM:RTC:TrackUnpublish":"TrackUnpublish","RM:RTC:SwitchRole":"SwitchRole","RM:RTC:UserLeave":"UserLeave","RC:Chatroom:Leave":"Leave"};var Me=Zl();const W=Ha({roomUid:"LIVE-2112263-12345",imConnectStatus:"connecting",screenShareStatus:!1,videoRef:$a(null),rtcClient:null,joinedRoom:null,mediaStreamTrack:[],mediaStreams:null,videoStatus:"init",microphones:[],cameras:[],selectedCamera:null,selectedMicrophone:null,likeCount:0,lastLikeCount:0,activeTracks:{},allowSeatsCtrl:!0,allowChatCtrl:!0,deviceStatus:{microphone:"init",camera:"init",screen:"init"}});var ae=W;const eh="c9kqb3rdc451j";al({appkey:eh});const th=si("RC:Chatroom:SeatsCtrl",!0,!0),nh=si("RC:Chatroom:ChatBan",!0,!0),rh=si("RC:Chatroom:SeatApply",!0,!0),ih=si("RC:Chatroom:SeatResponse",!0,!0),Wn=be,Co=Wn,{MESSAGES:_p}=Co,sh=Eo(Co,["MESSAGES"]);Yn(Wn.MESSAGES,n=>{console.log(n,"\u6536\u5230\u6D88\u606F");const{messages:e}=n;for(const t of e)Ae[t.messageType]&&Me.emit(Ae[t.messageType],ln(Et({},t.content),{$EventMessage:t}))});for(const n of Object.values(sh))Yn(n,e=>{console.log(n,e),Me.emit(n,{$EventMessage:null})});Yn(Wn.CONNECTING,()=>{console.log("connecting"),W.imConnectStatus="connecting"});Yn(Wn.CONNECTED,()=>{console.log("connected"),W.imConnectStatus="connected"});Yn(Wn.DISCONNECT,()=>{console.log("disconnect"),W.imConnectStatus="disconnect"});const oh=async n=>{var e;try{const t=await ul(n);return W.rtcClient=cl(Ql,{}),console.log("connect success",(e=t.data)==null?void 0:e.userId),t}catch(t){throw t}},ah=n=>{W.videoRef&&(W.videoRef.volume=n/100)},ch=async()=>{var n;if(W.rtcClient){const e=await rn("screen"),t=W.activeTracks.camera;(n=W.joinedRoom)==null||n.unpublish([t]),sn([e],"screen"),W.videoRef&&e.play(W.videoRef),e==null||e.on(pe.EVENT_LOCAL_TRACK_END,r=>{W.screenShareStatus=!1,r.destroy(),sn([t],"camera"),W.videoRef&&t.play(W.videoRef)})}},uh=async()=>{const n=await lo.getMicrophones();return W.microphones=n,n},dh=async()=>{const n=await lo.getCameras();return W.cameras=n,n},vu=n=>{W.selectedCamera=n},Ru=n=>{W.selectedMicrophone=n},rn=async n=>{var r,i,s,o,u;let e,t=null;return n==="microphone"?e=await((i=W.rtcClient)==null?void 0:i.createMicrophoneAudioTrack("RongCloudRTC",{micphoneId:(r=W.selectedMicrophone)==null?void 0:r.deviceId})):n==="camera"?e=await((o=W.rtcClient)==null?void 0:o.createCameraVideoTrack("RongCloudRTC",{cameraId:(s=W.selectedCamera)==null?void 0:s.deviceId,faceMode:"user",frameRate:ft.FPS_15,resolution:Ce.W1280_H720})):e=await((u=W==null?void 0:W.rtcClient)==null?void 0:u.createScreenVideoTrack()),t=e==null?void 0:e.track,e.code===I.PERMISSION_DENIED?W.deviceStatus[n]="denied":W.deviceStatus[n]="granted",t},sn=async(n,e,t=!0)=>{var r;for(const i of n)W.activeTracks[e]=i;t&&await((r=W.joinedRoom)==null?void 0:r.publish(n))},Eu=async(n,e,t=!0)=>{var r;for(const i of n)i.destroy(),W.activeTracks[e]=null;t&&await((r=W.joinedRoom)==null?void 0:r.unpublish(n))},lh=async(n,e,t)=>{var i,s;await dl(n,{count:-1});const r=await((i=W.rtcClient)==null?void 0:i.joinLivingRoom(n,e));if((r==null?void 0:r.code)!=I.SUCCESS)throw Error("\u52A0\u5165\u623F\u95F4\u5931\u8D25");return(s=r.room)==null||s.registerRoomEventListener(t),r},hh=async()=>{var e,t;if(W.videoStatus!=="stream")throw Error("\u5F53\u524D\u65E0\u89C6\u9891\u6D41");if(W.joinedRoom){const r=await rn("microphone");console.log(r);const i=await rn("camera");await sn([i],"camera"),W.videoStatus="liveing",await sn([r],"microphone");const s=await((e=W.joinedRoom)==null?void 0:e.getMCUConfigBuilder());await((t=s.setOutputVideoRenderMode)==null?void 0:t.call(s,Hn.WHOLE)),await s.flush()}},ph=async()=>{var n;await $n.post("/api-im/user/statusImUser",{data:{os:"PC",status:2,userId:(n=ge.user)==null?void 0:n.id}}),W.videoStatus="stopped";for(const e in W.activeTracks)if(Object.prototype.hasOwnProperty.call(W.activeTracks,e)){const t=W.activeTracks[e];t&&Eu([t],e)}},Cu=async()=>{if(W.likeCount!==W.lastLikeCount||W.likeCount===0)try{await $n.get("/api-web/imLiveBroadcastRoom/syncLike",{hideLoading:!0,hideMessage:!0,params:{likeNum:W.likeCount,roomUid:W.roomUid}}),W.lastLikeCount=W.likeCount}catch{}setTimeout(()=>{Cu()},1e3*60)},Kr=()=>{var n,e,t,r;return{id:(n=ge.user)==null?void 0:n.speakerId,name:(e=ge.user)==null?void 0:e.speakerName,userId:(t=ge.user)==null?void 0:t.speakerId,userName:(r=ge.user)==null?void 0:r.speakerName}},Vt=async(n,e="text")=>{var i;let t=null;if(!n)return;const r={conversationType:z.CHATROOM,targetId:(i=W.joinedRoom)==null?void 0:i._roomId};if(e==="text"?t=new fl({user:Kr(),content:n}):e==="SeatsCtrl"?t=new th(n):e==="ChatBan"?t=new nh(n):e==="SeatApply"?t=new rh(n):e==="SeatResponse"&&(t=new ih(n)),!!t)return console.log(t),await Oc(r,t)},yu=async(n,e=!0)=>{var t;if(n==="microphone"&&W.activeTracks[n])(t=W.activeTracks[n])==null||t.unmute();else{const r=await rn(n);await sn([r],n,e),W.videoRef&&r.play(W.videoRef)}},qr=async(n,e=!0)=>{const t=W.activeTracks[n];n!=="microphone"?(await Eu([t],n,e),t==null||t.destroy()):t==null||t.mute()},fh=async n=>{const e=W.activeTracks[n],t=W.videoStatus==="liveing";e?qr(n,t):yu(n,t)};var gh=Je({methods:{async loginOut(){try{await $n.post("/api-auth/exit",{data:{}}),qr("camera"),qr("microphone"),wu.success("\u9000\u51FA\u6210\u529F"),Nu(),this.$router.push({path:"/login",query:Et({},this.$route.query)})}catch{}}},render(){var n,e,t;return L("div",{class:At.liveHeader},[L("div",{class:At.liveHeaderLeft},[L("div",{class:At.liveHeaderLeftIcon},[L("img",{class:At.liveLogo,src:(n=ge.user)==null?void 0:n.tenantLogo,alt:""},null),(e=ge.user)==null?void 0:e.tenantName]),L("div",{class:At.liveHeaderLeftText},[se("\u300A"),(t=ge.user)==null?void 0:t.roomTitle,se("\u300B")])]),L(gr,{trigger:"hover"},{default:()=>{var r;return[L("div",{class:At.avatarWrapper},[L("img",{class:At.userAvatar,src:"/src/assets/home/placehorder-icon.png"},null),L("span",null,[(r=ge.user)==null?void 0:r.speakerName])])]},dropdown:()=>L(Ai,null,{default:()=>[L(Mi,{command:"1",onClick:this.loginOut},{default:()=>[L("span",null,[se("\u5B89\u5168\u9000\u51FA")])]})]})})])}});const mh="_header_22t18_1",_h="_title_22t18_9";var La={header:mh,title:_h},vh=Je({name:"LiveBroadcastHeader",methods:{async startLive(){try{await yo.confirm("\u662F\u5426\u786E\u8BA4\u5F00\u59CB\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await hh()}catch{}},async closeLive(){var n;try{await yo.confirm("\u662F\u5426\u786E\u8BA4\u7ED3\u675F\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await $n.post("/api-im/user/statusImUser",{data:{os:"IOS",status:"2",userid:(n=ge.user)==null?void 0:n.id}}),await ph()}catch{}}},render(){var n;return L("div",{class:La.header},[L("h3",{class:La.title},[se("\u76F4\u64AD\u5185\u5BB9\uFF1A"),(n=ge.user)==null?void 0:n.liveRemark]),ae.videoStatus==="liveing"?L(_t,{type:"danger",color:"#EA4132",onClick:this.closeLive},{default:()=>[se("\u5173\u95ED\u76F4\u64AD")]}):L(_t,{type:"primary",color:"#01A79E",onClick:this.startLive},{default:()=>[se("\u5F00\u59CB\u76F4\u64AD")]})])}});const Rh="_volumeSlider_4c7vc_68",Eh="_volumeIcon_4c7vc_77",Ch="_btnInner_4c7vc_82";var ye={"action-bar":"_action-bar_4c7vc_1","bar-btn":"_bar-btn_4c7vc_12","bar-btn-text":"_bar-btn-text_4c7vc_19",volumeSlider:Rh,volumeIcon:Eh,btnInner:Ch},yh={},Th=Je({name:"LiveBroadcastShare",data(){return{form:{shareType:1},detail:{roomTitle:"",liveStartTime:"",liveRemark:""}}},methods:{copyText(){},shareImage(){}},render(){return L("div",{class:yh.header},[L(Au,{model:this.form,ref:"form",class:"form"},{default:()=>[L(Mu,{label:"\u5206\u4EAB\u65B9\u5F0F"},{default:()=>[L(ui,{modelValue:this.form.shareType,label:"1"},{default:()=>[se("\u94FE\u63A5\u5206\u4EAB")]}),L(ui,{modelValue:this.form.shareType,label:"2"},{default:()=>[se("\u4E8C\u7EF4\u7801\u5206\u4EAB")]}),L(ui,{modelValue:this.form.shareType,label:"3"},{default:()=>[se("\u7FA4\u804A\u5206\u4EAB")]})]})]}),L("div",null,[pt(L("div",{class:"linkWrap"},[L("div",{class:"shareWrap"},[L("h2",null,[se("\u4E50\u56E2\u8001\u5E08\u9080\u8BF7\u60A8\u53C2\u4E0E\u76F4\u64AD\u8BFE\uFF01")]),L("h4",null,[this.detail.roomTitle,se("111")]),L("p",null,[se("\u76F4\u64AD\u65F6\u95F4:"),this.detail.liveStartTime]),L("p",null,[se("\u76F4\u64AD\u5185\u5BB9:"),this.detail.liveRemark]),L("p",null,[se("\u76F4\u64AD\u5730\u5740:")])]),L("div",{class:"shareBtn",onClick:this.copyText},[se("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]),[[Yt("if"),"this.form.shareType == 1"]])]),pt(L("div",{class:"codeWrap"},[L("div",{class:"shareWrap"},[L(Ne("preview"),{form:this.detail,id:"preview"},null)]),L("div",{class:"shareBtn",onClick:this.shareImage},[se("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]),[[Yt("if"),"this.form.shareType == 2"]]),pt(L("div",{class:"groupWrap"},[L(Ne("groupChat"),null,null)]),[[Yt("if"),"this.form.shareType == 3"]])])}});function ka(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!Pu(n)}var Sh=Je({name:"LiveBroadcast-ActionBar",data(){return{volume:30,barStatus:{camera:!1,volume:!1,microphone:!1,screen:!1,share:!1},shareVisiable:!1}},computed:{isCameraDisabled(){return this.barStatus.camera&&ae.deviceStatus.camera!=="denied"},isMicrophoneDisabled(){return this.barStatus.microphone&&ae.deviceStatus.microphone!=="denied"},isVolumeDisabled(){return this.barStatus.volume&&this.volume===0}},methods:{startShare(){console.log("\u8C03\u7528"),this.shareVisiable=!0},volumeChange(n){this.volume=n,ah(n)}},render(){return L("div",{class:ye["action-bar"],id:"action-bar"},[L("div",{style:{display:"flex"}},[L("div",{class:ye["bar-btn"]},[L("div",{class:ye.btnInner},[L(Ne("SvgIcon"),{onClick:()=>{this.barStatus.camera=!this.barStatus.camera,fh("camera")},name:this.isCameraDisabled?"bar-camera-disabled":"bar-camera",style:{width:"22px",cursor:"pointer"}},null),L(gr,{placement:"top",onCommand:vu},{default:()=>[L("div",{class:ye["bar-btn"],style:{height:"32px"}},[L(Ne("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let n;return L(Ai,null,ka(n=ae.cameras.map(e=>L(Mi,{command:e},{default:()=>[e.label]})))?n:{default:()=>[n]})}})]),L("span",{class:ye["bar-btn-text"]},[se("\u6444\u50CF\u5934")])]),L("div",{class:ye["bar-btn"]},[L("div",{class:ye.btnInner},[L(Ne("SvgIcon"),{onClick:()=>{this.barStatus.volume=!this.barStatus.volume,this.volume=0},name:this.isVolumeDisabled?"bar-volume-disabled":"bar-volume",style:{width:"22px",cursor:"pointer"}},null),L(gr,{placement:"top-start","popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1}},{default:()=>[L("div",{class:ye["bar-btn"],style:{height:"32px"}},[L(Ne("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>L("div",{class:ye.volumeSlider},[L(Ne("SvgIcon"),{class:ye.volumeIcon,name:"message-voice",color:"#fff"},null),L(Lu,{modelValue:this.volume,onInput:this.volumeChange,size:"small"},null)])})]),L("span",{class:ye["bar-btn-text"]},[se("\u97F3\u91CF\u8C03\u8282")])]),L("div",{class:ye["bar-btn"],onClick:ch},[L("div",{class:ye.btnInner},[L(Ne("SvgIcon"),{name:"bar-screen-share",style:{width:"22px",cursor:"pointer"}},null)]),L("span",{class:ye["bar-btn-text"]},[se("\u5C4F\u5E55\u5171\u4EAB")])]),L("div",{class:ye["bar-btn"]},[L("div",{class:ye.btnInner},[L(Ne("SvgIcon"),{onClick:()=>{const n=ae.videoStatus==="liveing";this.barStatus.microphone=!this.barStatus.microphone,this.barStatus.microphone?qr("microphone",n):yu("microphone",n)},name:this.isMicrophoneDisabled?"bar-mike-disabled":"bar-mike",style:{width:"22px",cursor:"pointer"}},null),L(gr,{placement:"top-start","popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1},onCommand:Ru},{default:()=>[L("div",{class:ye["bar-btn"],style:{height:"32px"}},[L(Ne("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let n;return L(Ai,null,ka(n=ae.microphones.map(e=>L(Mi,{command:e},{default:()=>[e.label]})))?n:{default:()=>[n]})}})]),L("span",{class:ye["bar-btn-text"]},[se("\u9EA6\u514B\u98CE")])])]),L("div",{style:{display:"flex"},onClick:this.startShare},[L("div",{class:ye["bar-btn"]},[L("div",{class:ye.btnInner},[L(Ne("SvgIcon"),{name:"bar-share",style:{width:"22px",cursor:"pointer"}},null)]),L("span",{class:ye["bar-btn-text"]},[se("\u5206\u4EAB")])])]),L(ku,{width:"510px","append-to-body":!0,modelValue:this.shareVisiable,title:"\u5206\u4EAB","before-close":()=>{this.shareVisiable=!1}},{default:()=>[L(Th,null,null)]})])}});const Ih="_container_19awp_1",bh="_title_19awp_21",Oh="_tips_19awp_25";var lt={container:Ih,title:bh,tips:Oh},Nh=Je({name:"VideoStatus",render(){return L("div",{class:lt.container},[ae.deviceStatus.camera==="denied"?L("div",{class:lt.denied},[L(Ne("SvgIcon"),{name:"camera-status",class:lt.icon},null),L("p",{class:lt.title},[se("\u6444\u50CF\u5934\u88AB\u7981\u7528")]),L("p",{class:lt.tips},[se("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null,ae.deviceStatus.camera==="init"?L("div",{class:lt.init},[L(Ne("SvgIcon"),{name:"camera-status",class:lt.icon},null),L("p",{class:lt.title},[se("\u8BF7\u5B8C\u6210\u6444\u50CF\u5934\u6388\u6743")]),L("p",{class:lt.tips},[se("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null])}});const wh=async(n,e)=>{if(!navigator)throw new Error("\u6D4F\u89C8\u5668\u7248\u672C\u8FC7\u4F4E");return n?(e||[]).map(t=>n.removeTrack(t)):[]},Ah="_main_1b4ip_1",Mh="_video_1b4ip_12";var Ua={main:Ah,video:Mh};const Da=$a(null);let xa,Ni;var Ph=Je({name:"LiveBroadcast",async mounted(){this.initializeRoom(),Cu(),Me.on(Ae["RC:Chatroom:Like"],this.onLikeMessage)},beforeUnmount(){Me.off(Ae["RC:Chatroom:Like"],this.onLikeMessage)},methods:{onLikeMessage(n){ae.likeCount+=n.counts},async initializeRoom(){var n,e;if(!ge.user)throw Error("\u8BF7\u5148\u767B\u5F55");try{await oh((n=ge.user)==null?void 0:n.imToken),ae.videoRef=Da.value,await uh(),await dh(),vu(ae.cameras[0]),Ru(ae.microphones[0]),Ni=await rn("camera"),ae.videoRef&&Ni.play(ae.videoRef),await sn([Ni],"camera"),xa=await rn("microphone"),ae.videoRef&&xa.play(ae.videoRef),console.log(ae.deviceStatus),ae.videoStatus="stream";const t=await lh((e=ge.user)==null?void 0:e.roomUid,ct.VIDEO,{onMessageReceive(r,i){console.log(r,i)},onKickOff(r){console.log(r)},async onTrackPublish(r){var s;const i=await((s=t==null?void 0:t.room)==null?void 0:s.subscribe(r));console.log(i),(i==null?void 0:i.code)&&i.code!==I.SUCCESS&&console.log("\u8D44\u6E90\u8BA2\u9605\u5931\u8D25 ->",i.code)},onTrackUnpublish(r){console.log(r),Me.emit(Ae["RM:RTC:TrackUnpublish"],r)},onSwitchRole(r,i){Me.emit(Ae["RM:RTC:SwitchRole"],{userId:r,role:i})},onTrackReady(r){r.isAudioTrack()&&r.play()},onUserJoin(r){console.log("onUserJoin",r)},onUserLeave(r){Me.emit(Ae["RM:RTC:UserLeave"],r),console.log("onUserLeave",r)}});t.room&&t.code===I.SUCCESS&&(ae.joinedRoom=t.room)}catch(t){ae.videoStatus="error",console.log(t)}},closeLive(){wh(ae.mediaStreams,ae.mediaStreamTrack),ae.videoStatus="stopped"}},render(){return L("div",{class:Ua.main},[L(vh,null,null),L("div",{class:Ua.video},[L("video",{ref:Da},null),L(Nh,null,null)]),L(Sh,null,null)])}});const Lh="_container_jmhhf_1",kh="_dataCount_jmhhf_6",Uh="_num_jmhhf_17",Dh="_text_jmhhf_22",xh="_dataIcon_jmhhf_26",Vh="_tabContainer_jmhhf_31",Bh="_tabIcon_jmhhf_31",Fh="_tabContent_jmhhf_58",Hh="_tabList_jmhhf_64";var qe={container:Lh,dataCount:kh,num:Uh,text:Dh,dataIcon:xh,tabContainer:Vh,tabIcon:Bh,tabContent:Fh,tabList:Hh};const $h="_message_4zab7_1",jh="_buttonGroup_4zab7_1";var Va={message:$h,buttonGroup:jh},Kh=Je({name:"message",data(){return{options:"ALL"}},methods:{async SeatsCtrl(){await Vt(Et({seatBan:ae.allowSeatsCtrl},Kr()),"SeatsCtrl"),ae.allowSeatsCtrl=!ae.allowSeatsCtrl},async ChatBan(){await Vt(Et({chatBan:ae.allowChatCtrl},Kr()),"ChatBan"),ae.allowChatCtrl=!ae.allowChatCtrl}},render(){return L("div",{class:Va.message},[L("div",{class:Va.buttonGroup},[L(_t,{type:ae.allowChatCtrl?"info":"primary",onClick:this.ChatBan},{default:()=>[ae.allowChatCtrl?"\u5168\u4F53\u7981\u8A00":"\u5173\u95ED\u5168\u4F53\u7981\u8A00"]}),L(_t,{type:ae.allowSeatsCtrl?"info":"primary",onClick:this.SeatsCtrl},{default:()=>[ae.allowSeatsCtrl?"\u7981\u6B62\u8FDE\u9EA6":"\u5173\u95ED\u7981\u6B62\u8FDE\u9EA6"]})])])}});const qh="_sendMessage_p2cnx_1",Gh="_form_p2cnx_10";var Ba={sendMessage:qh,form:Gh};const zn=Ha({messageList:[],joinList:{},lookList:[]});var Le=zn;const ls=n=>{zn.messageList.push(n)},wn=(n,e)=>{zn.joinList[n]=e},An=n=>{delete zn.joinList[n]},Yh=n=>{zn.lookList.push(n)};var Jh=Je({data(){return{message:""}},methods:{async sendMessage(){try{await Vt(this.message);const n=Kr();ls({id:n.id,name:n.name,content:this.message,isSelf:!0,sendTime:yr(new Date).format("HH:mm:ss")}),this.message=""}catch{}}},render(){return L("div",{class:Ba.sendMessage},[L("div",{class:Ba.form},[L(Uu,{modelValue:this.message,onInput:n=>this.message=n,placeholder:"\u8BF7\u8F93\u5165\u6D88\u606F"},null),L(_t,{disabled:!this.message,onClick:this.sendMessage,round:!0,type:"primary"},{default:()=>[se("\u53D1\u9001")]})])])}});const Wh="_itemContent_7upzu_1",zh="_itemInfo_7upzu_11",Qh="_itemName_7upzu_14",Xh="_userName_7upzu_21",Zh="_rightTime_7upzu_35",ep="_itemText_7upzu_42",tp="_active_7upzu_46",np="_joinText_7upzu_49",rp="_join_7upzu_49",ip="_btn_7upzu_58",sp="_downBtn_7upzu_70",op="_loadingStyle_7upzu_75";var le={itemContent:Wh,itemInfo:zh,itemName:Qh,userName:Xh,"name-style":"_name-style_7upzu_28",rightTime:Zh,itemText:ep,active:tp,joinText:np,join:rp,btn:ip,downBtn:sp,loadingStyle:op};const ap="_icon_1svqd_9";var wi={"empty-container":"_empty-container_1svqd_1",icon:ap},mo=Je({props:{text:{type:String,default:"\u6682\u65E0\u6570\u636E"},icon:{type:String,default:"noData-no-message"}},render(){return L("div",{class:wi["empty-container"]},[L(Ne("SvgIcon"),{name:this.icon,class:[wi.icon]},null),L("p",{class:wi["empty-text"]},[this.text])])}}),cp=Je({data(){return{joinList:{},loadingJoin:!1}},computed:{count(){let n=0;for(const e in Le.joinList)if(Object.prototype.hasOwnProperty.call(Le.joinList,e)&&(Le.joinList[e].type===3&&(n+=1),n>3))break;return n}},mounted(){Me.on(Ae["RC:Chatroom:SeatApply"],this.onSeatApply),Me.on(Ae["RC:Chatroom:SeatResponse"],this.onSeatApply),Me.on(Ae["RM:RTC:UserLeave"],this.onSeatApply),Me.on(Ae["RM:RTC:SwitchRole"],this.onSwitchRole)},methods:{onSeatApply(n){if(Array.isArray(n)){for(const e of n)console.log("onSeatApply",e),An(e);return}n.type===3&&wn(n.audienceId,{name:n.audienceName,id:n.audienceId,type:n.type}),n.type===4&&Le.joinList[n.audienceId]&&An(n.audienceId)},agree(n){var t,r;if(this.count>3)return;const e=ln(Et({},n),{audienceName:n.name,audienceId:n.id,teacherId:(t=ge.user)==null?void 0:t.id,teacherName:(r=ge.user)==null?void 0:r.speakerName,type:1});wn(n.id,e),Vt(e,"SeatResponse")},refuse(n){var t,r;const e=ln(Et({},n),{audienceName:n.name,audienceId:n.id,teacherId:(t=ge.user)==null?void 0:t.id,teacherName:(r=ge.user)==null?void 0:r.speakerName,type:5});wn(n.id,e),Vt(e,"SeatApply")},onSwitchRole(n){Le.joinList[n.userId]&&n.role===2&&An(n.userId)}},render(){const n=Object.values(Le.joinList);return L("div",{style:{minHeight:"100%",position:"relative"}},[n.length>0?n.map(e=>L("div",{class:le.itemContent},[L("div",{class:le.itemInfo},[L("div",{class:le.itemName},[L("p",{class:le.userName},[L("span",{class:le["name-style"]},[e.name]),e.type===3?L("p",{style:{paddingLeft:"10px"}},[se("\u7533\u8BF7\u8FDE\u9EA6")]):L("p",{style:{paddingLeft:"10px",color:"var(--live-text-color)"}},[se("\u6B63\u5728\u8FDE\u9EA6")])]),e.type===3?L("div",{class:le.joinText},[L("div",{class:le.join},null),L(_t,{size:"small",type:"primary",disabled:this.count>3,class:le.btn,onClick:()=>this.agree(e)},{default:()=>[se("\u4E0A\u9EA6")]})]):L("div",{class:le.joinText},[L("div",{class:le.join},null),L(_t,{size:"small",plain:!0,class:[le.btn,le.downBtn],onClick:()=>this.refuse(e)},{default:()=>[se("\u4E0B\u9EA6")]})])])])])):this.loadingJoin?pt(L("div",{class:le.loadingStyle,"element-loading-background":"rgba(0, 0, 0, 0.8)"},null),[[Yt("loading"),this.loadingJoin]]):L(mo,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u53D1\u8D77\u8FDE\u9EA6\uFF01",icon:"noData-no-join"},null)])}}),up=Je({data(){return{lookList:[],loadingLook:!1}},mounted(){this.loadingLook=!0,Me.on(Ae["RC:Chatroom:Welcome"],this.onWelcome),Me.on(Ae["RC:Chatroom:SeatResponse"],this.onSeatResponse),Me.on(Ae["RM:RTC:UserLeave"],this.onSeatApply),setTimeout(()=>{this.loadingLook=!1})},methods:{async _init(){try{const n=sessionStorage.getItem("roomUid"),e=await $n.get("/api-web/imLiveBroadcastRoom/queryRoomUserInfo",{params:{roomUid:n}});console.log("_init",e)}catch{}},onSeatResponse(n){var e,t;if(n.type==3){Le.lookList.forEach(i=>{i.id==n.audienceId&&(i.type=1)});let r=Le.joinList[n.audienceId];console.log(Le.joinList),r?Le.joinList[n.audienceId].type=1:wn(n.audienceId,{id:n.audienceId,name:n.audienceName,audienceId:n.audienceId,audienceName:n.audienceName,teacherId:(e=ge.user)==null?void 0:e.id,teacherName:(t=ge.user)==null?void 0:t.speakerName,type:1})}},onWelcome(n){if(console.log(n),n&&n.user){const e=yr(n.$EventMessage.sentTime||new Date).format("HH:mm:ss");let t={name:n.user.name,id:n.user.id,sendTime:e},r=!1;Le.lookList.forEach(i=>{i.id===t.id&&(r=!0)}),r||Yh(t),this.loadingLook=!1}},async onUpLook(n){var e,t;try{const r={audienceName:n.name,audienceId:n.id,teacherId:(e=ge.user)==null?void 0:e.id,teacherName:(t=ge.user)==null?void 0:t.speakerName,type:1};await Vt(r,"SeatApply")}catch{}},async onDownLook(n){var e,t;try{const r=ln(Et({},n),{audienceName:n.name,audienceId:n.id,teacherId:(e=ge.user)==null?void 0:e.id,teacherName:(t=ge.user)==null?void 0:t.speakerName,type:5});wn(n.id,r),Vt(r,"SeatApply")}catch{}},onSeatApply(n){if(Array.isArray(n)){for(const e of n)An(e);return}console.log(n),n.type===4&&Le.joinList[n.audienceId]&&(An(n.audienceId),Le.lookList.forEach(e=>{e.id==n.audienceId&&(e.type=3)}))}},render(){return L("div",null,[Le.lookList.length>0?Le.lookList.map(n=>L("div",{class:le.itemContent},[L("div",{class:le.itemInfo},[L("div",{class:le.itemName},[L("p",{class:le.userName},[n.name]),n.type==1?L(_t,{size:"small",type:"primary",class:le.btn,onClick:()=>this.onUpLook(n)},{default:()=>[se("\u4E0A\u9EA6")]}):L(_t,{size:"small",plain:!0,class:[le.btn,le.downBtn],onClick:()=>this.onDownLook(n)},{default:()=>[se("\u4E0B\u9EA6")]})])])])):this.loadingLook?pt(L("div",{class:le.loadingStyle,"element-loading-background":"rgba(0, 0, 0, 0.8)"},null),[[Yt("loading"),this.loadingLook]]):L(mo,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u89C2\u770B\uFF01",icon:"noData-no-user"},null)])}}),dp=Je({props:{data:{type:Array,default:()=>[]}},data(){return{messageList:[],loadingMessage:!1}},mounted(){this.loadingMessage=!0,Me.on(Ae["RC:TxtMsg"],this.onMessage),Me.on(Ae["RC:Chatroom:Like"],this.onLike),setTimeout(()=>{this.loadingMessage=!1},2e3),this.scrollToBottom()},beforeUnmount(){Me.off(Ae["RC:TxtMsg"],this.onMessage),Me.off(Ae["RC:Chatroom:Like"],this.onLike)},methods:{onLike(n){var e;if(n&&n.user){const t=yr(n.$EventMessage.sentTime||new Date).format("HH:mm:ss");console.log(n,"like");let r={name:(e=n.user)==null?void 0:e.name,id:n.user.id,isSelf:!1,content:"\u7ED9\u60A8\u70B9\u4E86"+n.counts+"\u4E2A\u8D5E",sendTime:t};ls(r),this.loadingMessage=!1}this.scrollToBottom()},onMessage(n){var e;if(n&&n.user){const t=yr(n.$EventMessage.sentTime||new Date).format("HH:mm:ss");let r={name:(e=n.user)==null?void 0:e.name,id:n.user.id,isSelf:!1,content:n.content,sendTime:t};n.user.id===ge.user.speakerId&&(r.isSelf=!0),ls(r),this.loadingMessage=!1}this.scrollToBottom()},scrollToBottom(){this.$nextTick(()=>{var n,e;(e=document.querySelector("#tabList"))==null||e.scrollTo(0,((n=document.querySelector("#messageList"))==null?void 0:n.scrollHeight)||0)})}},render(){return L("div",{style:{minHeight:"100%",position:"relative"},id:"messageList"},[Le.messageList.length>0?Le.messageList.map(n=>L("div",{class:le.itemContent},[L("div",{class:le.itemInfo},[L("div",{class:le.itemName},[L("p",{class:le.userName},[L("span",{class:le["name-style"]},[n.name]),n.isSelf?L(Du,{effect:"dark",color:"#01A79E"},{default:()=>[se("\u4E3B\u8BB2\u4EBA")]}):null]),L("p",{class:le.rightTime},[n.sendTime])]),L("div",{class:[le.itemText,n.isSelf?le.active:null]},[n.content])])])):this.loadingMessage?pt(L("div",{class:le.loadingStyle,"element-loading-background":"rgba(0, 0, 0, 0.8)"},null),[[Yt("loading"),this.loadingMessage]]):L(mo,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u4E92\u52A8\uFF01",icon:"noData-no-message"},null)])}}),lp=Je({name:"LiveMessage",data(){return{modelIndex:"message"}},mounted(){var n;ae.likeCount=((n=ge.user)==null?void 0:n.likeNum)||0},methods:{tabChange(n){this.modelIndex=n.props.name}},render(){var n;return L("div",{class:qe.container},[L("div",{class:qe.dataCount},[L("div",null,[L("p",{class:qe.num},[(n=ge.user)==null?void 0:n.likeNum]),L("p",{class:qe.text},[L(Ne("SvgIcon"),{name:"message-look",color:"#fff",class:qe.dataIcon},null),se("\u5F53\u524D\u89C2\u770B")])]),L("div",null,[L("p",{class:qe.num},[ae.likeCount]),L("p",{class:qe.text},[L(Ne("SvgIcon"),{name:"message-giveUp",color:"#fff",class:qe.dataIcon},null),se("\u7D2F\u8BA1\u70B9\u8D5E")])])]),L(xu,{modelValue:this.modelIndex,"onTab-click":this.tabChange,class:qe.tabContainer},{default:()=>[L(di,{name:"message"},{label:()=>L("span",{style:{display:"flex",alignItems:"center"}},[L(Ne("SvgIcon"),{name:"message-message",color:this.modelIndex==="message"?"#00FFF0":"#fff",class:qe.tabIcon},null),se("\u804A\u5929")])}),L(di,{name:"join"},{label:()=>L("span",{style:{display:"flex",alignItems:"center"}},[L(Ne("SvgIcon"),{name:"message-evenEtc",color:this.modelIndex==="join"?"#00FFF0":"#fff",class:qe.tabIcon},null),se("\u8FDE\u9EA6")])}),L(di,{name:"look"},{label:()=>L("span",{style:{display:"flex",alignItems:"center"}},[L(Ne("SvgIcon"),{name:"message-look",color:this.modelIndex==="look"?"#00FFF0":"#fff",class:qe.tabIcon},null),se("\u89C2\u770B")])})]}),L("div",{class:qe.tabContent},[L(Kh,null,null),L("div",{class:qe.tabList,id:"tabList"},[pt(L(dp,null,null),[[li,this.modelIndex==="message"]]),pt(L(cp,null,null),[[li,this.modelIndex==="join"]]),pt(L(up,null,null),[[li,this.modelIndex==="look"]])]),L(Jh,null,null)])])}});const hp="_container_13n1h_1",pp="_home_13n1h_4";var Fa={container:hp,home:pp},vp=Je({render(){return L("div",{class:Fa.home},[L(gh,null,null),L("div",{class:Fa.container},[L(Ph,null,null),L(lp,null,null)])])}});export{vp as default};
|